Skip to content

Instantly share code, notes, and snippets.

View AeonFr's full-sized avatar

Francisco Cano AeonFr

View GitHub Profile
@AeonFr
AeonFr / markdown-for-txti.js
Last active September 13, 2016 22:20
Markdown preview for txti.es. This code should be injected at the end of a website with url like: txti.es/*/edit - The script is ready to be used with TamperMonkey user script manager (chrome extension)
// ==UserScript==
// @name Markdown Preview in txti
// @namespace https://gist.github.com/AeonFr/f44a8b6f175d059f8328638a6a30ce4d
// @version 0.1
// @description When EDITING a txti (txti.es/*/edit) in txti.es you should be able to preview your changes (a toggle preview button appears)
// @author Francisco Cano
// @match http://txti.es/*/edit
// @grant none
// @run-at document-end
// @require https://cdnjs.cloudflare.com/ajax/libs/showdown/1.3.0/showdown.min.js
@AeonFr
AeonFr / MusicoJuanIngaramo.cue
Last active September 17, 2016 03:59
Archivo .cue para el album "Músico" de Juan Ingaramo. Escuchalo ♪ https://www.youtube.com/watch?v=6Kx2k9_L5sY ☼ Apoyá al artista http://discosdelbosque.com.ar/juan-ingaramo/ - El autor de este gist no está asociado con Juan Ingaramo ni con Discos del Bosque -
REM DATE 2016
PERFORMER "Juan Ingaramo"
TITLE "Músico"
FILE "MusicoJuanIngaramo.mp3" MP3
TRACK 01 AUDIO
TITLE "Soltar"
INDEX 01 00:00:00
TRACK 02 AUDIO
TITLE "Comodín"
INDEX 01 04:07:00
@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.
@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;
<!-- 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 / 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.
@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 / 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 / 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 / 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(/\.$/, "");
};