Skip to content

Instantly share code, notes, and snippets.

View heri's full-sized avatar

Heri Rakotomalala heri

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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);
@heri
heri / get lat, long
Last active December 12, 2019 21:13
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"];
@heri
heri / 3dcnn.py
Last active March 31, 2019 05:18
3D CNN to infer throttle and angle for a RC autonomous car . Implementation of https://arxiv.org/pdf/1412.0767.pdf
# 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 =
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();
@heri
heri / todo.rb
Last active September 15, 2015 15:59
def add_message
page._message << { name: page._new_message }
page._new_todo = ''
end
@heri
heri / todo_index.html
Last active September 15, 2015 15:59
<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 }}" />
@heri
heri / main.html
Last active September 8, 2015 15:36
<!-- 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>
# 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
# 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