Skip to content

Instantly share code, notes, and snippets.

View mmacia's full-sized avatar

Moisès Macià mmacia

View GitHub Profile
#!/bin/env sh
echo -e "\n\nInstalling common packages ...\n\n"
sudo yum check-update && sudo yum update -y
sudo yum install -y htop jq sqlite-devel openssl-devel zsh git
sudo yum groupinstall -y "Development Tools"
sudo amazon-linux-extras install postgresql14
sudo yum install postgresql-devel -y

Keybase proof

I hereby claim:

  • I am mmacia on github.
  • I am mmacia (https://keybase.io/mmacia) on keybase.
  • I have a public key ASBLfiU7oxcAil_oR-5N7787Ho_guNkB56-24ZwCXP6Tawo

To claim this, I am signing this object:

@mmacia
mmacia / optional_monad.rb
Last active August 29, 2015 14:08
Explaining Optional Monad for lazy developers
# get the merchant name of a product in a shopping cart
@cart.items.first.purchasable.user.merchant.first_name
# => NoMethodError (undefined method for nil:NilClass)
@cart.items.first.purchasable.user.merchant.first_name
# ^
# \------ This item not exists (disposed, destroyed, ...)
# But any method in the chain could also be nil!
@mmacia
mmacia / in_memory_files.php
Created July 6, 2011 07:16
Generate files in-memory with PHP
<?php
/**
* This snippet shows a PHP neat trick: build a file into memory without use the filesystem.
*/
$fp = fopen('php://memory', 'rw'); // open an in-memory handler
for ($i = 0; $i < 100; ++$i) { // write some data to handler
fwrite($fp, $i."\n");
@mmacia
mmacia / test_undefined_offset_exception.php
Created July 5, 2011 10:31
How to catch an invalid array index offset as a native exception in PHP
<?php
/**
* this class shows how to override default PHP handler to catch undefined index errors
* and throw it as native exceptions, much more convenient way to work with object
* oriented programs.
*
* @author Moisés Maciá <[email protected]>
* @see http://codeup.net
*/