Skip to content

Instantly share code, notes, and snippets.

View Sharaal's full-sized avatar

Christoph Herrmann Sharaal

View GitHub Profile
@Sharaal
Sharaal / example.js
Last active March 1, 2019 15:41
Errors because of omitting ;
/**************************************************
* Immediatly executing anonymous function
**************************************************/
// Results in error "TypeError: console.log(...) is not a function"
console.log('example')
(async () => {})()
// With using of ; it works
@Sharaal
Sharaal / example.js
Last active April 7, 2021 11:20
SQL Tagged Template Literals with Node.js and `pg`
// with a sql tagged template literal use parameters directly in the sql query
const id = 5
const name = 'new name'
client.query(sql`
UPDATE users SET name = ${name} WHERE id = ${id}
`)
// text: 'UPDATE users SET name = $1 WHERE id = $2'
@Sharaal
Sharaal / blockchain.js
Last active January 24, 2018 10:52
An example blockchain implementation in Node.js to understand the concept behind
// example usage
const blockchain = new Blockchain();
blockchain.add(1);
blockchain.add(2);
blockchain.add(3);
blockchain.verify();
console.log(blockchain);
// example output