Skip to content

Instantly share code, notes, and snippets.

@babie
babie / api.js
Last active August 19, 2017 07:25
simple rest fetch api
import 'whatwg-fetch'
import store from './store'
function _buildUrl (path, query) {
let url = path
if (query !== undefined) {
let queryArray = []
for (const key of Object.keys(query)) {
queryArray = [...queryArray, `${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`]
}
@babie
babie / books_suite_test.go
Last active April 12, 2017 01:36
Use stretchr/testify/assert on onsi/ginkgo without onsi/gomega.
package books_test
import (
. "github.com/onsi/ginkgo"
//. "github.com/onsi/gomega"
ta "github.com/stretchr/testify/assert"
"testing"
)

Clojureを勉強している12

  • Clojure Documentation
    • ClojureDocs
      • 関数名やマクロ名で検索できる
      • See Alsoセクションが似たような機能の関数を集めていて便利
      • Quick Referenceもまた便利。チートシートだ。
    • Grimoire
      • チートシートになってる。
  • clojure/clojure
@babie
babie / .zshrc
Last active December 27, 2015 08:39
earthquake () {
/usr/bin/ssh -t dev 'socat STDIN,echo=0,icanon=0 SYSTEM:"reptyr $(cat /tmp/earthquake.pid)",pty,stderr,ignbrk=1'
sleep 20
earthquake
}
@babie
babie / pty-keeper
Last active December 27, 2015 08:39
#!/usr/bin/env ruby
require "pty"
require "optparse"
require "tmpdir"
module PtyKeeper
module Core
def parse!(argv)
options = {}
description "earthquake server"
author "babie wildheart <babie@example.com>"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
setuid babie
description "earthquake server"
author "babie wildheart <babie@example.com>"
# start,stopは正常に動くがsocat&reptyrで繋いだ時、文字入力に不具合がある
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
description "earthquake server"
author "babie <babie@example.com>"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
setuid babie
# Earthquake.config[:event_chain] = {
# :favorite => [':retweet %{id}'],
# :favorited => [':update @%{him} thx 4 ur fav!'],
# :followed => ['unblock %{him}', ':follow %{him}'],
# }
module Earthquake::Input
def passivise(str)
if str.end_with?("ed")
str
elsif str.end_with?("e")
require "date"
Earthquake.init do
_ = config[:save_image] ||= {}
_[:dir] ||= File.expand_path("./image", config[:dir])
FileUtils.mkdir_p(_[:dir]) unless Dir.exist? _[:dir]
command :save_image do |m|
tweet = twitter.status(m[1])
media = tweet["entities"]["media"]