Skip to content

Instantly share code, notes, and snippets.

@henkm
henkm / gist:6717960
Last active December 24, 2015 00:39
# new model:
# /app/models/letsgo_user.rb
belongs_to :user
belongs_to :letsgo
# changes these models:
# /app/models/user.rb
has_many :letsgo_users
has_many :letsgos, through: :letsgo_users
# start with empty list
list = []
# split pdf file into many text files (one for each page)
# `docsplit text jaarboek.pdf --no-ocr --pages all`
# define pattern for email address
regex = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/i
# loop through all the pages
Schrijfwijze Duitse plaatsnamen - geen umlaut gebruiken!
ä = ae
ö = oe
ü = ue
ß = ss
Dus
bijvoorbeeld:
# models/user.rb
class User < ActiveRecord::Base
def self.current
Thread.current[:user]
end
def self.current=(user)
Thread.current[:user] = user
end
end
# user.rb
after_create :create_money_bird_user
def create_money_bird_user
contact = MoneyBirdContact.new
contact.customer_id = "sjamar_#{self.id}"
contact.first_name = self.first_name
contact.last_name = self.first_name
contact.email = self.email
if contact.save
@henkm
henkm / gist:952240
Created May 2, 2011 19:55
Add new items via JQuery TokenInput / Ruby on Rails
#model (idea 100% stolen from ryanb)
def author_tokens=(ids)
ids.gsub!(/CREATE_(.+?)_END/) do
Author.create!(:name => $1).id
end
self.author_ids = ids.split(",")
end
# jquery.tokeninput.js
def get_referal
# controleren of er een ref-param is (mijndagjeweg.nl?ref=ze.nl)
# wordt gebruikt bij aanmelden nieuwe User
if params[:ref]
cookies[:ref] = params[:ref]
end
if request.remote_ip == "66.249.66.148"
logger.debug "Google BOt"
# redirect_to "http://www.teamtrips.nl/"