Skip to content

Instantly share code, notes, and snippets.

Avatar

Joyee Cheung joyeecheung

View GitHub Profile
@joyeecheung
joyeecheung / dss.ri
Last active Aug 29, 2015
Script for adding key constrainst for TPC-H.
View dss.ri
-- Sccsid: @(#)dss.ri 2.1.8.1
-- tpch Benchmark Version 8.0
USE tpch;
-- ALTER TABLE tpch.REGION DROP PRIMARY KEY;
-- ALTER TABLE tpch.NATION DROP PRIMARY KEY;
-- ALTER TABLE tpch.PART DROP PRIMARY KEY;
-- ALTER TABLE tpch.SUPPLIER DROP PRIMARY KEY;
-- ALTER TABLE tpch.PARTSUPP DROP PRIMARY KEY;
@joyeecheung
joyeecheung / dss.ddl
Created Mar 18, 2014
Script for creating tables for TPC-H.
View dss.ddl
-- Sccsid: @(#)dss.ddl 2.1.8.1
DROP DATABASE IF EXISTS tpch;
CREATE DATABASE tpch;
USE tpch;
CREATE TABLE NATION ( N_NATIONKEY INTEGER NOT NULL,
N_NAME CHAR(25) NOT NULL,
N_REGIONKEY INTEGER NOT NULL,
N_COMMENT VARCHAR(152));
@joyeecheung
joyeecheung / loaddata.sql
Created Mar 18, 2014
Example for loading data generated by TPC-H.
View loaddata.sql
USE tpch;
LOAD DATA LOCAL INFILE '/home/joyeecheung/tpch_2_16_1/dbgen/region.tbl' INTO TABLE REGION
FIELDS TERMINATED BY '|' LINES TERMINATED BY '|\n';
LOAD DATA LOCAL INFILE '/home/joyeecheung/tpch_2_16_1/dbgen/nation.tbl' INTO TABLE NATION
FIELDS TERMINATED BY '|' LINES TERMINATED BY '|\n';
LOAD DATA LOCAL INFILE '/home/joyeecheung/tpch_2_16_1/dbgen/supplier.tbl' INTO TABLE SUPPLIER
FIELDS TERMINATED BY '|' LINES TERMINATED BY '|\n';
@joyeecheung
joyeecheung / load.sh
Created Mar 18, 2014
Litter helper to generate loading command when building TPC-H.
View load.sh
#!/bin/bash
write_to_file()
{
file="loaddata.sql"
if [ ! -f "$file" ] ; then
touch "$file"
fi
View test.sh
for z in *.zip; do
d=`basename $z .zip`
mkdir $d && unzip $z -d $d
if [ -d "$d/src" ]; then
cp ../_s1/* $d/src/
if [ -f "$d/src/makefile" ]; then
rm $d/src/makefile
fi
cd $d/src/
make
@joyeecheung
joyeecheung / gpa.js
Created Jul 17, 2014
GPA calculator for SYSU third party academic administration system
View gpa.js
var tr = $("#score-result table tbody tr");
var credit_total = 0.0, total = 0.0;
tr.each(function(idx, row) {
var credit = parseFloat($(row).children('td')[0].textContent);
var score = parseFloat($(row).children('td')[2].textContent);
credit_total += credit;
total += score * credit;
});
@joyeecheung
joyeecheung / gpa-calculator-insysu.js
Last active Aug 29, 2015
GPA calculator for insysu.com
View gpa-calculator-insysu.js
var courses = $("#score-result table tbody tr");
var totalCredit = 0.0, totalProduct = 0.0;
courses.each(function(idx, course) {
var cells = $(course).children("td");
if (cells[3].textContent !== "公选") {
var credit = parseFloat(cells[2].textContent);
var score = parseFloat(cells[5].textContent);
totalCredit += credit;
@joyeecheung
joyeecheung / setup.sh
Last active Aug 29, 2015
Set up environment for SYSU Cloud Desktop
View setup.sh
# Download JDK
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u65-b17/jdk-7u65-linux-x64.tar.gz
# Untar JDK
tar xvzf jdk-7u65-linux-x64.tar.gz
# Remove the tar.gz
rm jdk-7u65-linux-x64.tar.gz
# set env var
View count.sh
#! /usr/bin/env bash
for i in {1..20}; do
ant run
result=`grep "No solution" ASearchDialog.txt`
if [ ! -z "$result" ]; then
echo "-1" >> result.txt
else
result=`grep -o "Total number of searched nodes:[0-9]\+" ASearchDialog.txt | grep -o '[0-9]\+$'`
echo $result >> result.txt
@joyeecheung
joyeecheung / plot.plt
Last active Aug 29, 2015
plotting result of Jigsaw
View plot.plt
set terminal png size 1378,768
set output 'result.png'
set xrange [-2000:30000]
set boxwidth 200 absolute
set style fill solid 1.0 noborder
bin_width = 1000;
bin_number(x) = floor(x/bin_width)
rounded(x) = bin_width * ( bin_number(x) + 0.5 )
plot 'result.txt' using (rounded($1)):(1.0/20) smooth frequency with boxes