This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr1 = [1, 2, 3] | |
var obj1 = {prop1: "lol", prop2: "lmao"} | |
var arr2 = [...arr1, 4, 5, 6] | |
var obj2 = {...Obj1, prop1: "Trololo", foo: "bar"} | |
console.log(arr2) | |
//expects: [1,2,3,4,5,6] | |
console.log(obj2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RandomService.formatPayload = function (id, fn) { | |
/* Should deduce that RandomService is an object, has a property named 'formatPayload' | |
a funtion with two arguments is being expressed on the property, so it's a method */ | |
return { | |
// this method returns an object | |
client_id: id, | |
/* returned object has a property 'client_id', which has the id argument as value or a reference | |
we cannot deduce the type of the 'id' argument |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create state with constructor | |
constructor(props) { | |
super(props); | |
this.state = {comment: "yo!"}; | |
} | |
// proper way to change the state | |
this.setState({comment: 'Hello'}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str = "<container>\n<row>\n <columns large=\"6\">\n <h1>%{toto}%</h1>\n </columns>\n %{kilo}%\n <columns large=\"6\">\n <i class=\"classx\">%{socco}%</i>\n </columns>\n %{kilo}%\n</row>\n</container>" | |
# /%{+\w+}%/ is the regex of the chosen string interpolation synthax e.g. %{variable}% | |
# we try to extract all of those and put them in an array | |
# first lets get the all the interpolation out of the text | |
interpolition_arr = str.scan(/%{+\w+}%/) | |
# => ["%{toto}%", "%{kilo}%", "%{socco}%", "%{kilo}%"] | |
# make each variable have only one occurence in the variable array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"services": [ | |
{ | |
"id": 8, | |
"name": "Interval training", | |
"default_picture": "http://localhost:3000/system/avatars/photos/000/000/036/medium/interval_train.jpg?1504207529" | |
}, | |
{ | |
"id": 9, | |
"name": "Yoga", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- how to use G_mapper --> | |
<!-- 1) add an input field with this structure --> | |
<input type="text" id="any_id_u_like" data-gmapper-input> | |
<!-- 2) add a div with “data-gmapper-render-for” with the id of input you've added as data attribute value --> | |
<div data-gmapper-render-for="any_id_u_like"> | |
<!-- 3) add a child div with id “distance” --> | |
<!-- and “data-gmapper-endpoint” with the address you want the itinerary from as value --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@club = Club.new(club_params) | |
respond_to do |format| | |
if @club.save | |
format.html { redirect_to @club, notice: 'Club was successfully created.' } | |
format.json { render :show, status: :created, location: @club } | |
else | |
format.html { render :new } | |
format.json { render json: @club.errors, status: :unprocessable_entity } |
NewerOlder