Skip to content

Instantly share code, notes, and snippets.

View klihelp's full-sized avatar
🎯
Focusing on life and money farm

klihelp

🎯
Focusing on life and money farm
View GitHub Profile
@brunoais
brunoais / loadingjQueryAsync(minified).html
Created February 1, 2013 12:06
This is a commented example code about adding jQuery in an async way. As long as you don't use jQuery stuff outside the fake ready() or in functions/methods that are called before the ready() method, all works without any modifications. Tested on IE 7+, FF 3.6+, Chrome 24, Opera 12.
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">(function(a,c,d){function b(b,c){"ready"==b?a.bindReadyQ.push(c):a.readyQ.push(b)}a.readyQ=[];a.bindReadyQ=[];var e={ready:b,bind:b};a.$=a.jQuery=function(a){if(a===c||a===d)return e;b(a)}})(window,document);function jQOk(){var a=jQuery,c=document;a.each(readyQ,function(c,b){a(b)});a.each(bindReadyQ,function(d,b){a(c).bind("ready",b)})} function jQErr(){var a=document.createElement("script");a.type="text/javascript";a.src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js";a.async=!1;a.defer=!1;a.onload=jQOk;document.getElementsByTagName("head")[0].appendChild(a)};</script>
<script async type="text/javascript"src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"onload="jQOk()"onerror="jQErr()"></script>
<!--[if lte IE 8]><script type="text/javascript">if("undefined"==typeof jQuery.fn){jQErr();var interval=setInterval(function(){jQOk();clearInterval(interval)},100);setTimeout(function(){clearInterval(interval)},12E3)};</sc
@dvessel
dvessel / r-em-sizing.scss
Last active October 30, 2018 09:59
font-size in rem and a tool for absolute to em conversion. http://css-tricks.com/snippets/css/less-mixin-for-rem-font-sizing/
// Inspired by this post from CSS-Tricks.
// http://css-tricks.com/snippets/css/less-mixin-for-rem-font-sizing/
//
// Plays nice with compass/typography/vertical_rhythm
// http://compass-style.org/reference/compass/typography/vertical_rhythm/
//
// Calculates font size in `rem` (root em).
//
// Relative values depends on $base-font-size. Pixle value for font-size depends
// on $legacy-support-for-ie6 or $legacy-support-for-ie7 or $legacy-support-for-ie8
@JoostKiens
JoostKiens / functions.php
Last active April 22, 2019 09:58
Improve the WordPress caption shortcode with HTML5 figure & figcaption, microdata & wai-aria attributes
<?php
/**
* Improves the WordPress caption shortcode with HTML5 figure & figcaption, microdata & wai-aria attributes
*
* Author: @joostkiens
* Licensed under the MIT license
*
* @param string $val Empty
* @param array $attr Shortcode attributes
* @param string $content Shortcode content
@isGabe
isGabe / get-highlight-terms.php
Last active February 12, 2022 16:22
WordPress: Output a list of taxonomy terms, then highlight the terms the belong to the current post. Updated to use in_array() to add a "current" CSS class to terms that the current post has. This way we don't have to worry about keeping up with terms in the CSS. Hooray for logic! #snippet #WordPress
<?php
/*
As the title implies, this will give you a way to
1. output a complete list of terms for a given taxonomy (nothing special there)
2. highlight the terms that the current post has (the magic!)
Probably need to figure out a better way to echo out the url of the term archive page...
*/
@zenman
zenman / snippet.php
Last active October 2, 2018 11:55
Archives by Category
<?php
/*
Plugin Name: Archives for a category
Plugin URI: http://kwebble.com/blog/2007_08_15/archives_for_a_category
Description: Adds a cat parameter to wp_get_archives() to limit the posts used to generate the archive links to one or more categories.
Author: Rob Schlüter
Author URI: http://kwebble.com/
Version: 1.4b
Copyright
@furf
furf / bookmarklet.url
Created October 4, 2012 18:24
Bookmarklet for displaying QR code of current URL (good for presentations)
javascript:void !function(e,t,n,r,i,s){while(n--&&(i=t[n])>e);s=r.style,s.position="fixed",s.zIndex=-1>>>1,s.top=s.left="50%",s.marginTop=s.marginLeft=i/-2+"px",r.src="http://chart.apis.google.com/chart?cht=qr&chld=H|0&chs="+i+"x"+i+"&chl="+escape(location)}(Math.min(top.innerHeight,top.innerWidth),[100,150,200,250,300,350,400,500],8,document.body.appendChild(new Image))
@juanmhidalgo
juanmhidalgo / visibly.js
Created September 27, 2012 10:21 — forked from addyosmani/visibly.js
Cross-browser Page Visibility API polyfill
/*!
* isVis - v0.5.6 Sep 2012 - Page Visibility API Polyfill
* Copyright (c) 2011 Addy Osmani
* Dual licensed under the MIT and GPL licenses.
*/
/*
* Firefox support added based on https://developer.mozilla.org/en-US/docs/DOM/Using_the_Page_Visibility_API
* @juanmhidalgo
*/
(function($) {
function parseImagesFromCSS(doc) {
var i, j,
rule,
image,
pattern = /url\((.*)\)/,
properties = ['background-image', '-webkit-border-image'],
images = {};
if (doc.styleSheets) {
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active April 20, 2025 21:15
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@gyrus
gyrus / shortcodes.php
Last active June 11, 2018 20:40
TinyMCE button for WordPress shortcode
<?php
/**
* Skeletal sample shortcode
*/
add_shortcode( 'pilau-sample', 'pilau_sample_shortcode' );
function pilau_sample_shortcode( $atts ) {
extract( shortcode_atts( array(
'text' => ''
), $atts ) );