Skip to content

Instantly share code, notes, and snippets.

Jarno Rantanen jareware

View GitHub Profile
@jareware
jareware / full-screen.html
Created Oct 6, 2017
Grafana full screen "plugin"
View full-screen.html
<button id="enter-full-screen">Enter full screen</button>
<style>
#enter-full-screen {
display: block;
margin: 60px auto;
padding: 30px 70px;
background: #464545;
border: 1px solid #636363;
}
@jareware
jareware / README.md
Last active Aug 10, 2018
Raspberry Pi -based sensor station
View README.md

Raspberry Pi -based sensor station

This is mostly documentation for myself. Feel free to use any of it if it helps, though.

Hardware

@jareware
jareware / package-json-engines.md
Last active Mar 15, 2019
Enforcing the engines property of package.json
View package-json-engines.md

Document your target environment with:

"engines": {
  "npm": ">=3.3.12 <4",
  "node": ">=5.5.0 <6"
},

Then install this:

"devDependencies": {
View understanding-immutable-record.md

Understanding Immutable.Record

Functional programming principles and with it immutable data are changing the way we write frontend applications. If the recent de-facto frontend stack of React and Redux feels like it goes perfectly together with immutable data, that's because it's specifically designed for that.

There's several interesting implementations of immutable data for JavaScript, but here I'll be focusing on Facebook's own Immutable.js, and specifically on one of its lesser known features, Records.

Why Records?

Immutable.js provides a beautiful, Clojure-inspired API for dealing with abstract Collections and Sequences, and several concrete data structur

View Component.js
export default renderFromStores(
[ 'fooStore', 'barStore' ],
({ fooStore, barStore, bazActions }) => (
<div>
Hola {fooStore.getName()}!
<button onClick={bazActions.doStuff}>Cheap</button>
<button onClick={() => bazActions.doStuffWith(fooStore.getName())}>Expensive</button>
</div>
@jareware
jareware / README.md
Last active Jun 7, 2018
Quick PSA on icon fonts and ligatures
View README.md

Long Live Icon Fonts!

or, a Quick PSA on icon fonts and ligatures.

tl;dr: keep using icon fonts, they are nice, just enable ligatures

These are my talking notes at the http://wwweeklies.com/ on 2015-12-04:

View eslint-instanceof-hazard.js
module.exports = function(context) {
'use strict';
return {
BinaryExpression: function(node) {
if (node.operator === 'instanceof' && node.left.type === 'UnaryExpression' && node.left.operator === '!') {
context.report(node, "Check dangerous instanceof use (! has higher precedence than instanceof)");
}
}
View freaklies-goes-es6.md

Freaklies goes ES6

Classes

Classes are purely syntactic sugar:

class Animal {
  constructor(name) {
    this.name = name;
@jareware
jareware / transparent-boot2docker-on-os-x.md
Last active Jun 7, 2018
Transparent boot2docker on OS X for a native-Linux-like Docker experience
View transparent-boot2docker-on-os-x.md

Transparent boot2docker on OS X

This is how you can autorun boot2docker on boot, so that you can use docker as you would on Linux, without ever* knowing that the daemon's not running locally.

  1. Install VirtualBox & boot2docker (obviously)
  2. Create a startup script with Automator
  3. Put in /usr/local/bin/boot2docker up && /usr/local/bin/boot2docker shellinit > ~/.boot2docker-shellinit.sh
  4. Add echo "export DOCKER_IP=$(boot2docker ip 2>/dev/null)" >> ~/.boot2docker-shellinit.sh if you want the non-standard but very-convenient DOCKER_IP env-var as well (thanks for the suggestion @city41!)
  5. Update your .profile or equivalent file with source ~/.boot2docker-shellinit.sh
  6. Reboot your machine
@jareware
jareware / s3-curl-backups.md
Last active Feb 21, 2019
Simple, semi-anonymous backups with S3 and curl
View s3-curl-backups.md

⇐ back to the gist-blog at jrw.fi

Simple, semi-anonymous backups with S3 and curl

Backing stuff up is a bit of a hassle, to set up and to maintain. While full-blown backup suites such as duplicity or CrashPlan will do all kinds of clever things for you (and I'd recommend either for more complex setups), sometimes you just want to put that daily database dump somewhere off-site and be done with it. This is what I've done, with an Amazon S3 bucket and curl. Hold onto your hats, there's some Bucket Policy acrobatics ahead.

There's also a tl;dr at the very end if you just want the delicious copy-pasta.

Bucket setup

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.