Skip to content

Instantly share code, notes, and snippets.

View brianherbert's full-sized avatar
🎯
Focusing

Brian Herbert brianherbert

🎯
Focusing
View GitHub Profile
@brianherbert
brianherbert / index.php
Created June 29, 2010 18:44
Simple Name Generator
<?php
require 'name_generator.php';
echo 'Random Name: '.name('boy');
?>
<?php
/**
* Messages view page.
*
* PHP version 5
* LICENSE: This source file is subject to LGPL license
* that is available through the world-wide-web at the following URI:
* http://www.gnu.org/copyleft/lesser.html
* @author Ushahidi Team <[email protected]>
* @package Ushahidi - http://source.ushahididev.com
<?php defined('SYSPATH') or die('No direct script access.');
/**
* Array of subdomains you would like to prevent MHI users from using.
*
*/
$config['blocked_subdomains'] = array(
// Team Member Names
@brianherbert
brianherbert / colormixer.php
Created December 8, 2010 20:05
This script takes two hex values and produces the average color.
<?php
$hex1 = 'FF0000';
$hex2 = '0000FF';
$hex3 = '';
$r1 = base_convert($hex1{0}.$hex1{1},16,10);
$g1 = base_convert($hex1{2}.$hex1{3},16,10);
$b1 = base_convert($hex1{4}.$hex1{5},16,10);
$r2 = base_convert($hex2{0}.$hex2{1},16,10);
@brianherbert
brianherbert / daysago.php
Created January 18, 2011 21:28
This is a function that returns a string stating the amount of time has passed from one timestamp to another.
<?php
function daysago($now,$then){
$daycount = floor(($now-$then)/86400); //86400 seconds in a day
$hourcount = floor(($now-$then)/3600); //3600 seconds in an hour
$minutecount = floor(($now-$then)/60); //60 seconds in a minute
if($daycount == 0) {
$str = 'Created ';
if($hourcount != 0) {
$str .= $hourcount.' ';
if($hourcount == 1) {
function geo_success(loc) {
$("#location_status").html('Location Found: '+loc.coords.latitude+','+loc.coords.longitude);
$("#lat").val(loc.coords.latitude);
$("#lon").val(loc.coords.longitude);
}
function geo_error() {
$("#location_status").html('Sorry, location search failed. Please try again.');
}
@brianherbert
brianherbert / .htaccess
Created February 15, 2011 19:59
Standard Ushahidi htaccess
# Turn on URL rewriting only when mod rewrite is turn on
<IfModule mod_rewrite.c>
RewriteEngine On
# Installation directory
RewriteBase /ushahidi
# Protect application and system files from being viewed
RewriteRule ^(application|modules|system) - [F,L]
$(document).ready(function(){
var ci_styles = new OpenLayers.StyleMap({
"default": new OpenLayers.Style({
pointRadius: "10", // sized according to type attribute
fillColor: "${fillcolor}",
strokeColor: "${strokecolor}",
strokeWidth: 2,
graphicZIndex: 1
},
@brianherbert
brianherbert / open311.php
Created July 29, 2011 07:08
This is an example skeleton hook file for the open311 plugin.
<?php defined('SYSPATH') or die('No direct script access.');
/**
* Open311 Hook - Load All Events
*
* PHP version 5
* LICENSE: This source file is subject to LGPL license
* that is available through the world-wide-web at the following URI:
* http://www.gnu.org/copyleft/lesser.html
* @author Ushahidi Team <[email protected]>
* @package Ushahidi - http://source.ushahididev.com
@brianherbert
brianherbert / update.sh
Created August 23, 2011 08:37
bash script to update localization
#! /bin/sh
cd /dir_to/Ushahidi-Localizations/
/usr/bin/git pull origin master
cd /dir_to/Ushahidi-Localizations.wiki/
/usr/bin/git pull origin master
/usr/bin/php /dir_to/Ushahidi-Localizations.updater/update.php