Skip to content

Instantly share code, notes, and snippets.

View AeonFr's full-sized avatar

Francisco Cano AeonFr

View GitHub Profile
@AeonFr
AeonFr / .zshrc
Last active December 15, 2021 15:57
Some of my zsh config / aliases
export LANG=en_US.UTF-8
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/francisco/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
@AeonFr
AeonFr / .vimrc
Last active December 15, 2021 15:55
Vim config (using Vundle)
set nocompatible
filetype off
" PLUGINS:
" -----------------------------
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
@AeonFr
AeonFr / human-date-range.js
Created June 29, 2020 12:16
Date range in "human friendly" format for Spanish and European format
const defaultLocale = "default"; // falls back to user's locale using the string "default"
const getMonthName = (date, { locale = defaultLocale, format = "long" }) => {
let result = date.toLocaleString(locale, {
month: format,
});
// Fix for ES: make first letter uppercase and remove trailing "."
return result.slice(0, 1).toUpperCase() + result.slice(1).replace(/\.$/, "");
};
@AeonFr
AeonFr / 2020-01-01-before-refactor.css
Last active June 3, 2020 07:58
analysis of a css file
@import url(https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i,900,900i);@font-face{font-family:filmin;src:url(../fonts/filmin-custom/big/filmin-big.eot);src:url(../fonts/filmin-custom/big/filmin-big.eot?#iefix) format("embedded-opentype"),url(../fonts/filmin-custom/big/filmin-big.woff) format("woff"),url(../fonts/filmin-custom/big/filmin-big.ttf) format("truetype"),url(../fonts/filmin-custom/big/filmin-big.svg#filmin) format("svg");font-weight:400;font-style:normal}@font-face{font-family:filmin-small;src:url(../fonts/filmin-custom/small/filmin-small.eot);src:url(../fonts/filmin-custom/small/filmin-small.eot?#iefix) format("embedded-opentype"),url(../fonts/filmin-custom/small/filmin-small.woff) format("woff"),url(../fonts/filmin-custom/small/filmin-small.ttf) format("truetype"),url(../fonts/filmin-custom/small/filmin-small.svg#filmin) format("svg");font-weight:400;font-style:normal}@-webkit-keyframes spinner{0%{transform:scale(.5) rotate(0deg)}to{transform:scale(.5) rotate(1turn)}}@keyf
@AeonFr
AeonFr / git-diff.bat
Created September 30, 2019 08:20
Git diff: creates a list of modified files from one commit to another, and saves it to a file (diff.log)
REM Usage: ./git-diff {commit_id_or_tag_name_or_branch_name}
git --no-pager diff --compact-summary --stat=255 --diff-algorithm=minimal --name-status %1 HEAD >> diff.log
@AeonFr
AeonFr / pdo-fetch-with-types.php
Last active August 16, 2019 12:01
From a PDO Statement, fetch all the results and store them in an associative array, mapping integer and float values to PHP int and float types. It reads the column metadata to read the value's type.
<?php
// Returns the contents of $stm (PDO Statement)
// as an associative array, with correct native types
// for integers, nulls, and floats
$array = [];
while ($fila = $stm->fetch(\PDO::FETCH_ASSOC)) {
@AeonFr
AeonFr / element.js
Last active August 7, 2018 06:29
Function to create DOM elements filled with attributes and content, in one line of JavaScript. Inspired on React.createElement().
/**
* el(tag, options[, innerHTML])
* Creates an HTMLElement object
* and fills it with various attributes and properties.
* Inspired by React's `React.createElement()` function
*
* @param string tag The element's tagname, such as P, DIV, etc.
* @param object options
* An object that can contain key-value pairs of attributes such as
* "aria-label", "itemtype", "disabled", etc.
<!-- facebook open graph & google tags (this also works for twitter) -->
<!-- This are usefull mostly for machines. -->
<meta property="og:url" content="https:{{ .Permalink }}" />
<!-- es_AR means "spanish from Argentina". Not really supported, though. That's why there's a fallback -->
<meta property="og:locale" content="es_AR" />
<meta property="og:locale:alternate" content="es_LA" />
@AeonFr
AeonFr / calculateTotalOffsets.js
Created April 19, 2018 16:30
calculateTotalOffsetTop() & calculateTotalOffsetLeft() - Recursive totalOffset of an $element, to calculate it's position relative to the whole page.
function calculateTotalOffsetTop (elem, total){
total = total || 0;
total = elem.offsetTop + total;
if (elem.offsetParent) return calculateTotalOffsetTop(elem.offsetParent, total)
else return total;
}
function calculateTotalOffsetLeft (elem, total){
total = total || 0;
total = elem.offsetLeft + total;
@AeonFr
AeonFr / mediumEditor.vue
Last active August 14, 2018 02:20
A .vue (single file component for vue) implementation of https://github.com/FranzSkuffka/vue-medium-editor/ - Import into a component and use like: <medium-editor :text="content" v-on:edit='applyTextEdit'></medium-editor>
<template>
<div ref="element" v-html="text"></div>
</template>
<script>
import MediumEditor from 'medium-editor'
// impure helper function, replaces some element from the dom with a new one of the given tag name
// returns the new one.