Skip to content

Instantly share code, notes, and snippets.

View upsuper's full-sized avatar

Xidorn Quan upsuper

View GitHub Profile
@upsuper
upsuper / Makefile
Created August 22, 2012 09:23
"xor rax, rax" vs. "mov rax, 0"
all: mov xor
mov: mov.o
ld -o mov mov.o
xor: xor.o
ld -o xor xor.o
mov.o: mov.asm
yasm -f macho64 -o mov.o mov.asm
@upsuper
upsuper / LICENSE
Last active July 15, 2022 03:02
A Java implementation of SHA-224 message digest algorithm with Provider
Copyright (c) 2012 Xidorn Quan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@upsuper
upsuper / update_self.sh
Created May 29, 2012 08:17
将 DNSPod 上指定子域名指向当前本机 IP 的脚本
#!/bin/bash
# 将 DNSPOD 上指定子域名指向当前本机 IP 的脚本
#
# 依赖:
# urlencode: http://www.shelldorado.com/scripts/cmds/urlencode
# jsawk: https://github.com/micha/jsawk
# 配置信息
EMAIL=""
@upsuper
upsuper / gist:2633348
Created May 8, 2012 07:51
HTML5 Canvas demo with lines smoothed using Bézier curve
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title></title>
<style type="text/css">
canvas { position: absolute; top: 0; left: 0; }
#c { background: #ccc; }
#ps { position: absolute; top: 0; right: 0; }
@upsuper
upsuper / tree.md
Created April 28, 2012 10:38 — forked from hrldcpr/tree.md
一行 Python 实现树

一行 Python 实现树

使用 Python 内置的 defaultdict,我们可以很容易的定义一个树形数据结构:

def tree(): return defaultdict(tree)

就是这样!

@upsuper
upsuper / mail.func.php
Created April 17, 2012 06:43
检验是否为有效的电子邮件地址的 PHP 函数
<?php
/**
* 检验是否为有效的电子邮件地址
*
* 根据 http://www.linuxjournal.com/article/9585 编写
*
* @param string $email
* @return bool
*/
@upsuper
upsuper / Makefile
Created March 21, 2012 10:54
中文C编程
CFLAGS=-fextended-identifiers -std=c99
objects=chinese.ucn.o
target=chinese
.PHONY: all clean
all: $(target)
$(target): $(objects)
$(CC) $< -o $@
@upsuper
upsuper / status.py
Created March 10, 2012 11:34
a python script to monitor account of twitter
#!/usr/bin/python
# - * - coding: UTF-8 - * -
import cgi
import json
import urllib
import httplib2
h = httplib2.Http()
query = urllib.urlencode({
@upsuper
upsuper / directory_icon.c
Created January 24, 2012 16:57
Set directory icon on Mac
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <CoreServices/CoreServices.h>
#include "directory_icon.h"
int setDirectoryIcon(const char *dirName, const char *iconData, size_t iconSize)
{
const int kResidIcon = -16455;
const OSType kRsrcType = 'icns';
@upsuper
upsuper / sendkeys.py
Created December 23, 2011 14:04
Send keys to clipboard or input directly (now only for Mac OS X and partly Linux)
# - * - coding: UTF-8 - * -
import subprocess
def macosx_set_clipboard(text):
p = subprocess.Popen('pbcopy', stdin=subprocess.PIPE)
p.communicate(text)
def macosx_send_keys(text):
text = text.replace('\\', '\\\\').replace('"', '\\"')