Skip to content

Instantly share code, notes, and snippets.

@doug-wade
doug-wade / getAttributeDomain
Last active December 12, 2015 09:19
Gets the full domain of an attribute from a relation.
if exists
(
select *
from sys.objects
where object_id = OBJECT_ID(N'[dbo].[getAttributeDomain]')
)
begin
drop procedure dbo.getAttributeDomain
end
go
@doug-wade
doug-wade / dateSerial
Last active December 12, 2015 09:19
creates a date from integers representing day/month/year
if exists (
select *
from sys.objects
where object_id = OBJECT_ID(N'[dbo].[dateSerial]')
and type in (N'FN', N'IF', N'TF', N'FS', N'FT')
)
begin
drop function [dbo].[dateSerial]
end
go
@doug-wade
doug-wade / isNullOrWhiteSpace
Last active December 12, 2015 09:19
A function that trims whitespace from strings
if exists
(
select *
from sys.objects
where objects.object_id = OBJECT_ID(N'[dbo].[isNullOrWhiteSpace]')
)
begin
drop function dbo.isNullOrWhiteSpace
end
go
@doug-wade
doug-wade / robbie-the-robot.lsp
Created August 15, 2013 21:41
Robbie the robot!
;Set up the rooms
(setf rooms
'((living-room (north front-stairs)
(south dining-room)
(east kitchen))
(upstairs-bedroom (west library)
(south front-stairs))
(dining-room (north living-room)
@doug-wade
doug-wade / errata.lsp
Created August 15, 2013 21:42
errata
(setf nerd-states '(sleeping eating waiting-for-a-computer programming debugging))
(defun nerdus (state)
(if (equal (last nerd-states) (list state))
(first nerd-states)
(second (member state nerd-states))
)
)
(defun sleepless-nerd (state)
@doug-wade
doug-wade / getColumnSelectivity.sql
Last active December 21, 2015 14:58
Gets the selectivity of all columns in a table or view in a MS SQL database.
if exists
(
select *
from sys.objects
where object_id = OBJECT_ID(N'[dbo].[getColumnSelectivity]')
)
begin
drop procedure dbo.getColumnSelectivity
end
go
@doug-wade
doug-wade / reactive-conf-talk-proposal.md
Created August 13, 2016 19:35
reactive conf talk proposal

React is an amazing library for client-side user interface, and it has the added benefit of being able to be rendered on the server, which is crucial for SEO, SEM, and user experience. However, server-side rendering in practice is significantly more complicated than just calling ReactDOMServer.renderToString and piping out the result, especially if you want to make sure your site loads quickly in a mobile-first world. React Server smoothes out the common problems you run into with React server-side rendering, encodes performance best practices into the framework, and makes it easy to build high performance websites by default.

I'll discuss some of the design decisions we made during development, show our performance improvements, talk about lessons we've learned running React Server in production for a year and a half, and give some hints about the future of React Server, including adding streaming to React core.

export default class LocalDate {
constructor (day, month, year) {
this.year = year;
this.month = month;
this.day = day;
}
toCompatString() {
return `${this.year}-${this.month}-${this.day}T00:00`;
}
const backingObject = Symbol();
const prune = Symbol();
const FIVE_MINUTES = 1000 * 60 * 5;
function getTimestamp() {
return (new Date()).getTime();
}
// Example usage:
// const inst = new SimpleReporting();
@doug-wade
doug-wade / sanitizejson.js
Created April 5, 2022 21:58
Remove a set of block-listed keys from a json file
const fs = require('fs')
const path = require('path')
const inputDirectory = process.argv[process.argv.indexOf('-i') + 1]
const outputDirectory = process.argv[process.argv.indexOf('-o') + 1]
const BLOCK_LIST = new Set(['type', 'description', 'extensions'])
if (!fs.existsSync(outputDirectory)){
fs.mkdirSync(outputDirectory);