Disk Usage Information on Mac OS X
Get disk usage information about the Desktop
$ du -h -d 0 Desktop
14G Desktop
Information about how much free space is available on computer
$ df -lh
Filesystem Size Used Avail Capacity Mounted on
/dev/disk0s2 111Gi 109Gi 2.3Gi 98% /
...
Written by Sean Behan on 06/17/2012
Working with Branches in Git
Show all the branches
git branch
Create a new branch
git branch my_experimental_feature
Use that branch
git checkout my_experimental_feature
Pushing the new branch to a remote server
git push origin my_experimental_feature
Pulling that branch down...
Written by Sean Behan on 06/17/2012
A Through Z
How to print the alphabet in Rails very easily.
("A".."Z").each {|letter| link_to letter, "/#{letter"}
"A".upto("Z") {|letter| link_to letter, "/#letter"}
Written by Sean Behan on 06/17/2012
Fun with Apache2 - httpd not running, trying to start (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down
Have you ever gotten this error message when trying to (re)start Apache
httpd not running, trying to start
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
If you are running with ...
Written by Sean Behan on 06/17/2012
Rails Paperclip Plugin Options for Attaching Files
I usually change some of the default settings when I use the Paperclip plugin. For most of my projects I don't like having separate directories for each image that is uploaded. I prefer, in this instance, to put avatars of different sizes together under o...
Written by Sean Behan on 06/17/2012
link_to_function Rails Ajax Reference
Link_to_function syntax for Haml template. Notice the "|" pipe which will allow for new lines in your code.
= link_to_function( "Add Line Item") |
{|page| page.insert_html :bottom, :invoice_line_items, |
:partial => "line_item", :locals=>{:line_item=...
Written by Sean Behan on 06/17/2012
SHA1 or MD5 Hashing in Python
import hashlib
print hashlib.sha1("My wonderful string").hexdigest()
print hashlib.md5("My other wonderful string").hexdigest()
Written by Sean Behan on 06/17/2012
Dynamic Attributes in Python Model Class
class Bar():
def __init__(self, **args):
for key in args:
self.__dict__[key] = args[key]
b = Bar(fullname="Monty Python", email="me@monthpython.org")
b.fullname #=> Monty Python
b.email #=>me@montypython.org
Written by Sean Behan on 06/17/2012
Python Zlib Compress DeCompress
import zlib
regular_string = 'this is my string'
compressed_string = zlib.compress(regular_string)
decompressed_string = zlib.decompress(compressed_string)
print compressed_string
print decompressed_string
Written by Sean Behan on 06/17/2012
Pickle Python Objects
import pickle
entity = {
"user_id": "1",
"title": "Natural Dog Training",
"link": "http://naturaldogtraining.com",
}
pickled_entity = pickle.dumps(entity)
unpickled_entity = pickle.loads(pickled_entity)
Written by Sean Behan on 06/17/2012