Skip to content

Instantly share code, notes, and snippets.

@ooade
ooade / AsyncComponent.jsx
Created January 21, 2017 10:30 — forked from scurker/AsyncComponent.jsx
Async Component in Preact
import { h, Component } from 'preact';
class AsyncComponent extends Component {
constructor() {
super();
this.state = { loading: true };
this.getAsyncState = this.getAsyncState.bind(this);
this.update = this.update.bind(this);
}
@ooade
ooade / split-point.js
Created January 17, 2017 09:45 — forked from developit/split-point.js
A couple of variants for preact split points
import { h, Component } from 'preact';
/**
* <SplitPoint load={require('bundle?lazy!./foo')} fallbackContent={(
* <div class="loading" />
* )} />
*/
class SplitPoint extends Component {
componentWillMount() {
let cb = this.linkState('child'),
@ooade
ooade / README.md
Last active January 14, 2017 12:32
My CS50 Hackerrank Solutions

Hello World! My solutions to the contest are posted here!

@ooade
ooade / README.md
Last active January 17, 2017 18:57
Hackerrank Week Of Code 28

This file contains hackerrank's week of code 28 solutions 😄

@ooade
ooade / Advanced PigLatin.js
Last active October 10, 2017 01:26
CodeWar Challenges
function translate(sentence) {
const vowels = 'aeiou'.split('');
const isUpper = (char => char === char.toUpperCase());
const pigLatin = ((str, i = 0) => {
if (vowels.includes(str[0])) {
return i === 0 ? str + 'way' : str + 'ay';
}
@ooade
ooade / package.json
Created November 3, 2016 05:53
Express serving production files
{
"name": "express-without-eject",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-scripts": "0.7.0"
},
"dependencies": {
"express": "^4.14.0",
"react": "^15.3.2",
@ooade
ooade / production_ready.js
Last active November 4, 2016 07:02
Express with webpack production ready
const express = require('express');
const PORT = process.env.PORT || 3000;
// Initialize express
const app = express();
// Serve the build file
app.use('/', express.static(process.cwd() + '/build'));
@ooade
ooade / server.dev.js
Created November 3, 2016 05:29
Express with webpack
// Grab dependencies
const express = require('express');
const chalk = require('chalk'); // Chalk was added by create-react-app, use only on the dev side
const webpack = require('webpack');
const webpackDevServer = require('webpack-dev-server');
// load up our environment variables
require('dotenv').load();
const PORT = process.env.PORT || 3000;
@ooade
ooade / package.json
Created November 3, 2016 04:23
Express...
{
"name": "express-without-eject",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-scripts": "0.7.0"
},
"dependencies": {
"express": "^4.14.0"
},
@ooade
ooade / server.dev.js
Last active November 3, 2016 04:14
Initialize express without webpack
const express = require('express');
// Chalk was added by create-react-app, use only on the dev side
const chalk = require('chalk');
// Initialize express
const app = express();
const PORT = process.env.PORT || 3000;
// Start up our express server
app.listen(PORT, (error) => {