This file contains hidden or 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
{-# LANGUAGE ScopedTypeVariables #-} | |
module Main where | |
import Network.HTTP | |
import Text.JSON | |
import System.IO.UTF8 as U | |
data Feed = Feed (JSObject JSValue) | |
stringFromObj :: String -> JSObject JSValue -> String | |
stringFromObj s obj = let Ok (v::JSString) = valFromObj s obj in fromJSString v |
This file contains hidden or 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> | |
#include <string.h> | |
#include <mach-o/loader.h> | |
#include <mach-o/nlist.h> | |
#include <assert.h> | |
void *find_function(char *obj, const char *name); | |
int main(void) |
This file contains hidden or 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
{-# LANGUAGE ScopedTypeVariables #-} | |
{-- | |
Copyright (c) 2009, eagletmt | |
Released under the MIT License <http://opensource.org/licenses/mit-license.php> | |
--} | |
-- | This program checks if newly followed or removed. | |
-- Please install the following libraries on ahead: | |
-- json <http://hackage.haskell.org/package/json> | |
-- base64-string <http://hackage.haskell.org/package/base64-string> |
This file contains hidden or 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 Nil {} | |
class Cons(X, XS) {} | |
template length(T) { | |
static if (is(T == Nil)) { | |
const length = 0; | |
} else static if (is(T _ == Cons!(X, XS), X, XS)) { | |
const length = 1 + length!(XS); | |
} | |
} |
This file contains hidden or 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
module Bar where | |
myReverse [] = [] | |
myReverse (x:xs) = myReverse xs ++ [x] |
This file contains hidden or 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
# TypableMap: 公式RT | |
Misuzilla::IronRuby::TypableMap.register("rt", "ReTweet Command") do |p, msg, status, args| | |
System::Diagnostics::Trace.WriteLine("RT: #{status.to_string}") | |
Session.RunCheck(Misuzilla::Applications::TwitterIrcGateway::Procedure.new{ | |
Session.twitter_service.POST("/statuses/retweet/#{status.id}.xml", System::Array[System::Byte].new(0)) | |
Session.send_channel_message("RT: #{status.text}") | |
}, System::Action[System::Exception].new{|ex| | |
Session.send_channel_message(msg.receiver, Server.server_nick, "メッセージ送信に失敗しました", false, false, true) | |
}) | |
true # true を返すとハンドルしたことになりステータス更新処理は行われない |
This file contains hidden or 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
import Data.Maybe (fromJust) | |
import Codec.Binary.UTF8.String (encodeString) | |
import Network.URI (URI, parseURI) | |
import Network.Browser | |
import Network.HTTP | |
tweet :: HStream ty => String -> String -> String -> IO (Response ty) | |
tweet user pass status = browse $ do | |
setOutHandler (const (return ())) | |
addAuthority auth |
This file contains hidden or 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
{-# LANGUAGE TypeFamilies, EmptyDataDecls, TypeOperators, UndecidableInstances #-} | |
data Z | |
data S n | |
data Nil | |
data x :<: xs | |
infixr 5 :<: | |
data Yes | |
data No |
This file contains hidden or 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 ruby1.9 | |
# coding: utf-8 | |
input = ARGF.gets.chomp | |
# 24 区切りに分ける | |
points = [0] * 10 | |
input.each_byte { |c| | |
points[(268-c)/24] += 1 | |
} |
This file contains hidden or 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
import Data.Array | |
import Data.Array.IArray (IArray) | |
import Data.Array.Unboxed (UArray) | |
import Data.Array.ST (STArray, thaw, freeze) | |
import Control.Monad.ST (ST, runST) | |
coerce :: (Ix i, IArray a e, IArray b e) => a i e -> b i e | |
coerce arr = runST $ thawST arr >>= freeze | |
where | |
thawST :: (Ix i, IArray a e) => a i e -> ST s (STArray s i e) |
OlderNewer