Skip to content

Instantly share code, notes, and snippets.

View dm4's full-sized avatar
4️⃣

dm4 dm4

4️⃣
View GitHub Profile
@dm4
dm4 / gist:4070732
Created November 14, 2012 06:56
to henry3716
for i in `seq 102 104`
do
join sum.list $i.list | awk '{print $6=(0.65*($4-$2)^2+($5-$3)^2)^(0.5)}' > $i.out
done
cat *.out > all.out
@dm4
dm4 / submit.sh
Created December 12, 2012 19:15
submit to ml12fall final from remote host
id="your id here"
pw="your password here"
filename="$1"
algo_name="$2"
curl -s -c cookie -d "team_name=${id}&passwd=${pw}&submit=submit" 'http://main.learner.csie.ntu.edu.tw/php/ml12fall/login.php' > /dev/null
curl -s -o output.html -b cookie -F "userfile=@${filename};type=text/plain" -F "algouse=${algo_name}" 'http://main.learner.csie.ntu.edu.tw/php/ml12fall/cal.php'
sed -nE 's/.*(AUC \(first-half\): [0-9\.]+).*/\1/p' output.html
#include <stdio.h>
#include <deque>
#include <map>
#define MAX_CHILD_NUM 10
using namespace std;
typedef struct _obj {
struct _obj *child[MAX_CHILD_NUM];
invoke-virtual v0, v1, v2, Landroid/content/Intent;->putExtra(Ljava/lang/String; Ljava/lang/String;)Landroid/content/Intent;
v0
invoke-virtual v0, v1, v2, Landroid/content/Intent;->putExtra(Ljava/lang/String; Landroid/os/Parcelable;)Landroid/content/Intent;
v0
invoke-virtual v0, v1, Landroid/content/Intent;->setPackage(Ljava/lang/String;)Landroid/content/Intent;
v0
invoke-direct v0, v1, Landroid/content/Intent;-><init>(Ljava/lang/String;)V
v0
new-instance v0, Landroid/content/Intent;
v1
invoke-virtual v0, v1, v5, Landroid/content/Intent;->putExtra(Ljava/lang/String; Ljava/lang/String;)Landroid/content/Intent;
v0
invoke-virtual v0, v1, v2, Landroid/content/Intent;->putExtra(Ljava/lang/String; Landroid/os/Parcelable;)Landroid/content/Intent;
v0
invoke-virtual v0, v1, Landroid/content/Intent;->setPackage(Ljava/lang/String;)Landroid/content/Intent;
v0
invoke-direct v0, v1, Landroid/content/Intent;-><init>(Ljava/lang/String;)V
v0
new-instance v0, Landroid/content/Intent;
v1
@dm4
dm4 / Macros.h
Created February 26, 2013 09:01 — forked from numo16/Macros.h
#define ApplicationDelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate])
#define UserDefaults [NSUserDefaults standardUserDefaults]
#define NotificationCenter [NSNotificationCenter defaultCenter]
#define SharedApplication [UIApplication sharedApplication]
#define Bundle [NSBundle mainBundle]
#define MainScreen [UIScreen mainScreen]
#define ShowNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = YES
#define HideNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = NO
#define NetworkActivityIndicatorVisible(x) [UIApplication sharedApplication].networkActivityIndicatorVisible = x
#define NavBar self.navigationController.navigationBar
# Usage: pr (pull request current branch into develop)
# Usage 2: pr stable (pull request current branch into stable)
function pr() {
base=$1;
if [ "$1" == "" ]; then
base="develop"
fi
hub pull-request -b team:"$base" -h team:`git rev-parse --abbrev-ref HEAD`;
}
@dm4
dm4 / double.c
Created July 24, 2013 18:04
原來 double 是指標啊
#include <stdio.h>
int main(int argc, const char *argv[]) {
double d = 12.34;
printf("d 0x%016x\n", d);
printf("&d 0x%016x\n", &d);
printf("*(long long *)&d 0x%016lx\n", *(long long *)&d);
return 0;
}
# A handy j() function, printing some useful info in bash cmdline
j() {
printf '\n\e[0;35m%(%Y/%m/%d (%a) %H:%M:%S)T\e[0m ' -1
printf '\n\e[0;33m%s@%s\e[0m ' "$USER" "${HOSTNAME/.*/}"
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
local GIT_CLEAN=
local GIT_REF=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
git diff-index --quiet HEAD && GIT_CLEAN=1
@dm4
dm4 / private.xml
Created January 29, 2014 16:14
Leaf RSS Reader j / k key binding using KeyRemap4Macbook
<?xml version="1.0"?>
<root>
<appdef>
<appname>Leaf</appname>
<equal>com.rockysandstudio.Leaf</equal>
</appdef>
<item>
<name>dm4</name>
<item>
<name>Leaf j/k key binding</name>