Skip to content

Instantly share code, notes, and snippets.

@junkmechanic
junkmechanic / p&c
Created November 10, 2013 16:09
Alternative (not really!) to itertools.permutations. Sweet recursive indulgence. However, due to lack of in-built support for TRE in Python, this is a slow implementation. So please do not try this at home.
# inspired by the algorithm to find all possible strings from a given
# set of alphabets (as in the function permute here)
# the execution time is compared with itertools.permutations
def permute(lst):
if len(lst) < 2:
yield lst
else:
for perm in permute(lst[1:]):
for i in range(len(lst)):

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
#!/bin/bash
# Paste at Pastebin.com using command line (browsers are slow, right?)
# coder : Anil Dewani
# date : Novemeber 7, 2010
#help function
howto()
{
echo "\
Pastebin.com Bash Script \
@junkmechanic
junkmechanic / sp
Last active August 29, 2015 14:12 — forked from wandernauta/sp
#!/bin/bash
#
# This is sp, the command-line Spotify controller. It talks to a running
# instance of the Spotify Linux client over dbus, providing an interface not
# unlike mpc.
#
# Put differently, it allows you to control Spotify without leaving the comfort
# of your command line, and without a custom client or Premium subscription.
#
#!/usr/bin/env python3
# Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015 The spop contributors
#
# This file is part of spop.
#
# spop is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
# It is an order of magnitude slower. So dont try this at home. I wanted to save
# it since I found this list comprehension interesting when I came up with it.
import itertools
def comprehend(long_list, batch_size):
return [[u for u in k if u is not None] for k in
itertools.izip_longest(*[long_list[i::batch_size]
for i in range(batch_size)])]
@junkmechanic
junkmechanic / gitflow-breakdown.md
Created January 19, 2018 07:12 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository