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
This probaly could be done in more "specy" way with loop but this will do for now
def multiple_places_in_city_from_beermapping(city) allow(BeermappingApi).to receive(:places_in).with(city).and_return( [ Place.new( name:"Oljenkorsi", id: 1), Place.new( name:"Kello baari", id: 2), Place.new( name:"Hopeatuoppi", id: 3)] ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def outputcase \n for i in 0...@records.recordsArr.length do\n\n isfit = checkMustHaveNotLimit @records.recordsArr[i]\n \n\n for j in 0...@records.recordsArr[i].valuesArr.length do\n print parameters.paramsArr[j].elementsArr[@records.recordsArr[...
[ "0.5171808", "0.5158201", "0.51521015", "0.51455355", "0.5117879", "0.5081813", "0.50799143", "0.5059243", "0.5039016", "0.50172246", "0.5005991", "0.5004115", "0.49803367", "0.49742758", "0.49685693", "0.49685693", "0.49677327", "0.4958952", "0.4946675", "0.4938495", "0.4933...
0.0
-1
Initialize this Pattern instance. site The Site. base The String path to the dir containing the pattern file. name The String filename of the pattern file. Returns the new Pattern.
def initialize(site, source, dir, name) @site = site @dir = dir @base = containing_dir(source, dir) @name = name read_yaml(@base, name) self.markup_escaped = CGI.escapeHTML(content) self.id = data.key?('id') ? data['id'].to_s : name.match(MATCHER)[1] self.section = data.key?('section') ? [data['section'].to_s] : [] self.usage = data.key?('usage') ? data['usage'].to_s : nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(site, name, patterns)\n @site = site\n @dir = ''\n @name = name\n @patterns = patterns\n\n self.basename = name.gsub(' ', '-')\n self.ext = '.html'\n self.data = {\n 'layout' => 'pattern_library',\n 'patterns' => patterns,\n 'sections' => patte...
[ "0.72502935", "0.7065959", "0.7036724", "0.6972731", "0.68835664", "0.6836079", "0.68202406", "0.6737908", "0.65452296", "0.64780134", "0.6436933", "0.6425312", "0.6369336", "0.633542", "0.620871", "0.6206066", "0.6169135", "0.6148808", "0.6123083", "0.6087598", "0.6087352", ...
0.5914717
30
Get the full path to the directory containing the pattern files
def containing_dir(source, dir) File.join(source, dir, '_patterns') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query\n dir, _, file = @pattern.gsub(/[_\\-\\*]+/, '').rpartition '/'\n dir.gsub(%r{/(\\w{,2})[^/]+}, '\\1') + # map 2 chars per folder\n file.gsub(/\\.\\w+/, '') # remove extension\n end", "def full_path\n look_in.each do |dir|\n extensions.each do |ext| \...
[ "0.68543875", "0.6758664", "0.67166877", "0.66465354", "0.6623477", "0.66223437", "0.6523856", "0.65213394", "0.65061957", "0.64749914", "0.6433306", "0.64152014", "0.6384811", "0.6368883", "0.63144666", "0.629667", "0.62882304", "0.6281049", "0.6274255", "0.6221876", "0.6221...
0.71348125
0
Obtain destination path. dest The String path to the destination dir. Returns destination file path String.
def destination(dest) # The url needs to be unescaped in order to preserve the correct filename path = Jekyll.sanitized_path(dest, CGI.unescape(url)) path = File.join(path, 'index.html') if path[/\.html$/].nil? path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destination(dest)\n File.join(dest, @ddir, @name)\n end", "def destination(dest)\n File.join(dest, @dir, insert_before_last_dot(@name, @nameextension))\n end", "def destination(dest)\n # The url needs to be unescaped in order to preserve the correct filename.\n path = File.joi...
[ "0.8428197", "0.7794281", "0.77484876", "0.7536702", "0.7441646", "0.7441646", "0.7353197", "0.72095585", "0.71266216", "0.69978476", "0.6919035", "0.6918112", "0.6850506", "0.67687774", "0.67319864", "0.6726791", "0.669323", "0.66200346", "0.6385388", "0.62795645", "0.624811...
0.6629053
17
Merge Pattern attributes to the data hash used by Liquid.
def to_liquid data.deep_merge({ 'id' => id, 'markup_escaped' => markup_escaped, 'markup' => content, 'section' => section }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def passive\t\n\thash=Digest::MD5.hexdigest(@tagpattern)\n\t[{:name=>\"tag pattern hash\",:string=>hash}]\nend", "def pattern\n attributes.fetch(:pattern)\n end", "def pattern\n attributes.fetch(:pattern)\n end", "def pattern\n attributes.fetch(:pattern)\n end"...
[ "0.60892904", "0.60045403", "0.60045403", "0.60045403", "0.5958694", "0.5882634", "0.54726464", "0.5471879", "0.5376867", "0.5358489", "0.53488773", "0.52894545", "0.52724844", "0.5250469", "0.51854295", "0.5165312", "0.5159891", "0.51457417", "0.51019835", "0.50978655", "0.5...
0.0
-1
Compares Pattern objects. First compares the Pattern id. If the ids are equal, it compares the Pattern filename. other The other Pattern we are comparing to. Returns 1, 0, 1
def <=>(other) cmp = id <=> other.id if 0 == cmp cmp = name <=> other.name end cmp end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ==(other)\n @pattern == other.pattern\n end", "def eql?(other)\n\t\t\tself.fileid.eql?(other.fileid)\n\t\tend", "def quick_compare(another)\n self == another || (self.kind_of?(File) && another.kind_of?(File) && self.path == another.path)\n end", "def find_same_files\n # loop over fin...
[ "0.6466042", "0.59572023", "0.57648844", "0.5756986", "0.5749427", "0.57184607", "0.5709936", "0.5666147", "0.5665333", "0.54457366", "0.535312", "0.5300145", "0.5281808", "0.52757215", "0.527003", "0.52358925", "0.5234192", "0.5227244", "0.5216049", "0.5175559", "0.51613545"...
0.0
-1
Returns the shorthand String identifier of this Pattern.
def inspect "<Pattern: #{id}>" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def short_identify\n \"# #{self.id}\"\n end", "def unique_format_name\n title + \" (#{id || \"?\"})\"\n end", "def identifier_for identifier\n \"#{name.gsub(/^.*::/,'').downcase}s.#{identifier}\"\n end", "def name_inline_pattern( rule_name )\n name = rule_name.is_a?(Name) ? rule_n...
[ "0.6508747", "0.63072586", "0.6242334", "0.62032664", "0.61931306", "0.6182131", "0.6154871", "0.6148119", "0.61242986", "0.61147285", "0.61147285", "0.6097492", "0.6067098", "0.5956153", "0.59534144", "0.59474945", "0.5936135", "0.5936135", "0.5911306", "0.58939284", "0.5891...
0.59110826
19
Initialize a LibraryPage instance. site The actual Site instance. name The String page name. patterns The Array of Pattern objects Returns a new LibraryPage instance.
def initialize(site, name, patterns) @site = site @dir = '' @name = name @patterns = patterns self.basename = name.gsub(' ', '-') self.ext = '.html' self.data = { 'layout' => 'pattern_library', 'patterns' => patterns, 'sections' => pattern_attr_hash('section'), 'title' => name } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate(site)\n patterns = read_content(site, '', '_patterns', Pattern)\n\n site.pages << LibraryPage.new(site, 'pattern library', patterns)\n end", "def initialize(website)\n\t\t@subpages = website.subpages\n\t\t@base_url = website.base_url\n\t\t@pattern_finder, @pattern_tester = PatternFinder...
[ "0.7092953", "0.57706034", "0.5765519", "0.5544619", "0.55328244", "0.5474454", "0.54677075", "0.5441894", "0.5421549", "0.5390345", "0.5369922", "0.52800405", "0.52580535", "0.5189265", "0.5183664", "0.5181913", "0.5167189", "0.5162886", "0.512814", "0.5125363", "0.5109584",...
0.77669084
0
Generates pattern library pages. site The current Site instance. Returns nothing than an electric wind.
def generate(site) patterns = read_content(site, '', '_patterns', Pattern) site.pages << LibraryPage.new(site, 'pattern library', patterns) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate(site)\n end", "def generate(site)\n site.data['pages'].each do |page|\n if !page['external']\n require 'cgi'\n\n page['name'] = CGI.escapeHTML(page['name']) if page['name']\n site.pages << SitePage.new(site, site.source, page)\n\n zones ...
[ "0.65836114", "0.65413934", "0.6440137", "0.6429966", "0.63806367", "0.6363609", "0.62894857", "0.62356853", "0.62140375", "0.61636025", "0.6128852", "0.60038644", "0.595365", "0.5952468", "0.5946774", "0.59301496", "0.5863687", "0.58497137", "0.5801128", "0.5790571", "0.5746...
0.80189425
0
Read all files in // and create a new object of the given class with each one site The current Site instance. dir The String path to the parent directory after the site.source. name The String filename. klass The Class used to represent files in the directory Returns an Array of the given class objects
def read_content(site, dir, magic_dir, klass) site.get_entries(dir, magic_dir).map do |entry| klass.new(site, site.source, dir, entry) if klass.valid?(entry) end.reject do |entry| entry.nil? end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_objects(dir_name, kind, klass)\n files(dir_name).map do |filename|\n # Read and parse data\n meta, content = *parse_file(filename, kind)\n\n # Get attributes\n attributes = {\n :filename => filename,\n :extension => File.extname(filename)[1..-1],\n ...
[ "0.71646094", "0.675514", "0.6575856", "0.6516473", "0.63850534", "0.63810027", "0.6378814", "0.60002357", "0.5986362", "0.59554523", "0.59429735", "0.5856373", "0.58408505", "0.57834756", "0.57754534", "0.57743114", "0.5752556", "0.5749027", "0.5711285", "0.5691513", "0.5649...
0.6546445
3
Statuses dont change a log, so keep them cached to make ticket listing faster.
def status_translations @status_translations ||= Assembla.statuses['ticket_statuses'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def statuses; end", "def status(memoize = true)\n if @status[:updated].nil? or not memoize or (memoize and not @status[:updated].nil? and \n ((Time.now - @status[:updated]) >= self.class.status_update_threshold))\n response = Crocodoc.connection.get 'document/status', :uuids => @uuid\n ...
[ "0.63542956", "0.61060333", "0.60173917", "0.5962851", "0.594984", "0.594984", "0.58934087", "0.58904743", "0.58904743", "0.5755886", "0.57496524", "0.5710642", "0.5637914", "0.55909044", "0.5580965", "0.5563831", "0.5544308", "0.55247486", "0.5512276", "0.5504211", "0.549452...
0.5505275
19
Translates a statusid into its statusname equivalent.
def status_string number status_translations.each do |hash| if hash['list_order'] == number return hash['name'] end end 'Unknown' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getStatusName(status_id)\n \tbegin\n statusname = Capstatus.find(status_id).status\n rescue ActiveRecord::RecordNotFound => e\n statusname = ''\n end \n return statusname\n end", "def status_name\n STATUS[self.status_id][0]\n end", "def status_name\n STATUSES[status]\n end", ...
[ "0.71683586", "0.69419134", "0.6776753", "0.6695358", "0.6592659", "0.6433393", "0.6316047", "0.6299464", "0.6212713", "0.61991763", "0.6151669", "0.6131283", "0.6121865", "0.60478914", "0.6042841", "0.60187316", "0.6017905", "0.59993637", "0.59964067", "0.59769756", "0.59593...
0.5483702
46
Translates a milestoneid into its milestonename equivalent.
def milestone_string number milestone_translation.each do |hash| if hash['id'] == number return hash['title'] end end 'Unknown' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def milestone_name\n milestone ? milestone.name : 'None'\n end", "def milestone(project, id)\n get(\"/projects/#{url_encode project}/milestones/#{id}\")\n end", "def mission_id_to_locale_id(id)\n \"m_#{id}\"\nend", "def group_milestone(id, milestone_id)\n get(\"/groups/#{url_encode id}/mile...
[ "0.6928679", "0.6254726", "0.6254099", "0.61892503", "0.5767911", "0.5595989", "0.55171436", "0.5505468", "0.5481009", "0.5481009", "0.54305774", "0.53850824", "0.53814155", "0.53814155", "0.53612965", "0.53612965", "0.53612965", "0.53075343", "0.5302446", "0.52898306", "0.52...
0.69942707
0
You may (and should) use the substrings method you wrote in the previous exercise. For the purposes of this exercise, you should consider all characters and pay attention to case; that is, "AbcbA" is a palindrome, but neither "Abcba" nor "AbcbA" are. In addition, assume that single characters are not palindromes. input: string output: string only palindromic substrings iterate through the array created by substrings method in previous exercise. If string == string.reverse, add to output
def substrings(string) result = [] 0.upto(string.size-1) do |index1| index1.upto(string.size-1) do |index2| result << string[index1..index2] end end result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def palindromes(string)\n array = substrings(string)\n array.select { |sub| sub == sub.reverse }\nend", "def palindromes(str)\n palindromic_substrings = []\n\n substrings = substrings(str)\n puts substrings\n\n substrings.each do |substr|\n palindromic_substrings << str if str == str.reverse\n end\n\n ...
[ "0.87072676", "0.8559117", "0.8478173", "0.84776634", "0.84263945", "0.83970183", "0.8390052", "0.8365389", "0.83221525", "0.8313065", "0.8312266", "0.83117115", "0.82449204", "0.8191274", "0.8168176", "0.81566864", "0.8103453", "0.79505295", "0.791351", "0.78644335", "0.7851...
0.0
-1
number original number Examples is_odd(3) => 'true' Returns if number is odd.
def is_odd(number) return true if number % 2 != 0 return false if number % 2 == 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_odd?(number)\n number.to_i.odd?\nend", "def is_odd(number)\n if number % 2== 1\n return true\n else \n return false\n end \nend", "def is_odd?(number)\n\n\t#WHY WASN\"T MODULO WORKING?\n\t# if (number%2) != 0\n\t# \tputs \"true\"\n\t# \treturn true\n\tnumber = number.to_i\n\tif n...
[ "0.8559289", "0.849433", "0.8478733", "0.8477539", "0.8471775", "0.84578466", "0.84378946", "0.8386037", "0.8365827", "0.83539623", "0.8351008", "0.8346245", "0.8344417", "0.83180285", "0.8313873", "0.8311684", "0.830552", "0.830552", "0.8301595", "0.82871574", "0.8277806", ...
0.83059853
16
The NTP log file timestamp epoch begins at 18581117 00:00:00 UTC See: Modified Julian Date
def ntp_epoch_start @ntp_epoch_start ||= Time.parse("1858-11-17 00:00:00 UTC") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def timestamp\n time = Time.now.getutc\n\n secs = time.to_i\n millis = time.nsec/1000000\n\n return @last if @millis == millis && @secs == secs\n\n unless secs == @secs\n @secs = secs\n @date = time.strftime('%Y-%m-%d %H:%M:%S.')\n end\n\n @millis = millis\n @l...
[ "0.6870663", "0.67468315", "0.6588951", "0.65676695", "0.6539978", "0.64663494", "0.64577335", "0.64212644", "0.6386592", "0.6355795", "0.6292023", "0.62746805", "0.62677926", "0.62464166", "0.6234186", "0.6216995", "0.6212133", "0.6208646", "0.61051697", "0.61007607", "0.608...
0.6817118
1
File::foreach gives us individual lines as strings to play with Try to figure out what kind of logfile we're dealing with, and convert appropriately
def convert_line(line, filename) if filename.include?('loops') || filename.include?('peers') convert_ntp_line(line) elsif filename.include?('message') convert_message_line(line) elsif filename.include?('nagios') convert_nagios_line(line) else convert_ntp_line(line) # give up, fall back on original behavior end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call\n @logs = []\n @logs_unique = nil\n File.foreach(@filename) do |line|\n if m = line.match(@log_format)\n @logs.push Log.new(*m.captures)\n else\n raise Error, \"Unmatched lines: #{line}\"\n end\n end\n end", "def each_log_line\n File.readlines('/var/log/syslo...
[ "0.6180719", "0.5969064", "0.5791305", "0.56926274", "0.558846", "0.55353624", "0.5491865", "0.54766387", "0.53825486", "0.53684986", "0.53387076", "0.53376573", "0.52244097", "0.5204976", "0.5184397", "0.5157974", "0.5156808", "0.5110752", "0.5104826", "0.509945", "0.5036424...
0.6560255
0
57844 27156.724 127.0.0.1 9014 0.005995526 0.032311653 3.937740536 0.002301804
def convert_ntp_line(line) line_array = line.split(' ') days = line_array[0] secs = line_array[1] human_timestamp = ntp_epoch_start.add_days(days).add_secs(secs) format(human_timestamp, line_array, 2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def latency; end", "def on_getaddr\n #addrs = @node.addrs.select{|a| a.time > Time.now.to_i - 10800 }.shuffle[0..250]\n #p \"<< addr (#{addrs.size})\"\n #send_data P::Addr.pkt(*addrs)\n end", "def server_timing; end", "def extract_data(server_num, source_file, max_samples)\n\traw_data = Arr...
[ "0.5859646", "0.5540546", "0.5472723", "0.54419523", "0.53723776", "0.53193414", "0.53186256", "0.53156435", "0.53057015", "0.5301863", "0.5288774", "0.52624035", "0.5213883", "0.5213883", "0.5139019", "0.5133436", "0.5133436", "0.5116206", "0.5084869", "0.5046279", "0.504513...
0.0
-1
Jan 1 00:00:00 rest of the log message goes here
def convert_message_line(line) line_array = line.split(' ') human_timestamp = Time.parse(line_array[0..2].join(' ')) format(human_timestamp, line_array, 3) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log(message)\n puts Time.now.strftime('[%d-%b-%Y %H:%M:%S] ') + message\n end", "def daily\n logger.info \" daily\"\n end", "def time_stamp(event)\n file_local_write(@logfile,\"\\nKeylog Recorder #{event} at #{Time.now.to_s}\\n\\n\")\n end", "def success\n @log[Date.today.iso8601] = 0...
[ "0.6615549", "0.64032143", "0.6076639", "0.6061115", "0.6035361", "0.6035348", "0.6031951", "0.6005669", "0.59837145", "0.58933556", "0.5823868", "0.58227754", "0.5806736", "0.58067167", "0.57982236", "0.5785717", "0.57604456", "0.5743552", "0.5736973", "0.571662", "0.5713966...
0.0
-1
[1490289098] SERVICE ALERT: hostname and other message stuff here where the bit in brackets is an epoch timestamp :(
def convert_nagios_line(line) line_array = line.split(' ') epoch_timestamp = line_array[0].gsub(/\D/, '') human_timestamp = Time.at(epoch_timestamp) format(human_timestamp, line_array, 1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_metadata(msg)\n return {:timestamp=>Time.now.utc.strftime('%FT%T.%3NZ'),\n :msg=>msg,\n :ip=>@ip,\n :pid=>@pid}\n end", "def format_log_message(msg)\n \"[Cloudtasker/Server][#{id}] #{msg}\"\n end", "def fmt(data)\n pkt = \"<190>1 \"\n pkt += \"#{da...
[ "0.59727615", "0.59495276", "0.5854783", "0.5762841", "0.5628444", "0.55867153", "0.5551732", "0.55501735", "0.5542433", "0.55044085", "0.5467815", "0.54640925", "0.54603654", "0.54250056", "0.54139346", "0.5406667", "0.5406667", "0.5406667", "0.5406667", "0.5406667", "0.5406...
0.54702663
10
Format the timestamp consistently and smash everything back into a string
def format(human_timestamp, line_array, offset) human_timestamp.getlocal.strftime('%Y-%m-%d %H:%M:%S%z') + ' ' + line_array[offset..-1].join(' ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_timestamp(t)\n t.strftime('%s%9N')\n end", "def format_timestamp(raw_timestamp)\n Time.at(raw_timestamp).getutc.strftime(\"%Y%m%d%H%M%S\")\n end", "def timestamp\n time_formated = Time.now.to_i.to_s.reverse.chop.chop.chop.reverse.to_i\n return time_formated.to_s\nend", "def forma...
[ "0.79133564", "0.78061295", "0.7656879", "0.75102085", "0.73122746", "0.72326493", "0.7106478", "0.7095668", "0.70630807", "0.70280087", "0.6971394", "0.6960248", "0.69185454", "0.684056", "0.68128824", "0.6770847", "0.6754066", "0.67479277", "0.66478497", "0.66321516", "0.66...
0.6505959
29
GET /advance_payments/1 GET /advance_payments/1.xml
def show @session_id=session[:id] @session = Session.find(session[:id]) @person = Person.find(@session.person_id) @advance_payment = AdvancePayment.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @advance_payment } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @payments = Payment.top\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @payments }\n end\n end", "def index\n @payments = Payment.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :...
[ "0.66702145", "0.6517796", "0.64454174", "0.6330063", "0.632101", "0.632101", "0.62914217", "0.61728317", "0.61453664", "0.6119832", "0.60544133", "0.60145193", "0.6006985", "0.6003804", "0.59896874", "0.5969986", "0.5966092", "0.59079444", "0.5901139", "0.5896285", "0.588553...
0.61688644
8
GET /advance_payments/new GET /advance_payments/new.xml
def new @advance_payment = AdvancePayment.new #Get the org_code and org_location in people table based on user id. @session_id=session[:id] @session = Session.find(session[:id]) @person = Person.find(@session.person_id) @admission=Admission.find(:all,:conditions => "org_code='#{@person.org_code}' and admn_status='Admitted'", :order =>"id DESC") respond_to do |format| format.html # new.html.erb format.xml { render :xml => @advance_payment } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @payment = Payment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @payment }\n end\n end", "def new\n @pay_period = PayPeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pay_p...
[ "0.7532973", "0.72531605", "0.7230576", "0.7155683", "0.7142538", "0.71053815", "0.70748746", "0.70538926", "0.7030893", "0.7028818", "0.7026227", "0.7015864", "0.70145726", "0.7003628", "0.69574434", "0.6943745", "0.69333065", "0.69333065", "0.69333065", "0.6913001", "0.6908...
0.70472574
8
POST /advance_payments POST /advance_payments.xml
def create @advance_payment = AdvancePayment.new(params[:advance_payment]) @session_id=session[:id] @session = Session.find(session[:id]) @person = Person.find(@session.person_id) @advance_payment.already_paid_amount=@advance_payment.gross_amount.to_f+@advance_payment.already_paid_amount.to_f respond_to do |format| if @advance_payment.save # format.html { redirect_to(@advance_payment, :notice => 'advance payments was successfully created.') } format.html { redirect_to("/advance_payments/report_bill/#{@advance_payment.id}?print_type=original&format=pdf", :notice => 'AdvancePayment was successfully created.') } format.xml { render :xml => @advance_payment, :status => :created, :location => @advance_payment } else @adm=Admission.find_by_admn_no(@advance_payment.admn_no) if(@adm) @patient_name=@adm.patient_name @ward=@adm.ward @room=@adm.room @floor=@adm.floor @bed=@adm.bed end format.html { render :action => "new" } format.xml { render :xml => @advance_payment.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def payment\n @amount = 10.00\n @sim_transaction = AuthorizeNet::SIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], @amount, :hosted_payment_form => true)\n @sim_transaction.set_hosted_payment_receipt(AuthorizeNet::SIM::HostedReceiptPage.new(:link_metho...
[ "0.66339236", "0.6558264", "0.651462", "0.64256984", "0.6331028", "0.6290555", "0.6245464", "0.6245464", "0.6118071", "0.60402244", "0.60211474", "0.6014517", "0.6008838", "0.59904593", "0.5929309", "0.59058696", "0.5878829", "0.5877097", "0.5873628", "0.58607525", "0.5847605...
0.56741595
39
PUT /advance_payments/1 PUT /advance_payments/1.xml
def update @advance_payment = AdvancePayment.find(params[:id]) respond_to do |format| if @advance_payment.update_attributes(params[:advance_payment]) format.html { redirect_to("/advance_payments/report_bill/#{@advance_payment.id}?print_type=original&format=pdf", :notice => 'Admission was successfully updated.') } #format.html { redirect_to("/advance_payments/?user_id=#{params[:user_id]}", :notice => 'AdvancePayment was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @advance_payment.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n ...
[ "0.6003731", "0.598196", "0.597565", "0.59570825", "0.5932758", "0.59015083", "0.5900349", "0.5873205", "0.58310246", "0.5761606", "0.5753884", "0.5748019", "0.57391423", "0.5705008", "0.5691757", "0.56869256", "0.5683306", "0.5683306", "0.5683306", "0.5683306", "0.5683306", ...
0.61908144
0
DELETE /advance_payments/1 DELETE /advance_payments/1.xml
def destroy @advance_payment = AdvancePayment.find(params[:id]) @advance_payment.destroy respond_to do |format| format.html { redirect_to(advance_payments_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def destroy\n @payment = Payment.find(params[:id])...
[ "0.70188254", "0.6736302", "0.6713614", "0.66653407", "0.66653407", "0.66278976", "0.6594388", "0.65304625", "0.64880747", "0.64765745", "0.6463586", "0.64344573", "0.6434148", "0.6396757", "0.634541", "0.6327807", "0.6327807", "0.6307478", "0.630463", "0.6293965", "0.6289044...
0.7350184
0
helpers for number of tiles per level
def very_easy_level_maker(game) level = Level.find_or_create_by(difficulty: "very easy") game.level = level level.games << game game.save! level.tiles.delete_all # binding.pry 4.times do |i| level.tiles << Tile.new(game_id: game.id) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tile_size level\n\t\t\t2 ** level\n\t\tend", "def level_size level\n\t\t\t@unit_size * tile_size(level)\n\t\tend", "def measure map, x, y \n if map[x][y] != 'land' || x >= 6 || y >= 6 #Ensures water, counted land, and coordinates\n return 0 #off the grid aren't counte...
[ "0.81527114", "0.7276575", "0.70323104", "0.70270157", "0.69605625", "0.68555665", "0.68508947", "0.6842748", "0.6816328", "0.6712837", "0.670293", "0.66650015", "0.66488445", "0.6601578", "0.65897065", "0.6551793", "0.65106344", "0.65039355", "0.6437292", "0.6436011", "0.640...
0.0
-1
Validates each segment of a constant path in the correct scope.
def on_constant_path(node) definitions = current_scope @in_constant_path = true # The first constant check should take data from parent scopes into # account. The following segments should not. method = :has_definition? node.children.each do |segment| name = segment.name unless definitions.send(method, :constant, name) error("undefined constant #{name}", segment) break end definitions = definitions.lookup(:constant, name) method = :defines? end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_constant_path?(token)\n current = scope\n\n token.name.each do |segment|\n found = current.lookup(:constant, segment)\n\n if found and token.line > found.token.line\n current = found\n else\n return false\n end\n end\n\n ...
[ "0.65460366", "0.58346784", "0.5795345", "0.5731851", "0.5427144", "0.51436055", "0.5097625", "0.50944304", "0.5082766", "0.50675106", "0.5052496", "0.5017125", "0.5006043", "0.5006043", "0.500037", "0.49975845", "0.49315766", "0.49291685", "0.4901817", "0.48924834", "0.48655...
0.6109865
1
storage :fog Override the directory where uploaded files will be stored. This is a sensible default for uploaders that are meant to be mounted:
def store_dir "uploads/attachments/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def store_dir\n 'file_uploads'\n end", "def store_dir\n \"uploads\"\n end", "def store_dir\n 'uploads'\n end", "def store_dir\n # \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n # This works for the file storage as well as Amazon S3 and Rackspace Cloud Files.\n # D...
[ "0.7506556", "0.7366542", "0.73328435", "0.73327684", "0.73038065", "0.7298899", "0.7278492", "0.7278492", "0.7278492", "0.72696203", "0.7245164", "0.72298074", "0.7226038", "0.7202023", "0.718703", "0.7179372", "0.7165151", "0.7150369", "0.7150369", "0.7150369", "0.7150369",...
0.0
-1
Return the character as a String object
def char self.class.codepoint2char(@codepoint) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getChar(c)\n c.chr\nend", "def getChar(c)\n c.chr\nend", "def char\n\t\t\t\t@char\n\t\t\tend", "def encode_character(char)\n if @@has_ord ||= char.respond_to?(:ord)\n char.ord.to_s\n else\n char[0]\n end\n end", "def to_s\n st = @char\n ...
[ "0.75101787", "0.75101787", "0.7181099", "0.7163236", "0.71493226", "0.7035988", "0.70131576", "0.6958647", "0.693191", "0.6887989", "0.6882716", "0.6833814", "0.683135", "0.683135", "0.683135", "0.683135", "0.683135", "0.683135", "0.683135", "0.683135", "0.683135", "0.6831...
0.7117789
5
Returns true iff this Character and parameter 'another' represent the same character. [another] any Object. The way the equality is tested depends on the another's class Example: newOne = Character.new(?\u03a3) newOne == newOne true. Identity newOne == Character.new(?\u03a3) true. Both have same codepoint newOne == ?\u03a3 true. The single character String match exactly the char attribute. newOne == 0x03a3 true. The Integer is compared to the codepoint value. Will test equality with any Object that knows the to_s method
def ==(other) case other when Character to_str == other.to_str when Integer codepoint == other when String other.size > 1 ? false : to_str == other else # Unknown type: try with a convertion self == other.to_s # Recursive call end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ==(other)\n @chars == other.chars\n end", "def == other\n return false if other.class != self.class\n return false if other.length != self.length\n len = self.length\n while(len > 0)\n return false if self.get_char(len) != other.get_char(len)\n len = len - 1\n end\n...
[ "0.6943716", "0.6668627", "0.6442764", "0.6422109", "0.62311393", "0.62067527", "0.61262053", "0.6059121", "0.60309345", "0.60091704", "0.5991544", "0.5970458", "0.5949894", "0.594892", "0.5912954", "0.59071624", "0.59060216", "0.5905413", "0.59013915", "0.5895077", "0.589507...
0.72048455
0
Return a plain English description of the character
def explain "the character '#{to_str}'" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_character_blah\n \n puts \"Name: #{name}\"\n puts \"Bio: #{description}\"\n end", "def heading\n\t\t\"Character Descriptors\"\n\tend", "def single_character_display\n SINGLE_CHARACTER\n end", "def single_character_display\n SINGLE_CHARACTER\n ...
[ "0.7390016", "0.7165024", "0.6835023", "0.6835023", "0.6835023", "0.6835023", "0.68033504", "0.67663", "0.67331815", "0.65869164", "0.6559376", "0.648551", "0.64745843", "0.64554137", "0.6436214", "0.6385673", "0.6367864", "0.6365251", "0.6361676", "0.6352502", "0.63290614", ...
0.6760304
8
Conversion method redefinition. Purpose: Return the String representation of the expression. If the Character was initially from a text (the lexeme), then the lexeme is returned back. Otherwise the character corresponding to the codepoint is returned.
def text_repr return char if lexeme.nil? lexeme.dup end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n \"#{codepoint} (#{name})\"\n end", "def char\n self.class.codepoint2char(@codepoint)\n end", "def to_s\n st = @char\n node = self\n while node != nil\n node = node.up\n break if node==nil\n st = node.char+st\n end\n st\n end", "def p...
[ "0.6309289", "0.61352676", "0.6098375", "0.6049587", "0.59985626", "0.59505546", "0.5932142", "0.5926827", "0.58122015", "0.580636", "0.57612324", "0.573509", "0.5618381", "0.5583484", "0.55728465", "0.5539008", "0.5532029", "0.5504268", "0.55022615", "0.549673", "0.54804665"...
0.74494576
0
GET /dealers GET /dealers.json
def index if current_user.admin? @dealers = Dealer.all else redirect_to root_path end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @dealers = Dealer.all\n end", "def index\n @dealers = Dealer.all\n end", "def buyers\n result = get_buyers(params, false)\n render json: result, status: 200\n end", "def show\n render json: Agent.find(params[:id]).buyers\n end", "def show\n # @deal = Deal.find(params[:id],...
[ "0.7322215", "0.7322215", "0.69774485", "0.6861183", "0.65171885", "0.6498694", "0.6493155", "0.64340043", "0.64057803", "0.64057803", "0.64057803", "0.6380698", "0.6342994", "0.6251009", "0.62445396", "0.6209363", "0.6202483", "0.6194472", "0.61182994", "0.6109453", "0.61025...
0.60830104
21
GET /dealers/1 GET /dealers/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @dealers = Dealer.all\n end", "def index\n @dealers = Dealer.all\n end", "def show\n @deal = Deal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @deal }\n end\n end", "def show\n @deal = Deal.find(params[:id])...
[ "0.7104187", "0.7104187", "0.69208705", "0.69208705", "0.69208705", "0.6889136", "0.6817105", "0.6794931", "0.6793058", "0.66745275", "0.666655", "0.65569013", "0.65128535", "0.6451594", "0.6445409", "0.6441197", "0.6432699", "0.6367675", "0.6365314", "0.63580155", "0.6258022...
0.0
-1
POST /dealers POST /dealers.json
def create @dealer = Dealer.new(dealer_params) respond_to do |format| if @dealer.save format.html { redirect_to @dealer, notice: 'Dealer was successfully created.' } format.json { render :show, status: :created, location: @dealer } else format.html { render :new } format.json { render json: @dealer.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @adopter = Adopter.new(adopter_params)\n\n if @adopter.save\n render json: @adopter, status: :created, location: @adopter\n else\n render json: @adopter.errors, status: :unprocessable_entity\n end\n end", "def create\n @dealer = Dealer.new(dealer_params)\n respond_to do ...
[ "0.6642244", "0.6585507", "0.6513535", "0.63085556", "0.623345", "0.6164315", "0.613293", "0.61196357", "0.61196357", "0.60608", "0.6041987", "0.6030359", "0.60156286", "0.59745723", "0.5908797", "0.58654207", "0.58530694", "0.5837852", "0.58323896", "0.58273077", "0.58198833...
0.6581162
2
PATCH/PUT /dealers/1 PATCH/PUT /dealers/1.json
def update respond_to do |format| if @dealer.update(dealer_params) format.html { redirect_to @dealer, notice: 'Dealer was successfully updated.' } format.json { render :show, status: :ok, location: @dealer } else format.html { render :edit } format.json { render json: @dealer.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @adopter = Adopter.find(params[:id])\n\n if @adopter.update(adopter_params)\n head :no_content\n else\n render json: @adopter.errors, status: :unprocessable_entity\n end\n end", "def update_deal(id, params)\n put(\"deals/#{id}\", deal: params)\n end", "def update...
[ "0.66010934", "0.65861094", "0.64825433", "0.64666694", "0.64482784", "0.6445248", "0.6370103", "0.6367641", "0.62841403", "0.6253599", "0.62247694", "0.620776", "0.6189243", "0.6177333", "0.616616", "0.6160951", "0.61027473", "0.60569257", "0.60489565", "0.6048126", "0.60238...
0.6213936
12
DELETE /dealers/1 DELETE /dealers/1.json
def destroy @dealer.destroy respond_to do |format| format.html { redirect_to dealers_url, notice: 'Dealer was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @dealer.destroy\n respond_to do |format|\n format.html { redirect_to dealers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n # @deal = Deal.find(params[:id])\n @deal.destroy\n respond_to do |format|\n format.html { redirect_to deals_url }\n ...
[ "0.74891484", "0.73073703", "0.7296887", "0.72910523", "0.72776484", "0.7268725", "0.72608894", "0.72608894", "0.72116965", "0.71185106", "0.7116985", "0.7101055", "0.7064265", "0.7039374", "0.7038716", "0.6981854", "0.69624543", "0.693712", "0.69312644", "0.6910744", "0.6891...
0.7246097
9
Use callbacks to share common setup or constraints between actions.
def set_dealer @dealer = Dealer.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def dealer_params params.require(:dealer).permit(:dealer_name, :address, :email, :contact) 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.6980957", "0.6783065", "0.6747844", "0.6741468", "0.67356336", "0.6592548", "0.65036845", "0.64978707", "0.64825076", "0.64795035", "0.64560914", "0.64397955", "0.6379666", "0.6376688", "0.6366702", "0.6319728", "0.6300833", "0.6300629", "0.6294277", "0.6293905", "0.629117...
0.0
-1
=begin Typical block of reference node change looks like: Before: ..\packages\MassTransit.3.0.14\lib\net45\MassTransit.dll True After: (file version removed, hint path version number updated) ..\packages\MassTransit.3.0.15\lib\net45\MassTransit.dll True =end
def replace_project_versions proj_files begin # iterate each package file, replace version numbers and save proj_files.each{ |file| puts "Updating references in: #{file}..." doc = Nokogiri::XML File.read file nodes = doc.search 'Reference' nodes.each { |node| ref_val = node['Include'] # grab the identifier id = ref_val.split(',')[0] # clean out file version node['Include'] = id # replace version in hint path hint_path = node.search 'HintPath' if hint_path && hint_path[0] != nil hint_path_value = hint_path[0].children.to_s # this identifier is not the same as the node['Include'] one. # For ex., Runtime, Core and Storage assemblies will be referred to from within other packages like Management, Test etc hint_path_id = id_from_hint_path hint_path_value if @versions.has_key? hint_path_id hint_path_parts = hint_path_value.split '\\' hint_path_parts[2] = hint_path_id + GlobalConstants::DOT + @versions[hint_path_id] hint_path[0].children = hint_path_parts.join '\\' end end } File.write file, doc.to_xml } rescue puts $! return false end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resolve_reference; end", "def require_reference(path); end", "def references; end", "def references; end", "def test_node_change_log1\r\n @mymodel = Model.new(1, \"rubylicious\") \r\n node_list = @mymodel.node_list\r\n\r\n node1 = node_list.add_node('autonum', 'node one', NODE);\r\n...
[ "0.5471084", "0.5447363", "0.5312989", "0.5312989", "0.52841234", "0.5225092", "0.52004206", "0.5186044", "0.51643944", "0.5112983", "0.5042304", "0.50404096", "0.5009668", "0.5009532", "0.4975258", "0.49608403", "0.49426162", "0.4938916", "0.48863694", "0.486473", "0.4854612...
0.47070068
39
We support an object, if its class is Serializable and is already included in the Registry.
def supports?(another_object) another_object.class.ancestors.include?(ActivityFeed::Serializable) && instance[another_object.class.af_type_id.to_sym] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serialize(object) end", "def serializable?(value)\n true\n end", "def serialize(object)\n raise_or_return(object)\n end", "def serialize(object, data); end", "def serialize(_object, data); end", "def serialize(_object, data); end", "def object\n raise NotImplemented...
[ "0.6717054", "0.6472253", "0.6332966", "0.61425155", "0.6073836", "0.6073836", "0.6069357", "0.6063021", "0.60439", "0.6004501", "0.6004501", "0.59892976", "0.59872144", "0.5961174", "0.59514475", "0.5889394", "0.58681715", "0.5851104", "0.5822199", "0.57979465", "0.57979465"...
0.594241
15
this is a very naive implementation to keep the array of SCC down to 5 it was a simple requirement for a course exercise
def trim_scc_array if @scc_size.size > 0 @scc_size.sort! if @scc_size.size < 5 if @scc_size.first > @last_scc_size @scc_size.push(@last_scc_size) else @scc_size.unshift(@last_scc_size) end else if @last_scc_size > @scc_size.first @scc_size[0] = @last_scc_size end end else @scc_size.push(@last_scc_size) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strongly_connected_components\n\t\t@explored_nodes = Array.new(size, false)\n\t\t@finishing_time_arr = Array.new(size)\n\t\t@scc = Array.new\n\t\t@dfs_queue = Array.new\n\t\t@finishing_time_queue = Array.new\n\t\t@finishing_time = 0\n\t\tcalculate_finishing_time\n\t\t@leaders = scc_call_order\n\t\tcalculate_sc...
[ "0.6960574", "0.6130857", "0.6093842", "0.6067666", "0.59899485", "0.5948006", "0.5866916", "0.586149", "0.58539253", "0.5851496", "0.5827812", "0.5815613", "0.58018166", "0.57998675", "0.57592815", "0.5746487", "0.5718547", "0.5672691", "0.565821", "0.5658152", "0.565527", ...
0.7031612
0
rubocop: disable Metrics/MethodLength rubocop: disable Metrics/AbcSize
def transpose(string) arr = string.split(//) new_arr = '' i = 0 while i < string.length if arr[i] == 'n' && arr[i - 1] == 'g' arr[i], arr[i - 1] = arr[i - 1], arr[i] i -= 2 end i += 1 end arr.each { |n| new_arr += n } new_arr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def implementation; end", "def implementation; end", "def refutal()\n end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def schubert; end", "def strategy; end", "def offences_by; end", "def used?; end", "def custo...
[ "0.7670641", "0.6295587", "0.6235954", "0.6235954", "0.6215023", "0.61841494", "0.61841494", "0.61841494", "0.61841494", "0.61307836", "0.5952472", "0.5919521", "0.5884458", "0.58336973", "0.58336973", "0.5815753", "0.5812282", "0.57900274", "0.57900274", "0.57390547", "0.571...
0.0
-1
GET /longterm_goals GET /longterm_goals.json
def index @longterm_goals = LongtermGoal.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def goals(*args)\n @client.get \"#{@path}/goals\", Hash[*args]\n end", "def index\n @goals = @user.goals\n \n render json: @goals\n end", "def goals\n get(\"/user/#{@user_id}/activities/goals/daily.json\")\n end", "def goals\n get(\"/user/#{@user_id}/activities/...
[ "0.732945", "0.72592956", "0.72027224", "0.7200819", "0.694095", "0.6933644", "0.69254565", "0.6895508", "0.68438435", "0.67495525", "0.67495525", "0.67495525", "0.67495525", "0.6712588", "0.6693233", "0.6607886", "0.65974605", "0.65841395", "0.6572521", "0.6565937", "0.65232...
0.78816295
0
GET /longterm_goals/1 GET /longterm_goals/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @longterm_goals = LongtermGoal.all\n end", "def index\n @goals = @user.goals\n \n render json: @goals\n end", "def show\n @goal = @user.goals.find(params[:id])\n\n @tracked_activities = @goal.tracked_activities\n @untracked_activities = @goal.untracked_activities\...
[ "0.7745726", "0.72751945", "0.7134816", "0.7036258", "0.70007163", "0.6997096", "0.6996421", "0.6972888", "0.6970396", "0.6963692", "0.6897044", "0.6883135", "0.68740493", "0.67575157", "0.67575157", "0.67575157", "0.67575157", "0.669432", "0.669432", "0.669432", "0.669432", ...
0.0
-1
POST /longterm_goals POST /longterm_goals.json
def create @longterm_goal = LongtermGoal.new(longterm_goal_params) respond_to do |format| if @longterm_goal.save format.html { redirect_to @longterm_goal, notice: 'Longterm goal was successfully created.' } format.json { render :show, status: :created, location: @longterm_goal } else format.html { render :new } format.json { render json: @longterm_goal.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @long_term_goal = LongTermGoal.new(params[:long_term_goal])\n\n respond_to do |format|\n if @long_term_goal.save\n format.html { redirect_to(@long_term_goal, :notice => 'Long term goal was successfully created.') }\n format.xml { render :xml => @long_term_goal, :status => :cr...
[ "0.70534927", "0.67665017", "0.6689707", "0.6636825", "0.6435989", "0.6376466", "0.63576174", "0.63191056", "0.63141716", "0.63065654", "0.6303088", "0.6261073", "0.6246727", "0.6246675", "0.62346655", "0.6221175", "0.6192996", "0.6192996", "0.6183522", "0.61772084", "0.61744...
0.7435835
0
PATCH/PUT /longterm_goals/1 PATCH/PUT /longterm_goals/1.json
def update respond_to do |format| if @longterm_goal.update(longterm_goal_params) format.html { redirect_to @longterm_goal, notice: 'Longterm goal was successfully updated.' } format.json { render :show, status: :ok, location: @longterm_goal } else format.html { render :edit } format.json { render json: @longterm_goal.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @long_term_goal = LongTermGoal.find(params[:id])\n\n respond_to do |format|\n if @long_term_goal.update_attributes(params[:long_term_goal])\n format.html { redirect_to(@long_term_goal, :notice => 'Long term goal was successfully updated.') }\n format.xml { head :ok }\n e...
[ "0.73148376", "0.71607697", "0.69180954", "0.6841149", "0.6807351", "0.6791067", "0.678307", "0.6769511", "0.67477274", "0.67466885", "0.6742971", "0.67197686", "0.67132807", "0.6711081", "0.67098045", "0.67092973", "0.67092973", "0.67092973", "0.67092973", "0.67092973", "0.6...
0.7377008
0
DELETE /longterm_goals/1 DELETE /longterm_goals/1.json
def destroy @longterm_goal.destroy respond_to do |format| format.html { redirect_to longterm_goals_url, notice: 'Longterm goal was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @long_term_goal = LongTermGoal.find(params[:id])\n @long_term_goal.destroy\n\n respond_to do |format|\n format.html { redirect_to(long_term_goals_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @global_goal = GlobalGoal.find(params[:id])\n @global_goal.de...
[ "0.7716748", "0.7485457", "0.7369754", "0.73418015", "0.73412883", "0.73133284", "0.73133284", "0.7311161", "0.7256254", "0.72462916", "0.72044355", "0.7078552", "0.70718396", "0.7068877", "0.70644784", "0.70447594", "0.70447594", "0.70447594", "0.70447594", "0.70447594", "0....
0.7674615
1
Use callbacks to share common setup or constraints between actions.
def set_longterm_goal @longterm_goal = LongtermGoal.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def longterm_goal_params params.require(:longterm_goal).permit(:category_id, :target_time_min, :actual_time_min, :successful) 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
Test for updating form field
def test_post_form_field filename = 'FormFilled.docx' remote_name = 'TestPostFormField.docx' dest_name = remote_test_out + remote_name index = 0 body = FormFieldTextInput.new({:Name => 'FullName', :Enabled => true, :CalculateOnExit => true, :StatusText => '', :TextInputType => 'Regular', :TextInputDefault => ''}) st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_test_folder + test_folder + '/' + filename, "r").read @storage_api.put_create st_request request = PostFormFieldRequest.new remote_name, body, index, remote_test_folder + test_folder, :dest_file_name => dest_name, :node_path => 'sections/0' result = @words_api.post_form_field request assert_equal 200, result.code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_update_form_field\n remote_file_name = 'TestUpdateFormField.docx'\n\n upload_file File.join(local_test_folder, field_folder + '/FormFilled.docx'), remote_data_folder + '/' + remote_file_name\n\n request_form_field = FormFieldTextInput.new({:Name => 'FullName', :Enabled => true, :CalculateOn...
[ "0.6913447", "0.67746073", "0.6734589", "0.65769064", "0.6576172", "0.6536535", "0.6474004", "0.6466598", "0.64606446", "0.64342064", "0.64210725", "0.6354972", "0.6327273", "0.6284299", "0.6267089", "0.626404", "0.62495244", "0.6247602", "0.6222578", "0.6215646", "0.6205688"...
0.0
-1
Test for creating form field
def test_put_form_field filename = 'test_multi_pages.docx' remote_name = 'TestPutFormField.docx' dest_name = remote_test_out + remote_name body = FormFieldTextInput.new({:Name => 'FullName', :Enabled => true, :CalculateOnExit => true, :StatusText => '', :TextInputType => 'Regular', :TextInputDefault => '123', :TextInputFormat => 'UPPERCASE'}) st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_common_folder + filename, "r").read @storage_api.put_create st_request request = PutFormFieldRequest.new remote_name, body, remote_test_folder + test_folder, :dest_file_name => dest_name, :node_path => 'sections/0/paragraphs/0' result = @words_api.put_form_field request assert_equal 200, result.code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @form_field = FormField.new(form_field_params)\n\n respond_to do |format|\n if @form_field.save\n format.html { redirect_to @form_field, notice: 'Form field was successfully created.' }\n format.json { render :show, status: :created, location: @form_field }\n else\n ...
[ "0.65837556", "0.646171", "0.6320718", "0.6319424", "0.6302154", "0.6299457", "0.6296442", "0.6265436", "0.62363726", "0.6210737", "0.6208984", "0.61927074", "0.61748654", "0.6173392", "0.6171729", "0.6170146", "0.61695623", "0.6159038", "0.61277664", "0.6087086", "0.6069969"...
0.61010027
19
Test for removing form field
def test_delete_form_field filename = 'FormFilled.docx' remote_name = 'TestDeleteFormField.docx' index = 0 st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_test_folder + test_folder + '/' + filename, "r").read @storage_api.put_create st_request request = DeleteFormFieldRequest.new remote_name, index, remote_test_folder + test_folder, :node_path => 'sections/0' result = @words_api.delete_form_field request assert_equal 200, result.code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_field(key)\n @pdf_form.removeField(key.to_s)\n end", "def delete_field!(field_name); end", "def single_item_action_remove_form_fields(form, document)\n single_item_action_form_fields(form, document, 'remove')\n end", "def clear_field(field_name)\n\t\tend", "def link_to_remove_fie...
[ "0.71643376", "0.70429033", "0.7025128", "0.67498195", "0.67489874", "0.66602194", "0.6494545", "0.64924115", "0.6489925", "0.6469885", "0.6469885", "0.64598745", "0.63789976", "0.6373858", "0.6341011", "0.6305041", "0.6292618", "0.6280462", "0.62710565", "0.6270757", "0.6263...
0.59858537
26
Test for getting form field
def test_get_form_field filename = 'FormFilled.docx' remote_name = 'TestGetFormField.docx' index = 0 st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_test_folder + test_folder + '/' + filename, "r").read @storage_api.put_create st_request request = GetFormFieldRequest.new remote_name, index, remote_test_folder + test_folder, :node_path => 'sections/0' result = @words_api.get_form_field request assert_equal 200, result.code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def text_field?(field_name); end", "def get_field(field_name)\n\t\tend", "def form_field_params\n params[:form_field]\n end", "def field?\n true \n end", "def test_get_form_field\n remote_file_name = 'TestGetFormField.docx'\n\n upload_file File.join(local_test_folder, field_folder...
[ "0.70183766", "0.6934823", "0.6554872", "0.64931667", "0.6470671", "0.64678913", "0.6422354", "0.6414923", "0.64009976", "0.6388004", "0.6384089", "0.6365697", "0.6357989", "0.62687135", "0.6241873", "0.6166287", "0.61650234", "0.60889345", "0.60750645", "0.6050422", "0.60498...
0.62540704
14
Test for getting form fields
def test_get_form_fields filename = 'FormFilled.docx' remote_name = 'TestGetFormFields.docx' st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_test_folder + test_folder + '/' + filename, "r").read @storage_api.put_create st_request request = GetFormFieldsRequest.new remote_name, remote_test_folder + test_folder, :node_path => 'sections/0' result = @words_api.get_form_fields request assert_equal 200, result.code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fields\n @fields ||= form.fields\n end", "def form_fields\n params\n end", "def fields_on_form() #:nodoc:\r\n fields = []\r\n if @form['form']['fields']\r\n# read only field elements (key is Fixnum)\r\n @form['form']['fields'].each {|key,options| fields << options if key.class == F...
[ "0.708444", "0.70056933", "0.67474437", "0.6640493", "0.66006523", "0.65812916", "0.654523", "0.6527126", "0.6510921", "0.6390957", "0.6379048", "0.63340795", "0.6319897", "0.6310525", "0.62590176", "0.6252043", "0.62473977", "0.6237692", "0.6230975", "0.61806184", "0.6158978...
0.65928024
5
Changes: 1. Get form_id from selector 2. If collection is entries, not matter from context or current collection object, and form has entries_separated flag set, set collection name instance variable to entries plus form_id as new collection name 3. It's not good because it will query form to check entries_separated flag exists or not each time. Hope to find a better way later
def create_context_with_separated_entries context = create_context_without_separated_entries query_class = instance_variable_get :@klass if should_query_from_separated_collection? query_class new_collection_name = query_class.separated_collection_prefix + separated_value(query_class) # self.selector.except!('form_id') # filter = context.instance_variable_get(:@view).filter.except('form_id') # context.instance_variable_get(:@view).instance_variable_set :@filter, filter context.collection.instance_variable_set :@name, new_collection_name collection.instance_variable_set :@name, new_collection_name end instance_variable_set :@context, context context end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def criteria_with_separated_entries\n cri = criteria_without_separated_entries\n query_class = cri.instance_variable_get :@klass\n if should_query_from_separated_collection? query_class\n context = cri.context.clone\n context.collection.instance_variable_set :@name,...
[ "0.59690523", "0.58365697", "0.5706671", "0.52648", "0.52648", "0.52648", "0.52648", "0.52648", "0.52648", "0.52648", "0.52648", "0.52648", "0.52648", "0.52648", "0.52648", "0.52648", "0.52648", "0.5254219", "0.5243418", "0.5215959", "0.5183274", "0.5183274", "0.5175138",...
0.65107536
0
Changes: 1. 'base' should be an instance of Form 2. If form has entries_separated flat and collection name is entries, clone a new context because it is build each time when called and set to context. Then remove form_id from selector because all the entries inside the new collection has the same form_id
def criteria_with_separated_entries cri = criteria_without_separated_entries query_class = cri.instance_variable_get :@klass if should_query_from_separated_collection? query_class context = cri.context.clone context.collection.instance_variable_set :@name, "#{query_class.separated_collection_prefix}#{base.id}" cri.instance_variable_set :'@collection', @collection # cri.selector.except!('form_id') end cri end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_context_with_separated_entries\n context = create_context_without_separated_entries\n query_class = instance_variable_get :@klass\n if should_query_from_separated_collection? query_class\n new_collection_name = query_class.separated_collection_prefix + separated_value(query_class)\...
[ "0.6576616", "0.5736769", "0.56707036", "0.5559668", "0.5378339", "0.53390276", "0.53301847", "0.526304", "0.51821935", "0.5130522", "0.5095146", "0.50912625", "0.5086299", "0.5052921", "0.5042052", "0.5038239", "0.50339264", "0.50334024", "0.5026997", "0.4990072", "0.4969180...
0.57978886
1
this perhaps needs to be private?
def save @history << {@entry_station => @exit_station} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def internal; end", "def implementation; end", "def implementation; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def private_method\n end", "def probers; end", "def schubert; end", "def custom; end", "def custom; end", "def re...
[ "0.8628043", "0.68844175", "0.6809401", "0.6809401", "0.6738669", "0.6738669", "0.6738669", "0.6738669", "0.67097336", "0.66628116", "0.64757186", "0.6448042", "0.6448042", "0.6329847", "0.6317827", "0.63101923", "0.61640596", "0.6153795", "0.61508685", "0.61508685", "0.61508...
0.0
-1
Get a single snippet.
def user_snippet(id) get("/snippets/#{id}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_snippet(name, options = {})\n fetch('/snippets/%s' % name, options)\n end", "def get_published_snippet\n @snippet = Snippet.published.find params[:id]\n end", "def show\n # The snippet should be destroyed in the case where it is one-time and it should no longer be\n # pe possible to acc...
[ "0.75138646", "0.7378621", "0.70046693", "0.6905942", "0.6880125", "0.68199795", "0.6800261", "0.6763094", "0.6744326", "0.669336", "0.66555685", "0.66555685", "0.66555685", "0.66555685", "0.6567685", "0.6567061", "0.652993", "0.6518845", "0.647275", "0.647275", "0.63400865",...
0.7436838
1
Get raw contents of a single snippet.
def user_snippet_raw(id) get("/snippets/#{id}/raw", format: nil, headers: { Accept: 'text/plain' }, parser: ::Gitlab::Request::Parser) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def raw\n\t\treturn @content\n\tend", "def raw\n\t\treturn @content\n\tend", "def raw\n workhorse_set_content_type!\n\n # Until we don't migrate all snippets to version\n # snippets we need to support old `SnippetBlob`\n # blobs\n if defined?(blob.snippet)\n send_data(\n convert_line...
[ "0.7177273", "0.7177273", "0.6960773", "0.6859287", "0.6824384", "0.67682606", "0.65983325", "0.657727", "0.6518336", "0.63670653", "0.63670653", "0.63670653", "0.63167167", "0.63167167", "0.63064367", "0.62408125", "0.620866", "0.6205441", "0.6190683", "0.61764574", "0.61460...
0.7356102
0
Delete an existing snippet.
def delete_user_snippet(id) delete("/snippets/#{id}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n @page = Comatose::Page.find_is_snippet params[:id]\n if request.post?\n expire_cms_pages_from_bottom @page\n expire_cms_fragments_from_bottom @page\n @page.destroy\n flash[:notice] = \"Deleted snippet '#{@page.title}'\"\n redirect_to :controller=>self.contr...
[ "0.77703464", "0.75513184", "0.75513184", "0.74863595", "0.74863595", "0.73953474", "0.73678786", "0.7328685", "0.729586", "0.7294756", "0.72580326", "0.7186157", "0.7186157", "0.7186157", "0.71098465", "0.70793664", "0.6899279", "0.6711864", "0.6635156", "0.6625694", "0.6113...
0.72834575
10
List all public snippets.
def public_snippets(options = {}) get('/snippets/public', query: options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @snippets = Snippet.all\n end", "def index\n if(current_user)\n @snippets= current_user.snippets.paginate(page: params[:page],:per_page => 10)\n end\n end", "def index\n @snippets = Snippet.order(\"updated_at DESC\").where(private: false).paginate(page: params[:page], per_page: 1...
[ "0.67842335", "0.6760895", "0.6756018", "0.65286833", "0.63160247", "0.63156354", "0.62739253", "0.62032723", "0.62002754", "0.61789966", "0.6137268", "0.6126715", "0.61149895", "0.60618025", "0.6061513", "0.5976118", "0.59445965", "0.5856423", "0.584539", "0.5820418", "0.581...
0.8098759
0
Get user agent details for a snippet.
def snippet_user_agent_details(id) get("/snippets/#{id}/user_agent_detail") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_agent\n @data[\"user_agent\"]\n end", "def get_user_agent\n user_agent\n end", "def user_agent\n @headers['User-Agent']\n end", "def user_agent\n @headers['User-Agent']\n end", "def user_agent\n @headers['User-Agent']\n end", "def harvest_user_agent\n ...
[ "0.68625015", "0.67451423", "0.648771", "0.648771", "0.648771", "0.64798355", "0.6454123", "0.6439662", "0.6254034", "0.62220424", "0.62220424", "0.62220424", "0.61704874", "0.61264014", "0.6078006", "0.60755724", "0.60755724", "0.60540515", "0.60437596", "0.60300773", "0.602...
0.832505
0
Add member to usergroup
def add_member(id, user) client.post("#{path}/#{id}/members", user) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_group_as_member(group)\n self.groups.push group\n end", "def add_user_member(user, group)\n ids = users_by_group_id(group.id).push(user).map(&:id)\n current_ids = users_by_group_id(group.id).map(&:id)\n create_member(ids, current_ids, 'User', inherited_by: group.id, destroy: false)\n end", ...
[ "0.8129533", "0.8114213", "0.8070852", "0.8070257", "0.7820665", "0.7810652", "0.77881706", "0.7749405", "0.7713207", "0.7700273", "0.7693648", "0.75566113", "0.754295", "0.75424236", "0.74921227", "0.74745256", "0.739522", "0.739209", "0.73549634", "0.73436064", "0.7336587",...
0.6696365
69
Remove member from usergroup
def remove_member(id, user) client.delete("#{path}/#{id}/members", user) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_member(user)\n if (self.members.include?(user))\n self.memberships.find_by_user_id(user.id).destroy\n else\n raise GroupsManagement::UserIsNotMember, \"The user \" + user.email + \" is not a member of the group '\" + self.name + \"'.\"\n end\n \n end", "def remove_user_from_gro...
[ "0.8267318", "0.8212022", "0.81986845", "0.80474216", "0.785455", "0.78542924", "0.7830964", "0.7814298", "0.7770279", "0.77317727", "0.7729017", "0.76877916", "0.7653267", "0.7618087", "0.76009494", "0.7597236", "0.75732785", "0.751058", "0.74489677", "0.7446031", "0.7413682...
0.7216261
27
GET /funds/1 GET /funds/1.json
def show @fund = Fund.friendly.find(params[:id]) render json: @fund end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @funds = Fund.all\n\n render json: @funds\n end", "def show\n render json: @fund\n end", "def show\n @admin_fund = Fund.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_fund }\n end\n end", "def index\n ...
[ "0.7764602", "0.7490024", "0.70740074", "0.70078856", "0.6895374", "0.6871844", "0.6871844", "0.68113285", "0.6648034", "0.66044545", "0.65751237", "0.65477", "0.6480862", "0.6479069", "0.64501476", "0.641185", "0.6359536", "0.63481283", "0.63373536", "0.63302416", "0.6317559...
0.7769627
0
POST /funds POST /funds.json
def create @fund = Fund.new(fund_params) if @fund.save render json: @fund, status: :created, location: api_v1_fund_path(@fund) else render_validation_errors @fund.errors end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @fund = Fund.new(fund_params)\n\n if @fund.save\n render json: @fund, status: :created, location: @fund\n else\n render json: @fund.errors, status: :unprocessable_entity\n end\n end", "def create\n @admin_fund = Fund.new(params[:admin_fund])\n\n respond_to do |format|\n ...
[ "0.76247156", "0.67201215", "0.6639017", "0.6637702", "0.6556015", "0.65248096", "0.6471608", "0.6471608", "0.6406482", "0.639882", "0.6394309", "0.6377749", "0.63629115", "0.6358371", "0.6312209", "0.630026", "0.62258595", "0.6196665", "0.6178535", "0.6114387", "0.6107545", ...
0.7463888
1
PATCH/PUT /funds/1 PATCH/PUT /funds/1.json
def update @fund = Fund.friendly.find(params[:id]) authorize! :manage, @fund if @fund.update(fund_params) head :no_content else render_validation_errors @fund.errors end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @fund.update(fund_params)\n head :no_content\n else\n render json: @fund.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @fund.update(fund_params)\n format.html { redirect_to @fund, notice: 'Fund was successfully upd...
[ "0.737266", "0.70351905", "0.70329", "0.6857465", "0.6688017", "0.6627489", "0.6570984", "0.6570984", "0.65417963", "0.6516786", "0.6513741", "0.64612806", "0.64612806", "0.6456487", "0.6388797", "0.6368233", "0.6368233", "0.63540655", "0.635353", "0.6350312", "0.6318475", ...
0.65056443
11
DELETE /funds/1 DELETE /funds/1.json
def destroy @fund = Fund.friendly.find(params[:id]) authorize! :manage, @fund @fund.destroy head :no_content end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @fund.destroy\n\n head :no_content\n end", "def destroy\n @fund.destroy\n respond_to do |format|\n format.html { redirect_to funds_url, notice: 'Fund was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @fund.destroy\n res...
[ "0.7649942", "0.7518577", "0.7518577", "0.7509717", "0.74515253", "0.7195393", "0.7154278", "0.7129348", "0.7128182", "0.7114289", "0.70852596", "0.70835376", "0.70716876", "0.70389086", "0.7015833", "0.7006431", "0.6990429", "0.6984278", "0.6981383", "0.6976844", "0.6973521"...
0.70333636
14
This challenge took me [] hours. Pseudocode input: an array of integers output: a fizzbuzz array were integers with a multiple of 3 are replaced by "fizz", integers with a multiple of 5 are replaced with "buzz", and integers with a multiple of 15 are replace with "fizzbuzz" Iterate over an array of integers Check to see if integer is a multiple of 3 and replace integer in array with 'Fizz' if it is. Check to see if integer is a multiple of 5 and replace integer in array with 'Buzz' if it is. Check to see if integer is a multiple of 15 and replace integer in array with 'FizzBuzz' if it is. Otherwise, keep the existing integer. Initial Solution def super_fizzbuzz(array) array.map do |number| if number % 15 === 0 'FizzBuzz' elsif number % 3 === 0 'Fizz' elsif number % 5 === 0 'Buzz' else number end end end Refactored Solution
def super_fizzbuzz(array) array.map do |number| case when number % 15 === 0 then 'FizzBuzz' when number % 3 === 0 then 'Fizz' when number % 5 === 0 then 'Buzz' else number end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def super_fizzbuzz(array)\n array.map do |x|\n if x % 15 == 0\n x = x.to_s.replace(\"FizzBuzz\")\n elsif x % 5 == 0\n x = x.to_s.replace(\"Buzz\")\n elsif x % 3 == 0\n x = x.to_s.replace(\"Fizz\")\n else\n x = x\n end\nend\nend", "def super_fizzbuzz(array)\n array.map! do |x| \n...
[ "0.9009288", "0.8897243", "0.8878064", "0.8870779", "0.88473666", "0.88398254", "0.88394076", "0.88104224", "0.8786902", "0.87707025", "0.8755419", "0.8721189", "0.8715512", "0.8704932", "0.8688922", "0.86843157", "0.86776346", "0.8657403", "0.86435914", "0.8643129", "0.86311...
0.8575835
25
POST /parking_spaces POST /parking_spaces.json
def create space = ParkingSpace.new(user_id: current_user.id,cost: params[:cost], latitude: params[:latitude], longitude: params[:longitude], status: true, address: params[:address]) space.save redirect_to "/" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @space = Space.new(space_params)\n\n respond_to do |format|\n if @space.save\n format.html { redirect_to root_path, notice: \"Space was successfully created.\" }\n format.json { render :show, status: :created, location: @space }\n else\n format.html { render :new, ...
[ "0.66497165", "0.6637594", "0.65458053", "0.65427285", "0.6508127", "0.6339218", "0.6222908", "0.6212978", "0.6210185", "0.6129767", "0.6123309", "0.6094469", "0.6066002", "0.605453", "0.6046955", "0.59935045", "0.5983363", "0.59381974", "0.5905322", "0.5893489", "0.588292", ...
0.5955855
17
PATCH/PUT /parking_spaces/1 PATCH/PUT /parking_spaces/1.json
def update respond_to do |format| if @parking_space.update() format.html { redirect_to @parking_space, notice: 'Parking space was successfully updated.' } format.json { render :show, status: :ok, location: @parking_space } else format.html { render :edit } format.json { render json: @parking_space.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @space.update(space_params)\n render json: @space, status: :ok\n else\n render json: @space.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n old_name = @space_type.name\n if @space_type.update(space_type_params)\n @...
[ "0.7036821", "0.6905672", "0.67417186", "0.67258394", "0.672431", "0.6577326", "0.6521679", "0.6505496", "0.63878936", "0.6386075", "0.6371937", "0.62871313", "0.62064886", "0.62012887", "0.6196917", "0.6152263", "0.6124943", "0.6115081", "0.61142737", "0.6094343", "0.6090963...
0.7160079
0
DELETE /parking_spaces/1 DELETE /parking_spaces/1.json
def destroy @parking_space.destroy respond_to do |format| format.html { redirect_to parking_spaces_url, notice: 'Parking space was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @space.destroy\n respond_to do |format|\n format.html { redirect_to spaces_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @space = Space.find(params[:id])\n\n @space.destroy\n\n respond_to do |format|\n format.html { redirect_to spaces_url }\...
[ "0.7579779", "0.748946", "0.73665106", "0.7360793", "0.7360793", "0.73544115", "0.7353935", "0.7353935", "0.73025227", "0.7278187", "0.7246087", "0.7114373", "0.70578474", "0.7021938", "0.7005223", "0.7001286", "0.6980316", "0.69774145", "0.69031316", "0.6890877", "0.6887043"...
0.7652014
0
GET /practitioners GET /practitioners.json
def index @practitioners = Practitioner.paginate(page: params[:page]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def teachers\n url = drop_url_version + \"/count/teacherAssociations/#{params['edorg_id']}/teachers\"\n begin\n entities = RestClient.get(url, get_header)\n entities = JSON.parse(entities)\n rescue => e\n logger.info(\"Could not get ed orgs for #{entities} because of #{e.message}\")\n en...
[ "0.7090701", "0.67998195", "0.65641993", "0.6466721", "0.64629376", "0.6378065", "0.63714486", "0.63593394", "0.63593394", "0.634581", "0.62098026", "0.617209", "0.616472", "0.61512583", "0.61117274", "0.607021", "0.6057666", "0.6049288", "0.6047453", "0.6035049", "0.6028155"...
0.6931075
1
GET /practitioners/1 GET /practitioners/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @practitioner_type = PractitionerType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @practitioner_type }\n end\n end", "def show\n @practice = Practice.find(params[:id])\n\n respond_to do |format|\n format.html...
[ "0.69858426", "0.6791103", "0.6791103", "0.6753636", "0.6624337", "0.6498484", "0.6352189", "0.62798154", "0.62798154", "0.6258256", "0.6213024", "0.6201559", "0.61860955", "0.61835057", "0.6173803", "0.6146138", "0.6146138", "0.61447597", "0.60932773", "0.6086389", "0.607683...
0.0
-1
POST /practitioners POST /practitioners.json
def create @practitioner = Practitioner.new(practitioner_params) respond_to do |format| if @practitioner.save format.html { redirect_to @practitioner, notice: 'Practitioner was successfully created.' } format.json { render :show, status: :created, location: @practitioner } else format.html { render :new } format.json { render json: @practitioner.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def practitioner_params\n params.require(:practitioner).permit(:name, :description)\n end", "def create\n @practitioner_type = PractitionerType.new(params[:practitioner_type])\n\n respond_to do |format|\n if @practitioner_type.save\n format.html { redirect_to @practitioner_type, :notice...
[ "0.65139526", "0.6278431", "0.62691057", "0.62454134", "0.6224758", "0.61928886", "0.6185542", "0.6185398", "0.6178266", "0.60633326", "0.6053146", "0.60506445", "0.5919848", "0.5906567", "0.58720607", "0.58642817", "0.5858906", "0.5850141", "0.5836924", "0.57995397", "0.5793...
0.7080237
0
PATCH/PUT /practitioners/1 PATCH/PUT /practitioners/1.json
def update respond_to do |format| if @practitioner.update(practitioner_params) format.html { redirect_to @practitioner, notice: 'Practitioner was successfully updated.' } format.json { render :show, status: :ok, location: @practitioner } else format.html { render :edit } format.json { render json: @practitioner.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @practice = Practice.find(params[:id])\n\n respond_to do |format|\n if @practice.update_attributes(params[:practice])\n format.html { redirect_to @practice, notice: 'Practice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { ren...
[ "0.67615384", "0.67583185", "0.6685504", "0.6667822", "0.6667592", "0.6585007", "0.6544552", "0.6529318", "0.6356153", "0.63487786", "0.63487786", "0.6326776", "0.62937963", "0.62401474", "0.6216254", "0.6213003", "0.6213003", "0.6178898", "0.61749166", "0.6171659", "0.616517...
0.70598936
0
DELETE /practitioners/1 DELETE /practitioners/1.json
def destroy @practitioner.destroy respond_to do |format| format.html { redirect_to practitioners_url, notice: 'Practitioner was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @practice.destroy\n respond_to do |format|\n format.html { redirect_to practices_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @practitioner_type = PractitionerType.find(params[:id])\n @practitioner_type.destroy\n\n respond_to do |format|\n ...
[ "0.7297245", "0.72492486", "0.7194853", "0.7190964", "0.71013653", "0.71013653", "0.71013653", "0.7033669", "0.7001017", "0.6996043", "0.6931695", "0.692397", "0.69155365", "0.68976986", "0.6885773", "0.688508", "0.68744", "0.6853067", "0.68352884", "0.68323356", "0.68323356"...
0.74766666
0
Use callbacks to share common setup or constraints between actions.
def set_practitioner @practitioner = Practitioner.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 list of trusted parameters through.
def practitioner_params params.require(:practitioner).permit(:name, :phone, :email, :registration, :address, :fax, :location, :signature) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\...
[ "0.69485277", "0.6813547", "0.6799911", "0.6796169", "0.6745757", "0.6741778", "0.6527065", "0.65204644", "0.64925444", "0.64314413", "0.64314413", "0.64314413", "0.6398711", "0.6355623", "0.6355327", "0.6345812", "0.6343951", "0.6338371", "0.6327366", "0.6327366", "0.6327366...
0.0
-1
determine how many days in the iteration are considered 'workdays' as defined by the workspace configuration
def calculate_workdays iteration_start_date = Date.parse(@iteration.start_date) iteration_end_date = Date.parse(@iteration.end_date) total_iteration_days = iteration_end_date - iteration_start_date + 1 # number of total possible workdays within entire iteration total_workdays = 0 curr_day = iteration_start_date for i in 1..total_iteration_days total_workdays += 1 if $conn.workspace.is_workday?(curr_day.to_s) curr_day += 1 end total_workdays end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def potential_working_days(start_date, end_date)\n days_worked = (start_date..end_date).select do |day|\n day = day.strftime(\"%A\").downcase.to_sym\n works_on?(day)\n end\n days_worked.count\n end", "def working_days(from, to)\n days = (to - from).to_i\n if days > 0\n ...
[ "0.6902245", "0.6877124", "0.6850414", "0.6725095", "0.63789624", "0.63611805", "0.6360334", "0.6337088", "0.626955", "0.6264542", "0.62607074", "0.62492824", "0.62163204", "0.62117904", "0.61999243", "0.61975473", "0.61950326", "0.618262", "0.61129516", "0.61029315", "0.6097...
0.8777553
0
state_data is a hash of schedule states and associated icf data
def initialize(creation_date, state_data) @creation_date = creation_date @state_data = state_data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash\n [calendar_name, description, name, next_fire_time, previous_fire_time, state].hash\n end", "def state\n hash = {}\n hash[:frozen] = self.frozen \n hash[:active] = self.board.active\n hash[:students] = self.students.as_json\n hash[:tas] = self.tas.as_json\n hash\n end", "de...
[ "0.6714574", "0.6670478", "0.6506519", "0.62995106", "0.6203239", "0.6118409", "0.6118409", "0.6060443", "0.6031019", "0.59907514", "0.5987839", "0.59561497", "0.5938627", "0.58565134", "0.5824632", "0.5824632", "0.5824632", "0.5799751", "0.57913816", "0.57582605", "0.5758260...
0.56197613
30
Creates a new filter for testing using the given `fragment`.
def new_filter(fragment) if fragment.kind_of? String pipeline = new_pipeline fragment = pipeline.call(fragment)[:output].to_s end HTML::Pipeline::CiteFilter.new(fragment) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(fragment)\n @fragment = fragment\n end", "def to_fragment\n SomaticsFilter::Fragment.new({\n SomaticsFilter::Query::ParamNames[:is_set] => self.is_default? ? '1' : '0',\n SomaticsFilter::Query::ParamNames[:operator] => self.default_operator,\n SomaticsFilter::Qu...
[ "0.5810302", "0.55942386", "0.55397385", "0.5403405", "0.5361076", "0.5331779", "0.52745616", "0.5221384", "0.52118", "0.5189971", "0.51821774", "0.5161637", "0.5156447", "0.5105578", "0.50708187", "0.5033136", "0.50254375", "0.5006601", "0.50006294", "0.4998111", "0.49865073...
0.7674772
0
if user is logged in show review form else show flash message with link to log in (later after login redirect to previous page) redirect to show page
def create @site = Site.find(params[:site_id]) @review = Review.new(review_params) @review.site = @site @review.user = current_user @review.save redirect_to site_path(@site) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def view\n if !logged_in?\n\n redirect_to \"/\"\n flash[:notice] = \"You must be logged in to view your module reviews.\"\n end\n end", "def authorize_user_review\n session[:return_to] ||= request.referer\n if current_user != @review.user\n flash[:notice] = \"You didn't write th...
[ "0.787887", "0.7670798", "0.7043299", "0.70101374", "0.69598126", "0.6876825", "0.6833981", "0.6822782", "0.6781194", "0.6780646", "0.67798996", "0.6768844", "0.676586", "0.67054856", "0.66735727", "0.66675806", "0.6666045", "0.66397005", "0.6639458", "0.6632791", "0.6613093"...
0.0
-1
Check the categories calendar to control "free sales / stop sales" == Parameters: from:: The starting date to:: The ending date == Returns: An array of String that represents available category codes
def categories_available(from, to) not_available_event_type = ::Yito::Model::Calendar::EventType.first(:name => 'not_available') condition = Conditions::JoinComparison.new('$and', [Conditions::Comparison.new('event_type', '$eq', not_available_event_type), Conditions::JoinComparison.new('$or', [Conditions::JoinComparison.new('$and', [Conditions::Comparison.new('from','$lte', from), Conditions::Comparison.new('to','$gte', from) ]), Conditions::JoinComparison.new('$and', [Conditions::Comparison.new('from','$lte', to), Conditions::Comparison.new('to','$gte', to) ]), Conditions::JoinComparison.new('$and', [Conditions::Comparison.new('from','$eq', from), Conditions::Comparison.new('to','$eq', to) ]), Conditions::JoinComparison.new('$and', [Conditions::Comparison.new('from', '$gte', from), Conditions::Comparison.new('to', '$lte', to)]) ] ), ] ) not_available_calendars = Set.new(condition.build_datamapper(Yito::Model::Calendar::Event).all.map { |item| item.calendar.id }).to_a categories_with_calendar = ::Yito::Model::Booking::BookingCategory.all(active: true).select { |cat| not cat.calendar.nil? } calendars = categories_with_calendar.map { |cat| {:code => cat.code, :calendar => cat.calendar.id} } calendars.select! { |cal| not_available_calendars.index(cal[:calendar]) == nil } calendars.map { |cal| cal[:code] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def categories_payment_enabled(from, to)\n\n if SystemConfiguration::Variable.get_value('booking.payment', 'false').to_bool\n ::Yito::Model::Booking::BookingCategory.all.map { |item| item.code }\n else\n\n payment_enabled = ::Yito::Model::Calendar::EventType.first(:nam...
[ "0.6058778", "0.57509524", "0.5526555", "0.5476436", "0.53019786", "0.52073634", "0.51404333", "0.51291525", "0.5119761", "0.50636834", "0.5048777", "0.5009363", "0.49875358", "0.4975264", "0.49614623", "0.49453184", "0.49319103", "0.49149552", "0.49043623", "0.4886717", "0.4...
0.7215028
0
Check the categories that allow payment on a date range == Parameters: from:: The starting date to:: The ending date == Returns: An array of String that represents available category codes
def categories_payment_enabled(from, to) if SystemConfiguration::Variable.get_value('booking.payment', 'false').to_bool ::Yito::Model::Booking::BookingCategory.all.map { |item| item.code } else payment_enabled = ::Yito::Model::Calendar::EventType.first(:name => 'payment_enabled') condition = Conditions::JoinComparison.new('$and', [Conditions::Comparison.new('event_type', '$eq', payment_enabled), Conditions::Comparison.new('from', '$lte', from), Conditions::Comparison.new('to', '$gte', to)]) cat_payment_available = Set.new(condition.build_datamapper(Yito::Model::Calendar::Event).all.map {|item| item.calendar.name}).to_a end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def categories_available(from, to)\n\n not_available_event_type = ::Yito::Model::Calendar::EventType.first(:name => 'not_available')\n\n condition = Conditions::JoinComparison.new('$and',\n [Conditions::Comparison.new('event_type', '$eq', not_available_event_type),\n Conditio...
[ "0.7101328", "0.62735635", "0.58970535", "0.56554693", "0.55817103", "0.55375636", "0.55375636", "0.54960567", "0.54903847", "0.542484", "0.54075336", "0.53934556", "0.53893495", "0.53806585", "0.5347599", "0.5340662", "0.5339512", "0.5334514", "0.53178", "0.5295136", "0.5292...
0.65191936
1
Affiche combien le nom et les pdv
def gets_damage(attack_value) @life_points -= attack_value if @life_points <= 0 @life_points = 0 return " Le joueur #{self.name} a été tué !" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mostrar_dados\n puts \"Partido: #{@nome} - Votos: #{@votos}\" \n end", "def get_txt_panneau\n\t\treturn [mdl_par.panneaux[0].to_s,mdl_par.panneaux[1].to_s]\n\tend", "def listerParticipants\n puts \"\"\n puts \"\"\n puts \"---------------| PARTICIPANTS |----------------------\"\n puts...
[ "0.5883103", "0.5812132", "0.5741143", "0.56386125", "0.56386125", "0.5598354", "0.55919", "0.5575619", "0.5546636", "0.5527956", "0.54854494", "0.5358714", "0.5345943", "0.53400177", "0.53290886", "0.53200686", "0.5296151", "0.52958256", "0.5294061", "0.5288503", "0.5274722"...
0.0
-1
Affiche le nom, les pdv et le niveau de l'arme d'un HumanPlayer
def compute_damage return rand(1..6) * @weapon_level end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_players\r\n puts \"Tu as #{human_player.life_points}\"\r\n puts \"il reste #{@enemies.length} bots, courage!!\"\r\n end", "def show_players\n puts \"#{@human_player.name} a #{@human_player.life_points} points de vies\"\n @enemies.each do |mechant|\n puts \"#{mechant.nam...
[ "0.7031339", "0.6702909", "0.6618194", "0.6551857", "0.65414995", "0.6494093", "0.64341444", "0.6412389", "0.64101124", "0.6290578", "0.62794024", "0.6270742", "0.6239798", "0.6226701", "0.61776364", "0.6175895", "0.61131114", "0.6094717", "0.60884255", "0.6076224", "0.607209...
0.0
-1
Add an object (e.g. ActiveRecord model instance) to this ResultSet with an accompanying permission hash.
def add_object(object, with_permissions: {}) @object_permission_map[object].merge!(with_permissions) do |_k, v1, v2| { states: (v1[:states] + v2[:states]).uniq.sort } end self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_permission(permission) \n self.permissions << permission\n end", "def add_permission(permission) \n\t\tself[:permission_ids] << permission.id \n\t\tself[:permissions] << permission.name\n\t\tself.save\n\tend", "def add(permission)\n\t\t\tkparams = {}\n\t\t\t# The new permission\n\t\t\tclien...
[ "0.65119207", "0.6150227", "0.5786772", "0.5785791", "0.5690522", "0.5611273", "0.5585335", "0.55801797", "0.55314183", "0.5509732", "0.5465966", "0.5431941", "0.53828233", "0.53794724", "0.5327558", "0.5327558", "0.5321097", "0.5295404", "0.5247277", "0.5226252", "0.522274",...
0.5503314
10
Add multiple objects (e.g. ActiveRecord model instances) to this \ ResultSet all with the accompanying permission hash.
def add_objects(objects, with_permissions: {}) objects.each do |object| add_object object, with_permissions: with_permissions end self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_permissions\n [\"License\", \"Archive\", \"Contract\"].each do |doc|\n klass = doc.constantize\n doc_id = \"#{doc.downcase}_id\".to_sym\n permissions = self.send(\"#{doc.downcase.pluralize.singularize}_permissions\".to_sym)\n klass.find(:all).each { |record|\n permissions.crea...
[ "0.6408168", "0.57425654", "0.56682897", "0.5578576", "0.55255276", "0.55217415", "0.54989785", "0.5288826", "0.5227736", "0.51521134", "0.50619525", "0.50576097", "0.50567317", "0.5052704", "0.5052105", "0.50357103", "0.5004472", "0.49950257", "0.49950257", "0.4990647", "0.4...
0.54416794
7
Return all of the objects (e.g. ActiveRecord model instances) in this ResultSet.
def objects @object_permission_map.keys end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all\n results = CONNECTION.execute(\"SELECT * FROM #{get_table_name}\")\n\n results_as_objects = []\n\n results.each do |results_hash|\n results_as_objects << self.new(results_hash)\n end\n\n return results_as_objects\n end", "def all\n table_name = self.to_s.pluralize.underscore\n ...
[ "0.8098161", "0.8090431", "0.7949621", "0.7930559", "0.7898488", "0.78934777", "0.78613794", "0.7834249", "0.7743518", "0.77111906", "0.73122084", "0.70876086", "0.6983087", "0.6976729", "0.6970721", "0.6849735", "0.6780889", "0.67503935", "0.6690838", "0.6679457", "0.6649729...
0.0
-1
Retruns a collection of Authorizations::Query::Result objects that can be serialized for client applications to consume.
def serializable results = [] each do |object, permissions| results << SerializableResult.new(object, permissions) end results end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def result_set\n klass.requestor.get(nil, { query: to_s })\n end", "def to_a\n return @results\n end", "def results\n\t\t\tArray(result)\n\t\tend", "def to_a\n return @records unless loadable?\n\n @response = cache.get_or_set_query(klass, options) do\n connection.docu...
[ "0.7321772", "0.6461048", "0.6400923", "0.6286542", "0.6171394", "0.6171019", "0.60967255", "0.6091276", "0.60432345", "0.5935571", "0.5913783", "0.5913783", "0.59001476", "0.58964026", "0.58836544", "0.5872037", "0.5868297", "0.580177", "0.58009595", "0.57990634", "0.5792919...
0.6175182
4
the array of groups. Case doesn't matter in classifying string as anagrams (but case should be preserved in the output), and the order of the anagrams in the groups doesn't matter.
def combine_anagrams(words) [] unless words.empty? combine = Hash.new words.each do |word| sorted = word.downcase.chars.sort.join if combine.has_key?(sorted) combine[sorted] << word else combine[sorted] = [word] end end combine.values end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def grouped_anagrams(strings)\n return [] if strings.empty?\n\n result = {}\n groups = []\n\n strings.each do |word|\n key = word.split(\"\").sort.join\n if result.has_key?(key)\n result[key] << word\n else\n result[key] = [word]\n end\n end\n\n result.each do |k, v|\n groups << v\n ...
[ "0.7192206", "0.7080902", "0.70755094", "0.70583254", "0.7051047", "0.7012753", "0.7006105", "0.70009506", "0.6990449", "0.6973939", "0.69702774", "0.6956652", "0.6953352", "0.69491625", "0.69365895", "0.69168514", "0.69047385", "0.6903787", "0.6893285", "0.6885485", "0.68852...
0.0
-1
TODO: POST ajax query
def change_status # Администратор может поменять статус заявки на любой. Клиент же только на "отменена" if current_user.owner_or_worker?(@organization) || (current_user == @appointment.user_by_phone && %w(cancel_client).include?(params[:state])) @appointment.status = params[:state] respond_to do |wants| if @appointment.save wants.html { redirect_to calendar_path(day: @appointment.start.to_i, worker_id: @appointment.worker_id), notice: 'Статус успешно изменен' } wants.js { render js: refresh_calendar } else wants.html { redirect_to calendar_path(day: @appointment.start.to_i, worker_id: @appointment.worker_id), notice: 'При сохранении произошла ошибка' } wants.js { render js: "alert('при сохранении произошла ошибка'" } end end else redirect_to :back, alert: 'У вас не достаточно прав' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query\n\n # Allows us to execute javascript\n respond_to do |format|\n format.html\n format.js\n end\n\n # If a post request is made, store the show name in @query\n if request.post?\n @query = params[:show]\n end\n\n end", "def POST; end", "def post\n request_object.po...
[ "0.6640112", "0.63850844", "0.63821924", "0.6324391", "0.6123822", "0.61008024", "0.599643", "0.5946033", "0.5839651", "0.579824", "0.5796508", "0.57816523", "0.5747491", "0.5737637", "0.5709993", "0.5708591", "0.5704761", "0.5702172", "0.5679744", "0.56621134", "0.56424856",...
0.0
-1
this worker is offset by 1 minute, make sure to account for the spread
def get_prices(timestamp, duration = 31.minutes) price_class = "::#{exchange_name.capitalize}Price".constantize execute_query( price_class.where('timestamp > ?', (timestamp - duration.to_i)).to_sql ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push_next_try_at\r\n self.next_try_at = 15.minutes.from_now\r\n end", "def doge_control\r\n @next_queue_time = get_queue_time\r\n end", "def worker_check_interval(interval); end", "def update_worker(start_time,duration)\n queue = Sidekiq::ScheduledSet.new\n queue.each do |job| \n ...
[ "0.6141344", "0.61186355", "0.6080952", "0.60594875", "0.59592414", "0.5805524", "0.5767693", "0.5762605", "0.5662397", "0.5654371", "0.5653106", "0.56367546", "0.5634213", "0.5600469", "0.5586494", "0.5543185", "0.55361706", "0.55317193", "0.5527452", "0.55154186", "0.550622...
0.0
-1
Unfortuantely pg_dump does not work if datallowcon=false (ie quiesced) so logic needs to be implemented to check if the database can receive connections and if not, turn it back on just before running the pg_dump. At the end of the method, it should put the datallowcon back to the state it was in originally
def backup begin check_if_db_exists is_allowed = @conn.exec("select datallowconn from pg_catalog.pg_database where datname='#{@options[:database]}'")[0]['datallowconn'] if is_allowed == 'f' # unquiece temporarily set_dataallowcon_to true end # Check to see if the directory for backups exists and if not, create it with parents unless File.exist?(@options[:bkdir]) FileUtils.mkdir_p @options[:bkdir] end filename = "postgresbk_#{@options[:database]}_#{Time.new.strftime("%m%d%y%H%M%S")}.dump" # The below system call assumes you have passwordless access as the user passed into the executable tool # either due to ~/.pgpass or pg_hba.conf has your user as a 'trust' auth method `pg_dump -U #{@options[:user]} #{@options[:database]} -F c -f #{@options[:bkdir]}/#{filename}` rescue Exception => e raise e ensure if is_allowed == 'f' # re quiesce set_dataallowcon_to false end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def psql_db_command__dump psql_db\n psql_db_command__program \"pg_dump\", psql_db\n end", "def run_cmd!\n \"pg_dump #{pg_dump_args} | psql #{new_db_name}\"\n end", "def reexecute_connections?\n return true\n end", "def postgres_keep_alive\n stat = @connection.status()\n rescue PGError => e...
[ "0.6289234", "0.60187024", "0.59925276", "0.5930819", "0.5867983", "0.5866526", "0.5699605", "0.56190515", "0.56118846", "0.5585545", "0.55830693", "0.55807143", "0.55603784", "0.5556293", "0.5556293", "0.5552273", "0.55461043", "0.55160654", "0.5511669", "0.5508263", "0.5504...
0.6412538
0
Similarly to pg_dump, pg_restore does not work if datallowcon=false (ie quiesced) so logic needs to be implemented to check if the database can receive connections and if not, turn it back on just before running the pg_restore. At the end of the method, it should put the datallowcon back to the state it was in originally
def restore # pg_restore -c -U postgres -d dataslam -1 /tmp/out.dump begin check_if_db_exists is_allowed = @conn.exec("select datallowconn from pg_catalog.pg_database where datname='#{@options[:database]}'")[0]['datallowconn'] if is_allowed == 'f' # unquiece temporarily set_dataallowcon_to true end fn = get_latest_backup_fn if fn == "" raise NoBackupsAvailableException.new "There are no backups available at the specified location or in the default location (/tmp/postgresbk)" end # The below system call assumes you have passwordless access as the user passed into the executable tool # either due to ~/.pgpass or pg_hba.conf has your user as a 'trust' auth method `pg_restore -c -U #{@options[:user]} -d #{@options[:database]} -1 #{@options[:bkdir]}/#{fn}` rescue Exception => e raise e ensure if is_allowed == 'f' # re quiesce set_dataallowcon_to false end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def backup \n begin\n check_if_db_exists\n is_allowed = @conn.exec(\"select datallowconn from pg_catalog.pg_database where datname='#{@options[:database]}'\")[0]['datallowconn']\n if is_allowed == 'f'\n # unquiece temporarily\n set_dataallowcon_to true\n end\n\n # Check to...
[ "0.66191566", "0.6167767", "0.60580295", "0.60518366", "0.58649886", "0.5774392", "0.57292444", "0.56798965", "0.5666848", "0.55465037", "0.55465037", "0.5533619", "0.55072737", "0.54791415", "0.54324603", "0.542333", "0.53889334", "0.53619266", "0.53598046", "0.5339613", "0....
0.7014995
0
GET /service_users GET /service_users.json
def index @service_users = ServiceUser.all render json: @service_users end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_users\n self.class.get('/users')\n end", "def users(args = {})\n get(\"/users.json\",args)\n end", "def index\n @users = UserService.all_users\n end", "def get_users_list\n service_response = AdminManagement::Users::UserList.new(params).perform\n render_api_response(service...
[ "0.74256253", "0.73730755", "0.72365767", "0.7230674", "0.72009695", "0.7072412", "0.7037225", "0.70040864", "0.694816", "0.693819", "0.69315773", "0.6894944", "0.6894944", "0.68812585", "0.686779", "0.68436503", "0.6835722", "0.6804655", "0.67931384", "0.67915654", "0.675968...
0.78232
0
GET /service_users/1 GET /service_users/1.json
def show render json: @service_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @service_users = ServiceUser.all\n render json: @service_users\n end", "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n ...
[ "0.74731046", "0.7389385", "0.71487534", "0.69709796", "0.69657165", "0.6872706", "0.68179536", "0.6813221", "0.679102", "0.6790224", "0.6753235", "0.6676664", "0.6655953", "0.6611763", "0.6596083", "0.6590129", "0.65832865", "0.6582873", "0.6572825", "0.6553574", "0.6553574"...
0.693555
5