Skip to content

Instantly share code, notes, and snippets.

View chernjie's full-sized avatar

CJ (curl | jq) chernjie

View GitHub Profile
@chernjie
chernjie / hostname.sh
Created June 26, 2015 03:47
hostname.sh - Set hostname based on /etc/hostname
#! /bin/sh
### BEGIN INIT INFO
# Provides: hostname
# Required-Start:
# Required-Stop:
# Should-Start: glibc
# Default-Start: S
# Default-Stop:
# Short-Description: Set hostname based on /etc/hostname
# Description: Read the machines hostname from /etc/hostname, and
#!/usr/bin/env bash
json2markdowntable () {
local headers=$@
echo $headers | sed "s, , | ,g"
seq $# | while read i; do echo " --- "; done | xargs | sed "s, , | ,g"
json -a $headers -d" | "
}
@chernjie
chernjie / ubertrips.js
Last active October 8, 2017 18:04
Export Uber trips from https://riders.uber.com/trips
(function($){
var map = {
pickup: 1,
driver: 2,
fare: 3,
car: 4,
city: 5,
payment_method: 6
};
#!/usr/bin/env node
// time csvtojson data/order-interval-20180102.csv | node mockup/order-interval.js
var stdin = require('../../ppdg/ppdg-elk/src/stdinjson.js');
var lodash = require('lodash');
stdin(_process);
function _process (err, data) {
return lodash(data)
@chernjie
chernjie / .editorconfig
Last active January 28, 2018 02:42
everwing
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
#!/bin/sh
rundir=/var/run/parallelLimit
pause_file="$rundir/paused"
harakiri_file="$rundir/good-day-to-die"
is-paused() {
[ -f "$pause_file" ]
}
@chernjie
chernjie / git-ps1.source
Last active April 24, 2018 10:34
source git-ps1.source
#!/usr/bin/env bash
# Source git completion and git prompts
command -v __git_ps1 > /dev/null ||
for i in git-completion.bash git-prompt.sh
do
echo source ~/bin/$i
source ~/bin/$i
done
if declare -f __git_ps1 2>&1 >/dev/null
#!/usr/bin/env php
<?php
// if no arguments, take input from stdin
$argc < 2 && array_push($argv, file_get_contents("php://stdin"));
array_shift($argv);
$output = array();
@chernjie
chernjie / git-gh-setup.sh
Created February 9, 2015 09:25
Fetch Github's Pull Request as a remote branch
#!/usr/bin/env bash
git remote -v | grep fetch | grep github | \
while read remote url _; do
if ! git config --get-all "remote.$remote.fetch" | grep -q refs/pull
then
git config --add "remote.$remote.fetch" \
'+refs/pull/*/head:refs/remotes/'"$remote"'/pull/*'
fi
done
var table = $$('.emoji-card').map((el, i) => {
return {
emoji: el.firstChild.firstChild.innerHTML,
code: el.lastChild.firstChild.innerHTML,
description: el.lastChild.lastChild.innerHTML
};
}).reduce((table, el, i) => {
var tr = document.createElement('tr');
tr.innerHTML = '<td>' + el.emoji + '</td><td>' + el.code + '</td><td>' + el.description + '</td>';
table.appendChild(tr);