jr3 (63K)

Recap from Ruby Coding Group: 8-11-07

Posted by Jessica Thu, 27 Sep 2007 00:03:00 GMT

  • Make sure Ruby, Rails, MySql & Subversion are installed and working properly on your machine.
  • Create 2 databases: atlrug01_development & atlrug01_test
  • Login to Assembla where the atlrug coding project 1 is being hosted. You need to be invited to the atlrug project in order to checkout the project with subversion.
  • Checkout the atlrug project: svn co http://tools.assembla.com/svn/atlrug. You will have to enter your assembla password and username in order to check the project out.

Here are two options for syncing the data between development databases in rails:

1. export and import sql—using a command like this one…

mysql -u root -p atlrug01_development < /path/to/your/project/.../atlrug/atlrug01/trunk/atlrug01/db/development_data.sql

2. fixtures + yaml

I placed a rake task in lib/tasks that will take whatever is in the db and dump that into a yaml fixture located in test/fixtures.

After checking out the latest version of the project, you run rake db:migrate & rake db:fixtures:load to import the yaml to your db.

Full instructions here: http://snippets.dzone.com/posts/show/3393

Digg is my guilty pleasure...

Posted by Jessica Tue, 01 May 2007 17:18:00 GMT

Dear Digg,

I just don’t know how to quit you. Your front page with its ultimate tutorial lists, DIY hacks, news of new software releases, links to photos of scantily-clad women & oh God, don’t get me started on diggnation. Digg, you make me feel… inadequate. There’s always something new to tweak, new software to try, links to bookmark, news stories to, err…’research’. I can’t keep up.

And who’s fault is it that I feel inadequate? Well, I certainly can’t be the one to blame; you are everywhere! Even after removing all digg artifacts from my browser, I cannot escape the ‘digg this’ buttons & the ‘top-on-digg’ widgets slopped on various blogs (I think there was one on this blog at one time). You are in my internetz, destroying my blankspaces & thus, my self-esteem (not that that is terribly hard).

I want my simple, pre-digg life back; a life where I did important things, like save kittens & write “bad” poetry.

Fortunately, my interest in mouseHole has given me reason to spend less time at digg and more time at code.whytheluckystiff.net/mouseHole/ (Google says I’ve made 6 visits since the middle of this month! & that excludes all of the internet stalking I’ve been doing at the library). Now, I know what your’e thinking… “Just write a nice little mouseHole script to removes all of the digg paraphernalia from around the web.” And writing such a script would be a smart thing for me to do; my time away from digg would result in more time away from digg. But alas, I can’t seem to quit you. In fact, the mouseHole script that I ended up writing [1] uses your new API to display the number of diggs for the page I am currently viewing, along with (what else) a link to that page on digg.

And you know, the thing is that I suck at writing Ruby. Hell, I don’t even know if I’m a programmer yet. I have lots to learn and do with Ruby; I don’t have time for you & your front page and especially not for your comments or video podcasts. Maybe you could meet me half way and make yourself a paid-members only site? No? Then, I am hopelessly yours. Just promise me that you won’t take all of my time and that if you ever leave me for good, that you will return that little piece of my heart that I have given to you.

Lovingly, but irritatedly,

JessiRae

[1] Using this Ruby Digg Wrapper, I added to the browserbar.rb mouseHole script that I created earlier. The browserbar script places a list of links at the top of every page; the list forms a bar, similar to the plugins and quick links firefox makes available. Yeah, sure you are making all of your web surfing known to digg, but that just makes the guilt stronger. To use the digg “plugin”, place the digg.rb wrapper in your {mouseHole_root}/lib/mouseHole directory.


UPDATE:

