2008-10-01から1ヶ月間の記事一覧

ActiveSupport、Time#minus_with_coercion

>> Time.local(2008, 12, 31) - Time.local(2008, 12, 30) => 86400.0 >> require "date" => true >> Time.local(2008, 12, 31) - Date.new(2008, 12, 31) TypeError: can't convert Date into Float from (irb):3:in `-' from (irb):3 >> Time.local(2008, …

Commons Lang、StringUtils.isNumeric()

まんま import org.apache.commons.lang.StringUtils; public class C2008103100 { public static void main(String[] args) { System.out.println(StringUtils.isNumeric(null)); System.out.println(StringUtils.isNumeric("")); System.out.println(Strin…

Parsec.Combinator:manyTill

まんま module Main where import Text.ParserCombinators.Parsec simpleComment = do{ string "")) } run :: Show a => Parser a -> String -> IO () run p input = case (parse p "" input) of Left err -> do{ putStr "parse error at " ; print err } Ri…

C API、lua_next()

/* * $ gcc -Wall -W -I/usr/include/lua50 -o 2008103100 -llua50 2008103100.c */ #include <stdio.h> #include <lua.h> int main(void) { lua_State *L; L = lua_open(); lua_newtable(L); lua_pushstring(L, "foo"); lua_pushnumber(L, 10); lua_settable(L, 1); lua_pus</lua.h></stdio.h>…

ActiveSupport、Time#last_year

>> require "rubygems" => true >> require "active_support" => true >> Time.local(2008, 12, 31).last_year => Mon Dec 31 00:00:00 +0900 2007

Commons Lang、StringUtils.isNotEmpty()

まんま import org.apache.commons.lang.StringUtils; public class C2008103000 { public static void main(String[] args) { System.out.println(StringUtils.isNotEmpty(null)); System.out.println(StringUtils.isNotEmpty("")); System.out.println(Str…

Parsec.Combinator:choice

module Main where import Text.ParserCombinators.Parsec run :: Show a => Parser a -> String -> IO () run p input = case (parse p "" input) of Left err -> do{ putStr "parse error at " ; print err } Right x -> print x で、 *Main> :l 20081004_…

C API、lua_rawget(), lua_rawset()

/* * $ gcc -Wall -W -I/usr/include/lua50 -o 2008103000 -llua50 2008103000.c */ #include <stdio.h> #include <lua.h> int main(void) { lua_State *L; L = lua_open(); lua_newtable(L); lua_pushstring(L, "foo"); lua_rawget(L, 1); printf("%d\n", lua_isnil(L, -1))</lua.h></stdio.h>…

ActiveSupport、Time#last_month

>> require "rubygems" => true >> require "active_support" => true >> Time.local(2008, 1, 1).last_month => Sat Dec 01 00:00:00 +0900 2007

Commons Lang、StringUtils.isNotBlank()

まんま import org.apache.commons.lang.StringUtils; public class C2008102900 { public static void main(String[] args) { System.out.println(StringUtils.isNotBlank(null)); System.out.println(StringUtils.isNotBlank("")); System.out.println(Str…

Parsec.Combinator:option

まんま module Main where import Char import Text.ParserCombinators.Parsec priority :: Parser Int priority = option 0 (do{ d <- digit ; return (digitToInt d) }) run :: Show a => Parser a -> String -> IO () run p input = case (parse p "" inp…

C API、lua_newtable(), lua_gettable(), lua_settable()

/* * $ gcc -Wall -W -I/usr/include/lua50 -o 2008102900 -llua50 2008102900.c */ #include <stdio.h> #include <lua.h> int main(void) { lua_State *L; L = lua_open(); lua_newtable(L); lua_pushstring(L, "foo"); lua_gettable(L, 1); printf("%d\n", lua_isnil(L, -1</lua.h></stdio.h>…

ActiveSupport、Time#end_of_year, Time#at_end_of_year

>> require "rubygems" => true >> require "active_support" => true >> Time.local(2008, 1, 1).end_of_year => Wed Dec 31 23:59:59 +0900 2008 >> Time.local(2008, 1, 1).at_end_of_year => Wed Dec 31 23:59:59 +0900 2008

Commons Lang、StringUtils.isEmpty()

まんま import org.apache.commons.lang.StringUtils; public class C2008102800 { public static void main(String[] args) { System.out.println(StringUtils.isEmpty(null)); System.out.println(StringUtils.isEmpty("")); System.out.println(StringUti…

Parsec.Combinator:between

ほぼ、まんま module Main where import Text.ParserCombinators.Parsec braces = between (char '{') (char '}') run :: Show a => Parser a -> String -> IO () run p input = case (parse p "" input) of Left err -> do{ putStr "parse error at " ; pri…

C API、lua_load()

/* * $ gcc -Wall -W -I/usr/include/lua50 -o 2008102800 -llua50 2008102800.c */ #include <stdio.h> #include <lua.h> #include <lauxlib.h> /* from lauxlib.c */ typedef struct LoadF { FILE *f; char buff[LUAL_BUFFERSIZE]; } LoadF; static const char *getF (lua_State *L, v</lauxlib.h></lua.h></stdio.h>…

ActiveSupport、Time#end_of_week, Time#at_end_of_week

>> require "rubygems" => true >> require "active_support" => true >> Time.local(2008, 12, 31).end_of_week => Sun Jan 04 23:59:59 +0900 2009 >> Time.local(2008, 12, 31).at_end_of_week => Sun Jan 04 23:59:59 +0900 2009

Commons Lang、StringUtils.isBlank()

まんま import org.apache.commons.lang.StringUtils; public class C2008102700 { public static void main(String[] args) { System.out.println(StringUtils.isBlank(null)); System.out.println(StringUtils.isBlank("")); System.out.println(StringUti…

Parsec.Combinator:count

module Main where import Text.ParserCombinators.Parsec test1 :: Parser String test1 = count 3 letter run :: Show a => Parser a -> String -> IO () run p input = case (parse p "" input) of Left err -> do{ putStr "parse error at " ; print err…

C API、lua_setgcthreshold()

/* * $ gcc -Wall -W -I/usr/include/lua50 -o 2008102700 -llua50 2008102700.c */ #include <stdio.h> #include <lua.h> int main(void) { lua_State *L; L = lua_open(); printf("%d %d\n", lua_getgccount(L), lua_getgcthreshold(L)); lua_setgcthreshold(L, 1); printf</lua.h></stdio.h>…

ActiveSupport、Time#end_of_quarter, Time#at_end_of_quarter

>> require "rubygems" => true >> require "active_support" => true >> Time.local(2008, 12, 31).end_of_quarter => Wed Dec 31 23:59:59 +0900 2008 >> Time.local(2008, 1, 31).end_of_quarter => Mon Mar 31 23:59:59 +0900 2008 >> Time.local(2008, …

Commons Lang、StringUtils.isAlphaSpace()

まんま import org.apache.commons.lang.StringUtils; public class C2008102600 { public static void main(String[] args) { System.out.println(StringUtils.isAlphaSpace(null)); System.out.println(StringUtils.isAlphaSpace("")); System.out.println…

Parsec.Combinator:sepEndBy1

module Main where import Text.ParserCombinators.Parsec test1 :: Parser String test1 = sepEndBy1 letter (char ',') run :: Show a => Parser a -> String -> IO () run p input = case (parse p "" input) of Left err -> do{ putStr "parse error at …

C API、lua_getgccount(), lua_getgcthreshold()

/* * $ gcc -Wall -W -I/usr/include/lua50 -o 2008102600 -llua50 2008102600.c */ #include <stdio.h> #include <lua.h> int main(void) { lua_State *L; int i; L = lua_open(); printf("%d %d\n", lua_getgccount(L), lua_getgcthreshold(L)); for (i = 0; i < 20; i++) </lua.h></stdio.h>…

ActiveSupport、Time#end_of_month, Time#at_end_of_month

>> require "rubygems" => true >> require "active_support" => true >> Time.local(2008, 12, 1).end_of_month => Wed Dec 31 23:59:59 +0900 2008 >> Time.local(2008, 12, 1).at_end_of_month => Wed Dec 31 23:59:59 +0900 2008

Commons Lang、StringUtils.isAlphanumericSpace()

まんま import org.apache.commons.lang.StringUtils; public class C2008102500 { public static void main(String[] args) { System.out.println(StringUtils.isAlphanumericSpace(null)); System.out.println(StringUtils.isAlphanumericSpace("")); Syst…

Parsec.Combinator:sepEndBy

module Main where import Text.ParserCombinators.Parsec test1 :: Parser String test1 = sepEndBy letter (char ',') run :: Show a => Parser a -> String -> IO () run p input = case (parse p "" input) of Left err -> do{ putStr "parse error at "…

C API、lua_concat()

/* * $ gcc -Wall -W -I/usr/include/lua50 -o 2008102500 -llua50 2008102500.c */ #include <stdio.h> #include <lua.h> int main(void) { lua_State *L; L = lua_open(); lua_pushstring(L, "foo"); lua_pushstring(L, " bar"); lua_pushstring(L, " baz"); lua_concat(L,</lua.h></stdio.h>…

ActiveSupport、Time#end_of_day

>> require "rubygems" => true >> require "active_support" => true >> Time.local(2008, 12, 31).end_of_day => Wed Dec 31 23:59:59 +0900 2008 at_end_of_day はないんだ〜

Commons Lang、StringUtils.isAlphanumeric()

まんま import org.apache.commons.lang.StringUtils; public class C2008102400 { public static void main(String[] args) { System.out.println(StringUtils.isAlphanumeric(null)); System.out.println(StringUtils.isAlphanumeric("")); System.out.pri…