Skip to content

Instantly share code, notes, and snippets.

View tadast's full-sized avatar

Tadas Tamošauskas tadast

View GitHub Profile
@tadast
tadast / README.md
Last active August 29, 2015 14:25 — forked from chrisroos/README.md
Spike into ways of visualising Smart Answers

The print_graph method displays the Smart Answer as a tree.

The print_questions_and_possible_next_nodes method displays the questions and their possible next nodes.

The extraction of possible next nodes is horrible in the case where the Smart Answer uses the block syntax of next_node. I'm getting the source of the block and extracting things that look like symbols.

@tadast
tadast / Preventing anchor links from scrolling
Created January 18, 2011 21:18
how to prevent anchor links from scrolling to id element but update address bar with hash (useful for some sort of tabs)
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"
# 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
class Office < ActiveRecord::Base
belongs_to :teacher
accepts_nested_attributes_for :teacher
end
class Teacher < ActiveRecord::Base
has_one :office
end
@tadast
tadast / terminal_color.sh
Created August 10, 2011 15:14
Colorize heroku production console for Terminal on OSX
# 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 / heroku_colors.sh
Created August 10, 2011 15:07
Colorize heroku production console for iTerm2 on OSX
# 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 / gist:1569954
Created January 6, 2012 10:07
useful sublime text 2 stuff

== 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 },

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
# helpers
module PublicHelper
def router_attributes
{
"data-router-class" => "#{controller_name.to_s.titleize}Controller",
"data-router-action" => action_name.to_s
}
end
end