Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View streamich's full-sized avatar
🕶️
married

Va Da streamich

🕶️
married
  • Switzerland
  • 17:49 (UTC +02:00)
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Webpack Bundle Analyzer</title>
<!-- viewer.js -->
<script>
@streamich
streamich / gist:a06b056cc18a69811c423bde646b5e73
Created October 4, 2017 15:30 — forked from millermedeiros/gist:891886
iPad HTML5 video quirks and hacks
/*
* Example how to preload HTML5 video on the iPad (iOS 3.2+)
* @author Miller Medeiros
* Released under WTFPL
*/
var vid = document.createElement('video');
vid.src = 'lol_catz.mp4';
document.getElementById('video-holder').appendChild(vid);
@streamich
streamich / react16-css.js
Created October 7, 2017 01:21
Dynamic CSS for React components using React's v16 element array render result
class Button extends Component {
@css`
background-color: #ff0000;
width: 320px;
padding: 20px;
border-radius: 5px;
border: none;
outline: none;
&:hover {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>For loop benchmark</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
const React = require("react");
const Lifecycles = React.createLifecycleEvents({
didMount({ setState }) {
setState({
disabled: false,
});
},
didUpdate({ inputRef }) {
if (document.activeElement !== inputRef.value) {
@streamich
streamich / async-render.md
Last active March 5, 2018 09:34
Usage cases for async generator render functions: https://github.com/reactjs/rfcs/issues/29

Load data on client and server:

async function * MyComponent() {
  yield (<div>Loading...</div>);
  const users = await fetch('/users');
  yield () =>
    <div>
      <UserList users={users} />
 {this.props.buttonLabel}

PubSub class like this:

class PubSub {
  constructor () {
    this.el = document.createElement('div');
  }

  subscribe (eventName, handler) {
 this.el.addEventListener(eventName, handler);
@streamich
streamich / gist:03d109062e4b330359dd6e11481fbd6f
Created August 31, 2018 08:12 — forked from kingbin/gist:9435292
Manually Start/Stop PostgresSQL on Mac
# Stop PostgreSQL from auto starting
sudo launchctl unload -w /Library/LaunchDaemons/com.edb.launchd.postgresql-9.3.plist
# Enable PostgreSQL to auto start
sudo launchctl load -w /Library/LaunchDaemons/com.edb.launchd.postgresql-9.3.plist
# Start postgres
$ sudo su postgres
Password:
bash-3.2$ pg_ctl -D /Library/PostgreSQL/9.3/data/ start

Specify required fields, rest will be optional.

export type Required<T, K extends keyof T> = Partial<T> & Pick<T, K>;

Specify which fields to omit.

export type Omit = Pick&gt;;

tweet-css

Smallest possible CSS-in-JS library.