Skip to content

Instantly share code, notes, and snippets.

View freeonterminate's full-sized avatar

HOSOKAWA Jun freeonterminate

View GitHub Profile
@freeonterminate
freeonterminate / FMX.Log.pas
Last active August 29, 2015 13:55
FMX.Types.Log が色々ダメ(Log.d の実態が Log.i だったり、Windows だと出力されなかったり、TAG が全く意味が無かったり)なので作った。
{
最新版は github に引っ越しました
FMX.Log newest version moved to github.
https://github.com/freeonterminate/delphi/tree/master/FMXLog
}
@freeonterminate
freeonterminate / FizzBuzzNoIf2.pas
Created February 18, 2014 05:03
if 文を使わない FizzBuzz version 2
program FizzBuzz;
uses
System.SysUtils;
var
i: Integer;
S: array [0.. 2] of String = ('', 'Fizz', 'Buzz');
begin
for i := 1 to 100 do
Writeln(S[Ord(i mod 3 = 0)] + S[Ord(i mod 5 = 0) shl 1], i.ToString.Substring(0, (i mod 3) * (i mod 5) * $ff));
end.
@freeonterminate
freeonterminate / PosixTest.pas
Created February 21, 2014 08:47
DCCARM で POSIX が定義されているか実験
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls;
type
TForm1 = class(TForm)
@freeonterminate
freeonterminate / IntentSample.pas
Created March 7, 2014 01:23
Intent を使うサンプル
uses
Androidapi.JNI.JavaTypes,
Androidapi.JNI.GraphicsContentViewText,
FMX.Log,
FMX.Helpers.Android;
procedure StartIntent;
var
Intent: JIntent;
begin
@freeonterminate
freeonterminate / NSWindowSample.pas
Last active August 29, 2015 13:57
OS X の API が、シームレスに扱える例です。
uses
Macapi.ObjectiveC,
Macapi.CocoaTypes,
Macapi.Foundation,
Macapi.AppKit,
FMX.Platform.Mac
procedure SetMinSize(const iForm: TForm; const iMinW, iMin: Integer);
var
Wnd: NSWindow; // OS X 用のクラスがそのまま使えてる
unit uKeyHook;
interface
uses
Winapi.Windows;
type
TKeyHookEvent = procedure(const iVKKey, iState: DWORD) of object;
@freeonterminate
freeonterminate / Generics.pas
Created May 19, 2014 09:15
Delphi Generics
program Project1;
uses
System.SysUtils;
type
TTest<T> = record
Value: T;
end;
@freeonterminate
freeonterminate / Hang.pas
Last active August 29, 2015 14:01
最小限の Hung Up コード
program Project1;
type
IFoo<T> = interface;
TBar<T> = record
Value: IFoo<TArray<T>>;
end;
IFoo<T> = interface
@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;