Skip to content

Instantly share code, notes, and snippets.

View patrickkeller's full-sized avatar

Patrick Keller patrickkeller

  • Switzerland
View GitHub Profile
@patrickkeller
patrickkeller / rbenv-install-system-wide.sh
Created May 24, 2012 10:39 — forked from devsigner/rbenv-install-system-wide.sh
rbenv install ruby 1.9.3-p125 on Debian 6 Squeeze
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential git-core curl libssl-dev \
libreadline5 libreadline5-dev \
zlib1g zlib1g-dev \
libmysqlclient-dev \
libcurl4-openssl-dev \
libxslt-dev libxml2-dev
@patrickkeller
patrickkeller / gist:2941129
Created June 16, 2012 11:54 — forked from trey/gist:1739889
Get Bootstrap's fancy Glyphicons working in Rails

Well, to get Bootstrap working, first install [Less Rails Bootstrap][lrb].

Then create a button with a [fancy icon][fi] like so:

<%= link_to raw('<i class="icon-trash icon-white"></i>'), card, confirm: 'Are you sure?', method: :delete, :class => 'btn btn-danger' %>

Note that you have to link to raw to get it to not escape the HTML.

@patrickkeller
patrickkeller / installation.sh
Created June 29, 2012 06:38 — forked from mikhailov/installation.sh
nginx+passenger (real production config)
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
$ tar xzvf openssl-1.0.1c.tar.gz && rm -f openssl-1.0.1c.tar.gz
@patrickkeller
patrickkeller / default.vcl.pl
Created November 5, 2012 17:07 — forked from bmarini/default.vcl.pl
A good varnish config for a Rails app
# https://www.varnish-cache.org/docs/2.1/tutorial/vcl.html
# https://www.varnish-cache.org/trac/wiki/VCLExamples
# Summary
# 1. Varnish will poll the backend at /health_check to make sure it is
# healthy. If the backend goes down, varnish will server stale content
# from the cache for up to 1 hour.
# 2. Varnish will pass X-Forwarded-For headers through to the backend
# 3. Varnish will remove cookies from urls that match static content file
# extensions (jpg, gif, ...)
@patrickkeller
patrickkeller / set_up_backup_script.sh
Created November 6, 2012 11:20
Avaya ACR Postgres Set-Up-Backup-Script
#!/bin/bash
# add new user to the system. the backups will be saved in the home dir
userdel backup
useradd -g users -u 1003 -m -s /bin/bash backup
passwd backup # ask for password
echo "User backup with defined password sucessfully added"
###
development: &defaults
# Configure available database sessions. (required)
sessions:
# Defines the default session. (required)
default: &default_session
# Defines the name of the default database that Mongoid can connect to.
# (required).
database: delight_development
# Provides the hosts the default session can connect to. Must be an array
# of host:port pairs. (required)
@patrickkeller
patrickkeller / mode.rb
Created April 12, 2013 20:45
tire custom filter settings model
settings analysis: {
analyzer: {
custom_analyzer: {
tokenizer: [ "whitespace", "lowercase" ],
filter: [ "ngram_filter", "word_delimiter_filter" ],
type: "custom"
}
},
filter: {
ngram_filter: {
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@patrickkeller
patrickkeller / backup_mongo.sh
Last active December 17, 2015 03:38
MongoDB Backupscript
#!/bin/sh
backup_source="/var/mongobackup/db"
backup_dest="/var/mongobackup"
now=$(date +"%d_%m_%Y")
filename="db_prod_back_$now.tgz"
# make a dump of all mongodbs
mongodump -o "/var/mongobackup/"
# remove old backup
rm "/var/mongobackup"/*.tgz
@patrickkeller
patrickkeller / backup_mongo_daily.sh
Created May 19, 2013 13:48
Get MongoDB backup from backup_mongo script
#!bin/sh
keyfile=""
remote_source="/var/mongobackup/*.tar.gz"
day_of_week="$(date +'%A')"
backup_dest="/home/apbackup/web4fm/${day_of_week}"
tmp_dest="/tmp/"
# scp copy
scp -i $keyfile deploy@80.74.150.148:$remote_source $tmp_dest
# remove old backup