Posts

ngx translate Angular 5

Image
Clash Royale CLAN TAG #URR8PPP ngx translate Angular 5 When I change the language in settings.ts (page) and check currentLanguage in the same page, it changes the language correctly and show it. But when I do the same thing in app.component.ts, CurrentLanguage does not change even if i change it 10 times. Here is the code. Button for language change is in settings.html settings.ts import TranslateService from '@ngx-translate/core'; constructor(private translate: TranslateService) //code... changeLang(lang) this.translate.use("en"); console.log("Switched to ", this.translate.currentLang); this.translate.use("ru"); console.log("Switched to ", this.translate.currentLang); app.component.ts import TranslateService from '@ngx-translate/core'; constructor(private translate: TranslateService) //code... this.translate.use("ru"); console.log("it is ", this.translate.currentLang); this.translate.use("en...

VC++ macro definition ## operator

Image
Clash Royale CLAN TAG #URR8PPP VC++ macro definition ## operator I am trying to port our solution from VS2010 to VS2017 and have hit this compilation error with the macro definition involving token pasting operator. Here is the code below #include “stdafx.h” #define TEST_MACRO(str) _T(“Error”) ## str ## _T(“””); int main() TEST_MACRO(“ check “); return 0; This compiles fine in VS2010 but fails in VS2017/VS2015. It doesn’t seem to recognize _T(“””) following str ##. I am using “multi byte character set” and hence _T(x) resolves to x ( in tchar.h ). Can someone help me understand this issue? for what you use _T at all ? – RbMm Aug 10 at 11:38 _T Is it because you are using the “ char - replace with " Also you might need to #include <tchar.h> for the _T – Angus Comber Aug 10 at 11:42 what is sense of this macro at all ? what you try get ? ...

C# SQL insert query syntax error with MS Access

Image
Clash Royale CLAN TAG #URR8PPP C# SQL insert query syntax error with MS Access I am trying to perform an insert query in C# but it keeps telling me syntax error in insert into statement. Here is my query: Checks.SQL.Insert(mydb, "SELECT * FROM Employee", "INSERT INTO Employee(First_Name,Last_Name,Email,CellPhone_Number,TypeOfUser,Username,Password) VALUES('" + txtFirstName.Text + "','" + txtLastName.Text + "','" + txtEmail.Text + " ', '" + txtCellphone.Text + "'," + typeId + ",'"+Encrypcion.encrypt(txtUsername.Text)+"','"+Encrypcion.encrypt(txtPassword.Text)+"' )"); Here is my checks insert function public static void Insert(OleDbConnection mydb, string SelectQuery, string InsertQuery) mydb.Open(); OleDbDataAdapter query2 = new OleDbDataAdapter(SelectQuery, mydb); OleDbCommand cmd = new OleDbCommand(InsertQuery, mydb); query2.InsertCommand ...

Jquery Insert element in an other on event

Image
Clash Royale CLAN TAG #URR8PPP Jquery Insert element in an other on event First post here and quite new on javascript/jquery/webstuff but even after some research about the thing I'm trying to do, I didn't manage to find something that made this thing work. So, here is the context : I'm creating a schedule with HTML and Javascript/Jquery. I want to be able to inject an automated generated <span> or something directly by clicking on the day (which is a <td> ). <span> <td> At first I used basic stuff like "getElementById()" but if I manage to do the thing with this, I'm going on a lot of repetitive code. And I'm quite sure I can avoid this. So basically I wanted to do generic code and be able to get the which the user clicked. Here is what I managed to do by now: HTML part : <table> <tr> <th class="day-name">Sun</th> <th class="day-name">Mon</th> <th class="da...

XML Serialization error - Invalid or missing value of the choice identifier 'ItemsElementName' of type 'ItemsChoiceType[]'

Image
Clash Royale CLAN TAG #URR8PPP XML Serialization error - Invalid or missing value of the choice identifier 'ItemsElementName' of type 'ItemsChoiceType' I am trying to serialize an object to be passed to a web service and getting the error above. I can see when debugging that the value is present in the object itself but it doesn't seem to be picking this up: string tradeAreas = new string "Area1", "Area2", "Area3", "Area4"; //RetrieveMarketResultsFor ItemsChoiceType choices = new ItemsChoiceType ItemsChoiceType.area ; MarketResultIdentifier mri = new MarketResultIdentifier ItemsElementName = choices, Items = tradeAreas, ItemElementName = ItemChoiceType6.applyingDate, Item = DateTime.Today.AddDays(-1) ; var ser = new XmlSerializer(typeof(MarketResultIdentifier)); using (var stream = new FileStream("mri.xml", FileMode.Create)) ser.Serialize(stream, mri); The web service generated code has the following classes ...

