Skip to content

Instantly share code, notes, and snippets.

View suhanlee's full-sized avatar
:octocat:
Focusing

kyle suhanlee

:octocat:
Focusing
View GitHub Profile
@suhanlee
suhanlee / str_reverse.py
Created November 10, 2017 00:31
String reverse
reduce(lambda x,y: y + x, "abcde")
@suhanlee
suhanlee / recurse.exs
Created November 5, 2017 12:23
elixir recursive pattern
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
@suhanlee
suhanlee / gist:a03161d167e02290af12675d4ec31287
Created November 1, 2017 19:14 — forked from dustismo/gist:6203329
How to install leveldb on ubuntu
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
@suhanlee
suhanlee / drb_client.rb
Created October 21, 2017 05:03
drb_example
require 'drb/drb'
require 'pp'
obj = DRbObject.new_with_uri('druby://localhost:1234')
pp obj
pp obj.to_a
pp obj.to_single
@suhanlee
suhanlee / binding.rb
Last active October 21, 2017 04:50
bindig example
class Demo
def initialize(n)
@secret = n
end
def get_binding
return binding()
end
end
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
@suhanlee
suhanlee / index.html
Created September 25, 2017 01:06
SNS Share button template
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
.content {
width: 80%;
}
.share ul{
list-style: none
@suhanlee
suhanlee / template1.go
Last active September 21, 2017 18:28
template1.go
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!")
@suhanlee
suhanlee / flash_message.go
Last active September 21, 2017 18:16
http_cookie.go
package main
import (
"net/http"
"encoding/base64"
"fmt"
"time"
)
func setMessage(w http.ResponseWriter, r *http.Request) {
@suhanlee
suhanlee / http_json.go
Created September 21, 2017 17:56
http_json.go
package main
import (
"net/http"
"fmt"
"encoding/json"
)
func writeExample(w http.ResponseWriter, r *http.Request) {
str := `<html>