This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RedisConnect | |
@@db_redis = nil | |
@@db_adtext_redis = nil | |
def self.redis | |
if @@db_redis.nil? | |
config = YAML.load_file('config/database.yml')[ENV['RACK_ENV']] | |
@@db_redis = Redis.new(:host => config["host"], :port => config["port"], :db => config["db"]) | |
end | |
return @@db_redis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RedisConnect | |
@@db_redis = nil | |
@@db_adtext_redis = nil | |
def self.redis | |
if @@db_redis.nil? | |
config = YAML.load_file('config/database.yml')[ENV['RACK_ENV']] | |
@@db_redis = Redis.new(:host => config["host"], :port => config["port"], :db => config["db"]) | |
end | |
return @@db_redis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "ščřžýáíéáýžřčřžýáíážřýášžýěáč".scan(/./mu)[0,10].join |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding : utf-8 -*- | |
require "active_support" | |
require 'active_support/inflector' | |
puts ActiveSupport::Inflector::transliterate("Nějaký ten string ščřžýáíé") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add to Gemfile | |
# gem "mail" | |
# | |
# or do in terminal | |
# 'gem install mail' | |
# send_mail_with_inline_image.rb | |
require 'mail' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this in your test helper file | |
# This works when using the default Sinatra sessions (i.e. enable :sessions) | |
# (helper preamble not included) | |
require 'securerandom' | |
class Test::Unit::TestCase | |
include Rack::Test::Methods | |
def app | |
Sinatra::Application # or the name of your modular app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def show_nfi_tfl percent | |
if percent.nil? | |
"" | |
elsif percent < 0 | |
tfl = "tfl_3critical" | |
elsif percent < 10 | |
tfl = "tfl_3red" | |
elsif percent < 20 | |
tfl = "tfl_2yellow" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- iPad Settings --> | |
<meta name="apple-mobile-web-app-capable" content="yes" /> | |
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1"/> | |
<!-- iOS ICONS --> | |
<link rel="apple-touch-icon" sizes="144x144" href="<%= image_path("apple_icons/icon-144.png") -%>" /> | |
<link rel="apple-touch-icon" sizes="114x114" href="<%= image_path("apple_icons/icon-114.png") -%>" /> | |
<link rel="apple-touch-icon" sizes="72x72" href="<%= image_path("apple_icons/icon-72.png") -%>" /> | |
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="<%= image_path("apple_icons/icon-144.png") -%>" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding : utf-8 -*- | |
require 'tire' | |
require 'tire/http/clients/curb' | |
Tire.configure do | |
# # logger 'log/elasticsearch.log', :level => 'debug' if Bandit.env == 'development' | |
# #logger STDOUT, :level => 'debug' | |
client Tire::HTTP::Client::Curb | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############ | |
# PLASE FILL | |
############ | |
secret_key = "APPLICATION_SECRET_KEY_INSERT" | |
application = "APPLICATION_KEY_INSERT" | |
instance = "INSTANCE_INSERT" | |
############ | |
# THAN RUM |
OlderNewer