Skip to content

Instantly share code, notes, and snippets.

View fi3ework's full-sized avatar

fi3ework

View GitHub Profile
@xtuc
xtuc / Babel.md
Last active April 17, 2019 04:43

Path

remove

Removes the current path.

Example

Visistor:

@myitcv
myitcv / 01_ReactTeamProposal.ts
Last active September 18, 2019 15:32
Typescript example comparing various signatures for getDerivedStateFromProps
interface MyCompProps {
model: Model;
modParams: ModParams;
}
interface MyCompState {
derived1?: Derived1;
derived2?: Derived2;
initialized: boolean;
@sfcgeorge
sfcgeorge / packed-pixels-switchresx.md
Created December 9, 2015 16:13
Packed Pixels HiDPI Retina using SwitchResX

On OS X the Packed Pixels display won't automatically show up as "Retina" or "HiDPI" resolution, instead the OS will use the full resolution of the display making everything tiny. This can be changed using the 3rd party app (non-free) SwitchResX.

First, download SwitchResX.

You can play with the resolutions for the Packed Pixels which is probably listed as Color LCD (2). However not all of the HiDPI resolutions work due to an OS X bug. If you are happy with any of the ones that do work then stop here, else continue.

If you're on El Capitan or later you need to disable System Integrity Protection (temporarily) to add a custom resolution for Packed Pixels. Follow the instructions from SwitchResX creator.

Now add a Custom Resolution that is "scaled". It must be 2 pixels bigger or smaller than the native resolution in one direction (this is the OS X quirk). I found bigger makes it slightly blurry so go w

@bluejava
bluejava / Soon (Fast)
Last active November 11, 2020 15:12
Insanely Fast Javascript thread Yield (see blog post)
// See http://www.bluejava.com/4NS/Speed-up-your-Websites-with-a-Faster-setTimeout-using-soon
// This is a very fast "asynchronous" flow control - i.e. it yields the thread and executes later,
// but not much later. It is far faster and lighter than using setTimeout(fn,0) for yielding threads.
// Its also faster than other setImmediate shims, as it uses Mutation Observer and "mainlines" successive
// calls internally.
// WARNING: This does not yield to the browser UI loop, so by using this repeatedly
// you can starve the UI and be unresponsive to the user.
// This is an even FASTER version of https://gist.github.com/bluejava/9b9542d1da2a164d0456 that gives up
// passing context and arguments, in exchange for a 25x speed increase. (Use anon function to pass context/args)
var soon = (function() {
@carl0zen
carl0zen / styled-components-mixin-example.jsx
Last active December 8, 2021 05:51
Styled Components Mixin example
// Mixin like functionality
const textInput = props => `
color: ${props.error ? color.white : color.base};
background-color: ${props.error ? color.alert : color.white};
`;
export const Input = styled.input`
${textInput}
`;
@cekstam
cekstam / gist:a7758b8f315835d479f379715eebd0c3
Last active December 27, 2021 14:15
create valid JSON from git log using python and ast.literal_string
git log -n 10\
--pretty=format:'{"commit": "%H", "author": "%aN <%aE>", "date": "%ai", "message": """%B""", "notes": """%N""" },' \
$@ | awk 'BEGIN { print("[") } { print($0) } END { print("]") }' | python -u -c \
'import ast,json,sys; print(json.dumps(ast.literal_eval(sys.stdin.read())))'
@swyxio
swyxio / Gatsby-bootstrap-lifecycle.md
Last active April 1, 2022 11:19
Gatsby bootstrap lifecycle

Sequence of Gatsby's bootstrap lifecycle with links to source code as of v2.0.0

  1. open and validate gatsby-config (get-config-file.js) 1.5 load themes (swyx added this note July 2019)
  2. load plugins (load-plugins/index.js) from the list given in gatsby-config.js
  3. onPreBootstrap: runs onPreBootstrap if it is implemented in any plugins, for example gatsby-plugin-typography. Receives handy [apiCallArgs](https://github.com/gatsbyjs/gatsby/blob/ffd8b2d691c9
@okikio
okikio / resolve-imports.js
Last active April 15, 2022 16:43
A fork of resolve.exports but for the imports field of package.json
/** resolve.exports but for imports */
/**
* @param {object} imports
* @param {Set<string>} keys
*/
function loop(imports, keys) {
if (typeof imports === 'string') {
return imports;
}
@somebody32
somebody32 / README.md
Last active April 25, 2022 18:24
Tailwind purging + external components library

Prerequisites

  1. The app that uses tailwind + external component library (CL) (but not 3rdparty, your company internal one, for example)
  2. The component library also uses tailwind

The goal

To be able to purge safely unused tailwind classes from the build (https://tailwindcss.com/docs/controlling-file-size)

Solution

The idea here is simple: we're going to purge css on the app side + whitelist classes that component library is using.

@rodkranz
rodkranz / GoConfigPrivateRepository.md
Last active July 27, 2022 13:15
Go Get from private repository

I had a problem with go get using private repository on gitlab from our company. I lost a few minutes trying to find a solution.... and I did find one:

  1. You need to get a private token at:

    https://gitlab.mycompany.com/profile/account

  2. Configure you git to add extra header with your private token:

$ git config --global http.extraheader "PRIVATE-TOKEN: YOUR_PRIVATE_TOKEN"