Skip to content

Instantly share code, notes, and snippets.

View ilovejs's full-sized avatar
🐡

Hao ilovejs

🐡
  • 13:55 (UTC +10:00)
View GitHub Profile
<?
require("redis.php");
require("json.php");
$term = $_GET['term'];
$r = new Redis("127.0.0.1","6379");
$r->connect();
$items = $r->zrangebylex("kernel","[$term","[$term\xff",Array("LIMIT","0","10"));
@ilovejs
ilovejs / convertDatetime2int.sql
Created September 3, 2014 01:05
convert datetime type to int
SELECT * FROM [MZTEST].[dbo].[AccessToken]
use [mztest]
alter table AccessToken
add expireDateNew int
alter table AccessToken
drop column expireDate
@ilovejs
ilovejs / heapsort.go
Created September 17, 2014 17:01
Heapsort in Go, inspired by <Algorithm 4th> Robert S.
package main
/*
Follow graph on http://algs4.cs.princeton.edu/24pq/
for viewing heap structure.
p.s. Heap is of binary tree form with root at index 1
Index spread out by tree's level order (left to right, up to down.
*/
import (
@ilovejs
ilovejs / cssAnimation.css
Created September 25, 2014 05:13
css animation snippet
#ux-header header nav ul li a:hover {
color: #00bcf2;
text-decoration: none;
}
#ux-header header nav ul li a {
color: #ebebeb;
-o-transition: .3s ease-in-out;
-ms-transition: .3s ease-in-out;
-moz-transition: .3s ease-in-out;
package main
import (
"fmt"
"time"
)
//http://www.goinggo.net/2014/02/the-nature-of-channels-in-go.html
func main() {
package main
import (
"fmt"
"time"
)
// STARTMAIN1 OMIT
type Ball struct{ hits int }
@ilovejs
ilovejs / hacknewsParser.py
Last active August 29, 2015 14:07
Parse hacknews and store into sqlite database in form: id, hid, title, url. Able to run the script multiple times, since it's check duplication via hid (unique key for each news).
#!/usr/bin/env python
import requests
from lxml import html
from sqlalchemy import Column, String, Integer
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Record(Base):
__tablename__ = 'HNews'
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
#preview {
/* position: relative;
background: #333;
color: #fff;
float: left;
width: 268px;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VariableCapture
{
class Program
{
@ilovejs
ilovejs / Heroku.md
Last active August 29, 2015 14:11
Heroku Guide

Heroku Guide


Create

git push heroku master

Procfile

Use a Procfile, a text file in the root directory of your application, to explicitly declare what command should be executed to start your app.

e.g. web: gunicorn gettingstarted.wsgi --log-file -