Skip to content

Instantly share code, notes, and snippets.

View arecker's full-sized avatar
🍕
my life is dope, and I have dope emacs configs

Alex Recker arecker

🍕
my life is dope, and I have dope emacs configs
View GitHub Profile
@arecker
arecker / hud.py
Created February 18, 2014 03:10
Mini LCD pi-powered HUD script
#!/usr/bin/env python
import os
import subprocess
import time
import imaplib
import praw
import json
try:
from minecraft_query import MinecraftQuery
@arecker
arecker / git-clean
Created April 16, 2014 15:41
Git Clean
#!/bin/bash
# Deletes all branches except for the ones you want to keep
# Git-Bash doesn't have /dev/null, so I can't suppress the IF output
echo -n "Don't delete these: "
read protect
echo "VERIFY"
for branch in $(git branch | cut -c 3-)
do
@arecker
arecker / cherry-pop
Last active August 29, 2015 14:01
cherry-pop
#!/bin/bash
# Applies last commit to a branch to the current branch
branch=$1
hash=$(git log $branch | head -1 | awk '{ print $2 }')
message=$(git log $branch | head -5 | tail -1)
if [ "$branch" == "" ]
then
echo "Forgot your branch, stupid."
@arecker
arecker / gist:7657a7095e2274cc3a47
Created November 3, 2014 16:53
First Bash Script
clear; sleep 0.5
echo "WELCOME to RSSFeeder"
echo " "; sleep 0.2;
echo "by Monte Cristo"
echo " "; echo " ";
sleep 0.3; echo "Type a number to select an option."
sleep 0.2
echo "1: Setup an RSSFeeder loop."
echo "2: About RSSFeeder."
echo "3: Exit RSSFeeder."
@arecker
arecker / highlightNav.js
Last active August 29, 2015 14:09
Highlighting a Nav Button
// Title Tags: 'Site Name | Page'
// Button id: '#pageButton'
$('.nav-pills').find('li').removeClass('active');
$('#' + $('title').text().split(' | ')[1].toLowerCase().trim() + 'Button').addClass('active');
@arecker
arecker / branch_diff.sh
Created March 20, 2015 16:28
Gitflow Branch Diff
#!/bin/bash
# feature-diff
# Constructs a summary of all outstanding work in feature branches
# Paths
REPO=/your/repo
OUTPUT=/path/to/output/textfile.txt
DEVELOP=upstream/develop
MASTER=upstream/master
@arecker
arecker / settings.py
Last active October 27, 2015 02:46
Pruned settings.py
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = 'lol-so-secret'
DEBUG = True
ALLOWED_HOSTS = []
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
@arecker
arecker / wtf.py
Created November 4, 2015 22:22
That's one way to do it...
qualifying = self.filter(...)
return {1: lambda: qualifying[0]}.get(len(qualifying), lambda: None)()
@arecker
arecker / models.py
Last active November 14, 2015 12:29
models
from uuid import uuid4
from django.db import models
from django.core.validators import MinValueValidator
class Rate(models.Model):
id = models.UUIDField(primary_key=True,
editable=False,
default=uuid4,
unique=True)
@arecker
arecker / models.py
Created November 13, 2015 00:23
Rate .save()
from decimal import Decimal
class Rate(models.Model):
'''...rest of model...'''
def save(self, *args, **kwargs):
self.amount_per_day = self.amount / Decimal(self.days)
return super(Rate, self).save(*args, **kwargs)