Skip to content

Instantly share code, notes, and snippets.

@adoc
adoc / hashdeept
Last active February 3, 2016 20:03
hashdeept $@: Hashdeep and trim "##" and "%%%%" lines
#!/bin/bash
# /usr/local/sbin/hashdeept $@: Hashdeep and trim "##" and "%%%%" lines
# author: https://github.com/adoc
# link: https://gist.github.com/adoc/8c117fb895c6dfdc962d
# resources:
# http://unix.stackexchange.com/a/174720
# deps:
# hashdeep (http://md5deep.sourceforge.net/)
# todo:
# check incoming ards for -l and -j??
@adoc
adoc / rndaz09
Last active February 3, 2016 20:04
rndaz09 N: Cat N urandom characters and return limited [a-z0-9]
#!/bin/bash
# /usr/local/sbin/rndaz09 N: Cat N urandom characters and return limited [a-z0-9]
# link: https://gist.github.com/adoc/275cba7ef1639cc648bb
# resource: http://stackoverflow.com/a/2793856
cat /dev/urandom | tr -cd 'a-z0-9' | head -c $1
@adoc
adoc / gist:b403e729d29f5bf86670
Created October 1, 2015 02:29
JS code: ns coerce and "gen" check
ns: {
coerce: function (namespace, hash, back) {
hash = hash || {};
back = back || false;
var nsSplit = namespace.split('.'),
newHash = hash,
stop = nsSplit.length - (back && 1 || 0),
ns;
if (_.isEmpty(namespace)) {
@adoc
adoc / eye.py
Created September 21, 2015 00:06
Repeating timer.
""" Watcher.
"""
import logging
log = logging.getLogger(__name__)
import threading
class Watcher:
@adoc
adoc / sillyencoder.py
Last active September 18, 2015 20:48
silly encoder ideas
def bit_count(byte_or_num):
bits = 0
if isinstance(bytes, byte_or_num):
n = ord(byte_or_num)
else:
n = byte_or_num
while n > 1: # n >= 1 ????
n //= 2
bits += 1
return bits
{
"trunks": [
"11003",
"21003"
],
"type": [
"orig",
"peak",
"term"
],
/* Collate at the given dimension namespace.
:param Object rawData: The raw data from the RESTful api.
:param Array dimensions: Array of string namespaces that define the
nesting and collation order.
:param String collateAt: Namespace to stop "digging" and begin to
collate the data.
*/
function collateData(rawData, dimensions, collateAt, __forwardData,
__returnData) {
@adoc
adoc / install_python3.4
Last active August 29, 2015 14:18
Python 3.4 install
#!/bin/bash
# Python 3.4 build/install
_py34_install_cwd="`pwd`" # Save current directory.
yum -y install wget
yum -y install openssl-devel
yum -y install zlib-devel
yum -y install bzip2-devel
yum -y install readline-devel
yum -y groupinstall development
@adoc
adoc / migrate.py
Created March 18, 2015 09:42
SQLAlchemy Migration Tool
#!/usr/bin/env python
"""
# Original Author: Tyler Lesmann
# Original Source: http://www.tylerlesmann.com/2009/apr/27/copying-databases-across-platforms-sqlalchemy/
# TODO: Look at https://gist.github.com/thoas/1589496 if any
# "sequencing" issues come in to play.
@adoc
adoc / datafile.py
Created March 14, 2015 01:45
Python data file with pickle.
class DataFile:
"""Handle a data file using pickle.
"""
def __init__(self, filepath, init_data={}):
"""Initialize or load a pickled data file.
"""
self.__filepath = filepath
self.data = init_data