Skip to content

Instantly share code, notes, and snippets.

View zaagan's full-sized avatar
🤘
Hey !! Have a nice day

Ozesh Thapa zaagan

🤘
Hey !! Have a nice day
View GitHub Profile
@zaagan
zaagan / Ruby Basics - Methods and Access Control.rb
Created January 27, 2020 12:10
Ruby Basics - Methods and Access Control
class MyClass
def method_1
puts 'This is a public method'
end
def method_2
puts 'This is a public method'
end
@zaagan
zaagan / Ruby - Accessors 2.rb
Created January 14, 2020 18:15
Ruby - Accessors 2
class SpaceShip
# Combines attr_reader and attr_writer
attr_accessor :destination
# Define multiple accessors
attr_accessor :insulation, :parachutes
attr_reader :name
attr_writer :name
end
@zaagan
zaagan / Ruby - Accessors.rb
Created January 14, 2020 18:13
Ruby - Accessors
class SpaceShip
attr_accessor :destination
end
# Behind the scenes
class SpaceShip
# Getter
def destination
@destination
end
@zaagan
zaagan / Ruby Dynamic Json Object Reader.rb
Created January 8, 2020 19:17
Ruby Dynamic Json Object Reader
require './cars'
class Car
def initialize(data)
data.each do |key, value|
self.class.add_attribute(key,value)
end
end
@zaagan
zaagan / DH - Ruby Car Data 2.rb
Created January 8, 2020 19:13
DH - Ruby Car Data 2.rb
# Source
# https://github.com/vega/vega/blob/master/docs/data/cars.json
FORD_MAVERICK_DATA = {
Name: "ford maverick",
Miles_per_Gallon: 21,
Cylinders: 6,
Displacement: 200,
Horsepower: 85,
Weight_in_lbs: 2587,
@zaagan
zaagan / DH - Ruby Car Data Implementation.rb
Created January 8, 2020 18:50
DH - Ruby Car Data Implementation
require './cars'
class Ford
attr_reader :Name, :Origin
def initialize(data)
@Name = data[:Name]
@Origin = data[:Origin]
end
end
@zaagan
zaagan / DH - Ruby Car Data Sample.rb
Last active January 8, 2020 18:47
DH - Ruby Car Data Sample
FORD_MAVERICK_DATA = {
Name: "ford maverick",
Miles_per_Gallon: 21,
Cylinders: 6,
Displacement: 200,
Horsepower: 85,
Weight_in_lbs: 2587,
Acceleration: 16,
Year: "1970-01-01",
Origin: "USA",
@zaagan
zaagan / MS SQL Find Stored Procedure Containing A Text.sql
Created January 5, 2020 11:51
MS SQL Find Stored Procedure Containing A Text
-- Find An SP Containing text
SELECT name,
OBJECT_DEFINITION(object_id)
FROM sys.procedures
WHERE OBJECT_DEFINITION(object_id)
LIKE '%user-request%';
-- Find An SP Containing text
-- Using System Information schema View
SELECT ROUTINE_NAME,
@zaagan
zaagan / MS SQL Find Stored Procedure.sql
Created January 5, 2020 11:47
MS SQL Find Stored Procedure
-- Find SP By Name
SELECT
name
FROM
sys.procedures
WHERE
name LIKE '%request%'
-- Find SP via System Information schema View
SELECT
@zaagan
zaagan / MS SQL Find A Table.sql
Last active January 5, 2020 11:42
MS SQL Find A Table
-- Find Table By Name
SELECT *
FROM sys.tables
WHERE name LIKE '%request%';
-- Find Table From All Databases By Name
EXEC sys.sp_MSforeachdb
'SELECT ''?'' DatabaseName, Name
FROM [?].sys.Tables
WHERE Name