Skip to content

Instantly share code, notes, and snippets.

View coralieco's full-sized avatar

Coralie Collignon coralieco

View GitHub Profile
@coralieco
coralieco / attestation_rule.rb
Created March 20, 2021 10:54
French Attestation Rules
HOT_DEPARTMENTS = ["Aisne", "Alpes-Maritimes", "Essonne", "Eure", "Hauts-de-Seine", "Nord", "Oise",
"Paris", "Pas-de-Calais", "Seine-et-Marne", "Seine-Saint-Denis", "Seine-Maritime", "Somme",
"Val-de-Marne", "Val-d’Oise", "Yvelines"]
def please_explain(living_department:, reason_to_get_out:)
if HOT_DEPARTMENTS.include?(living_department)
distance_rule = reason_to_get_out.include?("*") ? "not " : ""
return "You need an attestation & you're #{distance_rule}limited by the 30km rule"
else
if Time.now.hour.between?(9, 19)
@coralieco
coralieco / ruby_on_lambda.md
Last active July 4, 2019 16:05
Ruby on Lamdba Tutorial - main struggles

How to deploy Ruby Functions/ Apps with AWS Lambda

I followed this tutorial about getting started with Ruby on Lambda.

Nothing really happened as mentionned in the tutorial because many surprises occurred along the way :)

This tutorial is basically in 3 parts:

  1. Creating a Hello World example
  2. Including dependencies
@coralieco
coralieco / useful_tools.md
Last active June 13, 2019 16:35
Useful tools

Useful tools in case I have to setup a environment on a new machine

Browser extension (Chrome, Firefox, Opera and Safari) that displays a code tree on GitHub

Browser extension - Preview your notifications without leaving the page

@coralieco
coralieco / apktool.md
Created January 16, 2019 15:22
Apk Tool

How to read static fields from an APK

First install apktool

brew install apktool

Second run the command

apktool d PATH_TO_THE_APK_FILE
@coralieco
coralieco / invalid_column_reference.md
Last active November 23, 2018 16:50
Result from query differs between Postgres and SQLite3

I am trying to run a very simple query on Postgres.

SQLite3

With Sqlite3, this query works perfectly:

>> SELECT DISTINCT "users".* FROM "users" INNER JOIN "comments" ON "comments"."user_id" = "users"."id" ORDER BY "comments"."rating" ASC
@coralieco
coralieco / database_managenent_for_sql_queries.md
Last active November 21, 2018 14:22
ActiveRecord advanced query: What happens in DB with has_many & distinct queries

ActiveRecord advanced query

☀️ postgresql: has_many & distinct.

What happens in DB ?

Rails app

I created a rails app with models like so:

@coralieco
coralieco / pg_ar_in_ruby_project.md
Last active November 17, 2018 15:22
Use ActiveRecord and PG in Ruby project to play with data

Connect DB to a Ruby Project and play with queries in console

I already had a ruby project, and there are few things I wanted to try to test some ActiveRecord queries. First I implemented a small script (see here ) But it was not easy to play with classes as I had to run the full script (gem installs, models definitions etc.).

I was looking a way to interact directly with the dabase in console.

Models

@coralieco
coralieco / has_many.rb
Created November 12, 2018 18:50
Thoughtbot upcase: Querying has_many Associations
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
@coralieco
coralieco / belongs_to.rb
Created November 12, 2018 16:16
Thoughtbot upcase: Querying belongs_to Associations
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
@coralieco
coralieco / belongs_to.md
Last active October 22, 2018 13:32
errors.details for belongs_to validation

errors.details is { error: blank } on belongs_to validation

With Rails 5, there is a validation on belongs_to association.

Actual behavior

If you have: