Skip to content

Instantly share code, notes, and snippets.

View skahack's full-sized avatar
🐳
...

Hiroki Sato skahack

🐳
...
View GitHub Profile
@skahack
skahack / goo.gl.hs
Created September 13, 2011 23:30
Goo.gl - Google URL shortener
{-# LANGUAGE OverloadedStrings, FlexibleContexts #-}
module Googl
( shorten
, expand
) where
import Control.Applicative ((<$>), (<*>), empty)
import Control.Monad
import Data.Aeson
#import <Cocoa/Cocoa.h>
void applicationMain()
{
NSString *str = @"abcdefghijklmnopqrstuvwxyz";
s
str = [str stringByReplacingOccurrencesOfString:@"a" withString:@"b"];
str = [str stringByReplacingOccurrencesOfString:@"b" withString:@"c"];
}
@skahack
skahack / out
Created September 22, 2011 16:16
test
function! s:hd2str(hd)
" a:hd is a list because to avoid copying the value.
" Old routine.
let start1 = reltime()
let _ = join(map(split(a:hd[0], '..\zs'), 'v:val == "00" ? "" : eval(''"\x'' . v:val . ''"'')'), '')
echomsg '1:'.reltimestr(reltime(start1))
" To use nr2char(), change encoding option.
" nr2char(255) => "\xc3\xbf" (utf8)
@skahack
skahack / gist:1333371
Created November 2, 2011 10:42
Pythonインストールではまった

Pythonインストールではまった

背景

ImportError: No module named time

なぜかこんなエラーが

原因

インストールディレクトリの lib/python{VERSION}/lib-dynload が空になっている インストール元ディレクトリの build/lib.*/* をコピーして解決

@skahack
skahack / gist:2393086
Created April 15, 2012 14:18
CoffeeScript in Yesod

CoffeeScript in Yesod

Settings.hs

widgetFile :: String -> Q Exp
#if DEVELOPMENT
widgetFile = Yesod.Default.Util.widgetFileJsCss ("coffee", coffeeFileReload)
                                                ("lucius", luciusFileReload)
#else
widgetFile = Yesod.Default.Util.widgetFileJsCss ("coffee", coffeeFile)
@skahack
skahack / process.rb
Created May 14, 2012 21:25
Haskell installed packages DocSet for Dash
require 'cgi'
require 'nokogiri'
xml = <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<Tokens version="1.0">
EOF
doc = nil
@interface Range : NSObject <NSFastEnumeration>
@property (readwrite, nonatomic, retain) NSNumber *start;
@property (readwrite, nonatomic, retain) NSNumber *end;
+ (Range *)createWithStart:(NSUInteger)start End:(NSUInteger)end;
- (id)initWithStart:(NSUInteger)start End:(NSUInteger)end;
@end
@implementation Range
@synthesize start = _start;
int main(void) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *str = @"hello";
NSLog(@"%@", [str uppercaseString]);
NSLog(@"%@", [str performSelector:@selector(uppercaseString)]);
NSLog(@"%@", [str performSelector:NSSelectorFromString(@"uppercaseString")]);
[pool release];
(->
lodash = require('lodash')
((root, _) ->
class _Kernel
class: 'Kernel'
constructor: (v) ->
@v = v
@updateProperties()