Skip to content

Instantly share code, notes, and snippets.

View bcho's full-sized avatar
💍
一起来发财吧!Let's make some money!

hbc bcho

💍
一起来发财吧!Let's make some money!
View GitHub Profile
class A(object):
bounded_lambda = lambda x: x
def __init__(self, unbounded_lambda):
self.unbounded_lambda = unbound_lambda
def __call__(self):
print(self.bounded_lambda, self.unbounded_lambda)
{
"\u756a2B\u8def": [
"10700231",
"10700230"
],
"7\u8def": [
"10000700",
"10000701"
],
"983\u7ebf": [
@bcho
bcho / gzbus.json
Created January 26, 2015 08:01
广州公交
This file has been truncated, but you can view the full file.
{
"10036900": {
"starting_station": "\u8305\u5c97\u65b0\u6751\u603b\u7ad9",
"stations": [
"\u8305\u5c97\u65b0\u6751\u603b\u7ad9",
"\u8305\u5c97\u516c\u5bd3\u7ad9",
"\u4e1c\u82d1\u5c0f\u533a\u7ad9",
"\u6e2f\u6e7e\u5e02\u573a\u7ad9",
"\u6e2f\u6e7e\u8def\u53e3\u7ad9",
"\u5927\u6c99\u897f\u7ad9",
@bcho
bcho / test.go
Created January 16, 2015 12:28
trick
package main
import (
"fmt"
"os"
)
type MyFile struct {
MyField string
*os.File
maxsum(A, B) :-
maxsum_aux(A, 0, 0, B).
% Kadane's algorithm
maxsum_aux([Elem|Tail], F, M, ANS) :-
choose_max(0, F + Elem, Fx),
choose_max(M, Fx, Mx),
maxsum_aux(Tail, Fx, Mx, ANS).
maxsum_aux([], F, M, ANS) :-
@bcho
bcho / item.py
Created December 20, 2014 02:35
trick
import dis
def item_instanate():
class Item:
pass
print(Item(), Item(), Item())
@bcho
bcho / primes.go
Created December 12, 2014 15:19
trick
package main
import (
"fmt"
"sync"
)
func piper(left chan int, wg *sync.WaitGroup) {
forRight := make(chan int, 0)
@bcho
bcho / locality.c
Created November 26, 2014 05:20
trick
// Locality test.
//
// See:
// http://en.wikipedia.org/wiki/Locality_of_reference#Matrix_multiplication
#include <string.h>
#define N 1000
int a[N][N], b[N][N], c[N][N];
<?php
// user is a subject
$user = UserService::getCurrentUser();
// role creation
$role = RbacService::createRole('post', [
// Permission:
//
// -1: Deny
581c581
< moduleNames = [f for f in os.listdir(moduleDir) if f.endswith('gents.py') or f.endswith('search.py')]
---
> moduleNames = [f for f in os.listdir(moduleDir) if f.endswith('gents.py')]
667c667
< pass
---
> pass
\ No newline at end of file