This file contains hidden or 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
file_builder = open("logger.txt", "w+") | |
for i in range(50000): | |
file_builder.write(f"I'm on line {i + 1}\n") | |
file_builder.close() |
This file contains hidden or 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
const allTopics = document.querySelectorAll('.topics') | |
allTopics | |
copy(allTopics) | |
const arrtopicssample = Array.prototype.slice.call(allTopics); | |
arrtopicssample |
This file contains hidden or 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
console do | |
Rails::ConsoleMethods.send :include, ConsoleHelper::Console | |
end |
This file contains hidden or 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
2.5.0 :005 > u | |
User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."deleted_at" IS NULL ORDER BY "users"."id" DESC LIMIT $1 [["LIMIT", 1]] | |
=> #<User id: 513, email: "[email protected]", created_at: "2017-09-23 23:16:07", updated_at: "2017-09-23 23:16:08", full_name: "Jordan Hudgens", roles: nil, username: "jdhudgenasdfa", slug: "jdhudgenasdfa", deleted_at: nil, role: "standard_user", posts_count: 0> | |
2.5.0 :006 > u('[email protected]') | |
User Load (6.6ms) SELECT "users".* FROM "users" WHERE "users"."deleted_at" IS NULL AND "users"."email" = $1 LIMIT $2 [["email", "[email protected]"], ["LIMIT", 1]] | |
=> #<User id: 1, email: "[email protected]", created_at: "2017-07-11 01:39:44", updated_at: "2017-09-09 19:35:02", full_name: "Jordan Hudgens", roles: nil, username: "jordan", slug: "jordan", deleted_at: nil, role: "standard_user", posts_count: 107> |
This file contains hidden or 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
module ConsoleHelper | |
module Console | |
def u(email = nil) | |
if email | |
User.find_by_email(email) | |
else | |
User.last | |
end | |
end | |
end |
This file contains hidden or 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
class DecoratedClass { | |
constructor(arr) { | |
this.arr = arr; | |
this.total = 0; | |
} | |
sum() { | |
this.arr.map(el => { this.total += el }) | |
return this.total; |
This file contains hidden or 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
class Heading: | |
def __init__(self, content): | |
self.content = content | |
def render(self): | |
return f'<h1>{self.content}</h1>' | |
class Div: | |
def __init__(self, content): | |
self.content = content |
This file contains hidden or 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
class Html: | |
def __init__(self, content): | |
self.content = content | |
def render(self): | |
raise NotImplementedError("Subclass must implement render method") | |
class Heading(Html): | |
def render(self): |
This file contains hidden or 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
const headingGenerator = (title, typeOfHeading) => { | |
return ` | |
<h${typeOfHeading}>${title}</h${typeOfHeading}> | |
` | |
} | |
headingGenerator('Greetings', 1); |
This file contains hidden or 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 heading_generator(title, heading_type): | |
return f'<h{heading_type}>{title}</h{heading_type}>' | |
print(heading_generator('Greetings!', '1')) | |
print(heading_generator('I am in a title', '3')) |