Posts

Showing posts from July 10, 2018

Axios posting empty request

Axios posting empty request I am trying to send an axios request to the backend, but it ends up having an empty body , and i do not understand why it does that. This is the code for the request: axios body axios.post('/register', {email: email, password: password, username: username, company: company}).then(response => { console.log(response.data); }); And this is the code for the backend: authRouter.post('/register', (request, response) => { console.log(request.body); }); And this one outputs an empty request.body . I've also checked the JSON sent, and it is not empty at all. Is there a way to see what is the form of the request before being sent? This authRouter is a module.export , that is being used by the main app module. This app module has this configuration: request.body JSON authRouter module.export app app app.use(express.static("public")); app.use(session({ secret: "shh", resave: false, saveUninitialized: false }

Readability of thymeleaf

Readability of thymeleaf I'm used to writing templates like this: ${name} This seems much more readable for me, in that I can see the variables outside of the tags themselves. Currently in thymeleaf, I would need to do: Or: ${name} // this text will be replaced and doesn't matter Is there a way to enter in the variable like I have at the top? The point of Thymeleaf is that templates are valid and renderable HTML , this allows for easier 1) styling, 2) validation, 3) formatting. Personally I think that Thymelead is far more readable than mixing multiple different languages. Now - the catch - the "I think" means that this is opinion based, so again off topic. – Boris the Spider Jul 2 at 21:10 P.S. worth reading – Boris the Spider Jul 2 at 21:13

Mail attachment from Unix script in loop

Mail attachment from Unix script in loop I have below sample script which was working fine until last week, however, not sure what has changed, I am not getting any attachments sent. I just get greet / text message but not any attachment. I tried with sample .txt as attachment which is success. But not .csv, not sure if csv's are being filtered by unix server, but I don't see any error message. Any idea how to track / check what is going wrong pls? #!/bin/bash FILES=/inbox/*.* to="test@temp.com" from="test@temp.com" subject="Test Files" filecount=`find $FILES -type f | wc -l` totalfiles=" : Total " subject=${subject}${totalfiles}${filecount} body="Dear All,Please find the attached latest files." echo $subject $filecount declare -a attargs for att in $(find $FILES -type f -name "*.*");do #attaching all files. attargs+=( "-a" "$att" ) done mail -s "$subject" -r "$from" &q

How do you properly nest for loops inside if/else statements in shell script?

How do you properly nest for loops inside if/else statements in shell script? I have the following code in Linux: #!/bin/sh echo "Enter a number:"; read n; if (($# != 0)) for ((i=1; i< $n+1; i++)) do echo $i done else for ((i=1; i<21; i++)) do echo $i done fi As you can tell, I am trying to print the values from 1 to n. If no user input is given, I automatically print from 1 to 20. When I run this script, it says I have syntax error near unexpected token else . Can somebody please help, I don't know what I'm missing. else Your missing shellcheck.net which can also help you in the future. – Walter A Jul 2 at 21:07 "shell" is not a specified environment. Please tag this with the correct shell. Also, check the description of tags. The other two an

Difference in output with waitKey(0) and waitKey(1)

Difference in output with waitKey(0) and waitKey(1) I've just begun using the OpenCV library for Python and came across something I didn't understand. cap = cv2.VideoCapture(0) while True: ret, frame = cap.read() #returns ret and the frame cv2.imshow('frame',frame) if cv2.waitKey(1) & 0xFF == ord('q'): break When I use cv2.waitKey(1), I get a continuous live video feed from my laptops webcam, but when I use cv2.waitKey(0), I get still images. Every time I close the window, another one pops up with another picture taken at the time. Why does it not show as a continuous feed? 2 Answers 2 From the doc - https://docs.opencv.org/2.4/modules/highgui/doc/user_interface.html?highlight=waitkey 1. waitKey(0) will display the window infinitely until any keypress (it is suitable for image display). waitKey(0) 2. waitKey(1) will display a frame for 1 ms,

Meteor, SimpleSchema, meteor-collection2 - Adding to array

