This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var sqlite3 = require('sqlite3').verbose(); | |
| var get_rows = function(query, callback){ | |
| var db = new sqlite3.Database('test.db'); | |
| db.serialize(function(){ | |
| db.all(query, function(err, rows){ | |
| callback(rows); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var parse_params = function(url){ | |
| var pairs = url.match(/\/?\??(.*)/)[1].split('&'); | |
| var out = []; | |
| pairs.forEach(function(chunk){ | |
| var keyvalues = chunk.split('='); | |
| for(var i=0; i<keyvalues.length; i++){ | |
| if(i % 2 === 0){ | |
| var obj = {}; | |
| obj[keyvalues[i]] = keyvalues[i + 1] | |
| out.push(obj); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let pp = this.proposalForm; | |
| let $datefields = $('.date input').datepicker( | |
| { | |
| format: "dd/mm/yyyy" | |
| } | |
| ); | |
| $datefields.on('changeDate', function (e) { | |
| let fcn = $(this).attr('formControlName'); | |
| let index = e; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $data = array("name" => "James", "age" => "36"); | |
| $data_string = json_encode($data); | |
| $ch = curl_init('http://localhost/post.php'); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
| 'Content-Type: application/json', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const arrayOfWords = ['the', 'quick', 'brown', 'fox']; | |
| for (let i = 0; i < arrayOfWords.length; i += 1) { | |
| arrayOfWords[i] = arrayOfWords[i][0].toUpperCase() + arrayOfWords[i].slice(1); | |
| } | |
| console.log(arrayOfWords); // ["The", "Quick", "Brown", "Fox"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const axios = require('axios'); | |
| const chalk = require('chalk'); | |
| const commander = require('commander'); | |
| commander | |
| .version('1.0.0') | |
| .option('-t --type <type>', 'Lookup type') | |
| .option('-n --number <number>', 'Number of results') | |
| .parse(process.argv); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| router.get('/', (req, res, next) => { | |
| const users = req.app.locals.users; | |
| users | |
| .find({}) | |
| .toArray() | |
| .then(data => res.json(data)); | |
| }); | |
| router.post('/', (req,res, next) => { | |
| const users = req.app.locals.users; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // app.js | |
| const MongoClient = require('mongodb').MongoClient; | |
| const passport = require('passport'); | |
| const LocalStrategy = require('passport-local').Strategy; | |
| const ObjectID = require('mongodb').ObjectID; | |
| MongoClient.connect('mongodb://localhost:27017/test', (err, client) => { | |
| if (err) throw err; | |
| const db = client.db('test'); | |
| const users = db.collection('users'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
| <title>Submit a form with JavaScript</title> | |
| <style> | |
| html, body { | |
| height: 100%; |