Skip to content

Instantly share code, notes, and snippets.

@tejovanthn
tejovanthn / gist:f2eae0cee36f54d6fb56
Last active August 29, 2015 14:17
authomatic test
from authomatic import Authomatic
authomatic = Authomatic(app.config['AUTHOMATIC'], app.config['SECRET_KEY'], report_errors=False)
@user.route('/login/<provider_name>/', methods=['GET', 'POST'])
def login_social(provider_name):
"""
Login handler, must accept both GET and POST to be able to use OpenID.
From the example at http://peterhudec.github.io/authomatic/examples/flask-simple.html
"""
@tejovanthn
tejovanthn / digits.js
Last active September 13, 2015 14:37
Digits integration
//Include <script id="digits-sdk" src="https://cdn.digits.com/1/sdk.js" async></script> in <head></head>
document.getElementById('digits-sdk').onload = function() {
Digits.init({ consumerKey: 'NpImh5k6yWhDAyhiafRop44Ur' })
.done(function(){
console.log("Digits is initialized")
})
.fail(function(){
console.log("Digits failed to initialize")
})
@tejovanthn
tejovanthn / ko_selectize.js
Last active December 20, 2015 06:36 — forked from xtranophilist/ko_selectize.js
ko_selectize.js ; Full details and demo here - http://motorscript.com/selectize-js-binding-knockout-js/
var inject_binding = function (allBindings, key, value) {
//https://github.com/knockout/knockout/pull/932#issuecomment-26547528
return {
has: function (bindingKey) {
return (bindingKey == key) || allBindings.has(bindingKey);
},
get: function (bindingKey) {
var binding = allBindings.get(bindingKey);
if (bindingKey == key) {
binding = binding ? [].concat(binding, value) : value;
@tejovanthn
tejovanthn / exifread.py
Created January 22, 2014 17:38
Script to yield (index, shutter speed) for processing.
import exifread
# Open image file for reading (binary mode)
i = 1
with open("~/timelapse/files.txt", "r") as fn:
for line in fn:
f = open("/home/tejovanth/timelapse/src/"+line[:-1], 'rb')
# Return Exif tags
tags = exifread.process_file(f)
@tejovanthn
tejovanthn / enablePostgisFunctions.sh
Last active May 13, 2016 08:50
upgrade postgres and reinit
psql username
CREATE EXTENSION cube;
CREATE EXTENSION earthdistance;
@tejovanthn
tejovanthn / append.py
Created July 21, 2016 15:28
Lost in dicts
def append(data):
if not data.get('type',None):
return {'type':'object', 'properties':data}
else:
return data
@tejovanthn
tejovanthn / api1.feature
Created August 24, 2016 08:34
Behave feature tests
Feature: API User
Background: User setups
Given a user with name "userA"
And a user with name "userB"
Scenario Outline: A user and an admin tries to access /user routes
Given <name> has role <role>
When <method> of "/users" is accessed by userA
Then status <code> is returned
@tejovanthn
tejovanthn / split_folder.sh
Created February 28, 2018 10:22
Bash script to split the current directory into N sub directories each with a set number of files.
function split_folder {
#Optional Positional Arguments
N_FILES=${1:-100} # Number of files you want in each folder.
FILES=${2:-"*.*"} # Filetype, accepts any string.
let m=0 # Loop vairable.
let M=0 # Folder name variable.
for i in $FILES; do
@tejovanthn
tejovanthn / split_folder.sh
Created February 28, 2018 10:22
Bash script to split the current directory into N sub directories each with a set number of files.
function split_folder {
#Optional Positional Arguments
N_FILES=${1:-100} # Number of files you want in each folder.
FILES=${2:-"*.*"} # Filetype, accepts any string.
let m=0 # Loop vairable.
let M=0 # Folder name variable.
for i in $FILES; do
@tejovanthn
tejovanthn / split_folder.sh
Last active February 28, 2018 10:24
Bash script to split the current directory into N sub directories each with a set number of files.
# split_folder
#
# Usage:
# split_folder NumberOfFilesPerFolder FileType
#
# Example:
# split_folder 100 "*.jpg"
# split_folder 250 "*.NEF"
function split_folder {