Skip to content

Instantly share code, notes, and snippets.

Controllers are to:
1. Decide what actions to perform
2. Decide how to respond to action results
Controllers are not to:
1. Perform actions
2. Configure responses
@zflat
zflat / note_for_locking
Created April 3, 2012 15:04
rails with_lock
see http://guides.rubyonrails.org/3_2_release_notes.html
This makes it possible to write the following:
class Order < ActiveRecord::Base
def cancel!
transaction do
lock!
# ... cancelling logic
@zflat
zflat / gist:5662984
Created May 28, 2013 14:04
pass errors and warnings as reference to OLE server
def wrapper_for_operation
e = AsRefArg::new_obj
w = AsRefArg::new_obj
instance.call_operation(args, e, w)
parse_error_warnings(*WIN32OLE::ARGV[1..2])
end
def parse_error_warnings(e, w)
# handle e and w args
@zflat
zflat / pg_migrate_steps.sh
Last active March 17, 2022 04:51
Migrate pg dump from Heroku to local sqlite3 development (and beyond)
# Export the Heroku PG database to a local dump file
# https://devcenter.heroku.com/articles/heroku-postgres-import-export#export
heroku pgbackups:capture
curl -o latest.dump `heroku pgbackups:url`
# Install postregs & Setup password
# https://help.ubuntu.com/community/PostgreSQL
# List databases
sudo -u postgres psql -l
@zflat
zflat / gist:7076465
Created October 20, 2013 23:08
Git repo from central location
git clone ssh://user@domain.com/~/path_to.git
Article at: http://toroid.org/ams/git-central-repo-howto
@zflat
zflat / gist:7117767
Created October 23, 2013 12:30
Reset-postgres-primary-key-sequence
Useful when inserting rows into postres (like when seeding data from a .sql dump) messes up the database.
http://stackoverflow.com/questions/244243/how-to-reset-postgres-primary-key-sequence-when-it-falls-out-of-sync
// Login to psql and run the following
// What is the result?
SELECT MAX(id) FROM your_table;
// Then run...
@zflat
zflat / altair_help_files.md
Last active December 26, 2015 19:19
Altair Help Locations
  • HyperMesh overview:

[file:///C:/Program%20Files/Altair/12.0/help/hm/hmbat.htm?hypermesh.htm][1]

  • HyperMesh Tutorials

    [file:///C:/Program%20Files/Altair/12.0/help/hm/hmbat.htm?hypermesh_tutorials.htm][2]

  • HyperWorks Desktop Overview: