Skip to content

Instantly share code, notes, and snippets.

split -d -b 4300m backup.tar.bz2 backup.tar.bz2.
cat backup.tar.bz2.* > backup.tar.bz2
sed 's/old/new/g' input.txt > output.txt
$myValue = '123';
// First you need to set the visual value, then you need to set it selected, this is retarted
$('#myselect').val($myValue).attr("selected", "selected");
@SubZane
SubZane / gist:5896271
Created June 30, 2013 18:23
tar and bzip a folder and its subfolders
tar -c --bzip2 -f foo.tar.bz1 foo/
@SubZane
SubZane / Asset.php
Created August 27, 2012 14:55
WordPress: get_attachment_id_from_src
function get_attachment_id_from_src ($src) {
global $wpdb;
$reg = "/-[0-9]+x[0-9]+?.(jpg|jpeg|png|gif)$/i";
$src1 = preg_replace($reg,'',$src);
if($src1 != $src){
$ext = pathinfo($src, PATHINFO_EXTENSION);
$src = $src1 . '.' .$ext;
}
$query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$src'";
$id = $wpdb->get_var($query);
@SubZane
SubZane / Asset.php
Created August 23, 2012 14:38
WordPress: Image Custom Meta Property
add_action( 'add_meta_boxes', 'custom_meta_boxes' );
add_action( 'save_post', 'ExtraImageProperty_save' );
function custom_meta_boxes() {
add_meta_box('ExtraImageProperty', 'Extra Image Property', 'ExtraImageProperty', 'page');
}
function ExtraImageProperty() {
global $post;
$extra_image_url = get_post_meta($post->ID, 'extra_image_url', true);