Skip to content

Instantly share code, notes, and snippets.

View ItsJonQ's full-sized avatar
🦄
Hai!

Q ItsJonQ

🦄
Hai!
View GitHub Profile
@ItsJonQ
ItsJonQ / use-controlled-state.js
Last active November 24, 2021 16:32
react-use-controlled-state.js
import { useState, useEffect, useRef } from "react";
export function useControlledState(initialState) {
const [state, setState] = useState(initialState);
const stateRef = useRef(initialState);
useEffect(() => {
if (initialState !== stateRef.current) {
setState(initialState);
stateRef.current = initialState;

Keybase proof

I hereby claim:

  • I am itsjonq on github.
  • I am itsjonq (https://keybase.io/itsjonq) on keybase.
  • I have a public key ASB0svRnRcuz0nmoHAUZQVPC1C7WDkUmBjSnZDbWJDF_rwo

To claim this, I am signing this object:

// Source
// https://github.com/facebook/react/blob/master/fixtures/unstable-async/time-slicing/src/Clock.js
import React, {createRef, PureComponent} from 'react';
const SPEED = 0.003 / Math.PI;
const FRAMES = 10;
export default class Clock extends PureComponent {
faceRef = createRef();
@ItsJonQ
ItsJonQ / createUniqueIDFactory.js
Last active December 3, 2018 00:00
Creates a unique incrementing ID with a prefix
export function createUniqueIDFactory(prefix) {
let index = 1
return `${prefix}${index++}`
}
@ItsJonQ
ItsJonQ / get.js
Last active December 1, 2018 23:46
A tiny implementation of lodash.get
/**
* Retrieves a (deeply) nested value from an object.
* A tiny implementation of lodash.get.
*
* Tests:
* https://codesandbox.io/s/48052km1q7
*
* Perf tests:
* https://jsperf.com/get-try-catch-vs-reduce-vs-lodash-get
*
@ItsJonQ
ItsJonQ / install.sh
Created August 31, 2016 01:41 — forked from JeffreyWay/install.sh
Super-fast LAMP + 5.5 install script.
sudo apt-get update
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
sudo apt-get install -y vim curl python-software-properties
sudo add-apt-repository -y ppa:ondrej/php5
sudo apt-get update
sudo apt-get install -y php5 apache2 libapache2-mod-php5 php5-curl php5-gd php5-mcrypt php5-readline mysql-server-5.5 php5-mysql git-core php5-xdebug
@ItsJonQ
ItsJonQ / Vagrantfile
Created August 31, 2016 01:41 — forked from JeffreyWay/Vagrantfile
Quickie vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :private_network, ip: "192.168.33.21"
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@ItsJonQ
ItsJonQ / index.html
Last active August 29, 2015 14:00
HTML 5 - Blank - Starter (Based on HTML 5 Boilerplate)
<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="public/css/main.css">