Skip to content

Instantly share code, notes, and snippets.

View larsar's full-sized avatar

Lars Preben Sørsdahl larsar

View GitHub Profile
Steps to install and run PostgreSQL 9.3 using Homebrew (Mac OS X)
(if you aren't using version 9.2.4, change to the correct version)
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
mv /usr/local/var/postgres /usr/local/var/postgres92
brew upgrade postgresql
initdb /usr/local/var/postgres -E utf8
pg_upgrade -b /usr/local/Cellar/postgresql/9.2.4/bin -B /usr/local/Cellar/postgresql/9.3.0/bin -d /usr/local/var/postgres92 -D /usr/local/var/postgres
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
# config/initializers/char_converter.rb
require 'uri'
module Support
class CharConverter
def initialize(app)
@app = app
end
# config/initializers/char_converter.rb
require 'uri'
module Support
class CharConverter
SANITIZE_ENV_KEYS = [
"HTTP_COOKIE", # bad cookie encodings kill rack: https://github.com/rack/rack/issues/225
"HTTP_REFERER",
"PATH_INFO",
@larsar
larsar / gist:bc43b7f508b87fe8a9e1
Created June 7, 2014 07:26
Regex for replacing global variable with let in specs in RubyMine.
Search: @(\S*)\s=
Replace: let(:$1) {
/* global _ */
/*
* Complex scripted Logstash dashboard
* This script generates a dashboard object that Kibana can load. It also takes a number of user
* supplied URL parameters, none are required:
*
* index :: Which index to search? If this is specified, interval is set to 'none'
* pattern :: Does nothing if index is specified. Set a timestamped index pattern. Default: [logstash-]YYYY.MM.DD
@larsar
larsar / git_workflow.txt
Created April 3, 2011 11:16
My Git development workflow
# Based on http://reinh.com/blog/2009/03/02/a-git-workflow-for-agile-teams.html
# Start working on new feature/fix
git checkout -b <feature/fix branch name>
# On a regular basis, rebase against upstream
git fetch origin master
git rebase origin/master
# When feature/fix is finished, rebase and squash commits into fewer
@larsar
larsar / gist:1362913
Created November 13, 2011 23:34
Set textmate as Git editor
git config --global core.editor "mate -w"
@larsar
larsar / user_larstobi.pp
Created November 14, 2011 13:01 — forked from larstobi/user_larstobi.pp
Puppet user resource
class user_larstobi {
$user = "larstobi"
group { "$user":
ensure => present,
allowdupe => false,
}
user { "$user":
comment => "Lars Tobias Skjong-Borsting",
gid => "$user",
@larsar
larsar / gitolite.pp
Created November 14, 2011 13:02 — forked from larstobi/gitolite.pp
Gitolite manifest
file {
"/var/spool/gitolite":
ensure => directory,
owner => "git",
group => "git";
"admin.pub":
ensure => present,
path => "/var/spool/gitolite/admin.pub",
content => "ssh-rsa AAAAB3NzaC1...bmhLcxczOQ== admin@example.net";
@larsar
larsar / selinux-create-policy
Created November 14, 2011 14:46
Creating SELinux policy for failing stuff
For instance Puppet server will not start under RHEL SELinux. Try to start it, then run the following script. Continue this cycle until it starts. It will probably work for different SELinux challenges as well.
The script requires:
$yum install policycoreutils-python
cd /tmp && \
cat /var/log/audit/audit.log | audit2allow -m puppetmaster > puppetmaster.te && \
checkmodule -M -m puppetmaster.te -o puppetmaster.mod && \
semodule_package -m puppetmaster.mod -o puppetmaster.pp && \
semodule -i puppetmaster.pp