Skip to content

Instantly share code, notes, and snippets.

View mikeflynn's full-sized avatar
🥪
A little hungry, but overall OK.

Mike Flynn mikeflynn

🥪
A little hungry, but overall OK.
View GitHub Profile
function toJSON(object) {
var json = new Array();
for(var index in object) {
type = typeof(object[index]);
if(type == 'object'){
json.push('"'+index+'":' + toJSON(object[index]));
} else if(type == 'string') {
json.push('"'+index+'":' + '"'+object[index].replace(/\"/g,'\\"')+'"');
} else if(type == 'boolean' || type == 'number') {
json.push('"'+index+'":' +object[index]);
@mikeflynn
mikeflynn / iframe_click_tracking.js
Created July 20, 2011 10:32
Tracking Clicks on iFrame Ads
// Limitations:
// 1. We won't know where they are headed.
// 2. If the ads open in a new window, it doesn't trigger the unload event.
// 3. If there are multiple ad units in the iframe, we won't know which one was clicked.
function iframe_click_tracking(selector) {
jQuery(selector).bind('mouseover', function() {
// If they are over the ad and click, the unload will trigger to log the click.
jQuery(window).unload(function(){ // Event: onbeforeunload
jQuery.ajax({url:'http://local.logger.com/logger/?log=mobile&message=realclick', async: false});
@mikeflynn
mikeflynn / gist:1131156
Created August 8, 2011 03:27
How to kill tynt's copy/paste bullsh*t
1. Open terminal and type "sudo vi /etc/hosts"
2. Add the following lines at the bottom of the file:
127.0.0.1 tcr.tynt.com
127.0.0.1 tynt.com
3. type: [esc], then ":wq" and close terminal
4. Go to http://tcr.tynt.com/ti.js in your browser of choice. Your browser won't find it and you can copy/paste without added crap!
@mikeflynn
mikeflynn / lmi_json_check.clj
Created March 19, 2012 22:41
1st clojure script to find the bad json strings in a file.
#_(defdeps ; defeps call for lein oneoff
[[org.clojure/clojure "1.3.0"]
[clj-json "0.5.0"]])
(ns jsoncheck
(:require [clj-json [core :as json]]
[clojure.java.io :as io]))
(defn processfile [file-name checkfn]
"Takes file path and function to parse each line."
@mikeflynn
mikeflynn / Sorting Code Challenge.php
Created March 20, 2012 05:40
given a list of words, i need every unique combination where the list is in alphabetical order.
<?php
function order_list($words, &$return = null)
{
if(!$return) $return = array();
sort($words);
$string = implode(', ', $words);
if(!empty($string) && !in_array($string, $return)) $return[] = $string;
;; Namespaces, Symbols, and Vars (Oh, My!) -- @craigandera
;; require = "load"
;; dots => slashes, dash => underscore in require to file
(require '[net.cgrand.enlive-html :as html]) ...you can alias by passing the list elements as sequence.
;; * Single quoting above sequence the reading of the sequence as evaluating happens.
(ns some.name)
@mikeflynn
mikeflynn / .gitconfig
Created July 3, 2012 16:03
My work ~/.gitconfig file
[color]
branch = auto
diff = auto
status = auto
interactive = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
@mikeflynn
mikeflynn / etchosts.sh
Created December 13, 2012 19:04
An /etc/hosts manager bash script (v1.1) -- Added import and export commands!
#!/bin/bash
HOSTSFILE="/etc/hosts"
BAKFILE="$HOSTSFILE.bak"
DOMAINREGEX="^[a-zA-Z0-9]{1}[a-zA-Z0-9\.\-]+$"
IPREGEX="^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"
URLREGEX="^https?:\/\/[a-zA-Z0-9]{1}[a-zA-Z0-9\/\.\-]+$"
backup()
{
(defn parse-xml [xml]
(try
(xml/parse (java.io.ByteArrayInputStream. (.getBytes (.trim xml))))
(catch Exception e {})))
@mikeflynn
mikeflynn / chromebook_pixel_setup.md
Last active December 17, 2015 11:38
My various Chromebook Pixel setup notes

Chromebook Pixel Configuration

What does this do? Good question. What you will end up with is essentially Chrome OS and Ubuntu (with KDE) running side by side.

1. Get in to developer mode

Hold down ESC + REFRESH + POWER, when it reboots hit CTRL + D, and ENTER to confirm.

(You will have to hit CTRL + D at ever boot when you see the scary dev mode OS screen.)