Skip to content

Instantly share code, notes, and snippets.

@dotjosh
dotjosh / ayendetaxsolution.cs
Created Sep 23, 2011
Ayende blog tax solution
View ayendetaxsolution.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
namespace TaxAyende
{
internal class Program
{
View fillheight
(function ($) {
$.fn.fillheight = function () {
return this.each(function () {
$(this)
.height("100%")
.parent().wrapInner("<table style='height:100%;width:100%;margin:0;padding:0;border:0;'/>").end()
.siblings().wrapAll("<tr><td style='padding:0;'></td></tr>").end()
.wrap("<tr><td style='height:100%;padding:0;'></td></tr>");
});
};
@dotjosh
dotjosh / gist:7509488
Last active Dec 28, 2015
Arma2 UDP Query in NodeJS
View gist:7509488
var dgram = require( "dgram" ),
fs = require("fs"),
_ = require("lodash");
exports.query = query;
var packet = {
initialChallenge: "FE" + "FD" + "09",
base: "FE" + "FD" + "00",
View OpenWithSublimeText2.bat
@echo off
SET st3Path=C:\Stuff\Dropbox\Tools\Sublime Text 3\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@dotjosh
dotjosh / getJsWithRetries.js
Last active Aug 18, 2017
AJAX Javascript loader for poor connections
View getJsWithRetries.js
/*
[License]
MIT
[Purpose]
Also lets you verify the result content is valid or else it keeps retrying.
[Sample Usage]
getJsWithRetries("path/to/some.js", resp => resp.length === 100)
.then(() => {
@dotjosh
dotjosh / Promise Redux Thunk Middleware.js
Last active Feb 12, 2019
Promise Redux Thunk Middleware
View Promise Redux Thunk Middleware.js
//Your action before
export const query = dispatch => {
dispatch("MYTYPE_START");
myAPI.query()
.then(resp => dispatch("MYTYPE_SUCCESS", resp))
.catch(err => dispatch("MYTYPE_ERROR", err);
}
//Your action after
export const query = () => ({
@dotjosh
dotjosh / revdb.sql
Last active Nov 14, 2020
Revision Database
View revdb.sql
DROP TYPE IF EXISTS tmp_events_op CASCADE;
CREATE TYPE tmp_events_op AS ENUM ('create', 'update', 'delete');
DROP TABLE IF EXISTS tmp_events;
CREATE TEMPORARY TABLE tmp_events
(
id SERIAL PRIMARY KEY,
op tmp_events_op NOT NULL,
name text NOT NULL,
value text NOT NULL