Skip to content

Instantly share code, notes, and snippets.

@zunda
zunda / gist:1156261
Created August 19, 2011 07:30
A code not to create zombies
static void sigchld(int x);
static void
sigchld(int x __attribute__ ((unused)))
{
while(waitpid(-1, NULL, WNOHANG) > 0);
signal(SIGCHLD, sigchld);
}
@zunda
zunda / gist:1279201
Created October 11, 2011 19:53
Galaxy Tab 10.1にUSBで給電している時のlogcat
D/BatteryService( 282): update start
D/KeyguardUpdateMonitor( 282): received broadcast android.intent.action.BATTERY_CHANGED
D/KeyguardUpdateMonitor( 282): handleBatteryUpdate
D/KeyguardUpdateMonitor( 282): isBatteryUpdateInteresting(batteryStatus = 3, mBatteryStatus =3, batteryLevel=96
D/KeyguardUpdateMonitor( 282): isBatteryUpdateInteresting(stateChangedWhilePluggedIn = false, isPluggedIn =false, isPluggedIn=false
D/BatteryService( 282): level:96 scale:100 status:3 health:2 present:true voltage: 4 temperature: 302 technology: Li-ion AC powered:false USB powered:true icon:17302740 invalid charger:0
D/WifiService( 282): ACTION_BATTERY_CHANGED pluggedType: 2
W/PowerManagerService( 282): Timer 0x3->0x3|0x0
@zunda
zunda / gist:1279245
Created October 11, 2011 20:05
Galaxy Tab 10.1につないでるとddmsが落ちる
10:03:25 E/ddms: shutting down due to uncaught exception
10:03:25 E/ddms: Failed to execute runnable (java.lang.IllegalArgumentException: Index out of bounds)
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.IllegalArgumentException: Index out of bounds)
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Unknown Source)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at com.android.ddms.UIThread.runUI(UIThread.java:492)
at com.android.ddms.Main.main(Main.java:103)
@zunda
zunda / follow-redirect.rb
Created November 21, 2011 20:31
follow-redirect.rb: checks where shortened URLs are going
#!/usr/bin/ruby
# redirect.rb: checks where shortened URLs are going
#
# usage: ruby redirect.rb http://example.com/
# shows URLs while being redirected
#
# Copyright 2011 (C) zunda <zunda at freeshell.org>
#
# Permission is granted for use, copying, modification,
# distribution, and distribution of modified versions of this
@zunda
zunda / arp.rb
Created December 7, 2011 07:15
A script to create byte sequence of an arp packet. This can not emit packet onto the network.
#!/usr/bin/env ruby
# asks for IP address of a MAC address
#
# Copyright (c) 2011 zunda <zunda at freeshell.org>
#
# Permission is granted for use, copying, modification,
# distribution, and distribution of modified versions of this
# work as long as the above copyright notice is included.
#
@zunda
zunda / gist:1678424
Created January 25, 2012 20:19
Momonga 7のetoysのウインドウの大きさが小さくならないようにする
--- /usr/bin/etoys 2010-09-01 13:36:27.000000000 -1000
+++ ./etoys 2012-01-25 10:18:26.000000000 -1000
@@ -5,7 +5,7 @@
# with the etoys.image
VM="/usr/bin/squeak"
-VMOPTIONS="-encoding UTF-8 -vm-display-x11 -xshm"
+VMOPTIONS="-encoding UTF-8 -vm-display-x11"
IMAGE="/usr/share/etoys/etoys.image"
IMOPTIONS=""
require "open-uri"
urls = %w(
http://pastebin.com/raw.php?i=Kc9ng18h
http://pastebin.com/raw.php?i=vCMndK2L
http://pastebin.com/raw.php?i=JdQkuYwG
http://pastebin.com/raw.php?i=fw43srjY
)
passwords = Hash.new{|h, k| h[k] = Array.new}
require "open-uri"
lookfor = Regexp.new("(?:#{ARGV.map{|s| Regexp.escape(s)}.join('|')}).*:", Regexp::IGNORECASE)
%w(
http://pastebin.com/raw.php?i=Kc9ng18h
http://pastebin.com/raw.php?i=vCMndK2L
http://pastebin.com/raw.php?i=JdQkuYwG
http://pastebin.com/raw.php?i=fw43srjY
).each do |url|
@zunda
zunda / gist:2920616
Created June 12, 2012 22:48
DynDNSがプライベートIPアドレスを指すようになっちゃった時のルータのログ
Jan/1/2000 00:00:02 WAN DHCP client send DHCP Discover
Jan/1/2000 00:00:07 WAN DHCP client send DHCP Discover
Jan/1/2000 00:00:08 WAN DHCP client receive DHCP Offer
Jan/1/2000 00:00:08 WAN DHCP client send DHCP Request
Jan/1/2000 00:00:09 WAN DHCP client receive DHCP Ack
Jan/1/2000 00:00:09 WAN DHCP client get IP 192.168.100.10
Jan/1/2000 00:00:31 WAN DHCP client send DHCP Release
Jan/1/2000 00:00:31 WAN DHCP client send DHCP Discover
Jan/1/2000 00:00:32 WAN DHCP client send DHCP Discover
Jan/1/2000 00:00:32 WAN DHCP client receive DHCP Offer
@zunda
zunda / csv2psv.rb
Created June 14, 2012 03:10
カンマ区切りのファイルをパイプ区切りのファイルに変換する。データにパイプがあると変になるよ
#!/usr/bin/ruby
# usage: ruby csv2psv.rb path-to.csv > path-to.psv
#
# Copyright 2012 (C) zunda <zunda at freeshell.org>
#
# Permission is granted for use, copying, modification,
# distribution, and distribution of modified versions of this
# work as long as the above copyright notice is included.
require 'csv'