Skip to content

Instantly share code, notes, and snippets.

View davidwindell's full-sized avatar

David Windell davidwindell

View GitHub Profile
{
"layout": {
"model": "pc105",
"layout": "us",
"variant": "",
"options": "",
"rules": "evdev",
"isUSStandard": true,
"isUserKeyboardLayout": false
},
#include <dlfcn.h>
#include <pthread.h>
#include <stdio.h>
// THIS IS TO AVOID A SIGFAULT WHEN RUNNING python3.6 manage.py runserver
// This should be fixed at some point by Alpine and/or Python
// Check this issue for more info
// https://github.com/docker-library/python/issues/211
typedef int (*func_t)(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg);
@davidwindell
davidwindell / git-timestamp.sh
Last active January 9, 2024 11:42
Set a files last modified time to match it's git commit timestamp
#!/bin/bash -e
####
# based on http://www.clock.co.uk/blog/a-guide-on-how-to-cache-npm-install-with-docker
#
# Set's the last modified timestamp of a file to it's repositories commit timestamp.
#
# Particularly useful with docker when building after a new git checkout has been made,
# can improve docker build times for composer, bower, npm, etc
#
# @see https://github.com/docker/docker/issues/3556
@davidwindell
davidwindell / wercker.yml
Last active February 10, 2016 00:25
Build, test, cache and deploy docker images with wercker, quay.io and Elastic Beanstalk
box: wercker-labs/docker
build:
steps:
- script:
name: fix timestamps
code: |
sudo wget https://gist.githubusercontent.com/davidwindell/fbfef588c6295666c6a1/raw/c2870b13a50a7aeb4aed1e6eb4daec3a905a7fc0/git-timestamp.sh -O /usr/local/bin/git-timestamp
sudo chmod +x /usr/local/bin/git-timestamp
git-timestamp composer.json
git-timestamp composer.lock
<?php
/**
* Handle various type conversions that should be supported natively by Doctrine (like DateTime)
*
* @param mixed $value
* @param string $typeOfField
* @return DateTime
*/
protected function handleTypeConversions($value, $typeOfField)
{
@davidwindell
davidwindell / FlushEntities.php
Created November 9, 2012 17:03
ZF2 Doctrine Flush Listener
<?php
namespace Application\Listener\Doctrine;
use Doctrine\DBAL\DBALException;
use Doctrine\ORM\EntityManager;
use Zend\EventManager\EventInterface;
use Zend\Mvc\MvcEvent;
class FlushEntities
{
"ticket": {
"ticketid": 174,
"status": "open",
"type": "ticket",
"subject": "Hello there",
"followup": false,
"contact": {
"contactid": 99,
"name": "Person",
<?php
'doctrine' => array(
'configuration' => array(
'orm_default' => array(
//'sqlLogger' => new \Doctrine\DBAL\Logging\EchoSQLLogger(),
),
),
),
@davidwindell
davidwindell / gist:3181965
Created July 26, 2012 13:12
ZF2 Select Element bound to Object
<?php
namespace My\Form\Element;
use Zend\Form\Element\Select as SelectElement;
class DepartmentSelect extends SelectElement
{
<?php
public function setPosts(array $posts) {
foreach ($posts as $post) {
if ($this->posts->contains($post)) {
return;
}
$this->posts->add($post);
$post->setTicket($this);