Skip to content

Instantly share code, notes, and snippets.

View dhernandez's full-sized avatar

Daniel Hernández Marín dhernandez

View GitHub Profile
@dhernandez
dhernandez / yarn_tab_autocomplete.sh
Last active November 16, 2023 09:51
yarn <tab><tab> autocomplete with yarn commands from yarn --help. yarn run <tab><tab> autocomplete with scripts from package.json
#/bin/bash
_yarn(){
if [ "$2" = "" ]; then SEARCH_PATTERN="."; else SEARCH_PATTERN=$2
fi
if [ "$3" == "run" ]; then
COMPREPLY=( $(cat package.json | jq '.scripts | keys[]' | tr -d \" | grep -E ^$SEARCH_PATTERN | tr \\n ' ') )
else
COMPREPLY=( $(yarn --help | grep -e "-\s" | tr -d '\- ' | grep -E ^$SEARCH_PATTERN | tr -d ' ' | tr \\n ' ') )
fi
@dhernandez
dhernandez / main.py
Last active June 1, 2023 11:03
Calculo del reparto de diputados en la Diputación Provincial de Soria para el año 2023
#!/bin/bash
import math
import numpy as np
import pandas as pd
import requests
from fake_useragent import UserAgent
from requests.adapters import HTTPAdapter, Retry
from municipalities import municipalities
@dhernandez
dhernandez / Dockerfile - Docker lines to add couchbase PHP SDK in Alpine
Last active January 13, 2021 21:15
Docker lines to add couchbase PHP SDK in Alpine
RUN apk add --no-cache \
gcc \
g++ \
make \
php7-dev \
zlib-dev \
libcouchbase-dev \
;
RUN pecl channel-update pecl.php.net \
@dhernandez
dhernandez / mysql_countries.sql
Last active March 1, 2018 10:34 — forked from kamermans/mysql_countries.sql
MySQL Dump - continents and countries with 2 and 3 char codes, names and full names - Spanish and English - Braintree compatible as of Dec 2011
/**
*
* Added spanish language by Daniel Hernández.
*
* Continents and Countries MySQL Tables compiled from Wikipedia, Braintree Payments documentation
* and a couple other places I don't recall at the moment. This data is compatible with the Braintree
* Payment API as of Dec 2011
*
* Compiled by Steve Kamerman, 2011
*/
@dhernandez
dhernandez / loop_dates.php
Created February 7, 2018 09:21
Loop through dates range (PHP)
<?
$from = new DateTime('2018-01-01');
$to = new DateTime('2018-12-31');
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($from, $interval, $to);
foreach ($period as $day) {
echo $day->format('Y-m-d');