Skip to content

Instantly share code, notes, and snippets.

View asbjornenge's full-sized avatar
Swinging madly across the sun.

Asbjorn Enge asbjornenge

Swinging madly across the sun.
View GitHub Profile
@asbjornenge
asbjornenge / bcoin-neutrino-docker.md
Last active February 7, 2018 21:49
bcoin playing nice with neutrino via docker

A short demo of neutrino support in bcoin ⚡ 🎉

Prerequisites

In order to test our neutrino node, we need to mine a few test-coins we can send. For that we need the primary wallet address of our fullnode.

By default bcoin stores it's configuration in ~/.bcoin (/root/.bcoin inside the container). We want this configuration to stay consisten between container restarts, so we mount it to a temporary path on our local filesystem (/tmp/bcoin).

docker run --rm -v /tmp/bcoin:/root/.bcoin --name bcoin -d asbjornenge/bcoin:neutrino ./bin/bcoin --network=simnet
@asbjornenge
asbjornenge / update-stack.js
Created November 21, 2017 20:51
Update the images for a docker stack file from swarm
#!/usr/bin/env node
const fs = require('fs')
const { execSync } = require('child_process');
const args = process.argv.slice(2)
const stack = args[0]
const stackfile = stack+'.yml'
const SWARM_SERVICES_RAW = execSync(`docker service ls | grep ${stack} | awk '{print $5}'`)
const STACKFILE_SERVICES_RAW = execSync(`cat ${stackfile} | grep image | awk '{print $2}'`)
let swarm_services = SWARM_SERVICES_RAW.toString().split('\n')
kernel:
image: "linuxkit/kernel:4.9.x"
cmdline: "console=ttyS0 console=tty0 page_poison=1"
init:
- linuxkit/init:63eed9ca7a09d2ce4c0c5e7238ac005fa44f564b
- linuxkit/runc:b0fb122e10dbb7e4e45115177a61a3f8d68c19a9
- linuxkit/containerd:18eaf72f3f4f9a9f29ca1951f66df701f873060b
- linuxkit/ca-certificates:5fc6ba7f91534ddbfef975404c33e44581e6ed7a
onboot:
- name: sysctl
@asbjornenge
asbjornenge / app.js
Created August 4, 2015 13:01
🔥 fireflux 🚀
import React from 'react'
import { FireStarter } from './fireflux'
import Component from './component'
@FireStarter('https://fireflux.firebaseio.com/')
class App extends React.Component {
render() {
return <Component />
}
}
@asbjornenge
asbjornenge / app.js
Created April 1, 2015 19:43
React ScopeSyle InjectStyle
import React from 'react'
import { InjectStyle } from 'react-scopestyle'
import Component from './component'
React.render(
<div className="app">
<InjectStyle />
<Component />
</div>
, document.body)
@asbjornenge
asbjornenge / component.js
Last active August 29, 2015 14:18
React ScopeStyle
import React from 'react'
import ScopeStyle from 'react-scopestyle'
let css = "div { color:pink; }"
export default class MyScopeStyleComponent extends React.Component {
render() {
return (
<ScopeStyle style={css}>
<div>yolo</div>
@asbjornenge
asbjornenge / stylusify.js
Last active August 29, 2015 14:16
Stylus browserify transform 🚀
var transformTools = require('browserify-transform-tools')
var stylus = require('stylus')
module.exports = transformTools.makeStringTransform(
"stylusify",
{
includeExtensions: [".styl"]
},
function (content, opts, done) {
stylus(content).render(function(err, css) {
@asbjornenge
asbjornenge / imgify.js
Created March 6, 2015 08:43
Browserify img -> base64 data uri transform
var through = require('through2');
var i = -1
var head = function(type) { i++; return i == 0 ? 'module.exports = "data:image/'+type+';base64,' : '' }
var tail = function() { return '"' }
var isImg = function(file) {
return (/\.((lit)?gif|png|jpg|jpeg)$/).exec(file);
}
module.exports = function (file) {
if (!isImg(file)) return through()
@asbjornenge
asbjornenge / Router.js
Created February 20, 2015 22:44
Tiny React Router
import React from 'react'
import assign from 'react/lib/Object.assign'
import Route from 'route-parser'
export default class Router extends React.Component {
constructor(props) {
super(props)
let routes = Object.keys(this.props.routes).map((route) => {
return { route : new Route(route), handler : this.props.routes[route] }
})
@asbjornenge
asbjornenge / dnspop.js
Created November 23, 2014 08:42
Docker Rainbow-dns Polulator
#!/usr/bin/env node
var request = require('request')
var Docker = require('dockerode')
var swarm = Docker({host: 'http://docker.host', port: 4243})
var dnshost = 'http://dns.host:8080'
var interval = 2000
var loop = function () {
getContainers(function (currContainer) {
updateDns(currContainer)