Skip to content

Instantly share code, notes, and snippets.

Yo-An Lin c9s

View GitHub Profile
View com.disk.noatime.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.disk.noatime</string>
<key>ProgramArguments</key>
<array>
<string>mount</string>
View gist:e0ef1f0a1f78e6adedb2
check_tree.c:34:35: warning: implicit declaration of function 'zstrdup' is invalid in C99 [-Wimplicit-function-declaration]
fail_if( r3_node_add_child(n, zstrdup("/add") , child) == FALSE );
^
/opt/local/include/check.h:271:4: note: expanded from macro 'fail_if'
(expr) ? \
^
check_tree.c:34:35: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'char *' [-Wint-conversion]
fail_if( r3_node_add_child(n, zstrdup("/add") , child) == FALSE );
^~~~~~~~~~~~~~~
/opt/local/include/check.h:271:4: note: expanded from macro 'fail_if'
@c9s
c9s / bench.pl
Created May 20, 2014
libr3 benchmarks
View bench.pl
use Time::HiRes qw(time);
my %routes = (
"/foo/bar/baz" => 0,
"/foo/bar/qux" => 1,
"/foo/bar/quux" => 2,
"/foo/bar/corge" => 3,
"/foo/bar/grault" => 4,
"/foo/bar/garply" => 5,
"/foo/baz/bar" => 6,
"/foo/baz/qux" => 7,
View gist:e296c0edf3a8665e9db2
~/tmp/ % cd Router-R3
█▓▒░c9s@c9smba█▓▒░ Fri May/23 PM 00:22:57
~/tmp/Router-R3/ % git init
Initialized empty Git repository in /Users/c9s/tmp/Router-R3/.git/
█▓▒░c9s@c9smba█▓▒░ Fri May/23 PM 00:22:58
~/tmp/Router-R3/ (git:master) % git submodule init
█▓▒░c9s@c9smba█▓▒░ Fri May/23 PM 00:23:01
~/tmp/Router-R3/ (git:master) % git submodule add https://github.com/c9s/r3.git libr3
Cloning into 'libr3'...
remote: Reusing existing pack: 2031, done.
View benchmark.pl
#!/usr/bin/env perl
use lib 'lib';
use strict;
use warnings;
use Time::HiRes qw(time);
use Router::R3;
use Router::Boom;
use Router::Boom::Method;
use Router::Simple;
use HTTP::Router;
View HTTP Request Header
Cache-Control
Connection
Date
Pragma
Trailer
Transfer-Encoding
Upgrade
Via
Warning
Accept
View ci.zsh
ci () {
git status -uno
if [[ -n "$*" ]]
then
echo "Committing..."
git commit -v -a -m "$*"
else
echo "**** Please Enter Commit Message ****"
cat > .commit-msg
if [[ -e '.commit-msg' ]]
View tree.json
{
"endpoint": 0,
"compare": 0,
"edges": [
{
"pattern": "\/",
"opcode": 0,
"slug": false,
"child": {
"endpoint": 0,
View api.c
/*
* Request Header
* http://tools.ietf.org/html/rfc2616#section-5.3
*/
h3_request_header_get_accept(RequestHeader *header); // Get "Accept"
h3_request_header_get_accept_charset(RequestHeader *header); // Get "Accept-Charset"
h3_request_header_get_accept_language(RequestHeader *header); // Get "Accept-Language"
h3_request_header_get_accept_encoding(RequestHeader *header); // Get "Accept-Encoding"
h3_request_header_get_authorization(RequestHeader *header); // Get "Authorization"
h3_request_header_get_expect(RequestHeader *header); // Get "Expect"
View try-catch-return.php
<?php
function foo() {
try {
// throw new YoubikeException;
throw new Exception;
} catch (Exception $e) {
echo 'Caught Exception: ', get_class($e), "\n";
return 1;
} finally {
echo 'Finally block';
You can’t perform that action at this time.