This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import munch | |
import os | |
class Config(object): | |
def __init__(self, config_file=None): | |
self.config_file = config_file | |
def load(self): | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sort(x): | |
'''Sort a numeric list''' | |
for i in range(0, len(x)): | |
while i != 0 and x[i] < x[i-1]: | |
x[i], x[i-1] = x[i-1], x[i] | |
i -= 1 | |
return x | |
def revstrcp(x): | |
'''Reverse a str without using .reversed()''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = [2, 6, 4, 8, 6, 1, 2, 11] | |
def f(x): | |
for j in range(1, len(x)): | |
while j > 0 and x[j] < x[j-1]: | |
x[j], x[j-1] = x[j-1], x[j] | |
j -= 1 | |
return x | |
print f(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
free && sync && echo 3 > /proc/sys/vm/drop_caches && free |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class CelsiusOrFahrenheit { | |
public static void main(String[] args) { | |
System.out.println("Hello there, lets make some calculations."); | |
System.out.println("What is the temperature today? Type only the degrees."); | |
Scanner keyboard = new Scanner(System.in); | |
double randomNum = keyboard.nextDouble(); | |
double fahrenCalc = (randomNum * 9 / 5) + 32; | |
double celsiusCalc = (randomNum - 32) * 5 / 9; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .bashrc | |
user=$(whoami) | |
# Source global definitions | |
if [ -f /etc/bashrc ]; then | |
. /etc/bashrc | |
fi; | |
# Parse the current git branch for a name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#################################### | |
# Dirty arg parse, utilizes just system | |
#################################### | |
import sys | |
args = [{i.split('=')[0].replace('--',''):i.split('=')[1]} for i in sys.argv[1:]][0] | |
##################################### | |
# ArpParse.py, utilizes argparse: | |
##################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Stack: | |
stack = None | |
_size = None | |
def __init__(self): | |
self.stack = [] | |
self.size() | |
def push(self, item): | |
self.stack.append(item) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tax(income, tax_percent, min_tax, tax_break): | |
tax = (min_tax + ((income - tax_break) * tax_percent)) | |
post_tax = income - tax | |
return { | |
"net": { | |
"yearly": "{0:.2f}".format(float(post_tax)), | |
"monthly": "{0:.2f}".format(float(post_tax / 12)), | |
"biweekly": "{0:.2f}".format(float(post_tax / 26)) | |
}, | |
"taxes": "{0:.2f}".format(float(tax)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 | |
/sbin/mkswap /var/swap.1 | |
/sbin/swapon /var/swap.1 |