Skip to content

Instantly share code, notes, and snippets.

@vmihailenco
vmihailenco / websocket.go
Created November 22, 2011 10:44
WebSocket server
package main
import (
"fmt"
"os"
"http"
"websocket"
)
type subscription struct {
@vmihailenco
vmihailenco / client.go
Created November 22, 2011 12:23
WebSocket client
package main
import (
"os"
"fmt"
"websocket"
)
const (
NumProcs = 5
@vmihailenco
vmihailenco / model_update.py
Created February 2, 2012 15:57
Model update for Django <= 1.3
import operator
from django.db.models.expressions import F, ExpressionNode
EXPRESSION_NODE_CALLBACKS = {
ExpressionNode.ADD: operator.add,
ExpressionNode.SUB: operator.sub,
ExpressionNode.MUL: operator.mul,
ExpressionNode.DIV: operator.div,
@vmihailenco
vmihailenco / monit_supervisor_programs.py
Created February 5, 2012 14:30
Monit/nagios script to monit supervisord programs state
#!/usr/bin/env python
import sys
import socket
import xmlrpclib
import argparse
def supervisord_processes(address):
try:
@vmihailenco
vmihailenco / ela.go
Created February 15, 2012 15:52
Error level analys for JPEG in Golang
package main
import (
"bytes"
"flag"
"image"
"image/jpeg"
_ "image/png"
"os"
)
@vmihailenco
vmihailenco / dj_monit_celeryd.py
Created March 6, 2012 14:04
Django command to monitor celeryd
import sys
from django.core.management.base import BaseCommand
from celery.task.control import ping
class Command(BaseCommand):
def ok(self, message):
self.stdout.write('OK: %s' % message)
sys.exit(0)
@vmihailenco
vmihailenco / tastypie_logging.py
Created April 14, 2012 08:29
Logging mixin for Django tastypie
class LoggingMixin(object):
def dispatch(self, request_type, request, **kwargs):
logger.debug(
'%s %s %s' %
(request.method, request.get_full_path(), request.raw_post_data))
try:
response = super(LoggingMixin, self).dispatch(
request_type, request, **kwargs)
except (BadRequest, fields.ApiFieldError), e:
.formRow {
.crearfix();
}
is compiled to:
.formRow {
*zoom: 1;
}
.formRow:before,
@vmihailenco
vmihailenco / proxy.go
Created June 25, 2012 21:33
Redis proxy
package main
import (
"flag"
"io"
"log"
"net"
"os"
"os/signal"
"runtime/pprof"
@vmihailenco
vmihailenco / redis_proxy.go
Created July 31, 2012 08:27
redis_proxy.go
package main
import (
"net"
"runtime"
)
func proxy(conn net.Conn) {
buf := make([]byte, 1000)