Skip to content

Instantly share code, notes, and snippets.

~/.irbrc:
require 'irb/completion'
require 'irb/ext/save-history'
# where history is saved
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"
# how many lines to save
IRB.conf[:SAVE_HISTORY] = 1000
@vidmantas
vidmantas / gist:921206
Created April 15, 2011 05:46
Lock wait timeout exceeded
Mysql::Error: Lock wait timeout exceeded; try restarting transaction: INSERT INTO `weekly_balances` (`start_date`, `context_id`, `context_type`, `register_id`, `approved_by`, `approved_at`, `created_at`, `rem_approve_w1`, `rem_approve_w2`, `rem_overrun`) VALUES ('2011-04-11', 997, 'Shop', 0, NULL, NULL, '2011-04-15 05:41:23', 0, 0, 0)
/opt/ruby-1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:207:in `rescue in log'
/opt/ruby-1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:199:in `log'
/opt/ruby-1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/mysql_adapter.rb:289:in `execute'
/opt/ruby-1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/database_statements.rb:282:in `insert_sql'
/opt/ruby-1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5/lib/active_record/connection_adapters/mysql_adapter.rb:300:in `insert_sql
@vidmantas
vidmantas / gist:833472
Created February 18, 2011 09:38
Get text width in prawn
pdf.width_of(text)
pdf.width_of(text, :size => 10)
# or if you have more fonts in layout
@your_font.compute_width_of(text, :size => 8)
~/projects/same4[master]$ git commit -am "Some raws and html_safes"
[master dfaa879] Some raws and html_safes
13 files changed, 77 insertions(+), 11 deletions(-)
create mode 100644 .bundle/config
create mode 100644 assets/documents/69/hs_err_pid1931.log
create mode 100644 public/uploads/gallery_image/file/1176/original_IMG_06012011_123717.png
create mode 100644 public/uploads/gallery_image/file/1176/thumb_IMG_06012011_123717.png
create mode 100644 tmp/export/overview_day_2011-01-23-2011-01-23.xls
create mode 100644 tmp/export/tbl_c64_01251304.xls
create mode 100644 tmp/import/c64-samsoee_fields.csv
~/projects/same3[live]$ rake stats
(in /home/vidmantas/projects/same3)
Booting Rails... (0.61s)
+----------------------+-------+-------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 7819 | 5948 | 88 | 503 | 5 | 9 |
| Helpers | 2959 | 2372 | 0 | 308 | 0 | 5 |
| Models | 15778 | 11727 | 107 | 878 | 8 | 11 |
| Libraries | 839 | 628 | 14 | 73 | 5 | 6 |
$ traceroute in1.samesystem.com
traceroute to in1.samesystem.com (194.255.16.121), 30 hops max, 60 byte packets
1 192.168.0.1 (192.168.0.1) 1.060 ms 1.045 ms 1.570 ms
2 81-7-125-16.static.zebra.lt (81.7.125.16) 9.853 ms 10.476 ms 11.183 ms
3 82-135-129-1.static.zebra.lt (82.135.129.1) 11.683 ms 12.402 ms 12.878 ms
4 81-7-119-41.static.zebra.lt (81.7.119.41) 13.908 ms 14.640 ms 15.375 ms
5 81-7-120-162.static.zebra.lt (81.7.120.162) 16.046 ms 17.006 ms 17.753 ms
6 war-b3-link.telia.net (213.248.85.89) 27.860 ms 18.271 ms 18.868 ms
7 hbg-bb2-link.telia.net (80.91.245.46) 34.240 ms 34.577 ms 35.476 ms
8 kbn-bb2-link.telia.net (213.155.130.103) 36.904 ms kbn-bb2-link.telia.net (80.91.249.206) 39.347 ms 40.389 ms
~/projects/same3[live]$ ss
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
/home/vidmantas/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require': no such file to load -- spreadsheet (MissingSourceFile)
from /home/vidmantas/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `block in require'
from /home/vidmantas/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /home/vidmantas/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from /home/vidmantas/.rvm/gems/ruby-1.9.2-p136/gems/roo-1.9.3/lib/roo/excel.rb:2:in `<top (required)>'
from /home/vidmantas/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from /home/vidmantas/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `block
# This one works way better:
PS1='\[$(tput sgr0)$(tput setaf 5)\]\w\[$(tput sgr0)$(tput setaf 2)\]$(__git_ps1 "[%s]") \[$(tput
sgr0)\]$ '
if ENV and ENV['RAILS_ENV']
require 'hirb'
Hirb.enable
end
def ar_logger
ActiveRecord::Base.logger = Logger.new(STDOUT)
reload!
end
class Object
NameError (undefined local variable or method `change' for #<Class:0x00000009001258>):
/home/vidmantas/.rvm/gems/ruby-1.9.2-p0/gems/will_paginate-2.3.14/lib/will_paginate/finder.rb:170:in `method_missing_with_paginate'
app/models/calendar_line.rb:1150:in `block (3 levels) in autoupdate_for'
app/models/calendar_line.rb:1149:in `each'
app/models/calendar_line.rb:1149:in `block (2 levels) in autoupdate_for'
app/models/calendar_line.rb:1106:in `each'
app/models/calendar_line.rb:1106:in `block in autoupdate_for'
app/models/calendar_line.rb:1105:in `autoupdate_for'
app/models/user.rb:105:in `after_update'