Skip to content

Instantly share code, notes, and snippets.

Avatar

Tadas Tamošauskas tadast

View GitHub Profile
@tadast
tadast / Preventing anchor links from scrolling
Created Jan 18, 2011
how to prevent anchor links from scrolling to id element but update address bar with hash (useful for some sort of tabs)
View Preventing anchor links from scrolling
View gpg sample wrapper.rb
class GpgWrapper
class GpgNotInstalled < StandardError; end
class CanNotFindPgpKey < StandardError; end
attr_reader :file_to_encrypt, :tmp_dir, :pgp_key, :email
def initialize(file_content, for_what = "customer")
check_gpg
load_config(for_what)
random_filename = "#{String.random}_#{Time.now.to_i}.xml"
View gist:1107116
# yes it is HAML
- Language.all.each do |language|
= label_tag do
= check_box_tag "teachers[language_ids][]", language.id, f.object.languages.include?(language)
= language.name
View gist:1107162
class Office < ActiveRecord::Base
belongs_to :teacher
accepts_nested_attributes_for :teacher
end
class Teacher < ActiveRecord::Base
has_one :office
end
@tadast
tadast / heroku_colors.sh
Created Aug 10, 2011
Colorize heroku production console for iTerm2 on OSX
View heroku_colors.sh
# iTerm2, OS X
# 1. change 'your_app_production' to your application name
# 1a. Tune the colors by your taste
# 2. put these functions to your .bashrc, .zshrc
# or anywhere where it gets loaded for your iTerm session
# 3. restart iTerm or 'source ~/.zshrc' and use these functions
set_color() {
local HEX_FG=$1
local HEX_BG=$2
@tadast
tadast / terminal_color.sh
Created Aug 10, 2011
Colorize heroku production console for Terminal on OSX
View terminal_color.sh
# Terminal, OS X (iTerm version: https://gist.github.com/1137050)
# 1. change 'your_app_production' to your application name
# 1a. Tune the colors by your taste
# 2. put these functions to your .bashrc, .zshrc
# or anywhere where it gets loaded for your iTerm session
# 3. restart iTerm or 'source ~/.zshrc' and use these functions
set_color() {
local R=$1
local G=$2
@tadast
tadast / gist:1569954
Created Jan 6, 2012
useful sublime text 2 stuff
View gist:1569954

== Key Bindings

[
  //https://github.com/alexstaubo/sublime_text_alternative_autocompletion
  { "keys": ["escape"], "command": "alternative_autocomplete", "context":
    [
      { "key": "num_selections", "operator": "equal", "operand": 1 },
      { "key": "overlay_visible", "operator": "equal", "operand": false },
View gist:1730393
https://gist.github.com/1688857
=== 1.9.3-p0
✗ time (rails runner 'puts(1)')
6.33s user 0.69s system 99% cpu 7.027 total
✗ time (rspec spec)
1736/1736: 100% |==========================================| Time: 00:00:34
42.32s user 1.52s system 92% cpu 47.279 total
View gist:3723042
# helpers
module PublicHelper
def router_attributes
{
"data-router-class" => "#{controller_name.to_s.titleize}Controller",
"data-router-action" => action_name.to_s
}
end
end
@tadast
tadast / gist:4160627
Created Nov 28, 2012
Open the last migration file from shell
View gist:4160627
# stole this from Tor Erik Linenrud @telinnerud
alias olm='subl `ls -r db/migrate/* | head -n 1`'
You can’t perform that action at this time.