Skip to content

Instantly share code, notes, and snippets.

View dpogue's full-sized avatar
👨‍💻
I may be slow to respond.

Darryl Pogue dpogue

👨‍💻
I may be slow to respond.
View GitHub Profile
package com.socialtext;
public class Resting
{
public enum Route
{
PAGE("/data/workspaces/%s/pages/%s"),
PAGES("/data/workspaces/%s/pages"),
PAGETAG("/data/workspaces/%s/pages/%s/tags/%s"),
PAGECOMMENTS("/data/workspaces/%s/pages/%s/comments"),
package com.socialtext;
class SignalParameters
{
public enum Fields
{
kBefore,
kAfter,
kLimit,
kOrder,
@dpogue
dpogue / vtem.py
Created October 18, 2010 03:36
First vttest screen (in Python)
import sys
width = 80
height = 24
inner_l = int((width - 60) / 2)
inner_r = 61 + inner_l
sys.stderr.write("\033?3l")
sys.stderr.write("\033[H")
@dpogue
dpogue / gist:752680
Created December 23, 2010 07:05
Python try/except/finally bytecode
*****************************************
* try: *
* import sys *
* try: *
* print 'something else' *
* except AssertionError: *
* print '...failed' *
* except ImportError: *
* print 'Oh Noes!' *
* finally: *
@dpogue
dpogue / gist:754565
Created December 24, 2010 23:30
Python bytecode if/elif/else statements
0 LOAD_GLOBAL 0: kChatBroadcastMsg |
3 STORE_FAST 2: msgtype | msgtype = kChatBroadcastMsg
6 LOAD_FAST 1: flags |
9 LOAD_GLOBAL 3: kRTChatPrivate |
12 COMPARE_OP 2 |
,------ 15 JUMP_IF_FALSE 10 (to 28) | if (flags == kRTChatPrivate):
| 18 POP_TOP |
| 19 LOAD_GLOBAL 4: kChatPrivateMsg |
| 22 STORE_FAST 2: msgtype | msgtype = kChatPrivateMsg
,-------|------ 25 JUMP_FORWARD 47 (to 75) |
@dpogue
dpogue / main.cpp
Created December 27, 2010 11:31
Attempts at a Radix Sorting algorithm
#include <iostream>
#include "radix.h"
using namespace std;
int main() {
RadixSort rs;
int a[] = {130372, 119068, 186654, 129168, 76632, 42031, 46162, 119045, 14752, 193735, 157498, 126817, 142080, 147393, 86974, 127750, 34873, 87204, 65382, 113653, 192509, 121459, 78682, 185678, 79606, 37281, 197370, 99172, 116931, 70106, 10163, 61512, 173365, 16677, 26241, 96800, 56034, 68555, 41906, 38607, 191949, 88513, 156681, 63427, 94429, 48383, 126838, 11463, 72520, 12490 };
void plDrawableSpans::ISortSpace(std::vector<plSpaceBuilderNode*>& nodes, int axis) {
if (nodes.size() < 2)
// Already sorted
return;
hsRadixSort rad;
hsRadixSortElem* list = new hsRadixSortElem[nodes.size()];
hsRadixSortElem* head = list;
for (int i = 0; i < nodes.size(); i++) {
switch (axis) {
@dpogue
dpogue / netcode Blah.cpp
Created January 26, 2011 19:55
Potential idea for conditional data in a network packet
class Blah {
enum {
net_X_pos = (1 << 0),
net_Y_pos = (1 << 1),
net_OtherVar = (1 << 2),
net_AnotherVar = (1 << 3),
...
};
private:
@dpogue
dpogue / netwatcher.py
Created January 30, 2011 10:10
Python script to watch for Avahi/Bonjour workstation broadcasts and present alerts using libnotify
#!/usr/bin/env python
import dbus, gobject, avahi, pynotify, time
from dbus import DBusException
from dbus.mainloop.glib import DBusGMainLoop
TYPE = '_workstation._tcp'
def service_resolved(*args):
name = args[5].split('.')[0]
ip = args[7]
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ctrl="clr-namespace:CCClient">
<RadialGradientBrush x:Key="GlowBrush">
<RadialGradientBrush.RelativeTransform>
<TransformGroup>
<ScaleTransform ScaleX="1.702" ScaleY="2.243"/>
<SkewTransform AngleX="0" AngleY="0"/>
<RotateTransform Angle="0"/>