Instantly share code, notes, and snippets.

View troublesort.py
def troublesort(V):
done = False
while not done:
done = True
for i in range(len(V)-2):
if V[i] > V[i+2]:
done = False
V[i], V[i+2] = V[i+2], V[i]
def check(V):
View gist:8fe4b429e853fe82f4a17d185008bb74
cp .git/config /tmp/gitBackup
rm -rf .git
git init
cp /tmp/gitBackup .git/config
git remote add origin <url from 1st command>
git add .
git status
git commit -m "rewrite history"
git push -f
View stalls.rb
def solve(n, k)
l = 0
p2 = 1 # 2**0
k1 = k
n1 = n
chunk = n
while (k1 - p2 > 0)
k1 -= p2
n1 -= p2
chunk -= 1
View netgenerous
#! /usr/bin/python
"""
Share network connection, possibly run a WPA2-PSK or open access point
Make sure the downstream interface is listed as unmanaged in
/etc/NetworkManager/NetworkManager.conf
[keyfile]
unmanaged-devices=mac:MACADDRESS
View keybase.md

Keybase proof

I hereby claim:

  • I am dashohoxha on github.
  • I am dashohoxha (https://keybase.io/dashohoxha) on keybase.
  • I have a public key ASClLI_RjQu6KDeKRN9_rdFd2cAI6QJ8fd7L2eckpxwIGwo

To claim this, I am signing this object:

View index.html
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<link rel="stylesheet" href="http://info.btranslator.org/api-examples-js/style.css" type="text/css" />
<script src="http://info.btranslator.org/api-examples-js/config.js"></script>
<script src="http://info.btranslator.org/api-examples-js/http_request.js"></script>
<script src="http://info.btranslator.org/api-examples-js/debug.js"></script>
<script src="http://info.btranslator.org/api-examples-js/get_access_token.js"></script>
View index.html
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<link rel="stylesheet" href="http://info.btranslator.org/api-examples-js/style.css" type="text/css" />
<script src="http://info.btranslator.org/api-examples-js/config.js"></script>
<script src="http://info.btranslator.org/api-examples-js/http_request.js"></script>
<script src="http://info.btranslator.org/api-examples-js/get_access_token.js"></script>
View partelf.rb
# Problem description: https://code.google.com/codejam/contest/3004486/dashboard#s=p0
powers = [1]
nr = 1
41.times do
nr = nr * 2
powers << nr
end
T = gets.to_i
View jsbin.giweta.css
#div-output {
float: left;
margin: 2px 10px 5px 15px;
width: 100%;
}
View speak.sh
#!/bin/bash
rawurlencode() {
local string="${1}"
local strlen=${#string}
local encoded=""
for (( pos=0 ; pos<strlen ; pos++ )); do
c=${string:$pos:1}
case "$c" in