Skip to content

Instantly share code, notes, and snippets.

Geoffrey Dhuyvetters duivvv

Block or report user

Report or block duivvv

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@duivvv
duivvv / index.js
Last active Nov 21, 2018
FizzBuzz
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`
@duivvv
duivvv / react_fiber.md
Last active Nov 11, 2019
What is React Fiber? And how can I try it out today?
View react_fiber.md
@duivvv
duivvv / prevent_scroll.js
Last active Dec 19, 2016
prevent scrolling on iOS
View prevent_scroll.js
document.addEventListener(`touchmove`, e => {
e.preventDefault();
});
@duivvv
duivvv / 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"
      ]
View promises.js
(() => {
const delay = (time=1000) => {
return new Promise((resolve, reject) => {
if(typeof time !== 'number') return reject(new Error('wrong type'));
setTimeout(() => {
return resolve(`waited ${time}ms`);
}, time);
});
};
View Todos.jsx
class Todos extends Component {
componentDidMount() {
const {getTodos} = this.props;
getTodos();
}
/* ... */
}
@duivvv
duivvv / script.js
Last active Oct 28, 2015
react style as a template string
View script.js
import ReactDOM from 'react-dom';
import React from 'react';
const toCamelCase = data => {
let str = '';
data.split('-').forEach((part, i) => {
if(i > 0) str += (part.charAt(0).toUpperCase() + part.substr(1, part.length));
else str += part;
View buildFormData.js
export const buildFormData = (form, data={}) => {
let fd = form ? new FormData(form) : new FormData();
for(let key in data){
fd.append(key, data[key]);
}
return fd;
};
View fetchAndMerge.js
export const fetchAndMerge = arr => {
return Promise.all(arr)
.then(data => Object.assign({}, ...data));
};
You can’t perform that action at this time.