Skip to content

Instantly share code, notes, and snippets.

View kevcha's full-sized avatar

Kevin Chavanne kevcha

  • WeDressFair
  • Lyon, France
View GitHub Profile

HTML & CSS font partie des langages du web, c'est à dire qu'ils peuvent être lu et compris par un navigateur web. En terme technique, un navigateur web est un logiciel qui est capable de parser et d'interpréter de l'HTML, du CSS, et d'exécuter du JavaScript (on verra ca plus tard).

Donc, quand on envoie un fichier HTML à a un navigateur (ou quand on ouvre un fichier HTML présent sur son ordi dans un navigateur), si le fichier est bien écrit, qu'il respecte la spécification du W3C (World Wide Web Consortium), alors il va construire une interface graphique a partir du code HTML & CSS.

Du coup, HTML c'est vraiment le contenu, que l'on structure dans des tags (le plus courant est la div, pour "division"). Depuis HTML5, on a a disposition plein de nouveau tags, qui se comportent exactement comme des divs (ils sont par defaut des blocks), mais ils ont une valeur "sémantique", qui va permettre aux moteurs de recherche de mieux comprendre notre page web quand on se fera indexer. Donc c'est mieux d'utiliser les nouv

@kevcha
kevcha / assets_in_rails.md
Created September 3, 2018 07:48
Assets in rails

How assets are handled in Rails

What's assets ? Assets are all javascripts, css, and images files. They are stored in app/assets and app/javascripts.

The directory app/assets is handled by a tool called sprockets that we want to change in future. The directory app/javascripts is handled by another tool called webpack.

Why we have 2 directories with differents tools ?

Historically, we used only the directory app/assets for all javascripts, css and images files. Sprockets was used to apply some transformation on all those files.

@kevcha
kevcha / namespace_partials_sharing.md
Last active December 29, 2022 07:53
How to automatically share partials between namespaces in rails

When writing a rails app, we often have to deal with multiple namespaces. The most common case is having classic actions and some others in an admin namespace. Some actions may have same views between namespaces.

For exemple, you could have a ProjectsController with an action index :

class ProjectsController < ApplicationController
  def index
    # do something
  end
end
@kevcha
kevcha / doc.md
Last active August 29, 2015 14:13
1D touch API documentation

Authentication

Get an OAuth Token

Each user that has a valid 1D touch account can generate an api Token with

POST /oauth/token
{
  grant_type=password
  username=user@example.com
  password=password
@kevcha
kevcha / heroku_private_gem.md
Last active August 29, 2015 14:11
Deploying pivate gems on Heroku

Deploying private gems on heroku

Heroku is a incredible tool for deploying web apps in minutes. The problem comes when you want to deploy an with a private gem.

Here are the solutions I've found browsing the web

Vendorize your gem in your app

  • Unpacking your gem in vendor/your_gem and link it in Gemfile :
gem 'your_gem', path: 'vendor/your_gem
@kevcha
kevcha / rules.md
Last active August 29, 2015 14:08
Phpcs

Generic

Classes

DuplicateClassName : Reports errors if the same class or interface name is used in multiple files

CodeAnalysis

EmptyStatementSniff : Reports errors if the a statement is empty (only whitespaces or comments)

ForLoopShouldBeWhileLoopSniff : This rule is based on the PMD rule catalog. Detects for-loops that can be simplified as a while-loop.

ForLoopWithTestFunctionCallSniff : This rule is based on the PMD rule catalog. Detects for-loops that use a function call in the test expression.

@kevcha
kevcha / timezones.md
Last active August 29, 2015 14:03
Timezones

Initial configuration

My current timezone : GMT+2 ('Europe/Paris')
rails new sandbox (rails 4.1.1)
rails g model User name:string

Database : Postgresql 9.3.4

In seed.rb :

User.create(name: 'Kévin')
@kevcha
kevcha / Explanations.md
Last active July 6, 2019 03:33
Rails 4 view resolvers

The problem

Using multiple namespaces will require to have also namespaces views. For exemple, if you have an Admin namespace, with a Admin::ProjectsController with a show action that also exists in non namespaced ProjecsController, you cannot render views/projects/show.html.erv from Admin::ProjecsController.

What we want to do

The researched behavior is to try to render the views/admin/projects/show.html.erb, and, if it doesn't exist, fallback to views/projects/show.html.erb

The solution

@kevcha
kevcha / gist:6163894
Created August 6, 2013 12:02
Difference between Factory, Services and Providers @see https://groups.google.com/forum/#!msg/angular/56sdORWEoqg/b8hdPskxZXsJ => Miško Hevery answers
Lets look at the simplest scenario
provide.value('a', 123);
function Controller(a) {
expect(a).toEqual(123);
}
in this case the injector simple returns the value as is. But what if you want to compute the value. Then use a factory