Skip to content

Instantly share code, notes, and snippets.

View samsamm777's full-sized avatar

Sam Hudson samsamm777

View GitHub Profile
@samsamm777
samsamm777 / pre-commit
Last active December 11, 2015 22:19
Git pre-commit hook to run phpunit tests for Symfony2
#!/bin/sh
phpunit -c /PATH_TO_SYMFONY/app
@samsamm777
samsamm777 / post-commit
Last active December 24, 2015 16:19
git post commit hook to export to htdocs folder
#!/bin/sh
unset GIT_INDEX_FILE
export GIT_WORK_TREE=/example.com/
export GIT_DIR=/home/whoever/development/web-project/.git/
git checkout -f
@samsamm777
samsamm777 / gist:7230159
Last active April 26, 2024 13:24
PHP set private property value using reflection. This allows you to set a private property value from outside the object, great for PHPUnit testing.
<?php
$a = new A();
$reflection = new \ReflectionClass($a);
$property = $reflection->getProperty('privateProperty');
$property->setAccessible(true);
$property->setValue($a, 'new-value');
echo $a->getPrivateProperty();
//outputs:
@samsamm777
samsamm777 / test.php
Created February 13, 2015 10:30
Example use of predis transactions to do check and set conditional updates. Running this example from multiple threads will maintain a consistent increment value
// Our redis client
$redis = $this->getContainer()->get("redis_client");
// Set the key
$key = 'my_key';
// predis transaction options
$options = array(
'cas' => true, // Initialize with support for CAS operations
'watch' => $key, // Key that needs to be WATCHed to detect changes
@samsamm777
samsamm777 / gist:3e0a17b6046413d73f56
Created March 12, 2015 11:47
AWS Linux AMI xorg configuration for nvidia graphics card without a screen.
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig: version 346.47 (buildmeister@swio-display-x86-rhel47-01) Thu Feb 19 19:19:45 PST 2015
# Modified by Sam Hudson (sam.hudson@thefoundry.co.uk). Added Headless monitor, for use without a physical screen.
Section "Monitor"
Identifier "Headless"
HorizSync 80.0 - 80.0
VertRefresh 75.0
Modeline "1280x1024_75.00" 138.45 1280 1368 1504 1728 1024 1025 1028 1069 -Hsync +Vsync
EndSection
function addCameraGizmos() {
cameraControl = new THREE.TransformControls(ThreeCameraService.cameras[0], ThreeRendererFactory.renderer.domElement);
cameraControl.attach(ThreeCameraService.cameras[1]);
ThreeSceneService.scene.add(cameraControl);
var renderCameraHelper = new THREE.CameraHelper(ThreeCameraService.cameras[1]);
ThreeSceneService.scene.add(renderCameraHelper);
def get_images(vin, host, d=0):
"""
- Return a list of lists of images on disk for the give vin, younger than 'days'
List objects: [ index, image_url ]
- Don't return _thumbs.
"""
days = int(d)
image_list = []
now = time.time()
try:
<?php
// setup file cache - CCP wants you to respect their cache timers, meaning
// some of the API Pages will return the same data for a specific while, or worse
// an error. If you use one of the availabe caching implementations,
// pheal will do the caching transparently for you.
// in this example we use the file cache, and configure it so it will write the cache files
// to /tmp/phealcache
Config::getInstance()->cache = new \Pheal\Cache\FileStorage('cache/');
@samsamm777
samsamm777 / table_drop.py
Last active January 11, 2016 20:42 — forked from lauriehawkins/table_drop.py
dropping mongo tables
__author__ = 'laurie'
import bottle
import os
from bottle import route, run, template, static_file
from pymongo import MongoClient
bottle.TEMPLATE_PATH.insert(0, '/home/laurie/devops_tools/table_drop')
/**
* Return the current user from the config object, if its present.
*
* @return {User}
*/
public getCurrentUser(): User {
var _json = {
username: "sam",
name: "Sam Hudson",