Skip to content

Instantly share code, notes, and snippets.

@RobinHerbots
RobinHerbots / uriSchemeWithHyperlinkFallback.js
Created December 6, 2018 15:43 — forked from ChaseFlorell/uriSchemeWithHyperlinkFallback.js
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.
// 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
// tries to execute the uri:scheme
function uriSchemeWithHyperlinkFallback(uri, href) {
if(!window.open(uri)){
window.location = href;
}
}
@RobinHerbots
RobinHerbots / 52-nvidia-coolbits.conf
Last active January 22, 2018 09:08
nvidia coolbits config for Ubuntu 17.10 (cp /usr/share/X11/xorg.conf.d/)
Section "Screen"
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24
Option "Coolbits" "12"
SubSection "Display"
Depth 24
EndSubSection
EndSection
@RobinHerbots
RobinHerbots / index.ejs
Created February 23, 2017 12:24 — forked from ksrb/index.ejs
jquery.inputmask webpack configuration and package.json
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<input id="float"/>
</body>
</html>
@RobinHerbots
RobinHerbots / index.ejs
Created February 23, 2017 12:24 — forked from ksrb/index.ejs
jquery.inputmask webpack configuration and package.json
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<input id="float"/>
</body>
</html>
@RobinHerbots
RobinHerbots / Multiple Download example
Created May 14, 2013 11:24
Multiple download file
this.downloadUpload = function (rowid) {
var rowids = rowid ? [rowid] : res.Control.uploadOverview.jqGrid('getGridParam', 'selarrrow');
$.each(rowids, function (ndx, rwd) {
var downloadFrame = $("<iframe></iframe>");
downloadFrame.attr("src", '@Url.Action("DownloadFile", "Upload")?uploadId=' + rwd);
downloadFrame.on("onload", function() {
$(this).remove();
});
$("body").append(downloadFrame);
});
@RobinHerbots
RobinHerbots / jquery.ajax.progress.js
Last active October 8, 2018 07:57 — forked from db/jquery.ajax.progress.js
XMLHttpRequest2 progress event on $.ajax
(function($) {
var originalXhr = $.ajaxSettings.xhr;
$.ajaxSetup({
progress: $.noop,
xhr: function() {
var req = originalXhr(), that = this;
if (req) {
if (typeof req.addEventListener == "function") {
req.addEventListener("progress", function(evt) {
that.progress(evt);
@RobinHerbots
RobinHerbots / Global.asax
Last active December 14, 2015 08:09
MVC DataAnnotations - Validate submodel in model with separate result in ModelState
public class MvcApplication : HttpApplication
{
protected void Application_Start()
{
ModelValidatorProviders.Providers.Add(new RecursiveModelValidatorProvider());
....
@RobinHerbots
RobinHerbots / Proxy.tt
Created April 26, 2012 12:42
Proxy generation template
/*
== DO NOT EDIT THIS GENERATED FILE ==
Generated on <#=DateTime.Now.ToShortDateString()#> at <#=DateTime.Now.ToShortTimeString()#>
*/
<#@ template hostspecific="True" #>
<#@ assembly name="System.ServiceModel.dll" #>
<#@ assembly name="System.Xml" #>
<#@ assembly name="EnvDTE" #>
<#@ assembly name="Microsoft.VisualStudio.OLE.Interop" #>
@RobinHerbots
RobinHerbots / hash.js
Created December 14, 2011 10:56
hashtable in javascript
/*
http://www.mojavelinux.com/articles/javascript_hashes.html
added keys array to more easily retrieve the data elements - RH
*/
function Hash() {