Skip to content

Instantly share code, notes, and snippets.

@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/');
@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();
};
# 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 / 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リポジトリのログをツリー表示
@mayosuke
mayosuke / bl.ocks.org.test
Last active March 13, 2016 02:04 — forked from mbostock/.block
test.
http://bl.ocks.org/mayosuke/151f8c7cf195a72a71ef
[user]
name = Yosuke MIYAJIMA
email = mayo.suke@gmail.com
[core]
editor = vim
excludesfile = ~/.gitignore_global
autocrlf = false
[merge]
tool = vimdiff
[diff]
@mayosuke
mayosuke / argparse.patch
Last active August 13, 2018 09:27
Patch for argparse.py before Python 3.7
--- /home/ec2-user/anaconda3/lib/python3.6/argparse.py 2018-04-29 16:18:42.000000000 +0000
+++ argparse.py 2018-08-13 02:30:36.317112960 +0000
@@ -1064,6 +1064,7 @@
prog,
parser_class,
dest=SUPPRESS,
+ required=False,
help=None,
metavar=None):
@mayosuke
mayosuke / copy-to-clipboard-as-md-link-bookmarklet.md
Last active March 1, 2019 10:40 — forked from stefanmaric/copy-to-clipboard-bookmarklet.md
Create Bookmarklet (browser bookmark that executes Javsacript) to copy a browser window's page title and URL as markdown link style to a clipboard
@mayosuke
mayosuke / gist.md
Last active November 1, 2018 03:39
A command to add a transparent area to a non-square image to make it square and centered

regular expression:

^\s+\"(.*)({.+})(.*)\",*

converted result:

$1●●●$3