Skip to content

Instantly share code, notes, and snippets.

@segphault
segphault / extreddit.js
Created March 6, 2012 22:19
Create an Ext JS store that processes data from Reddit's JSON API
Ext.define('MyApp.store.base.RedditStore', {
extend: 'Ext.data.Store',
config: {
storeId: 'MyJsonPStore',
proxy: {
type: 'jsonp',
url: 'http://www.reddit.com/hot.json',
callbackKey: 'jsonp',
reader: {
@segphault
segphault / caltask.rb
Created February 4, 2012 23:56
CalendarStore task in MacRuby
framework "calendarstore"
store = CalCalendarStore.defaultCalendarStore
pred = CalCalendarStore.taskPredicateWithCalendars(store.calendars)
reminders = store.calendars.find {|c| c.title == "Reminders"}
newTask = CalTask.alloc.init
newTask.title = "This is a test"
newTask.calendar = reminders
@segphault
segphault / spottest.rb
Created February 4, 2012 23:50
Querying spotlight with MacRuby
def performSearch(pred, &cb)
search = NSMetadataQuery.alloc.init
search.predicate = pred
search.searchScopes = [File.expand_path("~")]
NSNotificationCenter.defaultCenter.addObserverForName(
"NSMetadataQueryDidFinishGatheringNotification", object:nil, queue:nil,
usingBlock: Proc.new {|n| n.object.results.each {|r| cb.call(r) } })
search.startQuery
@segphault
segphault / game.js
Created February 2, 2012 22:58
Moonbase
//
// Moonbase Mayhem
//
var util = require('util');
var events = require('events');
function Game() {
events.EventEmitter.call(this);
@segphault
segphault / videotest2.html
Created January 20, 2012 10:09
HTML5 photo booth
<html>
<head>
<title>HTML5 Photo Booth</title>
</head>
<body>
<h2>HTML5 Photo Booth</h2>
<video id="live" autoplay></video>
<canvas id="snapshot" style="display:none"></canvas>
@segphault
segphault / videotest.html
Created January 20, 2012 07:45
Live video with getUserMedia
<html>
<head>
<title>HTML5 Webcam Test</title>
</head>
<body>
<h2>The Thing cannot be described&mdash;there is no language for such abysms of shrieking and immemorial lunacy, such eldritch contradictions of all matter, force, and cosmic order</h2>
<video id="live" autoplay></video>
@segphault
segphault / gdeskstatus.py
Created June 2, 2011 05:41
This is the original source code of GDeskStatus, a simple PyGtk+ utility that eventually became Gwibber
#!/usr/bin/env python
import gtk, pango, gobject
import urllib2, base64, time, datetime, os
try:
import simplejson
def loadjson(content): return simplejson.loads(content)
except:
def loadjson(content):
tell application "Dock"
activate
end tell
tell application "System Events"
tell process "Dock"
set frontmost to true
activate
tell list 1
perform action "AXShowMenu" of UI element "Google Chrome"
=== modified file 'client/gwibber-client.vala'
--- client/gwibber-client.vala 2010-11-22 02:06:24 +0000
+++ client/gwibber-client.vala 2010-11-22 04:44:23 +0000
@@ -34,6 +34,7 @@
"Jorge Castro",
"Gustavo Niemeyer",
"Ted Gould"};
+
var messages = new string[10] {
"Adding unit tests to the Unity panel service. Mixing GTester + C++ is interesting, definitely not as bad as I thought it would be.",
#!/usr/bin/env python
import gtk, dbus, dbus.service, sqlite3
from dbus.mainloop.glib import DBusGMainLoop
DB_FILENAME = "/home/segphault/test.sqlite"
DBusGMainLoop(set_as_default=True)
class Notifier(dbus.service.Object):