Skip to content

Instantly share code, notes, and snippets.

@adellhk
adellhk / amazonReturnInstructions
Created June 15, 2016 07:13
Print a return label from Amazon without printing the instructions
if (isReturnInstructions()) {
divs = document.getElementsByClassName('a-section');
for (i = 0; i < divs.length; i++) {
div = divs[i];
if (! div.className.includes("page-break-avoid") && ! div.parentElement.className.includes("page-break-avoid")) {
div.className += (" no-print");
console.log("Div #"+ (i+1) + div.className);
}
}
}
var inputCleaned = input.prompt.toLowerCase().replace(/\s+/g, '')
switch (inputCleaned) {
case 'uninspired':
alert(response.uninspired);
break;
case 'lackofpassion':
alert(response.noPassion);
break;
// etc...
}
@adellhk
adellhk / bingo_case.rb
Created September 7, 2015 04:59
example case statement for a nested bingo array in ruby
case @ran_letter
when "b"
@column = 0
when "i"
@column = 1
when "n"
@column = 2
when "g"
@column = 3
when "o"
def separate_comma(num)
separated_num = num.to_s.split("").reverse
result = []
separated_num.each_with_index.map do |num, index|
if index % 3 == 0 && index != 0
result << num + ","
else
result << num
end
end
$(document).ready(function() {
bindStart(); //assumes you have an element, could be a div or button or whatever, with an id of 'start'
bindRGBYButtons();
});
function bindStart() {
$('#start').on('click', function() {
startGame();
});
};
def vert(board)
board[0].each_with_index do |cell, column_num|
puts "Cell: #{cell}"
if cell == "x"
column = []
4.times do |row_num|
column << board[row_num + 1][column_num]
end
puts "#Column: #{column}"
return true if column.count('x') == 4