Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

// original source: https://medium.com/@ndyhrdy/making-the-bottom-sheet-modal-using-react-native-e226a30bed13 🙇
import React, {useEffect, useRef} from 'react';
import {
Animated,
Dimensions,
Modal,
PanResponder,
StyleSheet,
View,
} from 'react-native';
watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/npm-* && rm -rf $TMPDIR/haste-* && rm -rf $TMPDIR/metro-* && rm -rf node_modules && npm install && rm -rf ios/Pods && cd ios && pod cache clean --all && pod repo update && pod install && ./android/gradlew clean -p ./android/ && rm -rf ios/build && rm -rf ~/Library/Developer/Xcode/DerivedData && npm start -- --reset-cache
@adrianmcli
adrianmcli / counter-composition.js
Last active February 5, 2019 13:23
An example of using plain functions and composing them to make state containers.
// state container definition
const useState = initVal => {
let val = initVal;
const get = () => val;
const set = x => (val = x);
return Object.freeze({ get, set });
};

PDF Make Definitions

A list of all the properties for the Document Definition objects in PDF Make. Gathered from the examples source code. Up to date for version 0.1.38.

Basic definition

  • The Document Definition is a javascript object: {}. It can contain the following.
  • content: array. This defines the layout of your document. All your tags will be defined in there. You define tags using object (e.g. content: [{text: 'Hello World'}])
  • styles: object. A dictionary of all the named styles in your document. You can then apply a style to any object using style: 'name' or style: ['name1', 'name2']
  • defaultStyle: object. Defines a style to be applied to every element in the document.
  • images: object. Another dictionary that you can use to specify all the images in your document.
@giladHaimov
giladHaimov / BasicERC20.sol
Last active March 19, 2024 20:03
Basic ERC20 implementation
pragma solidity ^0.4.19;
contract ERC20Basic {
string public constant name = "ERC20Basic";
string public constant symbol = "BSC";
uint8 public constant decimals = 18;
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);

Oh my zsh.

Install with curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Enabling Plugins (zsh-autosuggestions & zsh-syntax-highlighting)

  • Download zsh-autosuggestions by
@gaearon
gaearon / slim-redux.js
Last active March 25, 2024 19:12
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {

Folder Structure

Please note

While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.

Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.

var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],