Skip to content

Instantly share code, notes, and snippets.

@srdjan-m
srdjan-m / primnav_w_soc_icns.php
Last active January 28, 2017 20:53 — forked from cdils/functions.php
wordpress: add widget area (with Simple Socian Icons) to primary navigation.
.genesis-nav-menu .widget {
float: right;
}
.genesis-nav-menu .simple-social-icons ul li {
margin-bottom: 0 !important;
margin-top: 0.7rem !important;
}
// *** Extends the following class: src/wp-includes/class-wp-widget.php
class My_Widget extends WP_Widget {
/**
* Sets up the widgets name etc
*/
public function __construct() {
$widget_ops = array(
'classname' => 'my_widget',
@srdjan-m
srdjan-m / optimized_badass.rb
Last active December 29, 2016 02:56
sonic_pi: optimized badass
# "The Optimized Badass"
# Sonic Pi v2.11
# ----------------------------------------
# Samples used in this song can be downloaded from:
# https://dl.dropboxusercontent.com/u/657073/sonicpi/badass-samples.zip
# Unpack and put them into your samples folder.
# ----------------------------------------
# This file is too long to be played from the Sonic Pi IDE
# Instead of pasting this code, just enter the following into the Sonic Pi editor:
# run_file "/path/to/this_file.rb"
@srdjan-m
srdjan-m / song_of_the_sea.rb
Last active February 18, 2018 20:07
sonic_pi: the song of the sea
# Sonic Pi 2.11
set_volume! 1
##| Link to the samples folder:
samples_dir = "/Users/srdjan/Dropbox Srdjan/Dropbox/Projects/Sonic_Pi/song_by_sea/samples/"
##| There is 99.9999% chance that your link is different. Change it to point to your dir...
use_synth_defaults pulse_width: 0.99, coef: 0.45
# -------------------- CONTROL --------------------
@srdjan-m
srdjan-m / rmPostHeaderMeta.php
Last active July 25, 2016 08:45
genesis: remove post entry meta in entry header
//* Remove the entry meta in the entry header (requires HTML5 theme support)
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
@srdjan-m
srdjan-m / rmPostFooterMeta.php
Last active July 25, 2016 08:45
genesis: remove post meta info in entry footer
//* Remove the post meta function after the post (Filled under...)
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
@srdjan-m
srdjan-m / imagemagick-anim-gif.txt
Last active June 7, 2016 13:25
imagemagick: animated GIF
// Animated GIF
convert -delay 120 -loop 0 *.png animated.gif
// Get duration for animated gif frames
identify -format "Frame %s: %Tcs\n" animated.gif
@srdjan-m
srdjan-m / imagemagick.txt
Last active June 7, 2016 13:25
imagemagick: various commands
// Change canvas size (resize canvas to 48x48 pixels)
convert input.png -gravity center -background transparent -extent 48x48 output.png
// Resize
convert img1.png -resize 400x300 img2.png
// Resize by height only:
convert img1.png -resize x300 img2.png
// width_x_height_+_leftoffset_+_topoffset_
@srdjan-m
srdjan-m / topixels.js
Created June 7, 2016 09:53
javascript: convert number to string with 'px' as sufix
function toPixels(pNum) {
'use strict';
return pNum + 'px';
}
@srdjan-m
srdjan-m / classutils.js
Last active January 31, 2017 22:20
javascript: add or remove class
function hasClass(el, className) {
'use strict';
if (el.classList) {
return el.classList.contains(className);
}
return !!el.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)'));
}
function addClass(el, className) {
'use strict';