Commands for Vim Macros

q<register>                                        start recording into <register>        (ex: qq, qw, qe, q any char)

q (when rec)                                      end recording

@<register>                                      execute macro saved in <register> (ex: @q, @w, @e)

<num>@<reg>                                  execute macro saved in <reg> <num> times

@@                                                    repeat last macro

:g/<pattern>/normal @<register>   run macro every time we match the pattern

:reg(isters)                                         check the contents of all registers

:reg <reg_id>                                     check the contents of a given register (this can be chained with several registers, Ex: qwe checks register q, w, and e)

let @<reg_id>='<commands>’          to manually create macros

Render Vs. Redirect_to in Rails

New to Rails and poking around a controller. You are bound to come across the methods render and redirect_to.

render ‘new’

redirect_to root_path

If you are wondering, “what is the difference between the two and how do I know when it is appropriate to use either?” this is the right place to be : D

Cheers to you for being so resourceful!

Render pulls the specified view and fills it in with the current information set while redirect_to hits the specified controller action.

Consider the following snippet for a user create action:

def create
  @user = User.new(params[:user])
  if @user.save
    sign_in @user
    flash[:success] = "Welcome to RideSociable. Your carriage awaits."
    redirect_to @user
  else
    @sub_title = "Sign up"
    render 'new'
  end
end

Note: in rails “redirect_to @user” is equivalent to “redirect_to user_path(@user)”

In this case redirect_to hits the user#show action in the users controller. The show action can then run code and set various variables (ex: “@user = User.find(params[:id])”) and render the show view users the variables it sets. render, by contrast, does not trigger the user#new action. It merely renders the ‘new’ view using the parameters set in the current action.

Why use render in this case?

The user has not provided valid credentials and cannot be added to the database. The user must fill out the form again. You can do one of two things:

  1. give the user a new blank form to fill out
  2. give the user a new form with most of their data filled in

Option two is much more user friendly and doesn’t discourage a potential user from signing up. Go with that one. @user has pulled all the data from the users submitted form. If you redirect_to the new_user_path to return the user to the form you will not have access to any of the data you just pulled from the form using “@user = User.new(params[:user])”. If you use render, you will pull the specified view using the variables you just defined, pre-filling in the form with most of the data the user needs.

render uses the currently defined instance variables and specifies a view to render

redirect_to sends a new request to the browser. It hits a new controller action and sets new variables.

Let me know if anything was unclear. Hope this was helpful.

David

Home Has a Funny Way of Saying Welcome Home.

NOTE: Written December 27th, but not posted until new years day. Sorry gang.

Saturday December 17th, 10 days ago, I was suffering the consequences of accumulating a massive sleep deficit. I traveled from text books and laptop pixels, to a semi social celebration, and finally settled on a massive technology and sugar crash. Whisked away from a life of stress and passionate isolationism, I traveled the land of the maple leaf with the rest of the Lichtenberg/Danenberg gang in tow (aka moms and big bro).

WARNING: This post is personal and mostly serves as an attempt to collecting my thoughts from the jumble I would like to call the last week and a half. If you don’t like rantings and disorganization, here is your out. We can just talk next time. No hard feelings, imaginary reader I am pretending will actually stumble on my blog and be interested in it!

Here were the highlights of the trip for me:

The Discovery of Global Warming

#spooky

Heading most of the way to the ice castle before realizing it hasn’t been built (oops).

Yep, no snow equals no ice castle. Is this not reason enough to crusade with big blue recycling bins. Take that global warming.

Injuring my neck while awaking up from glorious slumber

(THIS HAPPENED, I WAS OUT OF COMMISSION FOR TWO DAYS). Here’s just the tip of the conversation:

David: Silence
Daniel: Silence
David: …umm daaniel
Daniel: (pretending to still be sleeping)
David: hey…daniel
Daniel: (deeply concentrating on not having an early morning conversation with baby bro)
David: daaaniel, I think I broke my neck
Daniel: …
David: DANIEL CALL MOM I STRETCHED TOO HARD AND I CAN’T MOVE MY NECK
le when medics arrive:
David: who do you think is going to be able to help me get pants on?

Not having cellphone service or a computer. This cannot even be expressed using people words. Your brain definitely adapts to the shifts in focus associated with information flux. Disconnecting, at least for some time makes you feel smarter and more relaxed.

Spending christmas eve exploring a beautiful city in icy cold air with some of my favorite people. We went to Chinatown, a beautiful cathedral, steak dinner, and a piano bar with a really talented musician, all in one night. Nights like this are all I can hope for in life.

Quebec City and Montreal are beautiful, but enough about the trip.

