Skip to content

Instantly share code, notes, and snippets.

View eagletmt's full-sized avatar

Kohei Suzuki eagletmt

View GitHub Profile
{-# 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
#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)
{-# 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>
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);
}
}
module Bar where
myReverse [] = []
myReverse (x:xs) = myReverse xs ++ [x]
# 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 を返すとハンドルしたことになりステータス更新処理は行われない
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
{-# LANGUAGE TypeFamilies, EmptyDataDecls, TypeOperators, UndecidableInstances #-}
data Z
data S n
data Nil
data x :<: xs
infixr 5 :<:
data Yes
data No
#!/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
}
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)