Skip to content

Instantly share code, notes, and snippets.

@dataday
dataday / .bash_network
Created May 4, 2017 12:59
Creates a bridge between the system network and the local shell session on MAC OS
#!/usr/bin/env bash
#
# Date: 04 2015
# Author: dataday
#
# Support:
# Mac OS 10.6+, or anything with Mac's 'networksetup' tools installed.
# Bash 3.2.48(1)-release
#
# Links:
@dataday
dataday / docker-machine
Created May 4, 2017 13:03
Creates a docker machine with associated private registry credentials
#!/usr/bin/env bash
#
# author: dataday
# created: 23/02/2016
#
# Description:
# Creates docker machine with associated registry credentials
# For input variables see $SCRIPT_ROOT/environment
#
# fail on error (turned off to remain running)
@dataday
dataday / auth-actions.js
Created May 4, 2017 13:10
Firebase PaaS - Auth Actions (storage and authentication)
/**
* # auth-actions.js
*
* Auth Actions
*
* https://firebase.google.com/docs/auth/web/password-auth
*
* @flow
*/
'use strict'
@dataday
dataday / generate_email_fields.py
Created July 9, 2017 14:50
Generates a list of email fields from a list of names.
import re
from collections import Counter
# PEP 8 formatted code
class GenerateEmailFields:
version = '1.0.0'
description = 'Generates a list of email fields from a list of names.'
names_list = []
@dataday
dataday / calculate_file_sizes.py
Last active July 10, 2017 11:17
Calculate file sizes for selected system file types
import re
from collections import OrderedDict
# re.MULTILINE
line_pattern = re.compile('^([\w\W]+)\.([\w\d]+)\s(\d+)b$')
selected_file_types = {
'music': ['mp3', 'aac', 'flac'],
'images' : ['jpg', 'bmp', 'gif'],
'movies' : ['mp4', 'avi', 'mkv'],
'other' : ['7z', 'txt', 'zip', 'exe']
#!/usr/bin/ruby
require 'mysql2'
require 'base64'
begin
connection = {
host: 'localhost',
username: 'username',
@dataday
dataday / rn-common-button.js
Created August 24, 2017 12:49
React Native Common Button
/**
* # button.js
*
* Component
*
* @author dataday
*
* @flow
*/
'use strict'
@dataday
dataday / rn-common-icon.js
Created August 24, 2017 12:51
React Native Common Icon
/**
* # icon.js
*
* Component
*
* @author dataday
*
* @flow
*/
'use strict'
@dataday
dataday / hex_to_rgba.js
Created August 24, 2017 12:53
Converts HEX to RGBA
const hexToRGBA = (hex: string, opacity: number = 1) => {
hex = hex.replace('#', '')
let r = parseInt(hex.substring(0, 2), 16)
let g = parseInt(hex.substring(2, 4), 16)
let b = parseInt(hex.substring(4, 6), 16)
return 'rgba(' + r + ',' + g + ',' + b + ',' + opacity + ')'
}
@dataday
dataday / nunjucksRender.manageEnv
Created August 24, 2017 12:58
nunjucksRender Filters
...
nunjucksRender: {
manageEnv: function(env) {
const utils = new Utils();
env.addFilter('split', utils.splitFilter);
env.addFilter('get', utils.getFilter);
env.addFilter('is', utils.isFilter);
env.addFilter('classify', utils.classifyFilter);
}
}