This file contains hidden or 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
| // INPUT | |
| [ | |
| { "id": "a0001" | |
| , "name": "happiness inc." | |
| , "opens_at": (3600 * 8) | |
| , "closes_at": (3600 * 20) | |
| , "popularity": 8 | |
| } | |
| , |
This file contains hidden or 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
| # naive implementation. We could move all the .index stuff into one loop | |
| # and do all kinds of other terrible things | |
| # but that's boring | |
| class ParkingOrder | |
| def initialize(current) | |
| @state = current.split('').uniq | |
| @empty = @state.index ?_ | |
| end |
This file contains hidden or 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
| seasonalize () { | |
| local season="$1" | |
| shift | |
| rename 's/\d{2}/S'"$season"'E$&/' "$@" | |
| } |
This file contains hidden or 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
| require 'cgi' | |
| require 'open-uri' | |
| require 'json' | |
| class AutoPoet | |
| BaseURL = 'http://suggestqueries.google.com/complete/search?client=chrome&q=' | |
| Seeds = ['i love', 'you are', 'why does', 'why do', 'why not', 'i have', 'why are', 'where is', 'when will', | |
| 'who is', 'will i', 'can i', 'my girlfriend', 'my boyfriend', "i can't", 'i can', 'my dad', 'my mom', 'my wife', | |
| 'my husband', 'our family', 'some people', 'why do boys', 'why do girls' | |
| ] |
This file contains hidden or 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
| class Integer | |
| Roman = 'IVXLCDM' | |
| def to_roman | |
| raise "Number too large" if self > 3999 | |
| num = self | |
| num_size = Math.log10(num).to_i | |
| # for each num_size.downto(0), | |
| # get which character to display for that level. | |
| num_size.downto(0).map do |pow| | |
| mid = (pow * 2) + 1 |
This file contains hidden or 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
| rule110 = [0, 1, 1, 1, 0, 1, 1, 0] | |
| iterate = (array_of_bools) -> | |
| result_array = [] | |
| array_of_bools = [false, false, array_of_bools..., false, false] | |
| for index_pointer in [0..(array_of_bools.length - 2)] | |
| tally = 0 | |
| tally += 1 << i for i in [0..2] when array_of_bools[index_pointer + 2 - i] | |
| result_array.push rule110[tally] |
This file contains hidden or 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
| d=document;s=d.createElement('script');s.src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js";s.type="text/javascript";d.getElementsByTagName('head')[0].appendChild(s); |
This file contains hidden or 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
| class Hash | |
| def search(m) | |
| retval = [] | |
| self.each_pair do |k,v| | |
| if v.kind_of?(Hash) | |
| v.search(m).each {|u| retval << [k,*u]} | |
| else | |
| rets = case m | |
| when Regexp | |
| v.to_s =~ m |
This file contains hidden or 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
| +javascript:(function()%7Bd%3Ddocument%3Bs%3Dd.createElement(%22script%22)%3Bs.src%3D%22//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js%22%3Bs.type%3D%22text/javascript%22%3Bd.getElementsByTagName(%22head%22)%5B0%5D.appendChild(s)%3B%24().ready(function()%7B%24(%22.spoiler%22).click(function()%7B%24(this).removeClass(%22spoiler%22)%7D)%7D)%7D)()%3B |
This file contains hidden or 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
| git_prompt () { | |
| if ! git rev-parse --git-dir > /dev/null 2>&1; then | |
| return 0 | |
| fi | |
| git_branch=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p') | |
| echo "[$git_branch]" | |
| } | |
| PS1="\w \$(git_prompt)\$ " |