How to scale SVG when svg reference another

Image
Clash Royale CLAN TAG #URR8PPP How to scale SVG when svg reference another I use inline svg in my project and I want change width and height to use like small icon but use tag dont resize. .row display: flex; justify-content: space-between; align-items: center; border: solid 1px; svg.icon border: solid 1px tomato; /**debug*/ overflow: visible; .icon use border: solid 1px green; <svg style="display: none;" viewBox="0 0 24 24" width="24" height="24"> <defs> <g id="ico-and"> <path d="M152.682,458.363c0,15.3,10.2,25.5,25.5,25.5h25.5v89.25c0,20.4,17.85,38.25,38.25,38.25s38.25-17.85,38.25-38.25v-89.25 h51v89.25c0,20.4,17.85,38.25,38.25,38.25s38.25-17.85,38.25-38.25v-89.25h25.5c15.3,0,25.5-10.2,25.5-25.5v-255h-306V458.363z M88.932,203.363c-20.4,0-38.25,17.851-38.25,38.25v178.5c0,20.4,17.85,38.25,38.25,38.25s38.25-17.85,38.25-38.25v-178.5 C127.182,221.213,109.332,203.363,88.932,203.363z M522.432,203.363c...

Name resolution failing during docker build

Image
Clash Royale CLAN TAG #URR8PPP Name resolution failing during docker build I am experiencing an issue where I receive the following error when issuing the docker build command:- curl: (6) Could not resolve host: dl.yarnpkg.com gpg: no valid OpenPGP data found. Here is my Dockerbuild file # Base image FROM ruby:2.5.0 RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - RUN curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.lisT RUN apt-get update RUN apt-get install -qq -y build-essential libpq-dev nodejs yarn The commands complete successfully when run outside of docker. In order to resolve the issues I have tried the following I have tried DNS servers from Google and OpenDNS, as well as multiple ISPs depending on the location im running the command from Laptop is running Ubuntu 16:04 with Docker version 18.06.0-ce, build 0ffa825 installed. Using the fol...

Delete Rows and Columns until specific range

Image
Clash Royale CLAN TAG #URR8PPP Delete Rows and Columns until specific range I have an Excel workbook in which I search for a date in the heading using .Find . .Find For example if it is found in RANGE("C3") then it should remove rows above and columns before it. RANGE("C3") Please help me write the VBA code to perform this operation. Dim WSD As Worksheet Set WSD = Worksheets("report") Dim MyRange As Range Set MyRange = WSD.Range("A:AZ") Set R = MyRange.Find("Date", LookIn:=xlValues) Debug.Print R.Address So for all intents and purposes you are shifting Date to A1 ...? – Jeeped Aug 10 at 12:03 yes. i want my header to start from 1 row and 1 column – Prayag Aug 10 at 12:06 my macro which contains many modules is based on A1. rest all other are completed only for one sheet my progress is halted. – Prayag Aug 10 at 12:10 2 Answers 2 Try, dim MyRange as range with Worksheets("report") Set MyRange ...

SelectionChanged Event does not fire after reselecting Datagrid row?

Image
Clash Royale CLAN TAG #URR8PPP SelectionChanged Event does not fire after reselecting Datagrid row? A simple Datagrid which groups row by one of the property: Datagrid <DataGrid x:Name="MyDataGrid" SelectionChanged="MyDataGrid_SelectionChanged" ItemsSource="Binding Programs" Style="StaticResource dataGridStyle"> <DataGrid.GroupStyle> <GroupStyle ContainerStyle="StaticResource GroupHeaderStyle"> <GroupStyle.HeaderTemplate> <DataTemplate> <StackPanel> <TextBlock Text="Binding Path=Heading" /> </StackPanel> </DataTemplate> </GroupStyle.HeaderTemplate> </GroupStyle> </DataGrid.GroupStyle> </DataGrid> Style if matters: Style <Style x:Key="GroupHeaderStyle" TargetType="x:Type GroupItem"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="x:Type GroupItem...

How to get time in format HH:mm:ss from timestamp 20180805231400 -0300 [duplicate]

Image
Clash Royale CLAN TAG #URR8PPP How to get time in format HH:mm:ss from timestamp 20180805231400 -0300 [duplicate] This question already has an answer here: Below is my code but it throws an exception saying that unable to parse date format. try DateFormat outputFormat = new SimpleDateFormat("yyyyMMddHHmmss zzzz", Locale.getDefault()); DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss", Locale.getDefault()); String inputText = channelListArrayList.get(0).getTv().getProgramme().get(j).getStart(); Date date = inputFormat.parse(inputText); String outputText = outputFormat.format(date); catch (Exception e) e.printStackTrace(); This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. 20180805231400 -0300 is not a TimeStamp its a Format. TimeStamp usually called for epoch time . – ADM Aug 10 at 12:04 20180805231400 -0300 your inputFormat should be...

