Skip to content

Instantly share code, notes, and snippets.

View runspired's full-sized avatar
💜
Pondering Paradigms

Chris Thoburn runspired

💜
Pondering Paradigms
View GitHub Profile
@runspired
runspired / garmin2nike
Last active October 9, 2015 14:57
Demonstration of how to port your Garmin Connect data to Nike+ using http://www.awsmithson.com/tcx2nikeplus/ If you have any questions, feel free to tweet me @runspired
/*
As of 5/13/2013 3:06PM Central Time this script is working. Tweet @runspired to report malfunctions.
*/
/*
Use the Javascript console in Google Chrome and the tcx2nikeplus converter located here: http://www.awsmithson.com/tcx2nikeplus/
This will take some time to run but will port all of your garmin data to nike+.
@runspired
runspired / gist:3565869
Created September 1, 2012 06:42
Make your timeline legible after a single user spams it
//just run this in the javascript console and you won't have to see that user's tweets until you leave or refresh the page!
function hideTweetsFromScreenName(s) {
var tweets = document.querySelectorAll('[data-screen-name='+s+']');
var length = tweets.length;
while(length--)
tweets[length].parentNode.hidden = true;
setTimeout((function(){ hideTweetsFromScreenName(s);}),100);
};
@runspired
runspired / timelineManager.js
Created September 7, 2012 03:27
Twitter Timeline Manager
/*
This javascript closure will create a timeline manager to let you filter
out users and keywords from your stream. In theory it stores the info
in a cookie for one day, but cookie setting appears to be not working currently.
The manager object has methods for showing a hidden username or keyword,
but currently no buttons to do so.
Keyword filtration is case sensitive and is done based on a single string
match on the tweet's content, it does not match usernames that might
@runspired
runspired / complexInterval.js
Last active December 15, 2015 16:19
setInterval() and setTimeout() don't fit all use cases. Additionally the last few releases of Firefox have sped up the interval to almost 50% the defined value e.g. `setTimeout('foo,5000);` will execute in 2500ms This provides a firefox shunt as well as allowing for the interval's delay to be adjusted, paused, and restarted
function complexInterval = function( fn , t ) {
var _delay = t? parseInt(t) : 0
, callback = fn
//stores the time of last callback execution for play/pause behavior and firefox shunt
, lastExecution = (new Date()).getTime()
//shunt for firefox, which executes setTimeout up to 50% early
, checkExecution = function(){ var time = (new Date()).getTime() - lastExecution; if (time >= _delay) return true; timeout = setTimeout( (function(){ once(); }), time ); }
@runspired
runspired / isIncludedFile.php
Last active December 15, 2015 18:09
3 Methods of determining whether a PHP script is executing as an included file.
<?php
/*
One of the more common PHP questions I've encountered is how to determine whether the currently executing
script were included by another script or called directly. Often this question is coupled with AJAX / API
security. While none of the three methods below should be used to consider an AJAX or API request valid,
they will absolutely tell you whether the script was included.
*/
//Method 1 : define a constant in the parent script, check for it in the possibly included script
@runspired
runspired / chrome.fixed-relative-scale.js
Last active December 20, 2015 00:19
Quick Javascript Fix for Google Chrome "scale elements with position relative/absolute within element with position fixed" bug.
/*
Google Chrome fauls to resize the bounding box of elements with relative/absollute position that are within
fixed position elements. (Discovered this problem when making this page: http://jthoburn.com/expressive.ly/splash )
This solution is for an 'em based' layout in which width needed to remain in ems in order to not break a scale-while-scroll
effect, but would work similarly for pixel and percent based layouts as well.
*/
(function(){
var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1
, forceRender = function(e){
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
/*
This code is to fix Microsoft TextRange object (IE8 and below), to give equivalent of
HTML5 Range object's startContainer,startOffset,endContainer and endOffset properties.
*/
/**
@runspired
runspired / ember-data-embedded-save.js
Last active January 1, 2016 08:09
A method of saving / updating embedded records for ember.js and ember-data. This is probably NOT the best method, it's simply the best method I've come up with currently "as an adapter". It relies on calls to several store methods that should be private, and essentially turns a single save request into a save queue. This code could be altered to…
var DSA = {};
DSA.RESTAdapter = DS.RESTAdapter.extend({
/*
@private
Saves a newly created record, traverses and saves dirty related records
Currently Only belongsTo relationships are traversed
*/
saveRecord : function(_store,type,record,initiator) {
@runspired
runspired / isNumericId.js
Last active January 1, 2016 13:49
Fighting Ember-Data to get a related record from the store.
/*
When traversing record.eachRelationship in Ember-Data you
may want to actually look up and include the record if it
is already in the store.
Unfortunately, when dealing with records that are being saved
get(record,attribute) may or may not return the record even if
it is in the store.
If the ID were a temporary ember one (i.e. `<ember-234:null>`)
import re
from django.utils.text import compress_string
from django.utils.cache import patch_vary_headers
from django import http
try:
import settings
XS_SHARING_ALLOWED_ORIGINS = settings.XS_SHARING_ALLOWED_ORIGINS