Ruby Variable Pointers

Ruby Variable Pointers

Ruby variables point at objects

Posted in Uncategorized | Tagged | Leave a comment

HTML5 Flowchart

Posted in Uncategorized | Tagged | Leave a comment

National Vulnerability Database

National Vulnerability Database

Never knew this existed!!! Very interesting. 🙂

Posted in Uncategorized | Tagged | Leave a comment

Beauty of Brevity

Parentheses are optional in all Ruby method calls. Leaving them out is something called syntactic sugar.

Syntactic Sugar1

Just watched the video “Working with Procs & Lambdas” and loved the phrase syntactic sugar so much that I had to post it on Facebook.

(Video found here: Working With Procs & Lambdas)

It dawned on me by the end of the video that syntactic sugar isn’t just a neat trick in Ruby; it represents the philosophy behind the language itself. Matz wanted Ruby to feel natural and eliminating the need for parentheses seems subtle but really allows us to read and write code like this:

syntactic sugar

With parentheses, the body of the block above would look like this:
p.title(“My awesome paper”)
p.heading(“This is my paper”)
p.body(“The entire contents of my paper would go here.”)

Eliminating the need for parentheses allows for organized indentation and visual repetition of structure, which allows your eyes to focus immediately on what’s relevant.

Beautiful. Love it!

Posted in Uncategorized | Tagged , , , , | Leave a comment

open -a “Google Chrome”

This is the last time I will accidentally click Firefox when I meant to open Chrome. 
Image

If you are already in terminal, you can type in $ open -a “Google Chrome” to do so without reaching for your mouse! 100% accuracy unless you forget the quotes.

This works with other apps as well — and I imagine this extends to any app in your applications folder. $ open -a firefox should open Firefox (duh).

But in the end, it occurred to me that you could always just hotkey Spotlight (check your settings to figure out what it’s set to; mine is cmd + spacebar) and just type Chrome. Duh. 🙂

Posted in Uncategorized | Tagged , | Leave a comment

Ruby: Each vs Collect

Working through Codeacademy — I’m 67% done! Woohoo!

So the .each and .collect methods — how do they differ?

I read up on this here but in summary, array.each returns the original array whereas array.collect returns the new array. Slight detail but important nonetheless.

Posted in Uncategorized | Tagged | Leave a comment

HTML5/CSS3 Review

Progress: Mixing and matching steps.

Previous experience: HTML4/XHTML and CSS2

Treasure Hunt

It can be frustrating reviewing a large amount of content, but I’ve been dutifully going through each video listed on the pre-work so I don’t miss anything. True, I could just learn as I’m actually doing it, but perhaps because of my intense RPG-gaming background, I have this slight OCD need to “get everything in the game”. It’s like that student who won’t settle for less than 100% on every test. Clearly this is an unsustainable way to live.

I am going to change my review strategy from “get everything” to “get enough”.

This is hard to do for the seasoned treasure hunter. Imagine telling a pirate that he should only get SOME of the gold from a sinking ship. It just won’t make any sense. Why NOT get all the gold?

Okay, I am clearly going on a tangent. Anyway, back to work! I am going to post helpful resources and notes below. So…

TL;DR Below is a list of resources for anyone learning CSS3, having had experience (long ago) with CSS2.

==================

Flatiron Pre-work

CSS Cheat Sheet

caniuse.com — checks browser compatibility

-Webkit? -moz?

W3 Schools: CSS Reference

Colorzilla Gradient Editor

==================

NOTES

input[type=”submit”] —> attribute selector

tr:nth-child(even)

Problems with floating elements?
clearfix
Box Sizing
Check margins
CSS tricks – floating
iOS Orientation Change Fix

Postion: Relative (to where it used to be), Fixed (always same place on browser window; moves with scrolling) and Absolute (Sets position based on browser window; doesn’t scroll)

Block level elements (ex: <div>) with no width specified (width: auto;) will scale horizontally as far as they are able to, until they run into their parent container.

Posted in Uncategorized | Tagged , , , , , | Leave a comment

Command Line

Progress in Pre-work: First step.

Est. time 2-6 hrs… It’s definitely taking me a lot longer than I expected. I’m familiar with command, but my knowledge is basic. Here are some questions, and a couple of answers.

==LESSONS LEARNED==

1. You have to create the .bash_profile file.
After trying to open ~/.bash_profile in every way possible, I learned that your OS doesn’t automatically create the file for you. touch $HOME/.bash_profile did the trick.

Seems simple, right? Then why would it take someone so long to figure this out, even after seeing that .bash_profile doesn’t exist in the root directory? Let me explain myself here. My current understanding is that when you open terminal (a login shell), it will automatically look through several files, one of which includes .bash_profile (.bashrc and .bash_login are the others). It was unclear where these files were located, but I’d always assumed that if you logged in when you booted up your computer, you’d also automatically have a profile associated with your account. This is what made me rack my brain. At some point, I even concluded that cd ~ wasn’t really bringing me to the “root” directory, which in my case is /Users/dbc26. I thought the root would be ‘/’. Wouldn’t that make more sense? I even checked to see if .bash_profile would be in that folder but no cigar. So currently, I understand it this way: Every user on this machine who logs in might have a different root directory. In fact, you can change your root direct by changing CDPATH. Wherever your root directory is is where you will want to create your .bash_profile file.

