Skip to content

Instantly share code, notes, and snippets.

View kbberker's full-sized avatar

Kenan Berker kbberker

  • Octopus MoneyCoach
  • London, UK
View GitHub Profile
//&& will only do the rhs if lhs is truthy
this.props.botPresent && this.state.bots.map(...)
let { bot } = props;
// is equivalent to..
let bot = props.bot;
rails destroy resource Dog #get rid of everything related to Dog
--------------------------------------------------------------------------
rails new dog-app -T #-T to create without the test framework . Test with byebug
cd dog-app/
# To create a rails api app with postgresql as the database:
rails new <my_app_name> --database=postgresql --api
# Navigate to your Gemfile and uncomment gem 'rack-cors'
# Make sure you add the gem 'active_model_serializers' to your Gemfile.
class VideoGameCharacter
@@all = []
def initialize(name, level)
@name = name
@level = level
@@all << self
end
@kbberker
kbberker / video_game_character.rb
Last active November 27, 2018 10:16
Defining self in RUby
class VideoGameCharacter
def initialize(name, level)
@name = name
@level = level
end
end
@kbberker
kbberker / class_wizard.rb
Created November 15, 2018 10:34
Wizard Class
class Wizard
attr_accessor :name, :age, :hair_colour, :favourite_spell
@@all = []
def initialize(name, age, hair_colour, favourite_spell)
@name = name
@age = age
@hair_colour = hair_colour
@kbberker
kbberker / hash_of_wizards.rb
Last active November 15, 2018 10:11
Hash of wizards
wizards = {
"Harry" =>{
:full_name => "Harry James Potter",
:age => 12,
:hair_colour => "brown",
:favourite_class => "Defence Against the Dark Arts"
},
"Ron" =>{
:full_name => "Ronald Bilius Weasley",
:age => 11,
@kbberker
kbberker / array_wizards.rb
Created November 15, 2018 09:21
Array of wizards
wizard = ["Harry Potter", 12, "brown"]
wizards = [["Harry Potter", 12, "brown"],["Ron Weasley", 11, "ginger"],["Hermione Granger", 12, "brown"]]
@kbberker
kbberker / string_wizard.rb
Last active November 15, 2018 09:20
Wizards evolution
wizard = "Harry Potter"
wizard #=> "Harry Potter"