Skip to content

Instantly share code, notes, and snippets.

@mayosuke
mayosuke / command line memo
Last active October 12, 2015 06:47
command line memo
# hcidump -R の出力を改行無しにする
sudo hcidump -i hci0 -R | ruby -ne 'BEGIN{l = ""}; $_.strip!; if $_[0] == ">" then puts l; l = $_ else l << " " << $_ end'
# ruby one-liner
ruby -E UTF-8 -ne "print $_ if $_.include? 'hoge' or $_.include? 'fuga'" strings.xml
# gitリポジトリが管理するファイルのリスト表示
git ls-files
# gitリポジトリのログをツリー表示
# Run directly from github
# ruby -e "$(curl https://raw.github.com/gist/3962976/)"
randam = rand(10)
while true do
input = gets
number = input[0..-1].to_i
if number == randam
puts 'hit!'
break
@mayosuke
mayosuke / openGmailEditPage
Created August 13, 2012 03:53
本文欄にWebサイトのタイトル、URLをセットしてGMail作成画面を起動するブックマークレット。
javascript:(function(){
d = document;
w = window;
if (d.selection) {
s = d.selection.createRange().text;
} else if (w.getSelection) {
s = w.getSelection();
} else if (d.getSelection) {
s = d.getSelection();
};
@mayosuke
mayosuke / simplewebserver.js
Created January 12, 2012 18:04
This simple web server written in Node responds with "Hello World" for every request from nodejs.org.
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');