Skip to content

Instantly share code, notes, and snippets.

View chrisjlee's full-sized avatar
💭
🏈

Chris J. Lee chrisjlee

💭
🏈
View GitHub Profile
// tools/jest/setupTests.js
const error = console.error;
console.error = (...args) =>
// Suppress error messages regarding network error in tests
/Error: Request failed with status code 500/m.test(
args[0]
)
? void 0
: error(...args);
@ih2502mk
ih2502mk / list.md
Last active May 12, 2024 05:41
Quantopian Lectures Saved
@bundit
bundit / count-lines-of-code-in-local-repo
Created October 8, 2020 03:22
Count lines of code a git tracked project
// Referenced from https://gist.github.com/mandiwise/dc53cb9da00856d7cdbb
// List line count of all tracked files
$ git ls-files | xargs wc -l
// Match only certain file-types
$ git ls-files -- '*.js*' | xargs wc -l
// Add additional file-types to count
$ git ls-files -- '*.js*' '*.jsx' '*.tsx' '*.css' | xargs wc -l
@threepointone
threepointone / feature-flags.md
Last active May 24, 2023 11:03
Feature flags: why, how, all that

(I'm enjoying doing these raw, barely edited writeups; I hope they're useful to you too)

Feature flags

This is my own writeup on feature flags; for a deep dive I'd recommend something like Martin Fowler's article (https://martinfowler.com/articles/feature-toggles.html).

So. Feature flags. The basic idea that you'll store configuration/values on a database/service somewhere, and by changing those values, you can change the user experience/features for a user on the fly.

Let's say that you're building a new feature, called 'new-button' which changes the color of buttons, which is currently red, to blue. Then you'd change code that looks like this -

let UserContext = React.createContext();
class App extends React.Component {
state = {
user: null,
setUser: user => {
this.setState({ user });
}
};
import * as React from "react";
type Value = boolean;
type ContextWithSetter = React.Context<{
value: Value;
setValue: (value: Value) => void;
}>;
const { Provider, Consumer }: ContextWithSetter = React.createContext({
import React, { Component, createContext } from 'react'
function initStore(store) {
const Context = createContext();
class Provider extends React.Component {
constructor() {
super();
this.state = store.initialState;
}
@jmkgreen
jmkgreen / keycloak-compose.yml
Created August 3, 2017 09:01
KeyCloak docker-compose file for swarm stack launch purposes
version: '3.3'
services:
keycloak:
image: jboss/keycloak-mysql
environment:
- constraint:serverclass==gateway
- PROXY_ADDRESS_FORWARDING=true
- MYSQL_USER=keycloak
@KeenWarrior
KeenWarrior / docker-compose.yml
Created March 27, 2017 07:35
keycloak with ssl
db:
image: postgres
environment:
- POSTGRES_DB=keycloak
- POSTGRES_USER=keycloak
- POSTGRES_PASSWORD=password
- POSTGRES_ROOT_PASSWORD=root_password
keycloak:
@wesbos
wesbos / async-await.js
Created February 22, 2017 14:02
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}