Skip to content

Instantly share code, notes, and snippets.

@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

@ccwasden
ccwasden / automateSandboxTesterEntry.js
Last active May 6, 2024 10:31
Automate rapid/fast creation of sandbox testers in itunesConnect
// Steps to use:
// 1. Go to itunesConnect > Users & Roles
// 2. Select "Testers" under the "Sandbox" header on the left
// 2. Open the console on your browser (eg. CMD-OPT-J)
// 3. Paste the code below (modified to your liking) into the console and hit enter
// 4. enter `createUser('desiredEmailAlias')` into the console and watch the user get created automatically
//
// NOTE: To create several users rapidly: in the console hit the up arrow, change the alias, and hit enter again. Repeat.
// Edit the user here to your liking
@ccwasden
ccwasden / Await+Threading.swift
Created April 27, 2020 22:39
Await+Threading
//
// Author: Chase Wasden
// Website: https://gist.github.com/ccwasden
// Licensed under MIT license https://opensource.org/licenses/MIT
//
import Foundation
import Combine
// Threading
@Rich-Harris
Rich-Harris / script.sh
Created September 16, 2018 02:23
10 second Svelte demo
echo "<button on:click='set({ count: count + 1 })'>{count}</button>" > App.html
npx svelte compile App.html --format iife --name App > App.js
echo "<div id=target></div>
<script src=App.js></script>
<script>
new App({
target,
data: { count: 0 }