Skip to content

Instantly share code, notes, and snippets.

View koohz's full-sized avatar
🏠
Working from home

koohz

🏠
Working from home
View GitHub Profile
@koohz
koohz / get-vertex-of-rotated-rect.markdown
Last active May 23, 2017 15:28
Get Vertex of Rotated Rect
/*
Gulpfile.js file for the tutorial:
Using Gulp, SASS and Browser-Sync for your front end web development - DESIGNfromWITHIN
http://designfromwithin.com/blog/gulp-sass-browser-sync-front-end-dev
Steps:
1. Install gulp globally:
npm install --global gulp
@koohz
koohz / repeat_metabox.php
Created February 18, 2017 10:03 — forked from invmatt/repeat_metabox.php
WP Custom repeatable metabox
<?php
echo '<ul class="iv-slider">';
$sliders = get_post_meta( get_the_id(), 'gp', false );
foreach ( $sliders as $slider ) {
echo '<li class="iv-slide">';
echo '<h3>'.$slider["iv-slider-title"].'</h3>';
echo '<p>'.$slider["iv-slider-desc"].'</p>';
echo wp_get_attachment_image(array_shift($slider["iv-slider-img"]));
jQuery.fn.nextOrFirst = function(selector) {
var next = this.next(selector);
return next.length ? next : this.prevAll(selector).last();
};
jQuery.fn.prevOrLast = function(selector) {
var prev = this.prev(selector);
return prev.length ? prev : this.nextAll(selector).last();
};
@koohz
koohz / jquery.parallaxBg.js
Created December 23, 2016 13:39
Parallax Background Image
// The plugin code
(function($){
$.fn.parallax = function(options){
var $$ = $(this);
offset = $$.offset();
var defaults = {
"start": 0,
"stop": offset.top + $$.height(),
"coeff": 0.95
};
@koohz
koohz / navbar.css
Created December 5, 2016 20:38
Auto adjust navbar-brand depending on line-height with bootstrap
.navbar-header {
min-height: 100%;
position: absolute;
top: 0;
bottom: 0;
}
.navbar-brand>img {
max-width:100%;
max-height:100%;
@koohz
koohz / functions.php
Last active December 5, 2016 18:21
Reload Styles in Wordpress Customizer Preview
add_action('customize_controls_print_footer_scripts', function(){?>
<script type="text/javascript">
( function ( wp, $ ) {
console.log($("#save"))
var btn = $("<button style='margin-right: 5px' class='button button-primary'>Reload CSS</button>").click(function(e){
e.preventDefault(true);
wp.customize.previewer.preview.iframe.get(0).contentWindow.reloadStylesheets();
});
$("#save").after(btn);
@koohz
koohz / gist:0e5d94d0e8534d55edc2
Last active August 29, 2015 14:20
Get Season By Given Day and Month
/*
* 0 = winter
* 1 = spring
* 2 = summer
* 3 = autumn
*/
function get_season(day, month)
{
return parseInt(((month - (+(day < 21))) / 3) % 4);
}
@koohz
koohz / mb-custom-attrs.php
Created January 6, 2015 22:31
Trick: How to add custom html attributes to a wordpress metabox
<?php
add_filter( 'postbox_classes_post_metaboxid', function ($classes) {
// Notice the unmatched <">, this will close the class attribute
// Ex: <" customattribute="Hello World>
array_push($classes, '" custom_attribute="Hello World' );
return $classes;
});
?>