Skip to content

Instantly share code, notes, and snippets.

View moimikey's full-sized avatar
:shipit:
ship it

Michael Scott Hertzberg moimikey

:shipit:
ship it
View GitHub Profile
@snej
snej / missing_includes.rb
Created October 2, 2023 16:19
Script to find missing std #includes in C++ headers
#! /usr/bin/env ruby
#
# missing_includes.rb
# By Jens Alfke <jens@couchbase.com>
# Version 2.0 -- 2 Oct 2023
# Copyright 2021-Present Couchbase, Inc.
#
# This script scans C++ header files looking for usage of common standard library classes, like
# `std::vector`, without including their corresponding headers, like `<vector>`. It similarly looks
# for standard C functions like `strlen` that are used without including their header (`<cstring>`.)
@moimikey
moimikey / traverseDOMNode.js
Last active June 7, 2023 17:09
Traverse the DOM with cascading predicates
function traverseDOMNodes(node, predicates, cb) {
if (predicates.length === 0) {
// Base case: If there are no more predicates, invoke the callback.
return cb(node);
}
const [currentPredicate, ...remainingPredicates] = predicates;
const children = node.childNodes;
for (let child of children) {
@moimikey
moimikey / web-application-stack.md
Last active September 29, 2021 15:32
web-application-stack.md

Packages

dependencies

  • Apollo
  • Babel
  • Serverless or CDK
  • GraphQL
  • MobX
  • MobX State Tree
  • NextJS
@Raynos
Raynos / mutex.js
Last active June 9, 2020 15:43
PromiseLock or Mutex ?
/**
* A PromiseLock like object.
*
* Used to ensure that we only do one thing at a time on a shared resource.
*
* For example, with async iterator:
*
* this.readLock = new Mutex()
* this.readLock.do(async () => {
* const data = await itr.next();
@moimikey
moimikey / rick-roll.js
Last active October 26, 2023 15:24
rick-roll
var music, musicParse;
musicParse = function(f) {
return eval("for(var t=0,S='RIFF_oO_WAVEfmt " + atob('EAAAAAEAAQBAHwAAQB8AAAEACAA') + "data';++t<3e5;)S+=String.fromCharCode(" + f + ")");
};
music = function() {
var audio, formula;
formula = '(t<<3)*[8/9,1,9/8,6/5,4/3,3/2,0][[0xd2d2c8,0xce4088,0xca32c8,0x8e4009][t>>14&3]>>(0x3dbe4688>>((t>>10&15)>9?18:t>>10&15)*3&7)*3&7]&255';
audio = new Audio("data:audio/wav;base64," + (btoa(musicParse(formula))));
@lizthegrey
lizthegrey / attributes.rb
Last active February 24, 2024 14:11
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
@gaearon
gaearon / uselayouteffect-ssr.md
Last active May 2, 2024 13:42
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {
@staltz
staltz / example.js
Created March 18, 2019 20:59
Build your own RxJS
function createObservable(subscribe) {
return {
subscribe,
pipe: function(operator) {
return operator(this);
},
};
}
const numberObservable = createObservable(function(observer) {
// ==UserScript==
// @name Goodbye new FB ads
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Remove facebook ads
// @author Maurizio Carboni
// @match https://www.facebook.com/*
// @grant none
// ==/UserScript==
import React, { Suspense } from 'react';
import { Router } from '@reach/router';
import Loading from './Loading';
const Home = React.lazy(() => import('./Home'));
const Dashboard = React.lazy(() => import('./Dashboard'));
const Overview = React.lazy(() => import('./Overview'));
const History = React.lazy(() => import('./History'));
const NotFound = React.lazy(() => import('./NotFound'));