Skip to content

Instantly share code, notes, and snippets.

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.
<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();
@jmealo
jmealo / gist:f84d69cfc7d0c0e8489a
Created May 12, 2015 13:16
snippet to fix watcher for PHPStorm EAP 141.1000
// Insert this just after: if (/move/i.test(verb)) { @ line 115
if (file.indexOf('___jb_bak___') !== -1) {
verb = 'PUT';
destination = destination.replace('___jb_bak___', '');
file = destination;
fileStream = fs.createReadStream(file);
headers['Content-Length'] = fs.statSync(file).size;
}
/* Add the following entries to your config.json global ignore:
@jmealo
jmealo / jsonpp
Created May 25, 2015 23:01
JSON prettifier for the terminal, just pipe to stdin and it'll output formatted JSON
#!/usr/bin/env node
var stdin = process.openStdin();
var data = "";
stdin.on('data', function(chunk) {
data += chunk;
});
[user]
name = Jeffrey Mealo
email = jeffreymealo@gmail.com
[credential]
helper = osxkeychain
[core]
autocrlf = input
excludesfile = /Users/jmealo/.gitignore_global
#!/bin/bash
cd /usr/share/postgresql/9.4/tsearch_data
wget https://stop-words.googlecode.com/files/stop-words-collection-2011.11.21.zip
unzip stop-words-collection-2011.11.21.zip
wget http://src.chromium.org/svn/trunk/deps/third_party/hunspell_dictionaries/en_US.dic
wget http://src.chromium.org/svn/trunk/deps/third_party/hunspell_dictionaries/en_US.dic_delta
wget http://src.chromium.org/svn/trunk/deps/third_party/hunspell_dictionaries/en_US.aff -O en_us.affix
# Remove first line
@jmealo
jmealo / output.json
Last active September 30, 2015 15:07
Illuminate API Documentation Scraper
{
"endPoints": {
"Sites": {
"description": "Returns a list of District and School sites.",
"method": "GET",
"urls": [
"https://<subdomain>.illuminateed.com/<root_dir>/rest_server.php/Api/Sites/"
],
"responseExample": [
{
@jmealo
jmealo / gist:3602657
Created September 2, 2012 18:27
Zipcode to State
var state_abbr = [ 'AA','AE','AK','AL','AP','AR','AZ','CA','CO','CT','DC','DE','FL','GA','GU','HI',
'IA','ID','IL','IN','KS','KY','LA','MA','MD','ME','MI','MN','MO','MS','MT','NC',
'ND','NE','NH','NJ','NM','NV','NY','OH','OK','OR','PA','PR','RI','SC','SD','TN',
'TX','UT','VA','VT','WA','WI','WV','WY' ];
var prefix_matrix = { 100:38, 101:38, 102:38, 103:38, 104:38, 105:38, 106:38, 107:38, 108:38,
109:38, 110:38, 111:38, 112:38, 113:38, 114:38, 115:38, 116:38, 117:38,
118:38, 119:38, 120:38, 121:38, 122:38, 123:38, 124:38, 125:38, 126:38,
127:38, 128:38, 129:38, 130:38, 131:38, 132:38, 133:38, 134:38, 135:38,
136:38, 137:38, 138:38, 139:38, 140:38, 141:38, 142:38, 143:38, 144:38,
CREATE OR REPLACE FUNCTION refresh_materialized_views() RETURNS VOID
AS
$body$
DECLARE
result integer;
BEGIN
EXECUTE (SELECT string_agg('REFRESH MATERIALIZED VIEW ' || oid::regclass::text, ';')
FROM pg_class
WHERE relkind = 'm');
RETURN;
@jmealo
jmealo / String to APA (English) Abbreviation
Created January 30, 2013 14:46
This function returns the capitalized abbreviation of the passed string according to APA rules for title case (http://blog.apastyle.org/apastyle/2012/03/title-case-and-sentence-case-capitalization-in-apa-style.html). It omits the following minor words: and, or, nor, but, a, an, the, as, at, by, for, in, of, on, per and to.
function strToAbbr(str) {
str = str.toUpperCase();
str = str.replace(/\b(AND|OR|NOR|BUT|A|AN|THE|AS|AT|BY|FOR|IN|OF|ON|PER|TO)\b/g, '');
var words = str.split(/\s+/), abbr = '';
for(var x = 0; x < words.length; x++) abbr += words[x].substr(0,1);
return abbr;
}