This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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:/# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 ~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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; |