Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
var my_sports_keyword = "Hiking"; | |
var getSports = await getJSON("https://sports.api.decathlon.com/sports/search/" + my_sports_keyword +"?coordinates=" + latLng); | |
var sport = getSports[0]; | |
console.log("Found sport " + sport["attributes"]["name"] + " with sport_id " + sport["id"] + " for " + my_sports_keyword); |
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
var my_city = "Montreal"; | |
var getJSON = require("async-get-json"); | |
var geLatLng = await getJSON("https://api.opencagedata.com/geocode/v1/json?key=50adaa7181d24a7581a62fd3d9c0a2e0&q=" + my_city); | |
var latLng = geLatLng.results[0].geometry["lng"] + "," + geLatLng.results[0].geometry["lat"]; |
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 basic end-to-end autonomous car uses 2d images to infer throttle and steering. However, speed and acceleration can change this. If the car is already speeding, throttle should decrease. If the car already has speed, then steering should be proportionally less | |
# One way to improve this is with hardware, by adding a RPM speed sensor (optical or magnetic), a GPS, an IMU or a combination. This is used as an input to the model | |
# If one does not have a speed sensor, another way is to update the model so it takes into account the last frames, and by using Kera's 3d convolution methods. Reference paper to read : https://arxiv.org/pdf/1412.0767.pdf | |
# This can slow down inference and result in lower fps | |
img_in3D = Input(shape=(3, 120, 160, 3), name='img_in') # First layer, input layer, takes 3 Shapes comes from camera.py resolution, RGB | |
x = img_in3D x = Cropping3D(cropping = ((0, 0),(60, 0),(0, 0)))(x) # Depending on your camera angle. Most cameras are pointed downards so the top X pixels can be safely cropped | |
x = |
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
jQuery.getJSON('/cart.js', function(cart) { | |
items = cart.items; | |
var results = items.filter(x => x.id === 6223106801703); | |
if ((results.length == 0) && (items.length > 0)) { | |
jQuery.post('/cart/add.js', { | |
quantity: 1, | |
id: 6223106801703 | |
}); | |
location.reload(); |
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
def add_message | |
page._message << { name: page._new_message } | |
page._new_todo = '' | |
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
<h1>Let's chat</h1> | |
<ul> | |
{{ page._messages.each do |message| }} | |
<li>{{ message._name }}</li> | |
{{ end }} | |
</ul> | |
<form e-submit="add_message"> | |
<label>Todo</label> | |
<input type="text" value="{{ page._new_message }}" /> |
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
<!-- Using a top level navigation component --> | |
<:nav href="/about">About</:nav> | |
<!-- Rendered as --> | |
<:Nav> | |
<li class="{{ if active_tab? }}active{{ end }}"> | |
<a href="{{ attrs.href }}">{{ yield }}</a> | |
</li> |
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
# Saves a comment by current user to an event | |
def save_event_comment | |
model._created_at = Time.now | |
model.save!.then do | |
flash._notices << "Thanks for adding a comment" | |
new_event_comment | |
end.fail do |err| | |
flash._notices << err.to_s | |
end | |
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
# Callback hell :/ | |
Yelp.get("restaurants").then do |response| | |
PlacesTasks.sort(response.json[:places]}) do |response| | |
Place.review(response, {ranking: -1}) do |response| | |
puts "All finished" | |
end | |
end | |
end | |
# More readable asynchronous calls with Promises |
NewerOlder