Skip to content

Instantly share code, notes, and snippets.

View tmaier's full-sized avatar
🤓
I like pizza

Tobias L. Maier tmaier

🤓
I like pizza
View GitHub Profile
@NAR8789
NAR8789 / dnsmasq.conf
Last active September 26, 2024 11:34
wildcard dns for docker-compose using dnsmasq
# explicitly define host-ip mappings
address=/myapp.local/172.16.1.2
# dnsmasq entries are always wildcard entries, so this maps both myapp.local and *.myapp.local
# (yes, it's fine for this to be your entire dnsmasq config. the defaults are pretty sensible)
# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
@pcreux
pcreux / Gemfile
Last active December 11, 2023 20:24
Fast Rails + Heroku Configuration
group :production do
gem 'unicorn'
# Enable gzip compression on heroku, but don't compress images.
gem 'heroku-deflater'
# Heroku injects it if it's not in there already
gem 'rails_12factor'
end
@lucasdavila
lucasdavila / dynamic_form_for_hstore_attributes_in_rails.html.erb
Created September 13, 2012 15:54
Dynamic form for hstore attributes in rails
<%= simple_form_for @product do |f| %>
<%= f.simple_fields_for :attributes do |d| %>
<% f.object.attributes.try(:each) do |key, value| %>
<%= d.input key, :input_html => {:value => value } %>
<% end %>
<% end %>
<% end %>
@ches
ches / tags_input.rb
Created August 26, 2011 08:09
SimpleForm (1.4.x) input for mongoid_taggable -- place in app/inputs
# Input builder to render tags from an Array field, for use with my fork
# of mongoid_taggable:
#
# https://github.com/ches/mongoid_taggable
#
class TagsInput < SimpleForm::Inputs::StringInput
map_type :tags, :to => :text_field
protected
@karmi
karmi / ngrams-and-tire.rb
Created August 21, 2011 10:17
An example of using ngram analysis in ElasticSearch with the Tire rubygem
# An example of using ngram analysis in ElasticSearch with the Tire rubygem
# ==========================================================================
# The original, raw example: https://gist.github.com/988923
require 'rubygems'
require 'tire'
require 'yajl/json_gem'
class URL
def initialize(attributes={})
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end