Skip to content

Instantly share code, notes, and snippets.

@ismyrnow
ismyrnow / postgres-log-trigger.sql
Last active August 27, 2015 14:07
Copies a row on update into a log table for historical analysis or auditing.
-- Create an empty log table from an existing table
insert * into status_log from status;
truncate status_log;
-- Create function which inserts trigger-provided rows into a log table
CREATE OR REPLACE FUNCTION trg_status_log()
RETURNS trigger AS
@ismyrnow
ismyrnow / getModulesInDirectory.js
Created October 6, 2014 02:24
Node module to synchronously and recursively search a directory for node modules
/* jshint node:true */
var fs = require('fs');
var path = require('path');
var getModulesInDirectory;
/**
* Synchronously recurses a directory and it's subdirectories, returning
* an array of files found with the '.js' extension.
*
* @returns {Array} module file descriptors
@ismyrnow
ismyrnow / auto-load-routers.js
Created October 6, 2014 14:49
Node module to mount express routes in a directory
var fs = require('fs');
var path = require('path');
/**
* Mounts all of the routes defined in a directory, using the module paths
* to dictate the mount path. All '.js' files in the directory should be
* modules that export an Express.Router().
*/
module.exports = function (app, pathToRoutes) {
var modulePaths = getModulesInDirectory(pathToRoutes);
@ismyrnow
ismyrnow / vagrant-postgis.sh
Created March 23, 2015 13:57
Virtual PostGIS setup using Vagrant
mkdir ubuntu-postgis
cd ubuntu-postgis
vagrant init ondrejsika/ubuntu-postgis
vagrant up
vagrant ssh
sudo su
# Edit postgresql.conf to change listen address to '*':
sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/" "/etc/postgresql/9.1/main/postgresql.conf"
@ismyrnow
ismyrnow / MapManager.mxml.as
Last active August 29, 2015 14:17
ArcGIS Flex Viewer map initialization change to read query params
// leave the preceding code unchanged...
private function map_loadHandler(event:MapEvent):void
{
map.removeEventListener(MapEvent.LOAD, map_loadHandler);
// Get query string parameters for "z" and "ll", convert them to the necessary
// format, and attempt to set some map parameters to them.
var queryParams:Object = getQueryParams();
if (queryParams.z && queryParams.ll)
@ismyrnow
ismyrnow / _readme.md
Last active August 29, 2015 14:22
Personal ConEmu Settings

This is my personal settings file for ConEmu. It combines some of the interface niceties of cmder with the base ConEmu styles. Based on the default settings in build 150513.

@ismyrnow
ismyrnow / arcgis-feature-stream.js
Last active August 29, 2015 14:24
Stream Features from ArcGIS
var request = require('request');
var debug = require('debug')('arcgis-feature-stream');
var noms = require('noms').obj;
function arcgisFeatureStream(options) {
var baseUrl = options.baseUrl;
var idField = options.idField;
var start = options.start || 0;
var step = options.step || 1000;
@ismyrnow
ismyrnow / geojson-to-cartodb.js
Created July 13, 2015 15:42
Stream GeoJSON into CartoDB
/**
* Streams a geojson file to an existing cartodb dataset.
* This requires that the dataset is created in CartoDB
* initially using a subset (1st record) of geojson data.
*/
var fs = require('fs');
var through2 = require('through2');
var geojsonStream = require('geojson-stream');
var cartodbTools = require('cartodb-tools');
@ismyrnow
ismyrnow / FormatOptional.cs
Last active August 29, 2015 14:25
HtmlHelper for rendering nullable value with a suffix/prefix
public static IHtmlString FormatOptional<T>(this HtmlHelper htmlHelper, Nullable<T> obj, string format = "{0}") where T : struct
{
if (obj == null || !obj.HasValue)
{
return new HtmlString("");
}
return new HtmlString(String.Format(format, obj.Value));
}
@ismyrnow
ismyrnow / IValidatableEntity.cs
Last active August 29, 2015 14:25
Allow DbContext models to define their own validation
public interface IValidatableEntity
{
DbEntityValidationResult ValidateEntity(DbEntityEntry entityEntry, IDictionary<object, object> items, DMMSContext dbContext);
}