Tuesday, December 9, 2014

YAML

Research & Examples

Yet Another Markup Language

The YAML Cookbook
http://www.yaml.org/YAML_for_ruby.html#simple_sequence

http://stackoverflow.com/questions/3877004/how-do-i-parse-a-yaml-file
require 'yaml'
thing = YAML.load_file('some.yml')
puts thing.inspect

AJAX

Research & Examples

http://www.tutorialspoint.com/ruby-on-rails/rails-and-ajax.htm
Ajax stands for Asynchronous JavaScript and XML. Ajax is not a single technology; it is a suite of several technologies. Ajax incorporates the following:

XHTML for the markup of web pages
CSS for the styling
Dynamic display and interaction using the DOM
Data manipulation and interchange using XML
Data retrieval using XMLHttpRequest
JavaScript as the glue that meshes all this together
Ajax enables you to retrieve data for a web page without having to refresh the contents of the entire page. In the basic web architecture, the user clicks a link or submits a form. The form is submitted to the server, which then sends back a response. The response is then displayed for the user on a new page.

When you interact with an Ajax-powered web page, it loads an Ajax engine in the background. The engine is written in JavaScript and its responsibility is to both communicate with the web server and display the results to the user. When you submit data using an Ajax-powered form, the server returns an HTML fragment that contains the server's response and displays only the data that is new or changed as opposed to refreshing the entire page.

For a complete detail on AJAX you can go through our AJAX Tutorial

http://edgeguides.rubyonrails.org/working_with_javascript_in_rails.html

http://www.gotealeaf.com/blog/the-detailed-guide-on-how-ajax-works-with-ruby-on-rails

http://richonrails.com/articles/basic-ajax-in-ruby-on-rails

https://www.railstutorial.org/book/following_users

http://stackoverflow.com/questions/5550188/simple-ajax-example



Videos

AJAX and RoR
http://youtu.be/yB2wZdvw07E


Different ways of implementing AJAX in your Ruby on Rails applications
http://youtu.be/n6eE-nd3ci4

AJAX in Ruby on Rails tutorial
http://youtu.be/mtYsLAOGzfI

Ruby on Rails 4 Tutorial #79 - Forms And Ajax
http://youtu.be/10bV7Xku6vw



Tid Bits

Testing with AKAX
http://robots.thoughtbot.com/automatically-wait-for-ajax-with-capybara

--------------------------------------------

`form_tag :remote`  defaults to AJAX

http://www.rubydoc.info/docs/rails/4.1.7/ActionView/Helpers/FormTagHelper:form_tag
While looking at this documentation I saw the part:

:remote - If set to true, will allow the Unobtrusive JavaScript drivers to control the submit behavior. By default this behavior is an ajax submit.
This could be useful when we go to do Ajax calls.

Tuesday, November 18, 2014

Postgres command cheatsheet

http://blog.jasonmeridth.com/posts/postgresql-command-line-cheat-sheet/

change to postgres user and open psql prompt
$ sudo -u postgres psql postgres

