Skip to content

Instantly share code, notes, and snippets.

View cuter44's full-sized avatar

Galin Wu cuter44

  • Guangzhou, China
View GitHub Profile
@cuter44
cuter44 / des.js
Created November 17, 2013 18:26
DES Encrypt/Decrypt ECB/ZeroPadding
// all functions below accepts input and provide output in big-endian.
var bit_mask = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80];
var ip_table =
[
[[7,1],[6,1],[5,1],[4,1],[3,1],[2,1],[1,1],[0,1]],
[[7,3],[6,3],[5,3],[4,3],[3,3],[2,3],[1,3],[0,3]],
[[7,5],[6,5],[5,5],[4,5],[3,5],[2,5],[1,5],[0,5]],
[[7,7],[6,7],[5,7],[4,7],[3,7],[2,7],[1,7],[0,7]],
@cuter44
cuter44 / utf8.js
Last active December 28, 2015 17:58
jsString <=> UTF8 byte array convert
var utf8_scope = [0x0, 0x7f, 0x7ff, 0xffff, 0x10000];
var utf8_prefix = [0x80, 0x00, 0xc0, 0xe0, 0xf0];
var utf8_valid_bits = [6, 7, 5, 4, 3];
var utf8_valid_mask = [0x3f, 0x7f, 0x1f, 0x0f, 0x07];
function str2utf(str)
{
//if (!(str instanceof String))
//return;
@cuter44
cuter44 / HttpUtil.java
Last active December 29, 2015 03:59
com.github.cuter44.util.servlet
package com.github.cuter44.util.servlet;
import java.nio.ByteBuffer;
/* util */
import java.util.List;
import java.util.ArrayList;
import java.util.StringTokenizer;
/* http */
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@cuter44
cuter44 / mail-firer.js
Created December 30, 2013 16:59
[Bookmarklet]send page URL and selection via e-mail, adapted from douban bookmarklet.
javascript:void(
function()
{
var to=prompt("收件人","442030700@qq.com"),
d=document,
e=encodeURIComponent,
s1=window.getSelection,
s2=d.getSelection,
s3=d.selection,
s=s1?s1():s2?s2():s3?s3.createRange().text:'',
@cuter44
cuter44 / build.xml
Last active August 29, 2015 13:56
JavaWeb defaults
<?xml version="1.0" encoding="utf-8"?>
<!--
Default build.xml file for JavaWeb Project
==========================================
@depend ant-1.9.2+ (tested, actually more below this)
@author "galin"<cuter44@qq.com>
@version 1.3.1 build 2014/2/15
==========================================
You can do whatever to this file as you wish.
This file and other attachement is provided as-if, and no warranty.
@cuter44
cuter44 / build.xml
Last active August 29, 2015 13:56
Java defaults
<?xml version="1.0" encoding="utf-8"?>
<!--
Default build.xml file for local Java Project
==========================================
@depend ant-1.9.2+ (tested, actually more below this)
@author "galin"<cuter44@qq.com>
@version 1.0.0 build 2014/2/25
==========================================
You can do whatever to this file as you wish.
This file and other attachement is provided as-if, and no warranty.
@cuter44
cuter44 / getpoint-getgeohash.js
Created March 2, 2014 15:04
附着在百度经纬度拾取工具的增强, 将经纬度转换成 geohash.
/** user-script baidu map Lat/Long -> geohash.org adapter
* attach to http://api.map.baidu.com/lbsapi/getpoint/index.html
* for non-IE
*/
function toGeohash()
{
var loc = document.getElementById("pointInput").value.split(",");
var body = document.getElementsByTagName("body")[0];
var oldf = document.getElementById("geohash");
@cuter44
cuter44 / zfbot.js
Last active July 9, 2018 03:06
正方抢课脚本
var zfbot = {
interval:5000,
data:null,
count:null,
started:false,
load_jq:function()
{
var jq = document.createElement("script");
jq.type = "text/javascript";
jq.src = "http://libs.baidu.com/jquery/1.10.2/jquery.min.js";
@cuter44
cuter44 / PhotoMerge.java
Created May 28, 2014 07:58
for 倩怡, 能纵向拼合图片的东东
package com.github.cuter44.photomerge;
import java.io.*;
import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;
import java.util.logging.*;
public class PhotoMerge
{
@cuter44
cuter44 / ISBN13Parser.js
Last active August 29, 2015 14:03
Parse ISBN-13 from image taken by camera, with pure js.
/** ISBN-13 decoder
* author by galin<cuter44@foxmail.com>
* free to use if reserve the author info.
*/
function ISBN13Parser(){
this.sResult = null;
this.iaResult = null;
this.baResult = null;
this.thresold = 80;