Skip to content

Instantly share code, notes, and snippets.

View jraczak's full-sized avatar

Justin Raczak jraczak

View GitHub Profile
@jraczak
jraczak / .java
Created July 27, 2015 23:40
Implementing classes & methods - Constructors
public Car(double mpg)
{
milesDriven = 0; // initialize value
gasInTank = 0; // initialize value
milesPerGallon = mpg; // initialize value
}
@jraczak
jraczak / .java
Last active August 29, 2015 14:26
Implementing classes & methods - implementing a method
public class Car
{
private double milesDriven;
private double gasInTank;
public void drive(double distance)
{
milesDriven = milesDriven + distance;
}
public void addGas(double amount)
@jraczak
jraczak / .java
Created July 27, 2015 22:53
Implementing classes & methods - the stump
public class Car
{
private double milesDriven;
private double gasInTank;
public void drive(double distance)
public void addGas(double amount)
// Additional methods fill in below
}
# controllers/api/venues_controller.rb
module API
class VenuesController < ApplicationController
respond_to :json
def show
@venue = Venue.find(params[:id])
render json: @venue
#respond_to do |format|
# format.json { render :json => venue }
module API
class VenuesController < ApplicationController
respond_to :json
def show
@venue = Venue.find(params[:id])
render json: @venue
#respond_to do |format|
# format.json { render :json => venue }
#end
# routes.rb
...
#API Routes
namespace :api, path: '/', constraints: { subdomain: 'api' } do
resources :venues, only: [ :index, :show ]
end
# /controllers/api/venues_controller.rb
curl https://saucelabs.com/rest/v1/[username]/js-tests \
-X POST \
-u [username]:[username] \
-H 'Content-Type: application/json' \
--data '{
"platforms": [["Windows 8", "internet explorer", "10"]],
"url": "https://qunit.herokuapp.com/test/test.html?coverage=true",
"framework": "qunit"}'
$(document).ready(function () {
var audioPlayer = new AudioPlayer ({
el: document.getElementById("audio-player"),
songs: [
{
name: "Language Is Alive (Mass Effect Mashup)",
duration: "6:38",
srcs: [
{
src: "Language Is Alive (Mass Effect Mashup).mp3",
t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
t.string :unlock_token # Only if unlock strategy is :email or :both
t.datetime :locked_at
def self.search(query)
__elasticsearch__.search(
{
query: {
multi_match: {
query: query,
fields: ['name^5', 'properties^3', 'tips', 'venue_subcategory'],
}
}
}