Skip to content

Instantly share code, notes, and snippets.

@rmruano
rmruano / SimpleLinkedList.php
Last active March 1, 2021 07:33
Simple iterable linked list storing keyvalues. No removal implemented for simplicity. Easy & fast removal could be implemented with a Double Linked List approach. Requires PHP 7.4 (typed properties)
<?php
class LinkedNode {
protected LinkedNode $next;
protected $value;
protected string $key;
public function __construct(string $key, $value) {
$this->value = $value;
$this->key = $key;
}
public function key(): string {
@rmruano
rmruano / mpFlashAPILoad_extended.as
Last active February 3, 2017 11:06 — forked from miniplay/mpFlashAPILoad_extended.as
Miniplay API - Loading of the AS3 API into a flash game (EXTENDED). Additional content provided, refer to the BASE for the simplest version.
/* 1. Imports */
import flash.display.LoaderInfo;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.system.Security;
/* 2. Get the url from the flashvars */
var params:Object = LoaderInfo(root.loaderInfo).parameters; /* Access to the root object is required */
@rmruano
rmruano / mpFlashAPILoad_base.as
Last active February 3, 2017 11:05 — forked from miniplay/mpFlashAPILoad_base.as
Miniplay API - Loading of the AS3 API into a flash game (BASE)
/* 1. Imports */
import flash.display.LoaderInfo;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.system.Security;
/* 2. Get the url from the flashvars */
var params:Object = LoaderInfo(root.loaderInfo).parameters; /* Access to the root object is required */
@rmruano
rmruano / id_rsa.pub
Created February 20, 2016 16:44
Public key
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvEH2o4mKp7Jrbhgvo7JDSEhw+RUZHLJ59SSUTiRTu9DkrpvvZrQs4YXAStkw9zSsvhJp3kQ/86n16SMA/p12KC9Kr9PeGovXJQMkQjnvYNXmYWiMA9g3ubQ7YCMZWbzIS6aKXc8ujP4Au3RNTcBinPgZorLkMvKlm9EphjRZSLuyBZ+0TLNBA7DHmYGu3Rd69q2rosoWMabsKS/NC9U8JX64P/hXsc68wP4OhSMxQzqf4suGJtBLZHk4R6wr4j+TVwEbDdlD5fL6Vaty7Rf7+ZNeMeYSLhyC1CwyYFEgfmJ1KzBivKGGnnY1hNzHe5Kn39TLeOPJJMs1upLM/6rTUQ== [email protected]
@rmruano
rmruano / FilteredSubsetWithGeneratorsDemo.php
Created September 10, 2014 18:28
Just a very simple demo showing how to get a filtered subset from a collection by using generators.
<?php
/**
* PHP 5.5+ Required
* How to get a filtered subset from a collection by using generators.
* @author http://www.github.com/rmruano
*/
/* 1. Classes definition ------------------------------------------------------------------------ */
if (typeof getGraphiteValue=="undefined") {
var getGraphiteValue, reloadGraphiteValues;
getGraphiteValue = function(target, jsonUrl) {
var $target;
if (target instanceof $) {
$target = target;
} else {
$target = $(target);
}
$.ajax({
1) CHAR SPLITS
hbase(main):011:0> create 'split_test_char',{NAME=>'D',VERSIONS=>'1',TTL=>'1'},{SPLITS => ['4','8','b']}
Name Region Server Start Key End Key Requests
split_test_char,,1393314827787.204ca55f6f71c548cd5926102d3cfc2b. host.com:60030 4 0
split_test_char,4,1393314827787.36c384800191ae5aa8b73f24d88e1aba. host.com:60030 4 8 0
split_test_char,8,1393314827787.8e00a315871dc155fc2788dd64573589. host.com:60030 8 b 0
split_test_char,b,1393314827787.d84c59baca0e3cb7c6a76cc1edb1d778. host.com:60030 b 0
@rmruano
rmruano / IterableGroupOfTypedObjects.php
Last active December 15, 2015 04:09
Iterable group of typed objects, can be easily refactored to only allow scalars.
<?php
namespace Model\User\UserItem;
/**
* Iterable group of UserItems
*/
class Group implements \Iterator {
private $position = 0;
@rmruano
rmruano / gist:4971537
Created February 17, 2013 13:41
Miniplay S2S API: Signature validation for server 2 server callbacks (PHP)
$json = file_get_contents("php://input"); /* Get the RAW POST DATA */
if ( ! ( isset($_SERVER['HTTP_MINI_SIGNATURE'])
&& $_SERVER['HTTP_MINI_SIGNATURE'] == md5("[YOUR_API_KEY]".$json) )) {
throw new Exception("Invalid signature");
}
/* the request signature has been validated! */
@rmruano
rmruano / gist:4971509
Created February 17, 2013 13:34
Miniplay API: Parameters validation snippet (PHP)
/* 1. Decode all get parameters */
foreach ($_GET as $key=>$value)
$_GET[$key] = urldecode($value); /* 1. May not be needed in your language */
/* 2. Check signature */
if ($_GET['mini_signature'] != signParameters("YOUR_API_KEY",$_GET)) {
die("The 'mp_*' parameters signature is invalid");
} else {
echo "The 'mp_*' parameters signature is valid!";
}
/* 3. Helper function definition, yeah, it will look so good inside a class :) */