#ifwinactive World of Warcraft { LWin::!F12 !Tab::!F11 Capslock::!F10 F12::LWin }
Wednesday, January 23, 2013
AutoHotKey script to disable windows key, capslock, etc for games
Friday, October 26, 2012
Rails 3.2 Double-Post on adding AJAX
Wednesday, October 24, 2012
Rails 3.2.8 AJAX super-basic example
First, my versions of things I am using!
carmen@ubuntu:~/ws$ uname -a Linux ubuntu 3.2.0-31-generic #50-Ubuntu SMP Fri Sep 7 16:16:45 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux carmen@ubuntu:~/ws$ ruby -v ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] carmen@ubuntu:~/ws$ rails -v Rails 3.2.8
Now on to the good stuff!
rails new ponies cd ponies rails generate scaffold Pony name:string profession:string rake db:migrate rails s
Make some ponies...
http://localhost:3000/ponies/new
Update your destroy line in index.html.erb. Add :remote => true, :class => 'delete_pony'
to app/views/ponies/index.html.erb
. The line should now look like:
<%= link_to 'Destroy', pony, method: :delete, data: { confirm: 'Are you sure?' }, :remote => true, :class => 'delete_pony' %>
Create a file, destroy.js.erb
, put it next to your other .erb files (under app/views/ponies
). It should look like this:
$('.delete_pony').bind('ajax:success', function() { $(this).closest('tr').fadeOut(); });
Add format.js { render :layout => false }
to your controller (app/controllers/ponies_controller.rb
). Your destroy method should now look like this:
# DELETE /ponies/1 # DELETE /ponies/1.json def destroy @pony = Pony.find(params[:id]) @pony.destroy respond_to do |format| format.html { redirect_to ponies_url } format.json { head :no_content } format.js { render :layout => false } end end
Restart your server, and click 'Delete' on some ponies (Preferably Rainbow Dash), and viola, they just fade out! In Rails 3.2.8.
Saturday, August 8, 2009
Ruby and Postgres
First do these steps
Here's my code that converts the csv file and loads it up. I could not figure out how to turn of autocommit (we all know how I feel about autocommit) so I just start a transaction asap. I also couldn't figure out how to see how many rows are inserted with each insert statement like in perl, so I just used the PK. Enjoy!
require 'rubygems'
require 'pg'
raise 'usage: ruby usbank.rb csvfile' if not ARGV[0]
@conn = PGconn.new({:host=>'localhost',:user=>'DBUSER',:dbname=>'DBNAME'})
@conn.setnonblocking(true)
@conn.exec('BEGIN')
def getid
@conn.exec('select max(txn_id::numeric)+1 as txn_id from txn')[0]['txn_id']
end
file = File.new(ARGV[0], "r")
file.gets
begin_id = getid()
while (line = file.gets)
@array = line.split(",")
date = @array[0]
item = "#{@array[1]} #{@array[2]} #{@array[3]}"
amount = @array[4]
amount.chomp!
puts "#{amount} #{date} #{item}"
query = "insert into txn (date, amount, cat_id, item, source_id, txn_id)
select
\'#{date}\',
#{amount},
0,
\'#{item}\',
5,
( select nextval('txn_id_seq'))
where not exists (
select 1 from txn where date= \'#{date}\' and amount=#{amount}
);\n"
@conn.exec(query)
end
end_id = getid()
puts "#{Integer(end_id) - Integer(begin_id)} updated."
@conn.exec('COMMIT')
@conn.finish
file.close
turn off autocommit for psql
Anyways, it's pretty easy. Just
cd ~and make it look like this
vim .psqlrc
SET AUTOCOMMIT OFFviola! Now you may enjoy the wonders of Postgres (including transactional ddl, my favorite), without having to keep looking over your shoulder.
Friday, December 26, 2008
How to Test the Coil on a 2003 Ford Focus

- Take it out
- Measure the primary and secondary resistances according to this picture. If something is infinite, the coil may be broken. Be careful though, make sure you are testing it right and getting a solid connection.
My car just needed new plugs & wires. I wanted to be sure that was the problem before I just replaced them willy-nilly though!
Check out this thread for more info: http://www.focusfanatics.com/forum/showthread.php?t=180606