Skip to content

Instantly share code, notes, and snippets.

View pie6k's full-sized avatar

Adam Pietrasiak pie6k

View GitHub Profile
@pie6k
pie6k / useShareForwardedRef.tsx
Created October 23, 2019 10:02
forwardRef hook
import React, { useRef, forwardRef, Ref, useEffect } from 'react';
import { TextInputProps, TextInput } from 'react-native';
import styled from 'styled-components/native';
interface Props extends TextInputProps {
showEditLabel?: boolean;
}
const Input = styled.TextInput``;
@pie6k
pie6k / suspensify-promise.ts
Last active September 18, 2019 07:50
Suspensify Promise Typescript
type AllowedArg = number | string | boolean | null | undefined;
function stringifyArg(arg: AllowedArg) {
return `${arg}`;
}
function serializeArgs(args: AllowedArg[]) {
const argsLimiter = "<<<<***>>>>";
if (args.length === 0) {
@jakewtaylor
jakewtaylor / readme.md
Last active January 6, 2024 23:29
VS Code CSS addition to increase readability on file tree.

Increases indentation on the file tree and adds some lines to each directory/file.

Works 15 levels deep, but you can expand it by just adding more of each line thats repeating, i.e.:

  • add another box shadow
    • (n*-20px) 0 0 0 rgba(255, 255, 255, 0.4)
  • add another padding-left
    • .monaco-tree-row[aria-level="n"] { padding-left: ((n-1)*20)px; }
  • add another :before & :after with left positioning
    • .monaco-tree-row[aria-level="n"]:before { left: (((n-1)*20)-9)px; }
  • .monaco-tree-row[aria-level="n"]:after { left: (((n-1)*20)-9)px; }
@pie6k
pie6k / init.coffee
Last active July 7, 2017 10:57
My atom settings
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@armand1m
armand1m / Dockerfile
Last active March 10, 2024 14:54
Yarn cache compatible Dockerfile
FROM alpine
RUN apk add --update --no-cache nodejs
RUN npm i -g yarn
ADD package.json yarn.lock /tmp/
ADD .yarn-cache.tgz /
RUN cd /tmp && yarn
RUN mkdir -p /service && cd /service && ln -s /tmp/node_modules
@noeljackson
noeljackson / docker-compose-swarm.sh
Last active September 27, 2020 17:56
Run docker-compose with docker-machine and docker-swarm on digital ocean
#from https://www.linux.com/learn/how-use-docker-machine-create-swarm-cluster
#export digital ocean token
export DO_TOKEN="abcdefghijklmnopqrstuvwxyz"
#make keystore
docker-machine create -d digitalocean \
-digitalocean-access-token ${DO_TOKEN} \
--digitalocean-region "nyc1" \
--digitalocean-image="ubuntu-14-04-x64" \
--digitalocean-size "512mb" \
@guncha
guncha / relay.d.ts
Last active April 3, 2023 08:15
Very basic Relay typings for Typescript
declare module 'react-relay' {
// fragments are a hash of functions
interface Fragments {
[query: string]: ((variables?: RelayVariables) => string)
}
interface CreateContainerOpts {
initialVariables?: Object
prepareVariables?(prevVariables: RelayVariables): RelayVariables
@chriddyp
chriddyp / my sublime text keyboard mapping
Last active March 13, 2017 09:48
map the arrow keys to JKLI with `cntrl` and jump code blocks with `cntrl`-`option`-K, `cntrl`-`option`-I
[
{ "keys": ["ctrl+j"], "command": "move", "args": {"by": "words", "forward": false} },
{ "keys": ["ctrl+l"], "command": "move", "args": {"by": "words", "forward": true} },
{ "keys": ["ctrl+k"], "command": "move", "args": {"by": "lines", "forward": true} },
{ "keys": ["ctrl+i"], "command": "move", "args": {"by": "lines", "forward": false} },
{ "keys": ["ctrl+alt+j"], "command": "move", "args": {"by": "words", "forward": false} },
{ "keys": ["ctrl+alt+l"], "command": "move", "args": {"by": "words", "forward": true} },
{ "keys": ["ctrl+alt+k"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": true} },

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.

@fta2012
fta2012 / DragTransform
Last active May 1, 2024 21:15
Slightly modified compiled coffeescript from this codepen: http://codepen.io/fta/pen/ifnqH. Paste into console on a page that has jQuery to load the two dependent libraries (jquery-ui and numericjs). Then call makeTransformable('#selector-name') to make that element WYSIWYG editable. Use inspector to get the CSS for the transforms.
var selector = 'img' // Replace this with the selector for the element you want to make transformable
jQuery.getScript('//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js', function() {
jQuery.getScript('//cdnjs.cloudflare.com/ajax/libs/numeric/1.2.6/numeric.min.js', function() {
(function() {
var $, applyTransform, getTransform, makeTransformable;
$ = jQuery;