Skip to content

Instantly share code, notes, and snippets.

Daniel Hoelzgen dhoelzgen

Block or report user

Report or block dhoelzgen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
dhoelzgen / base_controller.rb
Last active Oct 14, 2018
CORS in Rails 4 APIs
View base_controller.rb
class API::V1::BaseController < ApplicationController
skip_before_filter :verify_authenticity_token
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'
dhoelzgen / intercom.rb
Created Nov 15, 2013
Just add the following to your Intercom initializer which was generated by the intercom-rails gem. It disabled the messages module completely, so you can implement your own version using the API directly.
View intercom.rb
# Add a disabled modules configuration to the script tag configuration
module IntercomRails
class ScriptTag
alias_method :original_intercom_settings, :intercom_settings
def intercom_settings
hsh = original_intercom_settings
hsh[:disable_modules] = ['messages']
dhoelzgen / dlv_formatter.rb
Created Aug 7, 2012
Better Formatting for DLV / DLV Complex Answer Sets
View dlv_formatter.rb
#!/usr/bin/env ruby
output = %x(/usr/local/bin/dlv-complex -silent #{ARGV[0]})
output = output.scan(/[[:print:]]/).join
@answerset =
def reset
@bracket_level = 0
View screen.rb
require 'formula'
# Gets the latest Gnu Screen with 256 support
# Method from:
# and
class Screen <Formula
head 'git://'
homepage ''
dhoelzgen / gist:966044
Created May 11, 2011
SaboteurAgent in experimental DSL
View gist:966044
require 'simple_agent'
class SaboteurAgent < SimpleAgent
on_percept :visibleEntity do |name, position, team, status|
next if team == @team
if enemy = @enemies[name]
enemy.position = position
You can’t perform that action at this time.