Skip to content

Instantly share code, notes, and snippets.

View kaosf's full-sized avatar
🏠
Working from home

ka kaosf

🏠
Working from home
View GitHub Profile
@kaosf
kaosf / ka-aliases.rb
Last active December 19, 2015 23:58
"ka's aliases"; earthquake.gem's plugin; ref. http://bko.hateblo.jp/entry/2012/04/28/151017
Earthquake.alias_command ':r', ':retweet'
Earthquake.alias_command ':f', ':favorite'
Earthquake.alias_command ':re', ':recent'
Earthquake.alias_command ':m', ':mentions'
Earthquake.alias_command ':o', ':open'
Earthquake.alias_command ':br', ':browse'
Earthquake.alias_command ':del', ':delete'
Earthquake.alias_command ':rm', ':delete'
Earthquake.init do
command :fr do |m|
target = twitter.status(m[1])
if confirm("fav & RT '@#{target["user"]["screen_name"]}: #{target["text"]}'")
async_e {
twitter.retweet(m[1])
twitter.favorite(m[1])
}
end
end
@kaosf
kaosf / file0.txt
Created July 31, 2013 10:08
Git で最新のコミットのコミットログの summary を取得 ref: http://qiita.com/ka_/items/f434fb7ce1334ac54930
git log -1 --oneline | cut -b 9-
<root>
<tag1>body1</tag1>
<tag2>
<tag21>body21</tag21>
<tag22>body22</tag22>
</tag2>
</root>
@kaosf
kaosf / xml-seq-return-seq.clj
Created August 11, 2013 14:31
(= (xml-seq x) (seq (xml-seq x)))
(let [[a1 a2 _] (let [x (xml-seq (clojure.xml/parse (clojure.java.io/input-stream (java.net.URI. "https://gist.github.com/kaosf/6205132/raw/17a803a4cd7e816698fde5b30552a77272a2b507/sample.xml"))))] (clojure.data/diff x (seq x)))] (and (nil? a1) (nil? a2)))
@kaosf
kaosf / xml-seq-return-seq.clj
Created August 11, 2013 15:23
(= (xml-seq x) (seq (xml-seq x)))
(do
(require 'clojure.xml 'clojure.data)
(let
[[a1 a2 _]
(let
[x
(xml-seq
(clojure.xml/parse
(clojure.java.io/input-stream
(java.net.URI. "https://gist.github.com/kaosf/6205132/raw/17a803a4cd7e816698fde5b30552a77272a2b507/sample.xml"))))]
@kaosf
kaosf / xml-seq-equals-to-seq.clj
Created August 11, 2013 16:53
`(= (xml-seq x) (seq (xml-seq x)))` returns true?
(do
(require 'clojure.xml 'clojure.data)
(let
[x
(xml-seq
(clojure.xml/parse
(clojure.java.io/input-stream
(java.net.URI. "https://gist.github.com/kaosf/6205132/raw/17a803a4cd7e816698fde5b30552a77272a2b507/sample.xml"))))]
(= x (seq x))))
@kaosf
kaosf / xml-seq-equals-to-seq-with-left-to-right-operator.clj
Created August 11, 2013 16:59
`(= (xml-seq x) (seq (xml-seq x)))` returns true? Implement with ->> (left to right) operator.
(do
(require 'clojure.xml 'clojure.data)
(let
[x
(->> (java.net.URI. "https://gist.github.com/kaosf/6205132/raw/17a803a4cd7e816698fde5b30552a77272a2b507/sample.xml") clojure.java.io/input-stream clojure.xml/parse xml-seq)]
(= x (seq x))))
@kaosf
kaosf / autohash.rb
Last active April 6, 2017 10:24
"autohash"; earthquake.gem's plugin; add hash tags to the tails of a tweet automatically; ref. https://github.com/kaosf/earthquake-plugin-autohash
class HashTagsManager
def filepath
"#{ENV['HOME']}/.earthquake/autohash"
end
def save(hashtags)
File.open filepath, 'w' do |f|
f.puts hashtags
end
end
@kaosf
kaosf / can-create-heroku-app-with-the-name-of
Created August 17, 2013 02:07
check whether the heroku app with specified name can be created or not; http://qiita.com/ka_/items/e0aeb4741d3862013336
#! /bin/sh
[ 1 = $(curl $1.herokuapp.com 2> /dev/null | grep "<h1><strong>Heroku | No such app</strong></h1>" | wc -l) ]