This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# print 'next' field of object(by chain) | |
# | |
# usage: | |
# (gdb)pnext ptr (equals to 'print ptr->next') | |
# (gdb)ENTER (equals to 'ptr->next->next') | |
define pnext | |
init-if-undefined $a = $arg0 | |
init-if-undefined $b = $arg0 | |
# 0 means initialize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
showbranch='git br 2>&1 | ruby -ne "if /\* (.*)/ =~ \$_.chomp; print \$1; end"' | |
export PS1='$('"${showbranch}"')' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function xhr(callback) { | |
console.log('now requesting...'); | |
setTimeout(function () { | |
var response = { | |
status: '200' | |
}; | |
callback(response); | |
}, 1000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Ult::Server; | |
use strict; | |
use warnings; | |
use IO::Socket::INET; | |
use Plack::Util; | |
use Plack::HTTPParser qw( parse_http_request ); | |
use constant MAX_REQUEST_SIZE => 131072; | |
sub new { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
interval_sec=1 | |
say_rate=240 # words/minute | |
while : | |
do | |
number=$RANDOM # RANDOM is between 0 and 32767 in bash | |
say -r ${say_rate} ${number} | |
sleep ${interval_sec} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pbpaste | perl -pne 's/ | |
/\n/g' | perl -pne 's/\t/ | /g; s/(.*)/| $1 |/' | pbcopy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import re | |
import lldb | |
def lsview(debugger, command, result, internal_dict): | |
root_view = _get_root_view() | |
view_hierarchy = get_view_hierarchy(root_view) | |
print_view_hierarchy(view_hierarchy) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "System Preferences" | |
activate | |
set the current pane to pane "Bluetooth" | |
end tell | |
tell application "System Events" | |
tell process "System Preferences" | |
click (menu button of splitter group of group of window 1) | |
click ((menu item "Update Services") of menu of menu button of splitter group of group of window 1) | |
end tell | |
end tell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PAPER=shuuron | |
OUTPUT_DIR=out | |
# TeX commands | |
TEX=platex | |
TEX_OPTIONS=-kanji=utf8 -output-directory=$(OUTPUT_DIR) | |
DVI2PDF=dvipdfmx | |
DVI2PDF_OPTIONS=-o $(OUTPUT_DIR)/$(PAPER).pdf | |
BIBTEX=pbibtex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <math.h> | |
#define FIXED_BIT 12 | |
unsigned short int float2fix(float n) | |
{ | |
unsigned short int int_part = 0, frac_part = 0; | |
int i; | |
float t; |
OlderNewer