MySQL Query with the count, group by

Image
Clash Royale CLAN TAG #URR8PPP MySQL Query with the count, group by Table: statistics id | user | Message ---------------------- 1 | user1 |message1 2 | user2 |message2 3 | user1 |message3 I am able to find the count of messages sent by each user using this query. select user, count(*) from statistics group by user; How to show message column data along with the count? For example user | count | message ------------------------ user1| 2 |message1 |message3 user2| 1 |message2 what is size of message column? – Shubham Aug 10 at 11:29 message varchar(100) – lazyboy Aug 10 at 11:30 Is your sample data and expect result correct? because message3 is for user1 . – D-Shih Aug 10 at 11:37 message3 user1 What's your mysql version? – D-Shih Aug 10 at 11:42 @D-Shih mysql version is 5.6 and yes sample data is correct. This is messages sent by the user. user1 has sent 2 messages: message1 and message3. – l...

Oracle SQL Developer: Dynamic Selection of Rows Where Value in Column = MAX Value

Image
Clash Royale CLAN TAG #URR8PPP Oracle SQL Developer: Dynamic Selection of Rows Where Value in Column = MAX Value Please see example below to better understand my question: Columns in table "Names": Table and Columns Goal is to get the maximum Version per ID. Output should be: Output What are the possible ways to achieve that? E.g. using self join on the table? Thanks in advance. Please post text rather than images. Also your sample data image shows everything with ID 1, the output suggests the last two rows should have 2; and is the name always the same for all rows for an ID? You already know you need the max, which is an aggregate function, so what problems are you having trying to use that? – Alex Poole Aug 10 at 12:02 I have fixed the ID. It doesn't matter if same the ID has identical name, the version is different (also there might be more columns with differences, I have only added 3 columns for simplicity). My goal is to filter by MAX version per...

Webpack - Dynamically importing a class

Image
Clash Royale CLAN TAG #URR8PPP Webpack - Dynamically importing a class I'm trying to dynamically import a class when a router condition is met. I have no problems importing a standard (non-class) module, as this works as expected: Router.on( '/:region/map': (params) => import("Controllers/map.js" /* webpackChunkName: "map" */).then((map) => map.initialise(params.region); ); ); But trying to do the same with a class is not working as expected. Router.on( '/:region/map': (params) => import("Controllers/map.js" /* webpackChunkName: "map" */).then(Map => Map.initialise(params.region); ); ); Which fails 'e.initialise is not a function'; I also try to instantiate the class by using the new keyword: new Router.on( '/:region/map': (params) => import("Controllers/map.js" /* webpackChunkName: "map" */).then(Map => const MapClass = new Map(); MapClass.initialise(p...

Right click on PrimeFaces tree node does not trigger select event

Image
Clash Royale CLAN TAG #URR8PPP Right click on PrimeFaces tree node does not trigger select event I am using a PrimeFaces 6.2 p:tree component with a context menu which differ for each node. When I click left and then right the menu is rendered properly, but when I click right directly the menu is not updated. Any ideas how to solve it? p:tree I know that there are some posts about ajax after right click (event contextMenu ), but it does not help, because the context menu disappears. contextMenu Sample p:tree can look like: p:tree <p:tree id="docs" value="#treeContextMenuView.root" var="doc" selectionMode="single" selection="#treeContextMenuView.selectedNode" dynamic="true"> <p:ajax event="select" update="form:contextMenu" /> <p:treeNode expandedIcon="ui-icon-folder-open" collapsedIcon="ui-icon-folder-collapsed"> <h:outputText value="#doc.name" /...

How is argv a string array when it's a char array?

Image
Clash Royale CLAN TAG #URR8PPP How is argv a string array when it's a char array? Why doesn't argv[0] print the first character of the filename instead of the whole filename string? argv[0] If argv is a pointer to an array of chars, then shouldn't accessing it with [n] result with a char? If its a string (as printf(argv[n] ) suggests) then why doesn't argv[0][0] get me the first char of filename (compiles but crashes when started)? argv [n] printf(argv[n] argv[0][0] int main(int argc, char **argv) printf(argv[0][0]); while (1) return 0; Because argv is a pointer to an array of char pointers . – Weather Vane Aug 10 at 12:01 argv char A char ** can be accessed via two indexing operators like a 2D array ( argv[0][0] ), but a 2D array is an array of arrays, not an array of pointers. You can find several questions already addressing this here on SO. – John Bollinger Aug 10 at 12:06 char ** argv[0][0] @LukaKostic The compiler doesn't care. T...