Skip to content

Instantly share code, notes, and snippets.

@BYVoid
BYVoid / gist:7749193
Created December 2, 2013 13:10
Simple FTP server using pyftpdlib
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
authorizer = DummyAuthorizer()
authorizer.add_user("byvoid", "pass", "/home/byvoid/ftp", perm="elradfmw")
handler = FTPHandler
handler.authorizer = authorizer
@BYVoid
BYVoid / ffmpeg-convert.js
Created October 19, 2013 06:08
Batch convert multimedia files
fs = require("fs");
path = require("path");
var files = fs.readdirSync(".");
for (var i = 0; i < files.length; i++) {
var file = files[i];
var ext = path.extname(file);
if (ext != '.ogg') {
continue;
}
@BYVoid
BYVoid / pagerank.go
Last active October 14, 2016 16:51
Calculate pagerank of every vertex in a graph using Go language
package main
import (
"bufio"
"errors"
"fmt"
"io"
"math"
"os"
"strings"
@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;
};
@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 / 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 / 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 / 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 / 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 / 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>