Skip to content

Instantly share code, notes, and snippets.

Avatar

Patrik Jíra papricek

  • http://www.patrikjira.com
  • Prague
View GitHub Profile
@papricek
papricek / gist:1518887
Created Dec 25, 2011
Render tree within a single sql query
View gist:1518887
def render_tree(nodes = [])
stack = []
html = ""
nodes.each do |node|
if stack.empty?
html << start_tag(node)
stack.push(node)
next
end
if stack.last.lft < node.lft && node.lft < stack.last.rgt
View gist:1649154
<a href="http://www.rajremesel.cz" style="text-align:center;" title="Další libovolnej text">
<img src="http://www.rajremesel.cz/media/logosmall-transparent.png" alt="Popisek loga takže asi něco jako RájŘemesel.cz"><br />
Text si doplň dle libosti Ládí
</a>
@papricek
papricek / gist:1704844
Created Jan 30, 2012
What a syntax sugar!
View gist:1704844
def in_action?(actions)
actions = [actions] if actions.is_a?(String)
actions.map(&:to_s).include?(params[:action])
end
@papricek
papricek / gist:3418963
Created Aug 21, 2012
Sample .gitignore file for kinda typical rails app
View gist:3418963
# What are .gitignore files for? Well, not everything should be stored in a repo.
# Typically your IDE files, log files, or database related stuff (like paperclip attachments in public/system)
.DS_Store # because Mac file system
/.rvmrc # when you have .rvmrc file with default rails and gemset
/.idea # RubyMine project stuff
/.bundle # Bundler temp stuff
/db/*.sqlite3 # DB file, when using sqlite
/config/database.yml # db config - this is probably the only line here, that not including is both bad practice and dangerous
/log/*.log # wanna store gigabytes of logs in repo? c'mon...
View text_mail_interceptor.rb
# You just put this in config/initializers. Dont create text.erb files! ;)
# Text parts are auto-generated from html.erb templates.
include ActionView::Helpers::SanitizeHelper
class TextMailInterceptor
def self.delivering_email(message)
html = message.html_part.try(:body).try(:to_s) || message.body.to_s
text = HTMLEntities.new.decode(html).gsub(/<a.+?href=("|')([^"']+).*?>(.+?)<\/a>/, "\\2: \\3")
attachments = message.attachments
View anonymous_user.rb
class AnonymousUser < User
attr_accessible *ACCESSIBLE_ATTRS, :type, :token, as: :registrant
def register(params)
params = params.merge(type: 'User', token: nil)
self.update_attributes(params, as: :registrant)
end
end
@papricek
papricek / Gemfile
Created Sep 30, 2013
How to setup an easy test suite.
View Gemfile
# ./Gemfile
...
group :test do
gem "shoulda-context"
gem "shoulda-matchers"
gem "factory_girl_rails"
gem "mocha"
gem "ffaker"
@papricek
papricek / variables.yml
Created Apr 24, 2018
Variables to be edited by analytic power
View variables.yml
---
:line_fields:
:general:
:lines:
obchodni_nazev_ID7:
:cg_name: ID7
:cg_type: text
:cg_test_data: HEINEKEN SLOVENSKO
:cg_description: Obchodní název
:label_cs: Obchodní název
@papricek
papricek / autoexec.cfg
Last active Oct 25, 2019
Counter Strike Global Offensive Config
View autoexec.cfg
// budi's CS:GO config
// Updated 7/1/2019
// Rates
rate "786432" // max rate, lower if having network issues
cl_cmdrate "128"
cl_updaterate "128"
cl_interp "0.0"
cl_interp_ratio "1"
cl_interpolate "1"
View gist:c35d575113fb7a61a19f71df6c13878e
<div class="clearfix text-right" style="width: 100%">
<a href="#" class="text-blue btn">Přihlášení</a>
<a href="#" class="text-blue btn">Registrace</a>
</div>