Skip to content

Instantly share code, notes, and snippets.

View schuster-rainer's full-sized avatar

Rainer Schuster schuster-rainer

View GitHub Profile
@schuster-rainer
schuster-rainer / MyWPFUI.xaml
Created July 12, 2012 22:16
Clojure.Compile a ClojureCLR script with gen-class and a WPF UI into an executable console app
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="My WPF UI" Height="300" Width="300">
<StackPanel Margin="5">
<StackPanel>
<Label Content="Prename:" />
<TextBox x:Name="preName" MinWidth="50"/>
</StackPanel>
<StackPanel>
<Label Content="Surename:" />
@schuster-rainer
schuster-rainer / wpf_load_xaml.clj
Created July 10, 2012 14:36
Run a WPF Window loaded from a xaml file in ClojureCLR and modify it at the REPL
;reference wpf assemblys
(import '(System.Reflection Assembly))
(Assembly/LoadWithPartialName "PresentationFramework")
(Assembly/LoadWithPartialName "PresentationCore")
(Assembly/LoadWithPartialName "WindowsBase")
(Assembly/LoadWithPartialName "System.Xml")
(ns wpf
(:import (System.Windows Application Window))
(:import (System.Windows.Threading Dispatcher DispatcherPriority))
@schuster-rainer
schuster-rainer / wpf.clj
Created July 6, 2012 19:11
Run a WPF Window from ClojureCLR and modify it at the REPL
;reference wpf assemblys
(import '(System.Reflection Assembly))
(Assembly/LoadWithPartialName "PresentationFramework")
(Assembly/LoadWithPartialName "PresentationCore")
(Assembly/LoadWithPartialName "WindowsBase")
(ns wpf
(:import (System.Windows Application Window))
(:import (System.Windows.Threading Dispatcher DispatcherPriority))
(:import (System.Threading ApartmentState ThreadStart Thread AutoResetEvent))
@schuster-rainer
schuster-rainer / readme
Created June 7, 2012 20:46
python test discovery from commandline and visual studio 2010
# Projekt Structure
- project_root
|
+ doc/
+ src/
+ tests/
+ run_tests.bat
@schuster-rainer
schuster-rainer / RelayCommand.cs
Created May 9, 2012 21:17
Implementation from Josh Smith of the RelayCommand
//http://msdn.microsoft.com/en-us/magazine/dd419663.aspx#id0090030
public class RelayCommand : ICommand
{
#region Fields
readonly Action<object> _execute;
readonly Predicate<object> _canExecute;
#endregion // Fields
@schuster-rainer
schuster-rainer / DynamicBindingProxy.cs
Created May 9, 2012 14:09
INotifyPropertyChanged generic proxy implementation based on DynamcObject and the DLR
// http://www.deanchalk.me.uk/post/WPF-e28093-Easy-INotifyPropertyChanged-Via-DynamicObject-Proxy.aspx
public class DynamicBindingProxy<T> : DynamicObject, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private static readonly Dictionary<string, Dictionary<string, PropertyInfo>> properties =
new Dictionary<string, Dictionary<string, PropertyInfo>>();
private readonly T instance;
private readonly string typeName;
@schuster-rainer
schuster-rainer / create_public_method_proxy.py
Created March 30, 2012 14:58
create a proxy class from the baseclass with methods publish by the method projector
import inspect
import logging
def interrogate(item):
"""Print useful information about item."""
if hasattr(item, '__name__'):
logging.debug( "NAME: " + item.__name__)
if hasattr(item, '__class__'):
logging.debug("CLASS: " + item.__class__.__name__)
logging.debug("ID: {0}".format(id(item)))
@schuster-rainer
schuster-rainer / copy_files_newer_than.sh
Created March 26, 2012 10:42
Copy files that are newer than "date" from "source" to "target"
# $0 = date of format 201203220650
# $1 = source
# $2 = target
touch -t $0 .probe
find $1 -type f -newer .probe -exec cp {} $2 \;
@schuster-rainer
schuster-rainer / load-gtk.fsx
Created February 24, 2012 10:27
Script to reference GTK# assemblies and create an fsi event loop for dispatching the commands
// Script from Tomas Petricek
// http://stackoverflow.com/questions/4174852/how-to-force-f-interactive-to-reference-gtk-by-default
[<AutoOpen>]
module GtkSharp
// Load some common Gtk# assemblies (from /usr/lib/mono/2.0/../gtk-sharp-2.0)
#r "../gtk-sharp-2.0/gtk-sharp.dll"
#r "../gtk-sharp-2.0/gdk-sharp.dll"
#r "../gtk-sharp-2.0/glib-sharp.dll"
@schuster-rainer
schuster-rainer / rx_websocket_protokol.html
Created February 20, 2012 21:58
WebSocket Demo using ws4py, cherrypy to echo incomming traffic. CoffeeScript, jQuery, RxJS, websock.js for the Client
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<title>Pushing with Rx and websock.js</title>
<script src="script/jquery-1.7.1.js" type="text/javascript"></script>
<script src="script/rx.min.js" type="text/javascript"></script>
<script src="script/rx.jquery.js" type="text/javascript"></script>
<script src="script/rx.time.min.js" type="text/javascript"></script>
<script src="script/base64.js"></script>