query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Method for when choosing the wrong option | def wrong_choice_castle
castle_choices = ["door", "staircase"]
puts "\nTry something else!"
sleep(2)
puts "\nWould you like to open the door, or walk up the staircase"
puts "Type 'door' or 'stairs':"
print"> "
confirm = $stdin.gets.chomp.upcase
clear_screen
if confirm == 'DOOR' or confirm == 'D'
puts "The door is locked and you dont have another key."
wrong_choice_castle
elsif confirm == 'STAIRS' or confirm == 'S'
sleep(3)
puts "You found the person who wrote the note! They ask you if you brought their things."
user_items
else
puts "Choose again..."
wrong_choice_castle
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_wrong_option\n print \"Option not available. \".red\n determine_action(get_entry(\"Select option: \"))\n end",
"def invalid_option\n\t\t\t\talert_menu \"Invalid option!\"\n\t\t\tend",
"def wrong\n puts \"That isn't an option.\"\nend",
"def handle_failed_option param, value\n @op... | [
"0.82844484",
"0.7254024",
"0.6870698",
"0.66863483",
"0.6630172",
"0.6547199",
"0.6544381",
"0.64546454",
"0.64275086",
"0.6419179",
"0.64147204",
"0.63416606",
"0.63246053",
"0.629147",
"0.6258797",
"0.6213058",
"0.6212745",
"0.62104946",
"0.62104946",
"0.6209898",
"0.62082... | 0.57740885 | 80 |
Method to determine if the items_collected are equal to the correct items | def user_items
puts "\nLets see if you collected the correct items: "
#sleep arguement to build suspense
puts "Confirming please wait..."
sleep(4)
puts "........................."
sleep(3)
puts "...........in progress"
sleep(2)
puts "......complete"
sleep(2)
# verification that the items_collected equal valid_items
if $items_collected == ["key", "ruby"] or $items_collected == ["key", "trolls_head"]
puts "\nYou have the correct combination!\n\n"
winner
else
puts "\nYou have the wrong combination\n\n"
game_over
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def elements_to_check\n if _expected_items\n SitePrism.logger.debug('Expected Items has been set.')\n _mapped_items.select { |name| _expected_items.include?(name) }\n else\n _mapped_items\n end\n end",
"def eql?(other)\n items == other.items\n end",
"def has_diffe... | [
"0.68206316",
"0.66478705",
"0.63728166",
"0.6343408",
"0.6107428",
"0.6076263",
"0.6073184",
"0.6022486",
"0.6015479",
"0.5984871",
"0.5984871",
"0.5971225",
"0.59331584",
"0.5925663",
"0.5912528",
"0.5910336",
"0.59098506",
"0.5895275",
"0.5863873",
"0.58603",
"0.5829628",
... | 0.590831 | 17 |
Method for declaring a winner | def winner
puts "██╗ ██╗██╗███╗ ██╗███╗ ██╗███████╗██████╗ "
sleep(1)
puts "██║ ██║██║████╗ ██║████╗ ██║██╔════╝██╔══██╗"
sleep(1)
puts "██║ █╗ ██║██║██╔██╗ ██║██╔██╗ ██║█████╗ ██████╔╝"
sleep(1)
puts "██║███╗██║██║██║╚██╗██║██║╚██╗██║██╔══╝ ██╔══██╗"
sleep(1)
puts "╚███╔███╔╝██║██║ ╚████║██║ ╚████║███████╗██║ ██║"
sleep(1)
puts " ╚══╝╚══╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝"
sleep(1)
puts " "
sleep(1)
restart_game
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def choose_winner; end",
"def determineWinner() \n\n end",
"def winner\n win_hash = { basic: basic_winner,\n war: war_winner,\n mutually_assured_destruction: \"No Winner\"\n }\n win_hash[type]\n end",
"def calculate_winner\n self.winner = case huma... | [
"0.8574461",
"0.8283075",
"0.7913106",
"0.7911575",
"0.78621525",
"0.78519833",
"0.77920395",
"0.7756256",
"0.7721722",
"0.7719243",
"0.7676749",
"0.7655556",
"0.76424044",
"0.7613858",
"0.7608238",
"0.7604449",
"0.7602887",
"0.75950396",
"0.7579058",
"0.7568165",
"0.755622",... | 0.0 | -1 |
Method for declaring a loser | def game_over
puts " ██████╗ █████╗ ███╗ ███╗███████╗"
sleep(1)
puts "██╔════╝ ██╔══██╗████╗ ████║██╔════╝"
sleep(1)
puts "██║ ███╗███████║██╔████╔██║█████╗ "
sleep(1)
puts "██║ ██║██╔══██║██║╚██╔╝██║██╔══╝ "
sleep(1)
puts "╚██████╔╝██║ ██║██║ ╚═╝ ██║███████╗"
sleep(1)
puts "╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝"
sleep(1)
puts " "
sleep(1)
puts "██████╗ ██╗ ██╗███████╗██████╗ "
sleep(1)
puts "██╔═══██╗██║ ██║██╔════╝██╔══██╗ "
sleep(1)
puts "██║ ██║██║ ██║█████╗ ██████╔╝ "
sleep(1)
puts "██║ ██║╚██╗ ██╔╝██╔══╝ ██╔══██╗ "
sleep(1)
puts "╚██████╔╝ ╚████╔╝ ███████╗██║ ██║ "
sleep(1)
puts "╚═════╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝ "
sleep(1)
exit(0)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loser\n losing_players\n end",
"def recruit_follower(follower)\n if follower.age >= self.minimum_age\n BloodOath.new(follower, self)\n else\n \"You're too young to join!\"\n end\nend",
"def recruit_follower(follower)\n Bloodoath.new(self,follower)\n end",
"def recruit_follower(followe... | [
"0.6729429",
"0.58560693",
"0.5849615",
"0.5828402",
"0.58095354",
"0.5807593",
"0.57001513",
"0.56908226",
"0.5678635",
"0.5651082",
"0.56043345",
"0.5533269",
"0.55029476",
"0.54984325",
"0.5496572",
"0.5496047",
"0.548521",
"0.5442592",
"0.5442592",
"0.5442592",
"0.5442592... | 0.0 | -1 |
Invoked when whole batch of tests starts | def start_run
# Abstract
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def begin_lights_test\n puts 'Invoker: start test'\n @on_start.execute if @on_start.is_a? Command\n\n puts 'Invoker: ...loading last tests...'\n\n puts 'Invoker: starting last tests'\n @on_finish.execute if @on_finish.is_a? Command\n end",
"def start_tests(files)\n end",
"def testing_begin... | [
"0.7290005",
"0.7084365",
"0.7042356",
"0.6970161",
"0.6792924",
"0.6775403",
"0.67496324",
"0.67052776",
"0.6659743",
"0.6659743",
"0.6612536",
"0.65535635",
"0.64874935",
"0.6461042",
"0.644774",
"0.644774",
"0.6446313",
"0.64417565",
"0.64395756",
"0.6395584",
"0.6391873",... | 0.0 | -1 |
Abstract Invoked when whole batch of tests ends | def end_run(run_status)
# Abstract
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testing_end\n end",
"def end_test(test_status)\n # Abstract\n end",
"def end_test(test_status)\n # Abstract\n end",
"def after_test(_test); end",
"def after_test(_test); end",
"def after_test(_test); end",
"def batch_finished\n end",
"def done\n puts '... | [
"0.77203494",
"0.74123335",
"0.74123335",
"0.7402124",
"0.7402124",
"0.7402124",
"0.72058165",
"0.7073947",
"0.70392084",
"0.70234823",
"0.69800544",
"0.6884681",
"0.68260604",
"0.68111736",
"0.67228776",
"0.6640883",
"0.66164255",
"0.66055936",
"0.6594827",
"0.65786266",
"0.... | 0.6485218 | 42 |
Abstract Invoked when a single test is started | def start_test(test_status, test_metadata)
# Abstract
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_test(test_status)\n # Abstract\n end",
"def test_setup\r\n \r\n end",
"def running_test_case; end",
"def running_test_step; end",
"def begin_lights_test\n puts 'Invoker: start test'\n @on_start.execute if @on_start.is_a? Command\n\n puts 'Invoker: ...loading las... | [
"0.7968036",
"0.7566972",
"0.74446654",
"0.7241516",
"0.7220218",
"0.7218993",
"0.7218993",
"0.71957314",
"0.71957314",
"0.71708286",
"0.71708286",
"0.7111567",
"0.705856",
"0.6937283",
"0.68861485",
"0.68625987",
"0.6861229",
"0.6852014",
"0.6852014",
"0.68318546",
"0.681504... | 0.76185226 | 1 |
Abstract Invoked when a single test is finished | def end_test(test_status)
# Abstract
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testing_end\n end",
"def after_test(_test); end",
"def after_test(_test); end",
"def after_test(_test); end",
"def done\n puts 'Done running tests'\n end",
"def teardown\n\t\tputs \"Completed unit test execution\"\n\tend",
"def after_finished\n end",
"def finish()\n #This is ... | [
"0.7962815",
"0.7819478",
"0.7819478",
"0.7819478",
"0.75422674",
"0.73557276",
"0.7245735",
"0.719548",
"0.71774197",
"0.71605736",
"0.7155796",
"0.7155796",
"0.7155796",
"0.7155796",
"0.7155796",
"0.7155796",
"0.7155796",
"0.7155796",
"0.704473",
"0.7012503",
"0.69680226",
... | 0.7530713 | 6 |
to use a block, there are two additional bit that ruby need to support for block 1 block_given? 2 yield ... stops our method and and runs block of code passed | def called_with_block?
if block_given?
p "You called me with a block"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end"... | [
"0.8180861",
"0.8180861",
"0.8180861",
"0.8180861",
"0.8180861",
"0.8180861",
"0.8180861",
"0.8180861",
"0.8180861",
"0.8180861",
"0.8180861",
"0.8180861",
"0.8180861",
"0.8180861",
"0.8180861",
"0.8180861",
"0.8180861",
"0.8180861",
"0.8180861",
"0.8180861",
"0.8110118",
"... | 0.0 | -1 |
we can pass pass data to block using yield our version of each | def each_in_list(list)
for i in 0..(list.length - 1)
yield list[i]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feed_each(data, &block)\n end",
"def each &block\n @data.each &block\n end",
"def each(&block)\n @data.each(&block)\n end",
"def each(&blk)\n data.each(&blk)\n end",
"def each(&block)\n self.data.each(&block)\n end",
"def each &block\n @data.each &block\n ... | [
"0.8161349",
"0.8096761",
"0.80914736",
"0.80085903",
"0.8004402",
"0.7966251",
"0.7947691",
"0.7918746",
"0.78044",
"0.77272123",
"0.7619077",
"0.7589166",
"0.75881994",
"0.7548609",
"0.7520659",
"0.75036633",
"0.7502962",
"0.74911416",
"0.7488918",
"0.7477532",
"0.7477532",... | 0.0 | -1 |
using yield to return a value from a block | def map_words(input)
results = []
input.split.each do |word|
results << yield(word)
end
results
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_block_value\r\n if block_given?\r\n value = yield\r\n pp \"The block returned #{value}\"\r\n end\r\nend",
"def return(&block); end",
"def do_something\n value = yield('Hello world') if block_given?\n puts \"The block returned #{value}\"\nend",
"def returning(value)\n yield(value)\n ... | [
"0.7992489",
"0.78341293",
"0.77304065",
"0.7671132",
"0.76454616",
"0.7567461",
"0.75410604",
"0.74981266",
"0.74981266",
"0.74380744",
"0.73910165",
"0.7345365",
"0.7314998",
"0.7304299",
"0.7304299",
"0.7304299",
"0.7304299",
"0.72700906",
"0.725804",
"0.72552013",
"0.7255... | 0.0 | -1 |
Called as stabby lamdas switching to block again, we can assign block to a parameter using special syntax. We can specify an optional final parameter to hold the block prefixed by ampersand | def modify_prices(prices, &block)
p block.inspect
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def block=(_arg0); end",
"def block=(_arg0); end",
"def set_block &b\n @block = b\n end",
"def foo(&block)\n a = 2\n block.call(a)\nend",
"def block_node=(_); end",
"def remember(&a_block)\r\n @block = a_block\r\nend",
"def foo(name, &block)\n @name = name\n block.call\nend... | [
"0.77472895",
"0.77472895",
"0.7455451",
"0.7233907",
"0.723242",
"0.71880937",
"0.68847764",
"0.68172693",
"0.67245847",
"0.6721035",
"0.67081654",
"0.66449654",
"0.6635449",
"0.6625725",
"0.6605358",
"0.6579073",
"0.6579073",
"0.6579073",
"0.6579073",
"0.6579073",
"0.657907... | 0.6050906 | 94 |
pass block of code or use Proc as seen in most of the metaprogrmming.. | def modify_prices(prices, &block)
prices.each do |p|
block[p] if block_given?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_block_3\n p = Proc.new # if new proc is not passed a code block, it looks to see if the current scope has been passed a code block and use that\n p.call # if current scope has not been passed a code block, there will be an error\nend",
"def run_block\n p = Proc.new\n p.call... | [
"0.7720571",
"0.75377864",
"0.74258494",
"0.7398269",
"0.7398269",
"0.7398269",
"0.7398269",
"0.7398269",
"0.7398269",
"0.7398269",
"0.7398269",
"0.7398269",
"0.7398269",
"0.7398269",
"0.7398269",
"0.7398269",
"0.7398269",
"0.7398269",
"0.7398269",
"0.7398269",
"0.7398269",
... | 0.0 | -1 |
Convert this object to an Agent. For Checkpointsupplied Agents, this is an identity operation, but it allows consistent handling of the builtin types and applicationsupplied types that will either implement this interface or convert themselves to a builtin type. This removes the requirement to extend Checkpoint types or bind to a specific conversion method. | def to_agent
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_agent_tuple\n Tuple[:agent].new(agent_type: agent_type, uuid: uuid)\n end",
"def coerce(object)\n self.class.coerce(object)\n end",
"def coerce(object)\n self.class.coerce(object)\n end",
"def convert\n self.class.convert(object)\n end",
"def coerc... | [
"0.60046655",
"0.5536329",
"0.55353683",
"0.54204965",
"0.5391419",
"0.5383643",
"0.5311593",
"0.5301959",
"0.52916276",
"0.5214576",
"0.514344",
"0.5069456",
"0.50564843",
"0.50355834",
"0.50274915",
"0.4975721",
"0.4973651",
"0.4957715",
"0.49461257",
"0.49162304",
"0.48552... | 0.581481 | 1 |
Get the wrapped actor's type. If the actor implements `agent_type`, we will return that. Otherwise, we use the actors's class name. | def type
if actor.respond_to?(:agent_type)
actor.agent_type
else
actor.class
end.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_type(env, type, receiver)\n case type\n when :index_type\n receiver.index_type(env)\n when :element_type\n receiver.element_type(env)\n when :receiver_type\n receiver.pione_type(env)\n else\n type\n end\n end",
"def type\n... | [
"0.6202704",
"0.5930499",
"0.5864608",
"0.5833658",
"0.5821107",
"0.5819627",
"0.5818607",
"0.5818607",
"0.58079803",
"0.5772161",
"0.5726402",
"0.57082295",
"0.5706997",
"0.56911093",
"0.5679871",
"0.56624985",
"0.5649103",
"0.5649103",
"0.5649103",
"0.5585056",
"0.55701196"... | 0.8446102 | 0 |
Check whether two Agents refer to the same concrete actor. | def eql?(other)
other.is_a?(Agent) && actor.eql?(other.actor)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(other)\n other.is_a?(Agent) && type == other.type && id == other.id\n end",
"def linked_to?(actor)\n Thread.current[:actor].links.include? actor\n end",
"def actor?\r\n return false\r\n end",
"def look_same_as?(other)\n return nil unless other.kind_of?(self.class)\n ... | [
"0.6278713",
"0.619616",
"0.6174688",
"0.6112218",
"0.61115396",
"0.60836273",
"0.6047211",
"0.6047211",
"0.60236424",
"0.5974829",
"0.5930189",
"0.5917547",
"0.5905566",
"0.5875404",
"0.58613443",
"0.5861254",
"0.5840898",
"0.5840898",
"0.58294636",
"0.58269083",
"0.58220667... | 0.7472399 | 0 |
Check whether two Agents refer to the same concrete actor by type and id. | def ==(other)
other.is_a?(Agent) && type == other.type && id == other.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eql?(other)\n other.is_a?(Agent) && actor.eql?(other.actor)\n end",
"def eql?(other)\n self.class == other.class && self.id == other.id\n end",
"def ==(other)\n self.class == other.class && id == other.id\n end",
"def ==(other)\n self.id == other.id && self.class == other.cla... | [
"0.69051707",
"0.60379946",
"0.60222465",
"0.60088724",
"0.58996063",
"0.58996063",
"0.58942366",
"0.5865945",
"0.5865945",
"0.5865945",
"0.5862867",
"0.5842338",
"0.5747345",
"0.5744862",
"0.5717884",
"0.5685177",
"0.56765276",
"0.5670254",
"0.5651778",
"0.56490237",
"0.5643... | 0.68022585 | 1 |
GET /status_items GET /status_items.json | def index
@search_status_items = policy_scope(StatusItem).ransack(params[:q])
@status_items = @search_status_items.result.paginate(page: params[:page], per_page: 20)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status\n response = JSON.parse(@client.get(\"items/#{send(:id)}/status\").body)\n response['items']\n end",
"def status\n response = JSON.parse(@client.get(\"items/#{send(:id)}/status\").body)\n response['items']\n end",
"def status\n response = JSON.parse(@client.get(\"items... | [
"0.82049584",
"0.82049584",
"0.82049584",
"0.7148908",
"0.6766604",
"0.6742756",
"0.667233",
"0.66605115",
"0.6629315",
"0.6569975",
"0.6523782",
"0.6522255",
"0.6472431",
"0.64691335",
"0.64624625",
"0.63979334",
"0.6390386",
"0.634674",
"0.634674",
"0.634674",
"0.634674",
... | 0.63399684 | 21 |
GET /status_items/1 GET /status_items/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status\n response = JSON.parse(@client.get(\"items/#{send(:id)}/status\").body)\n response['items']\n end",
"def status\n response = JSON.parse(@client.get(\"items/#{send(:id)}/status\").body)\n response['items']\n end",
"def status\n response = JSON.parse(@client.get(\"items... | [
"0.78736347",
"0.78736347",
"0.78736347",
"0.746309",
"0.68788105",
"0.6713889",
"0.66903204",
"0.65787816",
"0.6533995",
"0.65177274",
"0.6514236",
"0.650695",
"0.65025604",
"0.64566934",
"0.64464825",
"0.6436558",
"0.6435421",
"0.6426243",
"0.6415056",
"0.6396658",
"0.63934... | 0.0 | -1 |
POST /status_items POST /status_items.json | def create
@status_item = StatusItem.new(status_item_params)
respond_to do |format|
if @status_item.save
format.html { redirect_to status_items_path, notice: 'El estatus del artículo fue creado correctamente.' }
format.json { render :show, status: :created, location: @status_item }
else
format.html { render :new }
format.json { render json: @status_item.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @itemstatus = Itemstatus.new(params[:itemstatus])\n\n respond_to do |format|\n if @itemstatus.save\n format.html { redirect_to @itemstatus, notice: 'Itemstatus was successfully created.' }\n format.json { render json: @itemstatus, status: :created, location: @itemstatus }\n ... | [
"0.7076711",
"0.6967802",
"0.6790715",
"0.6577659",
"0.6509211",
"0.6380083",
"0.6379919",
"0.63392854",
"0.6317945",
"0.6313543",
"0.62310207",
"0.62304074",
"0.614993",
"0.61203545",
"0.6107005",
"0.60871875",
"0.60833555",
"0.6061557",
"0.6059936",
"0.6059896",
"0.6055732"... | 0.7090766 | 0 |
PATCH/PUT /status_items/1 PATCH/PUT /status_items/1.json | def update
respond_to do |format|
if @status_item.update(status_item_params)
format.html { redirect_to status_item_path, notice: 'El estatus del artículo fue actualizado' }
format.json { render :show, status: :ok, location: @status_item }
else
format.html { render :edit }
format.json { render json: @status_item.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @itemstatus = Itemstatus.find(params[:id])\n\n respond_to do |format|\n if @itemstatus.update_attributes(params[:itemstatus])\n format.html { redirect_to @itemstatus, notice: 'Itemstatus was successfully updated.' }\n format.json { head :ok }\n else\n format.html {... | [
"0.7111423",
"0.6999463",
"0.68491036",
"0.681192",
"0.6785213",
"0.67474246",
"0.6579958",
"0.65617806",
"0.65611833",
"0.6501318",
"0.648072",
"0.6470073",
"0.6460353",
"0.6458689",
"0.645246",
"0.6450342",
"0.6436367",
"0.6430249",
"0.64288926",
"0.64249027",
"0.64173406",... | 0.67625105 | 5 |
DELETE /status_items/1 DELETE /status_items/1.json | def destroy
@status_item.destroy
respond_to do |format|
format.html { redirect_to status_items_url, notice: 'El estatus del articulo fue eliminado.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @itemstatus = Itemstatus.find(params[:id])\n @itemstatus.destroy\n\n respond_to do |format|\n format.html { redirect_to itemstatuses_url }\n format.json { head :ok }\n end\n end",
"def delete_item(item_id)\n response = Unirest.delete CONNECT_HOST + '/v1/' + LOCATION_ID + '/i... | [
"0.7661168",
"0.736224",
"0.72245306",
"0.7192955",
"0.7187989",
"0.7105858",
"0.7045946",
"0.7040649",
"0.700396",
"0.69929534",
"0.696036",
"0.6953687",
"0.69291955",
"0.69160455",
"0.6889761",
"0.68853897",
"0.6869821",
"0.6860778",
"0.6860509",
"0.6860509",
"0.6860509",
... | 0.7329811 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_status_item
@status_item = StatusItem.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def status_item_params
params.require(:status_item).permit(:name, :description, :key, :status)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6980244",
"0.6782812",
"0.6745103",
"0.6741142",
"0.6733961",
"0.65925",
"0.6503602",
"0.64967257",
"0.64822173",
"0.64796996",
"0.6456357",
"0.6439594",
"0.63803256",
"0.6376499",
"0.63644457",
"0.6319286",
"0.6299465",
"0.6298051",
"0.62935406",
"0.62923044",
"0.6291212"... | 0.0 | -1 |
MOCK EMAIL USER IF THEY ARE MENTIONED IN A POST after_create :notified_users def notified_users mentioned_users.each do |user| Mail.new(user) end end | def mentions
@mentions ||= begin
regex = /@([\w]+)/
body.scan(regex).flatten
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_notifications\n notifications = []\n User.find_each do |u|\n notifications << Notification.new(recipient: u,\n notifiable_id: @lecture.id,\n notifiable_type: 'Lecture',\n actio... | [
"0.65356946",
"0.6446861",
"0.63779384",
"0.63359576",
"0.62917817",
"0.6275109",
"0.62714034",
"0.6233564",
"0.6216317",
"0.6205028",
"0.6205028",
"0.6201881",
"0.6199155",
"0.6195134",
"0.6176046",
"0.61629355",
"0.61545295",
"0.61309904",
"0.6088717",
"0.60796493",
"0.6069... | 0.0 | -1 |
Initialize a Request to the given +path+. Query parameters and data can be passed in as hashes named :params and :body, respectively. If :sign is passed in the +options+ then the URL of this request will be signed with the Chimps user's Infochimps API key and secret. Signing a request which doesn't need to be signed is just fine. Forgetting to sign a request which needs to be signed will result in a 401 error from Infochimps. If :sign_if_possible is passed in the +options+ then an attemp to sign the URL will be made though an error will _not_ raise an error. | def initialize path, options={}
self.path = path
self.query_params = options[:query_params] || options[:query] || options[:params] || {}
self.body = options[:body] || options[:data] || {}
@authentication_required = [:authenticate, :authenticated, :authenticate_if_possible, :sign, :signed, :sign_if_possible].any? { |key| options[key] }
@forgive_authentication_error = options[:sign_if_possible] || options[:authenticate_if_possible]
@raw = options[:raw]
authenticate_if_necessary!
super(url_with_query_string, {:headers => DEFAULT_HEADERS.merge(options[:headers] || {})})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_signed_request(http_method, path, token = nil, request_options = {}, *arguments)\n request = create_http_request(http_method, path, *arguments)\n sign!(request, token, request_options)\n request\n end",
"def sign_request(options)\n options.merge!(:pub => @api_key)\n options... | [
"0.653346",
"0.65019524",
"0.6493432",
"0.61565745",
"0.60329413",
"0.5894599",
"0.5880735",
"0.5875828",
"0.58722955",
"0.5842007",
"0.58075935",
"0.5803782",
"0.57883525",
"0.5783074",
"0.57593566",
"0.5755239",
"0.57429063",
"0.5736373",
"0.572927",
"0.56733143",
"0.565333... | 0.72903144 | 0 |
Return the URL for this request with the (signed, if necessary) query string appended. | def url_with_query_string
if query_string && query_string.size > 0
base_url + "?#{query_string}"
else
base_url
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url\n raise InvalidQueryError unless query && page\n\n \"http://#{ENDPOINT}#{REQUEST_URI}\" + # base\n \"?#{canonical_query_string}\" + # query\n \"&Signature=#{uri_escape(signature)}\" # signature\n end",
"def request_uri\n return nil if absolute? && scheme !~ /^htt... | [
"0.77718955",
"0.73483515",
"0.72521603",
"0.7178929",
"0.71000034",
"0.70972306",
"0.6977908",
"0.6959429",
"0.6913432",
"0.68558955",
"0.6817175",
"0.6802651",
"0.6793703",
"0.6747851",
"0.6698859",
"0.6692154",
"0.6685215",
"0.66458684",
"0.6623754",
"0.6619378",
"0.661321... | 0.72838056 | 2 |
Should the request be authenticated? | def authenticate?
@authentication_required
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_authenticated?\n end",
"def require_auth\n (authorized? && authenticated?) || halt(401)\n end",
"def authenticated?\n true\n end",
"def authenticated?\n false\n end",
"def authenticate\n self.get && true\n end",
"def must_authenticate \n if @authenticated_user && (@u... | [
"0.80283415",
"0.7872298",
"0.7730487",
"0.7713752",
"0.7633757",
"0.76003015",
"0.7585424",
"0.7535467",
"0.75333947",
"0.7525391",
"0.75082815",
"0.7495014",
"0.7478932",
"0.7442755",
"0.74369526",
"0.7434772",
"0.7422276",
"0.7405641",
"0.7403049",
"0.7396053",
"0.73824704... | 0.70858186 | 90 |
Should the query string and request body be encoded? Control this by passing in the :raw keyword when initializing this Request. | def should_encode?
!@raw
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encoded_body\n @encoded_body ||= should_encode? ? encode(body) : body.to_s\n end",
"def encoded_body\n Ethon::Easy::Form.new(nil, options[:body]).to_s\n end",
"def encode_body\n '' # No body by default\n end",
"def set_request_body!(request); end",
"def raw_post_request raw_para... | [
"0.65571624",
"0.6310326",
"0.62735116",
"0.6099656",
"0.5910468",
"0.58929414",
"0.5865099",
"0.57985365",
"0.5762418",
"0.5755017",
"0.5730337",
"0.5728852",
"0.57251996",
"0.5693878",
"0.5661189",
"0.5651287",
"0.56504196",
"0.56493956",
"0.56386286",
"0.5633151",
"0.56297... | 0.6243838 | 3 |
Should this be considered a raw request in which neither the query string nor the body should be encoded or escaped? | def raw?
!!@raw
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def raw_post_request raw_params\n json_body = raw_params.to_json\n Rubix.logger.log(Logger::DEBUG, \"SEND: #{json_body}\") if Rubix.logger\n Net::HTTP::Post.new(uri.path).tap do |req|\n req['Content-Type'] = 'application/json-rpc'\n req.body = json_body\n end\n end",... | [
"0.67443466",
"0.604377",
"0.601197",
"0.5984443",
"0.59794855",
"0.59557545",
"0.59343",
"0.59211326",
"0.5921046",
"0.5898076",
"0.58715606",
"0.58383006",
"0.58010554",
"0.5795799",
"0.5782865",
"0.5778323",
"0.5771045",
"0.57686967",
"0.5768502",
"0.5761933",
"0.5761397",... | 0.0 | -1 |
Is this request authentiable (has the Chimps user specified an API key and secret in their configuration file)? | def authenticable?
Chimps.config[:catalog][:key] && Chimps.config[:catalog][:secret]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorized?\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n user = ENV[\"HTTP_USER\"]\n pass = ENV[\"HTTP_PASS\"]\n @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == [user, pass]\n end",
"def is_api?\n current_user\n @env[... | [
"0.7596266",
"0.7474536",
"0.7470657",
"0.74478054",
"0.7328421",
"0.7328171",
"0.7318912",
"0.7206807",
"0.71550936",
"0.7136516",
"0.71241236",
"0.7114857",
"0.7108842",
"0.70885",
"0.7087299",
"0.70353764",
"0.70140904",
"0.6983217",
"0.69782245",
"0.6945779",
"0.691844",
... | 0.766663 | 0 |
The host to send requests to. | def host
@host ||= Chimps.config[:catalog][:host]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def host\n request.host\n end",
"def host\n @request['Host']\n end",
"def get_host\n @host\n end",
"def host\n @host\n end",
"def host\n @connection.host\n end",
"def host\n self.host\n end",
"def host\n @host\n end",
"def host\n @host\n end... | [
"0.83975214",
"0.8296139",
"0.8161584",
"0.8120623",
"0.8041911",
"0.79586",
"0.7872457",
"0.7872457",
"0.7869039",
"0.7869039",
"0.7808956",
"0.7744918",
"0.7734998",
"0.771637",
"0.7600049",
"0.75965774",
"0.7552609",
"0.75462687",
"0.7545964",
"0.7509401",
"0.7507167",
"... | 0.68009055 | 82 |
Return the base URL for this request, consisting of the host and path but not the query string. | def base_url
File.join(host, path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _base_url\n r = @_request\n scheme = r.scheme\n port = r.port\n \"#{scheme}://#{r.host}#{\":#{port}\" unless DEFAULT_PORTS[scheme] == port}\"\n end",
"def base_url\n \"#{scheme}://#{host}\"\n end",
"def base_url\n @url.to_s.split('?').first\n end",... | [
"0.8310888",
"0.7860204",
"0.76309687",
"0.75991106",
"0.75331295",
"0.74928284",
"0.7434145",
"0.74234027",
"0.7420423",
"0.7416231",
"0.7405444",
"0.73347676",
"0.73062885",
"0.7292525",
"0.7249815",
"0.7230284",
"0.7196472",
"0.71867585",
"0.71699077",
"0.7163374",
"0.7159... | 0.78547937 | 2 |
Return the query string for this request, signed if necessary. | def query_string
(authenticate? && authenticable?) ? signed_query_string : unsigned_query_string
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signed_query_string\n return unsigned_query_string unless should_encode?\n text_to_sign = ((body == true || (! body.empty?)) ? encoded_body : unsigned_query_string_stripped)\n signature = sign(text_to_sign)\n \"#{unsigned_query_string}&signature=#{signature}\"\n end",
"def query_str... | [
"0.81911975",
"0.7309382",
"0.71586907",
"0.7089198",
"0.70831865",
"0.7030179",
"0.6985509",
"0.6974242",
"0.6913987",
"0.6801886",
"0.67557293",
"0.668645",
"0.66425",
"0.6548912",
"0.6497722",
"0.64938384",
"0.64513546",
"0.64052355",
"0.63868356",
"0.63859785",
"0.6352318... | 0.84073687 | 0 |
Perform a GET request to this URL, returning a parsed response. Any headers in +options+ will passed to RestClient::Resource.get. | def get options={}, &block
handle_exceptions do
Chimps.log.info("GET #{url}")
Response.new(super(options, &block))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(path, options={})\n url = build_url path, options\n headers = options[:headers] || {}\n Response.new(@client[url].get headers)\n rescue RestClient::Exception => e\n Response.new e.response\n end",
"def get(options={}, &block)\n response = http.get_uri(options, &block)\n ... | [
"0.80321944",
"0.79979354",
"0.7717585",
"0.7701206",
"0.76681894",
"0.7638973",
"0.7634085",
"0.7629559",
"0.76142776",
"0.76011413",
"0.75465554",
"0.75065756",
"0.74853873",
"0.7466928",
"0.7466928",
"0.74579155",
"0.7412766",
"0.7409269",
"0.73828703",
"0.73494756",
"0.73... | 0.7313103 | 23 |
Perform a POST request to this URL, returning a parsed response. Any headers in +options+ will passed to RestClient::Resource.post. | def post options={}, &block
handle_exceptions do
Chimps.log.info("POST #{url}")
Response.new(super(encoded_body, options, &block))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(options = {})\n url = build_url(options)\n ret = post_response(url, options)\n ret\n end",
"def post\n RestClient.post(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def post(path, options={})\n response = request(path, ... | [
"0.81367993",
"0.7703004",
"0.7594577",
"0.75563943",
"0.7543971",
"0.7358132",
"0.7341438",
"0.7341438",
"0.73212653",
"0.7286806",
"0.7128208",
"0.70905817",
"0.707518",
"0.70192164",
"0.6974585",
"0.695954",
"0.695951",
"0.695951",
"0.695951",
"0.6939714",
"0.68627715",
... | 0.706406 | 13 |
Perform a PUT request to this URL, returning a parsed response. Any headers in +options+ will passed to RestClient::Resource.put. | def put options={}, &block
handle_exceptions do
Chimps.log.info("PUT #{url}")
Response.new(super(encoded_body, options, &block))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(path, options={})\n response = request(path, :put, options)\n validate response\n responsed_response = parse response\n data = { headers: response.headers, body: parsed_response }\n end",
"def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req... | [
"0.7908723",
"0.7831401",
"0.7808376",
"0.7772424",
"0.77042013",
"0.7659873",
"0.7659873",
"0.7629992",
"0.76133776",
"0.7446056",
"0.7356261",
"0.73012775",
"0.7281053",
"0.7267145",
"0.72615975",
"0.7250715",
"0.7250715",
"0.7191393",
"0.71705663",
"0.71705663",
"0.7147004... | 0.777566 | 3 |
Perform a DELETE request to this URL, returning a parsed response. Any headers in +options+ will passed to RestClient::Resource.delete. | def delete options={}, &block
handle_exceptions do
Chimps.log.info("DELETE #{url}")
Response.new(super(options, &block))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(path, options={})\n url = build_url path, options\n headers = options[:headers] || {}\n # nothing returned in response body for DELETE\n Response.new(@client[url].delete headers)\n rescue RestClient::Exception => e\n Response.new e.response\n end",
"def delete(uri, optio... | [
"0.8193757",
"0.8022737",
"0.8020758",
"0.8020758",
"0.79801905",
"0.79677653",
"0.7940213",
"0.7940213",
"0.7935626",
"0.78184867",
"0.78184867",
"0.7796679",
"0.77468234",
"0.76760465",
"0.76491016",
"0.7585825",
"0.7444331",
"0.7441583",
"0.73821133",
"0.7355532",
"0.73518... | 0.7775914 | 12 |
Yield to +block+ but rescue any RestClient errors by wrapping them in a Chimps::Response. | def handle_exceptions &block
begin
yield
rescue RestClient::Exception => e
Response.new(e.response, :error => e.message)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connection_wrapper(&block)\n begin\n response = block.call\n raise ClientError.new(response.body['error']) if response.body.has_key?('error')\n rescue Faraday::ParsingError => e\n # Has gotten a response, but it is not formatted with JSON\n raise ClientError.ne... | [
"0.69025636",
"0.6865501",
"0.67730224",
"0.67175525",
"0.66577274",
"0.66132957",
"0.6236305",
"0.60615474",
"0.6029391",
"0.6004882",
"0.5995989",
"0.5981048",
"0.59677577",
"0.5950428",
"0.593921",
"0.58847743",
"0.58442247",
"0.5839413",
"0.5819495",
"0.5809625",
"0.57966... | 0.81975645 | 0 |
Authenticate this request by stuffing the :requested_at and :apikey properties into its :query_params hash. Will do nothing at all if Chimps::Requestauthenticate? returns false. | def authenticate_if_necessary!
return unless authenticate? && should_encode?
raise Chimps::AuthenticationError.new("Catalog API key (Chimps.config[:catalog][:key]) or secret (Chimps.config[:catalog][:secret]) missing from #{Chimps.config[:config]} or #{Chimps.config[:site_config]}") unless (authenticable? || @forgive_authentication_error)
query_params[:requested_at] = Time.now.to_i.to_s
query_params[:apikey] = Chimps.config[:catalog][:key]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authentication_params\n {\n api_user: @api_user,\n api_key: @api_key\n }\n end",
"def authenticate\n @apikey = request.headers[:apikey]\n if @apikey==nil || @apikey!= APIKEY\n json_response={\n error: 'autorization error'\n }\n respond_with json_respons... | [
"0.6823241",
"0.63878036",
"0.62639666",
"0.62484515",
"0.6218319",
"0.61805844",
"0.6107713",
"0.60886645",
"0.60828257",
"0.6077564",
"0.6052029",
"0.6019611",
"0.5995799",
"0.5987131",
"0.5971032",
"0.5960542",
"0.59595156",
"0.59417945",
"0.59356475",
"0.58949196",
"0.588... | 0.7565355 | 0 |
Return an unsigned query string for this request. | def unsigned_query_string
(should_encode? ? RestClient::Payload.generate(query_params) : query_params).to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signed_query_string\n return unsigned_query_string unless should_encode?\n text_to_sign = ((body == true || (! body.empty?)) ? encoded_body : unsigned_query_string_stripped)\n signature = sign(text_to_sign)\n \"#{unsigned_query_string}&signature=#{signature}\"\n end",
"def query_str... | [
"0.81510824",
"0.80960196",
"0.7556436",
"0.7383905",
"0.73345923",
"0.73245275",
"0.7321481",
"0.72447497",
"0.7243798",
"0.7239879",
"0.7044277",
"0.7022589",
"0.68629926",
"0.6771279",
"0.67322356",
"0.67297184",
"0.6662549",
"0.6599266",
"0.6569166",
"0.65331626",
"0.6528... | 0.85439575 | 0 |
Return an unsigned query string for this request without the & and = characters. This is the text that will be signed for GET and DELETE requests. | def unsigned_query_string_stripped
@query_params_text ||= obj_to_stripped_string(query_params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signed_query_string\n return unsigned_query_string unless should_encode?\n text_to_sign = ((body == true || (! body.empty?)) ? encoded_body : unsigned_query_string_stripped)\n signature = sign(text_to_sign)\n \"#{unsigned_query_string}&signature=#{signature}\"\n end",
"def unsigned_... | [
"0.8173759",
"0.81529176",
"0.78520703",
"0.726955",
"0.71774274",
"0.7172952",
"0.71548766",
"0.7145758",
"0.71076447",
"0.705612",
"0.7040277",
"0.7017664",
"0.69764185",
"0.6736644",
"0.67299116",
"0.6727337",
"0.6725882",
"0.66254884",
"0.6605107",
"0.6565718",
"0.6561532... | 0.7547315 | 3 |
Return this Requests's body as a suitably encoded string. This is the text that will be signed for POST and PUT requests. | def encoded_body
@encoded_body ||= should_encode? ? encode(body) : body.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode_body\n '' # No body by default\n end",
"def to_s\n body.to_s\n end",
"def to_s\n @body.to_s\n end",
"def encoded_body\n Ethon::Easy::Form.new(nil, options[:body]).to_s\n end",
"def body\n Base64::decode64(self[:body])\n end",
"def to_s\n @body\n ... | [
"0.7234783",
"0.72003925",
"0.71803796",
"0.7137235",
"0.710202",
"0.7010645",
"0.6939093",
"0.69350433",
"0.6902838",
"0.68647575",
"0.6848038",
"0.6848038",
"0.6843149",
"0.6768113",
"0.6661691",
"0.6525185",
"0.651794",
"0.6491227",
"0.6490104",
"0.6479487",
"0.6437969",
... | 0.74408376 | 0 |
Sign +string+ by concatenting it with the secret and computing the MD5 digest of the whole thing. | def sign string
raise Chimps::AuthenticationError.new("No Catalog API secret stored in #{Chimps.config[:config]} or #{Chimps.config[:site_config]}. Set Chimps.config[:catalog][:secret].") unless (authenticable? || @forgive_authentication_error)
require 'digest/md5'
Digest::MD5.hexdigest(string + Chimps.config[:catalog][:secret])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign secret, string_to_sign, digest_method = 'sha256'\n Base64.encode64(hmac(secret, string_to_sign, digest_method)).strip\n end",
"def sign(str, secret)\n OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new(\"sha256\"), secret, str)\n end",
"def sign(string, secret_access_key)\n hmac = HMAC::SHA256.n... | [
"0.7514343",
"0.73603946",
"0.7248535",
"0.7011148",
"0.68964064",
"0.68892956",
"0.6713473",
"0.6664131",
"0.66400194",
"0.6619523",
"0.6592884",
"0.65647775",
"0.6559052",
"0.6507309",
"0.65045184",
"0.64932686",
"0.64834845",
"0.64834845",
"0.64834845",
"0.6448245",
"0.642... | 0.75780386 | 0 |
Append the signature to the unsigned query string. The signature made from the Chimps user's API secret and either the query string text (stripped of & and =) for GET and DELETE requests or the request body for POST and PUT requests. | def signed_query_string
return unsigned_query_string unless should_encode?
text_to_sign = ((body == true || (! body.empty?)) ? encoded_body : unsigned_query_string_stripped)
signature = sign(text_to_sign)
"#{unsigned_query_string}&signature=#{signature}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query\n \"#{unsigned_query}&Signature=#{escape signature}\"\n end",
"def query_string_sig2\n @query_elements['Timestamp']= Time::at(Time.now).utc.strftime(\"%Y-%m-%dT%H:%M:%S.000Z\") unless @query_elements['Timestamp']\n @query_elements['AWSAccessKeyId']= @credentials.accessID\n signat... | [
"0.7555797",
"0.7259777",
"0.694431",
"0.68520194",
"0.6619296",
"0.6591438",
"0.6572113",
"0.6447108",
"0.642026",
"0.6401396",
"0.64008987",
"0.6344959",
"0.6306241",
"0.62560236",
"0.62452555",
"0.61526835",
"0.60310364",
"0.60293055",
"0.60162127",
"0.6015645",
"0.6002721... | 0.7776267 | 0 |
Turn +obj+ into a string, sorting on internal keys. | def obj_to_stripped_string obj
case obj
when Hash then obj.keys.map(&:to_s).sort.map { |key| [key.to_s.downcase, obj_to_stripped_string(obj[key.to_sym])].join('') }.join('')
when Array then obj.map { |e| obj_to_stripped_string(e) }.join('')
else obj.to_s
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deeply_stringify_keys(obj)\n deep_key_stringifier.call( obj )\n end",
"def sort(objects)\n objects.sort_by {|x| x.to_s }\nend",
"def sort(objects)\n objects.sort_by {|x| x.to_s }\nend",
"def sort(objs)\n Array(objs).flatten.compact.uniq.collect(&:to_s).sort.collect(&:to_sym)\n e... | [
"0.66216093",
"0.63593423",
"0.63593423",
"0.614132",
"0.614132",
"0.6131521",
"0.61253756",
"0.6042234",
"0.60222006",
"0.5971086",
"0.5918515",
"0.5826218",
"0.576676",
"0.57336354",
"0.5696487",
"0.5629524",
"0.5621039",
"0.5593682",
"0.5573392",
"0.5500554",
"0.5494876",
... | 0.72341084 | 0 |
Lists items for a user on a marketplace. | def items
response = JSON.parse(@client.get("users/#{send(:id)}/items").body)
users = response.key?('items') ? response['items'] : []
users.map { |attributes| Promisepay::Item.new(@client, attributes) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_user_items\n\t\t# gather user items of current user\n \t@user_items = UserItem.paginate :per_page => 8, :page => params[:page], :conditions => { :user_id => current_user.id }, :order => 'created_at DESC'\n\t\t# gather sold items of current user\n @sold = Transaction.find_all_by_seller_id(current_user.... | [
"0.6940427",
"0.6924999",
"0.69220686",
"0.6878154",
"0.68529534",
"0.6725131",
"0.66228306",
"0.65787756",
"0.6538865",
"0.6520194",
"0.6481196",
"0.64705455",
"0.6375573",
"0.6374197",
"0.636045",
"0.6332505",
"0.62898177",
"0.62776726",
"0.6214252",
"0.62044483",
"0.61438"... | 0.5837946 | 37 |
Gets Bank account for a user on a marketplace. | def bank_account
response = JSON.parse(@client.get("users/#{send(:id)}/bank_accounts").body)
Promisepay::BankAccount.new(@client, response['bank_accounts'])
rescue Promisepay::UnprocessableEntity
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_marketplace_bank_account\n Balanced::BankAccount.find(\"/v1/bank_accounts/BAj6sNNBdMp5WmY6PJ7sAu3\")\n end",
"def getaccount(bitcoinaddress)\n @api.request 'getaccount', bitcoinaddress\n end",
"def get_accounts_by_user\n return User.find(params[:user_id]).accounts\n end",
"def g... | [
"0.8199737",
"0.657737",
"0.65633076",
"0.63248754",
"0.6249686",
"0.62336624",
"0.6199189",
"0.6139345",
"0.6135745",
"0.61231655",
"0.6113223",
"0.6113223",
"0.60969424",
"0.60655916",
"0.6061479",
"0.6061479",
"0.6061479",
"0.6061479",
"0.6061479",
"0.6061479",
"0.6061479"... | 0.6740948 | 1 |
Gets Card account for a user on a marketplace. | def card_account
response = JSON.parse(@client.get("users/#{send(:id)}/card_accounts").body)
Promisepay::CardAccount.new(@client, response['card_accounts'])
rescue Promisepay::UnprocessableEntity
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_marketplace_bank_account\n Balanced::BankAccount.find(\"/v1/bank_accounts/BAj6sNNBdMp5WmY6PJ7sAu3\")\n end",
"def get_user\n\t\treturn Account.find(self.account_id)\n\tend",
"def get_accounts_by_user\n return User.find(params[:user_id]).accounts\n end",
"def account_user(id)\n ... | [
"0.68043673",
"0.6245407",
"0.6237358",
"0.6181206",
"0.60910505",
"0.5951668",
"0.59202546",
"0.5843615",
"0.5836375",
"0.5836375",
"0.5836375",
"0.5836375",
"0.5836375",
"0.5836375",
"0.5836375",
"0.5836375",
"0.5836375",
"0.5836375",
"0.5816879",
"0.58158845",
"0.58130103"... | 0.66752326 | 1 |
Gets PayPal account for a user on a marketplace. | def paypal_account
response = JSON.parse(@client.get("users/#{send(:id)}/paypal_accounts").body)
Promisepay::PaypalAccount.new(@client, response['paypal_accounts'])
rescue Promisepay::UnprocessableEntity
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_marketplace_bank_account\n Balanced::BankAccount.find(\"/v1/bank_accounts/BAj6sNNBdMp5WmY6PJ7sAu3\")\n end",
"def get_user\n\t\treturn Account.find(self.account_id)\n\tend",
"def account_user(id)\n get(\"accountuser/#{id}\")\n end",
"def get_accounts_by_user\n return User.fin... | [
"0.6559576",
"0.62649006",
"0.5890261",
"0.5820804",
"0.578312",
"0.5757738",
"0.57499474",
"0.5739473",
"0.5717036",
"0.5711432",
"0.56955105",
"0.56312907",
"0.55724806",
"0.5571626",
"0.5571626",
"0.5571626",
"0.5571626",
"0.5571626",
"0.5571626",
"0.5571626",
"0.5571626",... | 0.6512261 | 1 |
Set the disbursement account for a user. | def disbursement_account(account_id)
options = { account_id: account_id }
JSON.parse(@client.post("users/#{send(:id)}/disbursement_account", options).body)
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_disbursement\n @disbursement = Disbursement.find(params[:id])\n end",
"def deactivate_user(user_id)\n post(\"/users/#{user_id}/deactivate\")\n end",
"def decline\n @group_user = GroupUser.find(params[:id])\n @group_user.decline!\n respond_to do |format|\n flash[:notice] = ... | [
"0.59111536",
"0.57493204",
"0.57310206",
"0.5709309",
"0.56897146",
"0.56802595",
"0.56380326",
"0.56343347",
"0.5614693",
"0.5613141",
"0.5531685",
"0.5529655",
"0.55007774",
"0.5458006",
"0.541649",
"0.5336984",
"0.5332172",
"0.5321836",
"0.5302468",
"0.52743644",
"0.52709... | 0.68383384 | 0 |
Gets company for a user on a marketplace. | def company
response = JSON.parse(@client.get("users/#{send(:id)}/companies").body)
Promisepay::Company.new(@client, response['companies'])
rescue Promisepay::NotFound
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_company\n if Client.find_by_id(current_user.client_id)\n Client.find_by_id(current_user.client_id).client_name\n end\n end",
"def get_Company(name=nil)\n\n getElement_text(\"cust_vendors\").click\n\n getElement_text(\"Customers\").click\n\n if(name!=nil)\n getElement_te... | [
"0.6328475",
"0.6298967",
"0.62590176",
"0.62227803",
"0.62055665",
"0.61119354",
"0.59435564",
"0.59395504",
"0.5912225",
"0.5879924",
"0.587058",
"0.58427346",
"0.5839436",
"0.5821214",
"0.582079",
"0.5809776",
"0.58054775",
"0.57958835",
"0.5774805",
"0.5754094",
"0.573078... | 0.71915007 | 0 |
The username that the account was logged in with | def login
@user_login
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_username\n @user_name ||= self.user.username\n end",
"def user_username\n if self.user != nil\n self.user.username\n end\n end",
"def getUsername\n return @username\n end",
"def username\n credentials.first\n end",
"def username\n profi... | [
"0.8064074",
"0.7993244",
"0.79212147",
"0.79165995",
"0.7911915",
"0.7835728",
"0.78042585",
"0.7776564",
"0.7753775",
"0.7749319",
"0.77160853",
"0.7689129",
"0.7681146",
"0.76723593",
"0.7615741",
"0.75873023",
"0.7563363",
"0.75592303",
"0.75592303",
"0.7535352",
"0.75339... | 0.0 | -1 |
Prints out the names of all the courses | def print_courses
@learn_courses.each do |course|
puts course.name.foreground(:yellow)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_courses\n self.make_courses\n Course.all.each do |course|\n if course.title\n puts \"Title: #{course.title}\"\n puts \" Schedule: #{course.schedule}\"\n puts \" Description: #{course.description}\"\n end\n end\n end",
"def print_courses\n self.make_courses\... | [
"0.80604225",
"0.79784185",
"0.70298",
"0.70063627",
"0.6899865",
"0.6883695",
"0.6796061",
"0.6767988",
"0.66272336",
"0.660421",
"0.657742",
"0.65596133",
"0.65015584",
"0.6493519",
"0.64687747",
"0.6402675",
"0.6379134",
"0.63215613",
"0.6317507",
"0.6286192",
"0.62700796"... | 0.8560346 | 0 |
The array of the user's courses in string format | def courses
@learn_courses
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def course_array\n self.current_active_courses.all.map { |course| [course.name, course.id] }\n end",
"def to_s\n \"#{user} #{course}\"\n end",
"def section_courses\n all_sections = sections.to_a.concat(sections_as_student).uniq\n\n # In the future we may want to make it so that if assigned a ... | [
"0.7469018",
"0.68677133",
"0.6747556",
"0.6667052",
"0.6616441",
"0.65387565",
"0.6461755",
"0.6453934",
"0.6433973",
"0.6389421",
"0.6388939",
"0.6358793",
"0.63221115",
"0.63206017",
"0.6284959",
"0.62837964",
"0.62818223",
"0.62279016",
"0.62225354",
"0.6200999",
"0.61724... | 0.657847 | 5 |
Prints out every course's name and the grades registered with it | def print_grades
@learn_grades.each do |grade|
puts grade.which_course?.foreground(:yellow) + ": ".foreground(:yellow)
puts grade.summary
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_courses\n @learn_courses.each do |course|\n puts course.name.foreground(:yellow)\n end\n end",
"def print_courses\n self.make_courses\n Course.all.each do |course|\n if course.title\n puts \"Title: #{course.title}\"\n puts \" Schedule: #{course.schedule}\"\n ... | [
"0.77968794",
"0.7189545",
"0.70960855",
"0.70204574",
"0.6687492",
"0.6526269",
"0.65114313",
"0.64451385",
"0.63342446",
"0.6331015",
"0.6315916",
"0.62926626",
"0.62180704",
"0.6163137",
"0.61612844",
"0.61343116",
"0.6121018",
"0.61068666",
"0.6099717",
"0.6089621",
"0.60... | 0.8152635 | 0 |
The array of user's grades in string format | def grades
@learn_grades
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_grade(grades_array)\n\t# Determine the average of the grades\n\t\t# Set a new variable called grades_total to zero\n\t\tgrades_total = 0\n\t\t# Add each grade in grades_array to grades_total\n\t\tgrades_array.each do |x|\n\t\t\tgrades_total += x\n\t\tend\n\t\t# New variable average = grades_total divided b... | [
"0.6849752",
"0.653529",
"0.6507176",
"0.64418817",
"0.6414756",
"0.64112914",
"0.6408905",
"0.6360139",
"0.63269806",
"0.62809813",
"0.62544733",
"0.62449163",
"0.6240323",
"0.623217",
"0.6227963",
"0.62151295",
"0.6197067",
"0.6184771",
"0.6174667",
"0.61554384",
"0.6148515... | 0.6470674 | 3 |
Holding on to the learn URL for easy change. You may try simply changing this URL to a different University's URL. But remember, this is a hacky scrape job. Don't be surprised if things break. | def learn_url
"http://learn.uwaterloo.ca"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def course_url\n \"/d2l/lp/ouHome/home.d2l?ou=\"\n end",
"def play_rock\n self.redirect_to(\"https://www.wikipedia.org\")\n end",
"def htlal_users_url\n if htlal_language_id\n \"http://how-to-learn-any-language.com/forum/languages.asp?language=#{htlal_language_id}\"\n end\n end",
"def fet... | [
"0.6074117",
"0.59196496",
"0.55785054",
"0.55612355",
"0.55612355",
"0.54848874",
"0.5483589",
"0.5455626",
"0.5454718",
"0.53972626",
"0.5388244",
"0.5316376",
"0.5295571",
"0.52912825",
"0.5289017",
"0.5269254",
"0.5263463",
"0.526345",
"0.5259638",
"0.5245336",
"0.5244229... | 0.7615144 | 0 |
Just in case if D2L decides to change their markup, you know where to look for (hopefully) a quick fix. | def course_url
"/d2l/lp/ouHome/home.d2l?ou="
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def markup_context; end",
"def html_markup_org(text); end",
"def deprecated_tag(text); end",
"def update_html\n # need to filter HTML first... remove <script> and chunks and the like...\n self.html = RedCloth.new(strip_tags(self.redcloth.to_s),\n [ :no_span_caps ]).to_html(\n # no link refere... | [
"0.5230523",
"0.50851595",
"0.5063125",
"0.5040712",
"0.5032879",
"0.50193566",
"0.4973102",
"0.4919472",
"0.4919472",
"0.4919472",
"0.4897259",
"0.48925433",
"0.48743293",
"0.48743293",
"0.4868363",
"0.48557442",
"0.48529238",
"0.48421657",
"0.48023227",
"0.4801414",
"0.4793... | 0.0 | -1 |
Just in case if D2L decides to change their markup, you know where to look for (hopefully) a quick fix. | def course_html
"//ul[@id='z_w']//div[@class='dco_c']//a"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def markup_context; end",
"def html_markup_org(text); end",
"def deprecated_tag(text); end",
"def update_html\n # need to filter HTML first... remove <script> and chunks and the like...\n self.html = RedCloth.new(strip_tags(self.redcloth.to_s),\n [ :no_span_caps ]).to_html(\n # no link refere... | [
"0.52367085",
"0.50904226",
"0.50664836",
"0.5042996",
"0.503352",
"0.50198966",
"0.4977166",
"0.49231917",
"0.49231917",
"0.49231917",
"0.48968294",
"0.4894386",
"0.48752284",
"0.48752284",
"0.48690858",
"0.48581243",
"0.48561233",
"0.48423722",
"0.48069876",
"0.48057744",
"... | 0.0 | -1 |
Just in case if D2L decides to change their markup, you know where to look for (hopefully) a quick fix. | def error_html
"//div[@class='error']"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def markup_context; end",
"def html_markup_org(text); end",
"def deprecated_tag(text); end",
"def update_html\n # need to filter HTML first... remove <script> and chunks and the like...\n self.html = RedCloth.new(strip_tags(self.redcloth.to_s),\n [ :no_span_caps ]).to_html(\n # no link refere... | [
"0.5235045",
"0.5089007",
"0.50659996",
"0.5042844",
"0.50338024",
"0.502138",
"0.49763545",
"0.4923088",
"0.4923088",
"0.4923088",
"0.48984095",
"0.48940167",
"0.4875899",
"0.4875899",
"0.48692265",
"0.48581132",
"0.48553246",
"0.48436892",
"0.48058212",
"0.48044458",
"0.479... | 0.0 | -1 |
The starting point of crawling. Calls the authentication and scraping methods. | def start
# Very important object. Don't lose or overwrite it. Required for scraping.
agent = Mechanize.new
begin
# Authenticates in this method call.
links = authenticate agent
# Scrapes in this method call.
acquire links, agent
puts "Grades acquired.".foreground(:cyan)
rescue Exception => e
puts e.message
rescue Mechanize::ResponseCodeError, Net::HTTPNotFound
puts "Looks like the website has changed. Contact the developer to fix this issue.".foreground(:red)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_crawling\n begin\n if @params[:url]\n page = @agent.get(@params[:url])\n else\n @pre_middlewares.each { |mw| mw.call(@params) }\n page = @params[:page]\n raise 'internal error' if page.nil?\n end\n rescue => _\n raise CrawlingException::Initiali... | [
"0.7145175",
"0.6983163",
"0.6663635",
"0.6531755",
"0.65110105",
"0.6415126",
"0.6403518",
"0.6387489",
"0.6321791",
"0.6289653",
"0.6226989",
"0.6225133",
"0.618805",
"0.6175649",
"0.6132004",
"0.61291206",
"0.6126831",
"0.60724396",
"0.60513514",
"0.60466343",
"0.6024716",... | 0.6886187 | 2 |
Logs in using the user credentials. Returns an array of anchor() elements of course links. | def authenticate(agent)
puts "Authenticating ".foreground(:cyan) + @user_login.foreground(:cyan) + "...".foreground(:cyan)
# Login form submission
page = agent.get learn_url
form = page.forms.first
form.username = @user_login
form.password = @user_passw
page = agent.submit form
course_links = page.search course_html
login_error = page.search error_html
if login_error.empty? and course_links.empty?
raise "D2l has changed. Please contact the developer.".foreground(:red)
elsif !login_error.empty?
raise "Couldn't authenticate. Please try again.".foreground(:red)
end
course_links
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_course_links(page)\n page.links.each do |link|\n return link.click.links if link.href == \"/courses\"\n end\n end",
"def index\n @links = current_user.links\n end",
"def index\n @username = session[:cas_user]\n @login_url = CASClient::Frameworks::Rails::Filter.login_url(se... | [
"0.58448595",
"0.55082554",
"0.54977375",
"0.5391044",
"0.5368523",
"0.53678715",
"0.5352513",
"0.534451",
"0.5328647",
"0.53203404",
"0.5296442",
"0.5258034",
"0.51716477",
"0.51706827",
"0.5168614",
"0.51511854",
"0.5134666",
"0.510892",
"0.5094588",
"0.50850886",
"0.508429... | 0.5627084 | 1 |
Extracts the course name and code for further scraping of grades. The scraping occurs in the initialization of the grade objects. | def acquire(links, agent)
puts "Acquiring data...".foreground(:cyan)
links.each do |link|
name = link.inner_html.to_s
code = link["href"].to_s.sub course_url, ""
if name == "" || code == ""
raise "Incorrect parsing. Please contact the developer.".foreground(:red)
end
grade = Grade.new name, code, agent
course = Course.new name, code, grade
@learn_courses << course
@learn_grades << grade
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_courses(url, counter, parsed_page)\n all_paragraphs = parsed_page.xpath '//p' # all <p> on the page\n paragraph_number = 8 # The description paragraph for most pages\n\n # get the course's description\n course_description = \"\"\n while !all_paragraphs[paragraph_number].text.eql? \"Qualifica... | [
"0.60634804",
"0.6010499",
"0.59868795",
"0.59716433",
"0.5928691",
"0.5873364",
"0.58708763",
"0.5794507",
"0.567066",
"0.5622464",
"0.560442",
"0.5598162",
"0.55883384",
"0.5574429",
"0.5547613",
"0.5526265",
"0.55158126",
"0.5509742",
"0.54929787",
"0.5468265",
"0.54668367... | 0.6089036 | 0 |
ex. 4 Write a method that counts down to zero using recursion. | def count_to_zero(number)
if number <= 0
puts number
else
puts number
count_to_zero(number-1)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_to_zero(number)\n if number <= 0\n puts number\n else\n puts number\n count_to_zero(number - 1)\n end\nend",
"def count_down(num) \n if num == 0\n p \"Houston, we have lift-off!\"\n return;\n end\n\n p num\n count_down(num - 1)\nend",
"def count_down(start)\n puts start\n if s... | [
"0.82013893",
"0.78925955",
"0.77423084",
"0.76379955",
"0.75490654",
"0.7477965",
"0.7451004",
"0.74343324",
"0.73448664",
"0.7320004",
"0.72069526",
"0.70943713",
"0.70866483",
"0.70713437",
"0.706271",
"0.6889662",
"0.6881661",
"0.68802845",
"0.687459",
"0.687459",
"0.6874... | 0.82669646 | 3 |
move each horse forward random number of spaces | def move_horses wants_to_cheat = false
horses.each do |horse|
location = horse.location
distance_moved = rand(1..MAX_MOVEMENT_FORWARD)
location.position += distance_moved
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_left\n\t\t# if the horse isn;t yet at the left of of the screne move it left 20\n\t\tif @x > 0\n\t\t\t\t@x = @x -20\n\t\tend\n\tend",
"def move\n @position += MOVMENT_ALTERATIONS[rand(0..1)]\n end",
"def place_random_ships\n ship_count = size / 4\n while ship_count.positive?\n row = ran... | [
"0.6373705",
"0.6262019",
"0.6127016",
"0.6012197",
"0.60103536",
"0.60020256",
"0.5898477",
"0.5889358",
"0.58709246",
"0.5861591",
"0.5845159",
"0.5777327",
"0.5771943",
"0.57595974",
"0.5721648",
"0.5714188",
"0.5711639",
"0.5697771",
"0.5684981",
"0.5664121",
"0.5650453",... | 0.710495 | 0 |
true if user_input = "cheat" / false | def user_wants_to_cheat?
puts "Press Enter to continue"
continue = gets.chomp
if continue.downcase == "cheat"
self.move_my_horse
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_true(user_input)\n if user_input == \"yes\"\n true\n else\n false\n end\nend",
"def joke_ex2(joke, correct_response)\n puts joke\n user_input = gets.chomp\n if user_input == correct_response\n return true\n else\n return false\n end\nend",
"def tell_a_joke(joke_to_tell, correct_respo... | [
"0.7588111",
"0.742317",
"0.73621756",
"0.71752864",
"0.7134951",
"0.6904905",
"0.6904472",
"0.69024104",
"0.68353873",
"0.6765318",
"0.67643964",
"0.6685983",
"0.6677632",
"0.6677632",
"0.6677632",
"0.6677632",
"0.6670277",
"0.6651513",
"0.6647398",
"0.66370225",
"0.66227275... | 0.6621946 | 21 |
GET /app_config/1 GET /app_config/1.json | def show
@default_check_out_duration = Settings.default_check_out_duration
@clients_can_see_equipment_outside_their_groups = Settings.clients_can_see_equipment_outside_their_groups
@attendants_can_self_check_out = Settings.attendants_can_self_check_out
respond_to do |format|
format.html # show.html.erb
# format.json { render json: @app_config }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @app_config = AppConfig.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @app_config }\n end\n end",
"def get_config()\n return @api.do_request(\"GET\", get_base_api_path() + \"/config\")\n end",
"def show\n @glo... | [
"0.7766584",
"0.7333203",
"0.72002465",
"0.7195243",
"0.70840114",
"0.6879468",
"0.6753053",
"0.66654015",
"0.66578853",
"0.6540063",
"0.6498536",
"0.6464206",
"0.645833",
"0.64196265",
"0.64094406",
"0.64004606",
"0.6387071",
"0.63174266",
"0.63021547",
"0.62913334",
"0.6290... | 0.56713057 | 98 |
PUT /app_config/1 PUT /app_config/1.json | def update
@default_check_out_duration = params[:default_check_out_duration].to_i || Settings.defaults[:default_check_out_duration]
@clients_can_see_equipment_outside_their_groups = (params[:clients_can_see_equipment_outside_their_groups] == 'true')
@attendants_can_self_check_out = (params[:attendants_can_self_check_out] == 'true')
saved = true
obj = Settings.object('default_check_out_duration')
obj.value = @default_check_out_duration
saved &&= obj.save
obj = Settings.object('clients_can_see_equipment_outside_their_groups')
obj.value = @clients_can_see_equipment_outside_their_groups
saved &&= obj.save
obj = Settings.object('attendants_can_self_check_out')
obj.value = @attendants_can_self_check_out
saved &&= obj.save
respond_to do |format|
if saved
format.html { redirect_to settings_path, notice: 'Settings were successfully updated.' }
# format.json { head :no_content }
else
format.html { render action: "edit" }
# format.json { render json: @settings.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @app_config = AppConfig.find(params[:id])\n\n respond_to do |format|\n if @app_config.update_attributes(params[:app_config])\n format.html { redirect_to @app_config, notice: 'App config was successfully updated.' }\n format.json { head :no_content }\n else\n format... | [
"0.7466702",
"0.7444938",
"0.66432863",
"0.659621",
"0.655171",
"0.6486678",
"0.64577895",
"0.64281094",
"0.6413539",
"0.6296864",
"0.62750953",
"0.62691057",
"0.62691057",
"0.6237923",
"0.62295246",
"0.6176928",
"0.6144174",
"0.60958207",
"0.60946333",
"0.6062278",
"0.601470... | 0.0 | -1 |
given 2 teams, creates an array with 2 arrays of team names and team ids [["Paul/Abigail", "21/23"], ["Mac/Nani", "24/25"]] | def team_name_with_team_number_array(team_ids)
team1_id, team2_id = team_ids.split("-")
team1_name, team2_name = create_game_title_from_team_ids(team_ids).split(" vs ")
[[team1_name, team1_id], [team2_name, team2_id]]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def teams_with_ids\n team_array = []\n\n self.teams.all.each do |team|\n team_array << [team.name, team.id]\n end\n\n team_array\n end",
"def all_teams_hash_by_leagues(league_ids)\n teams = {}\n league_ids.each do |league_id|\n teams_in_league = parse_api_request(\"#{BASE_URL}teams/league/... | [
"0.75608176",
"0.67396384",
"0.6721347",
"0.6720578",
"0.6716793",
"0.6716793",
"0.65857226",
"0.65857226",
"0.65275156",
"0.6422633",
"0.64160645",
"0.63438404",
"0.62631994",
"0.623931",
"0.61995155",
"0.61705136",
"0.61584175",
"0.61584175",
"0.61221355",
"0.60833937",
"0.... | 0.7487032 | 1 |
def points_earned_kob(num_of_teams) if num_of_teams == 4 return [100, 50, 25, 20] else points = [100, 50, 25, 20, 20] until points.length == num_of_teams points << 10 end return points end end | def get_kob_court_standings_poolplay(court_id)
team_ids = self.poolplay_teams.select { |pool| pool.court_id == court_id && pool.version === 'poolplay'}
team_ids = get_team_ids_from_court()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def final_results_list\n winners = sort_group_of_teams(self.teams.select { |team| team.playoffs && team.court_id == 100 })\n losers = sort_group_of_teams(self.teams.select { |team| team.playoffs && team.court_id != 100 })\n\n #only for kob, game play will not have a losers court\n ## winner of consolat... | [
"0.652452",
"0.64847404",
"0.6391291",
"0.6332639",
"0.63230735",
"0.61779284",
"0.61447066",
"0.60998875",
"0.59833807",
"0.59726703",
"0.5969186",
"0.5959289",
"0.59565765",
"0.5940857",
"0.5931938",
"0.5916704",
"0.5906452",
"0.590582",
"0.5899667",
"0.5872385",
"0.5867669... | 0.0 | -1 |
returns an array of Team objects sorted by wins and pool_diff | def poolplay_standings(team_ids, teams)
group = teams.select { |team| team_ids.include?(team.id) }
sort_teams_by_record_points(group)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nen... | [
"0.67388314",
"0.6698069",
"0.667349",
"0.6579947",
"0.65533066",
"0.6548536",
"0.6545007",
"0.6537264",
"0.6460173",
"0.645034",
"0.63865167",
"0.6367101",
"0.6318163",
"0.63127637",
"0.6296603",
"0.62800854",
"0.627583",
"0.62727034",
"0.62626284",
"0.6255841",
"0.6243323",... | 0.6683535 | 2 |
The set of attributes for the given model | def attributes
superclass_attrs = superclass.attributes if superclass.respond_to? :attributes
@__attrs ||= AttributeCollection.new + superclass_attrs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model_attributes\n @model_attributes ||= Prepares.model_attributes\n end",
"def attributes\n model_attributes(@@setters_list)\n end",
"def attributes\n model_attributes(@@setters_list)\n end",
"def attributes\n model_attributes(@@setters_list)\n end",
"de... | [
"0.7218278",
"0.71783614",
"0.71783614",
"0.71783614",
"0.71783614",
"0.71783614",
"0.71783614",
"0.71740115",
"0.71728873",
"0.71488756",
"0.707285",
"0.6905587",
"0.6881034",
"0.68693894",
"0.6844762",
"0.6841524",
"0.6814395",
"0.679449",
"0.67886233",
"0.6772798",
"0.6766... | 0.0 | -1 |
Current price of 1 BTC in USD (or another currency), float returned. | def price(currency = 'USD')
first_one do |api|
api.price(currency)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def price\n (price_in_cents / 100.0) unless price_in_cents.nil?\n end",
"def total_value_usd\n @quantity * price_in_usd\n end",
"def price\n BigDecimal('3.0')\n end",
"def price_in_cents\n Integer( price * 100 + 0.5 ) # +0.5 Because floating-point numbers don’t always have an exact interna... | [
"0.7202857",
"0.7071412",
"0.701981",
"0.6973965",
"0.6924654",
"0.6903886",
"0.6842143",
"0.6842059",
"0.6819966",
"0.68176854",
"0.68144",
"0.68074846",
"0.6787552",
"0.6783708",
"0.6767649",
"0.67670774",
"0.67249227",
"0.6711893",
"0.6711893",
"0.6711288",
"0.66996276",
... | 0.0 | -1 |
Generates new Bitcon private key and returns in Hash160 format. | def generate
key = Bitcoin::Key.generate.priv
@log.info("Bitcoin private key generated: #{key[0..8]}...")
key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key(hash160)\n key = Bitcoin::Key.new\n key.priv = hash160\n key\n end",
"def key(hash160)\n key = Bitcoin::Key.new\n key.priv = hash160\n key\n end",
"def generate\n key = Bitcoin::Key.generate.priv\n info(\"Bitcoin private key generated: #{key[0..8]}...\")\n key\n en... | [
"0.7759179",
"0.76228106",
"0.7452207",
"0.65134305",
"0.65134305",
"0.6486096",
"0.6425016",
"0.64110684",
"0.6398727",
"0.6245406",
"0.623796",
"0.62224954",
"0.6182704",
"0.6163349",
"0.6153661",
"0.6148974",
"0.61454296",
"0.61454296",
"0.61077785",
"0.60919744",
"0.60620... | 0.7375816 | 3 |
Creates Bitcon address using the private key in Hash160 format. | def create(pvt)
key = Bitcoin::Key.new
key.priv = pvt
key.addr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key(hash160)\n key = Bitcoin::Key.new\n key.priv = hash160\n key\n end",
"def key(hash160)\n key = Bitcoin::Key.new\n key.priv = hash160\n key\n end",
"def new_address\n private_key, public_key = Bitcoin::generate_key\n address = Bitcoin::pubkey_to_address(public_key)\n [priv... | [
"0.7065973",
"0.685901",
"0.68547285",
"0.6757681",
"0.67147106",
"0.65684915",
"0.656253",
"0.64995795",
"0.62075293",
"0.6196291",
"0.6104347",
"0.604917",
"0.6028682",
"0.60056627",
"0.5998261",
"0.5928632",
"0.5889616",
"0.58284837",
"0.5768464",
"0.57675403",
"0.57650363... | 0.6482546 | 8 |
Gets the balance of the address, in satoshi. | def balance(address)
first_one do |api|
api.balance(address)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def balance(address)\n json = Sibit::Json.new(http: @http, log: @log).get(\n Iri.new('https://api.blockchair.com/bitcoin/dashboards/address').append(address).fragment(the_key)\n )['data'][address]\n if json.nil?\n @log.info(\"Address #{address} not found\")\n return 0\n end... | [
"0.79297596",
"0.7650384",
"0.7475143",
"0.74137586",
"0.7399117",
"0.7381385",
"0.7330787",
"0.73150444",
"0.718895",
"0.70118725",
"0.6929778",
"0.67927784",
"0.6729396",
"0.6651305",
"0.6649159",
"0.6649159",
"0.66137683",
"0.65630424",
"0.6541119",
"0.6535886",
"0.6492944... | 0.6337254 | 22 |
Sends a payment and returns the transaction hash. If the payment can't be signed (the key is wrong, for example) or the previous transaction is not found, or there is a network error, or any other reason, you will get an exception. In this case, just try again. It's safe to try as many times as you need. Don't worry about duplicating your transaction, the Bitcoin network will filter duplicates out. If there are more than 1000 UTXOs in the address where you are trying to send bitcoins from, this method won't be helpful. +amount+: the amount either in satoshis or ending with 'BTC', like '0.7BTC' +fee+: the miners fee in satoshis (as integer) or S/M/X/XL as a string +sources+: the hashmap of bitcoin addresses where the coins are now, with their addresses as keys and private keys as values +target+: the target address to send to +change+: the address where the change has to be sent to | def pay(amount, fee, sources, target, change)
first_one do |api|
api.pay(amount, fee, sources, target, change)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pay(amount, fee, sources, target, change)\n p = price('USD')\n satoshi = satoshi(amount)\n f = mfee(fee, size_of(amount, sources))\n satoshi += f if f.negative?\n raise Error, \"The fee #{f.abs} covers the entire amount\" if satoshi.zero?\n raise Error, \"The fee #{f.abs} is bigge... | [
"0.7036879",
"0.70280915",
"0.5980211",
"0.5980211",
"0.58373976",
"0.58263755",
"0.5822743",
"0.57826245",
"0.57366514",
"0.56992",
"0.56563693",
"0.56258243",
"0.5613714",
"0.5609184",
"0.5592399",
"0.55460155",
"0.5545829",
"0.55409896",
"0.5535818",
"0.55158484",
"0.54930... | 0.56034124 | 14 |
Gets the hash of the latest block. | def latest
first_one(&:latest)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def latest\n Sibit::Json.new(http: @http, log: @log).get(\n URI('https://blockchain.info/latestblock')\n )['hash']\n end",
"def latest\n uri = Iri.new('https://chain.api.btc.com/v3/block/latest')\n json = Sibit::Json.new(http: @http, log: @log).get(uri)\n data = json['data']\n ... | [
"0.8422635",
"0.8365425",
"0.8211273",
"0.75357264",
"0.7477265",
"0.72320265",
"0.7173713",
"0.7045299",
"0.6821578",
"0.6813969",
"0.64557725",
"0.6422807",
"0.62548715",
"0.62225044",
"0.62210983",
"0.6159969",
"0.61576414",
"0.6144877",
"0.6136921",
"0.6130533",
"0.609022... | 0.0 | -1 |
THINK ABOUT IT: The two major ways to write class methods are: class Demo def self.method end class against DRY def self.method looks clean, but I see that class << self provides a way to group all class methods at one place in a larger codebase, this would help partition the code nicely just like sandwiches yum :D | def test_heres_an_easy_way_to_call_class_methods_from_instance_methods
fido = Dog.new
assert_equal :still_another_way, fido.class.another_class_method
# Fuck another ways now
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_method2\n end",
"def class_method2\nend",
"def methods() end",
"def class() end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
... | [
"0.68303746",
"0.6702443",
"0.6481057",
"0.63212013",
"0.62247986",
"0.62247986",
"0.62247986",
"0.62247986",
"0.6223364",
"0.6223364",
"0.6223364",
"0.6223364",
"0.6223364",
"0.6223364",
"0.6223364",
"0.6223364",
"0.6223364",
"0.6223364",
"0.6223364",
"0.6223364",
"0.6057526... | 0.56588125 | 48 |
Use API V0 to load the public_key directly from the user object using the chefclient code. | def chef_api_client
@chef_api_client ||= begin
require "chef/api_client"
Chef::ApiClient
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_key\n as_public_key(rpc(:account_key, _access: :key))\n end",
"def publickey hashid, &block\n em_get( \"/clients/#{uuid}/#{hashid}/publickey\" ) { |response| block.call( response ) }\n end",
"def public_key\n public_key_object.to_pem\n end",
"def public_key\n require_key\n... | [
"0.6940505",
"0.6890452",
"0.6836415",
"0.67794424",
"0.6772616",
"0.67346877",
"0.66491306",
"0.6585814",
"0.6585796",
"0.6507385",
"0.6507385",
"0.6443224",
"0.63981575",
"0.6390771",
"0.63629246",
"0.63421977",
"0.63175255",
"0.63175255",
"0.6303444",
"0.6303444",
"0.62915... | 0.0 | -1 |
Similar thing as above but for client. | def chef_user
@chef_user ||= begin
require "chef/user"
Chef::User
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def client; end",
"def client; end",
"def client\n end",
"def clientserver\n end",
"def client_access\n super\n end",
"def client\n self.class.client\n end",
"def add(client); end",
"def prepare_simple_client(client, channel, type); end",
"def init_client; end",
"def process_client(... | [
"0.706747",
"0.706747",
"0.6820406",
"0.64928514",
"0.6333187",
"0.6051272",
"0.6031061",
"0.6016571",
"0.6013299",
"0.5989057",
"0.5978077",
"0.5978077",
"0.5937444",
"0.59349215",
"0.59237075",
"0.59092486",
"0.5891264",
"0.5884349",
"0.58703184",
"0.5861107",
"0.5847865",
... | 0.0 | -1 |
The following designations are used: TI tap installed TR tap renamed CI core installed CR core renamed | def setup
# checkout to new branch
initialize_revisions
[@repo_dir, @tap_dir].each do |dir|
Dir.chdir(dir.to_s) do
shutup { `git checkout -b #{@new_branch}` }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def describePlatform\n TC.name.gsub(' ', '_')\nend",
"def tr_base_name\n \"#{@stage}-#{crit}-#{phylo_prog}-#{thres}-#{hgt_type.to_s}-tr\"\n end",
"def platform_shortname\n if rhel?\n if \"rocky\" == Ohai[\"platform\"]\n \"rocky\"\n else\n \"el\"\n ... | [
"0.5965676",
"0.52435905",
"0.5201827",
"0.5128636",
"0.50439733",
"0.5036705",
"0.50172853",
"0.49229506",
"0.49164268",
"0.49144223",
"0.490743",
"0.4907004",
"0.48922455",
"0.48913452",
"0.48875463",
"0.4868041",
"0.48535913",
"0.48489353",
"0.48414615",
"0.48365107",
"0.4... | 0.0 | -1 |
board is an array of strings ["X", "", " ", "0", etc] index is a number to check index values are 0 through 8 | def position_taken?(board, index)
!(board[index] == " " || board[index] == "" || board[index] == nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_move?(index)\n if (index>=0 && index <=8 && @board[index]==\" \")\n return true\n end\n end",
"def board\n @board_string = @board_string.to_s.split(//).each_slice(9).to_a.map!{|array| array.map!{|string| string.to_i}}\n\n end",
"def valid_move? (board, index)\n if (0..8) === index ... | [
"0.7350416",
"0.73004925",
"0.7250608",
"0.715243",
"0.7086785",
"0.6994624",
"0.6960037",
"0.6958567",
"0.69481844",
"0.6948014",
"0.6925095",
"0.6924128",
"0.690933",
"0.69033813",
"0.69033813",
"0.69027185",
"0.68874204",
"0.68802905",
"0.68690395",
"0.68573356",
"0.685296... | 0.0 | -1 |
create data for login | def setup_user
login_as(User.where(email: 'masterchef@cookbook.com').first, scope: :user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login_data\n tbcreds = UserTestbedCredential.where(:user_id => user.id, :testbed_id => testbed.id).first\n logindata = {\n \"authenticationData\" => [\n {\n \"urnPrefix\" => tbcreds.testbed.urn_prefix_list,\n \"username\" => tbcreds.username,\n ... | [
"0.7416416",
"0.71867996",
"0.705455",
"0.703058",
"0.6686994",
"0.66506004",
"0.64984",
"0.6474949",
"0.64742637",
"0.64722973",
"0.6429459",
"0.641876",
"0.6411072",
"0.63706136",
"0.63452315",
"0.6340528",
"0.6325237",
"0.6270257",
"0.6244063",
"0.62409616",
"0.6233994",
... | 0.0 | -1 |
GET /movies/1 GET /movies/1.xml | def show
@movie = Movie.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @movie }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def movies\n get('Movies')\n end",
"def index\n @movies = Movie.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @movies }\n end\n end",
"def show\n @movie = @catalogue.movies.find(params[:id])\n\n respond_to do |format|\n forma... | [
"0.74905664",
"0.7227729",
"0.6813911",
"0.6706425",
"0.6703394",
"0.6683271",
"0.6554838",
"0.6545393",
"0.6541379",
"0.653199",
"0.6505898",
"0.6505898",
"0.63817346",
"0.63783413",
"0.6367264",
"0.63462895",
"0.6324439",
"0.6324439",
"0.6324439",
"0.6324439",
"0.6324439",
... | 0.70540154 | 3 |
GET /movies/new GET /movies/new.xml | def new
@movie = Movie.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @movie }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @movie = @school.movies.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @movie }\n end\n end",
"def new\n @movie_list = MovieList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mov... | [
"0.712044",
"0.70635086",
"0.7053852",
"0.6852358",
"0.6852358",
"0.6852358",
"0.6852358",
"0.6852358",
"0.6852358",
"0.6852358",
"0.6852358",
"0.6852358",
"0.6707608",
"0.6674157",
"0.6659915",
"0.6659915",
"0.6635974",
"0.6621828",
"0.6552099",
"0.65469706",
"0.6487732",
... | 0.74744016 | 3 |
POST /movies POST /movies.xml | def create
@movie = Movie.new({:name => params[:movie][:name], :rating => 0})
respond_to do |format|
if @movie.save
format.html { redirect_to(@movie, :notice => 'Movie was successfully created.') }
format.xml { render :xml => @movie, :status => :created, :location => @movie }
else
format.html { render :action => "new" }
format.xml { render :xml => @movie.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @movie = Movie.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to(@movie, :notice => 'Movie was successfully created.') }\n format.xml { render :xml => @movie, :status => :created, :location => @movie }\n else\n format.html... | [
"0.6326424",
"0.6055285",
"0.6046898",
"0.6036378",
"0.6036378",
"0.6036378",
"0.6036378",
"0.6036378",
"0.6036378",
"0.6036378",
"0.6036378",
"0.6036378",
"0.60282844",
"0.6027713",
"0.6022759",
"0.6022759",
"0.6022759",
"0.6022759",
"0.6022759",
"0.60067016",
"0.5990893",
... | 0.6298027 | 1 |
PUT /movies/1 PUT /movies/1.xml | def update
@movie = Movie.find(params[:id])
respond_to do |format|
if @movie.update_attributes(params[:movie])
format.html { redirect_to(@movie, :notice => 'Movie was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @movie.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n if @movie.update_attributes(params[:movie])\n format.html { redirect_to(edit_movie_path(@movie), :notice => 'Movie was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :... | [
"0.6384537",
"0.61805356",
"0.61697054",
"0.61602646",
"0.61602646",
"0.61602646",
"0.61602646",
"0.61602646",
"0.61602646",
"0.61444443",
"0.6137829",
"0.6010092",
"0.5984022",
"0.5942114",
"0.5942114",
"0.5942114",
"0.5942114",
"0.5942114",
"0.5942114",
"0.5942114",
"0.5942... | 0.64294046 | 1 |
DELETE /movies/1 DELETE /movies/1.xml | def destroy
@movie = Movie.find(params[:id])
@movie.destroy
respond_to do |format|
format.html { redirect_to(movies_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @movies.each do |movie|\n #@movie = Movie.find(params[:id])\n movie.destroy\n end\n\n # respond_to do |format|\n \n # format.xml { head :ok }\n # end\n end",
"def destroy\n @users_movie = UsersMovie.find(params[:id])\n @users_movie.destroy\n\n respond_to do |fo... | [
"0.730383",
"0.69725376",
"0.69207084",
"0.67968184",
"0.6777412",
"0.6772278",
"0.6752129",
"0.67457765",
"0.67457765",
"0.67457765",
"0.67457765",
"0.67457765",
"0.67457765",
"0.67457765",
"0.6711468",
"0.6623412",
"0.66028565",
"0.66028565",
"0.66028565",
"0.66028565",
"0.... | 0.73004377 | 3 |
Created a method to determine which driver made the most money. | def most_money(driver_data)
driver_id = nil
most_money = 0
driver_data.each do |driver, data|
if data[:money] > most_money
driver_id = driver
most_money = data[:money]
end
end
return driver_id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output_driver_with_most_money(earned_per_each_driver)\n max_earned = earned_per_each_driver.max_by do |current_driver|\n current_driver[:driver_earned]\n end\n\n puts \"\\nDriver #{max_earned[:driver_id]} earned the most money $#{max_earned[:driver_earned]}.\"\nend",
"def highest_earner(drivers)\n # h... | [
"0.81282663",
"0.76657116",
"0.7633933",
"0.75995225",
"0.7596862",
"0.7535593",
"0.7491152",
"0.7451346",
"0.7421987",
"0.7405285",
"0.7256428",
"0.7159454",
"0.7154489",
"0.7123531",
"0.71171486",
"0.7093118",
"0.7049649",
"0.69343907",
"0.69123286",
"0.6853169",
"0.6825836... | 0.79879457 | 1 |
Created a method to determine which driver has the highest average rating. | def get_top_rating(driver_data)
driver_id = nil
top_rating = 0
driver_data.each do |driver, data|
if data[:average_rating] > top_rating
driver_id = driver
top_rating = data[:average_rating]
end
end
return driver_id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def driver_with_highest_rating(average_rating)\n return average_rating.max_by { |driver_rating| driver_rating[:avg_rating]}\nend",
"def return_driver_who_had_highest_ave_rating(drivers_average_ratings)\n highest_rating = drivers_average_ratings.each_value.max\n driver_with_highest_average_rating = \"\"\n dri... | [
"0.87453985",
"0.8707861",
"0.8641107",
"0.8465715",
"0.8183191",
"0.81344813",
"0.8100368",
"0.79883665",
"0.788034",
"0.7858469",
"0.77140737",
"0.7710916",
"0.76935613",
"0.7430107",
"0.7071019",
"0.70530796",
"0.69635344",
"0.69365567",
"0.68239015",
"0.6796933",
"0.67962... | 0.7690269 | 13 |
Computes the stat for MultivariateGeary. | def stat
m = fields.size
gearys = fields.map do |field|
Geary.new(scope, field, weights).stat
end
gearys.transpose.map { |x| x.reduce(:+) / m }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mult(y)\n z=Density.new\n z.delete(0)\n z.uniform=false\n z.exact=false\n z.fail=true\n\n @d.each { |k,v| z[k]=v*y }\n return z\n end",
"def get_gei\n aux = 0.0\n @contenido.each do |alimento|\n aux += alimento.gei\n end\n @gei = aux\n end",
"... | [
"0.51245993",
"0.4948533",
"0.49135694",
"0.4907416",
"0.49063772",
"0.490413",
"0.48474038",
"0.4808376",
"0.47698644",
"0.47204435",
"0.46917725",
"0.4660273",
"0.46018684",
"0.45821592",
"0.45335317",
"0.45236707",
"0.45121428",
"0.45059988",
"0.4491788",
"0.44906336",
"0.... | 0.65031916 | 0 |
Permutation test to determine a pseudo pvalues of the +stat+ method. Shuffles all tuples, recomputes +stat+ for each variation, then compares to the computed one. The ratio of more extreme values to permutations is returned for each observation. | def mc(permutations = 99, seed = nil)
# in this case, one tuple of vals is held constant, then
# the rest are shuffled, so for crand we will pass in an arr
# of indices, which will return a list of new orders for the fields.
# They will then be shuffled corresponding to the new indices.
rng = gen_rng(seed)
rids = crand(permutations, rng)
n_1 = weights.n - 1
sparse = weights.sparse
row_index = sparse.row_index
ws = sparse.values
wc = weights.wc
stat_orig = stat
ids = (0..n_1).to_a
observations = Array.new(weights.n)
(0..n_1).each do |idx|
idsi = ids.dup
idsi.delete_at(idx)
idsi.shuffle!(random: rng)
idsi = Numo::Int32.cast(idsi)
sample = rids[idsi[rids[true, 0..wc[idx] - 1]]]
# account for case where there are no neighbors
row_range = row_index[idx]..(row_index[idx + 1] - 1)
if row_range.size.zero?
observations[idx] = permutations
next
end
wi = Numo::DFloat.cast(ws[row_range])
stat_i_new = mc_i(wi, sample, idx)
stat_i_orig = stat_orig[idx]
observations[idx] = mc_observation_calc(stat_i_orig, stat_i_new,
permutations)
end
observations.map do |ri|
(ri + 1.0) / (permutations + 1.0)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def probability_exact\n\t\t str_format=\"%0#{nr}b\"\n\t\t combinations=2**nr\n\t\t #p str_format\n\t\t total_w=combinations.times.map do |i|\n comb=sprintf(str_format,i)\n w_local=comb.length.times.inject(0) do |ac,j|\n sgn=comb[j]==\"0\" ? -1 : 1\n\t\t\t\t ac+(j+1)*sgn\... | [
"0.575583",
"0.5712715",
"0.54724723",
"0.5311956",
"0.52977407",
"0.5231148",
"0.5204127",
"0.5195126",
"0.51618016",
"0.51376516",
"0.5110066",
"0.5078625",
"0.5065539",
"0.50262445",
"0.50046575",
"0.49816874",
"0.4963103",
"0.4956394",
"0.49300206",
"0.49094224",
"0.48906... | 0.45405045 | 77 |
used to create a set of graphs for the dpm to show the user picks one graph for the dpm process | def create_hash(filename)
graphs = [] #array of all graphs
graph = [] #array of points
point = [] #points
hash = {}
noYcolumns = 0
file = File.open(filename, 'r')
while !file.eof?
line = file.readline
line = line.split(",").collect {|x| x.strip}
noYcolumns = line.length-1
for t in 0...noYcolumns #iterate over Y columns in row
point[t] = [line[0].to_f, line[t+1].to_f] #get x,y1/2/3/...; save in point
graph.push(point[t]) #store each point in a graph
end
graphs.push(graph) #store graph created in graphs array
graph = [] #clear the graph array
end
#graphs.length = num rows, graphs[i].length = num cols
for i in 0...noYcolumns #for each column i
for j in 0...graphs.length #for each row j
hash.store(graphs[j][0][0], graphs[j][i][1]) #let x point to y1/2/3/...
end
graph[i] = hash
hash = {}
end
file.close
graph
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_graph\n end",
"def create_graphs\n if(@config[\"Smain\"][\"graphs\"] == \"interval\")\n @childs[\"graph\"] = Process.fork do\n # Ignore HANUP signal\n trap('HUP', 'IGNORE')\n\n # Exit on SIGTERM or SIGKILL\n trap(\"SIGTERM\") { Process.exit!(0) }\n trap(... | [
"0.6661165",
"0.66315943",
"0.64288664",
"0.61954075",
"0.6169429",
"0.61606646",
"0.60190177",
"0.59859467",
"0.59821135",
"0.5910649",
"0.5906404",
"0.5883479",
"0.5874232",
"0.5853601",
"0.58114713",
"0.5804337",
"0.5802088",
"0.5800825",
"0.5767552",
"0.57651466",
"0.5758... | 0.0 | -1 |
returns the last point in the hash takes a hash as input | def getLastPoint myhash
#sort the hash and get the x values
dummy = myhash.keys.sort
#save the x value of the last point
xval = dummy.last
#get the y value of the last point
yval = myhash[xval]
return [xval, yval]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last \n\t\tlast = @hash.last\n\t\t[last.key, last.value]\n\tend",
"def largest_hash_key(hash)\n current_highest_id = \"\"\n current_highest = 0\n hash.each do |k,v|\n if v > current_highest\n current_highest = v\n current_highest_id = k\n end\n end\n current_highest_id\... | [
"0.6526282",
"0.6501007",
"0.6375931",
"0.63043624",
"0.6257313",
"0.61579835",
"0.6120598",
"0.6104429",
"0.61024433",
"0.6096591",
"0.60615605",
"0.5960726",
"0.59316427",
"0.59278876",
"0.5922526",
"0.58824307",
"0.5871067",
"0.5858177",
"0.5853811",
"0.5847213",
"0.584207... | 0.75563836 | 0 |
tstrain=log(1+strain); tstress=stress.(1+strain); %Subtract out elastic region of curve pstrain=tstrain(tstress./E); this functions returns the tstrain (array) and pstrain vs tstress (hash) values trial is a hash youngs is youngs modulus to calculate tstress the return value is a hash [tstrain pstrainvststress] | def tp_strain trial, youngs
tstrain = Array.new
pstrain = Hash.new
trial.each do |key, value|
#change stress values first (y values)
new_value = value * (1 + key)
#change the strain values to tstrain values
new_key = Math.log(1 + key)
#add the tstrain values to the array
tstrain << new_key
#change the tstrain to pstrain
new_key = new_key - (new_value / (youngs * 1000))
pstrain.store(new_key, new_value)
end
return [tstrain, pstrain]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSystemVars stress, pstress, tstrain, hardstress, neckingpoint, gauge, fitparam, youngs\n\t\t#get the index of the last point \n\t\tneckindex = hardstress.length - 1\n\t\tdf = getLastPoint(pstrain)[0]\n\t\tdn = tstrain.sort[neckindex]\n\t\tsigma_n = pstress[neckingpoint]\n\t\tlaststresspoint = getLastPoint(s... | [
"0.58790946",
"0.58663845",
"0.5213134",
"0.5156626",
"0.5121587",
"0.50848687",
"0.50074226",
"0.5004561",
"0.49559283",
"0.48976824",
"0.48839763",
"0.48662123",
"0.4863339",
"0.4784831",
"0.47631183",
"0.47507533",
"0.4739241",
"0.47229534",
"0.47167715",
"0.46993577",
"0.... | 0.75297433 | 0 |
end Returns the value of f(x) f(x) = (a+x)/(b+x))^(b+x) c/d | def equationValue(a, b, c, d, x)
f = ((a+x)/(b+x))**(b + x)
f = f - (c/d)
return f
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ctof(c)\n f = c * 9.0/5.0 + 32.0\nend",
"def ctof(ctemp)\n32.0+(ctemp*9.0/5.0)\nend",
"def ctof(c)\n c * 9.0/5.0 + 32.0\nend",
"def ctof(temp)\n temp * (9.0 / 5.0) + 32\nend",
"def *(a,b,c,d)\n\t\treturn (a/b)*(c/d)\n\tend",
"def calc_contribution(f)\n each_class do |k|\n a, b, c, d ... | [
"0.67312235",
"0.66130173",
"0.6470566",
"0.64124846",
"0.6397467",
"0.63732386",
"0.6355258",
"0.63538647",
"0.6333967",
"0.62844557",
"0.6237387",
"0.6233394",
"0.62059873",
"0.61898506",
"0.6186081",
"0.61372334",
"0.6134267",
"0.6127998",
"0.6115651",
"0.6102846",
"0.6062... | 0.797256 | 0 |
This is for checking that we're working with the right side of our asymptope The point is to give more accurate error message | def isLeftSideOfAsymptote(a, b, c, d)
hasError = false
f1 = E**(a-b)
f2 = c/d
if (f1 < f2)
hasError = true
end
#puts "f1 = " + f1.to_s
#puts "c/d = " + f2.to_s
#puts "hasError = " + hasError.to_s
return hasError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanity_check\n if self[:length] < 10\n raise DRDA::RespError, \"DDM Length is too short.\"\n elsif self[:length2] < 4\n raise DRDA::RespError, \"DDM Length2 is too short.\"\n elsif self[:length]-6 != self[:length2]\n raise DRDA::RespError, \"Codepoint: 0x#{self[:codepoint].to_s(16)} DDM... | [
"0.63637567",
"0.61961454",
"0.6177376",
"0.61529624",
"0.60680604",
"0.60643476",
"0.6031873",
"0.5972809",
"0.5971107",
"0.59410787",
"0.5926638",
"0.59183085",
"0.58822095",
"0.58168983",
"0.58166105",
"0.5813235",
"0.5797311",
"0.5789627",
"0.578656",
"0.5765237",
"0.5759... | 0.0 | -1 |
this function will return the swift coefficients these are needed to create the final output the output of this function is [eps_o, n, k] | def getSwifts epsPF, epsPN, sigF, sigN
rtn = Array.new
#first get eps_o using the solver
eps_o = solve(epsPF, epsPN, sigF, sigN)
rtn << eps_o
#back solve for n
n = eps_o + epsPN
rtn << n
#back solve for k
k = sigF / ((eps_o + epsPF)**n)
rtn << k
rtn
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coeffs_t\n out={}\n se=coeffs_se\n coeffs.each do |k,v|\n out[k]=v / se[k]\n end\n out\n end",
"def get_exp_coeffs\n\t\tp = (0...@n).reduce(0) {|sum, i| sum + Math::log(@ys[i])} # Sum {ln(y)}\n\t\tq = (0...@n).reduce(0) {|sum, i| sum + (@xs[i]**2... | [
"0.6637278",
"0.5841168",
"0.5735587",
"0.5596814",
"0.5511897",
"0.5496474",
"0.53843915",
"0.53824794",
"0.5358904",
"0.5319239",
"0.52782613",
"0.52165884",
"0.51630616",
"0.5125045",
"0.5123708",
"0.5086167",
"0.50640893",
"0.5056878",
"0.50290537",
"0.5028233",
"0.501671... | 0.5889372 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.