Skip to content

Instantly share code, notes, and snippets.

View okal's full-sized avatar

Okal okal

View GitHub Profile
@okal
okal / flickr-fullscreen.js
Created June 26, 2012 19:59
Revert Flickr Fullscreen link text to "
var lightbox_fullscreen = document.getElementById('lightbox-fullscreen');
document.addEventListener('fullscreenchange', function() {
lightbox_fullscreen.innerHTML = (document.fullscreen) ? 'Exit Fullscreen': 'Fullscreen';
}, false);
@okal
okal / pesapal.py
Created May 28, 2012 10:30
Pesapal Python Snippet
"""
MIT License
Copyright 2012 Okal Otieno
A (very rough) port of the Pesapal PHP IFrame integration code to Python.
PHP source at https://www.pesapal.com/Content/downloads/pesapal-iframe.php.txt
Uses Leah Culver's python-oauth library for Oauth 1.0 integration. https://github.com/leah/python-oauth
"""
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@okal
okal / RaphaelJSShapeDrawingApp.html
Created January 1, 2012 01:59 — forked from kaylarose/RaphaelJSShapeDrawingApp.html
A Simple Vector Shape Drawing App with RaphaelJS and jQuery
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script src="http://yandex.st/raphael/1.5.2/raphael.min.js"></script>
<script>
/**
* A Simple Vector Shape Drawing App with RaphaelJS and jQuery
* copyright 2010 Kayla Rose Martin - Licensed under the MIT license
* Inspired by http://stackoverflow.com/questions/3582344/draw-a-connection-line-in-raphaeljs
**/
@okal
okal / spark.php
Created November 16, 2011 09:51 — forked from kirkegaard/spark.php
holmans spark in php
#!/usr/bin/env php
<?php
$ticks = array('▁','▂','▃','▄','▅','▆','▇');
$args = explode(',', (($argv[1] == '--stdin') ? fgets(fopen('php://stdin', 'r'), 1024) : $argv[1]));
$range = (max($args) - min($args)) + 1;
array_map(function($val) use ($ticks, $args, $range) {
print $ticks[round((($val - min($args)) / $range) * (count($ticks) - 1))];
}, $args);
print "\n";
@okal
okal / use_counter.py
Created November 3, 2011 20:21
Using word_counter.py
from word_counter import word_counter
print word_counter("The quick brown fox jumped over the lazy dog.")
@okal
okal / word_counter.py
Created November 3, 2011 19:05
A Python wordcounter.
#Inspired by http://www.daniweb.com/software-development/python/code/216495
def word_counter(text):
return len(text.split(None))
@okal
okal / index.php
Created September 30, 2011 13:38
<?php
header("Location:https://erp.acimarketing.org");
@okal
okal / alias.sh
Created April 16, 2011 20:55
Installing Python2.5 on Ubuntu 10.04 Lucid Lynx
$ alias gaes='/path/to/sdk/dev_appserver.py'
@okal
okal / tropo.php
Created January 4, 2011 14:20
Using Tropo Scripting API from the server with PHP and Curl
<?php
$url = "http://api.tropo.com/1.0/sessions?action=create&token=YOUR_TOKEN_HERE";//You can pass more parameters just as shown in the Quickstart guide.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "username:password");
$xmlResponse = curl_exec($ch);
curl_close ($ch);
echo $xmlResponse; //So you can see the results from your browser when you access this script
?>