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 / slugify.js
Last active February 24, 2021 08:59
Converts a string to a "URL-safe" slug
/**
* Converts a string to a "URL-safe" slug.
* Allows for some customization with two optional parameters:
*
* @param {string} Delimiter used. If not specified, defaults to a dash "-"
* @param {array} Adds to the list of non-alphanumeric characters which
* will be converted to the delimiter. The default list includes:
* ['–', '—', '―', '~', '\\', '/', '|', '+', '\'', '‘', '’', ' ']
*/
if (!String.prototype.slugify) {
@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 / 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 / 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 / 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 / .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 / 1-questions.md
Last active December 20, 2015 06:58
Front-end Developer Questions Customized list of questions/answers for front-end developer interviews. It is an offshoot of the great, user-contributed list located here: https://github.com/darcyclarke/Front-end-Developer-Interview-Questions/
  1. What is the "smallest" number possible in JavaScript?

  2. Explain why the following doesn't work as an IIFE. What needs to be changed to properly make it an IIFE? function foo(){ }();

  3. What is arr.length?

var arr = [];
arr[10] = 'ten';
function PrimeNumberGenerator() {
this.indx = 2;
}
PrimeNumberGenerator.prototype.next = function () {
var counter = 2;
while (counter < this.indx) {
if (this.indx % counter++ === 0) {
counter = 2;