Skip to content

Instantly share code, notes, and snippets.

@ivandoric
ivandoric / gist:11219200
Created April 23, 2014 15:10
jQuery: Vertical align elements
(function (jQuery) {
// VERTICALLY ALIGN FUNCTION
jQuery.fn.vAlign = function() {
return this.each(function(i){
var ah = jQuery(this).height();
var ph = jQuery(this).parent().height();
var mh = Math.ceil((ph-ah) / 2);
jQuery(this).css('padding-top', mh);
});
};
@ivandoric
ivandoric / gist:11219129
Created April 23, 2014 15:08
sublime: Package Control doesn't work
Just add this to:
Preferences > Package Setteings > Settings - User
{
"auto_upgrade_last_run": 1331660912,
"repository_channels": [
"http://sublime.wbond.net/repositories.json"
]
}
@ivandoric
ivandoric / gist:11219071
Created April 23, 2014 15:07
sublime: No "map to remote" command solution
To fix this, please perform the following:
Open Preferences > Browse Packages…
Navigate into the SFTP/ folder and open SFTP.py in Sublime.
Without making any modifications, save the file. Sublime SFTP should now be fully functional again.
@ivandoric
ivandoric / gist:11219045
Created April 23, 2014 15:06
css: Target only Firefox with CSS
@-moz-document url-prefix() {
ul.nav li a {
padding:0 15px 2px 15px;
}
}
@ivandoric
ivandoric / gist:11219021
Created April 23, 2014 15:06
wordpress: Automatically add category to post when certain other category is selected
<?php
function add_category_automatically1($post_ID) {
global $wpdb;
if(in_category(7)){
$cat = array(10);
wp_set_object_terms($post_ID, $cat, 'category', true);
}
}
add_action('publish_post', 'add_category_automatically1');
@ivandoric
ivandoric / gist:11218980
Created April 23, 2014 15:05
shell: Tar
tar -cvzf backup.tar * //packing
tar zxvf file_name.tar.gz * //unpacking
@ivandoric
ivandoric / gist:11215772
Created April 23, 2014 13:46
wordpress: More that works on pages and posts
<?php
global $more;
$more = 0;
the_content('');
?>
@ivandoric
ivandoric / gist:11215753
Created April 23, 2014 13:46
wordpress: Filter posts by comparing meta value
<?php
$trenutnovrijeme = strtotime('now');
query_posts( array(
'post_type' => 'javna-nadmetanja',
'orderby' => 'wpcf-datum-objave',
'meta_key' =>'wpcf-datum-zatvaranja',
'meta_compare'=>'>' ,
'meta_value' => $trenutnovrijeme,
'order' => DESC,
'showposts' => 10,
@ivandoric
ivandoric / gist:11215702
Created April 23, 2014 13:44
sublime: Always use same indentation
Add this to Preferences - Settings user
"tab_size": 8,
"translate_tabs_to_spaces": true,
"auto_indent": true,
"detect_indentation": false
@ivandoric
ivandoric / gist:11215689
Created April 23, 2014 13:43
wordpress: Title for custom Wordpress pages, that have special loops on them
<?php
$post_id = $wp_query->post->ID; // get post ID
?>
<h2><?php echo get_the_title($post_id); ?></h2>
/* If using WPML for translation then */
<h2><?php echo get_the_title(icl_object_id($post_id, 'page', false)); ?></h2>