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
object nQueens { | |
def queens(n: Int): Set[List[Int]] = { | |
def placeQueens(k: Int): Set[List[Int]] = | |
if (k == 0) Set(List()) | |
else | |
for { | |
queens <- placeQueens(k - 1) | |
col <- 0 until n | |
if isSafe(col, queens) | |
} yield col :: queens |
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
Show hidden characters
{ | |
"font_size": 13.0, | |
"tab_size": 2, | |
"translate_tabs_to_spaces": true, | |
"trim_automatic_white_space": true, | |
"trim_trailing_white_space_on_save": true, | |
"use_tab_stops": true | |
} |
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 sieve(s: Stream[Int]): Stream[Int] = { | |
s.head #:: sieve(s.tail.filter(_ % s.head != 0)) | |
} | |
val primes = sieve(Stream.from(2)) //infinite lazy stream | |
println((primes take 15).toList) |
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 Y = function(proc) { | |
return (function(x) { | |
return proc(function(y) { return (x(x))(y);}); | |
})(function(x) { | |
return proc(function(y) { return (x(x))(y);}); | |
}); | |
}; | |
var factgen = function(fact) { | |
return function(n) { |
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
export PKG_CONFIG_PATH=/usr/X11/lib/pkgconfig/:/usr/X11/lib/pkgconfig: | |
export CLICOLOR=1 | |
export LSCOLORS=ExFxCxDxBxegedabagacad | |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* | |
source /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash | |
source /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-prompt.sh | |
GIT_PS1_SHOWDIRTYSTATE=true | |
#export PS1='\u@\h:\w$(__git_ps1)$ ' |
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
{ | |
"auto_complete_commit_on_tab": true, | |
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme", | |
"folder_exclude_patterns": | |
[ | |
".svn", | |
".git", | |
".hg", | |
"CVS", | |
"node_modules" |
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
/** Because Handlebars sucks and won't let you iterate with @index | |
* Use this lookup helper to do things with the automatic @index var inside loops | |
* | |
* Usage example: (Get the item at @index each iteration through foo) | |
* {{#each foo}} | |
* <div>{{someProp}}</div> | |
* <div>{{lookup ../dailyStat @index}}</div> | |
* {{/each}} | |
* | |
* Block usage example: (get the item at @index in monthlyUniqueCustomers and then use its subcomponents |
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
// Mini-bandit | |
const explorationRatio = 0.1; | |
// example levers array | |
/* [{name: 'control', trials: 412, conversions: 113, revenue: 22260}, | |
{name: 'noCarousel', trials: 723, conversions: 298, revenue: 45390}, | |
{name: 'crazyCarousel', trials: 19, conversions: 11, revenue: 6600} | |
] | |
*/ |
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
# my_app/web/controllers/auth_controller.ex | |
defmodule MyApp.AuthController do | |
use MyApp.Web, :controller | |
import Ecto.Query | |
alias MyApp.TwilioToken | |
# Connect this to a route for /token:identity | |
def token(conn, %{"identity" => identity}) do | |
token = TwilioToken.for_video(identity) | |
json conn, %{token: token, identity: identity} |