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 / wiimoterx.py
Created December 19, 2010 22:35
Use reactive framework with wiimotelib to create triggers from data stream. Hopefully, extension methods are implemented the right way into the next release of IronPython
import clr
clr.AddReferenceToFileAndPath(r"c:\shared\lib\wiimote\v4\wiimotelib.dll")
clr.AddReference("System.CoreEx")
clr.AddReference("System.Reactive")
clr.AddReference("System.Interactive")
from System.Linq import *
from WiimoteLib import *
from System.Reactive import *
#if INTERACTIVE
#r "Microsoft.CSharp.dll"
#endif
open System
open System.Dynamic
open System.Linq.Expressions
open System.Reflection
open System.Runtime.CompilerServices
open Microsoft.CSharp.RuntimeBinder
open System
open System.Net.Mail
open System.Security
open System.Security.Cryptography
open System.Text
open SmtpClientExtension
type Account = {
User : string;
@schuster-rainer
schuster-rainer / raven_db_http_api.py
Created September 7, 2011 13:40
ironpython access for the raven_db_http_api
import clr
from System.Net import WebRequest
from System.Text import ASCIIEncoding
from System.IO import StreamReader
def http(method, url, data_string=None, header={}):
request = WebRequest.Create(url)
request.UseDefaultCredentials = True
request.Method = method
@schuster-rainer
schuster-rainer / load-wpf.fsx
Created October 1, 2011 12:02
wpf environ dispatcher for fsi
//-----------------------------------------------------------------------------
// A script utility for using WPF with F# Interactive (fsi.exe)
//
// Copyright (c) Microsoft Corporation 2005-2006.
// This sample code is provided "as is" without warranty of any kind.
// We disclaim all warranties, either express or implied, including the
// warranties of merchantability and fitness for a particular purpose.
//-----------------------------------------------------------------------------
// When running inside fsi, this will install a WPF event loop
@schuster-rainer
schuster-rainer / wpf-host.fsx
Created October 1, 2011 20:12
prototyping panel with fsi and WPF
#if INTERACTIVE
#load "load-wpf.fsx"
#endif
// === WPF ===
open System.Windows
open System.Windows.Controls
open System.Windows.Media.Imaging
@schuster-rainer
schuster-rainer / svn_change_history.py
Created October 12, 2011 12:41
get the change history from a repository and write it as csv to disk
# download and install http://pysvn.tigris.org
import pysvn
import csv
from datetime import datetime
svn = pysvn.Client()
#DATEFORMAT = "%Y-%m-%d %H:%M:%S"
DATEFORMAT = "%Y-%m-%d"
@schuster-rainer
schuster-rainer / logging_sample.py
Created January 10, 2012 10:59
configure console and rotating logger
import os
import logging
import logging.handlers
import datetime
def configure_console_and_rotating_logger(log_file_name=__name__,
log_folder="./logs",
date_format="%Y-%m-%d %H:%M:%S",
log_format="%(asctime)s - %(module)s - %(levelname)s - %(message)s",
log_level=logging.NOTSET,
@schuster-rainer
schuster-rainer / jquery_json_rpc_20.js
Created January 12, 2012 22:41
jQuery json-rcp 2.0 using $.ajax
$.ajax({url: "to/my/service/endpoint.what",
type: "POST",
contentType: "application/json",
data: JSON.stringify({"jsonrpc": "2.0",
"method": "remote_func", "params": ["arg1","arg2"], "id": 1,
}),
dataType: "json",
success: function(response) {
alert(response.result);
},
@schuster-rainer
schuster-rainer / qmlview.py
Created February 10, 2012 09:33
QML viewer using PySide to display a qml or html embedding a qml
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from PySide import QtCore, QtGui, QtDeclarative
import argparse
from PySide.QtWebKit import QWebPluginFactory, QWebView, QWebSettings