Skip to content

Instantly share code, notes, and snippets.

View cabans's full-sized avatar
:octocat:

Abel Cabans cabans

:octocat:
View GitHub Profile
@zaydek-old
zaydek-old / bookmark.min.js
Last active January 22, 2023 13:42
A *simple* CSS debugger. To use, bookmark "Debug CSS" at https://zaydek.github.io/debug.css. Learn more here https://medium.freecodecamp.org/88529aa5a6a3 and https://youtu.be/2QdzahteCCs?t=1m25s (starts at 1:25)
/* debug.css | MIT License | zaydek.github.com/debug.css */ if (!("is_debugging" in window)) { is_debugging = false; var debug_el = document.createElement("style"); debug_el.append(document.createTextNode(`*:not(g):not(path) { color: hsla(210, 100%, 100%, 0.9) !important; background: hsla(210, 100%, 50%, 0.5) !important; outline: solid 0.25rem hsla(210, 100%, 100%, 0.5) !important; box-shadow: none !important; filter: none !important; }`)); } function enable_debugger() { if (!is_debugging) { document.head.appendChild(debug_el); is_debugging = true; } } function disable_debugger() { if (is_debugging) { document.head.removeChild(debug_el); is_debugging = false; } } !is_debugging ? enable_debugger() : disable_debugger();
@hash-bang
hash-bang / gulp-tasks-scripts.js
Created February 12, 2016 01:12
Example Gulp task for scripts building using gulp-notify
/**
* Compile all JS files into the build directory
*/
var scriptBootCount = 0;
gulp.task('scripts', ['load:config'], function() {
var hasErr;
return gulp.src(paths.scripts)
.pipe(gplumber({
errorHandler: function(err) {
gutil.log(colors.red('ERROR DURING JS BUILD'));
@jnlsn
jnlsn / functions.php
Last active February 20, 2022 20:28
WP Query Orderby Taxonomy Term Name
add_filter('posts_clauses', 'posts_clauses_with_tax', 10, 2);
function posts_clauses_with_tax( $clauses, $wp_query ) {
global $wpdb;
//array of sortable taxonomies
$taxonomies = array('example-taxonomy', 'other-taxonomy');
if (isset($wp_query->query['orderby']) && in_array($wp_query->query['orderby'], $taxonomies)) {
$clauses['join'] .= "
LEFT OUTER JOIN {$wpdb->term_relationships} AS rel2 ON {$wpdb->posts}.ID = rel2.object_id
LEFT OUTER JOIN {$wpdb->term_taxonomy} AS tax2 ON rel2.term_taxonomy_id = tax2.term_taxonomy_id
LEFT OUTER JOIN {$wpdb->terms} USING (term_id)
@evalica
evalica / CSScomb Alphabetical order
Created October 2, 2012 17:13
See CSScomb (http://csscomb.com/) for more details. Alphabetical order can be used by replacing $default_sort_order variable in "/Sublime Text 2/Packages/CSScomb/csscomb/libs/csscomb.php" with the following code:
$default_sort_order = '[
"-webkit-animation",
"-moz-animation",
"-ms-animation",
"-o-animation",
"animation",
"-webkit-animation-delay",
"-moz-animation-delay",
"-ms-animation-delay",
"-o-animation-delay",
@cabans
cabans / fix_paged_homepage.php
Created September 27, 2012 09:34
Wordpress: Fix for loop pagination with Custom Post Type in homepage
<?php
//Fix homepage pagination
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} else if ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
@jreinke
jreinke / generate.php
Created August 14, 2012 14:45
Default password encoding in Silex micro-framework
<?php
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
$encoder = new MessageDigestPasswordEncoder();
echo $encoder->encodePassword('foo', '');
// 5FZ2Z8QIkA7UTZ4BYkoC+GsReLf569mSKDsfods6LYQ8t+a8EW9oaircfMpmaLbPBh4FOBiiFyLfuZmTSUwzZg==
@Zodiac1978
Zodiac1978 / .htaccess
Last active March 15, 2024 08:29
Make your Website faster - a safe htaccess way
#
# Sources:
# http://stackoverflow.com/questions/7704624/how-can-i-use-gzip-compression-for-css-and-js-files-on-my-websites
# http://codex.wordpress.org/Output_Compression
# http://www.perun.net/2009/06/06/wordpress-websites-beschleuinigen-4-ein-zwischenergebnis/#comment-61086
# http://www.smashingmagazine.com/smashing-book-1/performance-optimization-for-websites-part-2-of-2/
# http://gtmetrix.com/configure-entity-tags-etags.html
# http://de.slideshare.net/walterebert/die-htaccessrichtignutzenwchh2014
# http://de.slideshare.net/walterebert/mehr-performance-fr-wordpress
# https://andreashecht-blog.de/4183/
@kanduvisla
kanduvisla / jquery.increment.js
Created March 28, 2012 10:30
jQuery Input Field Incrementer
(function (jQuery) {
jQuery.fn.extend({
incrementButtons:function (options) {
var defaults = {
minVal:null,
maxVal:null,
incClass:'inc',
decClass:'dec',
@ninnypants
ninnypants / remove-empty-p.php
Last active January 3, 2023 01:11
Remove empty p tags from WordPress posts
<?php
add_filter( 'the_content', 'remove_empty_p', 20, 1 );
function remove_empty_p( $content ){
// clean up p tags around block elements
$content = preg_replace( array(
'#<p>\s*<(div|aside|section|article|header|footer)#',
'#</(div|aside|section|article|header|footer)>\s*</p>#',
'#</(div|aside|section|article|header|footer)>\s*<br ?/?>#',
'#<(div|aside|section|article|header|footer)(.*?)>\s*</p>#',
'#<p>\s*</(div|aside|section|article|header|footer)#',
@jcsrb
jcsrb / gist:1081548
Created July 13, 2011 23:05
get avatar from google profiles, facebook, gravatar, twitter, tumblr
function get_avatar_from_service(service, userid, size) {
// this return the url that redirects to the according user image/avatar/profile picture
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px )
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word )
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px )
// for twitter use get_avatar_from_service('twitter', username, size-in-px or size-as-word )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )
// everything else will go to the fallback
// google and gravatar scale the avatar to any site, others will guided to the next best version