Skip to content

Instantly share code, notes, and snippets.

chanux chanux

Block or report user

Report or block chanux

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@chanux
chanux / za.sh
Last active Nov 12, 2015
Go back in directory tree
View za.sh
function za()
{
## I added this in my bashrc so that I can easily
## jump back in my directory tree.
## There's probably a better way of doing this.
## But I was bored anyway.
## Backstory: https://chanux.wordpress.com/2012/08/09/no-more-cd-dot-dot-slash/
## See it in my bashrc: https://github.com/chanux/dotfiles/blob/master/bash/aliases#L25
## Usage: za <number>
@chanux
chanux / wtime.sh
Created Mar 12, 2012
Simple script to query time zone data
View wtime.sh
#!/bin/bash
#Show date and time in other time zones
ZONEINFO=/usr/share/zoneinfo/posix/
FORMAT='%a %F %T'
query=$(echo $1 | tr '[:upper:]' '[:lower:]')
case "$query" in
au | aus )
@chanux
chanux / fixsrt.py
Created Mar 15, 2012
A simple python tool to fix time of srt files
View fixsrt.py
#!/usr/bin/env python
from sys import argv, exit
from os import path
import datetime
if len(argv) == 5:
(script, inputf, outputf, sign, msec) = argv
else:
print "fixsrt <input.srt> <output.srt> <+/-> <milli seconds>"
exit(1)
@chanux
chanux / routy.sh
Created Aug 13, 2012
Easily set routing table to allow the use of 2 different network connections
View routy.sh
#!/usr/bin/env bash
# This script helps you easily set routing tables to allow you use
# two different network connections.
# I use this to use My mobile broadband connection to access internet
# while retaining access to office network for internal stuff.
# Use 'route -n' to view current routing table.
#set your preferred defaults here
PRIMARY_GW="192.168.8.1"
@chanux
chanux / landport.sh
Created Aug 14, 2012
Classify landscape and portrait images in a directory.
View landport.sh
#!usr/bin/env bash
# This script accepts a directory name and classifies
# portrait and landscape images in that directory.
if [ $# == 0 ];then
echo "$0 <path to image directory>"
exit 1
else
DIR=$1
@chanux
chanux / README
Last active Dec 11, 2015
Portable encrypted vitual disk.
View README
How to create encrypted virtual disk (with luks)
1) First we create a file with random data in it. You can chose a size that matches your needs. In this example I’m making a 20MB virtual disk so I will create a 20MB file in this step.
$ dd if=/dev/urandom of=~/sekret bs=1M count=20
Here, the dd command creates 20 1MB blocks and fill it with random data. ~/sekret means that we create the device named sekret in your home directory. You can chose a file name you like and also a path you like.
2) Next we need to create a block device from the file. For that find a free loop device with
@chanux
chanux / mongodb.repo
Created Sep 12, 2013
MongoDB repository configuration for CentOS
View mongodb.repo
#/etc/yum.repos.d/mongodb.repo
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
@chanux
chanux / Dockerfile
Created Sep 18, 2013
Files required in the guide for setting up development environment on docker. http://play.thinkcube.com/development-environment-on-docker
View Dockerfile
#DOCKER-VERSION 0.6.1
# Build the image of ubuntu 12.04 LTS
from ubuntu:precise
# Run apt-get update
run apt-get -y update
# Install LAMP
run DEBIAN_FRONTEND=noninteractive apt-get -y install lamp-server^
@chanux
chanux / battery.py
Last active Dec 24, 2015
Laptop battery status notifier inspired by http://www.wired.com/gadgetlab/2013/09/laptop-battery. Images are Ubuntu specific.
View battery.py
#!/usr/bin/env python
# Inspired by the article http://www.wired.com/gadgetlab/2013/09/laptop-battery
#
# Info about battery life vary depending on who you ask from. So I'm not sure
# what to believe anymore. Anyhow wrote this because the last time I tried at
# writing a battery status notifier, I failed.
#
# I couldn't live with that memory!
@chanux
chanux / celerybeat basic
Last active Apr 25, 2018
The absolute minimal celerybeat setup
View celerybeat basic
Following is the absolute minimal celerybeat setup. I will use redis as the broker.
Install and run redis
on Ubuntu
sudo apt-get install redis-server
on CentOS
sudo yum install redis
You can’t perform that action at this time.