Skip to content

Instantly share code, notes, and snippets.

View jmealo's full-sized avatar

Jeff Mealo jmealo

View GitHub Profile
<html>
<head>
<title>Softphone</title>
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script>
$(function() {
var $dialpad = $('#dialpad');
$(document).on('click', '#dialpad,[title="Dialpad"]', function(e) {
e.stopPropagation();

Errors

All error messages should answer:

  • What went wrong.
  • What to do next.

Errors requiring escalation need:

  • Error logging that provides engineering, support and development pertinent information.
@jmealo
jmealo / spread.xml
Last active December 21, 2015 07:18
Spread SMF manifest for the pkgsrc distribution on SmartOS (based off: evercity's manifest)
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
<service name='network/spread' type='service' version='0'>
<create_default_instance enabled='true'/>
<single_instance/>
<dependency name='fs-local' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/system/filesystem/local'/>
</dependency>
<dependency name='network-service' grouping='require_all' restart_on='none' type='service'>
@jmealo
jmealo / wackamole.xml
Created August 19, 2013 14:20
Wackamole SMF manifest for the pkgsrc distribution on SmartOS (based on everycity's manifest)
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
<service name='network/wackamole' type='service' version='0'>
<dependency name='filesystem_minimal' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/system/filesystem/minimal'/>
</dependency>
<dependency name='loopback' grouping='require_any' restart_on='error' type='service'>
<service_fmri value='svc:/network/loopback'/>
</dependency>
@jmealo
jmealo / extract-progress.py
Last active December 21, 2015 06:28
Extracts .tar, .tar.gz, .tar.bz2 and .zip files with an optional progress bar. Raises ExtractException when it encounters an error.
import os, re, commands, subprocess
def streamCommand(cmd):
# runs a shell command and returns stdout as a stream you can loop over
stdout = subprocess.Popen(cmd, shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT).stdout
return stdout
def getFileExtension(filename):
@jmealo
jmealo / prep-env.sh
Last active December 21, 2015 01:59
Script to prepare environment in SmartOS Zone or Ubuntu VM before installing software
#!/bin/bash
# To run:
# source <(curl -s https://gist.github.com/jmealo/6231713/raw)
# note: running it this way renders the network configuration tests superfluous
if [[ "$(uname)" = "SunOS" ]] ; then
OS="SMARTOS"
elif [[ -f /etc/debian_version ]]; then
OS="DEBIAN"
crime_enum = {
'Aggravated Assault Firearm': 0,
'Aggravated Assault No Firearm': 1,
'Burglary Non-Residential': 2,
'Burglary Residential': 3,
'Homicide - Criminal ': 4,
'Homicide - Criminal': 4,
'Homicide - Gross Negligence': 5,
'Homicide - Justifiable ': 6,
'Motor Vehicle Theft': 7,
sw=# EXPLAIN ANALYZE SELECT ST_Distance(ST_Transform(ST_GeomFromText('POINT(-75.211457 39.956314)', 4326), 900913), planet_osm_line.way) AS planar_degrees, name FROM planet_osm_line ORDER BY planar_degrees ASC LIMIT 2;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------
Limit (cost=4719.15..4719.15 rows=2 width=600) (actual time=39.156..39.157 rows=2 loops=1)
-> Sort (cost=4719.15..4758.76 rows=15845 width=600) (actual time=39.154..39.154 rows=2 loops=1)
Sort Key: (st_distance('010100002031BF0D005777154645F05FC15B189DFEB2895241'::geometry, way))
Sort Method: top-N heapsort Memory: 25kB
-> Seq Scan on planet_osm_line (cost=0.00..4560.70 rows=15845 width=600) (actual time=0.028..33.340 rows=15845 loops=1)
Total runtime: 39.186 ms
(6 rows)
@jmealo
jmealo / philadelphia.poly
Created April 20, 2013 23:47
Poly file for the city of Philadelphia
city_limits_0
1
-7.501497E+01 4.013793E+01
-7.501456E+01 4.013768E+01
-7.501401E+01 4.013735E+01
-7.501387E+01 4.013726E+01
-7.501223E+01 4.013626E+01
-7.501146E+01 4.013578E+01
-7.501062E+01 4.013527E+01
-7.501043E+01 4.013515E+01
@jmealo
jmealo / gist:5417527
Created April 19, 2013 01:40
MongoError: Can't extract geo keys from object, malformed geometry?:
{
"type": "LineString",
"coordinates": [
[
-75.43241,
40.122597
],
[
-75.432447,
40.122651