Let’s talk about how much you regress when you see people from your past. so much. I saw my old friend Ben and we acted like the giddy 16-year-old trouble makers we once were. I’m oh, so, immature.

I saw my old friend Matt, we succeeded in stressing the (heck darn) out of each other about making something decent of ourselves until we came to a verbal agreement to go out in the near tropical rainstorm occurring outside. We pretty much just walked and talked for a while, then walked and didn’t talk for a while. We gave up when our jackets soaked through. That’s what I came home from tonight. That is why I am all introspective and inspired to exude beautiful prose without necessarily possessing any solid direction or structure. My brain is repeating the thought, “If you don’t push yourself forward, you won’t end up forward.” and then gracefully dancing around itself teasing “Don’t take life to seriously; you’ll never get out of it alive.” Thanks Elbert Hubbard. There’s something about being a semi-intelligent person in your early twenties that makes you so hyper-focused on proving yourself.

Let’s blame globalization. Or the pressure associated with the increase in the cost of education. Output must be greater than or equal to cost. My what a deep hole we’ve just dug (tuition). Then you get to the point where you realize how many people don’t even get to learn about the things or meet the people who you do. You remember that the things that stress you out and make you uncomfortable with day-to-day operations are an opportunity and a choice. They were and are a blessing. You force yourself to breathe. You remember to push yourself forward. Then you remember it’s good to do good.

It’s good to do good. Only one person can be the best. It probably won’t be you or me. Do what you can, and that isn’t meant casually. Feel good mentalities, aren’t always realistic, but they sure feel good.

David

The Romance Of Starting Up

Starting a startup is romantic. You need to be passionate about something and have the willingness to sacrifice (time, money, emotional state, etc.) to back up that passion. One day soon, you’ll make it with big beautiful sparkle stars in your eyes. You’ll be meeting all the people to meet and seeing all the places to see.

But, until then, you’ll probably be doing the following (The tell-tale signs that you’ve just completed your first week):

  • You have been wearing the same pajama bottoms for four days straight: heh. I will impress no one.
  • You understand that surviving on ramen is a myth and impossible: Eating only ramen for several days straight is nutritionally irresponsible, no matter how much time and money you save. This bad boy eats breakfast cereal.
  • You think whiteboards are the bees knees: Sure, there’s only one or two of you, and white paper could probably do the trick. But hey, it’s time to be professional.
  • You finally understand how expensive Google AdWords is: I have put this service on a pedestal day in and day out for the past week, UNTIL, Matthew, my cofounder, and I actually tried to create an account. Our budget allowed for us to buy two clicks a day! We don’t have any source of revenue. Please don’t bleed us dry mr. internet.
  • Your mom really likes your idea: Pretty much all the validation this guy needs. I’ll see you when I’m on top of you, World.

Really though, it has been a lot of fun and a lot of hard work. It is a lot of taking shots in the dark and hoping they hit a target. When you’ve never done something like this before, you don’t really know what is a valuable use of your time and what isn’t. You just try to estimate, act, hope for the best, analyze the results, re-estimate, rinse and repeat. Matthew’s and My expectations aren’t to make it big and cash out. I just have an idea of how the internet could make people’s lives more fun. We both want to see it make some people happy. That is the prettiest target you can try to hit.

I hope this intrigued/informed/fascinated/inspired you. If not, I’ll try harder next time, and you can let me know what I can do better @dmlicht on the twitters. learn more about the project at the ice cream rock blog.

Thanks for reading,

David

The Five Important Steps to Finals Preparation

Step one: Prepare your body

English: A Snickers candy bar, broken in half.
This is my life right now. Prepare your body
Thinking hard is a lot like running a marathon. If you are not well nourished you could die. You obviously won’t have time to take a break later, so go to your local supermarket and purchase every flavor of snickers bar. Junk food is better because it has a higher caloric density. This means you get more nourishment faster! Buy as much as you can, then go get an ice cream sundae. You’re not chubs, you just mean business.

Step two: Prepare your mind

If you focus too hard you WILL go crazy. It is your responsibility to yourself to relax for a moment. Get it all out of your system. Go ahead, watch a few hours of YouTube. Call everyone you need to catch up with. Don’t worry if they seem like they don’t want to talk to you because they actually have $#!+ to do. They will appreciate your friendliness, you bright little bundle of sunshine you. Be sure you spend time stalking people you don’t care about and have no relevance to your life on Facebook. It gives you perspective.

Step three: Make your rounds on social medias

Twitter
You will be off the map for so long with your intense studying. It’s important you maintain the badass internet persona that you’ve worked so long and hard to build (23 followers on twitter, awws yeah). Make important lists; how to prepare for finals.

Step four: Organize

