Skip to content

Instantly share code, notes, and snippets.

@exallium
exallium / rfcomm.py
Created January 10, 2012 19:17
rfcomm
import bluetooth
server_sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
port = bluetooth.get_available_port( bluetooth.RFCOMM )
server_sock.bind(("",port))
server_sock.listen(1)
print "listening on port %d" % port
uuid = "00001101-0000-100­0-8000-00805F9B34FB"
@exallium
exallium / make.sh
Created February 19, 2012 01:06
load and execute lua function
g++ -o test test.cpp -llua
@exallium
exallium / thread.cpp
Created February 19, 2012 16:37
Boost Multithread Example
#include <iostream>
#include <boost/thread.hpp>
using namespace std;
using boost::thread;
using boost::mutex;
mutex a;
const int THREAD_COUNT = 10;
@exallium
exallium / thread.cpp
Created March 5, 2012 03:38
Boost Multithread Example with shared lock
#include <iostream>
#include <boost/thread.hpp>
using namespace std;
using boost::thread;
using boost::mutex;
using boost::shared_lock;
using boost::shared_mutex;
using boost::upgrade_lock;
using boost::upgrade_to_unique_lock;
@exallium
exallium / reverse.asm
Created March 10, 2012 20:53
YASM/NASM Reverse a string w.o. copy for x64 Linux
; ------------------------
; reverse.asm - Reverse a string without copying it
; Max length of string is 64 bytes
; This is for an x86_64 Linux System
; Assemble with:
; yasm -f elf64 reverse.asm
; Link with:
; ld -o reverse reverse.o
; Note: Also perfectly capable of swapping yasm for nasm without changing code
; ------------------------
@exallium
exallium / bot.py
Created May 8, 2012 17:02
Simple IRC bot using ircutils
from ircutils import bot
from random import randint
# Nice to me
GOOD_PEOPLE = ['exallium']
GOOD_RESPONSES = ['Yes, sir.', "At once.",
"Right away, sir", "Of course.", "Absolutely."]
# Rude to people who aren't me.
BAD_RESPONSES = ["No.", "I'm not your toy.", "F*** off.",
@exallium
exallium / urlencoder.c
Created May 12, 2012 02:53
URL Encoder / Decoder in C, (C) Geek Hideout
/**
* @file urlencode.c
* @brief URL Encoder and Decoder
* @author Geek Hideout
* @date 2011
*/
/* Copyright 2011 Geek Hideout. http://geekhideout.com
* Retrieved May 11th, 2012
*/
@exallium
exallium / settings_local.py
Created July 17, 2012 12:50
SQL Query Logging for Django, just in case.
# Required
DEBUG = True
# SQL Query Logging
# Rename _LOGGING to LOGGING to enable.
_LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'simple': {
@exallium
exallium / renderer.coffee
Created August 11, 2012 02:28
CoffeeScript/Backbone Template Renderer with Caching, originally written in JS on github
class TemplateRenderer
constructor: (@directory='/static/templates', @cache={}) ->
render: (name, tmpl_data) ->
unless @cache[name]
url = @directory + '/' + name + '.html'
tmpl_string = null
$.ajax {
url: url,
method: 'GET',
@exallium
exallium / wrapper.py
Created August 30, 2012 01:41
Wrapper Class
class Wrapper(object):
def __init__(self, **kwargs):
for key, value in kwargs.items():
setattr(self, key, value)