Skip to content

Instantly share code, notes, and snippets.

View markusklems's full-sized avatar

Markus Klems markusklems

View GitHub Profile
@markusklems
markusklems / gulpfile.js
Created April 9, 2016 23:26
Gulp task: replace <script src="node_modules/.../filename.js"> with <script src="lib/filename.js">
const replace = require('gulp-replace');
gulp.task('copy:index', ['clean'], function() {
gulp.src(['index.html'])
.pipe(replace(/node_modules(.*)\/(.*).js/g, 'lib/$2.js'))
.pipe(gulp.dest('dist'));
});
@markusklems
markusklems / lambda-dynamodb-scan
Created January 19, 2015 23:46
Short aws lambda sample program that scans a dynamodb table
// create an IAM Lambda role with access to dynamodb
// Launch Lambda in the same region as your dynamodb region
// (here: us-east-1)
// dynamodb table with hash key = user and range key = datetime
console.log('Loading event');
var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB({apiVersion: '2012-08-10'});
exports.handler = function(event, context) {
@markusklems
markusklems / lambda-dynamo
Last active September 24, 2021 03:48
Short aws lambda sample program that puts an item into dynamodb
// create an IAM Lambda role with access to dynamodb
// Launch Lambda in the same region as your dynamodb region
// (here: us-east-1)
// dynamodb table with hash key = user and range key = datetime
console.log('Loading event');
var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB({apiVersion: '2012-08-10'});
exports.handler = function(event, context) {
#!/bin/bash
sudo lvcreate -l 100%FREE -n riak-data ubuntu-vg
sudo mkfs.ext4 /dev/ubuntu-vg/riak-data
sudo mkdir -p /riak-data/riak
echo "/dev/ubuntu-vg/riak-data /riak-data ext4 default 0 0" | sudo tee -a /etc/fstab
sudo mount -a
sudo ln -s /riak-data/riak /var/lib
#!/bin/bash
sudo apt-get install -y xfsprogs
sudo lvcreate -l 100%FREE -n riak-data ubuntu-vg
sudo mkfs.xfs /dev/ubuntu-vg/riak-data
sudo mkdir /riak-data
echo "/dev/ubuntu-vg/riak-data /riak-data xfs noatime 0 0" | sudo tee -a /etc/fstab
sudo mount -a
sudo ln -s /riak-data/riak /var/lib
#!/bin/bash
sudo apt-get install haproxy
echo "
listen riak 0.0.0.0:8087
balance leastconn
mode tcp
option tcplog
option contstats
#!/bin/bash -ex
cat >sysctl.conf <<END_OF_FILE
vm.swappiness = 0
net.ipv4.tcp_max_syn_backlog = 40000
net.core.somaxconn=4000
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_fin_timeout = 15
@markusklems
markusklems / DBWrapper
Created July 15, 2013 15:05
Modified DBWrapper records null rows as -2 errors.
/**
* Copyright (c) 2010 Yahoo! Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You
* may obtain a copy of the License at
#!/bin/bash -ex
# Make sure the Riak cluster is stopped
sudo /usr/sbin/riak stop
# Change IP from 127.0.0.1 to whatever the eth0 ip is
my_ip=`ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'`
sed -i -e "s|127.0.0.1|$my_ip|" /etc/riak/app.config
sed -i -e "s|127.0.0.1|$my_ip|" /etc/riak/vm.args
# Get rid of old info that is stored on the node
sudo rm -rf /var/lib/riak/ring/*
#!/bin/bash -ex
# Riak install and config script snippets
# http://docs.basho.com/riak/latest/ops/building/installing/debian-ubuntu/
# http://docs.basho.com/riak/latest/tutorials/installation/Installing-on-RHEL-and-CentOS/
if which dpkg &> /dev/null; then
curl http://apt.basho.com/gpg/basho.apt.key | sudo apt-key add -
sudo bash -c "echo deb http://apt.basho.com $(lsb_release -sc) main > /etc/apt/sources.list.d/basho.list"
sudo apt-get update