Skip to content

Instantly share code, notes, and snippets.

@mwisnicki
mwisnicki / generic-comparator-adapter.cc
Created April 6, 2010 22:58
TODO: C++ STL comparator adapter
// external
struct Object;
bool compare(Object& l, Object& r);
std::vector<Object*> objects;
// <TODO>
template<class T, class Comparator>
Comparator<T*> adaptToPtr(Comparator<T&> cmp) {
// adapt comparator of T& to T*
// must work for both functions and functors
@mwisnicki
mwisnicki / PassByReference.scala
Created May 6, 2010 02:09
Pass by reference for Scala
// 'out' and 'inout' arguments for scala
object BasicExample {
// out param
def set(newvalue: Int, x: Int => Unit) { x(newvalue) }
// inout param
def inc(amount: Int, x: (Int, Int => Unit)) { x._2(x._1 + amount) }
}
// with wrapper classes
@mwisnicki
mwisnicki / pkgindex.awk
Created July 29, 2010 21:27
Filters INDEX file to remove entries irrelevant to package manager
#!/usr/bin/awk -f
# Filters INDEX file to remove entries irrelevant to package manager
BEGIN {
FS="|"
# descrfile|bdeps|edeps|pdeps|fdeps
skip="^(5|8|11|12|13)$"
}
@mwisnicki
mwisnicki / PreShutdown.java
Created December 9, 2010 20:58
A pre-shutdown JVM hook
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
/**
* Sequentially executes hooks on shutdown, before any shutdown hook registered
* with Runtime#addShutdownHook(Thread).
* Not portable, tested with Sun JVM 1.6u22
*/
public class PreShutdown {
@mwisnicki
mwisnicki / gadget.xml
Created February 16, 2011 00:37
github gadget
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs directory_title="GitHub Repositories"
title="__UP_username__`s GitHub Repositories"
description="Shows a GitHub user's repositories."
author="Aupajo"
author_email="pete@metanation.com"
height="60"
screenshot="http://labs.metanation.com/github-google-gadget/screenshot.gif"
thumbnail="http://labs.metanation.com/github-google-gadget/logo.gif">
@mwisnicki
mwisnicki / pam_af_tool-statlist.xml
Created November 19, 2011 16:05
Crashing on pam_af_tool unlock
<hoststat>
<host hostname='mail.net1.bg'>
<attempts>1</attempts>
<last_attempt>Thu Dec 16 15:33:08 2010</last_attempt>
<status>unlocked</status>
</host>
<host hostname='2002:4e08:934d:0:a41d:e29f:9230:fc9a'>
<attempts>0</attempts>
<last_attempt>Thu Mar 10 15:19:00 2011</last_attempt>
<status>unlocked</status>
@mwisnicki
mwisnicki / ShowPropertiesInGrid.diff
Created February 11, 2012 01:48
Using Grid for layout of PropertyControl
diff -r 0ea90643ac5a -r 61278776d28c Source/PropertyTools.Wpf/PropertyControl/PropertyControl.cs
--- a/Source/PropertyTools.Wpf/PropertyControl/PropertyControl.cs Fri Feb 03 13:45:59 2012 +0100
+++ b/Source/PropertyTools.Wpf/PropertyControl/PropertyControl.cs Fri Feb 10 16:58:49 2012 +0100
@@ -939,12 +939,19 @@
group.Content = categoryItems;
tabItems.Children.Add(group);
}
-
+ var propertyGrid = new Grid();
+ Grid.SetIsSharedSizeScope(propertyGrid, true);
@mwisnicki
mwisnicki / PropertyControl.diff
Created February 14, 2012 09:39
Using Grid for layout of PropertyControl v2
diff -r 0ea90643ac5a -r 468f9a9165a4 Source/PropertyTools.Wpf/PropertyControl/PropertyControl.cs
--- a/Source/PropertyTools.Wpf/PropertyControl/PropertyControl.cs Fri Feb 03 13:45:59 2012 +0100
+++ b/Source/PropertyTools.Wpf/PropertyControl/PropertyControl.cs Mon Feb 13 12:16:16 2012 +0100
@@ -161,6 +161,16 @@
new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
/// <summary>
+ /// The shared size labels property.
+ /// </summary>
+ public static readonly DependencyProperty SharedSizeLabelsProperty =
@mwisnicki
mwisnicki / .gitignore
Created February 19, 2012 18:13
Generic solution for DataTemplate-based editor of value-like types (structs, enums, strings) ?
*.suo
*.*proj.user
_ReSharper.*/
Debug/
Release/
@mwisnicki
mwisnicki / boot.log
Created May 1, 2012 13:47
Boot log for pfSense-2.0.1 (FreeBSD-8.1R-p6) on Intel D2500CC
OK boot -d -v -s
KDB: debugger backends: ddb
KDB: current backend: ddb
KDB: enter: Boot flags requested debugger
[thread pid 0 tid 0 ]
Stopped at kdb_enter+0x3d: movq $0,0xa4b500(%rip)
db> c
SMAP type=01 base=0000000000000000 len=000000000008f000
SMAP type=02 base=000000000008f000 len=0000000000001000
SMAP type=01 base=0000000000090000 len=000000000000e800