Hopefully some wiser panda is reading this and can enlighten me to the true, bamboo path. “Path”. Hah.

2. Removing files with intimidating names like ‘deleteMeAndMacExplodes.dylib’.
After installing Brew, console will recommend you run Brew Doctor, so I did. 5 warnings already (wtf??). Some fixes were easy and took minutes. 2 were particularly painful. Here’s the first:

Warning: Unbrewed dylibs were found in /usr/local/lib

Forum answers were as simple as, “wipe your HD, reinstall everything” and as ominous as, “delete the unwanted files, at your own risk.” I scrounged forum after forum hoping for a magic alternative when finally, the voice of my former AP US History teacher kicked in after 2 hours of searching: “You’re done researching when you stop finding anything new.” Clearly, I was done 1.75 hours ago. Then it dawned on me: just Google the files you need to delete. I did, and they were from some app a friend installed on my comp to access files from work remotely a long time ago.

So why wasn’t this obvious to begin with? First off, I’d been instructed to download and run the Rails Installer, which installed 9 cryptic, unseen components to my computer. Moreover, I’d read a long thread on osx-gcc installer needing some update since it was packaged with an older version of Xcode. Deleting a file could create even MORE problems (aarrrghh!!) so I shied away.

Secondly, most people who posted the same error didn’t have the same files as I. I overcame my fear after noticing that a few had some common files here and there and concluded that if they weren’t reporting problems after deletion, perhaps I won’t either.

The ball finally began rolling when I also started looking for specific files and ACTUALLY READING the filenames. Deleting something like “libSFsqlite3.7.4.dylib” doesn’t sound so foreboding when you realize sqlite could easily be a torrent downloader or something. Turns out several of mine were from an app a friend installed on my comp long ago to access files from work when his computer died. Boom, done. DELETE!!!!.

TL;DR Delete the unwanted files if you get a DYLIB warning… but make sure to Google where those files are from so as to cover your @ss.

3. When in doubt with permissions, just login as root user. (I will get to this point in the last paragraph. Jump to the solution below if you’d like.)

The other grueling warning that consumed me for over an hour was:

Warning: You have a non-Homebrew ‘pkg-config’ in your            
             PATH: /opt/sm/pkg/active/bin/pkg-config

My first instinct was to edit PATH in .bash_profile. I did so, deleting all instances of /opt/sm/… Done! Or so I thought. When I typed $PATH in terminal again, I got:

$PATH
-bash: /usr/local/rvm/gems/ruby-1.9.3-p392/bin:/usr/local/rvm/gems/ruby-1.9.3-p392@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p392/bin:/usr/local/rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/local/rvm/gems/ruby-1.9.3-p392/bin:/usr/local/rvm/gems/ruby-1.9.3-p392@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p392/bin:/usr/local/rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/opt/sm/bin:/opt/sm/pkg/active/bin:/opt/sm/pkg/active/sbin: No such file or directory

It’s still there! ARGGH.

But there are definitely some clues here, which I have yet to solve and no more patience for today. Here are some questions to explore later:

  1. Why didn’t changing PATH in .bash_profile work? /usr/local/bin is top of the list currently so that rules out loading from /usr/bin.
  2. Why does the PATH repeat itself?

After more scrounging forums, I found this solution, which brings me back to the title of this third lesson.  When modifying a script that contained a PATH entry, the script would open in Xcode. It denied me permission to write, so after some more research, I tried a sudo chmod 777 command on the file. When THAT didn’t work, I figured that I probably have to open Xcode as root user to gain permission. At this point, I had fixed 5 other warnings and decided to just log in as root user using directory utility. It worked… but there are some branch-off questions (see below).

==UNRESOLVED/CURRENT==

1. Why doesn’t tab completion complete a cd command until the point of conflict like so many blogs and articles says it would?

2. What happens if I entered touch file.txt twice? Does it re-write?
— I edited the original file and when I did my second touch, none of my edits were erased. Does this mean touch does nothing if the file already exists?

3. Currently working on (source): **UPDATE: Resolved**

  • If you’re using RVM, it will add when it installs itself. This essentially is a conditional which says if the file at ~/.rvm/scripts/rvm exists bash should load that file. You can check to see if this file exists yourself by doing ls $HOME/.rvm/scripts/rvm

QUESTION: What if it says it doesn’t exist? Currently checking to see if my path is correct, though I do know if I type rvm -h, the console knows what I’m talking about.

Resolution here.

Posted in Uncategorized | Tagged , , , , | Leave a comment

First Post

Hello reader!

This is a code journal. I will be attending the Flatiron School in a month and am working through their pre-work.

Until this month, I was a high school math teacher (Bronx / Manhattan). I caught the coding bug (“decoding bug”, you say? ^_^) when I decided to take an internship in 2011. I hear it’s permanent.

In any case, if you’re reading, chances are either

  • you either know me,
  • have a common interest in code, or…
  • …you’re a panda.

Feel free to comment 🙂

 

Posted in Uncategorized | Leave a comment