Skip to content

Instantly share code, notes, and snippets.

View reyhansofian's full-sized avatar

Reyhan Sofian reyhansofian

View GitHub Profile

Effective Engineer - Notes

What's an Effective Engineer?

  • They are the people who get things done. Effective Engineers produce results.

Adopt the Right Mindsets

@reyhansofian
reyhansofian / SingletonEnforcer.js
Created December 11, 2017 01:49 — forked from uran1980/SingletonEnforcer.js
ES6 singleton pattern: use Symbol to ensure singularity
// http://stackoverflow.com/a/26227662/1527470
const singleton = Symbol();
const singletonEnforcer = Symbol();
class SingletonEnforcer {
constructor(enforcer) {
if (enforcer !== singletonEnforcer) {
throw new Error('Cannot construct singleton');
}
@reyhansofian
reyhansofian / gist:ddee0668cc8f68a1b4ae698f363c08f1
Created June 22, 2017 04:02 — forked from dmitshur/gist:6927554
How to `go get` private repos using SSH key auth instead of password auth.
$ ssh -A vm
$ git config --global url."git@github.com:".insteadOf "https://github.com/"
$ cat ~/.gitconfig
[url "git@github.com:"]
	insteadOf = https://github.com/
$ go get github.com/private/repo && echo Success!
Success!

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@reyhansofian
reyhansofian / encryption.js
Created May 17, 2017 12:52 — forked from vlucas/encryption.js
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bytes (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', new Buffer(ENCRYPTION_KEY), iv);
@reyhansofian
reyhansofian / gist:4b45135bd72d53a7892753b2a5e46c67
Created May 8, 2017 17:48 — forked from jasonrudolph/gist:6057563
GitHub Search API: Get the number of stars for a repository

James Sugrue [asked][1], "@GitHubAPI is there a way to find the number of stars for a given repository?"

Example

$ curl -ni "https://api.github.com/search/repositories?q=more+useful+keyboard" -H 'Accept: application/vnd.github.preview'
{
@reyhansofian
reyhansofian / test.js
Created January 4, 2017 16:43
setup and teardown in tape
var test = require('tape');
test('setup', function (t) {
// ...
t.end();
});
// tests go here
test('teardown', function (t) {
@reyhansofian
reyhansofian / ubuntu_agnoster_install.md
Created September 12, 2016 16:44 — forked from renshuki/ubuntu_agnoster_install.md
Ubuntu 14.04 + Terminator + Oh My ZSH with Agnoster Theme

Install Terminator (shell)

sudo add-apt-repository ppa:gnome-terminator
sudo apt-get update
sudo apt-get install terminator

Terminator should be setup as default now. Restart your terminal (shortcut: "Ctrl+Alt+T").

Install ZSH

@reyhansofian
reyhansofian / .bash_profile
Last active September 5, 2016 09:25 — forked from ladyrassilon/.bash_profile
Add this to your bash script to avoid docker-machine env dev blocking your bash if dev isn't running
docker_running=$(docker-machine ls | grep default)
if [[ "$docker_running" == *"Stopped"* ]]
then
docker-machine start
eval "$(docker-machine env)"
env | grep "DOCKER_HOST"
elif [[ "$docker_running" == *"Running"* ]]
then
eval "$(docker-machine env)"
fi
@reyhansofian
reyhansofian / after.sh
Created May 6, 2016 03:33 — forked from cluppi/after.sh
Turning SSL on for Homestead
#!/bin/sh
# Config for SSL.
echo "--- Making SSL Directory ---"
mkdir /etc/nginx/ssl
echo "--- Copying $i SSL crt and key ---"
openssl req -nodes -new -x509 -keyout /etc/nginx/ssl/server.key -out /etc/nginx/ssl/server.crt -subj "/C=US/ST=NY/L=NYC/O=Dis/CN=www.example.com"
echo "--- Turning SSL on in nginx.conf. ---"