Skip to content

Instantly share code, notes, and snippets.

@yashigani
yashigani / MyPickerView.h
Last active June 28, 2017 01:48
MyPickerView
#import <UIKit/UIKit.h>
@interface MyPickerView : UIView
<UIPickerViewDataSource, UIPickerViewDelegate>
{
UIToolbar *toolbar;
UIPickerView *picker;
void (^completion)(NSString *selected);
- (void)sizeToFitWithAnchorPoint:(AnchorPoint)anchorPoint
{
CGRect srcFrame = self.frame;
[self sizeToFit];
CGRect dstFrame = self.frame;
CGPoint p = dstFrame.origin;
switch (anchorPoint) {
case AnchorPointRightTop:
p = CGPointMake(
CGRectGetMaxX(srcFrame) - dstFrame.size.width,
@yashigani
yashigani / sugoih_osaka1.hs
Created November 10, 2012 13:44
すごいH本読書会 in 大阪 #1 練習問題
-- ex1
-- my null
null' xs = xs == []
-- my sum
sum' xs = if null' xs then 0 else head xs + sum' (tail xs)
-- my product
product' xs = if null' xs then 1 else head xs * product' (tail xs)
@yashigani
yashigani / sugoih_osaka3.hs
Last active December 11, 2015 00:29
すごいH本読書会 in 大阪#3の練習問題を解いた
-- すごいHaskell読書会 in 大阪 #3
-- 練習問題
-- 問題1
-- 次のリスト内包を **map** と **filter** で書き直してみましょう
-- [ x ^ 2 | x <- [1..5], odd x]
q1 = map (^2) $ filter odd [1..5]
-- 問題2
@yashigani
yashigani / Parupunte.hs
Created January 30, 2013 21:34
すごいH本読書会 in 大阪#4
module Parupunte
( (+)
, (*)
) where
import qualified Prelude as Pre
(+) a b = b Pre.* a
(*) a b = b Pre.+ a
@yashigani
yashigani / gist:4943873
Created February 13, 2013 11:03
すごいH本読書会#5 練習問題

ブックマークをつくる

Webブラウザのブックマークのデータ構造を作ってみましょう.ブックマークのツリーには以下のノードがあります.

  • ブックマーク
  • フォルダ

ノードはそれぞれ以下の要素を持ちます.

ブックマーク

  • name
@yashigani
yashigani / gist:4944114
Created February 13, 2013 11:57
すごいH本読書会 in 大阪 #5
data Bookmark = Bookmark { name :: String, url :: String } |
Folder { name :: String, children :: [Bookmark] } deriving (Show, Eq)
root = Folder "root" [(Bookmark "sample1" "http://example.com"),
(Bookmark "sample2" "http://example.com"),
(Bookmark "sample3" "http://example.com")]
emptyChildren = Folder "root" []
recursibleFolder = Folder "root" [(Bookmark "sample1" "http://example.com"),
root]
@yashigani
yashigani / sugoi2.hs
Created February 17, 2013 22:56
すごいH本読書会 in 大阪#2の練習問題を解いた
import Data.Char (toUpper, intToDigit)
import Data.List (concat, words, tails, isPrefixOf)
upperCase :: String -> String
upperCase = map toUpper
removeSpace :: String -> String
removeSpace = concat . words
cover :: Eq a => [a] -> [a] -> Bool
@yashigani
yashigani / gist:5116116
Created March 8, 2013 12:22
すごいH本読書会 in 大阪 #6
data Akari a = Waai a (Akari a) | Daisuki deriving (Show)
data H oo gle = H oo oo oo oo oo gle deriving (Show)
data Ha y oo = Ha y oo oo oo oo oo deriving (Show)
data O b = OOOO|OOOOOO|O|OO deriving (Show)
data Hom r a = Hom (r -> a)
data State s a = State (s -> (a, s))
data Just a = Nothing | Maybe (Maybe a)
instance Functor Akari where
fmap _ Daisuki = Daisuki
@yashigani
yashigani / main.md
Last active December 15, 2015 08:38
すごいH本読書会 in 大阪 #7

すごいH本読書会 #7

8章 入出力

Hello, world

そのまえに...

入出力(I/O)の基本

  • I/Oアクションとは何か?
  • I/Oアクションはどう入出力を可能にするか?