Skip to content

Instantly share code, notes, and snippets.

Robin Herbots RobinHerbots

  • Belgium
View GitHub Profile
@ChaseFlorell
ChaseFlorell / uriSchemeWithHyperlinkFallback.js
Last active Apr 23, 2019
Ever want to launch a mobile app from within the browser, but ensure that the browser still redirects the user to the link if the app isn't installed? This took some fiddling around, but when the "ah ha" moment hit, the solution is really quite simple.
View uriSchemeWithHyperlinkFallback.js
// tries to execute the uri:scheme
function uriSchemeWithHyperlinkFallback(uri, href) {
// set up a timer and start it
var start = new Date().getTime(),
end,
elapsed;
// attempt to redirect to the uri:scheme
// the lovely thing about javascript is that it's single threadded.
// if this WORKS, it'll stutter for a split second, causing the timer to be off
@pithyless
pithyless / gist:1547408
Created Jan 1, 2012
jQuery set Headers for $.ajax
View gist:1547408
// jQuery Headers support for $.ajax
$.ajax({
beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Accept","application/json");
}
type: "POST",
url: "/article",
processData: false,
@db
db / jquery.ajax.progress.js
Created May 11, 2011
add XHR2 progress events to jQuery.ajax
View jquery.ajax.progress.js
(function addXhrProgressEvent($) {
var originalXhr = $.ajaxSettings.xhr;
$.ajaxSetup({
progress: function() { console.log("standard progress callback"); },
xhr: function() {
var req = originalXhr(), that = this;
if (req) {
if (typeof req.addEventListener == "function") {
req.addEventListener("progress", function(evt) {
that.progress(evt);
@chicagoworks
chicagoworks / jQuery.stringify.js
Created Dec 24, 2010
jQuery.stringify() utility
View jQuery.stringify.js
/**
* converted stringify() to jQuery plugin.
* serializes a simple object to a JSON formatted string.
* Note: stringify() is different from jQuery.serialize() which URLEncodes form elements
* UPDATES:
* Added a fix to skip over Object.prototype members added by the prototype.js library
* USAGE:
* jQuery.ajax({
You can’t perform that action at this time.