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 |
|---|---|---|---|---|---|---|
The constructor will accept a ChannelBlock object and convert it internally to a number of segments from which samples can be made | def initialize(channel)
@segments = []
@extrap = channel.extrapolation
# Edge case - channel has no anim at all
@segments = if channel.length.zero?
[ConstantFunction.new(channel.base_value)]
else
create_segments_from_channel(channel)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(attributes)\n @block_size = attributes[:block_size]\n @blocks = attributes[:block_count]\n @block_data = attributes[:blocks].map(&:dup)\n end",
"def blocks_for_num_blocks\n # Don't create blocks if we have no words\n return [] if single_block.empty?\n\n # Split the s... | [
"0.6009416",
"0.5745767",
"0.5680458",
"0.5494756",
"0.544908",
"0.5390512",
"0.53885967",
"0.5374906",
"0.5258923",
"0.52393436",
"0.5206751",
"0.5176479",
"0.5164609",
"0.5151466",
"0.5123888",
"0.5114465",
"0.5112332",
"0.5089674",
"0.5082638",
"0.50774306",
"0.50689465",
... | 0.55823916 | 3 |
Sample the value of the animation curve at this frame | def sample_at(frame)
if :cycle == @extrap
return sample_from_segments(frame_number_in_cycle(frame))
elsif :revcycle == @extrap
return sample_from_segments(frame_number_in_revcycle(frame))
else
sample_from_segments(frame)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample(value)\n end",
"def update(sample)\n now = Time.new\n elapsed = now - @time\n @sum += sample\n if elapsed > 1.0\n @value = newValue elapsed, @sum/elapsed\n @time = now\n @sum = 0.0\n end\n end",
"def flamegraph_sample_rate=(_arg0); end",
"def cur... | [
"0.6308371",
"0.59260535",
"0.5878747",
"0.5866141",
"0.5866141",
"0.5860469",
"0.5841952",
"0.5798493",
"0.57959974",
"0.5682944",
"0.5655967",
"0.56077355",
"0.56077355",
"0.54955065",
"0.544081",
"0.543659",
"0.54198885",
"0.54070425",
"0.53824604",
"0.536771",
"0.5349652"... | 0.62286 | 1 |
Returns the first frame number that is concretely defined as a keyframe after the prepolation ends | def first_defined_frame
first_f = @segments[0].end_frame
return 1 if first_f == NEG_INF
return first_f
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_defined_frame\n last_f = @segments[-1].start_frame\n return 100 if last_f == POS_INF\n return last_f\n end",
"def frames\n @keyframes.last.index + @keyframes.last.duration\n end",
"def frame_number\n @frame_number ||= valid? ? frame.size : frame.size - 1\n end",
"def frame\n a... | [
"0.6829905",
"0.6787892",
"0.6654908",
"0.65503275",
"0.6549532",
"0.64964145",
"0.6330498",
"0.6185357",
"0.6089346",
"0.60822713",
"0.6021492",
"0.59472525",
"0.59071463",
"0.5899628",
"0.58619255",
"0.58541965",
"0.58016205",
"0.57521945",
"0.5745784",
"0.56922525",
"0.563... | 0.69495094 | 0 |
Returns the last frame number that is concretely defined as a keyframe before the extrapolation starts | def last_defined_frame
last_f = @segments[-1].start_frame
return 100 if last_f == POS_INF
return last_f
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def frames\n @keyframes.last.index + @keyframes.last.duration\n end",
"def last_frame; frames.last; end",
"def frame_number\n @frame_number ||= valid? ? frame.size : frame.size - 1\n end",
"def frame\n (@frame || 1).to_f\n end",
"def frameNumber\n\t\tif @frameScores.length == @lastFrameNumber\t... | [
"0.70405996",
"0.6980521",
"0.6964617",
"0.68965256",
"0.67190856",
"0.65070695",
"0.6471792",
"0.6309098",
"0.62063867",
"0.6194321",
"0.6058045",
"0.60512966",
"0.60470784",
"0.5994033",
"0.59190834",
"0.58997786",
"0.5888143",
"0.5864748",
"0.58464193",
"0.578206",
"0.5747... | 0.7516775 | 0 |
We need both the preceding and the next key | def key_pair_to_segment(key, next_key)
case key.interpolation
when :bezier
BezierSegment.new(key.frame, next_key.frame,
key.value, next_key.value,
key.r_handle_x,
key.r_handle_y,
next_key.l_handle_x, next_key.l_handle_y)
when :natural, :hermite
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_key\n @next && @next.key\n end",
"def each_key\n\t record = @head\r\n\t while record.next && record.next != @tail\r\n\t\t record = record.next\n\t\t yield record.key\r\n\t end\r\n end",
"def next_node(current, key)\n return nil, nil unless current[:key_length]\n nex... | [
"0.74059856",
"0.671848",
"0.6717685",
"0.6557158",
"0.6468539",
"0.64429754",
"0.641606",
"0.63311404",
"0.63311404",
"0.6226305",
"0.62109447",
"0.62056386",
"0.61576575",
"0.61123276",
"0.60965866",
"0.60965866",
"0.60432434",
"0.60322565",
"0.6023442",
"0.602239",
"0.6018... | 0.0 | -1 |
Notice here we use the "Facade" design pattern, so users of our class won't notice we have actually splitted the Author into 2 disctinct pieces (name and date). | def author
[author_developer.name_and_email, author_date, author_date_gmt_offset]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def author; end",
"def author; @author; end",
"def author; @author; end",
"def resolved_author; end",
"def\n get_author()\n @author\n end",
"def author_name\n \"#{author.first_name} #{author.last_name}\"\n end",
"def get_author()\n @author\n end",
"def add_author(name)\n a... | [
"0.7555077",
"0.7429711",
"0.7429711",
"0.734539",
"0.71430635",
"0.70342946",
"0.7026173",
"0.69968045",
"0.69604367",
"0.69540936",
"0.69527715",
"0.69105107",
"0.6907357",
"0.6893143",
"0.6878303",
"0.685823",
"0.68357813",
"0.6818121",
"0.67563707",
"0.673825",
"0.6719104... | 0.6634473 | 26 |
The same comment done above for Author applies here for Committer (on using the "Facade" design pattern). | def committer
[committer_developer.name_and_email, committer_date, committer_date_gmt_offset]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def author; end",
"def resolved_author; end",
"def inner_author\n @commit.author\n end",
"def author; @author; end",
"def author; @author; end",
"def author\n @actor ||= Actor.new(@commit.author)\n end",
"def author\n user\n end",
"def author\n @author\n end",
"def author\n\... | [
"0.76221937",
"0.7603538",
"0.7286137",
"0.7204525",
"0.7204525",
"0.7066666",
"0.7030997",
"0.6913186",
"0.679066",
"0.677207",
"0.6731319",
"0.67129725",
"0.6690014",
"0.66813576",
"0.66588145",
"0.6654155",
"0.6642716",
"0.66365474",
"0.66303235",
"0.66277516",
"0.6590221"... | 0.62722325 | 44 |
The method should return an array containing all of "peaks" of the array. An element is considered a "peak" if it is greater than both it's left and right neighbour. The first or last element of the array is considered a "peak" if it is greater than it's one neighbour Write Your method code here | def find_peaks(array)
peaks = []
# Deal with first element
if array[0] > array[1]
peaks << array[0]
end
# Deal with middle elements
for i in 1..array.length-2
if array[i] > array[i+1] and array[i] > array[i-1]
peaks << array[i]
end
end
# Deal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def peak_finder(arr)\n peaks =[]\n arr.each_with_index do |curr, i|\n left = arr[i - 1]\n right = arr[i + 1]\n \n if i == 0 && curr > right\n peaks << curr\n elsif i == arr.length - 1 && left < curr\n peaks << curr\n elsif left < curr && curr >... | [
"0.82265615",
"0.8112982",
"0.793633",
"0.79159844",
"0.7847753",
"0.7796208",
"0.747867",
"0.7287622",
"0.7264386",
"0.6871168",
"0.68711233",
"0.6831726",
"0.6791674",
"0.67786485",
"0.670429",
"0.66403764",
"0.6427672",
"0.63709843",
"0.62795717",
"0.61912197",
"0.6176887"... | 0.8009972 | 2 |
Driver Code: Do not edit under this line check_solution runs a single test case and prints whether it was successful or not. | def check_solution(test_number, array, expected)
actual = find_peaks(array)
if actual != expected
puts "Test ##{test_number}: Incorrect value: got #{actual}, expected #{expected}"
return false
end
puts "Test ##{test_number}: Correct"
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_tests\n check_solution(1, [6, 29, 18, 2, 72, 19, 18, 10, 37], 18, 2)\n check_solution(2, [6, 29, 18, 2, 72, 19, 18, 10, 37], 9, -1)\nend",
"def run_tests()\n check_solution(1, [1, 4, 10, 13, 15], true)\n check_solution(2, [1, 4, 10, 10, 13, 15], true)\n check_solution(3, [1, 2, 5, 3, 4 ], fals... | [
"0.806618",
"0.7950083",
"0.7950083",
"0.793218",
"0.7879944",
"0.7879944",
"0.7879944",
"0.772255",
"0.7392804",
"0.7374205",
"0.70244944",
"0.6986632",
"0.6914028",
"0.68971735",
"0.68762517",
"0.6875802",
"0.6841559",
"0.67115974",
"0.67115974",
"0.6693409",
"0.6675608",
... | 0.6446311 | 26 |
run_tests runs each of the test cases. | def run_tests()
check_solution(1, [1, 3, 5, 4], [5])
check_solution(2, [4, 2, 3, 6, 10], [4, 10])
check_solution(3, [4, 2, 11, 6, 10], [4, 11, 10])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_tests\n puts \"Running exactly #{@spec.size} tests.\"\n @spec.each do |test_case|\n sleep test_case.wait_before_request\n response = send_request_for(test_case)\n Checker.available_plugins.each do |plugin|\n result = @expectation.check(plugin, response, test_case)\n if no... | [
"0.78858274",
"0.7763636",
"0.754633",
"0.7431604",
"0.738298",
"0.7371646",
"0.7348436",
"0.7290566",
"0.72036654",
"0.71892005",
"0.71592253",
"0.7075362",
"0.7025014",
"0.69931746",
"0.6969139",
"0.69393474",
"0.6935906",
"0.6929577",
"0.69040996",
"0.6893316",
"0.6858604"... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_sponsor
@sponsor = Sponsor.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.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.532... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def sponsor_params
params.require(:sponsor).permit(WHITE_LIST)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121862",
"0.70524937",
"0.6947974",
"0.69016707",
"0.6735245",
"0.67157984",
"0.66887176",
"0.66779864",
"0.6660236",
"0.6554225",
"0.6527208",
"0.6456831",
"0.6451704",
"0.64509416",
"0.64478475",
"0.6432556",
"0.6411603",
"0.6411603",
"0.6389978",
"0.63789994",
"0.63789... | 0.5913775 | 91 |
generating the auth token for client side | def generate_auth_token!
loop do
@token = Devise.friendly_token
break unless Token.find_by(token: @token)
end
self.tokens.create token: @token
return @token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_auth_token\n\t token = SecureRandom.hex\n\t #self.update_columns(token_key: token)\n\t token\n\t end",
"def generate_auth_token\n self.auth_token = SecureRandom.hex\n end",
"def auth_token\n curtime = Time.now.utc.strftime '%Y%m%d%H' # yyyymmddhh. hh is 24 hour 0 padded\n t... | [
"0.78943586",
"0.77885026",
"0.7641267",
"0.76003546",
"0.7553071",
"0.754711",
"0.75204617",
"0.7478281",
"0.7461496",
"0.74439555",
"0.74287516",
"0.7346666",
"0.73398143",
"0.7280292",
"0.72559315",
"0.72404134",
"0.7232035",
"0.7222333",
"0.7207101",
"0.71731627",
"0.7149... | 0.67769927 | 90 |
checking the role doctor/patient | def is_doctor?
return role === 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_a_patient?\n ((!self.role.blank?) && (self.role == self.class::PATIENT))\n end",
"def can_view_patient?\n has_role?(:enroller) || has_role?(:public_health) || has_role?(:public_health_enroller)\n end",
"def check_user_role \t \n redirect_to root_path unless current_user.roles.first.nam... | [
"0.73798925",
"0.72749037",
"0.7115874",
"0.71140903",
"0.70247453",
"0.69113034",
"0.68682814",
"0.6827888",
"0.6805924",
"0.6748492",
"0.6748256",
"0.6709516",
"0.66798985",
"0.6678139",
"0.66763896",
"0.662238",
"0.6614849",
"0.6591085",
"0.6585738",
"0.6564991",
"0.655406... | 0.7836191 | 0 |
returns an array containing all of the prime factors of the given number. | def prime_factors(num)
#initialize an array
primeFacts = []
#iterate each number from 1 until num
(1..num).each do |nums|
#if the remainder is 0 and nums is prime push nums
if num % nums == 0 && prime?(nums)
primeFacts << nums
end
end
return primeFacts
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prime_factors(number)\n fs = []\n f1 = factor(number)\n return [number] if f1 == 1\n f2 = number/f1\n fs.concat(prime_factors(f1))\n fs.concat(prime_factors(f2))\n return fs\n end",
"def prime_factors num\n\tfactors = []\n\ttest_value = 2\n\twhile num > 1 do\n\t\twhile n... | [
"0.8588034",
"0.8510778",
"0.84617823",
"0.8366233",
"0.83277607",
"0.8324418",
"0.8311165",
"0.82642937",
"0.82628363",
"0.8238722",
"0.8197565",
"0.8197514",
"0.8184725",
"0.8180583",
"0.8174437",
"0.81742305",
"0.8163969",
"0.816201",
"0.8140834",
"0.81330085",
"0.8120917"... | 0.7984196 | 25 |
raise("i am your father") | def foo()
x = 0
p(x)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def boom\n raise \"boom\"\n end",
"def raise_exception \n puts 'I am before the raise.' \n raise 'An error has occuredzzzz' \n puts 'I am after the raise' \nend",
"def throw_stone(target)\n puts \"#{self.name} threw a stone ...\"\n end",
"def eat\n puts \"From Oreo\"\n super\n end",
"... | [
"0.69783854",
"0.67045474",
"0.6576902",
"0.65104073",
"0.64466995",
"0.6302684",
"0.62992865",
"0.62698835",
"0.62545544",
"0.62458843",
"0.6235188",
"0.61637884",
"0.6151502",
"0.61080456",
"0.61056024",
"0.60966533",
"0.6083689",
"0.6080852",
"0.6073416",
"0.6072069",
"0.6... | 0.0 | -1 |
Use the howamidoing API to check my statuses. | def update!
response = Tessellator::Fetcher.new.call('get', 'https://howamidoing-duckinator.herokuapp.com/status.json')
@@statuses = JSON.parse(response.body)['statuses']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status\n get('/api/status')\n end",
"def status\n debug { \"status\" }\n verify_response { Remote.get('/status', :api_key => api_key ) }\n end",
"def statuses\n api.get('status')\n end",
"def health_check\n JSON.parse(@client.get('status').body)\n end",
"def status\... | [
"0.7443052",
"0.7281684",
"0.71822345",
"0.7142388",
"0.7049071",
"0.701907",
"0.6930328",
"0.68886465",
"0.68495476",
"0.67571187",
"0.67354184",
"0.6717934",
"0.66937965",
"0.667498",
"0.66284347",
"0.6590132",
"0.65892065",
"0.65892065",
"0.6496307",
"0.64361817",
"0.64194... | 0.6621567 | 15 |
export ROOT node and its joints | def export_root(root)
file.puts "ROOT #{root.name}"
file.puts "{"
export_bone_data(root)
file.puts "}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export\n # takes nodes and edges.. and exports something nice\n p @nodes\n p @edges\n end",
"def export\n @tree\n end",
"def export_nodes\n existing_hiera = Dir.glob(Path.named_path([:hiera, '*'], @provider_dir))\n existing_files = Dir.g... | [
"0.6666101",
"0.63091",
"0.62355626",
"0.62269855",
"0.5932933",
"0.592974",
"0.59203005",
"0.59203005",
"0.59203005",
"0.59148574",
"0.5827964",
"0.57451355",
"0.5733973",
"0.5663462",
"0.5635875",
"0.5542074",
"0.55027556",
"0.5496808",
"0.5486659",
"0.5470829",
"0.54670197... | 0.70598763 | 0 |
export JOINT node, or End Site if joint has no joints level defines number of preceding tab stops | def export_joint(bone, level = 1)
tabs = "\t"*level
header = if bone.end_site? then "End Site"
else "JOINT #{bone.name}"
end
file.puts "#{tabs}#{header}"
file.puts "#{tabs}{"
export_bone_data(bone, level)
file.puts "#{tabs}}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export_bone_data(bone, level = 0)\n level += 1 # we're within a node, so it's one more tab than expected\n tabs = \"\\t\"*level\n file.puts \"#{tabs}OFFSET\\t #{bone.offset.collect { |i| \"%.6f\" % i }.join(\"\\t \")}\"\n if bone.channels.length > 0\n chans = bone.channels.join(\" \"... | [
"0.4818875",
"0.47453716",
"0.47453716",
"0.4723309",
"0.4723309",
"0.4723309",
"0.46753207",
"0.46347937",
"0.4615233",
"0.45838818",
"0.45762908",
"0.45442897",
"0.45292494",
"0.45197743",
"0.4472521",
"0.44693717",
"0.4464482",
"0.44642866",
"0.44588202",
"0.44154733",
"0.... | 0.67590225 | 0 |
exports bone data, regardless of type, including its joints level defines number of preceding tab stops | def export_bone_data(bone, level = 0)
level += 1 # we're within a node, so it's one more tab than expected
tabs = "\t"*level
file.puts "#{tabs}OFFSET\t #{bone.offset.collect { |i| "%.6f" % i }.join("\t ")}"
if bone.channels.length > 0
chans = bone.channels.join(" ")
file.puts("#{... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export_joint(bone, level = 1)\n tabs = \"\\t\"*level\n header = if bone.end_site? then \"End Site\"\n else \"JOINT #{bone.name}\" \n end\n file.puts \"#{tabs}#{header}\"\n file.puts \"#{tabs}{\"\n export_bone_data(bone, level)\n file.puts \"#{tabs}}\"\n end",
"def w... | [
"0.7474628",
"0.5275658",
"0.4912689",
"0.48649567",
"0.4812747",
"0.4781658",
"0.47321332",
"0.47208783",
"0.46865916",
"0.46580705",
"0.46391606",
"0.4615526",
"0.4610053",
"0.45823494",
"0.45666343",
"0.45595506",
"0.45552436",
"0.45248926",
"0.45089233",
"0.4483113",
"0.4... | 0.7850355 | 0 |
Potencia de 2 a la n1 | def square(numCuadro)
return 2 ** (numCuadro-1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def penjumlahan(nilai_1, nilai_2)\n p = nilai_2-nilai_1\n return p\n nilai_1 - nilai_2\n end",
"def s2(n)\n n*(n+1)*(2*n+1)/6\nend",
"def s1(n)\n (n*(n+1)/2)**2\nend",
"def penta(n)\n return n* (3*n - 1) / 2\nend",
"def cantor_pairing(n, m)\n (n + m) * (n + m + 1) / 2 + m\nend",
"def pote... | [
"0.695619",
"0.6748462",
"0.6555232",
"0.64777225",
"0.6339996",
"0.6270758",
"0.62267065",
"0.62115",
"0.6193784",
"0.6154938",
"0.6116385",
"0.60941625",
"0.6085671",
"0.60774577",
"0.6074624",
"0.60197955",
"0.5998052",
"0.5995193",
"0.59805787",
"0.59777105",
"0.59744626"... | 0.0 | -1 |
Get a single authorization = Examples nimbu = Nimbu.new :basic_auth => 'login:password' nimbu.oauth.get 'authorizationid' | def get(*args)
require_authentication
arguments(args, required: [:authorization_id])
get_request("/authorizations/#{authorization_id}", arguments.params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorization(id)\n get \"/authorizations/#{id}\"\n end",
"def o_auth_authorization\r\n OAuthAuthorizationController.instance\r\n end",
"def auth\r\n OAuth2\r\n end",
"def authorization_id\n @authorization_id ||= begin\n join = AuthJoin.by_user_object_id(:key =... | [
"0.7168983",
"0.6885949",
"0.6721162",
"0.65170413",
"0.6432089",
"0.63185066",
"0.6296645",
"0.6271675",
"0.62559766",
"0.62388",
"0.62306774",
"0.6191118",
"0.61119103",
"0.6076104",
"0.6075976",
"0.60505426",
"0.6047219",
"0.6047219",
"0.60468113",
"0.60433537",
"0.6037071... | 0.6865929 | 2 |
Create a new authorization = Inputs :scopes Optional array A list of scopes that this authorization is in. :note Optional string A note to remind you what the OAuth token is for. :note_url Optional string A URL to remind you what the OAuth token is for. = Examples nimbu = Nimbu.new :basic_auth => 'login:password' nimbu... | def create(*args)
require_authentication
arguments(args) do
sift(VALID_AUTH_PARAM_NAMES)
end
post_request("/authorizations", arguments.params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(*args)\n raise_authentication_error unless authenticated?\n arguments(args) do\n assert_required :note, :scopes\n end\n\n post_request('/authorizations', arguments.params)\n end",
"def create_from_oauth oauth\n create(\n email: oauth.email.downcase,\n ... | [
"0.6484318",
"0.6109779",
"0.5947511",
"0.594426",
"0.59108394",
"0.5823771",
"0.57923853",
"0.57258964",
"0.5691873",
"0.5650325",
"0.5606298",
"0.55653566",
"0.54972744",
"0.54767483",
"0.54718184",
"0.54467434",
"0.5426443",
"0.5406723",
"0.5406723",
"0.53417724",
"0.53259... | 0.5669979 | 9 |
Update an existing authorization = Inputs :scopes Optional array A list of scopes that this authorization is in. :add_scopes Optional array A list of scopes to add to this authorization. :remove_scopes Optional array A list of scopes to remove from this authorization. :note Optional string A note to remind you what the... | def update(*args)
require_authentication
arguments(args, required: [:authorization_id]) do
sift(VALID_AUTH_PARAM_NAMES)
end
patch_request("/authorizations/#{authorization_id}", arguments.params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorization_update(id, authorization_update_parameters, opts = {})\n data, _status_code, _headers = authorization_update_with_http_info(id, authorization_update_parameters, opts)\n data\n end",
"def update!(**args)\n @authorization = args[:authorization] if args.key?(:authorization)\n... | [
"0.6361243",
"0.61452943",
"0.61452943",
"0.597174",
"0.5820734",
"0.5749954",
"0.56585747",
"0.56538635",
"0.5602767",
"0.5602767",
"0.55723315",
"0.5515314",
"0.55080765",
"0.5473157",
"0.54628843",
"0.5430091",
"0.5430091",
"0.5427912",
"0.53904796",
"0.53669983",
"0.53055... | 0.64644843 | 0 |
Delete an authorization = Examples nimbu.oauth.delete 'authorizationid' | def delete(*args)
require_authentication
arguments(args, required: [:authorization_id])
delete_request("/authorizations/#{authorization_id}", arguments.params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_authorization(id)\n boolean_request :delete, \"/authorizations/#{id}\"\n end",
"def destroy\n @authorization = Authorization.find(params[:id])\n @authorization.destroy\n\n respond_to do |format|\n format.html { redirect_to authorizations_url }\n format.json { head :no_co... | [
"0.80913657",
"0.74780345",
"0.7179439",
"0.67997724",
"0.6712065",
"0.66998863",
"0.6620671",
"0.6542594",
"0.6473311",
"0.6451149",
"0.640935",
"0.63906884",
"0.63745487",
"0.6372935",
"0.6371973",
"0.632974",
"0.6328676",
"0.6323404",
"0.6285511",
"0.6281807",
"0.6278155",... | 0.78875315 | 1 |
GETTERS AND SETTERS SET Dancer | def fake_name=(name)
self.dancer_id = Dancer.find_or_create_by(fake_name: name).id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name\n return @name\nend\ndef age\n return @age\nend\n#setters, allows you to change or set something\ndef name=(name)\n @name = name\nend",
"def set_dan\n @dan = Dan.find(params[:id])\n end",
"def set; end",
"def set; end",
"def setting; end",
"def inject_acl_object_getter_setter(method_n... | [
"0.5946311",
"0.58574086",
"0.5734934",
"0.5734934",
"0.56821775",
"0.5591355",
"0.55532587",
"0.5543364",
"0.5507261",
"0.5501304",
"0.5486951",
"0.5483645",
"0.54664713",
"0.54455614",
"0.54414886",
"0.5411653",
"0.5363763",
"0.5363547",
"0.53560704",
"0.5350728",
"0.534900... | 0.0 | -1 |
show recipes title and image + ingredients and method | def show
url = URI("https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/information")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["x-rapi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @recipes = @ingredient.recipes.reorder(ingredient_order_by(\"recipes\")).paginate(page: params[:page], per_page: 2)\n @title = \"Recipes using: \" + @ingredient.name\n # goto render /views/ingredients/show.html.erb using /shared/_show_recipes using @recipes, @title\n end",
"def show\n @re... | [
"0.7408948",
"0.7402311",
"0.72470534",
"0.71823794",
"0.71556",
"0.6997625",
"0.697541",
"0.6975132",
"0.68664587",
"0.68664587",
"0.6827267",
"0.6749306",
"0.6728282",
"0.6678355",
"0.65969455",
"0.6596937",
"0.65958804",
"0.65813",
"0.65722734",
"0.6542623",
"0.65368503",
... | 0.6622506 | 14 |
add recipe to 'My Recipe' folder title and image | def add
url = URI("https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:recipe_id]}/information")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["x-rapidapi-key... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(name)\n @cookbook.add_recipe(name)\n end",
"def add_recipe(name)\n name = \"recipe[#{name}]\" unless name =~ /^recipe\\[(.+?)\\]$/\n run_list << name\n end",
"def recipe(name, description)\n @recipes[name] = description\n end",
"def add_recipe(name)\n ... | [
"0.65594053",
"0.6498705",
"0.6492207",
"0.6476314",
"0.6027405",
"0.60182697",
"0.59902257",
"0.596018",
"0.59532654",
"0.5889177",
"0.5877465",
"0.58617187",
"0.58617187",
"0.58587927",
"0.5817081",
"0.577082",
"0.577082",
"0.57484555",
"0.5745526",
"0.5731243",
"0.57163006... | 0.52383107 | 55 |
Quizas sea mejorar hacer el csv con los gtfs | def generate_routes
require 'csv'
include HTTParty
require 'json'
response = HTTParty.get('http://citppuc.cloudapp.net/api/lineas')
body = JSON.parse(response.body)
CSV.open('csv/aplicacion/routes.csv', 'w') do |csv|
body.each do |item|
puts "Agragando ruta: "+item["codigo_linea"]
csv << [item["codigo_lin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCsvText\r\n sep = \"|\"\r\n t = \"\"\r\n \r\n t << \"Question Number\" + sep \r\n questions.size.times do |i| \r\n t << (i + 1).to_s + sep \r\n end\r\n t << \"Points\"\r\n t << \"\\n\"\r\n \r\n t << \"Correct Answer\" + sep\r\n for question in questions \r\n t << correctAnswerText(questi... | [
"0.7193524",
"0.666373",
"0.6290883",
"0.62165135",
"0.6118436",
"0.6101675",
"0.60306215",
"0.598972",
"0.5920956",
"0.5883621",
"0.5871495",
"0.584582",
"0.5800031",
"0.57809997",
"0.57677346",
"0.57643616",
"0.57455117",
"0.5741651",
"0.5702671",
"0.56627893",
"0.56591827"... | 0.0 | -1 |
se necesita tener cargada la base de datos | def generate_route_shapes
require 'csv'
include HTTParty
require 'json'
response = HTTParty.get('http://citppuc.cloudapp.net/api/lineas')
body = JSON.parse(response.body)
CSV.open('csv/aplicacion/routeShapes.csv', 'w') do |csv|
body.each do |item|
json = nil
while json.nil?
response2 = HTTParty.get('h... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_balada\n @connection = ActiveRecord::Base.establish_connection\n sql = \"SELECT * FROM Balada INNER JOIN Cadastro ON Balada.idCadastro = Cadastro.idCadastro WHERE(Cadastro.idCadastro = #{params[:id]} && Cadastro.isActive = true);\"\n @balada = ActiveRecord::Base.connection.exec_query(sql)\n ... | [
"0.61412424",
"0.5959146",
"0.58455414",
"0.5775226",
"0.5745317",
"0.5694909",
"0.5657588",
"0.5657588",
"0.5604021",
"0.55857515",
"0.557849",
"0.55677044",
"0.55588824",
"0.5531855",
"0.5518507",
"0.5509684",
"0.55096066",
"0.5506463",
"0.54901016",
"0.5488496",
"0.5486119... | 0.0 | -1 |
Parse options, check arguments, then process the command | def run
if parsed_options? && arguments_valid?
puts "Start at #{Time.new.to_s}\n\n" if @options.verbose
output_options if @options.verbose # [Optional]
process_arguments
process_command
puts "\nFinished at #{Time.new.to_s}" if @options.verbose
else
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run\n if parsed_options? && arguments_valid? \n process_arguments \n process_command\n else\n output_options\n end\n end",
"def run\n if options_valid? && option_combinations_valid? \n process_arguments \n process_command\n else\n output_usa... | [
"0.8106814",
"0.80526197",
"0.80209607",
"0.7948825",
"0.77199274",
"0.75657964",
"0.7490003",
"0.7395482",
"0.73463374",
"0.73101896",
"0.73101896",
"0.73101896",
"0.73101896",
"0.73101896",
"0.73101896",
"0.7294806",
"0.72876114",
"0.7229941",
"0.72118735",
"0.72117335",
"0... | 0.70799404 | 25 |
Performs postparse processing on options | def process_options
@options.verbose = false if @options.quiet
@options.forceUpdate = true unless Time.parse(@options.since.to_s)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _process_options(options); end",
"def _process_options(options); end",
"def parse_options; end",
"def parse_options; end",
"def parse!() options.parse!(self) end",
"def process_options\n \n end",
"def process_options\n \n end",
"def process_options\n \n end",
"def proces... | [
"0.7552151",
"0.7552151",
"0.74326104",
"0.74326104",
"0.71797276",
"0.70810777",
"0.70810777",
"0.70810777",
"0.69738847",
"0.68673354",
"0.67721355",
"0.6761081",
"0.6709791",
"0.6709791",
"0.67004716",
"0.6654269",
"0.65885067",
"0.65824604",
"0.65355545",
"0.65026164",
"0... | 0.0 | -1 |
True if required arguments were provided | def arguments_valid?
# TO DO - implement some real logic here
true if @arguments.length == 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_missing_required_arg?\n !missing_required_arguments.empty?\n end",
"def includes_arguments?\n !default_data.empty? || !flags.empty? ||\n !required_args.empty? || !optional_args.empty? ||\n !remaining_arg.nil? || flags_before_args_enforced?\n end",
"def ar... | [
"0.85331726",
"0.8464038",
"0.819422",
"0.7929419",
"0.7853149",
"0.78399676",
"0.78301585",
"0.7824135",
"0.7803908",
"0.77834",
"0.77770644",
"0.77695304",
"0.7759738",
"0.7754239",
"0.7737054",
"0.77349025",
"0.7723665",
"0.76814485",
"0.76814485",
"0.765231",
"0.7631987",... | 0.78337026 | 6 |
The tests expect this to take in no arguments | def take_ride
# This happens if the user is both too short & ticketless to take the ride:
if self.user.tickets < self.attraction.tickets && self.user.height < self.attraction.min_height
# The rspec tests expect this output to be the return value:
"Sorry. You do not have enough tickets to ride the #... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tests=(_arg0); end",
"def tests=(_arg0); end",
"def test_nothing\n end",
"def should; super end",
"def __dummy_test__\n end",
"def spec; end",
"def spec; end",
"def test_nothing; end",
"def test_nothing\n end",
"def self_test; end",
"def self_test; end",
"def passed?; end",
"def ... | [
"0.69305265",
"0.69305265",
"0.66267973",
"0.66164845",
"0.6521277",
"0.6487694",
"0.6487694",
"0.6475037",
"0.64310324",
"0.64009327",
"0.64009327",
"0.6358231",
"0.6358231",
"0.6358231",
"0.6355523",
"0.6311199",
"0.628249",
"0.6217029",
"0.6217029",
"0.6217029",
"0.6217029... | 0.0 | -1 |
Wrapper function to call thrift APIs This will handle exceptions raised by thrift and make appropriate assert | def call_thrift(expected_error = nil, max_time = nil, &block)
if max_time && max_time > THRIFT_BLOCK_TIMEOUT && @comm_type != CommType::SERIAL
#Close existing connection
close
#Connect to device with maximum socket timeout
connect_to_device true, max_time
elsif !max_time
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_builds_thrift_object_chain_correctly\n test_message = TestMessage.new message: 'testing 123'\n\n client = Thrifter.build TestClient\n client.config.uri = uri\n\n socket, transport, protocol = stub, stub(open: nil, close: nil, open?: false), stub\n\n Thrift::Socket.expects(:new).\n with... | [
"0.5588099",
"0.55871236",
"0.5508453",
"0.5445049",
"0.5428579",
"0.5425485",
"0.5365559",
"0.53383535",
"0.5331072",
"0.5317298",
"0.5317298",
"0.5317298",
"0.5317298",
"0.53138757",
"0.5312426",
"0.5295534",
"0.5295043",
"0.5286504",
"0.52755183",
"0.5258338",
"0.524458",
... | 0.74109 | 0 |
Set serial net Id | def set_net_id(x)
$test_logger.log("Serial net Id change. New net Id '#{x}'")
begin
@transport.net_id = x
rescue Exception => e
$test_logger.log_e("Error while changing serial net Id to '#{x}'", e)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def net_id\n $test_logger.log(\"Get serial net Id\")\n begin\n n = @transport.net_id\n rescue Exception => e\n $test_logger.log_e(\"Error while getting current serial net Id\", e)\n end\n n\n end",
"def set_serial\n @serial = Serial.find(params[:id])\n end",
... | [
"0.71177274",
"0.6776036",
"0.67147744",
"0.67147744",
"0.6521435",
"0.6245139",
"0.6165119",
"0.5962866",
"0.58643",
"0.5752259",
"0.574715",
"0.5648597",
"0.5559891",
"0.5558018",
"0.55525726",
"0.55403125",
"0.5527827",
"0.5527827",
"0.5507461",
"0.54410934",
"0.5366069",
... | 0.8238615 | 0 |
Get serial net Id | def net_id
$test_logger.log("Get serial net Id")
begin
n = @transport.net_id
rescue Exception => e
$test_logger.log_e("Error while getting current serial net Id", e)
end
n
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serial\n fetch('device.serial')\n end",
"def serial_number\n return @serial_number\n end",
"def serial_number; Common.serial_number(@handle); end",
"def serial\n @cert.serial.to_i\n end",
"def serial\n @cert.serial.to_i\n end",
"def _get... | [
"0.7125634",
"0.69214123",
"0.69069225",
"0.6472727",
"0.6464544",
"0.64618886",
"0.64397734",
"0.63991153",
"0.6398237",
"0.63405526",
"0.6314749",
"0.6301457",
"0.6271253",
"0.6266528",
"0.625954",
"0.6252791",
"0.6243085",
"0.6226615",
"0.61698025",
"0.615604",
"0.61013675... | 0.92678523 | 0 |
Ensure device is up and running Sync communication channel for responses receive all pending response packets for last run verify device is up and running | def ensure_device_status
$test_logger.log("Inside ensure_device_status for Thrift Protocol")
max_retry = 5
retry_count = 0
@is_reconnected = false
begin
begin
#Increment current retry
retry_count += 1
$test_logger.log("Ensure device status for MA1000... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push_notify_ready\n droid_destinations = patient.devices.map do |device|\n device.token if device.platform == 'android' && device.enabled\n end\n data = {:type => \"READY\", :message =>\n \"Your appointment with #{clinic.name} at #{delayed_date_time_ampm} is ready\" }\n Thread.new do\n ... | [
"0.5979307",
"0.57957906",
"0.5789853",
"0.5749463",
"0.5739915",
"0.5674054",
"0.56697553",
"0.56649745",
"0.56602156",
"0.56493455",
"0.56355304",
"0.5593923",
"0.55621684",
"0.55621684",
"0.55604815",
"0.5557217",
"0.5557217",
"0.55353093",
"0.5533791",
"0.5521259",
"0.552... | 0.6491712 | 0 |
Check device responds or not with immediate command | def ping(response_timeout=2)
#Initialize ping result as false
ping_ok = false
begin
#Ping data
ping_data = "\x4\x1\x8"
$test_logger.log "Ping with #{Common.unpackbytes(ping_data)}"
#Ping and check terminal status
ping_res = call_thrift(nil, response_timeout){t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_devices\n\n\n end",
"def check ()\n\t return \"OK\" if @simulate\n\t return \"IES\" unless @sock\n\t @sock.readline().chomp\n\tend",
"def check_devices\n\traise \"No connected device was found.\" if no_device?\nend",
"def battery_connected?\n $ioreg_return.split(' = ')[4].strip.split(\... | [
"0.63051665",
"0.6114076",
"0.60973835",
"0.5977758",
"0.57710373",
"0.5718388",
"0.571241",
"0.5695596",
"0.5678905",
"0.5656221",
"0.5654299",
"0.5621602",
"0.56143284",
"0.55891836",
"0.55834025",
"0.558011",
"0.5575752",
"0.5573915",
"0.55554867",
"0.55518323",
"0.5548235... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_conference
@conference = Conference.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.6163443",
"0.604317",
"0.5943409",
"0.59143174",
"0.5887026",
"0.58335453",
"0.57738566",
"0.5701527",
"0.5701527",
"0.56534666",
"0.5618685",
"0.54237175",
"0.5407991",
"0.5407991",
"0.5407991",
"0.5394463",
"0.5376582",
"0.5355932",
"0.53376216",
"0.5337122",
"0.5329516"... | 0.0 | -1 |
Safely delete a document. If the document is in the trash, it will not be deleted. | def delete
reload!
if path.start_with?("/#{@client.account.name}/Trash")
raise Springcm::DeleteRefusedError.new(path)
end
unsafe_delete
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(document)\n delete_path(document.path)\n end",
"def destroy(document)\n document.destroy\n end",
"def delete_document(document_id)\n doc = @user.get_document_by_id(document_id)\n if !doc.nil?\n doc.purge\n else\n raise ::Rbt::User::Document::Error::No... | [
"0.7147735",
"0.7068843",
"0.69635385",
"0.688712",
"0.68173784",
"0.6785152",
"0.67675096",
"0.6752326",
"0.67478323",
"0.66937065",
"0.66835797",
"0.66551054",
"0.66064733",
"0.65879166",
"0.6569766",
"0.65684444",
"0.65671855",
"0.6543082",
"0.65391296",
"0.6533204",
"0.65... | 0.6391342 | 27 |
Problem: Write a program to convert a Binary Tree into its Mirror Tree A mirror of a Binary Tree T is another Binary Tree M(T) with left and right children of all nonleaf nodes interchanged. Example: 1 / \ 2 3 / \ / 4 5 6 / 8 becomes 1 / \ 3 2 \ / \ 6 5 4 \ 8 | def convert_binary_tree_to_mirror(root)
return if !root
temp_node = Node.new()
# recursively call the method on both left and right subtrees
convert_binary_tree_to_mirror(root.left_child)
convert_binary_tree_to_mirror(root.right_child)
# swap the left and right subtrees
temp_node = root.left_child
root... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_to_mirror(node)\n return if node.nil?\n\n # We will do a post-order traversal of the binary tree.\n convert_to_mirror(node.left) unless node.left.nil?\n convert_to_mirror(node.right) unless node.right.nil?\n\n # Let's swap the left and right nodes at current level.\n temp = node.left\n node.left... | [
"0.80927885",
"0.75067985",
"0.72769535",
"0.723096",
"0.71621954",
"0.71404827",
"0.7109963",
"0.7071516",
"0.70363605",
"0.70270246",
"0.69915503",
"0.69593984",
"0.691372",
"0.6886429",
"0.6849989",
"0.683885",
"0.6813309",
"0.67026204",
"0.66086096",
"0.63911396",
"0.6285... | 0.8285886 | 0 |
def city session[:city] end | def parse_path(path)
path_hash = Rails.application.routes.recognize_path(path)
return path_hash[:controller], path_hash[:action]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n session[:city] = params[:city]\n end",
"def store_city(city_id = 0, city_name = \"\")\n session[:city_id] = city_id\n session[:city_name] = city_name\n end",
"def city\n @city\n end",
"def current_city\n if session[:city_id] && session[:city_id] != 0\n return City.find(ses... | [
"0.80449027",
"0.79660475",
"0.7642453",
"0.76332676",
"0.7453654",
"0.7453654",
"0.7452487",
"0.7452487",
"0.7452487",
"0.7452487",
"0.7328224",
"0.7290737",
"0.71777385",
"0.7172398",
"0.713639",
"0.70620304",
"0.70503074",
"0.70047027",
"0.69886696",
"0.6963546",
"0.686883... | 0.0 | -1 |
each_with_index is similar, but allows us to call a block with two arguments, the item and its index. | def my_each_with_index
i = 0
while i < self.size
yield(self[i], i)
i += 1
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_with_index(&block)\n to_a.each_with_index(&block)\n end",
"def each_with_index(&block)\n to_a.each_with_index(&block)\n end",
"def each_index\n @block_args.each_index do |i|\n yield i\n end\n end",
"def each_with_index(&blk)\n (0..@size-1).eac... | [
"0.8370783",
"0.8370783",
"0.7963594",
"0.7898421",
"0.7797964",
"0.77867794",
"0.77844155",
"0.7693263",
"0.76853746",
"0.7655174",
"0.7630191",
"0.7618271",
"0.7570295",
"0.75265527",
"0.7499275",
"0.74961275",
"0.74951094",
"0.74407744",
"0.7416381",
"0.74067515",
"0.73911... | 0.74570256 | 17 |
select builds an array from the elements that return true after passing through the given block. | def my_select
new_arr = []
self.my_each do |ele|
new_arr << ele if yield ele
end
new_arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select(array)\n final_selections = []\n\n for elem in array do\n result = yield(elem)\n final_selections << elem if result\n end\n \n final_selections\nend",
"def my_select(&block)\n result = []\n my_each do |elem|\n result << elem if block.call(elem) == true\n end\n result\n end... | [
"0.7694446",
"0.75804764",
"0.73668635",
"0.72974545",
"0.72797686",
"0.7251652",
"0.71550035",
"0.71184725",
"0.7094323",
"0.70828456",
"0.70808905",
"0.7064556",
"0.70150447",
"0.7008238",
"0.69339204",
"0.69274825",
"0.69076717",
"0.69076514",
"0.6811462",
"0.6798323",
"0.... | 0.6807924 | 19 |
all? returns true unless a pass through the block returns false. If no block is given, it returns true when none of the items are false or nil. | def my_all?
return unless block_given?
self.my_each do |ele|
if not yield ele then return false
end
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_all?\n if block_given?\n self.my_each{|item| return false if yield(item) == false }\n # return true unless one is false\n true\n else\n # if no block given return true\n true\n end\n end",
"def my_all?\n all = true\n self.my_each do |x|\n if !block_given?\n ... | [
"0.8574552",
"0.8110024",
"0.805208",
"0.8050583",
"0.7896583",
"0.78290737",
"0.7771298",
"0.77599704",
"0.7721769",
"0.7721769",
"0.7702907",
"0.7661981",
"0.7657061",
"0.7649931",
"0.7646025",
"0.76383245",
"0.7574705",
"0.7542945",
"0.7463236",
"0.7463031",
"0.7414027",
... | 0.7890444 | 5 |
any? is almost identical to all? except it returns true if ANY iteration returns true. | def my_any?
return unless block_given?
self.my_each do |ele|
if yield ele then return true
end
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_any?(&prc)\n self.my_each { |el| return true if prc.call(el) }\n false\n end",
"def my_any?(&prc)\n\t\tself.my_each do |ele|\n\t\t\treturn true if prc.call(ele)\n\t\tend\n\t\tfalse\n\tend",
"def any?(arr)\n arr.each { |el| return true if yield(el) }\n false\nend",
"def any?(arr)\n ... | [
"0.8106471",
"0.80745924",
"0.80613923",
"0.80613923",
"0.8049476",
"0.80020976",
"0.7962728",
"0.7939115",
"0.79304105",
"0.7907924",
"0.7864137",
"0.7756335",
"0.7751252",
"0.77419263",
"0.770319",
"0.770319",
"0.763113",
"0.76168287",
"0.75857157",
"0.75854176",
"0.7564114... | 0.72479945 | 33 |
none? is very similar as well, but it only returns true if every pass through the block returns false. | def my_none?
return unless block_given?
self.my_each do |ele|
if yield ele then return false
end
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_none?(&block)\n return true unless block_given?\n\n # Exit with false as early as possible.\n my_each { |*args| return false if block.call(*args) }\n\n true\n end",
"def my_none?\n self.my_each {|x| return false if yield(x) == true}\n true\n end",
"def my_none?\n if block_given?\n... | [
"0.88188434",
"0.86560583",
"0.8627934",
"0.8609141",
"0.85694754",
"0.85151863",
"0.8300744",
"0.8279812",
"0.82694656",
"0.8217775",
"0.81089777",
"0.8087005",
"0.8001538",
"0.80003923",
"0.7990696",
"0.7961563",
"0.7810096",
"0.7774185",
"0.7769836",
"0.7754092",
"0.770935... | 0.84945303 | 6 |
count takes an optional block or parameter and adds up all the elements in a collection. If a block is passed, count will only count the iterations that return true. If an argument is passed, count will only add the elements that match it. Otherwise it just counts the total elements. | def my_count(a = nil)
total = 0
if block_given?
self.my_each do |ele|
total += 1 if yield ele
end
elsif a
self.my_each do |ele|
if ele == a
total += 1
end
end
else
self.my_each do |ele|
total += 1
end
end
total
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count(collection)\n block_rtn_true_count = 0\n\n for element in collection\n block_rtn_true_count += 1 if yield element\n end\n\n block_rtn_true_count\nend",
"def count(collection)\n block_rtn_true_count = 0\n\n collection.each { |element| block_rtn_true_count += 1 if yield element }\n block_rtn_tr... | [
"0.8143692",
"0.81151533",
"0.77053124",
"0.76851726",
"0.7666171",
"0.7604255",
"0.74109226",
"0.73296237",
"0.7237088",
"0.71473366",
"0.71237314",
"0.70660144",
"0.70504916",
"0.69995594",
"0.6994115",
"0.6967571",
"0.6953738",
"0.69304806",
"0.69295764",
"0.69150966",
"0.... | 0.707925 | 11 |
map builds an array with the results of each iteration through the block. It can also perform the same task using a proc. If given neither a proc nor a block, it returns an enumerator. | def my_map(proc = nil)
new_arr = []
if proc
self.my_each do |ele|
new_arr << proc.call(ele)
end
elsif block_given?
self.my_each do |ele|
new_ele = yield ele
new_arr << new_ele
end
else
new_arr = self.to_enum
end
new_arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_map(proc = nil, &block)\n\t\tarray = []\n\t\tif proc != nil && proc.is_a?(Proc)\n\t\t\tself.my_each do |x|\n\t\t\t\tarray << proc.call(x)\n\t\t\tend\n\t\telsif block_given?\n\t\t\tself.my_each do|x|\n\t\t\t\tarray << yield(x)\n\t\t\tend\n\t\tend\n\t\treturn array\n\tend",
"def my_map_proc_block(my_proc = ... | [
"0.7759144",
"0.77291334",
"0.7714471",
"0.76287985",
"0.76219153",
"0.7617219",
"0.7566321",
"0.75620794",
"0.7537429",
"0.7529642",
"0.7512903",
"0.7512903",
"0.746068",
"0.74396384",
"0.74388",
"0.7418745",
"0.7400467",
"0.73703164",
"0.7352075",
"0.7341779",
"0.7326536",
... | 0.69249016 | 41 |
inject combines all the elements of a collection with a binary operation, using a block and an optional argument for its initial value. If no initial value is given, inject will use the first element of the collection. | def my_inject(*args)
if args
memo = args[0]
s = 0
else
memo = self[0]
s = 1
end
self[s..self.length].my_each do |ele|
memo = yield(memo,ele)
end
memo
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_inject(initial_value = nil, &block)\n raise StandardError('no block given') unless block_given?\n\n accumulator = initial_value\n\n my_each do |*args|\n if accumulator.nil\n accumulator = first\n next\n end\n accumulator = block.call(accumulator, *args)\n end\n\n ... | [
"0.72934014",
"0.72811675",
"0.7081783",
"0.6978426",
"0.6967443",
"0.6952557",
"0.68219906",
"0.68073463",
"0.6759752",
"0.67558914",
"0.671617",
"0.6681216",
"0.66329587",
"0.6622999",
"0.65566903",
"0.65347815",
"0.65188944",
"0.6518489",
"0.65086544",
"0.6489794",
"0.6477... | 0.6738684 | 10 |
and then returns the result of concatenating the shorter string, the longer string, and the shorter string once again. | def short_long_short(str1, str2)
if str1.size < str2.size
str1 + str2 + str1
else
str2 + str1 + str2
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def short_long_short(str1, str2)\nnew_str = ''\nstr1.length < str2.length ? new_str + str1 + str2 + str1 : new_str + str2 + str1 + str2\nend",
"def short_long_short(string1, string2)\n newstring = \"\"\n if string1.length > string2.length\n newstring = string2.concat(string1, string2)\n else\n newstring... | [
"0.78252536",
"0.78179586",
"0.7770671",
"0.7748341",
"0.7728986",
"0.77173644",
"0.7701019",
"0.768097",
"0.7646978",
"0.76335406",
"0.76320934",
"0.7628606",
"0.7628606",
"0.761394",
"0.7605015",
"0.76038456",
"0.75971806",
"0.7567294",
"0.75668955",
"0.75187457",
"0.750888... | 0.7495205 | 24 |
This was unnecessary; trying to account for duplicates Don't need to. Refer to specs def correct_colors correct = 0 | def correct_positions
counter = 0
combined = guess.zip(secret_code)
combined.select do |code, turn|
if code == turn
counter += 1
end
end
counter
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_correct_colors\n colors_by_difficulty.each do |color|\n if @code_guess.count(color) < @secret_code.count(color)\n @white_peg += @code_guess.count(color)\n else\n @white_peg += @secret_code.count(color)\n end\n end\n end",
"def add_correct_colors(temp_guess, temp_code... | [
"0.76916325",
"0.7528237",
"0.73192465",
"0.7229954",
"0.717698",
"0.7139549",
"0.70473474",
"0.6985711",
"0.69310576",
"0.6774844",
"0.6673125",
"0.66461",
"0.65248597",
"0.6505883",
"0.64884454",
"0.64162254",
"0.64092463",
"0.63649726",
"0.6292175",
"0.6281038",
"0.6280269... | 0.0 | -1 |
GET /trainings GET /trainings.json | def publish
@training = Training.find(params[:id])
@training.publish
respond_to do |format|
format.html { redirect_to @training, notice: 'Training was successfully published.' }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trainings\n render json: @plan.trainings\n end",
"def show\n @training = trainings.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @training }\n end\n end",
"def all\n url = url_for(\"organizers\", credentials.... | [
"0.79527164",
"0.7483754",
"0.7443308",
"0.7246551",
"0.7246551",
"0.7246551",
"0.6909961",
"0.683408",
"0.6791949",
"0.67264205",
"0.6718133",
"0.6682787",
"0.65627974",
"0.65575814",
"0.65575814",
"0.65575814",
"0.6535238",
"0.65161145",
"0.644478",
"0.63918084",
"0.6314592... | 0.0 | -1 |
GET /trainings/1 GET /trainings/1.json | def show
@training = Training.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @training }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @training = trainings.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @training }\n end\n end",
"def trainings\n render json: @plan.trainings\n end",
"def index\n @trainings = Training.all\n end",
"def inde... | [
"0.7626834",
"0.7446954",
"0.7113045",
"0.7113045",
"0.7113045",
"0.6905254",
"0.6831284",
"0.6798103",
"0.67097205",
"0.65186435",
"0.65186435",
"0.65186435",
"0.6505371",
"0.64892113",
"0.64836603",
"0.64687425",
"0.6448636",
"0.6407635",
"0.6387985",
"0.6368642",
"0.628195... | 0.680606 | 7 |
GET /trainings/new GET /trainings/new.json | def new
@training = Training.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @training }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @training = current_user.trainings.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @training }\n end\n end",
"def create\n @training = Training.new(params[:training])\n\n respond_to do |format|\n if @training.save\n format... | [
"0.7253821",
"0.69338214",
"0.6838206",
"0.6825611",
"0.6797989",
"0.67664593",
"0.67664593",
"0.67664593",
"0.6736809",
"0.6708734",
"0.6680256",
"0.66675735",
"0.6648418",
"0.6628102",
"0.66112834",
"0.65612966",
"0.6522654",
"0.6503299",
"0.6479375",
"0.6477995",
"0.647613... | 0.73694485 | 0 |
FIXME training report on editing GET /trainings/1/edit | def edit
@training = Training.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_training\n @training = Training.find(params[:id])\n end",
"def set_training\r\n @training = Training.find(params[:id])\r\n end",
"def update\n @training = trainings.find(params[:id])\n\n respond_to do |format|\n if @training.update_attributes(params[training_param])\n form... | [
"0.6971405",
"0.69695324",
"0.6960404",
"0.6946256",
"0.6942428",
"0.6942428",
"0.6942428",
"0.6942428",
"0.6942428",
"0.6942428",
"0.6942428",
"0.6937959",
"0.68526417",
"0.68526417",
"0.68526417",
"0.6846626",
"0.67866725",
"0.6729881",
"0.6707269",
"0.66698855",
"0.6638607... | 0.7353937 | 0 |
POST /trainings POST /trainings.json | def create
@training = Training.new(params[:training])
respond_to do |format|
if @training.save
format.html { redirect_to @training, notice: 'Training was successfully created.' }
format.json { render json: @training, status: :created, location: @training }
else
format.html ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trainings\n render json: @plan.trainings\n end",
"def create\n @training = @runner.trainings.new(training_params)\n @training.time = set_time(training_params) #calculate the total amount of seconds with hours, minutes and seconds\n respond_to do |format|\n if @training.save\n ... | [
"0.6850966",
"0.66812235",
"0.66684455",
"0.66571224",
"0.66571224",
"0.66571224",
"0.66098136",
"0.66012704",
"0.6587163",
"0.6579643",
"0.6571401",
"0.649504",
"0.64638346",
"0.63992864",
"0.6392737",
"0.6377953",
"0.6356972",
"0.625761",
"0.62222886",
"0.62222886",
"0.6222... | 0.6690802 | 1 |
PUT /trainings/1 PUT /trainings/1.json | def update
@training = Training.find(params[:id])
respond_to do |format|
if @training.update_attributes(params[:training])
format.html { redirect_to @training, notice: 'Training was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @training = trainings.find(params[:id])\n\n respond_to do |format|\n if @training.update_attributes(params[training_param])\n format.html { redirect_to @training, notice: 'Training was successfully updated.' }\n format.json { head :no_content }\n else\n format.html... | [
"0.6905972",
"0.6819948",
"0.6721533",
"0.6453292",
"0.6453292",
"0.6453292",
"0.6453292",
"0.6453292",
"0.6453292",
"0.6453292",
"0.6404468",
"0.63835585",
"0.63700855",
"0.63522553",
"0.63445795",
"0.63445795",
"0.63445795",
"0.63445795",
"0.62917805",
"0.62753904",
"0.6244... | 0.65124315 | 3 |
DELETE /trainings/1 DELETE /trainings/1.json | def destroy
@training = Training.find(params[:id])
@training.destroy
respond_to do |format|
format.html { redirect_to trainings_path }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @train.destroy\n respond_to do |format|\n format.html { redirect_to trains_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @training = current_user.trainings.find(params[:id])\n @training.destroy\n\n respond_to do |format|\n format.html { redi... | [
"0.7659412",
"0.74005234",
"0.73722523",
"0.7308671",
"0.7271932",
"0.7271932",
"0.7271932",
"0.7271932",
"0.7266162",
"0.7169712",
"0.7148757",
"0.711883",
"0.7114612",
"0.7111165",
"0.7097358",
"0.70902836",
"0.7074824",
"0.69814694",
"0.6932554",
"0.6929258",
"0.6929258",
... | 0.76065654 | 1 |
GET /kopies/1 GET /kopies/1.xml | def show
@kopy = Kopy.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @kopy }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @kpis = Kpi.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @kpis }\n end\n end",
"def show\n @kingdom = Kingdom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :x... | [
"0.6211726",
"0.5854002",
"0.5849522",
"0.58057904",
"0.574202",
"0.573891",
"0.5731724",
"0.56965923",
"0.56076044",
"0.55954486",
"0.558007",
"0.55646443",
"0.5550862",
"0.5550366",
"0.5545802",
"0.55250776",
"0.5517818",
"0.5506607",
"0.54917145",
"0.54873127",
"0.54733557... | 0.6269608 | 0 |
GET /kopies/new GET /kopies/new.xml | def new
@kopy = Kopy.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @kopy }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @kingdom = Kingdom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @kingdom }\n end\n end",
"def new\n @kontakty = Kontakty.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @kontakty... | [
"0.6616404",
"0.6397797",
"0.6336229",
"0.6315931",
"0.6291268",
"0.6280122",
"0.6260957",
"0.62589",
"0.61746645",
"0.6165621",
"0.6109849",
"0.6090919",
"0.6072196",
"0.6069459",
"0.60558563",
"0.6054181",
"0.6051213",
"0.601728",
"0.6008745",
"0.5995297",
"0.59906083",
"... | 0.66060317 | 1 |
POST /kopies POST /kopies.xml | def create
@kopy = Kopy.new(params[:kopy])
respond_to do |format|
if @kopy.save
format.html { redirect_to(@kopy, :notice => 'Kopy was successfully created.') }
format.xml { render :xml => @kopy, :status => :created, :location => @kopy }
else
format.html { render :action => ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @kingdom = Kingdom.new(params[:kingdom])\n\n respond_to do |format|\n if @kingdom.save\n flash[:notice] = 'Kingdom was successfully created.'\n format.html { redirect_to(@kingdom) }\n format.xml { render :xml => @kingdom, :status => :created, :location => @kingdom }\n ... | [
"0.5667148",
"0.5393722",
"0.5362845",
"0.5357881",
"0.5324781",
"0.51871973",
"0.5124678",
"0.5117287",
"0.5108669",
"0.51023644",
"0.50769085",
"0.5068877",
"0.50676996",
"0.5045867",
"0.5014112",
"0.50012016",
"0.49844006",
"0.49826595",
"0.4976504",
"0.49762693",
"0.49701... | 0.5556606 | 1 |
PUT /kopies/1 PUT /kopies/1.xml | def update
@kopy = Kopy.find(params[:id])
respond_to do |format|
if @kopy.update_attributes(params[:kopy])
format.html { redirect_to(@kopy, :notice => 'Kopy was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def put!\n request! :put\n end",
"def update\n @onske = Onske.find(params[:id])\n\n respond_to do |format|\n if @onske.update_attributes(params[:onske])\n ... | [
"0.59903306",
"0.5877223",
"0.5709052",
"0.5692221",
"0.56879526",
"0.5660963",
"0.55663013",
"0.55162984",
"0.5501693",
"0.5460586",
"0.54184675",
"0.54178447",
"0.5417151",
"0.5405263",
"0.53989655",
"0.53884846",
"0.53838986",
"0.53716844",
"0.5370442",
"0.5370442",
"0.537... | 0.5649241 | 6 |
DELETE /kopies/1 DELETE /kopies/1.xml | def destroy
@kopy = Kopy.find(params[:id])
@kopy.destroy
respond_to do |format|
format.html { redirect_to(kopies_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @kontak = Kontak.find(params[:id])\n... | [
"0.6608149",
"0.6468206",
"0.6420043",
"0.64063257",
"0.6376162",
"0.63630915",
"0.63440925",
"0.6294796",
"0.6231471",
"0.6220693",
"0.621785",
"0.62122965",
"0.62059593",
"0.61441916",
"0.6132923",
"0.6127828",
"0.61079",
"0.6082123",
"0.6054385",
"0.60522306",
"0.6047659",... | 0.6896353 | 0 |
Handles module dependency inclusion injects class + instance mixins | def instance_helper
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inject_dependencies\n add_to_load_path\n add_to_dependency_load_paths\n add_to_dependency_load_once_paths\n add_to_mixable_app_types\n end",
"def auto_include!\n mixins = @@class_mixins[name]\n send(:include, *mixins) if mixins\n end",
"def included(klass); end",
"def included(klass);... | [
"0.65348643",
"0.64707553",
"0.6368718",
"0.6368718",
"0.632069",
"0.6281769",
"0.6240357",
"0.6196527",
"0.6118891",
"0.61031145",
"0.60518205",
"0.59845346",
"0.5916539",
"0.5899948",
"0.58714366",
"0.58487093",
"0.58379364",
"0.5834233",
"0.5824499",
"0.5823783",
"0.581730... | 0.0 | -1 |
string The String that will be changed chr1 The String that will be changed chr2 The String that will replace chr1 Examples replace("apa", "a", "b") => "bpb" Returns the changed string | def replace_chr(string, chr1, chr2)
i = 0
output = ""
while i <= string.length-1
if string[i] == chr1
output += chr2
else
output += string[i]
end
i += 1
end
return output
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace(string, chr, replace)\n i = 0\n output = \"\"\n while i < string.length\n if string[i..i+chr.length-1] != chr\n output += string[i]\n i += 1\n else \n output += replace\n i += chr.length\n end\n \n end\n return outpu... | [
"0.75951236",
"0.71455204",
"0.7068899",
"0.6766278",
"0.6744792",
"0.66670895",
"0.66421443",
"0.6604494",
"0.6588017",
"0.6452092",
"0.63889796",
"0.6361755",
"0.63306403",
"0.6316633",
"0.6261651",
"0.61961126",
"0.61755913",
"0.6149837",
"0.6147552",
"0.61407006",
"0.6121... | 0.83280295 | 0 |
GET /addresses GET /addresses.xml | def index
@addresses = Address.paginate :page => params[:page], :order => 'street ASC'
#@addresses = Address.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @addresses }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addresses\n IbmCloudRest.get \"#{@uri}/addresses\"\n end",
"def show_addresses(**params)\n get('addresses', params)\n end",
"def addresses\n message = { nodes: { item: resource[:name]}}\n transport[wsdl].get(:get_address, message)\n end",
"def addresses\n @client.request('... | [
"0.7571819",
"0.7477239",
"0.7431259",
"0.7139603",
"0.6884371",
"0.68622106",
"0.68120635",
"0.6706471",
"0.6632585",
"0.6565645",
"0.6511091",
"0.65040886",
"0.64928603",
"0.6456904",
"0.64316213",
"0.64316213",
"0.6422068",
"0.6365905",
"0.6333263",
"0.6322218",
"0.6303991... | 0.66031444 | 9 |
GET /addresses/1 GET /addresses/1.xml | def show
# @address = Address.find(params[:id])
@address = Address.find_by_permalink!(params[:id])
@address.revert_to(params[:version].to_i) if params[:version]
add_crumb @address.usable, @address
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_addresses(**params)\n get('addresses', params)\n end",
"def addresses\n message = { nodes: { item: resource[:name]}}\n transport[wsdl].get(:get_address, message)\n end",
"def addresses\n IbmCloudRest.get \"#{@uri}/addresses\"\n end",
"def show\n @address = Address.find(... | [
"0.7066064",
"0.6982572",
"0.6770775",
"0.6680347",
"0.6662985",
"0.6594181",
"0.6582757",
"0.653146",
"0.6475902",
"0.6430858",
"0.64247674",
"0.6399826",
"0.6387671",
"0.6295195",
"0.6279735",
"0.62245613",
"0.61991477",
"0.61704475",
"0.6158836",
"0.6158836",
"0.61514115",... | 0.0 | -1 |
GET /addresses/new GET /addresses/new.xml | def new
@address = Address.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @address }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @person = Person.new\n @person.build_address\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end",
"def getnewaddress(account = nil)\n request :getnewaddress, account\n end",
"def new\n @address = Address.new\n ... | [
"0.717899",
"0.7095456",
"0.70670414",
"0.7026539",
"0.70089644",
"0.6992892",
"0.6992892",
"0.6992892",
"0.6983144",
"0.69636035",
"0.69594973",
"0.6927672",
"0.6920977",
"0.6804424",
"0.676635",
"0.6744469",
"0.66110724",
"0.6584639",
"0.65749645",
"0.6527539",
"0.6523074",... | 0.75114495 | 0 |
POST /addresses POST /addresses.xml | def create
@address = Address.new(params[:address])
# respond_to do |format|
# if @address.save
# flash[:notice] = 'Address was successfully created.'
# format.html { redirect_to(@address) }
# format.xml { render :xml => @address, :status => :created, :location ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postEntityInvoice_address( entity_id, building_number, address1, address2, address3, district, town, county, province, postcode, address_type)\n params = Hash.new\n params['entity_id'] = entity_id\n params['building_number'] = building_number\n params['address1'] = address1\n params['address2'] ... | [
"0.63133126",
"0.6245878",
"0.6052534",
"0.6019263",
"0.6011892",
"0.59587616",
"0.5947923",
"0.5946224",
"0.59116155",
"0.58955467",
"0.5892327",
"0.58668125",
"0.58668125",
"0.584377",
"0.5821601",
"0.5809709",
"0.5808692",
"0.5793103",
"0.57861",
"0.57417023",
"0.5723957",... | 0.0 | -1 |
PUT /addresses/1 PUT /addresses/1.xml | def update
# @address = Address.find(params[:id])
@address = Address.find_by_permalink!(params[:id])
respond_to do |format|
if @address.update_attributes(params[:address])
flash[:notice] = 'Address was successfully updated.'
format.html { redirect_to(@address) }
f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def upd... | [
"0.6684501",
"0.6556205",
"0.6184579",
"0.6164678",
"0.6144232",
"0.6101555",
"0.5943634",
"0.5937891",
"0.5937891",
"0.5937891",
"0.5937891",
"0.59374124",
"0.58989286",
"0.58533496",
"0.58243877",
"0.58188003",
"0.57991415",
"0.57880116",
"0.5755004",
"0.57399064",
"0.57362... | 0.5700978 | 23 |
DELETE /addresses/1 DELETE /addresses/1.xml | def destroy
# @address = Address.find(params[:id])
@address = Address.find_by_permalink!(params[:id])
@address.destroy
respond_to do |format|
format.html { redirect_to(addresses_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @address = Address.find(params[:id])\n @address.destroy\n\n respond_to do |format|\n format.html { redirect_to(:action=>'index') }\n format.xml { head :ok }\n end\n end",
"def delete_address(id)\n delete(\"addresses/#{id}\")\n end",
"def delete\n @addresses ... | [
"0.6978777",
"0.68631554",
"0.6810547",
"0.6798137",
"0.67845625",
"0.6684369",
"0.665323",
"0.6607683",
"0.65785193",
"0.65785193",
"0.65785193",
"0.65785193",
"0.65563875",
"0.653047",
"0.64765644",
"0.64735824",
"0.6441446",
"0.6401678",
"0.63979816",
"0.6392529",
"0.63872... | 0.6934415 | 1 |
Detect Rack::Testlast_response vs ActionDispatch::TestCaseresponse | def last_response
defined?(super) ? super : response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_success_scenario\n assert last_response.ok?\n end",
"def check_error_response(last_response)\n refute_match 'Sinatra doesn’t know this ditty', last_response.body, \"unmatched url\"\n end",
"def test_should_be_json_response\n get '/mock/example'\n assert_equal last_response.content_... | [
"0.67797166",
"0.6778269",
"0.6552366",
"0.6520661",
"0.64979327",
"0.64340514",
"0.63349134",
"0.63349134",
"0.63349134",
"0.63349134",
"0.630644",
"0.6305068",
"0.62835497",
"0.6257408",
"0.62484163",
"0.62357223",
"0.6181408",
"0.61700284",
"0.61271226",
"0.61267054",
"0.6... | 0.598508 | 22 |
gets the nearest past monday relative to the date given | def find_monday date
date.monday? ? date : find_monday(date - 1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def monday(date = Date.today)\n today = date\n day = today.wday\n diff = case day\n when 0\n 6\n when 1..6\n day - 1\n end\n today - diff\n end",
"def monday(t)\n dt = to_datetime t\n mon = dt - (dt.cwday - 1)\n ... | [
"0.76611316",
"0.71781665",
"0.6961554",
"0.694161",
"0.67945176",
"0.6612512",
"0.6570319",
"0.65298384",
"0.6459516",
"0.6406952",
"0.63962793",
"0.63940775",
"0.638014",
"0.636892",
"0.6349824",
"0.63354224",
"0.6306636",
"0.626007",
"0.6188547",
"0.617527",
"0.6139637",
... | 0.76377934 | 1 |
parse must be implmented by parser that inherit from Dillinger::Parser::Base. | def parse
fail StandardError.new('parse has not been implemented.')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse; end",
"def parse; end",
"def parse; end",
"def parse\n raise NotImplementedError\n end",
"def parse\n end",
"def parse\n raise \"absctract method called\"\n end",
"def parse\n raise NotImplementedError.new\n end",
"def parser; end",
"def parser; end",
"def ... | [
"0.78827405",
"0.78827405",
"0.78827405",
"0.7740723",
"0.76936924",
"0.76830953",
"0.75954115",
"0.751249",
"0.751249",
"0.751249",
"0.751249",
"0.7455588",
"0.7419254",
"0.7419254",
"0.7335137",
"0.7297981",
"0.7260773",
"0.717799",
"0.7159532",
"0.71546763",
"0.707805",
... | 0.79193556 | 0 |
All parsers are initilized with a file. | def initialize(file)
@file = file
@transactions = Set.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(file)\n @file = parse(file)\n end",
"def open_parser(this_file)\n\t\t@file = this_file\n\t\t@parser = PbfParser.new(file)\n\tend",
"def initialize(filename)\n @filename = filename\n parse()\n end",
"def initialize f\n unless f.instance_of? IO\n f = File.new(f)\n ... | [
"0.7469318",
"0.72506505",
"0.7176907",
"0.6893473",
"0.67832476",
"0.67409796",
"0.67283475",
"0.6664281",
"0.66455626",
"0.66071236",
"0.65895444",
"0.65895444",
"0.6581347",
"0.654699",
"0.654699",
"0.654699",
"0.64893913",
"0.64814407",
"0.6474453",
"0.6456101",
"0.641203... | 0.0 | -1 |
Appends a transaction to the transaction set. | def add_transaction(transaction)
transactions << transaction
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_transaction\n\t\t\t@@transactions << self\n\t\tend",
"def add_transaction(t)\n @transactions << t\n end",
"def add_transaction(transaction)\n transactions.push transaction\n end",
"def add_to_transaction(*)\n @connection.add_transaction_record(self)\n end",
"def add_transact... | [
"0.81844056",
"0.81610906",
"0.7837788",
"0.76976293",
"0.7682079",
"0.7252214",
"0.69148517",
"0.68825203",
"0.68491673",
"0.6749682",
"0.66936827",
"0.6522439",
"0.64758223",
"0.6389052",
"0.63857085",
"0.6246911",
"0.6238703",
"0.6196673",
"0.61730474",
"0.6133248",
"0.601... | 0.7766613 | 3 |
Program Starts =begin This 'checkValidInput(value)' Method Will Check Whether Valid I/P is given i.e. Not A Positive Integer Or Empty I/P Return true If Valid I/P Else false =end | def checkValidInput(value)
flag=true
if value[0]==nil #To Check Empty Input
puts "No Input Given"
flag=false
elsif (value.match(/\d*/)[0]<=>value)!=0 then #To Check The Input Is An Positive Integer
puts "Not A Positive Integer Number"
flag=false
end
return flag
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkValidInput(value)\n\nflag=true\n\n if value[0]==nil\t\t\t\t\t\t#To Check Empty Input\n puts \"No Input Given\"\n flag=false\n elsif (value.match(/\\d*/)[0]<=>value)!=0 then \t#To Check The Input Is An Positive Integer\n puts \"Not A Positive Integer Number\"\n flag=false\n end\nreturn flag\nend",
... | [
"0.82397866",
"0.7880461",
"0.7635753",
"0.7375727",
"0.73254097",
"0.72654915",
"0.72048044",
"0.7033356",
"0.6982019",
"0.69127697",
"0.68817294",
"0.6870494",
"0.68504465",
"0.6844639",
"0.6836966",
"0.6801261",
"0.6800309",
"0.6793116",
"0.6768888",
"0.6767889",
"0.676518... | 0.8261804 | 0 |
=begin This 'checkPallindrome(value)' method will Check Whether The Passed Parameter Is Pallindrome Or Not Returns True If Pallindrome Else False =end | def checkPallindrome(value)
i=0
flag=true
while i<value.length/2 do
if value[i]!=value[value.length-i-1] then
flag=false
break
end
i+=1
end
return flag
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_palindrome(s)\n \nend",
"def can_make_valid_palindrome(s)\n\nend",
"def pallindrome? n\n n.to_s == n.to_s.reverse\nend",
"def pallindrome?(s)\n return s == s.reverse\nend",
"def palindrome?(param)\n param == param.reverse\nend",
"def palindrome?(argument)\n argumen.reverse == argument\ne... | [
"0.79464734",
"0.76896685",
"0.7684266",
"0.7680615",
"0.7665451",
"0.7588004",
"0.7519006",
"0.7519006",
"0.7502954",
"0.74806654",
"0.74772465",
"0.7438086",
"0.7434225",
"0.7434225",
"0.7425021",
"0.742198",
"0.7409528",
"0.73945963",
"0.73785484",
"0.737178",
"0.7365296",... | 0.7750468 | 1 |
Delete the user with the given id. | def destroy_user(id)
#TODO:
# ADD SOME USER LEVEL TO AVOID THESE
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_user(id)\n # accept an id input parameter\n # use the User Model class to remove the User associated with the `id` primary key from the database\n # (no return is required)\n (User.find_by(id: id)).destroy\n end",
"def delete_user(id)\n get_user_byid(id).destroy\n end",
"def... | [
"0.8770093",
"0.87333924",
"0.8554899",
"0.8546715",
"0.8472349",
"0.8415203",
"0.8381973",
"0.8296094",
"0.8273333",
"0.816098",
"0.8071525",
"0.80592483",
"0.7968646",
"0.79622227",
"0.7931608",
"0.7928118",
"0.79041815",
"0.7721827",
"0.77189046",
"0.7680261",
"0.76767313"... | 0.7286858 | 58 |
GET /duplicatas/new GET /duplicatas/new.xml | def new
respond_to do |format|
format.html #index.html.erb
format.js #index.js.erb
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @dupa = Dupa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dupa }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituto }\n end\n end",
"def new\n res... | [
"0.7103022",
"0.67509186",
"0.6610514",
"0.65520674",
"0.6477426",
"0.6445415",
"0.6434342",
"0.6430409",
"0.63959444",
"0.63891363",
"0.6376787",
"0.6373985",
"0.6373985",
"0.6371439",
"0.63667077",
"0.633355",
"0.6330497",
"0.6330014",
"0.6327926",
"0.63247377",
"0.63181466... | 0.0 | -1 |
POST /duplicatas POST /duplicatas.xml | def create
create_or_update
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @dupa = Dupa.new(params[:dupa])\n\n respond_to do |format|\n if @dupa.save\n format.html { redirect_to(@dupa, :notice => 'Dupa was successfully created.') }\n format.xml { render :xml => @dupa, :status => :created, :location => @dupa }\n else\n format.html { rende... | [
"0.5698202",
"0.53962034",
"0.52763367",
"0.52477",
"0.51652735",
"0.5156078",
"0.5137214",
"0.51142216",
"0.50923055",
"0.50719655",
"0.506732",
"0.50625384",
"0.5057374",
"0.5052947",
"0.5033149",
"0.50299704",
"0.50292486",
"0.5014635",
"0.50086427",
"0.4979603",
"0.493863... | 0.0 | -1 |
GET /accounts GET /accounts.json | def index
@accounts = Account.all
respond_to do |format|
format.html
format.json
format.csv { send_data @accounts.to_csv, filename: "accounts-#{Date.today}.csv" }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accounts\n get('/accounts')['accounts']\n end",
"def get_accounts()\n http_get(accounts_url)\n end",
"def get_account\n as_json(get_results('/account'))\n end",
"def index\n\t\t@accounts = Account.all\n\t\trespond_to do |format|\n\t\t\tformat.json { render json: @accounts }\n\t\tend\n... | [
"0.8533888",
"0.83190995",
"0.7973665",
"0.7771086",
"0.77162343",
"0.7610971",
"0.7565949",
"0.7560706",
"0.74776775",
"0.7466583",
"0.7398896",
"0.7361162",
"0.73488057",
"0.7347849",
"0.7335021",
"0.7275009",
"0.7273285",
"0.72268224",
"0.72127986",
"0.7174189",
"0.7172127... | 0.0 | -1 |
POST /accounts POST /accounts.json | def create
@account = Account.new(account_params)
#@account.user_id = current_account.id
respond_to do |format|
if @account.save
format.html { redirect_to root_url, notice: 'Account was successfully created.' }
format.json { render :json => @account.as_json}
forma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n megam_rest.post_accounts(to_hash)\n end",
"def post_accounts(json_hash)\n @options = {:path => '/users.json',\n :body => json_hash[:json]}.merge(@options)\n\n request(\n :expects => 201,\n :method => :post,\n :body => @options[:body]\n )\n ... | [
"0.77059096",
"0.74428105",
"0.6998076",
"0.68458116",
"0.684345",
"0.68387824",
"0.6831728",
"0.680515",
"0.67691255",
"0.67659897",
"0.67633784",
"0.6748523",
"0.67459255",
"0.67459255",
"0.67459255",
"0.67459255",
"0.67459255",
"0.67459255",
"0.67459255",
"0.67459255",
"0.... | 0.64739954 | 37 |
PATCH/PUT /accounts/1 PATCH/PUT /accounts/1.json | def update
@account = Account.find(params[:id])
respond_to do |format|
if @account.update(account_params)
format.html { redirect_to "/", notice: 'Account was successfully updated.' }
format.json { render :index, status: :ok, location: @account }
else
format.html ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update \n begin\n @resource = Account.find(params[:id])\n @resource.update_attributes!(params[:account])\n render :response => :PUT\n rescue Exception => e\n @error = process_exception(e)\n render :response => :error\n end\n end",
"def update\n respond_to do |format|\... | [
"0.6888599",
"0.6804737",
"0.6624664",
"0.65900904",
"0.65116084",
"0.6494731",
"0.6494731",
"0.64934766",
"0.64834315",
"0.6454537",
"0.6452745",
"0.63773006",
"0.63558024",
"0.63543844",
"0.6313002",
"0.63076025",
"0.62961894",
"0.6243234",
"0.6234015",
"0.622561",
"0.62235... | 0.6243666 | 17 |
DELETE /accounts/1 DELETE /accounts/1.json | def destroy
@account.destroy
respond_to do |format|
format.html { redirect_to accounts_url, notice: 'Account was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_account\n @connection.request({\n :method => 'DELETE'\n }) \n end",
"def destroy\n @api_v1_account.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_accounts_url, notice: 'Account was successfully destroyed.' }\n format.jso... | [
"0.76616204",
"0.7554835",
"0.754963",
"0.73521537",
"0.73521537",
"0.73470473",
"0.73470473",
"0.73470473",
"0.73277366",
"0.73277366",
"0.73277366",
"0.73277366",
"0.73277366",
"0.73277366",
"0.7280975",
"0.7280975",
"0.7256079",
"0.71945333",
"0.7172777",
"0.71404386",
"0.... | 0.70606905 | 38 |
Use callbacks to share common setup or constraints between actions. | def set_account
@account = Account.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.6163443",
"0.604317",
"0.5943409",
"0.59143174",
"0.5887026",
"0.58335453",
"0.57738566",
"0.5701527",
"0.5701527",
"0.56534666",
"0.5618685",
"0.54237175",
"0.5407991",
"0.5407991",
"0.5407991",
"0.5394463",
"0.5376582",
"0.5355932",
"0.53376216",
"0.5337122",
"0.5329516"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def account_params
params.require(:account).permit(:ipaddress, :dummy, :username, :name, :password, :email, :org, :bio, :location, :website, :profile_img, :header_img, :export)
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.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Initializes an instance url:: URL to a BigBlueButton server (e.g. salt:: Secret salt for this server version:: API version e.g. 0.7 (valid for 0.7, 0.71 and 0.71a) | def initialize(url, salt, version='0.7', debug=false)
@supported_versions = ['0.7', '0.8']
@url = url
@salt = salt
@debug = debug
@timeout = 10 # default timeout for api requests
@request_headers = {} # http headers sent in all requests
@version = version || get_api_ve... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(url, salt, version='0.7', debug=false)\n @supported_versions = ['0.7','0.8']\n @url = url\n @salt = salt\n @debug = debug\n\n if version.nil?\n @version = get_api_version\n else\n @version = version\n end\n unless @supported_versions.include?(@ve... | [
"0.7920307",
"0.74579024",
"0.71374613",
"0.6924523",
"0.6844548",
"0.6791782",
"0.67423034",
"0.6709734",
"0.66671",
"0.66671",
"0.66671",
"0.6665787",
"0.66654485",
"0.6641853",
"0.6552267",
"0.64940226",
"0.6465425",
"0.64597994",
"0.645935",
"0.6457238",
"0.6447683",
"0... | 0.7906645 | 1 |
Returns true or false as to whether meeting is open. A meeting is only open after at least one participant has joined. meeting_id (string, int):: Unique identifier for the meeting | def is_meeting_running?(meeting_id)
hash = send_api_request(:isMeetingRunning, { :meetingID => meeting_id } )
BigBlueButtonFormatter.new(hash).to_boolean(:running)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def meeting_running?(id)\n prepare\n @api.is_meeting_running?(id)\n end",
"def is_meeting_running?(meeting_id)\n hash = send_api_request(:isMeetingRunning, { :meetingID => meeting_id } )\n hash[:running].downcase == \"true\"\n end",
"def open?\n\t\t@time = Time.now.to_formatted_s(:time)\n\t... | [
"0.64487904",
"0.6412545",
"0.6259013",
"0.6051096",
"0.5980567",
"0.5980567",
"0.59355843",
"0.5844721",
"0.58067757",
"0.578322",
"0.5775261",
"0.5770325",
"0.5756218",
"0.5714649",
"0.56994057",
"0.5691672",
"0.5687676",
"0.56811565",
"0.56689215",
"0.56496906",
"0.5631746... | 0.62998986 | 2 |
Returns the url used to join the meeting meeting_id (string, int):: Unique identifier for the meeting user_name (string):: Name of the user password (string):: Password for this meeting used to set the user as moderator or attendee options (Hash):: Hash with optional parameters. The accepted parameters are: userID (str... | def join_meeting_url(meeting_id, user_name, password, options={})
valid_options = [:userID, :webVoiceConf]
valid_options += [:createTime] if @version >= "0.8"
options.reject!{ |k,v| !valid_options.include?(k) }
params = { :meetingID => meeting_id, :password => password, :fullName => user_name }... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_meeting_url(meeting_id, user_name, password,\n user_id = nil, web_voice_conf = nil)\n\n params = { :meetingID => meeting_id, :password => password, :fullName => user_name,\n :userID => user_id, :webVoiceConf => web_voice_conf }\n get_url(:join, params)\n end",
"def join_meetin... | [
"0.7968436",
"0.76392967",
"0.7367475",
"0.7303728",
"0.7056507",
"0.66734076",
"0.59233373",
"0.56451887",
"0.5637598",
"0.5624009",
"0.53558415",
"0.53407776",
"0.53233105",
"0.5256323",
"0.5230473",
"0.51780427",
"0.51545465",
"0.51225346",
"0.51223046",
"0.50723886",
"0.5... | 0.8255434 | 0 |
Warning: As of this version of the gem, this call does not work (instead of returning XML response, it should join the meeting). Joins a user into the meeting using an API call, instead of directing the user's browser to moderator_url or attendee_url (note: this will still be required however to actually use bbb). Retu... | def join_meeting(meeting_id, user_name, password, options={})
valid_options = [:userID, :webVoiceConf]
valid_options += [:createTime] if @version >= "0.8"
options.reject!{ |k,v| !valid_options.include?(k) }
params = { :meetingID => meeting_id, :password => password, :fullName => user_name }.mer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_meeting_url(meeting_id, user_name, password, options={})\n valid_options = [:userID, :webVoiceConf]\n valid_options += [:createTime] if @version >= \"0.8\"\n options.reject!{ |k,v| !valid_options.include?(k) }\n\n params = { :meetingID => meeting_id, :password => password, :fullName =>... | [
"0.74205744",
"0.7307646",
"0.7115753",
"0.63867486",
"0.6381555",
"0.6031591",
"0.59472317",
"0.58699673",
"0.57993877",
"0.57381535",
"0.57108957",
"0.55314445",
"0.544055",
"0.542879",
"0.53774965",
"0.53226876",
"0.52863395",
"0.52524304",
"0.52453977",
"0.5233393",
"0.51... | 0.72225356 | 2 |
Returns the API version (as string) of the associated server. This actually returns the version returned by the BBB server, and not the version set by the user in the initialization of this object. | def get_api_version
response = send_api_request(:index)
response[:returncode] ? response[:version].to_s : ""
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_version\n @api_version ||= begin\n pool = self.pool.get_all[0]\n host = self.pool.get_master(pool)\n major = self.host.get_API_version_major(host)\n minor = self.host.get_API_version_minor(host)\n \"#{major}.#{minor}\"\n end\n end",
"def get_server_version\... | [
"0.80206114",
"0.79237044",
"0.78497654",
"0.782226",
"0.7770796",
"0.7735149",
"0.76670396",
"0.76271665",
"0.75945365",
"0.7554735",
"0.7508946",
"0.7505813",
"0.7482755",
"0.7469365",
"0.7390926",
"0.7369384",
"0.7311573",
"0.7304656",
"0.7296197",
"0.7295418",
"0.72845536... | 0.7726154 | 6 |
Helper functions Make a simple request to the server to test the connection. | def test_connection
response = send_api_request(:index)
response[:returncode]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_connection\n args = get_connection_args(\"#{endpoint}/auth\")\n args[:raw_response] = true\n RestClient::Request.execute(args)\n end",
"def test_can_get_ping\n get '/ping'\n assert last_response.ok?\n assert_equal 'PONG', last_response.body\n end",
"def make_http_request\n Net::HT... | [
"0.7159951",
"0.6873441",
"0.6841275",
"0.67629474",
"0.67625",
"0.6669177",
"0.6559965",
"0.6555055",
"0.65218675",
"0.6506425",
"0.6487279",
"0.64414424",
"0.64261395",
"0.6386903",
"0.6369974",
"0.63616425",
"0.6331781",
"0.6284501",
"0.6259085",
"0.62503654",
"0.6224313",... | 0.7016856 | 2 |
API's are equal if all the following attributes are equal. | def ==(other)
r = true
[:url, :supported_versions, :salt, :version, :debug].each do |param|
r = r && self.send(param) == other.send(param)
end
r
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(other)\n attributes == other.attributes\n end",
"def ==(other)\n self.attributes == (other.respond(:attributes) || {} )\n end",
"def same_attributes?(spec)\n @@attributes.all? {|name, default| self.send(name) == spec.send(name) }\n end",
"def assert_equal_attributes(object, expecte... | [
"0.666395",
"0.65977573",
"0.6571436",
"0.6422637",
"0.6413307",
"0.6380215",
"0.63594145",
"0.6309719",
"0.6289587",
"0.6286771",
"0.62656426",
"0.61897993",
"0.61850756",
"0.6079484",
"0.60753626",
"0.6058154",
"0.60120946",
"0.600652",
"0.5992535",
"0.59824777",
"0.5975196... | 0.5897013 | 27 |
Returns the HTTP response object returned in the last API call. | def last_http_response
@http_response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def http_response\n return @http_response\n end",
"def last_response\n @response\n end",
"def last_response\n @last_response\n end",
"def last_response\n @last_response if defined? @last_response\n end",
"def last_response\n @last_response if defined? @last_response\n ... | [
"0.78373253",
"0.7790845",
"0.767886",
"0.75021964",
"0.75021964",
"0.75021964",
"0.75021964",
"0.7485466",
"0.7256914",
"0.7186673",
"0.7186573",
"0.7126663",
"0.7077371",
"0.70587206",
"0.70494",
"0.6994628",
"0.69891703",
"0.6960455",
"0.68754894",
"0.68754894",
"0.6875489... | 0.79104835 | 0 |
Returns the XML returned in the last API call. | def last_xml_response
@xml_response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xml_last_response\n Ox.parse_obj(last_response.body)\n end",
"def to_xml\n response\n end",
"def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end",
"def to_xml\n http.body\n end",
"def response_xml... | [
"0.7733096",
"0.725854",
"0.69987714",
"0.69981116",
"0.6748657",
"0.6580087",
"0.6524857",
"0.6447358",
"0.63682294",
"0.63070565",
"0.6296411",
"0.6219655",
"0.6133388",
"0.6133388",
"0.6085445",
"0.6070982",
"0.6059409",
"0.6057793",
"0.60059077",
"0.59642595",
"0.5962933"... | 0.793454 | 0 |
Formats an API call URL for the method 'method' using the parameters in 'params'. method (symbol):: The API method to be called (:create, :index, :join, and others) params (Hash):: The parameters to be passed in the URL | def get_url(method, params={})
if method == :index
return @url
end
url = "#{@url}/#{method}?"
# stringify and escape all params
params.delete_if { |k, v| v.nil? } unless params.nil?
params_string = ""
params_string = params.map{ |k,v| "#{k}=" + CGI::escape(v.to_s) unl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_url(method, params = nil)\n escaped_params = expand_params(params).map do |k,v|\n k = URI.escape(k.to_s).gsub(';', '%3B').gsub('+', '%2B').gsub('&', '%26')\n v = URI.escape(v.to_s).gsub(';', '%3B').gsub('+', '%2B').gsub('&', '%26')\n \"#{k}=#{v}\"\n end\n\n query = escaped_params.j... | [
"0.69454914",
"0.69274324",
"0.68062806",
"0.6525747",
"0.64522225",
"0.6381919",
"0.6350686",
"0.5995927",
"0.5967072",
"0.5949244",
"0.5921649",
"0.5898338",
"0.5890998",
"0.58673334",
"0.5859476",
"0.58470714",
"0.5774158",
"0.5766814",
"0.575664",
"0.57549",
"0.57546",
... | 0.6358666 | 6 |
Performs an API call. Throws a BigBlueButtonException if something goes wrong (e.g. server offline). Also throws an exception of the request was not successful (i.e. returncode == FAILED). Only formats the standard values in the response (the ones that exist in all responses). method (symbol):: The API method to be cal... | def send_api_request(method, params={}, data=nil)
url = get_url(method, params)
@http_response = send_request(url, data)
return { } if @http_response.body.empty?
# 'Hashify' the XML
@xml_response = @http_response.body
hash = Hash.from_xml(@xml_response)
# simple validation o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call(method, params={})\n # Build path\n params[:apikey] = @api_key\n params = params.map { |p| p.join('=') }.join('&').gsub(/\\s/, '%20')\n path = [@uri.path, API_VERSION, method].compact.join('/') << '?' << params\n # Send request\n get = Net::HTTP::Get.new(path)\n response... | [
"0.7222562",
"0.6847748",
"0.6569997",
"0.6539583",
"0.6470618",
"0.6446804",
"0.6392708",
"0.6350929",
"0.6298151",
"0.62926155",
"0.6253337",
"0.62358916",
"0.6229878",
"0.6180175",
"0.61643845",
"0.61633307",
"0.6162265",
"0.6146752",
"0.6144345",
"0.6125988",
"0.6124955",... | 0.74346334 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.