Skip to content

Instantly share code, notes, and snippets.

View khalib's full-sized avatar

Caleb Whang khalib

  • San Francisco Giants
  • San Francisco, CA
View GitHub Profile
@khalib
khalib / graphite_init.sh
Created June 26, 2015 23:42
Graphite Drush Init
drush -l local.graphite.org vset preprocess_js 0 --yes
drush -l local.graphite.org vset preprocess_css 0 --yes
drush -l local.graphite.org pm-disable -y masquerade
drush -l local.graphite.org pm-disable -y cdn
drush -l local.graphite.org vset honeypot_time_limit 0 --yes
drush -l local.graphite.org vset error_level 2 --yes
drush -l local.graphite.org vset csm_migration_d6_hostname local.csm.org --yes
drush -l local.graphite.org vset tlr_csm_sync_csm_api_host local.csm.org --yes
<?php
$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'graphite_150623',
'username' => 'graphite',
'password' => 'graphite',
[docker version]
Client version: 1.5.0
Client API version: 1.17
Go version (client): go1.4.1
Git commit (client): a8a31ef
OS/Arch (client): darwin/amd64
Server version: 1.5.0
Server API version: 1.17
Go version (server): go1.4.1
Git commit (server): a8a31ef
@khalib
khalib / cs-api-php-example.php
Last active August 29, 2015 14:09
Example usage of the Common Sense api-php driver.
$api_info = variable_get('csm_api_info');
// the third TRUE param sets to use DEV api server. Remove for launch.
$api = new CommonSenseApi($api_info['clientId'], $api_info['appId'], TRUE);
// Get education API instance.
// There are two magic methods to fetch data from the API
// <type>_list($options) and <type>_item($id, $options)
// where <type> is one of: products, blog, app_flows, lists, user_reviews, boards
$education = $api->education();
@khalib
khalib / deploy.sh
Last active June 1, 2016 21:50
Dev Sandbox Deploy
###########
# LOCAL #
###########
# Copy Acquia ssh key for Git access.
scp -i ~/.ssh/cs_education.key ~/.ssh/acquia_graphite_rs* root@ec2-54-215-27-192.us-west-1.compute.amazonaws.com:/root/.ssh/
############
# SERVER #
############
# Change ssh key access.
@khalib
khalib / mirror.git
Last active August 29, 2015 14:02
Mirror deviated branch to an existing branch
# Branch DEV has extra files and commits that are not needed anymore
# DEV is to be a mirror of MASTER
# Get the latest DEV branch
git checkout DEV
git pull origin DEV
# Get the latest MASTER branch
git checkout MASTER
git pull origin MASTER
<div class="coming-soon">
<h1><?php print $node->title; ?></h1>
This is a coming soon review
</div>
function tlr_learning_rating_menu() {
$items = array();
$items['node/%node'] = array(
'page callback' => 'tlr_learning_rating_view_alt_page',
'page arguments' => array(1),
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
@khalib
khalib / drinks.js
Last active August 29, 2015 13:57
How to communicate from the backend to javascript in Drupal 7.
(function($) {
Drupal.behaviors.drinks = {
attach: function(context, settings) {
var drinkType = settings.drinks.page_type;
alert('This page is of type: ' + drinkType);
}
}
})(jQuery);
@khalib
khalib / view_modes_example.module
Created January 22, 2014 21:34
Example of how Drupal 7 view mode template variables are set
<?php
function tlr_blog_preprocess_node(&$variables) {
global $user;
$node = $variables['node'];
if ($node->type == 'tlr_blog') {
$blog = new TLRBlog($node->nid);
$account = $blog->get_user();