Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
@jonniedarko
jonniedarko / reverse-proxy-server.js
Last active August 29, 2015 14:26
A very basic reverse proxy server
var http = require('http'),
httpProxy = require('http-proxy'),
proxy = httpProxy.createProxyServer({});
var url = require('url');
http.createServer(function (req, res) {
var pathname = url.parse(req.url).pathname;
console.log('pathname', pathname);
var conversationsPath = '/api/conversations';
var discoverPath = '/api/discover';
@jonniedarko
jonniedarko / .inputrc
Last active September 25, 2015 13:46
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on
[[ $- = *i* ]] && bind TAB:menu-complete
# for changes to file
alias reloadBash='source ~/.bash_profile'
alias editBash='subl ~/.bash_profile'
#mongo
alias mongod='mongod --dbpath ~/data/db'
# open in chrome
alias chrome='open -a "Google Chrome"'
#alias cp='cp -iv' # Preferred 'cp' implementation
alias mv='mv -iv' # Preferred 'mv' implementation
If the forward-delete key just keeps inputting a '~' when pressed, instead of deleting the next character there is an easy solution.
In Terminal Preferences, click `profiles > Keyboard and + (Add)`
Double-click on the `del (forward delete)` key.
In the window that pops open, in the input box just below "Action."Type:
`Control-Option-D`
you should see '\004' in the box. Click OK, close the Terminal Inpsector window, and you should now have a working forward-delete key.
Yay!
@jonniedarko
jonniedarko / dev functions
Created January 7, 2016 14:30
Useful console functions
var localStorageToJSON = function localStorageToJSONFn(obj){
var storage = {};
for(var item in obj){
try{
json = JSON.parse(obj[item]);
storage[item] = json;
} catch(err){
storage[item] = obj[item]
}
}
@jonniedarko
jonniedarko / index.html
Last active January 14, 2016 17:25
Symbol in HTML Input
<style>
.input-symbol{
position:relative;
}
.input-symbol span{
position: absolute;
transform: translate(0,-50%);
top:50%;
pointer-events:none;
@jonniedarko
jonniedarko / memReport.py
Created January 28, 2016 13:57
reports on memory of system
#!/usr/bin/python
# src: http://apple.stackexchange.com/questions/4286/is-there-a-mac-os-x-terminal-version-of-the-free-command-in-linux-systems
import subprocess
import re
# Get process info
ps = subprocess.Popen(['ps', '-caxm', '-orss,comm'], stdout=subprocess.PIPE).communicate()[0]
vm = subprocess.Popen(['vm_stat'], stdout=subprocess.PIPE).communicate()[0]
# Iterate processes
[alias]
ca = !sh -c 'git add -A && git commit -m \"$1\"'
@jonniedarko
jonniedarko / excel-functions.js
Created February 24, 2016 15:34
Math Functions
//
/**
* Returns the inverse of the standard normal cumulative distribution.
* The distribution has a mean of zero and a standard deviation of one.
* Based on: https://github.com/liorzoue/js-normal-inverse
* @param Number
*/
function normsInv(x){
if(isNaN(x)){
throw new TypeError('normsInv requires a parameter of type Number');