Skip to content

Instantly share code, notes, and snippets.

@dukemai
dukemai / content
Last active May 6, 2024 10:35
useful notes
- Research has shown that the ideal line length is about 65 characters. Anywhere between 45 and 85 is generally seen as acceptable, in the context of a roman alphabet.
- You may have heard that using the wildcard selector (*) is bad practice. Some will tell you that it is slow, and can affect the overall performance of your page.
Happily, this is not true. It's been debunked again and again. Even in 2009, when computers were slower and browsers were less optimized, this wasn't an issue. Performance concerns around the wildcard selector are a particularly-resilient urban legend.
@dukemai
dukemai / searchHandling.js
Created November 23, 2020 16:57
dream object usage
const {
get,
getOr,
pipe,
map,
flatMap,
toPairs,
compact,
find,
pathEq,
@dukemai
dukemai / command line cheatsheet
Last active May 6, 2024 10:35
gcloud commands
https://cloud.google.com/sdk/docs/cheatsheet
curl -sSO https://dl.google.com/cloudagents/install-monitoring-agent.sh
sudo bash install-monitoring-agent.sh
curl -sSO https://dl.google.com/cloudagents/install-logging-agent.sh
sudo bash install-logging-agent.sh
@marv7000
marv7000 / perm_mode_str.h
Created May 5, 2024 22:40
[C23] Compile time constant file permission flags from a string
#pragma once
/*
* Scary abuse of the sizeof syntax so static_assert gets evaluated.
* If it passes, we don't want to modify the result though, so AND with 0.
* This is illegal in C++!
*/
#define MODE_ASSERT(x, m) sizeof(struct { static_assert(x, m); char _ghost; }) & 0
/*
@marcospgp
marcospgp / SafeTask.cs
Last active May 6, 2024 10:34
Cancel async tasks in Unity upon exiting play mode
using System;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;
namespace UnityUtilities
{
/// <summary>
/// A replacement for `Task.Run()` that cancels tasks when entering or
/// exiting play mode in the Unity editor (which doesn't happen by default).
@dukemai
dukemai / import-amundi.js
Created September 29, 2020 21:52
import
const pLimit = require("p-limit");
const axios = require("axios");
const XLSX = require("xlsx");
const db = require("./data/db");
const { listRows } = require("./lib/google-drive");
const transform = require("./data/transformers/raw-amundi");
const { logger } = require("../logger");
const amundiId = "1MG_NAeEgtcwxYeioEBckygAa5nlcWPPnLsohgc2nBbE";
@willowCeleste
willowCeleste / imageHero.js
Created February 8, 2022 18:42
Hero custom cursor logic at the module level
import Swiper, { Navigation, EffectFade } from 'swiper';
Swiper.use([Navigation, EffectFade]);
const component = document.querySelector('[data-component="imageHero"]');
export default {
init
};
function init () {
return bindEvents();
@willowCeleste
willowCeleste / data-import.js
Created February 8, 2022 19:19
CSV import
const rollbar = require('../helpers/rollbar');
const _ = require('lodash');
module.exports = {
name: 'data-import',
label: 'Data Import',
pluralLabel: 'Data Imports',
seo: false,
openGraph: false,
addFields: [
@SS-brainstorm
SS-brainstorm / .eslintrc.js
Created January 19, 2020 12:19
eslint default config
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:promise/recommended",
"plugin:sonarjs/recommended",
@wojteklu
wojteklu / clean_code.md
Last active May 6, 2024 10:31
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules