Skip to content

Instantly share code, notes, and snippets.

@propella
propella / MyModel.cpp
Created July 3, 2011 06:11
Qt drag and drop test
#include "MyModel.h"
MyModel::MyModel(const QStringList &strings, QObject *parent)
: QAbstractListModel(parent)
{
_list = strings;
}
// columnCount はデフォルトの実装があるので rowCount のみ実装します。
int MyModel::rowCount(const QModelIndex &) const
@propella
propella / MyModel.cpp
Created June 16, 2011 23:31
Qt model-view test
#include "MyModel.h"
// お約束として、コンストラクタで親オブジェクトを渡す。
// 親オブジェクトが削除されると子オブジェクトも削除されるしくみ。
MyModel::MyModel(const QStringList &strings, QObject *parent)
: QAbstractListModel(parent)
{
stringList = strings;
}
@propella
propella / reversible.hs
Created December 20, 2010 08:08
An idea of reversible parser
-- An idea of reversible parser
-- todo: String8 Structure
{-# OPTIONS -XViewPatterns #-}
import Data.Bits
import Test.HUnit
main = runTestTT $ test [
"bitOf" ~: testBitOf,
module Heap where
import Test.QuickCheck (verboseCheck)
data Heap a = E | T Int a (Heap a) (Heap a)
instance Show a => Show (Heap a) where
showsPrec _ E = showString "_"
showsPrec _ (T r x E E) = showElement r x
showsPrec _ (T r x a b) = showChar '(' . showElement r x . showChar ' ' . shows a . showChar ' ' . shows b . showChar ')'
(*
Generate Hello World Flash version
./outsprite
build:
ocamlc -g -I ocaml -I ocaml/swflib ocaml/extLib.cma ocaml/swflib/swflib.cma -o abcsprite abcsprite.ml
*)
open As3
(*
Generate SWF from a ActionScript bytecode file.
abc2swf filename.abc [width height]
build:
ocamlc -g -I ocaml -I ocaml/swflib ocaml/extLib.cma ocaml/swflib/swflib.cma -o abc2swf abc2swf.ml
*)
open Swf
(* Generate Hello World program in a ABC file *)
open As3
let filename = "outabc.abc"
let id i = As3parse.magic_index i
let idz i = As3parse.magic_index_nz i
(* constants *)
// 終端記号の定義
terminals z s
// 文法定義 n は z または s n
syntax
n ::= z
| s n
// 公理
// judgment 名前 : 式
-- Test for type classes
class Eq a => Point a where
radian :: a -> Float
coordinates :: Float -> Float -> a
x :: a -> Float
y :: a -> Float
-- Minimal complete definition: radian, coordinates, x, and y
(+~) :: Point b => a -> b -> a
@propella
propella / SineSound.as
Created May 25, 2009 07:15
A simple sin wave sound.
// SineSound.as
// A simple sine sound.
//
// compile option
// mxmlc -target-player 10.0.0 SineSound.as
package {
import flash.display.Sprite;
import flash.events.SampleDataEvent;
import flash.media.Sound;