Skip to content

Instantly share code, notes, and snippets.

View krolow's full-sized avatar

Vinícius Krolow krolow

View GitHub Profile
@CHH
CHH / MetaObject.php
Created August 30, 2011 13:55
PHP does Meta Programming too! (Requires PHP 5.4)
<?php
namespace CHH;
trait MetaObject
{
protected static $__metaClass;
static function setMetaClass(MetaClass $metaClass)
{
@paulmillr
paulmillr / active.md
Last active July 15, 2024 10:55
Most active GitHub users (by contributions). http://twitter.com/paulmillr

Most active GitHub users (git.io/top)

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Wed, 21 Sep 2022 till Thu, 21 Sep 2023.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
 .filter(user =&gt; user.followers &gt; 1000)
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@max-mapper
max-mapper / helloworld.js
Created November 27, 2012 06:55
droneduino
var serialport = require('node-serialport')
var sp = new serialport.SerialPort("/dev/ttyO3", {
parser: serialport.parsers.raw,
baud: 9600
})
sp.on('data', function(chunk) {
console.log(chunk.toString('hex'), chunk.toString(), chunk)
})
@krolow
krolow / Meta.php
Created December 2, 2012 16:45
PHP Adding method dynamically, meta programming example in PHP 5.3
<?php
/**
* Example in PHP 5.3
*/
class Meta
{
private $methods = array();
public function addMethod($methodName, $methodCallable)
@krolow
krolow / MetaTrait.php
Last active October 4, 2019 15:32
PHP Meta Programming PHP 5.4
<?php
trait MetaTrait
{
private $methods = array();
public function addMethod($methodName, $methodCallable)
{
if (!is_callable($methodCallable)) {
throw new InvalidArgumentException('Second param must be callable');
@igorw
igorw / gist:4475804
Last active October 4, 2019 15:32
Composer Versioning
@Raynos
Raynos / non-block.md
Created January 7, 2013 18:30
What it means to be non-blocking in node.

What it means to be non-blocking in node.

From October 2011. Outdated.

In reply to [Wilcox's research paper][1] there seems to be a major confusion about what it means to be non blocking and why node is non blocking.

Now let's start with why node is in a single process and why its non-blocking.

What's the alternative?

@AD7six
AD7six / bench.php
Created August 15, 2013 09:36
Is is_null still slow?
<?php
$null = null;
$notNull = 123;
$is_null = function($value) {
for($i = 0; $i < 1000000; $i++) {
$result = is_null($value);
}
return "is_null";
};
@wandernauta
wandernauta / sp
Last active July 10, 2024 07:57
sp is a command-line client for Spotify's dbus interface. Play, pause, skip and search tracks from the comfort of your command line.
#!/usr/bin/env bash
#
# This is sp, the command-line Spotify controller. It talks to a running
# instance of the Spotify Linux client over dbus, providing an interface not
# unlike mpc.
#
# Put differently, it allows you to control Spotify without leaving the comfort
# of your command line, and without a custom client or Premium subscription.
#