Skip to content

Instantly share code, notes, and snippets.

View mexitek's full-sized avatar

Arlo Carreon mexitek

View GitHub Profile
@mexitek
mexitek / khan_marklet.js
Created September 11, 2011 01:14
Khan Academy Bookmarklet that is meant to automatically answer your current question correctly. Simply copy and paste this code into a new bookmark.
javascript:
/* Build URI endpoint for Khan API */
var url="/api/v1/user/exercises/"+userExercise.exercise+"/problems/"+(userExercise.total_done+1)+"/attempt";
/* Slowly, but surely, collecting the data for a successfull API call */
var data={
complete:1,
count_hints:0,
time_taken:Math.floor(Math.random()*10),
attempt_number:userExercise.total_done+1,
@mexitek
mexitek / postgis_fill_points.sql
Created August 26, 2011 00:36
Postgre Function that fills in a table calls points with random Lat/Long for location field and a unique name
DECLARE
amount ALIAS FOR $1;
r_lat FLOAT;
r_lon FLOAT;
BEGIN
FOR v_Count IN 1..amount LOOP
r_lat := random()*360;
r_lon := random()*360;
INSERT INTO points (name_of_place,location) VALUES ( 'place_'||v_Count, makepoint( r_lat, r_lon) );
END LOOP;
@mexitek
mexitek / json_to_postgre.php
Created August 25, 2011 19:12
Script to automate an import process from .json file to postgre DB.
<?php
# Configure
$DB_USER = 'admin';
$DB_PASS = 'qwerty';
$DB_HOST = 'localhost';
$DB_NAME = 'postgis-2-0';
// Param 3 when ran in shell will override this value
$DB_TABLE = 'public.florida_establishments_garman';
// Param 2 when ran in shell will override this value
$CATEGORY = 'misc';
@mexitek
mexitek / init.rb
Created August 2, 2011 19:04
Moved: https://github.com/mexitek/redmine_wiki_html_util - Redmine Wiki Extension that allows placement of raw HTML, CSS or JS into your wiki. Useful for Web UI Demos.
#
# vendor/plugins/redmine_wiki_html_util/init.rb
#
require 'redmine'
require 'open-uri'
Redmine::Plugin.register :redmine_gist do
name 'Redmine Wiki HTML Util'
author 'Arlo Carreon'
author_url 'http://www.arlocarreon.com/'
@mexitek
mexitek / SubPub.lua
Created June 30, 2011 01:21
Lua SubPub Utility (or PubSub, whatevs)
--
-- subpub.lua
--
-- Created by Arlo Carreon on 2011-06-29.
-- MIT License: 2011 Corillo Apps.
--
-- SUBPUB.lua : A hub for application events. Class can publish an event,
-- all methods subscribed to said event will be executed.
--
-- Try out the test below!!
@mexitek
mexitek / JSON.js
Created May 18, 2011 19:12
Quick and Dirty JSON object for any small app
// JSON detection
var JSON = JSON || {};
// implement JSON.stringify serialization
JSON.stringify = JSON.stringify || function (obj) {
var t = typeof (obj);
if (t != "object" || obj === null) {
// simple data type
if (t == "string") obj = '"'+obj+'"';
return String(obj);
@mexitek
mexitek / Websnapr_Thumbnail_Hack.html
Created May 12, 2011 21:00
Made this hack to display the failed attempt at securing a JS service
<!-- // Include their JS service -->
<script src="http://www.websnapr.com/js/websnapr.js"></script>
<script>
// Use this function instead of wsr_snapshot()
function wsr_snapshot2(url,key,size,link){
link=typeof(link)!='undefined'?link:1;
if(size==''||size==undefined){size='s'};
var src="http://images.websnapr.com/?size="+(size.toLowerCase()=='t' || '' ?'t':'s')+
"&key="+encodeURIComponent(key)+
@mexitek
mexitek / SimpleGeo Feature Categories HTML
Created April 6, 2011 15:33
List of SimpleGeo Feature Categories as of 4/6/2011 used the JSON representation via https://gist.github.com/732639 @mager to generator this HTML
<style>
td {text-align:center}
</style>
<table>
<tbody>
<tr>
<th>Category ID</th>
<th>Sub Category</th>
<th>Category</th>
<th>Type</th>
@mexitek
mexitek / Recover_Hidden_Web_Passwords.js
Created March 30, 2011 19:29
Reveals any passwords that are masked behind bullets on any password field. Copy/Paste this code into a new BOOKMARK in your browser
javascript:
var s='',f = document.getElementsByTagName('input');
for(var i=0;i<f.length;i++){
if(f[i].type.toLowerCase()=='password' && f[i].value)
{s+='found: '+f[i].value+' \n';}
}
s=(s)?s+'\nThat\'s All Folks!':'No Passwords Found';
alert(s);
@mexitek
mexitek / Coldfusion and Facebook's signed_request Param
Created March 24, 2011 02:48
How to handle facebook's signed_request FORM Parameter in Coldfusion
<!--- Check for the param --->
<cfparam name="FORM.signed_request" default="">
<!--- Split the param by the . --->
<cfset raw_str = ListGetAt(FORM.signed_request, 2, ".")>
<!--- Add padding if string is too short. --->
<!--- CF Fix: Exception invalid base64 string --->
<cfset res = Len(raw_str) % 4>
<cfif res eq 2>