Skip to content

Instantly share code, notes, and snippets.

@Whiteknight
Whiteknight / map.cs
Created May 8, 2015 17:56
Map DataRow to nested object
private CreateItem<T>(DataRow row)
where T : new()
{
T item = new T();
foreach (PropertyInfo property in typeof(T).GetProperties())
{
MapFromDataRow(row, "", property, item);
}
return item;
@Whiteknight
Whiteknight / blog.rb
Created December 12, 2012 23:07
If I run this code as-is, the function returns the list of posts as expected. If I uncomment line #4, the function returns an array of nil, breaking my view.
def posts_in_order
ordered = posts.sort{|x, y| x.number <=> y.number }
dummy = for i in (0..ordered.length) do
#x = ordered[i].number
end
return ordered
end
@Whiteknight
Whiteknight / CurrentSettings.vssettings
Created November 30, 2012 20:58
My most recent vssettings file from work
<UserSettings><ApplicationIdentity version="10.0"/><ToolsOptions><ToolsOptionsCategory name="Environment" RegisteredName="Environment"><ToolsOptionsSubCategory name="Documents" RegisteredName="Documents" PackageName="Visual Studio Environment Package"><PropertyValue name="ShowMiscFilesProject">false</PropertyValue><PropertyValue name="AutoloadExternalChanges">false</PropertyValue><PropertyValue name="CheckForConsistentLineEndings">false</PropertyValue><PropertyValue name="SaveDocsAsUnicodeWhenDataLoss">false</PropertyValue><PropertyValue name="InitializeOpenFileFromCurrentDocument">true</PropertyValue><PropertyValue name="ReuseSavedActiveDocWindow">false</PropertyValue><PropertyValue name="DetectFileChangesOutsideIDE">true</PropertyValue><PropertyValue name="DontShowGlobalUndoChangeLossDialog">true</PropertyValue><PropertyValue name="AllowEditingReadOnlyFiles">true</PropertyValue><PropertyValue name="DocumentDockPreference">1</PropertyValue><PropertyValue name="MiscFilesProjectSavesLastNItems">0</PropertyValu
@Whiteknight
Whiteknight / orgapp.txt
Created March 23, 2012 18:53
Parrot organization GSOC application (raw)
Organization ID parrot
Organization Name Parrot Foundation
Organization Description The Parrot Foundation supports development of the Parrot Virtual Machine (PVM) and an entire ecosystem of related library and compiler projects.
Organization Home Page URL http://parrot.org/
Main Organization License Artistic license 2.0
@Whiteknight
Whiteknight / generated.pir
Created March 22, 2012 15:44
Errors with winxed optional params
.sub 'whatever' :subid('WSubId_2')
.param string __ARG_1 :optional
.param int __opt_flag__ARG_1 :opt_flag
if __opt_flag__ARG_1 goto __label_1
.annotate 'line', 10
$P1 = WSubId_1()
set __ARG_1, $P1
__label_1:
.const 'Sub' WSubId_1 = "WSubId_1"
.annotate 'line', 12
@Whiteknight
Whiteknight / winxedcc.winxed
Created February 18, 2012 18:26
pure winxed-to-pbc compiler
function get_winxed_compiler(string pbc_name = "winxedst3.pbc")
{
var wx_pbc = load_packfile(pbc_name);
for (var load_sub in wx_pbc.subs_by_tag("load"))
load_sub();
return compreg("winxed");
}
function main[main](var args)
{
@Whiteknight
Whiteknight / output.txt
Created February 5, 2012 17:14
Optional Args in Winxed
<winxed git:optional_args> ./winxed test.winxed
foo
4
5
6
bar
foo
7
@Whiteknight
Whiteknight / gist:1741304
Created February 5, 2012 00:12
Winxed syntax ideas for NotFound
Some ideas for new winxed syntax:
anonymous function foo(...){...} instead of
function foo(var x named 'bar')
same as:
function foo(var x [named("bar")])
foo(x named 'bar')
same as:
<parrot git:master> ./parrot test.pir
test_call_sig: 3.87282800674438s
test_get_context: 3.55188488960266s
<parrot git:master> ./parrot test.pir
test_call_sig: 4.13274502754211s
test_get_context: 3.56804704666138s
<parrot git:master> ./parrot test.pir
test_call_sig: 3.73126316070557s
N = 100000
SORT_TRANSITION = 6
FORWARD-SORTED (PRESORTED) BENCHMARKS
sort with .sort BUILTIN (reversed)
9.771104s - %100.000000
Number of items out of order: 0
sort with Rosella Query (reversed)
8.664588s - %88.675631 (-%11.324369 compared to base)