Skip to content

Instantly share code, notes, and snippets.

$site_list = get_blog_list();
foreach ($site_list as $site)
{
switch_to_blog($site_list['blog_id']);
wp_signon($credentials);
}
restore_current_blog();
@beezee
beezee / sample node analytics query
Created February 6, 2012 17:14
max-results returns empty result
var mainQuery = {
'ids': 'FILL_THIS_IN',
'start-date': '2012-01-19',
'end-date': '2012-02-05'
'dimensions': 'ga:pageTitle,ga:hostName,ga:pagePath,ga:date',
'metrics': 'ga:pageviews,ga:visits,ga:timeOnSite',
'sort': '-ga:pageviews',
'max-results': 100000
};
@beezee
beezee / nGramr
Created March 19, 2012 18:57
caclulate every possible combination of n words up to x from a string
var nGramr = {}
nGramr.words = prompt('Whats the phrase?').split(' ');
nGramr.wordlen = nGramr.words.length;
nGramr.depth = prompt('Whats the n?');
nGramr.results = 0;
nGramr.grams = function(aWords) {
var words = aWords;
var depth = words.length;
console.log(depth);
_.each(nGramr.words, function(word) {
<script type="text/javascript">
function Drawium_explain_box_displayed(index){
console.log(index);
$("#binno-custom-tabs li").unbind('click.drawium');
if (index == 1) {
$(".drawium_next_button").remove();
$("#binno-custom-tabs li:nth-child(2)").bind('click.drawium', function() {
Drawer.tutorial_next();
});
}
<script type="text/javascript">
var tourApp = {
tabSteps: {
3: 'images',
10: 'users',
},
needsTweaking: function(i) {
return typeof tourApp.tabSteps[i] != 'undefined';
var tourApp = {
tabSteps: {
8: 'images',
12: 'users'
},
needsTweaking: function(i) {
return typeof tourApp.tabSteps[i] != 'undefined';
},
var tourApp = {
tabSteps: {
8: 'images',
12: 'users'
},
needsTweaking: function(i) {
return typeof tourApp.tabSteps[i] != 'undefined';
},
@beezee
beezee / param_call.php
Created July 1, 2012 18:55 — forked from maxpert/param_call.php
PHP named parameter calling
<?php
$x = function($bar, $foo="9") {
echo $foo, $bar, "\n";
};
class MissingArgumentException extends Exception {
}
function call_user_func_named_array($method, $arr){
@beezee
beezee / php-cs-fixer-pre-commit.php
Created September 8, 2012 16:04 — forked from mardix/php-cs-fixer-pre-commit.php
A pre-commit hook to make PHP code PSR-2 compliant, check for syntax error
#!/usr/bin/php
<?php
/**
* .git/hooks/pre-commit
*
* This pre-commit hooks will check for PHP error (lint), and make sure the code
* is PSR compliant.
*
* Dependecy: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer)
*
@beezee
beezee / gist:3831274
Created October 4, 2012 03:20
Mass assignment + custom setter which modifies value type
Class Task extends ActiveRecord\Model
{
public static $table = 'tasks';
public function set_history($history)
{
$this->assign_attribute('history', serialize($history));
}