Skip to content

Instantly share code, notes, and snippets.

View slattery's full-sized avatar

Mike Slattery slattery

View GitHub Profile
@davisford
davisford / gist:5039064
Last active February 9, 2022 13:39
git clone into non-empty directory

Let's say you start a project locally, and do some editing.

$ mkdir -p ~/git/foo && cd ~/git/foo
$ touch NEWFILE

Now you decide you want to create a new github repo and track it, but the directory is non-empty so git won't let you clone into it. You can fix this, thusly:

@audreyt
audreyt / apply.sql
Last active October 6, 2016 13:14
plv8 SQL for the |> and <| operators (aka LiveScript application): SELECT '{"hello": [1,2,3]}' |> 'this.hello[0]'; SELECT 'this.hello[0]' <| '{"hello": [1,2,3]}';
CREATE OR REPLACE FUNCTION plv8x.json_eval(code text) RETURNS plv8x.json AS $$
return JSON.stringify(
eval("(function(){return #code})").apply(this)
);
$$ LANGUAGE plls IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION plv8x.json_eval(data plv8x.json, code text) RETURNS plv8x.json AS $$
return JSON.stringify(
eval("(function(){return #code})").apply(JSON.parse(data))
);
$$ LANGUAGE plls IMMUTABLE STRICT;
@simianhacker
simianhacker / json_path.sql
Last active May 13, 2019 17:40
Here is a set of functions for working with a PostgreSQL+JSON+PLV8 database.
-- Function: json_path(json, text)
-- DROP FUNCTION json_path(json, text);
CREATE OR REPLACE FUNCTION json_path(data json, path text)
RETURNS text AS
$BODY$
/* JSONPath 0.8.0 - XPath for JSON
*
* Copyright (c) 2007 Stefan Goessner (goessner.net)
@plentz
plentz / nginx.conf
Last active May 21, 2025 05:22
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@oevans
oevans / AGO_PullHostedFeatures.py
Last active April 16, 2024 18:37
Python script to pull hosted features with attachments into a local file geodatabase. See ReadMe below.
import os, urllib, urllib2, datetime, arcpy, json
## ============================================================================== ##
## function to update a field - basically converts longs to dates for date fields ##
## since json has dates as a long (milliseconds since unix epoch) and geodb wants ##
## a proper date, not a long.
## ============================================================================== ##
def updateValue(row,field_to_update,value):
outputfield=next((f for f in fields if f.name ==field_to_update),None) #find the output field
@kindy
kindy / app.js
Created November 26, 2013 06:17
angular.module('MyApp', [])
.controller('MyCtrl', ['$scope', '$debounce', function($scope, $debounce) {
$scope.val = 0;
$scope.inc = function() {
$debounce(increase, 300);
};
var increase = function() {
$scope.val++;
}
angular.module('ngDebounce', [])
.factory('$debounce', ['$rootScope', '$browser', '$q', '$exceptionHandler',
function($rootScope, $browser, $q, $exceptionHandler) {
var deferreds = {},
methods = {},
uuid = 0;
function debounce(fn, delay, invokeApply) {
var deferred = $q.defer(),
promise = deferred.promise,
@novalore
novalore / 1.gitlab_on_wheezy.md
Last active December 31, 2015 22:19
A guide to install GitLab >6.0 on Debian 7 "Wheezy"

GitLab is a self hosted Git management software based on Ruby on Rails.

It is free software and that is always a plus!

This tutorial is heavily based on the excellent post at rosehosting.com and collects information I found in documentation and on the internet generally.

Note: We'll work in a root console using Bash

If you don't have an editor of choice install vim (it's great!)

@CompMike
CompMike / gist:8883546
Created February 8, 2014 13:13
Gitignore
# Ignore docs files
_gh_pages
_site
.ruby-version
# Numerous always-ignore extensions
*.diff
*.err
*.orig
*.log
@acdha
acdha / leaflet-defer-scrolling.js
Created February 21, 2014 20:55
Prevent LeafletJS from halting a page scroll if the map passes under the pointer by disabling scroll/touch zooming until the user has clicked on the map
(function () {
ItemMap.scrollWheelZoom.disable();
ItemMap.touchZoom.disable();
var enableMapInteraction = function () {
map.scrollWheelZoom.enable();
map.touchZoom.enable();
}
$('#item-map').on('click touch', enableMapInteraction);