Skip to content

Instantly share code, notes, and snippets.

View xposedbones's full-sized avatar

Benoit Lavoie-Lamer xposedbones

View GitHub Profile
export default class Easing {
// Based on https://github.com/danro/jquery-easing/blob/master/jquery.easing.js
/**
* @param {number} t - Current Time
* @param {number} b - Start Value
* @param {number} c - Target Value
* @param {number} d - Duration
*/
static easeInQuad(t: number, b: number, c: number, d: number): number {
return c * (t /= d) * t + b;
<?php
function ob_html_compress($buf){
return preg_replace(array('/<!--(.*)-->/Uis',"/[[:blank:]]+/"),array('',' '),str_replace(array("\n","\r","\t"),'',$buf));
}
// Usage
ob_start('ob_html_compress');
get_header();
@xposedbones
xposedbones / map.js
Last active March 23, 2024 19:12
Javascript Map range of number to another range
Number.prototype.map = function (in_min, in_max, out_min, out_max) {
return (this - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
@xposedbones
xposedbones / admin_filters.php
Created December 12, 2013 21:27
filter by custom taxonomy and/or custom post type in the wordpress backend
<?php
add_action('restrict_manage_posts','create_lists');
function create_lists() {
global $typenow;
$filters_arr = array();
// In which page do you want the filters to display,
// $filters_arr = array("emploi");
if(in_array($typenow, $filters_arr)){
@xposedbones
xposedbones / setHeight.js
Last active December 22, 2015 16:38
Set every item (or their child) to the same height easily (needs jquery)
;(function($){
$.fn.setHeight = function(affectChildren){
if (typeof affectChildren === "undefined" || affectChildren===null) affectChildren = false;
var height = [];
this.each(function(){
if(affectChildren){
height = [];
$(this).children().each(function(){
height.push($(this).outerHeight());
@xposedbones
xposedbones / paginate.php
Created September 9, 2013 14:55
Wordpress Pagination
function hwl_home_pagesize( $query ) {
global $allposts,$latestpost;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if(CONDITION){
$query->query_vars['posts_per_page']=1;
$query->query_vars['paged'] = $paged;
return;
}