Skip to content

Instantly share code, notes, and snippets.

View celine-m-s's full-sized avatar

Céline MS celine-m-s

  • Paris
View GitHub Profile
@celine-m-s
celine-m-s / Javascript Cheat Sheet
Last active August 29, 2015 14:19
A Javascript cheat sheet for newbies!
// Javascript Cheat Sheet
/************************************
*********** DOM: How to... *********
************************************/
// Find an element by its ID
document.getElementById("anId");
// Show an element
element.show();
client = get_client
positions = client.profile(:fields => ["positions"])
positions.values # should return a hash with companies, dates and so on.
# This is what I did with Devise:
# devise.rb
config.omniauth :linkedin, ENV['OAUTH_LINKEDIN_ID'], ENV['OAUTH_LINKEDIN_SECRET'],
fields: %w(id email-address first-name last-name headline industry picture-url public-profile-url location num-connections positions)
@celine-m-s
celine-m-s / capybara_cheat_sheet.md
Last active February 12, 2017 21:52
Capybara Cheat sheet

#Matchers

expect(page).to have_content 'Success'
expect(page).to have_xpath("//a",:href => "google.com")
expect(page).to have_selector(:xpath, "//p/h1")
expect(page).to have_selector(:css, "p a#post_edit_path")
expect(page).to have_selector("input", :value =>"Post Title")    

#Actions

@celine-m-s
celine-m-s / rspec_cheat_sheet.md
Last active March 7, 2017 15:37
RSpec cheat sheet

Create a new objet and associate it to a new variable before each scenario or it.

let!(:message) { create(:message) } # if used with FactoryGirl, otherwise Message.create(params)

Check if objets have been created

expect { createsomething }.to change{Message.count}.by(20)

# run server
./manage.py runserver
# Interactive shell
./manage.py shell
# don't forget to import the objects you need (models, ...)
# eg from polls.models import Question, Choice
#################################
########### Generators ##########
# check ruby version && rbenv
rbenv local
# Check last available version of Ruby
rbenv install --list
# Create app
rails _5.1.4_ new appname --database=postgresql
# Add pg gem to Gemfile
@celine-m-s
celine-m-s / Dockerfile
Created April 2, 2018 13:04 — forked from remarkablemark/Dockerfile
Install node and npm with nvm using Docker.
# set the base image to Debian
# https://hub.docker.com/_/debian/
FROM debian:latest
# replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# update the repository sources list
# and install dependencies
RUN apt-get update \
@celine-m-s
celine-m-s / python_vs_ruby.md
Last active May 16, 2018 12:16
Python versus Ruby

Ruby

base_class.metadata.sorted_tables
  .each_value
  .select do |value|
    models.any? { |model| value.description.include?(model.__tablename__) }
  end
# Update files that are already in the index and commit.
# == git add . + git commit -m "A message"
git commit -a -m "Ajouté itinéraire dans checklist-vacances.md"
# Create a new commit to cancel another one.
git revert SHACommit
# Change last commit message.
git commit --amend -m "Votre nouveau message"