Skip to content

Instantly share code, notes, and snippets.

View gdamjan's full-sized avatar

Дамјан Георгиевски gdamjan

View GitHub Profile
@gdamjan
gdamjan / gist:666499
Created November 7, 2010 20:41
connect in to the realtime twitter stream
-module(twit2).
-author('gdamjan@gmail.com').
-export([start/0]).
%%% http://dev.twitter.com/pages/streaming_api_concepts#connecting
%%% TODO:
%%% - handle timeouts
%%% - handle errors
%%% - backoff (exponential, start 10 secs, up to 240 secs)
@gdamjan
gdamjan / pedometer.c
Created December 16, 2010 21:44
somethingmeter in C
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/io.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define INTERFACE "ppp0"
@gdamjan
gdamjan / gist:792308
Created January 23, 2011 18:38
PyQt applet for a conference timer - originally done for TEDxSkopje, can be customized for anything else
#! /usr/bin/env python3
# -*- encoding: utf8 -*-
# references:
# http://doc.qt.nokia.com/4.6/stylesheet.html
# http://doc.qt.nokia.com/4.6/statemachine-eventtransitions.html
# http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/pyqt4ref.html
# http://www.ibm.com/developerworks/linux/library/l-pygen.html
normal_style = """
@gdamjan
gdamjan / namespaces.c
Created March 7, 2011 12:40
a small C program to start a process in a Linux namespace
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
@gdamjan
gdamjan / ez_share.py
Created August 10, 2011 10:26
enhanced the simple file sharing with python
#! /usr/bin/env python2
# -*- coding: utf-8 -*-
import os, socket
import BaseHTTPServer, SimpleHTTPServer
PORT = 9999
NAME = "File sharing"
HOSTNAME = "%s.local" % socket.gethostname()
URL = "http://%s:%d/" % (HOSTNAME, PORT)
@gdamjan
gdamjan / bash_functions.sh
Created August 10, 2011 13:53
A bash function to create a Python PEP-370 virtual environment, similar to virtualenv but leaner
# This is a shell (bash) function. you need to add it to your bashrc or bash_profile file
# Create a PEP-370 Python virtual environment
function create_env () {
ENV=`readlink -f $1` || return 1
mkdir $ENV || return 1
mkdir $ENV/bin || return 1
cat <<-EOF > $ENV/bin/activate
# first check if other env is active
[ x"$PYTHONUSERBASE" != x ] && echo "PYTHONUSERBASE already active from '$PYTHONUSERBASE'. Use 'deactivate' first." && return 1
@gdamjan
gdamjan / ipv6-rd.sh
Created August 12, 2011 10:51
Script to configure an ipv6 6rd tunnel
#!/bin/sh
## You must have a real routable IPv4 address for IPv6 rapid deployment (6rd)
## tunnels.
## Also make sure you have at least linux kernel 2.6.33 and you have enabled 6rd
## CONFIG_IPV6_SIT_6RD=y
PREFIX="2a02:2b64" # 6rd ipv6 prefix
GATEWAY=`dig +short 6rd.on.net.mk` # 6rd gateway host
@gdamjan
gdamjan / leafnode.socket
Created August 12, 2011 14:53
SystemD config files for leafnode (socket activation)
[Unit]
Description=Leafnode NNTP Socket
[Socket]
ListenStream=127.0.0.1:119
Accept=true
[Install]
WantedBy=sockets.target
@gdamjan
gdamjan / rc.powersave
Created August 12, 2011 19:58
a script to enable powersaving options
#!/bin/sh
# A script to enable laptop power saving features for #! & Debian GNU+linux.
# http://crunchbanglinux.org/forums/topic/11954
# List of modules to unload, space seperated. Edit depending on your hardware and preferences.
modlist="nsc_ircc uhci_hcd"
# Bus list for runtime pm. Probably shouldn't touch this.
buslist="pci i2c"
case "$1" in
@gdamjan
gdamjan / twitter_stream.erl
Created September 8, 2011 00:34
twitter stream : ibrowse + json_stream_parse + mochiweb
-module(twitter_stream).
-author("gdamjan@gmail.com").
%% Depends on:
%% ibrowse for http
%% couchbeam for couchbeam_json_stream (a fork of damienkatz json_stream_parse)
%% mochiweb for mochiweb_util:urlencode
-export([start/0]).