Skip to content

Instantly share code, notes, and snippets.

View Ikke's full-sized avatar

Kevin Daudt Ikke

  • Netherlands
  • 02:37 (UTC +02:00)
View GitHub Profile
<?php
interface DoSomething
{
function doSomething();
}
trait Test
{
@Ikke
Ikke / gist:5999543
Last active December 19, 2015 18:29
Group by
<?php
$usersGrouped = array();
foreach($users as $user)
{
$key = sprintf("%s:%s:%s", $user->field1, $user->field2, $user->field3);
if(!isset($usersGrouped[$key]))
{
$usersGrouped[$key] = array();
//Module fasctgi
class Fastcgi
{
}
class FastcgiRequestFactory implements RequestFactory
{
public method getRequest()
package require http
namespace eval twitter {
variable status_url "http://api.twitter.com/1/statuses/user_timeline/"
bind pub -|- "!twitter" twitter::tweet
}
proc twitter::tweet {nick uhost hand chan argv} {
if {[string length $argv] < 1} {
@Ikke
Ikke / gist:5455351
Last active December 16, 2015 15:19
DCI in python: Adding and deleting methods from objects.
def add_role(subject, role):
for name, function in inspect.getmembers(role, predicate=inspect.isfunction):
setattr(subject, name, types.MethodType(function, subject))
def remove_role(subject, role):
for name, function in inspect.getmembers(role, predicate=inspect.isfunction):
delattr(subject, name)
class Person:
pass
@Ikke
Ikke / gist:5390715
Last active December 16, 2015 06:19
diff --git a/src/components/compiler/assembler.c b/src/components/compiler/assembler.c
index 42dad59..2a36bfe 100644
--- a/src/components/compiler/assembler.c
+++ b/src/components/compiler/assembler.c
@@ -446,6 +446,7 @@ static void _assembler_output_frame(t_dll *frame, FILE *f) {
case OPERATOR_XOR : fprintf(f, "XOR"); break;
case OPERATOR_SHL : fprintf(f, "SHL"); break;
case OPERATOR_SHR : fprintf(f, "SHR"); break;
+ case OPERATOR_COA : fprintf(f, "COA"); break;
}
assignment_expression:
conditional_expression { $$ = $1; }
| coalesce_expression { $$ = $1; }
| unary_expression assignment_operator assignment_expression { $$ = ast_assignment($2, $1, $3); }
;
coalesce_expression:
T_IDENTIFIER T_COALESCE scalar_value { $$ = ast_opr(T_COALESCE, 2, $1, $3); }
;
a = requests.get('http://www.google.nl')
dir(a)
['__bool__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__nonzero__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_content', '_content_consumed', 'apparent_encoding', 'close', 'connection', 'content', 'cookies', 'encoding', 'headers', 'history', 'iter_content', 'iter_lines', 'json', 'links', 'ok', 'raise_for_status', 'raw', 'reason', 'request', 'status_code', 'text', 'url']
@Ikke
Ikke / gist:5240907
Last active December 15, 2015 09:49
git-feature-branch :: (topic) » git log --all --decorate --graph --oneline ~/tmp/git-feature-branch
* 420737a (HEAD, topic) B4
* d3fe9b6 B3
|\
* | 046de8c B2
* | fc175ec B1
| | * 2f01b7a (master) A3
| |/
| * 926464b A2
|/
<?php
namespace Test\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Helper\ViewModel;
class TestController extends AbstractActionController
{
public function indexAction()