You can’t study if your environment is not clean and organized. Don’t even worry about learning until you have several different hand written lists of what you need to learn, organized by: date due, date assigned, subject, importance, spelling, how much you don’t want to do it, and teacher hotness. You’ll probably only use the last list, but it is good prepare just in case. Don’t forget to do laundry, vacuum, and organize your socks by length and color.

Step five: Rest Up

Cougar sleep

Murr

It’s been a long day. Sleep deprivation does not offer promising results. You are going to do an awesome job tomorrow if you take the night off and go to bed at 8PM.

Want more finals related humor:

I Have to Laugh About Finals So I Don’t Cry

Top 5 Things To Do In The Library During Finals

Finals Week Oh NO

If you like this post, follow me on twitter. There is more where this came from and 23 IS the loneliest number.

Question:

What do you do to prepare? What do you do to de-stress?

Want to learn a thing or two about programming, right here, right now?

Official Ruby logo

Image via Wikipedia

Don’t be lazy. It will take 10 minutes and, in fact, its fun. At the very least, it will make you seem pretty darn smart. Just click the first link:

tryruby

You should only be reading this if you finished the try ruby tutorial. If you did not, click ^ lazy bum.

Computer Science Education Week is coming to a close. The premise of the week is to spread a little information about CS to people who may not have heard of it, or understand what it is. Understanding the core principles and trying a project out for yourself can sharpen your thought process and give you new perspectives in problem solving, productivity, and organization. There doesn’t need to be a special week to spread the knowledge, but since we have one, this is a great time to share some sites that make it easy to get a free sample. (Don’t act like you’ve never been to Costco and done unspeakable things to your tummy). Soon enough you’ll be doing this (note: type to understand)

 

In Browser Coding Based:

Trybloc

Trybloc is free and provides an awesome introduction to programming using ruby through the style of learn by doing. With Trybloc you learn to code by writing code in the browser.

http://www.trybloc.com/

Course Listing:

Code School

They are the people who brought you tryruby and as you may or may not have noticed, they also let you code in browser. There are a few courses provided for free, however most of the content can be aquired either through monthly subscription or individual course purchases. The individual courses are pretty pricey, so if you are serious about learning some web development I suggest the monthly subscription ($25/mo). Code school is my personal favorite. They get my dollars every month.

Check out their free course: Rails For Zombies

http://www.codeschool.com/

Course Listing:

 

ScreenCast Based:

Tutsplus Network

Tutsplus provides courses, screen casts, and written tutorials. They have a large selection of tutorials available for free spanning everything from web development and design to Photoshop effects to audio production. Tutsplus is an AWESOME resource. The full courses are a new feature, and require paid subscription.

Check out their free course: 30 Days To Learn HTML and CSS

Course Listing:

Treehouse

Treehouse teaching web development and design through videos and quizzes. The Treehouse website is very pretty, which bears significance for a website that teaches design. I haven’t yet tried any of their course offering; I’ll let them speak for themselves:

www.teamtreehouse.com

 

Closing:

Try to share this with someone who doesn’t know what computer science is or someone scared of computers! Writing a little code is empowering and encourages them to get the most out of their machine.

If you want to learn more and really get the fundamentals down, I suggest checking out the head first books series: http://amzn.to/shjivG

Is there anything awesome for beginners that I left out? What is your favorite resource?

Thanks for reading,

David

Demo Art

Okay this is really the last of it until after my databases exam! I have a serious problem.

Also, If any people like the image / want to know how it was made, I can make a tutorial. Let me know.

David

Free online courses from stanford

View from Hoover Tower observation deck of the...

Image via Wikipedia

It is amazing when institutions make an effort to spread free flow of information. I was really excited when I found out Stanford was offering full CS courses, both video lectures and assignments, free for anyone to enroll in. I was, however, unable to find a comprehensive list of all courses being offered. I poked around Stanford’s website a bit and assembled this list:

Computer Science:
Machine Learning, Andrew Ng
Computer Science 101, Nick Parlante
Software Engineering for Software as a Service, Armando Fox and David Patterson
Human-Computer Interaction, Scott Klemmer
Natural Language Processing, Chris Manning and Dan Jurafsky
Game Theory, Matthew Jackson and Yoav Shoham
Probabilistic Graphical Models, Daphne Koller
Cryptography, Dan Boneh
Design and Analysis of Algorithms I, Tim Roughgarden

Entrepreneurship:
The Lean Launchpad, Steve Blank
Technology Entrepreneurship, Chuck Eesley

Medicine:
Anatomy, Sakti Srivastava

Civil Engineering:
Making Green Buildings, Martin Fischer

Electrical Engineering:
Information Theory, Tsachy Weissman

Let me know if I left anything out. I hope you find something you like!

David