Skip to content

Instantly share code, notes, and snippets.

@GideonPARANOID
GideonPARANOID / find.sh
Created December 27, 2015 16:54
Find files modified between dates
find . -type f -newermt $STARTDATE ! -newermt $ENDDATE -exec ls {} \;
@GideonPARANOID
GideonPARANOID / get-full-object-path-find-in-tree.js
Last active September 10, 2015 11:49
Finds a match for an attribute/value pair in an object tree (uses lodash).
function find(subtree, attribute, value) {
var result = null;
subtree.hasOwnProperty(attribute) && subtree[attribute] === value ?
result = subtree :
_.forEach(Object.keys(subtree), function (key) {
if (typeof subtree[key] === 'object') {
var next = find(subtree[key], attribute, value);
if (next != null) {
result = {};
@GideonPARANOID
GideonPARANOID / ftp-push.sh
Created August 30, 2015 12:36
Pushing files on changes to an FTP
find . -type f -not -path '*/\.*' | entr ncftpput -R -u <username> -p <password> <ftp url> <remote directory> <local directory>
@GideonPARANOID
GideonPARANOID / montage-maker.sh
Last active August 29, 2015 14:27
Builds a montage from a video file, of a set length using equally spaced 1 second clips
#!/bin/bash
# functions
function get_file_extension() {
local filename=$(basename $1)
echo ${filename##*.}
}
function float_to_int() {
echo ${1%.*}
@GideonPARANOID
GideonPARANOID / _cmdrc
Created August 13, 2015 07:23
Some bash aliases for Windows shell
@echo off
doskey ls=dir /ONE $*
doskey l=dir /ONE $*
doskey cat=type $*
doskey rm=del $*
doskey clear=cls
@GideonPARANOID
GideonPARANOID / zig-zag.java
Created May 7, 2015 09:58
Operation for constructing a grid of points & respective draw order using an unbroken line of two zig zags - most efficient for larger grids
int length = 5;
float[] vertices = new float[length * length * 3];
short[] drawOrder = new short[(length * length * 2) - 1];
// building up grid points
{
int position = 0;
for (float i = 0f; i < length; i++) {
for (float j = 0f; j < length; j++) {
data = [
{
quote : 'It is a truth universally acknowledged, that a single man in possession of a good dissertation, must be in want of a wife.',
book : 'Pride and Prejudice',
author : 'Jane Austen'
}, {
quote : 'It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had a dissertation before us, we had nothing before us, we were all going direct to Hell, we were all going direct the other way.',
book : 'A Tale of Two Cities',
author : 'Charles Dickens'
}, {
@GideonPARANOID
GideonPARANOID / .gitconfig
Created January 25, 2015 22:31
A useful alias for pushing to multiple remotes at the same time
[alias]
pha = "!f(){ for i in `git remote`; do git push $i; done; };f"
@GideonPARANOID
GideonPARANOID / split-string-and-sort-by-length.min.sh
Last active August 29, 2015 14:13
Ordering an input string in descending word length - 161 characters
#!/bin/bash
a=(${1/// });for l in `seq 0 ${#a[@]}`;do for((i=l;i>0;i--));do j=$((i-1));[ ${#a[i]} -gt ${#a[j]} ]&&eval "a[$j]=${a[$i]};a[$i]=${a[$j]}";done;done;echo ${a[*]}
@GideonPARANOID
GideonPARANOID / vj.py
Created November 22, 2014 18:28
Viola-Jones face detection from webcam
#!/usr/bin/env python
import cv2
import sys
import video
if __name__ == '__main__':
try : fn = sys.argv[1]
except : fn = 0