Skip to content

Instantly share code, notes, and snippets.

View dm4's full-sized avatar
4️⃣

dm4 dm4

4️⃣
View GitHub Profile
@dm4
dm4 / 自動填教學意見調查
Created December 5, 2011 17:06 — forked from jimmyken793/自動填教學意見調查
自動填教學意見調查
把以下的東西存成bookmark 然後在填答表格那頁點下去 然後Magic!!
javascript:y=document.forms['frm1'].elements;for(var j=1;j<=28;j++){a=y['ans'+j];if(a){var c=a.length;if(c==undefined){a.checked=(a.value=='3')}for(var i=0;i<c;i++){a[i].checked=false;if(a[i].value=='3'){a[i].checked=true}}}}
@dm4
dm4 / hw2.sh
Created December 11, 2011 07:38
trace.sh
#!/bin/bash
[ -z "$1" ] && echo '請輸入目錄' && exit
[ ! -d "$1" ] && echo '請輸入目錄' && exit
trace() {
if [ -d "$1" ]; then
for file in "$1/"*.txt
do
echo "$file"
@dm4
dm4 / gist:1616584
Created January 15, 2012 17:55
find pair
hput () {
eval hash"$1"='$2'
}
hget () {
eval echo '${hash'"$1"'#hash}'
}
for tmp in "$@"
do
if [ "`hget $tmp`" != "" ]
then
@dm4
dm4 / gist:1619367
Created January 16, 2012 06:20
find pair
hput () {
eval hash"${1//[.-]/a}"='$2'
}
hget () {
eval echo '${hash'"${1//[.-]/a}"'#hash}'
}
for tmp in "$@"
do
tmp=`echo $tmp | cut -c 5-`
tmp=`echo $tmp | cut -d_ -f1`
@dm4
dm4 / Makefile
Created March 7, 2012 11:47
DSA Homework #1
main: poly.cpp main.cpp poly.h
g++ dm4.cpp main.cpp -o poly
run:
./poly < input
@dm4
dm4 / 下推.vb
Created May 7, 2012 05:05
國二寫的人生第一隻程式
VERSION 5.00
Begin VB.Form Form1
Caption = "上推"
ClientHeight = 5415
ClientLeft = 60
ClientTop = 345
ClientWidth = 6930
LinkTopic = "Form1"
ScaleHeight = 5415
ScaleWidth = 6930
@dm4
dm4 / web5.pl
Created July 26, 2012 06:44
HITCON 2012 Wargame Web 5
#!/usr/bin/perl -w
use 5.010;
use LWP;
use URI::Escape;
use strict;
my $str = 'abcdefghijklmnopqrstuvwxyz0123456789~!@#$%^&*()_+`-=[]\\{}|;\':",./<>? ';
my @chars = map { uri_escape($_) } split //, $str;
my @stack;
@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];