Meteor, SimpleSchema, meteor-collection2 - Adding to array I have defined my filed and shema as: storageArticles: { type: Array, autoValue: function() { return ; }, label: 'Articless added to storage.', }, 'storageArticles.$': { type: String } When I try to update this field by using (in my server side method): Storages.update(storageId , {$set: { "storageArticles" : articleId }}); Everything goes OK, but data is no added to Array. Can you give me some guidance to solve this. EDIT Edit adds more details on this question, maybe here is my mistake. 'articles.articleAddToStorage': function articleAddToStorage(storageId,articleId) { check(storageId, String); check(articleId, String); try { Articles.update(articleId, { $set: {articleAssignedToStorage:true}}); Storages.update(storageId , {$addToSet: { "storageArticles" : articleId }}); } catch (exception) { handleMethodException(exception); } }

Kendo Grid Validation

Kendo Grid Validation Currently i am using Kendo Grid in my project to display data. And for validation of the same i have used kendo validator. Can any one kindly help me in making it generic, so that function can be used from any page which contains grid. (function ($, kendo) { $.extend(true, kendo.ui.validator, { rules: { // custom rules startdatetimevalidation: function (input, params) { if ($(input).val() && $(input).attr('id') == "StartDateTime") { if ($('#EndDateTime').val() && $(input).getKendoDateTimePicker().value() > $('#EndDateTime').getKendoDateTimePicker().value()) { return false; } } return true; }, endatetimevalidation: function (input, params) { if ($(input).val() && $(input).attr('id') == "EndDateTime") { if ($('#StartDateTime').val() &&

Dynamic dropdown list react axios get request

Image
Dynamic dropdown list react axios get request Inside of my main App.js componentDidMount() lifecycle phase I have an axios get request to a rest service. App.js componentDidMount() EDIT: Included full UserForm.js UserForm.js class App extends Component { // default state object constructor() { super(); this.state = { schemas: } } componentDidMount() { axios .get('http://localhost:port/querier/api/rest/dataschema/list') .then(response => { console.log(response) this.setState({ schemas: response }); }) .catch(error => console.log(error.response)); } render() { return ( App ); } } This request is successful in returning an array of schemas(strings) (only 1 for now) in the console messages Response: { "data": [ "Phone Record" ], "status": 200,

Yeoman Generator - How to Parse Package.json of Generator Project

Image
Yeoman Generator - How to Parse Package.json of Generator Project I have the following, standard folder structure within my generator. The task I am current struggling with is I currently have a templated _package.json that I write to disk for the main generation. There is one variable in the written package.json I would like to hydrate which is the actual version of the generator project. Basically, I want to be able to determine via the new generated api project's package.json which version of the generator was used to construct the project, so that I can target older versions and mark them for updates. I have tried to accomplish this in both various generator steps like prompting.js and writing.js and via the following code: var fs = require('fs'); let pkgGeneratorAPIVersion = JSON.parse(fs.readFileSync('../../package.json', 'utf8')); but it isn't working. I keep getting the following error: Error: ENOENT: no such file or directory, open 'pack

Convert string into json string and parsing in R

Convert string into json string and parsing in R I have a data with a column as json string: reservation reasons 1592 [{"name"=>"jorge", "value"=>"MX"}, {"name"=>"Billing phone number", "value"=>"1123"}, {"name"=>"BillingCountry", "value"=>"USA"}] 1597 [{"name"=>"BillingAddress_Country", "value"=>"IN"}, {"name"=>"Billing phone number country code", "value"=>"IN"}, {"name"=>"Latest amount", "value"=>"583000000"}] I want to parse the column as follows: reservation name value 1592 jorge mx 1592 Billing phone number 1123 1592 BillingCountry USA 1597 BillingAddress_Co

Map specific parent td ID based on class

Map specific parent td ID based on class I'm having trouble getting this code to report EACH machine name that has a child td with a class of 'up_avail'. This code simply replies two times wtih the same machine name, rather than grabbing the two machine name which is intended. Any help is appreciated. <table border=1> <th>Machine Name</th><th>Result</th><th>Status</th> <tr> <td class="tdresult" id="WN-MN161FY0X066">WN-MN161FY0X066</td> <td>Found</td> <td class='up_avail'>New</td> </tr> <tr> <td class="tdresult" id="WD-ORA60YY1U015">WD-ORA60YY1U015</td> <td>Found</td> <td class='up_success'>Complete</td> </tr> <tr> <td class="tdresult" id="WD-ORA60YY1U030">WD-ORA60YY1U030</td> <td>

Filter NSDictionary using DidSelectRow selection as key/filter object

Filter NSDictionary using DidSelectRow selection as key/filter object I parsed and stored an XML in two mutable arrays,they are albumArray and trackArray. I created an dictionary using these two arrays and that is as follows, XML trackANDAlbum = [NSMutableDictionary dictionaryWithObjects:trackArray forKeys:albumArray]; so my dictionary looks like this : album1 = song1 album1 = song2 album1 = song3 etc. Since the albumArray contains duplicates, I eliminated it using NSSet and this new array called "eliminateDupe" is given as the data source for a UITableView . NSSet UITableView The problem I face is that, when the user selects a particular album name in the TableView then, the corresponding songs of the selected album must be displayed in another view. So is it possible to identify what album name is selected in DidSelectRow of TableView and provide that as a key for the dictionary trackANDAlbum, and retrieve the corresponding songs and display it in an tableview. DidS

VBA - run-time error '424' - object required - folderpicker

VBA - run-time error '424' - object required - folderpicker I need to run a loop through all excel files in a folder and copy/paste the data from those files into a existing spreadsheet. To open the folder I'm using the 'msoFileDialogFolderPicker' from FileDialog applications. I've been troubleshooting the runTimeError '424' without success, & all research has led me to general info. Any help would be greatly appreciated, & thanks in advance. Here's the program: Sub LoopAllExcelFilesInFolder() Dim wb As Workbook Dim myPath As String Dim myFile As String Dim myExtension As String Dim FlrdPicker As FileDialog Dim RowN As Long Application.ScreenUpdating = False Application.EnableEvents = False Application.Calculation = xlCalculationManual 'Retrieve target folder path from user Set FlrdPicker = Appplication.FileDialog(msoFileDialogFolderPicker) With FlrdPicker .Title = "Select a Folder" .AllowMultiSelect = False .Initial

js-beautify indent block of JavaScript compared to HTML

js-beautify indent block of JavaScript compared to HTML I am using js-beautify to format eynamically generated HTML that includes a script block that contains JavaScript. Sense the method to format HTML is different than formatting JS, I do this: htmlText1 = html_beautify(htmlText1, { "indent_size": 2 }); jsText = js_beautify(jsText, { "indent_size": 2 }); htmlText2 = html_beautify(htmlText2, { "indent_size": 2 }); allFormattedCode = htmlText1 + 'n' + jsText + 'n' + htmlText2; It is formatted nicely, except the JS is at the left margin. Is there some way to indent all the code in the script block X number of spaces? Thanks! -Matt 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.

How to Remove Text Between brackets with php

How to Remove Text Between brackets with php How to remove text Between brackets. For exp. $str = 'Aylmers(test, test2), Ancaster(Clandeboye, Bluevale)'; i want to get as $str = 'Aylmers, Ancaster'; Possible duplicate of Remove Text Between Parentheses PHP – billynoah 14 mins ago 3 Answers 3 Please try this: $str = 'Aylmers(test, test2), Ancaster(Clandeboye, Bluevale)'; echo preg_replace("/([^)]+)/","",$str ); output: Aylmers, Ancaster Regex unfortunately this does not remove nested brackets such as A (B (C) D) and leaves you with A D – rawathemant 13 mins ago

node-postgres: how to execute “WHERE col IN ()” query?

node-postgres: how to execute “WHERE col IN (<dynamic value list>)” query? I'm trying to execute a query like this: SELECT * FROM table WHERE id IN (1,2,3,4) The problem is that the list of ids I want to filter against is not constant and needs to be different at every execution. I would also need to escape the ids, because they might come from untrusted sources, though I would actually escape anything that goes in a query regardless of the trustworthiness of the source. node-postgres appears to work exclusively with bound parameters: client.query('SELECT * FROM table WHERE id = $1', [ id ]) ; this will work if I had a known number of values ( client.query('SELECT * FROM table WHERE id IN ($1, $2, $3)', [ id1, id2, id3 ]) ), but will not work with an array directly: client.query('SELECT * FROM table WHERE id IN ($1)', [ arrayOfIds ]) , as there does not seem to be any special handling of array parameters. client.query('SELECT * FROM table WHERE id