Skip to content

Instantly share code, notes, and snippets.

@dvoiss
dvoiss / remote-global-plugin-script.gradle
Last active Mar 14, 2016
An initscript to apply gradle plugins globally
View remote-global-plugin-script.gradle
/*
This must be added to ~/.gradle/init.gradle or to a .gradle file under ~/.gradle/init.d/ before applying.
initscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
@dvoiss
dvoiss / android-emulators.sh
Created Feb 25, 2016
EMU-laters: Launch multiple Genymotion emulators from the command line with the "emu" command.
View android-emulators.sh
function emu() {
green=$(tput setaf 64)
reset=$(tput sgr0)
# is VBoxManage available on the machine?
if hash VBoxManage 2>/dev/null; then
# print the emu:
echo "${green}"
echo '
/-/-=/-=
@dvoiss
dvoiss / print-calendar.py
Created Aug 14, 2012
Reddit Daily Programmer Challenge: Print a Calendar
View print-calendar.py
#!/usr/bin/python
# For the reddit daily programmer challenge
# Challenge: http://www.reddit.com/r/dailyprogrammer/comments/y5svk/8132012_challenge_88_intermediate_printing_out_a/
# Solution: http://www.reddit.com/r/dailyprogrammer/comments/y5svk/8132012_challenge_88_intermediate_printing_out_a/c5soy7s
# run code at http://ideone.com/yFOA4
# by @dvoiss on github / @daveasaurus on reddit
# Two variations:
@dvoiss
dvoiss / vigenere-cipher.py
Created Aug 13, 2012
Reddit Daily Programmer Challenge: Vigenère cipher
View vigenere-cipher.py
#!/usr/bin/python
# For the reddit daily programmer challenge
# Challenge: http://www.reddit.com/r/dailyprogrammer/comments/y5sox/8132012_challenge_88_easy_vigen%C3%A8re_cipher/
# Solution: http://www.reddit.com/r/dailyprogrammer/comments/y5sox/8132012_challenge_88_easy_vigen%C3%A8re_cipher/c5socop
# by @dvoiss on github / @daveasaurus on reddit
from string import ascii_uppercase as up
@dvoiss
dvoiss / unwrap.py
Created Aug 12, 2012
Programming Praxis: Unwrap a spiral
View unwrap.py
# http://programmingpraxis.com/2010/06/01/unwrapping-a-spiral/
# Unwrapping A Spiral
# 1 2 3 4
# 5 6 7 8
# 9 10 11 12
# 13 14 15 16
# 17 18 19 20
# input assumption:
@dvoiss
dvoiss / questions.py
Created Aug 12, 2012
Programming Praxis: Steve Yegge's Phone screen questions
View questions.py
# http://programmingpraxis.com/2009/06/30/steve-yegges-phone-screen-coding-exercises/
# Steve Yegge's Phone screen questions
# reverse-string
# built-in in python: input[::-1] => "gnirts-tset"
def reverse_string(input, input_length):
result = ""
i = input_length - 1
while i >= 0:
result += input[i]
@dvoiss
dvoiss / code-jam.py
Created Aug 12, 2012
Programming Praxis: Google Code Jam Qualification Round Exercises (2010)
View code-jam.py
# programming praxis:
# http://programmingpraxis.com/2011/02/15/google-code-jam-qualification-round-africa-2010/
# "Today's three programming exercises come from the Google Code Jam Qualification Round Africa 2010"
# 1.
# find the index of the two items that add up to the total credit amount
def store_credit(sample, credit):
for i, x in enumerate(sample):
for j, y in enumerate(sample):
if x + y == credit and i != j:
@dvoiss
dvoiss / sokoban.py
Created Aug 12, 2012
Reddit Daily Programmer Challenge: Sokoban in the terminal
View sokoban.py
#!/usr/bin/python
# For the reddit daily programmer challenge
# Challenge: http://www.reddit.com/r/dailyprogrammer/comments/y2lbv/8102012_challenge_87_difficult_sokoban_game/
# Solution: http://www.reddit.com/r/dailyprogrammer/comments/y2lbv/8102012_challenge_87_difficult_sokoban_game/c5rv38d
# by @dvoiss on github / @daveasaurus on reddit
# Uses curses and plays in the terminal. This started out pretty minimal but
# then grew a bit in complexity, so it isn't very clean: the grid is a
@dvoiss
dvoiss / piglatin.py
Created Aug 11, 2012
Programming Praxis: Convert English text to Pig Latin and back again (with tests)
View piglatin.py
#!/usr/bin/env python
# convert english to pig-latin and pig-latin to english
# solution for: http://programmingpraxis.com/2009/06/02/pig-latin/2/
# rules:
# words that start with a consonant and followed immediately by a vowel,
# such as 'sorry' become 'orry-say', (first letter plus 'ay')
# words that start with vowels: 'amazing' => 'amazing-way' ('way' is appended)
@dvoiss
dvoiss / script.py
Created Aug 9, 2012
Reddit Daily Programmer Challenge: Weekday Calculations
View script.py
#!/usr/bin/python
# Challenge: http://www.reddit.com/r/dailyprogrammer/comments/xx97s/882012_challenge_86_intermediate_weekday/
# Solution: http://www.reddit.com/r/dailyprogrammer/comments/xx97s/882012_challenge_86_intermediate_weekday/c5qgu1k
# Run code online: http://ideone.com/HIyf7
import sys
# this example assumes proper dates are entered (there are no safety checks performed)
if len(sys.argv) == 1: