Skip to content

Instantly share code, notes, and snippets.

View marcelaraujo's full-sized avatar

Marcel Araujo marcelaraujo

View GitHub Profile
<?php
// root path
$path = realpath('.');
// finds everything in $path including root directory
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
$success = 0;
$error = 0;
$skipped = 0;
<?php
class BobTest {
public function PublicMethod() { return; }
protected function ProtectedMethod() { return; }
private function PrivateMethod() { return; }
public function TestCallables() {
echo "testing myself...", PHP_EOL;
@marcelaraujo
marcelaraujo / gist:09c5e0fb1187f3ac39bb
Created December 17, 2014 13:03
Clear Bind9 Cache
If you are running BIND as a resolver for your office - ie. not forwarding to another a resolver.
Flush everything in the cache:
rndc flush
Flush a specific record:
rndc flushname example.com
If you are forwarding then you are at the mercy of the forwarder's cache.
<?php
// A closure can be bound ($this will be a specific object), unbound ($this not set) or static ($this cannot be set)
// A closure may be scoped (it can see the private properties of a specific class), or unscoped (no class)
// At present, a closure must be bound or static if it is scoped, and unscoped if it is unbound
// I propose changing this to also allow scoped, unbound closures
// I want to add Closure::call, which lets you call and bind a closure (to avoid creating a new closure for each object you want to bind to)
$foo = function () {
return $this->x;
@marcelaraujo
marcelaraujo / gist:e4b35cb90a15699a5f8a
Created January 13, 2015 18:08
Jade Bug - Process out of memory
# Bug
# FATAL ERROR: JS Allocation failed - process out of memory
- var n = 0
ul
while n < 20
= n++
@marcelaraujo
marcelaraujo / gist:89e6a355b5aa7ed524b8
Created February 5, 2015 00:45
Reading private properties
$reader = function($object, $property) {
$value = \Closure::bind(function() use($property) {
return $this->$property;
}, $object, $object)->__invoke();
return $value;
};
print_r( $reader($this, 'created') );
@marcelaraujo
marcelaraujo / README.md
Last active August 29, 2015 14:15 — forked from dciccale/README.md

DOM Ready

Tiny Cross-browser DOM ready function in 111 bytes of JavaScript.

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
$ curl -O ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz
$ tar -xzvf ncurses-5.9.tar.gz
$ cd ./ncurses-5.9
$ ./configure --prefix=/usr/local \
--without-cxx --without-cxx-binding --without-ada --without-progs --without-curses-h \
--with-shared --without-debug \
--enable-widec --enable-const --enable-ext-colors --enable-sigwinch --enable-wgetch-events \
&& make
$ sudo make install
@marcelaraujo
marcelaraujo / array_map_recursive
Created February 26, 2015 03:59
The most memory-efficient array_map_recursive()
<?php
function array_map_recursive(callable $func, array $arr) {
array_walk_recursive($arr, function(&$v) use ($func) {
$v = $func($v);
});
return $arr;
}