This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
type Token = | |
| Number of int | |
| UnaryOperator of (int -> int -> int) | |
let tryCharToToken a = | |
match (Int32.TryParse a) with | |
| (true, num) -> Some (Number num) | |
| (false, _) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# On the server side split the core file into 50M chunks naming them core.0000000000 etc. | |
# $ split -a 10 -b 50M -d core core. | |
# reassamble on the other side via | |
# $ cat core.* > core | |
chunk_count = 538 | |
root_name = "core." # name on server is 'core.00001 etc' | |
host = "myhost.com" | |
path = "/tmp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun setup-docker-machine-env () | |
" Parse the output of docker-machine env and setup the needed env vars" | |
(interactive) | |
(mapcar | |
(lambda (e) | |
(if e | |
(let ((var-value (split-string-and-unquote (car e) "="))) | |
(setenv (s-chop-suffix "=" (car var-value)) (car (cdr var-value)))))) | |
(mapcar | |
(lambda (e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; URL for current branch PR should | |
;; look like this: | |
;; https://github.com/sideshowcoder/tbrokersetip/compare/master...sideshowcoder-patch-1?quick_pull=1 | |
;; (requires magit) | |
(defun coder/string-remove-until (string seperator) | |
(nth 1 (split-string string seperator))) | |
(defun coder/string-remove-after (string seperator) | |
(nth 0 (split-string string seperator))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; make sure we always use the correct user for git when using magit, and save it off for later as well | |
;; in the local user property for the repo | |
(require 'subr-x) | |
(defun yammer-git-repo-p () | |
(string-match "int.yammer.com" (shell-command-to-string "git config --get remote.origin.url"))) | |
(defun yammer-git-property (prop) | |
(string-trim (shell-command-to-string (format "git config --get %s" prop)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "pry" | |
def chop number, numbers, acc = 0 | |
return -1 if numbers.nil? || numbers.empty? | |
pivot_pos = (numbers.size / 2) | |
pivot = numbers[pivot_pos] | |
return pivot_pos + acc if pivot == number | |
smaller = numbers.slice(0, pivot_pos) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = [1,2,3] | |
b = [4,5,6] | |
# ruby can be quite functional sadly we don't have a sum by default | |
sum = lambda { |args| args.reduce(:+) } | |
# with this we can do | |
a.zip(b).map(&sum) | |
# extending does not change much | |
c = [7,8,9] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProcessCtrl | |
module LibC | |
PR_SET_NAME = 15 | |
extend FFI::Library | |
ffi_lib "c" | |
attach_function :prctl, [:int, :pointer, :long, :long, :long], :int | |
end | |
class << self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
a = add | |
ac = add -p | |
c = commit | |
co = checkout | |
p = push | |
pr = pull-request | |
s = status | |
serve = daemon --verbose --export-all --base-path=.git --reuseaddr --strict-paths .git/ | |
l = log --oneline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MAX_MEM=50000 | |
for pid in $(ps ax|grep 'unicorn_rails worker'|awk 'NR>1 {print l} {l=$1}'); do | |
test $(cat "/proc/$pid/status" | grep "VmSize:" | sed -re s,VmSize:\\s+,, | cut -d" " -f1) -gt $MAX_MEM && kill -QUIT $pid | |
done |