Skip to content

Instantly share code, notes, and snippets.

View freeonterminate's full-sized avatar

HOSOKAWA Jun freeonterminate

View GitHub Profile
@freeonterminate
freeonterminate / NoHungUp.pas
Created May 19, 2014 10:43
こうすると正しくコンパイルエラー
program Project1;
type
TFoo<T> = class; // interface から class に変えた
TBaz<T> = record
Value: TFoo<TArray<T>>; // E2604 ジェネリック型を再帰的に使用しています
end;
TFoo<T> = class
@freeonterminate
freeonterminate / FixBackToFront.pas
Last active August 29, 2015 14:04
バックグラウンドプロセス化したアプリが Front に戻ってきたとき真っ黒問題に対処するコード
//
// あんまり、おこらないかもしれない!
//
// IFMXApplicationEventService をTPlatformServices.Current.GetPlatformService から取り出して
// AppEventService.SetApplicationEventHandler(AppEvent); をして
// そのイベントハンドラで以下の様にする
function TLifecycleManager.AppEvent(
iAppEvent: TApplicationEvent;
iContext: TObject): Boolean;
@freeonterminate
freeonterminate / FMX.MemoHelper.pas
Last active August 29, 2015 14:17
TMemo.Lines.Add を高速化する。
(*
* TMemoHelper
8 [Method List]
* FastAdd - Fast Add Method
*
* [How to use]
* 1. uses FMX.MemoHelper;
* 2. Memo1.FastAdd('something');
*)
unit JavaSample;
interface
uses
Androidapi.JNI.GraphicsContentViewText;
function SaveJavaBitmapToFile(
const iSrc: JBitmap; // JBitmap は android.graphics.Bitmap です。同様に接頭辞 J で始まる物は全部 Java のクラスです
const iFileName: String): Boolean;
@freeonterminate
freeonterminate / uTabControlHelper.pas
Created June 19, 2015 03:08
TTabControl で先頭のタブをプログラムで変更可能にするヘルパー
unit uTabControlHelper;
interface
uses
FMX.TabControl;
type
TTabControlHelper = class helper for TTabControl
private
@freeonterminate
freeonterminate / uIfExp.pas
Last active June 23, 2018 09:12
If expression
(*
* If expression - ternary operator like C.
*
* HOW TO USE
* 1. uses uIfExp;
* 2. IfExp<TYPE>(BooleanValue) - TRUE_VALUE or FALSE_VALUE
* or
* IfExp<TYPE>(BooleanValue).ThenElse(TRUE_VALUE, FALSE_VALUE);
*
* EXAMPLE
(*
* This is sample code (My memorandum)
* System.Net.HttpClient.THttpClient class
*
* Programmed by HOSOKAWA Jun / twitter @pik
*)
program MVPCount;
{$APPTYPE CONSOLE}
@freeonterminate
freeonterminate / HeWo.dpr
Last active September 30, 2015 08:18
先制 hello, world - FreePascal での解答
{
2015/09/30 検証用プログラム修正
CodeIQ で出題された「先制 hello, world」の僕の解答と、ちょっとだけ解説です。
特設ページ http://nabetani.sakura.ne.jp/codeiq/prehewo/index.html
僕が提出したコードは下記(先頭に空白アリ)
{'4#()3.}BEGIN WRITE(LOWERCASE('PREEMPTIVE '#34'HELLO'#44' WORLD'#34))END.
@freeonterminate
freeonterminate / CLikeSwitchCase.pas
Created November 10, 2015 02:34
[tips] C like case-sentence
program CLikeSwitchCase;
function SwitchCase(const A: Integer): Integer;
label
Case0, Case1, CaseElse;
begin
Result := 0;
case A of
0: goto Case0;
@freeonterminate
freeonterminate / Switches.pas
Created November 30, 2015 06:46
順序型以外でも使える Case 文
(*
* Switches
* Case sentence with Anytype !
*
* Copyright (c) 2015 HOSOKAWA Jun.
*
* CONTACT
* Twitter @pik or [email protected]
*
* LAST UPDATE