Skip to content

Instantly share code, notes, and snippets.

View apendua's full-sized avatar

Tomasz Lenarcik apendua

View GitHub Profile
@apendua
apendua / gist:0f175c05b9eb4af4a02f
Last active August 29, 2015 14:01
meteor installation script which does not copy launcher to /usr/local/bin
#!/bin/sh
# This is the Meteor install script!
# Are you looking at this in your web browser, and would like to install Meteor?
# Just open up your terminal and type:
#
# curl https://install.meteor.com/ | sh
#
# Meteor currently supports:
# - Mac: OS X 10.6 and above

#Covert Data URI to Blob

@apendua
apendua / install-nebula.sh
Last active August 29, 2015 14:06
install-nebula.sh
#!/bin/bash
if [ ! -e $HOME/.meteor ];
then
sudo curl https://install.meteor.com/ | sh
fi
sudo apt-get update
sudo apt-get install -y python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
@apendua
apendua / fontSize.js
Created February 22, 2017 10:40
Calculate approximate font size
// Based on:
// http://stackoverflow.com/questions/118241/calculate-text-width-with-javascript
export function fontSize (el = document.body) {
const test = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
const div = document.createElement('div');
div.style.position = 'absolute';
div.style.visiblity = 'hidden';
div.style.height = 'auto';
div.style.width = 'auto';
div.style.whiteSpace = 'nowrap';
@apendua
apendua / worker.js
Created March 4, 2017 12:08
A simple pattern for concurrent workers using observers from Meteor collections
import { Meteor } from 'meteor/meteor';
import { Tasks } from '/imports/common/collections';
// The workerId should be unique, and at the same time it should persist
// across server restarts, because otherwise we may end up with unfinished tasks falling into limbo.
const workerId = process.env.WORKER_ID || 'theOnlyWorker';
const tasksInProgress = {};
const makeTaskProcessor = execute => (task) => {
if (!task.workerId) {