Skip to content

Instantly share code, notes, and snippets.

@codfish
codfish / #linting.md
Last active May 6, 2024 18:12
Prettier + ESLint + Husky + lint-staged + commitlint

My personal & professional linting setup. Run's Prettier as an ESLint rule via their ESLint plugin. Dynamic support for react or non-react applications depending on your project dependencies. Dynamic inclusion of Kent C Dodds' ESLint Jest config depending on your project dependencies.

Convenient opt-in configs for projects using Docker or Ethereum to avoid common false positives.

To understand more, see https://github.com/codfish/eslint-config-codfish.

To avoid having to manually setup everything and add all configuration/boilerplate code to your project, use cod-scripts instead. It was forked from kcd-scripts and ultimately inspired by react-scripts.

Why

@getify
getify / 1.md
Last active October 15, 2020 01:44
BetterPromise: a strawman experiment in subclassing Promise and "fixing" a bunch of its awkward/bad parts

Some things that are "better" with this BetterPromise implementation:

  • BetterPromise # then(..) accepts a BetterPromise (or Promise) instance passed directly, instead of requiring a function to return it, so that the promise is linked into the chain.

    var p = BetterPromise.resolve(42);
    
    var q = Promise.resolve(10);
    
    p.then(console.log).then(q).then(console.log);
@amoodie
amoodie / make_random_names.md
Last active April 28, 2022 13:52
Make random names in Python

The following code is written for Python3. Complete random name function in next file.

The first bit of code grabs a disctionary listing from the web and returns a list of all the entries in that dictionary.
(see https://stackoverflow.com/a/49524775/4038393)

import urllib.request

word_url = "http://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-type=text/plain"
response = urllib.request.urlopen(word_url)
@remy
remy / .eslintignore
Last active April 13, 2021 04:48
My Next.js eslint config + `npm install --save-dev eslint eslint-plugin-react babel-eslint`
.next
out
@rafaelrozon
rafaelrozon / mock_axios_storybook.jsx
Last active April 26, 2023 12:29
Mock Axios requests in Storybook
import React from 'react';
import { storiesOf } from '@storybook/react';
// 1. import axios and MockAdapter
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
// 2. create the mock
const mock = new MockAdapter(axios);
@fgilio
fgilio / axios-catch-error.js
Last active April 11, 2024 19:02
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@rikschennink
rikschennink / README.md
Last active January 29, 2019 09:44
Sass OO Mixins: OOCSS without the HTML clutter

Sass OO Mixins: OOCSS without the HTML clutter

  • Less HTML clutter (caused by all those fragmented class names).
<button class="btn btn-primary btn-large btn-outline">Buy!</button>
  • Descriptive classes (or no classes at all) in the HTML results in cleaner and easier to read HTML.
Buy!
@craigbeck
craigbeck / introspection-query.graphql
Created April 6, 2016 20:20
Introspection query for GraphQL
query IntrospectionQuery {
__schema {
queryType { name }
mutationType { name }
subscriptionType { name }
types {
...FullType
}
directives {
@shannonmoeller
shannonmoeller / multiline-regexp.js
Last active April 12, 2021 22:16
Multiline Regular Expressions using ES6 Template Strings
/**
* Inspired by XRegExp via 2ality
* http://www.2ality.com/2012/12/template-strings-xregexp.html
* http://xregexp.com/
*/
import test from 'ava';
export function rx(flags) {
const trailingComments = /\s+#.*$/gm;
@neilellis
neilellis / cached-circle.yml
Last active August 29, 2015 14:19
Basic Circle.yml files for Tutum
machine:
services:
- docker
dependencies:
cache_directories:
- "~/docker"
override:
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS tutum.co