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
#include <stdio.h> | |
#include <sys/sysctl.h> | |
#include <mach/host_info.h> | |
#include <mach/mach_host.h> | |
#include <mach/task_info.h> | |
#include <mach/task.h> | |
void usage(int verbose) { | |
printf("Usage:\n"); |
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
#include <winsock2.h> | |
#include <stdio.h> | |
#include <windows.h> | |
#pragma comment(lib, "ws2_32.lib") | |
int main(int argc, char* argv[]) { | |
if (argc != 2) { | |
fprintf(stderr, "Usage: %s port\n", argv[0]); | |
return -1; | |
} |
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
use strict; | |
use warnings; | |
use URI::Escape qw(uri_escape_utf8); | |
use open IO => ":utf8", # UTF8 by default | |
":std"; # Apply to STDIN/STDOUT/STDERR | |
my $query = do { local $/; <> }; | |
$query =~ s/^\s+//g; | |
$query =~ s/\s+$//g; |
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
#!/usr/bin/perl | |
# Description: http://daringfireball.net/2010/08/open_urls_in_safari_tabs | |
# License: See below. | |
# http://gist.github.com/507356 | |
use strict; | |
use warnings; | |
use URI::Escape; |
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
LDFLAGS = -framework IOKit -framework ApplicationServices | |
test: test.m |
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
\documentclass[a4paper, 12pt]{book} | |
\usepackage[colorlinks,linkcolor=blue,anchorcolor=blue,citecolor=green,CJKbookmarks=true]{hyperref} | |
\usepackage{fontspec,xltxtra,xunicode} | |
\usepackage{xeCJK} | |
\setCJKmainfont[BoldFont={STHeiti},ItalicFont={STKaiti}]{STSong} | |
\setmainfont{Times New Roman} | |
\setCJKsansfont[BoldFont={STHeiti}]{STXihei} | |
\setsansfont{Helvetica} | |
\setCJKmonofont{STFangsong} | |
\setmonofont{Courier New} |
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
#include <stdio.h> | |
#include <stdlib.h> | |
/* The following include files for the network interface. */ | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <ifaddrs.h> | |
#include <net/if.h> | |
#include <net/if_dl.h> | |
#include <netinet/in.h> | |
#include <arpa/inet.h> |
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
in AndroidManifest.xml (application-part): | |
<receiver android:enabled="true" android:name=".BootUpReceiver" | |
android:permission="android.permission.RECEIVE_BOOT_COMPLETED"> | |
<intent-filter> | |
<action android:name="android.intent.action.BOOT_COMPLETED" /> | |
<category android:name="android.intent.category.DEFAULT" /> | |
</intent-filter> | |
</receiver> |
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
#!/usr/bin/env python | |
import sys, os, time, atexit | |
from signal import SIGTERM | |
class Daemon: | |
""" | |
A generic daemon class. | |
Usage: subclass the Daemon class and override the run() method |
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
#zz from http://www.exonsoft.com/~kochin/TinyP2P/tinyp2p.html | |
# tinyp2p.py 1.0 (documentation at http://freedom-to-tinker.com/tinyp2p.html) | |
# (C) 2004, E.W. Felten | |
# license: http://creativecommons.org/licenses/by-nc-sa/2.0 | |
# Annotated by Kochin Chang, Jan. 2005 | |