Skip to content

Instantly share code, notes, and snippets.

View miguelramos's full-sized avatar
🔥
Making picasso moves 🏄‍♂️

Miguel Ramos miguelramos

🔥
Making picasso moves 🏄‍♂️
View GitHub Profile
@miguelramos
miguelramos / CSS-HR
Created March 6, 2012 23:05
CSS: HR Styles
/**
* CSS HR STYLES
*
* @source http://css-tricks.com/examples/hrs/
* @author [email protected]
*/
/* Gradient color1 - color2 - color1 */
hr.style-one {
@miguelramos
miguelramos / PHP-ELEMENT-Search.php
Created March 6, 2012 23:31
PHP: Search element in array recursive
<?php
/**
* Function to search for key/value in recursive mode. If last arg is true
* it returns it's value or key. By default give true or false if key/value have been found.
*
* @param array $array Array to search
* @param string $search What to search
* @param string $mode Mode search for value or key
* @param boolean $return Return value or key
@miguelramos
miguelramos / node-and-npm-in-30-seconds.sh
Created April 17, 2012 13:55 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
@miguelramos
miguelramos / Config.php
Created June 18, 2012 17:50
PHP: Class Config
<?php namespace Fig;
/**
*-------------------------------------------------------------------------------
* Config Class
*-------------------------------------------------------------------------------
* This is a simple class for config itens. The propose is to demonstrate the
* explicity of name methods and the use of conditionals.
*
* @package Fig
* @author Miguel Ramos <[email protected]>
/etc/bind/named.conf
/etc/bind/named.conf.options
/etc/bind/named.conf.local
sudo /etc/init.d/bind9 restart
zone "1.168.192.in-addr.arpa" {
type master;
notify no;
file "/etc/bind/db.192";
@miguelramos
miguelramos / Example.php
Last active December 10, 2015 14:09
Umpirsky Silex I18nRouting
<?php
/**
* This is the application file that extends from silex application.
*
*/
public function __construct(Config $config)
{
parent::__construct();
/**

#Four Ways To Do Pub/Sub With jQuery and jQuery UI (in the future)

Between jQuery 1.7 and some of work going into future versions of jQuery UI, there are a ton of hot new ways for you to get your publish/subscribe on. Here are just four of them, three of which are new.

(PS: If you're unfamiliar with pub/sub, read the guide to it that Julian Aubourg and I wrote here http://msdn.microsoft.com/en-us/scriptjunkie/hh201955.aspx)

##Option 1: Using jQuery 1.7's $.Callbacks() feature:

$.Callbacks are a multi-purpose callbacks list object which can be used as a base layer to build new functionality including simple publish/subscribe systems. We haven't yet released the API documentation for this feature just yet, but for more information on it (including lots of examples), see my post on $.Callbacks() here:

@miguelramos
miguelramos / HttpPost.php
Last active August 29, 2015 14:00
False is always True
$response = false;
$uri = preg_replace('/({\w+})/i', $entity, $this->getRoutes()->object_field_new->uri);
$rs = $this->rest->post($uri, array('field'=>array(
'name' => 'resource',
'required' => true,
'searchable' => false,
'type' => 4
)));
@miguelramos
miguelramos / Procedimento.txt
Last active August 29, 2015 14:00
Business API
Request (/create/product/obras/123)
|
|------- POST BODY {"price": "20", "available": "true", "quantity": "5", "description": "O meu lindo produto", "vat": "1"}
----------------------------------
| |
| API LOGIC |
| |
----------------------------------
@miguelramos
miguelramos / PriorityCalculator.php
Last active August 29, 2015 14:03 — forked from fcaravana/PriorityCalculator.php
Random probability by weight.
<?php
class PriorityCalculator
{
private $data = array();
private $universe = 0;
public function add( $data, $probability )
{
$this->data[ $x = count( $this->data ) ] = new stdClass;