Skip to content

Instantly share code, notes, and snippets.

@rhamdeew
Last active November 29, 2021 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhamdeew/988b07ed1baba05ed64c9f3a54e361ac to your computer and use it in GitHub Desktop.
Save rhamdeew/988b07ed1baba05ed64c9f3a54e361ac to your computer and use it in GitHub Desktop.
Ruby snippets for VS Code
{
"Byebug": {
"prefix": "bb",
"body": [
"byebug",
],
"description": "Place debugger breakpoint"
},
"Screenshot and save": {
"prefix": "ss",
"body": [
"screenshot_and_save_page",
],
"description": "Capybara Screenshot and save page"
},
"Insert attr_reader": {
"prefix": "r",
"body": "attr_reader :${0:attr_names}"
},
"Insert attr_writer": {
"prefix": "w",
"body": "attr_writer :${0:attr_names}"
},
"Insert attr_accessor": {
"prefix": "rw",
"body": "attr_accessor :${0:attr_names}"
},
"Insert inctance variable cache": {
"prefix": "ivc",
"body": "@${1:variable_name} ||= ${0:cached_value}"
},
"Insert each with inline block": {
"prefix": "ea",
"body": "each { |${1:e}| $0 }"
},
"Insert each with multiline block": {
"prefix": "ead",
"body": [
"each do |${1:e}|",
"\t$0",
"end"
]
},
"Insert each with index inline block": {
"prefix": "eawi",
"body": "each_with_index { |${1:e}, ${2:i}| $0 }"
},
"Insert each with index multiline block": {
"prefix": "eawid",
"body": [
"each_with_index do |${1:e}, ${2:i}|",
"\t$0",
"end"
]
},
"Insert each with object multiline block": {
"prefix": "eawod",
"body": [
"each_with_object({}) do |${1:e}, ${2:i}|",
"\t$0",
"end"
]
},
"Insert reduce inline block": {
"prefix": "red",
"body": "reduce(${1:init}) { |${2:mem}, ${3:var}| $0 }"
},
"Insert reduce multiline block": {
"prefix": "redd",
"body": [
"reduce(${1:init}) do |${2:mem}, ${3:var}|",
"\t$0",
"end"
]
},
"Insert map inline block": {
"prefix": "map",
"body": "map { |${1:e}| $0 }"
},
"Insert map multiline block": {
"prefix": "mapd",
"body": [
"map do |${1:e}|",
"\t$0",
"end"
]
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment