Skip to content

Instantly share code, notes, and snippets.

@BYVoid
BYVoid / gist:3233573
Created August 2, 2012 04:30
Cassandra Load
import random
import json
import hashlib
import threading
import pycassa
import time
from pycassa.pool import ConnectionPool
from pycassa.columnfamily import ColumnFamily
reg = True
@BYVoid
BYVoid / gist:3233582
Created August 2, 2012 04:31
Cassandra Scan
import pycassa
import time
from pycassa.pool import ConnectionPool
from pycassa.columnfamily import ColumnFamily
servers = [
'',
]
pool = ConnectionPool('Keyspace1', servers, pool_size=1)
@BYVoid
BYVoid / shut.cpp
Created August 2, 2012 12:03
线性规划与网络流24题 #2 太空飞行计划问题
/*
* Problem: 线性规划与网络流24题 #2 太空飞行计划问题
* Author: Guo Jiabao
* Time: 2009.6.26 18:09
* State: Solved
* Memo: 网络最大流 最小割
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
@BYVoid
BYVoid / ball.cpp
Created August 2, 2012 12:11
线性规划与网络流24题-魔术球问题
/*
* Problem: 线性规划与网络流24题 #4 魔术球问题
* Author: Guo Jiabao
* Time: 2009.6.27 12:06
* State: Solved
* Memo: 网络最大流 最小路径覆盖 枚举答案
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
@BYVoid
BYVoid / table.cpp
Created August 2, 2012 12:27
线性规划与网络流24题-圆桌问题
/*
* Problem: 线性规划与网络流24题 #5 圆桌问题
* Author: Guo Jiabao
* Time: 2009.6.27 12:59
* State: Solved
* Memo: 网络最大流 二分图多重匹配
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
@BYVoid
BYVoid / alis.cpp
Created August 2, 2012 12:37
线性规划与网络流24题-最长递增子序列问题
/*
* Problem: 线性规划与网络流24题 #6 最长递增子序列问题
* Author: Guo Jiabao
* Time: 2009.7.3 13:52
* State: Solved
* Memo: 网络最大流 动态规划
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
@BYVoid
BYVoid / gui.c
Created August 26, 2012 16:54
Mandelbrot Set Calculator and GUI
#include "mandelbrot.h"
GtkLabel ** axis_imag_lables, ** axis_real_lables;
int numXLabels, numYLabels;
gboolean redrawed;
gboolean expose(GtkDrawingArea *drawing_area, GdkEventExpose *event, gpointer data)
{
GtkWidget *widget = GTK_WIDGET(drawing_area);
GdkGC *gc = widget->style->fg_gc[GTK_WIDGET_STATE(widget)];
@BYVoid
BYVoid / func.c
Created September 21, 2012 10:06
Global variable in multiple files
int buf = 0;
void func() {
buf = 2;
/* Do something else */
}
@BYVoid
BYVoid / func.c
Created September 22, 2012 15:02
Global variable in multiple files (strong)
#include <stdio.h>
int buf = 0;
void func();
int main() {
buf = 1;
func();
printf("%d\n", buf);
return 0;
@BYVoid
BYVoid / closure.cpp
Created October 10, 2012 11:39
Closure in C++11
#include <iostream>
#include <functional>
using namespace std;
function<void()> closure() {
int a = 0;
auto func = [a]() mutable {
a += 1;
cout << a << endl;
};