Skip to content

Instantly share code, notes, and snippets.

View scribu's full-sized avatar

Cristi Burcă scribu

View GitHub Profile
if(!jQuery('<input PLACEHOLDER="1" />')[0].placeholder){ //Uppercase attr for IE
jQuery(':input[placeholder]').each(function(){
var $this = $(this);
if(!$this.val()){
$this.val($this.attr('placeholder'));
$this.addClass('input-placeholder');
}
}).live('focus', function(e){
var $this = $(this);
if($this.hasClass('input-placeholder')){
@scribu
scribu / lesswatch.js
Created September 5, 2011 20:12 — forked from idris/lesswatch.js
lesswatch command that can be run to watch a directory and compile .less files to .css files when they are modified.
#!/usr/bin/env node
var fs = require('fs');
var exec = require('child_process').exec;
/*
* lesswatch usage:
*
* `lesswatch` to watch the current directory
@scribu
scribu / generate_update.sh
Created November 20, 2011 17:06 — forked from xentek/generate_update.sh
Generate the necessary sql statements to move a WordPress site from one environment to another
#!/usr/bin/env bash
echo "@@@ @@@ @@@@@@@@ @@@ @@@ @@@@@@@ @@@@@@@@ @@@ @@@ "
echo "@@@ @@@ @@@@@@@@ @@@@ @@@ @@@@@@@ @@@@@@@@ @@@ @@@ "
echo "@@! !@@ @@! @@!@!@@@ @@! @@! @@! !@@ "
echo "!@! @!! !@! !@!!@!@! !@! !@! !@! @!! "
echo " !@@!@! @!!!:! @!@ !!@! @!! @!!!:! @!@@!@! "
echo " @!!! !!!!!: !@! !!! !!! !!!!!: !!@!!! "
echo " !: :!! !!: !!: !!! !!: !!: !!: :!! "
echo ":!: !:! :!: :!: !:! :!: :!: :!: !:! "
@scribu
scribu / sad-php-attempt
Created February 23, 2012 22:04 — forked from anonymous/sad-php-attempt
poor attempt at php
// Find related posts
$related = p2p_type( 'brand_to_product' )->get_related( get_queried_object_id() );
// Display related posts
if ( $related->have_posts() ) :
?>
<?php while ( $related->have_posts() ) : $related->the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br />
<?php endwhile; ?>
@scribu
scribu / latency.txt
Created May 31, 2012 09:07 — forked from jboner/latency.txt
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns
Mutex lock/unlock 25 ns
Main memory reference 100 ns
Compress 1K bytes with Zippy 3,000 ns
Send 2K bytes over 1 Gbps network 20,000 ns
Disk seek (SSD) 100,000 ns
Read 1 MB sequentially from memory 250,000 ns
Round trip within same datacenter 500,000 ns
@scribu
scribu / gist:3906950
Created October 17, 2012 17:40 — forked from tierra/gist:3061041
Script to sync wxWidgets SVN to GitHub
#!/bin/bash
# Intial git svn clone:
# git svn clone --prefix=svn/ -A ~/.svn2git/authors -s https://svn.wxwidgets.org/svn/wx/wxWidgets wxWidgets
cd ~/svn-git-mirrors/wxWidgets;
if [ -f .sync-running-wxWidgets ]; then exit 1; fi;
touch .sync-running-wxWidgets
@scribu
scribu / .gitconfig
Created October 17, 2012 19:33 — forked from stas/.gitconfig
WordPress Git SVN config example
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
autocrlf = false
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:Courseware/buddypress-courseware.git
[branch "master"]
# Install Xcode, Command Line Tools, Xquartz (on 10.8)
# In a terminal (probably best to do one thing at a time):
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
brew install php54 --with-mysql
chmod -R ug+w /usr/local/Cellar/php54/5.4.7/lib/php
pear config-set php_ini /usr/local/etc/php/5.4/php.ini
@scribu
scribu / generate-key-mac.sh
Last active September 7, 2016 14:43 — forked from floydpink/travis-secure-key-mac.sh
Generating secure environment variables for GitHub deployment keys to be used from a Travis-CI build.
#!/usr/bin/env bash
# On OS X, use this script to generate an encrypted deployment key for Travis CI.
# Dependencies:
# gem install travis
# brew install coreutils
if [ $# -lt 1 ]; then
echo "usage: $0 <user>/<repo>"
<?php
/**
* Iterates over results of a query, split into many queries via LIMIT and OFFSET
*/
class QueryIterator implements Iterator {
var $limit = 500;
var $query = '';
var $global_index = 0;