Skip to content

Instantly share code, notes, and snippets.

@code26
code26 / jsp_switch_page_template.php
Last active August 29, 2015 14:06
Automatic template selector for Wordpress Ancestor/Child Pages
function jsp_switch_page_template() {
global $post;
if (is_page() && !get_page_template_slug( $post->ID )) { //if no template was selected via WP
$ancestors = $post->ancestors;
if ($ancestors) {
$templatePath = TEMPLATEPATH . '/';
$prefix = 'page-'; //default page template prefix
$ext = '.php';
@code26
code26 / jsp_switch_category_template.php
Last active August 29, 2015 14:06
Automatic template selector for Wordpress Child/Ancestor Categories
function jsp_switch_category_template() {
if (is_category()) {
$ancestors = get_ancestors(get_query_var('cat'),'category');
$catname = get_query_var('category_name');
if ($ancestors) {
$templatePath = TEMPLATEPATH . '/';
$prefix = 'category-'; //default page template prefix
$ext = '.php';
$appender = '_child';
$parent_id = $ancestors[0];
@code26
code26 / eos_plymouth_fix.md
Last active August 29, 2015 14:25
[eOS] Plymouth fix for 1366 screens after updating to Nvidia proprietary driver

Plymouth

  1. Open /lib/plymouth/themes/elementary/elementary.script
  2. add aspectRatio = Window.GetWidth() / 1366;
  3. find logo.image = Image (logo_filename).Scale (logo.screen_size, logo.screen_size);
  4. change to logo.image = Image (logo_filename).Scale (logo.screen_size * aspectRatio, logo.screen_size);
  5. (also apply to logo_blurred)
  6. save
  7. sudo update-initramfs -u

Grub

@code26
code26 / clone_parts.md
Last active August 29, 2015 14:25
Clone a specific folder

svn checkout https://github.com/foobar/Test/trunk/foo

where trunk = tree/master

@code26
code26 / aliasWithParameter.md
Last active August 29, 2015 14:25
create an alias that accepts a parameter

Go to www directory with subdirectory option

wwwdir() { cd /var/www/$1 }

alias www=wwwdir

@code26
code26 / gulp-watch_ENOSPC_fix.md
Created July 23, 2015 08:11
fix for the mysterious error on Ubuntu

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

OR

npm dedupe

{
"auto_complete": false,
"auto_complete_commit_on_tab": false,
"bold_folder_labels": true,
"caret_extra_bottom": 0,
"caret_extra_top": 0,
"caret_extra_width": 1,
"caret_style": "phase",
"color_inactive_tabs": true,
"color_scheme": "Packages/Seti_UI/Scheme/Seti_monokai.tmTheme",
@code26
code26 / gist:149e98ee20d1b68164bf
Created January 8, 2016 04:45
Grant permission to user
sudo usermod -aG www-data username
sudo chown -R www-data:www-data /var/www/example.com/public_html
sudo chmod -R 770 /var/www/example.com/public_html
@code26
code26 / transpose.js
Created February 1, 2016 02:43
simple transpose
//from http://stackoverflow.com/a/7936999
function transposeChord(chord, amount) {
var scale = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
return chord.replace(/[CDEFGAB]#?/g,
function(match) {
var i = (scale.indexOf(match) + amount) % scale.length;
return scale[ i < 0 ? i + scale.length : i ];
});
}
@code26
code26 / mailchimp
Created March 2, 2016 02:53
mailchimp js
var app = (function(){
return {
events: function() {
//form
var $form = $('#subscribeForm'),
$formContainer = $('.form-container'),
$notify = $('.error-msg',$formContainer);
if ( $form.length > 0 ) {
$form.on('submit',function(e){