Skip to content

Instantly share code, notes, and snippets.

@ewlarson
ewlarson / centroids.rb
Last active August 31, 2017 05:49
Calculate centroid for Solr RPT field value
# Install Dependences
require 'rsolr'
# Connect to solr
solr = RSolr.connect :url => 'http://localhost:8983/solr/geoportal'
# Search request
response = solr.get 'select', :params => {:q => '*:*', :rows => '10000'}
@obfusk
obfusk / break.py
Last active May 1, 2024 20:32
python "breakpoint" (more or less equivalent to ruby's binding.pry); for a proper debugger, use https://docs.python.org/3/library/pdb.html
import code; code.interact(local=dict(globals(), **locals()))
@sheikhwaqas
sheikhwaqas / setup-mysql.sh
Last active September 6, 2023 15:59
Install MySQL Server on Ubuntu (Non-Interactive Installation)
# Download and Install the Latest Updates for the OS
apt-get update && apt-get upgrade -y
# Set the Server Timezone to CST
echo "America/Chicago" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
# Enable Ubuntu Firewall and allow SSH & MySQL Ports
ufw enable
ufw allow 22
@onderaltintas
onderaltintas / degrees2meters.js
Last active April 12, 2022 01:38 — forked from springmeyer/degress2meters.js
javascript coordinate conversions between 900913(3857) - 4326(lat lon)
var degrees2meters = function(lon,lat) {
var x = lon * 20037508.34 / 180;
var y = Math.log(Math.tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180);
y = y * 20037508.34 / 180;
return [x, y]
}
//test
lon= -77.035974
lat = 38.898717
@vigneshwaranr
vigneshwaranr / migrator.sh
Created August 24, 2012 18:34
Script to convert SQLITE dumps into PostgreSQL compatible dumps
#! /bin/sh
usage_error () {
echo 'Usage: sh migrator.sh <path to sqlite_to_postgres.py> <path to sqlite db file> <an empty dir to output dump files>'
echo
echo 'Example:'
echo '>sh migrator.sh sqlite_to_postgres.py ~/reviewboard.db /tmp/dumps'
echo
echo 'Tested on:'
echo 'Python 2.7.3'
@sim51
sim51 / nginx play
Created March 4, 2012 17:44
My nginx configuration for opendata-map.org
server {
listen 80;
server_name www.opendata-map.org;
root /var/www/opendata-map.org;
access_log /var/log/nginx/opendata-map.access.log;
error_log /var/log/nginx/opendata-map.error.log debug;
# GEOSERVER PROXY & CACHE
location /geoserver {
proxy_pass http://127.0.0.1:8080/geoserver;
@coldnebo
coldnebo / Default (Linux).sublime-keymap
Created August 10, 2011 23:20
simple scripts to prettify your xml and json in sublime text 2
[
{ "keys": ["ctrl+shift+x"], "command": "tidy_xml" },
{ "keys": ["ctrl+shift+j"], "command": "prettify_json" }
]
@kurtraschke
kurtraschke / parsecallno.py
Created September 1, 2010 03:04
Regular expression and script for parsing and sorting Library of Congress Classification call numbers
import re
myfile = open('list', 'r')
callnos = myfile.readlines()
p = re.compile("""^(?P<aclass>[A-Z]{1,3})
(?P<nclass>\\d{1,4})(\\ ?)
(\\.(?P<dclass>\\d{1,3}))?
(?P<date>\\ [A-Za-z0-9]{1,4}\\ )?
/* For Node.js - resolve a chain of HTTP redirects
Uses getResponse() from http://gist.github.com/399276
Example: resolveHttpRedirects('http://ow.ly/1Kn4j', function(url) { sys.puts(url) });
*/
function resolveHttpRedirects(url, callback, maxnum) {
maxnum = maxnum || 3;
var count = 0;
function next(url) {
getResponse(url, function(response) {