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 Newtonsoft.Json | |
open Newtonsoft.Json.Linq | |
open System.Collections.Generic | |
open System | |
open System.IO | |
open System.Text | |
type TypeNodeMut = | |
{ fieldname: string | |
children : Dictionary<string, TypeNodeMut> |
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
defmodule StackPls do | |
@behaviour :gen_statem | |
def callback_mode(), do: :state_functions | |
def start_link(opts) do | |
:gen_statem.start_link(__MODULE__, opts, []) | |
end | |
# Mandatory callback functions |
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
(defn interactive-content? | |
"Check if an html element (in hiccup form) is interactive content. See http://www.w3.org/html/wg/drafts/html/master/dom.html#interactive-content-0" | |
[node] | |
(match node | |
[(:or :a :button :details :embed :iframe :keygen :label :select :textarea :video) & _] true | |
[(:or :audio :video) {:controls _} & _] true | |
[ (:or :img :object) {:usemap _} & _] true | |
[:input attrs & _ ] (not (= "hidden"(:type attrs))) | |
:else 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
var process = Process.Start(new ProcessStartInfo("foo.exe")); | |
process.StandardInput.Write("sup"); |
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
task :foo do | |
puts "foo" | |
end | |
task :bar => "foo" do | |
puts "bar" | |
end | |
task :baz do | |
puts "baz" |
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
function video_info { | |
ffprobe -v quiet -print_format json $1 -show_streams | |
} |
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
update_in = (obj, keys, value) -> | |
node = obj | |
while true | |
key = keys.shift() | |
if keys.length > 0 | |
node[key] = {} unless node[key]? | |
node = node[key] | |
else | |
node[key] = value | |
break |
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
# Check out rbenv into ~/.rbenv. | |
cd | |
git clone git://github.com/sstephenson/rbenv.git .rbenv | |
# Add ~/.rbenv/bin to your $PATH for access to the rbenv command-line utility. | |
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile | |
# Add rbenv init to your shell to enable shims and autocompletion. | |
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile |
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
def ghetto_cartesian_product colls | |
if colls.empty? | |
[[]] | |
else | |
colls.first.reduce([]) do |memo, e| | |
rest = colls.drop 1 | |
tails = ghetto_cartesian_product(rest).map do |tail| | |
[e].concat tail | |
end | |
memo.concat tails |
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
// How to win. Script for okcupid.com | |
// Using a script manager, e.g., this thing: https://github.com/defunkt/dotjs | |
// Replace cities_close_enough array with what is close enough for you. | |
// Drop this in ~/.js/okcupid.com.js | |
window.setInterval(function(){ | |
$('p.location:visible').each(function(){ | |
var loc = $(this).text(); | |
var city = loc.substring(0,loc.indexOf(',')); | |
var cities_close_enough = ['Palo Alto', 'Mountain View', 'Sunnyvale', 'Stanford']; |