This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
int singleNumber(int A[], int n) { | |
int x = 0; | |
for(int i = 0;i<n;i++){ | |
x ^= A[i]; | |
} | |
return x; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a:link, a:visited, a:active { | |
color: #8e8d93; | |
-webkit-transition: all .15s; | |
-moz-transition: all .15s; | |
-ms-transition: all .15s; | |
-o-transition: all .15s; | |
transition: all .15s; | |
} | |
a.top:link, a.top:visited, a.top:active { | |
color: #000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: l = [(1, 2), (3, 4), (5, 6), (7, 8), (9, 0)] | |
In [2]: [sum(x) for x in zip(*l)] | |
Out[2]: [25, 20] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from forwardable import def_delegators | |
def_delegators('event', ('begin_time', 'end_time', )) |
OlderNewer