Skip to content

Instantly share code, notes, and snippets.

View rhannequin's full-sized avatar

Rémy Hannequin rhannequin

View GitHub Profile
@rhannequin
rhannequin / best_observation_time.rb
Created July 16, 2023 23:18
Ruby script to compute the best days to observe a celestial body, based on its elevation on the celestial sphere and its angular diamater, based on the IMCCE Opale API.
require "date"
require "faraday"
host = "https://opale.imcce.fr"
observer_longitude = 2.3522
observer_latitude = 48.8566
body = 699 # https://www.imcce.fr/content/medias/recherche/equipes/asd/calceph/html/c/calceph.naifid.html
year = 2023
first_date = Date.new(year, 1, 1)
last_date = Date.new(year, 12, 31)
@rhannequin
rhannequin / equatorial_to_horizontal.rb
Last active July 3, 2022 21:58
Ruby script to convert equatorial to horizon coordinates
require "bigdecimal"
require "date"
time = Time.new(2022, 6, 26, 3, 10, 5, "+02:00")
latitude = BigDecimal("49.70911954641343")
longitude = BigDecimal("0.20271537957527094")
right_ascension_hour = 21
right_ascension_minute = 49
right_ascension_second = 8.6
declination_degree = -14
@rhannequin
rhannequin / excluding-polymorphic.md
Created July 28, 2016 16:19
Issue while trying to exclude articles with specific tag using Rails 5 and polymorphic association

ActiveRecord excluding polymorphic association issue

Considering this situation with Rails 5: I have an Article model and a Tag model. An article has many tags, and a tag can belong to many articles. My schema then looks like this:

class Article < ApplicationRecord
  has_many :taggings, as: :taggable
  has_many :tags, through: :taggings
end
@rhannequin
rhannequin / Gruntfile.js
Last active December 15, 2015 15:28
Optimization with RequireJS.
module.exports = function (grunt) {
//...
grunt.initConfig({
//...
requirejs: {
options: {
@rhannequin
rhannequin / backbone-architecture.js
Last active December 14, 2015 13:08
Understanding of Backbone architecture with Models, Views and Collections.
var Model = Backbone.Model.extend({});
var ModelView = Backbone.View.extend({
initiliaze: function () {
_.template($('#model-template').html());
},
render: function () {
return this.template(this.model.toJSON());
}
});
@rhannequin
rhannequin / requirejs-with-grunt.md
Created February 15, 2013 23:16
Try to understand how to use RequireJS with tools creating single minified-concatenated script file.

Context

I have a bit experience in JavaScript development but I'm quite new in modern development tools such as Yeoman, Grunt or Bower. But I can create webapps with RequireJS, separate logic with Backbone.js and use templating with Handlebars. I am aware of what's going on.

I saw that these tools leads you to concat files, which is great, in my case I want to speak about JavaScript files. I can't understand how it works.

I love RequireJS

With RequireJS, I can separate files, for example if I'm using Backbone.js, every model, every view can be a file. If my application is big enough, some pages will need some models and some other pages will need some other models. And thanks to RequireJS I can load only the models (I mean the files, then) I need.