Skip to content

Instantly share code, notes, and snippets.

for (; *s; s++) t[*s]++;
void count(char *s, int t1, int t2, …, int t255)
{
if (*s == '\0') {
// output answer
} else if (*s == 1) {
count(str + 1, t1 + 1, t2, …, t255);
} else if (*s == 2) {
count(str + 1, t1, t2 + 1, …, t255);
@yllan
yllan / gist:1436494
Created December 6, 2011 02:58
Scala gist
// Ugly version but works
def cons(a:Any, b:Any) = (m:Any)⇒m.asInstanceOf[Function2[Any,Any,Any]](a,b)
def car(z:Any) = z.asInstanceOf[Function1[Function2[Any,Any,Any],Any]]((a:Any,b:Any)⇒a)
def cdr(z:Any) = z.asInstanceOf[Function1[Function2[Any,Any,Any],Any]]((a:Any,b:Any)⇒b)
// Try with type parameter, failed.
def cons[A,B,Z](a:A, b:B) = (m:(A,B)⇒Z)⇒m(a,b)
def car[A,B](z:((A,B)⇒A)⇒A) = z((a:A, b:B)⇒a)
def cdr[A,B](z:((A,B)⇒B)⇒B) = z((a:A, b:B)=>b)
@yllan
yllan / gist:1437272
Created December 6, 2011 07:52
NSFastEnumeration
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len
$ rvm list
rvm rubies
=> ree-1.8.7-2011.03 [ i686 ]
ruby-1.9.1-p431 [ i386 ]
$ echo $GEM_PATH
@yllan
yllan / gist:1646327
Created January 20, 2012 09:18
libfcgi patch
--- acinclude.m4.orig 2001-12-20 20:12:50.000000000 -0700
+++ acinclude.m4 2009-01-18 23:50:28.000000000 -0700
@@ -1,6 +1,6 @@
dnl $Id: acinclude.m4,v 1.2 2001/12/21 03:12:50 robs Exp $
-AC_DEFUN(FCGI_COMMON_CHECKS, [
+AC_DEFUN([FCGI_COMMON_CHECKS], [
AC_CHECK_TYPE([ssize_t], [int])
AC_MSG_CHECKING([for sun_len in sys/un.h])
@yllan
yllan / gist:1646947
Created January 20, 2012 11:42
libfcgi formula
require 'formula'
class Libfcgi < Formula
url 'http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz'
homepage 'http://www.fastcgi.com'
md5 'd15060a813b91383a9f3c66faf84867e'
def options
[
['--universal', 'Build as a Universal Intel binary.']
@yllan
yllan / gist:1768058
Created February 8, 2012 10:43
會造成截斷的字
𠁹
@yllan
yllan / gist:1840635
Created February 16, 2012 01:33
Create Non-Blocking response
def index = Action {
val slowFetch: Promise[Response] = WS.url("http://fetch.some.data/").get
val asyncResult: Promise[Result] = slowFetch.orTimeout("Can't get data", 10000).map { eitherResponseOrTimeout ⇒
eitherResponseOrTimeout.fold(
timeout ⇒ InternalServerError(timeout),
response ⇒ Ok("Fetched " + response.body)
)
}
@yllan
yllan / gist:1852273
Created February 17, 2012 09:53
Command Line Tools 內容
BluetoothSDK.pkg
CoreAudioSDK.pkg
DevSDK.pkg
DeveloperToolsCLI.pkg
FireWireSDK.pkg
JavaSDK.pkg
OpenGLSDK.pkg
QuickTimeSDK.pkg
WebKitSDK.pkg
X11Documentation.pkg
@yllan
yllan / gist:2233235
Created March 29, 2012 04:16
買日本演唱會門票方法
作者: houyating (橘色和風糰) 看板: N-E-W-S
標題: [分享] 買日本演唱會門票方法
時間: Sat Oct 13 18:02:04 2007
原文照例吃光光(最近糰財布扁到沒錢只好吃b板文維生!?)
以下內容全數轉載自改版前的J'P,前壇主caca的心得感想...
因為改版後該壇主似乎不知去處...