Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
import csv
import sys
import subprocess
from collections import namedtuple
DiskTrack = namedtuple("DiskTrack", "disk track episode name filename")
@brandonhesse
brandonhesse / scrub.py
Created March 19, 2016 05:35
Modified a script I found in /r/learnpython
"""
Un-scrape
Downloads images from the ~NEW~ section on Unslash.com and stores them for later use
Created by Roulx
Modified by midelh
"""
# I'm in python3 on this PC,
# so this should allow me to use my print and you can still run this in py2
from __future__ import print_function
import json #json over csv, personal preference
ng.directive('smGroup', ['$cacheFactory', '$log', function ($cacheFactory, $log) {
var cache = $cacheFactory('smGroupModelCache');
function searchAndDestroy(array, target) {
var index, found;
if (!Array.isArray(array)) {
return false;
}
(function () {
'use strict';
var checkbox = (function checkBoxBuilder() {
var prototype = {
values: function () {
var keys = Object.keys(this);
var type = this;
return keys.filter(function (key) {
return type[key];
});
(function(ng, undefined) {
ng.module('sm.directive')
.factory('es6Macro', [function es6Macro() {
// ECMAScript6 style string replacement implemented in ES5
return function macro(replace, macroString) {
var compiled = macroString,
keyR = Object.keys(replace),
replacementR = keyR.map(function (key) {
return new RegExp('\\${' + key + '}', 'g');
}), keyIdx, replacementCnt = replacementR.length;
#!/usr/bin/python
from __future__ import print_function
from argparse import ArgumentParser, Namespace
import subprocess
import logging
import sys
import os.path
try:
import configparser as cp
social/sys/classes/mvses.reports.class.php:139: LEFT JOIN product_dept pd ON t.ptype = pd.id
social/sys/classes/mvses.credits.class.php:238: LEFT JOIN product_dept pd ON p.department_id = pd.id
social/sys/func/cron.sync.system_updates.php:87: $dept = $mydb->GetOne("SELECT department FROM product_dept WHERE id={$deptid}");
social/sys/era404.mvses.setup.php:155:echo "<b>====|| CREATING product_dept TABLE:<br /></b><ul>";
social/sys/era404.mvses.setup.php:156: $query = "CREATE TABLE IF NOT EXISTS product_dept (
social/sys/era404.mvses.setup.php:180:echo "<b>====|| POPULATING product_dept TABLE:<br /></b><ul>";
social/sys/era404.mvses.setup.php:182: $query = "INSERT IGNORE INTO product_dept (id, department, item) VALUES ($did, '{$d[0]}','{$d[1]}')";
@brandonhesse
brandonhesse / matches.js
Last active August 29, 2015 14:19
Matches in both items
.filter('findMatches', [function() {
return function findMatches(arr1, arr2) {
// We cache because JS has some funny properties.
var len1, len2, i, j, matches, match;
// Because you're passing in strings
arr1 = arr1.split(' ');
arr2 = arr2.split(' ');
// Since the container will always be filled with matches
matches = [];
@brandonhesse
brandonhesse / SerializerDecoratorSample.php
Created April 16, 2015 15:17
Sample of what modular serializer might look like
<?php
interface DecoratorInterface {
public function dectorate($value, array $options);
public function supports($class);
}
class InvalidDecoratorSerilizationException extends \Exception {};
class DateTimeDecorator impliments DecoratorInterface {