Digg is sick right now. :-(

Get well soon.

Browser Bar for mouseHole

Posted by Jessica Tue, 24 Apr 2007 23:06:00 GMT

Add the following line to any of your user scripts in your .mouseHole folder to add a browser bar at the top of every page your view with mouseHole; like this…
def rewrite(page)
  document.search('//a[@href]') do |link|
    href = URI(link.attributes['href']) rescue nil
    next unless href && href.host && href.host != page.location.host
    link.after '<span style="font-size:8px">[' + href.host + ']</span>'
  end

#add the following line 
  document.search("body").prepend("<a href=\"http://del.icio.us/jowensbysandifer\">" 
  +"<img src=\"http://127.0.0.1:3704/doorway/static/images/delicious.gif\" />" 
  +"</a>")
#just include your links to your favorite sites and you can check them... 
#   no matter where you are

end

Oh and don’t forget to place any icons in the static/images folder in your mouseHole application.

-Teehe! And if I knew how to get the url to the script, I could submit sites to del.icio.us (or whatever site I wanted) via javascript… but that might be dangerous!-

UPDATE:

Here’s how to submit a site to del.icio.us via the browser bar by getting the page url.

Step 1: save the request in proxyhandler.rb as $request. A global… bad I know :-( I’m still figuring out how mouseHole works. Maybe the best thing to do would be to write the value out to the database?

Step 2: add submit html to a user script or create a new one (I call mine browserbar.rb), like this…

document.search("body").prepend("<a href=\"http://del.icio.us/jowensbysandifer?url=" 
+ $request.to_s + "&submit=save&jump=no\">" 
+" <img src=\"http://127.0.0.1:3704/doorway/static/images/delicious.gif\" /></a>")

Step 3: Restart mouseHole.

Installing Openssl on Ubuntu

Posted by Jessica Mon, 12 Mar 2007 04:25:00 GMT

If you have tried to install Mechanize or any gem that requires openssl on Ubuntu or Debian, you may have encountered the following error…

LoadError: no such file to load—openssl

despite the fact that you have installed openssl with “gem install libopenssl-ruby”.

Thanks to this thread, I found out that in order to install openssl, you have to tell ruby how to compile the openssl extension, like this…

cd /ruby-1.8.4/ext/openssl
ruby extconf.rb
make
make install

Some things I learned last week...

Posted by Jessica Mon, 26 Feb 2007 19:51:00 GMT

  1. You can’t really crop in Inkscape. :-( But you can change the size of a svg drawing to get some perspective on how large or small the drawing will be after it is exported.
  2. Ctrl + Alt + A opens align window in Inkscape.
  3. To create Stylish Text with GIMP create a new layer, select a portion of the text to make shiny from original layer, copy and paste selection into new layer and change the color of the pasted portion.
  4. This is how good iterative web design goes.
  5. Y Combinator is now accepting applications for summer 2007 funding. Aahhh, if only I were confident and had a partner.
  6. There are a number of sites that support OpenID. What prevents someone from claiming your site as their own (other than it being against OpenID’s policy)?
  7. On the Rails deployment learning front, I discovered that ‘require_dependency…’ lines go in environment.rb and not in the controllers themselves (at least for how my hosting company has things set up).

Grab all of the href links from a Page

Posted by Jessica Tue, 06 Feb 2007 17:49:00 GMT

Use Rubyful Soup to get all of the hyperlinks on a page…

soup = BeautifulSoup.new(page_content)
result = soup.find_all('a')
result.each { |tag| 
  urls[i] = tag['href']
  if urls[i].to_s.slice(0,1) != 'h' then
          #add first part of url to href link if link is internal
          urls[i] = home + urls[i]
  end
  i = i + 1
}

Multiline Comments with Ruby

Posted by Jessica Thu, 25 Jan 2007 06:00:00 GMT

I didn’t know that ruby has multiline comments.

    =begin

    Name:

    Last Updated:

    Location:

    ...

    =end

Well, at least I wasn’t the only one.

Sitemap with Rails

Posted by Jessica Sun, 21 Jan 2007 00:07:00 GMT

I finally got around to generating a sitemap for this site. I used these instructions for creating sitemaps in rails. Very simple and straight forward instructions.

Unfortunately, the sitemap created isn’t valid according to google. The xml document created has <link> tags instead of <loc> tags which google webmaster requires.

I am guessing that these errors mean that my sitemap is useless to Google. Still looking for a solution and will post an update as soon as I find one.

Install mouseHole on Ubuntu 1

Posted by Jessica Mon, 15 Jan 2007 06:23:00 GMT

mouseHole is a personal proxy server written in ruby, allowing you to…

rewrite the web as you view it, altering content and behavior as you browse. Basically, it’s an alternative to Greasemonkey, which does similar things from inside the Firefox web browser.

To get mouseHole up and running, first install the required gems (json and sqlite3) if you don’t already have them installed. I encountered the following issues while installing those gems…

Lastly, if you are running Debian or Ubuntu, visit http://localhost:3704 instead of http://127.0.0.1:3704 after starting mouseHole.

One-liners

Posted by Jessica Sun, 07 Jan 2007 04:18:00 GMT

and Frequently used commands I can’t seem to remember the exact syntax of. Nothin’ fancy.

Linux
find . -name \*.* | xargs grep search_string

    navigate to folder you would like to search, enter this command with the search string you would like to find and this command lists all files containing that string
ps x -Ho pid,args
    lists all of the processes running
find / -name gcc
    finds all folders named gcc
sed '/$/,/' /home/Desktop/jessirae > /home/Desktop/jessirae2
    places a comma at the end of each line
paste -sd '\0' - /home/Desktop/jessirae2 > /home/Desktop/jessirae3
    The NEWLINE character of every line except the last line in each input file will be replaced with a separator

Ruby

"<a href=\"http://www.oldurl.com\">JessiRae.com</a>". gsub(/(http?:\/{2})\S+\.(\w+)(\S+)/,"http://www.jessirae.com/blog/")
    global substitution replaces all instances of some expression in a string with some other string or performs some function on that string
require 'open-uri' .... open(url) { |page| page_content = page.read() page_content }
    returns html from specified webpage

Older posts: 1 2 3


designed by jowensbysandifer