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 |
|---|---|---|---|---|---|---|
execute a block with a given locale | def with_locale(locale, &block)
old_locale = I18n.locale
I18n.locale = locale
yield(locale)
I18n.locale = old_locale
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __with_locale__(locale, &block)\n yield\n end",
"def locale(locale, &block)\n scope :locale => locale, &block\n end",
"def configure(&block)\n block.call @locale\n end",
"def each_locale(&block)\n self.mounting_point.locales.each do |locale|\n Locomotive::Mount... | [
"0.7399309",
"0.7196485",
"0.71274513",
"0.69179153",
"0.65948945",
"0.6537104",
"0.6459768",
"0.64495015",
"0.6407083",
"0.62979454",
"0.6179541",
"0.59268045",
"0.5905082",
"0.5901907",
"0.5841946",
"0.57877207",
"0.5738932",
"0.5718401",
"0.57145023",
"0.5703196",
"0.56424... | 0.64250916 | 8 |
To display output immediately on windows using git bash | def remove_vowels(strings)
strings.map { |string| string.delete('aeiouAEIOU') }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prompt_git_branch\n if !is_git?\n return \"\"\n end\n stat = `git status`\n \"[#{stat.split(\"\\n\")[0].split(\" \")[-1]}]\".yellow\nend",
"def stdout; end",
"def stdout; end",
"def stdout; end",
"def stdout; end",
"def stdout; end",
"def stdout; end",
"def prep_screen\n system(\"clear\... | [
"0.6219506",
"0.61200327",
"0.61200327",
"0.61200327",
"0.61200327",
"0.61200327",
"0.61200327",
"0.6103044",
"0.60350794",
"0.59949106",
"0.5973232",
"0.59097284",
"0.58951396",
"0.5886012",
"0.586864",
"0.58550465",
"0.582788",
"0.5807792",
"0.5802978",
"0.5773198",
"0.5745... | 0.0 | -1 |
kudos to for the inspiration | def sibling_page(flag, tag)
page_index = case flag
when :next
1
when :previous
-1
else
raise ArgumentError, "flag must be :next or :previous"
end
current = tag.locals.page
order_by = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def schubert; end",
"def formation; end",
"def suivre; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def operations; end",
"def operations; end",
"def stderrs; end",
"def terpene; end",
"def who_we_are\r\n end",... | [
"0.71688193",
"0.66786164",
"0.64292425",
"0.64211226",
"0.6410926",
"0.6165882",
"0.6165882",
"0.6165882",
"0.6165882",
"0.6153942",
"0.6153942",
"0.61359435",
"0.6063777",
"0.605108",
"0.5988271",
"0.5962692",
"0.5945236",
"0.58904225",
"0.5888514",
"0.58675075",
"0.5865701... | 0.0 | -1 |
controller for the "university", which is the help section of the application the views can be used to help users understand the platform each method has a view which renders static content to users | def index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @university = University.find(params[:id])\n end",
"def help\n #render(text: \"Help method in StaticPages controller class\");\n end",
"def show\n @university = University.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: ... | [
"0.6591416",
"0.65498656",
"0.6485437",
"0.6485437",
"0.6437675",
"0.63202286",
"0.63114476",
"0.6279287",
"0.6273043",
"0.6267386",
"0.62623864",
"0.62512714",
"0.6221988",
"0.62185895",
"0.62124276",
"0.6207911",
"0.62059015",
"0.6187631",
"0.6185509",
"0.6181993",
"0.61639... | 0.0 | -1 |
checks the plan's metadata for a custom public name and uses that if available else it will use plan[:name] | def plan_public_name(plan)
plan = plan.with_indifferent_access
(plan[:metadata] &&
plan [:metadata][:stripe_invoice] &&
plan[:metadata][:stripe_invoice][:public_name]) || plan[:name]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plan\n data['plans'][me]\n end",
"def display_name\n public_name\n end",
"def plan_name\n if @plan_name.nil?\n jmeter_document do |doc|\n test_plan = doc.xpath('//TestPlan').first\n @plan_name = test_plan['testname']\n end\n if @plan_name.blank? || (@... | [
"0.6251663",
"0.59329575",
"0.59300804",
"0.57350254",
"0.56650627",
"0.56046164",
"0.56046164",
"0.55753094",
"0.5529659",
"0.552672",
"0.54545456",
"0.5453242",
"0.5434254",
"0.54185915",
"0.5400739",
"0.53613985",
"0.5349313",
"0.5347449",
"0.5344665",
"0.5314728",
"0.5306... | 0.7749701 | 0 |
+client+:: The client facade. | def initialize(client)
@buffer = String.new
@client = client
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def client\n @client ||= Client.new\n end",
"def client\n @client ||= Client.current\n end",
"def client\n @client\n end",
"def client\n @client\n end",
"def client\n @client\n end",
"def client\n @client ||= self.class.client\n end",
"def client\n ... | [
"0.8423091",
"0.825698",
"0.82149976",
"0.82149976",
"0.82149976",
"0.81915313",
"0.81036353",
"0.80499095",
"0.80499095",
"0.80336106",
"0.79981774",
"0.79979974",
"0.79979974",
"0.79979974",
"0.79979974",
"0.79979974",
"0.79979974",
"0.79979974",
"0.79979974",
"0.79979974",
... | 0.0 | -1 |
Check existence of records in one batch. | def batch_exists(client, key_prefix, size)
# Batch into one call.
keys = []
(0...size).each do |i|
keys << Key.new(Shared.namespace, Shared.set_name, key_prefix + (i+1).to_s)
end
exists_array = client.batch_exists(keys)
(0...exists_array.length).each do |i|
key = keys[i]
exists = exists_array[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_for_empty_batch?\n batch.empty?\n end",
"def batch_exist?(id)\n mutex(id) do |bid|\n redis.exists(bid)\n end\n end",
"def exists?\n _redis.exists(_batch_key)\n end",
"def success?\n data_rows.exists? && !data_rows.failed.exists?\n end",
"def... | [
"0.7319781",
"0.7146759",
"0.70453787",
"0.6931748",
"0.68921036",
"0.6672837",
"0.6624762",
"0.66123474",
"0.65888643",
"0.6521107",
"0.64816546",
"0.6464635",
"0.6449691",
"0.6392653",
"0.63511",
"0.6341251",
"0.63399667",
"0.633448",
"0.6309724",
"0.6305513",
"0.6275911",
... | 0.66538584 | 6 |
Read records in one batch. | def batch_reads(client, key_prefix, bin_name, size)
# Batch gets into one call.
keys = []
(0...size).each do |i|
keys << Key.new(Shared.namespace, Shared.set_name, key_prefix+(i+1).to_s)
end
records = client.batch_get(keys, [bin_name])
(0...records.length).each do |i|
key = keys[i]
record = r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunk_records(records, batch_size)\n Enumerator.new do |enum|\n chunked_records = []\n\n records.each do |record|\n if chunked_records.size == batch_size\n enum.yield(chunked_records)\n chunked_records = []\n end\n\n transformed_record = block_given? ? yield(record) : record... | [
"0.6614754",
"0.66114587",
"0.64357936",
"0.6428955",
"0.6363377",
"0.63466775",
"0.62532955",
"0.6229867",
"0.6224886",
"0.61406714",
"0.6119103",
"0.61057615",
"0.6101047",
"0.6086604",
"0.60824764",
"0.6072424",
"0.6072424",
"0.60613966",
"0.60547304",
"0.60092545",
"0.600... | 0.6394853 | 4 |
Read record header data in one batch. | def batch_read_headers(client, key_prefix, size)
# Batch gets into one call.
keys = []
(0...size).each do |i|
keys[i] = Key.new(Shared.namespace, Shared.set_name, key_prefix+(i+1).to_s)
end
records = client.batch_get_header(keys)
(0...records.length).each do |i|
key = keys[i]
record = records[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_header_info\n @data.rewind\n \n #column_count_offset = 33, record_count_offset = 24, record_length_offset = 36\n @record_count, @data_offset, @record_length = data.read(HEADER_LENGTH).unpack(\"@24 I x4 I I\")\n @column_count = (@data_offset-400)/200\n end",
"def grab_header\n ... | [
"0.6902902",
"0.65095377",
"0.6320976",
"0.6271641",
"0.62153774",
"0.6202378",
"0.6188682",
"0.61861455",
"0.6161466",
"0.61317956",
"0.6114323",
"0.6113934",
"0.61076605",
"0.60075253",
"0.600435",
"0.5995089",
"0.59499264",
"0.5927144",
"0.5922903",
"0.5922903",
"0.5882436... | 0.6896367 | 1 |
GET /systems GET /systems.json | def index
@ajax_search = params[:ajax_search] == "true" ? true : false
@systems = System.search(params[:search]).order(sort_column + " " + sort_direction).paginate(:page => params[:page], :per_page => 10)
respond_to do |format|
format.html # index.html.erb
format.js # index.js.erb
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_systems(opts = {})\n data, _status_code, _headers = get_systems_with_http_info(opts)\n return data\n end",
"def get_systems_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: UniverseApi.get_systems ...\"\n end\n ... | [
"0.76317644",
"0.76225734",
"0.72966117",
"0.671495",
"0.66773045",
"0.66577905",
"0.66125035",
"0.6544244",
"0.64612997",
"0.6411968",
"0.64079034",
"0.6394844",
"0.6377694",
"0.6332792",
"0.6299502",
"0.62923014",
"0.62487775",
"0.6222313",
"0.61828655",
"0.6164332",
"0.615... | 0.0 | -1 |
GET /systems/new GET /systems/new.json | def new
@system = System.new
respond_to do |format|
format.html # new.html.erb
format.js # new.js.erb
format.json { render json: @system }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n #override new, if we already have a system \n if System.all.empty?\n @system = System.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @system }\n end\n else\n respond_to do |format|\n flash[:notice] = \"System has al... | [
"0.79895794",
"0.73416847",
"0.71916944",
"0.71649134",
"0.69883716",
"0.69402283",
"0.6936344",
"0.69138753",
"0.6881952",
"0.6871274",
"0.684851",
"0.68380994",
"0.6837832",
"0.6781058",
"0.67783946",
"0.67295",
"0.67277014",
"0.67077565",
"0.66933244",
"0.6679336",
"0.6672... | 0.7766565 | 1 |
POST /systems POST /systems.json | def create
@system = System.new(params[:system])
respond_to do |format|
if @system.save
format.html { redirect_to systems_url, flash[:info]="System was successfully created." }
format.js { flash[:info]="System was successfully created." }
format.json { render json: @system, status... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @system = System.new(params[:system])\n\n respond_to do |format|\n if @system.save\n format.html { redirect_to @system, notice: 'System was successfully created.' }\n format.json { render json: @system, status: :created, location: @system }\n else\n format.html { r... | [
"0.728779",
"0.70293206",
"0.6888112",
"0.6794667",
"0.67209214",
"0.6619307",
"0.6493325",
"0.64559233",
"0.64479196",
"0.64186424",
"0.6354116",
"0.634666",
"0.6264458",
"0.6212248",
"0.6198111",
"0.6175118",
"0.6173521",
"0.6154388",
"0.61461276",
"0.61393887",
"0.6121444"... | 0.6786277 | 4 |
PUT /systems/1 PUT /systems/1.json | def update
@system = System.find(params[:id])
respond_to do |format|
if @system.update_attributes(params[:system])
format.html {redirect_to systems_url, flash[:info]='System was successfully updated.' }
format.js { flash[:info]='System was successfully updated.' }
format.json { he... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @system = System.find(params[:id])\n\n respond_to do |format|\n if @system.update_attributes(params[:system])\n flash.now[:success] = \"System was successfully updated.\"\n format.html { redirect_to @system }\n #proper response to http PUT is also no_content\n fo... | [
"0.7040339",
"0.66495305",
"0.66266626",
"0.6613053",
"0.6500259",
"0.6469428",
"0.6425912",
"0.6356739",
"0.6339277",
"0.6339277",
"0.63173515",
"0.63076824",
"0.62852937",
"0.62259275",
"0.619179",
"0.6168773",
"0.6151728",
"0.61445713",
"0.6109397",
"0.6104393",
"0.6091127... | 0.68115205 | 1 |
DELETE /systems/1 DELETE /systems/1.json | def destroy
@system = System.find(params[:id])
@system.destroy
@systems = System.search(params[:search]).order(sort_column + " " + sort_direction).paginate(:page => params[:page], :per_page => 10)
respond_to do |format|
format.html { redirect_to systems_url, flash[:info]='System was successf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @hydraulic_system = HydraulicSystem.find(params[:id])\n @hydraulic_system.destroy\n\n respond_to do |format|\n format.html { redirect_to hydraulic_systems_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @it_system.destroy\n respond_to do |format|\n... | [
"0.72376794",
"0.71929735",
"0.7083203",
"0.70778745",
"0.70219934",
"0.7020831",
"0.7014653",
"0.7013914",
"0.69841015",
"0.69699454",
"0.6943594",
"0.6905724",
"0.6845635",
"0.68272775",
"0.6794116",
"0.67832893",
"0.67679834",
"0.6757881",
"0.6750421",
"0.67492175",
"0.671... | 0.69867355 | 8 |
sort icin default direction asc | def sort_direction
# karakter kontrol yapiliyor security icin
%w[asc desc].include?(params[:direction]) ? params[:direction] : "asc"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def order\n \"#{sort} #{dir}\"\n end",
"def sort_entries; end",
"def default_sort\n 'name asc'\n end",
"def sort_order\n 0\n end",
"def sort_direction\n params[:dir] == \"asc\" ? \"asc\" : \"desc\"\n end",
"def sort_name\n sort_constituent\n end",
"def __sort... | [
"0.6900811",
"0.66569996",
"0.6633097",
"0.66125464",
"0.65713453",
"0.6529674",
"0.64983565",
"0.64875174",
"0.6461752",
"0.64567053",
"0.64194524",
"0.6414498",
"0.63974535",
"0.6385862",
"0.6379661",
"0.637299",
"0.637299",
"0.637299",
"0.6353133",
"0.63504964",
"0.6350496... | 0.67963916 | 6 |
print documentation ri 'Arraypop' Array.ri Array.ri :pop arr.ri :pop | def ri(method = nil)
unless method && method =~ /^[A-Z]/ # if class isn't specified
klass = self.kind_of?(Class) ? name : self.class.name
method = [klass, method].compact.join('#')
end
puts `ri '#{method}'`
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def using_pop(array)\n array.pop()\nend",
"def \n \n using_pop(array)\n \n\n array.pop()\n \nend",
"def pop\r\n @arr.shift\r\n end",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(arr)\n arr.pop\nend",
"def using_pop(array)\n element = ... | [
"0.7991212",
"0.79750896",
"0.7928716",
"0.7904846",
"0.78675395",
"0.7847575",
"0.7818912",
"0.7792735",
"0.7792735",
"0.7792735",
"0.7792735",
"0.7792735",
"0.7792735",
"0.7792735",
"0.7792735",
"0.7792735",
"0.76495844",
"0.7579722",
"0.74776727",
"0.7279086",
"0.72510755"... | 0.0 | -1 |
`time` in irb via | def time(times = 1)
require 'benchmark'
ret = nil
Benchmark.bm { |x| x.report { times.times { ret = yield } } }
ret
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time()\n return _request([\n 'time',\n '0'\n ])[0]\n end",
"def ctime() end",
"def ctime() end",
"def ctime() end",
"def time()\n return self._request([\n 'time',\n '0'\n ])[0]\n end",
"def sec() time[2] end",
"def time; end",
"def time; end... | [
"0.7948778",
"0.76522946",
"0.76522744",
"0.76522744",
"0.7588226",
"0.75732744",
"0.7568076",
"0.7568076",
"0.7568076",
"0.7568076",
"0.7568076",
"0.7568076",
"0.7568076",
"0.7568076",
"0.7568076",
"0.74862564",
"0.72946876",
"0.72946876",
"0.72946876",
"0.729123",
"0.725584... | 0.0 | -1 |
Initialize a `LinkRelation`. A LinkRelation can be one of the relations registered, or use the CURIE syntax to introduce a custom namespace. This syntax is introduced by using the separator `:`. | def initialize(name)
splits = name.to_s.split(":")
splits.size < 2 ? @name = splits.first : (@curie, @name = splits)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(relation = self.class.relation, attributes = self.class.attributes)\n super()\n @relation = relation\n @attributes = attributes\n @relationships = self.class.relationships\n end",
"def initialize(name, relation, aliases = nil)\n super(name)\n ... | [
"0.611418",
"0.593573",
"0.58457935",
"0.5798361",
"0.572757",
"0.57230663",
"0.5722415",
"0.5660434",
"0.56526506",
"0.56346697",
"0.5532976",
"0.5510066",
"0.54707164",
"0.5364855",
"0.536448",
"0.53329694",
"0.5329353",
"0.5328084",
"0.5327276",
"0.5323147",
"0.53187084",
... | 0.0 | -1 |
Returns a custom formatted string representation of the object. | def to_s
@curie and "#{@curie}:#{@name}" or @name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n object.to_s\n end",
"def to_s\n Formatter::ToString.format(self)\n end",
"def to_s\n @string || @object.strftime(FORMAT)\n end",
"def to_s\n @object.to... | [
"0.80619985",
"0.8056995",
"0.79787123",
"0.7895628",
"0.78834313",
"0.7788708",
"0.7788708",
"0.7662816",
"0.7656497",
"0.7592533",
"0.75465256",
"0.747521",
"0.7456826",
"0.7429509",
"0.7420867",
"0.7410505",
"0.73525745",
"0.73084134",
"0.73084134",
"0.7306603",
"0.7274315... | 0.0 | -1 |
p winning_tickets_off_by_one("1234", ("1234", "3333", "4444") | def first_longer_than_second(first, second)
if first.length > second.length
puts true
else
puts false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def off_by_one(my_ticket, winning_array)\n\t\n\tclose_array = []\n\twinning_array.each do |element|\n\t\tif element.length == my_ticket.length\n\t\t\tif string(my_ticket, element) == my_ticket.length\n\t\t\tclose_array.push(element)\n\t\t\tend\n\t\tend\n \tend\n\tclose_array\nend",
"def off_one(ticket,winners)\r... | [
"0.71357626",
"0.6875929",
"0.6864861",
"0.6428634",
"0.6140095",
"0.61107963",
"0.59706736",
"0.595493",
"0.595493",
"0.58294713",
"0.5810365",
"0.5730132",
"0.572614",
"0.5707766",
"0.5671476",
"0.5628278",
"0.5558042",
"0.54794794",
"0.54694927",
"0.5467688",
"0.54669136",... | 0.0 | -1 |
arr_multiples = [] multiple = 3 while multiple <= number arr_multiples << multiple multiple += 3 end multiple = 5 while multiple <= number arr_multiples << multiple if !arr_multiples.include?(multiple) multiple += 5 end arr_multiples.sum end Their solution, much simpler def multisum(max_value) sum = 0 1.upto(max_value)... | def multisum(max_value)
(1..max_value).inject(0) do |sum, n|
n % 3 == 0 || n % 5 == 0 ? sum + n : sum
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multisum(max_value)\n (1..max_value).select {|num| num % 3 == 0 || num % 5 == 0}.reduce(:+)\nend",
"def multisum(max)\n sum = 0\n 1.upto(max) { |num| sum += num if num % 3 == 0 || num % 5 == 0 }\n sum\nend",
"def multisum(limit)\n multiples = []\n\n for num in 1..limit\n multiples << num if num % ... | [
"0.88577336",
"0.8763278",
"0.8649913",
"0.8633251",
"0.8632139",
"0.85555017",
"0.8552703",
"0.853164",
"0.8448029",
"0.8418969",
"0.8394671",
"0.8376682",
"0.8368051",
"0.8349414",
"0.8343001",
"0.8324209",
"0.8320653",
"0.82896256",
"0.8288808",
"0.82870334",
"0.82725877",... | 0.9064822 | 0 |
def get_balance(id) ans = Users.first(:conditions => "user_id = ?", id) ans.balance end def get_trades(id) ans = Users.first(:conditions => "user_id = ?", id) ans.trades end def get_longs(u_id, m_id) ans = Users.first(:conditions => "user_id = ? AND market_id = ?", u_id, m_id) ans.longs end def get_shorts(u_id, m_id) a... | def get_b_val(id)
ans = Market.where(:id => id).first
ans.b_val
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n\n @user = User.find(params[:id])\n @trades = @user.trades.all\n if current_user.id == params[:id].to_i\n @iscurrentuser = true\n else\n @iscurrentuser = false\n end\n @idcurr = current_user.id\n @par = params[:id]\n @gain = @user.wallet - 10000\n @gainpercent = (@use... | [
"0.6550168",
"0.64445996",
"0.63708264",
"0.62829894",
"0.6273213",
"0.61816734",
"0.61247575",
"0.6114332",
"0.60944784",
"0.6051617",
"0.6034927",
"0.5970256",
"0.5941132",
"0.5938894",
"0.5927849",
"0.5922524",
"0.59019387",
"0.5865737",
"0.5863076",
"0.5862602",
"0.585645... | 0.0 | -1 |
Do we need user id for these? | def get_longs(mid,uid)
if (uid) then
ans = Share.where(:market_id => mid, :user_id =>uid).first
if ans then
return ans.longs
else
return 0
end
else
ans = Market.where(:id => mid).first
return ans.long... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_id; 1; end",
"def user_id\n raise \"Implement in Client or Advocate\"\n end",
"def user_defined?\n !@user.nil? || !@user['userId'].nil?\n end",
"def user_id; config[:user_id]; end",
"def user; end",
"def user; end",
"def current_user_id\n 1\n end",
"def get_user_id\n # TOD... | [
"0.7609527",
"0.7166505",
"0.69326156",
"0.6873548",
"0.68513685",
"0.68513685",
"0.68451226",
"0.68101066",
"0.67990327",
"0.67990327",
"0.67981476",
"0.67923963",
"0.67923605",
"0.67923605",
"0.6727594",
"0.6717807",
"0.66809386",
"0.6665236",
"0.6653873",
"0.6617173",
"0.6... | 0.0 | -1 |
Clears the entire cache. | def clear
FileUtils.rm_rf(path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear\n cache.clear\n end",
"def clear\n @cache.clear\n end",
"def cache_clear\n @client.flushall\n end",
"def clear\r\n @cache.flush\r\n end",
"def clear_cache!\n @cache = {}\n end",
"def clear_cache!\n @cache = {}\n end",
"def clear!\n ... | [
"0.8797166",
"0.86835974",
"0.8482756",
"0.8459508",
"0.83657265",
"0.83657265",
"0.8337028",
"0.8330368",
"0.82912576",
"0.8290783",
"0.82553536",
"0.8227743",
"0.8214157",
"0.81667763",
"0.8091179",
"0.80722374",
"0.80386484",
"0.8037688",
"0.801953",
"0.80156195",
"0.80141... | 0.0 | -1 |
Checks if a cache hit is found for a given gollum page. name The name of the page to check. version The version of the page to check. Returns true if the page has been cached, otherwise returns false. | def cache_hit?(name, version='master')
page = wiki.page(name, version)
File.exists?(page_path(name, version)) unless page.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def version_present_in_cache?(version)\n tag = %x( cd #{@work_dir} && git tag -l \"#{version}\" )\n tag.strip == \"#{version}\"\n end",
"def get_page(name, version='master')\n IO.read(page_path(name, version)) if cache_hit?(name, version)\n end",
"def page_cache_exists?(url)\n File.exis... | [
"0.66862833",
"0.6382975",
"0.61389",
"0.58045745",
"0.57780045",
"0.5651596",
"0.5612981",
"0.5530155",
"0.54763955",
"0.5472171",
"0.54710495",
"0.5435356",
"0.53877884",
"0.53803796",
"0.5348838",
"0.53319955",
"0.53192556",
"0.5299012",
"0.5286107",
"0.52576977",
"0.52297... | 0.81264716 | 0 |
Retrieves the content of the cached page. name The name of the wiki page. version The version of the wiki page. Returns the contents of the HTML page if cached. Otherwise returns nil. | def get_page(name, version='master')
IO.read(page_path(name, version)) if cache_hit?(name, version)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_hit?(name, version='master')\n page = wiki.page(name, version)\n File.exists?(page_path(name, version)) unless page.nil?\n end",
"def get_html\n print \"Getting doc...\"\n if File.size?(@cache)\n html = File.read(@cache)\n else\n html = open(URL).read\n ... | [
"0.6894426",
"0.6430152",
"0.640326",
"0.6319392",
"0.6055476",
"0.5999763",
"0.59760386",
"0.58946747",
"0.5866297",
"0.58415866",
"0.57759756",
"0.57735956",
"0.576542",
"0.5756927",
"0.5709433",
"0.5699748",
"0.56872475",
"0.5679276",
"0.565285",
"0.5633713",
"0.56197375",... | 0.85448456 | 0 |
Sets the cached content for a page. name The name of the wiki page. version The version of the page. content The content to cache. Returns nothing. | def set_page(name, version, content)
p "set page: #{name} : #{version.class}"
page = wiki.page(name, version)
if !page.nil?
path = page_path(name, version)
FileUtils.mkdir_p(File.dirname(path))
File.open(path, 'w') do |f|
f.write(content)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_page(content, path, extension = nil, gzip = Zlib::BEST_COMPRESSION)\n if perform_caching\n page_cache.cache(content, path, extension, gzip)\n end\n end",
"def cache_page(content, path)\n return unless perform_caching\n\n benchmark \"Cached page: #{p... | [
"0.68158746",
"0.6635808",
"0.6220722",
"0.6185113",
"0.61405355",
"0.6082335",
"0.6017745",
"0.59808743",
"0.59492254",
"0.59362996",
"0.59151965",
"0.5891623",
"0.5876544",
"0.5806265",
"0.5779055",
"0.5741482",
"0.5741482",
"0.5678042",
"0.5670072",
"0.5643642",
"0.5636118... | 0.73810214 | 0 |
Removes the cached content for a page. name The name of the wiki page. version The version of the page. Returns nothing. | def remove_page(name, version='master')
page = wiki.page(name, version)
File.delete(page_path(name, version)) if !page.nil? && File.exists?(page_path(name, version))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expire_cache(page_name)\n expire_pages(ContentPage.find_all_by_page_name(page_name))\n end",
"def get_page(name, version='master')\n IO.read(page_path(name, version)) if cache_hit?(name, version)\n end",
"def cache_hit?(name, version='master')\n page = wiki.page(name, version)\n File.... | [
"0.6638009",
"0.63070035",
"0.57237864",
"0.5633808",
"0.5591406",
"0.55859876",
"0.5585594",
"0.5509417",
"0.5475012",
"0.5424186",
"0.54186106",
"0.5405263",
"0.5391378",
"0.53859305",
"0.53688914",
"0.53561556",
"0.535492",
"0.52995354",
"0.52800685",
"0.52535933",
"0.5248... | 0.76156276 | 0 |
Retrieves the path to the cache for a given page. name The name of the wiki page. version The version of the page. Returns a file path to the cached wiki page. | def page_path(name, version='master')
page = wiki.page(name, version)
if !page.nil?
"#{path}/#{page.path}/#{page.version.id}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_page(name, version='master')\n IO.read(page_path(name, version)) if cache_hit?(name, version)\n end",
"def cache_hit?(name, version='master')\n page = wiki.page(name, version)\n File.exists?(page_path(name, version)) unless page.nil?\n end",
"def page_cache(page)\n if page\n ... | [
"0.79468113",
"0.7151081",
"0.6202652",
"0.61838865",
"0.6049701",
"0.60120744",
"0.5892972",
"0.5883368",
"0.58638704",
"0.5800209",
"0.57712317",
"0.571067",
"0.57082874",
"0.56929463",
"0.569071",
"0.5681009",
"0.5677387",
"0.5660452",
"0.5655943",
"0.56527233",
"0.5612079... | 0.71641624 | 1 |
makes all instance methods become module methods as well | def load(string)
::YAML.load string
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instance_modules(*mods)\n @instance_modules ||= [ \n Command::InstanceMethods, \n Command::Options::InstanceMethods\n ]\n @instance_modules += mods\n end",
"def create_methods_from_instance(instance)\n\t instance.public_methods(false).each do |method_name|\n\t... | [
"0.69951224",
"0.67791075",
"0.6700032",
"0.65119636",
"0.65069956",
"0.64462036",
"0.6419921",
"0.63751924",
"0.63738626",
"0.6366937",
"0.6350222",
"0.6334864",
"0.62819177",
"0.62819177",
"0.62819177",
"0.62394136",
"0.62294453",
"0.62237805",
"0.6192933",
"0.61919856",
"0... | 0.0 | -1 |
Returns a SQL condition to be used to match the given field and value in the serialized object. | def where_object_condition(arel_field, field, value)
arel_field.matches("%\n#{field}: #{value}\n%")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def where_object_condition(arel_field, field, value)\n # Convert to JSON to handle strings and nulls correctly.\n json_value = value.to_json\n\n # If the value is a number, we need to ensure that we find the next\n # character too, which is either `,` or `}`, to ensure that searching\n ... | [
"0.6890752",
"0.6241492",
"0.6026467",
"0.60145307",
"0.5986407",
"0.5919434",
"0.5893257",
"0.58524656",
"0.5820705",
"0.5807694",
"0.5717516",
"0.56953394",
"0.56808656",
"0.5662983",
"0.5565193",
"0.5546556",
"0.5508226",
"0.54879975",
"0.5474904",
"0.545978",
"0.5440887",... | 0.67871755 | 2 |
Creates initializes a new instance of the SpellCheckClient class. | def initialize(credentials = nil, options = nil)
super(credentials, options)
@base_url = '{Endpoint}/bing/v7.0'
fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil?
@credentials = credentials
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_client\n @client = HelpScoutDocs::Client.new(@options) unless defined?(@client) && @client.hash == @options.hash\n @client\n end",
"def initialize(*args)\n\t\t\t\tsuper\n\t\t\t\t#super called in order to call the same method from the parent class and then adding our thing (next line)\... | [
"0.5968625",
"0.5788272",
"0.570941",
"0.56905484",
"0.565623",
"0.55503273",
"0.55213195",
"0.54820424",
"0.5479798",
"0.5456211",
"0.54412174",
"0.54412174",
"0.5439116",
"0.542026",
"0.5388672",
"0.5382835",
"0.53641",
"0.53641",
"0.53641",
"0.53641",
"0.53641",
"0.53641... | 0.0 | -1 |
Some ground rules: We'll never rename a label To do mappings, we'll create the new label, and then for each issue with the old label, we'll add the new label, then remove the old one. | def ensure_label(repository, label)
mappings = label.fetch("mappings") { [] }
all = github.labels(repository)
if label["delete"]
puts " Deleted label: '#{label['name']}'" if github.delete_label!(repository, label["name"])
return
end
current = all.select { |cur| cur[:name] == label["name"] }.first
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_label(repository, label)\n mappings = label.fetch(\"mappings\") {[]}\n all = github.labels(repository)\n\n if label[\"delete\"]\n puts \"Deleted label: '#{label['name']}'\"\n github.delete_label!(repository, label[\"name\"])\n return\n end\n\n current = all.select { |cur| cur[:name] == lab... | [
"0.75748307",
"0.72133726",
"0.7113347",
"0.6884551",
"0.6863046",
"0.683273",
"0.6807703",
"0.6777501",
"0.6768076",
"0.67318314",
"0.6682066",
"0.6588015",
"0.6587046",
"0.65578765",
"0.64746755",
"0.6468158",
"0.63621217",
"0.6298623",
"0.629821",
"0.6294854",
"0.62062925"... | 0.75787735 | 0 |
Same basic rules as for labels, but we have to edit issues to set the milestone rather than updating the list of labels. TODO: handle state and due_date | def ensure_milestone(repository, milestone)
mappings = milestone.delete("mappings") { [] }
all = github.milestones(repository)
current = all.select { |cur| cur[:title] == milestone["name"] }.first
new = current
if current.nil?
new = github.create_milestone(repository, milestone["name"], description: mil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_labels_to_an_issue(fq_repo_name, issue_number, requested_labels)\n issue(fq_repo_name, issue_number).add_labels(requested_labels)\n end",
"def replace_all_labels(repo, number, labels, options = {})\n put \"#{Repository.path repo}/issues/#{number}/labels\", labels\n end",
"def add_la... | [
"0.63503015",
"0.6269965",
"0.6192762",
"0.6170717",
"0.6168163",
"0.6152889",
"0.61426514",
"0.6053437",
"0.60197484",
"0.60071236",
"0.59645844",
"0.5898247",
"0.5898247",
"0.5874763",
"0.58235776",
"0.5776955",
"0.56546795",
"0.56426287",
"0.56010544",
"0.5516418",
"0.5505... | 0.5486979 | 21 |
Yields each issue number that has the label or milestone Returns an array of all issues that have the label | def issues_with(repository, type, label, &block)
query_string = "repo:#{repository} #{type}:\"#{label}\""
issues = github.search_issues(query_string)[:items].map { |item| item[:number] }
if block_given?
issues.each do |issue|
yield(issue)
end
end
issues
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_issue_array( issues, label )\n\t\ttagged_issues_array = []\n\t\tissues.each do | a |\n\t\t\tlabels = a[ 'labels' ]\n\t\t\tlabels.each do | b |\n\t\t\t\tif b[ 'name' ] == label\n\t\t\t\t\tmatched_issue = {}\n\t\t\t\t\tmatched_issue[ 'url' ] = a[ 'html_url' ]\n\t\t\t\t\tmatched_issue[ 'title' ]= a[ 'title'... | [
"0.6496666",
"0.63760096",
"0.6369451",
"0.61156094",
"0.6024271",
"0.59498775",
"0.5905907",
"0.57810426",
"0.5619868",
"0.56167966",
"0.5615718",
"0.5615718",
"0.5605947",
"0.5572934",
"0.5553526",
"0.5480154",
"0.5466555",
"0.5464717",
"0.5442421",
"0.54366934",
"0.5374511... | 0.60292566 | 5 |
rescues github timeouts so we can wait and try again | def ensure_with_retries(type, repo, object)
attempts = 1
send("ensure_#{type}".to_sym, repo, object)
rescue Octokit::BadGateway => e
raise "Too many errors received from Github. Cannot continue! #{e}" if attempts > 10
sleep 5
attempts += 1
retry
rescue Octokit::TooManyRequests
time_until_limit_over = gith... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_github_response\n Retriable.retriable(retry_options) do\n yield\n end\n rescue MovedPermanentlyError => e\n fail_with_message(e, \"The repository has moved, update your configuration\")\n rescue Octokit::Forbidden => e\n fail_with_message(e, \"Exceeded retry limit\")\n ... | [
"0.6305529",
"0.61219555",
"0.5807343",
"0.5801515",
"0.5600211",
"0.5529469",
"0.5519509",
"0.5504566",
"0.5470245",
"0.5469087",
"0.5469087",
"0.5469087",
"0.5452774",
"0.53822416",
"0.536604",
"0.53401625",
"0.5324227",
"0.5281566",
"0.5240613",
"0.51961064",
"0.51961064",... | 0.67214566 | 0 |
either fetch repos from the org specified in the config file or from the repos in the config | def repos(config_hash)
if config_hash["organizations"]
repos = []
config_hash["organizations"]["orgs"].each do |org|
# grab all the full repo names in this org. If no type is specified use public and also skip the forks
# we also skip anything in the blacklist array
repos << github.org_repos... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_repos_by_orga(orga) \n\t\treturn self.fetch(\"repos?owner_name=#{orga}\")\n\tend",
"def fetch_repositories(repos = nil)\n # Init git settings\n Git.configure do |config|\n config.binary_path = \"#{@config['git']['path']}\"\n end\n @return_repos = []\n # Loop through repos and fetch it... | [
"0.7271043",
"0.7046267",
"0.7040311",
"0.7028698",
"0.69938654",
"0.69770294",
"0.6947184",
"0.6912391",
"0.68873376",
"0.68835956",
"0.6841199",
"0.68387717",
"0.6764415",
"0.66997457",
"0.66760516",
"0.66721404",
"0.66442996",
"0.6626466",
"0.65872747",
"0.65832597",
"0.65... | 0.73250216 | 0 |
use this later to disable debugger | def nothing; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable_advanced_debugging_tools; end",
"def toggle_debug\n @debug = @debug == false ? true : false\n end",
"def enable_advanced_debugging_tools=(_arg0); end",
"def disable_breakpoint(bp)\n bp.disable\n end",
"def restart_debug\n restart do\n debug\n end\n end... | [
"0.7325523",
"0.70271546",
"0.6901459",
"0.68832535",
"0.68432355",
"0.6799331",
"0.6665707",
"0.6641209",
"0.66373986",
"0.66178435",
"0.66032404",
"0.6574555",
"0.6568783",
"0.656364",
"0.65451515",
"0.6536127",
"0.64669865",
"0.64669865",
"0.64343536",
"0.6409538",
"0.6398... | 0.0 | -1 |
Example: after :foo, :bar do ... end This executes the body of the block after the foo and bar instance methods for side effects without modifying the return values of the foo and bar methods after :fizz, :buzz do |r| ... r end This executes the body of the block after the foo and bar instance methods for side efects, ... | def after(*method_symbols, &block)
options = method_symbols[-1].kind_of?(Hash) ? method_symbols.pop : {}
method_symbols.each do |method_sym|
__composed_methods__[method_sym].after.push(__unbound_method__(block, options[:name]))
__rebuild_method__(method_sym)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after(*args, &block)\n meths, advice, options = Aspects.resolve(self, args, block)\n \n for meth in meths\n advices! << [:after_method, meth, advice]\n end\n \n return self\n end",
"def after(&block)\n define_before_or_after_method_with_block(:after, &block)\n end",
"def... | [
"0.77075344",
"0.76492274",
"0.71078295",
"0.71078295",
"0.7078459",
"0.7078459",
"0.7078459",
"0.7078459",
"0.70620835",
"0.7060012",
"0.70366395",
"0.7027626",
"0.69381416",
"0.6887223",
"0.68728995",
"0.6736498",
"0.66997355",
"0.6687557",
"0.66713256",
"0.6661228",
"0.656... | 0.6141321 | 37 |
Removes all advice from the named methods. Intended for testing. | def reset_befores_and_afters(*method_symbols)
method_symbols.each do |method_sym|
__composed_methods__[method_sym].before = []
__composed_methods__[method_sym].after = []
__rebuild_method__(method_sym)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_intercepting!\n @original_methods.each do |m|\n class_eval do\n alias_method m, \"intercepted_#{m}\"\n remove_method \"intercepted_#{m}\"\n end\n end\n\n class_eval do\n remove_method :synthesis_expectation\n remove_method :synthesis_expectation... | [
"0.7005163",
"0.6870369",
"0.66332346",
"0.6589949",
"0.65322614",
"0.65315616",
"0.6444211",
"0.64205956",
"0.64148915",
"0.64148915",
"0.6353877",
"0.6327736",
"0.6253916",
"0.6237635",
"0.6237635",
"0.623419",
"0.6194457",
"0.6136701",
"0.61078686",
"0.6091923",
"0.6064526... | 0.5600149 | 48 |
Modified to reapply advice when a method is overridden. So: class Foo def foo(bar); end end class Bar < Foo include MethodAdvice after :foo do ... end end class Blitz < Bar include MethodAdvice def foo(bar) ... end end In this case the class Blitz overrides the method foo, but the advice in class Bar is still applied, ... | def method_added(method_sym)
unless instance_variable_get("@#{UNIQ}_in_method_added")
__safely__ do
__composed_methods__[method_sym].between = self.instance_method(method_sym)
@old_method_added and @old_method_added.call(method_sym)
__rebuild_method__(method_sym)
end
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_advice_methods!\n scope # force calculation of scope before aliasing methods.\n\n @mutex.synchronize do\n return self if @advice_methods_registered\n\n this = self\n mod_target.instance_eval do\n define_method(this.before_meth, &this.advice.before)\n de... | [
"0.66031796",
"0.6356579",
"0.6333789",
"0.62640613",
"0.626013",
"0.6221967",
"0.61992294",
"0.6162634",
"0.61460745",
"0.6122515",
"0.60321987",
"0.594805",
"0.5920865",
"0.59015816",
"0.58961314",
"0.5879351",
"0.5876419",
"0.5862849",
"0.586147",
"0.58357364",
"0.58201504... | 0.5008236 | 94 |
result = [] result << array[1..1] << array[0] p result.flatten end alt one line | def rotate_array(array)
array[1..-1] + [array[0]]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_line_flatten(array, ret = [])\n array.each { |x| x.is_a?(Array) ? one_line_flatten(x, ret) : ret << x }; ret\nend",
"def using_flatten(array)\n array.flatten\n end",
"def using_flatten(array)\n array.flatten()\nend",
"def flatten(array)\n array.flatten(1)\nend",
"def flatten(array)\n arr... | [
"0.74665296",
"0.71041137",
"0.7063333",
"0.70251304",
"0.70251304",
"0.70175606",
"0.7001719",
"0.69866145",
"0.69360185",
"0.6931513",
"0.69249827",
"0.684783",
"0.684783",
"0.68187207",
"0.67906344",
"0.6770823",
"0.67677563",
"0.67677563",
"0.67677563",
"0.67677563",
"0.6... | 0.0 | -1 |
p rotate_array([7, 3, 5, 2, 9, 1]) == [3, 5, 2, 9, 1, 7] p rotate_array(['a', 'b', 'c']) == ['b', 'c', 'a'] p rotate_array(['a']) == ['a'] x = [1, 2, 3, 4] p rotate_array(x) == [2, 3, 4, 1] => true p x == [1, 2, 3, 4] => true further exploration def rotate_string(string) characters = string.chars rotate_array(character... | def rotate_string(string)
rotate_array(string.chars).join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate_string(string)\n arr = string.chars\n str = rotate_array(arr).join\nend",
"def rotate_string(str)\n arr = str.chars\n rotate_array(arr).join\nend",
"def rotate_string(str)\n rotate_array(str.chars).join\nend",
"def rotate_string(str)\n rotate_array(str.chars).join\nend",
"def rotate_string... | [
"0.8853305",
"0.8730751",
"0.86959493",
"0.86959493",
"0.86959493",
"0.85971594",
"0.8592087",
"0.8362614",
"0.81275207",
"0.8076",
"0.78297096",
"0.78297096",
"0.77737564",
"0.7701596",
"0.7478746",
"0.7424562",
"0.72993135",
"0.7147949",
"0.7077483",
"0.70420796",
"0.698972... | 0.88507783 | 4 |
Neuen User anlegen REST POST /user.xml | def create
# Wenn Formular abgeschickt
if ! params[:user].nil?
if params[:user][:password] == params[:user][:password2]
# Wird gesetzt damit die Create-Forms verschwinden
@inputs = true;
# entferne Passwortwiederhohlung aus den Parametern um User zu erzeugen
params[:user]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.json { render json: @user }\n format.xml { render xml: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n ... | [
"0.69617355",
"0.6797196",
"0.66545045",
"0.65959173",
"0.6578448",
"0.6559525",
"0.6551056",
"0.65430933",
"0.653884",
"0.6493092",
"0.6488621",
"0.64830095",
"0.64795595",
"0.6462754",
"0.6459808",
"0.64446455",
"0.64416707",
"0.643576",
"0.643576",
"0.643576",
"0.643576",
... | 0.0 | -1 |
take item from an NPC | def take(item_name)
if current_room.npc && current_room.npc.has_item(item_name)
npc_item = item_to_take(item_name)
@player.add_to_inventory(npc_item)
# this just doesn't seem to remove the item from NPC inventory no matter what I do :(
current_room.npc.remove_from_inventory(npc_item)
els... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_item(user, item)\r\n position = user.get_position(item)\r\n x = user.show_item(position)\r\n self.add_item(x)\r\n user.give_away_item(position)\r\n end",
"def take_item(command)\n if @current_room.has_item?(command) # item isn't in current room\n self.new_current_item(comma... | [
"0.70769596",
"0.701767",
"0.680646",
"0.6751463",
"0.66943055",
"0.6637092",
"0.6626924",
"0.6618685",
"0.6378054",
"0.63602984",
"0.63019943",
"0.62930566",
"0.6289469",
"0.62866604",
"0.6255734",
"0.6237278",
"0.6236976",
"0.6233258",
"0.6233258",
"0.6183521",
"0.61790097"... | 0.7566036 | 0 |
take item from a Room | def pick_up(item_name)
if current_room.has_item(item_name)
item = current_room.items.find { |thing| thing.name == item_name }
@player.add_to_inventory(item)
current_room.remove_one(item)
else
puts "Sorry, that item is not in this room. Try again."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def take_item(command)\n if @current_room.has_item?(command) # item isn't in current room\n self.new_current_item(command)\n # Remove from room and add to backpack\n @current_room.remove_item(command)\n @player.pick_up(command)\n puts \"\\nYou have picked up a #{@current_item.name}\"\n ... | [
"0.691922",
"0.6838345",
"0.6364502",
"0.63501865",
"0.62964845",
"0.6205045",
"0.60626066",
"0.59974545",
"0.5947529",
"0.5916599",
"0.59066963",
"0.5846474",
"0.58391535",
"0.58119935",
"0.5788291",
"0.5788291",
"0.5785833",
"0.57833445",
"0.57833445",
"0.57833445",
"0.5783... | 0.6288124 | 5 |
use an item from your inventory | def use(item_name)
# TODO: figure out how to pass around entire item object to access effects anywhere
if @player.has_item(item_name) && current_room.npc && current_room.npc.has_item(item_name)
effect = current_room.npc.inventory.select { |i| i.name == item_name }.first.effects
puts effect
@pl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def use_item(item)\n battler.use_item(item)\n end",
"def use_item(item, entity)\n index = has_item(item)\n if index\n actual_item = inventory[index].first\n actual_item.use(self, entity)\n remove_item(actual_item) if actual_item.consumable\n else\n print NO_SUCH_ITE... | [
"0.78594345",
"0.78063875",
"0.75991166",
"0.7575277",
"0.7424123",
"0.7319071",
"0.72013265",
"0.71198064",
"0.710201",
"0.7100019",
"0.70934474",
"0.70898926",
"0.70185816",
"0.701162",
"0.700507",
"0.69365436",
"0.69344616",
"0.6921967",
"0.6913077",
"0.6894861",
"0.681426... | 0.73655486 | 5 |
talk to an NPC | def talk
if current_room.npc
puts current_room.npc.dialogue[:default]
else
puts "Sorry, no one else is in here!"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_enemy_talk_action\n $game_temp.talking_actor = @subject\n target_index = @subject.current_action.target_index\n target = $game_troop.members[target_index]\n @log_window.display_talk_action(@subject, target)\n $game_troop.setup_talk_event(@subject.current_action.target_index)\n while !... | [
"0.6433438",
"0.63530946",
"0.61760306",
"0.6148449",
"0.60806245",
"0.595064",
"0.59385073",
"0.5910451",
"0.588352",
"0.5878969",
"0.58765185",
"0.58705634",
"0.5841591",
"0.5828112",
"0.5822594",
"0.58055484",
"0.5803432",
"0.5783018",
"0.57773936",
"0.57756025",
"0.575129... | 0.7194106 | 0 |
print your inventory to the console | def print_inventory
@player.print_inventory
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_inventory\n print \"Current gold in pouch: #{@gold}.\\n\\n\"\n\n if @inventory.empty?\n print \"#{@name}'s inventory is empty!\\n\\n\"\n return\n end\n\n puts \"#{@name}'s inventory:\"\n @inventory.each do |couple|\n puts \"* #{couple.first.name} (#{couple.se... | [
"0.82967085",
"0.8094175",
"0.80912024",
"0.8042742",
"0.7911296",
"0.7865084",
"0.78453696",
"0.78104156",
"0.7606681",
"0.7559416",
"0.75376546",
"0.7418",
"0.7375748",
"0.7354795",
"0.7278544",
"0.7209167",
"0.71362036",
"0.7120264",
"0.70670986",
"0.70159024",
"0.675698",... | 0.79232526 | 4 |
TODO: clean this method up like whoa | def parse_choice(choice)
new_choice = choice.split.join("_")
valid_choice = @valid_choices.select { |entry| entry == new_choice.to_sym }.first
if choice.include?('move') && valid_move(choice)
move(choice.split(' ').last.to_sym)
elsif choice.include?('pick up')
item = choice.split.select{ |it... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def suivre; end",
"def refutal()\n end",
"def formation; end",
"def offences_by; end",
"def weber; end",
"def implementation; end",
"def implementati... | [
"0.7492509",
"0.6667339",
"0.6572146",
"0.63572514",
"0.63572514",
"0.63572514",
"0.63572514",
"0.62396705",
"0.6119712",
"0.6103747",
"0.58787626",
"0.5842155",
"0.5841868",
"0.5841868",
"0.58170116",
"0.5794176",
"0.5792813",
"0.57710564",
"0.57537794",
"0.57537794",
"0.575... | 0.0 | -1 |
check that move is in a valid direction | def valid_move(user_input)
user_input.split(' ').first == 'move' &&
['north','south', 'east', 'west'].include?(user_input.split(' ').last)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_move(direction)\n\n if direction == 0 #up\n if @y < 1\n \n return false\n end\n elsif direction == 1 #down\n if @y > @boundry\n \n return false\n end\n elsif direction == 2 #left\n if @x < 1\n \n return false\n end\n else... | [
"0.8024617",
"0.78249174",
"0.7767276",
"0.77669835",
"0.7744395",
"0.7722005",
"0.7720703",
"0.76950794",
"0.76831347",
"0.76750726",
"0.7661058",
"0.7643349",
"0.7638551",
"0.760493",
"0.76024157",
"0.75967175",
"0.7588064",
"0.7584769",
"0.75562394",
"0.7546619",
"0.750721... | 0.72834426 | 47 |
see all the rooms | def display_map
@map.display_map
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_reserved_rooms\n unless @rooms.empty?\n @rooms.each do |key, room|\n puts room.report_lister\n end\n end\n end",
"def list_all_rooms\n return @rooms\n end",
"def list_rooms\n @rooms.each do |room_name, cap| \n puts \"#{room_name} #{cap.available_space()}\"\... | [
"0.8032606",
"0.7973507",
"0.78296155",
"0.7663536",
"0.7644042",
"0.76292276",
"0.758311",
"0.75116706",
"0.7419847",
"0.7393618",
"0.7393618",
"0.7393618",
"0.7393618",
"0.7393618",
"0.7393618",
"0.7393618",
"0.7393618",
"0.7393618",
"0.7393618",
"0.7393618",
"0.7377754",
... | 0.0 | -1 |
checks that Player input is valid | def check_validity(choice)
valid_options = ['pick up', 'use', 'display inventory', 'move']
@valid_choices.include?(choice.to_sym) || valid_options.include?(choice)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_player_input\n loop do \n input = @player.get_input\n return input if input_is_valid?(input)\n puts \"Invalid input - x,y format and hidden cards only!\" if @player\n end\n end",
"def validate_player\n \t@player = Player[params[:player_id]]\n if @player.nil?\n render_e... | [
"0.82825154",
"0.75199026",
"0.7457739",
"0.7434191",
"0.732501",
"0.72140765",
"0.71807456",
"0.7104263",
"0.7087973",
"0.6984191",
"0.6932688",
"0.6895405",
"0.68399113",
"0.67939246",
"0.67895955",
"0.6741073",
"0.67169183",
"0.6673923",
"0.66694844",
"0.6664663",
"0.66296... | 0.0 | -1 |
Comando que recebe as configuracoes | def configure
yield self if block_given?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure\n send_command \"--configure\"\n end",
"def enum_configs\n host = session.session_host\n port = session.session_port\n exec_commands = [\n {\n 'cmd' => '/export verbose',\n 'fn' => 'get_config',\n 'desc' => 'Get Device Config on Mikrotik Device'\n },\n... | [
"0.68462527",
"0.64490736",
"0.62477475",
"0.6197782",
"0.6130815",
"0.60947746",
"0.5940793",
"0.5931984",
"0.5930478",
"0.58927965",
"0.58673036",
"0.58114314",
"0.57434505",
"0.5732119",
"0.5708001",
"0.5663407",
"0.566144",
"0.56420285",
"0.56406546",
"0.563819",
"0.56224... | 0.0 | -1 |
Retornar a url conforme o ambiente | def set_endpoint
if ambiente == :producao
return GetnetApi::Configure::URL[:producao]
elsif ambiente == :homologacao
return GetnetApi::Configure::URL[:homologacao]
else
return GetnetApi::Configure::URL[:sandbox]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url() \n\t #'http://' << ENV['DOMAIN'] << \n\t '/' << self.author.username.to_s << '/' << self.name.to_s\n end",
"def get_url\n URI.parse(\"#{@server}#{URL}\")\n end",
"def p_url\n Rails.application.routes.url_helpers.rent_url(id, host: PUBLIC_URL)\n end",
"def sub_url (p)\n res = (p !... | [
"0.6620393",
"0.6597478",
"0.6528795",
"0.65210503",
"0.64799243",
"0.6432048",
"0.6312373",
"0.63032013",
"0.6301393",
"0.6299516",
"0.6295489",
"0.62949044",
"0.62827194",
"0.62525475",
"0.62525475",
"0.62412715",
"0.61856395",
"0.6183368",
"0.6183368",
"0.6183368",
"0.6183... | 0.68898666 | 0 |
1. a simple (default) RESTful controller 1. a simple (default) +nested+ RESTful controller In order to use the first form, the only thing that it requires is that the describe contain the controller constant. Controller name, params, and URLs are all derived from this. It will not work if you stray from the base resour... | def controller_name
@controller_name ||= controller.class.to_s.sub('Controller', '').underscore
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_action_controller_test_case_specifiK\n\n ##get\n\n # Makes a get request.\n\n # Assertions are made directly on the response obejct.\n\n # Controller is deduced from current classname / filename.\n\n get :action0\n get :action1\n get :haml\n #get(:action0, {'i... | [
"0.63407904",
"0.6005727",
"0.57189494",
"0.56997615",
"0.5698269",
"0.5684364",
"0.5640455",
"0.5597708",
"0.55460507",
"0.5484851",
"0.54677933",
"0.5454408",
"0.5445591",
"0.54173124",
"0.5373263",
"0.5350084",
"0.5304606",
"0.52727216",
"0.5240581",
"0.5221899",
"0.520777... | 0.0 | -1 |
for basic nested routes | def parent_controller_name
@parent_controller
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def _routes; end",
"def custom_routes; end",
"def anchored_routes; end",
"def ... | [
"0.7283693",
"0.7283693",
"0.7283693",
"0.7283693",
"0.7283693",
"0.7283693",
"0.7283693",
"0.7283693",
"0.7283693",
"0.7283693",
"0.7283693",
"0.70540464",
"0.6868366",
"0.681296",
"0.6759217",
"0.6759217",
"0.6709971",
"0.66694075",
"0.66678816",
"0.66574776",
"0.66402507",... | 0.0 | -1 |
This will be called with both lines are the same | def match(event)
#@output << htmlize(event.old_element, :match_class)
@output << event.old_element
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lineCheck (l1, l2)\n if(l1 == l2)\n true;\n else\n false;\n end\nend",
"def is_same_line on_line, off_line\n\tif on_line == off_line\n\t\ttrue\n\telse\n\t\tfalse\n\tend\nend",
"def same_line(line, start_index, end_index)\n if (start_index > end_index)\n start_index = reverse_direction(line, st... | [
"0.71547526",
"0.71445155",
"0.671782",
"0.6573709",
"0.6514605",
"0.6196718",
"0.6194537",
"0.61822987",
"0.61547846",
"0.6093012",
"0.6040366",
"0.60284615",
"0.60225654",
"0.5982883",
"0.59712005",
"0.5966738",
"0.5966738",
"0.5961046",
"0.5959356",
"0.5913193",
"0.5910471... | 0.0 | -1 |
This will be called when there is a line in A that isn't in B | def discard_a(event)
#@output << htmlize(event.old_element, :only_a_class)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_file_must_not_contain_found()\n\t\tCfruby::FileEdit.file_must_not_contain(@multilinefilename, \"second line\")\n\t\tFile.open(@multilinefilename, File::RDONLY) { |fp|\n\t\t\tlines = fp.readlines()\n\t\t\tassert_equal(false, lines.include?(\"second line\\n\"))\n\t\t}\n\t\t\n\t\tCfruby::FileEdit.file_must_n... | [
"0.59915113",
"0.59910864",
"0.59560066",
"0.59560066",
"0.58499426",
"0.5840793",
"0.5813305",
"0.5789967",
"0.57771647",
"0.5771616",
"0.57706475",
"0.5761949",
"0.5746558",
"0.57411104",
"0.5736211",
"0.57271844",
"0.5716114",
"0.57140785",
"0.57085323",
"0.57042724",
"0.5... | 0.0 | -1 |
This will be called when there is a line in B that isn't in A | def discard_b(event)
#@output << htmlize(event.new_element, :only_b_class)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_not_referenced_by_any_line_item\n \t\tif line_items.empty?\n \t\t\treturn true\n \t\telse\n \t\t\terrors.add(:base, 'Existe linha de item')\n\t\t \treturn false\n \t\tend\n \tend",
"def missed_lines; end",
"def missed_lines; end",
"def ensure_not_referenced_by_any_line_item\r\n\t\tunless line_item... | [
"0.5770932",
"0.5622741",
"0.5622741",
"0.5606354",
"0.55905604",
"0.5542376",
"0.55416715",
"0.553924",
"0.55353165",
"0.5533867",
"0.5532923",
"0.5529414",
"0.55259997",
"0.5523522",
"0.5517605",
"0.5515797",
"0.5511437",
"0.5509485",
"0.5505961",
"0.54963225",
"0.5469365",... | 0.0 | -1 |
returns from heros.tesoro, the list of (maybe repeated) ids of the heros with self.id gem/runa/joya available | def disponibles
total = []
heros.each do |h|
next unless h.tesoro
next unless h.tesoro[item + 's']
h.tesoro[item + 's'].each do |e|
(total << h.id) if e == id
end
end
total
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def technos\n object.technos.map { |t| t.id }\n end",
"def ids\n @ids ||= []\n end",
"def child_object_ids(valkyrie: false)\n child_objects(valkyrie: valkyrie).map(&:id)\n end",
"def ids\n root.ids\n end",
"def all_ids\n @all_ids ||= @ids_fenotypes.keys\n ... | [
"0.6230926",
"0.6196081",
"0.616313",
"0.6159807",
"0.6153772",
"0.61224294",
"0.61103",
"0.6090642",
"0.6088926",
"0.60346377",
"0.6008128",
"0.60044205",
"0.5988953",
"0.5976287",
"0.59639597",
"0.5919356",
"0.5917234",
"0.590555",
"0.5903414",
"0.5893801",
"0.58903635",
... | 0.63843226 | 0 |
start welcomes the user and asks him if he wants to boot the program if user answered affirmative, run is called with "true" if user answered negative, run is called with "false" if command is not recognized, start is called again | def start
puts "\nWelcome to Awesome-O Todo-Master 3000
\n Do you want to start working?
\n [y] to Start
\n [n] to Quit
\n "
answer = gets.chomp.downcase
if answer == "y"
self.run(true)
elsif answer ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_program\n puts 'Type Start to begin program or type Exit to close it at any time'\n user_response = gets.chomp\n while user_response != 'Exit' && user_response != 'Start'\n puts 'Incorrect input'\n puts 'Type Start to begin program or type Exit to close it at any time'\n user_resp... | [
"0.71299493",
"0.7074898",
"0.6702011",
"0.6531444",
"0.64885783",
"0.63098717",
"0.6301744",
"0.62525773",
"0.6181948",
"0.6168534",
"0.6162911",
"0.61477655",
"0.6143968",
"0.6118434",
"0.60712796",
"0.60564184",
"0.6055214",
"0.6032691",
"0.6026211",
"0.5999367",
"0.598966... | 0.7060214 | 2 |
Case is used for getting commands from user variables are set up so that the command from the user is always first,then comes the target list and then an arbitrary amount of arguments if a command is entered for that no case exists, method ends and returns true (is fired again by "run" then) if a command is entered for... | def get_command
print "\nType a Command to get to work (e.g. make-list to start a new list of todo´s)
\n( type <show-commands> to see your options)
\n"
cmd, target, *args = gets.chomp.downcase.split(' ')
case cmd
when 'up'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(songs) # I thought we were supposed to call this bit 'runner'?\n puts \"Welcome to my Jukebox!\\n\\n Please enter a command:\\n\\n Help, List, Play, or Exit\\n\\n\"\n help\n command = gets.strip.to_s\n case command # I originally used if-else\n when \"help\"\n help\n when \"list\"\n lis... | [
"0.6438057",
"0.62148684",
"0.617156",
"0.6087837",
"0.6025995",
"0.59816086",
"0.59363276",
"0.5924196",
"0.5903016",
"0.5901339",
"0.5886463",
"0.5846902",
"0.5842139",
"0.5834658",
"0.5824568",
"0.58198327",
"0.57957846",
"0.5785245",
"0.5782927",
"0.5750187",
"0.57313836"... | 0.6471966 | 0 |
get_command return true in the end with "run" get_command is repeatedly called if user enters "quit" as command, false is returned | def run(set)
while set
return if !get_command
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def command_given?\n !@command.empty?\n end",
"def command?(command=RC.current_command)\n return true if self.command.nil?\n self.command == command.to_s\n end",
"def command?\n !@data[:command].nil?\n end",
"def command?\n @is_command\n end",
"def get_command(c... | [
"0.7308964",
"0.7224531",
"0.71564966",
"0.7128125",
"0.68979895",
"0.68259776",
"0.6822023",
"0.6822023",
"0.6747998",
"0.6689269",
"0.6682965",
"0.66760623",
"0.66407436",
"0.66385615",
"0.6634741",
"0.6611928",
"0.6595183",
"0.65831524",
"0.65766305",
"0.65540695",
"0.6547... | 0.6111332 | 68 |
Returns true if the http method being parsed (if known at this point in the parse) must have a body. If the method hasn't been determined yet, returns false. | def must_have_body?
Methods[@method].must_have_body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def body?\n HTTY::Request::METHODS_SENDING_BODY.include? method\n end",
"def can_have_body?\n Methods[@method].can_have_body\n end",
"def body_allowed?\n @status.allows_body? && @request_method.allows_body?\n end",
"def has_body?\n @body\n end",
"def body?\n !body.emp... | [
"0.7999659",
"0.7645706",
"0.7442392",
"0.69295096",
"0.6802516",
"0.6528711",
"0.6494513",
"0.6494513",
"0.64696026",
"0.62912184",
"0.62366784",
"0.62295014",
"0.61139786",
"0.60957795",
"0.6077999",
"0.6047012",
"0.6035697",
"0.6011099",
"0.59959364",
"0.5990022",
"0.59681... | 0.8055277 | 0 |
Returns true if the http method being parsed (if known at this point in the parse) can have a body. If the method hasn't been determined yet, returns false. | def can_have_body?
Methods[@method].can_have_body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def body?\n HTTY::Request::METHODS_SENDING_BODY.include? method\n end",
"def must_have_body?\n Methods[@method].must_have_body\n end",
"def body_allowed?\n @status.allows_body? && @request_method.allows_body?\n end",
"def has_body?\n @body\n end",
"def body?\n !body.e... | [
"0.7984505",
"0.7912565",
"0.7517442",
"0.70199174",
"0.6753836",
"0.6587441",
"0.6587441",
"0.65637934",
"0.6526658",
"0.63791835",
"0.6271488",
"0.6190793",
"0.6127661",
"0.60895115",
"0.602737",
"0.60187185",
"0.59995526",
"0.5982281",
"0.59730583",
"0.59621775",
"0.595878... | 0.7911676 | 2 |
Returns true if the request has a body. | def has_body?
@body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def body?\n !body.empty?\n end",
"def has_response_body?\n !response.body.nil? && !response.body.empty?\n end",
"def body?\n HTTY::Request::METHODS_SENDING_BODY.include? method\n end",
"def body?\n\t\t\t\t\t@body and !@body.empty?\n\t\t\t\tend",
"def body_allowed?\n ... | [
"0.8275284",
"0.8106742",
"0.8047029",
"0.793608",
"0.78416467",
"0.763096",
"0.7255102",
"0.72309506",
"0.69865996",
"0.6852164",
"0.6805528",
"0.67919207",
"0.6696598",
"0.66576463",
"0.66226006",
"0.6608993",
"0.65688974",
"0.6534406",
"0.64977527",
"0.63763636",
"0.629036... | 0.84405726 | 0 |
Takes a string and runs it through the parser. Note that it does not consume anything it can't completely parse, so you should always pass complete request chunks (lines or body data) to this method. It's mostly for testing and convenience. In practical use, you want to use parse!, which will remove parsed data from th... | def parse(str)
parse!(str.dup)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(string, options = {}, &block)\n file = StringIO.new(string)\n _read file, options, &block\n end",
"def parse(str); end",
"def parse!(str)\n scanner = StringScanner.new(str)\n begin\n while (!scanner.eos?)\n start_pos = scanner.pos\n send(:\"parse_#{@sta... | [
"0.7141707",
"0.670467",
"0.66762674",
"0.66064626",
"0.64147174",
"0.6367929",
"0.6353647",
"0.6329572",
"0.6296161",
"0.62866455",
"0.6229998",
"0.6201764",
"0.6170904",
"0.6170904",
"0.61699426",
"0.61699426",
"0.61699426",
"0.61699426",
"0.6080634",
"0.60758835",
"0.60758... | 0.64827 | 4 |
Consumes as much of str as it can and then removes it from str. This allows you to iteratively pass data into the parser as it comes from the client. | def parse!(str)
scanner = StringScanner.new(str)
begin
while (!scanner.eos?)
start_pos = scanner.pos
send(:"parse_#{@state}", scanner)
if (scanner.pos == start_pos)
# if we didn't move forward, we've run out of useful string so throw it back.
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup(str)\n str\n end",
"def strip(str); end",
"def parse(str)\n parse!(str.dup)\n end",
"def ungets(str)\n @buffer = str + @buffer\n nil\n end",
"def clean(string)\n ::ActiveSupport::SafeBuffer.new string.to_s.dup.tap { |s| clean!(s) }\n end",
"def remov... | [
"0.6803862",
"0.66618127",
"0.66456425",
"0.6379887",
"0.63298357",
"0.6317103",
"0.6205868",
"0.60792947",
"0.60776305",
"0.60332584",
"0.59970486",
"0.5909236",
"0.5880981",
"0.5838308",
"0.58208364",
"0.58202755",
"0.5778947",
"0.5751672",
"0.5726547",
"0.5695201",
"0.5694... | 0.65886486 | 3 |
Normalizes a header name to be UPPERCASE_WITH_UNDERSCORES | def normalize_header(str)
str.upcase.gsub('-', '_')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_header_name(name)\n name.\n # remove heading HTTP if present\n sub(/^#{RACK_PREFIX}/, '').\n # split on underscore\n split('_').\n # transform UPCASE to Upcase\n map(&:capitalize).\n # join back on a dash\n join('-')\n end",
"def canon... | [
"0.81469786",
"0.79981804",
"0.7905524",
"0.73586196",
"0.72618246",
"0.71671927",
"0.71143204",
"0.69574594",
"0.6915184",
"0.6825737",
"0.67775136",
"0.6719092",
"0.6706106",
"0.6692594",
"0.6670451",
"0.6657103",
"0.66264415",
"0.66093713",
"0.659205",
"0.6527476",
"0.6526... | 0.7948252 | 2 |
Given a basic rack environment, will properly fill it in with the information gleaned from the parsed request. Note that this only fills the subset that can be determined by the parser library. Namely, the only rack. variable set is rack.input. You should also have defaults in place for SERVER_NAME and SERVER_PORT, as ... | def fill_rack_env(env = {})
env["rack.input"] = @body || StringIO.new
env["REQUEST_METHOD"] = @method
env["SCRIPT_NAME"] = ""
env["REQUEST_URI"] = @path
env["PATH_INFO"], query = @path.split("?", 2)
env["QUERY_STRING"] = query || ""
if (@headers["HOST"] && !env["SERVER_NAME"])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rack_input ; @env['rack.input'] ; end",
"def build_rack_env\n uri = URI.parse(request_env.url)\n headers = request_env.headers.to_h\n\n env = base_rack_env\n env.merge!({\n \"PATH_INFO\" => uri.path,\n \"QUERY_STRING\" => uri.query,\n \"SERVER_NAME\" => ... | [
"0.6654423",
"0.65874016",
"0.65046895",
"0.64652705",
"0.6364942",
"0.6344778",
"0.59374577",
"0.59214056",
"0.5842937",
"0.5782288",
"0.5738072",
"0.5727669",
"0.5719205",
"0.5709837",
"0.57059866",
"0.5642336",
"0.5599861",
"0.5581948",
"0.5558861",
"0.55143154",
"0.549877... | 0.7613082 | 0 |
Returns true if the request is completely done. | def done?
@state == :done
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finished?\n\t\t\t\t@finished && @body.length >= @headers['CONTENT_LENGTH']\n\t\t\tend",
"def done_request_line?\n [:headers, :body_identity, :body_chunked, :body_chunked_tail, :done].include?(@state)\n end",
"def complete?\n completed_at && response\n end",
"def completed?\n\t\t\treturn r... | [
"0.80113757",
"0.78455806",
"0.7794354",
"0.7709042",
"0.7671382",
"0.7594426",
"0.7543056",
"0.75386703",
"0.75386703",
"0.75058657",
"0.7494026",
"0.7494026",
"0.74698395",
"0.74698395",
"0.74698395",
"0.74698395",
"0.74296916",
"0.7416975",
"0.7405195",
"0.7403768",
"0.739... | 0.7079891 | 63 |
Returns true if the request has parsed the requestline (GET / HTTP/1.1) | def done_request_line?
[:headers, :body_identity, :body_chunked, :body_chunked_tail, :done].include?(@state)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_valid?(data)\n ln = 0\n data.each_line {|l|\n ln += 1\n }\n if ln > 1\n return true\n else\n puts \"\\e[1;31mCatch GET's without header information / Other \\e[0m\\ \"\n return false # Due to single GET Requests to no headers \n end\n end",
... | [
"0.7618652",
"0.6769437",
"0.6745394",
"0.6723495",
"0.6719939",
"0.6521013",
"0.6465073",
"0.64515316",
"0.6413949",
"0.63204545",
"0.6318958",
"0.6317573",
"0.6300576",
"0.6258243",
"0.62526876",
"0.6242643",
"0.6228496",
"0.62201774",
"0.6191775",
"0.61523986",
"0.6126876"... | 0.6701856 | 5 |
Returns true if all the headers from the request have been consumed. | def done_headers?
[:body_identity, :body_chunked, :body_chunked_tail, :done].include?(@state)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def headers?\n @headers.empty?\n end",
"def done_request_line?\n [:headers, :body_identity, :body_chunked, :body_chunked_tail, :done].include?(@state)\n end",
"def empty?\n no_headers.empty? rescue true\n end",
"def headers_sent?\n return true if _httpsession.resp.headers_sent\n ret... | [
"0.74349886",
"0.72160447",
"0.6789655",
"0.6691772",
"0.66370636",
"0.66161925",
"0.6507162",
"0.6475736",
"0.63946074",
"0.638419",
"0.6377304",
"0.6358163",
"0.630648",
"0.6285502",
"0.6283004",
"0.6220021",
"0.6180809",
"0.6152121",
"0.6133123",
"0.608684",
"0.6081417",
... | 0.7469557 | 0 |
Returns true if the request's body has been consumed (really the same as done?) | def done_body?
done?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def done_request_line?\n [:headers, :body_identity, :body_chunked, :body_chunked_tail, :done].include?(@state)\n end",
"def finished?\n\t\t\t\t@finished && @body.length >= @headers['CONTENT_LENGTH']\n\t\t\tend",
"def performed?\n response_body\n end",
"def body?\n !body.empty?\n ... | [
"0.7892393",
"0.73883075",
"0.6986425",
"0.6901193",
"0.67740303",
"0.67392915",
"0.67253935",
"0.6724834",
"0.66962415",
"0.6641698",
"0.662319",
"0.6555832",
"0.6555832",
"0.6523008",
"0.6437058",
"0.63631517",
"0.6317913",
"0.62877864",
"0.61907095",
"0.6157766",
"0.615359... | 0.7658253 | 1 |
Create handle incoming SMS message from TWILIO (Will need adjustment if other gateway is used) Twilio sends the message to create just as if it were a web HTTP request The create method should handle the incoming message by determining any actions needed and sending a return message. ToDo Remove line for testing; confi... | def create # need the name 'create' to conform with REST defaults, or change routes
#puts "**** IncomingController create: params=#{params}"
@from = params[:From] # The phone number of the sender
#debugger
body = params[:Body] # This is the body of the incoming message
AppLog.create(:code => "SMS.incomi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n to = params[:to]\n\n unless to\n raise IOError, \"Incorrect params for sending text message\" \n end\n\n @client = Twilio::REST::Client.new(\n CONFIG[:twilio_account_sid],\n CONFIG[:twilio_auth_token])\n\n @account = @client.account\n @message = @ac... | [
"0.73262656",
"0.72483236",
"0.7214355",
"0.71366274",
"0.6984982",
"0.69830894",
"0.6929738",
"0.68834",
"0.67903674",
"0.6786883",
"0.6736829",
"0.6701736",
"0.66780967",
"0.6664455",
"0.6632652",
"0.6631665",
"0.65801805",
"0.6578087",
"0.6569934",
"0.6510791",
"0.649473",... | 0.70757383 | 4 |
Parse the message received from mobile | def process_sms(body)
return I18n.t('sms.nothing_in_msg') if body.blank?
command, text = extract_commands(body)[0] # parse to first word=command, rest = text
return case command.downcase
when 'd' then group_deliver(text)
when 'group', 'groups' then do_list_groups
when 'info' then do_inf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(msg)\n if(String(msg).empty?)\n return\n end\n \n #\n # If there is no timestam, given them \n #\n if(@timestamp.nil?)\n @timestamp=Time.now\n end\n \n #\n ... | [
"0.6881307",
"0.68608236",
"0.67374897",
"0.6710591",
"0.66458035",
"0.64635426",
"0.6453257",
"0.6419683",
"0.64051706",
"0.6392606",
"0.6387397",
"0.6332094",
"0.6319304",
"0.63138986",
"0.6296359",
"0.62419045",
"0.62353337",
"0.62287533",
"0.61543655",
"0.6151458",
"0.614... | 0.0 | -1 |
Return help ToDo add specific help about commands | def do_help(text=nil)
# NB: If command summary is changed, be sure to make corresponding changes in the
# I18n translation tables
command_summary = [ ['d <group>', 'deliver msg to grp'],
['groups', 'list main grps'],
['info <name>', 'get contact info'],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def help\n base = [\"Usage: houst [action] [optional parameter]\"]\n\n @commands.each do |command|\n base << \"\\t#{command[:name]}: \\t#{command[:description]}\"\n end\n\n base << \"\\nAdditional help can be obtained by using\\n\\thoust help [command]\\n\"\n\n base.join \"\\n\"\n ... | [
"0.77570945",
"0.76877266",
"0.7659207",
"0.74248594",
"0.73800457",
"0.7369106",
"0.72915816",
"0.71946996",
"0.71946996",
"0.7188602",
"0.7173799",
"0.7163884",
"0.715752",
"0.71242315",
"0.70969015",
"0.7093146",
"0.7082782",
"0.7033615",
"0.7025644",
"0.7016071",
"0.70160... | 0.72579503 | 7 |
Send a list of abbreviations for the "primary" groups (primary meaning that) they're important enough to fit into this 160character string | def do_list_groups()
I18n.t("sms.some_groups") + ": " + Group.primary_group_abbrevs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def abbreviate_sentence(sent)\n words = sent.split(\" \")\n new_words = []\n \n words.each do |word|\n if word.length > 4\n new_word = abbreviate_word(word)\n new_words << new_word\n else\n new_words << word\n end\n end\n \n return new_words.join(\" \")\n end",
"def abbrev... | [
"0.6118408",
"0.6116712",
"0.6112406",
"0.60952646",
"0.60716486",
"0.60656524",
"0.6039935",
"0.60294443",
"0.598358",
"0.5974996",
"0.59599334",
"0.59295267",
"0.58713245",
"0.58579725",
"0.58195627",
"0.57826024",
"0.5699851",
"0.5696503",
"0.56654876",
"0.565719",
"0.5650... | 0.0 | -1 |
append the short version of sender name, yielding a string of at most maxlength characters | def insert_sender_name(text, sender, maxlength=nil)
maxlength ||= MaxSmsLength-Message.timestamp_length
sender_name = @sender.shorter_name
text[0..(maxlength-2-sender_name.size)] + '-' + sender_name # Truncate msg and add sender's name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def short_name\n name.size > 35 ? \"#{name[0..35]}...\" : name\n end",
"def shortened_email\n \"#{email[0..4]}...\"\n end",
"def short_name\n short = name[0..30]\n if name.length > 30\n short += '...'\n end\n short\n end",
"def short_name(how_short = 55)\n\t\tstr = self.name\n\t... | [
"0.7076486",
"0.6893923",
"0.6752968",
"0.671645",
"0.6688918",
"0.6586634",
"0.6488088",
"0.636328",
"0.6171163",
"0.6170532",
"0.61569667",
"0.61327463",
"0.6101455",
"0.60759443",
"0.5996947",
"0.5973962",
"0.59634453",
"0.59477574",
"0.59385014",
"0.590292",
"0.5901651",
... | 0.8021557 | 0 |
Post the sender's message as a news update, expiring in 4 hours (add code to make variable if desired) | def report_update(text)
body = "#{I18n.t(:via)} #{@sender.shorter_name}: #{text}" # Will accept messages longer than 150, though I don't think gateways will do this
sms_only = insert_sender_name(text, @sender)
message = Message.new(:user_id => @sender.id, :send_sms=>false, :news_update => true,
:sms... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_news\n @feeder.send_feed(message.chat.id)\n end",
"def update_message(data); end",
"def update_message(data); end",
"def news_added(user, news)\n redmine_headers 'Project' => news.project.identifier\n @author = news.author\n message_id news\n references news\n @news = news\n ... | [
"0.65279245",
"0.63612473",
"0.63612473",
"0.62812877",
"0.62721986",
"0.62654924",
"0.6147898",
"0.6139172",
"0.6138483",
"0.6113132",
"0.6072021",
"0.6072021",
"0.6060704",
"0.6056918",
"0.60331583",
"0.60270065",
"0.602443",
"0.6003772",
"0.5994301",
"0.59900403",
"0.59789... | 0.62082237 | 6 |
Return to the user the latest news updates | def send_updates(text)
# The regular expression is to look for keyword(s) and/or limit (integer) in either order
if text+' ' =~ /\A\s*(\d+)\W*(.*)/
limit, keyword = $1, $2
else
text+' ' =~ /\s*(\w.*?)[, :\/\(]+(\d*)/
limit, keyword = $2, $1
end
limit = limit.blank? ? nil : limit.t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @news_updates = NewsUpdate.all.paginate(page: params[:page], per_page: 5).order(\"created_at desc\")\n end",
"def latest_news(m)\n news = News.order(:date).last\n\n author = reveal_author(news.author)\n date = I18n.localize(news.date, :full)\n\n m.reply I18n.news_fet... | [
"0.7086116",
"0.6898294",
"0.68449175",
"0.68393874",
"0.6812846",
"0.67424554",
"0.6701597",
"0.6685787",
"0.66784024",
"0.66634005",
"0.66385025",
"0.65864486",
"0.6467106",
"0.6459818",
"0.6412124",
"0.63909125",
"0.6364227",
"0.63462704",
"0.63049257",
"0.63036644",
"0.62... | 0.0 | -1 |
The user has sent an SMS text confirming response of a previous message | def process_response(command, text)
message_id = command[1..99]
message = Message.find_by_id(message_id)
#puts "**** command=#{command}, text=#{text}, @sender.id=#{@sender.id}, message=#{message.id}"
if message
@possible_senders.each do |a_member|
message.process_response(:member => a_member, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_code_again\n current_user.send_confirmation_sms\n end",
"def send_sms\n status = self.status\n if status.upcase == 'INTERVENTION'\n self.message\n end\n end",
"def twilio_sms\n sms = {\n :sid => params[:SmsSid], \n :from => params[:From],\n :to => p... | [
"0.67036676",
"0.65857726",
"0.64924866",
"0.6449953",
"0.6359304",
"0.6354412",
"0.63141274",
"0.6299907",
"0.6275592",
"0.6222611",
"0.6210748",
"0.6160787",
"0.61379814",
"0.61371547",
"0.6098004",
"0.60725284",
"0.6064162",
"0.60448885",
"0.6042756",
"0.6024934",
"0.59888... | 0.66166824 | 1 |
TODO: this should go to tog_core into the RatesHelper module Till then it stays here, since we cannot rely on the host app defining this helper. | def rating_stars(rateable, filled, empty)
if rateable.total_ratings > 0
return stars(rateable, :filled_star => image_tag(filled), :empty_star => image_tag(empty)) do |content,rating,filled|
link_to content, member_rate_path(:type => rateable.class.name, :id => rateable.id, :rate => rating), :id => "ra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def version_helper; end",
"def version_helper; end",
"def version_helper; end",
"def version_helper; end",
"def period_helper\n \"#{@sprint_start_date } - #{@sprint_end_date}\"\n end",
"def rate_your_date\n DateEventApplicationsMailer.rate_your_date\n end",
"def dates\n end",
"def get_... | [
"0.5598273",
"0.5598273",
"0.5598273",
"0.5598273",
"0.556118",
"0.55355734",
"0.5403898",
"0.5403089",
"0.5403089",
"0.5388976",
"0.5388976",
"0.5388976",
"0.53812295",
"0.5235707",
"0.5225498",
"0.52102345",
"0.52102345",
"0.5207629",
"0.519731",
"0.519731",
"0.519731",
"... | 0.0 | -1 |
Returns the next element of the local_iterator or nil if no next element available | def next
if (@local_iterator && @local_iterator.has_next?)
@local_iterator.get_next
else
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next\n\n if (@local_iterator)\n @local_iterator.get_next\n else\n raise \"No iterator defined! Cannot get next element\"\n end\n\n end",
"def peek_next()\n return nil if @at_end\n\n begin\n @reader.peek\n rescue StopIteration\n nil\n end\n end",
"def next()\n ... | [
"0.8637198",
"0.6667394",
"0.65109473",
"0.6508372",
"0.6489195",
"0.6466904",
"0.6463799",
"0.64620054",
"0.6347466",
"0.6313816",
"0.62500626",
"0.6205323",
"0.61996686",
"0.61648756",
"0.6161937",
"0.6095676",
"0.6092553",
"0.60900676",
"0.6050604",
"0.6048979",
"0.6045968... | 0.89667404 | 0 |
When get is used to retrieve an element, it is assumed that the index does not need correction, for instance, no negative index is allowed. If one wants to use negative indexes, then method [] should be used. So mat.get([1, 0, 0]) raises an exception while mat[1, 0, 0] gets the last value for the first dimension. | def [](*index)
if (index.size != 0)
@local_index[*index]
elsif (@local_iterator)
@local_iterator.get_current
else
raise "No iterator defined! Cannot get element"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(i,j)\n if( !(i.is_a? Fixnum) or i < 0 or i >=@fil or !(j.is_a? Fixnum) or j < 0 or j >= @col)\n return nil\n end\n \n return @matrix[i][j]\n end",
"def [](i,j) \n @matriz[i][j]\nend",
"def get(row, col)\n validate_pos(row, col)\n ... | [
"0.69543713",
"0.66380084",
"0.6629697",
"0.6502642",
"0.6502642",
"0.6329933",
"0.62742954",
"0.6269114",
"0.62296814",
"0.6199686",
"0.6162799",
"0.6142647",
"0.613466",
"0.61149305",
"0.6105257",
"0.60924053",
"0.6085774",
"0.6068087",
"0.60104954",
"0.5929822",
"0.5912596... | 0.0 | -1 |
When get is used to retrieve an element, it is assumed that the index does not need correction, for instance, no negative index is allowed. If one wants to use negative indexes, then method [] should be used. So mat.get([1, 0, 0]) raises an exception while mat[1, 0, 0] gets the last value for the first dimension. | def get(index = nil)
@local_index.get(index)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(i,j)\n if( !(i.is_a? Fixnum) or i < 0 or i >=@fil or !(j.is_a? Fixnum) or j < 0 or j >= @col)\n return nil\n end\n \n return @matrix[i][j]\n end",
"def [](i,j) \n @matriz[i][j]\nend",
"def get(row, col)\n validate_pos(row, col)\n ... | [
"0.69545263",
"0.663815",
"0.66291064",
"0.6502794",
"0.6502794",
"0.63306326",
"0.6274494",
"0.6268867",
"0.6228704",
"0.6200045",
"0.61621755",
"0.6142439",
"0.6134627",
"0.6114391",
"0.610603",
"0.6092927",
"0.6087052",
"0.6067702",
"0.60091245",
"0.59306204",
"0.5912207",... | 0.0 | -1 |
Sets a value for a scalar D0 array | def get_scalar
@local_index.get_scalar
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_scalar(value)\n @local_index.set_scalar(value)\n end",
"def x=(value)\n self[0] = value\n end",
"def s0=(value)\n self[:s0] = value\n end",
"def s0=(value)\n self[:s0] = value\n end",
"def s0=(value)\n self[:s0] = value\n end",
"def s0=(value)\n self[:s0] = value\... | [
"0.6530049",
"0.6022201",
"0.60002863",
"0.60002863",
"0.60002863",
"0.60002863",
"0.60002863",
"0.60002863",
"0.60002863",
"0.60002863",
"0.60002863",
"0.60002863",
"0.60002863",
"0.60002863",
"0.60002863",
"0.60002863",
"0.60002863",
"0.60002863",
"0.60002863",
"0.60002863",
... | 0.0 | -1 |
Gets the next element of the local iterator | def get_next
if (@local_iterator)
@local_iterator.get_next
else
raise "No iterator defined! Cannot get next element"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next\n\n if (@local_iterator && @local_iterator.has_next?)\n @local_iterator.get_next\n else\n nil\n end\n\n end",
"def next()\n result = current\n @index += 1\n @got_next_element = false\n @next_element = nil\n result\n end",
"def next\n self.offset(1... | [
"0.88285",
"0.73890996",
"0.7089945",
"0.6989716",
"0.696195",
"0.6904838",
"0.6884382",
"0.68811727",
"0.68792474",
"0.68790907",
"0.68603706",
"0.6800033",
"0.67778426",
"0.67448646",
"0.67280453",
"0.66897887",
"0.66882795",
"0.6650605",
"0.65601057",
"0.6534652",
"0.65346... | 0.8998405 | 0 |
When set is used to assign to an element, it is assumed that the index does not need correction, for instance, no negative index is allowed. If one wants to use negative indexes, then method [] should be used. So mat.set([1, 0, 0], 10), raises an exection while mat[1, 0, 0] = 10 sets the last value for the first dimens... | def set(index, value)
@local_index.set(index, value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set(index, val)\n \n end",
"def set(row, column, value)\n @matrix[row][column] = value\n end",
"def set!(row, col, val)\n validate_pos(row, col)\n @fm[row*@cols+col] = val\n end",
"def set( index , value)\n raise \"Only positive indexes #{index}\" if index <= 0\n if ind... | [
"0.71963626",
"0.6745636",
"0.6717228",
"0.6691979",
"0.6656406",
"0.66162455",
"0.66119206",
"0.6553816",
"0.6512689",
"0.64641184",
"0.642119",
"0.63938075",
"0.6368283",
"0.63544095",
"0.62958074",
"0.62687874",
"0.62561494",
"0.6251671",
"0.6251671",
"0.62102014",
"0.6193... | 0.5972475 | 30 |
Sets a value for a scalar D0 array | def set_scalar(value)
@local_index.set_scalar(value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def x=(value)\n self[0] = value\n end",
"def s0=(value)\n self[:s0] = value\n end",
"def s0=(value)\n self[:s0] = value\n end",
"def s0=(value)\n self[:s0] = value\n end",
"def s0=(value)\n self[:s0] = value\n end",
"def s0=(value)\n self[:s0] = value\n end",
"def... | [
"0.6023718",
"0.6000415",
"0.6000415",
"0.6000415",
"0.6000415",
"0.6000415",
"0.6000415",
"0.6000415",
"0.6000415",
"0.6000415",
"0.6000415",
"0.6000415",
"0.6000415",
"0.6000415",
"0.6000415",
"0.6000415",
"0.6000415",
"0.6000415",
"0.6000415",
"0.6000415",
"0.6000415",
"... | 0.65312016 | 0 |
Given an MDArray, makes it immutable. Renjin data cannot be changed as Renjin assumes it can delay processing. | def immutable
instance_eval { def set(name, value) raise "Array is immutable" end }
instance_eval { def set_scalar(name, value) raise "Array is immutable" end }
instance_eval { def set_next(value) raise "Array is immutable" end }
instance_eval { def []=(name, value) raise "Array is immutable" end }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def immutable!\n @data = data.to_smash(:freeze)\n end",
"def mutliplied(array)\nend",
"def mutate(arr)\n arr.pop # (no bang! here) mutates\nend",
"def mutate_rmhc(array)\n mutated_position = rand(array.length)\n\n array.clone.tap do |new_array|\n new_array[mutated_position] = inverse(new_array[... | [
"0.6409942",
"0.60444224",
"0.5907143",
"0.5898404",
"0.58022964",
"0.57947665",
"0.57947665",
"0.57947665",
"0.57947665",
"0.57947665",
"0.57947665",
"0.57947665",
"0.57947665",
"0.57947665",
"0.57947665",
"0.57947665",
"0.57947665",
"0.57947665",
"0.57947665",
"0.57947665",
... | 0.63441795 | 1 |
Cycles through the whole list of elements yielding to a block (if given) the next element and its iterator. Was made private so that users do not need to know about iterator. Giving iterator could be a speed up usefule for final users concerned about performance. | def each_with_iterator
iterator = get_iterator_fast
while (iterator.has_next?)
yield iterator.get_next, iterator if block_given?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _each(&block)\n _next.each(&block) if _next\n end",
"def each(&block)\n i = @elements.length - 1\n while i >= 0\n yield @elements[i]\n i -= 1\n end\n end",
"def each\n while true do\n yield\n break if ! advance\n end\n ... | [
"0.71445954",
"0.6998145",
"0.67899436",
"0.6775146",
"0.67720574",
"0.67520666",
"0.67445105",
"0.67030174",
"0.67012775",
"0.66746825",
"0.66729563",
"0.66393876",
"0.65997344",
"0.659565",
"0.6546348",
"0.64993036",
"0.64992756",
"0.6487391",
"0.6461326",
"0.64136577",
"0.... | 0.7748276 | 0 |
This file contains the two functions that are used by the main program (cspoof.rb) dump the cookies to a file in verbose mode | def puts_verbose(text, src_ip, dst_ip)
#generate the filename
user = File.open("cookie_#{src_ip}->#{dst_ip}.txt", "a")
puts "File opened: #{user.path}"
user.puts "----------------------------------------------------"
user.puts(text)
user.close
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_cookie(cookie)\n dputs __method__.to_s\n File.open($CONF['cookie'], \"w\") do |fc|\n fc.write(cookie)\n end\nend",
"def puts_verbose(text, src_ip, dst_ip)\n if @verbose then\n \n #generate the filename\n user = File.open(\"cookie_#{src_ip}->#{dst_ip}.txt\", \"a\") \n puts \"File opene... | [
"0.68905324",
"0.6680175",
"0.61863405",
"0.597792",
"0.59136254",
"0.59136254",
"0.59136254",
"0.59136254",
"0.59136254",
"0.59136254",
"0.59136254",
"0.5775075",
"0.5766567",
"0.5695047",
"0.5686072",
"0.5644787",
"0.5643763",
"0.55872226",
"0.5585725",
"0.5583988",
"0.5582... | 0.6601483 | 2 |
sniff the traffic and capture the cookie packets, and dump them to a file | def cookie_grabber
puts "Waiting for cookies............:"
iface = @interface
capture_session = PacketFu::Capture.new(:iface => iface, :start => true, :promisc => true,
:filter => "tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)")
capture_session.stream.each { |packet|
if packet ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capture_traffic\n check_pcaprub_loaded()\n ::Socket.do_not_reverse_lookup = true # Mac OS X workaround\n open_pcap({'FILTER' => datastore['FILTER']})\n @capture_thread = Rex::ThreadFactory.spawn(\"DNSSpoofer\", false) do\n each_packet do |pack|\n begin\n parsed = PacketFu::Pac... | [
"0.5847115",
"0.5669681",
"0.56156147",
"0.55420643",
"0.5536752",
"0.5428383",
"0.54196113",
"0.54074633",
"0.535917",
"0.5274551",
"0.5228758",
"0.51821196",
"0.51759034",
"0.51611173",
"0.51595473",
"0.5071599",
"0.50644207",
"0.5062396",
"0.50183874",
"0.5007444",
"0.4978... | 0.7295756 | 0 |
GET /languages GET /languages.json | def index
@languages = Language.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_languages\n\t\trender json: Language.all.to_json\n\tend",
"def get_languages(options = {})\n object_from_response(GogoKit::PagedResource,\n GogoKit::LanguagesRepresenter,\n :get,\n get_root.links['viagogo:language... | [
"0.8044327",
"0.7907578",
"0.7801487",
"0.77280736",
"0.76700276",
"0.75882673",
"0.75538105",
"0.742302",
"0.7378772",
"0.7361126",
"0.6960328",
"0.69310206",
"0.68852",
"0.68464166",
"0.68208843",
"0.6812054",
"0.67476225",
"0.6731535",
"0.6706139",
"0.6695307",
"0.66920954... | 0.6975428 | 10 |
GET /languages/1 GET /languages/1.json | def show
@allfeeds = Preloadsource.where(language: @language)
@submittagresults = params[:feed_ids]
# If no user is logged in
if !current_user
# Check whether the modal has been triggered
if @submittagresults
@selectedfeeds = @allfeeds.where(id: @submittagresults).take(3)
@ot... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_language\n\t\trender json: Language.find(params[:language_id]).to_json\n\tend",
"def language(id, params = {})\n get \"languages/#{id}\", {query: params}\n end",
"def index\n @languages = Language.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { ... | [
"0.77902025",
"0.75983334",
"0.74638444",
"0.73959213",
"0.7359037",
"0.7303772",
"0.72510153",
"0.7036646",
"0.69528466",
"0.6943945",
"0.6933537",
"0.68406355",
"0.68190813",
"0.67241716",
"0.67241716",
"0.67241716",
"0.67241716",
"0.67241716",
"0.67241716",
"0.67241716",
"... | 0.0 | -1 |
GET /languages/new def new | def create
# @language = Language.new(language_params)
# respond_to do |format|
# if @language.save
# format.html { redirect_to @language, notice: 'Language was successfully created.' }
# format.json { render :show, status: :created, location: @language }
# else
# format.htm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @languages = Language.all\n end",
"def new\n @lang = Lang.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lang }\n end\n end",
"def new\n @language = Language.new\n @locale_name = Language.where(iso_639_code: I18n.locale).f... | [
"0.8357383",
"0.83341753",
"0.81722265",
"0.8140132",
"0.79241383",
"0.7798069",
"0.7657381",
"0.76162654",
"0.74993366",
"0.748857",
"0.74726367",
"0.74461555",
"0.7420388",
"0.73173803",
"0.73146224",
"0.7270338",
"0.7231685",
"0.7225175",
"0.7211918",
"0.7178689",
"0.71291... | 0.7043654 | 26 |
Use callbacks to share common setup or constraints between actions. | def set_language
@language = Language.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.532... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def language_params
params.permit(:language)
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.69811666",
"0.6782836",
"0.6747644",
"0.6742015",
"0.6735273",
"0.6593917",
"0.65037674",
"0.6498627",
"0.6482372",
"0.64795715",
"0.64566946",
"0.6439213",
"0.6380714",
"0.6378147",
"0.63657266",
"0.63206697",
"0.6300169",
"0.62992156",
"0.6295538",
"0.62943023",
"0.62915... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.