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('simon.boudrias@datadoghq.com');
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 */

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);
}