Skip to content

Instantly share code, notes, and snippets.

@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);
<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>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
body {
font-family: Segoe UI;
font-size: 11px;
}
@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
@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
{
#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 / index.html
Created October 8, 2015 17:48
rOwWMe
<label class="control-label">Form Action</label>
<input type="url" class="form-control" id="theURL" value="https://kevinsw.localtunnel.me/app_services/auth-silent-post.aspx"/>
<h2>Silent Post Form</h2>
<form action="" method="post" id="theForm">
<div class="col-md-6 form-group"><input type="text" name="x_response_code" value="1"/></div>
<div class="col-md-6 form-group"><input type="text" name="x_response_subcode" value="1"/></div>
<div class="col-md-6 form-group"><input type="text" name="x_response_reason_code" value="1"/></div>
<div class="col-md-6 form-group"><input type="text" name="x_response_reason_text" value="This transaction has been approved."/></div>
<div class="col-md-6 form-group"><input type="text" name="x_auth_code" value=""/></div>
<div class="col-md-6 form-group"><input type="text" name="x_avs_code" value="P"/></div>
@kavun
kavun / $.debounce(d) window.resize events
Last active December 15, 2015 19:38
testing window.resize event with $.debounce
<!doctype html>
<html>
<head>
</head>
<body>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="https://raw.github.com/cowboy/jquery-throttle-debounce/master/jquery.ba-throttle-debounce.min.js"></script>
<script>
function log(s) {
s = s || 'logged something';
@kavun
kavun / Credit Card Generator
Last active December 16, 2015 20:02 — forked from B-Con/Credit Card Generator
This JavaScript function generates random number strings that pass the Luhn checksum, the test that credit card numbers must conform to. It assumes there is an HTML radio input to indicate which company issued the card. This code is from my webpage here: http://bradconte.com/cc_generator.html.
javascript:
!(function () {
/*
Copyright (c) 2015, Brad Conte (http:bradconte.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright
@kavun
kavun / gist:6390166
Created August 30, 2013 14:01
VS2010 search filter
*.vb;*.resx;*.xsd;*.wsdl;*.xaml;*.xml;*.htm;*.html;*.css;*.aspx;*.asmx;*.js;*.ascx;*.cs;*.asa;*.asp;*.txt; *.master