Skip to content

Instantly share code, notes, and snippets.

View freekrai's full-sized avatar

Roger Stringer freekrai

View GitHub Profile
@freekrai
freekrai / multisite_functions.php
Created July 19, 2011 14:20
Some handy wordpress multisite functions
<?php
$posts = multisite_latest_post( array(
"how_many"=>10,
"how_long_days"=>30,
"how_many_words"=>50,
"more_text"=>"[...]",
"remove_html"=>true,
"sort_by"=>"post_date",
// if paginating:
"paginate"=>true,
// Plugin
$.fn.iWouldLikeToAbsolutelyPositionThingsInsideOfFrickingTableCellsPlease = function() {
var $el;
return this.each(function() {
$el = $(this);
var newDiv = $("<div />", {
"class": "innerWrapper",
"css" : {
"height" : $el.height(),
"width" : "100%",
@freekrai
freekrai / gist:1112482
Created July 28, 2011 20:32 — forked from chriscoyier/gist:945619
commentgraph.php
<?php
/*
Template Name: Comment Graph
*/
?>
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
@freekrai
freekrai / gist:1149844
Created August 16, 2011 18:54
wordpress redirect on login based on roles
function fs_login($user, $pass) {
$uname = $user;
$pass1 = $pass;
$credentials = array(
'user_login' => $user,
'user_password' => $pass,
'remember' => true
);
$user = wp_signon($credentials, false);
if( $user->ID ){
/* ------------------------------------------------------------------------
* Class: prettyPhoto
* Use: Lightbox clone for jQuery
* Author: Stephane Caron (http://www.no-margin-for-errors.com)
* Version: 3.0.1
* ------------------------------------------------------------------------- */
(function($){$.prettyPhoto={version:'3.0'};$.fn.prettyPhoto=function(pp_settings){pp_settings=jQuery.extend({animation_speed:'fast',slideshow:false,autoplay_slideshow:false,opacity:0.80,show_title:true,allow_resize:true,default_width:500,default_height:344,counter_separator_label:'/',theme:'facebook',hideflash:false,wmode:'opaque',autoplay:true,modal:false,overlay_gallery:true,keyboard_shortcuts:true,changepicturecallback:function(){},callback:function(){},markup:'<div class="pp_pic_holder"> \
<div class="ppt">&nbsp;</div> \
<div class="pp_top"> \
@freekrai
freekrai / boyer-moore.php
Created February 24, 2012 19:31
Boyer-Moore string match algorithm
<?php
define('ALPHABET_SIZE',1);
function compute_prefix($str,$size,&$result=0)
{
$result = $result[$size + 1];
$q;
$k;
$result[0] = 0;
@freekrai
freekrai / Boyer-Moore-Horspool.php
Created February 24, 2012 19:32
Boyer-Moore-Horspool string matching algorithm
<?php
define('UCHAR_MAX',255);
function boyermoore_horspool_memmem($haystack,$needle){
$hlen = strlen($haystack);
$nlen = strlen($needle);
$scan = 0;
$bad_char_skip[UCHAR_MAX + 1];
if ($nlen <= 0 || !$haystack || !$needle) { return NULL; }
for ($scan = 0; $scan <= UCHAR_MAX; $scan = $scan + 1)
$bad_char_skip[$scan] = $nlen;
@freekrai
freekrai / backbone.behaviour.js
Created March 9, 2012 22:30 — forked from Qard/backbone.behaviour.js
Behaviour abstraction system for backbone.js
!function (Backbone) {
// Store blank stuff here
var blankEl = $()
, blankModel = new Backbone.Model.extend()
, blankCollection = new Backbone.Collection.extend({
model: blankModel
})
, blankView = new Backbone.View.extend({
el: blankEl
})
<?php
define('LOCK_FILE', isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '/tmp/secondcrack-updater.pid');
// Ensure that no other instances are running
if (file_exists(LOCK_FILE) &&
($pid = intval(trim(file_get_contents(LOCK_FILE)))) &&
posix_kill($pid, 0)
) {
fwrite(STDERR, "Already running [pid $pid]\n");
exit(1);
@freekrai
freekrai / Config.php
Created March 12, 2012 02:50
Second crack
<?php
// ----- Don't edit this -----------------
require_once(dirname(__FILE__) . '/engine/Updater.php');
// ---------------------------------------
// ----- You can edit these settings: -----
date_default_timezone_set('America/New_York'); // Sometimes I hate PHP. This is one of those times.