Skip to content

Instantly share code, notes, and snippets.

View jackboberg's full-sized avatar

Jack Boberg jackboberg

View GitHub Profile
@jackboberg
jackboberg / script-template.sh
Last active October 3, 2024 16:54 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
Script description here.
@jackboberg
jackboberg / immutable-array.js
Created December 16, 2017 09:04
immutable array functions for ES6
// https://twitter.com/lukejacksonn/status/928244319760220160
module.exports = {
clone: x => [...x],
push: y => x => [...x, y],
pop: x => x.slice(0, -1),
unshift: y => x => [y, ...x],
shift: x => x.slice(1),
sort: f => x => [...x].sort(f),
delete: i => x => [...x.slice(0, i), ...x.slice(i + 1)],
@jackboberg
jackboberg / npm-update.sh
Last active July 12, 2017 20:11
Update global npm inside a node docker container
cd /tmp && \
npm install npm && \
rm -rf /usr/local/lib/node_modules && \
mv /tmp/node_modules /usr/local/lib/ && \
cd && \
npm install npm -g # update bin path for npx
@jackboberg
jackboberg / example.js
Last active April 11, 2017 20:39
asynchronously iterate on mongodb records
const { MongoClient } = require('mongodb')
const MongoSeries = require('./mongo-run-series')
const { host } = process.env // mongodb://localhost:27017/database
const task = (doc, done) => {
// do something async with the mongodb document
done(null, {})
}
@jackboberg
jackboberg / App
Created February 10, 2017 20:03
Modified ./src/App.js from create-react-app
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
render() {
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
# ./sites-enabled/config
server {
listen 8080;
server_name helloxervo-96020.app.xervo.io;
root /mnt/app/build;
index index.html index.htm;
# single page app routing
location /.+\..+ {
@jackboberg
jackboberg / populator.js
Created December 22, 2016 15:23
connects to a mongo db and randomly populates it with data
/**
* populator
*
* connects to a db and randomly populates it with data
*/
const MONGO_URL = 'mongodb://user:[email protected]:27017/db_name'
const mongoose = require('mongoose')
const random = require('mongoose-simple-random')
@jackboberg
jackboberg / deploy-meteor.sh
Last active October 23, 2015 14:27 — forked from fiveisprime/quick-start
Modulus Meteor Quickstart
#!/usr/bin/env bash
meteor create --example leaderboard
modulus project create leaderboard -r node.js -s 512
modulus env set ROOT_URL $(modulus project list | grep leaderboard | awk '{print $4}') -p leaderboard
modulus addons add mongo:base -p leaderboard
modulus deploy -p leaderboard
var os = require('os')
var cliopts = require('cliclopts')
var parseArgs = require('minimist')
var rc = require('rc')
var pkg = require('../package')
var opts = require('./options')
var clopts = cliopts(opts.default)
@jackboberg
jackboberg / gist:382197e26bf435de797e
Last active August 29, 2015 14:09
{ parse: true } not passed to children
var State = require('ampersand-state');
var A = State.extend({
props: { n: 'number' },
parse: function (attrs) {
attrs.n = parseInt(attrs.n, 10);
return attrs;
}
});