Skip to content

Instantly share code, notes, and snippets.

View neojp's full-sized avatar

Joan P. neojp

View GitHub Profile
@neojp
neojp / Node.js: Using "supervisor" with "Locomotive"
Created February 16, 2012 19:59
Runs a Locomotive app, listens and auto-reloads server if code changes are found.
# node-supervisor: https://github.com/isaacs/node-supervisor
# locomotive: http://locomotivejs.org/
supervisor --watch app/controllers,config,config/environments,config/initializers -- node_modules/locomotive/bin/lcm.js server
@neojp
neojp / gist:1865776
Created February 19, 2012 21:06
Slugify a string, remove whitespace, convert accented letters and some signs
slugify = (str) ->
str = str.replace /^\s+|\s+$/g, ''
str = str.toLowerCase()
# remove accents, swap ñ for n, etc
from = "àáäâèéëêìíïîòóöôùúüûñ箩·/_,:;"
to = "aaaaeeeeiiiioooouuuuncrc------"
for i, character of from.split ''
str = str.replace new RegExp(character, 'g'), to.charAt i
@neojp
neojp / coffee.sh
Created February 19, 2012 21:09
Watch and auto update a Node.js app in Coffeescript with Supervisor.
coffee -wc app.coffee
@neojp
neojp / classses.styl
Created March 2, 2012 15:40
Stylus: Image replacement mixin
// Image replacement
ir()
width = arguments ? arguments[0] : 100%
height = arguments && arguments[1] ? arguments[1] : false
height = height ? height : width
direction ltr
display block
height height
overflow hidden
@neojp
neojp / assets.php
Created March 21, 2012 18:50
Enqueue WordPress static assets with dynamic versioning passed over in the query string.
// enqueue local theme assets
function _enqueue_assets($css, $js) {
// add files to the $css or $js arrays like this
// 'handle' => 'js/filename.js'
//
// or like this
// 'handle' => array(
// 'src' => 'js/filename.js', // don't start with /
// 'deps' => null, // can be string or array of strings
// 'version' => null,
/*
* Simple javascript mobile OS / iphone/ android detector
*
* License: GPLv3+
* Author: justin.kelly.org.au
*
*/
$(document).ready(function() {
var deviceIphone = "iphone";
@neojp
neojp / widget-css-classes.class.php
Created October 9, 2012 15:49
Wordpress CSS Classes - Widget Context support
// http://wordpress.org/extend/plugins/widget-css-classes/developers/
// widget-css-classes/includes/widget-css-classes.class.php - Line 97
// if Widget Logic plugin is enabled, use it's callback
if ( in_array( 'widget-logic/widget_logic.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
$widget_opt = get_option( $widget_obj['callback_wl_redirect'][0]->option_name );
// if Widget Context plugin is enabled, use it's callback
} elseif ( in_array( 'widget-context/widget-context.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
$widget_opt = get_option( $widget_obj['callback_original_wc'][0]->option_name );
@neojp
neojp / gist:5561946
Created May 12, 2013 00:42
How to install Node.js & NPM on CentOS 6.4
# rpm -Uvh http://epel.mirror.constant.com/6/i386/epel-release-6-8.noarch.rpm
# yum --enablerepo=epel-testing install npm
@neojp
neojp / gist:5678717
Created May 30, 2013 15:21
Refresh the Upstart scripts index on Ubuntu
# initctl reload-configuration
@neojp
neojp / custom-debug-bar-panel-class.php
Created January 20, 2014 19:54
WordPress - Debug Bar Panel class
<?php
Class CustomDebugBarPanel extends Debug_Bar_Panel {
public function init() {
$this->title(__('Custom Debug Bar Panel', 'debug-bar'));
add_action('wp_print_styles', array( $this, 'print_styles'));
add_action('admin_print_styles', array( $this, 'print_styles'));
}
public function prerender() {