Skip to content

Instantly share code, notes, and snippets.

View batandwa's full-sized avatar

Batandwa batandwa

View GitHub Profile
@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 / 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 / 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,
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 / custom_block.php
Created June 12, 2014 13:06
Drupal 7 - Custom block hooks
<?php
/**
* Implements hook_block_info().
*/
function YOUR_MODULE_block_info() {
$blocks = array();
$blocks['YOUR_BLOCK_ABC'] = array(
'info' => t('YOUR BLOCK NAME'),
);
@batandwa
batandwa / prefill_machine.js
Created June 27, 2014 10:46
Prefill Machine bookmarklet to auto-fill forms
(function(win, doc, $) {
'use strict';
// Don't run script if jQuery isn't loaded
if (typeof win.jQuery === 'undefined') {
return;
}
var data, fillForm, FormData, len, _rand;
@batandwa
batandwa / xdebug_debugging.md
Last active August 29, 2015 14:03
Check list for debugging Xdebug remote debugging issues

Host

  1. Check that the Xdebug is installed and loaded on your host. Run a phpinfo() script?
  2. Is xdebug.remote_enable enabled?
  • Is the IP in xdebug.remote_host correct?

Client

  1. Does your xdebug.remote_port match what is set in your client?
  2. Is xdebug.remote_port open on your client?
@batandwa
batandwa / str_split.vb
Created July 9, 2014 09:45
Excel: Split a string by a delimiter
Function STR_SPLIT(str, sep, n) As String
Dim V() As String
V = Split(str, sep)
If (n < 0) Then
STR_SPLIT = V(UBound(V) + 1 + n)
Else
STR_SPLIT = V(n - 1)
End If
End Function
@batandwa
batandwa / entity_wrapper_create.php
Created August 19, 2014 14:27
Drupal 7 Entities - Create an entity using the entity_metadata_wrapper class.
<?php
// The entity and bundle we are working with
$entity_type = "node";
$bundle = "node";
// Instantiate the wrapper for the bundle
$entity = entity_create($entity_type, array('type' => $bundle));
$wrapper = entity_metadata_wrapper($entity_type, $entity);
// Check what fields are available to us.
@batandwa
batandwa / entityfieldquery.php
Created August 19, 2014 17:04
Drupal 7 Entities - Fetch entities using EntityFieldQuery.
<?php
$entity_type = "node";
$bundle = "my_custon_content_type";
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', $entity_type)
->entityCondition('bundle', $bundle)
->fieldCondition('field_dwnl_file_content', 'value', 9);