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 / 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 / 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 / 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 / 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 / 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 / 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:6086052
Last active December 20, 2015 06:29
Format for CSV files importing into Crowdmap
Format:
(posting user) (map id if owned by map) (post message) (lat) (lon) (alt) (location name) (date posted) (duh) (a map to attach this post to)
user_id, owner_map_id, message, lat, lon, altitude, location_name, date_posted, public, posts_maps_map_id
|
|
Note: must include altitude although it isn't
actually being inserted. You can use "0" as
a default value
@brianherbert
brianherbert / .htaccess
Created September 9, 2013 13:44
Example Ushahidi .htaccess file
# Turn on URL rewriting only when mod rewrite is turn on
<IfModule mod_rewrite.c>
RewriteEngine On
# Installation directory
RewriteBase /
# Protect application and system files from being viewed
RewriteRule ^(application|modules|system|tests|sql) - [F,L]
@brianherbert
brianherbert / filter-table.js
Created September 10, 2013 01:03
Filters a table based on data attributes
// This script is for supporting forms with searchable filters to show/hide rows of the table
$(document).ready(function() {
root.filters = [];
$('.filter-table-filters').find('td').each(function(i) {
var tdKey = 'td'+i;
$(this).data('filters',tdKey);
@brianherbert
brianherbert / twit.js
Last active January 1, 2016 02:29
Parse through Twit reposes in Meteor
var fut = new Future();
var screen_name = Meteor.user().profile.twitterHandle;
Twit.get('statuses/user_timeline', { screen_name: screen_name, include_rts: false, count: 200 }, function(err, tweets) {
var i;
for (i = 0; i < tweets.length; ++i) {
if(tweets[i].geo != null) {
var geo = {lat: tweets[i].geo.coordinates[0], lon: tweets[i].geo.coordinates[1]};
fut['return'](geo);
return;