Skip to content

Instantly share code, notes, and snippets.

View jkusachi's full-sized avatar

James Kusachi jkusachi

View GitHub Profile
@thomas-sivilay
thomas-sivilay / SwiftUImagePickerController.swift
Last active September 14, 2020 16:26
SwiftUI with UIImagePickerController
final class UserData: ObservableObject {
@Published var image: UIImage? = nil
}
struct ContentView: View {
@EnvironmentObject var userData: UserData
@State var pickerIsActive: Bool = false
var body: some View {
NavigationView {
@iamtmrobinson
iamtmrobinson / custom-props.tsx
Created January 8, 2018 14:49
Using custom props with a Redux form in Typescript
import * as React from 'react';
import {
Field as FormField,
InjectedFormProps,
reduxForm,
} from 'redux-form';
interface CustomProps {
customText: string;
}
@theverything
theverything / createElement.js
Last active July 7, 2017 19:48
React style create element function
function createElement(tag, props = {}, ...children) {
const element = document.createElement(tag);
const listeners = [];
Object.keys(props).forEach((key) => {
if (key.slice(0, 2) === 'on') {
const event = key.slice(2).toLowerCase();
element.addEventListener(event, props[key]);
listeners.push(() => element.removeEventListener(event, props[key]));
} else if (key === 'ref' && typeof props[key] === 'function') {
@jkusachi
jkusachi / destructuring.js
Created March 31, 2016 21:48
Playing with Destructuring
var master = {
data: {
values: [1, 2, 3],
labels: ["one", "two", "three"],
food: {
name: "pizza"
},
groups: [
{
brand: 'zillow',
@Gozala
Gozala / Readme.md
Last active March 19, 2020 15:09
WTF Flow ?

WTF Flow

[Flow][] static type checker is a wonderful attempt to bring [algebric data types][] to JS. It is still fairly new project and there for has few WTFs that can pull you down the rabbit hole. This document is attempt to document things that may seem like a WTF from the perspective of JS developer who tries to employ static type checker, or in other words, some items on the list may be very subjective & based on the background of the writer.

Polymorphic type that is a function

It is very likely that one will wind up using [Polymorphic functions][] to solve a more general problem. And if you define type alias for such a function you may be puzzled what is the right syntax should be used for such type definition.

Let's start with:

@ryanseddon
ryanseddon / cli.bash
Created October 9, 2015 05:44
Mocha compiler for css-module support in tests using sass
mocha --compilers js:babel/register,js:./test/css-modules-compiler.js --recursive -w
@wbotelhos
wbotelhos / phantomjs_intaller.sh
Last active December 12, 2019 12:08
Installing PhantomJS 1.9 on Ubuntu 12/14.xx x64/x86
#!/bin/bash
sudo apt-get remove phantomjs
sudo unlink /usr/local/bin/phantomjs
sudo unlink /usr/local/share/phantomjs
sudo unlink /usr/bin/phantomjs
cd /usr/local/share
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 18, 2024 10:01
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/