Skip to content

Instantly share code, notes, and snippets.

View jordanhudgens's full-sized avatar

Jordan Hudgens jordanhudgens

View GitHub Profile
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()
const allTopics = document.querySelectorAll('.topics')
allTopics
copy(allTopics)
const arrtopicssample = Array.prototype.slice.call(allTopics);
arrtopicssample
console do
Rails::ConsoleMethods.send :include, ConsoleHelper::Console
end
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>
module ConsoleHelper
module Console
def u(email = nil)
if email
User.find_by_email(email)
else
User.last
end
end
end
class DecoratedClass {
constructor(arr) {
this.arr = arr;
this.total = 0;
}
sum() {
this.arr.map(el => { this.total += el })
return this.total;
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
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):
const headingGenerator = (title, typeOfHeading) => {
return `
<h${typeOfHeading}>${title}</h${typeOfHeading}>
`
}
headingGenerator('Greetings', 1);
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'))