This file contains 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
#!/usr/bin/env ruby | |
def anagram?(subject, test) | |
(test.downcase.chars - subject.downcase.chars).none? | |
end | |
tests = { | |
'evil' => 'vile', | |
'a gentleman' => 'elegant man', | |
'Santa' => 'Satan', |
This file contains 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
#!/usr/bin/env ruby | |
require "csv" | |
# Going to store each line into an array. | |
output = [] | |
# Loop over input from STDIN | |
ARGF.each do |line| | |
# Removes newlines and such. | |
line.chomp! |
This file contains 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
# frozen_string_literal: true | |
def max_subarray(haystack, target_length) | |
cons = haystack.each_cons(target_length).to_a | |
sums = cons.collect(&:sum) | |
cons[sums.index(sums.max)] | |
end | |
puts max_subarray([-4, 2, -5, 1, 2, 3, 6, -5, 1], 4).inspect | |
puts max_subarray([1, 2, 0, 5], 2).inspect |
This file contains 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
let els = document.querySelectorAll("body *[class]"); els.forEach((el) => { let el2 = document.createElement("span"); el2.innerText = el.classList.toString(); el2.style = "color: red;"; el.parentNode.prepend(el2); }); |
This file contains 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
user = User.create(email: 'whatever@nowhere', team_id: 123) | |
# ??? eager loading ??? | |
# user.eager_load(team: {memberships: :admins}) # Maybe? | |
# user.reload(includes: {team: {memberships: :admins}}) # Adds an extra fetch. | |
# N+1 on `memberships` and `admins`. | |
notify_emails = user.team.memberships.admins.collect(:email) |
This file contains 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
// type the part of the emote you want into your chat in Twitch. | |
// For example: :hype | |
// Then paste this into your browser's developer console. | |
// Will yield all of the hype emotes you've gotten on Twitch. | |
// Beware pasting them that there is a 500 character limit per chat. | |
a = []; document.querySelectorAll('.chat-input-tray__open .jrwvz').forEach((i, idx, array) => {a.push(i.title)}); console.log(a.join(' ')); |
This file contains 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
# See https://help.github.com/articles/ignoring-files for more about ignoring files. | |
# | |
# If you find yourself ignoring temporary files generated by your text editor | |
# or operating system, you probably want to add a global ignore instead: | |
# git config --global core.excludesfile '~/.gitignore_global' | |
# Ignore bundler config. | |
/.bundle | |
# Ignore the default SQLite database. |
This file contains 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
FROM rwxrob/base | |
RUN touch ~/found |
This file contains 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
body { | |
background-color: green; | |
color: white; | |
} |
This file contains 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
FROM ruby:2.6 AS jekyll | |
WORKDIR /usr/src/app | |
COPY Gemfile Gemfile.lock /usr/src/app/ | |
RUN bundle install --quiet -j 4 | |
COPY . /usr/src/app/ | |
EXPOSE 3000 | |
CMD jekyll server -P 3000 -H 0.0.0.0 -w --force_polling --incremental | |
FROM jekyll AS website | |
ENV JEKYLL_ENV=production |
NewerOlder