Skip to content

Instantly share code, notes, and snippets.

View AndreiCalazans's full-sized avatar
🏠
Working from home

Andrei Xavier de Oliveira Calazans AndreiCalazans

🏠
Working from home
View GitHub Profile
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active June 15, 2024 08:22
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@mbinna
mbinna / effective_modern_cmake.md
Last active June 13, 2024 01:33
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

const fs = require('fs');
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
const paths = [
{ path: 'graphql/connection/', tag: 'Connection' },
@sibelius
sibelius / MutationUtils.js
Created March 19, 2018 10:20
Helper methods for Relay Modern updater
// @flow
import { ConnectionHandler } from 'relay-runtime';
import { isObject, isArray } from 'lodash/fp';
export function listRecordRemoveUpdater({ parentId, itemId, parentFieldName, store }) {
const parentProxy = store.get(parentId);
const items = parentProxy.getLinkedRecords(parentFieldName);
parentProxy.setLinkedRecords(items.filter(record => record._dataID !== itemId), parentFieldName);
}
class Example extends React.Component<
Props,
State,
Snapshot
> {
static getDerivedStateFromProps(
nextProps: Props,
prevState: State
): $Shape<State> | null {
// ...
@alexshagov
alexshagov / install-universal-ctags-with-gtags-osx.md
Last active May 21, 2022 13:41
How to install GNU Global with universall ctags support on mac OS

Unfortunately, homebrew does not support --with-universal-ctags option for global (on the state of April 2018) The reason is that universal-ctags is not officially released yet.

Install universal ctags

Run brew install --HEAD universal-ctags/universal-ctags/universal-ctags (See https://github.com/universal-ctags/homebrew-universal-ctags repo)

If you're on macOS, you might have an old ctags installed with command line tools for XCode. To fix this, simply run alias ctags="brew --prefix/bin/ctags"

@sebmarkbage
sebmarkbage / The Rules.md
Last active June 6, 2024 16:25
The Rules of React

The Rules of React

All libraries have subtle rules that you have to follow for them to work well. Often these are implied and undocumented rules that you have to learn as you go. This is an attempt to document the rules of React renders. Ideally a type system could enforce it.

What Functions Are "Pure"?

A number of methods in React are assumed to be "pure".

On classes that's the constructor, getDerivedStateFromProps, shouldComponentUpdate and render.

@kamilchm
kamilchm / shell.nix
Created September 17, 2018 12:06
React Native nix-shell
with import <nixpkgs> {};
let
jdk = openjdk;
node = nodejs-10_x;
sdk = androidenv.androidsdk {
platformVersions = [ "23" ];
abiVersions = [ "x86" ];
useGoogleAPIs = true;
useExtraSupportLibs = false;
@swyxio
swyxio / 1.md
Last active February 8, 2024 22:30
Learn In Public - 7 opinions for your tech career

2019 update: this essay has been updated on my personal site, together with a followup on how to get started

2020 update: I'm now writing a book with updated versions of all these essays and 35 other chapters!!!!

1. Learn in public

If there's a golden rule, it's this one, so I put it first. All the other rules are more or less elaborations of this rule #1.

You already know that you will never be done learning. But most people "learn in private", and lurk. They consume content without creating any themselves. Again, that's fine, but we're here to talk about being in the top quintile. What you do here is to have a habit of creating learning exhaust. Write blogs and tutorials and cheatsheets. Speak at meetups and conferences. Ask and answer things on Stackoverflow or Reddit. (Avoid the walled gardens like Slack and Discourse, they're not public). Make Youtube videos

@swyxio
swyxio / Timer fallback.js
Created November 14, 2018 01:25
Timer component for use as a Suspense fallback
function Timer() {
const startTime = React.useRef(performance.now());
const [time, setTime] = React.useState(performance.now());
React.useEffect(() => {
const id = setTimeout(() => {
ReactDOM.flushSync(() => {
setTime(performance.now());
});
}, 2);