Skip to content

Instantly share code, notes, and snippets.

View bearice's full-sized avatar
🐻

Bearice Ren bearice

🐻
View GitHub Profile
@bearice
bearice / time_utils.erl
Created August 24, 2011 06:54
strftime for erlang
-module(time_utils).
-author("Bearice Ren <bearice@gmail.com>").
-export([strftime/2]).
strftime(Fmt,{_,_,_}=Time)->
strftime(Fmt,calendar:now_to_datetime(Time));
strftime(Fmt,{_,_}=Time)->
lists:reverse(strftime(str,Fmt,Time,[])).
@bearice
bearice / websocket.js
Created September 27, 2011 07:01
My own (and dirty) implementation of WebSocket-Protocol-Version-8 on nodejs
var crypto = require('crypto');
var WSProtocolHandler = {
"8":{
handshake:function(req,socket,head,callback){
var key = req.headers["sec-websocket-key"];
if(!key)return false;
key += "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
var sha1 = crypto.createHash('sha1');
sha1.update(key);
@bearice
bearice / jquery.dnd.js
Created October 19, 2011 03:04
jQuery plugin for <del>Dungeon and Dragons</del> Drag and Drop Event
/**
* jQuery plugin for <del>Dungeon and Dragons</del> Drag and Drop Event
*/
(function($){
$.fn.dragAndDropFiles = function(options){
if(typeof(window.FileReader)=== 'undefined')return;
var defaults = {
MIME : ["image/png","image/jpeg","image/bmp"],
//accept = function(e){},
//cancel = function(e){},
bearice@Bearice-Mac-Air ~
%dig fanfou.icybear.net !693 [20:07:21]
; <<>> DiG 9.7.3-P3 <<>> fanfou.icybear.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2591
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 4, ADDITIONAL: 8
;; QUESTION SECTION:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !=m.moegirl.org
RewriteCond %{HTTP_USER_AGENT} .*iPhone.* [OR]
RewriteCond %{HTTP_USER_AGENT} .*Android.* [OR]
RewriteCond %{HTTP_USER_AGENT} .*SymbianOS.* [OR]
RewriteCond %{HTTP_USER_AGENT} .*Windows\ Phone.*
RewriteRule ^(.*)$ http://m.moegirl.org/$1 [L,R=301]
if (obj['replylinks'] !== '') {
_ref = obj['replylinks'].split('&');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
x = _ref[_i];
ret.add((x.split('='))[0]);
}
}
<%
const L_Title_Text = "IIS - 身份验证管理器"
const L_ISM_Text = "Internet 服务管理器"
const L_IIS6_Text = "用于 Internet 信息服务器 6.0"
const L_PWS_Text = "用于点 Web 服务"
const L_PwdSoon_Text = "您的密码将很快过期"
const L_ChangePwd_Text = "您想现在更改吗?"
const L_SSL1_Text = "要更改密码,需要安全信道(SSL 或 PCT)"
const L_SSL2_Text = "您的系统上没有安装或启用 SSL/PCT,请安装,以启用此功能"
const L_PasswordExpired_Text = "您的密码已过期"
@bearice
bearice / gist:2849461
Created June 1, 2012 06:13
Google Keywords
[
"王",
"江",
"周",
"胡",
"刘",
"李",
"吴",
"毛",
"温",
%curl 'api.fanfou.com/statuses/user_timeline.json?id=ruif&max_id=khOb6zZ-koQ&count=60&mode=lite' | pjson | grep rawid | sort
"rawid": 123828553,
"rawid": 123828707,
"rawid": 123830009,
"rawid": 123832006,
"rawid": 123832193,
"rawid": 123833721,
"rawid": 123833953,
"rawid": 123834867,
"rawid": 123835062,
@bearice
bearice / build.sh
Created August 21, 2012 13:50
Cross Compile NodeJS 0.8.7 on arm [Kindle] On OSX 10.8
export HOST=arm-kindle-linux-gnueabi
export CC=$HOST-gcc
export CPP=$HOST-g++
export CXX=$HOST-g++
export LD=$HOST-ld
export AS=$HOST-as
export AR=$HOST-ar
export LDFLAGS="-static -static-libgcc -static-libstdc++"
export PATH=$PATH:/Volumes/XTools/arm-kindle-linux-gnueabi/bin