Skip to content

Instantly share code, notes, and snippets.

@zunda
zunda / git-prompt.sh.say.patch
Created August 5, 2014 10:04
OSXでプロンプトを表示するたびにGItブランチ名をしゃべる。うるさいし遅い。
--- git-prompt.sh.orig 2014-08-04 23:48:33.000000000 -1000
+++ git-prompt.sh 2014-08-05 00:02:38.000000000 -1000
@@ -439,7 +439,8 @@
fi
local f="$w$i$s$u"
- local gitstring="$c${b##refs/heads/}${f:+$z$f}$r$p"
+ local branchname=${b##refs/heads/}
+ local gitstring="$c$branchname${f:+$z$f}$r$p"
@zunda
zunda / solution.txt
Created August 30, 2014 00:28
9x9にトロミノを敷き詰めるやりかた
MMNNOPPQQ
JMKNOOPLQ
JJKKHHLLI
DDEEFHGII
ADBEFFGGC
AABB899CC
556688977
051623347
001122344
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char *p = "hello world";
free(p);
return 0;
}
require 'prime'
max = 0
begin
Prime.each{|i| max = i}
rescue Exception => e
puts e
puts max
end
# http://docs.ruby-lang.org/en/2.1.0/Prime/EratosthenesSieve.html#method-i-compute_primes
require 'prime'
class Prime
class EratosthenesSieve
attr_reader :primes, :max_checked # tested with ruby 2.1.2p95
end
end
puts "#prime-number table-size"
@zunda
zunda / cap
Last active August 29, 2015 14:13 — forked from wuputah/cap
#!/bin/sh
scrot -s -e 'cloudapp $f; rm $f'
@zunda
zunda / test.c
Last active August 29, 2015 14:15
No child process
$ gcc -o test test.c
$ ./test
output from perror(): No child processes
@zunda
zunda / dmesg
Created April 2, 2015 17:59
Connected a Microsoft Band
[ 329.308238] usb 1-2.1.3: new full-speed USB device number 8 using ehci-pci
[ 329.380222] usb 1-2.1.3: device descriptor read/64, error -32
[ 329.556337] usb 1-2.1.3: device descriptor read/64, error -32
[ 329.732304] usb 1-2.1.3: new full-speed USB device number 9 using ehci-pci
[ 329.804319] usb 1-2.1.3: device descriptor read/64, error -32
[ 329.980298] usb 1-2.1.3: device descriptor read/64, error -32
[ 330.156273] usb 1-2.1.3: new full-speed USB device number 10 using ehci-pci
[ 330.564090] usb 1-2.1.3: device not accepting address 10, error -32
[ 330.636338] usb 1-2.1.3: new full-speed USB device number 11 using ehci-pci
[ 331.044080] usb 1-2.1.3: device not accepting address 11, error -32
@zunda
zunda / to-utf8.rb
Created April 20, 2015 19:32
Convert `data` into UTF-8 if it was in EUC-JP. Crappy-ish.
begin
data.force_encoding(Encoding::EUC_JP)
data.encode!(Encoding::UTF_8)
rescue Encoding::InvalidByteSequenceError
data.force_encoding(Encoding::UTF_8)
end
@zunda
zunda / dmesg
Created May 3, 2015 22:21
Booting Dell Latitude E-4200 with xubuntu 15.04
[ 3.991676] b43-phy0: Broadcom 4312 WLAN found (core revision 15)
[ 4.021524] b43-phy0: Found PHY: Analog 6, Type 5 (LP), Revision 1
[ 4.021544] b43-phy0: Found Radio: Manuf 0x17F, ID 0x2062, Revision 2, Version 0
[ 4.030371] kvm: disabled by bios
[ 4.032490] Broadcom 43xx driver loaded [ Features: PNL ]
[ 4.040083] b43 ssb0:0: Direct firmware load for b43/ucode15.fw failed with error -2
[ 4.040115] b43 ssb0:0: Direct firmware load for b43/ucode15.fw failed with error -2
[ 4.040146] b43 ssb0:0: Direct firmware load for b43-open/ucode15.fw failed with error -2
[ 4.040163] b43 ssb0:0: Direct firmware load for b43-open/ucode15.fw failed with error -2
[ 4.040169] b43-phy0 ERROR: Firmware file "b43/ucode15.fw" not found