Skip to content

Instantly share code, notes, and snippets.

View kinday's full-sized avatar

Leonard Kinday kinday

View GitHub Profile
@addyosmani
addyosmani / backboneglobalpubsub.md
Created February 4, 2012 19:37
Backbone.js global pub/sub

Generally one implements notifications by listening for events on specific models but if one wishes to have a single global message interchange, it could be done as follows:

var pubsub = new Backbone.Model;

View1 = Backbone.View.extend({
  initialize: function(){
    pubsub.bind('custom event', callback);
  }
 // ...
@fideloper
fideloper / usevm.md
Created June 6, 2012 02:24
You should develop in a Virtual Machine

#You should do all your LAMP development in a Virtual Machine

##Here's Why:

Many of us develop on Macintoshes. There are many reasons for this, but one of them is that it's based on a Unix platform of some sort. This allows us to run common server software such as Apache, Ruby, Python and Nodejs on our Macs.

Our computers become powerful develoment machines similar to the servers our apps will eventually live on.

Sometime we start our computer only to find Apache won't start, or MySQL can't create a PID file, or we've updated to Mountain Lion and Apache needs to be reconfigured. Death!

@Abban
Abban / WordPress Theme Customizer Sample.php
Created June 21, 2012 21:09
WordPress Theme Customizer Sample
<?php
function themename_customize_register($wp_customize){
$wp_customize->add_section('themename_color_scheme', array(
'title' => __('Color Scheme', 'themename'),
'priority' => 120,
));
// =============================
@artpolikarpov
artpolikarpov / doubleHover.js
Created August 22, 2012 19:51
Cинхронное подсвечивание одинаковых ссылок: http://artgorbunov.ru/bb/soviet/20120823/
/*
Функция для одновременной подсветки ссылок с одинаковым href,
на вход принимает:
1) selector — джеквери-селектор ссылок, чтобы
была возможность включить дублирующую подсветку в определённом фрагменте;
2) hoverClass — какой класс добавить по ховеру и псевдо-ховеру.
Инициализация для всего документа:
doubleHover('a', 'hover');
@artpolikarpov
artpolikarpov / shuffle-children.js
Created July 20, 2013 10:19
$.fn.shuffleChildren
(function ($) {
$.fn.shuffleChildren = function () {
return this.each(function () {
var $children = $(this).children(),
l = $children.length;
// Fisher–Yates Shuffle
// http://bost.ocks.org/mike/shuffle/
// While there remain elements to shuffle
@WebEndevSnippets
WebEndevSnippets / functions.php
Created October 27, 2013 15:37
WordPress: Reduce Database Queries
Reduce database queries (http://www.catswhocode.com/blog/speeding-up-your-wordpress-blog-7-effective-solutions)
It is important to reduce unecessary queries to your database as each query take a few milliseconds to execute. First, you might want to know how many queries your blog execute in order to display a page. To do so, paste the code below in your functions.php file. Once done, just have a look to your site footer to know how many queries has been executed and how many time it took to completely load the page.
add_action( 'wp_footer', 'tcb_note_server_side_page_speed' );
function tcb_note_server_side_page_speed() {
date_default_timezone_set( get_option( 'timezone_string' ) );
$content = '[ ' . date( 'Y-m-d H:i:s T' ) . ' ] ';
$content .= 'Page created in ';
$content .= timer_stop( $display = 0, $precision = 2 );
$content .= ' seconds from ';
@mistakster
mistakster / cool-widget.css
Last active August 29, 2015 14:03
Example of the BEM-style mixins
.cool-widget {
position: relative;
}
.cool-widget__title {
font: bold 20px/1 sans-serif;
}
.cool-widget__body {
font: normal 14px/1.4 sans-serif;
color: white;
}
@sebmarkbage
sebmarkbage / ElementFactoriesAndJSX.md
Last active May 17, 2022 11:06
New React Element Factories and JSX

New React Element Factories and JSX

In React 0.12, we're making a core change to how React.createClass(...) and JSX works.

If you're using JSX in the typical way for all (and only) React components, then this transition will be seamless. Otherwise there are some minor breaking changes described below.

The Problem

@addyosmani
addyosmani / README.md
Last active April 2, 2024 20:18 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version