Skip to content

Instantly share code, notes, and snippets.

@yuga
yuga / gist:5874010
Last active December 19, 2015 01:09
Eclipse Test & Performance Tools Platform Projectのプロファイラの使い方メモ。

Eclipseで使うJava用プロファイラ

Eclipse Test & Performance Tools Platform Project
http://www.eclipse.org/tptp/index.php

以前にYourkit Java Profilerという製品を購入して使ったことがあったけれど、もうだいぶ昔のバージョンになるし、新しいバージョンに更新するにはお金がかかるし、その古いバージョンがリモートのプロセスにアタッチして使うってことができるかどうか調べたことがなかった。AWS上のJavaプロセスにアタッチして、そのプロファイルをとりたかったので、リモートと簡単に接続できるのが必須だったのです。

とりあえずEclipseのサブプロジェクトっぽいEclipse TPTPというのをトライアル。リモートマシンにAgentをインストールしてやる必要があるのだけど、Linux用のパッケージをインストールしたら、中に含まれているソフトウェア構成用のファイルがなぜWindows形式でパスを記述してあって動かないという罠にかかる。Windowsメインで開発してるんですね...

@yuga
yuga / add.sql
Last active December 19, 2015 04:48
/* LearningSQLExample.sql
from http://examples.oreilly.com/9780596007270/LearningSQLExample.sql
Modified for PostgreSQL.
% psql -f add.sql
*/
/* begin table creation */
create table department
(dept_id serial,
@yuga
yuga / gist:6612105
Last active December 23, 2015 09:09
Add support for cabal sandbox to syntastic. Write this in your .vimrc.
function! s:get_cabal_sandbox()
if filereadable('cabal.sandbox.config')
let l:output = system('cat cabal.sandbox.config | grep local-repo')
let l:dir = matchstr(substitute(l:output, '\n', ' ', 'g'), 'local-repo: \zs\S\+\ze\/packages')
return '-s ' . l:dir
else
return ''
endif
endfunction
@yuga
yuga / lcs_length.py
Created October 27, 2013 03:54
アルゴリズムイントロダクション 2巻 第3版 練習問題15.4-2, 15.4-3, 15.4-4
# -*- coding: utf-8 -*-
import codecs
import sys
class Matrix:
def __init__(self, rows, columns, value=0):
self.rows = rows
self.columns = columns
self.mat = [[value for _ in range(columns)] for _ in range(rows)]
@yuga
yuga / Bin.hs
Created November 10, 2013 06:53
What to do to make this to be used as a library?
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MagicHash #-}
module Bin where
import Control.Applicative (Applicative(..), (<$>))
import Control.Monad (ap)
import qualified Data.Array.MArray as M
import Data.Array.Storable hiding (getBounds)
import qualified Data.Array.Unsafe as U
@yuga
yuga / gist:8255552
Last active September 11, 2016 05:34

Haskellでバイナリデータ

1. はじめに

Haskellでバイナリファイルの読み書きをすることがこれまで何回かあったので、それをネタにアドベントカレンダーに参加したつもりだったのですが、定刻よりもだいぶ遅れての年始の到着となりました。申し訳ございません。これはHaskell Advent Calender 2013 11日目だったはずの記事です。明けましておめでとうございます。

さて。コンンピュータで扱うデータはすべてバイナリ形式で表現されています。したがってすべてはバイナリデータであるという言い方ができますが、しかし一般には、テキストでないデータをバイナリデータと呼びます。

Haskellにはバイナリデータを扱うライブラリがたくさんあります。どのライブラリも特別難しい要素があるわけでなく、Haskellのライブラリの中では扱いの容易な部類に含まれるものと思います。しかし、初めて取り組むときには、主要なライブラリのどれも同じようなインターフェイスを提供していることに、何を選べば良いか戸惑う人も多いのではないでしょうか。

GHC管理のメモリを表現する型の違い

        | Immutable   | Mutable           
--------|-------------|-------------------
Boxed   | Array#      | MutableArray#
--------|-------------|-------------------
Unboxed | ByteArray#  | MutableByteArray#
------------------------------------------
@yuga
yuga / printf.idr
Created May 17, 2014 05:30
skills matterにVideoがあがっていたIdrisで書く型安全なprintf; youtube => http://youtu.be/fVBck2Zngjo
module Printf
%default total
data Format = FInt Format -- %d
| FString Format -- %s
| FOther Char Format -- [a-zA-Z0-9]
| FEnd --
format : List Char -> Format
@yuga
yuga / andb_false.v
Last active August 29, 2015 14:02
Logic_J.vより抜粋。tacticを使わずに証明オブジェクトを手書きするのを試しているけど僕には難しい。
(* **** Exercise: 1 star (bool_prop) *)
(** **** 練習問題: ★ (bool_prop) *)
Theorem andb_false : forall b c,
andb b c = false -> b = false \/ c = false.
Proof.
intros b c H.
unfold andb in H.
destruct b.
right. apply H.
left. reflexivity.
@yuga
yuga / typeclass0.hs
Created June 27, 2014 07:35
typeclass0.hs の例でのコンパイルエラーを前に少し悩んだので。
class Producer p where
get :: Resource r => p -> r
class Resource a where
fire :: a -> Int
data A = A Int
data B = B Int
instance Producer A where