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
/**
* Taken from Nikita Popov's answer on stack overflow: http://stackoverflow.com/questions/16489509/decrypting-aes-ctr-little-endian-with-php
*/
static public function ctr_crypt($str, $cipher = MCRYPT_RIJNDAEL_256, $key, $iv) {
$numOfBlocks = ceil(strlen($str) / 16);
$ctrStr = '';
for ($i = 0; $i < $numOfBlocks; ++$i) {
$ctrStr .= $iv;
@jaytaph
jaytaph / imports.md
Last active December 23, 2015 02:49
importing in saffire

namespaces, importing and autoloading

Qualified class names

A class name can be in one of the following formats:

  • Unqualified class name (UCN)
@jaytaph
jaytaph / saffire.rst
Last active December 20, 2015 00:49
saffire datastructure subscriptions

Datastructures and subscriptions

A basic datastructure is defined as:

<datastructure>[<elementlist>]
  • The datastructure can be a data-structure class (something that implements the interface datastructure, or subscription or something?).
  • The element-list is a comma separated list of 0 or more elements.
import saffire;
import http::request;
import saffire::sapi;
class http {
protected property sapi = null;
public method detectSapi() {
switch (saffire.sapi()) {
case "fastcgi" :
/usr/share/saffire/modules
/usr/share/saffire/modules/sfl
/usr/share/saffire/modules/sfl/io.sf
/usr/share/saffire/modules/sfl/saffire.sf
/usr/share/saffire/modules/Framework.sf
/usr/share/saffire/modules/Framework
/usr/share/saffire/modules/Framework/View.sf
/usr/share/saffire/modules/Framework/Http.sf
diff --git a/src/components/compiler/saffire.y b/src/components/compiler/saffire.y
index 1d9ff12..06702b8 100644
--- a/src/components/compiler/saffire.y
+++ b/src/components/compiler/saffire.y
@@ -95,7 +95,7 @@
%token T_CATCH "catch" T_BREAK "break" T_GOTO "goto" T_BREAKELSE "breakelse"
%token T_CONTINUE "continue" T_THROW "throw" T_RETURN "return" T_FINALLY "finally"
%token T_TRY "try" T_DEFAULT "default" T_METHOD "method"
-%token T_SELF "self" T_PARENT "parent" T_NS_SEP T_TO
+%token T_SELF "self" T_PARENT "parent" T_NS_SEP "::" T_TO
namespace eval moin {
bind pubm -|- * moin::moin
}
proc moin::moin { nick host handle chan text } {
if {[regexp -nocase -- {(^moin|^mornin)} $text]} {
putserv "PRIVMSG $chan :$nick moin"
}
if {[regexp -nocase -- {(^:\)|^:P)} $text]} {
namespace eval moin {
bind pubm -|- * moin::moin
}
proc moin::moin { nick host handle chan text } {
if {[regexp -nocase -- {(^moin|^mornin)} $text]} {
putserv "PRIVMSG $chan :$nick moin"
}
}
@jaytaph
jaytaph / ini.php
Created May 10, 2013 14:09
simple php reader/writer
<?php
class MyIni {
protected $file;
protected $section_endings;
protected $keys;
function __construct($filename) {
$this->file = file($filename);
$this->_parse();
<?php
namespace Acme\DemoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="Foo", uniqueConstraints={
@ORM\UniqueConstraint(name="fullname",columns={"firstname", "lastname"}),