Skip to content

Instantly share code, notes, and snippets.

View jsalonen's full-sized avatar

Jaakko Salonen jsalonen

View GitHub Profile
@jsalonen
jsalonen / outrun.js
Last active August 29, 2015 13:57
Out Run - Performance Optimized Implementation with JavaScript on node.js
'use strict';
var fs = require('fs'),
instream = fs.createReadStream(process.argv[2]),
bufferSize = 16384,
buffer1 = new Int32Array(bufferSize),
buffer2 = new Int32Array(bufferSize),
seedReader = true,
_a = 0,
_token = -1,
_tokens = 1;
main = lift shittyClock (every second)
isBroken t =
mod (floor (inSeconds t)) 2 == 0
shittyClock t =
if isBroken t then plainText <| show "broken" else clock t
clock t = collage 400 400 [ filled lightGrey (ngon 12 110)
{
"name": "my-bower-project",
"version": "0.0.0",
"private": true,
"dependencies": {
"angularjs": "~1.3.15",
"jquery": "~2.1.3",
"lodash": "~3.6.0"
}
}
trained with manners
very boring is console
very sher is boring
very smile like 'LOL'
very polite like 'hello'
such smile much like happy people are
wow
very happy is 'world'
such no manners anymore
wow
@jsalonen
jsalonen / start-docker.sh
Last active April 11, 2016 09:06
Docker machine + docker compose startup script
docker-machine start default
eval "$(docker-machine env default)"
docker-compose start
import React, { Component } from 'react';
class Counter extends Component {
constructor(props) {
super(props);
this.state = {
count: 0
};
}
import React, { useState } from 'react';
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>You clicked {count} times</p>
<button onClick={() => setCount(count + 1)}>
Click me
class Clock extends Component {
componentDidMount() {
this.clockIntervalId = window.setInterval(() => {
console.log('tick');
}, 1000)
}
componentWillUnmount() {
window.clearInterval(this.clockIntervalId);
}
function Clock() {
React.useEffect(() => {
const clockIntervalId = window.setInterval(() => {
console.log('tick');
}, 1000);
return () => {
window.clearInterval(clockIntervalId);
};
}, []);
function BigClock() {
function makeClock(intervalInMs) {
return () => {
const clockIntervalId = window.setInterval(() => {
console.log('tick', intervalInMs);
}, intervalInMs);
return () => {
window.clearInterval(clockIntervalId);
console.log('disabled clock')