Skip to content

Instantly share code, notes, and snippets.

View Danack's full-sized avatar

Danack

  • Bristol, England
View GitHub Profile
@Danack
Danack / composerRunner.php
Created June 21, 2013 22:44
Composer Runner - calls composer update from a PHP script. Not recommended practice at all but may be necessary for people using web servers where they don't have shell access.
//<?php
//
//Yes you can run Composer with a little PHP wrapper. All of the Composer source code is available in the Phar file, so it can be extracted and then you can run it after setting up an InputInterface to replace Composer expecting the commands to be passed in via the command line.
//
//If you setup your directory structure like this:
//
//./project
//./project/composer.json
//./project/composer.lock
//./project/webroot/composerExtractor.php
@Danack
Danack / setCookie.php
Created May 30, 2013 18:16
Set cookie function - part of old codebase.
function setCookieVariable($cookieName, $value, $secureOnly = false){
$timeSeconds = 60 * 60 * 24 * 30; //30 days in the future.
// if($GLOBALS['outputStarted'] == true){
// logToFileFatal("Trying to set cookie '$cookieName' but page output has already started. That's bad.");
// header('X-OUTPUT-STARTED: 12345');
// return;
// }
if($secureOnly == true){
@Danack
Danack / co-routines compared to class
Created May 10, 2013 18:47
Co-routines can be done as objects instead.
<?php
function loggerCoroutine(){
// set something up
$fileHandle = fopen($fileName, 'a');
while($continue == true){
//Do something
fwrite($fileHandle, yield . "\n");
@Danack
Danack / BlockSelecting.sql
Last active December 10, 2015 21:59
How to order within blocks
// Given the following table:
//
// --------------
// | id | event |
// --------------
// | 00 | start |
// | 01 | data |
// | 02 | end |
// | 03 | data |
// | 04 | data |