Skip to content

Instantly share code, notes, and snippets.

@rvause
rvause / Pipfile
Last active September 7, 2018 16:52
Toolbox-Python
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
django = "*"
celery = "*"
coverage = "*"
django-rest-framework = "*"
@rvause
rvause / clean_pattern
Created June 8, 2018 11:50
Remove files matching a given pattern
#!/usr/bin/env bash
find . -name "$1"
read -p "Do you wish to remove these files? (y/N) " yn
case ${yn:0:1} in
[Yy]* ) find . -name "$1" -delete;;
* ) exit;;
esac
echo "Files have been removed"
from IPython import get_ipython
from IPython.terminal.prompts import Prompts, Token
c = get_config()
class SimplePrompt(Prompts):
def in_prompt_tokens(self, cli=None):
return [(Token.Prompt, '[{}] >>> '.format(self.shell.execution_count))]
@rvause
rvause / css.sh
Created February 4, 2017 17:28
Simple alternative to using gulp/grunt to build CSS using Less
#!/usr/bin/env bash
function css_build {
echo "Starting build..."
lessc --verbose ./less/main.less ../assets/css/app.css
echo "Completed at `date +%H:%I:%S`"
}
function css_watch {
echo "Building CSS on changes (CTRL+C to stop)"
@rvause
rvause / upc_check_digit.py
Last active December 1, 2016 13:28
Calculate UPC check digit or alternatively check a full UPC code
def handle_checkdigit(upc, append=False):
if len(upc) not in [11, 12]:
raise ValueError('Given UPC must be 11 or 12 digits')
bool_mode = len(upc) == 12
if bool_mode:
check_digit = upc[11]
upc = [int(i) for i in upc[:11]]
odd = []
@rvause
rvause / server.py
Created October 26, 2016 19:57
Simple Flask app server that takes a JSON payload and prints formatted output.
import json
import sys
from flask import Flask, request
app = Flask(__name__)
@app.route('/', methods=['POST'])
# Thinkpad T420
hwmon /sys/devices/virtual/thermal/thermal_zone0/temp
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp1_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp2_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp3_input
tp_fan /proc/acpi/ibm/fan
# Semi aggressive
#(0, 0, 55)
@rvause
rvause / mkpy
Created February 29, 2016 18:09
#!/usr/bin/env python
import os
import sys
class ProgramError(Exception):
pass
@rvause
rvause / currentfile.py
Last active July 3, 2018 09:57
Put current file path in status bar relative to project directory
import os.path as op
import sublime_plugin
class CurrentFile(sublime_plugin.EventListener):
def on_activated_async(self, view):
encoding = view.encoding()
if encoding == 'Undefined':
encoding = ''
'use strict';
var http = require('http');
var https = require('https');
var zlib = require('zlib');
module.exports = function (grunt) {
grunt.registerMultiTask('httpfetch', 'Fetch file over HTTP', function () {
var _this = this;
this.files.forEach(function (file) {