var ClassFirst = function () {};
var ClassSecond = function () {};
var instance = new ClassFirst();
typeof instance; // object
typeof instance == 'ClassFirst'; // false
instance instanceof Object; // true
instance instanceof ClassFirst; // true
instance instanceof ClassSecond; // false
// https://stackoverflow.com/a/19078591 | |
let win = window.open( | |
'', | |
'Title', | |
'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=200,top=' + | |
(screen.height - 400) + | |
',left=' + | |
(screen.width - 840), | |
); |
var mediaJSON = { "categories" : [ { "name" : "Movies", | |
"videos" : [ | |
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org", | |
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ], | |
"subtitle" : "By Blender Foundation", | |
"thumb" : "images/BigBuckBunny.jpg", | |
"title" : "Big Buck Bunny" | |
}, | |
{ "description" : "The first Blender Open Movie from 2006", | |
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ], |
var udp = require('dgram'); | |
// --------------------creating a udp server -------------------- | |
// creating a udp server | |
var server = udp.createSocket('udp4'); | |
// emits when any error occurs | |
server.on('error',function(error){ | |
console.log('Error: ' + error); |
https://www.ntu.edu.sg/home/ehchua/programming/sql/PostgreSQL_GetStarted.html
Magic words:
psql -U postgres
Some interesting flags (to see all, use -h
or --help
depending on your psql version):
// check version | |
node -v || node --version | |
// list installed versions of node (via nvm) | |
nvm ls | |
// install specific version of node | |
nvm install 6.9.2 | |
// set default version of node |
const fs = require('fs'); | |
const path = require('path'); | |
fs.readdir('./icons', (err, files) => { | |
if (err) { | |
return; | |
} | |
for (const file of files) { | |
console.log(file); |
http://blog.httpwatch.com/2009/02/20/how-secure-are-query-strings-over-https/
- URLs are stored in web server logs
- typically the whole URL of each request is stored in a server log. This means that any sensitive data in the URL (e.g. a password) is being saved in clear text on the server. Here’s the entry that was stored in the httpwatch.com server log when a query string was used to send a password over HTTPS:
2009-02-20 10:18:27 W3SVC4326 WWW 208.101.31.210 GET /Default.htm password=mypassword 443 ...
parent ref: http://www.skrenta.com/2007/08/md5_tutorial.html ref: http://www.pbm.com/dice/random.html
After becoming frustrated with the lack of a standalone, portable, decent random number generator, I decided to make one based on a one-way hash function. I chose MD5 since it is fast and free source was readily available. More cryptographically secure hash functions are available (e.g. SHA-1), but for the purposes of a rand/random/erand48 replacement, MD5 should be more than sufficient. MD5 takes an arbitrary amount of input and yields a 16 byte hash. This RNG continually MD5's a 16 byte digest, and uses the bottom N bits as the random number yielded, where N is just large enough to include the largest random number desired, e.g.:
To yield a random number between 0 and r:
create mask which has enough bits to include all of r
(for example, if r is 100, mask would be 0x7F)