Skip to content

Instantly share code, notes, and snippets.

View demoive's full-sized avatar

Paulo Ávila demoive

  • Barcelona
View GitHub Profile
@demoive
demoive / Helper:SpreadsheetApp.gs
Last active December 23, 2023 18:25
Google Apps Script Helper - Spreadsheet App
/**
* Converts a rich text value to HTML markup.
*
* Only honours "markdown-supported" HTML tags, disregarding any other cell formatting value (such as color, background color, etc.). In other words, keeps the plain text value of the text in the cell, adding only the following HTML tags when necessary:
*
* - <strong>
* - <em>
* - <del>
* - <span style="text-decoration: underline">
* - <a href="">
@demoive
demoive / Helper:HtmlService.gs
Created March 3, 2020 00:01
Google Apps Script Helper - HTML Service
/**
* Facilitates adding includes into HTML documents.
* <?!= include('path/to/filename'); ?>
*
* https://developers.google.com/apps-script/guides/html/best-practices#separate_html_css_and_javascript
*/
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename).getContent();
}
@demoive
demoive / Helper:PropertiesService.gs
Last active May 1, 2020 23:15
Google Apps Script Helper - Properties Service
/**
* Creates a new top-level menu item (called: 🔬) with useful debugging options within.
*
* Requires a global `CONFIG.ENV` variable is set to "development".
*/
if (CONFIG.ENV === 'development') {
var ui = DocumentApp.getUi();
var topMenu = ui.createMenu('🔬'); // As addon, equivalent to `ui.createAddonMenu()` (title is the Addon name)
@demoive
demoive / ia-fba-tracker.html
Created July 12, 2017 11:27
Facebook Analytics Tracking Code Snippet for Instant Articles
<figure class="op-tracker">
<iframe>
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '{PIXEL/APP_ID}'); // Insert your pixel ID here.
@demoive
demoive / gist:b26cf3597f3a33a3c6343d0192f91411
Created June 29, 2017 11:55
Modify the date of a commit
git filter-branch -f --env-filter \
'if [ $GIT_COMMIT = dad723b0e1993e4626e4d91edcea101389bdd87e ]
then
export GIT_AUTHOR_DATE="Mon Nov 17 16:00:53 2014 +0000"
export GIT_COMMITTER_DATE="Mon Nov 17 16:00:53 2014 +0000"
fi'
@demoive
demoive / Bash Notes
Last active July 31, 2020 19:07
Reference for commands/utilities for use in CLI on Unix and Mac OS X
# use:
# .bash_profile - only gets executed for login bash shells
# .bashrc - only gets executed for NON-login bash shells for only NON-login shells
# .profile - gets executed for ANY login shell
# .bash_logout - only gets executed for bash shells after logout
# Sets the prompt:
#PS1='\h:\w \u\$ '
#PS2='> '
@demoive
demoive / .gitconfig
Last active April 25, 2017 20:11
My config settings for Git
[user]
name = Paulo Avila
#email =
[alias]
br = branch
co = checkout
ci = commit -a
feature = checkout -b
amend = commit --amend #--no-edit
@demoive
demoive / .hg_template
Last active December 2, 2015 01:38
Template file for Mercurial smartlog
changeset = "{shortest(node)} {label('blue', '{author|user}')}{if(phabdiff, label('bold', \" {phabdiff}\"))}{bookmarks} {label('cyan', '({date|age})')}\n{desc|firstline}{ifeq(rev, revset('.'), '{files}{file_mods}{file_adds}{file_dels}')}\n\n"
# CURRENTLY, for some reason, the ifeq() condition doesn't work
# I think it's because we're doing the check with "current" inside this "bookmark variable"
bookmark = " {ifeq(bookmark, current, label('yellow', '{bookmark}*'), label('green', '{bookmark}'))}"
#start_files = "ALL:\n"
start_files = "\n\n {sub(\"(\d+):\s+\+(\d+)\/-(\d+)\", label('magenta underline', '\\1 files changed: +\\2/-\\3:'), diffstat)}"
file = ""
end_files = ""
@demoive
demoive / .hgrc
Last active December 3, 2015 00:06
My config settings for Mercurial
[ui]
username = Paulo Avila #<>
status.modified = blue bold # M
status.added = green bold # A
status.removed = red bold # R
#status.clean = # C
#status.deleted = cyan bold #
#status.missing = # !
#status.untracked = blue bold # ?
@demoive
demoive / bash_colors.sh
Last active August 29, 2015 14:01
Displays all the bash colors to the screen
### Bash colors and formatting
# To set the formatting/color, use the following:
# - escape character (\e, \033, \x1B)
# - open square bracket
# - attributes (semicolon-separated)
# - the letter m
#
# \033[<attribute>;...m