Skip to content

Instantly share code, notes, and snippets.

@photofroggy
photofroggy / logging.py
Created November 7, 2011 00:17
BufferedLogger.push method
def push(self, limit=None):
""" Push some queued items out of the queue.
This method causes queued items to be written to be saved to a file.
Only `limit` items will be pushed out of the queue. If `limit` is
`0`, then all items will be pushed from the queue.
"""
if limit is None:
limit = self.default_push
import os
import os.path
from stutter import logging
class ChannelLogger(logging.ThreadedLogger):
""" Channel-concious logger.
This logger hopefully manages to save logs for different channels in
appropriate sub folders of the logging directory.
@photofroggy
photofroggy / subcmd.py
Created November 30, 2011 13:23
Experimenting with subcommands. Really icky code atm. Needs plenty of revision if it is ever going to be a reasonable option.
''' Sub commands
Hackish experiment in supporting sub commands using
reflex as a base. Thrown together pretty quickly.
TODO:
- clean up?
Based on the command stuff found in Terra.
'''
''' dAmnViper.dA.oauth module
Copyright (c) 2011, Henry "photofroggy" Rapley.
Released under the ISC License.
This module provides objects which can be used to authorize applications
with deviantart.com's oAuth API. Note that this product is in no way
affiliated with or endorsed by deviantART.com. This is not an official
service of deviantART.com. This is an independent project created by
photofroggy.
'''
''' Example usage of oAuth objects.
Created by photofroggy.
'''
import os
import sys
from twisted.internet import reactor
sys.path.insert(0, os.curdir)
@photofroggy
photofroggy / da_oauth.py
Created December 6, 2011 22:29
Problems with twisted?
''' Copyright (c) 2011, Henry "photofroggy" Rapley.
Released under the ISC License.
This module provides objects which can be used to authorize applications
with deviantart.com's oAuth API. Note that this product is in no way
affiliated with or endorsed by deviantART.com. This is not an official
service of deviantART.com. This is an independent project created by
photofroggy.
'''
@photofroggy
photofroggy / methods.js
Created June 9, 2012 19:58
new regex parsing
// This stuff determines how certain tablumps are handled.
// lumps[tag] => [ chunks, callback ]
this.lumps = {
'&a\t': [
2, function( data ) {
return '<a target="_blank" href="'+data[0]+'" title="'+data[1]+'">';
}
]
};
@photofroggy
photofroggy / gist:2902640
Created June 9, 2012 21:28
tablump rule stuff
this.lumps = {
'&avatar\t': [ 2, function( data ) {
un = data[0];
icon = data[1];
ru = new RegExp('\\$un(\\[([0-9]+)\\])', 'g');
function repl( m, s, i ) {
return un[i].toLowerCase();
}
io.sockets.on('connection', function (socket) {
var client = net.connect({host: 'chat.deviantart.com', port: 3900});
client.on('data', function(data) {
socket.send( data );
});
client.on('end', function() {
socket.disconnect();
});
@photofroggy
photofroggy / client.html
Created August 18, 2012 05:01
This is a simple client for dAmn.
<html>
<head>
<title>dAmn Chat</title>
<style type="text/css">
body {
width: auto;
margin: 0;
padding: 0;
height: 97%;
overflow: hidden;