Skip to content

Instantly share code, notes, and snippets.

require 'bcrypt'
module Gencore
class User < Sequel::Model
set_schema do
primary_key :id
varchar :username
text :passwd, :default => '*'
end
#!/usr/bin/env python
import gconf, os, time, pynotify
from PIL import Image
pynotify.init("BgChanger")
DEFAULTWPDIR = "/usr/share/backgrounds"
NTITLE = "Up Next..."
class Cashier
@@tokens = {100 => 1, 200 => 4, 500 => 2, 1000 => 2, 2000 => 2, 5000 => 2, 10000 => 2, 20000 => 1, 50000 => 0, 100000 => 0}
def givemychange(ch)
@change = []
p = @@tokens.keys.sort.reverse
p.each do |money|
temp = ch / money
next if temp == 0 or @@tokens[money] == 0
@fudanchii
fudanchii / mplayer_screenshot_v2_safe.diff
Created June 3, 2011 06:56
lulz patch for mplayer screenshot filter v2
diff --git a/command.c b/command.c
index de7f1fb..c0e0087 100644
--- a/command.c
+++ b/command.c
@@ -3289,12 +3289,13 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
case MP_CMD_SCREENSHOT:
if (mpctx->video_out && mpctx->video_out->config_ok) {
+ char *fname = get_metadata(mpctx, META_NAME);
+ void* param[2] = {&cmd->args[0].v.i, fname};
@fudanchii
fudanchii / http.go
Created June 8, 2011 09:26
web server example for serving static file
package main
import (
"http"
"runtime"
"log"
"flag"
"os"
)
@fudanchii
fudanchii / test_fwx.h
Created July 19, 2011 10:33
Synchro test macro
/*
* synchro Test Suite Macro collection
* synchro is collection of simple macro
* I used to test my C/C++ unit.
* The design itself is dead simple and
* straight-forward, since I found another
* Unit Test tool for C/C++ is either bloated or
* simply not enough for my need.
* If you read this source and has intention to use it,
* go on, I hereby permit the use of this source code
def p(a)
print a
print "\n"
end
def a(ab, *test)
p test.inspect
end
a(1,:ss => "123", :ab => 123)
@fudanchii
fudanchii / fabfile.py
Created April 29, 2012 15:05
fabric file to upgrade nginx in remote host
from __future__ import with_statement
from fabric.api import *
from posixpath import basename
version = "1.5.7"
what="http://nginx.org/download/nginx-%s.tar.gz" % version
prefix="/opt/nginx"
opt = "--prefix=/opt/nginx --with-openssl=../openssl-1.0.1e --with-pcre --with-http_ssl_module --with-http_spdy_module --with-http_stub_status_module --with-ipv6 --with-http_image_filter_module"
env.hosts = [""]
@fudanchii
fudanchii / fabfile.py
Created May 9, 2012 07:50
fabric file to manage mercurial repository in remote host
from fabric.api import *
from fabric import contrib
# Put your server address here
env.host_string = "192.168.0.133:2221"
env.user = "hg"
# Put your username here
user="adie"
@fudanchii
fudanchii / jsc.c
Last active December 21, 2015 04:18
#include "jsc.h"
#include "main.js"