Skip to content

Instantly share code, notes, and snippets.

View zip-excluding-specific-directories-and-files.md

Zip excluding specific directories

Exclude .git file and node_modules directory

$ zip -r9 [target_file] [source_file] -x *.git* node_modules/\*

Exclude .git file and files in node_modules directory, but keep node_modules directory

$ zip -r9 [target_file] [source_file] -x *.git* node_modules/**\*
View metaplate-from-file.php
<?php
/**
* Load the template data from a file (file must be .html or .htm )
*/
//load from child theme or parent theme
$file = 'template.html';
echo caldera_metaplate_from_file( $file, $post_id );
//or use absolute patth
//$file = __FILE__ . '/template.html';
@yoren
yoren / 0_reuse_code.js
Created May 31, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View .scrutinizer.yml
filter:
excluded_paths:
- 'languages/*'
- 'lib/*'
- 'tests/*'
paths:
- 'inc/*'
- '*'
tools:
php_cpd:
@yoren
yoren / functions.php
Last active Jan 1, 2016 — forked from WerdsWords/post_row_actions.php
Remove quickedit.
View functions.php
<?php
/**
* Disable Quick Edit row action for posts
*
* @see WP_Posts_List_Table::single_row()
*
* @param array $actions An array of row actions, keys corresponding to the span class attribute of each element.
* @param object $post The post object.
*
* @return array The row actions array.
View copy post to blog function
<?php
function copy_post_to_blog($post_id, $target_blog_id) {
$post = get_post($post_id, ARRAY_A); // get the original post
$meta = get_post_meta($post_id);
$post['ID'] = ''; // empty id field, to tell wordpress that this will be a new post
switch_to_blog($target_blog_id); // switch to target blog
$inserted_post_id = wp_insert_post($post); // insert the post
foreach($meta as $key=>$value) {
update_post_meta($inserted_post_id,$key,$value[0]);
}
@yoren
yoren / index.html
Created Oct 24, 2013 — forked from anonymous/index.html
A quick demo showing how to capture the order of connected sortable lists.
View index.html
<ul id="image-list1" class="sortable-list">
<li id="a">A</li>
<li id="b">B</li>
<li id="c">C</li>
</ul>
<ul id="image-list2" class="sortable-list">
<li id="1">1</li>
<li id="2">2</li>
<li id="3">3</li>
View launch_sublime_from_terminal.markdown

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@yoren
yoren / del_dir.php
Created Dec 19, 2012 — forked from devpilot/del_dir.php
PHP: Delete directory and its content
View del_dir.php
<?php
/**
* Delete directory with content in it
* @author Pilot
* @param string $directory Directory to delete
*/
function del_dir($directory) {
$content = scandir($directory);
unset($content[0], $content[1]);
@yoren
yoren / gist:3749066
Created Sep 19, 2012 — forked from willmot/gist:1277790
WordPress attachment category plugin
View gist:3749066
<?php
/*
Plugin Name: Attachment Categories
Description: Allows attachments to be categorised
Version: 1.0
Author: Human Made Limited
Author URI: http://hmn.md
*/