This file contains hidden or 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
reduce(lambda x,y: y + x, "abcde") |
This file contains hidden or 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 Recurse do | |
def loopy([head | tail]) do | |
IO.puts "Head: #{head} Tail: #{inspect(tail)}" | |
loopy(tail) | |
end | |
def loopy([]), do: IO.puts "Done!" | |
end |
This file contains hidden or 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
sudo apt-get install libsnappy-dev | |
wget https://leveldb.googlecode.com/files/leveldb-1.9.0.tar.gz | |
tar -xzf leveldb-1.9.0.tar.gz | |
cd leveldb-1.9.0 | |
make | |
sudo mv libleveldb.* /usr/local/lib | |
cd include | |
sudo cp -R leveldb /usr/local/include |
This file contains hidden or 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 'drb/drb' | |
require 'pp' | |
obj = DRbObject.new_with_uri('druby://localhost:1234') | |
pp obj | |
pp obj.to_a | |
pp obj.to_single |
This file contains hidden or 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 Demo | |
def initialize(n) | |
@secret = n | |
end | |
def get_binding | |
return binding() | |
end | |
end |
This file contains hidden or 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
Pry.config.exception_handler = proc do |output, exception, _| | |
if UserError === exception && SyntaxError === exception | |
output.puts "SyntaxError: #{exception.message.sub(/.*syntax error, */m, '')} | |
else | |
output.puts "#{exception.class}: #{exception.message}" | |
output.puts "from #{exception.backtrace}" | |
end | |
end |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<style> | |
.content { | |
width: 80%; | |
} | |
.share ul{ | |
list-style: none |
This file contains hidden or 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
package main | |
import ( | |
"net/http" | |
"html/template" | |
) | |
func process(w http.ResponseWriter, r *http.Request) { | |
t, _ := template.ParseFiles("tmpl.html") | |
t.Execute(w, "Hello World!") |
This file contains hidden or 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
package main | |
import ( | |
"net/http" | |
"encoding/base64" | |
"fmt" | |
"time" | |
) | |
func setMessage(w http.ResponseWriter, r *http.Request) { |
This file contains hidden or 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
package main | |
import ( | |
"net/http" | |
"fmt" | |
"encoding/json" | |
) | |
func writeExample(w http.ResponseWriter, r *http.Request) { | |
str := `<html> |