Skip to content

Instantly share code, notes, and snippets.

Chris Eberle eberle1080

Block or report user

Report or block eberle1080

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@eberle1080
eberle1080 / PyUnicode_AsASCIIString.cpp
Created Oct 22, 2013
An example of how to use PyUnicode_AsASCIIString
View PyUnicode_AsASCIIString.cpp
// Assumption: you have a variable named "pyobj" which is
// a pointer to an instance of PyUnicodeObject.
PyObject* temp = PyUnicode_AsASCIIString(pyobj);
if (NULL == temp) {
// Means the string can't be converted to ASCII, the codec failed
printf("Oh noes\n");
return;
}
@eberle1080
eberle1080 / kwallet.py
Created Oct 21, 2011
Python KWallet sample usage (command line)
View kwallet.py
# I just wanted to find a simple way to store credentials in KWallet, and fetch it from
# a command line application. Here's how (assumes the credentials are already set):
def getCredentials():
from PyKDE4.kdeui import KWallet
from PyQt4 import QtGui
from PyQt4 import QtCore
app = QtGui.QApplication([])
wallet = KWallet.Wallet.openWallet(KWallet.Wallet.LocalWallet(), 0)
@eberle1080
eberle1080 / dirwatcher.scala
Created Sep 26, 2011
Recursive directory watcher in Scala
View dirwatcher.scala
/**
* dirwatcher.scala
*
* Uses the Java 7 WatchEvent filesystem API from within Scala.
* Adapted from:
* http://download.oracle.com/javase/tutorial/essential/io/examples/WatchDir.java
*
* @author Chris Eberle <eberle1080@gmail.com>
* @version 0.1
*/
@eberle1080
eberle1080 / dirwatcher.scala
Created Sep 25, 2011
Uses the Java 7 WatchEvent filesystem API from within Scala
View dirwatcher.scala
/**
* watcher.scala
*
* Uses the Java 7 WatchEvent filesystem API from within Scala.
* Based on http://markusjais.com/file-system-events-with-java-7/
*
* @author Chris Eberle <eberle1080@gmail.com>
* @version 0.1
*/
@eberle1080
eberle1080 / leds.py
Created Jun 28, 2011
Schoolbus LED script
View leds.py
#!/usr/bin/env python
# Randomly change LED lights on schoolbus
import sys, random, time
def main():
while True:
fh = open('/dev/led', 'w')
fh.write(random.choice(('shutdown', 'fault on', 'fault off', 'ready on')) + '\n')
fh.close()
@eberle1080
eberle1080 / module_watcher.py
Created Jun 7, 2011
Automatically reload python module / package on file change
View module_watcher.py
#!/usr/bin/env python
# Author: Chris Eberle <eberle1080@gmail.com>
# Watch for any changes in a module or package, and reload it automatically
import pyinotify
import imp
import os
class ModuleWatcher(pyinotify.ProcessEvent):
"""
You can’t perform that action at this time.