Skip to content

Instantly share code, notes, and snippets.

@arekbartnik
arekbartnik / js-encode-decode.md
Created January 20, 2020 20:31 — forked from yidas/js-encode-decode.md
JavaScript HTML Entities Encode & Decode
@arekbartnik
arekbartnik / App.js
Created November 11, 2018 22:22 — forked from ryanflorence/App.js
import React, { Suspense, useState } from "react";
import { unstable_createResource as createResource } from "react-cache";
import {
Combobox,
ComboboxInput,
ComboboxList,
ComboboxOption
} from "./Combobox2.js";
function App({ tabIndex, navigate }) {
let UserContext = React.createContext();
class App extends React.Component {
state = {
user: null,
setUser: user => {
this.setState({ user });
}
};
@arekbartnik
arekbartnik / figma-project-stats.js
Created June 21, 2018 19:20 — forked from rsms/figma-project-stats.js
Script that generates statistics for a Figma project, like number of files, frames, versions etc
//
// Figma project stats
// Pulls statistics like number of files, frames, versions etc for a project.
//
// Usage:
// export FIGMA_API_ACCESS_TOKEN='your-token'
// node figma-project-stats.js <project-id>
//
// You can generate tokens in your account settings or at
// https://www.figma.com/developers/explorer#personal-access-token
// handy method to create a Higher Order Component out of a
// Render Prop Component (like a Context.Consumer).
// handles, statics, displayName, refs, and value forwarding
function createHOCFromRenderProp({prop, Consumer}) {
return Component => {
function Wrapper(props, ref) {
return (
<Consumer>
{value => <Component {...{...props, [prop]: value, ref}} />}
@arekbartnik
arekbartnik / ResizeObservable.js
Created December 24, 2017 09:04 — forked from vincentriemer/ResizeObservable.js
React Component prototype that provides element query functionality via ResizeObserver
// @flow
import * as React from "react";
import ResizeObserver from "resize-observer-polyfill";
import invariant from "invariant";
type Entry = {
+contentRect: {
+width: number,
+height: number
@arekbartnik
arekbartnik / react-image-objectfit-fallback.js
Created December 24, 2017 09:02 — forked from vincentriemer/react-image-objectfit-fallback.js
Image React Component with `object-fit` Fallback
// @flow
import * as React from "react";
import getStyleProp from "desandro-get-style-property";
const supportsObjectFit = !!getStyleProp("objectFit");
type Props = React.ElementProps<"img">;
export default class Image extends React.Component<Props> {
@arekbartnik
arekbartnik / cron.md
Created December 23, 2017 20:54 — forked from evancz/cron.md
Cron job to remind myself to stretch

Type crontab -l to see your cron jobs. Type crontab -e to edit them. You have to use Vim apparently.

Add a line like this:

0,30	*	*	*	*	/Users/YOURNAME/Documents/scripts/stretch.sh

That is on every 0th and 30th minute of the hour. Make sure all the separators in there are tabs!

@arekbartnik
arekbartnik / git-bash.sh
Created October 7, 2017 09:26 — forked from gyandeeps/git-bash.sh
Bash alias for git
# Global variables
re='^[0-9]+$'
# Will create a new branch with name ($1) from master
# it will also make sure master is up to date from origin
workstart() {
if ! [[ $1 =~ $re ]]
then
val=$1
else
@arekbartnik
arekbartnik / scroll-manager.js
Created April 27, 2017 21:10 — forked from maddie927/scroll-manager.js
Scroll Manager for React Router v4
import React from 'react'
import { func, node, number, object, shape, string } from 'prop-types'
import { withRouter } from 'react-router'
import debounceFn from 'lodash/debounce'
class ScrollManager extends React.Component {
static propTypes = {
children: node.isRequired,
history: shape({
action: string.isRequired,