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 Car | |
attr_reader :current_speed | |
attr_reader :brand | |
attr_reader :max_speed | |
# use hash args because then you know what parameters are what when calling | |
# the function. | |
def initialize(args = {}) | |
@current_speed = args[:current_speed] || 0 | |
@brand = args[:brand] || "unknown" |
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
# Below is the controller code from a sort of "group/party game" webapp I had worked on at one point. | |
# | |
# It's from a Ruby on Rails application, which provides a lot of functionality out of the box | |
# So it might not look like "that much code" because Rails eliminates the need for writing a ton of boilerplate. | |
# | |
# I believe it at least demonstrates some understanding of model relationships and high level application design. | |
# | |
# information is broadcasted in real-time using websockets via ActionCable | |
class GamesController < ApplicationController |
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
// This code is from a language learning web application that I've been building as a hobby project. | |
// The `Login` function is a React component. It displays a login form to the user if the user is not logged in. | |
// If they are already logged in, they are redirected to the home page. | |
// The form is submitted to a Rails backend, which uses the Devise gem configured in API mode. | |
// A JSON Web Token is returned, and the client stores it as a cookie. | |
// The other file in this gist, `store.js`, is a data structure which represents the front-end's global state. | |
import Layout from "components/layout" | |
import { useState } from "react" |
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
2:08:07 PM: Executing task 'SpringbootAuthUpdatedApplication.main()'... | |
Download https://repo.maven.apache.org/maven2/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.pom | |
Download https://repo.maven.apache.org/maven2/javax/xml/bind/jaxb-api-parent/2.3.0/jaxb-api-parent-2.3.0.pom | |
Download https://repo.maven.apache.org/maven2/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar | |
> Task :compileJava | |
> Task :processResources UP-TO-DATE | |
> Task :classes | |
> Task :SpringbootAuthUpdatedApplication.main() |
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
const UserRegistration = (props) => { | |
const appContext = useContext(AppContext) | |
const history = useHistory(); | |
const [cookies, setCookie, removeCookie] = useCookies(['auth-token']); | |
const [messagesCleared, setMessagesCleared] = useState(true) | |
useEffect(() => { | |
return () => { | |
appContext.setStatusMessage({type: null, text: null}) | |
appContext.setErrors(null) |
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
const UserRegistration = (props) => { | |
const appContext = useContext(AppContext) | |
const history = useHistory(); | |
const [cookies, setCookie, removeCookie] = useCookies(['auth-token']); | |
const [messagesCleared, setMessagesCleared] = useState(true) | |
useEffect(() => { | |
console.log('messagesCleared: ' + messagesCleared) // always appears false... | |
// doing this to avoid le infinite loopz |
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
import React from 'react'; | |
import './App.css'; | |
import { BrowserRouter } from "react-router-dom" | |
import AppContext from "./AppContext" | |
import IssueBrowser from "./components/IssueBrowser" | |
import ErrorMessages from "./components/ErrorMessages" | |
import LoaderWidget from "./components/LoaderWidget" |
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
function setupRedirect() { | |
<Redirect .../> | |
} | |
render() { | |
setupRedirect(); | |
return ( | |
<form>...</form> | |
) | |
} |
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
<Switch> | |
<Route path="/admin/books"> | |
<RecordAdmin singular="book" plural="books" table={BookTable} form={BookForm} /> | |
</Route> | |
<Route path="/admin/authors"> | |
<RecordAdmin singular="author" plural="authors" table={AuthorTable} form={AuthorForm} /> | |
</Route> | |
<Route path="/admin/branches"> | |
<RecordAdmin singular="branch" plural="branches" table={BranchTable} form={BranchForm} /> | |
</Route> |
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
<Switch> | |
<Route path="/admin/books"> | |
<RecordAdmin singular="book" plural="books" table={BookTable} form={BookForm} /> | |
</Route> | |
<Route path="/admin/authors"> | |
<RecordAdmin singular="author" plural="authors" table={AuthorTable} form={AuthorForm} /> | |
</Route> | |
<Route path="/admin/branches"> | |
<RecordAdmin singular="branch" plural="branches" table={BranchTable} form={BranchForm} /> | |
</Route> |