Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View freekrai's full-sized avatar

Roger Stringer freekrai

View GitHub Profile
@freekrai
freekrai / gist:2855154
Created June 1, 2012 21:07
Ajaxify links
(function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('<iframe tabindex="-1" title="empty"/>').hide().one("load",function(){r||l(a());n()}).attr("src",r||"javascript:0").insertAfter("body")[0].contentWindow;h.onpropertychange=function(){try{if(event.propertyName==="title"){q.document.title=h.title}}catch(s
@freekrai
freekrai / mongoapi.class.php
Created November 16, 2012 22:28
Monoglab PHP class
<?php
class MongoAPI{
private $db;
private $col;
private $apiKey;
public function __construct($db,$col,$apiKey){
$this->db = $db;
$this->col = $col;
@freekrai
freekrai / DropboxSync.py
Created December 1, 2012 16:34 — forked from wrenoud/DropboxSync.py
DropboxSync
import os
import sys
import pickle
import console
import dropboxlogin # this code can be found here https://gist.github.com/4034526
STATE_FILE = '.dropbox_state'
class dropbox_state:
@freekrai
freekrai / Pinboard.py
Created December 3, 2012 18:52
Post to Pinboard
import console
console.show_activity()
import urllib
from urllib import urlencode
import bs4
import requests
import webbrowser
import sys
import sound
sound.load_effect('Powerup_2')
@freekrai
freekrai / Image Effects.py
Created December 6, 2012 16:23 — forked from silarsis/Image Effects.py
Pythonista Scripts
# Image Effects
# Demonstrates some effects using different modules
# from the Python Imaging Library (PIL).
#
# Tip: You can touch and hold an image in the output
# to copy it to the clipboard or save it to your
# camera roll.
import Image, ImageOps, ImageFilter
from Image import BILINEAR
@freekrai
freekrai / gist.php
Last active December 11, 2015 16:08
Embed Gists in wordpress via shortocde
// Place this code in your functions.php
// Then when you want to embed a gist, use [gist GISTID] and it will show up in your post
function embedGists( $atts ) {
$gist = $atts[0];
$string = '<script src="https://gist.github.com/'.$gist.'.js"></script>';
return $string;
}
add_shortcode( 'gist', 'embedGists' );
@freekrai
freekrai / gist:4997491
Last active March 8, 2016 04:43
Firefox only CSS
<style type='text/css'>
#categoryBackNextButtons{
width:490px;
}
@-moz-document url-prefix() {
#categoryBackNextButtons{
width:486px;
}
}
</style>
<style type='text/css'>
@-moz-document url-prefix() {
}
</style>
@freekrai
freekrai / migrate.php
Last active December 15, 2015 10:49
Secondcrack to Wordpress
<?php
/*
Move second crack files to wordpress:
1) Create a folder called "migrate", and upload this file to that folder.
2) Upload the PHPMarkdownExtra and PHP Smartypants libraries to this folder as well.
3) Move the posts folder from your second crack site into this folder.
4) In your browser, run: http://mysite/migrate/migrate.php and let it run.
This will move all posts in your posts folder into wordpress, it doesn't touch pages, only posts.
<!DOCTYPE html>
<html>
<body>
<h1>Todo List</h1>
<form id="todo_form" method="post" accept-charset="utf-8">
<p><input type="text" name="todo_field" value="" id="todo_field" /><input type="submit" value="Create Todo" /></p>
</form>
<p>You have <span id="todo_count">?</span> todos remaining.</p>
<div id="todo_list_wrapper"></div>