Skip to content

Instantly share code, notes, and snippets.

View jareware's full-sized avatar

Jarno Rantanen jareware

View GitHub Profile
@jareware
jareware / full-screen.html
Created October 6, 2017 15:40
Grafana full screen "plugin"
<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 August 10, 2018 12:06
Raspberry Pi -based sensor station

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 October 30, 2020 18:36
Enforcing the engines property of package.json

Document your target environment with:

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

Then install this:

"devDependencies": {

Important: At the time of writing (2019-11-11) Immutable.js is effectively abandonware, so I can no longer recommend anyone to follow the advice given here. I'll leave the article here for posterity, since it's still getting some traffic.

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 i

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 June 7, 2018 04:12
Quick PSA on icon fonts and ligatures

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:

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)");
}
}

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 November 8, 2019 14:40
Transparent boot2docker on OS X for a native-Linux-like Docker experience

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 May 11, 2024 23:39
Simple, semi-anonymous backups with S3 and curl

⇐ 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