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/ruby | |
| # -*- coding: utf-8 -*- | |
| $VERBOSE = true | |
| def new_section | |
| puts '-' * 80 | |
| end | |
| # Can a class variable be accessed from the class methods? | |
| class Hoge | |
| @@a = "in #{self}" |
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 Profile | |
| DEFAULT = "default" | |
| def self.generate_source name=DEFAULT | |
| %Q" | |
| #{self}.new #{name.dump} do|p| | |
| # Required Properties | |
| # DO NOT LEAVE THEM EMPTY! | |
| p.src = '' | |
| p.dest = '' |
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 Control.Monad | |
| import System.IO | |
| main :: IO () | |
| main = do | |
| putStr "あなたの名前は? " | |
| hFlush stdout | |
| eof <- isEOF | |
| if eof | |
| then |
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 Kuku where | |
| import qualified Data.Text as T | |
| import Data.Text (Text) | |
| import qualified Data.Text.IO as TIO | |
| -- general function | |
| showText :: (Show a) => a -> Text | |
| showText = T.pack . show |
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 qualified Data.Text.IO as TIO (hGetLine) | |
| import Data.Text (Text) | |
| import qualified Data.Text as T | |
| import System.IO | |
| import Control.Applicative ((<$>), (<*>), pure) | |
| hGetLines :: Handle -> IO [Text] | |
| hGetLines h = do | |
| eof <- hIsEOF h | |
| if eof |
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 PoleEither where | |
| import Control.Monad.Error () | |
| import Data.List (intersperse) | |
| type Birds = Int | |
| type Pole = (Birds, Birds) | |
| landLeft :: Birds -> Pole -> Either String Pole | |
| landLeft n (left, right) = |
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 RPNWriter where | |
| -- 逆ポーランド記法で書かれた式を計算する関数 solveRPN (p.214) に、 | |
| -- Writerモナドを使って計算経過ログをとる機能を追加してみよう。 | |
| import Control.Monad.Writer | |
| import Control.Applicative ((<$>)) | |
| import Data.Char (isDigit) | |
| solveRPNwithLog :: String -> Writer String Double | |
| solveRPNwithLog s = do |
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
| #!/bin/bash | |
| # maybe useful when you want to try your committed vimscript on your vim | |
| # WARNING: as written, this script doesn't backup the destination directory | |
| GIT_PAGER=cat | |
| PAGER=cat | |
| updated_files=$(git diff --name-only master) | |
| dest_dir=$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
| #!/usr/bin/bashdb | |
| # GistID: 4971264 | |
| ###################################################### | |
| # NOTES: | |
| # This is not just an executable shell script. | |
| # You can read this as a blog post also. | |
| # And by excuting, you'll find what I experienced. | |
| # I recommend you to execute this script step by step |
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
| # -*- coding: utf-8 -*- | |
| # GistID: 5023699 | |
| # Tried by: Rails 3.2.12 | |
| # 自己中な (Selfish) Controller | |
| class JikochusController < ApplicationController | |
| def index | |
| @jikochus = Jikochu.all |