Skip to content

Instantly share code, notes, and snippets.

キティ・ホワイト
ぼんぼんりぼん (127)
ダニエル・スター (122)
ポムポムプリン (103)
マイメロディ (74)
しろうさ&くろうさ (68)
----
マイメロディ
クロミ (95)
ポムポムプリン (83)
require 'mechanize'
agent = Mechanize.new
agent.user_agent = 'iPhone (Ruby; http://greeting.sucretown.net/)'
index_page = agent.get('http://www.puroland.co.jp/today/atr/sp.asp')
p t = index_page.search('div[align="center"]').children[2].text
p t =~ /\A[\s ]*\((?<year>\d+)年0?(?<month>\d+)月0?(?<day>\d+)日\s*0?(?<hour>\d+):0?(?<minute>\d+)\s*現在\)s*\z/
p time = Time.local(Integer($~[:year]), Integer($~[:month]), Integer($~[:day]), Integer($~[:hour]), Integer($~[:minute]))
@mono0x
mono0x / cpuaffinity.rb
Created October 22, 2013 14:06
Set CPU Affinity
class CPUAffinity
def self.set_affinity(mask, pid = Process.pid)
system "taskset -p 0x#{mask.to_s(16)} #{pid}"
end
end
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\*\Shell]
[HKEY_CURRENT_USER\Software\Classes\*\Shell\Vim]
@="Vimで開く(&V)"
[HKEY_CURRENT_USER\Software\Classes\*\Shell\Vim\command]
@="D:\\Documents\\tools\\vim\\gvim.exe --remote-silent \"%1\""
@mono0x
mono0x / Makefile
Last active December 17, 2015 04:39
LaTeX
TEX = master.tex
DVI = $(TEX:.tex=.dvi)
PDF = $(TEX:.tex=.pdf)
AUX = $(TEX:.tex=.aux)
TMP = $(TEX:.tex=.bbl) $(TEX:.tex=.blg) $(TEX:.tex=.log)
BIB = $(wildcard *.bib)
PRN = $(wildcard *.prn)
PNG = $(wildcard *.png)
JPG = $(wildcard *.jpg)
EPS = $(PRN:.prn=.eps) $(PNG:.png=.eps) $(JPG:.jpg=.eps)
@mono0x
mono0x / downloadwebsite.sh
Created February 14, 2013 13:11
認証が必要なWebサイトのコンテンツをまとめてダウンロード
#!bin/sh
wget --keep-session-cookies --save-cookies=cookies.txt --post-data 'id=...&password=...' url
wget --load-cookies=cookies.txt -r url
require 'parallel'
module Jekyll
class Site
def render
payload = site_payload
self.posts.zip(Parallel.map(self.posts) {|post|
post.render(self.layouts, payload)
(function($) {
// Used by dateinput
$.expr = {':': {}};
// Used by bootstrap
$.support = {};
// Used by dateinput
$.fn.clone = function(){
var ret = $();
@mono0x
mono0x / paperfortune.rb
Created August 24, 2012 08:59
Paper Fortune
# -*- coding: utf-8 -*-
require 'date'
require 'digest/sha1'
module PaperFortune
def self.paper_fortune(w, *a)
n = w.inject(&:+)
r = Random.new(Digest::SHA1.hexdigest(Marshal.dump(a)).to_i(16)).rand(n)
w.each_index.find {|i| r < w[0..i].inject(&:+) }
@mono0x
mono0x / horoscopes.rb
Created August 24, 2012 03:43
Horoscopes
# -*- coding: utf-8 -*-
require 'date'
module Horoscopes
CONSTELLATIONS = [
:capricorn,
:aquarius,
:pisces,
:aries,