tag:blogger.com,1999:blog-35547751967192718752024-03-05T09:56:03.513-08:00House 9House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.comBlogger196125tag:blogger.com,1999:blog-3554775196719271875.post-69617614169637585372013-07-06T11:26:00.000-07:002013-07-06T11:40:16.817-07:00Puppet Solo (AKA: supply_drop)Similar to <a href="http://matschaffer.github.io/knife-solo/">knife-solo</a> for use with <a href="http://www.opscode.com/chef/">chef</a>, <a href="https://github.com/pitluga/supply_drop">supply_drop</a> allows you to provision servers using <a href="https://puppetlabs.com/">puppet</a> without the need for a puppet master server. It uses <a href="https://github.com/capistrano/capistrano">capistrano</a> for executing commands on the remote server. I put together a working sample set of puppet and supply_drop deployment scripts for provisioning a postgres server.<br />
<br />
<blockquote class="tr_bq">
See the github repo at <a href="https://github.com/house9/puppet-solo-hello-world">https://github.com/house9/puppet-solo-hello-world</a></blockquote>
<br />
<b>Resources</b><br />
<br />
<ul>
<li><a href="http://www.confreaks.com/videos/2479-railsconf2013-devops-for-the-rubyist-soul">http://www.confreaks.com/videos/2479-railsconf2013-devops-for-the-rubyist-soul</a></li>
<li><a href="https://speakerdeck.com/jtdowney/devops-for-the-rubyist-soul-at-rubynation-2013">https://speakerdeck.com/jtdowney/devops-for-the-rubyist-soul-at-rubynation-2013</a></li>
</ul>
<br />
<br />
<br />House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-23678333738275095022013-06-24T11:50:00.000-07:002013-06-24T11:50:49.484-07:00WAL-e chef cookbook<div style="background-color: white; color: #222222; font-family: arial; font-size: small; margin-bottom: 1.2em !important; margin-top: 1.2em !important;">
Postgres has various backup and restore options</div>
<ul style="background-color: white; color: #222222; font-family: arial; font-size: small; margin: 1.2em 0px; padding-left: 2em;">
<li style="margin: 0.5em 0px;"><a href="http://www.postgresql.org/docs/9.2/static/backup.html" style="color: #1155cc;"></a><a href="http://www.postgresql.org/docs/9.2/static/backup.html" style="color: #1155cc;">http://www.postgresql.org/docs/9.2/static/backup.html</a></li>
</ul>
<div style="background-color: white; color: #222222; font-family: arial; font-size: small; margin-bottom: 1.2em !important; margin-top: 1.2em !important;">
Do you have a recovery plan in case your Postgres server crashes - your daily pg_dump is probably not going to cut it.</div>
<div style="background-color: white; color: #222222; font-family: arial; font-size: small; margin-bottom: 1.2em !important; margin-top: 1.2em !important;">
Postgres uses Write-Ahead Logging (WAL)</div>
<blockquote style="background-color: white; border-left-color: rgb(221, 221, 221); border-left-style: solid; border-left-width: 4px; color: #777777; font-family: arial; font-size: small; margin: 1.2em 0px; padding: 0px 1em; quotes: none;">
<div style="margin-bottom: 1.2em !important; margin-top: 1.2em !important;">
Write-Ahead Logging (WAL) is a standard method for ensuring data integrity. A detailed description can be found in most (if not all) books about transaction processing. Briefly, WAL's central concept is that changes to data files (where tables and indexes reside) must be written only after those changes have been logged, that is, after log records describing the changes have been flushed to permanent storage. If we follow this procedure, we do not need to flush data pages to disk on every transaction commit, because we know that in the event of a crash we will be able to recover the database using the log: any changes that have not been applied to the data pages can be redone from the log records. (This is roll-forward recovery, also known as REDO.)</div>
</blockquote>
<ul style="background-color: white; color: #222222; font-family: arial; font-size: small; margin: 1.2em 0px; padding-left: 2em;">
<li style="margin: 0.5em 0px;">from <a href="http://www.postgresql.org/docs/9.2/static/wal-intro.html" style="color: #1155cc;"></a><a href="http://www.postgresql.org/docs/9.2/static/wal-intro.html" style="color: #1155cc;">http://www.postgresql.org/docs/9.2/static/wal-intro.html</a></li>
</ul>
<div style="background-color: white; color: #222222; font-family: arial; font-size: small; margin-bottom: 1.2em !important; margin-top: 1.2em !important;">
Setting up Continuous Archiving and Point-in-Time Recovery (PITR) for your Postgres WAL files is very complex, lucky for us the WAL-e project has simplified this process greatly. WAL-e has utilities for sending all WAL files to an AWS S3 bucket as the log files are being generated. More Information, see:</div>
<ul style="background-color: white; color: #222222; font-family: arial; font-size: small; margin: 1.2em 0px; padding-left: 2em;">
<li style="margin: 0.5em 0px;"><a href="http://www.postgresql.org/docs/9.2/static/continuous-archiving.html" style="color: #1155cc;"></a><a href="http://www.postgresql.org/docs/9.2/static/continuous-archiving.html" style="color: #1155cc;">http://www.postgresql.org/docs/9.2/static/continuous-archiving.html</a></li>
</ul>
<ul style="background-color: white; color: #222222; font-family: arial; font-size: small; margin: 1.2em 0px; padding-left: 2em;">
<li style="margin: 0.5em 0px;"><a href="https://github.com/wal-e/wal-e" style="color: #1155cc;"></a><a href="https://github.com/wal-e/wal-e" style="color: #1155cc;">https://github.com/wal-e/wal-e</a></li>
</ul>
<div style="background-color: white; color: #222222; font-family: arial; font-size: small; margin-bottom: 1.2em !important; margin-top: 1.2em !important;">
Recently I put together a chef cookbook which installs WAL-e on a Postgres instance, see:</div>
<ul style="background-color: white; color: #222222; font-family: arial; font-size: small; margin: 1.2em 0px; padding-left: 2em;">
<li style="margin: 0.5em 0px;"><a href="https://github.com/house9/wal-e-cookbook" style="color: #1155cc;"></a><a href="https://github.com/house9/wal-e-cookbook" style="color: #1155cc;">https://github.com/house9/wal-e-cookbook</a></li>
</ul>
<ul style="background-color: white; color: #222222; font-family: arial; font-size: small; margin: 1.2em 0px; padding-left: 2em;">
<li style="margin: 0.5em 0px;"><a href="https://github.com/house9/use_wal_e" style="color: #1155cc;"></a><a href="https://github.com/house9/use_wal_e" style="color: #1155cc;">https://github.com/house9/use_wal_e</a></li>
</ul>
House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-45636565638679345392013-06-11T18:28:00.001-07:002013-06-11T18:28:23.062-07:00Vagrant and puppet postgres 9.2 on ubuntuSome vagrant configuration to install postgres 9.2 using puppet<br />
<br />
<script src="https://gist.github.com/house9/5762219.js"></script>
<noscript>see https://gist.github.com/house9/5762219.js</noscript>
<br />
<script src="https://gist.github.com/house9/5762236.js"></script>
<noscript>see https://gist.github.com/house9/5762236.js</noscript>
<br />
<b>Resources</b><br />
<br />
<ul>
<li><a href="https://forge.puppetlabs.com/puppetlabs/postgresql">https://forge.puppetlabs.com/puppetlabs/postgresql</a></li>
<li><a href="https://github.com/puppetlabs/puppetlabs-postgresql">https://github.com/puppetlabs/puppetlabs-postgresql</a></li>
</ul>House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-85558832723171788102013-06-01T08:44:00.002-07:002013-06-01T08:45:21.347-07:00Vagrantfile for setting up multiple machines with chef configurationExample Vagrantfile below for setting up multiple virtual machines and using chef to provision them<br />
<br />
<br />
<script src="https://gist.github.com/house9/5690784.js"></script>
<noscript>
Your reader does not support javascript - please view configuration here - https://gist.github.com/house9/5690784#file-vagrantfile-multibox-chef-rb
</noscript>
<br />
Resources<br />
<br />
<ul>
<li><a href="http://docs.vagrantup.com/v2/multi-machine/index.html">http://docs.vagrantup.com/v2/multi-machine/index.html</a> </li>
<li><a href="http://jbbarth.com/posts/2011-03-20-vagrant-provisioning-with-chefsolo.html">http://jbbarth.com/posts/2011-03-20-vagrant-provisioning-with-chefsolo.html</a> </li>
</ul>
House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-27374607314219240102013-03-21T09:45:00.000-07:002013-03-21T09:47:49.983-07:00HipChat is now free!Just got an email from <a href="https://www.hipchat.com/">HipChat</a> - now free for small groups - awesome!<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRSNd5JBosARQWFWEDLUmYzQ8cTt6sNwUKF6n0WarCl7EnHuXiYtVwap6QbGiZHAtfyEfgxlFJHZ5PlQbCoZNaVc-0CWqRAWldLIeOhRVlYhrMEEsrzQp9l5iD4Le4cAupCNjSPZggurA/s1600/hipchat.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRSNd5JBosARQWFWEDLUmYzQ8cTt6sNwUKF6n0WarCl7EnHuXiYtVwap6QbGiZHAtfyEfgxlFJHZ5PlQbCoZNaVc-0CWqRAWldLIeOhRVlYhrMEEsrzQp9l5iD4Le4cAupCNjSPZggurA/s1600/hipchat.png" /></a></div>
<br />House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-87315322925967572802013-02-23T13:51:00.000-08:002013-02-23T13:51:43.257-08:00> random tricks you can do with RailsThere are bunch of really good nuggets in this presentation:<br />
<br />
<ul>
<li><a href="http://www.confreaks.com/videos/889-railsconf2012-ten-things-you-didn-t-know-rails-could-do">http://www.confreaks.com/videos/889-railsconf2012-ten-things-you-didn-t-know-rails-could-do</a> </li>
<li><a href="https://speakerdeck.com/jeg2/10-things-you-didnt-know-rails-could-do">https://speakerdeck.com/jeg2/10-things-you-didnt-know-rails-could-do</a></li>
</ul>
<div>
<br /></div>
House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-3268390039083718622013-02-23T13:42:00.002-08:002013-02-26T09:54:28.091-08:00Ruby on Rails continuous integration (CI) with Jenkins the easy way with Chef and KnifeDo you need a CI build setup for your Ruby on Rails app?<br />
<br />
Here are some <a href="http://www.opscode.com/chef/">chef</a> / <a href="http://matschaffer.github.com/knife-solo/">knife solo</a> scripts that will deploy a <a href="http://jenkins-ci.org/">Jenkins</a> server to run your <a href="http://www.martinfowler.com/articles/continuousIntegration.html">CI build</a> - you could be up and running in less than 1/2 an hour<br />
<br />
<a href="https://github.com/house9/ci_chef_jenkins_rails"><b>https://github.com/house9/ci_chef_jenkins_rails</b></a><br />
<br />
Check out the README for details<br />
<br />
<br />House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com1tag:blogger.com,1999:blog-3554775196719271875.post-71872939295158287862012-12-19T08:05:00.001-08:002012-12-19T08:05:29.457-08:00rails :remote => true jQuery eventsI constantly find myself looking these up, saving this link for future reference<br />
<br />
<a href="https://github.com/rails/jquery-ujs/wiki/ajax">https://github.com/rails/jquery-ujs/wiki/ajax</a><br />
<br />
contains all of the rails custom jQuery events for remote forms, such as "ajax:success", "ajax:before"; also includes the method signatures.<br />
<br />
<br />House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com1tag:blogger.com,1999:blog-3554775196719271875.post-86804942832105354282012-12-16T09:16:00.000-08:002012-12-16T09:19:20.440-08:00Sending email with Rails Mailers, The Random bits...<i>See the rails guides and railscasts for getting started with Rails Mailers; </i><br />
<i>this article includes some additional information on Rails Mailers not included in those articles.</i><br />
<br />
<b>RailsCasts: </b><a href="http://railscasts.com/episodes/206-action-mailer-in-rails-3">http://railscasts.com/episodes/206-action-mailer-in-rails-3</a><br />
<b>Rails Guides: </b>"<a href="http://guides.rubyonrails.org/action_mailer_basics.html">Action Mailer Basics</a>" on the rails guides - The guide covers all of the common mailer tasks<br />
<ul>
<li>setup and configuration</li>
<li>attachments</li>
<li>layouts</li>
</ul>
<br />
<span style="font-size: x-large;">Random Bits</span><br />
<blockquote class="tr_bq">
<i>These examples were created using rails 3.2</i></blockquote>
<div>
<div>
<span style="font-size: large;">Add importance headers</span></div>
<div>
<br /></div>
<div>
<script src="https://gist.github.com/4308619.js"></script></div>
<blockquote class="tr_bq">
<i>NOTE: many email clients will ignore these headers</i></blockquote>
</div>
<div>
<br /></div>
<div>
<div>
<span style="font-size: large;">Add receipt header</span></div>
<div>
<br /></div>
<div>
<script src="https://gist.github.com/4308683.js"></script></div>
<blockquote class="tr_bq">
<i>NOTE: many email clients will ignore these headers</i></blockquote>
</div>
<div>
<div>
<span style="font-size: large;"><br /></span>
<span style="font-size: large;">Testing mailer headers with rspec</span></div>
<div>
<br /></div>
<div>
If you have <a href="https://github.com/rspec/rspec-rails">rspec-rails gem</a> installed with your rails application then running the generator will stub out most of your mailer tests, including a fixture file for the mailer view, which you may or may not want to remove.</div>
<div>
<br /></div>
<div>
<script src="https://gist.github.com/4308712.js"></script></div>
<blockquote class="tr_bq">
<i>NOTE: test against mail.header, not mail.headers</i></blockquote>
</div>
<div>
<div>
<span style="font-size: large;"><br /></span>
<span style="font-size: large;">Use a different layout for some Mailer actions</span></div>
<div>
<br /></div>
<div>
our default layout is the customer facing one but we want to override it in some cases</div>
<div>
<br /></div>
<div>
<script src="https://gist.github.com/4309219.js"></script></div>
</div>
<div>
<br /></div>
<div>
<br /></div>
<br />House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-83949994232340385782012-11-03T11:11:00.000-07:002012-11-03T11:11:09.501-07:00Setting up a C.I. build (Continuous Integration) for a Ruby on Rails application<br />
It has never been easier than with Semaphore - Hosted Continuous Integration<br />
<br />
<ul>
<li><a href="https://semaphoreapp.com/">https://semaphoreapp.com/</a></li>
</ul>
<br />
How easy is it<br />
<br />
<ul>
<li>add semaphore ssh key to your github repo</li>
<li>then semaphore automatically determines your ruby version, database, etc...</li>
<li>you can tweak the build steps later, the defaults are pretty good</li>
</ul>
<br />
It will automatically detect new branches!!! That means zero setup when the new branch is added<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibLGy-jCjBoJf_BpMON1FOM-biBHzVqpOUg36byC4XbY8D86I3OrtZ9TWTXL8cFFrM6RT9LU4oeWKRy-9Tf2AWOgaX8qqPebT2rJZLKC8HMdeWMTKKo79eLTFDBbgzjf9Gpfy4fxa_5JQ/s1600/semaphoreapp-01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="348" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibLGy-jCjBoJf_BpMON1FOM-biBHzVqpOUg36byC4XbY8D86I3OrtZ9TWTXL8cFFrM6RT9LU4oeWKRy-9Tf2AWOgaX8qqPebT2rJZLKC8HMdeWMTKKo79eLTFDBbgzjf9Gpfy4fxa_5JQ/s640/semaphoreapp-01.png" width="640" /></a></div>
<br />
<br />
It is not <a href="https://semaphoreapp.com/pricing">cheap</a>, for personal side projects it might not make sense?<br />
But well worth the money if you are doing paid development<br />
House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-72764673713488463782012-11-03T10:47:00.004-07:002012-11-03T11:11:24.082-07:00Git Log Formatting The git log command is great and has tons of good information, but the output doesn't give you that nice 'overview' of the commit history, too much detail on too many lines<br />
<br />
I've been using the following in my .gitconfig file<br />
<blockquote class="tr_bq">
<span style="background-color: #cccccc;">l = log -20 --format='%h %ad %d %an: %s' --date=short</span></blockquote>
typing '<i style="background-color: #cccccc;">git l</i>' renders the following output:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZZi8Sf5RPrG_I7g20A-5Gz5pqwdjr0PV-iAikCPG7LYfW94WkVOLrH_OB8Ctph2BtaMxtjGCyGhKoWBHBr2n-YkuWG82wed1PeX4om0ViT2UuAJClB034cQs5yo1Qo_mgUPABHL-E6ko/s1600/git-l-01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="297" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZZi8Sf5RPrG_I7g20A-5Gz5pqwdjr0PV-iAikCPG7LYfW94WkVOLrH_OB8Ctph2BtaMxtjGCyGhKoWBHBr2n-YkuWG82wed1PeX4om0ViT2UuAJClB034cQs5yo1Qo_mgUPABHL-E6ko/s640/git-l-01.png" width="640" /></a></div>
<br />
<br />
Last night I watched the <a href="https://www.destroyallsoftware.com/">Destroy All Software</a> "<a href="https://www.destroyallsoftware.com/screencasts/catalog/pretty-git-logs">PRETTY GIT LOGS</a>" screencast which takes '<i style="background-color: #cccccc;">git l</i>' to the next level<br />
<br />
<ul>
<li><a href="https://www.destroyallsoftware.com/screencasts/catalog/pretty-git-logs">https://www.destroyallsoftware.com/screencasts/catalog/pretty-git-logs</a></li>
<li><a href="https://github.com/garybernhardt/dotfiles/blob/master/.gitconfig">https://github.com/garybernhardt/dotfiles/blob/master/.gitconfig</a></li>
<li><a href="https://github.com/garybernhardt/dotfiles/blob/master/.githelpers">https://github.com/garybernhardt/dotfiles/blob/master/.githelpers</a></li>
</ul>
<div>
<div>
now '<i style="background-color: #cccccc;">git l</i>' renders</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxIeu4ywTDAnH918yZxqm75DUrbphiVV2JuVKReVFkSniWzQq9cSHQHvyqC-tkYH45UM3BqGYjtHisRYjsrjS1aGCc35etEQP7_fLhCfmJutrwKxdxrjD-HFsW0VkfpuGdOPURO9xrmsE/s1600/git-l-02.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="242" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxIeu4ywTDAnH918yZxqm75DUrbphiVV2JuVKReVFkSniWzQq9cSHQHvyqC-tkYH45UM3BqGYjtHisRYjsrjS1aGCc35etEQP7_fLhCfmJutrwKxdxrjD-HFsW0VkfpuGdOPURO9xrmsE/s640/git-l-02.png" width="640" /></a></div>
<div>
<br /></div>
<div>
</div>
</div>
House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-67508350117747345622012-10-31T13:26:00.002-07:002012-11-03T11:11:47.881-07:00Helper script to delete git tags locally and remoteMight be useful to others, delete a bunch of git tags - remote and locally<br />
<br />
<br />
<script src="https://gist.github.com/3989586.js?file=build-and-execute-multiple-git-commands.sh"></script>
<noscript>
Your reader does not render gists; view code here -
<a href="https://gist.github.com/3989586.js?file=build-and-execute-multiple-git-commands.sh">https://gist.github.com/3989586.js?file=build-and-execute-multiple-git-commands.sh</a>
</noscript>
<br />
<b>Resources</b><br />
<br />
<ul>
<li><a href="http://nathanhoad.net/how-to-delete-a-remote-git-tag">http://nathanhoad.net/how-to-delete-a-remote-git-tag</a> </li>
<li><a href="http://www.linuxquestions.org/questions/programming-9/bash-read-every-line-in-the-files-and-use-the-line-as-parameters-as-another-program-246291/">http://www.linuxquestions.org/questions/programming-9/bash-read-every-line-in-the-files-and-use-the-line-as-parameters-as-another-program-246291/</a></li>
<li><a href="http://stackoverflow.com/questions/1605232/use-bash-to-read-a-file-and-then-execute-a-command-from-the-words-extracted">http://stackoverflow.com/questions/1605232/use-bash-to-read-a-file-and-then-execute-a-command-from-the-words-extracted</a></li>
</ul>
House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com1tag:blogger.com,1999:blog-3554775196719271875.post-70527762282511612012-09-05T07:22:00.004-07:002012-09-05T07:23:48.088-07:00414 Request-URI Too Large<br />
How to configure nginx to accept larger querystring requests<br />
<br />
Increase the '<i>large_client_header_buffers</i>'<br />
<br />
This is located in the '<i>http</i>' section of the configuration<br />
<br />
<b>Example:</b><br />
<div>
<blockquote class="tr_bq">
http {<br />
# override to allow long query string<br />
large_client_header_buffers 8 512k;<br />
<br />
...<br />
}</blockquote>
<br />
<b>Resources</b><br />
<br />
<ul>
<li><a href="http://stackoverflow.com/questions/1067334/how-to-set-the-allowed-url-length-for-a-nginx-request-error-code-414-uri-too">http://stackoverflow.com/questions/1067334/how-to-set-the-allowed-url-length-for-a-nginx-request-error-code-414-uri-too</a> </li>
<li><a href="http://nginx.2469901.n2.nabble.com/Nginx-returning-414-even-when-large-client-header-buffers-is-set-td7451517.html">http://nginx.2469901.n2.nabble.com/Nginx-returning-414-even-when-large-client-header-buffers-is-set-td7451517.html</a></li>
<li><a href="http://wiki.nginx.org/NginxHttpCoreModule#large_client_header_buffers">http://wiki.nginx.org/NginxHttpCoreModule#large_client_header_buffers</a> </li>
</ul>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-28578823442752962532012-08-25T12:25:00.003-07:002012-08-25T12:25:41.598-07:00Unofficial Twitter Bootstrap DocumentationUnofficial Twitter Bootstrap Documentation<br />
<a href="http://unofficial-twitter-bootstrap-documentation.com/">http://unofficial-twitter-bootstrap-documentation.com/</a><br />
<br />
The current project I am working on is running bootstrap 2.0.2 and after the release of 2.1.0 the online documentation for 2.0.x was gone.<br />
<br />
I went ahead and compiled the archive docs from the bootstrap github repo into a single site - hopefully others find it useful.<br />
<br />House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-52131609669565853882012-07-01T10:17:00.001-07:002012-07-01T10:17:05.147-07:00Rails - ActiveRecord created_by and updated_by gem<br />
Often your application will want to track who created and updated your data.<br />
On a previous rails 2 project I used a plugin called <a href="https://github.com/delynn/userstamp">userstamp</a> which worked well, but until recently it did not support rails 3+<br />
<br />
I didn't find any other gems out there at the time, so I put together the clerk gem,<br />
you can install it as a gem in your rails 3+ applications by adding <i style="background-color: #eeeeee;">gem 'clerk'</i> to your Gemfile, see the <a href="https://github.com/house9/clerk/blob/master/README.md">README</a> on github for details<br />
<br />
NOTE: the current version relies on your database tables having columns named created_by_id and updated_by_id and the gem does not support any custom configuration.<br />
<br />
<br />
<ul>
<li><a href="https://github.com/house9/clerk">https://github.com/house9/clerk</a></li>
<li><a href="http://rubygems.org/gems/clerk">http://rubygems.org/gems/clerk</a> </li>
</ul>
<br />House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-83975143915892902722012-04-29T11:45:00.000-07:002012-04-29T11:49:20.617-07:00postgres: random useful thingsRun sql statements from the command line, use the -c flag<br />
<script src="https://gist.github.com/2552568.js?file=postgres_sql_command.sql.sh">
</script><br />
<br />
create a random value<br />
<script src="https://gist.github.com/2552573.js?file=postgres.random_value.sql">
</script><br />
<br />
crazy updates using regexp_matches<br />
<script src="https://gist.github.com/2552587.js?file=postgres.regexp_matches.sql">
</script><br />
<br />House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-20271018258762878882012-04-29T11:35:00.001-07:002012-04-29T11:37:14.399-07:00postgres: terminate all database connectionsUsing psql from the command line you can terminate all connections to a database<br />
<div>
<br /></div>
<div>
<script src="https://gist.github.com/2552481.js?file=postgres_disconnect.sql.sh">
</script></div>
Comes in handy when you want to do things like restore your staging or development database<br />
<br />
<script src="https://gist.github.com/2552493.js?file=postgres_rebuild.sql.sh">
</script>
<br />
<div>
<b>Resources</b><br />
<br />
<ul>
<li><a href="http://www.postgresql.org/docs/9.1/static/reference-client.html">http://www.postgresql.org/docs/9.1/static/reference-client.html</a> </li>
<li><a href="http://blog.gahooa.com/2010/11/03/how-to-force-drop-a-postgresql-database-by-killing-off-connection-processes/">http://blog.gahooa.com/2010/11/03/how-to-force-drop-a-postgresql-database-by-killing-off-connection-processes/</a> </li>
</ul>
</div>House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-63243312907383009962012-02-03T18:06:00.000-08:002012-02-03T18:07:09.635-08:00Git WorkflowThis is the current git workflow we are using at work, your mileage may vary:<br />
<br />
<script src="https://gist.github.com/1734394.js?file=git-workflow.rb"></script><br />
<noscript>Your reader does not support javascript - see https://gist.github.com/1734394.js?file=git-workflow.rb</noscript><br />
<br />
<b>Resources</b><br />
<ul><li><a href="http://cheat.errtheblog.com/s/git">http://cheat.errtheblog.com/s/git</a> </li>
<li><a href="http://yanpritzker.com/gitbook.html#Keeping+a+topic+branch+in+sync+with+its+parent">http://yanpritzker.com/gitbook.html#Keeping+a+topic+branch+in+sync+with+its+parent</a> </li>
<li><a href="http://yanpritzker.com/gitbook.html#One+branch+per+bug">http://yanpritzker.com/gitbook.html#One+branch+per+bug</a> </li>
<li><a href="http://gitready.com/beginner/2009/02/02/push-and-delete-branches.html">http://gitready.com/beginner/2009/02/02/push-and-delete-branches.html</a> </li>
<li><a href="http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html">http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html</a> </li>
<li><a href="http://sleeplessgeek.blogspot.com/2011/03/using-git-cherry-pick.html">http://sleeplessgeek.blogspot.com/2011/03/using-git-cherry-pick.html</a> </li>
</ul>House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-26306459793587692622011-12-30T14:44:00.000-08:002011-12-30T14:44:24.829-08:00Inspect all jQuery events on an elementVery useful<br />
<br />
<span style="background-color: whitesmoke; color: #333333; font-family: monospace, verdana; font-size: 11px; line-height: 16px;">$("SELECTOR").data("events");</span><br />
<span style="background-color: whitesmoke; color: #333333; font-family: monospace, verdana; font-size: 11px; line-height: 16px;"><br />
</span><br />
All bound event handlers are stored in the elements data context under the events key<br />
This can be very useful when debugging with tools like FireBug<br />
<br />
<span style="background-color: whitesmoke; color: #333333; font-family: monospace, verdana; font-size: 11px; line-height: 16px;">$("form").submit(function () { alert('submit form'); });</span><br />
<span style="background-color: whitesmoke; color: #333333; font-family: monospace, verdana; font-size: 11px; line-height: 16px;">$("form").data("events");</span><br />
<span style="background-color: whitesmoke; color: #333333; font-family: monospace, verdana; font-size: 11px; line-height: 16px;">> Object { submit=[1] }</span><br />
<span style="background-color: whitesmoke; color: #333333; font-family: monospace, verdana; font-size: 11px; line-height: 16px;"><br />
</span><br />
Resources<br />
<br />
<ul><li><a href="http://www.bennadel.com/blog/1727-Viewing-jQuery-DOM-Event-Bindings-With-FireBug.htm">http://www.bennadel.com/blog/1727-Viewing-jQuery-DOM-Event-Bindings-With-FireBug.htm</a> </li>
</ul>House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-72804684238585421782011-12-02T07:07:00.000-08:002011-12-02T07:07:56.279-08:00Get table and column information in postgresUse the information_schema catalog - <a href="http://www.postgresql.org/docs/9.1/static/information-schema.html">http://www.postgresql.org/docs/9.1/static/information-schema.html</a><br />
<br />
Get table and columns from the public schema<br />
<br />
<script src="https://gist.github.com/1423507.js?file=select_table_and_columns_from_postgres.sql">
</script><br />
<noscript><br />
select <br />
tables.table_name, <br />
columns.column_name<br />
<br />
from information_schema.tables<br />
inner join information_schema.columns <br />
on information_schema.columns.table_name = information_schema.tables.table_name<br />
<br />
where tables.table_schema = 'public'<br />
and tables.table_type = 'BASE TABLE'<br />
<br />
order by tables.table_name, columns.column_name;<br />
</noscript><br />
<br />
This can be useful, maybe you want to auto generate some text that creates foreign keys based on a naming convention - for instance let's say we have a ruby/rails method called make_fk_unless_exists<br />
<br />
<script src="https://gist.github.com/1423533.js?file=create_fk_script_postgres.sql">
</script><br />
<noscript><br />
select <br />
tables.table_name, <br />
columns.column_name,<br />
('make_fk_unless_exists :' || tables.table_name || ', :' || columns.column_name || ', :' || REPLACE(columns.column_name, '_id', 's')) as code<br />
<br />
from information_schema.tables<br />
inner join information_schema.columns <br />
on information_schema.columns.table_name = information_schema.tables.table_name<br />
<br />
where tables.table_schema = 'public'<br />
and columns.column_name LIKE '%id'<br />
and columns.column_name <> 'id'<br />
and tables.table_type = 'BASE TABLE'<br />
<br />
order by tables.table_name, columns.column_name;<br />
</noscript><br />
<br />
The 'code' column would render something like<br />
<br />
<blockquote class="tr_bq"><i>make_fk_unless_exists :projects, :milestone_id, :milestones</i><br />
<i>make_fk_unless_exists :tasks, :project_id, :projects</i><br />
<i>...</i><br />
</blockquote><br />
<br />House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-44555797731078977892011-11-12T15:38:00.000-08:002011-11-12T15:38:08.421-08:00Sample Routes and Links with Rails 3 in the consoleThe content for this post is all from a gist, hopefully someone finds it useful<br />
<br />
<script src="https://gist.github.com/1361290.js?file=routes_link_to_in_rails_console.rb"></script><br />
<noscript><br />
Your reader does not support script, view the gist here<br />
https://gist.github.com/1361290<br />
</noscript><br />
<br />
<b>Resources</b><br />
<br />
<br />
<ul><li><a href="http://stackoverflow.com/questions/2778074/recognize-routes-in-rails-console-session">http://stackoverflow.com/questions/2778074/recognize-routes-in-rails-console-session</a></li>
</ul>House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-23680527366601909492011-11-09T13:48:00.000-08:002011-11-09T13:48:22.066-08:00Postgres: get the number of days in an interval<blockquote><span class="Apple-style-span" style="color: #38761d;">-- seconds / 60 = minutes / 60 = hours / 24 = days </span><br />
<span class="Apple-style-span" style="color: blue;">select</span> (((EXTRACT(EPOCH <span class="Apple-style-span" style="color: blue;">FROM</span> INTERVAL '<span class="Apple-style-span" style="color: #38761d;">2 years</span>') / 60) / 60) / 24)::integer <span class="Apple-style-span" style="color: blue;">as</span> number_of_days </blockquote><br />
good resource - <a href="http://stackoverflow.com/questions/952493/how-do-i-convert-an-interval-into-a-number-of-hours-with-postgres">http://stackoverflow.com/questions/952493/how-do-i-convert-an-interval-into-a-number-of-hours-with-postgres</a>House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com2tag:blogger.com,1999:blog-3554775196719271875.post-8457225060741589942011-10-15T09:07:00.000-07:002011-10-15T09:11:58.701-07:00Generating barcodes with ruby and railsRecently I had to convert some functionality from an old MS Access system to a Ruby on Rails application. The Access system generated a report that included a barcode; they were using a barcode font installed on the machine running access. I figured generating the barcode server side in the web app was going to be much nicer than installing barcode fonts on the client browsers. And since this is Ruby, I figured...<br />
<blockquote><i><span class="Apple-style-span" style="font-size: large;">There must be a gem for that </span></i></blockquote>Sure enough, the barby gem. It allows you to output your barcode as png, gif, svg, pdf, etc...<br />
<br />
In my case I generated png barcodes and included image references to those in my view files.<br />
<br />
Sample code<br />
<br />
<script src="https://gist.github.com/1289751.js?file=using_barby_to_generate_barcodes_with_ruby.rb">
</script><br />
<noscript><br />
# Gemfile, run bundle install after adding<br />
gem 'barby'<br />
gem 'chunky_png'<br />
<br />
# some code to generate the png file using 3 of 9 barcode style<br />
require 'barby'<br />
require 'barby/barcode/code_39'<br />
require 'barby/outputter/png_outputter'<br />
<br />
barcode_value = "099999333"<br />
full_path = "/somewhere/barcode_#{barcode_value}.png"<br />
barcode = Barby::Code39.new(barcode_value)<br />
File.open(full_path, 'w') { |f| f.write barcode.to_png(:margin => 3, :xdim => 2, :height => 55) }<br />
</noscript><br />
<br />
There is no pixel setting, it uses some other type of unit to determine size; using the xdim, margin and height options you can tweak the size, but I found that it was not very precise - <i>for my use case it was good enough.</i><br />
<br />
The generated barcode does not include the value, it is just the image which can be scanned using a barcode scanner, but it would be nice if there was an option to include the value below that. This is somewhat trivial to add in your view using html.<br />
<br />
Overall I was really pleased with this gem!<br />
<br />
Resources<br />
<ul><li><a href="http://toretore.eu/barby/">http://toretore.eu/barby/</a></li>
<li><a href="https://github.com/toretore/barby">https://github.com/toretore/barby</a></li>
<li><a href="http://barby.rubyforge.org/rdoc/">http://barby.rubyforge.org/rdoc/</a></li>
<li><a href="http://groups.google.com/group/ruby-barby">http://groups.google.com/group/ruby-barby</a></li>
</ul>House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com4tag:blogger.com,1999:blog-3554775196719271875.post-68359734159348586002011-09-18T17:04:00.000-07:002011-09-18T17:04:20.368-07:00NFL 2011 Sunday Night HD Stream for Free from NBCCheck it out here - <a href="http://snfallaccess.nbcsports.com/">http://snfallaccess.nbcsports.com/</a><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIagJMMRpgrXHaIs994xTJALqcgEjH3ucc1nncoM9Pm6Rs2yZ5IJaW1yPYbYdajbWJ8aRaqSAPApQqHYGqbWKPmW8uzGgYA7i3dUAfAqlrFcfFQaVp2o-7RKLENiuPmdyLW9U8L1Wsols/s1600/sunday-night-nfl.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="505" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIagJMMRpgrXHaIs994xTJALqcgEjH3ucc1nncoM9Pm6Rs2yZ5IJaW1yPYbYdajbWJ8aRaqSAPApQqHYGqbWKPmW8uzGgYA7i3dUAfAqlrFcfFQaVp2o-7RKLENiuPmdyLW9U8L1Wsols/s640/sunday-night-nfl.png" width="640" /></a></div>House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0tag:blogger.com,1999:blog-3554775196719271875.post-52808043490247457612011-08-22T09:35:00.000-07:002011-08-22T09:35:13.543-07:00CoffeeScript with Rails 2.3 and Rails 3.0I just uploaded a sample application that uses guard, coffee-script and a rake task to enable use of coffee-script with a rails 2.3 or 3.0 application. Check out the README file on github for details.<br />
<br />
<a href="https://github.com/house9/with_coffee">https://github.com/house9/with_coffee</a><br />
<br />
<br />
House 9http://www.blogger.com/profile/08045832658861127427noreply@blogger.com0