Skip to content

Instantly share code, notes, and snippets.

View seagoj's full-sized avatar

Jeremy Seago seagoj

View GitHub Profile
@seagoj
seagoj / app.js
Created January 21, 2015 20:46
browserify-shim
"use strict"
var $ = require('jquery');
require('fixedheadertable');
// ...
@seagoj
seagoj / Response.php
Created November 11, 2014 01:03
Autoloading
<?php namespace Devtools;
// /vendor/Devtools/Response.php
class Response
{
...
}
@seagoj
seagoj / gist:86c919f6d4c821557eaa
Created October 22, 2014 18:03
Discern between SELECT, INSERT & UPDATE
$stmt = $this->connection->prepare($queryString);
$executeResult = !is_null($params)
? $stmt->execute($params)
: $stmt->execute();
$data = $stmt->fetchAll($fetchType);
$isInsertStatement = empty($data)
&& $executeResult
&& ($lastInsertId = $this->connection->lastInsertId()) !== 0;
$isUpdateStatement = empty($data);
function it_saves_values_to_repository(
Devtools\Model $model,
Repository\UserRepositoryAdapter $repository
) {
$repository
->getProperties()
->shouldBeCalled()
->willReturn(
[
'userId',
@seagoj
seagoj / gist:917d941c5f91138b42c7
Last active August 29, 2015 14:07
Interfaces and type hints
interface Entity {}
class UserEntity implements Entity {}
interface Repository
{
public function persist(Entity $entity);
}
class UserRepository implements Repository
{
@seagoj
seagoj / gist:db02f7fdacabd3a22080
Created September 29, 2014 20:50
Vimscript Issue
function! TagbarGotoTag()
normal! "zyiw
call tagbar#OpenWindow('fcj')
:exe "/".@z.""
" Need to send a carriage return here to select the tag
:nohlsearch
endfunction
@seagoj
seagoj / msmq.php
Created June 3, 2014 19:57
PHP:MSMQ
<?php
define(MQ_SEND_ACCESS , 2);
define(MQ_DENY_NONE , 0);
$msgQueueInfo = new COM("MSMQ.MSMQQueueInfo") or die("can not create MSMQ Info object");
$msgQueueInfo->PathName = ".\TestQueue";
$msgQueue = new COM("MSMQ.MSMQQueue") or die("can not create MSMQ object");
$msgQueue=$msgQueueInfo->Open(MQ_SEND_ACCESS, MQ_DENY_NONE );
@seagoj
seagoj / gist:10736442
Created April 15, 2014 14:19
Custom error handler
public static function error_handler($errno, $errstr, $errfile, $errline, $errcontext) {
global $errorLog;
if (is_array($errstr) || is_object($errstr)) {
$errstr = var_export($errstr, true);
}
$message = "$errno:$errfile:$errline:$errstr:".json_encode($errcontext);
if (isset($errorLog) && get_class($errorLog)==='Devtools\Log') {
$errorLog->write($message, false);
} else {
echo $message;
@seagoj
seagoj / 0_reuse_code.js
Created March 18, 2014 19:13
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@seagoj
seagoj / mysql_db_copy.sql
Created January 27, 2014 15:26
Duplicate Mysql DB
mysqldump -u root -p[password] [db_src] | mysql -u root -p[password] [db_dest]