Skip to content

Instantly share code, notes, and snippets.

View msakai's full-sized avatar

Masahiro Sakai msakai

View GitHub Profile
@araipiyo
araipiyo / speed.rb
Created June 1, 2014 06:27
measure speed of HTTP GET at any particular site.
require 'net/http'
require 'uri'
url = URI.parse(ARGV[0])
http = Net::HTTP.new(url.host, url.port)
path = url.path != '' ? url.path : '/'
path += url.query ? "?#{url.query}" : ""
secs = []
@msakai
msakai / fakecoin.als
Created January 13, 2011 00:29
贋金パズルのAlloyモデル
// 失敗版
sig Coin {}
abstract sig State {
  candidates : set Coin,
}
sig Branch extends State {
  left, right : set Coin, 
  eq, lt, gt : State
@etale
etale / tropical.rb
Created October 4, 2011 05:48
an implementation of complex numbers with tropical flavor
# tropical.rb
# an implementation of complex numbers with tropical flavor
#
# self == e^{ord + 2 \pi i arg}
class Class
def get *args, &block
(new *args, &block).identity
end
end
@etale
etale / alg.rb
Last active September 27, 2015 17:47
an implementation of adeles
def not_implemented
puts "#{inspect} : #{self.class}"
raise NotImplementedError
end
$radix ||= 10 # 2 <= $radix <= 36
$adic ||= 10**4 # 2 <= $adic
$delim ||= ',' # or '|', etc.
$type ||= :arch # or :adic
$prec ||= 4 # default precision
@spake
spake / crypto400.md
Last active October 23, 2015 08:51
Trend Micro CTF 2015: Crypto 400

We get a single file, document.xbm, which looks like an XBM image (a strange old file format that encodes images inside C strings). In our case, we have three arrays of bytes: bits, metadata1, and metadata2.

#define ________________width 1024
#define ________________height 540

static unsigned char ________________bits[] =
{
  0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1, 0x00, 0x00,
 ...
#!/bin/env python -u
import random
from os import environ, listdir, path
from sys import exit
from subprocess import Popen, PIPE
import signal
from base64 import b64decode
def alarm_handler(signum, frame):
print "timed out, sorry"
@willwade
willwade / citeusync.py
Last active April 7, 2019 01:48
inspired by the perl version - but not quite the same. Simply use to download your bibtex file and attachments on a regular basis. NB: Only downloads the PDF if not already present so technically only 2 calls at a minimum to CUL (Login and download of bibtex. Obviously a lot more if downloading the PDFs). If more than one attachment - will only …
#!/usr/bin/env python
# Contact: Will Wade willwa.de
# Date: April 2013
# Needs mechanize and pybtex
#
# NB: Little error checking going on in this script
# TO-DO: Check last-download-date of bibtex file later than last-modified date on CUL. ? possible
#
# With thanks to https://pypi.python.org/pypi/citeulike_api/0.1.3dev for the login part
import mechanize
@rummelonp
rummelonp / mm2bl.rb
Created June 16, 2012 08:41
メディアマーカーの CSV をブクログ形式にするやつ
# -*- coding: utf-8 -*-
#
# メディアマーカーの CSV をブクログ形式にするやつ
# 使い方
# ruby mm2bl.rb /path/to/MediaMarkerExport.csv > output.csv
# 参考
# http://d.hatena.ne.jp/Unicellular/20120507/1336411135
require 'csv'
@koyhoge
koyhoge / gist:20b4570adcfc2bcab5da
Last active November 23, 2019 09:40
エンジニアのための法律勉強会 #3『判例に学ぶ、納期遅延と瑕疵担保責任についての注意事項』参加メモ

エンジニアのための法律勉強会 #3『判例に学ぶ、納期遅延と瑕疵担保責任についての注意事項』参加メモ

  • 日時: 2015-04-123 19:15-20:50
  • 講師: 野島 梨恵氏 (東京山王法律事務所)
  • 場所: Co-Edo

http://bit.ly/co-edo-2015-04-23-doc

  • 初参加の方が半分くらい