スキップしてメイン コンテンツに移動

投稿

C#: XML string to XmlDocument

I have wrote some utility methods for creating XmlDocument from XML string. public static class XMLUtils { // xml string to XmlDocument public static XmlDocument ToXmlDocument(this string xml) { var doc = new XmlDocument(); doc.LoadXml(xml); return doc; } // XmlReader to XmlDocument // XMLReader is useful for read xml data from url source public static XmlDocument ToXmlDocument(this XmlReader reader) { var doc = new XmlDocument(); doc.Load(reader); return doc; } // path to xml file to XmlDocument public static XmlDocument ReadFromPath( string path) { return ToXmlDocument(File.ReadAllText(path)); } }

ActionScript 3.0: Hit Youtube API

I wrote a tiny program for getting Youtube video information by hitting Youtube API in ActionScript 3.0. Some generic classes or methods might be missing but I think you can easily guess what they are doing and can add them easily yourself. Example Usage Ok, starting from the example usage. package utils.video { import flash.display.Sprite; import utils.file.SyncFileSaveDownLoader; import utils.ITaskProgressCounter; import utils.TaskProgressCounter; import utils.video.youtube.YoutubeAPI; import utils.video.YoutubeFLVURLGetEvent; import utils.video.youtube.YoutubeLocalCacheManager; import utils.video.youtube.YoutubeVideoEntryDispatcher; import utils.video.youtube.YoutubeVideoEntryEvent; public class Tester extends Sprite { private var downloader:SyncFileSaveDownLoader = new SyncFileSaveDownLoader(); private var youtubeLocalCacheManager:YoutubeLocalCacheManager = new YoutubeLocalCacheManager("c:\\temp\\youtube&qu

Webアプリケーション開発のためのリンク集

Webアプリケーション全般 OpenSpace : Webアプリの開発に関する非常に有用な情報が満載です! Webアプリケーション開発講座 WEB API 活用 WWWの基礎 とほほのWWW入門 http://x68000.q-e-d.net/~68user/net/ : ネットワークプログラミングを基礎から解説しています。 PHP phpthumb() : PHPでサムネイルを生成するためのソフトウェア cairo-php : PHPで画像処理をするためのCairo Graphics Libraryを利用した拡張モジュール Windows 7 で PHP の開発・実行環境を整える! :少し古い記事ですが、XAMPも含めて設定の仕方が書いてあるので参考になりました。 HTML Tag index : HTMLのタグについての解説サイト CSS Less : CSSをよりプログラムチックに扱うためのライブラリ。ただしLessファイルをCSSにコンパイルする必要があります。 Web API AmazonのProduct APIを使った開発については、 ここ が参考になります。私も早くチャレンジせねば。。。 Ruby Ruby Installer for Windows アクセスランキング解析 言わずと知れた Alexa のサイトです。 認証 Kerberos

PHP: Grouping Elements in Array by Specific Key Field

This is the code for grouping elements in array by specific key field of the element. Code <?php function groupBySpecificKey(array& $source, $key){ $map = array(); foreach($source as $elem){ $groupKey = $elem[$key]; if(is_null($groupKey)) continue; $map[$groupKey][] = $elem; } return $map; } Example $result = groupBySpecificKey($source, 'country'); var_dump($result); $source = array( array('id' => 1, 'name' =>'Joe', 'country' => 'China'), array('id' => 2, 'name' =>'Chris', 'country' => 'USA'), array('id' => 3, 'name' =>'Tod', 'country' => 'USA'), ); The result is below. array(2) { ["China"]=> array(1) { [0]=> array(3) { ["id"]=> int(1) ["name"]=> string(3) "Joe"

JSON

最近 JSON 形式のファイルを扱うことが多く、色んなライブラリを触ってきました。 どれも甲乙つけがたいですが、とりあえずいくつか紹介します。(そのうちコードサンプルを交えたレビューも書きたいと思います。) .Net用のライブラリ Json.NET : stackoverflowではかなり強く推薦されていました。 Jayrock Java用のライブラリ Jackson : これが一番使いやすかったです。annotationの機能はかなり便利です。 XStream : XMLのシリアライゼーションで有名ですが、JSONでも使えます。残念ながらまだ試したことはありません。。。 JSON Tools stringtree.org Json-lib : これも使ったことがあります。多機能すぎて、個人的には使用法を理解するのに時間がかかりました。ちょっと癖があると思います。

SourceForge.net: Platform

This entry is just for my memo. I always forget the sourceforge platform details and googling and googling again and again X( Project web and developer web platform : This page explains what language can be used on sourceforge web services including memory usage limitation etc. Release files for download Subversion repository administration SVN Admin Repo : This page is helpful when you would like to reset svn repository. Shell Service File Management Service : This page explains what protocols can be used for transferring files to source forge server.

ActionScript 3.0: Read catalog.xml

I have written reading catalog.xml program in ActionScript 3.0. I know my code is not perfect however I make my code public because I would like to help someone who would like to analyze catalog.xml... hope it helps :) In short the code is simply reading xml file. package utils.tool { public class CatalogXmlReader { // you should change the namespace based on flash version private static const NS:String = "http://www.adobe.com/flash/swccatalog/9"; public function CatalogXmlReader() { } public function create(xml:XML):SWCCatalog { var ns:Namespace = getDefaultNamespace(xml); if (!(ns.uri === NS)) throw new Error("Namespace is wrong"); var versions:XMLList = xml.child(new QName(ns, "versions")); var swcVersion:SWCVersions = new SWCVersions(); swcVersion.swcVersion = versions

Simplest AIR Application Launch Command

I always forgot how to launch AIR application from command line for debugging purpose :( As you know there are lot of command line options for adl but I think the simplest command is something like below: {PATH_TO_FLEX_SDK}\bin\adl.exe application.xml bin FlashDevelop's prepared bat files, which are generated when you created AIR project, also help your understanding for how the AIR app is launched.

Eclipse Plugin: Programming Language Support

DLTK (Dynamic Languages Toolkit) should help for developing application in language like Ruby, Python etc. Following screenshot is plugin install windows in my eclipse Indigo.

画像処理プログラミングでお勧めの本

私が読んだ画像処理の書籍の中でお勧めできるものをご紹介します。 詳解 画像処理プログラミング 基本的な処理は網羅されています。解説は丁寧で非常に分かりやすいです。特にサンプルプログラムが豊富なので、私のようなDeveloper型(?)の人間にとっても楽しく読めます。残念なのは、掲載されている画像がモノカラーな点と、誤字・脱字が多いことでしょうか。 ディジタル画像処理 画像処理に関する内容が広範に掲載されており、画像処理全体を概観するのに非常に役立ちます。オールカラーなので処理結果を理解しやすいです。今まで読んだ画像処理系の本の中では一番お勧めです! Learning OpenCV この本は分量も多くOpenCVのAPI解説だけにとどまらず、画像処理の理論的背景が非常に詳しく解説されています。お勧めです。 以下の本はちゃんと読んでいませんが、役に立ちそう、面白そうだと思う本です。 詳解 圧縮処理プログラミング 上のリンクからサンプルプログラムもダウンロードできます。

Javascript + HTML5を使った画像処理

HTML5のcanvasエレメントを使うと画像のピクセル処理ができると知りまして、試しにJavascriptで画像処理プログラムを書いてみました。 「画像処理なんてServer Sideでやれよ!」とか「なんでC++ではなくてJavascript?」というご指摘もありそうですがご容赦のほどを。 デモを公開 しました。 注意点など   デモを見るにはHTML5対応のブラウザが必要(当たり前)。  サイズの大きなメディアンフィルタのデモは少し時間がかかるので、気長に待ってください。  サーバサイド側では何もしていません。興味のある方はhtmlのソースを見てください。役に立ちそうなら、勝手に使っちゃってください。(でもこのブログにリンクとか張ってくれると、とても嬉しいです。)  今のところ以下の処理が選択できます。がんばって増やします!! 輝度変換 グレースケール化(YUV画像ののY値信号のみ取り出し) メディアンフィルタ(3x3, 5x5, 7x7) 判別分析法による2値化 Prewitt Filter Sobel Filter Laplacian Filter Sharpening Filter LOG Filter(エッジ検出)  今後、試したい処理 Gammaカーブ変更 コーナー検出 ハフ変換 パターンマッチング アフィン変換 画像のResampling フーリエ変換 バイラテラルフィルタ ラベリング ソースコード例 上記のURLからソースコードを読むと余計なコードが入っていますので、純粋に画像処理部分だけ抜き出したコードを下に示します。 興味がある方は、サンプルサイトのソースコードを読んでみてください。 判別分析法による2値化 function binalyze(srcRgbImageData, destImageData) { var step = 4; var LEN = 256, MAX=255; var srcRgb = srcRgbImageData.data; var dest = destImageData.data; var imgWidth = srcRgbImageData.width; v

Javascriptで実装された画像ギャラリーライブラリ

(2020年5月更新) こちらの下記理由により、デモを非公開にしました。 picasaはもうGoogle Photosに統合されてAPIが変わった。 Gallerifficももうアクティブに開発されていない。JQueryのプラグイン化されたようです。 記録目的で記事は残してあります。 Javascriptで実装された画像ギャラリーのライブラリ集です。 試しにいくつか使ってみた中で実際に使えると思ったものを選びました。 他にもかっこいいものがいっぱいあるのですが、実際使うとなると、なかなか厳しい(=使いにくい)ものも多いです。 最近はブラウザのJavascriptエンジンの性能も上がっていますし、HTML5やCSS3も徐々に浸透してきていますので、 ブラウザでお手軽に見栄えのするものが作れるのが魅力かなと思います。 注意点をいくつか。 上記のデモの場合、1つのオリジナル画像につき、「75px程度の正方形にクロップされた画像」と「幅が500px程度にサイズ変更された画像」の2つが必要です。 Picasaについては画像サイズを指定してクエリを投げられるので、ちょうどよい大きさの画像のクエリを作成して投げれば簡単にサムネイルが画像を取得できます。 肝はデモで使っているURLの https://picasaweb.google.com/data/feed/api/all?alt=rss&kind=photo&thumbsize=72c,512&access=public&imgmax=1600&hl=en_US&max-results=50 のthumbsize=72c,512の部分です。 簡単に説明しますと、サイズの後にcをつけると画像を正方形にクロップしてくれます。何もつけないとアスペクト比を固定して画像をリサイズしてくれます。 詳しく知りたい方は Picasa Data APIの公式ドキュメント を参照してください。 自分で大量の画像のサイズ変更するのは面倒くさいと思います。私の場合はJavaやC#で画像サイズを変更するプログラムを書きました。バッチ処理が可能な画像処理用のソフトを使うのもいいかもしれません。 C#のコードは簡潔で、実行性能もいいので載せておきます。画像を指定したサイズの正方形

Fast Fourier Transform Links

I love a kind of signal processing. The following links are the related to Fourier Transform. Article Nearly Optimal Sparse Fourier Transform Code Tips The faster-than-fast Fourier transform : MIT found fourier transform than fast fourier transform!! フーリエ逆変換を用いたローパスフィルタ(Player10) FFT.java Fast Fourier Transform 2D Fourier Transform On Images

Flatten JSON object to html ul & li items by Javascript

I have written Javascript code snippet which can flatten JSON object to html ul and li items. Please see this example . The example demonstrates flattening the following JSON object. { "Name":"Duke", "Birth Year": 1876, "Skill":{ "Java":"Wizard (hopefully)", "C#":"Master (kidding)", "F#":"Beginner (No!)" }, "Favorite":["Violin", "Programming"] } Actual Javascript code is something like this: // original data var person = { "Name":"Duke", "Birth Year": 1876, "Skill":{ "Java":"Wizard (hopefully)", "C#":"Master (kidding)", "F#":"Beginner (No!)" }, "Favorite":["Violin", "Programming"] } window.onload = function(){ try{ writeAsHtml(person,

Google App Engine

はじめに Google App Engineを試して見ようと思い、 Google App Engine for Java実践クラウド・プログラミング を購入して、ちょっと触って見ました。一通りできることは解説してあるので、とりあえずGoogle App Engineで動くサイトを作りたい人にはいい本かもしれません。 2012年7月8日追記: リンク先をチェックしたら 絶版 になってしまったようです。。。 必要なもの Java SDK: 私はJava SE Development Kit 7u3をインストールしました Eclipse: 私はEclipse IndigoのJava EE IDE for Web Developersをインストールしました Google App Engine Eclipse Plugin:私は以下の画像のものをとりあえずチェックしてインストールしました Bigtable Google App EngineのデータストアサービスであるBigtableのクエリに関しては、以下のリンクが参考になります。 Datastore Queries - Google App Engine — Google Developers 以下のコードでローカル環境に仮想のデータストアサービスがセットアップされます。 package com.dukesoftware.gaej.dao; import org.junit.After; import org.junit.Before; import org.junit.Test; import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; import com.google.appengine.tools.development.testing.LocalServiceTestHelper; public class DaoTest { private final LocalServiceTestHelper helper = new LocalServiceTestHelper(new LocalDatastoreSer

Aptana Studioの設定Tips

皆さんはWeb系の開発環境はどんなものを利用していますか? 私はいろいろ試して、結局 Aptana で公開されているAptana Studioを使っています。 日本語化 IT技術者入門サイト「GOBU」 コンビニメイト テーマの変更 Aptana Studio 3.0ではどういうわけか背景が黒のテーマがデフォルト設定になっています。 個人的には普通の白い背景の方が好きなので変更しました。 手順 メニューバーからWindow->Preferencesと開いて、右のAptana Studioツリー下のThemesという項目を見つけてください。テキストボックスから検索すると早いと思います。 コンボボックスから Aptana Studio 2.X に変更してみてください。 JQueryのコード補完 エディタ上でJQueryのコード補完(Ctrl + Spaceを押して自動的に出てくるやつ)を有効化する方法です。 適切なJQueryのsdocmlファイルをプロジェクト直下にコピーすれば良いようです。少なくとも私の場合はそれだけで上手くいきました。 私は github からjquery.1.4.2.sdocml をコピーしました。 参考にしたサイト Aptana3をインストールしてWeb開発環境を充実させる 3Add Star

クラウド関連のメモ

プラットフォーム Heroku サポート言語数の高いウェブホスティングサービス。サイトには"Ruby, Node.js, Clojure, Java, Python, and Scala. "と書かれているので、かなりの言語が自由に使えるようです。機会があればぜひ使ってみたいです。 AppFog  特に PHPFog はHerokuではサポートされていないPHPのアプリケーションの短期開発に有用そうです。 Windows Azure Web API Windows Live API

Javaライブラリ & 関連リンク

Javaの数多くあるライブラリで、私が気になったものをピックアップします。 Javaのライブラリの解説本としては、 現場で使えるJavaライブラリ が程よい解説の詳しさと、サンプルコードで、大変役に立ちました。 お勧めです。以下はAmazonへのリンクです。 JavaのCommonsのライブラリに関しては、若干古いですが、「O'ReillyのJakarta Commonsクックブック ―Javaプロジェクト必須のレシピ集」が役に立つかも知れません(こちらは私は未購入です...)。 ちなみにリタイアしたApacheプロジェクトは、 The Apache Attic によって管理されています。iBatisなど、私もお世話になったプロジェクトが結構あります。 ハッシュ値を計算するライブラリ SlavaSoft QuickHash Library Java Runtime Environment JRockit 文字列 JTMT : 文字列の類似度チェック Mail Sunの公式: Java Mail Apache Commons : Commons Email msgparser :.msgファイルをパースするためのJavaライブラリ Date Joda Time : Javaの標準実装のDateクラスとTimeクラスを置き換えるための、より高度な時刻や時間を管理するためのクラスライブラリ。定番。 スケジューリング Quartz : IBMでの解説ページ 描画関連 Batik : Apacheの XML Graphics Project で公開されているSVG可視化ライブラリ JFreeChart : JFree で公開されているグラフ描画用ライブラリ Collection Trove4j :高速なJavaのCollectionライブラリ。私は2008年ごろにTrove4jを使いました。今はGoogleのGuavaなどを皆さん使われているのでしょうか? コンパイラ Janino Javacc Jad : Javaのデコンパイラ Jadclipse : eclipse用のJavaコンパイラ 通信 Common

Java: Get the Latest File in Directory

Here is a simple code for getting the latest file from a given directory. public final static File getLatestFile(String dirPath, FileFilter filter){ return getLatestFile(new File(dirPath).listFiles(filter)); } public final static File getLatestFile(File[] files){ long lastMod = 0; File latestFile = null; for (File file : files) { if(file.lastModified() >= lastMod) { latestFile = file; lastMod = file.lastModified(); } } return latestFile; }

PHP: Immutable Row Update by Delete and Insert Operation

If you would like to realize update rows by only allowing delete and insert rows on DB, set operation might be helpful. For PHP, using array_diff function is really useful for realizing the operation. // we would like to insert '4', '5' and delete '2' in this example. // how to do this? $original_ids = array('1', '2', '3'); $new_ids = array('1', '3', '4', '5'); // one solution // 1) the key point is calculating subtract set. // 2) array_values is used only for re-numbering index. e.g. all index will be 0 origin sequence . // the result will be array(1){ [0] => '4', [0] => '5' } $ids_insert = array_values(array_diff($new_ids, $original_ids)); // the result will be array(1){ [0] => '2' } $ids_delete = array_values(array_diff($new_ids, $original_ids));