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 |
|---|---|---|---|---|---|---|
Use callbacks to share common setup or constraints between actions. | def set_rest
@rest = Rest.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 rest_params
params.require(:rest).permit(:name, :address, :description, :owner, :phone)
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 |
Unescape character escapes such as "\n" to their character equivalents. | def unescape(value)
return nil if value.nil?
regex = /\\(?:([nevfbart\\])|0?x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4}))/
value.gsub(regex) do
if Regexp.last_match(3)
[Regexp.last_match(3).to_s.hex].pack('U*')
elsif Regexp.last_match(2)
[Regexp.last_match(2)].pack('H2')
else
UNESCAPES[Regexp.last_match(1)]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unescape(x)\n # temporarily escape \\\\ as \\007f, which is disallowed in any text\n x.gsub(/\\\\\\\\/, \"\\u007f\").gsub(/\\\\,/, \",\").gsub(/\\\\[Nn]/, \"\\n\").\n tr(\"\\u007f\", \"\\\\\")\n end",
"def unescape( value )\n return value unless @escape\n\n value = value.to_... | [
"0.7542144",
"0.74841934",
"0.73203593",
"0.7089947",
"0.6895988",
"0.68688786",
"0.68088126",
"0.67174447",
"0.67139125",
"0.6576543",
"0.65458935",
"0.64962906",
"0.64219904",
"0.63760304",
"0.6365335",
"0.6240339",
"0.62335473",
"0.62074596",
"0.61736524",
"0.61627674",
"0... | 0.5966075 | 26 |
Unescape as above, and also convert all occurrences of \$char to $char | def unescape_all(value)
return nil if value.nil?
value = unescape(value).gsub(/\\(.)/) { Regexp.last_match(1) }
value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_escaped_chars; end",
"def unescape(escaped_string)\n escaped_string.\n gsub(/\\$\\$|\\$'|\\$L|\\$P|\\$R|\\$P|\\$T/i) do |match|\n case match\n when \"$$\"\n \"$\"\n when \"$'\"\n \"'\"\n when \"$L\", \... | [
"0.7082615",
"0.6705295",
"0.66962826",
"0.66601837",
"0.6593927",
"0.65566796",
"0.6539947",
"0.65179634",
"0.64973336",
"0.6444463",
"0.6427003",
"0.6376859",
"0.6364292",
"0.63418543",
"0.6294365",
"0.6279314",
"0.62752324",
"0.62519145",
"0.6248706",
"0.6212955",
"0.61923... | 0.0 | -1 |
Create a new key object | def initialize(args={})
ATTRIBUTES.each do |attr|
instance_variable_set("@#{attr}", args.has_key?( attr ) ? args[attr] : nil )
end
self.raw_line = args[:raw_pubkey] || args[:raw_line]
if args.has_key? :raw_pubkey
self.load_pubkey
return
end
unless self.raw_line.nil?
self.load_raw_line
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_key(start)\n start = start.to_i\n key = Key.new(start)\n @keys[key.keyid] = key\n key.keyid\n end",
"def create_key(arg = nil)\n set_or_return(\n :create_key,\n arg,\n kind_of: [ TrueClass, FalseClass ]\n )\n end",
"def create_key(key_name, creat... | [
"0.78871727",
"0.7613876",
"0.74968225",
"0.7046661",
"0.7009361",
"0.69653755",
"0.69453937",
"0.6865855",
"0.683629",
"0.6819702",
"0.6802487",
"0.6802487",
"0.6763601",
"0.6730844",
"0.67207867",
"0.6664415",
"0.66316795",
"0.662651",
"0.6624066",
"0.6603754",
"0.6571355",... | 0.0 | -1 |
Instantiate key based on pubkey file only set key_data,key_type and note attributes | def load_pubkey
#filter line data
load_raw_line([:key_data,:key_type,:note])
# sanitize old raw line
self.raw_line = self.gen_raw_line
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_public_key(filename); end",
"def load_data_public_key(data, filename = T.unsafe(nil)); end",
"def create(pvt)\n key = Bitcoin::Key.new\n key.priv = pvt\n key.addr\n end",
"def keyload(key_file_path=\"rsa_private_key.rb\")\n #require key_file_path\n require_relative key_file_path\n ... | [
"0.6864566",
"0.6860883",
"0.672304",
"0.6701389",
"0.6594955",
"0.65768236",
"0.6557497",
"0.64921284",
"0.6472643",
"0.64307",
"0.63999546",
"0.63033646",
"0.6252607",
"0.625141",
"0.62506586",
"0.6228636",
"0.62246054",
"0.6214617",
"0.62067485",
"0.6183494",
"0.6139712",
... | 0.60494775 | 30 |
Instantiate key object based on contents of raw_line | def load_raw_line opts = OPTS_REGEX.keys
self.raw_line.chomp!
opts.each do |xfield|
pattern = OPTS_REGEX[xfield]
did_set = raw_setter xfield, pattern
#puts did_set
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize( body, line=nil, column=nil )\n\t\tsuper\n\n\t\tkey = self.body[ /^([a-z]\\w+)$/ ] or\n\t\t\traise Inversion::ParseError,\n\t\t\t\t\"malformed key: expected simple identifier, got %p\" % [ self.body ]\n\t\t@key = key.to_sym\n\tend",
"def parse_key(string)\n @key_factory.parse(string)\n ... | [
"0.71902066",
"0.63361585",
"0.6314107",
"0.621172",
"0.61955464",
"0.59886926",
"0.5984003",
"0.5974245",
"0.59481716",
"0.58967143",
"0.58763695",
"0.5792431",
"0.57266515",
"0.5715586",
"0.57128125",
"0.5689253",
"0.56768274",
"0.5663554",
"0.5663554",
"0.56400365",
"0.563... | 0.5154162 | 92 |
set attribute (field) obtained from matching pattern in raw_line | def raw_setter xfield,pattern
field = "@#{xfield}"
m = self.raw_line.match pattern
return false if m.nil?
#p "#{field} => #{m.inspect}"
if BOOL_ATTRIBUTES.include? xfield
self.instance_variable_set(field, true)
return true
end
if STR_ATTRIBUTES.include? xfield
self.instance_variable_set(field, m[1])
return true
end
if ARR_STR_ATTRIBUTES.include? xfield
self.instance_variable_set(field, m.to_a)
return true
end
if SUB_STR_ATTRIBUTES.include? xfield
self.instance_variable_set(field, m[1])
return true
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_raw_line opts = OPTS_REGEX.keys\n self.raw_line.chomp!\n opts.each do |xfield|\n pattern = OPTS_REGEX[xfield]\n did_set = raw_setter xfield, pattern\n #puts did_set\n end\n end",
"def initialize line\n\n attributes = [:icao, :latitude, :longi... | [
"0.6869467",
"0.64021534",
"0.61670434",
"0.5938252",
"0.59255666",
"0.5875563",
"0.58038706",
"0.571091",
"0.56636614",
"0.5631684",
"0.55693185",
"0.55450433",
"0.5472618",
"0.5461977",
"0.5458264",
"0.5452722",
"0.54318404",
"0.54274374",
"0.5390945",
"0.5384219",
"0.53838... | 0.72973573 | 0 |
Set all boolean attributes at the same time +val+ > (boolean) | def all_no=(val)
BOOL_ATTRIBUTES.each do |attr|
self.instance_variable_set("@#{attr}",val)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_set_boolean(attr_type, attr_value)\n #This is a stub, used for indexing\n end",
"def set_boolean_value\n @values = [Value.new(@context, true)]\n end",
"def set_boolean!(value)\n @objects = nil\n @memory = nil\n\n self[:type] = :boolean\n self[:values][... | [
"0.76002645",
"0.71737343",
"0.70988846",
"0.701398",
"0.6834494",
"0.6761246",
"0.6756316",
"0.6746947",
"0.67047894",
"0.665515",
"0.65954226",
"0.65404296",
"0.6525709",
"0.6408451",
"0.6260781",
"0.62437904",
"0.6240183",
"0.6235671",
"0.62188125",
"0.6209311",
"0.6208010... | 0.71389675 | 2 |
Return the string representation of what the attribute will look like in the authorized_keys file Args : +field+ > Attribute name Returns : +string+ > A string representation of the attribute | def raw_getter field
val = self.instance_variable_get("@#{field}")
return nil if val.nil? == true || val == false
if BOOL_ATTRIBUTES.include? field
return field.to_s.gsub '_', '-'
end
if STR_ATTRIBUTES.include? field
return val
end
if ARR_STR_ATTRIBUTES.include? field && val.empty? == false
return val.join ' '
end
if SUB_STR_ATTRIBUTES.include? field
return SUB_STR_ATTRIBUTES[field].sub '%sub%', val
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_format(field)\n @formatted_key[field] ||= JSONAPI.configuration\n .key_formatter\n .format(resource_key_for(field))\n .to_sym\n end",
"def format_field key\n key.downcase.gsub(%r{[^A-Z0-9]+}xoi,' ').strip.gsub(' ','_')\n end",
"def key_field\n '... | [
"0.66736597",
"0.6583204",
"0.6251942",
"0.62163043",
"0.6191146",
"0.61861753",
"0.6184396",
"0.6127492",
"0.60428834",
"0.6031008",
"0.5991968",
"0.59852815",
"0.596714",
"0.596714",
"0.58966017",
"0.5867508",
"0.5829209",
"0.5814166",
"0.58020544",
"0.57961106",
"0.5748117... | 0.62356 | 3 |
Add a key to authorized keys file if it passes validation. If the validations fail the reason for the failure will be | def save
return false if not self.valid?
return self.class.write(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_authorized_key(key)\n queries = password_hash\n case key\n when String\n if File.exist?(key)\n key = File.open(key, \"r\")\n content = key.read.strip\n key.close\n else\n content = key\n end\n when File\n ... | [
"0.70383155",
"0.6780277",
"0.6525555",
"0.643588",
"0.6186489",
"0.6170219",
"0.6158968",
"0.6038772",
"0.6038772",
"0.6023439",
"0.5982191",
"0.5939054",
"0.5922996",
"0.5909971",
"0.5909971",
"0.5886401",
"0.58801097",
"0.5876721",
"0.5876721",
"0.5846328",
"0.58423823",
... | 0.0 | -1 |
Remove a key from the file Returns : +Boolean+ > Destroy success status | def destroy
return false if not self.saved?
return self.class.destroy self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(key)\n Lib.remove @path, @no_follow, key.to_s\n end",
"def delete key\n File.delete( cache_file(key) ) if File.exists?( cache_file(key) )\n end",
"def remove filename\n return false unless source_hash.key?(filename)\n source_hash.delete filename\n true\n end",
"def delete... | [
"0.7630755",
"0.730501",
"0.7292564",
"0.7200753",
"0.717114",
"0.71695024",
"0.7114485",
"0.71117383",
"0.71117383",
"0.71117383",
"0.71117383",
"0.71117383",
"0.70692676",
"0.6953806",
"0.68790305",
"0.6869346",
"0.6869346",
"0.6801761",
"0.678098",
"0.67712253",
"0.6770744... | 0.0 | -1 |
Construct the line that will be written to file Returns : +String+ > Line that will be written to file | def gen_raw_line
return nil unless self.valid?
line = ''
data = []
SUB_STR_ATTRIBUTES.each do |field,field_regex|
val = self.raw_getter field
data.push val if val.nil? == false
end
unless data.empty?
line = "#{data.join ' ,'}"
end
data = []
BOOL_ATTRIBUTES.each do |field|
val = self.raw_getter field
data.push val if val.nil? == false
end
unless data.empty?
if line == ''
line += "#{data.join ','} "
else
line += ",#{data.join ','} "
end
end
data = []
ARR_STR_ATTRIBUTES.each do |field|
val = self.raw_getter field
data.push val if val.nil? == false
end
unless data.empty?
if line == ''
line += "#{data.join ','} "
else
line += ", #{data.join ','} "
end
end
data = []
STR_ATTRIBUTES.each do |field|
val = self.raw_getter field
data.push val if val.nil? == false
end
line += data.join ' '
return line
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_line_to_file file_path,line\n return \"echo #{line} >> #{file_path}\"\n end",
"def string\n @line\n end",
"def write_line(data); end",
"def log(line)\n\t\tfile=File.open(@output_file,\"a+\")\n\t\tfile.puts(line)\n\t\tfile.close\n\tend",
"def line; end",
"def line; end",
"def line; e... | [
"0.66613233",
"0.65748626",
"0.65595996",
"0.65298337",
"0.6502042",
"0.6502042",
"0.6502042",
"0.6502042",
"0.6502042",
"0.6502042",
"0.6502042",
"0.6502042",
"0.6502042",
"0.6502042",
"0.6502042",
"0.6502042",
"0.6502042",
"0.6502042",
"0.6502042",
"0.64707774",
"0.6342598"... | 0.55080426 | 93 |
Validate the key If the validations fail the reason for the failure will be | def valid?
self.errors = []
BOOL_ATTRIBUTES.each do |field|
val = self.raw_getter field
unless val.nil? == true || val == true || val == false
self.errors.push field=>ERRORS[:bool]
end
end
if self.key_data.nil?
self.errors.push ERRORS[:data_nil]
return false
end
if self.key_type.nil?
self.errors.push ERRORS[:type_nil]
return false
end
if not self.key_data.match "^#{B64_REGEX}$"
self.errors.push ERRORS[:data_char]
end
if self.key_data.size < 30
self.errors.push ERRORS[:data_short]
end
if self.key_data.size > 1000
self.errors.push ERRORS[:data_long]
end
if self.key_data.size % 4 != 0
self.errors.push ERRORS[:data_modulus]
end
return self.errors.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_key; end",
"def verify_key; end",
"def validate_only(key)\n validation_name, attribute_name = key.split(\"/\")\n validation_name = validation_name.split(\"_\").collect{|word| word.capitalize}.join\n validation_key = \"#{self.name}/Validatable::Validates#{validation_name}/#{attribute_name}\"... | [
"0.71260524",
"0.71260524",
"0.6934062",
"0.69119585",
"0.6889627",
"0.67623305",
"0.67425066",
"0.67295855",
"0.67213017",
"0.6706033",
"0.6670275",
"0.6669564",
"0.6598329",
"0.65558654",
"0.6524957",
"0.65197897",
"0.65175945",
"0.65168136",
"0.6516789",
"0.6488474",
"0.64... | 0.5703121 | 95 |
Has the key already been saved to file? Returns : +Boolean+ > True if has been saved before, otherwise false | def saved?
return false if not self.valid?
return self.saved
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def already_stored?\n !file_uniqueness\n end",
"def can_save?\n @key != '1'\n end",
"def a_save_exists?\n DataManager.save_file_exists?\n end",
"def saved?\n return !@realfile.nil?\n end",
"def saved?\n self.class.exists?(self.hash)\n end",
"def persisted?\n ... | [
"0.76133144",
"0.7524009",
"0.7171883",
"0.7067247",
"0.6871968",
"0.68089825",
"0.6778028",
"0.66993994",
"0.6640026",
"0.660683",
"0.6599135",
"0.657249",
"0.6565435",
"0.6564998",
"0.6564799",
"0.6524434",
"0.6503525",
"0.6483026",
"0.6461757",
"0.64594525",
"0.6450251",
... | 0.620393 | 38 |
request_info is a RequestInfo object including the headers and the url, method and http version. Access it through the RequestMixin methods. | def initialize(request_info, connection = nil)
@request_info = request_info
@connection = connection
@finished_read = false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_infos\n req = request\n return {} unless req\n # FIXME: Use frozen string keys\n {\n :rid => request_id,\n :user_agent => client_user_agent,\n :scheme => req.scheme,\n :verb => req.env['REQUEST_METHOD'],\n :host => hostname,\n ... | [
"0.7221488",
"0.6775616",
"0.6639741",
"0.6639741",
"0.662",
"0.6614333",
"0.6614333",
"0.6613167",
"0.6613167",
"0.6613167",
"0.6613167",
"0.6569238",
"0.6569238",
"0.6569238",
"0.6569238",
"0.6569238",
"0.6569238",
"0.65649974",
"0.65649974",
"0.65649974",
"0.65649974",
"... | 0.62693447 | 30 |
Returns true if request fully finished reading | def finished_reading?; @finished_read; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finished?\n\t\t\t\t@finished && @body.length >= @headers['CONTENT_LENGTH']\n\t\t\tend",
"def stream_is_done?\n @stream.nil? || @stream.closed? || @stream.eof?\n end",
"def finished?\n @buffer.size == @size\n end",
"def end_of_stream?\n @next_chunk.nil?\n end",
"def eof?\n\t\t\t\tfil... | [
"0.78803635",
"0.7597073",
"0.75940007",
"0.74053127",
"0.7373751",
"0.7369345",
"0.7369345",
"0.7309881",
"0.7180534",
"0.7158285",
"0.7150497",
"0.7103735",
"0.70994383",
"0.70994383",
"0.70994383",
"0.70451105",
"0.7036706",
"0.7036706",
"0.7036706",
"0.7036706",
"0.703670... | 0.765932 | 1 |
When HTTP Parser marks the message parsing as complete, this will be set. | def finish_reading!
@finished_read = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_message_complete\n @finished = true\n end",
"def on_complete(env)\n if respond_to? :parse\n env[:body] = parse(env[:body]) unless [204,304].index env[:status]\n end\n end",
"def completed\n logger.debug \"Beetle: message processing completed\"\n logger.flush... | [
"0.71148336",
"0.6686827",
"0.6475304",
"0.64562744",
"0.6345647",
"0.6311137",
"0.62978137",
"0.623555",
"0.6193484",
"0.61669177",
"0.6164126",
"0.6147344",
"0.60477924",
"0.6038384",
"0.60100436",
"0.5998346",
"0.5981586",
"0.59812474",
"0.59300894",
"0.59076726",
"0.58987... | 0.0 | -1 |
Buffer body sent from connection, or send it directly to | def add_body(chunk)
if @on_body
@on_body.call(chunk)
else
@body ||= ""
@body << chunk
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_body(socket)\n if @body.respond_to?(:read) then send_body_io(socket)\n elsif @body.respond_to?(:call) then send_body_proc(socket)\n else send_body_string(socket)\n end\n end",
"def send_body(socket)\n if @body.respond_to?(:read) then send_body_io(socket)\n elsif @body.re... | [
"0.7272115",
"0.7272115",
"0.7107106",
"0.70534074",
"0.6878147",
"0.66320014",
"0.64327496",
"0.63975847",
"0.6383661",
"0.636277",
"0.63241136",
"0.6262457",
"0.62429",
"0.6237987",
"0.62368023",
"0.6229892",
"0.6176763",
"0.6170459",
"0.6125176",
"0.60986483",
"0.60740703"... | 0.0 | -1 |
Returns the body, if a block is given, the body is streamed to the block as the chunks become available, until the body has been read. If no block is given, the entire body will be read from the connection into the body buffer and then returned. | def body
raise "no connection given" unless @connection
if block_given?
# Callback from the http_parser will be calling add_body directly
@on_body = Proc.new
# clear out body buffered so far
yield read_from_body(nil) if @body
until finished_reading?
@connection.readpartial
end
@on_body = nil
else
until finished_reading?
@connection.readpartial
end
@body
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_body(socket, block)\n return unless socket\n if tc = self['transfer-encoding']\n case tc\n when /chunked/io then read_chunked(socket, block)\n else raise ::WEBrick::HTTPStatus::NotImplemented, \"Transfer-Encoding: #{tc}.\"\n end\n elsif self['content-length']... | [
"0.73344934",
"0.7266433",
"0.72579336",
"0.6999749",
"0.69008255",
"0.68755084",
"0.6628932",
"0.6619886",
"0.6606487",
"0.65947163",
"0.6581602",
"0.6529572",
"0.64907265",
"0.64597875",
"0.6440008",
"0.6425902",
"0.63898945",
"0.6268007",
"0.622951",
"0.6202733",
"0.617501... | 0.78568524 | 0 |
Read a number of bytes, looping until they are available or until read_from_body returns nil, indicating there are no more bytes to read Note that bytes read from the body buffer will be cleared as they are read. | def read(length = nil, buffer = nil)
raise ArgumentError, "negative length #{length} given" if length && length < 0
return '' if length == 0
res = buffer.nil? ? '' : buffer.clear
chunk_size = length.nil? ? @connection.buffer_size : length
begin
while chunk_size > 0
chunk = read_from_body(chunk_size)
break unless chunk
res << chunk
chunk_size = length - res.length unless length.nil?
end
rescue EOFError
end
return length && res.length == 0 ? nil : res
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_body(&block)\n while byte = @body.read(1)\n yield byte\n end\n end",
"def read(n=nil)\n if @response == nil\n raise IOError, \"No response available.\"\n end\n return @remaining_body.read(n)\n end",
"def read_body(socket, block)\n return unless socket\... | [
"0.7231826",
"0.7176725",
"0.67183006",
"0.6443749",
"0.6263354",
"0.62528884",
"0.62527543",
"0.61863875",
"0.6178254",
"0.6168622",
"0.61381185",
"0.61309606",
"0.61187243",
"0.61122686",
"0.60646546",
"0.60331625",
"0.59812707",
"0.59784293",
"0.5964736",
"0.5951795",
"0.5... | 0.6740672 | 2 |
Return a new instance with the given URL === Parameters url URL of the video | def initialize(url)
@url = url
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_video\n \t @video=UnvlogIt.new(url)\n \t self.embed_url=@video.embed_html(300, 169)\n \t self.thumb_url=@video.thumbnail\n end",
"def video_url\n \"http://video.ted.com/#{videoID}\"\n end",
"def new\n @video = Video.new\n @title = \"Video Submission\"\n \n @url = par... | [
"0.69987714",
"0.6820071",
"0.6700001",
"0.66479534",
"0.6625496",
"0.6623953",
"0.6623953",
"0.6623643",
"0.64801764",
"0.6450117",
"0.6450117",
"0.6450117",
"0.6450117",
"0.64365286",
"0.64296365",
"0.64028686",
"0.6401158",
"0.63858604",
"0.6352883",
"0.6330124",
"0.628666... | 0.6238091 | 23 |
Set the own media type. | def service
case self.url
when YOUTUBE_REGEXP then :youtube
when VIMEO_REGEXP then :vimeo
else nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_media_type\n @media_type = MediaType.find(params[:id])\n end",
"def set_default_media_type\n self.media_type = ::MIME::Types[self.content_type].first.try(:media_type) || 'file'\n end",
"def set_media_type\n media_types = self.class.head(@endpoint).headers['accept']\n O... | [
"0.81984866",
"0.774444",
"0.76506186",
"0.7602322",
"0.7284275",
"0.7251031",
"0.70867276",
"0.70646095",
"0.70615643",
"0.7060255",
"0.69953394",
"0.6954169",
"0.6954169",
"0.689309",
"0.6870712",
"0.68576276",
"0.68046117",
"0.68003726",
"0.6797459",
"0.67919534",
"0.67703... | 0.0 | -1 |
Returns the own video service id | def id
case self.service
when :youtube then parse_video_id_for_youtube
when :vimeo then parse_video_id_for_vimeo
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def video_id_public\n if video\n video.id_public\n end\n end",
"def video_id\n values[:video_id]\n end",
"def service_url\n begin\n return video.url\n rescue\n nil\n end\n end",
"def set_video_id\n send(\"#{provider}_video_id\")\n end",
"def avId\n begin... | [
"0.6972197",
"0.6930654",
"0.68147475",
"0.6795659",
"0.65848464",
"0.65729535",
"0.6571735",
"0.6541422",
"0.65072626",
"0.64860314",
"0.6455446",
"0.64406645",
"0.6383935",
"0.62886703",
"0.6279221",
"0.6240653",
"0.6212364",
"0.62025154",
"0.60879457",
"0.60879457",
"0.608... | 0.8061878 | 0 |
Returns the URL for this video embedded === Parameters options Configuration for the embedded URL. === Options :autoplay Autoplay on or off (default on) | def embedded(options={})
autoplay = options[:autoplay].nil? ? true : options[:autoplay]
autoplay = !!autoplay ? '1' : '0'
embeded_template = case self.service
when :youtube then YOUTUBE_EMBEDDED_TEMPLATE
when :vimeo then VIMEO_EMBEDDED_TEMPLATE
end
return embeded_template % [self.id, autoplay]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def embeddable_url\n\t\turl.sub('watch?v=', 'embed/')\n\tend",
"def embedded_video_url\n self.video_url.sub 'watch?v=', 'embed/'\n end",
"def youtube_embed_url\n VideoInfo.new(self.video_url).embed_url if self.video_url?\n end",
"def video_url(source, options = T.unsafe(nil)); end",
"def oembed_url... | [
"0.67662454",
"0.67657304",
"0.6668847",
"0.6600432",
"0.65870035",
"0.6400546",
"0.63416594",
"0.6239008",
"0.6233421",
"0.6227325",
"0.62022215",
"0.617299",
"0.6156925",
"0.6082928",
"0.60553336",
"0.60360926",
"0.6003414",
"0.5906813",
"0.5864534",
"0.5864097",
"0.5839515... | 0.7060799 | 0 |
Returns true if the URL is valid | def valid?
VideoUrl.valid?(self.url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_url?\n @url =~ URI::regexp\n end",
"def validate(url)\n begin\n uri = URI.parse(url)\n if uri.class != URI::HTTP\n\t return false\n end\n rescue URI::InvalidURIError\n\t return false\n end\n return true\nend",
"def valid_url?(url)\n return false if url.nil? || url.strip.... | [
"0.86343783",
"0.847988",
"0.84224933",
"0.8402104",
"0.8364294",
"0.8290405",
"0.82689095",
"0.82582146",
"0.82582146",
"0.82582146",
"0.82320714",
"0.82320714",
"0.82320714",
"0.82189757",
"0.8213499",
"0.8208009",
"0.81927603",
"0.8192227",
"0.8188528",
"0.81696975",
"0.81... | 0.7334312 | 58 |
Set video_id for a given regexp and index of match result | def parse_video_id_for_regexp_and_index(regexp, index)
match_result = self.url.match(regexp)
return match_result[index] if !!match_result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_video_id_for_vimeo\n parse_video_id_for_regexp_and_index(VIMEO_REGEXP, 4)\n end",
"def parse_video_id_for_youtube\n parse_video_id_for_regexp_and_index(YOUTUBE_REGEXP, 6)\n end",
"def set_url_video_id\r\n # Get the URL and put in this variable that will be filtered\r\n # down to... | [
"0.6204636",
"0.6068198",
"0.59581155",
"0.55719334",
"0.55719334",
"0.55719334",
"0.55719334",
"0.55719334",
"0.55665135",
"0.55393314",
"0.5427567",
"0.54152787",
"0.53871983",
"0.5354115",
"0.5343699",
"0.523123",
"0.5214084",
"0.5203008",
"0.5164026",
"0.5155969",
"0.5152... | 0.7568799 | 0 |
Parse the youtube video_id and set it in self | def parse_video_id_for_youtube
parse_video_id_for_regexp_and_index(YOUTUBE_REGEXP, 6)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def youtube_video_id\n video_id = link.match(/\\?v=/) ? link.split('?v=')[1] : link.split('/').last\n video_id = video_id.split('&')[0] if video_id =~ /&/\n self.vid = video_id\n end",
"def youtube_video_id\t\t\n\t\tif self.video_url.nil?\n\t\t\tnil\n\t\telse\n\t\t\tself.video_url.rpartit... | [
"0.84349173",
"0.77813375",
"0.77654135",
"0.7209885",
"0.7189224",
"0.7165815",
"0.71282816",
"0.7084522",
"0.7032639",
"0.69501424",
"0.6938494",
"0.6924599",
"0.68363214",
"0.68337727",
"0.6763516",
"0.67557114",
"0.671982",
"0.6702886",
"0.6670562",
"0.66660714",
"0.66604... | 0.82028997 | 1 |
Parse the vimeo video_id and set it in self | def parse_video_id_for_vimeo
parse_video_id_for_regexp_and_index(VIMEO_REGEXP, 4)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vimeo_video_id\n self.vid = link.split('/').last\n end",
"def youtube_video_id\n video_id = link.match(/\\?v=/) ? link.split('?v=')[1] : link.split('/').last\n video_id = video_id.split('&')[0] if video_id =~ /&/\n self.vid = video_id\n end",
"def initialize id, vimeo\n ... | [
"0.84515035",
"0.72542953",
"0.70958865",
"0.69669414",
"0.67937887",
"0.67703974",
"0.66919595",
"0.6685938",
"0.6685938",
"0.6685938",
"0.6685938",
"0.6685938",
"0.6631221",
"0.6560581",
"0.6560581",
"0.6560581",
"0.6560581",
"0.6560581",
"0.6560581",
"0.6560581",
"0.656058... | 0.8058369 | 1 |
used by the task "bagel:db:sync_permissions" | def permission_scheme
# Get the permission scheme class variable
class_variables.include?('@@permission_scheme') ? class_variable_get(:@@permission_scheme) : {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permissions = {}",
"def restore_permissions; end",
"def restore_permissions; end",
"def permissions_policy(&block); end",
"def paranoid_permissions\n true\n end",
"def setup_database_permissions(connection_string, db_name)\n # We tack on a space at the end to help regex matches\n connection_str... | [
"0.6796348",
"0.6758666",
"0.6758666",
"0.64878273",
"0.6230523",
"0.6175326",
"0.61568564",
"0.6143687",
"0.6143256",
"0.61308044",
"0.61078167",
"0.6088955",
"0.60830015",
"0.6065093",
"0.60535914",
"0.60429484",
"0.5961229",
"0.5929393",
"0.5891205",
"0.58892226",
"0.58635... | 0.0 | -1 |
try to pass method to the data variable | def method_missing(method, *args, &block)
if self.data.respond_to?(method)
typecast(self.data.send(method,*args,&block))
elsif self.data.is_a?(Hash) && self.data.key?(method.to_s)
typecast(self.data[method.to_s])
else
super
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method_missing(method, *args, &block)\n data.send(method, *args, &block)\n end",
"def data_to_method(data)\n raise \"No safe methods defined!\" unless @safe_methods.size > 0\n @safe_methods.each do |method|\n if data['mode'] == method.to_s\n self.send(data['mode'], d... | [
"0.7222773",
"0.681826",
"0.6801701",
"0.67775375",
"0.6767386",
"0.6766182",
"0.66884875",
"0.668479",
"0.6679737",
"0.66701275",
"0.6492078",
"0.6476859",
"0.63866854",
"0.63578206",
"0.6346368",
"0.6326291",
"0.631829",
"0.6311496",
"0.6288878",
"0.620792",
"0.6206238",
... | 0.67951 | 3 |
Fetches and scores gems then prints result | def call
timer do
fetch_gems_data
GemsBond::Printers::HTML.new(gems).call
GemsBond::Printers::CSV.new(gems).call
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_gems_data\n puts \"Fetching data for...\"\n # slice 100 to avoid too many requests on RubyGems and GitHub APIs\n gems.each_slice(100) do |batch|\n each_concurrently(batch) do |gem|\n begin\n retries ||= 0\n # set verbose to true to stdout... | [
"0.6492726",
"0.6254932",
"0.6246565",
"0.587646",
"0.57969266",
"0.56613815",
"0.55932623",
"0.5583416",
"0.5527911",
"0.55012906",
"0.5499438",
"0.54545134",
"0.54389244",
"0.5417412",
"0.53962076",
"0.53961456",
"0.5386545",
"0.5377254",
"0.5377254",
"0.5377254",
"0.536788... | 0.5837879 | 4 |
Returns number of gems | def gems_count
@gems_count ||= gems.count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gems_count\n Recommendable.config.ratable_classes.inject(0) do |sum, klass|\n sum + gemd_count_for(klass)\n end\n end",
"def gems_used\n tree = repository.repo.lookup(revision).tree\n gemfile = tree.select{|blob| blob[:name] == 'Gemfile'}.first\n return 0 if !gemfil... | [
"0.78801644",
"0.7844472",
"0.675362",
"0.67533034",
"0.63811404",
"0.63425595",
"0.6255015",
"0.61621636",
"0.6152294",
"0.6152294",
"0.6152294",
"0.6140528",
"0.60733366",
"0.6068115",
"0.60059845",
"0.5995317",
"0.59810305",
"0.5902619",
"0.5865549",
"0.5857041",
"0.585404... | 0.87557924 | 0 |
Starts a timer and executes given block | def timer
start_at = Time.now
yield
seconds = Time.now - start_at
time_per_gem_text = "#{(seconds / Float(gems_count)).round(2)} second(s) per gem"
puts "\nIt took #{seconds} second(s) to spy #{gems_count} gem(s) (#{time_per_gem_text})."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timer(&block)\n start_time = Time.now\n yield(start_time)\n time_elapsed = Time.now - start_time\n end",
"def with_timer(name, &block)\n start = Time.now\n block.call\n duration = Time.now - start\n # report in ms\n self.add_field(name, duration * 1000)\n ... | [
"0.7348997",
"0.6855058",
"0.6829429",
"0.6828768",
"0.6820101",
"0.6772839",
"0.67140955",
"0.654366",
"0.65370053",
"0.65215915",
"0.64120525",
"0.6399946",
"0.6378475",
"0.63638866",
"0.63542956",
"0.630586",
"0.6213037",
"0.6202187",
"0.6202161",
"0.61959404",
"0.61833644... | 0.0 | -1 |
Returns list of gems to spy | def gems
@gems ||=
Bundler.load.current_dependencies.map do |dependency|
GemsBond::Gem.new(dependency)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runtime_specific_gems\n []\n end",
"def gems\n provisioner, version = @impl.split('-')\n get_gem_list(provisioner, version)\n end",
"def find_gems\n @gems = RubygemsApi.call :all\n end",
"def gems; end",
"def gems; end",
"def gems; end",
"def spec_set\n Bundler.locked_... | [
"0.70879024",
"0.6976767",
"0.6734301",
"0.6725492",
"0.6725492",
"0.6725492",
"0.66878617",
"0.6617341",
"0.65354306",
"0.6518622",
"0.64967877",
"0.6388828",
"0.63587433",
"0.6313727",
"0.6254043",
"0.62126225",
"0.62045",
"0.61947095",
"0.61510247",
"0.61381125",
"0.610969... | 0.6238493 | 15 |
Fetches data for each gem | def fetch_gems_data
puts "Fetching data for..."
# slice 100 to avoid too many requests on RubyGems and GitHub APIs
gems.each_slice(100) do |batch|
each_concurrently(batch) do |gem|
begin
retries ||= 0
# set verbose to true to stdout the gem name
gem.prepare_data(verbose: true)
# rescue SocketError, Faraday::ConnectionFailed...
rescue StandardError
(retries += 1) <= RETRIES ? retry : nil
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prefetch gems\n end",
"def find_gems\n @gems = RubygemsApi.call :all\n end",
"def prefetch reqs\n names = reqs.map { |r| r.dependency.name }\n needed = names.find_all { |d| !@data.key?(d) }\n\n return if needed.empty?\n\n uri = @dep_uri + \"?gems=#{needed.sort.join ','}\"\n str = Gem::R... | [
"0.68294436",
"0.6725108",
"0.6156221",
"0.6070934",
"0.5985889",
"0.5914395",
"0.58899057",
"0.5846923",
"0.5840874",
"0.5831891",
"0.5726342",
"0.5714451",
"0.5713304",
"0.57059944",
"0.5692749",
"0.5676398",
"0.5673906",
"0.5651266",
"0.5651266",
"0.5643925",
"0.5622125",
... | 0.8024932 | 0 |
Starts a thread to process the given gem | def gem_thread(gem)
Thread.new do
begin
retries ||= 0
# set verbose to true to stdout the gem name
gem.prepare_data(verbose: true)
# rescue SocketError, Faraday::ConnectionFailed...
rescue StandardError
(retries += 1) <= RETRIES ? retry : nil
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_thread #does this need to be its own thread?\n @@thread = Thread.new do\n self.run\n end\n end",
"def start!\n start\n blocking_thread.join\n end",
"def start\n return if @thread\n @thread = Thread.new do\n loop do\n sleep\n load_files\n ... | [
"0.5795017",
"0.5713603",
"0.5627765",
"0.5621165",
"0.5576527",
"0.550631",
"0.54878664",
"0.54672587",
"0.5458609",
"0.54413325",
"0.54413325",
"0.54413325",
"0.5439998",
"0.543228",
"0.539618",
"0.5371561",
"0.53276306",
"0.531175",
"0.5305174",
"0.5288762",
"0.52602357",
... | 0.75423545 | 0 |
For new/create if a resource is going to be appended to a parent, the permissions should be based on the ability to update the parent it's going to be appended to. Enables users who only have permission to add to a single Ephemera Project. | def authorize_create!(change_set:)
if change_set.append_id.present?
authorize! :update, query_service.find_by(id: Array(change_set.append_id).first)
else
authorize! :create, resource_class
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n success = false;\n error = \"Resource not available.\"\n permissions = nil\n\n if params.key?(:project_id) and params.key?(:permissions)\n project = Project.find_by(id: params[:project_id])\n target_user = nil\n user_needs_placeholder = false\n\n if params[:permissions]... | [
"0.67868286",
"0.6540564",
"0.6443136",
"0.6385398",
"0.6385398",
"0.6385238",
"0.62786555",
"0.6266332",
"0.6266332",
"0.62471896",
"0.6221904",
"0.622131",
"0.6213768",
"0.62084085",
"0.61593294",
"0.6146667",
"0.61409307",
"0.6126567",
"0.6122699",
"0.61205477",
"0.6111573... | 0.5970547 | 30 |
Overridable method to enable controlling delete behavior in inherited | def around_delete_action
yield
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n raise NotImplementedError\n end",
"def delete\n raise NotImplementedError\n end",
"def delete\n raise NotImplementedError\n end",
"def delete\n raise NotImplementedError\n end",
"def delete; raise ActiveRecord::ReadOnlyRecord; end",
"def delete\n NotImplement... | [
"0.809797",
"0.80720335",
"0.8060069",
"0.8060069",
"0.792954",
"0.78638196",
"0.78638196",
"0.75142163",
"0.75142163",
"0.75142163",
"0.74707824",
"0.7406013",
"0.7365845",
"0.7125355",
"0.7125355",
"0.71045196",
"0.70952356",
"0.704617",
"0.7040714",
"0.7040714",
"0.7040714... | 0.0 | -1 |
Used for submissions from the FileBrowser in the File Manager interface. | def server_upload
change_set_persister.buffer_into_index do |buffered_changeset_persister|
change_set.validate(pending_uploads: change_set.pending_uploads + new_pending_uploads)
buffered_changeset_persister.save(change_set: change_set)
end
ServerUploadJob.perform_later(change_set.id.to_s, new_pending_uploads.map(&:id).map(&:to_s))
redirect_to ContextualPath.new(child: resource, parent_id: nil).file_manager
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file(_event)\n setTimeout 0 do\n @submitted = true\n @filed = true\n end\n end",
"def updated()\n # ICLA file form\n # TODO: why not used?\n _valid = %w(pubname email).all? do |name|\n document.querySelector(\"input[name=#{name}]\").validity.valid\n end\n\n # wire up form... | [
"0.6768956",
"0.6276299",
"0.62280166",
"0.6095093",
"0.6012633",
"0.6012633",
"0.6006448",
"0.59877175",
"0.5953974",
"0.5953974",
"0.59244",
"0.5897041",
"0.58288395",
"0.57683426",
"0.57683426",
"0.5741936",
"0.5741936",
"0.57363397",
"0.57241136",
"0.57205904",
"0.5720590... | 0.0 | -1 |
Remove the resource from given parent | def remove_from_parent
@change_set = ChangeSet.for(resource)
parent_resource = find_resource(parent_resource_params[:id])
authorize! :update, parent_resource
parent_change_set = ChangeSet.for(parent_resource)
current_member_ids = parent_resource.member_ids
parent_change_set.member_ids = current_member_ids - [resource.id]
obj = nil
change_set_persister.buffer_into_index do |persist|
obj = persist.save(change_set: parent_change_set)
end
after_update_success(obj, @change_set)
rescue Valkyrie::Persistence::ObjectNotFoundError => e
after_update_error e
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeFromParent\n @parent.remove(self) if @parent\n end",
"def remove_parent(parent)\n ActsAsDAG::HelperMethods.unlink(parent, self)\n return parent\n end",
"def remove_parent\n # has to go from parent to child\n self.parent.remove_child(self)\n end",
"def remove_item\n... | [
"0.79112875",
"0.7698963",
"0.76058424",
"0.7474343",
"0.7474127",
"0.71848273",
"0.71057445",
"0.6984999",
"0.6908093",
"0.6870487",
"0.67646116",
"0.6731585",
"0.6704699",
"0.65822965",
"0.6566884",
"0.65444684",
"0.6538078",
"0.6490064",
"0.64868987",
"0.6461714",
"0.64612... | 0.7830073 | 1 |
Construct the pending download objects | def new_pending_uploads
@new_pending_uploads ||=
begin
metadata_ingest_files ||
(params[:ingest_files] || []).map do |ingest_file|
# Skip hidden files.
next if ingest_file.split("/").last.start_with?(".")
file = Valkyrie::StorageAdapter.find_by(id: ingest_file)
PendingUpload.new(
id: SecureRandom.uuid,
storage_adapter_id: file.id,
created_at: Time.current,
file_name: ingest_file.split("/").last
)
rescue
nil
end.compact
end.flatten
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def downloads\n @downloads ||= ApiFactory.new 'Projects::Downloads'\n end",
"def setup_download_list\n return unless @container.readable?\n\n # Check if we should show flags for classifications on each of the types of container file\n @allow_show_flags = {}\n %i[stored_file archived_f... | [
"0.6575593",
"0.60133433",
"0.59669405",
"0.5819174",
"0.5802161",
"0.5762619",
"0.5666531",
"0.56363887",
"0.56182206",
"0.56048256",
"0.5569246",
"0.55197275",
"0.54748356",
"0.54615444",
"0.54092425",
"0.53610545",
"0.5302192",
"0.52952826",
"0.52792895",
"0.5258455",
"0.5... | 0.0 | -1 |
Local file ingest submits file metadata as JSON in fields. | def metadata_ingest_files
return if params[:metadata_ingest_files].blank?
params[:metadata_ingest_files].map do |metadata|
metadata = JSON.parse(metadata, symbolize_names: true)
file = Valkyrie::StorageAdapter.find_by(id: metadata[:id])
PendingUpload.new(
id: SecureRandom.uuid,
storage_adapter_id: file.id,
created_at: Time.current,
file_name: metadata[:filename],
type: metadata[:type]
)
rescue
nil
end.compact
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_type_import_body(uploaded_file)\n { 'fileUpload' => UploadIO.new(uploaded_file, uploaded_file.content_type, uploaded_file.original_filename) }\n end",
"def run\n super\n\n f = _get_entity_name\n\n # Read and split the file up\n begin\n json = JSON.parse (File.open(f,\"r\"... | [
"0.655321",
"0.6027442",
"0.5986133",
"0.5986133",
"0.59479463",
"0.59479463",
"0.59326756",
"0.58981025",
"0.58463246",
"0.57984537",
"0.5775936",
"0.57386565",
"0.57286096",
"0.5716162",
"0.5716162",
"0.5674555",
"0.56403655",
"0.56237704",
"0.56199056",
"0.5605414",
"0.556... | 0.6006758 | 2 |
The activesupport to_query extension doesn't escape the = character as it's meant for a primary query string | def to_query(params)
params.to_query.gsub("=", "%3D").gsub("&", "%26")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stringToQuery (val)\n\t\t\n\tend",
"def to_query(key)\n \"#{CGI.escape(key.to_param)}=#{CGI.escape(to_param.to_s)}\"\n end",
"def to_query(params)\n params.map do |key,value|\n \"#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}\"\n end * '&'\n end",
"def to_query(params)\... | [
"0.7703351",
"0.74878",
"0.73181206",
"0.7265",
"0.7253914",
"0.7204443",
"0.71720487",
"0.71463305",
"0.7111515",
"0.70547235",
"0.7051908",
"0.70347655",
"0.6945585",
"0.6938111",
"0.6905837",
"0.6905837",
"0.688844",
"0.68221706",
"0.67786735",
"0.67511123",
"0.67496675",
... | 0.77410597 | 0 |
TODO: Add email validation | def initials
self.first_name[0].to_s + self.last_name[0].to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email; end",
"def email; end",
"def email; end",
"def email; end",
"def email; @email; end",
"def email\n end",
"def email_required?; false end",
"def inbound_email; end",
"def inbound_email; end",
"def email_required?\n false\n end",
"def email_required? \n false \n end",
"def... | [
"0.74439025",
"0.74439025",
"0.74439025",
"0.74439025",
"0.7364892",
"0.7335147",
"0.7242103",
"0.71166867",
"0.71166867",
"0.70264524",
"0.7018231",
"0.7018185",
"0.7002332",
"0.6996276",
"0.699015",
"0.69869304",
"0.6957409",
"0.694389",
"0.69387954",
"0.6933944",
"0.692677... | 0.0 | -1 |
Method for only sending mail to the first recipient that is not sent yet | def send_new_mail(document)
recipient = Recipient.where(document: document, sent: false).first
if recipient.present?
DocumentMailer.with(user: document.user,
email: recipient.email,
document: document).signature_email.deliver_later
recipient.update(sent: true)
DocumentEvent.create!(document: document, message: "E-post sendt til #{recipient.email} ")
if document.status != 1
document.update!(status: 1)
end
else
document.update!(status: 2)
send_signature_complete_mail(document)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_email_sent_to(recipient)\n self.current_email = emails_sent_to(recipient).last\n end",
"def mailboxer_email(object)\n shouldSendEmail = true\n email if shouldSendEmail\n end",
"def delivered_mail(pos = 1)\n ActionMailer::Base.deliveries.last(pos).first\n end",
"def send_emails\n ... | [
"0.7550628",
"0.6983322",
"0.68503827",
"0.6821963",
"0.6744849",
"0.6715399",
"0.6591709",
"0.65161806",
"0.6505094",
"0.6446279",
"0.6385619",
"0.6358094",
"0.63521975",
"0.63484704",
"0.6342118",
"0.6339363",
"0.6320101",
"0.6315906",
"0.62961066",
"0.6292533",
"0.62666225... | 0.6268068 | 20 |
Method for sending mail if no attachment is found | def send_not_allowed_mail(document)
DocumentMailer.with(user: document.user,
email: mail.from[0],
document: document).no_attachment_email.deliver_later
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_msg\n # Files to be attached\n files = []\n files << 'facebook.jpg' if params[:my_mail][:jpeg_file] == 'true'\n files << 'pmt.pdf' if params[:my_mail][:pdf_file] == 'true'\n files << 'квитанция.doc' if params[:my_mail][:ms_doc_file] == 'true'\n files << '... | [
"0.69067234",
"0.66721886",
"0.6578228",
"0.6543926",
"0.6509965",
"0.65033174",
"0.6387092",
"0.63591826",
"0.63224727",
"0.6287134",
"0.627994",
"0.62671113",
"0.6246887",
"0.62191373",
"0.619815",
"0.6185012",
"0.61657",
"0.6159606",
"0.614271",
"0.6115382",
"0.61143345",
... | 0.5899764 | 29 |
Method for sending mail notifying signatures are complete | def send_signature_complete_mail(document)
DocumentMailer.with(email: document.user.email,
document: document).signing_complete.deliver_later
DocumentEvent.create!(document: document, message: "Varsel om ferdig signering sendt til #{document.user.email} ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def completed\n SignaturesMailer.completed\n end",
"def notify\n ActionMailer::Base.mail(:from => \"edgar-garcia@northwestern.edu\", :to => \"digitalcollections@northwestern.edu\", :cc => \"edgar-garcia@northwestern.edu\", :subject => \"DIL Upload permission request - \" + current_user.uid, :body => \"Use... | [
"0.6952288",
"0.6925116",
"0.6554835",
"0.6492871",
"0.6489387",
"0.6475009",
"0.64749724",
"0.6465613",
"0.6453635",
"0.6434189",
"0.6397043",
"0.6321912",
"0.6308923",
"0.6290171",
"0.62781715",
"0.62780416",
"0.6263897",
"0.6260927",
"0.6233106",
"0.6228436",
"0.6227088",
... | 0.7214326 | 0 |
Method for making a viable ActiveStorage blob from attachment | def attachment
mail.attachments.map do |attachment|
blob = ActiveStorage::Blob.create_after_upload!(
io: StringIO.new(attachment.decoded),
filename: attachment.filename,
content_type: attachment.content_type
)
return blob
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blob\n generate\n storage.get(path).body\n end",
"def save_to_storage\n if save_attachment?\n object = self.class.bucket.objects.build(full_filename)\n\n object.content_type = content_type\n object.acl = attachment_options[:acl]\n object.content = t... | [
"0.7118034",
"0.682665",
"0.67741495",
"0.67528325",
"0.67528325",
"0.6704198",
"0.66375333",
"0.66314626",
"0.66031206",
"0.64447635",
"0.6307627",
"0.6277796",
"0.6250707",
"0.62150043",
"0.6202388",
"0.617266",
"0.6167845",
"0.6167845",
"0.6167845",
"0.6167845",
"0.6167845... | 0.69095224 | 1 |
Retrieve email_token from mail | def email_token
recipient = mail.recipients.find { |r| MATCHER.match?(r) }
recipient[MATCHER, 1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_token_from_email(token_name)\n mail_body = last_email.body.to_s\n mail_body[/#{token_name.to_s}_token=([^\"]+)/, 1]\n end",
"def extract_token_from_email(token_name)\n mail_body = last_email.to_s\n mail_body[/#{token_name.to_s}_token=([^\"\\n\\r]+)/, 1]\n end",
"def read_user_emailtok... | [
"0.7751956",
"0.770032",
"0.73534673",
"0.71477175",
"0.69954956",
"0.6732436",
"0.6707616",
"0.67053014",
"0.6529971",
"0.64795786",
"0.6404596",
"0.6400369",
"0.63746166",
"0.6369599",
"0.63327336",
"0.63007706",
"0.6294674",
"0.6222821",
"0.6216576",
"0.6200276",
"0.619840... | 0.82676584 | 0 |
Creates a new SlimcdGateway The gateway requires that valid credentials be passed in the +options+ hash. ==== Options :client_id Assigned by the Slim CD administrator. (REQUIRED) :site_id Assigned by the Slim CD administrator. (REQUIRED) :price_id Assigned by the Slim CD administrator. (REQUIRED) :password Plaintext password for the client account. (REQUIRED) :key SDK developer key obtained from Slim CD, Inc. (REQUIRED) | def initialize(options = {})
requires!(options, :client_id, :site_id, :price_id, :password, :key)
@options = options
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(client_id, client_secret, options = {})\n @client_id = client_id.to_s\n @client_secret = client_secret.to_s\n\n options = {\n :self_key => 'WePay',\n :hash_algo => 'sha512',\n }.merge(options)\n\n @self_key = options[:self_key].to_s\n @hash_algo = options... | [
"0.6130195",
"0.5729571",
"0.5636998",
"0.5613266",
"0.55797356",
"0.5565636",
"0.5554126",
"0.5524659",
"0.55031383",
"0.54439574",
"0.5438366",
"0.54274815",
"0.53963387",
"0.53900474",
"0.53895235",
"0.53841865",
"0.53803444",
"0.53724813",
"0.5343282",
"0.5324289",
"0.532... | 0.6456997 | 0 |
Performs an authorization, which reserves the funds on the customer's credit card, but does not charge the card. ==== Parameters money The amount to be authorized. Either an Integer value in cents or a Money object. creditcard The CreditCard details for the transaction. options A hash of optional parameters. | def authorize(money, creditcard, options = {})
post = {}
add_invoice(post, options)
add_creditcard(post, creditcard)
add_address(post, creditcard, options)
add_customer_data(post, options)
add_duplicate_window(post)
commit('AUTH', money, post)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorize(money, creditcard, options = {})\n post = {}\n add_invoice(post, options)\n add_creditcard(post, creditcard)\n add_address(post, options)\n add_customer_data(post, options)\n add_duplicate_window(post)\n\n commit('AUTH_ONLY', money, post)\n end",
... | [
"0.82812846",
"0.8008966",
"0.7876404",
"0.7872116",
"0.7845436",
"0.7813927",
"0.7808644",
"0.7757511",
"0.7746927",
"0.7649464",
"0.744128",
"0.7372949",
"0.72782403",
"0.7277621",
"0.7263517",
"0.7257591",
"0.72059345",
"0.7167714",
"0.7099423",
"0.70803833",
"0.7073006",
... | 0.79264265 | 2 |
Perform a purchase, which is essentially an authorization and capture in a single operation. ==== Parameters money The amount to be purchased. Either an Integer value in cents or a Money object. creditcard The CreditCard details for the transaction. options A hash of optional parameters. | def purchase(money, creditcard, options = {})
post = {}
add_invoice(post, options)
add_creditcard(post, creditcard)
add_address(post, creditcard, options)
add_customer_data(post, options)
add_duplicate_window(post)
commit('SALE', money, post)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def purchase(money, credit_card, options = {})\n if result = test_result_from_cc_number(credit_card.number)\n return result\n end\n \n request = build_purchase_or_authorization_request(AUTH_TYPE, money, credit_card, options)\n \n commit(request)\n end",
"def pu... | [
"0.8893022",
"0.8756157",
"0.86764383",
"0.8644797",
"0.85461795",
"0.85436106",
"0.84747267",
"0.8463791",
"0.83907115",
"0.8383068",
"0.83319694",
"0.8189441",
"0.8118193",
"0.79195374",
"0.7839045",
"0.7764937",
"0.77463335",
"0.7647809",
"0.7558204",
"0.75515723",
"0.7501... | 0.82954663 | 11 |
Captures the funds from an authorized transaction. ==== Parameters money The amount to be captured. Either an Integer value in cents or a Money object. authorization The authorization returned from the previous authorize request. | def capture(money, authorization, options = {})
post = { :gateid => authorization }
commit('FORCE', money, post)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capture(money, authorization, options = {})\n post = { trans_id: authorization }\n add_customer_data(post, options)\n commit('PRIOR_AUTH_CAPTURE', money, post)\n end",
"def capture(money, authorization, options = {})\n post = {} \n add_authorization(post, refere... | [
"0.7781379",
"0.742546",
"0.7403893",
"0.7383614",
"0.7358988",
"0.73279506",
"0.7236774",
"0.72200316",
"0.7190169",
"0.7178628",
"0.71686333",
"0.70894414",
"0.6960688",
"0.6744804",
"0.6726318",
"0.66828895",
"0.6623468",
"0.661429",
"0.6598622",
"0.6541584",
"0.6457358",
... | 0.6933785 | 13 |
Void a previous transaction ==== Parameters authorization The authorization returned from the previous authorize request. | def void(authorization, options = {})
post = { :gateid => authorization }
commit('VOID', nil, post)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def void(authorization)\n post = {\n transactionId: authorization\n }\n\n commit(:cancel, post)\n end",
"def void_transaction!(authorization)\n response = provider_payment_gateway.void(authorization)\n log_gateway_response(response, \"void [transaction: #{authorization}]\... | [
"0.8511658",
"0.79625285",
"0.7513325",
"0.74927235",
"0.7229536",
"0.7138171",
"0.71273863",
"0.70469546",
"0.7023595",
"0.70138997",
"0.69301736",
"0.6682827",
"0.6679052",
"0.6623339",
"0.65439206",
"0.64832014",
"0.63889873",
"0.6101253",
"0.59945524",
"0.5891246",
"0.588... | 0.7399 | 4 |
Credit an account. This transaction is also referred to as a Refund and indicates to the gateway that money should flow from the merchant to the customer. ==== Parameters money The amount to be credited to the customer. Either an Integer value in cents or a Money object. identification The ID of the original transaction against which the credit is being issued. options A hash of parameters. ==== Options :card_number The credit card number the credit is being issued to. (REQUIRED) | def credit(money, identification, options = {})
post = { :gateid => identification }
commit('CREDIT', money, post)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def credit(money, identification_or_credit_card, options = {}) \n if reference_transaction?(identification_or_credit_card)\n # Referenced credit: refund of a settled transaction\n perform_reference_credit(money, identification_or_credit_card, options)\n else # must be a credi... | [
"0.813205",
"0.78354686",
"0.7818792",
"0.7759083",
"0.7637752",
"0.76291376",
"0.7576386",
"0.74380124",
"0.7097683",
"0.7074614",
"0.6963055",
"0.69241565",
"0.68987834",
"0.6822871",
"0.66994894",
"0.66994894",
"0.6695116",
"0.6693651",
"0.66687053",
"0.6605151",
"0.655881... | 0.8146303 | 0 |
Make a ruby type out of the response string | def normalize(field)
case field
when "true" then true
when "false" then false
when "" then nil
when "null" then nil
else field
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert(value, type)\n begin\n case type\n when 'json' then JSON.parse(value)\n when 'base64' then JSON.parse(Base64.decode64(value))\n when 'integer' then Integer(value)\n when 'number' then Float(value)\n else\n value.to_s\n end\n rescue Arg... | [
"0.6822089",
"0.6656662",
"0.65263885",
"0.6480913",
"0.6479441",
"0.6401203",
"0.63952774",
"0.6370618",
"0.6332342",
"0.62896943",
"0.6285262",
"0.62674725",
"0.6253528",
"0.6251857",
"0.62380135",
"0.623284",
"0.62236094",
"0.62236094",
"0.6209322",
"0.6204596",
"0.6199452... | 0.0 | -1 |
return pointer for use with pack('L') | def str_to_ptr(v)
[v].pack('p*').unpack('L')[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pack(p0) end",
"def unpack_pointer(packed_pointer)\n if is_64bit\n # Assume little endian\n packed_pointer.unpack('Q<')[0]\n else\n packed_pointer.unpack('V')[0]\n end\n end",
"def p32(*address)\n\treturn address.pack(\"L*\")\nend",
"def ret_s\n result = ''\n func = get... | [
"0.6726432",
"0.65648407",
"0.64998645",
"0.64528",
"0.62805027",
"0.62515354",
"0.62072206",
"0.6075672",
"0.60337585",
"0.5845405",
"0.5845405",
"0.5845405",
"0.5845405",
"0.5845405",
"0.5783891",
"0.5777143",
"0.5731012",
"0.57200515",
"0.570562",
"0.5607328",
"0.5537669",... | 0.66304564 | 1 |
Print all odd numbers from 1 to 99, inclusive. All numbers should be printed on separate lines. create a method that takes two arguments iterate over a range creating a new array with the selected elements output that numbers on seperate lines | def odd_numbers(num1, num2)
(num1..num2).select { |n| n.odd? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_odd\n range = (1..99).to_a\n range.each do |num|\n if num % 2 == 0\n puts num\n end\n end\nend",
"def print_odd(numbers)\n\tnumbers.each do |number|\n\t\tif number % 2 == 1\n\t\t\tp number\n\t\tend\n\tend\nend",
"def pares(num1, num2)\n (num1..num2).each do |par|\n puts par if par.e... | [
"0.845888",
"0.70679986",
"0.7051553",
"0.69453037",
"0.6926996",
"0.68728495",
"0.68418354",
"0.67936015",
"0.67302054",
"0.67041266",
"0.66925186",
"0.66859",
"0.66788906",
"0.66597515",
"0.66531456",
"0.6646816",
"0.66437536",
"0.6639255",
"0.6637021",
"0.66350055",
"0.661... | 0.6031004 | 61 |
Delivers integer of sum number of equipments owned by character instance | def total_items
items = Inventory.where(character_id: self.id)
items.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pool_acts_equip_mod\n return 0 if battler.nil? || !battler.is_a?(Game_Actor)\n battler.equips.inject(0) do |sum,e| \n mod = e.nil? ? 0 : (e.pool_acts_mod ||= 0)\n sum += mod\n end\n end",
"def character_weight\n total_weight = 0\n items = Inventory.where(character_id: self.i... | [
"0.6859731",
"0.68530625",
"0.65938455",
"0.6434458",
"0.6389056",
"0.6367064",
"0.62905943",
"0.62845594",
"0.62666035",
"0.62512994",
"0.62505794",
"0.6243097",
"0.62177783",
"0.62088156",
"0.6208674",
"0.619741",
"0.6176754",
"0.6137139",
"0.6111489",
"0.61032027",
"0.6096... | 0.6991001 | 0 |
Delivers integer describing sum of equipments owned weights | def character_weight
total_weight = 0
items = Inventory.where(character_id: self.id)
items.each do |i|
x = Equipment.find(i.equipment_id).weight
total_weight += x if x
end
total_weight
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weight\n self.ingredients.map{|i| i.quantity}.reduce(:+)\n end",
"def weightedsum\n ws = 0\n @inputs.each_index { |i| ws = ws + @inputs[i]*@weights[i] }\n ws\n end",
"def total_weight\n order_items.collect { |oi| oi.weight }.inject { |sum, x| sum + x } || 0\n end",
"def calculate_we... | [
"0.71391046",
"0.7086918",
"0.6982984",
"0.68481654",
"0.6818408",
"0.6754476",
"0.6699343",
"0.6699343",
"0.66631263",
"0.66443664",
"0.66359967",
"0.6633059",
"0.66157764",
"0.6575519",
"0.6495228",
"0.6480172",
"0.6399907",
"0.63695735",
"0.6368915",
"0.6348292",
"0.633856... | 0.64749855 | 16 |
GET /bestgames/1 GET /bestgames/1.json | def show
@bestgame = Bestgame.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @bestgame }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @games = Game.available\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def index\n @games = Game.all\n render json: @games\n end",
"def index\n @games = Game.all\n\n respond_to do |format|\n format... | [
"0.75343937",
"0.7344581",
"0.726822",
"0.7268165",
"0.7268165",
"0.7268165",
"0.7207151",
"0.71713203",
"0.71511453",
"0.71043414",
"0.7099059",
"0.69591147",
"0.6954685",
"0.6949844",
"0.6949844",
"0.6949844",
"0.6949844",
"0.6949844",
"0.6949844",
"0.6949844",
"0.69472194"... | 0.7781176 | 0 |
GET /bestgames/new GET /bestgames/new.json | def new
@bestgame = Bestgame.new
@player_select_data = Player.all.collect{|p| [p.name, p.id]}
@lineup_select_data = ""
@non_lineup_select_data = Player.all.collect{|p| [p.name, p.id]}
respond_to do |format|
format.html # new.html.erb
format.json { render json: @bestgame }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @game = Game.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @game }\n end\n end",
"def new\n @old_game = OldGame.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @old_game }\n en... | [
"0.7815345",
"0.77895147",
"0.7759262",
"0.7759262",
"0.7759262",
"0.7759262",
"0.7759262",
"0.7759262",
"0.7759262",
"0.7759262",
"0.7759262",
"0.7759262",
"0.7759262",
"0.7621673",
"0.75953907",
"0.75934213",
"0.757585",
"0.7552501",
"0.7500164",
"0.7462923",
"0.7445139",
... | 0.70340425 | 46 |
POST /bestgames POST /bestgames.json | def create
@bestgame = Bestgame.new(params[:bestgame])
respond_to do |format|
if @bestgame.save
format.html { redirect_to @bestgame, notice: 'Bestgame was successfully created.' }
format.json { render json: @bestgame, status: :created, location: @bestgame }
else
format.html { render action: "new" }
format.json { render json: @bestgame.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @game = current_or_guest_user.games.create\n render json: @game, status: 201\n end",
"def create\n game = @current_user.games.create!(game_params)\n render json: { game: game }\n end",
"def create\n @new_game = Game.create(game_params)\n render json: @new_game\n\n end",
"def... | [
"0.7068596",
"0.68883044",
"0.68633133",
"0.6773922",
"0.662005",
"0.6604422",
"0.653616",
"0.6505623",
"0.6488154",
"0.6471678",
"0.6464274",
"0.645424",
"0.64496934",
"0.64488995",
"0.6444146",
"0.6435989",
"0.6425111",
"0.6406201",
"0.63908786",
"0.63902277",
"0.63902277",... | 0.7362521 | 0 |
PUT /bestgames/1 PUT /bestgames/1.json | def update
@bestgame = Bestgame.find(params[:id])
respond_to do |format|
if @bestgame.update_attributes(params[:bestgame])
format.html { redirect_to @bestgame, notice: 'Bestgame was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @bestgame.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n #if game exists, pass here to update state\n @game = Game.find_by(id: params[:id])\n @game.update(game_params)\n render json: @game, status: 201\n end",
"def update\n\n @game.turn = params[:game][:turn]\n @game.finished = params[:game][:finished]\n @game.winner = params[:game][... | [
"0.68059254",
"0.6749593",
"0.6680789",
"0.6541481",
"0.6424901",
"0.641676",
"0.6412682",
"0.64113194",
"0.6409816",
"0.6409816",
"0.6409816",
"0.6409816",
"0.6409816",
"0.6409816",
"0.6409816",
"0.63943595",
"0.6390868",
"0.6361885",
"0.635334",
"0.6353",
"0.63510776",
"0... | 0.7373703 | 0 |
DELETE /bestgames/1 DELETE /bestgames/1.json | def destroy
@bestgame = Bestgame.find(params[:id])
@bestgame.destroy
respond_to do |format|
format.html { redirect_to bestgames_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @game.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.html { redirect_to contest_games_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @g... | [
"0.7487991",
"0.74776",
"0.7429544",
"0.74243677",
"0.7400176",
"0.7400176",
"0.7400176",
"0.7400176",
"0.7400176",
"0.7400176",
"0.7400176",
"0.7400176",
"0.7400176",
"0.7400176",
"0.7400176",
"0.7400176",
"0.73951095",
"0.73951095",
"0.73706836",
"0.73706836",
"0.73706836",... | 0.7804282 | 0 |
Override for default bottom bar: | def default_bbar
[
:add.action, :edit.action, :apply.action, :del.action,
"-", # Adds a separator
:search.action,
"-", # Adds a separator
{
:menu => [:add_in_form.action, :edit_in_form.action],
:text => I18n.t(:edit_in_form),
:icon => "/images/icons/application_form.png"
},
"-", # Adds a separator
:row_counter.action
]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bottom_links(content=nil,opts={}, &block)\n content_for(:bottom_linkbar, capture(&block))\n end",
"def default_bbar\n [\n :show_details.action, # The custom action defined below via JS\n :search.action,\n \"-\", # Adds a sepa... | [
"0.64004856",
"0.60715175",
"0.60101473",
"0.5988939",
"0.59506136",
"0.5872297",
"0.58097005",
"0.58091897",
"0.58091897",
"0.5774728",
"0.575915",
"0.573333",
"0.5695456",
"0.56887484",
"0.5688596",
"0.5678407",
"0.56711644",
"0.5654639",
"0.5635766",
"0.5601477",
"0.560147... | 0.57073534 | 12 |
Override for default context menu | def default_context_menu
[
:row_counter.action,
"-", # Adds a separator
*super # Inherit all other commands
]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_context_menu\n [\n :row_counter.action,\n \"-\",\n :ctrl_manage.action,\n :show_details.action, # The custom action defined below via JS\n \"-\", # Adds a separator\n *super ... | [
"0.7952461",
"0.7736506",
"0.7444761",
"0.6571905",
"0.65416527",
"0.65416527",
"0.6477728",
"0.64531034",
"0.6404722",
"0.6214464",
"0.6174655",
"0.6155644",
"0.61534774",
"0.61178565",
"0.607794",
"0.60713536",
"0.5826118",
"0.5812436",
"0.5742729",
"0.57195675",
"0.5714136... | 0.76309144 | 3 |
Don't require email or password, as we also use OAuth | def email_required?
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def oauth_authentication; end",
"def capable_plain_auth?; end",
"def password_required?\n super unless has_facebook_auth\n end",
"def valid_for_http_auth?; end",
"def password_required?\n return false if provider.to_s == 'google_oauth2'\n super\n end",
"def use_oauth\n\t\t\t\n\t\tend",
"def ... | [
"0.70852697",
"0.69221854",
"0.6912944",
"0.6893468",
"0.68055665",
"0.6797814",
"0.67725945",
"0.66705346",
"0.6625113",
"0.6622187",
"0.6611939",
"0.66031384",
"0.65685743",
"0.65513724",
"0.6541997",
"0.6499946",
"0.6492842",
"0.64732224",
"0.6431902",
"0.6423503",
"0.6382... | 0.0 | -1 |
if food == elsif food == elsif food == elsif food == end end | def rate_my_food(food)
case food
when "Steak"
"Pass the steak sauce! That's delicious"
when "Sushi"
"Great choice! My favorite food"
when "Tacos", "Burritos", "Quesadillas" # operator or
"Cheesy and filling! The perfect combination"
when "Tofu", "Brussel Sprouts"
"Disgusting! Yuck!"
else
"I don't know about that food!"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def should_eat( food, season )\n if (food == \"ice cream\" && season == \"winter\") || (food = \"hot chocolate\" && season == \"summer\")\n return false\n else\n return true\nend\nend",
"def should_eat(food, season)\n if food == \"hot chocolate\" && season == \"summer\"\n return \"False\"\n elsif fo... | [
"0.67317057",
"0.64594895",
"0.63268614",
"0.62275034",
"0.6100794",
"0.5943807",
"0.5914828",
"0.5830672",
"0.5829338",
"0.5818682",
"0.57995474",
"0.5782956",
"0.5764162",
"0.574029",
"0.56559646",
"0.5612018",
"0.55872655",
"0.5573228",
"0.55652463",
"0.5513945",
"0.549757... | 0.622389 | 4 |
Returns an Array containing the segments of a constant path. | def constant_segments(node)
segments = []
if node.children[0]
segments.concat(constant_segments(node.children[0]))
end
segments << node.children[1].to_s
return segments
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def segments_from_path(path)\n # Remove leading ^ and trailing $ from each segment (left-overs from regexp joining)\n strip = proc { |str| str.gsub(/^\\^/, '').gsub(/\\$$/, '') }\n segments = []\n while match = (path.match(SEGMENT_REGEXP))\n segments << strip[match.pre_match] u... | [
"0.73867816",
"0.7174711",
"0.66963434",
"0.66170824",
"0.620103",
"0.61622316",
"0.6158511",
"0.61437505",
"0.6074302",
"0.6015535",
"0.60024714",
"0.5941801",
"0.5906851",
"0.5896547",
"0.58913326",
"0.586919",
"0.58139795",
"0.58119565",
"0.5810146",
"0.5738162",
"0.573709... | 0.7640927 | 0 |
Don't do fill setup | def fill_setup(_gc)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_setup(gc)\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n # noop\n end",
"def setup\n\t\t# Do nothing\n\tend",
"def setup\n\t\t# Do nothing\n\tend",
"def setup\n self.setup! unless self.setup?\n ... | [
"0.75280595",
"0.7078427",
"0.7078427",
"0.6971083",
"0.6915514",
"0.6915514",
"0.6868871",
"0.6612044",
"0.6612044",
"0.6612044",
"0.6612044",
"0.6612044",
"0.6612044",
"0.6612044",
"0.6563023",
"0.650687",
"0.6501948",
"0.6470721",
"0.6460074",
"0.6424137",
"0.6386713",
"... | 0.75122476 | 1 |
OVERRIDE: Null out each controlled field before saving, meaning only incoming values will persist on the record. This results in blank controlled values in ingested CSVs being "deleted". | def update_collection(attrs)
# OVERRIDE: add call to custom #null_controlled_fields! method
null_controlled_fields!(attrs)
object.attributes = attrs
object.save!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def null_controlled_fields!(attrs)\n ::ScoobySnacks::METADATA_SCHEMA.controlled_field_names.each do |field_name|\n # do not null fields that are not being changed\n next unless attrs.keys.include?(\"#{field_name}_attributes\")\n\n object.public_send(\"#{field_name}=\", [])\n end\n end",
"de... | [
"0.7359445",
"0.7180945",
"0.7000423",
"0.6892833",
"0.687399",
"0.6728838",
"0.66691464",
"0.66640687",
"0.6632706",
"0.65243804",
"0.6440418",
"0.6424094",
"0.6414484",
"0.64028084",
"0.6357682",
"0.6353168",
"0.63478416",
"0.6319233",
"0.62338644",
"0.62305874",
"0.6194330... | 0.55892605 | 80 |
OVERRIDE: Add custom method to make Bulkrax and ScoobySnacks more compatible | def null_controlled_fields!(attrs)
::ScoobySnacks::METADATA_SCHEMA.controlled_field_names.each do |field_name|
# do not null fields that are not being changed
next unless attrs.keys.include?("#{field_name}_attributes")
object.public_send("#{field_name}=", [])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snat_pool\n super\n end",
"def sitemaps; end",
"def each\n snacks.each do |snack|\n yield snack\n end\n end",
"def private; end",
"def schubert; end",
"def snacks\n\n @snacks = Spree::Product.limit(5).order('id desc')\n @snacks.sort_by! { |x| x[:name].downcase }\n end",
"... | [
"0.57277834",
"0.56490725",
"0.5329209",
"0.5264472",
"0.5261022",
"0.5207125",
"0.5131607",
"0.5113928",
"0.5109255",
"0.50845385",
"0.5049509",
"0.5049509",
"0.5028065",
"0.49853888",
"0.49540144",
"0.4947893",
"0.49205974",
"0.4917866",
"0.4896474",
"0.48816085",
"0.487412... | 0.0 | -1 |
GET /hacks/1 GET /hacks/1.json | def show
@hack = Hack.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @hack }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @hacker = Hacker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hacker }\n end\n end",
"def new\n @hack = Hack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hack }\... | [
"0.70416176",
"0.66230714",
"0.6590241",
"0.6540019",
"0.6310924",
"0.6310924",
"0.6264245",
"0.624627",
"0.624627",
"0.61146516",
"0.59942466",
"0.59170043",
"0.5821667",
"0.5821667",
"0.5814296",
"0.5772688",
"0.57704675",
"0.5751515",
"0.5737273",
"0.5715793",
"0.5705145",... | 0.7400066 | 0 |
GET /hacks/new GET /hacks/new.json | def new
@hack = Hack.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @hack }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @hack = Hack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hack }\n end\n end",
"def new\n @hacker = Hacker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hacker }\n end\n end"... | [
"0.8059126",
"0.77401054",
"0.77401054",
"0.6790309",
"0.6655544",
"0.6633469",
"0.657953",
"0.6504488",
"0.64509076",
"0.6442616",
"0.6442448",
"0.64174134",
"0.6407759",
"0.6379512",
"0.63743067",
"0.63493705",
"0.63493705",
"0.63412446",
"0.6297349",
"0.629451",
"0.6217404... | 0.8019836 | 1 |
POST /hacks POST /hacks.json | def create
@hack = Hack.new(params[:hack])
#logger.info "event_name: ======="
event_name = params[:event_name]
#logger.info "event_name: " + event_name unless event_name.nil?
event = Event.find_by_name_caseinsensitive(event_name)
if(event.nil?)
logger.info "event not found, lets's create new one "
event = Event.create()
event.name = event_name
event.eventdate = Time.new
event.save
end
@hack.event = event
respond_to do |format|
if @hack.save
emailaddresses = params[:hack_team_emails]
logger.info "after new create hack, send team emails: " + emailaddresses
invite_team_members(emailaddresses, @hack)
format.html { redirect_to @hack, :notice => 'Hack was successfully created.' }
format.json { render :json => @hack, :status => :created, :location => @hack }
else
format.html { render :action => "new" }
format.json { render :json => @hack.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @hack = Hack.new(params[:hack])\n\n respond_to do |format|\n if @hack.save\n format.html { redirect_to @hack, notice: 'Hack was successfully created.' }\n format.json { render json: @hack, status: :created, location: @hack }\n else\n format.html { render action: \"... | [
"0.68881834",
"0.66280633",
"0.62280065",
"0.61810607",
"0.60406166",
"0.59946245",
"0.5958912",
"0.5920991",
"0.58166856",
"0.58166856",
"0.57151634",
"0.57151634",
"0.5638459",
"0.56355447",
"0.5546912",
"0.5462803",
"0.53735363",
"0.53677434",
"0.5311316",
"0.52749044",
"0... | 0.53665185 | 18 |
PUT /hacks/1 PUT /hacks/1.json | def update
@hack = Hack.find(params[:id])
respond_to do |format|
if @hack.update_attributes(params[:hack])
format.html { redirect_to @hack, :notice => 'Hack was successfully updated.' }
format.json { head :ok }
else
format.html { render :action => "edit" }
format.json { render :json => @hack.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @hack = Hack.find(params[:id])\n\n respond_to do |format|\n if @hack.update_attributes(params[:hack])\n format.html { redirect_to @hack, notice: 'Hack was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n... | [
"0.7111815",
"0.68478435",
"0.6722511",
"0.659202",
"0.659202",
"0.6347484",
"0.60263634",
"0.59213746",
"0.5888474",
"0.5802053",
"0.579233",
"0.57616717",
"0.57616717",
"0.565767",
"0.5615698",
"0.556979",
"0.55583864",
"0.5544215",
"0.5538186",
"0.55355215",
"0.55355215",
... | 0.7141757 | 0 |
DELETE /hacks/1 DELETE /hacks/1.json | def destroy
@hack = Hack.find(params[:id])
@hack.destroy
respond_to do |format|
format.html { redirect_to hacks_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @hack = Hack.find(params[:id])\n @hack.destroy\n\n respond_to do |format|\n format.html { redirect_to hacks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hacker = Hacker.find(params[:id])\n @hacker.destroy\n\n respond_to do |format|\n fo... | [
"0.7742959",
"0.7297151",
"0.7268553",
"0.690549",
"0.66731745",
"0.65752196",
"0.655937",
"0.654154",
"0.6390018",
"0.632456",
"0.627344",
"0.62694347",
"0.62603915",
"0.6252997",
"0.62400734",
"0.6210805",
"0.6210805",
"0.6210805",
"0.6210805",
"0.62079275",
"0.6195012",
... | 0.77715 | 0 |
recipes create when user adds a recipe, we know who added that recipe have authentication save user inputted info user_id fk on recipes table (MIGRATION) figure out who is logged in and add their id to the recipe that's getting made | def show
# accept the params
# go to the db and get the correct recipe for that param
p params[:id]
@recipe = Recipe.find_by(id: params[:id])
@ingredients = @recipe.ingredients.split(", ").map {|ingredient| ingredient.capitalize}
# send this to the view
# show that data to the user
render 'show.json.jb'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_recipe_connection(recipe_id)\n if user.recipes.where(id: recipe_id) == Recipe.all.where(id: recipe_id)\n recipe_finder(recipe_id)\n else\n UserRecipe.create(name: self.user.name, user_id: self.user.id, recipe_id: recipe_id)\n recipe_finder(recipe_id)\n ... | [
"0.7460179",
"0.7274224",
"0.7256458",
"0.7131675",
"0.7107879",
"0.70410264",
"0.6984449",
"0.69218016",
"0.6892945",
"0.68910486",
"0.6879346",
"0.6873885",
"0.68526244",
"0.6821334",
"0.68186754",
"0.6794784",
"0.6785803",
"0.67701733",
"0.67528045",
"0.67021084",
"0.66937... | 0.0 | -1 |
Show news content + 2 GT links "next" and "previous" | def show
@news = News.find(params[:id])
@next = News.where("publication_date <= ? AND id != ?", @news.publication_date, @news.id).order("publication_date DESC").first;
@previous = News.where("publication_date >= ? AND id != ?", @news.publication_date, @news.id).order("publication_date DESC").last;
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @previous_blog = @blog.previous\n @next_blog = @blog.next\n end",
"def publish_front_page\n\t\tfirst = (@current_page - 1) * 3\n\t\tlast = (first + 3) - 1\n\t\tpage = first..last\n\t\t@post[page].each do |each_post|\n\t\t\tputs \"#{each_post.title} #{each_post.date}\"\n\t\t\tputs \"#{each_post.... | [
"0.64494765",
"0.63321674",
"0.6331142",
"0.6284424",
"0.6270019",
"0.6252723",
"0.6249508",
"0.62449545",
"0.6211686",
"0.619979",
"0.60810107",
"0.6050475",
"0.5995736",
"0.5990199",
"0.5949574",
"0.59228194",
"0.5919695",
"0.59050727",
"0.5903859",
"0.5888443",
"0.58654964... | 0.6763704 | 0 |
Method to do basic validations like is this a valid file to even accept for any future transactions ==== Returns: true if the file is valid and false otherwise | def is_valid?
raise "Not Implemented. Class #{self.class.name} doesn't implement is_valid?"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_file(file)\n end",
"def valid?\n return false if @file_id.nil?\n true\n end",
"def validate_file(filename)\n return true\nend",
"def valid?\n ensure_file_open!\n\n ['Makefile', 'submission/', 'tests/'].all? { |entry| @file.find_entry(entry).present? }\n end",
"def shoul... | [
"0.7921186",
"0.77443755",
"0.7637357",
"0.7519518",
"0.745484",
"0.74079746",
"0.7294285",
"0.7247295",
"0.7231445",
"0.7216679",
"0.7203188",
"0.7202431",
"0.71676624",
"0.70958686",
"0.70870155",
"0.69900745",
"0.69497937",
"0.6912684",
"0.6863525",
"0.68626726",
"0.684946... | 0.0 | -1 |
Method to infer the language(s) of the caption by inspecting the file depending on the type of the caption file ==== Returns The ISO 6391 Letter Language codes | def infer_languages
raise "Not Implemented. Class #{self.class.name} doesn't implement infer_languages"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_language_by_file_extension s_file_path, msgcs\n if KIBUVITS_b_DEBUG\n bn=binding()\n kibuvits_typecheck bn, String, s_file_path\n kibuvits_typecheck bn, Kibuvits_msgc_stack, msgcs\n end # if\n ar_tokens=Kibuvits_str.ar_bisect(s_file_path.reverse, '.')\n s_file_e... | [
"0.6632015",
"0.6442927",
"0.64024466",
"0.6279754",
"0.6107243",
"0.6085391",
"0.6055107",
"0.5922786",
"0.5920917",
"0.5877072",
"0.5829107",
"0.58077836",
"0.5806559",
"0.5780551",
"0.5761174",
"0.5725719",
"0.57174224",
"0.57023156",
"0.5692218",
"0.5669612",
"0.565673",
... | 0.0 | -1 |
Method to set a translation engine +translator+ Instance of translation engine. Refer to `engines/aws` for example ==== Raises `InvalidInputException` when the argument `translator` is not an instance of Translator class | def set_translator(translator)
if translator && !(translator.is_a? Translator)
raise InvalidInputException.new("Argument is not an instance of Translator")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_translator\n @translator = Translator.find(params[:id])\n end",
"def set_translator\n @translator = Translator.find(params[:id])\n end",
"def translator\n @translator ||= Translator.new\n end",
"def configure(&block)\n unless provider\n raise 'Translation provider ... | [
"0.6233308",
"0.6233308",
"0.60803765",
"0.55349505",
"0.5384758",
"0.5176296",
"0.5095139",
"0.49945453",
"0.49788138",
"0.49754748",
"0.494479",
"0.49301872",
"0.4921156",
"0.4905077",
"0.48527458",
"0.4826315",
"0.48260474",
"0.48055702",
"0.478637",
"0.47804967",
"0.47587... | 0.7462785 | 0 |
Method to translate the caption from one language to another +src_lang+ can be inferred using infer_language method +target_lang+ Target 2 letter ISO language code to which the source needs to be translated in to. +output_file+ Output file. Can be a fully qualified path or just file name ==== Raises InvalidInputException shall be raised if 1. The input file doesn't exist or is unreadable or is invalid caption 2. The output file can't be written 3. The target_lang is not a valid ISO 6391 Letter Language code | def translate(src_lang, target_lang, output_file)
# Check if a non empty output file is present and error out to avoid
# the danger or overwriting some important file !!
if File.exists?(output_file) && File.size(output_file) > 0
raise InvalidInputException.new("Output file #{output_file} is not empty.")
else
# Just open the file in writable mode and close it just to ensure that
# we can write the output file
File.open(output_file, "w") {|f|
}
end
# Check if the file is writable ?
unless File.writable?(output_file)
raise InvalidInputException.new("Output file #{output_file} not writable.")
end
# Further checks can be done only in caption specific implementations
# or translation engine specific implementation
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def translate(input_text, src_lang, target_lang)\n raise \"Not Implemented. Class #{self.class.name} doesn't implement translate\"\n end",
"def convert\n # TODO: implementation\n output_file = choose_output\n return if output_file.nil?\n Converter.translate(@file, output_file)\n log(\"File con... | [
"0.62928003",
"0.61206913",
"0.6045052",
"0.6026681",
"0.59488124",
"0.571821",
"0.5589105",
"0.5477882",
"0.538116",
"0.52734816",
"0.5264656",
"0.5199831",
"0.5198509",
"0.5108316",
"0.5067594",
"0.50415075",
"0.49992803",
"0.49937707",
"0.49720055",
"0.4959468",
"0.4955963... | 0.827195 | 0 |
Method to convert from one caption type to other types. If the src_lang is not provided then all source languages will be converted to target types. For example, if a ttml file has "en" and "es" and target_type is vtt and no src_lang is provided 2 vtt files would be created one per language in the source. if a target_lang is provided then one of the lang from source would be picked for creating the output file with target_lang If no target_lang is provided, no translations are applied. output_file is created using without any need for any language translation services. Hence doesn't incur any cost !! Note: +src_lang+ makes sense only for caption types that can hold multi lingual captions like dfxp and ttml. For other caption sources this field is ignored +types+ An array of Valid input caption type(s). Refer to `CaptionType` +src_lang+ can be inferred using infer_language method +target_lang+ Target 2 letter ISO language code to which the source needs to be translated in to. +output_dir+ Output Directory. Generated files would be dumped here ==== Raises InvalidInputException shall be raised if 1. The input file doesn't exist or is unreadable or is invalid caption 2. The output dir doesn't exist 3. Invalid lang codes for a given caption type 4. Unsupported type to which conversion is requested for | def transform_to(types, src_lang, target_lang, output_dir)
if (types - supported_transformations).size != 0
raise InvalidInputException.new("Unknown types provided for conversion in input #{types}")
end
unless File.directory?(output_dir)
FileUtils.mkdir_p(output_dir)
end
# Basic validations
if types.include?(TYPE_SCC)
if target_lang && !target_lang.eql?("en")
raise InvalidInputException.new("SCC can be generated only in en. #{target_lang} is unsupported")
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def translate(src_lang, target_lang, output_file)\n # Check if a non empty output file is present and error out to avoid\n # the danger or overwriting some important file !!\n if File.exists?(output_file) && File.size(output_file) > 0\n raise InvalidInputException.new(\"Output file #{output_file} is ... | [
"0.645276",
"0.51610065",
"0.51556504",
"0.5090777",
"0.50742704",
"0.4923128",
"0.4892049",
"0.48383597",
"0.47344825",
"0.4706987",
"0.46942037",
"0.46891785",
"0.4681737",
"0.46329215",
"0.4613695",
"0.4571641",
"0.45504057",
"0.44888973",
"0.44713172",
"0.4471253",
"0.446... | 0.6803488 | 0 |
Method to report on the supported transformations. Each implementor is free to return the types to which it can convert itself to ==== Returns An array of one or more types defined as +TYPE_+ constants here | def supported_transformations
raise "Not Implemented. Class #{self.class.name} doesn't implement supported_transformations"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def types\n trans = ChessMoves::Transformations[@type]\n trans ? [@type, trans.first] : [@type]\n end",
"def cast_types; end",
"def transforms\n @transforms ||= [\n NullTransform, NormalizationTransform, CasingTransform,\n NamedTransform, BreakInternalTransform... | [
"0.6083852",
"0.58313733",
"0.5753641",
"0.574344",
"0.574344",
"0.574344",
"0.574344",
"0.574344",
"0.56845313",
"0.5650447",
"0.5531124",
"0.5522686",
"0.5522366",
"0.5462688",
"0.5385095",
"0.5371676",
"0.5352404",
"0.5289835",
"0.5285845",
"0.5265506",
"0.5255417",
"0.5... | 0.64704716 | 0 |
While the logic of abstracting stuff to callers has it's benefits, sometimes it's required to identify which instance are we specifically operate on. This method returns the instance currently being operated on and returns one of the +TYPE_+ constants defined here Implement this unless and absolutely it's necessary and there is no other easy way to do things ===== Returns the call sign of the instance | def callsign
raise "Not Implemented. Class #{self.class.name} doesn't implement callsign"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call_type\n return !@call_types.empty? ? @call_types[-1] : :instance_method\n end",
"def instance_type; end",
"def self_type; end",
"def self_type; end",
"def self_type; end",
"def type\n singleton ? 'class' : 'instance'\n end",
"def type\n singleton ? 'class' : 'instance'\n end... | [
"0.63145405",
"0.6009355",
"0.5955215",
"0.5955215",
"0.5955215",
"0.5902116",
"0.5902116",
"0.5902116",
"0.58847815",
"0.5875799",
"0.5869662",
"0.5867123",
"0.58491755",
"0.5782501",
"0.5722898",
"0.571801",
"0.57140434",
"0.568437",
"0.5671924",
"0.5670801",
"0.56575626",
... | 0.0 | -1 |
GET /pashiris GET /pashiris.json | def index
@pashiris = Pashiri.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pizzas = Pizza.all\n render json: @pizzas\n end",
"def index\n @iphs = Iph.paginate(:page => params[:page], :per_page => 10).order('created_at desc')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @iphs }\n end\n end",
"def index\n ... | [
"0.6671753",
"0.6513453",
"0.64613706",
"0.63841903",
"0.6178173",
"0.6176981",
"0.61122996",
"0.610425",
"0.60990757",
"0.6095957",
"0.6080021",
"0.60766923",
"0.6062933",
"0.6061838",
"0.6060596",
"0.6040236",
"0.60252005",
"0.6023783",
"0.6017991",
"0.60085934",
"0.6004138... | 0.6998126 | 0 |
GET /pashiris/1 GET /pashiris/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pizzas = Pizza.all\n render json: @pizzas\n end",
"def index\n @pashiris = Pashiri.all\n end",
"def index\n @iphs = Iph.paginate(:page => params[:page], :per_page => 10).order('created_at desc')\n respond_to do |format|\n format.html # index.html.erb\n format.json { rend... | [
"0.66167384",
"0.6603721",
"0.6566706",
"0.65295553",
"0.63762593",
"0.6374993",
"0.6369773",
"0.62963384",
"0.6288128",
"0.6253874",
"0.62332606",
"0.6231995",
"0.620562",
"0.6205173",
"0.61922646",
"0.6190718",
"0.6185784",
"0.61835223",
"0.6179229",
"0.6176657",
"0.6175287... | 0.0 | -1 |
POST /pashiris POST /pashiris.json | def create
@pashiri = Pashiri.new(pashiri_params)
respond_to do |format|
if @pashiri.save
format.html { redirect_to @pashiri, notice: 'Pashiri was successfully created.' }
format.json { render :show, status: :created, location: @pashiri }
else
format.html { render :new }
format.json { render json: @pashiri.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @pai = Pai.new(pai_params)\n\n respond_to do |format|\n if @pai.save\n format.html { redirect_to pais_path, notice: 'Pais creado existosamente.' }\n format.json { render :index, status: :created, location: @pai }\n else\n format.html { render :new }\n format... | [
"0.6159259",
"0.60890347",
"0.60772866",
"0.6008758",
"0.6002866",
"0.5978132",
"0.5931346",
"0.59150285",
"0.587966",
"0.5879078",
"0.5857598",
"0.5850426",
"0.584057",
"0.5800717",
"0.57987875",
"0.57905346",
"0.5789546",
"0.57742184",
"0.5723724",
"0.5700369",
"0.56997633"... | 0.68317336 | 0 |
PATCH/PUT /pashiris/1 PATCH/PUT /pashiris/1.json | def update
respond_to do |format|
if @pashiri.update(pashiri_params)
format.html { redirect_to @pashiri, notice: 'Pashiri was successfully updated.' }
format.json { render :show, status: :ok, location: @pashiri }
else
format.html { render :edit }
format.json { render json: @pashiri.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'P... | [
"0.6996014",
"0.67856693",
"0.6761445",
"0.66060716",
"0.65468925",
"0.6362387",
"0.6315003",
"0.63144445",
"0.631032",
"0.6305359",
"0.6305359",
"0.6267114",
"0.6262165",
"0.62608606",
"0.62486833",
"0.62308604",
"0.62308604",
"0.6164937",
"0.61633235",
"0.61633235",
"0.6152... | 0.60865915 | 28 |
DELETE /pashiris/1 DELETE /pashiris/1.json | def destroy
@pashiri.destroy
respond_to do |format|
format.html { redirect_to pashiris_url, notice: 'Pashiri was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete(path)\n RestCli... | [
"0.7265513",
"0.6966249",
"0.6952314",
"0.6947598",
"0.6925021",
"0.67955446",
"0.6780028",
"0.676251",
"0.6752695",
"0.6750176",
"0.67316246",
"0.6708789",
"0.67072487",
"0.6706297",
"0.6658185",
"0.66534936",
"0.6645861",
"0.6629904",
"0.66232824",
"0.66096556",
"0.66068786... | 0.67008525 | 14 |
Use callbacks to share common setup or constraints between actions. | def set_pashiri
@pashiri = Pashiri.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 pashiri_params
params.require(:pashiri).permit(:name, :iraisha)
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 |
NOTE: this approach will probably fetch _all_ messages sent to or received from the handle. This means direct messages will be interleaved with group messages (i think) | def get_messages_with_handle_as_csv(handle_id)
message_csv_str = query <<~EOF
select datetime(message.date/1000000000 + strftime('%s', '2001-01-01'), 'unixepoch', 'localtime'),
is_from_me,
text
from message
where handle_id = '#{handle_id}'
order by date asc;
EOF
csv = CSV.new(message_csv_str)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_msgs\n end",
"def handle_messages\n messages = *disque.fetch(from: queue_name,timeout: 100,count: batch_size)\n messages.each do |queue,id,data|\n Chore.logger.debug \"Received #{id.inspect} from #{queue.inspect} with #{data.inspect}\"\n yield(id, queue, nil, data, 0)\n ... | [
"0.6764413",
"0.663931",
"0.6599294",
"0.63376635",
"0.6298787",
"0.62887543",
"0.6254047",
"0.6231733",
"0.61697394",
"0.6111207",
"0.6095523",
"0.6024825",
"0.59972763",
"0.5996978",
"0.5974678",
"0.5935433",
"0.5914781",
"0.5905875",
"0.5854819",
"0.58360183",
"0.58342886"... | 0.0 | -1 |
+params+ must contain elements: :contact_email :is_double_opt_in => 0 or 1 :contact_name OR :contact_first_name / :contact_last_name | def add_list_contact(list_id, params = {})
contact_params = Resources::Contacts.build(params)
request = @request.get(self_path, params.merge(list_id: list_id, **contact_params))
response = Response.new(request).parse
if response[:status] == 'error'
raise Errors::UnprocessableEntityError.new, response[:message]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contact_params\n params.require(:contact).permit(:first, :last, :title, :city, :phone, :email)\n end",
"def contact_params\n params.require(:contact).permit(:name, :email, :phone, :description, \n addresses: %i[line1 line2 city state zip]\n )\n end",
"def contact_params\r\n\t\t\tparams.... | [
"0.63266873",
"0.63015115",
"0.6294575",
"0.6218992",
"0.61980987",
"0.61874056",
"0.6183909",
"0.61748743",
"0.6161672",
"0.6161672",
"0.61479",
"0.6110159",
"0.60816723",
"0.6063347",
"0.6062827",
"0.6046142",
"0.603291",
"0.60245126",
"0.6024472",
"0.6006388",
"0.60018224"... | 0.0 | -1 |
+list_ids+ array +paras+ must contain: :is_double_opt_in => 0 or 1 :contacts => array of hashes, required elements: :contact_email => string | def add_list_contacts(list_ids, params = {})
contact_params = params[:contacts].each_with_object({}).with_index do |(value, hash), index|
hash[index.to_s.to_sym] = value
end
request = @request.post(self_path, {
list_ids: list_ids.join(','),
contact: contact_params,
**params.except(:contacts)
})
response = Response.new(request).parse
if response[:status] == 'error'
raise Errors::UnprocessableEntityError.new, response[:message]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ffcrm_list_ids\n config.mailchimp_list_fields.map{ |f| f.settings['list_id'] }\n end",
"def list_ids params={}\n @nimble.get \"contacts/ids\", params\n end",
"def get_list(access_token, list_id)\n url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.li... | [
"0.6537701",
"0.6409986",
"0.6314376",
"0.6202293",
"0.61447304",
"0.6133586",
"0.61107796",
"0.6053742",
"0.6023222",
"0.6004759",
"0.5993043",
"0.5913859",
"0.58669436",
"0.585816",
"0.58186555",
"0.5792634",
"0.57781297",
"0.577165",
"0.5749327",
"0.5745986",
"0.573956",
... | 0.70998883 | 0 |
get camelcase version of (caller) method name | def self_path
caller_locations(1,1)[0].label.to_s.camelize(:lower)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def camelize_methodname\n self.titleize.gsub(' ', '').camelize(:lower)\n end",
"def name\n camel = self.class.to_s.gsub(/.*::/, '')\n camel.gsub(/(\\S)([A-Z])/, '\\1_\\2').downcase\n end",
"def getMethodName(description)\n description[0] = description[0].downcase\n description.to_s.gsub(' ', '... | [
"0.7676575",
"0.7536481",
"0.730788",
"0.72017646",
"0.71573156",
"0.71016043",
"0.70587593",
"0.70470953",
"0.7045474",
"0.70172",
"0.6978949",
"0.69406974",
"0.69333833",
"0.6916254",
"0.6914116",
"0.6911857",
"0.69048226",
"0.6902803",
"0.6886511",
"0.6886511",
"0.6854511"... | 0.0 | -1 |
sets up a new hit | def initialize(tracker, options = {}, query_string = '')
self.tracker = tracker
self.options = OptionSet.new(convert_booleans(options))
self.custom_params.merge! parse_parameter_string(query_string)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_hit\n @hit = Hit.find(params[:id])\n end",
"def hit; end",
"def add_hit\n @hits += 1\n :hit\n end",
"def newHit(cap, imp, pos)\n pos= 8191 if pos > 8191\n newHit = 0b0000000000000000 | cap << 15 | imp << 13 | pos\n end",
"def hit=(_arg0); end",
"def hit_count_increament\n... | [
"0.74592113",
"0.6873877",
"0.66228056",
"0.65721893",
"0.64456093",
"0.6355028",
"0.61643547",
"0.6117844",
"0.60593784",
"0.6007196",
"0.6006311",
"0.59244245",
"0.58541465",
"0.58380544",
"0.58306247",
"0.5787732",
"0.57863384",
"0.57863384",
"0.57689345",
"0.57485586",
"0... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.