Skip to content

Instantly share code, notes, and snippets.

View jaytaph's full-sized avatar
:shipit:
Calculating pi

Joshua Thijssen jaytaph

:shipit:
Calculating pi
View GitHub Profile
@jaytaph
jaytaph / example1.php
Created December 24, 2010 15:37
Appending the AppendIterator
<?php
// Define arrays
$array1 = new ArrayIterator( array('php', 'perl', 'python', 'c') );
$array2 = new ArrayIterator( array('singleton', 'factory', 'strategy') );
$array3 = new ArrayIterator( array('yellow', 'blue', 'red', 'white') );
// Create iterator and add all arrays to it
$iterator = new AppendIterator();
$iterator->append($array1);
$iterator->append($array2);
@jaytaph
jaytaph / phpinfo.php
Created December 26, 2010 12:39
Test gist
<?php
// Display some information about PHP
phpinfo();
@jaytaph
jaytaph / emaillog.pl
Created January 4, 2011 17:30
Small example using syslog()
#!/usr/bin/perl -n
# thanks to Brian Dowling for an example with security in mind.
$TO = ‘root@localhost’;
$FROM = $TO;
s/^<\d{1,2}>//;
open(MAIL, “|/usr/sbin/sendmail -t”);
@jaytaph
jaytaph / MyNewRegexIterator.php
Created January 6, 2011 11:39
MyRegexIterator.php
<?php
class MyNewerRegexIterator extends RegexIterator {
public function accept() {
$current = $this->current();
if (! isset($current->item)) {
return false;
}
if (preg_match($this->getRegex(), $current->item)) {
<?php
class Service_Controller_Action_Helper_RestContextSwitch extends Zend_Controller_Action_Helper_ContextSwitch
{
public function getActionContexts($action = null)
{
// All actions point back to the global action, or return the complete list of actions
return parent::getActionContexts($action ? 'global' : null);
}
@jaytaph
jaytaph / default.vcl
Created February 1, 2011 10:59
Sample file
backend default {
.host = "127.0.0.1";
.port = "80";
}
// Intialization
C{
#include "/usr/src/wurfl/wurfl.h"
int is_mobile;
}C
#include <avr/interrupt.h>
#include <avr/io.h>
#define INIT_TIMER_COUNT 100
#define RESET_TIMER2 TCNT2 = INIT_TIMER_COUNT
// These are the digits from 0 to 9, with 7 segments
byte ssd[10][7] = {
{ 1,1,1,1,1,1,0 },
{ 0,1,1,0,0,0,0 },
@jaytaph
jaytaph / Makefile.depend
Created April 24, 2011 08:29
The GNU Build tools
MAKEDEPEND=makedepend
# Since our sources are nothing more than our objects, which the .o changed to .c, we use this rule:
SRCS=$(OBJS:.o=.c)
depend:
$(MAKEDEPEND) -Y $(SRCS)
@jaytaph
jaytaph / binarybody.patch
Created September 27, 2011 20:04
Binary body Patch bug pecl #24381
Index: stomp.c
===================================================================
--- stomp.c (revision 317407)
+++ stomp.c (working copy)
@@ -473,7 +473,7 @@
while (1) {
char *p = NULL;
length = stomp_read_line(stomp, &p);
-
+
@jaytaph
jaytaph / example001.php
Created December 4, 2011 17:16
Examples for the iteratorAggregate blog
<?php
/*
* Example 1: Using iteratorAggregate
*/
// Simple class that represents our chapter
class Chapter {
protected $_title;
protected $_content;