Skip to content

Instantly share code, notes, and snippets.

View kermit-klein's full-sized avatar
🏠
Working from home

Ali Erbay kermit-klein

🏠
Working from home
View GitHub Profile
@kermit-klein
kermit-klein / example.js
Last active November 22, 2020 14:31
hoist3
var foo = 1;
function bar() {
if (!foo) {
var foo = 10;
}
alert(foo);
}
bar();
var printLastName;
printLastName = function() {
console.log("McClane")
}
var printFirstName; // undefined
printLastName() // "McClane"
printFirstName() // Uncaught TypeError: printFirstName is not a function
@kermit-klein
kermit-klein / functions.js
Created November 22, 2020 09:44
hoisting1
printLastName() // "McClane"
printFirstName() // Uncaught TypeError: printFirstName is not a function
function printLastName() {
console.log("McClane")
}
var printFirstName = function() {
console.log("John")
}
@kermit-klein
kermit-klein / check_parans
Created November 11, 2020 21:54
check_parans
#!/usr/bin/env ruby
require "./lib/check_parans/cli"
CheckParans::CLI.start
@kermit-klein
kermit-klein / cli.rb
Created November 11, 2020 14:47
cli checkparans
require 'thor'
require 'CheckParans'
module CheckParans
class CLI < Thor
desc "check_parans", "Determines if parenthesis are valid"
def check_parans(string)
puts CheckParans.valid_parentheses(string)
end
end
end
require 'CheckParans'
our_test_code_1 = 'const result = array.map((element)=>element*2)'
our_test_code_2 = 'const result = array.map((element)=>element*2))'
CheckParans.valid_parentheses(our_test_code_1)
CheckParans.valid_parentheses(our_test_code_2)
module CheckParans
def self.valid_parentheses(string)
only_parants = string.scan(/([()])/)
if only_parants.empty?
true
elsif only_parants.length == 1
false
end
k = false
until k == true
@kermit-klein
kermit-klein / CheckParans_spec.rb
Last active October 17, 2020 20:03
CreateParanstest
RSpec.describe CheckParans do
it "has a version number" do
expect(CheckParans::VERSION).not_to be nil
end
it "gives true when parentheses are valid" do
expect(CheckParans.valid_parentheses('((sdf)())')).to eql(true)
end
it "gives false when parentheses are invalid" do
expect(CheckParans.valid_parentheses('(sdfs')).to eql(false)
end
require_relative 'lib/check_parans/version'
Gem::Specification.new do |spec|
spec.name = "check_parans"
spec.version = CheckParans::VERSION
spec.authors = ["yourName"]
spec.email = ["yourEmail@gmail.com"]
spec.summary = "This is a test gem"
spec.description = "This gem checks parenthesis validity"
@kermit-klein
kermit-klein / CheckParans.gemspec
Created October 17, 2020 17:40
original gem spec
require_relative 'lib/CheckParans/version'
Gem::Specification.new do |spec|
spec.name = "CheckParans"
spec.version = CheckParans::VERSION
spec.authors = ["yourName"]
spec.email = ["yourEmail@gmail.com"]
spec.summary = %q{TODO: Write a short summary, because RubyGems requires one.}
spec.description = %q{TODO: Write a longer description or delete this line.}