Skip to content

Instantly share code, notes, and snippets.

@tejovanthn
tejovanthn / machine.js
Last active April 6, 2021 12:57
Generated by XState Viz: https://xstate.js.org/viz
let randomID = () => Math.random().toString(36).substring(7);
const addWriter = () =>
assign({
writers: (context, event) => [randomID(), ...context.writers]
});
const addEditor = () =>
assign({
@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 {
@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 / 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 / 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 / enablePostgisFunctions.sh
Last active May 13, 2016 08:50
upgrade postgres and reinit
psql username
CREATE EXTENSION cube;
CREATE EXTENSION earthdistance;
@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 / ko_selectize.js
Last active December 20, 2015 06:36 — forked from isDipesh/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 / 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")
})