Skip to content

Instantly share code, notes, and snippets.

@yoshimov
yoshimov / gist:9243169
Created February 27, 2014 02:31
Check the encoding of posix spawn standard out in ruby.
ruby -e 'require "posix-spawn"; process=POSIX::Spawn::Child.new("echo a"); o=process.out; puts o.encoding'
@yoshimov
yoshimov / gist:9243285
Created February 27, 2014 02:40
Shell command to create patch file from org file.
find -name *.org | sed 's/\.org$//' | xargs -IF diff -c F.org F
*** ./lib/gollum/helpers.rb.org Thu Feb 27 00:19:51 2014
--- ./lib/gollum/helpers.rb Thu Feb 27 00:20:35 2014
***************
*** 6,12 ****
return nil if file_path.nil?
last_slash = file_path.rindex("/")
if last_slash
! file_path[0, last_slash]
end
end
*** ./lib/gollum-lib/committer.rb.org Thu Feb 27 00:23:14 2014
--- ./lib/gollum-lib/committer.rb Thu Feb 27 00:24:20 2014
***************
*** 118,124 ****
end
end
! fullpath = fullpath.force_encoding('ascii-8bit') if fullpath.respond_to?(:force_encoding)
begin
@yoshimov
yoshimov / Dockerfile
Last active August 29, 2015 13:56
Dockerfile for multibyte enabled Gollum
# Docker file for multibyte enabled Gollum 2.7.0
#
# To build new image:
#
# > sudo docker build -t gollum-server:2.7.0 .
#
# To run the image:
#
# > git init /home/hoge
# > cd /home/hoge
@yoshimov
yoshimov / notifyIssues.js
Last active August 29, 2015 13:57
Notify specific web page periodically using GAS
function notifyIssues() {
var issueurl = PropertiesService.getScriptProperties().getProperty("issueurl");
var toaddress = PropertiesService.getScriptProperties().getProperty("mailaddress");
var httpuser = PropertiesService.getScriptProperties().getProperty("httpuser");
var httppass = PropertiesService.getScriptProperties().getProperty("httppassword");
var subject = PropertiesService.getScriptProperties().getProperty("subject");
var header = PropertiesService.getScriptProperties().getProperty("header");
var passenc = Utilities.base64Encode(httpuser + ":" + httppass);
var response = UrlFetchApp.fetch(issueurl, {"headers": {"Authorization": "Basic " + passenc}});
var content = response.getContentText();
@yoshimov
yoshimov / gist:9543617
Created March 14, 2014 07:48
Obtain email hash for gravatar using ruby.
ruby -e "require 'digest/md5';a='hoge';puts Digest::MD5.hexdigest(a.strip.downcase);"
@yoshimov
yoshimov / Dockerfile
Last active August 29, 2015 13:57
Docker file for tty.js
# Docker file for tty.js
#
# To build new image:
#
# > sudo docker build -t ttyjs .
#
# To run the image:
#
# > sudo docker run -d -p 8022:8080 -v /home/hoge:/ttyjs ttyjs
@yoshimov
yoshimov / Makefile
Created March 25, 2014 09:15
Makefile for paper with Markdown
# Makefile for paper with Markdown
#
# * Time-stamp: "2014-03-25 18:10:01 nomura"
#
# requires:
# * Cygwin texlive packages
# - texlive
# - texlive-collection-basic
# - texlive-collection-bibtexextra
# - texlive-collection-langcjk
@yoshimov
yoshimov / crontab
Created May 15, 2014 10:06
crontab for synchronizing git repositories every 2 hours.
0 */2 * * * cd /home/hoge/git && (git pull && git push) 2>&1 | grep -v 'up-to-date' | mail -E'set nonullbody' -s "title" somebody@gmail.com