Skip to content

Instantly share code, notes, and snippets.

View topless's full-sized avatar
💭
Music For The Jilted Generation

Christos Topaloudis topless

💭
Music For The Jilted Generation
View GitHub Profile
@ntarocco
ntarocco / Bookmarklet
Last active November 2, 2020 07:15
Bookmarklet for COVID "Attestation de déplacement dérogatoire", attestation generator in France (https://media.interieur.gouv.fr/deplacement-covid-19/)
Bookmarket (<https://en.wikipedia.org/wiki/Bookmarklet>) to autofill the form for sport. If you need for groceries, replace
document.getElementById('checkbox-sport_animaux').checked = true;
with
document.getElementById('checkbox-achats').checked = true;
Instructions:
1. fill in the values with your personal information
@bvaughn
bvaughn / index.md
Last active June 16, 2024 21:50
How to use profiling in production mode for react-dom

React recently introduced an experimental profiler API. This page gives instructions on how to use this API in a production release of your app.

Table of Contents

Profiling in production

React DOM automatically supports profiling in development mode for v16.5+, but since profiling adds some small additional overhead it is opt-in for production mode. This gist explains how to opt-in.

@goldo
goldo / lodash-assignIn-merge-defaults-diff.js
Last active December 14, 2023 00:49
Differences between .assignIn(), .assign, .merge(), defaults() and defaultsDeep()
// Tests with Lodash 4.16.4
// Thanks to http://stackoverflow.com/questions/19965844/lodash-difference-between-extend-assign-and-merge
_.assignIn ({}, { a: 'a' }, { a: 'bb' }) // => { a: 'bb' }
_.merge ({}, { a: 'a' }, { a: 'bb' }) // => { a: 'bb' }
_.defaults ({}, { a: 'a' }, { a: 'bb' }) // => { a: 'a' }
_.defaultsDeep({}, { a: 'a' }, { a: 'bb' }) // => { a: 'a' }
---
@eteeselink
eteeselink / delay.js
Created November 13, 2015 13:55
ES7 async/await version of setTimeout
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
async function something() {
console.log("this might take some time....");
await delay(5000);
console.log("done!")
}
something();
import basin
import string
from hashlib import sha1
## Fixed-length compact ids for compound keys. Given one or more strings, this will
## concat with delim (default '|'), sha1 hash the result, convert to the given base
## (default 62), truncate to the given length (default 12) and left-pad with zeros.
##
## *** WARNING MATH AHEAD ***
## Here's a handy way to approximate the birthday number for a given bitspace and a
@chantastic
chantastic / on-jsx.markdown
Last active May 30, 2024 13:11
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@Kartones
Kartones / postgres-cheatsheet.md
Last active July 6, 2024 20:44
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@Bouke
Bouke / gist:11261620
Last active August 3, 2023 01:46
Multiple Python installations on OS X

Previous versions used homebrew to install the various versions. As suggested in the comments, it's better to use pyenv instead. If you are looking for the previous version of this document, see the revision history.

$ brew update
$ brew install pyenv
$ pyenv install 3.5.0
$ pyenv install 3.4.3
$ pyenv install 3.3.6
$ pyenv install 3.2.6
$ pyenv install 2.7.10

$ pyenv install 2.6.9

@chenglou
chenglou / gist:40b75d820123a9ed53d8
Last active March 13, 2024 12:14
Thoughts on Animation

Interesting part (unmounting & API) is at the end if you're not interested in the rest =).

Stress Tests

This animation proposal is just an attempt. In case it doesn't work out, I've gathered a few examples that can test the power of a future animation system.

  1. Parent is an infinitely spinning ball, and has a child ball that is also spinning. Clicking on the parent causes child to reverse spinning direction. This tests the ability of the animation system to compose animation, not in the sense of applying multiple interpolations to one or more variables passed onto the child (this should be trivial), but in the sense that the parent's constantly updating at the same time as the child, and has to ensure that it passes the animation commands correctly to it. This also tests that we can still intercept these animations (the clicking) and immediately change their configuration instead of queueing them.

  2. Typing letters and let them fly in concurrently. This tests concurrency, coordination of an array of ch