Skip to content

Instantly share code, notes, and snippets.

Avatar

Francisco Cano AeonFr

View GitHub Profile
@AeonFr
AeonFr / .zshrc
Created Feb 5, 2021
Some of my zsh config / aliases
View .zshrc
alias cat='bat --style=plain'
alias ls='exa'
alias ll='exa -la --git'
alias ctags='`brew --prefix`/bin/ctags'
alias vim='nvim'
alias fchrome="open -a Google\ Chrome\ Beta --args --disable-web-security --ignore-certificate-errors --force-renderer-accessibility"
# Make a commit with a branchname prepended. Usage: gcbm "This is my message"
function gcbm() {
@AeonFr
AeonFr / .vimrc
Last active Feb 4, 2021
Vim config (using Vundle)
View .vimrc
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 Jun 29, 2020
Date range in "human friendly" format for Spanish and European format
View human-date-range.js
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(/\.$/, "");
};
View 2020-01-01-before-refactor.css
@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 Sep 30, 2019
Git diff: creates a list of modified files from one commit to another, and saves it to a file (diff.log)
View git-diff.bat
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 Aug 16, 2019
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.
View pdo-fetch-with-types.php
<?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 Aug 7, 2018
Function to create DOM elements filled with attributes and content, in one line of JavaScript. Inspired on React.createElement().
View element.js
/**
* 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.
View seo.html
<!-- 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 Apr 19, 2018
calculateTotalOffsetTop() & calculateTotalOffsetLeft() - Recursive totalOffset of an $element, to calculate it's position relative to the whole page.
View calculateTotalOffsets.js
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 Aug 14, 2018
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>
View mediumEditor.vue
<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.