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 / Mac OSX Finder View Hidden Files
Created January 7, 2014 00:21
View Hidden Files In OSX Finder
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
@khalib
khalib / cms_install.sh
Last active October 3, 2017 09:26
MNPP: Mac/Nginx/Percona-MySQL/PHP install via Homebrew
# Install Xcode
xcode-select --install
# Install Homebrew.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
brew update
# Install git.
brew install git
@khalib
khalib / Mac OSX Django install
Last active January 2, 2016 11:19
Mac OSX Django install
# Install python
brew install python
# Add python to path.
# export PATH=/usr/local/share/python:$PATH
# Install virtualenv.
pip install virtualenv
# Create virtual environment for the project.
@khalib
khalib / Useful Compass Commands
Last active January 2, 2016 13:19
Useful Compass Commands
# Install compass
gem update --system
gem install compass
# Force compile all SASS files.
compass compile -e production --force
# Clear registry/memcache on Acquia
echo -e "flush_all\r\nquit" | nc `hostname -s` 11211
@khalib
khalib / Graphite Nginx Virtual Host
Created January 9, 2014 18:57
Nginx config template for Graphite as a virtual host
server {
listen 127.0.0.1:80;
server_name local.graphite.org;
access_log /usr/local/var/log/nginx/graphite.access.log;
error_log /usr/local/var/log/nginx/graphite.error.log;
root /var/www/graphite.org/source/www/docroot;
location / {
try_files $uri @rewrite;
}
<?php
// Hook theme.
function tlr_learning_rating_theme() {
return array(
'learning_rating_rate' => array(
'template' => 'templates/block_learning_rating_rate',
),
);
}
?>
@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();
@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);
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,
);
<div class="coming-soon">
<h1><?php print $node->title; ?></h1>
This is a coming soon review
</div>