Skip to content

Instantly share code, notes, and snippets.

View YellowSharkMT's full-sized avatar

The Yellow Shark YellowSharkMT

View GitHub Profile
@YellowSharkMT
YellowSharkMT / rank_songs.py
Created July 4, 2017 01:52
Calculating Favorite Weezer songs from a Reddit thread.
from collections import Counter
"""
One-song per line, separate entries with a line containing only an equals sign
"""
fn = '------.txt'
SONGS = [
'my name is jonas',
'holiday',
'say it aint so',
@YellowSharkMT
YellowSharkMT / claymore-miner.conf
Created July 1, 2017 18:12
Supervisord config for Claymore/Ethereum Miner (ethdcrminer64) on Ubuntu 17.04
[program:claymore-miner]
command = /usr/local/claymore96/ethdcrminer64 -epool xx.xx.xx:XXXX -ewal <Wallet>.<WorkerName>/<EmailAddress> -epsw x -mode 1 -tt 68 -allpools 1
environment=GPU_FORCE_64BIT_PTR=0,GPU_MAX_HEAP_SIZE=100,GPU_USE_SYNC_OBJECTS=1,GPU_MAX_ALLOC_PERCENT=100,GPU_SINGLE_ALLOC_PERCENT=100
stdout_logfile = /var/log/claymore/claymore.log
stderr_logfile = /var/log/claymore/error-claymore.log
user = <Username>
autostart = true
stop_signal = SIGINT
@YellowSharkMT
YellowSharkMT / admin_dynamic_search_results_example.py
Created May 8, 2017 23:28
Customize Django's admin search results view to optionally show a column, with highlighted search term in the results.
"""
This is a fairly specific use-case, where we wanted to search columns on a related model, and present those results in a
sensible way. We wanted this column to only be present if the user is conducting a search, and we wanted to customize the
output to make the search term prominent in the results.
"""
import re
from django.contrib.admin import ModelAdmin
from django.utils import formats
from django.utils.safestring import mark_safe
@YellowSharkMT
YellowSharkMT / fabfile.py
Created November 29, 2016 00:23
Simple example of a "new-style" Fabric task
# For reference, see:
# - http://docs.fabfile.org/en/1.12.0/usage/tasks.html#new-style-tasks
# - http://docs.fabfile.org/en/1.12.0/api/core/tasks.html
# - http://docs.fabfile.org/en/1.12.0/usage/execution.html#execute
from fabric.api import env, run, roles, execute
from fabric.tasks import Task
env.use_ssh_config = True
env.roledefs = {
@YellowSharkMT
YellowSharkMT / nginx_custom_configure.sh
Last active December 6, 2015 21:53
Compile Nginx for Webfaction
#!/bin/bash
# This script is intended to be executed from the root directory of
# the extracted Nginx ZIP file. The ZIP file is available http://nginx.org/en/download.html
# The Nginx config dir will be ~/etc/nginx.
# The default HTML directory will be ~/htdocs/html.
#
# IMPORTANT NOTE: this script makes an attempt to be "upgrade-friendly". It backs up
# up the existing nginx directory, prior to upgrading, and also makes a copy of the
# existing ~/etc/nginx/nginx.conf file.
#
@YellowSharkMT
YellowSharkMT / watch_mem_usage.py
Created December 6, 2015 02:27
Python script that polls memory usage for a Linux user
#!/usr/bin/python
"""
This script is intended to run infinitely (ctrl-c to exit). It executes a "ps" command, and then
parses the result to determine the total memory usage for a given user account. It will output a
warning message if that value exceeds a specified threshold.
The following values can be configured:
USER - the account to be watched. The $USER bash environment variable is the default.
MEM_WARNING_LEVEL - warning message will be shown if current usage is above this
#!/usr/env python
"""
Fetches a set of placeholder images from placehold.it. Iterates over the background colors specified, and
uses the same text for each slide. Image filenames contain an index, the size, and the bg color.
Warning: quick/dirty script. Would be cooler if options could be entered on the command-line. Also would
probably be cooler to use the subprocess module, instead of os.system()
"""
import os
@YellowSharkMT
YellowSharkMT / watch_memory_usage.py
Created December 2, 2014 20:43
Python shell script, displays memory usage for a user's processes. Also displays warning message if the usage is over a configurable amount.
#!/usr/bin/python
import subprocess
from datetime import datetime
import time
import sys
import itertools
# Configurable Values
MEM_LIMIT = 600000
@YellowSharkMT
YellowSharkMT / BS Classname Helper
Created November 8, 2014 01:10
Javascript function that adds a class to the <body> element that denotes a particular responsive view/width for Bootstrap. Class names are bs-lg, bs-md, bs-sm, and bs-xs.
(function($, _window, undefined) {
$(document).ready(function () {
var $body = $('body');
var $tmp = $('<span id="bs-visibility-tester"/>');
var identifyBootstrapViewname = function (){
$tmp.appendTo($body);
var visible_for;
$.each(['lg','md','sm','xs'], function(z, viewname){
$tmp.addClass('visible-' + viewname);
@YellowSharkMT
YellowSharkMT / pygit2.sh
Created March 12, 2014 16:53 — forked from olivier-m/pygit2.sh
Install LibGit2 & PyGit2 to a Virtual Environment (venv must be activated before executing this script). Tested on Ubuntu 12.04.4.
#!/bin/sh
set -e
if [ "${VIRTUAL_ENV}" = "" ]; then
echo "Error: Not in a virtual env"
exit 1
fi
OS=$(uname -s)