Skip to content

Instantly share code, notes, and snippets.

@egbertp
egbertp / fleetui.service
Created January 14, 2015 21:51
CoreOS FleetUI service file
[Unit]
Description=FleetUI
After=docker.service
[Service]
User=core
TimeoutStartSec=20m
EnvironmentFile=/etc/environment
ExecStartPre=-/usr/bin/docker kill fleet-ui
ExecStartPre=-/usr/bin/docker rm fleet-ui
@egbertp
egbertp / send_SMS.php
Created January 20, 2015 15:57
Wholla!
$userPhone = 'xxxxxxxxx';
$userIdentity = strtolower(urlencode(sha1($userPhone, true)));;
$userName = 'admin';
$password = 'xxxxxxxxxxx';
$debug = true;
$w = new WhatsProt($userPhone, $userIdentity, $userName, $debug);
$w->Connect();
$w->LoginWithPassword($password);
while($w->pollMessage());
@egbertp
egbertp / rebalance.sh
Created May 13, 2015 09:06
Rebalance docker within fleet
#!/bin/bash -e
fleetctl list-units -fields=unit -no-legend | grep -v -e '@\|deis' | cut -d. -f1-2 | sort | uniq | while read name ; do
max=$(fleetctl list-machines -no-legend | wc -l)
count=$(fleetctl list-units -fields=unit -no-legend | grep -e "^$name" | wc -l)
if [ $count -gt $max ]; then
echo "Skipping $name, there are $count deployed units on $max fleet machines"
else
echo "Processing $name"
fleetctl list-units -fields=unit -no-legend | grep -e "^$name" | while read service; do
others=$(echo $service | cut -d. -f1-2)
@egbertp
egbertp / memcached.rb
Last active September 20, 2015 12:36
Service file memcached.rb that communicates with the memcached servers defined in ENV["MEMCACHED_SERVERS"]
# Add to your Gemfile: gem 'activesupport', :require => false
require 'active_support/inflector'
class Memcached
extend ::ActiveSupport::Inflector # Needed for .parameterize
def initialize
# [Egbert Pot - 2015-09-20 14:23:02]
# e.g.: export MEMCACHED_NAMESPACE=feed-supplier
@egbertp
egbertp / Install_Syncthing.md
Created November 26, 2015 13:43
Install Syncthing

Install

$ brew install syncthing

WebGUI

http://127.0.0.1:8384/

Install

$ brew install syncthing

WebGUI

http://127.0.0.1:8384/

@egbertp
egbertp / postgres.rb
Created August 20, 2013 11:20
Relevant part of /config/deploy/recipes/postgres.rb AFTER the database was succesfully created (so after cap production deploy:setup and cap production deploy:cold) Best of luck!
# set_default(:postgresql_host, "localhost")
# set_default(:postgresql_user) { application }
# set_default(:postgresql_password) { Capistrano::CLI.password_prompt "PostgreSQL Password: " }
# set_default(:postgresql_database) { "#{application}_production" }
namespace :postgresql do
# desc "Create a database for this application."
# task :create_database, roles: :db, only: {primary: true} do
# run %Q{#{sudo} -u postgres psql -c "create user #{postgresql_user} with password '#{postgresql_password}';"}
# run %Q{#{sudo} -u postgres psql -c "create database #{postgresql_database} owner #{postgresql_user};"}
@egbertp
egbertp / ImageUploader.rb
Created November 20, 2013 22:42
Carrierwave ImageUploader that uploads images to Rackspace Files
# encoding: utf-8
class ImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
include CarrierWave::MiniMagick
include CarrierWaveDirect::Uploader
# process :set_content_type
@egbertp
egbertp / git-cheat-sheet.md
Created February 10, 2016 17:42
Git cheat sheet

Remove remote tag

$ git push origin :refs/tags/deploy

Create tags

Annotated tags

@egbertp
egbertp / Platform161-API.rb
Created February 20, 2013 14:44
This ruby script connects to the Platform161 API. I've used this functionality to extract data from Platform161
##############################################################################
#
# Author: Egbert Pot | WebOak | www.weboak.nl
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,