Skip to content

Instantly share code, notes, and snippets.

View ilovejs's full-sized avatar
🐡

Michael Zhuang (Hao) ilovejs

🐡
  • 17:34 (UTC +11:00)
View GitHub Profile
# 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}
@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
@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 / 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 / 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.
PdfLatex is a tool that converts Latex sources into PDF. This is specifically very important for researchers, as they use it to publish their findings. It could be installed very easily using Linux terminal, though this seems an annoying task on Windows. Installation commands are given below.
* Install the TexLive base
$ sudo apt-get install texlive-latex-base
* Also install the recommended and extra fonts to avoid running into the error [1], when trying to use pdflatex on latex files with more fonts.
$ sudo apt-get install texlive-fonts-recommended
$ sudo apt-get install texlive-fonts-extra
* Install the extra packages,
@ilovejs
ilovejs / LabelExtensions.cs
Created July 15, 2015 01:17
MVC Mandatory Field Label For Helper
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Web.Mvc;
using System.Web.WebPages;
namespace RegistrationSample.UI.Web.mvcHelper
{
/// <summary>
/// Mandatory Field Extension
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@ilovejs
ilovejs / index.html
Last active August 29, 2015 14:19 — forked from ains/index.html
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
# Fibonacci numbers WITH memoization.
# Initialize the memoization hash.
@scratchpad = {}
@max_fibo_size = 1_000_000_000_000
# Calculate the nth Fibonacci number, f(n).
def fibo (n)
val = if n <= 1
n