Skip to content

Instantly share code, notes, and snippets.

@okjake
okjake / gist:1280968
Created October 12, 2011 11:26
Script to do a bulk change of Drupal 6 user email domains
<?php
/*
* Does a bulk change of email addresses stored in a Drupal 6 database, eg from *@example.com to *@new-example.com
*
* Ensure that a backup is taken before running this.
* 0. TAKE A BACKUP OF YOUR DATABASE - mysqldump -u[username] -p[password] [dbname] > [dbname].sql
* 1. Fill out the details below
* 2. Upload this somewhere accessible over the web
* 3. Point your browser to it
@okjake
okjake / drupal-theme-filesizes.php
Created December 21, 2011 17:34
Printing pretty filesizes in a Drupal theme
/*
* Takes a filesize integer and returns a decently formatted string
* This function needs to go into template.php, don't forget to change the theme name below
* Call it like this:
* - print mytheme_format_filesize($node->field_downloads[0]['filesize']
*/
function mytheme_format_filesize($filesize) {
if ($filesize < 1024) {
return $filesize . ' bytes';
@okjake
okjake / gist:2158253
Created March 22, 2012 13:05
Rails form errors with Bootstrap
# To get form error states showing properly using Bootstrap with Rails, use (in config/application.rb):
config.action_view.field_error_proc = Proc.new { |html_tag, instance| "<div class=\"control-group error\">#{html_tag}</div>".html_safe }
@okjake
okjake / gist:5021573
Created February 23, 2013 22:08
human readable filesizes
var humanFilesize = function(bytes){
if (bytes < 1024)
return bytes + ' bytes';
if (bytes < 1048576)
return (bytes / 1024) + ' kB';
if (bytes < 1073741824)
return bytes / 1048576 + ' MB';
if (bytes < 1099511627776)
return (bytes / 1073741824) + ' GB';
return (bytes / 1099511627776) + ' TB';
@okjake
okjake / wordpress apache proxy
Last active December 21, 2015 12:29
steps to proxy a wordpress url to a different server
1. Enable Apache modules if they're not already
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
2. Set up the proxy in a vhost
ProxyPass /localdir http://example.com/remotedir
ProxyPassReverse /localdir http://example.com/remotedir
@okjake
okjake / deploy.rb
Created December 12, 2013 13:06
Generic capistrano / capifony configuration for Symfony 2 project deployment to dopey servers
# app/config/deploy.rb
# Replace strings in "CAPITALS"
# Assumptions, adjust to taste:
# - Using Composer
# - No git on remote server
# - Staging and production environments are on the same IP
# - Database and webserver are on the same IP
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
@okjake
okjake / atmos
Last active August 29, 2015 13:57
EMC Atmos file upload
# Edit the following with relevant details
uid=""
key=""
endpoint=""
file_to_upload="/local/path/to/large/file.ext"
atmos_dir="/test/"
contentType="image/jpeg"
# Stop editing here
filename=`basename $file_to_upload`
@okjake
okjake / gist:441e807515bc740afcf1
Created August 31, 2014 16:59
Minimal PS1. Uses git-prompt.sh
source ~/.git-prompt.sh
export PS1='\[\033[0;31m\]$(__git_ps1 " (%s)") \[\033[0;37m\]~ '
@okjake
okjake / convert
Last active August 29, 2015 14:07
video transcoding for the web
#!/bin/bash
# Produces HTML5 friendly video formats
# Usage (OSX):
# brew install ffmpeg --with-libvpx --with-libvorbis --with-theora
# curl https://gist.githubusercontent.com/okjake/7d347f26b8bdc9496b67/raw/f2c91daf1ebacc3c117d8b304403f03b157f1109/gistfile1.txt > cnv.sh && chmod u+x cnv.sh
# cnv.sh /path/to/video1.mp4 /path/to/video2.mov
if [ ! $# -gt 0 ]; then
@okjake
okjake / patterns.json
Last active January 26, 2016 12:07
pattern manifest
{
"patterns": [
{
"id": "news-card-audio-001",
"name": "Audio Card",
"product": "News",
"type": "Card",
"inUse": true,
"description": "Used to play audio without leaving the current page",
"owner": "test@example.com",