Skip to content

Instantly share code, notes, and snippets.

View hiway's full-sized avatar

Harshad Sharma hiway

View GitHub Profile
@gleicon
gleicon / txredns.py
Created July 10, 2011 01:13
Python/Twisted/Redis backed DNS server.
# Python/Twisted/Redis backed DNS server - resolves from NAME to IP addrs
# fallback to google or any other DNS server to resolv domains not present on Redis
# to set a new domain on redis, just issue a SET domain.tld ip_addr
# run with twistd -ny txredns.tac
# gleicon 2011
from twisted.names import dns, server, client, cache
from twisted.application import service, internet
from twisted.internet import defer
from twisted.python import log
import jester, asyncdispatch, os, osproc, strutils, json, threadpool, asyncfile
proc respondOnReady(fv: FlowVar[TaintedString], resp: Response) {.async.} =
while true:
if fv.isReady:
echo ^fv
var errorsFile = openAsync("tmp/errors.txt", fmReadWrite)
var logFile = openAsync("tmp/logfile.txt", fmReadWrite)
var errors = await errorsFile.readAll()
@jobertabma
jobertabma / git-inspect.sh
Last active March 13, 2018 23:26
A script to manually iterate over git commits. Use qj/qk to navigate.
DIFF_NUMBER=1
while read -n1 -r -p "$DIFF_NUMBER:" && [[ $REPLY != q ]]; do
case $REPLY in
j)
DIFF_NUMBER=`expr $DIFF_NUMBER + 1`
;;
k)
DIFF_NUMBER=`expr $DIFF_NUMBER - 1`
;;
@dalanmiller
dalanmiller / asyncio-changefeeds.py
Created May 2, 2016 22:39
asyncio & RethinkDB changefeeds example
import rethinkdb as r
import asyncio
r.set_loop_type("asyncio")
async def get_connection():
return await r.connect("localhost", 28015)
async def changefeed_old():
@pithyless
pithyless / gist:1208841
Created September 10, 2011 21:49
Install Python 2.7 (homebrew + pip + virtualenv) on Mac OS X Lion

Install Python

$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7

Symlinks...

@tomster
tomster / gist:7585211
Last active July 5, 2018 09:16
bootstrap a freebsd 9.2 host with ansible. it requires a password for the root user to be set for which it will prompt you (-k). you must use the paramiko transport to allow password based login. based on https://gist.github.com/illenseer/6390361
---
# run this with ansible-playbook -i ansible_hosts bootstrap.yml -k -c paramiko
- hosts: jails_host
gather_facts: false
remote_user: root
tasks:
- name: install pkgng
raw: "pkg_info | grep -v 'pkg-' > /dev/null ; if $? pkg_add -r pkg; rehash ; pkg2ng; echo 'WITH_PKGNG=yes' >> /etc/make.conf; echo 'packagesite: http://pkgbeta.freebsd.org/freebsd%3A9%3Ax86%3A64/latest' >> /usr/local/etc/pkg.conf; pkg update ; pkg upgrade -y"
- name: install python27
raw: "pkg install -y python27"
@mgbowman
mgbowman / enczfs
Last active July 28, 2018 12:11
FreeBSD rc script for unlocking a geli encrypted zvol
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: enczfs
# REQUIRE: sshd
# BEFORE: iocage
# KEYWORD: shutdown
#
@pr1ntf
pr1ntf / grub.cfg
Last active August 4, 2018 14:30
Minix3 and bhyve Hints.
set root=(cd0,msdos2)
multiboot /boot/minix_latest/kernel rootdevname=c0d0p0s0 cttyline=0 cttybaud=9600
module /boot/minix_latest/mod01_ds.gz
module /boot/minix_latest/mod02_rs.gz
module /boot/minix_latest/mod03_pm.gz
module /boot/minix_latest/mod04_sched.gz
module /boot/minix_latest/mod05_vfs.gz
module /boot/minix_latest/mod06_memory.gz
module /boot/minix_latest/mod07_tty.gz
module /boot/minix_latest/mod08_mfs.gz
@raspi
raspi / md5move.py
Last active October 1, 2018 21:19
Move files based on file list in a md5 checksum file
#!/bin/env/python
# -*- encoding: utf8 -*-
# Move files based on file list in a md5 checksum file
# (c) Pekka Järvinen 2017-
import logging
log = logging.getLogger(__name__)
import os
@LeZuse
LeZuse / spotify.sh
Last active June 5, 2019 15:00
A bash helper for controlling Spotify on Mac over osascript
#!/usr/bin/env bash
# Install:
# ln -s $PWD/spotify-cmd.sh /usr/local/bin/spotify
ARG=$@
usage () {
echo "Usage: $0 [play|pause|playpause|next track|previous track]"
}