Skip to content

Instantly share code, notes, and snippets.

View rud's full-sized avatar

Laust Rud Jacobsen rud

View GitHub Profile
Capybara.register_driver :https_chrome do |app|
browser_options = Selenium::WebDriver::Chrome::Options.new
browser_options.add_argument('allow-insecure-localhost') # Ignore TLS/SSL errors on localhost
browser_options.add_argument('ignore-certificate-errors') # Ignore certificate related errors
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
end
@thomasdarimont
thomasdarimont / App.java
Created November 6, 2018 19:09
Simple Spring Boot App protected by Keycloak with initial roles from Keycloak and additional hierarchical app Internal roles. Supports fine grained permission checks, where the permissions are derived from roles.
package demo;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
@obfusk
obfusk / break.py
Last active May 1, 2024 20:32
python "breakpoint" (more or less equivalent to ruby's binding.pry); for a proper debugger, use https://docs.python.org/3/library/pdb.html
import code; code.interact(local=dict(globals(), **locals()))
@nathanl
nathanl / activerecord_scope_conditions.rb
Created June 11, 2013 14:45
Using joins and conditions in ActiveRecord scopes. (This was hard for me to find documentation on.)
class Person < ActiveRecord::Base
# This manual SQL query...
scope :allowed_to_eat_cheese, joins(
<<-SQL
INNER JOIN cities ON people.city_id = cities.id
INNER JOIN states ON cities.state_id = states.id
SQL
).where('states.allows_cheese_consumption' = 'Yeppers')
@dipth
dipth / network.yml
Created October 19, 2011 19:20
Tunneling to your local development computer
development:
tunnel:
public_host_username: root
public_host: [IP OF YOUR PUBLIC SERVER]
public_port: 3000
local_port: 3000
ssh_port: 22
server_alive_interval: 0
require "digest/md5"
require "resque-retry"
require "resque-loner"
#
# Statused Worker Example:
#
# class MyStatusedWorker < StatusedWorker
# def self.job_identity_arguments(user_id, credit_card_number, attributes = {})
# [user_id]
@stan
stan / 0_instructions.txt
Created May 19, 2011 02:25 — forked from sgruhier/0_instructions.txt
Sprocket 2 in Rails 3.0.x ala Rails 3.1
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
This stuff will be native in Rails 3.1 and the layout of the files on the
filesystem will be different but this guide will get you working with it
while we wait for all that to finalize.
Ignore the number prefixes on each file. This is just to ensure proper order in the Gist.
It's based on eric1234 gist https://gist.github.com/911003. ijust made it 3.1 compliant in terms of convention
@jeffkreeftmeijer
jeffkreeftmeijer / application.rb
Created February 14, 2011 13:08
Lighthouse Keeper: turns Lighthouse API XML into RSS - http://keeper.jeffkreeftmeijer.com
class Application < Sinatra::Base
get '/:domain/:project' do
tickets = HTTParty.get(
"https://#{params[:domain]}.lighthouseapp.com/projects/#{params[:project]}/tickets.xml?q=#{params[:q]}"
)['tickets']
builder do |xml|
xml.instruct! :xml, :version => '1.0'
xml.rss :version => "2.0" do
xml.channel do
@mbbx6spp
mbbx6spp / Vagrantfile.rb
Created February 5, 2011 05:36
Riak cluster Vagrantfile to offer an alternative to Basho Chef+Vagrant blog post suggestion and receive feedback at http://blog.basho.com/2011/02/04/creating-a-local-riak-cluster-with-vagrant-and-chef/
# Offering alternative Chef + Vagrant Riak cluster setup to the following blog post at basho:
# http://blog.basho.com/2011/02/04/creating-a-local-riak-cluster-with-vagrant-and-chef/
# Assumes Vagrant 0.7.0+ and VirtualBox 4.0+
# Now you should be able to launch your X (where X=4 in this case) vagrant VMs with the following:
# % vagrant up db1
# % vagrant up db2
# % vagrant up db3
# % vagrant up db4
@igrigorik
igrigorik / faraday-em-http.rb
Created January 30, 2011 01:12
using Faraday with EM-Synchrony & EM-Http
require 'faraday'
require 'net/http'
require 'pp'
# Repos:
# https://github.com/technoweenie/faraday
# https://github.com/pengwynn/faraday_middleware
# Blog posts:
# http://adventuresincoding.com/2010/09/writing-modular-http-client-code-with-faraday