Skip to content

Instantly share code, notes, and snippets.

<?php
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($dir),
\RecursiveIteratorIterator::SELF_FIRST
);
foreach ($iterator as $file)
if (!$file->isDir() && $file->getFilename() !== '.' && $file->getFilename() !== '..') {
$key = pathinfo($file->getPathName(), PATHINFO_DIRNAME);
if (!isset($data[$key]))
<?php
require_once('vendor/autoload.php');
use TFarla\Routing\Router;
use TFarla\Routing\Route;
$router = new Router([
new Route('show user', '^/users/(?P<id>\d+)/$', ['GET'], function($matches) {
return $matches['id'];
}),
new Route('list users', '^/users/$', ['GET'], function($matches) {
<?php
final class UserRole {
const Admin = 'Admin';
private function __construct() {
}
}
@tomodutch
tomodutch / README.md
Last active August 29, 2015 14:20
farla.io-exercism-example

Help!
Nobody can add two numbers.
We need an application wich accepts 2 numbers and adds them together.

@tomodutch
tomodutch / angular1.js
Last active August 29, 2015 14:24
angular1 vs angular2-now
angular.module('app').controller(['$meteor, $scope', function() {
$scores = $meteor.collection(Scores).subscribe('scores');
$scope.amount = '';
$scope.insertScore = function() {
$scores.call('insertScore', $scope.amount);
}
$scope.resetAmount = function() {
$scope.amount = '';
@tomodutch
tomodutch / recursion.js
Last active August 29, 2015 14:25
A simple demonstration of recursion
function addOne(number, times, iterated) {
iterated = iterated || 0;
return iterated == times ? number : addOne(number + 1, times, iterated + 1);
}
addOne(1, 10);
@tomodutch
tomodutch / container.js
Created August 23, 2015 11:09
IoC meteor jasmine
function Container() {
this.objects = {};
}
Container.prototype.register = function (name, object) {
return this.objects[name] = object;
};
Container.prototype.get = function (name) {
return this.objects[name];
<dom-module id="github-card">
<style>
</style>
<template>
<iron-ajax
id="getCard"
handle-as="json"
on-response="handleResponse">
</iron-ajax>
@tomodutch
tomodutch / index.html
Last active September 12, 2015 14:10
polymer pomodoro
<html>
<head>
...
<link rel="import" href="pomodoro-clock.html">
<link rel="import" href="pomodoro-timer.html">
</head>
<body>
<pomodoro-clock work-seconds="25" break-seconds="5"></pomodoro-clock>
</body>
</html>
@tomodutch
tomodutch / meteor.js
Created September 17, 2015 16:30
Meteor-polymer
Tasks = new Mongo.Collection('tasks');
if (Meteor.isServer) {
Tasks.insert({
text: 'hey'
});
Meteor.publish('tasks', function () {
console.log('connected');
var tasks = Tasks.find().fetch();
console.log(tasks);