Skip to content

Instantly share code, notes, and snippets.

@risent
risent / 12306AutoLogin.user.js
Created January 9, 2012 08:52 — forked from kevintop/12306AutoLogin.user.js
12306 Auto Login
/*
12306 Auto Login => A javascript snippet to help you auto login 12306.com.
Copyright (C) 2011 Kevintop
Includes jQuery
Copyright 2011, John Resig
Dual licensed under the MIT or GPL Version 2 licenses.
http://jquery.org/license
Includes 12306.user.js
@risent
risent / 12306AutoSubmit.user.js
Created January 9, 2012 08:52 — forked from kevintop/12306AutoSubmit.user.js
12306 Auto Submit
/*
12306 Auto Submit => A javascript snippet to help you auto submit.
Copyright (C) 2011 Kevintop
Includes jQuery
Copyright 2011, John Resig
Dual licensed under the MIT or GPL Version 2 licenses.
http://jquery.org/license
Includes 12306.user.js
@risent
risent / 12306.user.js
Created January 17, 2012 03:35 — forked from quietlynn/12306.user.js
12306 Auto Query => A javascript snippet to help you book ticket
/*
12306 Auto Query => A javascript snippet to help you book tickets online.
Copyright (C) 2011-2012 Jingqin Lynn
Includes jQuery
Copyright 2011, John Resig
Dual licensed under the MIT or GPL Version 2 licenses.
http://jquery.org/license
Includes Sizzle.js
@risent
risent / straight_include.py
Created March 7, 2012 15:33 — forked from HenrikJoreteg/straight_include.py
A Django Template tag for including files that you don't want to parse as templates
"""
Straight Include template tag by @HenrikJoreteg
Django templates don't give us any way to escape template tags.
So if you ever need to include client side templates for ICanHaz.js (or anything else that
may confuse django's templating engine) You can is this little snippet.
Just use it as you would a normal {% include %} tag. It just won't process the included text.
"""
A script for automatically extracting excerpts from articles. It requires lxml.
Usage::
from lxml_extractor import get_summary
url = "http://someurl.com/goes/here"
(title,description) = get_summary(url)
@risent
risent / 1-view-events.js
Created September 9, 2012 15:43 — forked from mxriverlynn/1-view-events.js
zombies! run!
MyView = Backbone.View.extend({
events: {
"click #someButton": "doThat",
"change #someInput": "changeIt"
},
doThat: function(){ ... },
changeIt: function(){ ... }
});
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(
@risent
risent / nbabot.go
Created April 18, 2013 16:14
A NBA bot writing in go, use 163.com data source.
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"net/http"
"time"
"strconv"

Python Number Conversion Chart

From To Expression
@risent
risent / alter_seq.py
Created May 14, 2013 03:57
Alter postgresql sequence permission to the correct owner after migrate from mysql by py-mysql2pgsql
import psycopg2
def alter():
conn = psycopg2.connect(database='bazaar4_13', user='postgres')
cur = conn.cursor()
seq_sql = """SELECT c.relname FROM pg_class c WHERE c.relkind = 'S'"""
cur.execute(seq_sql)
seq_list = cur.fetchall()