Skip to content

Instantly share code, notes, and snippets.

🐢
Coding

Benny Neugebauer bennyn

🐢
Coding
Block or report user

Report or block bennyn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View stateful-copies.js
const test = {
tree: {
branch1: 10,
branch2: 20,
}
};
const copies = {};
for (let i = 0; i < 10; i++) {
View 50-shades-types.ts
const a: object = { name: 'Benny' };
const b: Object = { name: 'Benny' };
const c: {} = { name: 'Benny' };
const d: Record<string, string> = { name: 'Benny' };
const e: any = { name: 'Benny' };
const f: {[index: string]: string} = { name: 'Benny' };
@bennyn
bennyn / nodejs-clean-exit.ts
Created Oct 8, 2019
Node.js process.exit cleanup
View nodejs-clean-exit.ts
function emitExit(signal: string) {
const exitCode = 0;
console.log(`Received "${signal}" signal. Will terminate with exit code "${exitCode}".`);
process.exit(exitCode);
}
// Catches Ctrl + C events
process.on('SIGINT', () => emitExit('SIGINT'));
// Catches "kill pid" events (for example: nodemon restarts)
@bennyn
bennyn / tsconfig.minimum.json
Created Aug 19, 2019
Minimum Viable TypeScript config
View tsconfig.minimum.json
{
"compilerOptions": {
"lib": ["dom", "es2017"],
"module": "commonjs",
"outDir": "dist",
"rootDir": "src",
"target": "es6"
}
}
View momentjs-cheatsheet.js
const moment = require('moment');
const date = moment('2019-07-23', 'YYYY-MM-DD');
const oneWeekLater = date.add(1, 'week');
console.log(oneWeekLater.format());
@bennyn
bennyn / material-ui-tricks.md
Last active Sep 10, 2019
Material UI Tricks
View material-ui-tricks.md

Add class

  render(): JSX.Element {
    const {classes, title} = this.props;
    return (
      <>
         <TextField
           className={classes.TextField}
           ...
View StoreHelper.ts
interface MandatoryProps {
id: number;
}
type StoreRecord =
MandatoryProps &
Object;
type Store = {[index: number]: StoreRecord};
View jasmine-samples.ts
import Spy = jasmine.Spy;
spyOn(exchange['client'], 'candles').and.callFake(() => {
const candlesSpy = (exchange['client'].candles as Spy);
switch (candlesSpy.calls.count()) {
case 1:
return require('../test/fixtures/binance/candles/BTC-USDT-1m-500-1561500000000.json');
case 2:
return require('../test/fixtures/binance/candles/BTC-USDT-1m-500-1561530000000.json');
default:
@bennyn
bennyn / window-fetch-post.js
Created Feb 18, 2019
Send POST request in Google Chrome
View window-fetch-post.js
// Using "var" here to easily change the parameters and resubmit the code in a JS dev console!
var url = 'http://127.0.0.1:3000/login';
var parameters = {
user: 'bennyn',
password: 'secret'
};
fetch(url, {
method: 'post',
@bennyn
bennyn / coinbase-transaction-buy.js
Created Feb 9, 2019
Log Coinbase buy transactions
View coinbase-transaction-buy.js
require('dotenv').config();
const Client = require('coinbase').Client;
const {promisify} = require('util');
const {COINBASE_API_KEY, COINBASE_API_SECRET} = process.env;
const client = new Client({
apiKey: COINBASE_API_KEY,
apiSecret: COINBASE_API_SECRET
});
You can’t perform that action at this time.