Skip to content

Instantly share code, notes, and snippets.

@jeff1evesque
jeff1evesque / ssh-into-docker.sh
Last active July 10, 2016 16:35
SSH into docker container
# step 1: build container
$ docker build -f docker/redis.dockerfile -t <image-alias> .
# step 2: run container
$ docker run -dt --name <container-name> <image-alias>
# step 3: unix based
$ docker exec -it <container-name> bash
root@cdaa90138643:/#
@jeff1evesque
jeff1evesque / interactive-docker.sh
Last active July 5, 2016 21:08
Query database docker container via interactive bash
Running pre-create checks...
Creating machine...
(default) Copying C:\Users\Jeff\.docker\machine\cache\boot2docker.iso to C:\User
s\Jeff\.docker\machine\machines\default\boot2docker.iso...
(default) Creating VirtualBox VM...
(default) Creating SSH key...
(default) Starting the VM...
(default) Check network to re-create if needed...
(default) Windows might ask for the permission to configure a dhcp server. Somet
imes, such confirmation window is minimized in the taskbar.
@jeff1evesque
jeff1evesque / ensure_tables
Last active June 20, 2016 13:46
Ensure missing drupal sql tables exist
# ensure missing sql tables exist
$ drush ev 'foreach(drupal_get_schema() as $name => $schema) if(!db_table_exists($name)) db_create_table($name, $schema)'
# update database schema
$ drush updatedb
@jeff1evesque
jeff1evesque / style.yml
Last active May 31, 2016 18:57
Configuration for scss-lint
# Default application configuration that all configurations inherit from.
scss_files: "**/*.scss"
plugin_directories: ['.scss-linters']
# List of gem names to load custom linters from (make sure they are already
# installed)
plugin_gems: []
# Default severity of all linters.
@jeff1evesque
jeff1evesque / gist:675b0d80845741a7d4b6
Created March 25, 2016 12:58
Test logic in puppet
# install module into my home dir
% puppet module install puppetlabs/inifile
Notice: Preparing to install into /home/rip/.puppetlabs/etc/code/modules ...
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/home/rip/.puppetlabs/etc/code/modules
└── puppetlabs-inifile (v1.5.0)
# grab a throw away php.ini
% cp /etc/php.ini ~
@jeff1evesque
jeff1evesque / gist:4540da7f91ad884d6ebc
Created July 18, 2015 12:39
Convert date string to unix time
// date to convert
$date_string = 'Thursday, July 9, 2015 - 14:54'
// conversion logic
$time = str_replace(' - ', ' ', $date_string);
$epoch = strtotime($time);
// converted unix time
var_dump($epoch);
@jeff1evesque
jeff1evesque / Vagrantfile
Created June 30, 2015 20:36
Vagrantfile used to install vagrant-r10k plugin
Vagrant.configure(2) do |config|
## Variables (ruby syntax)
required_plugins = %w(vagrant-r10k)
plugin_installed = false
## Install Vagrant Plugins
required_plugins.each do |plugin|
unless Vagrant.has_plugin? plugin
system "vagrant plugin install #{plugin}"
@jeff1evesque
jeff1evesque / mimetype_check.py
Created March 1, 2015 19:22
Check file mimetype
## this snippet requires `sudo pip install python-magic`
import magic
acceptable_type = ['text/plain', 'text/csv', 'text/xml', 'application/xml']
mimetype = magic.from_file( file, mime=True )
# validate mimetype
if ( mimetype not in acceptable_type ): print 'Invalid mimetype'
else: print 'Valid mimetype'
@jeff1evesque
jeff1evesque / list_element_index
Created January 27, 2015 19:09
Duplicate List Index
## duplicate_list_index: given a list, return a dictionary, with the 'key' being the list
# elements (unique, not duplicated), and the corresponding dictionary
# 'value' being a list containing the index location of each instance.
#
# for example:
# list_to_check = list('ABRACADABR')
#
# then, this method would return the following dictionary:
# {'A': [0, 3, 5, 7], 'R': [2, 9], 'B': [1, 8], 'C': [4], 'D': [6]}
def duplicate_list_index(list_to_check):
@jeff1evesque
jeff1evesque / haversine.js
Last active August 29, 2015 14:13
jQuery: haversine function(s)
/**
* haversine.js: contains necessary global functions needed to compute the distance
* between two GPS coordinate points (longitude, latitude).
*/
/**
* rad: converts degrees to radians.
*/
var rad = function(x) {
return x * Math.PI / 180;