Skip to content

Instantly share code, notes, and snippets.

View vindia's full-sized avatar

Vincent Oord vindia

View GitHub Profile
@vindia
vindia / app_controller.php
Created May 19, 2011 20:30
Override CakePHP redirect
<?php
# in app_controller.php
function redirect($url, $status = null, $exit = true) {
if(Configure::read('debug') > 0 && !is_array($url)) {
$this->layout = false;
echo sprintf('%1$s redirect to <a href="%2$s">%2$s</a>', $status, $url);
exit;
} else {
return parent::redirect($url, $status, $exit);
}
@vindia
vindia / launchrock_api.php
Created November 14, 2011 14:42
Simple Launchrock API class
<?php
/**
* Simple class for the Launchrock API, see http://support.launchrock.com/customer/portal/articles/74480-using-the-api for more information
*/
class LaunchRockApi {
var $apiKey = ''; # Your API key, get it from Launchrock.com
var $urlPrefix = ''; # Your referral url, minus the actual referral id, e.g. 'example.com/?refid='
var $lrDomain = ''; # The domain of your site as you registered it at Launchrock, e.g. 'example.com'
@vindia
vindia / sticky-footer.html
Created November 14, 2011 15:09
A very simple sticky footer
@vindia
vindia / defivy.js
Created November 28, 2011 13:13
Devify - Auto generate a development url from a live url
// Replaces regular TLDs like .co.uk, .nl, .com, .biz with .dev so you don't have to
javascript:location.href=location.href.replace(/((\.co)?\.[a-z]{2,3})\//,'.dev/')
@vindia
vindia / russian_transliteration.php
Created December 14, 2011 14:36
Russian (cyrillic) transliteration function
<?php
function transliterate($string) {
$roman = array("Sch","sch",'Yo','Zh','Kh','Ts','Ch','Sh','Yu','ya','yo','zh','kh','ts','ch','sh','yu','ya','A','B','V','G','D','E','Z','I','Y','K','L','M','N','O','P','R','S','T','U','F','','Y','','E','a','b','v','g','d','e','z','i','y','k','l','m','n','o','p','r','s','t','u','f','','y','','e');
$cyrillic = array("Щ","щ",'Ё','Ж','Х','Ц','Ч','Ш','Ю','я','ё','ж','х','ц','ч','ш','ю','я','А','Б','В','Г','Д','Е','З','И','Й','К','Л','М','Н','О','П','Р','С','Т','У','Ф','Ь','Ы','Ъ','Э','а','б','в','г','д','е','з','и','й','к','л','м','н','о','п','р','с','т','у','ф','ь','ы','ъ','э');
return str_replace($cyrillic, $roman, $string);
}
var_dump(transliterate('андрей шевченко')); # andrey shevchenko
?>
@vindia
vindia / venn.html
Created January 23, 2012 10:04
Venn Diagram in HTML and CSS
<!doctype html>
<title>A Venn Diagram in HTML and CSS</title>
<style>
div {
float: left;
width: 100px;
height: 100px;
border-radius: 50px;
color: #fff;
text-align: center;
@vindia
vindia / org.beanstalkd.bean.plist
Created January 23, 2012 13:03
Launch BeanstalkD with launchd
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.beanstalkd.bean</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/beanstalkd</string>
@vindia
vindia / org.mongodb.mongod.plist
Created January 23, 2012 13:20
Launch MongoDB with launchd
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.mongodb.mongod</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/mongod</string>
@vindia
vindia / org.apache.lucene.plist
Created January 23, 2012 13:20
Launch solr with launchd
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.apache.lucene</string>
<key>ProgramArguments</key>
<array>
<string>java</string>
@vindia
vindia / clickout.html
Created February 28, 2012 11:50
Uncached Redirect
<!DOCTYPE html>
<title>Anti spam test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('a').click(function(e){
e.preventDefault();
location.href = $(this).attr('rel') ;
});
});