Skip to content

Instantly share code, notes, and snippets.

@mashbash
mashbash / combinePredicates.scala
Last active August 12, 2016 15:55
How to combine Predicates
/*
* http://timepit.eu/~frank/blog/2012/08/combining_predicates_in_scala/
*/
val dataSet = List((1,"a"), (1,"b"), (2,"a"))
//simluating value selected from UI
val selectedAlphabet = List("a")
val selectedNum = List(1)
@mashbash
mashbash / gist:769001ab8a4900cc3db9
Created December 4, 2014 09:27
scala: higher order function
//helpful link: https://pragprog.com/magazines/2012-02/scala-for-the-intrigued
//function that takes a higher order function
def total(prices: List[Int], selector: Int => Boolean) ={
prices.foldLeft(0){(total,price) => if(selector(price)) total + price else total
}}
//price list to manipulate
val prices = List(12, 22, 33, 23, 21, 20)
def example(words: String*) = words.map(_ + " eat pumpkins")
val list = List("what", "who", "when")
//in order to pass a list to it, do a simple casting
example(list:_*)
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")

###1. How does link_to work? What possible arguments does it accept?

link_to is a helper method that creates a link tag. Which link tag is determined by the set of parameters passed in to it. The first parameter is the text that represents the link as seen by see user. The next is a string or hash which defines where the link leads to. A third one can provide HTML attributes.

Example time:

<%= link_to "DevBootcamp", "http://www.devbootcamp.com/" %>

translates to

@mashbash
mashbash / gist:5149456
Created March 13, 2013 04:48
Views and Partials
https://github.com/mashbash/rails_views_and_partials/blob/master/README.md
@mashbash
mashbash / gist:5114158
Created March 8, 2013 04:12
Basic app that lets you look at categories on etsy
https://github.com/mashbash/e_listing_app
@mashbash
mashbash / gist:5105549
Created March 7, 2013 04:17
tweet_later
https://github.com/mashbash/tweet_later/tree/master/app
@mashbash
mashbash / gist:5093366
Created March 5, 2013 19:25
Heroku 2: Apps Ahoy!
http://dry-cove-5190.herokuapp.com/
@mashbash
mashbash / gist:5093084
Created March 5, 2013 18:57
Heroku 1: Getting Started
http://floating-ravine-5524.herokuapp.com/