Skip to content

Instantly share code, notes, and snippets.

View maxcodes's full-sized avatar
🤓
Hire me! hire@maxholzheu.com

Max Holzheu maxcodes

🤓
Hire me! hire@maxholzheu.com
View GitHub Profile
class Fixture < ActiveRecord::Base
belongs_to :user
validates :home_team, :home_score_bet, :away_team, :away_score_bet, presence: true
validates :home_score_bet, :away_score_bet, numericality: { only_integer: true }
end
@maxcodes
maxcodes / Explanation
Last active August 29, 2015 14:01
Fixtures order problem (production ENV)
Every user has the same set of fixtures, in the same order. They just change their fields accordingly.
The problem I'm having (happening on production only) is that both on '/fixtures/index' and when editing on '/users/edit'
the fixtures are getting mixed up every time I update one.
Issue not happening on development ENV.
source 'https://rubygems.org'
# Add email validation
gem 'validates_email_format_of'
# Handle file upload
gem "carrierwave"
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'
def set_description_for_stripe
# A sample string would be "example@email.com: 1. Black Medium Lightning 2. Matte Silver Small Lightning"
str = "#{params[:email]}: " # => "example@email.com "
loop_count = 1
params[:order][:bracelets_attributes].map do |bracelet|
str << "#{loop_count}. " # => "example@email.com 1. "
# getting error in the next line: can't convert Symbol into Integer
str << "#{bracelet[loop_count-1]["color"]} " # => "example@email.com 1. Black "
str << "#{bracelet[loop_count-1]["size"]} " # => "example@email.com 1. Black Medium "
str << "#{bracelet[loop_count-1]["kind"]} " # => "example@email.com 1. Black Medium Lightning"
@maxcodes
maxcodes / NewMapComponent.js
Last active August 29, 2015 14:15
Pentaho NewMapComponent
/**
*
* NewMapComponent
*
* Places markers on a map or represents values as a color code
*
Changelog 2014-02-27 -------------
Support for representing data as a colored shape in a map,
e.g. population of a country using a color map.
@maxcodes
maxcodes / gist:156036911815a632ae6f
Created February 24, 2015 05:59
How to Learn to Code
Watch this first:
How to teach yourself to code (video)
https://www.youtube.com/watch?v=T0qAjgQFR4c
Let the fun begin:
Dip your toes:
Codecademy.com
* Javascript course
* HTML + CSS course
@maxcodes
maxcodes / user_visits_profile.rb
Created April 21, 2015 22:38
Randomly failing tests
require 'rails_helper'
feature "User visits his profile page" do
before(:each) do
@user = create(:user)
login_as @user
visit user_path(@user)
end
scenario "and has following" do
@maxcodes
maxcodes / log
Created April 22, 2015 01:59
On a journey to install Eventmachine
Building native extensions. This could take a while...
ERROR: Error installing eventmachine:
ERROR: Failed to build gem native extension.
/Users/max/.rbenv/versions/1.9.3-p484/bin/ruby extconf.rb
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... yes
checking for ruby/thread.h... no
checking for inotify_init() in sys/inotify.h... no
checking for __NR_inotify_init in sys/syscall.h... no