Skip to content

Instantly share code, notes, and snippets.

View vodik's full-sized avatar

Simon Gomizelj vodik

  • Movable Ink
  • Toronto, Ontario
View GitHub Profile
@vodik
vodik / nextbus.py
Last active August 29, 2015 14:01
Nextbus Predictions
#!/usr/bin/python3
import sys
import itertools
import requests
import xml.etree.ElementTree as ET
from optparse import OptionParser
def nextbus_request(command, agency, route, stop):
params = { 'command': command,
@vodik
vodik / configurator.py
Last active August 29, 2015 14:00
A Configurator
class Configurator:
def __init__(self, defaults, parent=None):
self.store = {}
self.parent = parent
for k, v in defaults.items():
self.store[k] = (None, v)
def get(self, key):
@vodik
vodik / zshrc
Created April 29, 2014 15:26
zshrc
autoload -U vcs_info
autoload -U colors && colors
autoload -U compinit && compinit
autoload zsh/terminfo
HISTFILE=$HOME/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
HISTIGNORE=' '
@vodik
vodik / queens.py
Last active August 29, 2015 13:57
fun with n-queen
#!/usr/bin/python3
def make_solution(size):
def exception_queen(i, half):
return 2 * i + half - 3
def simple_queen(i, half):
return 2 * i - 1
table = [0] * size
@vodik
vodik / rez-x
Last active November 23, 2021 20:54
startx alternative
#!/bin/bash
# startx
# Alternative, simpler startx which makes use of the XDG specification
# - assumes dbus is already running
[[ -n "$DISPLAY" ]] && exit 0
[[ -z "$XDG_VTNR" ]] && exit 1
XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
@vodik
vodik / Makefile
Last active January 1, 2016 08:18
Quick file search for local pacman files db
CFLAGS := -std=c99 \
-Wall -Wextra -pedantic \
-Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes \
-D_GNU_SOURCE \
${CFLAGS}
all: search
search: search.o boyermoore.o
clean:
@vodik
vodik / colourize.c
Created December 1, 2013 22:18
Hash to pallet lookup
#include <stdio.h>
#include <stdint.h>
static unsigned colour_table[] = {
0x24, 0x25, 0x26, 0x27, 0x29, 0x30, 0x31, 0x32,
0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
0x49, 0x50, 0x51, 0x59, 0x60, 0x61, 0x62, 0x63,
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, 0x71,
0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
@vodik
vodik / elf.c
Last active December 18, 2015 07:29
Dump needed dependancies
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <err.h>
#include <elf.h>
#include <sys/stat.h>
#include <sys/mman.h>
@vodik
vodik / SOS.md
Last active May 8, 2024 18:21
_Never_ -Sy when installing!

Once upon a time there was a user that wanted to install firefox.

The user tried to do pacman -S firefox but it didn't work. The all mighty pacman reported that firefox-3.2.4-1.i686.pkg.tar.gz could not be found on his mirror. So the user tried pacman -Sy firefox. It worked and the user rejoiced since he could once again go and troll /h/.

But all was not good. The user had made a grave error!

See, when the user told the almighty pacman to -Sy firefox, pacman did

@vodik
vodik / alpm-simple.c
Last active December 16, 2015 01:39
Load archlinux package metadata from a *.pkg.tar.* file.
#include "alpm-simple.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <err.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>