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
| #!/usr/bin/env ruby | |
| # deep_research.rb | |
| require 'openai' | |
| require 'json' | |
| require 'net/http' | |
| require 'uri' | |
| require 'timeout' | |
| require 'time' |
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
| #!/usr/bin/env sh | |
| word_length=$1 | |
| all_words=/usr/share/dict/words | |
| # use outer wrapping parens to convert to an array | |
| words=( $(grep -E "^.{$word_length}$" $all_words) ) | |
| num_words=${#words[@]} # get length of words array | |
| index=$(($RANDOM % $num_words)) # make a random index |
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
| // This is a very bare-bones (and incomplete) implementation of the idea | |
| // behind Promise, using a new function called Commitment: | |
| const Commitment = function(func) { | |
| this.state = 'PENDING' // will be changed to 'FULFILLED' or 'REJECTED' | |
| const resolve = (result) => { | |
| this.state = 'FULFILLED' | |
| this.resolver && this.resolver(result) | |
| } |
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 'stringio' | |
| require 'timeout' | |
| class Object | |
| def methods_returning(expected, *args, &blk) | |
| old_stdout = $> | |
| $> = StringIO.new | |
| methods.select do |meth| | |
| Timeout::timeout(1) { dup.public_send(meth, *args, &blk) == expected rescue false } rescue false |
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
| hjkl - move around | |
| :#,#d - deletes between two lines, eg: :10,12d deletes lines 10 through 12 | |
| x - delete character | |
| o - insert on next line | |
| O - insert on preceding line | |
| a - insert after cursor | |
| i - go into insert mode | |
| w - move to beginning of next word (also W for whitespace delimited word) | |
| e - move to end of word (also E for whitespace delimited words) | |
| b - move backward to start of word (also B) |
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 'rubygems' | |
| require 'google_drive' | |
| # Go get your consumer key, client_secret, and client_id for Google Drive here https://code.google.com/apis/console/ | |
| consumer_key = 'INSERT YOUR CONSUMER_KEY HERE' | |
| client_secret = 'INSERT YOUR CLIENT_SECRET HERE' | |
| client_id = 'INSERT YOUR CLIENT_ID HERE' | |
| client = OAuth2::Client.new( | |
| client_id, client_secret, |