Skip to content

Instantly share code, notes, and snippets.

@zebateira
zebateira / tutorials.json
Last active February 10, 2020 11:48
ProtoSchool Tutorials Data
{
"0001": {
"url": "data-structures",
"redirects": [],
"project": "IPFS",
"title": "Decentralized Data Structures",
"description": "The decentralized web relies on unique data structures and linking strategies. Learn about the benefits of hashing, content addressing, DAG and Merkle Trees!",
"resources": [
{
"title": "Understanding How IPFS Deals with Files",
@zebateira
zebateira / App.css
Created August 12, 2017 20:53
Squares in Black
.app {
width: 100%;
height: 100%;
text-align: center;
background-color: black;
color: #e0e0e0;
}
.squares {

Use these rapid keyboard shortcuts to control the GitHub Atom text editor on Mac OSX.

Key to the Keys

  • ⌘ : Command key
  • ⌃ : Control key
  • ⌫ : Delete key
  • ← : Left arrow key
  • → : Right arrow key
  • ↑ : Up arrow key
@zebateira
zebateira / onTap.js
Created April 19, 2017 14:44
To be used instead of onClick for touch devices.
// touchActiveClassName is a classname for the element when the item is active (touchstart).
export default (onTap, touchActiveClassName) => {
let domElement;
const onTouchStart = () => touchActiveClassName && domElement.classList.toggle(touchActiveClassName);
const onTouchEnd = () => {
touchActiveClassName && domElement.classList.toggle(touchActiveClassName);
onTap();
};
@zebateira
zebateira / drag-right.js
Last active April 19, 2017 14:40
Simple element drag for react elements.
const X_DELTA = 150; // 150 pixels
const DELAY_DETWEEN_DRAGS = 250; // 250 ms
export default (onDrag) => {
let domElement;
let startX;
let lastDragged;
return {
ref: (ref) => (domElement = ref),
@zebateira
zebateira / grid.js
Last active April 19, 2017 14:35
Simple grid positioner. It calculates an item position given the grid options.
export default ({ columns, size, item, center = true, direction = '' }) => (index) => {
let x = 0;
let y = 0;
const col = index % columns;
const row = Math.floor(index / columns);
const centerSpacing = (item.width / 2) * (columns * (row + 1) - Math.min(size, columns * (row + 1)));
x = item.width * col + (center ? centerSpacing : 0);
y = item.height * row;