This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: UTF-8 | |
import socket | |
import struct | |
def aton(addr): | |
return struct.unpack('!l', socket.inet_aton(addr)) | |
def ntoa(addr): | |
return socket.inet_ntoa(struct.pack('!l', addr)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FileInfo | |
def initialize(name, data) | |
@name = name | |
@length = data.length | |
@space = data.each_char.inject(0) { |n, c| | |
n += case c | |
when '\t' then 8 | |
when /\s/ then 1 | |
else 0 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
INITIAL_SIZE=5 | |
VOLUME_NAME='ramdisk' | |
MOUNTPOINT='/tmp/upsuper' | |
MOUNTPOINT_FILE='/tmp/ramdisk.mountpoint' | |
# find a non-existent initial mount point | |
mountpoint=$(mktemp -dt ramdisk) | |
# set ramdisk size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cat /proc/cpuinfo | grep processor | wc -l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# - * - 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('"', '\\"') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2012 Xidorn Quan <quanxunzhen@gmail.com> | |
* | |
* This file is part of MPlayer. | |
* | |
* MPlayer is free software; you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation; either version 2 of the License, or | |
* (at your option) any later version. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 将 DNSPOD 上指定子域名指向当前本机 IP 的脚本 | |
# | |
# 依赖: | |
# urlencode: http://www.shelldorado.com/scripts/cmds/urlencode | |
# jsawk: https://github.com/micha/jsawk | |
# 配置信息 | |
EMAIL="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 检验是否为有效的电子邮件地址 | |
* | |
* 根据 http://www.linuxjournal.com/article/9585 编写 | |
* | |
* @param string $email | |
* @return bool | |
*/ |