Skip to content

Instantly share code, notes, and snippets.

Avatar

Robin Herbots RobinHerbots

View GitHub Profile
@RobinHerbots
RobinHerbots / usp_CreateTypeFromTable.sql
Last active Aug 24, 2020
usp_CreateTypeFromTable.sql
View usp_CreateTypeFromTable.sql
CREATE PROCEDURE [dbo].[usp_CreateTypeFromTable] @TableName SYSNAME,
@TypeName SYSNAME
AS
BEGIN
DECLARE @sql NVARCHAR(MAX) = N'';
SELECT @sql = @sql + N',' + CHAR(13) + CHAR(10) + CHAR(9) +
QUOTENAME(c.name) + ' ' + s.name +
IIF(LOWER(s.name) LIKE '%char',
'(' +
View gist:940b0fce3248b4deb1de7a6e4290635b
$('#GetFile').on('click', function () {
$.ajax({
url: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/172905/test.pdf',
method: 'GET',
xhrFields: {
responseType: 'blob'
},
success: function (data) {
var a = document.createElement('a');
var url = window.URL.createObjectURL(data);
@RobinHerbots
RobinHerbots / gist:5eda12d1921c9c8bcd7737aec327ec9a
Created Jun 21, 2019 — forked from pmhsfelix/gist:4151369
Generating and validating JWT tokens using JWTSecurityTokenHandler
View gist:5eda12d1921c9c8bcd7737aec327ec9a
[Fact]
public void First()
{
var tokenHandler = new JWTSecurityTokenHandler();
var symmetricKey = GetRandomBytes(256/8);
var now = DateTime.UtcNow;
var tokenDescriptor = new SecurityTokenDescriptor
{
Subject = new ClaimsIdentity(new Claim[]
@RobinHerbots
RobinHerbots / uriSchemeWithHyperlinkFallback.js
Created Dec 6, 2018 — 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.
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
View uriSchemeWithHyperlinkFallback.js
// 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 Jan 22, 2018
nvidia coolbits config for Ubuntu 17.10 (cp /usr/share/X11/xorg.conf.d/)
View 52-nvidia-coolbits.conf
Section "Screen"
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24
Option "Coolbits" "12"
SubSection "Display"
Depth 24
EndSubSection
EndSection
@RobinHerbots
RobinHerbots / index.ejs
Created Feb 23, 2017 — forked from ksrb/index.ejs
jquery.inputmask webpack configuration and package.json
View index.ejs
<!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 Feb 23, 2017 — forked from ksrb/index.ejs
jquery.inputmask webpack configuration and package.json
View index.ejs
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<input id="float"/>
</body>
</html>
View Multiple Download example
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 Oct 8, 2018 — forked from db/jquery.ajax.progress.js
XMLHttpRequest2 progress event on $.ajax
View jquery.ajax.progress.js
(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);
You can’t perform that action at this time.