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

投稿

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));

Java実装のWeb Browser

Lobo: Java Web Browser Cobra CSSBox : Pure JavaのHtml, CSS2.1レンダーを行えるライブラリ Pure Javaでないものですと、SWTやJava FXで使用可能なWeb Browserのコンポーネントがあります。 org.eclipse.swt.browser.Browser javafx.scene.web.WebView

ActionScript 3.0: Test Tools

Test Suite AsUnit : FlashDevelop からでも使えます。 AS3Unit :ActionScript 3のためのテストフレームワークです。JUnitのActionScript 3.0版といったところでしょうか。 Spark Project 上で公開されています。 FlexUnit : AdobeLabs で公開されているTestSuitです。 FlexMonkey : FlexのためのUIのテストフレームワークです。 FlexPMD : Javaで有名なPMDのFlex版といったところでしょうか。 Code Coverage Tool flexcover :Code Coverage Tool for Flex and AIR applications.

Java: Resize Image Using Graphics2D

Here is a code for resizing image using Graphics2D. I also put bunch of rendering hints in the example code. Hope it helps for your understanding. private static BufferedImage resize(BufferedImage image, int width, int height) { BufferedImage shrinkImage = new BufferedImage(width,height, image.getType()); Graphics2D g2d = shrinkImage.createGraphics(); // rendering hints g2d.setRenderingHint(KEY_ALPHA_INTERPOLATION, VALUE_ALPHA_INTERPOLATION_QUALITY); g2d.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON); g2d.setRenderingHint(KEY_COLOR_RENDERING, VALUE_COLOR_RENDER_QUALITY); g2d.setRenderingHint(KEY_DITHERING, VALUE_DITHER_ENABLE); g2d.setRenderingHint(KEY_TEXT_ANTIALIASING, VALUE_TEXT_ANTIALIAS_ON); g2d.setRenderingHint(KEY_RENDERING, VALUE_RENDER_QUALITY); g2d.setRenderingHint(KEY_INTERPOLATION, VALUE_INTERPOLATION_BILINEAR); g2d.setRenderingHint(KEY_FRACTIONALMETRICS, VALUE_FRACTIONALME...

C#でExcelファイルの読み書き

C#でExcelファイルを読み書きするためには、まず以下の2つの準備が必要です。 Microsoft Office (Excel)のインストール Visual Studioから「参照の追加」=> 「COM」タブからMicrosoft Excel 11 Object Libraryを追加(COMのバージョン部分は、インストールしたOfficeのバージョンに依存します) サンプルコード 以下は、実際にExcelファイルを開いて、Cellへの読み書き、sheetの追加を行うサンプルコードです。 using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Office.Interop.Excel; namespace Example { class ExcelExample { private static void RunExcelExample() { Excel.Workbook book = null; Excel.Application excel = null; try { excel = new Excel.Application(); book = excel.Workbooks.Open(@"c:\test.xls", Type.Missing, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, ...

ActionScript3.0: Reflection Example

I introduce some tips for reflection (not reflection of image but "programatic") of ActionScript 3.0. getDefinitionByName If you would like to Class object getDefinitionByName function should help. var c:Class = getDefinitionByName("flash.display.Sprite") as Class; If you would like to know details information of Class you can use describeType , which returns class information as Xml format. Reflective Class Instantiation import flash.utils.getDefinitionByName; public class Instantiator { private var classRef:Class; public function Instantiator(className:String) { this.classRef = getDefinitionByName(className) as Class; } public function newInstance(...args):Object { if(args.length == 0){ return new classRef(); } else { return new classRef(args); } } } Example usage: import flash.display.Sprite; import seedion.io.XMLExporter; // class will be instantiated at line with (*) import utils.tool.Instantiat...