Skip to content

Instantly share code, notes, and snippets.

View SBoudrias's full-sized avatar

Simon Boudrias SBoudrias

View GitHub Profile
@SBoudrias
SBoudrias / CalendarColor.gs
Last active September 12, 2024 19:45
Google script to add colours & focus time to your calendar
function ColorEvents() {
const today = new Date();
const later = new Date();
later.setDate(later.getDate() + 20);
Logger.log(`Updating from ${today} to ${later}`);
const calendar = CalendarApp.getCalendarById('[email protected]');
const allEvents = calendar.getEvents(today, later).filter((event) => !event.isAllDayEvent());
function setEventColor(event, color) {
@SBoudrias
SBoudrias / user.js
Last active April 3, 2020 05:43
Using JS weakmaps as cache (Node)
const cache = new WeakMap();
// This pattern allows us to pass down a single argument (req) down our function chain.
// Then each function/class can get their dependencies in this way - and we know it'll only call
// our DB/storage once per request.
export async function getUserFromReq(req) {
if (cache.has(req)) {
return cache.get(req);
}
@SBoudrias
SBoudrias / user.js
Created April 3, 2020 04:24
Using a weakmap as cache.
const cache = new WeakMap();
export async function getUserForReq(req) {
if (cache.has(req)) {
return cache.get(req);
}
return await User.get(req.form.session_id);
}
@SBoudrias
SBoudrias / user.js
Created April 3, 2020 04:24
Using a weakmap as cache.
const cache = new WeakMap();
export async function getUserForReq(req) {
if (cache.has(req)) {
return cache.get(req);
}
return await User.get(req.form.session_id);
}
This file has been truncated, but you can view the full file.
<html>
<head>
<meta charset="utf-8">
<style> /*! TACHYONS v4.11.1 | http://tachyons.io */
/*! normalize.css v8.0.0 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[ty

So the issue with this setting is that when the initial bundle load, it cannot load future bundles.

Initial bundle comes from http://dev.local/m/bundles/foo-74b26207487b44f00927.js.

Then it tries to load the another bundle: http://dev.local/1.1-74b26207487b44f00927.js.

It looks like the webpack publicPath is messed up.

@SBoudrias
SBoudrias / config.js
Last active December 21, 2015 09:39
Using require.js map configuration to façade module in a way to always load relevant plugins and localization.
require.config({
paths: {
jquery : "../../vendors/js/jquery/jquery",
validate : "../../vendors/js/jquery.validation/jquery.validate",
validate_fr : "../../vendors/js/jquery.validation/messages_fr"
},
map: {
// Façade modules or swap them for another one
"*": {
@SBoudrias
SBoudrias / readline-test.js
Created May 13, 2013 20:56
Node.js Readline and CLI keypress example
var readline = require('readline'),
_ = require('lodash'),
charm = require('charm')(process.stdout),
rl = readline.createInterface(process.stdin, process.stdout);
var selected = 0;
var choices = [
"foo",
"bar",
"javascript",
img {
/*width: 3000px;
height: auto;*/
-webkit-transform: scale(3);
}
div {
background: blue;
}
.elem {
display: inline-block;
background: green;
height: 100%;
width: 1em;
}