Skip to content

Instantly share code, notes, and snippets.

View klaemo's full-sized avatar

Clemens Stolle klaemo

View GitHub Profile
@klaemo
klaemo / index.jsx
Created October 11, 2016 14:28
preact + AutoSizer
// The problem looks like a race condition, because I'm doing the following. isLoading can change pretty quickly
{!isLoading && <AutoSizer disableWidth>{({ height }) => <div>{height}</div>}</AutoSizer>}
@klaemo
klaemo / initial.sh
Last active March 8, 2016 02:00
initial ubuntu server setup
printf '\e[1;34m%b\e[m' "\nUpdating the system...\n"
apt-get -y -qq update
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
NEW_USER=${1:-admin}
SSH_PORT=${2}
if [ ! -d /home/${NEW_USER} ]; then
printf '\e[1;34m%b\e[m' "\nCreating user '$NEW_USER'...\n"
adduser --gecos "" $NEW_USER
@klaemo
klaemo / package.json
Created January 11, 2016 17:50
npm run description
{
"description": "fancy npm run",
"version": "1.0.0",
"scripts": {
"build": {
"title": "Build our js",
"cmd": "browserify index.js > foo.js"
},
"start": {
"title": "Start dev server",
@klaemo
klaemo / haproxy.log
Created December 18, 2015 14:55
Couch logs
[WARNING] 351/144441 (27) : config : log format ignored for frontend 'http-in' since it has no log address.
[WARNING] 351/144441 (27) : Health check for server couchdbs/couchdb1 failed, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms, status: 0/2 DOWN.
[WARNING] 351/144441 (27) : Server couchdbs/couchdb1 is DOWN. 2 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[WARNING] 351/144443 (27) : Health check for server couchdbs/couchdb2 failed, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms, status: 0/2 DOWN.
[WARNING] 351/144443 (27) : Server couchdbs/couchdb2 is DOWN. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[WARNING] 351/144444 (27) : Health check for server couchdbs/couchdb3 failed, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms, status: 0/2 DOWN.
[WARNING] 351/144444 (27) : Server couchdbs/couchdb3 is DOWN. 0 active and
@klaemo
klaemo / gist:5382743
Created April 14, 2013 13:30
nodejitsu error
info: Creating snapshot 0.8.0-7
info Uploading: [=============================] 100%
info: Updating app print-io.de
info: Activating snapshot 0.8.0-7 for print-io.de
info: Starting app print-io.de
error: Error running command deploy
error: Nodejitsu Error (500): Internal Server Error
error:
error: There was an error while attempting to start the app
error: Error spawning drone
@klaemo
klaemo / gist:3710789
Created September 12, 2012 23:37
v8 deopt
// the function:
Helpers.prototype.round = function (num, decimals) {
decimals = decimals || this.precision
return Math.round( num * Math.pow(10, decimals) ) / Math.pow(10, decimals)
}
// snippet of the --trace-deopt output
**** DEOPT: Helpers.round at bailout #9, address 0x0, frame size 8
@klaemo
klaemo / doc.json
Created April 1, 2012 16:15
sample result file
{
"hasThumbnail": true,
"result": {
"solidTone": {
"blk": {
"name": "Black",
"actDens-dE": [
[
1.698,
3.684
@klaemo
klaemo / gist:1860089
Created February 18, 2012 16:34
express route conditional response
app.get('/users', function(req, res){
if (req.xhr) {
// respond with the each user in the collection
// passed to the "user" view
res.partial('user', users);
} else {
// respond with layout, and users page
// which internally does partial('user', users)
// along with other UI
res.render('users', { users: users });
@klaemo
klaemo / couch-stub.js
Created November 17, 2011 20:25
klaemo's couch problem
// this is a very simplified version of what's going on in my app
// First I parse some CSV file (into valid JSON)
parseFile(myfile, function(err, fileJSON) {
if(err) {
throw err;
} else {
// db is the connection to my couch server
db.save(fileJSON, function(err, response) {
var Starplot = require('./starplot.js')
var plot = new Starplot()
plot.draw(foo)