Skip to content

Instantly share code, notes, and snippets.

Follow these steps
============
1) Create a folder on local disk Eg: C:\Users\keerthip\Documents\Dropbox
2) Create a Drive Letter Mapping eg:(H:) to the folder path in windows with following command
subst H: C:\Users\keerthip\Documents\Dropbox
3) Install Dropbox desktop software in advanced Mode.
Select the new local drive H: and sync either selective folders or all folder to local drive ( which is original folder path)
4) Wait till content is fully synced from web account
5) Pause Syncing and Exit Dropbox
6) Delete local folder drive mapping with following command
#! /usr/bin/env python
#
# http://instagram-engineering.tumblr.com/post/12202313862/storing-hundreds-of-millions-of-simple-key-value
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
@perpetual-hydrofoil
perpetual-hydrofoil / combine_audio_sinks.sh
Created March 14, 2015 21:35
Linux: send sound to multiple sound cards simultaneously
#! /bin/sh
cat << EOM
Combining your Pulse Audio sinks (outputs) and giving you another, combined set of speakers that looks like another sound card.
Perfect so that you can direct output to headphones and speakers at the same time.
Use pavucontrol to even end output of different apps (or different browser windows) to different speakers at the same time.
Listen to one youtube video out of your speakers while gaming in your headphones!
See http://www.deseret-tech.com/journal/pulseaudio-combine-sinks-for-simultaneous-output/ for tips.
@perpetual-hydrofoil
perpetual-hydrofoil / dictionary_comprehensions.py
Created March 26, 2015 15:02
Dictionary comprehensions in Python
# python 2.7 and later now allows list comprehensions against dictionaries too!
foo = {"alice": "camper", "joe": "medic", "paul": "sniper"}
# Now, you can do dictionary comprehensions like this (2.7):
bar = {first: last for first,last in foo.items() if last not in ["camper", "sniper"]}
# or, you can do it the old way:
baz = dict([(first, last) for first,last in foo.items() if last.lower() not in ["camper", "sniper"]])
# In each case, the result is:
# MOVED TO
# https://github.com/jamiesonbecker/redis2json
@perpetual-hydrofoil
perpetual-hydrofoil / gist:3bb699a7bd066364e535
Last active August 29, 2015 14:27 — forked from squioc/gist:3078803
conversion between iso8601 date format and unix epoch datetime
from datetime import datetime
import calendar
def epoch_to_iso8601(timestamp):
"""
epoch_to_iso8601 - convert the unix epoch time into a iso8601 formatted date
>>> epoch_to_iso8601(1341866722)
'2012-07-09T22:45:22'
"""
@perpetual-hydrofoil
perpetual-hydrofoil / redisdns.py
Created October 9, 2015 11:30
Python DNS server with Redis backend
# A naive dns server with a Redis backend
# Set keys in Redis you want to be authoritative for (set google.com. 127.0.0.1)
# Tip: Use Redis's ttl functions to have temporary names
# Currently only does A records, feel free to fix that
#
# Licensed under the PSF License
# Thanks to: http://code.activestate.com/recipes/491264-mini-fake-dns-server/
# Author: @Kaerast <[email protected]>
import socket
@perpetual-hydrofoil
perpetual-hydrofoil / forced_upgrade.sh
Last active February 2, 2017 13:23
Upgrade and force reboot if kernel changed as an hourly cron job for security-sensitive requirements.
cat << EOF > /etc/cron.hourly/local-system-upgrade
#! /bin/bash
#
# hourly server upgrade
logger -t local-system-upgrade Upgrading server.
sha1sum /vmlinuz > /vmlinuz.sha1sum
apt-get update
apt-get -qy dist-upgrade
apt-get -qy autoclean
# reboot when kernel upgraded
@perpetual-hydrofoil
perpetual-hydrofoil / springer-free-maths-books.md
Created December 28, 2015 19:20 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of maths books available for free, here are the direct links
/* resize_function executes a function whenever the screensize changes.
by Jamieson Becker. Public Domain (do what you will)
requires jQuery or compatible.
*/
on_resize = function(f) {
var still_running = false;
var previous_height = 0;
var previous_width = 0;
if (!f) console.error("Please provide resize_function with a function");