Skip to content

Instantly share code, notes, and snippets.

Avatar

Fuminori Sakamoto goldeneggg

View GitHub Profile
@goldeneggg
goldeneggg / attribute_convertable.rb
Created Oct 7, 2015
属性値の設定時に自動変換を行うconcern module
View attribute_convertable.rb
module AttributeConvertable
extend ActiveSupport::Concern
included do
# 全角英数字を半角英数字に変換
#
# (使用例.modelの定義)
# downcase_attr :hoge
#
# (使用例.modelへの値設定)
@goldeneggg
goldeneggg / slackrtm.go
Created Aug 3, 2015
WebSocket message receiver client for Slack
View slackrtm.go
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
@goldeneggg
goldeneggg / gocon2015s.md
Last active Aug 29, 2015
gocon 2015 summer のメモ
View gocon2015s.md

gocon2015s

https://github.com/GoCon/GoCon/blob/master/2015summer.rst

Prepare

  • rakyll/boom (ベンチマークツール) のコード読み
  • mholt/caddy (HTTP2サーバ) のコード読み
  • yhat/scrape (超シンプルwebスクレイパ) のコード読み
  • golang.org/x/ パッケージの最近の状況把握
@goldeneggg
goldeneggg / stdin
Created Jun 18, 2015
rails本体のテストコードっぽいファイル一覧
View stdin
./actionmailer/bin/test
./actionmailer/lib/action_mailer/test_case.rb
./actionmailer/lib/action_mailer/test_helper.rb
./actionmailer/test/fixtures/attachments/test.jpg
./actionmailer/test/test_case_test.rb
./actionmailer/test/test_helper_test.rb
./actionpack/bin/test
./actionpack/lib/action_controller/metal/testing.rb
./actionpack/lib/action_controller/test_case.rb
./actionpack/lib/action_dispatch/testing/test_process.rb
@goldeneggg
goldeneggg / grep.Body.Close.txt
Last active Mar 11, 2019
Go 1.4.2, grep "Body.Close"
View grep.Body.Close.txt
cmd/go/http.go-28-func httpGET(url string) ([]byte, error) {
cmd/go/http.go-29- resp, err := httpClient.Get(url)
cmd/go/http.go-30- if err != nil {
cmd/go/http.go-31- return nil, err
cmd/go/http.go-32- }
cmd/go/http.go:33: defer resp.Body.Close()
cmd/go/http.go-34- if resp.StatusCode != 200 {
cmd/go/http.go-35- return nil, fmt.Errorf("%s: %s", url, resp.Status)
cmd/go/http.go-36- }
cmd/go/http.go-37- b, err := ioutil.ReadAll(resp.Body)
@goldeneggg
goldeneggg / asanaevents.rb
Created May 20, 2015
asanaの新規タスク情報を取得するスクリプト
View asanaevents.rb
require "json"
require "net/http"
require "uri"
require "pathname"
require "pp"
class AsanaEvents
BASE_URI = "https://app.asana.com/api/1.0"
SYNC_SAVE_PATH = "#{ENV['HOME']}/.asana_events_api/sync.txt"
@goldeneggg
goldeneggg / trendsearcher.coffee
Created Mar 17, 2015
trend search by otter API
View trendsearcher.coffee
# Description:
# Trend search by otter API
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
View color.sh
#!/bin/sh
# fg
for i in {0..255} ; do
printf "\x1b[38;05;${i}mcolor${i}\n"
done
echo ''
# bg
for i in {0..255} ; do
View mangos_demo.go
package main
import (
"fmt"
"os"
"time"
"github.com/gdamore/mangos"
"github.com/gdamore/mangos/protocol/pub"
"github.com/gdamore/mangos/protocol/sub"
@goldeneggg
goldeneggg / Vagrantfile
Last active Aug 29, 2015
template of Vagrantfile
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
# config
$docker_port = 4243
$go_version = "1.4"