Skip to content

Instantly share code, notes, and snippets.

@littlefyr
littlefyr / IonCookieManager.java
Created November 13, 2014 17:43
Adding cookies to Ion
package com.medweb.cloud.manager;
import android.content.Context;
import com.koushikdutta.async.http.Headers;
import com.koushikdutta.ion.Ion;
import java.io.IOException;
import java.net.CookieManager;
import java.net.URI;
@littlefyr
littlefyr / SP.php
Created September 10, 2013 23:42
A couple sets of changes to get http://wordpress.org/plugins/saml-20-single-sign-on/developers/ working with OKTA. lib\classes\saml_client.php saml\modules\saml\lib\Auth\Source\SP.php Your mileage may vary
<?php
class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source {
/**
* The entity ID of this SP.
*
* @var string
*/
private $entityId;
<?php
class FrozenSso {
protected $plugin_slug = 'frzn-sso';
protected $auth_secret = 'super secret string :)';
protected static $instance = null;
protected $plugin_screen_hook_suffix = 'FrozenSso';
private function __construct() {
if ( NULL <> $this->auth_secret && !defined( 'FRZN_SSO_SECRET' ) )
@littlefyr
littlefyr / gist:4205471
Created December 4, 2012 15:59
What is the better approach?
var mapping = 'foo.bar';
var raw = eval('record.raw.' + mapping);
@littlefyr
littlefyr / Info.txt
Created June 13, 2012 17:19
Tracking down Mobgifts
It seems that mobgifts is taking over sites when you browse to them with an android phone. I've tracked down the problem to ads served up via the adnxs.com and trafficserv.info domains.
To determine this I did the following on my desktop:
* configured Chrome to use an andriod user agent
** Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus S Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
* opened the inspector and set the net panel to persist.
* requested a page known to have the problem
* exported the contents of the net tab to a HTTP Archive json
* wrote a script (below) to rerun the requests and dump out the contents
@littlefyr
littlefyr / gist:1829742
Created February 14, 2012 20:01
Better js declaration with single var
/*
In http://dropshado.ws/post/17210606192/varry-var-var Dave DeSandro declares that he is going to go to 1 var per variable. His reasons inclue:
* Easier to add more variables, no need to change any trailing comma or semi-colon.
* Eliminates unnecessary git commit diffs, where a line has changed only because you changed a trailing semi-colon or comma.
* Easier to read (IMO). var is a reserved keyword, so it jumps out when syntax highlighted.
* Eliminates awkward tab spacing underneath the var. It only lines up if your tabs are 4 spaces wide.
* [Per JFSIII] Helps collaboration, other devs might miss the change of semi-colon and accidentally add a global variable.
The following format resolves 3 of the 5 issues (but everyone knows that real JS is written using spaces not tabs.
$('body').delegate("*", "click", function(e){
console.log( 'here' , e.target);
});
$("*").click(function(e){
console.log( 'there', e.target );
});
$('body').delegate("click", "*", function(e){
console.log( 'HUH?!?!?' , e.target);
});
@littlefyr
littlefyr / open_encoded.rb
Created December 13, 2011 17:54
Load Files with the right encoding
#This should work for most cases, at least on OSX
def open_encoded file_name, &block
fcheck = `file --mime #{file_name}`
charset = fcheck.split(/charset=/).last.gsub(/\s+/, ' ').strip
if ["unknown-8bit", "iso-8859-1"].include?(charset)
encoding = Encoding::Windows_1250 #This is a guess. In the case of the files I'm working with, this is true. YMMV
else
begin
encoding = Encoding.find(charset)
@littlefyr
littlefyr / gist:1002723
Created June 1, 2011 16:46
Current FTP folder layout
/Site1_Dev
/Site1_Stage
/Site1_Web
/Site1_Assets
/Site1_Uninteresting_Folder
/Site1_Other_Uninteresting_Folder
/Site2_Dev
/Site2_Stage
/Site2_Web
@littlefyr
littlefyr / schema.js
Created March 15, 2011 04:04
Sample validation
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/my_database');
var Schema = mongoose.Schema
, ObjectId = Schema.ObjectId;
var BlogPost = new Schema({
author : ObjectId
, title : String