Skip to content

Instantly share code, notes, and snippets.

View reyhansofian's full-sized avatar

Reyhan Sofian reyhansofian

View GitHub Profile
@reyhansofian
reyhansofian / createFolderAndMoveToIt.sh
Created May 7, 2016 18:20
Create folder based on JSX files and move JSX file to the created folder
!#/bin/bash
for file in *.jsx; do
dir=${file%.js*}
if [ -e $dir ]; then
mv "$file" "$dir"
else
mkdir -p "$dir"
mv "$file" "$dir"
fi
done
@reyhansofian
reyhansofian / add_package_json_to_each_component_folder.sh
Created May 8, 2016 04:33
Create package.json to each component folder
!#/bin/bash
for dirs in ~/Projects/hostel/public_html/assets/reservation/components/*; do
if [ -d "$dirs" ]; then
for dir in $dirs; do
for comp in $dir/*; do
if [ -d "$comp" ]; then
for pol in $comp/*.jsx; do
cd $comp && touch package.json
str=${pol##*/}
rjsx=${str//.jsx}
@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 / 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 / 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) {
GET /users
response:
{
data: [
{
id: 1,
name: John Doe
},
@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 / 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);

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname

Pra-syarat


Hardware

  1. Laptop
  2. HP Android minimal Jelly Bean (4.1)
  3. Kabel data

Software

  1. Windows