Skip to content

Instantly share code, notes, and snippets.

View dvoiss's full-sized avatar
👋

David Voiss dvoiss

👋
View GitHub Profile
@dvoiss
dvoiss / remote-global-plugin-script.gradle
Last active November 1, 2022 15:10
An initscript to apply gradle plugins globally
/*
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 February 25, 2016 07:29
EMU-laters: Launch multiple Genymotion emulators from the command line with the "emu" command.
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 August 14, 2012 07:06
Reddit Daily Programmer Challenge: Print a Calendar
#!/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 August 13, 2012 23:35
Reddit Daily Programmer Challenge: Vigenère cipher
#!/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 August 12, 2012 13:24
Programming Praxis: Unwrap a spiral
# 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 August 12, 2012 12:31
Programming Praxis: Steve Yegge's Phone screen questions
# 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 August 12, 2012 09:42
Programming Praxis: Google Code Jam Qualification Round Exercises (2010)
# 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 August 12, 2012 06:11
Reddit Daily Programmer Challenge: Sokoban in the terminal
#!/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 August 11, 2012 13:18
Programming Praxis: Convert English text to Pig Latin and back again (with tests)
#!/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 August 9, 2012 10:46
Reddit Daily Programmer Challenge: Weekday Calculations
#!/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: