Posts

Showing posts from September 22, 2018

Write CSV file column title in javascript

Image
Clash Royale CLAN TAG #URR8PPP Write CSV file column title in javascript This is my code. I am trying to output my data as CSV and I am being successful but I can't add the title of the columns. Although I saved the CSV file but the column titles are missing. Can anyone help in this? var d= new Date(); var t=d.getHours()+":"+d.getMinutes()+":"+d.getSeconds(); var data = dataAWS var result = data.map(function(val) return t+'","'+val.payload.test_data; ).join('"n"'); var csvData = '"'+ result +'"'; var fs = require('fs'); fs.writeFile("tempN.csv", csvData, 'utf8', function (err) if (err) console.log("An error occured while saving CSV."); return console.log(err); console.log("CSV file has been saved."); ); 1 Answer 1 Without knowing more I would suggest something like: data.unshift(column_headers); var result = data.map(function(val) return t+&#

How can I make form fields / messages available for given locale in Symfony 4?

Image
Clash Royale CLAN TAG #URR8PPP How can I make form fields / messages available for given locale in Symfony 4? I created a form in Symfony 4: $form = $this->createFormBuilder($item) ->add('username', TextType::class, array('attr' => array('class' => 'form-control'))) But now I get an error message for username . username These messages are not available for the given locale and cannot be found in the fallback locales. Add them to the translation catalogue to avoid Symfony outputting untranslated contents. So I installed Symfony translation via composer, I still cannot find the "catalogue" and also why do I need to add this to a catalogue if I only have one language 1 Answer 1 In the Profiler you can see which catalogue symfony is looking for. normally validation is found in the validators catalogue, which means you need to add a validators.LOCALE.yml (locale must be the locale you are using ex. en) in the translations fol

selecting data from a dropdown list in excel

Image
Clash Royale CLAN TAG #URR8PPP selecting data from a dropdown list in excel I am trying to create a callable column of data in excel, based on a dropdown list. The idea is to create a list of all column names in a header cell at the end of the columns in the excel file, using Data Validation from the Data Menu in Excel. Then, when you select the column name from the list, the entire column is populated with the column values from the name that you have referenced. It should look like this... This is easy enough to do with IF loops when there are only a handful of columns you might need to call. But when there are hundreds of columns you want to be able to reference, the IF loop method means you will have to keep writing IF loops hundreds of times to get it to work. My Question: Is there a programmable way to do this in excel (VBA or otherwise) for many columns? It is not realistic to keep writing hundreds of IF loops to make this work. 2 Answers 2 I am not entirely sure wha

Adding items on ListView (simple?)

Image
Clash Royale CLAN TAG #URR8PPP Adding items on ListView (simple?) Is there a way to add items on listview without adding a class or doing something really complicated? I searched everywhere but they seem so complicated. So help me please! 2 Answers 2 ListView is designed as AdapterView to reduce memory usage and to make it faster. You cannot add views to a ListView directly, you have to use you own Adapter. You can you use ScrollView to add a few views and scroll it like ListView does. It's not as complicated as you think. You need: Lots of tutorial on the web, one for example By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Perl script running infinitelly - how to debug what happen?

Image
Clash Royale CLAN TAG #URR8PPP Perl script running infinitelly - how to debug what happen? I am running Perl script on Linux machine via cron job. However, from time to time (around 1% of all cases), the script stucks and run infinitelly. If I list processes, I can see its PID. However, I dont want to kill it right away, I would rather know what went wrong. Is there a way, how to show what lines are being executed from the script? Something like step-by-step debugging of the script based on PID. 2 Answers 2 Try to follow these steps: - find the process pid of the shell, you may use a command like: ps -ef | grep <your_script_name> Let's set this pid in the shell variable $PID. Find all the child processes of this $PID by run the command: ps --ppid $PID You might find one or more (if for example it's stuck in a pipelined series of commands). Repeat this command couple of times. If it doesn't change this means the script is stuck in certain command. In this c

Determine whether data is json or string and perform logic basing o that

Image
Clash Royale CLAN TAG #URR8PPP Determine whether data is json or string and perform logic basing o that Basically I'm trying to determine whether server returned json or just string and then convert that json and display its every element in loop or just display that one string. I'd want to reach something like that: Send post request with some data If post bodyText contains and then parse it as json and draw <li> in html <li> else new Vue({ el: '#app', data: user: UserLogin: 'test', UserEmail: 'test', UserPassword: 'test' , responseArr: , methods: submit() this.$http.post('http://api.com/validate', this.user) .then(response => return "OK"; , error => return error.bodyText; ) .then(data => console.log(data); if (data.includes("")) console.log("if"); data = JSON.parse(data); const arr = ; for (let key in data) arr.push(data[key]); this.responseArr = arr;

How to align the last element on the right when using hfill?

Image
Clash Royale CLAN TAG #URR8PPP How to align the last element on the right when using hfill? I am making a wine list from a CSV file (see my first question here: How to import data from excel and format it as text in LaTeX?) and I need to align the prices on the right. To do this, I used the datatool package to fetch the informations from my spreadsheet, DTLforeach to iterate what I wanted to do and hfill to align my prices on the right. (see code after the picture) datatool DTLforeach hfill As you can see on the picture, it worked very well for every line but the last one of each (subsub)section, which is slightly misaligned: Here is my code: documentclass[12pt]article usepackage[utf8]inputenc % Pour modifer les marges usepackagegeometry % Marges du document geometryhmargin=1.5cm,vmargin=1.5cm % To remove the heading of the table of contents ("Contents") makeatletter renewcommandtableofcontents% @starttoctoc% makeatother %%% WAS makeatotherx = ERROR %%% % To make it

