Skip to content

Instantly share code, notes, and snippets.

View chunkof's full-sized avatar

chunkof chunkof

View GitHub Profile
package main
import (
"fmt"
"sync"
)
type CrawledUrls struct {
v map[string]int
mux sync.Mutex
package main
import (
"fmt"
"golang.org/x/tour/tree"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader
@chunkof
chunkof / exercise-fibonacci-closure.go
Created May 19, 2018 20:50
Exercise: Fibonacci closure
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
n := 0
history := []int{0, 1}
return func() int {
@chunkof
chunkof / lambda_function.py
Last active September 10, 2016 08:33
copy_s3
from __future__ import print_function
import json
import boto3
import os
print('Loading function')
def lambda_handler(event, context):
print("Received event: " + json.dumps(event, indent=2))
# -*- coding:utf-8 -*-
import os
import boto3
import tweepy
import datetime
s3 = boto3.client('s3')
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
@chunkof
chunkof / file0.txt
Last active June 20, 2016 05:06
EC2にApacheでPython動かした時の覚書 ref: http://qiita.com/chunkof/items/e80129ea93dcfb6e6d61
$ sudo yum install httpd
@chunkof
chunkof / file1.txt
Last active August 3, 2017 01:42
EC2にnginx+uwsgi+python でHello World ref: http://qiita.com/chunkof/items/6c9d4b01f0057a9a8de0
uwsgi/
index.py # 実行ソース
uwsgi.ini  # 設定ファイル
uwsgi.log # ログ出力先
uwsgi.pid  # プロセスid出力先
@chunkof
chunkof / config.ini
Last active June 5, 2016 10:59
python .ini test
[last_modified]
year = 2016
month = 6
day = 5
hour = 19
minute = 58
@chunkof
chunkof / asyncsample.es6
Last active February 20, 2016 10:53
asyncサンプル
// TimeCounter
class TimeCounter{
constructor(symbol, delays){
this.symbol = symbol;
this.delays = delays;
}
async execute(){
for (let i=0; i<this.delays.length; ++i){
const delay = this.delays[i];
await TimeCounter.wait(delay);