Skip to content

Instantly share code, notes, and snippets.

#jenkins-name-icon {
display:none;
}
#jenkins-head-icon {
content:url("https://www.madebyspeak.com/SiteFiles/1973/Images/logo@2x.png");
height: 30px;
margin: 5px;
}
@kavun
kavun / GetDistinctDuplicates.cs
Created July 31, 2015 14:43
Use HashSet<T>.Add with a custom EqualityComparer<T> to efficiently find duplicates
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
@kavun
kavun / AsyncHandler.ashx
Created July 29, 2015 13:43
Async Generic Handler for ASP.NET with HttpTaskAsyncHandler
<%@ WebHandler Language="C#" Class="AsyncHandler" %>
using System;
using System.Web;
using System.Threading.Tasks;
public class AsyncHandler : HttpTaskAsyncHandler {
public override async Task ProcessRequestAsync (HttpContext context) {
context.Response.ContentType = "text/plain";
@kavun
kavun / 0_reuse_code.js
Last active August 29, 2015 14:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
body {
font-family: Segoe UI;
font-size: 11px;
}
<html>
<head>
<title>Mocha</title>
<link rel="stylesheet" href="mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="mocha.js"></script>
<script>mocha.setup('bdd');</script>
<script src="test.js"></script>
@kavun
kavun / CustomError.js
Created January 30, 2014 19:12
subclass Error
function CustomError(message) {
Error.call(this);
Error.captureStackTrace(this); // v8
this.name = 'CustomError';
this.message = message;
this.customProperty = true;
}
CustomError.prototype = Object.create(Error.prototype);
function t(s, d) {
for(var p in d) {
s = s.replace(new RegExp('{'+ p +'}','g'), d[p]);
}
return s.replace(/{[^}]*}/g, '');
}
@kavun
kavun / textWidth.js
Last active December 28, 2015 09:29
var textWidth = (function (el) {
document.body.appendChild(el);
el.style.position = 'absolute';
el.style.top = '-1000px';
return function (text) {
el.innerHTML = text;
return el.clientWidth;
};
})(document.createElement('div'));
// adapted from http://davidwalsh.name/detect-scrollbar-width
function getScrollBarWidth() {
var container = document.createElement('div');
container.style.width = '100px';
container.style.height = '100px';
container.style.overflow = 'scroll';
container.style.position = 'absolute';
container.style.top = '-9999px';
document.body.appendChild(container);
var width = container.offsetWidth - container.clientWidth;