Skip to content

Instantly share code, notes, and snippets.

Avatar

Geoffrey Dhuyvetters geoffreydhuyvetters

View GitHub Profile
View machine.js
const fetchMachine = Machine({
id: 'fetch',
initial: 'idle',
context: {
},
states: {
idle: {
on: {
CHANGE_THEME: 'required_information_filled_in',
CHANGE_TIME_TABLE: 'required_information_filled_in',
View .prettierrc
{
"singleQuote": true,
"trailingComma": "all"
}
@geoffreydhuyvetters
geoffreydhuyvetters / wrapWithArray.js
Last active Jan 13, 2021
Wrap any value with an array
View wrapWithArray.js
// not wrapped
const foo = 'foo';
// already wrapped
const bar = ['bar'];
console.log([foo].flat())
// [ 'foo' ]
View focus.sh
#!/bin/bash
# https://api.slack.com/legacy/custom-integrations/legacy-tokens
slack_legacy_token=<insert-your-token-here>
function set_slack_status {
curl -s -S -X POST \
-d "token=$1" \
--data-urlencode "profile={\"status_text\": \"Focus time!\", \"status_emoji\": \"🍅\"}" \
https://slack.com/api/users.profile.set
@geoffreydhuyvetters
geoffreydhuyvetters / refactoring.md
Last active Mar 19, 2020
refactoring rendering
View refactoring.md

BEFORE

const Component = () = {

  // a
  // lot
  // of 
 // logic
View index.js
#!/usr/bin/env node
for(i=0;i<100;)console.log((++i%3?'':'Fizz')+(i%5?'':'Buzz')||i)
View media.js
import { css } from 'styled-components';
export default {
tablet: (...args) => css`
@media (max-width: 1279px) {
${css(...args)};
}
`,
phone: (...args) => css`
@geoffreydhuyvetters
geoffreydhuyvetters / react_fiber.md
Last active Jun 20, 2022
What is React Fiber? And how can I try it out today?
View react_fiber.md
@geoffreydhuyvetters
geoffreydhuyvetters / prevent_scroll.js
Last active Dec 19, 2016
prevent scrolling on iOS
View prevent_scroll.js
document.addEventListener(`touchmove`, e => {
e.preventDefault();
});
@geoffreydhuyvetters
geoffreydhuyvetters / README.md
Last active May 10, 2016
forcing syntax highlighting in Atom
View README.md

You can force syntax highlighting on files in Atom by using customFileTypes in config.cson

"*":
  core:
    customFileTypes:
      "source.json": [
        ".eslintrc"
        ".babelrc"
 ]