Skip to content

Instantly share code, notes, and snippets.

View batandwa's full-sized avatar

Batandwa batandwa

View GitHub Profile
@batandwa
batandwa / dump.py
Created May 5, 2014 08:51
A configurable python script that wraps around mysqldump with some additional configuration.
#!/usr/bin/python
# Run with:
# python hello.py cameron
# python hello.py
# import modules used here -- sys is a very standard one
import sys
import subprocess
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e53a722096f0 aafd21071b99 /opt/bin/run_all 41 minutes ago Up 28 minutes 127.0.0.1:49251->22/tcp, 127.0.0.1:49252->9200/tcp es-b
0208431f9c7b aafd21071b99 /opt/bin/run_all 41 minutes ago Up 28 minutes 127.0.0.1:49249->22/tcp, 127.0.0.1:49250->9200/tcp es-a
@batandwa
batandwa / term_update.php
Created March 5, 2014 07:05
Drupal 7 - Update a file or any other field on a taxonomy term
<?php
dsm(taxonomy_term_load(1060));
dsm(taxonomy_term_load(1064));
$term = taxonomy_term_load(1311);
$filepath = drupal_realpath('sites/powertech_crabtree/files/images/footer_logo_aberdare.png');
// Create managed File object and associate with Image field.
$file = (object) array(
'uid' => 1,
'uri' => $filepath,
@batandwa
batandwa / term_recursive_nodes.php
Created February 20, 2014 08:43
Get nodes of term and it child terms
<?php
/**
* Uses the passed in term and its children and gets the associated nodes. Pass
* the returned array into entity_load to load the nodes.
*
* @author Batandwa Colani
* @date 2014-02-20
* @version 1
*
* @param int $tid The parent term id
@batandwa
batandwa / slide.html
Last active August 29, 2015 13:56
Simple fade slideshow by Jonathan Snook (http://snook.ca/archives/javascript/simplest-jquery-slideshow).
<div class="fadein">
<img src="http://farm3.static.flickr.com/2610/4148988872_990b6da667.jpg">
<img src="http://farm3.static.flickr.com/2597/4121218611_040cd7b3f2.jpg">
<img src="http://farm3.static.flickr.com/2531/4121218751_ac8bf49d5d.jpg">
</div>
@batandwa
batandwa / path_search.php
Last active January 3, 2016 14:09
Drupal - Prints the details of paths that starts with the specified search string.
<?php
function HOOK_menu_alter(&$items) {
$search = 'node/';
foreach ($items as $path => $options) {
if(strpos($path, $search) === 0) {
drupal_set_message('<strong>' . $path . '</strong><pre>'.var_export($options, TRUE).'</pre>', 'status', FALSE);
}
}
}
@batandwa
batandwa / vmtobox.sh
Last active January 3, 2016 00:39
Vigrant - Export a VirtualBox VM and import it as a Vagrant box
#!/bin/bash
if [ -z "$2" ];then
echo "We need two parameters, boet."
echo " Usage: $FUNCNAME vagrant-name vbox-machine-name"
return 1
fi
export lowername=$2
export tempdir=createvmbox.$((RANDOM))
@batandwa
batandwa / flush_style_images.php
Last active January 2, 2016 17:29
Drupal 7 - Removes all the style images generated so new ones can be created when needed.
<?php
module_load_include('module', 'image');
$styles = array_keys(image_styles());
image_style_flush($styles);
drupal_set_message(t('Flushed images for the following styles: %styles.', array('%styles' => implode(', ', $styles))), 'status', FALSE);
@batandwa
batandwa / admin_links.css
Created September 6, 2013 07:08
Drupal 7 Panels fix for contextual/admin links position
@batandwa
batandwa / conemu.py
Created July 3, 2013 08:15
Sublime Text 2 plugin for launching ConEmu.
import sublime, sublime_plugin, os, subprocess
class ConemuCommand(sublime_plugin.TextCommand):
def run(self, edit):
if os.name == "nt":
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
process = subprocess.Popen(('c:/Program Files (x86)/ConEmu/ConEmu.exe', '/single', self.view.file_name()),