Skip to content

Instantly share code, notes, and snippets.

View jyukutyo's full-sized avatar

Koichi Sakata jyukutyo

View GitHub Profile
ps axo "rss,ucomm" | awk '/Geek/ {printf "%.2f", $1/1024}'
ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{print ("System Battery: ",$10/$5 * 100,"%")}';
osascript -e 'set a to do shell script "ioreg -w0 -l | grep Capacity"' -e "set h to word 5 of a" -e "set z to word 33 of a" -e "set b to word 38 of a" -e "set c to 1000 * b / z" -e "set d to round c" -e "set f to d / 10" -e "set q to 1000 * h / b" -e "set w to round q" -e "set j to w / 10" -e '"Battery Health: " & j &"%"' | iconv -f utf-8 -t ucs-2-internal;
ioreg -w0 -l | grep "Cycle Count" | awk 'BEGIN { FS = "=" } ; {print $8}' | awk 'BEGIN { FS = "}" } ; {print $1, "Cycles"}';
tbatt=`ioreg -c BNBTrackpadDevice | grep BatteryPercent | tail -1|awk '{print $10}'`;
if [ ${#tbatt} -lt 1 ]; then
echo "Magic Trackpad: disconnected"
else
echo "Magic Trackpad Battery: $tbatt%"
top -l 1 | awk '/PhysMem/ {print "" $8 " "}' ;
ps -amcwwwxo "command %mem %cpu" | grep -v grep | head -19
@jyukutyo
jyukutyo / elscreen.patch
Created November 16, 2011 01:54
$ diff elscreen-1.4.6.el elscreen-1.4.6-5.el.https://launchpad.net/ubuntu/+source/elscreen/1.4.6-5
35a36,40
> (defun elscreen-booleanp (value)
> "Return t if VALUE is boolean.
> This implements GNU Emacs 22.1's `booleanp' function in earlier Emacs.
> This function may be removed when Emacs 21 is no longer supported."
> (or (equal value t) (equal value nil)))
136c141
< (when (or (booleanp value)
---
> (when (or (elscreen-booleanp value)
@jyukutyo
jyukutyo / gist:2506746
Created April 27, 2012 07:01
どのGCが使われているか表示する
import java.lang.management.*;
import java.util.List;
public class GC {
public static void main(String args[]) {
List<GarbageCollectorMXBean> l = ManagementFactory.getGarbageCollectorMXBeans();
for (GarbageCollectorMXBean b : l) {
System.out.println(b.getName());
}
}
@jyukutyo
jyukutyo / gist:2692509
Created May 14, 2012 07:43
UbuntuでAndroidのデバイスをを登録する
-- super userで実行する
# echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="ベンダーID", MODE="0666", GROUP="plugdev"' > /etc/udev/rules.d/51-android.rules
# chmod a+r /etc/udev/rules.d/51-android.rules
-- 一般ユーザでもよい
$ ./adb kill-server
$ sudo ./adb start-server
@jyukutyo
jyukutyo / post-commit.rb
Created June 21, 2012 07:38
SubversionのコミットフックでJenkinsのジョブを起動する
#!/bin/env ruby
# -*- coding: utf-8 -*-
require 'net/http'
def get_the_latest_changed_file(repos, rev)
IO.popen(sprintf('/usr/local/bin/svnlook changed %s -r %s', repos, rev)) {|io|
# 最初の行を返す
io.gets
@jyukutyo
jyukutyo / gist:2964416
Created June 21, 2012 07:39
Rubyスクリプトを呼び出すSubversionのpost-commitフック
#!/bin/sh
REPOS="$1"
REV="$2"
ruby $REPOS/hooks/post-commit.rb "$REPOS" "$REV"
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration that checks the sun coding conventions from:
- the Java Language Specification at