Skip to content

Instantly share code, notes, and snippets.

View compwright's full-sized avatar

Jonathon Hill compwright

View GitHub Profile
@compwright
compwright / AddressHelper.php
Created August 27, 2012 21:01 — forked from jonathonbyrdziak/AddressHelper.php
Parse Address :: This function is designed to parse a complete street address using PHP. If it can't figure out the parsing itself, then it sends the address to google to have google parse the street address.
<?php
/**
* @author Jonathon Byrd
* @package Address Parsing
*
*
*/
class AddressHelper extends ObjectBase
{
/**
@compwright
compwright / popup.php
Created November 16, 2012 23:25
Window popup hack to establish a session inside of a Facebook app iframe in Safari
<script type="text/javascript">
// Configure these settings in your config/application.php file:
// $config['fb_page_url'] = 'https://www.facebook.com/yourfacebookpage';
// $config['fb_app_id'] = '12345667890825978';
var top_frame_url = '<?php echo config_item('fb_page_url'); ?>/app_<?php echo config_item('fb_app_id'); ?>';
<?php if (isset($_COOKIE['PHPSESSID'])): ?>
// @HACK: pop-up a window if the page is clicked (anywhere) which will access the
// host domain so we can set cookies in Safari
@compwright
compwright / named_arguments.php
Created September 2, 2013 18:41
Illustrating how to optionally support named argument arrays in PHP methods
<?php
function getFriends(
$user_id = null,
$screen_name = null,
$cursor = -1,
$skip_status = false,
$include_user_entities = false
) {
// Support optionally named parameters via an array
Macbooks-MacBook-Pro:toyoursuccess jhill$ ./updatedb.sh
Updating Database to Latest Revision
---------------
Exporting Database
---------------
** Message: Connected to a MySQL server
** Message: TokuDB detected, creating dummy table for CS
** Message: Started dump at: 2016-04-15 11:24:37
@compwright
compwright / flatten.js
Created August 23, 2016 15:01
Flattens an array of arbitrarily nested arrays of integers into a flat array of integers
'use strict';
Array.prototype.flatten = function() {
var flattened = [];
this.map(function(element) {
if (Array.isArray(element)) {
// If the array element is an array,
// flatten it, then push each element
// onto the master flattened array.
@compwright
compwright / sample.js
Created August 24, 2016 17:52
ClickTripz Integration Test
var _ctq = _ctq || [];
// Create 'compare to' strip object
_ctq.push(['newCompareToStrip', 'a']);
_ctq.push(['a.setPublisherID', 4]);
_ctq.push(['a.setAnchorID', 'ctAnchor']);
// Attach the correct API methods to our search form, this is a 'Hotel Citywide' search.
_ctq.push(['a.setFormID', 'ctSearchForm']);
_ctq.push(['a.setCityNameID', 'ctCity']);
{
"_id" : ObjectId("58e2a3047463f61e5de6dbd6"),
"updatedAt" : ISODate("2017-04-03T19:31:16.681Z"),
"createdAt" : ISODate("2017-04-03T19:31:16.681Z"),
"name" : "Test calendar",
"active" : true,
"webhooks" : [
{
"url" : "http://localhost:8082/api/rdc/webhooks/scheduler",
"signatureAlgorithm" : "x-hub",
@compwright
compwright / javascript-disenchantment.md
Last active September 26, 2018 14:56
Javascript Disenchantment

Only in software, it’s fine if a program runs at 1% or even 0.01% of the possible performance. Everybody just seems to be ok with it....our portable computers are thousands of times more powerful than the ones that brought man to the moon. Yet every other webpage struggles to maintain a smooth 60fps scroll on the latest top-of-the-line MacBook Pro. --Nikita Prokopov, [Software disenchantment][1]

He is right!

Two questions immediately came to mind:

  1. Why do we write such bloated, inefficient software?
  2. How can we do better?
@compwright
compwright / client_automations.sql
Last active October 30, 2018 17:34
client_automations.sql
INSERT INTO `client_automations` (`client`, `source`, `status`, `credentials`, `rules`, `exclusions`, `created_timestamp`, `updated_timestamp`, `user`)
VALUES
(452,'servicetitan','active','{\"apiKey\":\"\",\"apiSecret\":\"\"}','[{\"settings\":{\"products\":[{\"code\":\"1\",\"qty\":1}],\"location\":\"7\",\"department\":null,\"cardType\":\"TY\"},\"conditions\":[{\"id\":\"0voXy6RCReZjFoa8HOQSi\",\"field\":\"invoice.total\",\"operator\":\"isMoreThan\",\"operand\":\"1.00\",\"operandType\":\"number\"}],\"isActive\":true,\"id\":\"v4sQi7iJJLl~FpKYAlaah\"}]',NULL,'2018-10-29 17:28:36','2018-10-29 17:34:14',2304),
(4799,'servicetitan','active','{\"apiKey\":\"\",\"apiSecret\":\"\"}','[{\"settings\":{\"products\":[{\"code\":\"1\",\"qty\":1}],\"location\":\"4579\",\"department\":\"4580\",\"cardType\":\"TY\"},\"conditions\":[{\"id\":\"0voXy6RCReZjFoa8HOQSi\",\"field\":\"invoice.total\",\"operator\":\"isMoreThan\",\"operand\":\"1.00\",\"operandType\":\"number\"}],\"isActive\":true,\"id\":\"v4sQi7iJJLl~FpKYAlaah\"}]',NULL,
@compwright
compwright / internal-receiverd.log
Created October 5, 2015 16:50
internal-receiverd.log (pairing issue)
[05/Oct/2015 16:26:08] INFO [ssh_server.py:837] RECV: limited-claim-status
[05/Oct/2015 16:26:08] INFO [ssh_server.py:848] Dispatching to: _cmd_limited_claim_status
[05/Oct/2015 16:26:08] INFO [ssh_server.py:616] SEND: 267 eyJzdGF0dXMiOiAiY2xhaW1pbmctY29uZmlndXJlIn0=
[05/Oct/2015 16:26:13] INFO [ssh_server.py:837] RECV: limited-claim-status
[05/Oct/2015 16:26:13] INFO [ssh_server.py:848] Dispatching to: _cmd_limited_claim_status
[05/Oct/2015 16:26:13] INFO [ssh_server.py:616] SEND: 267 eyJzdGF0dXMiOiAiY2xhaW1pbmctY29uZmlndXJlIn0=
[05/Oct/2015 16:26:15] INFO [limited-claim.py:73] configuring...
Stopping postgresql-server service: [ OK ]
Linking postgres time zone data
Mon Oct 5 16:25:58 UTC 2015