Unable to add Cordova plugins to my project

Image
Clash Royale CLAN TAG #URR8PPP Unable to add Cordova plugins to my project I am trying to add the buildinfo Cordova plugin to my project, to which I have added an Android platform. I was able to add rest of the required Cordova plugins. buildinfo Does it have anything to do with my Android version (6.4.0)? Also, after running command cordova plugin add cordova-plugin-buildinfo , it shows the attached screen but the buildinfo plugin folder along with the required contents gets created at my project's Plugins folder, but not inside the Plugins folder of the Android Platform inside my Cordova project. cordova plugin add cordova-plugin-buildinfo Plugins Plugins Plugins Folder contents Plugins Also kindly note that I have set my ANDROID_HOME and Path environment variables as seen in the below pictures: P.S. I am able to add the mentioned plugin to another Cordova project in my system! Possible duplicate of Failed to find 'ANDROID_HOME' environment variable – 

SQLSTATE[42S22]: Column not found: 1054 Unknown column material_tags.material_uuid

Image
Clash Royale CLAN TAG #URR8PPP SQLSTATE[42S22]: Column not found: 1054 Unknown column material_tags.material_uuid I have searched for people who encountered this error but I still can't find the solution. I have been getting the error: "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'material_tags.material_uuid' in 'field list' (SQL: select tags .*, material_tags . material_uuid as pivot_material_uuid , material_tags . tag_uuid as pivot_tag_uuid from tags inner join material_tags on tags . uuid = material_tags . tag_uuid where material_tags . material_uuid in (05a36470-d0a0-11e7-91b4-ff3d7d9f961a) and tags . deleted_at is null)" tags material_tags material_uuid pivot_material_uuid material_tags tag_uuid pivot_tag_uuid tags material_tags tags uuid material_tags tag_uuid material_tags material_uuid tags deleted_at in which if I have to view Material 05a36470-d0a0-11e7-91b4-ff3d7d9f961a it should look like this When I try to run this co

spark dataframe groupping does not count nulls

Image
Clash Royale CLAN TAG #URR8PPP spark dataframe groupping does not count nulls I have a spark DataFrame which is grouped by a column aggregated with a count: df.groupBy('a').agg(count("a")).show +---------+----------------+ |a |count(a) | +---------+----------------+ | null| 0| | -90| 45684| +---------+----------------+ df.select('a').filter('aisNull').count returns warning: there was one feature warning; re-run with -feature for details res9: Long = 26834 which clearly shows that the null values were not counted initially. What is the reason for this behaviour? I would have expected (if null at all is contained in the grouping result) to properly see the counts. null 2 Answers 2 Yes, count applied to a specific column does not count the null-values. If you want to include the null-values, use: count df.groupBy('a).agg(count("*")).show What is the reason for this behaviour? SQL-92 standard. In particular (emphasis mine): Let

sqlite query failing - no such column

Image
Clash Royale CLAN TAG #URR8PPP sqlite query failing - no such column I have a db that is created like this... public class DataBaseManager extends SQLiteOpenHelper{ Context mContext; private static final String TAG = "DataBaseManager"; private static final int dbVersion = 1;// ++ for DB changes static final String dbName ="LCInstore"; //Table Names static final String allIcons = "Icons"; static final String allScreens = "Screens"; static final String isLookUp = "LookUp"; //Column Names - LookUp static final String colIconID = "IconID"; static final String colScreenID = "ScreenID"; static final String colRank = "Rank"; // order //Column Names shared by tables: Screens and Icons static final String colID = "ID"; static final String colType = "Type"; static final String colName = "Name"; //Column Names - Icons static final String colImage = "Image";

The derivate class dosn't behave like the base when i pass parameter to them

Image
Clash Royale CLAN TAG #URR8PPP The derivate class dosn't behave like the base when i pass parameter to them I have done a class hierarchy for product several plot stile , in which change almost any parameter, just inherit and define a set of parameter for change the default plot .. but I have some problem with the derived class , basically from the abstract base class derive a complete and usable class which is callable ! (in this way i can call directly subplot, or plot referring to the derived class) The problem is that the usable base class that define the method __call__ works fine and accept and use in the right way the parameter passed by a generic script that instantiate it for create a plot, the derivatives classes don't. __call__ here I'm report minimal working code the base abstract class is: class BasePlot(metaclass=ABCMeta): def __init__(self, title : str = ' ' , filename : str = ' '): self.title = title self.filename = filename def sc

Redirect any page to Login screen on Session timeout ASP MVC 6

Image
Clash Royale CLAN TAG #URR8PPP Redirect any page to Login screen on Session timeout ASP MVC 6 So far I have the following but it seems not to be working. services.ConfigureApplicationCookie(options => options.LoginPath = "/Account/LogIn"; options.LogoutPath = "/Account/LogOff"; options.CookieName = "Yummy"; options.ExpireTimeSpan = TimeSpan.ParseExact(Configuration.GetValue<string>("Authorization:ExpireTimeSpan"), "c", null); options.AccessDeniedPath = "/"; options.ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter; options.SlidingExpiration = true; options.Cookie.HttpOnly = true; ); 1 Answer 1 Follow below URL for Autologut Use Usertimeout js for Auto redirect to login page Is there a way to do this without any javascript library – Tushortz Aug 6 at 14:02 I think it is not possible in back side but i am not sure – NIts577 Aug 6 at 14:09 By clicking "Post Your Ans