Skip to content

Instantly share code, notes, and snippets.

View willwright82's full-sized avatar
👾
parsleybox.com

Will Wright willwright82

👾
parsleybox.com
View GitHub Profile
@willwright82
willwright82 / chromeDevTools.js
Created April 3, 2017 14:53
Some neat things you can do with Chrome DevTools
// Access the currently selected element via:
console.log($0);
// See fired events with:
monitorEvents(window,'click');
// Kick off the debugger the next time the given function is called:
debug(myFunction);
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+
@willwright82
willwright82 / check_array_for_sum.rb
Created March 15, 2017 15:27
A Ruby solution for Google's Interview question: Check if any 2 numbers of an array add up to 8 (https://www.youtube.com/watch?v=XKu_SEDAykw)
def check_array_for_sum?(array, sum)
!!array.combination(2).detect { |a, b| a + b == sum }
end
sum = 8
array = [1, 2, 4, 9]
check_array_for_sum?(array, sum) # returns false
array = [1, 2, 4, 4]
@willwright82
willwright82 / flexBoxGrid.html
Last active May 18, 2017 10:02
Simple responsive flexbox grid
<style type="text/css" media="all">
body {
margin: 0;
}
.container {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.flex-grid {
@willwright82
willwright82 / exitPopup.js
Created March 13, 2017 15:09
Exit popup using a mouseout event listener
// Exit intent
var exitShown = false;
function addEvent(obj, evt, fn) {
if (obj.addEventListener) {
obj.addEventListener(evt, fn, false);
} else if (obj.attachEvent) {
obj.attachEvent("on" + evt, fn);
}
}
@willwright82
willwright82 / sqliteToPostgres.md
Last active September 22, 2022 00:32
Swap out sqlite for postgres in a fresh Rails install

Gemfile

  • Delete the line with sqlite and replace it with:
gem 'pg'

database.yml

@willwright82
willwright82 / awk-sed.sh
Created March 2, 2017 16:07
How to print text between tags or characters with awk or sed
echo "bla(foo)"|awk -F'[(|)]' '{print $2}'
#foo
echo "bla=@@foo@@"|awk -F'[@@|@@]' '{print $3}'
#foo
echo "blah(foo)"|sed -n 's/.*(\([^ ]*\))/\1/p'
#foo
echo "aaafoobbb"|sed -n 's/.*aaa\([^ ]*\)bbb/\1/p'
#foo
@willwright82
willwright82 / gitReflog.sh
Created February 21, 2017 14:06
Git Reflog == Time Machine ;)
git reflog
# you will see a list of every thing you've done in git, across all branches!
# each one has an index HEAD@{index}
# find the one before you broke everything
git reset HEAD@{index}
# magic time machine
@willwright82
willwright82 / hashToCSV.rb
Created February 15, 2017 10:27
Convert an array of hashes to a CSV file
CSV.open("data.csv", "wb") do |csv|
csv << @data.first.keys # adds the attributes name on the first line
@data.each do |hash|
csv << hash.values
end
end
@willwright82
willwright82 / duplicateVersion.sh
Last active February 15, 2017 10:28
Duplicate every line containing `attributeA` replacing it with `attributeB` in VIM
# Duplicate every line containing `attributeA` replacing it with `attributeB`
:g/attributeA/ copy . | s//attributeB/g