Skip to content

Instantly share code, notes, and snippets.

@joyeecheung
joyeecheung / dss.ri
Last active August 29, 2015 13:57
Script for adding key constrainst for TPC-H.
-- 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 March 18, 2014 10:21
Script for creating tables for TPC-H.
-- 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 March 18, 2014 12:44
Example for loading data generated by TPC-H.
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 March 18, 2014 13:14
Litter helper to generate loading command when building TPC-H.
#!/bin/bash
write_to_file()
{
file="loaddata.sql"
if [ ! -f "$file" ] ; then
touch "$file"
fi
@joyeecheung
joyeecheung / test.sh
Created July 2, 2014 13:29
Run the tests!
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 July 17, 2014 06:56
GPA calculator for SYSU third party academic administration system
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 August 29, 2015 14:04
GPA calculator for insysu.com
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 August 29, 2015 14:04
Set up environment for SYSU Cloud Desktop
# 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
@joyeecheung
joyeecheung / count.sh
Created August 5, 2014 11:10
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 August 29, 2015 14:04
plotting result of Jigsaw
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