Skip to content

Instantly share code, notes, and snippets.

View hauntedhost's full-sized avatar
💭
👻

Jules Omlor hauntedhost

💭
👻
View GitHub Profile
# Write a function which takes a number N of cats and outputs which cats have
# hats. Initially, none of the cats have hats. You walk down the line of cats,
# stopping at every cat, taking off its hat if it has one or putting on a hat
# if it doesn't have one. On the second round, you only stop at every second
# cat [eg #2, #4, #6], on the third round you stop at every third cat [eg #3,
# #6, #9...]. You continue this until you've done as many round as there are
# cats. Your function should output an array containing booleans indicating
# whether each cat has a hat or not by the end.
def cats_in_hats(num_cats)
# Write a method ordered_vowel_words that takes a string of lowercase words
# and returns a string with just the words containing all their vowels
# (excluding "y") in alphabetical order
def ordered_vowel_words(words)
vowels = %w(a e i o u)
ordered = []
words.split(" ").each do |word|
word_vowels = word.chars.select { |char| vowels.include? char } # amends = ae, complicated = oiae
ordered << word if word_vowels == word_vowels.sort
jQuery.noConflict();
(function ($) {
// your code in here can safely use $ for jQuery
})(jQuery);
// code using $ for another library
require 'rspec'
def ordered_vowel_words(words)
words.split(" ").inject([]) do |valid_words, word|
vowels = word.scan(/[aeiou]/)
valid_words.tap { |w| w << word if vowels == vowels.sort }
end.join(" ")
end
describe "#ordered_vowel_words" do
// Complete the solution so that it splits the string into pairs of two characters. If the string contains an odd number of characters then it should replace the missing second character of the final pair with an underscore ('_').
// Examples:
// solution('abc') // should return ['ab', 'c_']
// solution('abcdef') // should return ['ab', 'cd', 'ef']
function paddedPairs(str) {
var pairs = [''];
for (var i = 0; i < str.length; i++) {
require 'benchmark'
require 'set'
def ordered_vowel_words_regex(words)
valid_words = []
words.split(" ").each do |word|
vowels = word.scan(/[aeiou]/)
valid_words << word if vowels == vowels.sort
end
valid_words.join(" ")
{
"detect_indentation": false,
"draw_white_space": "all",
"font_size": 17.0,
"ignored_packages":
[
"Vintage",
"Handlebars",
"ColorPick"
],
@hauntedhost
hauntedhost / mnemonic-wordlist.txt
Created July 9, 2014 18:06
mnemonic wordlist, for naming servers, services, etc, etc.
Wordlist ver 0.732 - EXPECT INCOMPATIBLE CHANGES;
acrobat africa alaska albert albino album
alcohol alex alpha amadeus amanda amazon
america analog animal antenna antonio apollo
april aroma artist aspirin athlete atlas
banana bandit banjo bikini bingo bonus
camera canada carbon casino catalog cinema
citizen cobra comet compact complex context
credit critic crystal culture david delta
dialog diploma doctor domino dragon drama
@hauntedhost
hauntedhost / hookup_container_example.js
Created September 9, 2014 22:36
Ember.js HookupContainer mixin
// mixins/hookup_container.js
App.HookupContainer = Ember.Mixin.create({
// https://github.com/tehviking/giffindor/issues/1#issuecomment-51066764
hookupContainer: function() {
this.container = SoftLacrosse.__container__;
}.on('init'),
});
// components/my_component.js
App.MyComponent = Ember.Component.extend(
@hauntedhost
hauntedhost / Preferences.sublime-settings
Created September 25, 2014 19:05
Sublime preferences
{
"detect_indentation": false,
"draw_white_space": "all",
"font_size": 17.0,
"indent_to_bracket": true,
"rulers":
[
80
],
"show_full_path": true,