Skip to content

Instantly share code, notes, and snippets.

Avatar

James Kusachi jkusachi

View GitHub Profile
@thomas-sivilay
thomas-sivilay / SwiftUImagePickerController.swift
Last active Sep 14, 2020
SwiftUI with UIImagePickerController
View SwiftUImagePickerController.swift
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 Jan 8, 2018
Using custom props with a Redux form in Typescript
View custom-props.tsx
import * as React from 'react';
import {
Field as FormField,
InjectedFormProps,
reduxForm,
} from 'redux-form';
interface CustomProps {
customText: string;
}
@theverything
theverything / createElement.js
Last active Jul 7, 2017
React style create element function
View createElement.js
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 Mar 31, 2016
Playing with Destructuring
View destructuring.js
var master = {
data: {
values: [1, 2, 3],
labels: ["one", "two", "three"],
food: {
name: "pizza"
},
groups: [
{
brand: 'zillow',
@Gozala
Gozala / Readme.md
Last active Mar 19, 2020
WTF Flow ?
View Readme.md

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 Oct 9, 2015
Mocha compiler for css-module support in tests using sass
View cli.bash
mocha --compilers js:babel/register,js:./test/css-modules-compiler.js --recursive -w
@wbotelhos
wbotelhos / phantomjs_intaller.sh
Last active Dec 12, 2019
Installing PhantomJS 1.9 on Ubuntu 12/14.xx x64/x86
View phantomjs_intaller.sh
#!/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
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@ScottPhillips
ScottPhillips / .htaccess
Created Feb 2, 2012
Common .htaccess Redirects
View .htaccess
#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/
You can’t perform that action at this time.