Skip to content

Instantly share code, notes, and snippets.

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

kyle suhanlee

:octocat:
Focusing
View GitHub Profile
require 'thread'
require 'json'
require 'fiber'
require 'eventmachine'
require 'em-http-request'
module Async
class Request
attr_accessor :url, :body
@suhanlee
suhanlee / form1.go
Last active March 21, 2019 01:45
http
package main
import (
"net/http"
"fmt"
)
func process(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
fmt.Fprintln(w, r.Form)
@suhanlee
suhanlee / file_upload.go
Created September 21, 2017 17:37
file_upload.go
package main
import (
"net/http"
"io/ioutil"
"fmt"
)
func process_multipart_form(w http.ResponseWriter, r *http.Request) {
r.ParseMultipartForm(1024)
@suhanlee
suhanlee / http_redirect.go
Created September 21, 2017 17:52
http_redirect.go
package main
import (
"net/http"
"fmt"
)
func writeExample(w http.ResponseWriter, r *http.Request) {
str := `<html>
<head><title>hello</title></head>
@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>
@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 / 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 / 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
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 / 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