Skip to content

Instantly share code, notes, and snippets.

View ilovejs's full-sized avatar
🐡

Hao ilovejs

🐡
  • 15:51 (UTC +10:00)
View GitHub Profile
@ilovejs
ilovejs / alter column serial.sql
Created September 26, 2015 14:07
alter column to be serial
CREATE SEQUENCE "temp1_id_seq" OWNED BY "Temp1". ID;
ALTER TABLE "Temp1" ALTER COLUMN ID
SET DEFAULT nextval('temp1_id_seq');
COMMIT;
--Temp1 is table name, however, sequence name must be low-cased.
@ilovejs
ilovejs / How to properly install mysql on mac 10.10.5.txt
Last active November 26, 2015 23:37
How to properly install mysql on mac 10.10.5
MySQL 5.6
1. Download officla one, since it create lib folder for you
2. After installation
- Lib directory:
/usr/local/mysql/lib
- Bin, Data dir:
/usr/local/mysql-5.6.27-osx10.8-x86_64/bin/mysql
/usr/local/mysql-5.6.27-osx10.8-x86_64/data/mysql
@ilovejs
ilovejs / command_line_dictionary_tool.py
Created March 21, 2016 02:20
add word to database in command line.
import argparse
import sqlite3
conn = sqlite3.connect('saved_words.db')
parser = argparse.ArgumentParser()
parser.add_argument("-a", "--add", help="add word")
parser.add_argument("-c", help="compiling table", action='store_true')
parser.add_argument("-l", help="list words", action="store_true")
parser.add_argument("-v", "--verbosity", type=int, choices=[0, 1, 2], help="increase output verbosity")
@ilovejs
ilovejs / vowpal-hash.lhs
Created June 1, 2016 06:53 — forked from cartazio/vowpal-hash.lhs
vowpal hash
\begin{code}
{-# LANGUAGE BangPatterns #-}
{-|
Module : Data.Digest.VowpalHash
Copyright : (c) Carter Tazio Schonwald
License : BSD-style
Maintainer : first dot last @gmail.com
# a slightly more realistic version of the 'Healthy' vs. 'Fever' model is outlined and then generated
import random
states = ('Healthy', 'Fever')
observations = ('normal', 'cold', 'dizzy')
start_probability = {'Healthy': 0.6, 'Fever': 0.4}
transition_probability = {
'Healthy' : {'Healthy': 0.8, 'Fever': 0.2},
'Fever' : {'Healthy': 0.4, 'Fever': 0.6}
% !TeX spellcheck = <yes>
\documentclass[14pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\author{MZ}
\title{Share Terms}
\begin{document}
@ilovejs
ilovejs / progress-bar.sh
Created August 6, 2016 16:26 — forked from F1LT3R/progress-bar.sh
Bash Progress Bar
#!/bin/bash
# Bash Progress Bar: https://gist.github.com/F1LT3R/fa7f102b08a514f2c535
progressBarWidth=20
# Function to draw progress bar
progressBar () {
# Calculate number of fill/empty slots in the bar
@ilovejs
ilovejs / video_to_audio.sh
Created August 6, 2016 17:00
strip audio from video using ffmpeg
#!/bin/bash
# usage:
# ls *.avi | ./video_to_audio.sh
# for f in `ls *.avi`;
# do
# echo item: $f
# done
@ilovejs
ilovejs / isohybrid.pl
Created October 3, 2016 02:38 — forked from jsarenik/isohybrid.pl
isohybrid.pl from Syslinux-6.03
#!/usr/bin/perl
## -----------------------------------------------------------------------
##
## Copyright 2002-2008 H. Peter Anvin - All Rights Reserved
## Copyright 2009 Intel Corporation; author: H. Peter Anvin
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, Inc., 53 Temple Place Ste 330,
## Boston MA 02111-1307, USA; either version 2 of the License, or
@ilovejs
ilovejs / fuck_reporting.sql
Last active April 22, 2017 08:03
sql server, YTD profit, accumulative sum by product and week. Percentage of increate / decrease
drop table if exists sales;
create table sales (
prod_id int,
month_end varchar(10),
amount int
);
-- need to paddle zero if no sales, but we fill manually here
insert into sales values
(1, '2017-01-31', 100), (1, '2017-02-28', 300),