Skip to content

Instantly share code, notes, and snippets.

View apendua's full-sized avatar

Tomasz Lenarcik apendua

View GitHub Profile
@nicolashery
nicolashery / typescript-jsdoc-enum.md
Last active August 9, 2024 16:06
Emulating "enums" in JSDoc version of TypeScript

Emulating "enums" in JSDoc version of TypeScript

Problem

TypeScript has support for type-checking plain JavaScript files, which is very useful if you have an existing JS codebase and you want to test the waters and gradually add types.

There are some limitations in what you can do in JSDoc, but a lot of them can be worked-around by using type-definition files .d.ts (for example in a types/ directory). These files don't generate any JavaScript code, they are just there to provide extra type definitions to the compiler.

One thing you can't do in those .d.ts files though, is use enums. You could define them of course, but you won't get the runtime representation since the files don't generate JS code.

Raise Open File Limits in OS X

in OS X 10.4 to macOS sierra 10.12 and maybe higher!

Create Launcher Script:

/Library/LaunchDaemons/limit.maxfiles.plist

Copy this entire code block and paste it into your terminal and push Return to create this file for you with correct permissions. It will (probably) ask for your password:

@bisubus
bisubus / ES5-ES6-ES2017-ES2019 omit & pick
Last active April 13, 2024 21:03
ES5/ES6/ES2017/ES2019 omit & pick
@marinho
marinho / refCountWithDelay.ts
Created October 7, 2016 15:45
RxJS operator to delay before disposal when refCount reaches zero
import { Observable } from 'rxjs/Observable';
import { ConnectableObservable } from 'rxjs/observable/ConnectableObservable';
import { Subscription } from 'rxjs/Subscription';
import { async } from 'rxjs/scheduler/async';
/* This operator makes more sense when used with .publishReplay(1), as example below:
*
* let some$ = Observable.create(observer => {
* console.log(1110);
* observer.next('a value');
@sevastos
sevastos / aws-multipartUpload.js
Last active May 28, 2024 15:02
Example AWS S3 Multipart Upload with aws-sdk for Node.js - Retries to upload failing parts
// Based on Glacier's example: http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/examples.html#Amazon_Glacier__Multi-part_Upload
var fs = require('fs');
var AWS = require('aws-sdk');
AWS.config.loadFromPath('./aws-config.json');
var s3 = new AWS.S3();
// File
var fileName = '5.pdf';
var filePath = './' + fileName;
var fileKey = fileName;
@taberh
taberh / README.md
Last active April 13, 2016 15:10
Convert Data URI to Blob then can append FormData

#Covert Data URI to Blob

@srpouyet
srpouyet / nginx.conf
Last active August 5, 2018 22:37
Nginx Upstart script (Ubuntu 12.04)
### Nginx upstart script
### source: http://serverfault.com/a/391737/70451
### /etc/init/nginx.conf
description "nginx http daemon"
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
env DAEMON=/usr/local/sbin/nginx
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a