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
Never trust parameters from the scary internet, only allow the white list through.
def unit_params params.permit(:start_time, :end_time, :day,:start_time_2,:end_time_2,:day_2,:has_time_2,:has_exam_date) params.require(:unit).permit(:exam_date, :capacity, :code , :professor_id , :course_id , :term_id, :detail) 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
out the current state.
def display_board(board) divider="-"*11 for i in 0..8 do print " #{board[i]} " + ((2 == i%3)? "\n" :"|" ) if (2 == i%3 ) # print divider every 3 elements puts divider end #if end #for i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_state; end", "def write_state; end", "def state_out(path:)\n add option: \"-state-out=#{path}\"\n end", "def pop_state\t\n\t\t\t@state_buffer = Proc.new do\n\t\t\t\t@objs2 = []\n\t\t\t\t@current_state = @states.pop\n\t\t\tend\n\t\tend", "def final_state(state)\n final_states(state)\n ...
[ "0.72624224", "0.72624224", "0.67279774", "0.6647568", "0.6577878", "0.6515", "0.6501546", "0.6501546", "0.64870685", "0.64463556", "0.64091253", "0.63802713", "0.6377393", "0.6373034", "0.6373034", "0.6373034", "0.6373034", "0.6373034", "0.6373034", "0.6373034", "0.6373034",...
0.0
-1
Hash operation for storing a string into a "key"
def [](key) hash = hash(key) value = nil if File.exist?(File.join(@cache_dir, hash)) value = '' File.open(File.join(@cache_dir, hash), 'rb') { |f| value += f.read } end return value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash(key); end", "def str_hash(key)\n key.bytes.inject(&:+)\n end", "def hashify(key)\n array = key.split('')\n count = array.count\n index = array.inject(0) do |object,char|\n object += char.ord ** count\n count -= 1\n object\n end\n index % 89\n end", "def key_for_str...
[ "0.805152", "0.7532965", "0.73771846", "0.73740655", "0.7177354", "0.7170892", "0.71582", "0.7005533", "0.7005533", "0.7005533", "0.7005533", "0.7005533", "0.7005533", "0.7005533", "0.6985056", "0.696933", "0.696151", "0.69603956", "0.6861123", "0.68582714", "0.6773758", "0...
0.0
-1
Hash operation for returning the file of the cached copy
def get_filename(key) hash = hash(key) if File.exist?(File.join(@cache_dir, hash)) return File.join(@cache_dir, hash) else return nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash\r\n # TODO what if file is empty?\r\n @hash ||= Digest::SHA1.file(File.join(@directory, @filename)).hexdigest\r\n end", "def compute_hash( path )\n res = '0'\n autorelease_pool { res = NSData.sha1FromContentsOfFile(path) }\n res\n end", "def hash_file path, hash_store\r\n\thexdi...
[ "0.73901016", "0.7372921", "0.72942674", "0.71298474", "0.69874686", "0.6952802", "0.68883353", "0.6796016", "0.67659706", "0.67446625", "0.6658386", "0.665464", "0.66355217", "0.66270334", "0.6611895", "0.6598429", "0.655552", "0.6537258", "0.65259314", "0.6500439", "0.64694...
0.6206313
43
TODO optimize for generic DBMS
def peak_for_hour(hour, km_id, base=nil) starts = "TIME '#{hour}:00:00'" ends = "TIME '#{hour}:59:59'" self.peak_between(starts, ends, km_id, base) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def select(db); end", "def select(db); end", "def resultset; end", "def query; end", "def data_complextest(db); end", "def get_sighting_records(db)\r\n\r\n sighting_records = db.query(\"select * from sighting_details order by id\")\r\n\r\n return sighting_records.to_a\r\n\r\nend", "def orm; end", "...
[ "0.6106398", "0.6106398", "0.58392364", "0.58054274", "0.57133013", "0.56105644", "0.5574149", "0.55462873", "0.5524836", "0.54270494", "0.53907883", "0.53907883", "0.5388198", "0.5381796", "0.53787225", "0.536987", "0.53620875", "0.53533983", "0.5351881", "0.5323067", "0.531...
0.0
-1
Returns array with user status exclude replyes
def statuses_array(count = 1) statuses(count).map { |s| s['text'] }.delete_if { |status| status =~ /^\@/} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unanswered_questions\n Question.all.reject do |question|\n responsers_id = question.responses.pluck(:user_id)\n responsers_id.include?(self.id)\n end\n end", "def get_non_friends\n\n userFriends = self.all_friends\n userNotFriends = User.all_except(userFriends)\n\n #user is not frie...
[ "0.6449606", "0.6381133", "0.62619597", "0.62606084", "0.62305874", "0.61772585", "0.6160889", "0.6150628", "0.6144868", "0.6128897", "0.60921204", "0.6057441", "0.60455644", "0.603976", "0.6034954", "0.60339475", "0.60262406", "0.60262406", "0.6016571", "0.6006711", "0.59264...
0.0
-1
multiply all items by 2
def multiply_by_two(array) # double_numbers = [] # array.each do |number| # double_numbers << number * 2 # end # double_numbers array.map { |number| number * 2 } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multiply(nums)\r\n nums.reduce(:*)\r\nend", "def multiplies (*args)\n multi=1\n args.each do |item|\n multi *=item\n end\n multi\nend", "def multiply_by_two(array)\n array.map { |n| n * 2 }\nend", "def multiply_by_2(input)\n output = []\n input.reverse!\n input.each_...
[ "0.709858", "0.7094807", "0.7051089", "0.70304954", "0.70152885", "0.69073623", "0.68978095", "0.6815643", "0.6787611", "0.67801255", "0.67723215", "0.67383015", "0.67371935", "0.67217594", "0.6680924", "0.6653526", "0.66512656", "0.66475266", "0.66442215", "0.6640112", "0.66...
0.6793442
8
sum of all items
def sum_items(array) # total = 0 # array.each do |number| # total += number # end # total array.inject { |sum, num| sum + num } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum\n only_with('sum', 'Numeric', 'String')\n items.compact.sum\n end", "def total_items\r\n\t\t@items.inject(0) { |sum, i| sum + i.quantity }\r\n\tend", "def sum\n self.reduce('lambda{|sum, item| sum + item}')\n end", "def item_total\n line_items.map(&:total).reduce(:+)\n end", ...
[ "0.8272155", "0.78822124", "0.7841352", "0.76990056", "0.76462847", "0.76423335", "0.75907326", "0.7580964", "0.7558438", "0.7535831", "0.7533346", "0.7490579", "0.7478962", "0.7448934", "0.7447676", "0.7447676", "0.7415413", "0.7402631", "0.7394534", "0.73843724", "0.7365076...
0.7124693
54
Cannot generate ipaddr of invalid protocol
def test_gen_ipaddr_invalid_protocol assert_raises ArgumentError do RFauxFactory.gen_ipaddr(protocol: :ip5) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_gen_ipaddr_ip3_ending\n assert_equal RFauxFactory.gen_ipaddr(protocol: :ip3).split('.')[-1], '0'\n end", "def ipaddr?; end", "def ipaddr; end", "def ip_v4_address; end", "def test_gen_ipaddr_long_prefix\n assert_raises ArgumentError do\n RFauxFactory.gen_ipaddr(protocol: :ip4, prefix: ...
[ "0.71305054", "0.67672646", "0.6663809", "0.66280234", "0.6519361", "0.64219624", "0.6388894", "0.6374742", "0.6313316", "0.6301678", "0.6297902", "0.62905574", "0.62343395", "0.6224222", "0.6186645", "0.6186645", "0.6186645", "0.6186645", "0.6186645", "0.6186645", "0.6158536...
0.7375594
0
Cannot generate ipaddr with long prefix
def test_gen_ipaddr_long_prefix assert_raises ArgumentError do RFauxFactory.gen_ipaddr(protocol: :ip4, prefix: [10, 11, 12, 13]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_ip\n crc32 = Zlib.crc32(self.id.to_s)\n offset = crc32.modulo(255)\n\n octets = [ 192..192,\n 168..168,\n 0..254,\n 1..254 ]\n ip = Array.new\n for x in 1..4 do\n ip << octets[x-1].to_a[offset.modulo(octets[x-1].count)].t...
[ "0.680128", "0.66714615", "0.6523836", "0.6498401", "0.6483225", "0.6394241", "0.63633513", "0.63391477", "0.6321949", "0.63188404", "0.6315378", "0.62823814", "0.62785536", "0.627054", "0.62659657", "0.62025833", "0.6179907", "0.6147818", "0.6136345", "0.61290133", "0.610656...
0.7472579
0
Check generate ipaddr without prefix
def test_gen_ipaddr_without_prefix PROTOCOL_TYPES.keys.each do |protocol| assert_equal RFauxFactory.gen_ipaddr(protocol: protocol).split(PROTOCOL_SEPARATOR[protocol]).length, PROTOCOL_TYPES[protocol] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_gen_ipaddr_ip3_ending\n assert_equal RFauxFactory.gen_ipaddr(protocol: :ip3).split('.')[-1], '0'\n end", "def test_gen_ipaddr_long_prefix\n assert_raises ArgumentError do\n RFauxFactory.gen_ipaddr(protocol: :ip4, prefix: [10, 11, 12, 13])\n end\n end", "def find_good_ip_addr list\n li...
[ "0.7137188", "0.70191795", "0.686849", "0.6813128", "0.65890265", "0.653524", "0.6522178", "0.6508649", "0.6454406", "0.64341736", "0.6395352", "0.6294919", "0.6276404", "0.61697096", "0.61675155", "0.61567813", "0.6113983", "0.61085093", "0.61055255", "0.6085239", "0.6080074...
0.6911385
2
Check generate ipaddr without prefix
def test_gen_ipaddr_with_prefix PROTOCOL_TYPES.keys.each do |protocol| ipaddr = RFauxFactory.gen_ipaddr(protocol: protocol, prefix: [10, 11]) assert ipaddr.split(PROTOCOL_SEPARATOR[protocol]).length, PROTOCOL_TYPES[protocol] assert_includes ipaddr.split(PROTOCOL_SEPARATOR[protocol]), '10' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_gen_ipaddr_ip3_ending\n assert_equal RFauxFactory.gen_ipaddr(protocol: :ip3).split('.')[-1], '0'\n end", "def test_gen_ipaddr_long_prefix\n assert_raises ArgumentError do\n RFauxFactory.gen_ipaddr(protocol: :ip4, prefix: [10, 11, 12, 13])\n end\n end", "def test_gen_ipaddr_without_pref...
[ "0.71371424", "0.7019133", "0.69113445", "0.68684727", "0.6589001", "0.65351695", "0.6522147", "0.6508607", "0.6454383", "0.64341706", "0.6395361", "0.6294882", "0.6276368", "0.61696947", "0.6167481", "0.6156721", "0.61139405", "0.61084473", "0.61055076", "0.60851985", "0.608...
0.68130976
4
Check that ip3 ends with 0
def test_gen_ipaddr_ip3_ending assert_equal RFauxFactory.gen_ipaddr(protocol: :ip3).split('.')[-1], '0' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def an_ip_number?(element)\n element.to_i >= 0 && element.to_i <= 255\nend", "def valid_ip?(string)\n decimal_counter = 0\n range_counter = 0\n\n strArray = string.split('')\n strArray.each do |char|\n if char == '.'\n decimal_counter += 1\n end\n end\n\n numArray = string.split('.')\n numArra...
[ "0.6546504", "0.6522748", "0.6475629", "0.63831407", "0.63775617", "0.63669884", "0.63386446", "0.63255054", "0.6322312", "0.6310896", "0.628906", "0.62776226", "0.62693197", "0.62693197", "0.6225851", "0.6207032", "0.6187885", "0.61676836", "0.6129858", "0.612508", "0.610313...
0.7261051
0
Generate a multicast and globally unique MAC address
def test_gen_mac_unicast_globally_unique mac = RFauxFactory.gen_mac(multicast: false, locally: false) first_octect = mac.split(':')[0].to_i(16) mask = 0b00000011 assert_equal first_octect & mask, 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_mac\n if locate_config_value(:macaddress).nil?\n ('%02x' % (rand(64) * 4 | 2)) + (0..4).reduce('') { |s, _x|s + ':%02x' % rand(256) }\n else\n locate_config_value(:macaddress)\n end\n end", "def generate_mac \n (\"%02x\"%(rand(64)*4|2))+(0..4).inject(\"\"){|s,x|s...
[ "0.8006559", "0.7866787", "0.7567914", "0.75315917", "0.7446902", "0.74305457", "0.7396655", "0.72476536", "0.7213217", "0.7011633", "0.68995744", "0.6857859", "0.68375605", "0.66943496", "0.6647405", "0.6647405", "0.65428764", "0.6522817", "0.65095234", "0.64838856", "0.6472...
0.7401642
6
Generate a unicast and locally administered MAC address
def test_gen_mac_multicast_globally_unique mac = RFauxFactory.gen_mac(multicast: true, locally: false) first_octect = mac.split(':')[0].to_i(16) mask = 0b00000011 assert_equal first_octect & mask, 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_mac\n if locate_config_value(:macaddress).nil?\n ('%02x' % (rand(64) * 4 | 2)) + (0..4).reduce('') { |s, _x|s + ':%02x' % rand(256) }\n else\n locate_config_value(:macaddress)\n end\n end", "def generate_mac \n (\"%02x\"%(rand(64)*4|2))+(0..4).inject(\"\"){|s,x|s...
[ "0.80046564", "0.7696998", "0.7574962", "0.7509656", "0.7425773", "0.7238702", "0.71805775", "0.7154369", "0.69516873", "0.69076127", "0.6781537", "0.6668428", "0.6596661", "0.6541099", "0.6541099", "0.6516493", "0.6495483", "0.6438182", "0.64102006", "0.64060766", "0.6380741...
0.67865026
10
Generate a unicast and locally administered MAC address
def test_gen_mac_unicast_locally_administered mac = RFauxFactory.gen_mac(multicast: false, locally: true) first_octect = mac.split(':')[0].to_i(16) mask = 0b00000011 assert_equal first_octect & mask, 2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_mac\n if locate_config_value(:macaddress).nil?\n ('%02x' % (rand(64) * 4 | 2)) + (0..4).reduce('') { |s, _x|s + ':%02x' % rand(256) }\n else\n locate_config_value(:macaddress)\n end\n end", "def generate_mac \n (\"%02x\"%(rand(64)*4|2))+(0..4).inject(\"\"){|s,x|s...
[ "0.8003322", "0.76951313", "0.75745887", "0.7507478", "0.7237669", "0.71809", "0.71550316", "0.6949783", "0.6909297", "0.6786596", "0.6779944", "0.6667296", "0.65972507", "0.6543045", "0.6543045", "0.65170795", "0.64944947", "0.6440081", "0.6408476", "0.64063394", "0.6381061"...
0.74266547
4
Generate a multicast and locally administered MAC address
def test_gen_mac_multicast_locally_administered mac = RFauxFactory.gen_mac(multicast: true, locally: true) first_octect = mac.split(':')[0].to_i(16) mask = 0b00000011 assert_equal first_octect & mask, 3 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_mac\n if locate_config_value(:macaddress).nil?\n ('%02x' % (rand(64) * 4 | 2)) + (0..4).reduce('') { |s, _x|s + ':%02x' % rand(256) }\n else\n locate_config_value(:macaddress)\n end\n end", "def generate_mac \n (\"%02x\"%(rand(64)*4|2))+(0..4).inject(\"\"){|s,x|s...
[ "0.7927211", "0.76514775", "0.74453306", "0.7393037", "0.73881054", "0.7123027", "0.70720816", "0.70456654", "0.6991332", "0.6820584", "0.6699007", "0.6685494", "0.66563463", "0.65917194", "0.65917194", "0.6545933", "0.6495381", "0.64617956", "0.6442073", "0.6357877", "0.6286...
0.74970293
2
Cannot generate mac with wrong delimiter
def test_gen_mac_wrong_delimiter assert_raises ArgumentError do RFauxFactory.gen_mac(delimiter: RFauxFactory.gen_alpha(1)) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def macify\n split(\":\").map {|a| a[0].chr == \"0\" ? a[1].chr : a}.join(\":\")\n end", "def generate_mac\n crc32 = Zlib.crc32(self.id.to_s)\n offset = crc32.modulo(255)\n\n digits = [ %w(0),\n %w(0),\n %w(0),\n %w(0),\n %w(5),\...
[ "0.7778385", "0.73509413", "0.72822905", "0.71738076", "0.71738076", "0.7153903", "0.69857556", "0.6722365", "0.66648304", "0.663449", "0.66152847", "0.6595729", "0.6547691", "0.6456913", "0.64124453", "0.63444495", "0.6263917", "0.6251644", "0.62483156", "0.622557", "0.62130...
0.6767511
7
Returns array with operations for all primary files
def process_all_primary_files # NOTE: I investigated concurrent processing of files # to speed up this process, however I didn't pursue it # further: This process is highly CPU intensive, so the # only way to get a significant speedup is to use # multiple CPUs/Cores. In MRI this is only possible # with multiple processes. I didn't want to go through # the trouble of IPC to collect all files' operations. # It would be easier if we could use threads, however # that would require jruby or rbx. So I'm sticking with # sequential processing for now. Dir.glob( File.join(@repository.base_dir, '**/content/**/*.at') ).map { |absolute_file_path| next nil if !@file_list.any? { |e| absolute_file_path.index(e) } # Skip non content_at files unless absolute_file_path =~ /\/content\/.+\d{4}\.at\z/ raise "shouldn't get here" end # Note: @any_content_type may be the wrong one, however finding # corresponding STM CSV file will still work as it doesn't rely # on config but das regex replacements on file path only. content_at_file_to = Repositext::RFile::ContentAt.new( File.read(absolute_file_path), @language, absolute_file_path, @any_content_type ) @logger.info(" - process #{ content_at_file_to.repo_relative_path(true) }") soff = SubtitleOperationsForFile.new( content_at_file_to, @repository.base_dir, { from_git_commit: @from_git_commit, to_git_commit: @to_git_commit, prev_last_operation_id: @prev_last_operation_id, execution_context: @execution_context, } ).compute if soff.operations.any? @prev_last_operation_id = soff.last_operation_id soff else # Return nil if no subtitle operations exist for this file nil end }.compact end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_files; end", "def all_files; end", "def list\n FileOperations.find_all(self)\n end", "def all\n @files\n end", "def files\n @files ||= lambda {\n sorted_relevant_files = []\n\n file_globs.each do |glob|\n current_glob_files = Pathname.glob(glob)\n relevant_glob_f...
[ "0.63085407", "0.63085407", "0.6231007", "0.6196732", "0.60957783", "0.598398", "0.59547937", "0.5941569", "0.59392786", "0.59241617", "0.5902776", "0.58879477", "0.58641565", "0.5861816", "0.5861816", "0.5861816", "0.5861816", "0.5861816", "0.5861816", "0.58611584", "0.58554...
0.6628282
0
Returns array with operations for primary files that have changed. We determine change through the union of the following two: Any files where there is a diff in the content AT file. Any files that have the `st_sync_required` flag set to true (because of changes to time slices in STM CSV file).
def process_primary_files_with_changes_only # We get the diff only so that we know which files have changed. # It's ok to use the reference commits because we're dealing with # content AT files only. diff = @repository.diff(@from_git_commit, @to_git_commit, context_lines: 0) fwc = [] diff.patches.each { |patch| file_name = patch.delta.old_file[:path] # Skip non content_at files next if !@file_list.include?(file_name) # next if !file_name.index('63-0728') unless file_name =~ /\/content\/.+\d{4}\.at\z/ raise "shouldn't get here: #{ file_name.inspect }" end @logger.info(" - process #{ file_name }") absolute_file_path = File.join(@repository.base_dir, file_name) # Initialize content AT file `to` with contents as of `to_git_commit`. # It's fine to use the reference sync commit as the sync operation # doesn't touch content AT files, only STM CSV ones. content_at_file_to = Repositext::RFile::ContentAt.new( '_', # Contents are initialized later via `#as_of_git_commit` @language, absolute_file_path, @any_content_type ).as_of_git_commit(@to_git_commit) compute_st_ops_attrs = { from_git_commit: @from_git_commit, to_git_commit: @to_git_commit, prev_last_operation_id: @prev_last_operation_id, execution_context: @execution_context, } compute_st_ops_attrs = refine_compute_st_ops_attrs( compute_st_ops_attrs, { from_table_release_version: @from_table_release_version, to_table_release_version: @to_table_release_version, absolute_file_path: absolute_file_path } ) soff = SubtitleOperationsForFile.new( content_at_file_to, @repository.base_dir, compute_st_ops_attrs ).compute if soff.operations.any? # Only collect files that have subtitle operations @prev_last_operation_id = soff.last_operation_id fwc << soff end } # Then we add any files that have st_sync_required set to true and are # not in fwc already. @file_list.each { |content_at_filename| # Skip files that we have captured already next if fwc.any? { |soff| soff.content_at_file.repo_relative_path == content_at_filename } # Skip files that don't have st_sync_required set to true at to_git_commit dj_filename = content_at_filename.sub(/\.at\z/, '.data.json') # We use dj file contents at to_git_commit :at_child_or_ref dj_file = Repositext::RFile::DataJson.new( '_', # Contents are initialized later via #as_of_git_commit @language, dj_filename, @any_content_type ).as_of_git_commit( @to_git_commit, :at_child_or_ref ) next if(dj_file.nil? || !dj_file.read_data['st_sync_required']) # This file is not in the list of fwc yet, and it has st_sync_required. # We add an soff instance with no operations. This could be a file # that has changes to subtitle timeslices only. content_at_file_from = Repositext::RFile::ContentAt.new( '_', # Contents are initialized later via `#as_of_git_commit` @language, content_at_filename, @any_content_type ).as_of_git_commit(@from_git_commit) soff = Repositext::Subtitle::OperationsForFile.new( content_at_file_from, { file_path: content_at_file_from.repo_relative_path, from_git_commit: @from_git_commit, to_git_commit: @to_git_commit, }, [] # No operations ) fwc << soff } # Return list of unique files with changes fwc.uniq end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def altered_files; (modified + added + removed).sort; end", "def changed_files\n # FIXME: Implement properly once changed detection is available.\n files\n end", "def changed_files\n DeliveryTruck::Helpers.changed_files(\n DeliveryTruck::Helpers.pre_change_sha(node),\n node['del...
[ "0.6449585", "0.6340694", "0.631906", "0.6309208", "0.62062526", "0.61406773", "0.61399007", "0.6086273", "0.6080431", "0.6038805", "0.5992132", "0.59891677", "0.5987526", "0.59845185", "0.5922073", "0.5875331", "0.58538514", "0.58511543", "0.58394665", "0.5826469", "0.581438...
0.73299044
0
find the smallest cube such that five permutations of its digits are cube perms holds all the permutations remaining holds the array without the processed elements processed holds the array without the remaining elements
def permutations(perms, digits) counts = Array.new(digits.size, 0) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solve\n perms = (1..9).to_a.permutation.map {|p| p.join}\n prods = []\n\n perms.each do |p|\n (1..2).each do |len|\n a, b, c = p[0, len].to_i, p[len..4].to_i, p[5, 4].to_i\n prods << c if a * b == c\n end\n end\n \n prods.uniq.reduce( :+ )\n end", "def permuted_nums...
[ "0.6973509", "0.6691726", "0.64097166", "0.6380328", "0.63516444", "0.6316087", "0.6289786", "0.62523514", "0.6230836", "0.6199677", "0.6177152", "0.6177152", "0.6177152", "0.6177152", "0.61611086", "0.61424494", "0.6069512", "0.6061936", "0.6053008", "0.6035207", "0.60336804...
0.6106737
16
Can an applicant accept this offer?
def can_accept? !accepted? && !rejected? && !withdrawn? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_be_accepted_by?(acceptor)\n self.can_accept? && self.kase.person == acceptor &&\n (self.kase.offers_reward? ? self.kase.owner_only_offers_reward? : true)\n end", "def accept\n @assignment.active_offer.accepted!\n render_success @assignment.active_offer\n end", "def can_be_appr...
[ "0.71996206", "0.68589246", "0.6750572", "0.6728246", "0.6597135", "0.65781695", "0.65742993", "0.65563804", "0.6491666", "0.6434267", "0.6389413", "0.63456446", "0.63456446", "0.63456446", "0.6314786", "0.6314239", "0.62798774", "0.6276866", "0.6267067", "0.62586874", "0.623...
0.67484146
3
Can an applicant reject this offer?
def can_reject? !accepted? && !rejected? && !withdrawn? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reject_offer\n @auction = @current_user.auctions.find(params[:auction_id])\n @offer = @auction.offers.find(params[:offer_id])\n Alert.transaction do\n Alert.offer_to_reject_response!(@offer, @decision)\n if @decision\n @offer.reject!\n end\n end\n end", "def can_be_rejected...
[ "0.74356776", "0.7392785", "0.73851", "0.71458185", "0.6582555", "0.6582555", "0.6573929", "0.6561897", "0.65580153", "0.6515051", "0.6505544", "0.6490884", "0.6474272", "0.64692014", "0.64689565", "0.6466167", "0.6381114", "0.635267", "0.6346825", "0.6344122", "0.6320541", ...
0.6754919
4
four(plus(nine)) must return 13 eight(minus(three)) must return 5 six(divided_by(two)) must return 3
def switch(number, twitch) return number if twitch.nil? check_num = twitch.index(twitch.find { |x| x != nil }) # p check_num case check_num when 0 then number + twitch[check_num] when 1 then number - twitch[check_num] when 2 then number * twitch[check_num] when 3 then number / twitch[check_num] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def always_three_method(number)\n\t(((number+5)*2 -4)/2 - number)\nend", "def always_three (numberi)\n \n (((((numberi+5)*2)-4)/2)-numberi)\n \nend", "def always_three(num)\n (((num + 5) * 2 - 4) / 2 - num)\nend", "def times_three_and_plus_five(number)\n number * 3 + 5\n end", "def test_subtract...
[ "0.67076355", "0.6636529", "0.6628328", "0.6593949", "0.65884554", "0.6517106", "0.64788455", "0.64438164", "0.64123833", "0.63996285", "0.6349992", "0.63472354", "0.62998694", "0.6297826", "0.6296289", "0.6267265", "0.6249575", "0.62486935", "0.6194382", "0.6192581", "0.6179...
0.0
-1
implements Create and Update operations
def create # attributes begin attrs = jsonapi_received_attributes if attrs if @jsonapi_record # update @jsonapi_record.update! attrs else # create @jsonapi_record = jsonapi_model_class.new attrs @jsonapi_record.save! end end rescue NameError => e jsonapi_render_errors 500, "Model class not found." return rescue jsonapi_render_errors 500, @jsonapi_record.to_jsonapi_errors_hash return end # relationships jsonapi_received_relationships.each do |relationship| begin # to-one if relationship[:definition][:type] == :to_one @jsonapi_record.send :"#{relationship[:definition][:name]}=", relationship[:params][:data] next end # to-many @jsonapi_record.send(relationship[:definition][:name]).send :clear # initialize the relation relationship[:params][:data].each do |item| object = relationship[:receiver][:class].find_by_id item[:id] @jsonapi_record.send(relationship[:definition][:name]).send :<<, object end rescue # Should not happen jsonapi_render_errors 500, "Relationship could not be created." return end end show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n update\n end", "def create\n update\n end", "def update\n create\n end", "def update\n create\n end", "def create\n create_or_update\n end", "def create\n create_or_update\n end", "def create; end", "def create; end", "def create; e...
[ "0.7640191", "0.7566211", "0.7510254", "0.7488705", "0.7408561", "0.7408561", "0.73555595", "0.73555595", "0.73555595", "0.73555595", "0.73550385", "0.73550385", "0.71127915", "0.7100567", "0.7095558", "0.70263594", "0.69917786", "0.69866985", "0.6957609", "0.69565046", "0.69...
0.0
-1
private Extracts record attributes from received params. Use this for creating/updating a database record. Note that relationships (has_one associations etc) are filtered out but are still available in the original params.
def jsonapi_received_attributes begin params.require( :data ).require( :attributes ).permit( *jsonapi_model_class.attribute_names ).reject do |key, value| # ignore automatically generated attributes %w( id created_at created_on updated_at updated_on ).include?( key.to_s ) or # ignore reference attributes key.to_s =~ /_id$/ end rescue ActionController::ParameterMissing => e nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def params_to_attributes(params, **extra_params)\n put = self.params[:action] == 'update'\n \n attributes = {}\n attributes.merge!(extra_params) if extra_params\n\n self.class::PARAM_TO_MODEL.each do |f, v|\n if put && !params[f]\n attributes[v] = ''\n elsif params[f]\n attri...
[ "0.7486855", "0.6946592", "0.6885563", "0.6698446", "0.6524357", "0.6518761", "0.64951533", "0.64762795", "0.6447371", "0.6364642", "0.6358458", "0.6346856", "0.6346856", "0.6323023", "0.6285026", "0.6274631", "0.62548524", "0.62473744", "0.622997", "0.622828", "0.62081575", ...
0.603932
27
Definitions of all relationships for current model
def jsonapi_relationships jsonapi_model_class.reflect_on_all_associations.collect do |association| #type = nil type = :to_one if [ ActiveRecord::Reflection::HasOneReflection, ActiveRecord::Reflection::BelongsToReflection ].include? association.class type = :to_many if [ ActiveRecord::Reflection::HasManyReflection, ActiveRecord::Reflection::HasAndBelongsToManyReflection ].include? association.class next unless type { name: association.name, type: type, receiver: { type: association.klass.to_s.underscore.pluralize.to_sym, class: association.klass.to_s.constantize } } end.compact end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def model_relationships; end", "def relationships\n model.relationships(repository.name)\n end", "def relationships\n @relationships ||= {}\n end", "def relationships\n @relationships ||= Relationship.from_associations(self, associations)\n end", "def model_relationships\n ...
[ "0.7922789", "0.7609743", "0.7392979", "0.7354207", "0.7164474", "0.7125121", "0.7070261", "0.7008933", "0.69293964", "0.6872604", "0.68301046", "0.6769796", "0.6726882", "0.670048", "0.66647995", "0.6662626", "0.66212416", "0.65982074", "0.65921783", "0.65921783", "0.6534853...
0.7061004
7
TODO: define a separate method for relationship actions (i.e. when params[:relationship] != nil)
def jsonapi_received_relationships # Relationship definitions for current model rels = jsonapi_relationships # Consider only current relationship for relationship actions # (params[:relationship] contains the relationship name) if params[:relationship] rels.select! do |rel| rel[:name].to_sym == params[:relationship].to_sym end # If no relationship is received, then return the definition only if request.method == "GET" return rels.collect do |rel| {definition: rel} end end end rels.collect do |relationship| begin received_params = nil # Relationship action if params[:relationship] received_params = params.permit({ data: [ :type, :id ] }) # Object action else received_params = params.require( :data ).require( :relationships ).require( relationship[:name] ).permit({ data: [ :type, :id ] }) end # => {"data"=>{"type"=>"users", "id"=>1}} # sample value for a to-one association # => {"data"=>[{"type"=>"properties", "id"=>1}, {"type"=>"properties", "id"=>2}]} # sample value for a to-many association # is received data conformant to the database schema? conformant = true loop do # to-many if received_params[:data].kind_of? Array if relationship[:type] != :to_many conformant = false break end received_params[:data].each do |item| next if item[:type].to_sym == relationship[:receiver][:type] conformant = false break end break end # to-one if relationship[:type] != :to_one conformant = false break end conformant = false unless received_params[:data][:type].to_sym == relationship[:receiver][:type] break end next unless conformant { definition: relationship, params: received_params } rescue ActionController::ParameterMissing => e # nil assignment to to-one relationship? if relationship[:type] == :to_one begin if params[:relationship] # relationship action received_params = params.permit( :data ) else received_params = params.require( :data ).require( :relationships ).require( relationship[:name] ).permit( :data ) end # received nil? next if received_params[:data] # TODO: should return error to client? next { definition: relationship, params: received_params } rescue ActionController::ParameterMissing => e end end nil end end.compact end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def relationship_params\n params[:relationship]\n end", "def relationship_params\n params.require(:relationship).permit(:follower_user_id, :followed_act_id)\n end", "def relationship_params\n params.require(:relationship).permit(:follower_id, :followed_id)\n end", "def relationship_pa...
[ "0.75603294", "0.70107824", "0.678224", "0.67798114", "0.67798114", "0.67798114", "0.66909665", "0.66202605", "0.65832037", "0.65832037", "0.65832037", "0.65832037", "0.65832037", "0.65832037", "0.65832037", "0.65832037", "0.65832037", "0.65055776", "0.6470891", "0.64123213", ...
0.5861861
49
handle_input function Function that Waits until the user inputs a valid object within the array. Checks to see if the user is choosing the last index or a dash, which can't be chosen The user also has to validate their answer, otherwise the arrow goes back to its previous position
def handle_input # last arrows allows the arrow to return to its last position last_arrows = "^ " not_chosen = true while not_chosen # display puts $coins puts $arrows puts "Enter the index you want to choose to swap with the dashes(You cannot choose the last index or the dashes): " # input and check validity index = gets.chomp.to_i if $coins[index] != "-" && $coins[index+1] != "-" && index<11 && index >>0 # call movecursor using the index move_cursor(index) puts $coins puts $arrows # confirm the answer puts "Type Y or y to confirm your move, otherwise hit any other key to reset your action" key = gets.chomp # if confirmed, change the position of the arrows, swap, and end the loop if key=="Y" || key=="y" last_arrows = $arrows swap(index) not_chosen= false # else reset the arrows, the user didn't choose the answer they want else $arrows = last_arrows end else puts "You cannot choose the last index or a dash" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def select_item #this gets the user input when a specific item in the list needs to be selected\n valid_option = false\n while valid_option == false\n item_num = Integer(gets) rescue false\n if item_num == false\n\t puts \"Please enter a valid option.\"\n \telsif item_num > 0 and $to_do_list[item_num - 1...
[ "0.66524166", "0.66094834", "0.64985865", "0.63983047", "0.62978", "0.62841994", "0.62351733", "0.6223263", "0.6179913", "0.6142858", "0.6131281", "0.6120149", "0.611138", "0.6096539", "0.60682154", "0.6055419", "0.605384", "0.60415053", "0.6040707", "0.60392374", "0.6032748"...
0.7460085
0
swap function swaps the two given indexes within the coins string through converting it to an array then swapping them with the dashes within the array
def swap(index) $coins = $coins.split("") # finding dash indexes dash1 = $coins.index("-") dash2 = $coins.rindex("-") # swapping $coins[index], $coins[dash1] = $coins[dash1], $coins[index] $coins[index+1], $coins[dash2] = $coins[dash2], $coins[index+1] $coins = $coins.join end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def swap(string)\n array = string.split\n swapped_array = array.map do |element|\n element[0], element[-1] = element[-1], element[0]\n element\n end\n swapped_array.join(' ')\nend", "def swap (st1, char1, num1, st2, char2, num2, array)\n\n\ttempST = array[st1]\n\ttempCH = array[char1]\n\ttempNM = array...
[ "0.6656808", "0.6553026", "0.65372497", "0.6443365", "0.6402753", "0.6357849", "0.6326455", "0.6326455", "0.6267701", "0.62531507", "0.6244827", "0.62067515", "0.6176843", "0.61690384", "0.61158025", "0.608424", "0.6074209", "0.6063754", "0.6047188", "0.6014461", "0.5995177",...
0.8685979
0
move_cursor function finds the cursor within the arrows string and then swaps the cursor with the chosen input determined by the user
def move_cursor(index) cursor = $arrows.index("^") $arrows[index], $arrows[cursor] = $arrows[cursor], $arrows[index] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_cursor(input)\n\n if input == 'w'\n dx,dy = [-1,0]\n elsif input == 's'\n dx,dy = [1,0]\n elsif input == 'a'\n dx,dy = [0,-1]\n elsif input == 'd'\n dx,dy = [0,1]\n elsif input == 'q'\n exit\n end\n\n\n x, y = [cursor[0] + dx, cursor[1] + dy]\n #returns cur...
[ "0.76704484", "0.6659817", "0.6484411", "0.6455625", "0.6391406", "0.6391406", "0.6391406", "0.6391406", "0.6391406", "0.6391406", "0.6391406", "0.6391406", "0.6391406", "0.6391406", "0.6391295", "0.6391295", "0.6390777", "0.6390777", "0.63623214", "0.6310654", "0.6293376", ...
0.72107124
1
check_win_condition function checks to see whether or not the coins strings match the win conditions
def check_win_condition # delete the dashes $coins = $coins.split("") $coins = $coins.delete_if {|x| x == "-"} $coins = $coins.join puts $coins win_conditions=["HTHTHTHTHT","THTHTHTHTH"] # compare win conditions with $coins win_conditions.each { |win| if $coins == win puts "Congratulations! You've done it!" return end } puts "You have run out of tries" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def game_meets_win_cond? win_condition, game\n return false if game.game_result == \"\"\n win_condition=='ALL' || win_condition==game.game_result\n end", "def won?\n WIN_COMBINATIONS.any? do |combo|\n @board.cells[combo[0]] == @board.cells[combo[1]] && @board.cells[combo[0]] == @board.cells[combo...
[ "0.7036161", "0.686443", "0.6787592", "0.6755974", "0.66890967", "0.6656488", "0.6655228", "0.6640801", "0.6621644", "0.661985", "0.6614558", "0.6596755", "0.6585512", "0.65594155", "0.65594155", "0.6523098", "0.6518632", "0.6507796", "0.6504649", "0.64974576", "0.64974576", ...
0.82901776
0
play_game function plays the game and allows the user 5 options to win. also provides user with a description of the rules
def play_game puts "---------------------------------------------" puts "-----EVEN AND ODDS: A coin matching game-----" puts "---------------------------------------------" puts "----Given the string: HHHHHTTTTT, can you----" puts "----successfully move pairs of letters to----" puts "----change the string into the following:----" puts "----------HTHTHTHTHT or THTHTHTHTH-----------" puts "---------------------------------------------" puts "--------Here's the initial string:-----------" puts "---------------------------------------------" puts "\n\n" 5.times{ handle_input } check_win_condition end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def play_game\n puts \"Would you like to play\"\n puts \"Rock-Paper-Scissor (RPS)\" \n puts \"OR\" \n puts \"Rock-Paper-Scissor-Lizard-Spock? (RPSLS)\"\n h_line\n rule_type = check_input([\"RPS\",\"RPSLS\"])\n rules = rule_type == \"RPS\" ? RPS_Rules.new : RPSLS_Rules.new\n puts \"Ok! Let's play \" + rules...
[ "0.7543832", "0.7364362", "0.7186017", "0.7106607", "0.7022164", "0.6973125", "0.6966719", "0.69397026", "0.6843158", "0.682128", "0.6787612", "0.6785904", "0.67661244", "0.67656124", "0.6755519", "0.67433053", "0.67382723", "0.6721955", "0.67183226", "0.6715697", "0.67086184...
0.0
-1
GET /modes/1/stats GET /modes/1/stats.json
def index respond_to do |format| format.html { render 'application/cube_trainer' } format.json do stats = @mode.stats.map(&:to_simple) render json: stats, status: :ok end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stats\n request :get, \"_stats\"\n end", "def stats\n request :get, \"_stats\"\n end", "def stats\n Client.current.get(\"#{resource_url}/stats\")\n end", "def modes\n @client.get('/Journey/Meta/Modes')\n end", "def stats\n _get(\"/system/stats\") { |json| json...
[ "0.69450486", "0.69450486", "0.6808387", "0.6732367", "0.6727641", "0.63921094", "0.63801813", "0.62487656", "0.6221298", "0.6141719", "0.61313635", "0.61170346", "0.6111959", "0.6099768", "0.60922164", "0.60800517", "0.60768676", "0.6039275", "0.6039275", "0.6039275", "0.601...
0.7300694
0
GET /modes/1/stats/1 GET /modes/1/stats/1.json
def show respond_to do |format| format.html { render 'application/cube_trainer' } format.json { render json: @stat.to_simple, status: :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n respond_to do |format|\n format.html { render 'application/cube_trainer' }\n format.json do\n stats = @mode.stats.map(&:to_simple)\n render json: stats, status: :ok\n end\n end\n end", "def stats\n request :get, \"_stats\"\n end", "def stats\n reques...
[ "0.7317902", "0.6775806", "0.6775806", "0.66198736", "0.64493626", "0.6369107", "0.63271374", "0.63269675", "0.62546134", "0.6243415", "0.6195791", "0.61815673", "0.61211514", "0.6087388", "0.6063131", "0.6051972", "0.6013334", "0.5972833", "0.59588516", "0.5958003", "0.59508...
0.6086427
14
params: keyvalue of what properties you want to set in that bz_id
def set_bz_upstream_fields(bz_id, oneway, params) uri = URI.parse(URI.encode(APP_CONFIG['mead_scheduler'])) req = Net::HTTP::Put.new(get_bz_update_link(bz_id, oneway, params)) Net::HTTP.start(uri.host, uri.port) { |http| http.request(req) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def params=(hash); end", "def params=(hash); end", "def bocce_params\n params.require(:bocce).permit(:propID, :name, :location, :accessible, :lat, :long, :rating)\n end", "def update!(**args)\n @bucket_id = args[:bucket_id] if args.key?(:bucket_id)\n @obj_id = args[:obj_id] if a...
[ "0.60742545", "0.60742545", "0.5915824", "0.58292955", "0.5812568", "0.5779168", "0.5778948", "0.5775257", "0.5756561", "0.57164174", "0.56975615", "0.5674786", "0.56725997", "0.56711835", "0.5669095", "0.565873", "0.5646786", "0.5637437", "0.5609468", "0.5609102", "0.5602781...
0.60387063
2
If you have Nokogiri installed, you'll be shunted over to that. Otherwise, you'll hit the old NmapXMLStreamParser.
def import_nmap_xml(args={}, &block) return nil if args[:data].nil? or args[:data].empty? wspace = Msf::Util::DBManager.process_opts_workspace(args, framework) bl = validate_ips(args[:blacklist]) ? args[:blacklist].split : [] if Rex::Parser.nokogiri_loaded noko_args = args.dup noko_args[:blacklist] = bl noko_args[:workspace] = wspace if block yield(:parser, "Nokogiri v#{::Nokogiri::VERSION}") import_nmap_noko_stream(noko_args) {|type, data| yield type,data } else import_nmap_noko_stream(noko_args) end return true end # XXX: Legacy nmap xml parser starts here. fix_services = args[:fix_services] data = args[:data] # Use a stream parser instead of a tree parser so we can deal with # huge results files without running out of memory. parser = Rex::Parser::NmapXMLStreamParser.new yield(:parser, parser.class.name) if block # Whenever the parser pulls a host out of the nmap results, store # it, along with any associated services, in the database. parser.on_found_host = Proc.new { |h| hobj = nil data = {:workspace => wspace} if (h["addrs"].has_key?("ipv4")) addr = h["addrs"]["ipv4"] elsif (h["addrs"].has_key?("ipv6")) addr = h["addrs"]["ipv6"] else # Can't report it if it doesn't have an IP raise RuntimeError, "At least one IPv4 or IPv6 address is required" end next if bl.include? addr data[:host] = addr if (h["addrs"].has_key?("mac")) data[:mac] = h["addrs"]["mac"] end data[:state] = (h["status"] == "up") ? Msf::HostState::Alive : Msf::HostState::Dead data[:task] = args[:task] if ( h["reverse_dns"] ) data[:name] = h["reverse_dns"] end # Only report alive hosts with ports to speak of. if(data[:state] != Msf::HostState::Dead) if h["ports"].size > 0 if fix_services port_states = h["ports"].map {|p| p["state"]}.reject {|p| p == "filtered"} next if port_states.compact.empty? end yield(:address,data[:host]) if block hobj = report_host(data) report_import_note(wspace,hobj) end end if( h["os_vendor"] ) note = { :workspace => wspace, :host => hobj || addr, :type => 'host.os.nmap_fingerprint', :task => args[:task], :data => { :os_vendor => h["os_vendor"], :os_family => h["os_family"], :os_version => h["os_version"], :os_accuracy => h["os_accuracy"] } } if(h["os_match"]) note[:data][:os_match] = h['os_match'] end report_note(note) end if (h["last_boot"]) report_note( :workspace => wspace, :host => hobj || addr, :type => 'host.last_boot', :task => args[:task], :data => { :time => h["last_boot"] } ) end if (h["trace"]) hops = [] h["trace"]["hops"].each do |hop| hops << { "ttl" => hop["ttl"].to_i, "address" => hop["ipaddr"].to_s, "rtt" => hop["rtt"].to_f, "name" => hop["host"].to_s } end report_note( :workspace => wspace, :host => hobj || addr, :type => 'host.nmap.traceroute', :task => args[:task], :data => { 'port' => h["trace"]["port"].to_i, 'proto' => h["trace"]["proto"].to_s, 'hops' => hops } ) end # Put all the ports, regardless of state, into the db. h["ports"].each { |p| # Localhost port results are pretty unreliable -- if it's # unknown, it's no good (possibly Windows-only) if ( p["state"] == "unknown" && h["status_reason"] == "localhost-response" ) next end extra = "" extra << p["product"] + " " if p["product"] extra << p["version"] + " " if p["version"] extra << p["extrainfo"] + " " if p["extrainfo"] data = {} data[:workspace] = wspace if fix_services data[:proto] = nmap_msf_service_map(p["protocol"]) else data[:proto] = p["protocol"].downcase end data[:port] = p["portid"].to_i data[:state] = p["state"] data[:host] = hobj || addr data[:info] = extra if not extra.empty? data[:task] = args[:task] data[:name] = p['tunnel'] ? "#{p['tunnel']}/#{p['name'] || 'unknown'}" : p['name'] report_service(data) } #Parse the scripts output if h["scripts"] h["scripts"].each do |key,val| if key == "smb-check-vulns" if val =~ /MS08-067: VULNERABLE/ vuln_info = { :workspace => wspace, :task => args[:task], :host => hobj || addr, :port => 445, :proto => 'tcp', :name => 'MS08-067', :info => 'Microsoft Windows Server Service Crafted RPC Request Handling Unspecified Remote Code Execution', :refs =>['CVE-2008-4250', 'BID-31874', 'CWE-94', 'MSFT-MS08-067', 'MSF-Microsoft Server Service Relative Path Stack Corruption', 'NSS-34476'] } report_vuln(vuln_info) end if val =~ /MS06-025: VULNERABLE/ vuln_info = { :workspace => wspace, :task => args[:task], :host => hobj || addr, :port => 445, :proto => 'tcp', :name => 'MS06-025', :info => 'Vulnerability in Routing and Remote Access Could Allow Remote Code Execution', :refs =>['CVE-2006-2370', 'CVE-2006-2371', 'BID-18325', 'BID-18358', 'BID-18424', 'MSFT-MS06-025', 'MSF-Microsoft RRAS Service RASMAN Registry Overflow', 'NSS-21689'] } report_vuln(vuln_info) end # This one has NOT been Tested , remove this comment if confirmed working if val =~ /MS07-029: VULNERABLE/ vuln_info = { :workspace => wspace, :task => args[:task], :host => hobj || addr, :port => 445, :proto => 'tcp', :name => 'MS07-029', :info => 'Vulnerability in Windows DNS RPC Interface Could Allow Remote Code Execution', # Add more refs based on nessus/nexpose .. results :refs =>['CVE-2007-1748', 'MSF-Microsoft DNS RPC Service extractQuotedChar()', 'NSS-25168'] } report_vuln(vuln_info) end end end end } # XXX: Legacy nmap xml parser ends here. REXML::Document.parse_stream(data, parser) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nokogiri!\n @@parser = USE_NOKOGIRI\n end", "def parse_xml(string) #:doc:\n Nokogiri::XML::Document.parse(string) do |opts|\n opts.options = 0\n opts.noblanks\n end\n end", "def parse_xml(xml)\n Nokogiri::XML(xml, &:noblanks)\n end", "def init\n sup...
[ "0.67848814", "0.6258493", "0.6111307", "0.61100143", "0.6048194", "0.6041562", "0.58955926", "0.5777912", "0.5679643", "0.56777006", "0.5623331", "0.5620242", "0.56108457", "0.5604741", "0.5600749", "0.55937976", "0.558505", "0.5577131", "0.55360526", "0.5482686", "0.5422911...
0.65938336
1
Import Nmap's oX xml output
def import_nmap_xml_file(args={}) filename = args[:filename] data = "" ::File.open(filename, 'rb') do |f| data = f.read(f.stat.size) end import_nmap_xml(args.merge(:data => data)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def osmxml (ios)\n ios.write(\"<osm version=\\\"0.6\\\" >\\n\")\n @properties.each { |x| \n x.osmxml(ios) \n }\n ios.write(\"</osm>\\n\")\n end", "def to_xml\n Ox.to_xml document\n end", "def import_nmap_xml_file(args={})\n\t\tfilename = args[:filename]\n\t\twspace = args[:wspace]...
[ "0.7203837", "0.6537271", "0.6359113", "0.6330247", "0.61576325", "0.5946851", "0.5835244", "0.5793618", "0.5789072", "0.5780177", "0.57690406", "0.570984", "0.56481564", "0.5633083", "0.5631236", "0.55651903", "0.55643475", "0.5538239", "0.55378455", "0.5525181", "0.54868585...
0.6391303
2
GET /attendee_types/1 GET /attendee_types/1.xml
def show @attendee_type = AttendeeType.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @attendee_type } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @attendee_type = AttendeeType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @attendee_type }\n end\n end", "def appointment_types(params = {})\n scope 'default'\n get('schedule/appointmenttypes/', params)\n end", "def index...
[ "0.6403167", "0.6355725", "0.62875587", "0.6124446", "0.61237556", "0.6085812", "0.60768557", "0.60560524", "0.59996545", "0.5975472", "0.59401035", "0.5921132", "0.5895939", "0.58937913", "0.58750427", "0.58719003", "0.5846531", "0.5844924", "0.58394295", "0.5831366", "0.582...
0.73962736
0
GET /attendee_types/new GET /attendee_types/new.xml
def new @attendee_type = AttendeeType.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @attendee_type } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @attendee_type = AttendeeType.new(params[:attendee_type])\n\n respond_to do |format|\n if @attendee_type.save\n flash[:notice] = 'AttendeeType was successfully created.'\n format.html { redirect_to(@attendee_type) }\n format.xml { render :xml => @attendee_type, :status...
[ "0.7414288", "0.6966798", "0.6898391", "0.6898391", "0.68952966", "0.6874957", "0.6844455", "0.67740226", "0.6749548", "0.6738392", "0.6704347", "0.6651067", "0.6649988", "0.66105187", "0.6608392", "0.6592187", "0.65697175", "0.6546416", "0.6542467", "0.6538734", "0.6528678",...
0.79296446
0
POST /attendee_types POST /attendee_types.xml
def create @attendee_type = AttendeeType.new(params[:attendee_type]) respond_to do |format| if @attendee_type.save flash[:notice] = 'AttendeeType was successfully created.' format.html { redirect_to(@attendee_type) } format.xml { render :xml => @attendee_type, :status => :created, :location => @attendee_type } else format.html { render :action => "new" } format.xml { render :xml => @attendee_type.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @attendee = Attendee.new(attendee_params)\n\n respond_to do |format|\n if @attendee.save\n format.json { render json: @attendee.to_json, status: :created }\n else\n format.json { render json: @attendee.errors, status: :unprocessable_entity }\n end\n end\n end", ...
[ "0.5946869", "0.5792163", "0.57896453", "0.575829", "0.57313937", "0.57079726", "0.5688954", "0.56312746", "0.562494", "0.5593079", "0.55922496", "0.55917466", "0.5585956", "0.5582886", "0.55780035", "0.55186266", "0.5496733", "0.5475496", "0.5475084", "0.5416962", "0.538127"...
0.6750827
0
PUT /attendee_types/1 PUT /attendee_types/1.xml
def update @attendee_type = AttendeeType.find(params[:id]) respond_to do |format| if @attendee_type.update_attributes(params[:attendee_type]) flash[:notice] = 'AttendeeType was successfully updated.' format.html { redirect_to(@attendee_type) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @attendee_type.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @attendence_type.update(attendence_type_params)\n format.html { redirect_to @attendence_type, notice: 'Attendence type was successfully updated.' }\n format.json { render :show, status: :ok, location: @attendence_type }\n else\n format.html...
[ "0.6364461", "0.62592256", "0.62447065", "0.6225505", "0.6201862", "0.61649495", "0.61192274", "0.61114144", "0.60965455", "0.5935699", "0.5905182", "0.5905182", "0.5905182", "0.58582926", "0.5854418", "0.5840003", "0.5799654", "0.5795842", "0.5780963", "0.5771285", "0.571971...
0.74284583
0
DELETE /attendee_types/1 DELETE /attendee_types/1.xml
def destroy @attendee_type = AttendeeType.find(params[:id]) @attendee_type.destroy respond_to do |format| format.html { redirect_to(attendee_types_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deleteAttendee(name)\n RSVP.delete(@id,name)\n end", "def destroy\n @attendee = Attendee.find(params[:id])\n @attendee.destroy\n\n respond_to do |format|\n format.html { redirect_to attendees_url }\n format.json { head :ok }\n end\n end", "def destroy\n @attend = Attend.find(p...
[ "0.68941605", "0.67210585", "0.6717508", "0.67025185", "0.67025185", "0.6591217", "0.65573406", "0.64150095", "0.63885945", "0.6382531", "0.6351613", "0.63237554", "0.63018775", "0.6299788", "0.6282633", "0.62787324", "0.62749934", "0.62467957", "0.6245012", "0.62158066", "0....
0.78477234
0
GET /seguros/1 GET /seguros/1.json
def show @seguro = Seguro.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @seguro } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @sezione = Sezione.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sezione }\n end\n end", "def show\n @seguidore = Seguidore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format...
[ "0.67843974", "0.67638767", "0.6757166", "0.6749493", "0.6685769", "0.6617606", "0.6471783", "0.64687014", "0.6468379", "0.64639306", "0.6462563", "0.64357704", "0.6415008", "0.6414201", "0.64138806", "0.64032197", "0.63844514", "0.6372025", "0.6363893", "0.6360834", "0.63329...
0.7415031
0
GET /seguros/new GET /seguros/new.json
def new @seguro = Seguro.new respond_to do |format| format.html # new.html.erb format.json { render json: @seguro } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @selecao = Selecao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @selecao }\n end\n end", "def new\n @sezione = Sezione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sezione }\n ...
[ "0.77931243", "0.77308655", "0.77177453", "0.7463062", "0.7461351", "0.74605805", "0.74358726", "0.74169", "0.7406674", "0.7361798", "0.7358668", "0.73584545", "0.73314255", "0.73159313", "0.7303049", "0.7297028", "0.7284972", "0.7283781", "0.7282546", "0.7280062", "0.7274685...
0.80154467
0
POST /seguros POST /seguros.json
def create @seguro = Seguro.new(params[:seguro]) respond_to do |format| if @seguro.save format.html { redirect_to @seguro, notice: 'Seguro was successfully created.' } format.json { render json: @seguro, status: :created, location: @seguro } else format.html { render action: "new" } format.json { render json: @seguro.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @soatseguro = Soatseguro.new(soatseguro_params)\n\n respond_to do |format|\n if @soatseguro.save\n format.html { redirect_to @soatseguro, notice: 'Soatseguro was successfully created.' }\n format.json { render :show, status: :created, location: @soatseguro }\n else\n ...
[ "0.6907571", "0.66096765", "0.66093427", "0.6555054", "0.65544385", "0.65336233", "0.6431165", "0.6415831", "0.6400106", "0.6366946", "0.63569754", "0.6349831", "0.63184977", "0.6310014", "0.62842363", "0.62719035", "0.62604225", "0.62593764", "0.625265", "0.6249943", "0.6248...
0.71458614
0
PUT /seguros/1 PUT /seguros/1.json
def update @seguro = Seguro.find(params[:id]) respond_to do |format| if @seguro.update_attributes(params[:seguro]) format.html { redirect_to @seguro, notice: 'Seguro was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @seguro.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put!\n request! :put\n end", "def put(*args)\n request :put, *args\n end", "def update\n respond_to do |format|\n if @soatseguro.update(soatseguro_params)\n format.html { redirect_to @soatseguro, notice: 'Soatseguro was successfully updated.' }\n format.json { render :show...
[ "0.6336726", "0.6295592", "0.62858766", "0.62032026", "0.61834365", "0.6163441", "0.6145823", "0.6106609", "0.609704", "0.6088859", "0.60599035", "0.6054703", "0.60459125", "0.60319024", "0.6013503", "0.6012059", "0.6012059", "0.6012059", "0.60052884", "0.5992054", "0.5951311...
0.6817128
0
DELETE /seguros/1 DELETE /seguros/1.json
def destroy @seguro = Seguro.find(params[:id]) @seguro.destroy respond_to do |format| format.html { redirect_to seguros_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @seguidore = Seguidore.find(params[:id])\n @seguidore.destroy\n\n respond_to do |format|\n format.html { redirect_to seguidores_url }\n format.json { head :ok }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @selecao = Selecao.find(p...
[ "0.720422", "0.7118648", "0.7008624", "0.6993929", "0.69265574", "0.6917697", "0.69079643", "0.68915606", "0.6847051", "0.68271136", "0.68140906", "0.6796421", "0.6796282", "0.67833894", "0.677279", "0.67688805", "0.6766036", "0.6758755", "0.6756106", "0.67548496", "0.6751635...
0.7357167
0
Refreshes this token by a given amount of time but does NOT persist to the database.
def refresh(amount: 30.minutes) self[:expires_at] = expires_at + amount end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def refresh_time\n self.update_column( :expires, Time.zone.now + TOKEN_LIFE )\n end", "def refreshToken\n # is there a token? (and is it's timestamp not older than 24h?)\n if @token.nil? or @tokenTimeStamp < Time.now - 86400\n @token = getToken(@email,@password)\n @tokenTimeStamp = Time.now\n...
[ "0.7565451", "0.7031154", "0.69424987", "0.69344395", "0.69091016", "0.6877784", "0.67836374", "0.6770714", "0.6770714", "0.67509377", "0.6707301", "0.6679899", "0.6678762", "0.6672337", "0.66311055", "0.65461546", "0.65374017", "0.65230995", "0.6516999", "0.6508416", "0.6505...
0.71612984
1
list_id campaign_id subject message content_id content_url to_name from_name
def send(options) @client.get_request('/cm/list.send', options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_mailchimp_list(from_name, from_email, event)\n Person.roles.keys.each_with_index do |role, index|\n if index == 0 \n participant_ids = []\n Participant.statuses.keys.each do |s|\n response = gibbon.lists.create(make_mailchimp_hash(from_name, from_email, event, role, s))\n ...
[ "0.61859226", "0.58649576", "0.5686128", "0.56551373", "0.5642614", "0.56382513", "0.56230783", "0.5579275", "0.5554816", "0.55257034", "0.54999983", "0.5458246", "0.5428199", "0.54071736", "0.54063576", "0.5391736", "0.5388655", "0.5365594", "0.53564703", "0.53466403", "0.53...
0.0
-1
Authenticate and instantiate the google drive
def initialize(app_name, credentials_path, client_secrets_path, scope) gda = GoogleDriveAuthenticator.new(app_name, credentials_path, client_secrets_path, scope) @client = gda.client @drive_api = gda.drive_api @threads = [] @semaphore = Mutex.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n self.class.service = Google::Apis::DriveV3::DriveService.new\n authorize_service(self.class.service)\n end", "def google_set_up\n require 'google/apis/drive_v2'\n\n scopes = 'https://www.googleapis.com/auth/drive'\n authorization = Google::Auth.get_application_default(scope...
[ "0.7469977", "0.7436452", "0.70327795", "0.70249116", "0.69490886", "0.68067527", "0.6798968", "0.67048246", "0.66385305", "0.66273624", "0.65963876", "0.65943515", "0.6570062", "0.65594697", "0.6558439", "0.6558439", "0.6558439", "0.6558439", "0.6558439", "0.6558439", "0.655...
0.74966365
0
Ensure valid credentials, either by restoring from the saved credentials files or intitiating an OAuth2 authorization request via InstalledAppFlow. If authorization is required, the user's default browser will be launched to approve the request.
def authorize(credentials_path, client_secrets_path, scope) FileUtils.mkdir_p(File.dirname(credentials_path)) file_store = Google::APIClient::FileStore.new(credentials_path) storage = Google::APIClient::Storage.new(file_store) auth = storage.authorize check_auth_expiration auth, client_secrets_path, scope auth end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIAL))\n file_store = Google::APIClient::FileStore.new(CREDENTIAL)\n storage = Google::APIClient::Storage.new(file_store)\n auth = storage.authorize\n if auth.nil? || (auth.expired? && auth.refresh_token.nil?)\n app_info = Google:...
[ "0.7439608", "0.7410622", "0.727247", "0.7268212", "0.72368586", "0.6904663", "0.67897385", "0.66695076", "0.66040087", "0.6602347", "0.6524152", "0.64945465", "0.64744717", "0.6470572", "0.64681566", "0.6466714", "0.64655787", "0.6465307", "0.6453524", "0.64507556", "0.64411...
0.54558915
94
Checks authorization token expiration date and refreshes it if not there
def check_auth_expiration(auth, client_secrets_path, scope) return false unless auth.nil? || (auth.expired? && auth.refresh_token.nil?) app_info = Google::APIClient::ClientSecrets.load(client_secrets_path) flow = Google::APIClient::InstalledAppFlow.new( client_id: app_info.client_id, client_secret: app_info.client_secret, scope: scope) auth = flow.authorize(storage) puts "Credentials saved to #{credentials_path}" unless auth.nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def refresh_token_if_needed\n token_timestamp = decoded_jwt['exp']\n current_timestamp = DateTime.now.to_i\n return unless token_timestamp - current_timestamp <= 0\n\n refresh_token\n end", "def refreshToken\n # is there a token? (and is it's timestamp not ...
[ "0.80803216", "0.7768838", "0.76151675", "0.7581592", "0.7520131", "0.7500074", "0.7500074", "0.74959964", "0.7469917", "0.74528575", "0.74508256", "0.7433678", "0.7428557", "0.74155843", "0.7379257", "0.7344608", "0.7322231", "0.7320728", "0.7257423", "0.72560066", "0.725164...
0.0
-1
Backup the identified folder
def backup_folder(folder_id, path) backup_folder_rec folder_id, path puts 'Progress:' @threads.each_with_index do |thread, i| # <- Finish all jobs thread.join print '#' if i % @threads.size / 10 == 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def backup_dir\n @backup_dir ||= create_backup_dir\n end", "def backup\n self.keep_backup && !File.exists?( backup_path ) && FileUtils.cp( self.resource.path, backup_path )\n end", "def backup_file folder,file\n @manager ||= Conf::LocalFileManager.new\n newp = File.join(Conf::dire...
[ "0.71325934", "0.7015148", "0.6992402", "0.6969956", "0.6933985", "0.68737346", "0.67228353", "0.6708375", "0.6612531", "0.66111714", "0.6593981", "0.656416", "0.6561866", "0.6541312", "0.6539145", "0.65032005", "0.6470927", "0.6464696", "0.644051", "0.6427834", "0.6398943", ...
0.6770637
6
Recursively download every file in a folder
def backup_folder_rec(folder_id, path) results = @client.execute!( api_method: @drive_api.files.list, parameters: { q: "'#{folder_id}' in parents" }) children = results.data.items # puts "Children: #{children.size}" # puts 'No Children found' if children.empty? download_children children, path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download_files\n path = Conf::directories.tmp\n manager = @current_source.file_manager\n manager.start do\n @current_source.folders.each do |folder|\n files = @files[folder]\n puts \"folder => #{folder}, Files => #{files}\" i...
[ "0.67017967", "0.66356564", "0.65426964", "0.6506944", "0.6460195", "0.6417377", "0.6349547", "0.63154703", "0.631045", "0.6271115", "0.6252502", "0.6220537", "0.6154238", "0.6113927", "0.61007506", "0.60759926", "0.6051336", "0.6034005", "0.5984921", "0.5942133", "0.59350014...
0.59879476
18
Download files and make folders where necessary
def download_children(children, path) children.each do |child| new_path = "#{path}/#{child.title}" backup_folder_rec child.id, new_path if child.mimeType == FOLDER download_if_allowed_child child, new_path end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download_files\n path = Conf::directories.tmp\n manager = @current_source.file_manager\n manager.start do\n @current_source.folders.each do |folder|\n files = @files[folder]\n puts \"folder => #{folder}, Files => #{files}\" i...
[ "0.7293105", "0.70150113", "0.6883917", "0.6883613", "0.68757737", "0.6679542", "0.6655319", "0.66303957", "0.6612172", "0.6570471", "0.65622437", "0.65357155", "0.64742875", "0.64485794", "0.6433891", "0.64304733", "0.64169306", "0.63999313", "0.63965267", "0.634042", "0.629...
0.60195315
39
Download into new_path if is an allowed type
def download_if_allowed_child(child, new_path) return false unless ALLOWED_TYPES.include? child.mimeType revisions = retrieve_revisions(child.id) puts "Downloading #{revisions.size} revisions for #{child.title}"\ " (#{child.id}) in #{new_path}" FileUtils.mkdir_p new_path @semaphore.synchronize do @threads << Thread.new { download_revisions(child, revisions, new_path) } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download_original ; path_download_file(:original).download end", "def download(_io, _path)\n false\n end", "def download_file(file_type)\n temp_file = File.new(public_url.split('/').last, \"wb\")\n remote_data = open(URI.parse(public_url))\n temp_file.write(remote_data.read)\n u...
[ "0.6378795", "0.6361265", "0.6222622", "0.6135865", "0.61093247", "0.61047834", "0.6060282", "0.6003142", "0.5972961", "0.58276224", "0.57387763", "0.5708211", "0.5683693", "0.5682131", "0.567892", "0.5623045", "0.55913305", "0.55779135", "0.55707276", "0.5564703", "0.5561862...
0.5940562
9
Retrieve all revisions of a file
def retrieve_revisions(file_id) api_result = @client.execute( api_method: @drive_api.revisions.list, parameters: { 'fileId' => file_id }) if api_result.status == 200 revisions = api_result.data return revisions.items else puts "An error occurred: #{result.data['error']['message']}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_revisions(file_path, client)\n @log.debug \"Getting revisions of \" + file_path\n revs = []\n revisions = client.revisions file_path\n revisions.each do |rev|\n fileRev = FileRev.new\n if rev['is_deleted']\n fileRev.file_loc = rev[\"path\"]\n fileRev.is_delet...
[ "0.7486235", "0.73810863", "0.7372269", "0.72515345", "0.72025204", "0.71691644", "0.71471524", "0.7019852", "0.69765276", "0.69689935", "0.6949805", "0.68967843", "0.6882636", "0.67299587", "0.67066914", "0.6579598", "0.65670013", "0.6471881", "0.64532554", "0.63991284", "0....
0.79685223
0
Downlaod all revisions of a child
def download_revisions(child, revisions, new_path) revisions.each do |revision| download_url = retrieve_download_url revision, child.mimeType dl = @client.execute!(uri: download_url.to_s) # Download file save_revision child, revision, dl, new_path end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def revert!\n track_changes_save = self.class.track_changes_save\n self.class.track_changes_save = false\n self.transaction do\n content_versions.each do | c |\n if c.content.version == c.version\n c.content.revert_to(c)\n end\n end\n content_key_versions.each do | c ...
[ "0.61279714", "0.600183", "0.5952044", "0.58861226", "0.58715415", "0.57461774", "0.5711405", "0.5671056", "0.5651764", "0.5594573", "0.5594495", "0.5589427", "0.5579125", "0.55737793", "0.5545496", "0.55401677", "0.5537722", "0.5535386", "0.55328995", "0.5524925", "0.5479257...
0.5961084
2
Retrieve the download url of a revision
def retrieve_download_url(revision, type) # Download from export links as document download_url = revision['exportLinks'][DOCUMENT_LINK] if type == DOCUMENT # Otherwise download from export links as spreadsheet download_url = revision['exportLinks'][SHEETS_LINK] if type == SPREADSHEET # Otherwise download from export links as presentation download_url = revision['exportLinks'][PRES_LINK] if type == PRESENTATION download_url end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def url\n @client.get_download_link(@path)\n end", "def get_svn_url( dir='.' )\n\tinfo = get_svn_info( dir )\n\treturn info['URL']\nend", "def source_download_url(version, edition)\n src = iso_source(version, edition)\n assert_src_is_not_nil(src, version, edition) unless node['visuals...
[ "0.7115625", "0.692019", "0.69166803", "0.690489", "0.67453814", "0.6678584", "0.66289365", "0.6606281", "0.6606281", "0.6534521", "0.65274256", "0.65274256", "0.6511804", "0.64507645", "0.6443762", "0.6432969", "0.642532", "0.64223117", "0.64059794", "0.63889307", "0.6384515...
0.7835911
0
Save the revision to disk in new_path
def save_revision(child, revision, dl, new_path) modified_date = "#{revision['modifiedDate'].to_s.gsub(/:/, '_')}" output_file = "#{new_path}/#{child.title}_"\ "#{modified_date}_"\ "#{revision['lastModifyingUserName']}"\ ".#{retrieve_download_url(revision, child.mimeType)[-4, 4]}" # Save downloaded file # puts "Creating #{child.title} revision: ID #{revision.id}" IO.binwrite output_file, dl.body end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_path_history(old_path, current_path, revision)\n update_path_history(old_path, revision) if should_save_path_history?(old_path, current_path)\n end", "def save_to(path); end", "def mark\n \"(echo #{revision} > #{destination}/REVISION)\"\n end", "def newpath\n return path(n...
[ "0.67080194", "0.6460694", "0.6395696", "0.62750363", "0.62027496", "0.613611", "0.6088265", "0.60818374", "0.6037335", "0.59893435", "0.59877974", "0.5906096", "0.5877666", "0.5864992", "0.5855216", "0.58339995", "0.57689834", "0.5764363", "0.57262534", "0.57182896", "0.5703...
0.7127517
0
Use callbacks to share common setup or constraints between actions.
def set_game_instance @game_instance = GameInstance.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a trusted parameter "white list" through.
def game_instance_params params.require(:game_instance).permit(:game_round, :game_status, :user_status) 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.71207976", "0.705222", "0.69488335", "0.69021654", "0.67362636", "0.6717561", "0.6689192", "0.6678948", "0.66622657", "0.6555007", "0.6527569", "0.64588845", "0.64522904", "0.6450812", "0.6448551", "0.6434285", "0.6412147", "0.6412147", "0.6393719", "0.6381976", "0.6381976...
0.0
-1
Gets all object and returns last
def last at(-1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def last\n all.last\n end", "def last\n all.last\n end", "def last\n all.last\n end", "def last\n all.last\n end", "def last\n all.last\n end", "def last\n all.last\n end", "def last\n all.last\n end", "def last\n all.last\n ...
[ "0.7742263", "0.77077436", "0.77077436", "0.77077436", "0.77077436", "0.7658207", "0.7658207", "0.76342636", "0.7519564", "0.72524667", "0.71823895", "0.7155352", "0.7139403", "0.7132748", "0.7112843", "0.7035971", "0.7006488", "0.69360626", "0.6895617", "0.68773586", "0.6868...
0.63766795
58
Attempts to delete the collection. This may not work on every collection, ActiveCMIS does not (yet) try to check this client side. For folder collections 2 options are available, again no client side checking is done to see whether the collection can handle these options
def destroy(options = {}) if options.empty? conn.delete(@url) else unfileObjects = options.delete(:unfileObjects) continueOnFailure = options.delete(:continueOnFailure) raise ArgumentError("Unknown parameters #{options.keys.join(', ')}") unless options.empty? # XXX: have less cumbersome code, more generic and more efficient code new_url = @url new_url = Internal::Utils.append_parameters(new_url, :unfileObjects => unfileObjects) unless unfileObjects.nil? new_url = Internal::Utils.append_parameters(new_url, :continueOnFailure => continueOnFailure) unless continueOnFailure.nil? # TODO: check that we can handle 200,202,204 responses correctly conn.delete(@url) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n response = connection.delete(\"/collections/#{id}\")\n (200..299).include?(response.status)\n end", "def destroy\n authorize! :destroy, @collection\n\n @collection.destroy\n respond_to do |format|\n format.html { redirect_to admin_collections_url, notice: \"Collection '#{...
[ "0.73592085", "0.69988066", "0.69964576", "0.6858313", "0.67533046", "0.66805375", "0.66802", "0.6675966", "0.6670827", "0.66524595", "0.66155547", "0.66000646", "0.6556761", "0.65530217", "0.65399396", "0.6497576", "0.64952755", "0.6493844", "0.64815086", "0.6432266", "0.642...
0.0
-1
FIXME: these role methods should probably be refactored
def exec?(roles = [:contest_director, :psa_director]) roles = [roles] unless roles.kind_of? Array result = self.admin? if result true else roles.each do |role| result ||= self.has_role?(role) end end return result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def role; end", "def role; end", "def private; end", "def probers; end", "def rest_positionals; end", "def suivre; end", "def who_we_are\r\n end", "def anchored; end", "def operations; end", "def operations; end", "def aria_role; end", "def add_role\n person\n end", "def role?(role_nam...
[ "0.68847233", "0.68847233", "0.6684475", "0.57829213", "0.5727909", "0.5688923", "0.56636536", "0.560692", "0.55856204", "0.55856204", "0.5582033", "0.55616385", "0.55368865", "0.5485586", "0.548544", "0.54823923", "0.54789996", "0.54700714", "0.5470066", "0.54683053", "0.546...
0.0
-1
LDAP STUFF this one can be deprecated soon since migrations are coming from staff table
def get_ldap_data if Rails.env.production? result = LdapHelper::find_user(self.username) if result self.legacy_id ||= result.try(:employeeNumber).try(:first) self.first_name ||= result.try(:givenName).try(:first) self.last_name ||= result.try(:sn).try(:first) self.display_name ||= result.try(:displayName).try(:first) self.status ||= result.try(:employeeType).try(:first) || "potential" self.email ||= result.try(:mail).try(:first) || "#{username}@fake.me" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ldap_version\n super\n end", "def ldap_before_save\n self.email = Devise::LDAP::Adapter.get_ldap_param(self.username, \"mail\").first\n self.encrypted_password = Devise::LDAP::Adapter.get_ldap_param(self.username, \"userPassword\").first\n display_name = Devise::LDAP::Adapter.get_ldap_param(...
[ "0.629446", "0.57488567", "0.5740432", "0.57223815", "0.5412721", "0.5274693", "0.5197649", "0.51872", "0.5169361", "0.51398945", "0.509904", "0.5081612", "0.5068725", "0.50271285", "0.49696144", "0.49604744", "0.4959175", "0.49520913", "0.4938557", "0.4905174", "0.4898306", ...
0.50190663
14
syncs to legacy_profile (Legacy::Staff) DON'T PUT THIS IN A CALLBACK because of the sync script password needs to be passed in separately because the user will have already been updated
def sync_to_legacy_profile!(new_password = nil) p = self.legacy_profile # FIXME: don't bother adding missing legacy_profiles just yet if self.legacy_profile.blank? return true end if not self.email.blank? if not p.emails.blank? email = p.emails.first else email = Legacy::EmailInfo.new(pid: p.id) end email.addr = self.email email.stafflist = self.subscribed_to_staff ? 'y' : 'n' email.annclist = self.subscribed_to_announce ? 'y' : 'n' email.pri = 'Y' email.description = 'Default, synced from WREKtranet2' email.save! end pwd = new_password || self.password p.password = pwd unless pwd.blank? p.initials = username p.admin = admin ? "y" : "n" p.fname = first_name p.mname = middle_name p.lname = last_name p.status = status if self.roles.present? p.position = self.roles.map(&:full_name).join(', ') else p.position = '' end p.save! # exec is a reserved word, has to be done separately p.update_column :exec, exec_staff ? "y" : "n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sync_with_facebook_profile(fb_user)\n fb_info = FacebookUserProfile.populate(fb_user)\n address_book.sync_with_facebook(fb_user, fb_info) && \n profile.sync_with_facebook(fb_user, fb_info)\n end", "def set_org_member_password\n @user = User.includes(:profile).find_by_email(params[:email])\n\n ...
[ "0.625231", "0.6135153", "0.60492235", "0.5990611", "0.58137983", "0.56818694", "0.5650935", "0.5623716", "0.5601135", "0.55996996", "0.5578534", "0.5545023", "0.5543798", "0.5512627", "0.55116284", "0.5500605", "0.54913145", "0.54627717", "0.5453735", "0.54417515", "0.541614...
0.7797147
0
disable devise's uniqueness & presence validation for email
def email_required? false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def email_required?\n false\n end", "def email_required?\n false\n end", "def email_required?\n false\n end", "def email_required? \n false \n end", "def email_required?; false end", "def email_is_unique\n active_users = User.active.where(:email => self.email)\n active_users ...
[ "0.7282089", "0.72735167", "0.71814597", "0.7152297", "0.71453017", "0.71314967", "0.71226764", "0.70702755", "0.70702755", "0.70702755", "0.70702755", "0.70640266", "0.69986194", "0.69717205", "0.6894483", "0.68728864", "0.6757786", "0.6733534", "0.67181545", "0.67152596", "...
0.7298142
22
If a file was decorated or overridden and removed, this is the biggest pain point.
def worst_files @worst_files ||= CATEGORIES.inject({}) do |memo, category| memo[category] = customized_files_now_missing .select { |f| f.include?(category) } .count memo end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def obsolete_files; end", "def ignored_file?(path); end", "def overwrite?; end", "def replaced_files; end", "def modified_files; end", "def check_file\n super\n end", "def roll_file?\n raise NotImplementedError\n end", "def keep_files; end", "def maybe_hidden_file?(path); end", ...
[ "0.6687803", "0.65863496", "0.6076079", "0.5998135", "0.599066", "0.5925533", "0.58682597", "0.5862214", "0.5829086", "0.5829086", "0.58250105", "0.5812943", "0.578203", "0.5764677", "0.57571405", "0.57354474", "0.5727505", "0.5714098", "0.56987655", "0.5675053", "0.5624577",...
0.0
-1
Service Deliver by correct policy
def deliver self.class.deliver(self.id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deliver\n return if sent?\n\n begin\n provider = \"#{service.capitalize}Service\".constantize\n provider.new.send(receiver, message)\n\n update_attributes(sent: true)\n rescue NameError\n false\n end\n end", "def postpone_service(user, service)\n @user = user\n notifica...
[ "0.5784609", "0.54930514", "0.54576933", "0.5345692", "0.5344035", "0.5299078", "0.5296494", "0.52739525", "0.5269634", "0.5269204", "0.525003", "0.5235203", "0.5229956", "0.5173973", "0.51702315", "0.5166654", "0.512627", "0.5111638", "0.5096498", "0.509234", "0.5091001", ...
0.48108274
64
Public: Executes an HTTP GET request to a given url. Returns the raw HTTP response body as a String.
def get(url) request(:get, url, {}, nil) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def http_get(url)\n Net::HTTP.get_response(URI.parse(url)).body.to_s\n end", "def do_get url\n\t\turi = URI.parse(url)\n\t\tNet::HTTP.get_response(uri)\n\tend", "def http_get(url)\n require \"open-uri\"\n URI.parse(url).read\n end", "def http_get(url)\n response = client.get(url, follow_redir...
[ "0.8234754", "0.82156444", "0.7883236", "0.7707608", "0.7634456", "0.7626679", "0.7603415", "0.75843483", "0.75605714", "0.7510783", "0.7486872", "0.7433726", "0.7340425", "0.7340425", "0.7323908", "0.7311657", "0.72910047", "0.7280283", "0.72454315", "0.7242799", "0.72268", ...
0.75564456
9
Public: Executes an HTTP POST request to a given url with headers and body. Returns the raw HTTP response body as a String.
def post(url, headers, body) request(:post, url, headers, body) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post url, body, headers = {}\n http_request(url, Net::HTTP::Post, body, headers)\n end", "def post(url, body, headers = {})\n do_request Net::HTTP::Post, url, headers, body\n end", "def http_post_request(url, body = nil)\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n ...
[ "0.79968053", "0.7728051", "0.75461125", "0.7508836", "0.742672", "0.7230387", "0.72280747", "0.697417", "0.6961646", "0.6937794", "0.69223756", "0.69105035", "0.6888542", "0.6819843", "0.68141776", "0.68047553", "0.6800967", "0.67646885", "0.66879416", "0.6677852", "0.667224...
0.7558476
2
O(nlogn) compared to using bsearch: best case (when arr is already sorted) is linear, worst case still nlogn, while using bsearch even when arr is sorted results in n binary searches = nlogn even in the best case
def hash_two_sum(arr, target) h = Hash.new { |h, k| h[k] = [] } arr.each_with_index do |num, i| return true unless h[target - num].empty? h[num] << i end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bsearch(sorted_array, target)\n return nil if sorted_array.empty?\n \n i_mid = (sorted_array.length-1) / 2\n mid = sorted_array[i_mid]\n \n if target == mid\n i = i_mid\n elsif target < mid\n i = bsearch(sorted_array[0...i_mid], target)\n else\n i = bsearch(sorted_a...
[ "0.7813408", "0.7728089", "0.7707415", "0.76868755", "0.7679345", "0.7669797", "0.76643616", "0.7652391", "0.7643138", "0.7621919", "0.7607202", "0.76003534", "0.7597947", "0.75733525", "0.7522718", "0.7521333", "0.75145185", "0.7510915", "0.74886477", "0.7486463", "0.7483941...
0.0
-1
Override this method with your web page content.
def body_content raise NotImplementedError end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def get...
[ "0.67525566", "0.67525566", "0.67525566", "0.67525566", "0.67525566", "0.67525566", "0.67525566", "0.67525566", "0.67525566", "0.67525566", "0.67525566", "0.67525566", "0.67525566", "0.67525566", "0.661658", "0.6615409", "0.65340304", "0.65335", "0.65335", "0.65335", "0.64406...
0.6147918
37
Override this method to customize the title tag.
def page_title() nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def title_tag\n content_tag :title, title_text.to_s\n end", "def title(title=\"\")\n self.tag('title', title)\n end", "def title\n\t\tbase_title = title_extend\n\t\tif @title.nil?\n\t\t\tbase_title\n\t\telse\n\t\t\t\"#{base_title} | #{@title}\"\n\t\tend\n\tend", "def title=(value)\n super(valu...
[ "0.82337034", "0.78147423", "0.78034276", "0.77125376", "0.7692614", "0.76444685", "0.7644385", "0.7644385", "0.7644385", "0.7644385", "0.7644385", "0.7644385", "0.7644385", "0.7586405", "0.7569838", "0.75525004", "0.75141096", "0.75141096", "0.7465863", "0.7462345", "0.74623...
0.0
-1
Override this method with the chain of objects that corresponds to the user's position in the navigational structure. For instance, if the user is viewing a bug within an environment within a Project, you'd want to
def breadcrumbs() [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ancestors() end", "def ancestors; end", "def ancestors; end", "def ancestors; end", "def ancestors; end", "def ancestors\n end", "def go_to_where_you_belong\n \n end", "def parents\n references\n end", "def navigation\n\t\t\t@navigation\n\t\tend", "def navigation_children\n so...
[ "0.54851323", "0.5485088", "0.5485088", "0.5485088", "0.5485088", "0.53939956", "0.5301003", "0.5279507", "0.5265337", "0.52652407", "0.5195883", "0.5168399", "0.51625544", "0.5157405", "0.51552415", "0.51255256", "0.51174754", "0.5091025", "0.5046912", "0.5040417", "0.503735...
0.0
-1
Override this method to populate a set of ataglance numerical stats that will appear alongside the breadcrumbs. This method should returrn an array of arrays. The values of each inner array should be 1. the number to display, 2. a description of what the number represents, in singular, and 3. optionally, the plural form of 2.
def breadcrumbs_stats() [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def data\n final = [[\"25%\", 0], [\"50%\", 0], [\"75%\", 0], [\"100%\", 0]]\n self.usages.each do |usage|\n if usage.percent > 75 && usage.percent <= 100\n final[0][1] += 1\n final[1][1] += 1\n final[2][1] += 1\n final[3][1] += 1\n elsif usage.percent > 50 && usage.perc...
[ "0.57957405", "0.56050897", "0.55351496", "0.5474018", "0.5409218", "0.5337078", "0.53312075", "0.5325674", "0.52963126", "0.5263669", "0.52484673", "0.5205255", "0.5205255", "0.5200835", "0.5190775", "0.5168851", "0.51649445", "0.5156452", "0.51553375", "0.51437587", "0.5136...
0.6077536
0
HELPERS Like link_to, but makes a button. This much simpler version does not wrap it in a form, but instead uses the buttons.js.coffee file to add `` behavior to it.
def button_to(name, location, overrides={}) button name, overrides.reverse_merge(href: location) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def button_to( url, text = url, opts = {} )\n tag :button, text, opts.merge( url: url )\nend", "def bp_button(*args, &block)\n if block_given?\n options = args.first || {}\n html_options = args.second\n bp_button(capture(&block), options, html_options)\n else\n label = args.firs...
[ "0.77087826", "0.762886", "0.75721055", "0.75568324", "0.7550194", "0.74581677", "0.7433979", "0.7352617", "0.7334467", "0.73080975", "0.7260228", "0.7200416", "0.71913296", "0.71886647", "0.7183964", "0.71102065", "0.7056903", "0.70003057", "0.6990818", "0.6987437", "0.69111...
0.6481846
49
generate population with random filled members
def generate_population Array.new.tap do |population| Data::POPULATION_LENGTH.times do population.push(generate_random_member) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_population\n (0...@pop_size).each do\n chromosome = Chromosome.new\n (0...@num_genes).each do |_i|\n gene = rand 0..1\n chromosome << gene\n end\n evaluate_chromosome chromosome\n @chromosomes << chromosome\n end\n end", "def generate_initial_population\n ...
[ "0.77165264", "0.75206304", "0.72913057", "0.72913057", "0.7075215", "0.70726", "0.70457906", "0.6947969", "0.6929239", "0.68909025", "0.68671143", "0.6807688", "0.6793486", "0.6788079", "0.67029166", "0.67006636", "0.6699862", "0.66874933", "0.660266", "0.64680004", "0.63989...
0.7945086
0
Returns the list of books titles that require mapping
def missing_mappings books_with_missing_mapping.map(&:title) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_books_w_matching_title(title)\n books = @mybooks.get_books_by_title(title)\n\tbooks.each {|book| puts \"#{book[:key]} | #{book[:author]}, #{book[:title]}\"}\nend", "def book_mapping(book)\n title = book.title.downcase.gsub(/\\s+/, '')\n CONFIG[:sources][translation][:mappings][title...
[ "0.69025683", "0.6664996", "0.6332127", "0.63293105", "0.62854755", "0.6246722", "0.6224005", "0.61639774", "0.6144208", "0.6053566", "0.60528654", "0.60228664", "0.5941101", "0.59186614", "0.5905289", "0.58911085", "0.58618873", "0.5844521", "0.58437264", "0.58156776", "0.58...
0.76230174
0
Srapes single book translation
def scrape_book(book) print "\nScraping #{book.title}:" unless Rails.env.test? book.chapters_count.times do |i| print "\n#{i + 1}: " unless Rails.env.test? scrape_chapter(book, i + 1) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_by_slug(slug)\n record = @dao.search({ 'slug' => slug }, { limit: 1 })\n translate(record)\n end", "def translate\n api = ENV['API']\n url = 'https://translation.googleapis.com/language/translate/v2?key='\n target_language = self.phrasebook.language.abbr\n input = self.phrase.inp...
[ "0.5988808", "0.5945534", "0.59305304", "0.5876004", "0.5778311", "0.5680672", "0.5604238", "0.5564696", "0.554178", "0.5504638", "0.5498646", "0.5491932", "0.54851973", "0.54801464", "0.54512465", "0.54212636", "0.54133594", "0.5410673", "0.5404049", "0.54003185", "0.5386227...
0.48851603
95
Scrapes the verse text and creates the Bible::Verse. If the verse wasn't blank recoursively calls the function for scraping next verse
def scrape_verses(book, chapter, verse_number = 1) process_verse(book, chapter, verse_number) && scrape_verses(book, chapter, verse_number + 1) rescue OpenURI::HTTPError out false sleep(30) scrape_verses(book, chapter, verse_number) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_verse(book, chapter, verse_number)\n mapping = book_mapping(book)\n verse_text = scrape_verse(mapping, chapter, verse_number)\n out create_verse(book, chapter, verse_number, verse_text) if verse_text\n end", "def get_votd\n netbible_data = JSON.parse(HTTParty.ge...
[ "0.66651857", "0.60185486", "0.5984569", "0.57013804", "0.56346095", "0.55484354", "0.55468434", "0.5345324", "0.5207973", "0.50833035", "0.5078312", "0.5074357", "0.50493443", "0.50434434", "0.5029818", "0.49828693", "0.4969075", "0.49510396", "0.4945061", "0.49401522", "0.4...
0.60670334
1
Scrapes verse text and if it exists creates a verse
def process_verse(book, chapter, verse_number) mapping = book_mapping(book) verse_text = scrape_verse(mapping, chapter, verse_number) out create_verse(book, chapter, verse_number, verse_text) if verse_text end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_verse(book, chapter, verse_number, verse_text)\n Bible::Verse.create!({\n book: book,\n chapter: chapter,\n order: verse_number,\n text_translations: {\n translation => verse_text\n } \n })\n end", "def add_se...
[ "0.59089994", "0.58481884", "0.5305883", "0.5245764", "0.5184551", "0.51656747", "0.5018844", "0.49730462", "0.49343687", "0.492669", "0.49102795", "0.4910154", "0.48817116", "0.48749453", "0.48701695", "0.48669863", "0.48545125", "0.48519042", "0.4844091", "0.48378724", "0.4...
0.5777098
2
Gets the book mapping name for the scraping puposes
def book_mapping(book) title = book.title.downcase.gsub(/\s+/, '') CONFIG[:sources][translation][:mappings][title] || title end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def missing_mappings\n books_with_missing_mapping.map(&:title)\n end", "def map_name; end", "def map_name; $game_temp.map_names[@map_id]; end", "def get_name_mapping(pdfs_filename)\n raise \"call abstract method 'get_name_mapping(pdfs_filename)', please implement it in the subclass!\"\...
[ "0.6195914", "0.5830646", "0.5811328", "0.57970804", "0.56452596", "0.56055975", "0.5582518", "0.55486625", "0.54268086", "0.54221135", "0.5399856", "0.5393627", "0.53840697", "0.5372171", "0.5275032", "0.52674854", "0.5250245", "0.5216253", "0.5197439", "0.5182246", "0.51789...
0.7194218
0
Creates verse in the book
def create_verse(book, chapter, verse_number, verse_text) Bible::Verse.create!({ book: book, chapter: chapter, order: verse_number, text_translations: { translation => verse_text } }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @verse = Verse.new(params[:verse])\n\n respond_to do |format|\n if @verse.save\n format.html { redirect_to @verse, notice: 'Verse was successfully created.' }\n format.json { render json: @verse, status: :created, location: @verse }\n else\n format.html { render ac...
[ "0.6482045", "0.6482045", "0.63983214", "0.63827085", "0.60904753", "0.5927363", "0.59233105", "0.5917184", "0.5910559", "0.5905864", "0.58396024", "0.57493496", "0.5744076", "0.57306373", "0.57191336", "0.56805056", "0.56784487", "0.5669214", "0.5654265", "0.5654265", "0.561...
0.8155077
0
Gets the bible source url
def url CONFIG[:sources][translation][:url] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def source_uri\n URI.parse(url_for(@software))\n end", "def full_url\n self.source.full.url\n end", "def source_url\n settings.source_url\n end", "def url\n config.source_host_url\n end", "def content\n self.source? ? self.source.url : self.default_source_url\n e...
[ "0.7709089", "0.76768625", "0.75086725", "0.73601705", "0.7138343", "0.7138343", "0.69972104", "0.695548", "0.69356626", "0.6927709", "0.69160104", "0.69160104", "0.69160104", "0.69160104", "0.69160104", "0.6710826", "0.67029524", "0.66960347", "0.6690352", "0.66252196", "0.6...
0.66532016
19
Gets the translation code depending on the scraper class
def translation @translation ||= name.underscore.split('/').last end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translation_class\n const_get translation_class_name\n end", "def extract_code_language(attr); end", "def extract_code_language!(attr); end", "def find_lang (lang_code)\n LANGUAGE_LIST.each do |element|\n if element[1] == lang_code \n return element[0] \n end\n ...
[ "0.7067807", "0.6085108", "0.598393", "0.57998097", "0.5782291", "0.5782291", "0.5782291", "0.5782291", "0.57471645", "0.57222545", "0.5684312", "0.5636139", "0.56308925", "0.5627755", "0.56120497", "0.5563191", "0.5561217", "0.5561217", "0.55567145", "0.5525062", "0.552436",...
0.60626537
2
Returns the list of books titles that require mapping
def books_with_missing_mapping Bible::Book.all.select do |book| mapping = book_mapping(book) Rails.logger.info("Mapping Check: #{book.title}") begin out scrape_verse(mapping, 1, 2), true rescue OpenURI::HTTPError out false, true end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def missing_mappings\n books_with_missing_mapping.map(&:title)\n end", "def list_books_w_matching_title(title)\n books = @mybooks.get_books_by_title(title)\n\tbooks.each {|book| puts \"#{book[:key]} | #{book[:author]}, #{book[:title]}\"}\nend", "def book_mapping(book)\n title = book...
[ "0.76230174", "0.69025683", "0.6664996", "0.63293105", "0.62854755", "0.6246722", "0.6224005", "0.61639774", "0.6144208", "0.6053566", "0.60528654", "0.60228664", "0.5941101", "0.59186614", "0.5905289", "0.58911085", "0.58618873", "0.5844521", "0.58437264", "0.58156776", "0.5...
0.6332127
3
Outputs iteration result in a Rspec like format
def out(result, revert = false) (result ? print('.'.green) : print('F'.red)) unless Rails.env.test? revert ? !result : result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testi_display_result\n\t\t\tputs testi_stats\n\t\tend", "def results_to_html\n results_html = \"<p>Here are the last #{@results.length} test results:</p>\"\\\n \"<table style='width:100%;font-size:11px;'><tr>\"\\\n \"<th align='left'>Server</th><th align='left'>Download</th>\"\\\n \"<th ali...
[ "0.6464033", "0.643426", "0.634009", "0.6297308", "0.62467283", "0.62467283", "0.62330604", "0.6203041", "0.61640614", "0.6148228", "0.61408293", "0.61239874", "0.61081845", "0.61047155", "0.60518044", "0.60356224", "0.60198784", "0.6013839", "0.60074395", "0.5974336", "0.596...
0.0
-1
GET /services GET /services.json
def index if params[:processed].nil? @demands = Demand.scoped( :include => [:svns, :vms, :books, :enquiries], :order => "created_at DESC").page(params[:page]).per(10) else @demands = Demand.scoped( :include => [:svns, :vms, :books, :enquiries], :order => "created_at DESC").where(:processed => false).page(params[:page]).per(15) end respond_to do |format| format.html # index.html.erb format.json { render json: @demands } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n endpoint(get(services_url).body)\n end", "def services\n params = { command: 'account_services' }\n get('/json.php', params)\n end", "def list_services\n response = @http_client.get(prefix_path('services'))\n Response.new(response)\n end", "def services\n ...
[ "0.77775925", "0.7774661", "0.74383265", "0.7387468", "0.72641426", "0.72240984", "0.7216751", "0.708174", "0.6964788", "0.6895161", "0.68837124", "0.68795043", "0.6869667", "0.6818663", "0.6798342", "0.67873055", "0.67873055", "0.67873055", "0.6732333", "0.66650873", "0.6649...
0.0
-1
PUT /services/1 PUT /services/1.json
def update @demand = Demand.find(params[:id]) @demand.user_id = current_user.id @user = User.find(@demand.user_id) respond_to do |format| if @demand.update_attributes(params[:demand]) Notifier.processed_demands(@demand,@user).deliver if Rails.env.production? format.html { redirect_to services_path, notice: '申し込みは正常に処理されました' } format.json { head :ok } else format.html { render action: "edit" } format.json { render json: @demand.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @service.update(service_params)\n render json: @service, status: :ok, location: @service\n else\n render json: @service.errors, status: :unprocessable_entity\n end\n end", "def update_service(id, options={})\n self.class.put(\"/services/#{id}.json?apikey=#{apikey}\", :q...
[ "0.69190645", "0.688255", "0.66448134", "0.6633124", "0.6563937", "0.6563937", "0.64984876", "0.6493746", "0.64487135", "0.6349005", "0.6341838", "0.6330206", "0.6330206", "0.62442744", "0.6220658", "0.618756", "0.61561865", "0.6136029", "0.6125843", "0.61179686", "0.6116355"...
0.0
-1
What all happens? 1. We create the api method which defines: a. URL b. Method (get, post, etc) c. Params d. Headers e. URL Arguments (id, etc)
def before(api_method) api_method.headers.apply({ ruby_version: RUBY_VERSION, api_version: "v0" }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method_missing(method_id, *params)\n _request(method_id.to_s.sub('_api', ''), *params)\n end", "def api_request method, params = nil\n\t\t\tconnection = ZenfolioAPI::HTTP.new()\n\t\t\t@response = connection.POST(method, params, @auth.token)\n\t\tend", "def http_parse_args\n [(self.api.base_url...
[ "0.7094533", "0.6870368", "0.68259543", "0.6752628", "0.6747861", "0.66281503", "0.6616732", "0.6595478", "0.6595478", "0.6526356", "0.6487425", "0.64799434", "0.6470975", "0.6460656", "0.64530885", "0.6429375", "0.64285636", "0.64250046", "0.6404925", "0.6404423", "0.6389105...
0.0
-1
the constructor Required parameters arch_dev_key:: Your Architect dev key headers:: headers for the request for rails that would be request.env Returns a new instance of Wapl
def initialize(arch_dev_key = "", headers = {}) @dev_key= arch_dev_key @header_string = self.parse_headers(headers) @api_root="http://webservices.wapple.net" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(api_key)\n @api_key = api_key\n self.class.headers({\n \"X-API-Key\" => @api_key,\n \"Accept\" => \"application/json\"\n })\n end", "def initialize\n @headers = {\n \"Authorization\" => \"token #{ENV[\"AUTH_TOKEN\"]}\",\n \"User-Agent\" =>...
[ "0.58475095", "0.5810169", "0.5810169", "0.5810169", "0.5810169", "0.5810169", "0.5806213", "0.5740626", "0.57339674", "0.57242423", "0.561992", "0.5587999", "0.5584692", "0.5577625", "0.5553039", "0.55166745", "0.5484508", "0.54777163", "0.5474799", "0.54689604", "0.5440999"...
0.72529143
0
Parses the request headers and gets only HTTP_ headers returns properly formatted string of keys and values
def parse_headers(headers_hash) header_string = "" for header in headers_hash.select { |k,v| k.match("^HTTP.*") } do header_string += header[0]+":"+header[1]+"|" end return header_string end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_headers\n headers = {}\n @request.lines[1..-1].each do |line|\n # puts line.inspect\n # puts line.split.inspect\n return headers if line == \"\\r\\n\" # Because HTTP header's last line will be /r/n we return bc we're done\n header, value = line.split\n header = norma...
[ "0.7738052", "0.76375735", "0.7526284", "0.74985033", "0.7422471", "0.738596", "0.7347085", "0.7345516", "0.7265439", "0.72246337", "0.72185683", "0.7157916", "0.7121895", "0.7113913", "0.7101747", "0.70940393", "0.7065739", "0.7043374", "0.7026042", "0.70230514", "0.7005084"...
0.78744954
0
Communicates with the API Does a simple POST call with required arguments Always sends the dev_key and the headers path:: path to the API resource arg:: hash containing additional arguments (see wapl.info docs) Returns HTTP::result object
def send_request(path,arg = {}) url= URI.parse(@@api_root + @@resources[path].to_s) post_arg = {'devKey'=>@dev_key , 'headers'=>@header_string } post_arg.merge!(arg) res = Net::HTTP.post_form(url, post_arg) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post(path, params={})\n params[:apikey] = self.api_key\n RestClient::Request.execute(\n :method => :post,\n :url => \"#{self.uri}#{path}\",\n :headers=> {},\n :payload=> params,\n :verify_ssl=> @ssl_verify )\n end", "def http_post_request\n begin\n ...
[ "0.71245295", "0.7024135", "0.6828241", "0.6730758", "0.6640975", "0.6603632", "0.65757287", "0.65466326", "0.6541607", "0.65293646", "0.65129215", "0.65059215", "0.64961135", "0.6458618", "0.64403474", "0.6424357", "0.64227504", "0.64114785", "0.6407122", "0.63769543", "0.63...
0.734838
0
gets the info about mobile device Returns a Hash containing information model and the maker
def get_mobile_device() res = self.send_request 'get_mobile_device' device_info_xml = REXML::Document.new(res.body).root rez ={} device_info_xml.elements.each do |el| rez.merge! Hash[el.name.to_s,el.text.to_s] end return rez end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hm_device options\n id = options[:id] || 1\n {\n id: id,\n device_type: options[:device_type] || 'Mobile',\n operating_system_name: options[:os] || 'android',\n operating_system_version: options[:os_version] || '1.2.3',\n serial: \"serial#{id}\",\n model: options[:model] || 'Test Model',\n ...
[ "0.6981255", "0.6514642", "0.6396793", "0.63257015", "0.63199264", "0.62843055", "0.62265646", "0.61616135", "0.61467856", "0.614296", "0.61323994", "0.60735446", "0.6047256", "0.5994361", "0.5986404", "0.5956398", "0.59381473", "0.5819512", "0.5816249", "0.5765577", "0.57632...
0.76272607
0
checks whether the device is mobile Returns 1 for true and 0 for a desktop browser
def is_mobile_device() res = self.send_request 'is_mobile_device' return res.body end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mobile?\n is_mobile_device?\n end", "def mobile_device?\r\n if session[:mobile_param]\r\n session[:mobile_param] == \"1\"\r\n else\r\n request.user_agent =~ /Mobile|webOS/\r\n end\r\n end", "def mobile_device?\n request.user_agent =~ /Mobile|webOS/\n end", "def mobile_device?\...
[ "0.8076384", "0.80602413", "0.80303675", "0.8020441", "0.797894", "0.797894", "0.79370624", "0.7931952", "0.7920051", "0.7920051", "0.7893876", "0.7860712", "0.7858715", "0.78377277", "0.77994734", "0.77473164", "0.76635474", "0.7627628", "0.76069444", "0.7603537", "0.7571348...
0.7835746
14
Submits the wapl markup along with the headers wapl_xml:: Properly formatted WAPL XML (see docs at htp://wapl.info) or use the WaplHelper module Returns hash containing proper markup for the current device required headers which need to be sent back to the device
def get_markup_from_wapl(wapl_xml="") raise ArgumentError, "Empty string" if wapl_xml == "" res = self.send_request 'get_markup_from_wapl', {'wapl'=>wapl_xml} unless res.body.scan('WAPL ERROR').empty? markup = wapl_xml + "<!-- WAPL XML ERROR #{ res.body } -->" headers = '' else markup_res_xml = REXML::Document.new(res.body).root res = {} markup_res_xml.elements.each('header/item') do |el| splits = el.text.split(': '); h = Hash[splits[0], splits[1]] res.merge! h end markup = markup_res_xml.elements.collect('markup') { |el| el.cdatas} end return {'markup' => markup, 'headers'=>res } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start_wapl\n return '<wapl xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://wapl.wapple.net/wapl.xsd\">'\n end", "def header_xml(xml, wsa)\n xml.Header {\n xml[\"#{namespace_key(:wsa)}\"].Action(wsa, \"#{namespace_key(:envelope)}:mustUnderstand\" ...
[ "0.62905717", "0.57353795", "0.54520994", "0.52583444", "0.52562726", "0.5240979", "0.5093215", "0.507722", "0.50446224", "0.4962244", "0.49343324", "0.48955902", "0.48765084", "0.48511264", "0.47940433", "0.47748822", "0.47698236", "0.4755278", "0.47207412", "0.47197038", "0...
0.6648892
0
submits the wapl markup url along with the headers brings back proper markup for the current device and required headers TODO / FIXME check whether supplied string is a url
def get_markup_from_url(makrup_url="") raise ArgumentError, "Wrong or empty url" if markup_url == "" res = self.send_request 'get_markup_from_url', { 'waplUrl'=>markup_url } markup_data = self.process_res_xml res.body return {'res'=>res, 'data'=> markup_data} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def i_html_string\n\t\tr = ''\n\n\t\t# weather\n\t\tif @data['weather'] then\n\t\t\tr << \"#{I_HTML_START}\"\n\t\t\tr << %Q|<A HREF=\"#{@url}\">|\n\t\t\tr << CGI::escapeHTML( WeatherTranslator::S.new( @data['weather']).translate( Words_en ).compact.capitalize )\n\t\t\tr << \"</A>#{I_HTML_END}\\n\"\n\t\telsif @data...
[ "0.5571151", "0.5467372", "0.53040355", "0.52713674", "0.5197263", "0.51627654", "0.5110203", "0.50959563", "0.5092019", "0.50630033", "0.50373507", "0.50055283", "0.4994572", "0.4983167", "0.49661353", "0.4945212", "0.49268618", "0.49079075", "0.48952198", "0.48885214", "0.4...
0.5175752
5