Skip to content

Instantly share code, notes, and snippets.

View ahoulgrave's full-sized avatar

Agustín Houlgrave ahoulgrave

  • New Relic
  • Barcelona, España
View GitHub Profile
@ahoulgrave
ahoulgrave / main.cpp
Created August 21, 2013 13:54
Exponentes
#include <cstdlib>
#include <iostream>
using namespace std;
int potencia(int base, int exp);
int main(int argc, char *argv[])
{
@ahoulgrave
ahoulgrave / main.cpp
Created August 22, 2013 22:48
Ajedrez
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
int pos[2] = {1,1};
while (pos[0] != 8 || pos[1] != 8) {
@ahoulgrave
ahoulgrave / puntos.py
Created August 22, 2013 22:49
Metemática 1 - Guía 1 - Ej. 2
__author__ = 'hormiga'
rango = [10,11]
verdulerias = [
[0,3],
[2,3],
[1,8],
[7,9],
[7,1],
@ahoulgrave
ahoulgrave / main.cpp
Last active December 22, 2015 19:59
Matriz de 5x5...
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int m[5][5] = {
{1,2,3,4,5},
{6,7,8,9,10},
mysql -u username -p database_name < file.sql
@ahoulgrave
ahoulgrave / time_elapsed_string.func.php
Created December 1, 2015 17:43
Tiempo transcurrido en español
function time_elapsed_string($datetime, $full = false) {
$now = new \DateTime;
$ago = $datetime;
$diff = (array) $now->diff($ago);
$diff['w'] = floor($diff['d'] / 7);
$diff['d'] -= $diff['w'] * 7;
$string = array(
'y' => 'año',
@ahoulgrave
ahoulgrave / slugify.php
Created December 7, 2015 20:23
Slugify
function slugify($text)
{
// replace non letter or digits by -
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
// trim
$text = trim($text, '-');
// transliterate
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
{% for label, flashes in app.session.flashbag.all %}
{% for flash in flashes %}
<div class="alert alert-{{ label }}">
{{ flash }}
</div>
{% endfor %}
{% endfor %}
@ahoulgrave
ahoulgrave / appendParam.php
Last active March 10, 2016 00:33
Function to append a parameter to an url querystring
/**
* @param $value
* @param string $param
* @return string
*/
public function appendParam($param, $value)
{
$url = $this->request->getUri();
$queryString = parse_url($url, PHP_URL_QUERY);
$params = [];
<?php
class User
{
/**
* @var string
*/
private $name;