Skip to content

Instantly share code, notes, and snippets.

@justin-endler
justin-endler / todo.sublime-snippet
Created November 23, 2013 19:54
// @todo Sublime snippet.
<snippet>
<content><![CDATA[
// @todo
]]></content>
<tabTrigger>todo</tabTrigger>
<description>@todo</description>
</snippet>
@justin-endler
justin-endler / test.sublime-snippet
Created November 23, 2013 19:53
// @test Sublime snippet.
<snippet>
<content><![CDATA[
// @test
]]></content>
<tabTrigger>test</tabTrigger>
<description>@test</description>
</snippet>
@justin-endler
justin-endler / heroku-deploy.sh
Last active December 29, 2015 03:09
General node.js Express app deployment script for Heroku.
#!/bin/bash
# requires that node app.js be contained in a Procfile
# ./heroku-deploy.sh <NODE_ENV> <local_branch_to_push> <app_to_destroy_if_redeploy>
# validate minimal input
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Run with at least NODE_ENV and local_branch_to_push as arguments $1 and $2"
exit 1
fi
@justin-endler
justin-endler / console_info.sublime-snippet
Last active December 28, 2015 00:48
Sublime snippet for quick insertion of a labeled console.info()
<snippet>
<content><![CDATA[
console.info('${1:thing}:', ${1}); // @test
]]></content>
<tabTrigger>info</tabTrigger>
<description>console.info()</description>
<scope>source.js</scope>
</snippet>
@justin-endler
justin-endler / storeUtil.js
Last active December 19, 2015 02:39
JavaScript utilities for use in a Drupal Commerce project.
(function($) {
Drupal.behaviors.storeUtil = {
/**
* @param Number negative places to move the decimal left, positive to move it right
* @param String float
* @return String
*/
moveDecimal: function(places, f) {
// Move zero places.
if (!places) {
@justin-endler
justin-endler / endler-migrate-field-data.php
Created December 17, 2012 19:03
Simple Drush script skeleton to find string values in a node field and migrate them to other fields.
<?php
/**
* @file endler-migrate-field-data.php
*
* Drush script to migrate some string from one set of node fields to another.
*
* @author Justin Endler
*/
function update_node_fields($entity_id, $value) {
@justin-endler
justin-endler / endler-trim-backups.sh
Last active December 9, 2015 19:38
Set a maximum amount of files and trim to that amount for a particular location.
#!/bin/bash
#
# Trim total files to maxbackups amount.
#
# Cron:
# http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/
#
# @author Justin Endler
#
@justin-endler
justin-endler / endler-wordpress-render-media-button.php
Created December 17, 2012 01:00
How to render a media button in WordPress post edit, making it work for WordPress 3.x.
<?php
/**
* This assumes you'll be plugging in to media-upload.php in order to upload a file.
*
* @author Justin Endler
*/
// Get WordPress version.
$version = get_bloginfo('version');
@justin-endler
justin-endler / endler-d7-feature-review.sh
Created December 10, 2012 17:00
Sets up a local Drupal 7 branch review and attempts a merge with a forked-from repo.
#!/bin/bash
#
# Sets up a local Drupal 7 branch review and attempts a merge with a forked-from repo.
#
# @author Justin Endler
#
defaultsettings="http://drupalcode.org/project/drupal.git/blob_plain/HEAD:/sites/default/default.settings.php"
echo -e "\nThis script is D7-specific."