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 |
|---|---|---|---|---|---|---|
Helper method to simplify checks | def check_slide(slide, title, code, skipped, content_types = [ ], contents = [ ], strip = true, &checks)
assert_equal(title, slide.title)
assert_equal(code, slide.contains_code?)
assert_equal(skipped, slide.skip)
content_types.each_with_index { |e, i| assert_kind_of(e, slide.elements[i]) }
contents.each_with_index do |e, i|
if strip
assert_equal(e, slide.elements[i].to_s.strip)
else
assert_equal(e, slide.elements[i].to_s)
end
end
checks.call(slide.elements) unless checks.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checks; end",
"def check ; true ; end",
"def check\n \n end",
"def check\n \n end",
"def issn; end",
"def valid?(thing); end",
"def valid?(thing); end",
"def valid; end",
"def valid?(_) true end",
"def valid?(_) true end",
"def valid?\n \n \n ... | [
"0.69029903",
"0.66005415",
"0.65114754",
"0.65114754",
"0.6343877",
"0.63203996",
"0.63203996",
"0.6294905",
"0.62190044",
"0.62190044",
"0.6178143",
"0.61746085",
"0.61665463",
"0.6165975",
"0.6165975",
"0.6165975",
"0.6165975",
"0.6165975",
"0.61630183",
"0.6149998",
"0.61... | 0.0 | -1 |
Create array of lines from a string | def lines(string)
io = StringIO.new(string)
result = io.readlines
io.close
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lines\n result = Array.new\n @theLines.each { |l| result << String.new(l) }\n return result\n end",
"def get_lines(string)\n result = Array.new\n lines = string.split('[]')\n unless lines.first == \"LEDES1998B\"\n set_error_message(\"First line of Ledes file is not \\\"LEDES19... | [
"0.7634611",
"0.72438705",
"0.7181382",
"0.7147869",
"0.6996766",
"0.6996766",
"0.69694364",
"0.6860133",
"0.6804814",
"0.67996144",
"0.6780979",
"0.6683623",
"0.664279",
"0.6616253",
"0.65624845",
"0.65273696",
"0.6502209",
"0.6498536",
"0.6498536",
"0.6492357",
"0.64799446"... | 0.71985877 | 3 |
validates :role_id, :presence => true validates :date_in, :presence => true validates :date_out, :presence => true | def tags1
return projects_tags.where("tags_id in (select id from tags where type_tag=?)",1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_end_date_before_start_date\n return if date_out.nil? \n if date_out && date_in\n errors.add(:date_in, \": could not be after than Date out\") if date_out < date_in\n end\n end",
"def role_valid\n if !role_data\n errors.add(:role, :invalid)\n end\n end",
"def validate_sta... | [
"0.65318817",
"0.6463052",
"0.6332521",
"0.631046",
"0.62875867",
"0.6254319",
"0.6239401",
"0.6222454",
"0.6222454",
"0.6180557",
"0.61698115",
"0.6161679",
"0.61495787",
"0.6117884",
"0.60653234",
"0.6008963",
"0.59879816",
"0.5962545",
"0.59483576",
"0.59483576",
"0.594799... | 0.0 | -1 |
Attempt to push an item on the queue. If the queue is full, then the behavior is determined by the :drop_oldest setting provided to the constructor. Returns true if the object was pushed on the queue, or false if the queue was full. | def enqueue(object_)
result_ = true
if @push_ptr
if @pop_ptr == @push_ptr
if @drop_oldest
@pop_ptr += 1
@pop_ptr = 0 if @pop_ptr == @buffer.size
result_ = false
else
return false
end
elsif @pop_ptr.nil?
@pop_ptr = @push_ptr
end
@buffer[@push_ptr] = object_
@push_ptr += 1
@push_ptr = 0 if @push_ptr == @buffer.size
else
@buffer.push(object_)
end
result_
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_last(value)\n if @queue.size < @size\n @queue.push(value)\n true\n else\n false\n end\n end",
"def pushed?\n !pushed_at.nil?\n end",
"def insert_front(value)\n if @queue.size < @size\n @queue.unshift(value)\n true\n else\n false\n end\n end",
"... | [
"0.6784146",
"0.64809525",
"0.6380965",
"0.6276838",
"0.6215338",
"0.6041882",
"0.6004543",
"0.5968675",
"0.5930533",
"0.59057665",
"0.58883005",
"0.5886998",
"0.58579034",
"0.582185",
"0.5792463",
"0.57783526",
"0.5770018",
"0.57606775",
"0.57606065",
"0.5740639",
"0.5736608... | 0.7238949 | 0 |
Return the oldest item in the queue, or nil if the queue is empty. | def dequeue
if @push_ptr
if @pop_ptr
object_ = @buffer[@pop_ptr]
@buffer[@pop_ptr] = nil
@pop_ptr += 1
@pop_ptr = 0 if @pop_ptr == @buffer.size
@pop_ptr = nil if @pop_ptr == @push_ptr
object_
else
nil
end
else
@buffer.shift
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_front()\n if @queue.size > 0\n return @queue[0]\n end\n -1\n end",
"def peek()\n @queue.first\n end",
"def peek\n if empty?\n nil\n else\n tempArr = []\n while @queue.size > 1\n tempArr.push(@queue.remove)\n end... | [
"0.74382603",
"0.72326887",
"0.7223011",
"0.7161646",
"0.69525766",
"0.6934586",
"0.67884004",
"0.67561287",
"0.6718263",
"0.6716619",
"0.66483307",
"0.6636421",
"0.6636421",
"0.6598664",
"0.6589884",
"0.65497077",
"0.6543673",
"0.6510332",
"0.6491958",
"0.64709675",
"0.64671... | 0.0 | -1 |
Return an array of the contents of the queue, in order. | def dequeue_all
if @push_ptr
if @pop_ptr
if @pop_ptr < @push_ptr
ret_ = @buffer[@pop_ptr..@push_ptr-1]
else
ret_ = @buffer[@pop_ptr..-1] + @buffer[0..@push_ptr-1]
end
@buffer.fill(nil)
@push_ptr = 0
@pop_ptr = nil
ret_
else
[]
end
else
ret_ = @buffer
@buffer = []
ret_
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queued_messages\n @buffer.slice(@pointer, @buffer.length - @pointer)\n end",
"def queued_messages\r\n @buffer.slice(@pointer, @buffer.length - @pointer)\r\n end",
"def pop\n val = []\n @queue_mutex.synchronize do\n val = @memory_queue.pop\n end\n val\n end",
... | [
"0.7189088",
"0.7127472",
"0.6844221",
"0.67782277",
"0.6529813",
"0.63952917",
"0.6281892",
"0.6267112",
"0.6261744",
"0.6202497",
"0.6196211",
"0.6120766",
"0.6114355",
"0.60679007",
"0.6062635",
"0.6017754",
"0.59974",
"0.59681576",
"0.59681576",
"0.5916615",
"0.5829373",
... | 0.6611848 | 4 |
Return the size of the queue, which is 0 if the queue is empty. | def size
if @push_ptr
if @pop_ptr
value_ = @push_ptr - @pop_ptr
value_ > 0 ? value_ : value_ + @buffer.size
else
0
end
else
@buffer.size
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size\n\n @queue.size\n end",
"def size\n @queue.size\n end",
"def size\n @mutex.synchronize { @queue.size }\n end",
"def size\n @queue.size\n end",
"def size\n @queue.size\n end",
"def size\n @queue.size\n end",
"def length\n @queue.length\n ... | [
"0.88670236",
"0.88502824",
"0.88458216",
"0.884093",
"0.8811372",
"0.8742439",
"0.8613658",
"0.8587226",
"0.8478401",
"0.8167921",
"0.81189924",
"0.8092466",
"0.8063037",
"0.80547166",
"0.80545497",
"0.80353695",
"0.8034661",
"0.7942715",
"0.79209864",
"0.79019225",
"0.78829... | 0.6987391 | 43 |
1 Split document into words 2 Compute word frequency 3 Compute dot product | def documentDistance doc1,doc2
puts "Implmementing doc"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def document_frequency\n @corpus.each_with_object({}) do |doc, df|\n doc.bag_of_words.keys.each do |word|\n df[word] = (df.fetch(word) { 0.0 }) + 1.0\n end\n end\n end",
"def calculate_term_frequencies\n results = []\n\n @tokenized_documents.each do |tokens|\... | [
"0.7699382",
"0.73476",
"0.72993225",
"0.7179902",
"0.7063857",
"0.7047761",
"0.6792026",
"0.67630196",
"0.67150044",
"0.6678528",
"0.6675041",
"0.6614578",
"0.6613643",
"0.65825874",
"0.6520865",
"0.65160424",
"0.65044916",
"0.64923483",
"0.6442208",
"0.6389798",
"0.6380805"... | 0.0 | -1 |
try to ennsure that if I "archive" 3 app results today, they don't get thrown in with these ...while at the same time, I don't necessarily want to have them hang around until they would be autoarchived either... | def call
return if @customer.nil? || @results.blank?
raise S3SaveError unless upload_records
@results.update_all(archive_state: :archived)
# ServiceRunnerJob.perform_later("Pipeline::Archive::Destroyer", "app_results", @customer.id)
return unless @remaining_results_count > 2500
ServiceRunnerJob.perform_later("Pipeline::Archive::Archiver", @customer.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fixArchiveMeta\n nDone = 0\n allIDs = Item.where(Sequel.lit(\"updated >= '2020-05-18'\")).select_map(:id)\n allIDs.sort.each_slice(100) { |ids|\n DB.transaction {\n ids.each { |itemID| collectArchiveMeta(itemID, nil).save }\n }\n nDone += ids.length\n puts \"#{nDone}/#{allIDs.length} done.\... | [
"0.57010555",
"0.5669975",
"0.5578132",
"0.55163324",
"0.55163324",
"0.5506198",
"0.544077",
"0.53104424",
"0.5295086",
"0.5252758",
"0.5170933",
"0.5169608",
"0.5154852",
"0.51522034",
"0.51275694",
"0.5115928",
"0.51040655",
"0.51019514",
"0.5092366",
"0.5079567",
"0.507922... | 0.0 | -1 |
Generate standard YAML output, but never include the auto warning message. FIXME: Override to solve a convoluted, `simp config` code problem. Because `simp config` needs to know the scenario to use to build the Item decision tree, it needs to determine this Item's value ahead of time. Then, to make sure this Item is actually persisted in the YAML, | def to_yaml_s(include_auto_warning = false)
super(false)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auto_warning\n \">> VALUE SET BY `simp config` AUTOMATICALLY. <<\\n\"\n end",
"def to_yaml_s(include_auto_warning = false)\n raise InternalError.new( \"@key is empty for #{self.class}\" ) if \"#{@key}\".empty?\n\n x = \"=== #{@key} ===\\n\"\n x += \"#{(description || 'FIXME: NO DESCRI... | [
"0.6189041",
"0.5990701",
"0.5969959",
"0.5823672",
"0.5632906",
"0.54996115",
"0.5376722",
"0.5265555",
"0.5223406",
"0.51639843",
"0.51193625",
"0.50991535",
"0.50987667",
"0.5095213",
"0.5060933",
"0.50364095",
"0.5028591",
"0.49820378",
"0.49710774",
"0.492528",
"0.492248... | 0.6360387 | 0 |
Responds to request with index_ok status and resources | def index_ok(resources:)
render json: resources, status: :ok, include: index_includes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n render_result('ok')\n end",
"def index\n build_resource({})\n respond_with self.resource\n end",
"def request_res_index(*args)\n @res_index\n end",
"def index\n render status: :ok, json: { status: 'done' }.to_json\n\tend",
"def index\n status = get_health_status( )\n res... | [
"0.70537627",
"0.6929136",
"0.6889598",
"0.68736124",
"0.6838742",
"0.6838742",
"0.6796769",
"0.6636623",
"0.66111386",
"0.65857875",
"0.6577394",
"0.655659",
"0.6519567",
"0.64604425",
"0.6448699",
"0.6399619",
"0.6386759",
"0.6367987",
"0.6365259",
"0.63649845",
"0.6354009"... | 0.77497816 | 0 |
GET /kitchen_items GET /kitchen_items.json | def index
@kitchen_items = KitchenItem.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def items\n \tbegin\n \t@categories = Category.all.includes(items: [:dimensions])\n \t@ingredients = Ingredient.actives\n \trender 'api/v1/home/items', status: :ok\n \trescue Exception => e\n \t\terror_handling_bad_request(e)\n \tend\n\n\tend",
"def show\n @items = Item.find(params[:id])\n render j... | [
"0.7134772",
"0.69249094",
"0.687674",
"0.6861754",
"0.678004",
"0.6698239",
"0.66140956",
"0.6599162",
"0.6570955",
"0.6568973",
"0.65619594",
"0.6485358",
"0.6472469",
"0.6456834",
"0.64541215",
"0.6437892",
"0.6433963",
"0.6433963",
"0.6433963",
"0.6433963",
"0.64330137",
... | 0.7376812 | 0 |
GET /kitchen_items/1 GET /kitchen_items/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @kitchen_items = KitchenItem.all\n end",
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def show\n item = Item.find(params[:id])\n render json: item\n end",
"def index\n @api_v1_items = Item.all\n render json: @api_v1_items\n end",
"def show\... | [
"0.7043698",
"0.6975022",
"0.6800097",
"0.6777088",
"0.6717245",
"0.67129",
"0.67125845",
"0.6705742",
"0.66885334",
"0.66855645",
"0.66746444",
"0.66569424",
"0.6622738",
"0.6615867",
"0.6579635",
"0.6558462",
"0.65432334",
"0.65254223",
"0.65217423",
"0.6487448",
"0.6474693... | 0.0 | -1 |
POST /kitchen_items POST /kitchen_items.json | def create
@kitchen_item = KitchenItem.new(kitchen_item_params)
respond_to do |format|
if @kitchen_item.save
format.html { redirect_to @kitchen_item, notice: 'Kitchen item was successfully created.' }
format.json { render :show, status: :created, location: @kitchen_item }
else
format.html { render :new }
format.json { render json: @kitchen_item.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end",
"def create_item()\n\n request_body = {\n 'name' => 'Milkshake',\n 'variations' => [\n {\n 'name' => 'Small',\n 'pricing_type' => 'FIXED_PRICING',\n 'price_money' => {\n '... | [
"0.72451705",
"0.6928463",
"0.6806272",
"0.6793319",
"0.6772816",
"0.676852",
"0.6707462",
"0.66971517",
"0.66828066",
"0.6654724",
"0.6581394",
"0.65711427",
"0.6538814",
"0.651494",
"0.65121204",
"0.6478343",
"0.6473956",
"0.6432934",
"0.64138335",
"0.63993627",
"0.63717395... | 0.72483754 | 0 |
PATCH/PUT /kitchen_items/1 PATCH/PUT /kitchen_items/1.json | def update
respond_to do |format|
if @kitchen_item.update(kitchen_item_params)
format.html { redirect_to @kitchen_item, notice: 'Kitchen item was successfully updated.' }
format.json { render :show, status: :ok, location: @kitchen_item }
else
format.html { render :edit }
format.json { render json: @kitchen_item.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Item.update(params[\"id\"], params[\"item\"])\n end",
"def update\n json_response(@food_item.update!(food_item_params))\n end",
"def update\n\n #update the item of request_item\n if (params[:request_item].present?)\n @request_item.item = params[:request_item... | [
"0.7048443",
"0.6896587",
"0.68237144",
"0.67524743",
"0.6710602",
"0.6661912",
"0.6659253",
"0.65691996",
"0.6545763",
"0.6538919",
"0.6530061",
"0.6522068",
"0.64431727",
"0.64341956",
"0.6414629",
"0.64085096",
"0.6402146",
"0.6399562",
"0.63763523",
"0.6375756",
"0.637127... | 0.69881314 | 1 |
DELETE /kitchen_items/1 DELETE /kitchen_items/1.json | def destroy
@kitchen_item.destroy
respond_to do |format|
format.html { redirect_to kitchen_items_url, notice: 'Kitchen item was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def delete_item(item_id)\n response = Unirest.delete CONNECT_HOST + '/v1/' + LOCATION_ID + '/items/' + item_id,\n headers: REQUEST_HEADERS\n\n if response.code == 200\n puts 'Successfully deleted item'\n return response.... | [
"0.7543226",
"0.7345672",
"0.73273945",
"0.7256286",
"0.72124076",
"0.7212166",
"0.7191534",
"0.7148264",
"0.7145646",
"0.71179235",
"0.7109465",
"0.7107864",
"0.7074573",
"0.70669353",
"0.7063961",
"0.70634866",
"0.70634866",
"0.70634866",
"0.70634866",
"0.70634866",
"0.7063... | 0.7216307 | 4 |
Use callbacks to share common setup or constraints between actions. | def set_kitchen_item
@kitchen_item = KitchenItem.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def kitchen_item_params
params.require(:kitchen_item).permit(:name, :purchased_quantity, :used_quantity, :unit, :receipt_item_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /imagedemos GET /imagedemos.json | def index
@imagedemos = Imagedemo.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @images = Image.all\n\n render json: @images\n end",
"def index\n @images = getmydata(\"Image\")\n pagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @images }\n end\n end",
"def show\n @image = Image.find(params[:id])\... | [
"0.71706057",
"0.71033627",
"0.7084107",
"0.7084107",
"0.70489085",
"0.6948099",
"0.6942099",
"0.6930324",
"0.6929514",
"0.6918766",
"0.68134093",
"0.68132335",
"0.6805545",
"0.680441",
"0.6791519",
"0.6788768",
"0.6775336",
"0.6772888",
"0.67508864",
"0.6743682",
"0.6743682"... | 0.6965595 | 5 |
GET /imagedemos/1 GET /imagedemos/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @image = Image.find(params[:id])\n\n render json: @image\n end",
"def show\n @image = Image.find(params[:id])\n\n render json: @image\n end",
"def index\n @images = Image.all\n\n render json: @images\n end",
"def index\n @images = getmydata(\"Image\")\n pagination\n\n ... | [
"0.73817205",
"0.73817205",
"0.7233121",
"0.7165596",
"0.70986265",
"0.7077283",
"0.7067926",
"0.70449656",
"0.70106393",
"0.70106393",
"0.70106393",
"0.70106393",
"0.6989664",
"0.6958747",
"0.69349676",
"0.6933679",
"0.69262606",
"0.68988883",
"0.6895199",
"0.689226",
"0.686... | 0.0 | -1 |
POST /imagedemos POST /imagedemos.json | def create
@imagedemo = Imagedemo.new(imagedemo_params)
respond_to do |format|
if @imagedemo.save
format.html { redirect_to @imagedemo, notice: 'Imagedemo was successfully created.' }
format.json { render action: 'show', status: :created, location: @imagedemo }
else
format.html { render action: 'new' }
format.json { render json: @imagedemo.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_image\n @image = Image.create(image_path: params[:upload][:image])\n p @image\n render json: @image\n end",
"def create \n @image ||= Image.new(image_params)\n if @image.save\n render json: {\"url\" => @image.image_url(:resized), \"success\" => true}\n else\n render json: ... | [
"0.66844064",
"0.63975775",
"0.63907677",
"0.6249914",
"0.619083",
"0.6177423",
"0.6177007",
"0.6172407",
"0.61656713",
"0.61557436",
"0.60964936",
"0.6092667",
"0.60897505",
"0.6087746",
"0.60378796",
"0.60340583",
"0.6030172",
"0.60289156",
"0.5999898",
"0.5991341",
"0.5983... | 0.6904636 | 0 |
PATCH/PUT /imagedemos/1 PATCH/PUT /imagedemos/1.json | def update
respond_to do |format|
if @imagedemo.update(imagedemo_params)
format.html { redirect_to @imagedemo, notice: 'Imagedemo was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @imagedemo.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n params[:image].delete :created_at\n params[:image].delete :updated_at\n params[:image].delete :id\n @image = Image.find(params[:id])\n if @image.update_attributes(params[:image])\n render json: @image\n else\n render json: @image.errors, status: :unprocessable_entity\n e... | [
"0.6884882",
"0.68321043",
"0.6433385",
"0.6431917",
"0.6390499",
"0.6390499",
"0.6390499",
"0.6390499",
"0.63829255",
"0.638108",
"0.6376428",
"0.6303793",
"0.6292783",
"0.6292783",
"0.6292783",
"0.6292783",
"0.6292783",
"0.6292783",
"0.6292783",
"0.62687355",
"0.6242547",
... | 0.67917943 | 2 |
DELETE /imagedemos/1 DELETE /imagedemos/1.json | def destroy
@imagedemo.destroy
respond_to do |format|
format.html { redirect_to imagedemos_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @image.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n render json: {status: \"success\"}, status: :ok\n end",
"def destroy\n #Finds selected image\n @image = Imag... | [
"0.7461737",
"0.74285847",
"0.7316272",
"0.7244463",
"0.72352445",
"0.7227089",
"0.72268707",
"0.72268707",
"0.72268707",
"0.72268707",
"0.72268707",
"0.72268707",
"0.72259176",
"0.72172105",
"0.7168657",
"0.7168657",
"0.7168657",
"0.7168657",
"0.7168657",
"0.7168657",
"0.716... | 0.77337545 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_imagedemo
@imagedemo = Imagedemo.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def imagedemo_params
params.require(:imagedemo).permit(:fname, :lname, :image)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Finds worksheet by its name or numerical index | def [](ind)
case ind
when Integer then worksheets[ind]
when String then worksheets.find { |ws| ws.sheet_name == ind }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def worksheet idx\n case idx\n when Integer\n @worksheets[idx]\n when String\n @worksheets.find do |sheet| sheet.name == idx end\n end\n end",
"def worksheet_by_name(sheetname = nil)\n sheets.select { |s| s.name == sheetname }.first\n end",
"def worksheet( index )\n... | [
"0.8306105",
"0.7891127",
"0.75315154",
"0.7046851",
"0.69909555",
"0.6475498",
"0.6434711",
"0.6310057",
"0.63025266",
"0.6286639",
"0.6130749",
"0.61009437",
"0.6037043",
"0.58916146",
"0.5853227",
"0.5770568",
"0.5757218",
"0.5749886",
"0.5741633",
"0.5737839",
"0.57045406... | 0.77482533 | 4 |
Create new simple worksheet and add it to the workbook worksheets | def add_worksheet(name = nil)
if name.nil? then
n = 0
begin
name = SHEET_NAME_TEMPLATE % (n += 1)
end until self[name].nil?
end
new_worksheet = Worksheet.new(:workbook => self, :sheet_name => name)
worksheets << new_worksheet
new_worksheet
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_worksheet opts = {}\n opts[:name] ||= client(\"Worksheet#{@worksheets.size.next}\", 'UTF-8')\n add_worksheet Worksheet.new(opts)\n end",
"def add_worksheet worksheet\n worksheet.workbook = self\n @worksheets.push worksheet\n worksheet\n end",
"def add_worksheet(name = ... | [
"0.8110177",
"0.77272063",
"0.77159745",
"0.76507896",
"0.74569863",
"0.72874314",
"0.70154905",
"0.6885352",
"0.67705363",
"0.6718044",
"0.6703531",
"0.6619508",
"0.65931875",
"0.6549719",
"0.65302944",
"0.6451329",
"0.6392518",
"0.6388227",
"0.63838637",
"0.61581063",
"0.61... | 0.77608424 | 3 |
Calculate password hash from string for use in 'password' fields. | def password_hash(pwd)
hsh = 0
pwd.reverse.each_char { |c|
hsh = hsh ^ c.ord
hsh = hsh << 1
hsh -= 0x7fff if hsh > 0x7fff
}
(hsh ^ pwd.length ^ 0xCE4B).to_s(16)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def password_digest(password); end",
"def digest(string)\n cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST :\n BCrypt::Engine.cost\n BCrypt::Password.create(string, cost: cost)\n end",
"def digest(string)\n\t\tcost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_... | [
"0.7502564",
"0.72289884",
"0.72189313",
"0.72189313",
"0.7100617",
"0.6975053",
"0.6973624",
"0.6935003",
"0.6935003",
"0.6935003",
"0.69026077",
"0.68875515",
"0.67386955",
"0.6716514",
"0.66810834",
"0.65440243",
"0.6542212",
"0.65396833",
"0.6539318",
"0.65320736",
"0.644... | 0.7296077 | 1 |
by default, only sets cell to nil if :left is specified, method will shift row contents to the right of the deleted cell to the left if :up is specified, method will shift column contents below the deleted cell upward | def delete_cell(row_index = 0, column_index=0, shift=nil)
validate_workbook
validate_nonnegative(row_index)
validate_nonnegative(column_index)
row = sheet_data[row_index]
old_cell = row && row[column_index]
case shift
when nil then
row.cells[column_index] = nil if row
when :left then
row.delete_cell_shift_left(column_index) if row
when :up then
(row_index...(sheet_data.size - 1)).each { |index|
c = sheet_data.rows[index].cells[column_index] = sheet_data.rows[index + 1].cells[column_index]
c.row -= 1 if c.is_a?(Cell)
}
else
raise 'invalid shift option'
end
return old_cell
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_cell(row=0,col=0,shift=nil)\n validate_workbook\n validate_nonnegative(row)\n validate_nonnegative(col)\n if @sheet_data.size <= row || @sheet_data[row].size <= col\n return nil\n end\n\n cell = @sheet_data[row][col]\n @sheet_data[row][col]=nil\n\n if shift && shift != :left... | [
"0.66775256",
"0.63605005",
"0.6154143",
"0.59607273",
"0.5921581",
"0.5834795",
"0.58257157",
"0.5819249",
"0.57766175",
"0.57533693",
"0.5748814",
"0.5740785",
"0.5733002",
"0.5596116",
"0.5578374",
"0.55728936",
"0.5568853",
"0.55657446",
"0.55616975",
"0.55542773",
"0.555... | 0.6488819 | 1 |
Inserts row at row_index, pushes down, copies style from the row above (that's what Excel 2013 does!) NOTE: use of this method will break formulas which reference cells which are being "pushed down" | def insert_row(row_index = 0)
validate_workbook
ensure_cell_exists(row_index)
old_row = new_cells = nil
if row_index > 0 then
old_row = sheet_data.rows[row_index - 1]
if old_row then
new_cells = old_row.cells.collect { |c|
if c.nil? then nil
else nc = RubyXL::Cell.new(:style_index => c.style_index)
nc.worksheet = self
nc
end
}
end
end
row0 = sheet_data.rows[0]
new_cells ||= Array.new((row0 && row0.cells.size) || 0)
sheet_data.rows.insert(row_index, nil)
new_row = add_row(row_index, :cells => new_cells, :style_index => old_row && old_row.style_index)
# Update row values for all rows below
row_index.upto(sheet_data.rows.size - 1) { |r|
row = sheet_data.rows[r]
next if row.nil?
row.cells.each_with_index { |cell, c|
next if cell.nil?
cell.r = RubyXL::Reference.new(r, c)
}
}
return new_row
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_row(row_index=0)\n validate_workbook\n validate_nonnegative(row_index)\n\n increase_rows(row_index)\n\n @sheet_data.insert(row_index,Array.new(@sheet_data[row_index].size))\n\n row_num = row_index+1\n\n #copy cell styles from row above, (or below if first row)\n @sheet_data[row_inde... | [
"0.77728134",
"0.73713225",
"0.6821091",
"0.6818492",
"0.6501642",
"0.634587",
"0.6271167",
"0.61997044",
"0.60979337",
"0.5912466",
"0.5892402",
"0.5857722",
"0.58378756",
"0.5727148",
"0.56885797",
"0.55677676",
"0.55555385",
"0.5530888",
"0.54023814",
"0.538178",
"0.537955... | 0.7339157 | 2 |
Inserts column at +column_index+, pushes everything right, takes styles from column to left NOTE: use of this method will break formulas which reference cells which are being "pushed right" | def insert_column(column_index = 0)
validate_workbook
ensure_cell_exists(0, column_index)
old_range = cols.get_range(column_index)
#go through each cell in column
sheet_data.rows.each_with_index { |row, row_index|
old_cell = row[column_index]
c = nil
if old_cell && old_cell.style_index != 0 &&
old_range && old_range.style_index != old_cell.style_index then
c = RubyXL::Cell.new(:style_index => old_cell.style_index, :worksheet => self,
:row => row_index, :column => column_index,
:datatype => RubyXL::DataType::SHARED_STRING)
end
row.insert_cell_shift_right(c, column_index)
}
cols.insert_column(column_index)
# TODO: update column numbers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_column(col_index=0)\n validate_workbook\n validate_nonnegative(col_index)\n increase_columns(col_index)\n\n old_index = col_index > 0 ? col_index-1 : col_index+1\n old_col = @cols[get_cols_index(old_index)]\n if old_index == 1\n old_col = nil\n end\n\n #go through each cell ... | [
"0.7456166",
"0.7036691",
"0.59061456",
"0.59035003",
"0.5833103",
"0.5710718",
"0.5678746",
"0.5587918",
"0.55842537",
"0.55572724",
"0.5536212",
"0.5529086",
"0.5527865",
"0.5526873",
"0.5511202",
"0.54889226",
"0.5446902",
"0.5417679",
"0.5413551",
"0.5408778",
"0.5407602"... | 0.6948869 | 2 |
Get raw column width value as stored in the file | def get_column_width_raw(column_index = 0)
validate_workbook
validate_nonnegative(column_index)
range = cols.locate_range(column_index)
range && range.width
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def column_width\n return @column_width\n end",
"def width\n @column_widths.inject(0) { |s,r| s + r }\n end",
"def width\n @columns * @block_size\n end",
"def width\n metadata[:width] if valid?\n end",
"def width\r\n assert_exists\r\n return @o.i... | [
"0.71662885",
"0.70062655",
"0.68812126",
"0.6791667",
"0.6709167",
"0.67076576",
"0.66874766",
"0.6671525",
"0.66001284",
"0.65530646",
"0.6510749",
"0.6504935",
"0.64883566",
"0.6456142",
"0.6432641",
"0.6432641",
"0.6424143",
"0.6420093",
"0.64200306",
"0.6419416",
"0.6390... | 0.72390014 | 0 |
Get column width measured in number of digits, as per | def get_column_width(column_index = 0)
width = get_column_width_raw(column_index)
return RubyXL::ColumnRange::DEFAULT_WIDTH if width.nil?
(width - (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)).round
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def width\n @column_widths.inject(0) { |s,r| s + r }\n end",
"def column_width\n column_headings.values.collect {|l| l.to_s.length}.max + 2\n end",
"def column_width\n return @column_width\n end",
"def width\n begin\n (@num_cols.to_i) * (@col_width.t... | [
"0.8538969",
"0.83671516",
"0.8016057",
"0.7992989",
"0.79792637",
"0.7836938",
"0.762777",
"0.7625645",
"0.7590127",
"0.75601715",
"0.75453126",
"0.7534604",
"0.7534162",
"0.7403343",
"0.73857796",
"0.7327247",
"0.7291546",
"0.72057295",
"0.70836806",
"0.70370877",
"0.703220... | 0.73232603 | 16 |
Set raw column width value | def change_column_width_raw(column_index, width)
validate_workbook
ensure_cell_exists(0, column_index)
range = cols.get_range(column_index)
range.width = width
range.custom_width = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def column_width=(value)\n @column_width = value\n end",
"def change_column_width_raw(column_index, width)\n validate_workbook\n ensure_cell_exists(0, column_index)\n range = cols.get_range(column_index)\n range.width = width\n range.custom_width = true\n end",
"def wi... | [
"0.82118237",
"0.7760171",
"0.7335848",
"0.70408607",
"0.6981075",
"0.69714606",
"0.69631803",
"0.69631803",
"0.6905924",
"0.6892913",
"0.684795",
"0.68434346",
"0.6815215",
"0.6811709",
"0.6811709",
"0.6789892",
"0.6782631",
"0.67724526",
"0.67724526",
"0.6741233",
"0.673939... | 0.77122563 | 2 |
Get column width measured in number of digits, as per | def change_column_width(column_index, width_in_chars = RubyXL::ColumnRange::DEFAULT_WIDTH)
change_column_width_raw(column_index, ((width_in_chars + (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)) * 256).to_i / 256.0)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def width\n @column_widths.inject(0) { |s,r| s + r }\n end",
"def column_width\n column_headings.values.collect {|l| l.to_s.length}.max + 2\n end",
"def column_width\n return @column_width\n end",
"def width\n begin\n (@num_cols.to_i) * (@col_width.t... | [
"0.8538969",
"0.83671516",
"0.8016057",
"0.7992989",
"0.79792637",
"0.7836938",
"0.762777",
"0.7625645",
"0.7590127",
"0.75601715",
"0.75453126",
"0.7534604",
"0.7534162",
"0.7403343",
"0.73857796",
"0.7327247",
"0.73232603",
"0.7291546",
"0.72057295",
"0.70836806",
"0.703708... | 0.0 | -1 |
Helper method to get the style index for a column | def get_col_style(column_index)
range = cols.locate_range(column_index)
(range && range.style_index) || 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_col_style(column_index)\n range = cols.locate_range(column_index)\n (range && range.style_index) || 0\n end",
"def get_col_style(col)\n i = get_cols_index(col)\n if @cols[i].nil?\n @workbook.fonts['0'][:count] += 1\n return 0\n else\n return Integer(@cols[i][:attributes][:s... | [
"0.84076685",
"0.74073434",
"0.6766498",
"0.6570552",
"0.65280926",
"0.6457088",
"0.64526653",
"0.6422292",
"0.6404371",
"0.6251131",
"0.62388444",
"0.6232812",
"0.61847985",
"0.61167014",
"0.610176",
"0.60612184",
"0.6059679",
"0.6050912",
"0.6019696",
"0.59665334",
"0.59554... | 0.8339601 | 1 |
Helper method to update the row styles array change_type NAME or SIZE or COLOR etc main method to change font, called from each separate font mutator method | def change_row_font(row_index, change_type, arg, font)
validate_workbook
ensure_cell_exists(row_index)
xf = workbook.register_new_font(font, get_row_xf(row_index))
row = sheet_data[row_index]
row.style_index = workbook.register_new_xf(xf)
row.cells.each { |c| c.font_switch(change_type, arg) unless c.nil? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_row_font(row, change_type, arg, font, xf_id)\n validate_workbook\n validate_nonnegative(row)\n increase_rows(row)\n\n # Modify font array and retrieve new font id\n font_id = modify_font(@workbook, font, xf_id[:fontId].to_s)\n # Get copy of xf object with modified font id\n xf = dee... | [
"0.81528986",
"0.777216",
"0.71433884",
"0.71403795",
"0.71403795",
"0.70109606",
"0.69861317",
"0.69000655",
"0.688968",
"0.68635523",
"0.6840403",
"0.67529863",
"0.67448753",
"0.67448753",
"0.66979074",
"0.6432949",
"0.6309624",
"0.6215985",
"0.62131596",
"0.6140738",
"0.60... | 0.77753985 | 1 |
Helper method to update the fonts and cell styles array main method to change font, called from each separate font mutator method | def change_column_font(column_index, change_type, arg, font, xf)
validate_workbook
ensure_cell_exists(0, column_index)
xf = workbook.register_new_font(font, xf)
cols.get_range(column_index).style_index = workbook.register_new_xf(xf)
sheet_data.rows.each { |row|
c = row && row[column_index]
c.font_switch(change_type, arg) unless c.nil?
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_font_references(modified_font)\n xf = workbook.register_new_font(modified_font, get_cell_xf)\n self.style_index = workbook.register_new_xf(xf)\n end",
"def update_font_references(modified_font)\n xf = workbook.register_new_font(modified_font, get_cell_xf)\n self.style_index = wo... | [
"0.76473373",
"0.76473373",
"0.7472112",
"0.72790885",
"0.7174665",
"0.70401967",
"0.69972926",
"0.69875807",
"0.6777651",
"0.67595017",
"0.66546714",
"0.66544145",
"0.66544145",
"0.66344523",
"0.6599408",
"0.6513397",
"0.64952385",
"0.6485382",
"0.64818585",
"0.64818585",
"0... | 0.6796224 | 8 |
Merges cells within a rectangular area | def merge_cells(start_row, start_col, end_row, end_col)
validate_workbook
self.merged_cells ||= RubyXL::MergedCells.new
# TODO: add validation to make sure ranges are not intersecting with existing ones
merged_cells << RubyXL::MergedCell.new(:ref => RubyXL::Reference.new(start_row, end_row, start_col, end_col))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rect(a,b)\n new_cells = a.times.flat_map do |x|\n b.times.flat_map do |y|\n Cell.new(x,y,@width,@height)\n end\n end\n\n @cells.merge(new_cells)\n end",
"def merge_cells(row1=0,col1=0,row2=0,col2=0)\n validate_workbook\n @merged_cells << {\n :attributes => {\n :re... | [
"0.6700961",
"0.65571266",
"0.6238821",
"0.60323006",
"0.5990784",
"0.59731245",
"0.5920083",
"0.58003664",
"0.5800355",
"0.57871675",
"0.57121533",
"0.56206787",
"0.56206787",
"0.560465",
"0.5599614",
"0.5568948",
"0.5552552",
"0.55465734",
"0.5524695",
"0.5521296",
"0.55002... | 0.63581824 | 2 |
Changes fill color of cell | def change_fill(rgb = 'ffffff')
validate_worksheet
Color.validate_color(rgb)
self.style_index = workbook.modify_fill(self.style_index, rgb)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill(color)\n @style[:fill] = color\n end",
"def fill_color(color)\n end",
"def change_fill(rgb='ffffff')\n validate_worksheet\n Color.validate_color(rgb)\n @style_index = modify_fill(@workbook, @style_index,rgb)\n end",
"def setfillcolorind(*)\n super\n end",
"def ... | [
"0.7817586",
"0.7680768",
"0.7537821",
"0.74548644",
"0.7234923",
"0.7226518",
"0.70177794",
"0.69221914",
"0.68277735",
"0.67624754",
"0.66980034",
"0.6589905",
"0.6563709",
"0.6500531",
"0.64753926",
"0.6473927",
"0.63611907",
"0.63611335",
"0.6320901",
"0.62614584",
"0.620... | 0.75035655 | 3 |
Changes font name of cell | def change_font_name(new_font_name = 'Verdana')
validate_worksheet
font = get_cell_font.dup
font.set_name(new_font_name)
update_font_references(font)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_column_font_name(col=0, font_name='Verdana')\n # Get style object\n xf_id = xf_id(get_col_style(col))\n # Get copy of font object with modified name\n font = deep_copy(@workbook.fonts[xf_id[:fontId].to_s][:font])\n font[:name][:attributes][:val] = font_name.to_s\n # Update font and xf ... | [
"0.81314415",
"0.7896164",
"0.7712866",
"0.77062994",
"0.72959864",
"0.7255562",
"0.71670526",
"0.7110613",
"0.71081805",
"0.6693014",
"0.6693014",
"0.66816",
"0.66816",
"0.66166097",
"0.6615892",
"0.65713406",
"0.65297943",
"0.6436224",
"0.6427392",
"0.6379348",
"0.6362969",... | 0.8321192 | 0 |
Changes font size of cell | def change_font_size(font_size = 10)
validate_worksheet
raise 'Argument must be a number' unless font_size.is_a?(Integer) || font_size.is_a?(Float)
font = get_cell_font.dup
font.set_size(font_size)
update_font_references(font)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_column_font_size(col=0, font_size=10)\n # Get style object\n xf_id = xf_id(get_col_style(col))\n # Get copy of font object with modified size\n font = deep_copy(@workbook.fonts[xf_id[:fontId].to_s][:font])\n font[:sz][:attributes][:val] = font_size\n # Update font and xf array\n cha... | [
"0.77199495",
"0.7712393",
"0.7611653",
"0.71374416",
"0.6978516",
"0.692586",
"0.6728187",
"0.66601753",
"0.66556317",
"0.6619674",
"0.6533546",
"0.6522609",
"0.6501379",
"0.64703393",
"0.64372236",
"0.64372236",
"0.6417534",
"0.6395196",
"0.63928103",
"0.6318056",
"0.626153... | 0.7972899 | 0 |
Changes font color of cell | def change_font_color(font_color = '000000')
validate_worksheet
Color.validate_color(font_color)
font = get_cell_font.dup
font.set_rgb_color(font_color)
update_font_references(font)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_column_font_color(col=0, font_color='000000')\n Color.validate_color(font_color)\n # Get style object\n xf_id = xf_id(get_col_style(col))\n # Get copy of font object with modified color\n font = deep_copy(@workbook.fonts[xf_id[:fontId].to_s][:font])\n font = modify_font_color(font, fon... | [
"0.7461787",
"0.7249745",
"0.72065777",
"0.71350855",
"0.712429",
"0.71065754",
"0.7073131",
"0.7073131",
"0.70110637",
"0.70012754",
"0.6859599",
"0.68218386",
"0.68218386",
"0.6811806",
"0.6794766",
"0.67469627",
"0.6735331",
"0.6648561",
"0.664566",
"0.64648116",
"0.640000... | 0.7695715 | 0 |
Changes font italics settings of cell | def change_font_italics(italicized = false)
validate_worksheet
font = get_cell_font.dup
font.set_italic(italicized)
update_font_references(font)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_font_italics(italicized=false)\n validate_worksheet\n # Get copy of font object with modified italics settings\n font = deep_copy(workbook.fonts[font_id().to_s][:font])\n font = modify_font_italics(font, italicized)\n # Update font and xf array\n change_font(font)\n end"... | [
"0.72236353",
"0.678297",
"0.6767767",
"0.6639636",
"0.6613759",
"0.6494832",
"0.6494832",
"0.64336115",
"0.6389968",
"0.63753814",
"0.63357896",
"0.6335046",
"0.63281983",
"0.63196945",
"0.62855744",
"0.62762696",
"0.62762696",
"0.6264959",
"0.6257875",
"0.6174606",
"0.61452... | 0.78815913 | 0 |
Changes font bold settings of cell | def change_font_bold(bolded = false)
validate_worksheet
font = get_cell_font.dup
font.set_bold(bolded)
update_font_references(font)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bold_cell(options = {}, &block)\n cell({ font_style: :bold }.merge(options || {}), &block)\n end",
"def change_font_bold(bolded=false)\n validate_worksheet\n # Get copy of font object with modified bold settings\n font = deep_copy(workbook.fonts[font_id().to_s][:font])\n font = mo... | [
"0.8035638",
"0.7800186",
"0.73778224",
"0.7356081",
"0.7309667",
"0.70927423",
"0.6959655",
"0.69148815",
"0.6847863",
"0.6847863",
"0.67769545",
"0.67683005",
"0.674681",
"0.674681",
"0.66853034",
"0.66853034",
"0.66616106",
"0.66564745",
"0.6619126",
"0.6587305",
"0.657956... | 0.8302406 | 0 |
Changes font underline settings of cell | def change_font_underline(underlined = false)
validate_worksheet
font = get_cell_font.dup
font.set_underline(underlined)
update_font_references(font)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_font_underline(underlined=false)\n validate_worksheet\n # Get copy of font object with modified underline settings\n font = deep_copy(workbook.fonts[font_id().to_s][:font])\n font = modify_font_underline(font, underlined)\n # Update font and xf array\n change_font(font)\n ... | [
"0.7695589",
"0.7397015",
"0.7152001",
"0.6990113",
"0.66901463",
"0.66901463",
"0.63874716",
"0.637665",
"0.6372925",
"0.6372925",
"0.63182336",
"0.6254913",
"0.61407024",
"0.6133203",
"0.6093899",
"0.60723346",
"0.60723346",
"0.59276927",
"0.58676517",
"0.5845751",
"0.58457... | 0.826207 | 0 |
Helper method to update the font array and xf array | def update_font_references(modified_font)
xf = workbook.register_new_font(modified_font, get_cell_xf)
self.style_index = workbook.register_new_xf(xf)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_fonts # :nodoc:\n fonts = {}\n\n @xf_formats.each { |format| format.set_font_info(fonts) }\n\n @font_count = fonts.size\n\n # For the DXF formats we only need to check if the properties have changed.\n @dxf_formats.each do |format|\n # The only font properties that can c... | [
"0.721714",
"0.71970063",
"0.67808133",
"0.6753224",
"0.65124375",
"0.6366285",
"0.6298438",
"0.6283791",
"0.62599903",
"0.62576646",
"0.61224043",
"0.6081554",
"0.60470194",
"0.6039597",
"0.6025617",
"0.6017465",
"0.60067147",
"0.5992943",
"0.597199",
"0.5971267",
"0.5971267... | 0.69522786 | 2 |
Performs correct modification based on what type of change_type is specified | def font_switch(change_type, arg)
case change_type
when Worksheet::NAME then change_font_name(arg)
when Worksheet::SIZE then change_font_size(arg)
when Worksheet::COLOR then change_font_color(arg)
when Worksheet::ITALICS then change_font_italics(arg)
when Worksheet::BOLD then change_font_bold(arg)
when Worksheet::UNDERLINE then change_font_underline(arg)
when Worksheet::STRIKETHROUGH then change_font_strikethrough(arg)
else raise 'Invalid change_type'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_type=(value)\n @change_type = value\n end",
"def change_type\n return @change_type\n end",
"def change?\n type == 'change'\n end",
"def changeType(newType)\n\t\t\t#remove accessors for old type\n\t\t\tremoveAccessors()\n\t\t\t@type = newT... | [
"0.7415962",
"0.70975107",
"0.65295625",
"0.63964105",
"0.6308899",
"0.62117475",
"0.6207137",
"0.60622466",
"0.6033784",
"0.59838253",
"0.5969564",
"0.59412515",
"0.57860947",
"0.57648253",
"0.5755102",
"0.57204807",
"0.56712013",
"0.5636245",
"0.56282115",
"0.55879545",
"0.... | 0.62650555 | 5 |
Some users may not have this set yet | def ensure_last_signed_in_at_set
return unless current_user.present?
return if current_user.last_signed_in_at.present?
current_user.update last_signed_in_at: current_user.updated_at
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_user_specific?\n false\n end",
"def user_defined?\n !@user.nil? || !@user['userId'].nil?\n end",
"def settings\n\t\tcheck_if_myself\n\t\t@user = current_user\n\tend",
"def set_user; end",
"def first_time_user=(value)\n @first_time_user = !!value\n end",
"def check_user_id\n ... | [
"0.6671882",
"0.6390072",
"0.6336448",
"0.6301435",
"0.6270995",
"0.6263012",
"0.6255055",
"0.6175542",
"0.61709267",
"0.61237425",
"0.6068995",
"0.60667264",
"0.6038787",
"0.60378563",
"0.60347223",
"0.6006036",
"0.59983134",
"0.5982156",
"0.5980341",
"0.59708387",
"0.597021... | 0.0 | -1 |
Sign out users that expired, but check each 5min or so | def sign_out_expired_session
return unless current_user.present?
return if current_user.last_sign_in_check.present? && current_user.last_sign_in_check <= 5.minutes.ago
current_user.update last_sign_in_check: Time.now
if UniversumSsoClient.signed_out?(current_user.uid)
session[:user_id] = nil
@current_user = nil
clear_iris_session
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_expired!\n sessions.remove( { :expire => { '$lt' => Time.now } } )\n end",
"def expire\n touch :expires_at\n\n user.subscriptions.facebook.each do |subscription|\n subscription.deactivate\n end\n\n UserMailer.access_token_expired_email(user).deliver\n end",
"def perf... | [
"0.709647",
"0.6901253",
"0.68786657",
"0.6667334",
"0.64914",
"0.646918",
"0.642632",
"0.63955027",
"0.637446",
"0.637446",
"0.6355509",
"0.6298883",
"0.62933177",
"0.626521",
"0.62438047",
"0.62311155",
"0.6220791",
"0.62164086",
"0.61930686",
"0.6187678",
"0.61816233",
"... | 0.7406081 | 0 |
instantiate car, beginning with an empty cars array, then running ready_go method | def initialize
@cars = []
ready_go
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ready_go\n @cars << Car.new\n @cars << Car.new\n\n @cars.first.accelerate(random_speed)\n @cars.last.accelerate(random_speed)\n end",
"def initialize\n\t\t@cars = Array.new(2) { |i| Car.new }\n\t\t@cars.each { |car| car.accelerate(rand(1..100)) }\n\tend",
"def initialize\n\t\t@@cars_created +=... | [
"0.7600033",
"0.687104",
"0.66208076",
"0.6409292",
"0.6236859",
"0.622376",
"0.5987254",
"0.59474766",
"0.5944182",
"0.5929732",
"0.5876827",
"0.5736802",
"0.5665938",
"0.56465334",
"0.56434804",
"0.56250894",
"0.561246",
"0.5570857",
"0.5555686",
"0.55537194",
"0.5498692",
... | 0.8353904 | 0 |
method runs when race is instantiated; creates 2 new car instances runs accelerate method from Car class on both new cars and sets random speed | def ready_go
@cars << Car.new
@cars << Car.new
@cars.first.accelerate(random_speed)
@cars.last.accelerate(random_speed)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n\t\t@cars = Array.new(2) { |i| Car.new }\n\t\t@cars.each { |car| car.accelerate(rand(1..100)) }\n\tend",
"def accelerate\n @speed = @speed + @accelerator\n end",
"def race; end",
"def race; end",
"def race; end",
"def race; end",
"def race; end",
"def race; end",
"def accelerate... | [
"0.7564324",
"0.63941765",
"0.6352995",
"0.6352995",
"0.6352995",
"0.6352995",
"0.6352995",
"0.6352995",
"0.62272406",
"0.6182051",
"0.6178175",
"0.6166637",
"0.60955286",
"0.60896087",
"0.6033562",
"0.60181546",
"0.6006431",
"0.5977956",
"0.59735227",
"0.5850408",
"0.5843975... | 0.79100513 | 0 |
gets winner by sorting the two cars by speed; car with higher speed will be last and is the winner | def winner
@cars.sort_by(&:speed).last
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loser\n @cars.sort_by(&:speed).first\n end",
"def determine_winner\n @active_players.sort! do |player1, player2|\n if player1.strongest_hand > player2.strongest_hand\n -1\n elsif player1.strongest_hand < player2.strongest_hand\n 1\n else\n 0\n end\n end\nend",
"def winner(s... | [
"0.7321418",
"0.71831596",
"0.67357004",
"0.66314554",
"0.6460764",
"0.6365369",
"0.6320158",
"0.6278198",
"0.6260675",
"0.623123",
"0.61076343",
"0.6069894",
"0.6042041",
"0.59932053",
"0.5979605",
"0.5977265",
"0.5960466",
"0.595597",
"0.5953762",
"0.59519035",
"0.59418917"... | 0.85961664 | 0 |
gets loser by sorting the two cars by speed; car with lower speed will be first and is the loser | def loser
@cars.sort_by(&:speed).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def winner\n @cars.sort_by(&:speed).last\n end",
"def sort_drivers\n @drivers.sort! {|x, y| y.miles_driven <=> x.miles_driven}\n end",
"def cars_sorted_by_price\n @inventory.sort_by { |car| car.total_cost }\n end",
"def sortByDistanceFrom(otherLocation)\n ParkingSpots.new(@_parkingSpots.sort {... | [
"0.73397356",
"0.6214933",
"0.61986405",
"0.5973509",
"0.593515",
"0.5872672",
"0.5830151",
"0.5787065",
"0.5775618",
"0.5654479",
"0.556985",
"0.53686947",
"0.5350722",
"0.5286217",
"0.52636844",
"0.5244282",
"0.5231909",
"0.52247494",
"0.52035016",
"0.52019566",
"0.519644",... | 0.84053016 | 0 |
Wait for the poller thread to finish. | def join
@poller.join if @poller
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait\n @thread.join\n end",
"def wait\n # Here we use a loop-sleep combination instead of using\n # ThreadPoolExecutor's `wait_for_termination`. See issue #21 for more\n # information.\n loop do\n break if @executor.shutdown?\n sleep 0.1\n end\n end",
"def wait... | [
"0.74571145",
"0.7377745",
"0.73485595",
"0.7260831",
"0.72405624",
"0.7181136",
"0.71810913",
"0.71810913",
"0.7121612",
"0.710995",
"0.70700026",
"0.70470744",
"0.7032115",
"0.7021413",
"0.69822943",
"0.69539857",
"0.68975854",
"0.6882598",
"0.68608737",
"0.6858086",
"0.685... | 0.0 | -1 |
Hackish stub: Noah Paessel | def offerings
[]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stubs=(_arg0); end",
"def stub_implementation; end",
"def stubs; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def private; end",
"def hunter_stub\n\tend",
"def spec; end",
"def spec; end",
"def stubbed_params=(_arg0); end",
"def weber; end",
"def ... | [
"0.7181337",
"0.6988685",
"0.69544655",
"0.6822215",
"0.6822215",
"0.6822215",
"0.6822215",
"0.68051285",
"0.66895676",
"0.6655732",
"0.6655732",
"0.65847474",
"0.65661377",
"0.64519495",
"0.64519495",
"0.64519495",
"0.64519495",
"0.64519495",
"0.64519495",
"0.64519495",
"0.6... | 0.0 | -1 |
def self.display_name 'Activity' end | def left_nav_panel_width
300
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name\n # activities have names, so to be consistent ...\n self.title\n end",
"def name\n # activities have names, so to be consistent ...\n self.title\n end",
"def activity_name\n plan.activity.name\n end",
"def kind\n :activity\n end",
"def type_name\n activity_types(true)[sel... | [
"0.8318254",
"0.8318254",
"0.7651418",
"0.7540521",
"0.7509528",
"0.74540603",
"0.74540603",
"0.7407833",
"0.7319619",
"0.7311845",
"0.7307437",
"0.72926927",
"0.7292656",
"0.7283055",
"0.7283055",
"0.7283055",
"0.72351533",
"0.72351533",
"0.719235",
"0.71819127",
"0.71756685... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_supplier
@supplier = Supplier.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def supplier_params
params.require(:supplier).permit(:name, :active, :description, notes_attributes:[:id,:origin,:origin_id,:private,:text,:title,:_destroy],
document_files_attributes:[:description,:id,:title,:file,:origin, :origin_id,:esign,:esign_data,:photo,:photo_date,:photo_description,:_destroy],
contacts_attributes:[:id, :category,:origin, :origin_id,:title,{data:[:address,:zipcode,:zipcode,:state,:lat,:lng,:city,:email, :ddd,:phone]},:_destroy])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
Returns an adjacent enemy with the lowest HP and in reading order. | def find_adjacent_enemy(unit)
neighbors(unit.pos)
.map { |p| @units.find { |u| u.pos == p } }
.select { |u| u&.alive? && u.type != unit.type }
.min_by { |u| [u.hp, u.pos] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next_free_enemy(event_id)\n i = 1\n while i < $Enemies.length \n if !$Enemies[i].active\n $Enemies[i].set_id(event_id)\n $Enemies[i].set_active\n $Enemies[i].set_map_id\n return i\n break\n end\n i += 1 \n end\n end",
"def enemy_attack... | [
"0.5935563",
"0.5862665",
"0.5827971",
"0.5814727",
"0.5625451",
"0.5602667",
"0.5598812",
"0.55414605",
"0.5518041",
"0.54982936",
"0.54871815",
"0.54761016",
"0.5450481",
"0.5411065",
"0.5398956",
"0.53613365",
"0.5348235",
"0.534339",
"0.5309293",
"0.5302371",
"0.5261282",... | 0.6385588 | 0 |
Returns all unoccupied cells adjacent to any enemy units. | def find_destinations(unit)
@units
.select { |u| u.alive? && u.type != unit.type }
.flat_map { |u| neighbors(u.pos).to_a }
.reject { |p| occupied?(p) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_adjacent_enemy(unit)\n neighbors(unit.pos)\n .map { |p| @units.find { |u| u.pos == p } }\n .select { |u| u&.alive? && u.type != unit.type }\n .min_by { |u| [u.hp, u.pos] }\n end",
"def nearby_dead_cells(live_cells)\n live_cells.map { |p| neighborhood(p) }.reduce(:|) - live_cells\nend... | [
"0.7447935",
"0.69975096",
"0.692523",
"0.6865361",
"0.6865361",
"0.68157977",
"0.66270554",
"0.6532827",
"0.6495445",
"0.6459816",
"0.64525163",
"0.64149356",
"0.637686",
"0.63372386",
"0.6317639",
"0.6266547",
"0.6243248",
"0.6235778",
"0.62256867",
"0.6197037",
"0.6154198"... | 0.6336466 | 14 |
Returns the shortest path from src to one of the destinations. If there are multiple shortest paths, e.g. A>B has the same length as A>C, returns all of them. | def shortest_paths(src, destinations)
return [] if destinations.empty?
paths = []
visited = Set.new([src])
queue = Containers::MinHeap.new
queue.push([1, [src]])
until queue.empty?
_, path = queue.pop
# Not going to find shorter paths than current best, return.
break if paths.any? && paths[0].size < path.size
cur = path.last
paths << path if destinations.include?(cur)
neighbors(cur).each do |pos|
next if visited.include?(pos) || occupied?(pos)
visited.add(pos)
new_path = Array.new(path.size) { |i| path[i].dup }
new_path << pos
queue.push([new_path.size, new_path])
end
end
paths
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shortest_paths(source, dest)\n\t\t\t@source = source\n\t\t\tdijkstra source\n\t\t\tprint_path dest\n\t\t\treturn @distance[dest]\n\t\tend",
"def shortest_way(source, dest)\n\t\t@source = source\n dijkstra source\n \n if @distances[dest] != @infinity\n return @distances[dest]\n... | [
"0.7356156",
"0.72956985",
"0.7255069",
"0.7244874",
"0.7243841",
"0.7241848",
"0.7071049",
"0.69669163",
"0.6962118",
"0.6934361",
"0.6930844",
"0.6899296",
"0.68192947",
"0.68038255",
"0.6680243",
"0.6653647",
"0.65617514",
"0.65464807",
"0.6481064",
"0.64776665",
"0.646606... | 0.804517 | 0 |
The introspection system is prepared with a bunch of LateBoundTypes. Replace those with the objects that they refer to, since LateBoundTypes aren't handled at runtime. | def resolve_late_bindings
@types.each do |name, t|
if t.kind.fields?
t.fields.each do |_name, field_defn|
field_defn.type = resolve_late_binding(field_defn.type)
end
end
end
@entry_point_fields.each do |name, f|
f.type = resolve_late_binding(f.type)
end
@dynamic_fields.each do |name, f|
f.type = resolve_late_binding(f.type)
end
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_late_bound_types_with_built_in(types)\n GraphQL::Schema::BUILT_IN_TYPES.each do |scalar_name, built_in_scalar|\n existing_type = types[scalar_name]\n if existing_type.is_a?(GraphQL::Schema::LateBoundType)\n types[scalar_name] = built_in_scalar\n en... | [
"0.6899712",
"0.6023782",
"0.58795905",
"0.5839059",
"0.5776291",
"0.55884314",
"0.55273604",
"0.5485643",
"0.5435414",
"0.54223526",
"0.5421705",
"0.5408585",
"0.54031736",
"0.5332975",
"0.5289836",
"0.5289836",
"0.52734077",
"0.52734077",
"0.526387",
"0.5257885",
"0.5248008... | 0.6422491 | 1 |
This is probably not 100% robust but it has to be good enough to avoid modifying the builtin introspection types | def dup_type_class(type_class)
type_name = type_class.graphql_name
Class.new(type_class) do
# This won't be inherited like other things will
graphql_name(type_name)
if type_class.kind.fields?
type_class.fields.each do |_name, field_defn|
dup_field = field_defn.dup
dup_field.owner = self
add_field(dup_field)
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def explain_types; end",
"def reflection; end",
"def reflection; end",
"def nonregular_type; end",
"def types; end",
"def types; end",
"def types; end",
"def types; end",
"def types; end",
"def cast_types; end",
"def types(types); end",
"def type(type); end",
"def type_name_resolver; end",
... | [
"0.66166717",
"0.653142",
"0.653142",
"0.6509218",
"0.6285048",
"0.6285048",
"0.6285048",
"0.6285048",
"0.6285048",
"0.6263979",
"0.620563",
"0.61666775",
"0.6089412",
"0.5952076",
"0.5925658",
"0.59113324",
"0.59012777",
"0.58768064",
"0.5873869",
"0.58562684",
"0.585083",
... | 0.0 | -1 |
+++++++ | Field | Type | Null | Key | Default | Extra | +++++++ | ID | int(11) | | PRI | NULL | auto_increment | | Posted | datetime | | MUL | 00000000 00:00:00 | | | AuthorID | varchar(64) | | | | | | LastMod | datetime | | | 00000000 00:00:00 | | | LastModID | varchar(64) | | | | | | Title | varchar(255) | | MUL | | | | Title_html | varchar(255) | | | | | | Body | mediumtext | | | | | | Body_html | mediumtext | | | | | | Excerpt | text | | | | | | Excerpt_html | mediumtext | | | | | | Image | varchar(255) | | | | | | Category1 | varchar(128) | | MUL | | | | Category2 | varchar(128) | | | | | | Annotate | int(2) | | | 0 | | | AnnotateInvite | varchar(255) | | | | | | comments_count | int(8) | | | 0 | | | Status | int(2) | | | 4 | | | textile_body | int(2) | | | 1 | | | textile_excerpt | int(2) | | | 1 | | | Section | varchar(64) | | | | | | override_form | varchar(255) | | | | | | Keywords | varchar(255) | | | | | | url_title | varchar(255) | | | | | | custom_1 | varchar(255) | | | | | | custom_2 | varchar(255) | | | | | | custom_3 | varchar(255) | | | | | | custom_4 | varchar(255) | | | | | | custom_5 | varchar(255) | | | | | | custom_6 | varchar(255) | | | | | | custom_7 | varchar(255) | | | | | | custom_8 | varchar(255) | | | | | | custom_9 | varchar(255) | | | | | | custom_10 | varchar(255) | | | | | | uid | varchar(32) | | | | | | feed_time | date | | | 00000000 | | +++++++ | def to_page
u = User.find_by_login(authorid)
UserActionObserver.current_user = u
page = Page.new(
:title => title,
:created_at => lastmod,
:updated_at => lastmod,
:slug => url_title,
:status => Status[:published],
:breadcrumb => title,
:published_at => posted,
:enable_comments => annotate.to_s,
:keywords => keywords,
:created_by => u,
:updated_by => u
)
page.parts << PagePart.new(:name => 'body', :filter_id => "Textile", :content => body )
page.parts << PagePart.new(:name => 'intro', :filter_id => "Textile", :content => body.split(/\r\n\s*\r\n/).first)
page
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_by_feednormalizer(feed_text)\n feed_data = FeedNormalizer::FeedNormalizer.parse feed_text\n feed_data.entries.map do|e|\n metadata = {:author => e.author} if e.author\n {:did=>(e.id || e.urls.join(\" \")), :title=>e.title,:content=>e.content,:basetime=>e.date_published, \n :metadata=... | [
"0.5454667",
"0.5323727",
"0.5314784",
"0.52584106",
"0.5225491",
"0.5182719",
"0.51600033",
"0.5008293",
"0.50070024",
"0.49621317",
"0.49561638",
"0.495413",
"0.4951283",
"0.49498266",
"0.49483675",
"0.49440122",
"0.49397886",
"0.49390456",
"0.49389663",
"0.49353516",
"0.49... | 0.0 | -1 |
Challenge 2 Calculator Create a simple calculator that first asks the user what method they would like to use (addition, subtraction, multiplication, division) and then asks the user for two numbers, returning the result of the method with the two numbers. Here is a sample prompt: What calculation would you like to do? (add, sub, mult, div) add What is number 1? 3 What is number 2? 6 Your result is 9 | def calculator
#ask user method
puts "What calculation would you like to do? (add, sub, mult, div)"
calc_type = gets.chomp
#ask for first number
puts "What is number 1? where result = num_1 operator num_2"
num_1 = gets.chomp
num_1 = num_1.to_f
#ask for second number
puts "What is number 2?"
num_2 = gets.chomp
num_2 = num_2.to_f
# do calculation using num_1, num_2, calc_type
if calc_type == "add"
result = num_1 + num_2
elsif calc_type == "sub"
result = num_1 - num_2
elsif calc_type == "mult"
result = num_1 * num_2
else
result = num_1.to_f / num_2.to_f
end
#return result
puts "#{result}"
return result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculator()\n\n\tputs \"What kind of operation would you like to do - addition, substraction, multiplication, division\"\n\tchoice = gets.chomp\n\n\tputs \"What is number 1\"\n\tnum_1 = gets.chomp.to_f\n\n\tputs \"What is number 2\"\n\tnum_2 = gets.chomp.to_f\n\n\tcase choice\n\t\twhen \"addition\"\n\t\t\ttot... | [
"0.8001223",
"0.7889607",
"0.78600824",
"0.781014",
"0.7805129",
"0.7786566",
"0.7779403",
"0.7767423",
"0.7731978",
"0.7592265",
"0.7579605",
"0.7567149",
"0.7562794",
"0.7539188",
"0.7488816",
"0.74720186",
"0.73925084",
"0.7382979",
"0.7375263",
"0.73715585",
"0.7370982",
... | 0.797191 | 1 |
GET /subjects/1 GET /subjects/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @subject = Subject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subject }\n end\n end",
"def get_subjects\n if params[:c].present?\n sc_id = params[:c].to_i\n subjects = Subject.joins(:school_cycle_has_subject... | [
"0.7462031",
"0.73371226",
"0.73158705",
"0.7303327",
"0.7293112",
"0.7209648",
"0.7203975",
"0.7081049",
"0.70791173",
"0.70585805",
"0.70382094",
"0.7033256",
"0.7022359",
"0.7022359",
"0.70181674",
"0.6998612",
"0.69974196",
"0.68754363",
"0.685901",
"0.6858203",
"0.684328... | 0.0 | -1 |
POST /subjects POST /subjects.json | def create
subject_params[:name].each do |subject_name|
if (subject_name != "")
subject = Subject.find_or_create_by(name: subject_name)
Mark.find_or_create_by(notenplan_id: session[:notenplan_id], subject: subject)
end
end
notenplan = Notenplan.find_by(id: session[:notenplan_id])
redirect_to notenplan, notice: 'Das Fach wurde erfolgreich erstellt.'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @subject = Subject.new(params[:subject])\n\n respond_to do |format|\n if @subject.save\n format.html { redirect_to :subjects, :notice => 'Subject was successfully created.' }\n format.json { render :json => @subject, :status => :created, :location => @subject }\n else\n ... | [
"0.7093269",
"0.70017576",
"0.6920761",
"0.6879977",
"0.68733424",
"0.68470126",
"0.68272763",
"0.6759715",
"0.67476565",
"0.6704417",
"0.6680183",
"0.6653926",
"0.66498274",
"0.6640361",
"0.65838623",
"0.6575236",
"0.6574849",
"0.65735793",
"0.6570703",
"0.65252584",
"0.6524... | 0.0 | -1 |
PATCH/PUT /subjects/1 PATCH/PUT /subjects/1.json | def update
respond_to do |format|
if @subject.update(subject_params)
format.html { redirect_to @subject, notice: 'Das Fach wurde erfolgreich geändert.' }
format.json { render :show, status: :ok, location: @subject }
else
format.html { render :edit }
format.json { render json: @subject.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @subject = Subject.find(params[:id])\n\n respond_to do |format|\n if @subject.update_attributes(params[:subject])\n\n format.html { redirect_to subjects_url, :notice => 'Subject was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { ... | [
"0.7399212",
"0.7341869",
"0.72854865",
"0.712811",
"0.7044038",
"0.70004374",
"0.70004374",
"0.6995105",
"0.6978002",
"0.68667805",
"0.68179256",
"0.6792362",
"0.67713135",
"0.675009",
"0.6706549",
"0.66950065",
"0.6676277",
"0.66413474",
"0.66335547",
"0.6615197",
"0.658661... | 0.6620601 | 19 |
DELETE /subjects/1 DELETE /subjects/1.json | def destroy
@subject.destroy
respond_to do |format|
format.html { redirect_to subjects_url, notice: 'Das Fach wurde erfolgreich gelöscht.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @subject = Subject.find(params[:id])\n @subject.destroy\n\n respond_to do |format|\n format.html { redirect_to subjects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subject = Subject.find(params[:id])\n @subject.destroy\n\n respond_to do |fo... | [
"0.79004234",
"0.79000086",
"0.7851459",
"0.7812474",
"0.7791248",
"0.77289444",
"0.76450217",
"0.7632434",
"0.75925595",
"0.75750107",
"0.756666",
"0.7557011",
"0.75504565",
"0.7544504",
"0.75402933",
"0.75402933",
"0.75240225",
"0.7490376",
"0.7464556",
"0.7410753",
"0.7399... | 0.75413173 | 14 |
Use callbacks to share common setup or constraints between actions. | def set_subject
@subject = Subject.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def subject_params
params.require(:subject).permit(:number,:name => [])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Override this method so that Rails uses :ssn in routes instead of :id | def to_param
ssn
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ssn\n legacy_ssn\n end",
"def ssn\n # converts '123-45-6789' to 'xxx-xx-6789'\n 'xxx-xx-' + @ssn.split(\"-\").last\nend",
"def ssn\n # converts '123-45-6789' to 'xxx-xx-6789'\n 'xxx-xx-' + @ssn.split('-').last\nend",
"def ssn\n #converts '123-45-6789' to 'xxx-xx-6789'\n 'xxx-xx-x' + @ssn.split(... | [
"0.70171565",
"0.6557037",
"0.65499616",
"0.64264876",
"0.60873747",
"0.58631855",
"0.5850509",
"0.5815213",
"0.5753406",
"0.57305574",
"0.564014",
"0.55743694",
"0.55556226",
"0.555367",
"0.553803",
"0.55286986",
"0.5518139",
"0.5518139",
"0.5518139",
"0.5512503",
"0.55113",... | 0.67526466 | 1 |
Returns proper gender string | def gender_displayname
gender == MALE[:value] ? MALE[:display_name] : FEMALE[:display_name]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_gender\n return gender == 'f' ? \"female\" : \"male\"\n end",
"def gender_name\n case gender\n when 'm'\n 'male'\n when 'f'\n 'female'\n else\n ''\n end\n end",
"def fullgender\n\t\tcase gender\n\t\t\twhen 'F': 'female'\n\t\t\twhen 'M': 'male'\n\t\t\tel... | [
"0.8700179",
"0.8634686",
"0.8435832",
"0.8335108",
"0.81167954",
"0.80847424",
"0.8011789",
"0.7778357",
"0.7750152",
"0.77337664",
"0.76417285",
"0.76374507",
"0.75962657",
"0.75949854",
"0.75492257",
"0.7541535",
"0.75397366",
"0.7528571",
"0.7513674",
"0.7512521",
"0.7485... | 0.7952188 | 7 |
GET /rounds GET /rounds.json | def index
@rounds = Round.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_rounds\n\t\t@rounds = @participant.rounds\n\t\trender json: @rounds\n\tend",
"def rounds\n @title = \"My Rounds\"\n\n puts '====================== rounds'\n\n @user = User.find(params[:id])\n #@rounds = @user.rounds.where(complete: 'Y').paginate(page: params[:page], :per_page => 50)\n #@r... | [
"0.8179578",
"0.7138636",
"0.7110566",
"0.69381267",
"0.69308823",
"0.69218105",
"0.6695108",
"0.6681436",
"0.66559047",
"0.6504946",
"0.6480924",
"0.6423685",
"0.64184344",
"0.6388241",
"0.6317415",
"0.6298387",
"0.6298288",
"0.62912875",
"0.6209922",
"0.61707854",
"0.611569... | 0.7259982 | 5 |
GET /rounds/1 GET /rounds/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_rounds\n\t\t@rounds = @participant.rounds\n\t\trender json: @rounds\n\tend",
"def show\n @game = Game.where(user_id: current_user.id).find(params[:game_id])\n @round = @game.rounds.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: ... | [
"0.7735423",
"0.7122611",
"0.6970371",
"0.6970371",
"0.6970371",
"0.6970371",
"0.6970371",
"0.6970371",
"0.6970371",
"0.69027627",
"0.689435",
"0.6834668",
"0.68254834",
"0.6753524",
"0.6745448",
"0.66504645",
"0.6631633",
"0.65709615",
"0.65156215",
"0.64609367",
"0.6414302"... | 0.0 | -1 |
POST /rounds POST /rounds.json | def create
@round = Round.new(round_params['round'])
respond_to do |format|
if @round.save
@round.create_matches
update_parents(@round)
format.html { redirect_to @round, notice: 'Round was successfully created.' }
format.json { render :show, status: :created, location: @round }
else
format.html { render :new }
format.json { render json: @round.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_rounds\n Round.create_rounds(id)\n\n\n end",
"def create_rounds\n Round.create_rounds(id)\n\n\n end",
"def create\n @round = @tournament.rounds.build(round_params)\n\n respond_to do |format|\n if @round.save\n format.html do redirect_to @round, notice: 'Round was successful... | [
"0.7104489",
"0.7104489",
"0.70039594",
"0.6991256",
"0.6908583",
"0.6889093",
"0.68323505",
"0.6823776",
"0.6803231",
"0.6674662",
"0.66656566",
"0.65715724",
"0.6561143",
"0.65382886",
"0.64882076",
"0.6380548",
"0.63772136",
"0.63772136",
"0.63759726",
"0.6367244",
"0.6356... | 0.68040234 | 8 |
PATCH/PUT /rounds/1 PATCH/PUT /rounds/1.json | def update
respond_to do |format|
if @round.update_from_json(round_params['round'])
update_parents(@round)
format.html { redirect_to @round, notice: 'Round was successfully updated.' }
format.json { render json: @round.errors, status: :unprocessable_entity }
else
format.html { render :edit }
format.json { render json: @round.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @game = Game.where(user_id: current_user.id).find(params[:game_id])\n @round = @game.rounds.find(params[:id])\n\n respond_to do |format|\n if @round.update_attributes(params[:round])\n format.html { redirect_to @round, notice: 'Round was successfully updated.' }\n format.js... | [
"0.7072058",
"0.703137",
"0.68509346",
"0.6767903",
"0.6767903",
"0.6712788",
"0.6678458",
"0.66683185",
"0.6655102",
"0.6655102",
"0.6627183",
"0.66132647",
"0.65992844",
"0.6535786",
"0.63719124",
"0.6328629",
"0.6312666",
"0.61335635",
"0.61317116",
"0.61029226",
"0.605751... | 0.68880683 | 2 |
DELETE /rounds/1 DELETE /rounds/1.json | def destroy
@round.destroy
respond_to do |format|
format.html { redirect_to rounds_url, notice: 'round was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @round = Round.find(params[:id])\n @round.destroy\n\n respond_to do |format|\n format.html { redirect_to rounds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @round = Round.find(params[:id])\n @round.destroy\n\n respond_to do |format|\n f... | [
"0.76205236",
"0.76205236",
"0.76205236",
"0.7431568",
"0.7431568",
"0.7430822",
"0.7422256",
"0.72982204",
"0.72982204",
"0.72982204",
"0.72982204",
"0.7291912",
"0.72139317",
"0.7098678",
"0.69999164",
"0.6967715",
"0.6926577",
"0.69074655",
"0.68914616",
"0.68591595",
"0.6... | 0.72501194 | 12 |
Use callbacks to share common setup or constraints between actions. | def set_round
@round = Round.find(params[:id])
rescue ActiveRecord::RecordNotFound
render(:file => File.join(Rails.root, 'public/404.html'), :status => 404, :layout => false)
# handle not found error
rescue ActiveRecord::ActiveRecordError
render(:file => File.join(Rails.root, 'public/404.html'), :status => 404, :layout => false)
# handle other ActiveRecord errors
rescue StandardError
render(:file => File.join(Rails.root, 'public/404.html'), :status => 404, :layout => false)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def round_params
params.permit(:id, round:
[:roundtype_id, :round_number, :matches, :match_number]
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Link to kata: Description: Fix the code to make the items multiply. Answer: | def multiply(a, b)
a * b
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multiplies (*args)\n multi=1\n args.each do |item|\n multi *=item\n end\n multi\nend",
"def update_quality(items)\n items.each do |item|\n if is_special_item?(item)\n special_item(item)\n else\n item.sell_in > 0 ? decrement_normal_item(item, 1) : decrement_normal_item(item... | [
"0.65178484",
"0.6494396",
"0.62481374",
"0.6236508",
"0.62247133",
"0.6130931",
"0.61269057",
"0.60916394",
"0.60824734",
"0.6077863",
"0.60608226",
"0.60437316",
"0.6039011",
"0.60229564",
"0.6014245",
"0.5979744",
"0.5973772",
"0.5969177",
"0.5951408",
"0.5922475",
"0.5903... | 0.0 | -1 |
GENERATE A UNIQUE URL FOR GIVEN WEB ADDRESS BEFORE SAVING INTO DATABASE | def generate_short_url
url = ([*('a'..'z'),*('0'..'9')]).sample(UNIQUE_ID_LENGTH).join
old_url = ShortenedUrl.where(short_url: url).last
if old_url.present?
self.generate_short_url
else
self.short_url = url
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_url_name\n self.url_name ||=\n Base32.encode(SecureRandom.random_bytes(16)).downcase.sub(/=*$/, '')\n end",
"def generate_url_name\n self.url_name ||=\n Base32.encode(SecureRandom.random_bytes(16)).downcase.sub(/=*$/, '')\n end",
"def generate_unique_key\n\n # @TODO:need t... | [
"0.74512017",
"0.74512017",
"0.706487",
"0.70526636",
"0.6978883",
"0.6952801",
"0.6898779",
"0.6846092",
"0.683331",
"0.68292123",
"0.67476964",
"0.6738983",
"0.6736827",
"0.6705547",
"0.66989446",
"0.66934663",
"0.6665449",
"0.66541463",
"0.66531956",
"0.6548055",
"0.652662... | 0.6829834 | 9 |
CHECK IF ANY URL URL EXIST BEFORE SAVING INTO DATABASE | def find_duplicate
ShortenedUrl.find_by_sanitize_url(self.sanitize_url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exists?(url)\n return @store.has_key?(sanitise(url))\n end",
"def url_exists?(url)\n doc = @db[LINKS_COLLECTION_NAME].find_one('_id' => hash_url(url))\n doc.nil? == false\n end",
"def is_unknown_url? url\n @urls.count_documents(url:url) == 0\n end",
"def url?(url_hash)\n @@db.clie... | [
"0.694109",
"0.68834794",
"0.6843072",
"0.68170565",
"0.6689737",
"0.66301644",
"0.6571512",
"0.65411186",
"0.6455866",
"0.6453648",
"0.6438132",
"0.6419349",
"0.6418165",
"0.6392155",
"0.638497",
"0.637657",
"0.635905",
"0.6345422",
"0.63445497",
"0.6301218",
"0.62794805",
... | 0.0 | -1 |
SANITIZE THE USER GIVEN URL | def sanitize
self.original_url.strip!
self.sanitize_url = self.original_url.downcase.gsub(/(https?:\/\/)|(www\.)/, "")
self.sanitize_url = "http://#{self.sanitize_url}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize_url(str); end",
"def sanitize_url(url)\n url.gsub(%r{^https?://}, '').split('/').map {|u| CGI.escape(u) }.join('/')\n end",
"def sanitise(url)\n if url and m = url.match(/(\\w+)(:\\/*)([\\w\\.\\-].*)(\\/?.*)?/)\n clean_url = m.captures[0].downcase + m.captures[1] + m.captures[2].downca... | [
"0.83593374",
"0.79133815",
"0.77530813",
"0.76079863",
"0.7502041",
"0.739769",
"0.736596",
"0.7350331",
"0.7328615",
"0.72960794",
"0.72693604",
"0.72406995",
"0.7229166",
"0.71716213",
"0.7146208",
"0.71046895",
"0.70758563",
"0.7051779",
"0.7004767",
"0.69788677",
"0.6972... | 0.76592577 | 3 |
Returns triplets of (user, role name, observation) | def triples
requesters, approvers, observers = self.partitioned_roles
requesters = requesters.map { |r| [r.user, "Requester", nil] }
approvers = approvers.map { |r| [r.user, "Approver", nil] }
observers = observers.map { |r| [r.user, nil, self.observation_for(r.user)] }
requesters + approvers + observers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def triples\n requesters, approvers, observers = partitioned_roles\n requesters = requesters.map { |role| [role.user, \"Requester\", nil] }\n approvers = approvers.map { |role| [role.user, \"Approver\", nil] }\n observers = observers.map { |role| [role.user, nil, observation_for(role.user)] }\n\n re... | [
"0.676199",
"0.6488485",
"0.6043295",
"0.5974286",
"0.57820415",
"0.57253885",
"0.57227284",
"0.5720751",
"0.56910586",
"0.5626455",
"0.55749327",
"0.5476261",
"0.5463122",
"0.54611444",
"0.5459242",
"0.54471815",
"0.5431228",
"0.54303086",
"0.5409218",
"0.5409218",
"0.539977... | 0.64294827 | 2 |
sorted by how they should be displayed | def users
self.triples.map(&:first)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_entries; end",
"def sorted_results\n results.sort\n end",
"def order; end",
"def order; end",
"def sorted_labels; end",
"def sort_grosstotal\n BoxOffice::Movie.all.map( &:to_s ).sort {|a,b| b.grosstotal <=> a.grosstotal}.each.with_index(1) do |movie, index|\n puts \"#{movie.title}\"\... | [
"0.7500476",
"0.67306125",
"0.6548514",
"0.6548514",
"0.6542732",
"0.6497985",
"0.64924777",
"0.6478237",
"0.647098",
"0.6447001",
"0.6389402",
"0.63578457",
"0.635687",
"0.63364875",
"0.6334968",
"0.63329184",
"0.63181424",
"0.6294718",
"0.6284526",
"0.6275978",
"0.627442",
... | 0.0 | -1 |
Generate url that will redirect user to OAuth Dialogue. The canvas url should start by https:// and end with a slash. If you're building an facebook app, the canvas_url should be something like | def dialogue_url
return "https://www.facebook.com/dialog/oauth?client_id="+@app_id+"&redirect_uri="+@canvas_url+"&scope="+@permission
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def oauth_url\n url = <<-URL\n https://www.facebook.com/dialog/oauth/\n ?client_id=#{Network::Facebook.app_id}\n &redirect_uri=#{URI.escape(\"#{root_url}auth/facebook/?r=#{redirect_for(request.referer)}\")}\n &scope=#{Network::Facebook.scope}\n URL\n url.gsub(/\\s+/, '')\n end",
"de... | [
"0.77673143",
"0.7463259",
"0.73362935",
"0.727917",
"0.72202975",
"0.72021705",
"0.7188308",
"0.71678716",
"0.7117492",
"0.7117399",
"0.6944495",
"0.68771803",
"0.68126243",
"0.6753707",
"0.67356294",
"0.67098683",
"0.667351",
"0.6668717",
"0.6666714",
"0.66426975",
"0.66381... | 0.77077496 | 1 |
This will fetch the access_token given the code from the call_back of dialog_url | def access_token(code)
token_url = "https://graph.facebook.com/oauth/access_token?client_id="+@app_id+"&redirect_uri="+canvas_url+"&client_secret="+app_secret+"&code="+code
uri = URI.parse(URI.encode(token_url))
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
access_token = response.body
if access_token.index('{')==0
return nil
else
return access_token[13...access_token.length]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_access_token(code)\n @code = code\n @access_token ||= client.web_server.get_access_token( @code, :redirect_uri => callback_url)\n end",
"def get_token(code)\n option = {\n url: \"#{self.bot_origin}/oauth/token\",\n header: {\n \"Content-Type\": \"application/x-www... | [
"0.73680073",
"0.7310669",
"0.7187481",
"0.7172382",
"0.70974505",
"0.7043064",
"0.70424473",
"0.7003236",
"0.69842917",
"0.69842917",
"0.6973421",
"0.69657344",
"0.6884683",
"0.6882332",
"0.686407",
"0.6857548",
"0.68495405",
"0.68486476",
"0.6839015",
"0.6832812",
"0.679031... | 0.7041028 | 7 |
This will return some basic information of user | def userinfo(access_token)
querystr = "https://graph.facebook.com/me?access_token="+access_token
uri = URI.parse(URI.encode(querystr))
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
result = JSON.parse(response.body)
myinfo = {}
if result['name']
myinfo['name']=result['name']
myinfo['fbid']=result['id']
end
return myinfo
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_info\n response = from_server \"api/user.json\"\n response.data\n end",
"def get_user_info\n response = send_method(:get_user_info)\n user_from(response)\n end",
"def user_info\n\t\t\"name: #{name} \\n\"+\n\t\t\"email: #{email}\"\n\t\t\t\n\tend",
"def user_information\n ... | [
"0.8155738",
"0.8115469",
"0.810809",
"0.80705",
"0.79508626",
"0.7873232",
"0.7821335",
"0.77958405",
"0.77396715",
"0.77396715",
"0.7724438",
"0.76914585",
"0.7669007",
"0.7665276",
"0.76614237",
"0.765466",
"0.7627734",
"0.76034355",
"0.7579901",
"0.7551654",
"0.7543774",
... | 0.0 | -1 |
Cookbook Name:: openvnet Provider:: security_group Copyright 2015, TIS.inc All rights reserved Do Not Redistribute | def whyrun_supported?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def role_dmtcpsnooze\n $myxp.get_deployed_nodes('capi5k-init')\nend",
"def dcv_package\n \"nice-dcv-#{node['cluster']['dcv']['version']}-#{node['cluster']['base_os']}-#{dcv_url_arch}\"\nend",
"def define_group\n case new_resource.im_install_mode\n when 'admin'\n group = if new_resource.group.nil?\n ... | [
"0.59504247",
"0.5838618",
"0.5395198",
"0.5395198",
"0.5278193",
"0.52739584",
"0.52202475",
"0.52176625",
"0.52145195",
"0.52133954",
"0.5196774",
"0.5170964",
"0.5165706",
"0.51428854",
"0.51387364",
"0.5130683",
"0.512563",
"0.51101947",
"0.5109559",
"0.5105774",
"0.50844... | 0.0 | -1 |
GET /donation_record/actual_funds GET /donation_record/actual_funds.json | def index
@donation_record_actual_funds = DonationRecord::ActualFund.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n render json: @fund\n end",
"def index\n @funds = Fund.all\n\n render json: @funds\n end",
"def show\n @financial_donation = FinancialDonation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @financial_donation }\n ... | [
"0.6596142",
"0.65945756",
"0.63615215",
"0.6305707",
"0.6161346",
"0.61455595",
"0.61093575",
"0.60901374",
"0.6036757",
"0.60334677",
"0.6016985",
"0.6011211",
"0.5970263",
"0.59364307",
"0.5925354",
"0.58733046",
"0.5871314",
"0.58607954",
"0.585958",
"0.5850797",
"0.58495... | 0.7299994 | 0 |
GET /donation_record/actual_funds/1 GET /donation_record/actual_funds/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @donation_record_actual_funds = DonationRecord::ActualFund.all\n end",
"def show\n render json: @fund\n end",
"def show\n @fund = Fund.friendly.find(params[:id])\n\n render json: @fund\n end",
"def show\n @financial_donation = FinancialDonation.find(params[:id])\n\n ... | [
"0.7115516",
"0.6438892",
"0.64249253",
"0.64232653",
"0.6356215",
"0.62784916",
"0.6220401",
"0.62022436",
"0.613931",
"0.61367625",
"0.5972391",
"0.59632015",
"0.5940923",
"0.5934489",
"0.5919073",
"0.58974665",
"0.5890648",
"0.58894664",
"0.5885648",
"0.5877508",
"0.587208... | 0.0 | -1 |
POST /donation_record/actual_funds POST /donation_record/actual_funds.json | def create
# raise donation_record_actual_fund_params.inspect
@donation_record_actual_fund = DonationRecord::ActualFund.new(donation_record_actual_fund_params)
@donation_record_actual_fund.donation_record = @donation_record
respond_to do |format|
if @donation_record_actual_fund.save
format.html { redirect_to @donation_record }
format.json { render :show, status: :created, location: @donation_record_actual_fund }
else
format.html { render :new }
format.json { render json: @donation_record_actual_fund.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @fund = Fund.new(fund_params)\n\n if @fund.save\n render json: @fund, status: :created, location: @fund\n else\n render json: @fund.errors, status: :unprocessable_entity\n end\n end",
"def donation_record_actual_fund_params\n params.require(:donation_record_actual_fund)\n... | [
"0.65340567",
"0.6393791",
"0.6371374",
"0.6208825",
"0.6162286",
"0.6146011",
"0.61390823",
"0.6119465",
"0.60814506",
"0.6075106",
"0.60108215",
"0.5993477",
"0.5993477",
"0.59488827",
"0.5924591",
"0.5907125",
"0.58687466",
"0.5862193",
"0.5857213",
"0.58563",
"0.5840352",... | 0.70836675 | 0 |
PATCH/PUT /donation_record/actual_funds/1 PATCH/PUT /donation_record/actual_funds/1.json | def update
respond_to do |format|
if @donation_record_actual_fund.update(donation_record_actual_fund_params)
format.html { redirect_to @donation_record }
format.json { render :show, status: :ok, location: @donation_record_actual_fund }
else
format.html { render :edit }
format.json { render json: @donation_record_actual_fund.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @fund.update(fund_params)\n head :no_content\n else\n render json: @fund.errors, status: :unprocessable_entity\n end\n end",
"def update\n @financial_donation = FinancialDonation.find(params[:id])\n\n respond_to do |format|\n if @financial_donation.update_attributes... | [
"0.7077915",
"0.6724212",
"0.66699964",
"0.6653356",
"0.6619549",
"0.6597654",
"0.6597654",
"0.6472627",
"0.6453055",
"0.6384767",
"0.6382418",
"0.6380618",
"0.6364759",
"0.63643014",
"0.63605064",
"0.6359064",
"0.6346527",
"0.6346527",
"0.634648",
"0.6337091",
"0.63262707",
... | 0.74511325 | 0 |
DELETE /donation_record/actual_funds/1 DELETE /donation_record/actual_funds/1.json | def destroy
@donation_record_actual_fund.destroy
respond_to do |format|
format.html { redirect_to @donation_record}
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @financial_donation = FinancialDonation.find(params[:id])\n @financial_donation.destroy\n\n respond_to do |format|\n format.html { redirect_to financial_donations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fund.destroy\n\n head :no_content\n ... | [
"0.71260846",
"0.69668245",
"0.692731",
"0.6921285",
"0.6893681",
"0.68904257",
"0.6762004",
"0.6749507",
"0.6740935",
"0.6737535",
"0.6737535",
"0.6731841",
"0.6730209",
"0.6730209",
"0.6719878",
"0.6699781",
"0.66980433",
"0.6689116",
"0.6689069",
"0.668449",
"0.6666043",
... | 0.77491415 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_donation_record_actual_fund
@donation_record_actual_fund = (id=params[:id]) ? DonationRecord::ActualFund.find(id) : DonationRecord::ActualFund.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def donation_record_actual_fund_params
params.require(:donation_record_actual_fund)
.permit( :fund_type_id, :serialnum, fund_attributes: [:amount, :time, :comment], proof_attributes: [:file] )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
name of context if ip in map, else nil | def lookup_device(ip)
@map[ip]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ptr(ip)\n # use cache if ip was already resolved\n return @cache[ip] if @cache[ip]\n\n begin\n name = @hypedns.getname(ip).to_s\n @cache[ip] = name\n return name\n rescue Resolv::ResolvError, SocketError\n return nil\n end\n end",
"def context_key(appt)... | [
"0.59307575",
"0.5873855",
"0.58264774",
"0.56705517",
"0.5666831",
"0.5653831",
"0.5621642",
"0.561809",
"0.561809",
"0.561809",
"0.55739117",
"0.55609584",
"0.55510074",
"0.55510074",
"0.55510074",
"0.5479952",
"0.5463491",
"0.5452683",
"0.53916043",
"0.53842676",
"0.538158... | 0.5513688 | 15 |
Public: insert Allows a person to insert an object into the "dogs" table. Parameters: No Parameters Returns: id State changes: NA? This method IS working. | def insert
DATABASE.execute("INSERT INTO dogs (name, breed, age, serial_num, colour, description, temperament_id, owner_id) VALUES
('#{@name}', '#{@breed}', #{@age}, #{@serial_num}, '#{@colour}', '#{@description}', #{@temperament_id}, #{@owner_id})")
@id = DATABASE.last_insert_row_id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_dog(name)\n @db.get_first_value('INSERT INTO dogs VALUES (null, :name)', \n ':name' => name)\n end",
"def save \n if self.id \n self.update\n else\n sql = <<-SQL\n INSERT INTO dogs (name, breed) \n VALUES (?, ?)\n SQL\n DB[:conn].execute(... | [
"0.70982844",
"0.7040118",
"0.6813493",
"0.6692974",
"0.6578374",
"0.63533133",
"0.63266695",
"0.6322296",
"0.6293022",
"0.6206442",
"0.6147826",
"0.6115783",
"0.60721695",
"0.6044648",
"0.60252905",
"0.6023231",
"0.59795785",
"0.59591275",
"0.5957428",
"0.5950503",
"0.593797... | 0.74263877 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.