Skip to content

Instantly share code, notes, and snippets.

View fdorantesm's full-sized avatar
📫
Open to work

Fernando Dorantes fdorantesm

📫
Open to work
View GitHub Profile
@fdorantesm
fdorantesm / docker-compose.yml
Last active February 20, 2023 07:52
Minio docker container using docker compose
version: '3.8'
services:
minio:
image: minio/minio:latest
container_name: minio
restart: always
command: server --console-address :9001 /data
environment:
- MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE
@fdorantesm
fdorantesm / bullet-train.zsh-theme
Created February 17, 2023 05:44
Bullet train showing language version if directory contains language's files.
# README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
#
# In addition, I recommend the
# [Tomorrow Night theme](https://github.com/chriskempson/tomorrow-theme) and, if
# you're using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over
# Terminal.app - it has significantly better color fidelity.
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
# place this after nvm initialization!
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
/**
* SELECT * FROM users LIMIT 20
limit = 10
page?=1
offset = (page - 1) * limit
LIMIT offset,limit
function arrayPaginate(array, page_size, page_number) {
--page_number; // because pages logically start with 1, but technically with 0
return array.slice(page_number * page_size, (page_number + 1) * page_size);
}
@fdorantesm
fdorantesm / readcfdi.php
Created June 11, 2020 23:35 — forked from goedecke/readcfdi.php
Extraer información de CFDI XML facil con simplexml
<?php
$xml = simplexml_load_file('test.xml');
$ns = $xml->getNamespaces(true);
$xml->registerXPathNamespace('c', $ns['cfdi']);
$xml->registerXPathNamespace('t', $ns['tfd']);
//EMPIEZO A LEER LA INFORMACION DEL CFDI E IMPRIMIRLA
foreach ($xml->xpath('//cfdi:Comprobante') as $cfdiComprobante){
echo $cfdiComprobante['version'];
@fdorantesm
fdorantesm / uuid.js
Created April 27, 2020 18:05 — forked from bugventure/uuid.js
UUID regex matching in node.js
function createUUID() {
return uuid.v4();
}
// version 4
// createUUID.regex = '^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$';
createUUID.regex = '^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$';
createUUID.is = function (str) {
return new RegExp(createUUID.regex).test(str);
@fdorantesm
fdorantesm / aws.js
Created March 13, 2020 17:44
AWS Helpers
const AWS = require('aws-sdk')
const uuidBase62 = require('uuid-base62')
const mailcomposer = require('mailcomposer')
/**
* Upload file to AWS S3 Service
* @param {Buffer} f
* @param {String} path
* @param {String} filename Uploaded file's name
* @return {Promise<Object>} S3 Promise
@fdorantesm
fdorantesm / orderBy.php
Created January 3, 2020 16:26
Order by attribute
<?
function orderBy($items, $attr, $order)
{
$sortedItems = [];
foreach ($items as $item) {
$key = is_object($item) ? $item->{$attr} : $item[$attr];
$sortedItems[$key] = $item;
}
if ($order === 'desc') {
db.Shopping.updateMany({
_id: {
$nin: [
ObjectId("5e0002b5ee120c01b5492a3a"),
ObjectId("5e0001272f7790405e7c64ed"),
ObjectId("5e000302fbbe813c744409b3"),
ObjectId("5e0002c7fbbe813c744409b0"),
ObjectId("5e0001e02f7790405e7c64fa"),
ObjectId("5e0002a22f7790405e7c6505"),
ObjectId("5e0001ec2f7790405e7c64fd"),