Skip to content

Instantly share code, notes, and snippets.

View masakichi's full-sized avatar
🈂️

Yuanji masakichi

🈂️
View GitHub Profile
$ virtualenv env [21:30:32]
New python executable in env/bin/python
Installing setuptools...................................
Complete output from command /tmp/env/bin/python -c "#!python
\"\"\"Bootstra...sys.argv[1:])
// ==UserScript==
// @name hack_zf
// @namespace https://gist.github.com/jyjmrlk/8018695#file-hack_zf-js
// @version 0.1
// @description hack zhengfang review.
// @include http://202.119.248.199/xsjxpj.aspx*
// @copyright 2013+, 正吉熊Gimo
// ==/UserScript==
/*
The purpose of this function is to convert an unsigned
binary number to reflected binary Gray code.
The operator >> is shift right. The operator ^ is exclusive or.
*/
unsigned int binaryToGray(unsigned int num)
{
return (num >> 1) ^ num;
}
class Solution {
public:
int singleNumber(int A[], int n) {
int x = 0;
for(int i = 0;i<n;i++){
x ^= A[i];
}
return x;
}
};
tags = db.Table('tags',
db.Column('tag_id', db.Integer, db.ForeignKey('tag.id')),
db.Column('page_id', db.Integer, db.ForeignKey('page.id'))
)
class Page(db.Model):
id = db.Column(db.Integer, primary_key=True)
tags = db.relationship('Tag', secondary=tags,
backref=db.backref('pages', lazy='dynamic'))
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
from libs.pprint import pprint
from libs.base_handler import *
import json
class Handler(BaseHandler):
'''
this is a sample handler
@masakichi
masakichi / world_cup.py
Created June 20, 2014 02:32
World Cup in one line.
import urllib2, json
print '\n'.join([' '.join((jogo['home_team']['country'], str(jogo['home_team']['goals']), 'x', jogo['away_team']['country'], str(jogo['away_team']['goals']))) for jogo in json.loads(urllib2.urlopen('http://worldcup.sfg.io/matches').read().decode('utf-8')) if jogo['status'] == 'completed'])
#!/usr/bin/env python
#coding:utf8
import random,threading,time
from Queue import Queue
#Producer thread
class Producer(threading.Thread):
def __init__(self, t_name, queue):
threading.Thread.__init__(self,name=t_name)
self.data=queue
def run(self):
@masakichi
masakichi / all_gpa.py
Last active August 29, 2015 14:03
calculate GPA from csv file
# coding=utf8
#!/usr/bin/python
import csv
import sys
PATHS = ('/Users/Gimo/Desktop/1.csv',
'/Users/Gimo/Desktop/2.csv',
'/Users/Gimo/Desktop/3.csv',
'/Users/Gimo/Desktop/4.csv',
'/Users/Gimo/Desktop/5.csv'
@masakichi
masakichi / online_GPA.js
Created July 17, 2014 09:17
show GPA online.(designed for NJTech students)
// ==UserScript==
// @name online_GPA
// @version 0.1
// @description show GPA online.
// @include http://202.119.248.199/xscjcx_dq.aspx?xh=*
// @copyright 2014+, Gimo
// ==/UserScript==
function get_point(str){
if(str=="优秀") return 4.5;