Skip to content

Instantly share code, notes, and snippets.

function Enter-Using-Undisposable($receiver, [scriptblock]$body, [scriptblock]$finally) {
try {
return $receiver | % { & $body }
}
finally {
& $finally
}
}
function Enter-Using-Excel([scriptblock]$block) {
@ritalin
ritalin / ExampleTest.pas
Created April 17, 2014 04:35
Should-base unit test for DUnitX
unit ExampleTest;
interface
uses
DUnitX.TestFramework;
type
[TestFixture]
TMyTestObject = class(TObject)
// OK
IEnexArraycollection = interface(ICollection<TArray<integer>>)
function Op: TEnexExtOps<TArray<integer>>;
end;
// NG
IEnexArrayCollection<T> = interface(ICollection<TArray<T>>)
function Op: TEnexExtOps<TArray<T>>;
end;
program RecGenerics;
uses
System.SysUtils;
type
IHogeClass<T> = interface;
TTest<T> = record
Value: T;
@ritalin
ritalin / MyForm.pas
Created June 12, 2014 05:07
Class for binding to all child control property in a control (eg: TLayout,...)
procedure MyForm.AfterConstruction;
var
expr: TExpressionItem;
begin
inherited;
BindList2 := TBindControlList.Create(Self);
BindList2.SourceComponent := AdapterBindSource1;
BindList2.SourceMemberName := 'ColorsName1';
[o][230]Command aliases not defined when hosting
[c][229]Bitwise operators -band, -bor and -bxor
[o][228]Invalid expression stops all further processing of input
[c][227]Implement subexpression operator $(...)
[c][226]CSV cmdlets support; Escape character support
[o][225]Single quoted string doesn't allow escaped single quotes
[c][224]Get-Member fix; Introduction of Select-Object cmdlet; Refactoring
[c][223]Split-Path cmdlet
[c][222]Environment provider
[o][221]SessionStateProxy.GetVariable should return the actual object for value types
@ritalin
ritalin / ComponentStream.pas
Last active August 29, 2015 14:03
A support class for cloning component.
unit Sample;
interface
uses
SysUtils, Classes, FMX.Controls;
type
// 名前決定するためのイベント
@ritalin
ritalin / protpcpl_sample.ex
Created September 2, 2014 14:27
型クラスっぽく見える何か by Elixir
defmodule Option do
defmodule None, do: defstruct []
defmodule Some, do: defstruct [:value]
def none(), do: %None{}
def some(x), do: %Some{ value: x }
end
defprotocol FunctorSpec do
@type t :: term
function test(){
get-pscallstack | select -skip 1 -first 1 | %{
if ([io.path]::GetExtension($_.ScriptName) -eq ".psm1") {
if (test-path "$($_.ScriptName).config") {
[xml](Get-Content "$($_.ScriptName).config")
}
elseif (test-path "$($_.ScriptName).json") {
[string]::join('', (Get-Content "$($_.ScriptName).json")) | ConvertFrom-Json
}
else {
<?xml version="1.0" ?>
<configuration>
<appSettings>
<add key="AAA">
<sets>
<add key="AAA_1" value="値1" />
<add key="AAA_2" value="値2" />
<add key="AAA_3" value="値3" />
</sets>
</add>