Skip to content

Instantly share code, notes, and snippets.

View MSeven's full-sized avatar
🤦‍♂️
yeah.... whatever

MGriesbach MSeven

🤦‍♂️
yeah.... whatever
  • Munich, Germany
  • 15:22 (UTC +02:00)
View GitHub Profile
<?php
private function query($method, $authorized = false) {
if ($authorized) {
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => sprintf("Content-type: application/x-www-form-urlencoded\r\n"),
'content' => http_build_query(array(
'login' => $this->username,
'token' => $this->token
<?php
function timeAgo($difference) {
static $timeConf = array(
'Seconds' => 60,
'Minutes' => 60,
'Hours' => 24,
'Days' => 0
);
@MSeven
MSeven / queue_twitterscrape.php
Created July 19, 2009 09:44
Cakephp Queue Twitter example
<?php
class queueTwitterscrapeTask extends Shell {
/**
* @var array
*/
public $uses = array(
'Tweet',
'Queue.QueuedTask'
);
<?php
class QueueHelloworldTask extends Shell {
/**
* Adding the QueueTask Model.
* There is no magic here..
*
* @var array
*/
public $uses = array(
@MSeven
MSeven / zenddisk.php
Created October 3, 2009 11:38
Zend Data cache Storage engine for Cakephp cache
<?php
/* SVN FILE: $Id$ */
/**
* Zend Data Cache storage engine for cache.
*
*
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
@MSeven
MSeven / flickrshell.php
Created April 29, 2010 09:47
CakePhp Queue Flickr Upload tasks
<?php
/**
* @author MGriesbach@gmail.com
* @package QueuePlugin
* @subpackage QueuePlugin.Tasks
*/
abstract class FlickrShell extends Shell {
protected $perms = 'write';
protected $token;
@MSeven
MSeven / imagetim.php
Created June 1, 2010 21:06
Trim a Solid color border from an image using GDlib in PHP
<?php
function imagetrim(&$im) {
$width = imagesx($im);
$height = imagesy($im);
$imcopy = imagecreatetruecolor($width, $height);
imagecopy($imcopy, $im, 0, 0, 0, 0, $width, $height);
imagefilter($imcopy, IMG_FILTER_GAUSSIAN_BLUR);
@MSeven
MSeven / patent.hs
Created May 1, 2011 18:25
Patent 5,893,120
{- |
The claims of United States Patent 5,893,120 may be reduced to a set
of mathematical formulae expressed in the Typed Lambda Calculus, also
known as System F. This file contains these formulae. The language
used is Haskell, which is a version of System F with extra "syntactic
sugar" to make it useful for practical purposes.
It happens that formulae expressed in Haskell can also be transated by
a Haskell compiler into executable computer programs. However that
@MSeven
MSeven / gist:2021002
Created March 12, 2012 10:02
http byte range file server
<?php
// check if the file actually exists.
if (file_exists($filePath)) {
//everything OK, log the access and start pushing the file.
$info = pathinfo($filePath);
$fileSize = filesize($filePath) - 1;
$fp = fopen($filePath, 'rb');
// push it.
header("Expires: 0");
<?php
/**
* Return human readable sizes
*
* @author Aidan Lister <aidan@php.net>
* @version 1.3.0
* @link http://aidanlister.com/2004/04/human-readable-file-sizes/
* @param int $size size in bytes
* @param string $max maximum unit
* @param string $system 'si' for SI, 'bi' for binary prefixes