Skip to content

Instantly share code, notes, and snippets.

View tessi's full-sized avatar

Philipp Tessenow tessi

View GitHub Profile
@gabetax
gabetax / pretzel.rb
Last active December 19, 2015 00:29
https://twitter.com/garybernhardt/status/349920138889404416
[1] pry(main)> class Object; alias_method :&, :method; end
=> Object
With standard symbol to proc, &:foo evaluates to:
{ |x| x.foo }
With the "pretzel bun", &foo&:bar evaluates to:
@DonSchado
DonSchado / example_spec.rb
Last active December 22, 2015 20:18
Thoughtbot retracted their initial implementation of strong parameters matchers in v2.0.0 of shoulda-matchers, so we decided to build our own until new official ones are released. The following is a small matcher for testing what params should be permitted in controllers. The matcher's syntax is based on validation matchers. If you're not follow…
# assuming your subject is the UsersController with a method user_params
describe UsersController do
describe "params" do
# per default the matcher extracts the subject and params method
it { should permit_params(:email, :name, :role) }
# to overwrite the params method use explicit .params_method()
it { should permit_params(:first_name, :last_name).params_method(:other_user_params) }

Jumping, Finding, ...

Keybinding - Description
Ctrl-1 - Move to 1st tab (work every number)
Ctrl-p - Go to anything
Ctrl-g - Go to line
Ctrl-r - Go to symbol (e.g. section and labels)
Ctrl-m - Move to bracket
@christhekeele
christhekeele / pre-commit
Last active May 3, 2016 00:19
Ever committed with `gem 'foobar', path: '~/source'` in your Gemfile and broken a build?This git pre-commit hook ensures you never will again.If you try and commit while a gem in your Gemfile is loading with the `:path` option, you will be stopped with a helpful message. The only exception: gems embedded within your project are allowed.
#!/usr/bin/env ruby
# A pre-commit hook script to ensure that no local gem dependencies (gem 'asdf', path: '~/local')
# exist in your Gemfile before commiting.`
# Allows gems to be loaded from source within the current project directory, but not from outside.
puts 'Checking for local dependencies in your Gemfile.'
ROOT_PATH = File.expand_path('../../..', __FILE__)
NESTED_GEMSPECS = Dir["#{ROOT_PATH}/**/*.gemspec"]
GEMFILE = ENV['BUNDLE_GEMFILE'] || File.join(ROOT_PATH, 'Gemfile')
class Address
def initialize address, display_name, domain
@address = address
@display_name = display_name
@domain = domain
end
attr_reader :address, :display_name, :domain
def self.from_header h # returns an Array of Addresses
@crohr
crohr / install-openproject-plugins.md
Last active June 8, 2018 07:03
Install openproject plugins using the debian package

Let's say you wanted to install this plugin: https://github.com/finnlabs/openproject-meeting. Here is how you would do it with the openproject version packaged at https://pkgr.io/apps/tessi/openproject:

cat >> /opt/openproject/Gemfile.plugins <<EOF
gem "openproject-plugins", :git => "https://github.com/opf/openproject-plugins.git", :branch => "stable"
gem "openproject-meeting", :git => "https://github.com/finnlabs/openproject-meeting.git", :branch => "stable"
EOF
@tessi
tessi / my-way-to-postgresql-9-6-2-on-an-uberspace.md
Last active November 27, 2018 22:53
Upgrade Postgresql from 9.2 to 9.6 on an uberspace

Upgrade Postgresql from 9.2 to 9.6 on an uberspace

Uberspace (an awesome german web hoster) has superb postgresql support, except that it currently only offers postgresql versions 9.2.x and 9.3.x. I run postgresql 9.6.2 on my uberspace and documented steps for a migration to postgresql 9.6 here.

My goal was to be as close to the original uberspace-postgresql-setup as possible, but I had to copy and modify some uberspace scripts so they correctly use the new postgresql version.

Warning: Here be dragons. This is what I did -- that doesn't mean you should do the same or what I did was clever. Always backup your data and maybe test on a throw-away uberspace first. If you find things to improve, let me know and I'll try to keep this updated.

What I assume you have

@jstorimer
jstorimer / hilong.rb
Last active July 30, 2020 06:52
hilong -- A simply utility to show character counts for each line of input and highlight lines longer than 80 characters.
#!/usr/bin/env ruby
# A simply utility to show character counts for each line of input and
# highlight lines longer than 80 characters.
#
# Written as an example for http://jstorimer.com/2011/12/12/writing-ruby-scripts-that-respect-pipelines.html
#
# Examples:
#
# $ hilong Gemfile
@twosixcode
twosixcode / gist:1988097
Created March 6, 2012 18:40
Make "Paste and Indent" the default paste in Sublime Text 2
// swap the keybindings for paste and paste_and_indent
{ "keys": ["super+v"], "command": "paste_and_indent" },
{ "keys": ["super+shift+v"], "command": "paste" }
@kevinelliott
kevinelliott / osx-10.10-setup.md
Last active December 1, 2023 08:21
Mac OS X 10.10 Yosemite Setup

Mac OS X 10.10 Yosemite

Custom recipe to get OS X 10.10 Yosemite running from scratch, setup applications and developer environment. I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

Install Software