Once the postgres database is running the prompt will look like this: postgres=#
(So don't type in postgres=#, only what follows in the following commands...)

list databases
postgres=# \l

list roles
postgres=# \du

create role
postgres=# CREATE ROLE demorole1 WITH LOGIN ENCRYPTED PASSWORD 'password1' CREATEDB;

create role with multiple privileges
postgres=# CREATE ROLE demorole1 WITH LOGIN ENCRYPTED PASSWORD
postgres=# 'password1' CREATEDB CREATEROLE REPLICATION SUPERUSER;

alter role
postgres=# ALTER ROLE demorole1 CREATEROLE CREATEDB REPLICATION SUPERUSER;

drop role
postgres=# DROP ROLE demorole1;

create database
postgres=# CREATE DATABASE demodb1 WITH OWNER demorole1 ENCODING 'UTF8';

grant privileges to new user
postgres=# GRANT ALL PRIVILEGES ON DATABASE demodb1 TO demorole1;

drop database
postgres=# DROP DATABASE demodb1;

connect to database
postgres=# \c <databasename>

list tables in connected database
postgres=# \dt

list columns on table
postgres=# \d <tablename>

backup database


$ pg_dump <databasename> > <outfile> 

Create a Base Web App -

Web App Meetup Homework 1


Create a New Rails App

  1. $ rails new <name_of_app>
  2. $ cd <name_of_app>
  3. $ bundle install


Install Devise




Install Postgres

http://www.postgresql.org/download/linux/ubuntu/

$ gem install pg

Add gem 'pg' to your Gemfile and run bundle install.

-------------------------------
In config/database.yml, use the following settings:
(yaml is white space delimited so make sure you space it exactly like this)

development:
  adapter: postgresql
  encoding: unicode
  database: <yourdatabasename>
  pool: 5
  password: <yourpassword_orleaveitblank>

test:
  adapter: postgresql
  encoding: unicode
  database: <yourdatabasename>
  pool: 5
  timeout: 5000

production:
  adapter: postgresql
  database: <yourdatabasename>
  pool: 5
  timeout: 5000
  user: <yourusername>
  password: <yourpassword>
----------------------------------
For Ubuntu Trusty64

1. Create the file /etc/apt/sources.list.d/pgdg.list
2. add a line for the repository
deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main

Import the repository signing key, and update the package lists
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
sudo apt-key add -
sudo apt-get update

------------------------------------
http://stackoverflow.com/questions/20587779/heroku-wont-recognize-pg-gem-in-my-rails-app-gemfile

Once installed, make sure you initialize the pg datastore.
also, depending how your pg is installed, you might need to specify the username and host in your database.yml file
  username: someuser_on_pg
  host: localhost

Saturday, November 15, 2014

Ruby Interview Questions

http://thereq.com/q/best-ruby-software-interview-questions/easy

Array manipulation

Suppose you have the following array.

stuff = [:dog,:cat,:orange,:banana]

  • How can you slice this array to create a new array [:cat,:orange]
  • Add the element :apple on to the end of the array.
  • Now take :apple back off again
  • Add the element :fish to the start of the array.
  • Now remove the element :fish.

Friday, November 14, 2014

Understanding Algorithms - Resources

https://fiftyexamples.readthedocs.org/en/latest/algorithms.html

Calling something an algorithm means that the following properties are all true:
  • An algorithm is an unambiguous description that makes clear what has to be implemented. In a recipe, a step such as “Bake until done” is ambiguous because it doesn’t explain what “done” means. A more explicit description such as “Bake until the cheese begins to bubble” is better. In a computational algorithm, a step such as “Choose a large number” is vague: what is large? 1 million, 1 billion, or 100? Does the number have to be different each time, or can the same number be used on every run?
  • An algorithm expects a defined set of inputs. For example, it might require two numbers where both numbers are greater than zero. Or it might require a word, or a list of zero or more numbers.
  • An algorithm produces a defined set of outputs. It might output the larger of the two numbers, an all-uppercase version of a word, or a sorted version of the list of numbers.
  • An algorithm is guaranteed to terminate and produce a result, always stopping after a finite time. If an algorithm could potentially run forever, it wouldn’t be very useful because you might never get an answer.
  • Most algorithms are guaranteed to produce the correct result. It’s rarely useful if an algorithm returns the largest number 99% of the time, but 1% of the time the algorithm fails and returns the smallest number instead. [1]
  • If an algorithm imposes a requirement on its inputs (called aprecondition), that requirement must be met. For example, a precondition might be that an algorithm will only accept positive numbers as an input. If preconditions aren’t met, then the algorithm is allowed to fail by producing the wrong answer or never terminating.



http://core.ecu.edu/csci/wirthj/Algorithms/introAlgo-c.html
  An algorithm is a series of specific steps which solve a particular problem.
series
  • The steps must be done in a particular order and each of the steps must be used (unless the algorithm says otherwise).
specific
  • A step must NOT be replaced by a similar step.
steps
  • Like a cooking recipe, an algorithm tells you to do things. Each thing you do is called a step (aka instruction, aka command)
solve
  • An algorithm produces a final result (aka output) which is the solution to a problem.
particular problem
  • The algorithm for one problem will not usually solve a different problem.
  • The details defining the problem must be made available at the start of the algorithm. These details are called givens. (aka parameters).

  • Most algorithms have these basic parts:
  • Description of Problem
  • Set up
  • Parameters
  • Execution
  • Conclusion

http://www.cleveralgorithms.com/


Online Classes

Algorithms
http://theopenacademy.com/content/lecture-1-analysis-algorithms


Logic
https://www.coursera.org/course/intrologic

Monday, September 29, 2014

Mob Programming with Pat Maddox and Alistair Cockburn

My second Summer of Code is over so I am back to self study although I am not studying by myself right now. I am mobbing with Pat Maddox and Alistair Cockburn.

I spent the day with them we discussed a lot of things I had to Google:

Approval Testing
Approval tests take a snapshot of the results, and confirm that they have not changed.

http://approvaltests.sourceforge.net/ 
http://www.slideshare.net/lynnlangit/approval-tests-an-open-source-unit-testing-library-for-net-java-ruby-or-php-12532737

Golden Master Pattern
http://blog.adrianbolboaca.ro/2014/05/legacy-coderetreat-golden-master/

For all the given situations we need to think if the system tests generated with the Golden Master are enough, or we need to start adding other types of tests like unit tests, component tests, integration tests, security tests, etc.

The Golden Master technique is based on the following steps:
Find the way the system delivers its outputs
Check for clear outputs of the system: console, data layer, logger, file system, etc. 

Find a way to capture the output of the system without changing the production code
Think if that output can be “stolen” without changing the production code. For example you could “steal” the console output by redirecting the stream of the console to an in-memory stream. Another example would be injecting an implementation of a data layer interface that would write to another data source than the production code would. 

Find a pattern of the outputs
The output of the system could be text or a data structures tree or another type of stream. Starting from this output type you can decide if you could go on to the next step. 

Generate enough random inputs and persist the tuple input/output
In the case you can persist the outputs to a simple data repository, you can think about what are the inputs for the corresponding outputs. Here the magic consists in finding a good balance of random or pseudo-random inputs. We need inputs that would cover most of the system with tests, but in the same time the test would run in seconds. For example in the case of a text generating algorithm we need to decide if we want to feed the system with 1000 or one million entry data. Maybe 10 000 input data are enough. We will anyway check the tests coverage during the last stage.
We need to persist the pair input-output. The output would be the Golden Master, the reference data we will always check our SUT against. 

Write a system test to check the SUT against the previously persisted data
Now that we have a way to “steal” the outputs and we have a guess about how to generate enough input-output pairs, but not to many, we can call the system and check it against the outputs for a given input. We need to check if the test touches the SUT and if it passes. We also need to check that the test runs fast enough, in seconds. 

Commit the test
Always when a green test passes we need to commit the code to a local source control system. Why? So that we can easily revert to a stable testable system.
Important: Do not forget to commit also the golden masters (files, database, etc)! 

Check test behaviour and coverage

Hexagonal Architecture (http://alistair.cockburn.us/Hexagonal+architecture)
Allow an application to equally be driven by users, programs, automated test or batch scripts, and to be developed and tested in isolation from its eventual run-time devices and databases.



As events arrive from the outside world at a port, a technology-specific adapter converts it into a usable procedure call or message and passes it to the application. The application is blissfully ignorant of the nature of the input device. When the application has something to send out, it sends it out through a port to an adapter, which creates the appropriate signals needed by the receiving technology (human or automated). The application has a semantically sound interaction with the adapters on all sides of it, without actually knowing the nature of the things on the other side of the adapters.


This inspired: JavaScript non-framework called http://hexagonaljs.com/. It's so easy to extract GuiAdapter and StorageAdapter, leaving the middle hex boundary-unaware.

CQRS Pattern 
Command Query Responsibility Segregation built on Alistair's Hexagonal Architecture by Greg Young. http://cqrs.files.wordpress.com/2010/11/cqrs_documents.pdf 
Here is Alistair describing it: http://www.slashdotdash.net/2010/09/27/alistair-cockburns-lightning-talk-on-cqrs-recorded-at-the-mountain-west-ruby-conference-2010/

Monday, July 7, 2014

Command Line Tips

Excellent Resource:
https://github.com/0nn0/terminal-mac-cheatsheet/wiki/Terminal-Cheatsheet-for-Mac-(-basics-)

$ Ctrl+A -  to send the cursor to start of the command

$ Ctrl+E - to send the cursor to the end of the command.

$ Ctrl+C - used to quit a running program in terminal

$ Ctrl U - clears the line

$ Ctrl+L - clears the screen while retaining whatever was there on the current prompt

$ Ctrl+R - and write few characters from the start of command you’re looking for


$ echo <whatever> - reads back in the terminal whatever you write

$ cat <filename> - reads the file

$ touch <filename> - creates a new file

$ head -5 output - displays content from the beginning of a file

$ tail -5 output - displays the last five lines from the file ‘output’


$ history | grep "myarticle.txt"

$ rm -rf dirname - to force remove a directory and it's contents

$ ! - runs a previously run command


$ jobs - lists all the commands running in the background !

$ ps - displays a list of the processes you’ve launched

$ fg - bring a specific job back to the foreground

$ kill %<job-number> kills a process by it's job-number in the list or

$ kill<PID> kill a process by is process id (PID) 1234




sudo lsof -i - "list open files", which is used in many Unix-like systems to report a list of all open files and the processes that opened them. http://danielmiessler.com/study/lsof/

On a Mac you can 
$ Option + Click - to get to a specific spot in your commandline

For fun:

$ telnet towel.blinkenlights.nl 

http://www.tecmint.com/20-funny-commands-of-linux-or-linux-is-fun-in-terminal/


http://www.linuxjournal.com/content/time-saving-tricks-command-line

http://www.linuxuser.co.uk/tutorials/14-command-line-tips-tricks

http://mylinuxbook.com/5-really-cool-linux-command-line-tricks/

https://linuxacademy.com/blog/linux/ten-things-i-wish-i-knew-earlier-about-the-linux-command-line-2/

Blank Terminal Window
http://www.cnet.com/news/os-x-terminal-displays-a-blank-window-instead-of-a-command-prompt/

commandline windows pwd

http://www.lemoda.net/windows/windows2unix/windows2unix.html

arparp
assignlnCreate a file link
assignln -sOn Unix, a directory may not have multiple links, so instead a symbolic link must be created with ln -s.
assocfile
atat
batch
cron
attribchown
chmod
Sets ownership on files and directories
cdcdOn Windows, cd alone prints the current directory, but on Unix cd alone returns the user to his home directory.
cdpwdOn Windows, cd alone prints the current directory.
chkdskfsckChecks filesystem and repairs filesystem corruption on hard drives.
clsclearClear the terminal screen
copycp
date
time
dateDate on Unix prints the current date and time. Date and time on Windows print the date and time respectively, and prompt for a new date or time.
delrm
deltreerm -rRecursively deletes entire directory tree
dirls"dir" also works on some versions of Unix.
doskey /h
F7 key
historyThe Unix history is part of the Bash shell.
editvi
emacs
etc.
edit brings up a simple text editor in Windows. On Unix, the environment variable EDITORshould be set to the user's preferred editor.
exitexit
Control-D
On Unix, pressing the control key and D simultaneously logs the user out of the shell.
explorernautilus
etc.
The command explorer brings up the file browser on Windows.
fcdiff
findgrep
ftpftp
helpman"help" by itself prints all the commands
hostnamehostname
ipconfig /allifconfig -aThe /all option lets you get the MAC address of the Windows PC
memtopShows system status
mkdirmkdir
moremore
less
movemv
net sessionw
who
net statisticsuptime
nslookupnslookup
pingping
printlprSend a file to a printer.
reboot
shutdown -r
shutdown -r
regeditedit /etc/*The Unix equivalent of the Windows registry are the files under /etc and /usr/local/etc. These are edited with a text editor rather than with a special-purpose editing program.
rmdirrmdir
rmdir /srm -rWindows has a y/n prompt. To get the prompt with Unix, use rm -i. The i means "interactive".
setenvSet on Windows prints a list of all environment variables. For individual environment variables, set <variable> is the same as echo $<variable> on Unix.
set Pathecho $PATHPrint the value of the environment variable using set in Windows.
shutdownshutdownWithout an option, the Windows version produces a help message
shutdown -sshutdown -hAlso need -f option to Windows if logged in remotely
sortsort
start&On Unix, to start a job in the background, use command &. On Windows, the equivalent isstart command. See How to run a Windows command as a background job like Unix ?.
systeminfouname -a
tasklistps"tasklist" is not available on some versions of Windows. See also this article on getting a list of processes in Windows using Perl
title?In Unix, changing the title of the terminal window is possible but complicated. Search for "change title xterm".
tracerttraceroute
treefind
ls -R
On Windows, use tree | find "string"
typecat
veruname -a
xcopycp -RRecursively copy a directory tree

Nesta - aggregate the posts

This is the blog for my Rails Girls Summer of Code Team The Standard Librarians.

Nesta is a Ruby CMS built with Sinatra. We were originally going to be working in Sinatra for the summer but we switched to working on the Try Ruby Standard library.

I now want to change the year to month.

http://nestacms.com/docs/recipes/adding-links-to-archived-posts

Wednesday, June 25, 2014

git - change branch to master

We have been preparing our blog to document our progress during RGSoC for what seems like an eternity.

First we wrote and entire blog from scratch in Sinatra. We realized that it really needed a lot of work to acquire all the capabilities that we wanted it to have. Stephanie found Nesta, a ruby CMS built with Sinatra. So we abandoned the work we had done and started on the new blog. It has been a few weeks now and it is almost ready. There are a lot of things you need to manually configure in Nesta.

Last night when we were working on it Steph pushed and broke the blog. I had pulled these changes into my master without realizing it. Luckily I had a branch that still worked properly so I changed that branch into the master and force pushed it with the help of these lovely and helpful directions. 
Thanks again stackoverflow.

Monday, June 23, 2014

<=> The Spaceship Operator

Perl was the first language to use <=> the Spaceship Operator.
Groovy is another language that supports it.
So does Ruby!

What does it do?
Instead of returning 1 (true) or 0 (false) depending on whether the arguments are equal or unequal, the spaceship operator will return 1, 0, or −1 depending on the value of the left argument relative to the right argument.

a <=> b :=
  if a < b then return -1
  if a = b then return  0
  if a > b then return  1

It's useful for sorting an array.

http://stackoverflow.com/questions/16600251/how-does-rubys-sort-method-work-with-the-combined-comparison-spaceship-operat

tuple
In mathematics, computer science, linguistics, and philosophy a tuple is an ordered list of elements. In set theory, an -tuple is a sequence of elements, where is a non-negative integer. There is only one 0-tuple, an empty sequence.

Sunday, June 15, 2014

Gravatar

Adding a Gravatar to our Nesta Blog Post

from
http://www.markholmberg.com/articles/gravatar-and-ruby-on-rails
The quick and dirty 
There are many configurable options that you can pass into Gravtastic. I found it quite refreshing to have a gem just work "out-of-the-box". It also has support for plain ruby if you're not using something like rails. Also, if you want to have the gravatar load on the client side, it has an option to work using javascript if your using Rails 3.1 or higher. 
Gemfile  
gem 'gravtastic'
Model 
user.rb
include Gravtastic
has_gravatar 
View 
_comment.html.haml
= image_tag @comment.user.gravatar_url

Wednesday, June 11, 2014

Tuesday, June 10, 2014

Notes - Rails Tutorial Chapter 7.2.2

form_for helper method, which takes in an Active Record object and constructs a form using the object’s attributes. <%= form_for %>

These name values allow Rails to construct an initialization hash (via the params variable) for creating users using the values entered by the user
the Rails code:
<label for="user_name">Name</label>
<input id="user_name" name="user[name]" type="text" />
---------------------------------------------------------------
the html output:
<input id="user_name" name="user[name]" - - - />

Recall from Section 7.1.2 that adding resources :users to the routes.rb file (Listing 7.3) automatically ensures that our Rails application responds to the RESTful URLs from Table 7.8

Sunday, June 8, 2014

Lorem Ipsum for all my friends

A lorem ipsum generator for everyone...

Where did it come from and why?
http://www.straightdope.com/columns/read/2290/what-does-the-filler-text-lorem-ipsum-mean

Cicero, specifically De finibus bonorum et malorum, a treatise on the theory of ethics written in 45 BC. The original reads, Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit . . . ("There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain …").

Cats
http://www.catipsum.com/
Stretch give attitude yet stick butt in face for need to chase tail for hate dog. Sun bathe hate dog hunt anything that moves so chase mice burrow under covers.

Postmodernist
http://www.elsewhere.org/pomo/
The main theme of the works of Smith is a self-referential totality. Baudrillard promotes the use of capitalist nationalism to attack hierarchy. Thus, the characteristic theme of Bailey’s[3] model of libertarianism is not patriarchialism, as Baudrillard would have it, but prepatriarchialism.

Hipster
http://hipsum.co/
Wayfarers ethical stumptown, literally fanny pack Kickstarter dreamcatcher Odd Future. Next level chia +1 banh mi. Tattooed four loko retro street art locavore.

Cupcake
http://www.cupcakeipsum.com/
Cupcake ipsum dolor sit amet gummies danish donut cookie. Candy bear claw cake. Apple pie oat cake danish. Tart ice cream donut oat cake

Bacon
http://baconipsum.com/
Bacon ipsum dolor sit amet ad filet mignon jerky porchetta consectetur spare ribs flank. Biltong drumstick fatback strip steak short ribs jerky eiusmod jowl flank short loin ex landjaeger doner beef

TV
http://tvipsum.com/
The movie star the professor and Mary Ann here on Gilligans Isle. Just sit right back and you'll hear a tale a tale of a fateful trip that started from this tropic port aboard this tiny ship? we might as well say... Would you be mine?

Sagan
http://saganipsum.com/
Circumnavigated encyclopaedia galactica with pretty stories for which there's little good evidence Drake Equation, star stuff harvesting star light Apollonius of Perga prime number.

Mainer
http://maineripsum.com/
Fellers buggin' kid rig up got in a gaum what a cahd justa smidgin queeah some cunnin cubboard. Hahd tellin' not knowin' front dooryahd gawmy gash dang flatlanduhs and their boilin' plates.

Pokemon
http://nyarth.net/ipsum/
Bulbasaur Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ivysaur Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Yorkshire
http://tlipsum.appspot.com/
Tell thi summat for nowt aye shurrup. Nah then ey up nah then sup wi' 'im eeh appens as maybe. Ah'll gi' thi summat to rooer abaht ah'll gi' thee a thick ear. Ah'll gi' thee a thick ear where there's muck there's brass ah'll learn thi.

Whedon
http://www.commercekitchen.com/whedon-ipsum/
We're old friends from Navy. Friends from Old Navy. I worked retail, he'd come in, buy slacks Somebody put her tiny little thinking cap on! See if you were really a witch, you'd do a spell to escape. Did the primary buffer panel just fall off my Gorram ship for no apparent reason?

Gangsta
http://lorizzle.nl/
Lorizzle ipsum dolizzle yo mamma boom shackalack, consectetizzle adipiscing elizzle. Nullam dizzle velizzle, uhuh ... yih! uhuh ... yih!, uhuh ... yih! gizzle, cool gizzle, shizznit. Pellentesque fo shizzle cool. Stuff erizzle.

Zombies
http://www.zombieipsum.com/
Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro. De carne lumbering animata corpora quaeritis. Summus brains sit​​, morbo vel maleficia?

Pirates
http://pirateipsum.me/
Lateen sail hardtack gibbet galleon belay run a rig quarter spanker hands landlubber or just lubber. Jack Ketch Blimey gun pink chase guns draft strike colors swing the lead scuppers galleon.

Tuna
http://tunaipsum.com/
Pufferfish blue shark northern lampfish. Redfish ghost fish sucker snailfish roundhead, spiny eel cutlassfish treefish needlefish Pacific cod yellow moray labyrinth fish kokopu queen triggerfish pearleye sleeper.

Veggies
http://veggieipsum.com/
Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion daikon amaranth tatsoi tomatillo melon azuki bean garlic.

Downton Abbey
http://downtonipsum.com/
Countess of Grantham observed, “There's only one thing we can do.” Mrs. Bryant dismissed England. The lawn manipulated the maid. Jimmy Kent sobbed, “Mr Bates? Are you there?

Heisenberg
http://heisenbergipsum.com/
I continue cooking, you and I both forget about Pinkman. We forget this ever happened. We consider this a lone hiccup in an otherwise long and fruitful business arrangement. I prefer Option B.

Samuel L. Jackson
http://slipsum.com/
Normally, both your asses would be dead as fucking fried chicken, but you happen to pull this shit while I'm in a transitional period so I don't wanna kill you, I wanna help you.

Yolo
http://yoloipsum.wordpress.com/
Yolo ipsum dolor sit amet, consectetur adipiscing elit. Ut ac suscipit leo. Carpe diem vulputate est nec commodo rutrum. Pellentesque mattis convallis nisi eu and I ain’t stoppin until the swear jar’s full.

HTML
http://html-ipsum.com/
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>

Kiwi
http://kiwipsum.com/
Put the jug on will you bro, all these good as stubbiess can wait till later. The first prize for rooting goes to... Dr Ropata and his cool weka, what a dole bludger. Bro, lengths of number 8 wire are really epic good with bloody fellas, aye.

Fillerati
http://www.fillerati.com/
Then, in darting at the monster, knife in hand, he had but given loose to a sudden, passionate, corporal animosity; and when he received the stroke that tore him, he probably but felt the agonizing bodily laceration, but nothing more.

Keep Calm and Pommy
http://www.pommyipsum.com/
Pommy ipsum a tad cor blimey' crisps tip-top the fuzz, absolute twoddle indeed Queen Elizabeth copped a bollocking. Leisurely the fuzz every fortnight spend a penny the black death we'll be 'avin less of that the dog's dinner conked

Beer
http://beeripsum.com/
brewpub all-malt heat exchanger wheat beer glass, adjunct shelf life mash. cask conditioning, specific gravity aroma hops adjunct balthazar, dunkle pint glass abv. alcohol hop back aroma hops top-fermenting yeast.

Vatican Assasin
http://vaticanassass.in/
And Alex, try to get your mind around this, as a fellow warrior, deep in the trenches: Their entire manifesto is built upon complete and total surrender ... or the concept of complete and total surrender.

Cheese
http://www.cheeseipsum.co.uk/
Say cheese when the cheese comes out everybody's happy roquefort. Manchego pepper jack goat st. agur blue cheese parmesan airedale cheddar cottage cheese.

Movies
http://www.picksumipsum.co.uk/
Pull my finger! jasper: your baby is the miracle the whole world has been waiting for. you know, your bobby dangler, giggle stick, your general-two-colonels, master of ceremonies... yeah, don't be shy, let's have a look.

Journalism
http://www.niemanlab.org/journo-ipsum/
Cancel my subscription Google+ serendipity media diet hyperlocal Jeff Jarvis if the news is that important, it'll find me Project Thunderdome Journal Register, column-inch HuffPo.

Malevole
http://www.malevole.com/mv/misc/text/
One for all and all for one, Muskehounds are always ready. One for all and all for one, helping everybody. One for all and all for one, it's a pretty story.

Bluth
http://bluthipsum.com/
You might wanna lean away from that fire since you're soaked in alcohol. Up yours, granny! You couldn't handle it! Today I learned this is a real place, tho more lush than the OC. Saw this on the highway and almost blue myself. Hop on?

Barvaria
http://bavaria-ipsum.de/
Bavaria ipsum dolor sit amet des Fünferl, Marei des is hoid aso sammawiedaguad. Barfuaßat oamoi Brodzeid und a ganze Hoiwe Ledahosn, Biawambn! Schaugn des a Maß und no a Maß singan, Schneid di schüds nei.

Busey
http://www.buseyipsum.com/
All men are failed women at birth. These kind of things only happen for the first time once. I would like to give you a backstage pass to my imagination.

Baseball
http://baseballipsum.apphb.com/
Visitors nubber leather red sox on deck foul line first base streak bleeder. Plunked grand slam fastball in the hole small ball national pastime stance losses.

Lebowski
http://www.lebowskiipsum.com/
Roadie for Metallica. Speed of Sound Tour. Dolor sit amet, consectetur adipiscing elit praesent. Wait in the car, Donny. Ac magna justo pellentesque.

Trollem
http://trollemipsum.appspot.com/
Apparently Google Voice is better than Siri and TellMe put together I believe typical fanboy, to Flash in spite of fanboi, you’d buy shit if Apple sold it in the end Android is better because it’s open.

Skate
http://skateipsum.com/
Skate ipsum dolor sit amet, Japan air melancholy gap Geoff Rowley rock and roll. Casper slide noseblunt slide powerslide opposite footed.

Quote
http://quoteipsum.com/
You must have long-range goals to keep you from being frustrated by short-range failures. Instead of seeing the rug being pulled from under us, we can learn to dance on a shifting carpet.

Obama
http://obamaipsum.com/
We can dismiss Reverend Wright as a crank or a demagogue, just as some have dismissed Geraldine Ferraro, in the aftermath of her recent statements, as harboring some deep-seated racial bias

Japanese
http://romneyipsum.com/
炭酸パックは高い血行促進効果やくすみケア、肌にハリを持たせる効果のある美容法としてエステでも人気のあるものです。
Carbonate pack is also a popular Estes as beauty regimen that is effective to have a needle care, the skin dull and promoting blood circulation effect high.

Fashion
http://www.fashionipsum.co.uk/
Indigo tee navy blue minimal beauty braid seam Prada Saffiano white powder pink neutral. Leather tote knitwear ribbed cable knit Casio motif Givenchy. Loafers strong eyebrows Cara D. LA Acne Furla mint Hermès rings chignon.

Riker
http://www.rikeripsum.com/#!/
Indigo tee navy blue minimal beauty braid seam Prada Saffiano white powder pink neutral. Leather tote knitwear ribbed cable knit Casio motif Givenchy. Loafers strong eyebrows Cara D. LA Acne Furla mint Hermès rings chignon.

Corporate
http://www.cipsum.com/
Efficiently unleash cross-media information without cross-media value. Quickly maximize timely deliverables for real-time schemas. Dramatically maintain clicks-and-mortar solutions without functional solutions.

Gag
http://gagipsum.com/
In lol search read too mainstream clinton nother to do here weekend y u no portfolio top. On kitchen woman cat money problem? Cool bart mother of god simpson dog alcohol father star wars male.

Comic
http://comicipsum.com/
A multiplayer game mode has been included in this latest edition and features a selection of interesting game hacks and cheats that can be played between friends on one console, or via the web with other players through out the world.

Dalek
http://dalekipsum.com/
Lord You will be exterminated! Hello sweetie! It's bigger on the inside! Raxacoricofallapatorius Hello Sweetie. Bow ties are cool. The Shadow Proclamation Hello sweetie! the oncoming storm Bad Wolf the girl who waited

Delorean
http://www.deloreanipsum.com/
C'mon, he's not that bad. At least he's letting you borrow the car tomorrow night. This sounds pretty heavy. That was so stupid, Grandpa hit him with the car. Right, gimme a Pepsi free. What did she say? It's your mom, she's tracked you down. Quick, let's cover the time machine.

Swears
http://www.swearemipsum.com/
Swearem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam scelerisque fuckstick nisl, a mattis eros vestibulum cock. Vestibulum placerat purus ut nibh aliquam fringilla. Aenean et cunt shit, id tempor elit.

Startups
http://startupipsum.co/
Accelerator photo sharing business school drop out ramen hustle crush it revenue traction platforms. Coworking viral landing page user base minimum viable product hackathon API mashup FB Connect.

Hodor
http://hodoripsum.com/
Hodor hodor HODOR! Hodor HODOR hodor, hodor hodor, hodor. Hodor hodor - hodor. Hodor. Hodor, hodor. Hodor.

Bogan
http://www.boganipsum.com/
Trent from punchy cobber piece of piss as cunning as a gone walkabout. Get a dog up ya ironman how as cross as a rip snorter. He's got a massive gobful mate get a dog up ya divvy van.

Plain
http://loripsum.net/

http://www.webdesignerdepot.com/2012/03/15-dummy-text-generators-you-should-know/

Saturday, June 7, 2014

Notes - Rails Tutorial - Chapter 6

let http://www.railstutorial.org/book/modeling_users#sidebar-let
From Michael Harl's Rails Tutorial Chapter 6 Box 6.3. Using let
RSpec’s let method provides a convenient way to create local variables inside tests. The syntax might look a little strange, but its effect is similar to variable assignment. The argument of let is a symbol, and it takes a block whose return value is assigned to a local variable with the symbol’s name. In other words, 
let(:found_user) { User.find_by(email: @user.email) } 
creates a found_user variable whose value is equal to the result of find_by. We can then use this variable in any of the before or it blocks throughout the rest of the test. One advantage of let is that it memoizes its value, which means that it remembers the value from one invocation to the next. (Note that memoize is a technical term; in particular, it’s not a misspelling of “memorize”.) In the present case, because let memoizes the found_user variable, the find_by method will only be called once whenever the User model specs are run.
specify method -
This is just a synonym for it, and can be used when writing it would sound unnatural.

reload method for reloading a value from the database and the eq method for testing equality.
debug method
controller: static_pages
action: home 
This is a YAML3 representation of params, which is basically a hash, and in this case identifies the controller and action for the page.
params variable

Rails comes equipped with three environments: test, development, and production. The default environment for the Rails console is development:

Thursday, June 5, 2014

API & RESTFUL

Which HTTP methods match up to which CRUD methods?

Why it changed from PUT to PATCH https://github.com/rails/rails/issues/348

http://stackoverflow.com/questions/6203231/which-http-methods-match-up-to-which-crud-methods

GET = READ
POST = WRITE

Create = PUT with a new URI
         POST to a base URI returning a newly created URI
Read   = GET
Update = PUT with an existing URI
Delete = DELETE
PUT can map to both Create and Update depending on the existence of the URI used with the PUT.
POST maps to Create.
Correction: POST can also map to Update although it's typically used for Create. POST can also be a partial update so we don't need the proposed PATCH method.


http://stackoverflow.com/questions/19504434/rails-put-vs-post

According to rails convention,

PUT is used for updating an existing resource

POST is used for creating a new resource

In rails 4, PUT has been changed to PATCH to avoid confusion.

Rails generated routes will look like below by default

    posts GET    /posts(.:format)                            {:action=>"index", :controller=>"posts"}
          POST   /posts(.:format)                            {:action=>"create", :controller=>"posts"}
 new_post GET    /posts/new(.:format)                        {:action=>"new", :controller=>"posts"}
edit_post GET    /posts/:id/edit(.:format)                   {:action=>"edit", :controller=>"posts"}
     post GET    /posts/:id(.:format)                        {:action=>"show", :controller=>"posts"}
          PUT    /posts/:id(.:format)                        {:action=>"update", :controller=>"posts"}
          DELETE /posts/:id(.:format)                        {:action=>"destroy", :controller=>"posts"}
Notice the action for PUT and POST

The request methods of the HyperText Transfer Protocol (HTTP) computer protocol are a common example of idempotence, in that data retrieval operations can be performed without changing or otherwise affecting the data.

Tuesday, June 3, 2014

Markdown for Sinatra

I looked at a lot of tu

epic editor markdown editor

db problems with Sinatra

http://www.postgresql.org/docs/9.1/static/manage-ag-createdb.html

This worked for me.$ export DATABASE_URL=postgres://localhost/activerecord_sinatra

createdb --help
createdb creates a PostgreSQL database.

Usage:
  createdb [OPTION]... [DBNAME] [DESCRIPTION]

Options:
  -D, --tablespace=TABLESPACE  default tablespace for the database
  -e, --echo                   show the commands being sent to the server
  -E, --encoding=ENCODING      encoding for the database
  -l, --locale=LOCALE          locale settings for the database
      --lc-collate=LOCALE      LC_COLLATE setting for the database
      --lc-ctype=LOCALE        LC_CTYPE setting for the database
  -O, --owner=OWNER            database user to own the new database
  -T, --template=TEMPLATE      template database to copy
  --help                       show this help, then exit
  --version                    output version information, then exit

Connection options:
  -h, --host=HOSTNAME          database server host or socket directory
  -p, --port=PORT              database server port
  -U, --username=USERNAME      user name to connect as
  -w, --no-password            never prompt for password
  -W, --password               force password prompt

By default, a database with the same name as the current user is created.

Report bugs to <pgsql-bugs@postgresql.org>._adapters/postgresql_adapter.rb:891:in `rescue in connect': FATAL:  database

Twitter

https://discover.twitter.com/learn-more

Arrays

from rubylearning,com
"An Array is just a list of items in order (like mangoes, apples, and oranges). Every slot in the list acts like a variable: you can see what object a particular slot points to, and you can make it point to a different object. You can make an array by using square brackets In Ruby, the first value in an array has index 0. The size and lengthmethods return the number of elements in an array. The last element of the array is at index size-1. Negative index values count from the end of the array, so the last element of an array can also be accessed with an index of -1. If you attempt to read an element beyond the end of an array (with an index >= size) or before the beginning of an array (with an index < -size), Ruby simply returns nil and does not throw an exception. Ruby's arrays are mutable - arrays are dynamically resizable; you can append elements to them and they grow as needed."

locations.each do |loc|
  puts 'I love ' + loc + '!'
  puts "Don't you?"
end

Great examples
http://zetcode.com/lang/rubytutorial/arrays/

method shuffle

puts "#{planets.shuffle}"


http://www.ruby-doc.org/core-2.1.2/Array.html#method-i-shuffle
a.shuffle(random: Random.new(1))  #=> [1, 3, 2]


The Basics of Ruby Arrays
http://blog.teamtreehouse.com/ruby-arrays

SHUFFLE
http://stackoverflow.com/questions/1816378/how-to-randomly-sort-scramble-an-array-in-ruby
[1,2,3,4].shuffle => [2, 1, 3, 4]
[1,2,3,4].shuffle => [1, 3, 2, 4]

http://stackoverflow.com/questions/15974992/reproduce-random-array-sort
> arr = [1, 2, 3, 4] => [1, 2, 3, 4]
>> r = Random.new(17) => #<Random:0x000000017be4d0>
>> arr.shuffle(random: r) => [3, 1, 4, 2]
>> arr.shuffle(random: r) => [1, 3, 2, 4]
>> arr.shuffle(random: r) => [4, 3, 2, 1]
>> r = Random.new(17) => #<Random:0x00000001c60da8>
>> arr.shuffle(random: r) => [3, 1, 4, 2]
>> arr.shuffle(random: r) => [1, 3, 2, 4]
>> arr.shuffle(random: r) => [4, 3, 2, 1]
>> etc.
?>

http://www.rubymotion.com/developer-center/api/Array.html

http://tamlearnstocodewithoutsusanne.tumblr.com/