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 / taxes.php
Created June 6, 2013 08:19
PHP array of tax rates in decimal format by state. Source: http://en.wikipedia.org/wiki/Sales_taxes_in_the_United_States on June 6, 2013
<?php
$taxes = array(
'AL' => 0.04,
'AK' => 0.00,
'AZ' => 0.066,
'AR' => 0.06,
'CA' => 0.075,
'CO' => 0.029,
'CT' => 0.0635,
@brianherbert
brianherbert / gist:5537735
Last active December 17, 2015 02:39
wbench results for the new version of Crowdmap homepage
Testing https://crowdmap.com
At Wed May 8 11:13:16 2013
10 loops
Fastest Median Slowest Std Dev
---------------------------------------------------------------------------
Server performance:
Total application time Unable to be recorded
Host latency:
@brianherbert
brianherbert / cm_post.json
Created April 10, 2013 05:36
I'm curious how confusing this is. Posts can be associated with a specific map, as if the map owns the post. This post can also be posted to multiple maps. Currently, the owner of the post is listed under "maps" and the maps a post is posted to is under "posts_maps". The reason we don't return the ownership another way is because the post is *ac…
{
"posts": [
{
"externals": [],
"locations": [],
"maps": {
"map_id": 35,
"user_id": 5,
"media_id": 0,
"subdomain": "checkingificancreate",
@brianherbert
brianherbert / log_origins.php
Last active December 15, 2015 09:09
Write to a log file to get the HTTP origin of requests
if (isset($_SERVER['HTTP_ORIGIN'])){
$log_text = $_SERVER['HTTP_ORIGIN'];
}else{
$log_text = 'UNKNOWN';
}
$filename = "./debug/origins.log";
$fh = fopen($filename, "a") or die("Could not open log file.");
fwrite($fh, date("d-m-Y, H:i")." - ".$log_text."\n") or die("Could not write file!");
fclose($fh);
@brianherbert
brianherbert / lockedEmbed.html
Last active December 14, 2015 07:59
Lock an iframe within an iframe to
<style>
body { background-color:green;text-align:center;}
iframe { padding:0; margin:0; overflow: hidden; border: 0px;}
</style>
<script>
function iframeLoaded() {
var iframe = document.getElementById('testframe');
if(iframe) {
var body = iframe.contentDocument.body;
@brianherbert
brianherbert / example.js
Created August 17, 2012 02:11
prevent multiple calls for map markers
var lockCounter;
function ajaxCallFunc()
{
lockCounter++;
var check = lockCounter;
setTimeout(function(){
if (check == lockCounter)
{
// This request was the last one to increment the counter
@brianherbert
brianherbert / ol_map_center.js
Created July 21, 2012 04:57
Set map center on OpenLayers
map.setCenter(
new OpenLayers.LonLat(-71.147, 42.472).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
), 12
);
@brianherbert
brianherbert / reference.regex
Created July 18, 2012 00:47
Regular Expressions
Floating Point Number
Source: http://www.regular-expressions.info/floatingpoint.html
[-+]?([0-9]*\.)?[0-9]+
@brianherbert
brianherbert / duplicate_feed_fix.sql
Created July 10, 2012 07:52
Add a unique key to feed item in an Ushahidi deployment destroying duplicates
ALTER IGNORE TABLE `feed_item` ADD UNIQUE INDEX `name` (`item_link`);
@brianherbert
brianherbert / output.html
Created January 27, 2012 11:05
testing adsense plugin
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Local Ushahidi Deployment</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="http://ushahidi.osx/media/css/jquery-ui-themeroller.css" />
<link rel="stylesheet" type="text/css" href="http://ushahidi.osx/themes/default/css/style.css" />
<!--[if lte IE 7]><link rel="stylesheet" type="text/css" href="http://ushahidi.osx/media/css/iehacks.css" />
<![endif]--><!--[if IE 7]><link rel="stylesheet" type="text/css" href="http://ushahidi.osx/media/css/ie7hacks.css" />
<![endif]--><!--[if IE 6]><link rel="stylesheet" type="text/css" href="http://ushahidi.osx/media/css/ie6hacks.css" />