続くかどうかも分かんないで、とりあえず gist にアップ。
もうちょいなんかやんかなってきたら github に移すかもしらんっすー。
System.Console.ANSI がない言われた場合は http://alphaneet.hatenablog.com/entry/2012/01/23/022059 ここらへんを参考にしてくだしあ。
This file contains 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 -*- | |
import sys | |
sys.path = ['mechanize-0.2.5'] + sys.path | |
import mechanize | |
import imaplib | |
import datetime | |
gmail_user = '自分のGmailのID' | |
gmail_pass = '自分のGmailのパスワード' |
This file contains 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
;;; defn で関数の定義。引数は [] で囲む | |
(defn hello-work [a, b] | |
;; format を使うと printf ライクに書ける | |
(println (format "hello work %s %s" a, b))) | |
;;; 純粋 Lisp は空白を区切りとして扱うが、Clojure は「 , も空白として扱う」らしい | |
;;; 下記は両方とも意味は同じ | |
(hello-work "comma", "test") | |
(hello-work "space" "test") |
This file contains 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
object Par extends processing.core.PApplet { | |
applet => | |
import processing.core.{ | |
PImage, | |
PGraphics, | |
PVector | |
} | |
import processing.core.PConstants.{ | |
P2D, |
This file contains 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
object Main { | |
def createGUI(width: Int, height: Int) { | |
val frame = new javax.swing.JFrame("hoge") | |
val swing = new Swing | |
val dim = new java.awt.Dimension(width, height) | |
val applet = new PApplet(swing, width, height) | |
swing.setOpaque(false) | |
swing.setPreferredSize(dim) | |
swing.setLayout(null) |
This file contains 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 sbt._ | |
// 一般的な sbt project では Keys._ をするが、どこで使用してるか分かりやすくするためコメントアウト | |
//import Keys._ | |
object MyBuild extends Build { | |
val prompt = "oppai> " | |
lazy val root = Project( | |
id = "root", | |
base = file("."), |
This file contains 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 System.Exit ( exitWith, ExitCode(ExitSuccess) ) | |
-- http://hackage.haskell.org/package/GLUT | |
import Graphics.UI.GLUT | |
intToFloat :: Int -> Float | |
intToFloat n = read (show n)::Float | |
--scrx :: Int -> Float | |
scrx :: Fractional a => a -> a | |
scrx x = 2 * x / 320.0 - 1.0 |
This file contains 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 processing.core._ | |
object Main extends processing.core.PApplet { | |
import PConstants._ | |
val pos = new PVector() | |
val bullets = scala.collection.mutable.ArrayBuffer[PVector]() | |
override def setup() { |
This file contains 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
case class Idenshi(id: Int) | |
class Animal(val i: Idenshi) | |
class Dog(i: Idenshi) extends Animal(i) | |
class Tiwawa(i: Idenshi) extends Dog(i) | |
val a = new Tiwawa(Idenshi(3)) | |
println(a.i) | |
/** |
This file contains 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
package hoge { | |
case class A(str: String) { def run() = println("a dao: " + str) } | |
} | |
package object hoge { | |
implicit def strToA(str: String) = A(str) | |
} | |
object Main extends App { | |
import hoge._ |
OlderNewer