Skip to content

Instantly share code, notes, and snippets.

$:.unshift File.expand_path("../../lib", File.dirname(__FILE__))
require 'rubygems'
require 'bundler/setup'
require 'lob'
require 'csv'
require 'pry-byebug'
binding.pry
@lbvf50mobile
lbvf50mobile / why binding pry dose not stop a poe
Last active October 30, 2016 08:06
why binding pry dose not stop a pocess
require 'rubygems'
require 'bundler/setup'
require 'pry-byebug'
puts "test1"
binding.pry
@lbvf50mobile
lbvf50mobile / get_from.rb
Last active October 30, 2016 08:35
Task: Get subarray with "from..." keys
require 'rubygems'
require 'bundler/setup'
require 'pry-byebug'
hash = {
:text_data => "data",
:name => "name",
:from_address_select => "name from address slect",
:from_name => "name from name ",
:from_line1 => "name from line 1 ",
hash = {
:text_data => "data",
:name => "name",
:from_address_select => "name from address slect",
:from_name => "name from name ",
:from_line1 => "name from line 1 ",
:from_line2 => "name from line 2",
:from_city_name => "name city name " ,
:from_state_name => "name from state name",
def save_post_card
binding.pry
card = PostCard.where(:id => params[:post_card_id]).first
if card.nil?
render text: 'Nnot found postcard with provided ID', status: 404
return
end
text_data = params[:text_data]
name = params[:name].strip
create_table "post_cards", force: :cascade do |t|
t.string "name"
t.integer "user_id"
t.integer "design_id"
t.text "message"
t.integer "from_address_id"
t.integer "to_address_id"
t.integer "status"
t.decimal "price", precision: 12, scale: 2
t.datetime "created_at", null: false
hash = {
:text_data => "data",
:name => "name",
:from_address_select => " name from address slect",
:from_name => "name from name ",
:from_line1 => "name from line 1 ",
:from_line2 => "name from line 2 ",
:from_city_name => "name city name " ,
:from_state_name => "name from state name ",
:from_zip => "name from zip",
28: def process_action(*args)
29: super
30: rescue Exception => exception
31: request.env['action_dispatch.show_detailed_exceptions'] ||= show_detailed_exceptions?
=> 32: rescue_with_handler(exception) || raise(exception)
33: end
ef get_front_side (post_card)
@post_card = post_card
@msg = JSON.parse(@post_card.message)
@msg['front_side']['texts'].each do |text|
text['bg_color_rgba'] = 'rgba(255,255,255,'+(text['opacity'].to_f/100.0).to_s+')';
end
fonts_list = []
require 'benchmark'
n = 5000
h = "test"
salt = SecureRandom.random_bytes(64)
key = ActiveSupport::KeyGenerator.new('password').generate_key(salt)
Benchmark.bm do |x|
x.report("dbrequest:") do
n.times do