Rails is really a collection of pieces that can be put together to create a web app. You can enhance or replace many of the components - how you write views, how controllers work, and how you build models. While models are built on top of ActiveRecord in the
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
// Playground using NSLinguisticTagger to analyze and tag a block of text | |
// https://developer.apple.com/documentation/foundation/nslinguistictagger/identifying_parts_of_speech | |
import Foundation | |
// text from some article on Democratic candidate preferences (Nov 2018) | |
let text = "The Democratic frontrunner, according to Politico's poll: Joe Biden, former Vice President and Senator from Delaware, who managed to grab just over a quarter (26%) of the Democrats' vote for who they'd most like to see facing off against Trump in two years for control of the White House. The runner-up is Vermont Senator Bernie Sanders, who ran a close primary campaign against Hillary Clinton in 2016, managing to get about a fifth of the votes (19%). The third-place candidate is Rep. Beto O’Rourke from Texas, who built national name-recognition through his losing Senate bid last week, with 8 percent. Following O’Rourke are three senators, all thought to be likely candidates: Sens. Elizabeth Warren (Mass.) at 5 percent, Kamala Harris |
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
/** | |
Pair up with another person to complete this assignment. | |
Create a Swift function called fizzbuzz() that takes an integer and returns either: | |
- “Fizz” if the number is divisible by 3, | |
- “Buzz” if divisible by 5, | |
- “FizzBuzz” if divisible by both 3 and 5, or | |
- the number itself as a string if none of these other conditions hold. | |
Below you can find a sample of the function being called and what is being returned. | |
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
// A quick hack to add navigation in SwiftUI to buttons | |
// Using Swift 5.0 | |
// Running on macOS 11.0 | |
// Qapla' | |
// | |
import SwiftUI | |
extension View { |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
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
// Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository | |
$ git ls-files | xargs wc -l |
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
characters = { kirk: :TOS, spock: :TOS, picard: :TNG, janeway: :VOY, scotty: :TOS, sisko: :DS9, | |
kira: :DS9, chakotay: :VOY, seven: :VOY, dax: :DS9, tuvok: :VOY, tpol: :ENT, | |
riker: :TNG, troi: :TNG} | |
series = { TOS: "The Original Series", NTG: "The Next Generation", DS9: "Deep Space 9", | |
VOY: "Voyager", ENT: "Enterprise" } | |
runtimes = { TOS: [1966, 1969], NTG: [1987, 1994], DS9: [1993, 1999], | |
VOY: [1995, 2001] , ENT: [2001, 2004] } |
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
class CustomersController < ApplicationController | |
include ActionView::Helpers::NumberHelper | |
# Many controller actions missing... | |
def new | |
@customer = Customer.new | |
user = @customer.build_user | |
end |
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
# An example of nested forms if using the "accepts_nested_attributes_for" approach | |
# Context is projects and tasks, not customers and users | |
# Assumes you are using simple_form and nested_form gems: | |
# gem 'simple_form', '3.0.1' | |
# gem 'nested_form','0.3.2' | |
<%= simple_nested_form_for @project, :html => { :class => 'form-horizontal' } do |project_form| %> | |
<div class="row"> | |
<div class="small-7 columns"> | |
<fieldset> |