Skip to content

Instantly share code, notes, and snippets.

@andrwj
andrwj / connect.ssh
Created August 1, 2012 17:52
connect remote ssh server easily.
#!/bin/bash
# if $0 looks like id@domain
# then login as id
# else
# login as default user
__DEFAULT_SSH_LOGIN_UID__="root"
__self__="`basename $0`"
__tmp__="`mktemp -t uid`"
#!/bin/bash -eux
ARCH=${ARCH:-x86_64}
CORES=$(sysctl -n hw.ncpu)
GHC=${GHC:-7.4.2}
CABAL=${CABAL:-0.14.0}
PLATFORM=${PLATFORM:-2012.2.0.0}
[[ ! -d /usr/local/src ]] && mkdir -p /usr/local/src
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@andrwj
andrwj / set-cpu-limit-to-flash-player.sh
Last active January 1, 2016 13:18
set CPU limit to flash player!
#!/bin/bash
# A.J <[email protected]>
# 2013-12-27
# v0.0.6
#
# set cpu limit to Flash player!
# default limit value: 30%
# usage:
# set-cpu-limit-to-flash-player.sh 50
#
@andrwj
andrwj / climit.to
Last active January 1, 2016 13:39
Set CPU limits on pattern matched processes
#!/bin/bash
# A.J <[email protected]>
# 2013-12-27
# v0.0.2
#
# set cpu limit on pattern matched processes
# default limit value: 10%
# usage:
# climit.to <['process-name' | 'kill-all']> [value-to-limit-in-percentage]"
#
@andrwj
andrwj / Pebble-Build-in-Simulator.sublime-build
Created February 22, 2014 01:50
Sublime Build for Pebble Programming (Simulator)
{
"shell_cmd": "cd ../sim/ && make clean && make && ./PebbleSim",
"file_regex": "^../src/(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$"
}
@andrwj
andrwj / Pebble.ino
Created February 22, 2014 13:58 — forked from southwolf/Pebble.ino
#include <string.h>
#include <ctype.h>
#include <SoftwareSerial.h>
// the Bluetooth Shield connects to Pin D9 & D10
SoftwareSerial bt(9,10);
const uint8_t req[5] = {0x00, 0x01, 0x00, 0x11, 0x00};
const uint8_t cap[17] = {0x00, 0x0d, 0x00, 0x11, 0x01, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32};
const uint8_t ping[9] = {0x00, 0x05, 0x07, 0xd1, 0x00, 0xde, 0xad, 0xbe, 0xef};
@andrwj
andrwj / .ctags
Created August 18, 2014 23:37 — forked from tebeka/.ctags
--langdef=Go
--langmap=Go:.go
--regex-Go=/func([ \t]+\([^)]+\))?[ \t]+([a-zA-Z0-9_]+)/\2/d,func/
--regex-Go=/var[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,var/
--regex-Go=/type[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,type/
--regex-Go=/([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*:=/\1/d,var/
// Traverses an arbitrary struct and translates all stings it encounters
//
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Heye Vöcking
//
@andrwj
andrwj / connect-as-mosh-client.sh
Created January 18, 2016 05:08
easy connect ssh/mosh server
#!/bin/bash
# if $0 looks like id@domain
# then login as id
# else
# login as default user
default_uid="root"
script="`basename $0`"