This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<script type="text/javascript"> | |
function each(array, f) { | |
var new_array = [] | |
for (i = 0; i < array.length; i++) { | |
new_array.push(f(array[i])) | |
} | |
return new_array | |
} | |
function addTwo(element) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// selectors | |
$("#candyCanes") //says go grab me everything with this id. | |
$(".polarVortex") //class | |
$("footer") //with this element tag | |
// filter selections | |
$("div.foo").has("p"); //with p tag | |
$("h1").not(".bar"); //w/o bar | |
$("ul li").filter(".current"); //w current | |
$("ul li").first(); //first |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. selection an element | |
var chart = d3.select(".chart"); | |
var bar = chart.selectAll("div"); | |
// 2. then we have to join data to that element | |
var data = [4,3,5,33,5,67] | |
var barUpdate = bar.data(data); | |
// 3. enter/update/exit | |
var barEnter = barUpdate.enter().append(); | |
// 4. add/update/remove attr, content, styles, etc | |
barEnter.style("width", function(d){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ABC|DE) # => capture ABC or DE, once | |
(ABC|DE){2} # => capture ABC or DE, exactly two times. can be ABC or DE twice, or each of them once | |
[ABCDE] # => any of the letters once | |
.* # => any single character, zero or more times. the letter doesn't have to be the same one... | |
#for example, "aa" or "ab" will both be matched | |
[^ABC] # => any character besides ABC | |
a? # => 0 or 1 of a | |
a* # => 0 or more of a | |
a+ # => 1 or more of a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- public/app/partials/show-all.html --> | |
<div class="new-quote-form ng-hide"> | |
<h3>New Quote</h3> | |
<form> | |
<div class="row"> | |
<div class="large-12 columns"> | |
<label for="body">Body | |
<br> | |
<textarea ng-model="newItem.body" rows="4" cols="70" placeholder="To improve is to change..."></textarea> | |
</label> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// public/app/js/controllers.js | |
inspirationControllers.controller('ShowAllCtrl', [ | |
'$scope', '$http', | |
function($scope, $http) { | |
... | |
$scope.submit = function(newItem) { | |
$http.post("/quotes", newItem).success(function (newItem, status) { | |
$http.get("/authors").success(function(response) { | |
for (var i = 0; i < response.length; i++) { | |
$scope.firstNames.push(response[i].firstName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app.rb | |
# create new quote + author | |
post '/quotes' do | |
begin | |
params.merge! JSON.parse(request.env["rack.input"].read) | |
rescue JSON::ParserError | |
logger.error "Cannot parse request body." | |
end | |
@author = Author.find_or_create_by(params[:author]) | |
@author.quotes.build(:body => params[:body]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newItem = { | |
body: "this is the body!", | |
author: { | |
firstName: "first", | |
lastName: "last" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# devise | |
devise_for :users, :skip => [:sessions, :registerable] | |
as :user do | |
get '/users/sign_in' => 'devise/sessions#new', :as => :new_user_session | |
post '/users/sign_in' => 'devise/sessions#create', :as => :user_session | |
delete '/users/sign_out' => 'devise/sessions#destroy', :as => :destroy_user_session | |
end | |
get '/users/sign_up' => 'campaign#home' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './palindrome' | |
describe '#next_palindrome' do | |
it "should return the next smallest number that is greater than the given number which is a palindrome" do | |
expect(next_palindrome(121)).to eq(131) | |
end | |
it "should return the next smallest number that is greater than the given number which is a palindrome" do | |
expect(next_palindrome(1221)).to eq(1331) | |
end | |
it "should return the next smallest number that is greater than the given number which is a palindrome" do |
OlderNewer