Skip to content

Instantly share code, notes, and snippets.

View acapps's full-sized avatar

Alan Capps acapps

  • Zipwhip
  • Seattle, WA
View GitHub Profile
<?php
/**
* Interface ApplicantAPI
*/
interface ApplicantAPI {
/**
* @param $title
* @return int|null
*/
<?php
$jsonInput = '
[{
"_id": "58b5c92eb2f1c45f9b7d5bfd",
"ap_mac": "80:2a:a8:80:d8:f3",
"authorized_by": "api",
"end": 1496084526,
"mac": "00:26:08:db:ec:d4",
"site_id": "58261efcaa83e82c6b230cff",
<?php
class Supervisor {
private $prop1;
private $prop2;
protected $key;
protected function set($key, $val) {
$this->$key = $val;
}
@acapps
acapps / inheritance.php
Created February 3, 2017 06:44
PHP Inheritance Example
<?php
class Supervisor {
private $prop1;
private $prop2;
protected $key;
protected function set($key, $val) {
$this->$key = $val;
}
@acapps
acapps / mysql_no_relation.sql
Created February 2, 2017 17:54
MySQL select records that do not have relation with second table
SELECT *
FROM table_one
WHERE NOT EXISTS(SELECT *
FROM table_two
WHERE table_one.id = table_two.table_one_id);
@acapps
acapps / stopLogic.go
Last active November 1, 2016 18:54
Example implementation of Zipwhip's Stop Handling. One file, as it is meant to run on the Go Playground
package main
import (
"fmt"
"strings"
)
func main() {
testStop()
@acapps
acapps / Filter_JS_IMG_CSS
Created September 20, 2016 05:29
Query Access Logs, but ignore the noise, css, img, js.
cat access.log.2016-09-18 | grep '{search_term}' | grep -v '/css' | grep -v '/js' | grep -v '/img'
@acapps
acapps / exists.sql
Created September 14, 2016 22:24
SQL, at least one result exists.
SELECT EXISTS(SELECT 1 FROM table_name WHERE id = 1);
If it id exists then it will return 1 otherwise it will return 0.
@acapps
acapps / PHP-All Keys Exist in Array.
Created June 23, 2016 22:36
All keys exist in array.
//The values in this arrays contains the names of the indexes (keys) that should exist in the data array
$required = array('key1', 'key2', 'key3' );
$data = array(
'key1' => 10,
'key2' => 20,
'key3' => 30,
'key4' => 40
);