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 |
|---|---|---|---|---|---|---|
did not come up with this on my own | def is_even(n)
!n.odd?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def offences_by; end",
"def schubert; end",
"def anchored; end",
"def terpene; end",
"def formation; end",
"def rassoc(p0) end",
"def berlioz; end",
"def stderrs; end",
"d... | [
"0.656105",
"0.5981003",
"0.57980824",
"0.57980824",
"0.57980824",
"0.57980824",
"0.5785658",
"0.57535094",
"0.5641894",
"0.5612703",
"0.5585282",
"0.55651945",
"0.5549495",
"0.5436121",
"0.5411029",
"0.5411029",
"0.5411029",
"0.5387723",
"0.5371195",
"0.53625906",
"0.5351929... | 0.0 | -1 |
string The String which is to be decided. Examples is_empty("") => true Returns the boolean value of the comparison. | def is_empty(string)
return true if string.length == 0
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_string?(); @type == GRT_STRING; end",
"def is_string\n return @is_string\n end",
"def string?\n type == \"STRING\"\n end",
"def empty_str?(value)\n EMPTY_STRING.eql?(value)\n end",
"def empty(string)\n if string == \"\" \n return true\n else \n ... | [
"0.6848677",
"0.6819934",
"0.6817137",
"0.6809451",
"0.6780125",
"0.6743893",
"0.6686278",
"0.65856427",
"0.65034145",
"0.64639074",
"0.64535916",
"0.64395416",
"0.64324284",
"0.63794",
"0.63222355",
"0.6315465",
"0.6314787",
"0.63009185",
"0.62568605",
"0.6254949",
"0.625475... | 0.57386243 | 60 |
Special accessors that need typecasting or other parsing | def id
return self.topic['id'].to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_value; end",
"def parse\n raise NotImplementedError\n end",
"def parse\n raise NotImplementedError.new\n end",
"def value_coercion(value); end",
"def cast_types; end",
"def read_attr(anno, res, col, offset = 0)\n if anno[:class].ancestor? Integer\n self.class.parse_i... | [
"0.64054626",
"0.63684815",
"0.6135872",
"0.6096579",
"0.6064413",
"0.6058247",
"0.60174483",
"0.5997507",
"0.59937274",
"0.5988434",
"0.598519",
"0.5972595",
"0.5926462",
"0.58929044",
"0.58929044",
"0.58929044",
"0.5877874",
"0.58736825",
"0.58443475",
"0.581363",
"0.581363... | 0.0 | -1 |
When using Draper, we wrap the collection draper in a new class that correctly delegates methods that Active Admin depends on. | def collection_decorator
if decorator_class
Wrapper.wrap decorator_class
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n @coll = self.class.collection\n end",
"def collection\n klass.collection\n end",
"def collection_decorator\n if decorator_class\n Wrapper.wrap decorator_class\n end\n end",
"def initialize\n @coll=self.class.collection\n end",
"def collection\n ... | [
"0.6528904",
"0.6510735",
"0.64654833",
"0.63368165",
"0.6327918",
"0.6327918",
"0.63276905",
"0.6294771",
"0.6256529",
"0.6166439",
"0.6166439",
"0.615145",
"0.6131435",
"0.60946006",
"0.59815013",
"0.59517276",
"0.5946922",
"0.5946313",
"0.592683",
"0.5924381",
"0.5924103",... | 0.64501905 | 3 |
Use callbacks to share common setup or constraints between actions. | def set_email
@email = params[:id] ? Email.find(params[:id]) : Email.new(email_params)
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.6165422",
"0.60457647",
"0.5946384",
"0.5916027",
"0.58905005",
"0.583495",
"0.5777223",
"0.56995213",
"0.56995213",
"0.56532377",
"0.5621348",
"0.5422839",
"0.54118705",
"0.54118705",
"0.54118705",
"0.53935355",
"0.5379617",
"0.53577393",
"0.53407264",
"0.53398263",
"0.53... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def email_params
params.require(:email).permit(:name, :image, :image_cache, :remove_image, :description, :ngo, :ngo_link, :published)
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 |
Pseudocode: 1. Print welcome 2. Get horses 'define horses name' 3. Get user's bet 'select in theses horses the one that is going to win get.chomp' 4. Run the race 'select a horse randomly and compare it with the user choice ' 5. Print results 'print if you lose or win' | def you_win(winner)
`say "Congratulation! YOU WON, #{winner} was the 1st one!"`
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def game\n horse_playing = true\n while horse_playing == true\n selecting = TTY::Prompt.new\n horses = ['PinkLightning', 'WildCat', 'Eclipse', 'Delphi', 'TheDaringDrunk', 'CrazySisterSeline', 'JackSparrow', 'RunningBull', \"RazMaTazz\"]\n racers = []\n sele... | [
"0.8146855",
"0.72749084",
"0.7211143",
"0.7176953",
"0.7140253",
"0.7102776",
"0.7057495",
"0.6873467",
"0.68657655",
"0.6842399",
"0.68106127",
"0.67998683",
"0.6792916",
"0.67908597",
"0.6786418",
"0.67746675",
"0.6755455",
"0.6731502",
"0.6727311",
"0.6716355",
"0.6710269... | 0.0 | -1 |
If the string contains an odd number of characters then it should replace the missing second character of the final pair with an underscore ('_'). Examples: solution('abc') should return ['ab', 'c_'] solution('abcdef') should return ['ab', 'cd', 'ef'] | def solution(str)
if str.size.even?
res = str.scan(/../)
else
str << '_'
res = str.scan(/../)
end
res
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution(str)\n str.scan(/.{1,2}/).map{ |str| str.size == 1 ? str + \"_\" : str }\nend",
"def solution(str)\n str << \"_\" if str.length % 2 != 0\n str.chars.each_slice(2).map(&:join)\nend",
"def solution(str)\n str.scan(/.{1,2}/).map { |e| e[1].nil? ? e + '_' : e }\nend",
"def solution(str)\n s... | [
"0.8301458",
"0.81800497",
"0.7939715",
"0.76024735",
"0.6747341",
"0.6555052",
"0.6513336",
"0.6415058",
"0.629731",
"0.62598735",
"0.6237132",
"0.62004805",
"0.6181425",
"0.61359906",
"0.611304",
"0.6086847",
"0.6083299",
"0.6060474",
"0.6038935",
"0.6016481",
"0.60141504",... | 0.72064626 | 4 |
GET /apid_drivers GET /apid_drivers.json | def index
respond_with ApidDriver.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_drivers\n drivers\n end",
"def get_drivers\n return return_all_drivers\n end",
"def index\n @drivers = Driver.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drivers }\n end\n end",
"def index\n @drivers = Driver.all\n\n ... | [
"0.70294434",
"0.68312633",
"0.6802067",
"0.6802067",
"0.65791625",
"0.6509949",
"0.6509949",
"0.64879316",
"0.64879316",
"0.6417385",
"0.62555367",
"0.618175",
"0.6169089",
"0.6144645",
"0.6135036",
"0.6112338",
"0.6081415",
"0.60653627",
"0.6027641",
"0.60162634",
"0.597566... | 0.6880389 | 1 |
GET /apid_drivers/1 GET /apid_drivers/1.json | def show
respond_with ApidDriver.find(params[:id])
rescue ActiveRecord::RecordNotFound
respond_with nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_drivers\n drivers\n end",
"def index\n @drivers = Driver.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drivers }\n end\n end",
"def index\n @drivers = Driver.all\n\n respond_to do |format|\n format.html # index.html.erb\n ... | [
"0.66801065",
"0.66517365",
"0.66517365",
"0.66512454",
"0.664052",
"0.6602897",
"0.6602897",
"0.6591169",
"0.6476339",
"0.640531",
"0.6326954",
"0.6326954",
"0.6318182",
"0.6195097",
"0.6136131",
"0.61184335",
"0.60221756",
"0.60011137",
"0.59053755",
"0.5863376",
"0.5785017... | 0.6257913 | 13 |
POST /apid_drivers POST /apid_drivers.json | def create
respond_with :api,:v1, ApidDriver.create_or_update(params[:apid_driver])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n\t\t\t\trespond_with Driver.create(params[:driver])\n\t\t\tend",
"def add_drivers params\n @driver_hash = JSON.parse(params)\n\n @driver_hash['drivers'].each do |driver|\n add_driver(driver[\"id\"],driver[\"location\"])\n end\n true\n end",
"def create\n # Logic to create a dr... | [
"0.67292213",
"0.6542204",
"0.64566",
"0.6414626",
"0.6359257",
"0.61984324",
"0.60098124",
"0.5945948",
"0.591286",
"0.5858562",
"0.58171153",
"0.57804334",
"0.57344794",
"0.57307833",
"0.57247764",
"0.57038593",
"0.5645948",
"0.5642996",
"0.56396645",
"0.5632334",
"0.548742... | 0.70627916 | 0 |
PUT /apid_drivers/1 PUT /apid_drivers/1.json | def update
respond_with ApidDrive.update(params[:id], params[:apid_driver])
rescue ActiveRecord::RecordNotFound
respond_with ApidDrive::StateChangeError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n\t\t\t\trespond_with Driver.update(params[:id],params[:driver])\n\t\t\tend",
"def create\n respond_with :api,:v1, ApidDriver.create_or_update(params[:apid_driver])\n end",
"def update\n #@driver = Driver.find(params[:id])\n @driver = @event.drivers.find(params[:id])\n\n respond... | [
"0.67831063",
"0.66273797",
"0.6190632",
"0.5953544",
"0.581342",
"0.581342",
"0.5705497",
"0.56741136",
"0.5632317",
"0.5631887",
"0.55777097",
"0.5539444",
"0.5539444",
"0.5539444",
"0.5539444",
"0.55388117",
"0.55388117",
"0.5522386",
"0.54935586",
"0.54600024",
"0.5442",
... | 0.6600777 | 2 |
DELETE /apid_drivers/1 DELETE /apid_drivers/1.json | def destroy
respond_with ApidDrive.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n\t\t\t\trespond_with Driver.destroy(params[:id])\n end",
"def destroy\n @driver = Driver.find(params[:id])\n @driver.destroy\n\n respond_to do |format|\n format.html { redirect_to drivers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # Logic t... | [
"0.7346565",
"0.7260004",
"0.7176116",
"0.711944",
"0.69264615",
"0.6875296",
"0.6875296",
"0.6875296",
"0.68502605",
"0.68502605",
"0.68502605",
"0.68502605",
"0.68437195",
"0.6812075",
"0.6715202",
"0.67142797",
"0.67003924",
"0.6668725",
"0.6640283",
"0.6589354",
"0.656968... | 0.64356834 | 30 |
Add a new node to the graph. Node must not exist. | def add_node(n1)
raise ArgumentError, "Duplicate node name #{n1.name}" if @nodes.find_index(n1)
@nodes << n1
@incident_map[n1] = []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_node(node)\n @nodes.add node\n end",
"def add_node(n)\n @nodes.push n unless @nodes.include? n\n end",
"def add_node(node)\n\t\t\tunless has_node?(node)\n\t\t\t\t@nodes[node] = new_node(node)\n\t\t\t\t@order += 1\n\t\t\tend\n\t\t\tself\n\t\tend",
"def add_node(node)\n nodes[node.value]... | [
"0.82840943",
"0.7709978",
"0.76525205",
"0.76296014",
"0.76230377",
"0.75886595",
"0.75097567",
"0.7504663",
"0.74980867",
"0.7435528",
"0.74191654",
"0.7239807",
"0.7205008",
"0.7144659",
"0.7075337",
"0.70538026",
"0.70115465",
"0.6991444",
"0.69556624",
"0.6930441",
"0.68... | 0.708124 | 14 |
Add a unidirectional edge to the graph. The end point must have valid nodes that are already added to the graph. parallel edges are possible. So the edge may have the same end points. | def add_edge(edge)
@edges << edge
add_node(edge.n1) unless @nodes.find_index(edge.n1)
add_node(edge.n2) unless @nodes.find_index(edge.n2)
@incident_map[edge.n1] << edge
@incident_map[edge.n2] << edge
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(direction, edge)\n opposite_adjacencies(direction, edge) << edge\n end",
"def add_edge(e)\n add_vertex(e.from); add_vertex(e.to)\n (@from_store[e.from].add?(e) && @to_store[e.to].add(e) && e) || edge(e.from, e.to)\n end",
"def add_undirected_edge(id1,id2)\n @g[i... | [
"0.7474515",
"0.72760797",
"0.67912275",
"0.6766652",
"0.6747922",
"0.6738925",
"0.67329955",
"0.67080563",
"0.66677564",
"0.6650507",
"0.6546373",
"0.64769053",
"0.6438302",
"0.6425793",
"0.64153343",
"0.63825625",
"0.63232446",
"0.6295457",
"0.6293283",
"0.6288033",
"0.6281... | 0.6560428 | 10 |
Debug hook, Check that the graph is consistent. | def check
raise "Non unique node entries" unless nodes.uniq == nodes
raise "Non unique edge entries" unless edges.uniq == edges
@edges.each do |e|
raise "self loop" if e.n1 == e.n2
raise "wrong order" unless e.n1 < e.n2
raise "edge not found in n1 incident list" unless @incident_map[e.n1].find_index(e)
raise "edge not found in n2 incident list" unless @incident_map[e.n2].find_index(e)
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_07\n @dg = DiGraph.new([0,0],[6,0],[6,8],[2,6],[8,8],[3,4],[3,2],[3,9],[9,4],[9,6],[4,3],[4,8])\n @paths = Hash.new\n @paths[0] = [0]\n @paths[6] = [0,8]\n @paths[2] = [6]\n @paths[8] = [8]\n @paths[3] = [4,2,9]\n @paths[9] = [4,6]\n @paths[4]... | [
"0.6164582",
"0.61274487",
"0.61274487",
"0.61065865",
"0.6023812",
"0.5939961",
"0.5928433",
"0.5928433",
"0.5928433",
"0.5928433",
"0.59103066",
"0.59103066",
"0.5855401",
"0.5842462",
"0.58193654",
"0.578198",
"0.57057947",
"0.57056344",
"0.56885743",
"0.5688269",
"0.56341... | 0.52606255 | 63 |
Generate a certificate for example.org, signed by ca_root_key | def generate_signed_cert
unless @generated_signed_cert
domains = %w(example.org www.example.org)
key = OpenSSL::PKey::RSA.new(LetsCert::TEST::KEY_LENGTH)
cert = OpenSSL::X509::Certificate.new
cert.version = 2
cert.serial = 2
cert.issuer = OpenSSL::X509::Name.parse "/DC=letscert/CN=CA"
cert.public_key = key.public_key
cert.not_before = Time.now
# 20 days validity
cert.not_after = cert.not_before + 20 * 24 * 60 * 60
ef = OpenSSL::X509::ExtensionFactory.new
ef.subject_certificate = cert
domains.each do |domain|
cert.add_extension(ef.create_extension('subjectAltName',
"DNS:#{domain}",
false))
end
cert.sign(ca_root_key, OpenSSL::Digest::SHA256.new)
@generated_signed_cert = [cert, domains]
end
@generated_signed_cert
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_ssl_cert\n\t\tcert_request = TEST_WORKDIR + 'example.csr'\n\t\tsigning_key = TEST_WORKDIR + 'example.key'\n\t\tcert = TEST_WORKDIR + 'example.crt'\n\n\t\tunless File.exist?( cert )\n\t\t\tsystem 'openssl', 'req',\n\t\t\t\t'-new', '-newkey', 'rsa:4096',\n\t\t\t\t'-days', '365', '-nodes', '-x50... | [
"0.75827795",
"0.73909265",
"0.7386241",
"0.7341035",
"0.72272605",
"0.721721",
"0.6991933",
"0.6909108",
"0.6772082",
"0.67239326",
"0.6607741",
"0.6579856",
"0.6563864",
"0.6562421",
"0.65318424",
"0.6519538",
"0.63676304",
"0.63441074",
"0.6337626",
"0.6326589",
"0.6322056... | 0.7454715 | 1 |
Never trust parameters from the scary internet, only allow the white list through. | def status_params
params.require(:status).permit(:content,:picture)
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 |
Default voting If a user submits a post, he'll want to vote it up. mount_uploader :image, ImageUploader | def up_votes # We'll want a way to see only "up" or "down" votes
self.votes.where(value: 1).count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uppost\n post = Post.find_by_id(params[:id])\n if !post.nil?\n post.vote(current_user, true)\n end\n end",
"def cast_vote # :norobots:\n if image = find_or_goto_index(Image, params[:id].to_s)\n val = image.change_vote(@user, params[:value])\n Transaction.put_images(:id => image, :... | [
"0.63957137",
"0.6270201",
"0.62665915",
"0.62225986",
"0.5970969",
"0.59567064",
"0.59482086",
"0.58975244",
"0.58929807",
"0.5888929",
"0.5881109",
"0.5881109",
"0.5881109",
"0.5881109",
"0.5881109",
"0.5881109",
"0.5881109",
"0.5881109",
"0.5881109",
"0.5881109",
"0.588110... | 0.0 | -1 |
Who ever created a post, should automatically be set to "voting" it up. | def create_vote
self.user.votes.create(value: 1, post: self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @post = Post.new(params[:post])\n @post.user ||= current_user\n\n if @post.save\n Vote.vote_thusly_on_post_or_comment_for_user_because(1, @post.id, nil, current_user.id, nil)\n\n flash[:success] = \"Your post has been submitted successfully.\"\n\n redirect_to @post.comments_url... | [
"0.6533024",
"0.6496797",
"0.6473395",
"0.6473395",
"0.63758665",
"0.63555753",
"0.63349676",
"0.63148034",
"0.6281884",
"0.6266895",
"0.6261689",
"0.62605864",
"0.6223895",
"0.62026113",
"0.6138418",
"0.6128905",
"0.6127989",
"0.6061835",
"0.60538024",
"0.6016958",
"0.600598... | 0.6344203 | 7 |
puts "Input string to encrypt..." text_to_cipher = gets.chomp puts "Input cipher offset..." cipher_offset = gets.chomp puts CaesarCipher.encrypt("in", 5) puts CaesarCipher.encrypt("hello.", 11) | def caesar_cipher(string, key)
arr_string = string.downcase.split("")
alpha = ("a".."z").to_a
for i in arr_string do
if alpha.include?(i)
alpha_index = alpha.index(i)
string_index = arr_string.index(i)
if alpha_index + key > 25
key_change = alpha[alpha_index + key - 25 - 1]
arr_string[string_index] = key_change
else
key_change = alpha[alpha_index + key]
arr_string[string_index] = key_change
end
end
end
arr_string.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main\r\n\tputs \"Please, enter a string which you want to cipher!\"\r\n\tuser_string = gets.chomp\r\n\tputs \"Please, enter positive number\"\r\n\tuser_number = gets.chomp.to_i\r\n\r\n\tcaesar_cipher(user_string, user_number)\r\nend",
"def caesar_cipher(offset, string)\n\talph = [\"a\", \"b\", \"c\", \"d\", ... | [
"0.73170644",
"0.7271542",
"0.7180676",
"0.7167195",
"0.71498686",
"0.70933145",
"0.7053305",
"0.7040899",
"0.70117795",
"0.69665325",
"0.69166696",
"0.6911052",
"0.6859404",
"0.68502116",
"0.684943",
"0.6843077",
"0.6827996",
"0.67854136",
"0.67701423",
"0.67640656",
"0.6687... | 0.0 | -1 |
menu items like 'invoke', not a proper mouse click | def click
@automation_element.get_current_pattern(System::Windows::Automation::InvokePattern.pattern).invoke
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def click; end",
"def click; end",
"def click; end",
"def clicked;end",
"def press_menu\n driver.pressQuickMenuItem(text, true);\n end",
"def nMenuItems _obj, _args\n \"_obj nMenuItems _args;\" \n end",
"def menu # can do custom methods within a method/class\n end",
"def click_menu_i... | [
"0.69734347",
"0.69734347",
"0.69734347",
"0.6854282",
"0.68469274",
"0.6763902",
"0.6715973",
"0.66833013",
"0.66774136",
"0.6670237",
"0.66370136",
"0.65912074",
"0.658327",
"0.6581311",
"0.6581311",
"0.6520747",
"0.65024436",
"0.6489541",
"0.64653593",
"0.6464306",
"0.6431... | 0.5848139 | 90 |
=begin Implement repeatingkey XOR Here is the opening stanza of an important work of the English language: Burning 'em, if you ain't quick and nimble I go crazy when I hear a cymbal Encrypt it, under the key "ICE", using repeatingkey XOR. In repeatingkey XOR, you'll sequentially apply each byte of the key; the first byte of plaintext will be XOR'd against I, the next C, the next E, then I again for the 4th byte, and so on. It should come out to: 0b3637272a2b2e63622c2e69692a23693a2a3c6324202d623d63343c2a26226324272765272 a282b2f20430a652e2c652a3124333a653e2b2027630c692b20283165286326302e27282f Encrypt a bunch of stuff using your repeatingkey XOR function. Encrypt your mail. Encrypt your password file. Your .sig file. Get a feel for it. I promise, we aren't wasting your time with this. =end Simply proceed modularly through the array and fixed_xor the corresponding bytes. | def repeat_key_xor(text, key)
hex_text = text.unpack('H*').join
#Unpack the key into its individual letters
key_array = key.unpack('H2H2H2')
out = hex_text.scan(/../).map.with_index { |a, i| fixed_xor(a, key_array[i.modulo(3)]) }.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repeating_key_xor(string, key)\n counter = 0\n encrypted = []\n string.bytes.each do |byte|\n encrypted << (byte ^ key.bytes[counter])\n \n counter = counter == 2 ? 0 : counter += 1\n end\n # binding.pry\n encrypted.map{ |i| sprintf(\"%02x\", i) }.join.strip\n end",
"def cry... | [
"0.78090715",
"0.74087214",
"0.70919377",
"0.70691013",
"0.70683056",
"0.69675136",
"0.6938875",
"0.69280326",
"0.6831876",
"0.67813385",
"0.67658955",
"0.6741339",
"0.6735909",
"0.6733082",
"0.66798353",
"0.6665799",
"0.6617876",
"0.6600136",
"0.6588627",
"0.6586253",
"0.654... | 0.80354226 | 0 |
, :only => [:index, :edit, :destroy] GET /polygons GET /polygons.json | def index
@polygons = Polygon.paginate(:page => params[:page])
respond_to do |format|
format.html # index.html.erb
format.json { render json: @polygons }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @layers = Layer.order(:id)\n\n respond_to do |format|\n format.html # index.html.erb\n # example output:\n # {\"layers\":[{\"id\":14,\"name\":\"coutries\",\"number_of_polygons\":279}]}\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, n... | [
"0.66198695",
"0.65930706",
"0.63809395",
"0.6252743",
"0.62404734",
"0.623194",
"0.6194731",
"0.6190393",
"0.60708237",
"0.60525334",
"0.60468924",
"0.60019475",
"0.59400785",
"0.5934293",
"0.5897333",
"0.587534",
"0.58630836",
"0.5847473",
"0.5795676",
"0.5791273",
"0.57826... | 0.7244158 | 0 |
GET /polygons/1 GET /polygons/1.json | def show
@polygon = Polygon.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @polygon }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @polygons = Polygon.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @polygons }\n end\n end",
"def index\n @layers = Layer.order(:id)\n\n respond_to do |format|\n format.html # index.html.erb\n ... | [
"0.7352029",
"0.6623201",
"0.6446067",
"0.6316232",
"0.6227232",
"0.6203522",
"0.61881876",
"0.61881876",
"0.6172934",
"0.6171902",
"0.6166581",
"0.613502",
"0.6070721",
"0.59961194",
"0.5974895",
"0.59604883",
"0.5848663",
"0.584651",
"0.5775503",
"0.5707606",
"0.5692639",
... | 0.6875102 | 1 |
GET /polygons/new GET /polygons/new.json | def new
@polygon = Polygon.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @polygon }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @layer = Layer.new(params[:layer])\n\n respond_to do |format|\n if @layer and @layer.save\n @layers = Layer.all\n format.html { redirect_to layers_path, notice: 'Layer was successfully created.' }\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id,... | [
"0.6858009",
"0.6700113",
"0.66460365",
"0.638145",
"0.63777155",
"0.6344747",
"0.63346094",
"0.6304163",
"0.62628907",
"0.62494093",
"0.62494093",
"0.62275547",
"0.6196464",
"0.61795276",
"0.61472434",
"0.6117554",
"0.60944206",
"0.6083274",
"0.60822314",
"0.60618806",
"0.60... | 0.7595767 | 0 |
POST /polygons POST /polygons.json | def create
@polygon = Polygon.new(params[:polygon])
respond_to do |format|
if @polygon.save
format.html { redirect_to @polygon, notice: 'Polygon was successfully created.' }
format.json { render json: @polygon, status: :created, location: @polygon }
else
format.html { render action: "new" }
format.json { render json: @polygon.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @layer = Layer.new(params[:layer])\n\n respond_to do |format|\n if @layer and @layer.save\n @layers = Layer.all\n format.html { redirect_to layers_path, notice: 'Layer was successfully created.' }\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id,... | [
"0.65228736",
"0.595164",
"0.59452856",
"0.59246415",
"0.5849152",
"0.5825079",
"0.58121926",
"0.5754164",
"0.57329005",
"0.56419456",
"0.5603118",
"0.55640477",
"0.5562892",
"0.5518842",
"0.5409137",
"0.536409",
"0.5304422",
"0.5299539",
"0.5267293",
"0.52190936",
"0.5182779... | 0.6749226 | 0 |
PUT /polygons/1 PUT /polygons/1.json | def update
@polygon = Polygon.find(params[:id])
respond_to do |format|
if @polygon.update_attributes(params[:polygon])
format.html { redirect_to @polygon, notice: 'Polygon was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @polygon.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @layer = Layer.find(params[:id])\n\n respond_to do |format|\n if @layer.update_attributes(params[:layer])\n @layers = Layer.all\n format.html { redirect_to @layer, notice: 'Layer was successfully updated.' }\n format.json { render json: {layers: @layers.map {|layer| {id... | [
"0.6826295",
"0.61088365",
"0.60923445",
"0.6087015",
"0.5892075",
"0.58629286",
"0.58038306",
"0.57993364",
"0.57139134",
"0.5695231",
"0.56512505",
"0.56227225",
"0.55273837",
"0.5494119",
"0.546989",
"0.5374367",
"0.5350406",
"0.53445464",
"0.533678",
"0.5335534",
"0.53236... | 0.6763483 | 1 |
DELETE /polygons/1 DELETE /polygons/1.json | def destroy
@polygon = Polygon.find(params[:id])
@polygon.destroy
respond_to do |format|
format.html { redirect_to polygons_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @geometry.destroy\n respond_to do |format|\n format.html { redirect_to geometries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post_geo = current_user.post_geos.find(params[:id])\n @post_geo.destroy\n\n respond_to do |format|\n format.html... | [
"0.6596842",
"0.6481396",
"0.64797837",
"0.6337303",
"0.63017017",
"0.62546587",
"0.6242979",
"0.6229377",
"0.62050515",
"0.6199542",
"0.61053884",
"0.6094234",
"0.6087038",
"0.6079646",
"0.60688704",
"0.6068016",
"0.60649145",
"0.60514265",
"0.6039525",
"0.603931",
"0.603001... | 0.748428 | 0 |
Steps: List fibonacci numbers Add if they are even Return sum of even < 4000000 | def problem_two
first_num = 1 #Let first number be 1
second_num = 1 #we need this to make 2nd num
sum = 0
while sum < 4000000
first_num, second_num = second_num, first_num + second_num
if first_num.even?
sum += first_num
end
end
sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_even_fibonacci_numbers(num)\n even_fibonacci_numbers = fibonacci_numbers(num).select{|number| number.even?}\n even_fibonacci_numbers.inject(:+)\nend",
"def fibonacci(p2, p1, sum)\n next_number = p2 + p1\n return sum if next_number >= 4000000\n sum += next_number if next_number.even?\n fibonacci p1,... | [
"0.8183116",
"0.81647253",
"0.8162808",
"0.8140191",
"0.8104084",
"0.80710554",
"0.80452245",
"0.8018586",
"0.8002838",
"0.8002159",
"0.7944863",
"0.79199064",
"0.7898868",
"0.7892157",
"0.78717613",
"0.7871002",
"0.78633225",
"0.78596723",
"0.7839053",
"0.7823375",
"0.781449... | 0.0 | -1 |
Checks the AtomPub server at +uri+ for sanity. ==== Options uri the URI of the AtomPub server. Required. username an optional username for authentication password if a username is provided, a password is required. See Ape::Authent for more information. service_doc an optional service document. It'll be used instead of getting it from the uri. requested_e_coll a preferred entry collection to check requested_m_coll a preferred media collection to check | def check(uri, username=nil, password=nil, service_doc = nil,
requested_e_coll = nil, requested_m_coll = nil)
@authent = Authent.new(username, password)
@reporter.header = uri
::Ape.conf[:REQUESTED_ENTRY_COLLECTION] = requested_e_coll if requested_e_coll
::Ape.conf[:REQUESTED_MEDIA_COLLECTION] = requested_m_coll if requested_m_coll
begin
might_fail(uri, service_doc)
rescue Exception
@reporter.error(self, "Ouch! Ape fall down go boom; details: " +
"#{$!}\n#{$!.class}\n#{$!.backtrace}")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_uri(uri)\n response = RestClient.get BASE_URI, :params => { :doc => uri, :out => 'json' }\n @json = JSON.parse(response.body)\n @errors = retrieve_errors\n end",
"def validate_uri(uri)\n return validate({:doc => uri})\n end",
"def validate_uri( uri, dir, doc )\n # do n... | [
"0.5805499",
"0.5657943",
"0.5632669",
"0.54668003",
"0.5301297",
"0.5278516",
"0.52320725",
"0.5227043",
"0.5212603",
"0.51234555",
"0.5104248",
"0.5096873",
"0.5093398",
"0.50643986",
"0.50492966",
"0.5000894",
"0.49676612",
"0.4963593",
"0.49631557",
"0.49418417",
"0.48437... | 0.75422734 | 0 |
added from ActionView::Base with additional call to registerView added in there not proud of the solution but need to quickly establish access to the base class from within the template to pick up some gui widget metadata used to control the navigation | def _pick_template(template_path)
return template_path if template_path.respond_to?(:render)
path = template_path.sub(/^\//, '')
if m = path.match(/(.*)\.(\w+)$/)
template_file_name, template_file_extension = m[1], m[2]
else
template_file_name = path
end
# OPTIMIZE: Checks to lookup template in view path
if template = self.view_paths["#{template_file_name}.#{template_format}"]
template
elsif template = self.view_paths[template_file_name]
template
elsif (first_render = @_render_stack.first) && first_render.respond_to?(:format_and_extension) &&
(template = self.view_paths["#{template_file_name}.#{first_render.format_and_extension}"])
template
elsif template_format == :js && template = self.view_paths["#{template_file_name}.html"]
@template_format = :html
template
else
template = ActionView::Template.new(template_path, view_paths)
template.registerView(self)
if self.class.warn_cache_misses && logger
logger.debug "[PERFORMANCE] Rendering a template that was " +
"not found in view path. Templates outside the view path are " +
"not cached and result in expensive disk operations. Move this " +
"file into #{view_paths.join(':')} or add the folder to your " +
"view path list"
end
template
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_view\n #debugger\n self.becomes(self.type.constantize).get_view\n end",
"def add_view\n super\n end",
"def view_instance\n # view = if controller.response.template\n # controller.response.template\n # else\n View.new controller, master_helper_module\n ... | [
"0.67603225",
"0.6627405",
"0.6395054",
"0.63627064",
"0.6322792",
"0.6261792",
"0.6139669",
"0.6131248",
"0.60864604",
"0.60620207",
"0.60620207",
"0.59203887",
"0.58636576",
"0.58585614",
"0.57804656",
"0.5751333",
"0.5714061",
"0.5712798",
"0.5711969",
"0.56857693",
"0.568... | 0.0 | -1 |
GET /assets GET /assets.xml | def index
@assets = Asset.find(:all)
respond_to do |format|
format.html # index.rhtml
format.xml { render :xml => @assets.to_xml }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @assets = assets.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assets.to_xml }\n end\n end",
"def list_assets\n get('/video/v1/assets')\n end",
"def index\n @car = Car.find(params[:car_id])\n @assets = @car.assets\... | [
"0.766882",
"0.7315963",
"0.71050686",
"0.7104809",
"0.6935153",
"0.6924257",
"0.69046664",
"0.68881136",
"0.68466556",
"0.67834485",
"0.6737458",
"0.66746676",
"0.66599834",
"0.66599834",
"0.66415435",
"0.66150415",
"0.66150415",
"0.6613453",
"0.6604568",
"0.65537506",
"0.65... | 0.7255824 | 2 |
GET /assets/1 GET /assets/1.xml | def show
@asset = Asset.find(params[:id])
respond_to do |format|
format.html # show.rhtml
format.xml { render :xml => @asset.to_xml }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @assets = assets.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assets.to_xml }\n end\n end",
"def index\n @assets = Asset.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { rende... | [
"0.740832",
"0.70975775",
"0.7013955",
"0.6968848",
"0.6896635",
"0.6886804",
"0.6811859",
"0.6811859",
"0.67383313",
"0.6697305",
"0.6668664",
"0.66502386",
"0.66199934",
"0.6602234",
"0.6557599",
"0.6534046",
"0.64878243",
"0.6468242",
"0.6429968",
"0.6393348",
"0.6350668",... | 0.68244594 | 6 |
POST /assets POST /assets.xml | def create
@asset = Asset.new(params[:asset])
respond_to do |format|
if @asset.save
flash[:notice] = 'Asset was successfully created.'
format.html { redirect_to asset_url(@asset) }
format.js # render create.rjs << added for P/C >>
format.xml { head :created, :location => asset_url(@asset) }
else
format.html { render :action => "new" }
format.js # render create.rjs << added for P/C >>
format.xml { render :xml => @asset.errors.to_xml }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @asset = assets.build(params[:asset])\n\n respond_to do |format|\n if @asset.save\n flash[:notice] = 'Asset was successfully created.'\n format.html { redirect_to user_asset_url(@asset) }\n format.xml { head :created, :location => user_asset_url(@asset) }\n else\n... | [
"0.6193998",
"0.6134211",
"0.6111537",
"0.59586036",
"0.5951087",
"0.5928681",
"0.5899147",
"0.58949196",
"0.5881975",
"0.58126974",
"0.5795135",
"0.5778651",
"0.57770455",
"0.57389474",
"0.57338536",
"0.5731263",
"0.5700603",
"0.5698594",
"0.5691174",
"0.5639266",
"0.5636452... | 0.5408696 | 39 |
PUT /assets/1 PUT /assets/1.xml | def update
@asset = Asset.find(params[:id])
respond_to do |format|
if @asset.update_attributes(params[:asset])
flash[:notice] = 'Asset was successfully updated.'
format.js # render update.rjs << added for P/C >>
format.html { redirect_to asset_url(@asset)}
format.xml { head :ok }
else
format.js # render update.rjs << added for P/C >>
format.html { render :action => "edit" }
format.xml { render :xml => @asset.errors.to_xml }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @asset = Asset.find(params[:id])\n \n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n flash[:notice] = 'Asset was successfully updated.'\n format.html { redirect_to(@asset) }\n format.xml { head :ok }\n else\n format.html { render ... | [
"0.6663411",
"0.6543097",
"0.6458288",
"0.64563084",
"0.62763244",
"0.6273026",
"0.62198365",
"0.6209169",
"0.6209169",
"0.6209169",
"0.6172505",
"0.6096301",
"0.5975409",
"0.5963124",
"0.59567297",
"0.59267664",
"0.5914408",
"0.5910384",
"0.5907817",
"0.5900452",
"0.58916783... | 0.574395 | 34 |
DELETE /assets/1 DELETE /assets/1.xml | def destroy
@asset = Asset.find(params[:id])
@asset.destroy
respond_to do |format|
format.js # render destroy.rjs << added for P/C >>
format.html { redirect_to assets_url }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @asset = Asset.find(params[:id])\n @asset.destroy\n\n respond_to do |format|\n format.html { redirect_to(assets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @asset = Asset.find(params[:id])\n @asset.destroy\n\n respond_to do |format|\n format.h... | [
"0.7382295",
"0.7382295",
"0.7382295",
"0.732427",
"0.71312577",
"0.7078632",
"0.6886374",
"0.6871242",
"0.6871242",
"0.6871242",
"0.6871242",
"0.6816481",
"0.6816481",
"0.6816481",
"0.6816481",
"0.6816481",
"0.6812131",
"0.6791939",
"0.6786161",
"0.6743924",
"0.67189544",
... | 0.6651413 | 23 |
Creates `num` of each ContentBase subclass for helping with Sphinx tests | def make_content(num=nil, options=nil)
num ||= 1
options ||= {}
@generated_content = []
ContentBase::CONTENT_CLASSES.each do |klass|
@generated_content.push FactoryGirl.create_list(
klass.to_s.underscore.to_sym, num.to_i, options
)
end
@generated_content = @generated_content.flatten
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_type_counts\n vars = \"\"\n Repo::REPO_TYPES.each do |t|\n vars << \"@#{t}_count = #{t.camelize.constantize}.count;\"\n end\n eval(vars)\n end",
"def class_count\n @_count ||= \"(#{classes.size}/#{vedeu_classes.size})\"\n end",
"def auto_increment\n @@count_class_instance... | [
"0.6032869",
"0.59820944",
"0.5652937",
"0.5564144",
"0.54795355",
"0.5430587",
"0.541258",
"0.5403861",
"0.5333603",
"0.5333603",
"0.53129375",
"0.5307838",
"0.52916",
"0.52844983",
"0.5279191",
"0.52667797",
"0.5260656",
"0.5229471",
"0.5216411",
"0.51934385",
"0.5188417",
... | 0.63118696 | 0 |
Sometimes the index takes too long, but we want to actually test the sphinx results. This method will help for slower computers, for example, that take longer to run the index. Usage: ts_retry(2) do | def ts_retry(attempts=1, &block)
attempt = 0
begin
yield block
rescue RSpec::Expectations::ExpectationNotMetError => e
attempt += 1
if attempt > attempts
raise e
else
sleep 0.5
retry
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retry_query\n Rails.logger.info('Retrying EDS Search')\n @attempts += 1\n search(@query[:term], @query[:profile], @query[:facets],\n @query[:page], @query[:per_page])\n end",
"def reset_index\n ElasticMapper.index_name = \"elastic_mapper_tests\"\n index = ElasticMapper.index\n server =... | [
"0.6350596",
"0.6008212",
"0.60057944",
"0.5838339",
"0.5789068",
"0.5756824",
"0.56251746",
"0.55956846",
"0.55131274",
"0.55067295",
"0.5465428",
"0.5431075",
"0.5363156",
"0.5356042",
"0.53560334",
"0.5323898",
"0.52845746",
"0.52670664",
"0.52548444",
"0.5248886",
"0.5241... | 0.55046666 | 10 |
GET /api/v1/questions GET /api/v1/questions.json | def index
@api_v1_questions = Api::V1::Question.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def questions\n self.class.get(\"/2.2/questions\", @options)\n end",
"def get_question_list\n json= RestClient.get(\"http://localhost:3000/questions\")\n JSON.parse(json)\n end",
"def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format... | [
"0.8588737",
"0.7651844",
"0.763648",
"0.758824",
"0.74159724",
"0.7267644",
"0.7215423",
"0.7208577",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71... | 0.78128016 | 1 |
GET /api/v1/questions/1 GET /api/v1/questions/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def questions\n self.class.get(\"/2.2/questions\", @options)\n end",
"def index\n @api_v1_questions = Api::V1::Question.all\n end",
"def show\n if @v1_question\n render json: @v1_question\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end",
"def index\n ... | [
"0.79932857",
"0.7755646",
"0.73663837",
"0.7310721",
"0.72957736",
"0.7263938",
"0.7195237",
"0.7045953",
"0.70385146",
"0.7029269",
"0.7023901",
"0.70228696",
"0.70228696",
"0.70228696",
"0.7015446",
"0.6999904",
"0.69779843",
"0.69776154",
"0.69692695",
"0.69692695",
"0.69... | 0.0 | -1 |
POST /api/v1/questions POST /api/v1/questions.json | def create
@api_v1_question = Api::V1::Question.new(api_v1_question_params)
respond_to do |format|
if @api_v1_question.save
format.html { redirect_to @api_v1_question, notice: 'Question was successfully created.' }
format.json { render :show, status: :created, location: @api_v1_question }
else
format.html { render :new }
format.json { render json: @api_v1_question.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @question = Question.new(params[:question])\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to api_v1_question_path(@question), notice: 'Question was successfully created.' }\n format.json { render json: @question, status: :created, location: @question ... | [
"0.7403698",
"0.7302256",
"0.7193526",
"0.71894675",
"0.7154693",
"0.7065109",
"0.70428145",
"0.6877065",
"0.68398523",
"0.68280333",
"0.68256307",
"0.6820573",
"0.6810663",
"0.6805841",
"0.677892",
"0.6776349",
"0.67584056",
"0.67504466",
"0.67504466",
"0.67504466",
"0.67504... | 0.7252838 | 2 |
PATCH/PUT /api/v1/questions/1 PATCH/PUT /api/v1/questions/1.json | def update
respond_to do |format|
if @api_v1_question.update(api_v1_question_params)
format.html { redirect_to @api_v1_question, notice: 'Question was successfully updated.' }
format.json { render :show, status: :ok, location: @api_v1_question }
else
format.html { render :edit }
format.json { render json: @api_v1_question.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to api_v1_question_path(@question), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n ... | [
"0.7259023",
"0.7165158",
"0.7044536",
"0.7006729",
"0.6907968",
"0.68261033",
"0.6800151",
"0.6750449",
"0.67404205",
"0.6726497",
"0.6671826",
"0.6671826",
"0.6671826",
"0.6671826",
"0.6671826",
"0.66649675",
"0.66295034",
"0.66005725",
"0.65971416",
"0.6596202",
"0.6590358... | 0.7117659 | 2 |
DELETE /api/v1/questions/1 DELETE /api/v1/questions/1.json | def destroy
@api_v1_question.destroy
respond_to do |format|
format.html { redirect_to api_v1_questions_url, notice: 'Question was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v1_questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @v1_question.destroy\n render json: {'message': 'Deleted questio... | [
"0.8252109",
"0.8090987",
"0.776588",
"0.776588",
"0.77635974",
"0.7758693",
"0.7757807",
"0.7757807",
"0.7757807",
"0.7757807",
"0.7757807",
"0.7757807",
"0.7756929",
"0.7732027",
"0.77263165",
"0.77263165",
"0.77263165",
"0.77263165",
"0.77263165",
"0.77263165",
"0.7720597"... | 0.8159502 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_api_v1_question
@api_v1_question = Api::V1::Question.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.6165422",
"0.60457647",
"0.5946384",
"0.5916027",
"0.58905005",
"0.583495",
"0.5777223",
"0.56995213",
"0.56995213",
"0.56532377",
"0.5621348",
"0.5422839",
"0.54118705",
"0.54118705",
"0.54118705",
"0.53935355",
"0.5379617",
"0.53577393",
"0.53407264",
"0.53398263",
"0.53... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def api_v1_question_params
params.fetch(:api_v1_question, {})
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 |
Deliver all the sms messages marked with this as its sms service provider | def deliver
Outbound.deliver(delivery_options.merge(:conditions => ['sms_service_provider_id = ?', self.provider_id]))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deliver\n xml = Clockwork::XML::SMS.build_multiple( self.messages )\n http_response = Clockwork::HTTP.post( Clockwork::API::SMS_URL, xml, @use_ssl )\n responses = Clockwork::XML::SMS.parse_multiple( self.messages, http_response )\n end",
"def deliver\n #inform_interceptors\n if de... | [
"0.72850764",
"0.69843453",
"0.6950221",
"0.6770076",
"0.6458194",
"0.6195543",
"0.61663157",
"0.6090142",
"0.60884774",
"0.60609865",
"0.6017061",
"0.5958864",
"0.5947048",
"0.5935357",
"0.59302646",
"0.59207046",
"0.58750004",
"0.5869881",
"0.58133775",
"0.57955253",
"0.576... | 0.7601357 | 0 |
Sends a message to a phone number directly to the provider. No validations are performed +phone_number+ the exact string text to send +message+ the string message to send +options+ additional options to be used by the provider | def send_message(phone_number, message, options={})
raise SmsOnRails::SmsError.new("Override send_message in subclass #{self.class}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_to_phone(phone_obj, message, options={})\n\n if options[:skip_validation]\n phone_text = phone_obj.is_a?(ActiveRecord::Base) ? format_phone_number(phone_number) : phone_obj\n return send_message(phone_text, message, options)\n end\n\n phone_number = phone_obj.is_a?(A... | [
"0.8076961",
"0.7327399",
"0.72555643",
"0.71731424",
"0.7172145",
"0.7094982",
"0.7071273",
"0.7059622",
"0.70495224",
"0.7027857",
"0.6943535",
"0.6899074",
"0.689207",
"0.6848091",
"0.68376344",
"0.67783016",
"0.674744",
"0.67085665",
"0.670839",
"0.6684886",
"0.6682523",
... | 0.7171992 | 5 |
Sends a message to a phone number active record object or string and performs validation on the phone_number +phone_number+ can be either a phone number active record obj or a string text. Strings are converted to phone_number objects +message+ the message to send +options+ additional options to be used by the provider ===Options :skip_validation skips validation and sends the message directly to the provider | def send_to_phone(phone_obj, message, options={})
if options[:skip_validation]
phone_text = phone_obj.is_a?(ActiveRecord::Base) ? format_phone_number(phone_number) : phone_obj
return send_message(phone_text, message, options)
end
phone_number = phone_obj.is_a?(ActiveRecord::Base) ? phone_obj :
find_or_create_phone_number(phone_obj, options)
assert_message_options!(phone_number, message, options)
send_message(format_phone_number(phone_number), message, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @message = Message.new(params[:message])\n\n respond_to do |format|\n if @message.save\n recipient_phone = Phone.find_by_number(@message.number)\n \t recipient_phone ||= User.create!.phones.create!(:number => @message.number)\n @message.send_SMS(@message.raw_message, recip... | [
"0.6723519",
"0.64559287",
"0.645273",
"0.6400237",
"0.6301016",
"0.62924147",
"0.628437",
"0.627692",
"0.6229558",
"0.6199698",
"0.617848",
"0.6163542",
"0.6155938",
"0.61173975",
"0.61073047",
"0.6102288",
"0.61006",
"0.6095018",
"0.6086288",
"0.60789096",
"0.6069717",
"0... | 0.8213789 | 0 |
Send an Sms with validation +sms+ is an sms active record object that responds to phone_number and full_message Refer to send_to_phone for more infomation on validation | def send_sms(sms, options={})
send_to_phone(sms.phone_number, sms.actual_message, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_and_validate_sms\n sms_service.validate_params\n end",
"def sms\n \t\n \t#flash[:notice] = params\n \t#redirect_to root_path\n\n TwilioTextMessenger.new( params[:phone], params[:message]).call\n \t\n end",
"def send_sms_verification_code\n number_to_send_to = phone_number\n ve... | [
"0.7531832",
"0.7422945",
"0.7406239",
"0.73494947",
"0.7317686",
"0.72133756",
"0.7177639",
"0.7120962",
"0.7114795",
"0.7044778",
"0.7029981",
"0.7023073",
"0.70016986",
"0.6957868",
"0.69455945",
"0.69433737",
"0.6924345",
"0.6900544",
"0.68777055",
"0.68578756",
"0.685751... | 0.77748454 | 0 |
can override in subclass if different finder should be used | def find_or_create_phone_number(phone_text, options={})
phone = phone_klass.find_and_create_by_number(phone_text)
phone.assign_carrier(options[:carrier]) if options[:carrier]
phone
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finder_methods; end",
"def find(object, parent = @base)\n raise NotImplementedError, \"Subclasses must implement public method find\"\n end",
"def method_for_find\n resources_configuration[:self][:finder] || :find\n end",
"def method_missing(name, *args)\n if self.finders.has_k... | [
"0.72618836",
"0.70492786",
"0.70340765",
"0.7013792",
"0.6947906",
"0.6900682",
"0.67339385",
"0.6720188",
"0.6693351",
"0.6691238",
"0.66717136",
"0.6663905",
"0.6663524",
"0.66394144",
"0.6585558",
"0.65437466",
"0.653401",
"0.64552194",
"0.6424414",
"0.6395701",
"0.636924... | 0.0 | -1 |
override this if the expected format differs in subclass | def format_phone_number(phone_number)
phone_number.digits
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format\n raise '#format must be implemented in child class'\n end",
"def format\n raise NotImplementedError\n end",
"def formats; end",
"def formats; end",
"def _process_format(format); end",
"def _process_format(format); end",
"def _process_format(format) # :nodoc:\n end",
"de... | [
"0.70941126",
"0.6746338",
"0.6254865",
"0.6254865",
"0.6243915",
"0.6243915",
"0.6044545",
"0.60167336",
"0.59922403",
"0.597576",
"0.597576",
"0.597576",
"0.597576",
"0.597576",
"0.597576",
"0.597576",
"0.597576",
"0.5972988",
"0.5932285",
"0.58962744",
"0.57720035",
"0.5... | 0.0 | -1 |
Raise an exception if the white list is being used (only sends to people on this list) and this phone number is not on the list | def check_white_list!(phone_number)
if self.class.config[:white_list] && !phone_number.white_list?
raise SmsOnRails::SmsError.new("Phone number #{phone_number.human_display} is not in white list")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_do_not_send!(phone_number)\n if phone_number.do_not_send?\n raise SmsOnRails::SmsError.new(\"Phone number #{phone_number.human_display} do not send is set:#{phone_number.do_not_send}\")\n end\n end",
"def sms_eligibility_check\n redirect_to(root_url) && return unless curr... | [
"0.63761723",
"0.6157981",
"0.6129648",
"0.61189705",
"0.6074947",
"0.5705701",
"0.56808025",
"0.5662786",
"0.55959517",
"0.5570956",
"0.5565378",
"0.54994494",
"0.54616123",
"0.5456171",
"0.5398248",
"0.53038",
"0.5284092",
"0.52454835",
"0.5221184",
"0.52178013",
"0.5201030... | 0.79890454 | 0 |
Raise an exception if this phone_number is marked as do not send | def check_do_not_send!(phone_number)
if phone_number.do_not_send?
raise SmsOnRails::SmsError.new("Phone number #{phone_number.human_display} do not send is set:#{phone_number.do_not_send}")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invalid_number\n xml = Twilio::TwiML::Response.new do |r|\n if params[:device] =~ /sms/\n r.Message \"Sorry, to use our Services your number must not be private.\"\n else\n r.Say \"Sorry, we don't allow Customers with private or blocked numbers.\"\n r.Say \"Please try again from an... | [
"0.607112",
"0.6060908",
"0.6054189",
"0.60044056",
"0.5925642",
"0.5805717",
"0.5770679",
"0.5762686",
"0.57417256",
"0.5707474",
"0.5676484",
"0.5671356",
"0.56031024",
"0.5597773",
"0.55894005",
"0.55642843",
"0.5537139",
"0.552299",
"0.5512725",
"0.55118793",
"0.5495996",... | 0.8045469 | 0 |
Raise exception if invalid data is entered | def assert_message_options!(phone_number, message, options)
raise SmsOnRails::SmsError.new("Invalid or undefined phone number: #{phone_number.human_display}") unless phone_number && phone_number.valid?
raise SmsOnRails::SmsError.new("No message specified") unless message
raise SmsOnRails::SmsError.new("Message is too long. #{message}") if message.length > self.class.max_characters
check_white_list!(phone_number)
check_do_not_send!(phone_number)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invalid\n puts \"Invalid entry, please try again.\"\n end",
"def invalid(*arguments)\n raise Invalid\n end",
"def is_valid?\n raise Exception\n end",
"def validate_input\n problems = test_input\n raise OperationalError, \"Found the following problems: #{problem... | [
"0.7204732",
"0.68714714",
"0.6782001",
"0.67791027",
"0.66476434",
"0.66430736",
"0.6570518",
"0.65528625",
"0.6529928",
"0.6499327",
"0.64077157",
"0.6353185",
"0.622718",
"0.6171436",
"0.61366737",
"0.6089337",
"0.6045087",
"0.60324174",
"0.602325",
"0.59874827",
"0.590345... | 0.0 | -1 |
return the appropriate exception class Return a fatal error if the block returns true and a non fatal if the block returns false | def sms_error_class(&block)#:nodoc
if yield
SmsOnRails::FatalSmsError
else
SmsOnRails::SmsError
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_exception?; end",
"def CATCH(exception_klass, &block)\n yield\n rescue ::Exception\n if $!.instance_of?(exception_klass)\n pass\n else\n failure(\"Faced a exception, that instance of #{exception_klass}.\",\n \"Faced a exception, that instance of #{$!.class}.\... | [
"0.64999",
"0.639861",
"0.62881917",
"0.6216377",
"0.6079258",
"0.60760385",
"0.6013458",
"0.5898451",
"0.5898451",
"0.5891785",
"0.5890962",
"0.58423346",
"0.5833738",
"0.5830342",
"0.58183247",
"0.57865447",
"0.57862973",
"0.5762253",
"0.5762216",
"0.57568586",
"0.57344645"... | 0.567967 | 22 |
The class used for phone numbers can be overwritten and specified in environment.rb | def phone_klass
config[:phone_klass]||SmsOnRails::PhoneNumber
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def phone_number; end",
"def phone_number; end",
"def cell_phone; end",
"def shape_phone_number\n self.phone_number = twilio_format phone_number\n end",
"def initialize(phone)\n @phone = phone\n end",
"def phone_number\n \"(#{Helpers::FakeIt.area_code}) #{Helpers::FakeIt.exchange_code}-#{Hel... | [
"0.7149462",
"0.7149462",
"0.6723532",
"0.66596115",
"0.6586894",
"0.6545018",
"0.64875835",
"0.6354251",
"0.63465804",
"0.63203377",
"0.63079596",
"0.63079596",
"0.63017267",
"0.62971115",
"0.6267595",
"0.6260722",
"0.62606966",
"0.62460846",
"0.6218876",
"0.6217696",
"0.619... | 0.8048162 | 0 |
Name of service provider (downcase no spaces) | def name
@name ||= self.to_s.demodulize.underscore
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def service_name\n self[:name].gsub(/\\.|,/, '_').gsub(/\\s/, '').underscore.to_sym if self[:name]\n end",
"def _display_name\n respond_to?(:service_name) ? service_name : name.split(\"::\").last\n end",
"def name\n @provider[:name]\n end",
"def name(_prefix = false)\n 'Providers'\n e... | [
"0.80776316",
"0.760347",
"0.7460511",
"0.74558145",
"0.74318576",
"0.7325714",
"0.7313657",
"0.73103267",
"0.72889596",
"0.72464234",
"0.7233958",
"0.71187687",
"0.7117379",
"0.7114123",
"0.70778394",
"0.7077228",
"0.70516884",
"0.7050071",
"0.7030351",
"0.7002944",
"0.70021... | 0.62288576 | 70 |
Human name of provider | def human_name
@human_name ||= self.to_s.demodulize.titleize
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def provider_name\n object.provider_id.titleize\n end",
"def name\n @provider[:name]\n end",
"def name\n @provider_name\n end",
"def plugin_human_name\n @plugin_human_name ||= \"#{provider_name.titleize} Provider\"\n end",
"def provider_name\n return @prov... | [
"0.83065915",
"0.80116135",
"0.7943693",
"0.79019463",
"0.7733817",
"0.75995886",
"0.75586027",
"0.75013816",
"0.7470618",
"0.738612",
"0.7384954",
"0.73716587",
"0.7368003",
"0.73118037",
"0.73118037",
"0.7308407",
"0.7301407",
"0.7301407",
"0.7286233",
"0.7265958",
"0.72626... | 0.7038715 | 83 |
Hash map of provider_id to the provider | def provider_map
@provider_map ||= provider_list.inject({}) do |map, klass|
map[klass.provider_id] = klass unless klass.nil?
map
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def provider_by_id(provider_id)\n provider_map[provider_id.to_i] if provider_id.to_i > 0\n end",
"def provider_key\n map_options.try(:[], :provider_key)\n end",
"def provider_config\n @config[:providers].each do |provider|\n # Convert the symbol from the config int... | [
"0.77841043",
"0.7281434",
"0.6751144",
"0.67248017",
"0.66945326",
"0.66607016",
"0.64579046",
"0.6436252",
"0.6308327",
"0.63036674",
"0.62080294",
"0.61596274",
"0.60550034",
"0.6043217",
"0.6032127",
"0.59899306",
"0.5988631",
"0.5912014",
"0.58991325",
"0.5866773",
"0.58... | 0.8484686 | 0 |
List of all providers available | def provider_list
@provider_list ||= subclasses.inject([]) do |list, klass_name|
klass = klass_name.constantize
begin
list << klass.instance
rescue LoadError => exc
logger.error "#{klass} load error: #{exc}"
end
list
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def providers\n @providers.keys\n end",
"def providers\n @providers ||= {}\n end",
"def providers\n url = url_with_api_version(@base_url, 'providers')\n resp = rest_get(url)\n JSON.parse(resp.body)[\"value\"]\n end",
"def providers\n driver(current_driver)... | [
"0.8306263",
"0.7844875",
"0.78092164",
"0.7733508",
"0.7679863",
"0.7518636",
"0.7396428",
"0.7349031",
"0.7271211",
"0.725279",
"0.72131926",
"0.7002545",
"0.69713765",
"0.6923558",
"0.6800231",
"0.67870593",
"0.67870593",
"0.67741054",
"0.67666966",
"0.67639494",
"0.673865... | 0.7353798 | 7 |
Locate the service provider by provider id Example: SmsOnRails::ServiceProviders::Base.provider_by_id 1 | def provider_by_id(provider_id)
provider_map[provider_id.to_i] if provider_id.to_i > 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_service_provider(provider)\n case provider.class.to_s\n when 'Fixnum' then provider_by_id(provider)\n when 'String' then (provider.to_i > 0 ? provider_by_id(provider) : provider_by_name(provider))\n when 'Symbol' then provider_by_name... | [
"0.7458697",
"0.72878104",
"0.7274961",
"0.7274961",
"0.69589186",
"0.6915681",
"0.684967",
"0.67321646",
"0.66674227",
"0.66674227",
"0.66674227",
"0.66674227",
"0.66674227",
"0.66674227",
"0.66674227",
"0.6658751",
"0.66550994",
"0.6650489",
"0.6648719",
"0.66163296",
"0.65... | 0.7632758 | 0 |
Locate the service provider by name or symbol Example: SmsOnRails::ServiceProviders::Base.provider_by_name :dummy | def provider_by_name(provider_name)
key = provider_name.to_s.downcase
provider_list.detect{|p| key == p.name || provider_name == p.human_name}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_service_provider(provider)\n case provider.class.to_s\n when 'Fixnum' then provider_by_id(provider)\n when 'String' then (provider.to_i > 0 ? provider_by_id(provider) : provider_by_name(provider))\n when 'Symbol' then provider_by_name... | [
"0.75238806",
"0.6708917",
"0.63696367",
"0.6368261",
"0.6309314",
"0.6273535",
"0.62581193",
"0.6247125",
"0.6228032",
"0.6226512",
"0.62250024",
"0.6215729",
"0.6200408",
"0.61664134",
"0.6146286",
"0.6123955",
"0.60825837",
"0.60461485",
"0.6016185",
"0.59677553",
"0.59562... | 0.6485821 | 2 |
Locate the service provider object by provider_id, string, symbol, or ServiceProvider object Defaults to the default service provider SmsOnRails::ServiceProviders::Base.get_service_provider :dummy SmsOnRails::ServiceProviders::Base.get_service_provider 1 SmsOnRails::ServiceProviders::Base.get_service_provider SmsOnRails::ServiceProviders::Dummy | def get_service_provider(provider)
case provider.class.to_s
when 'Fixnum' then provider_by_id(provider)
when 'String' then (provider.to_i > 0 ? provider_by_id(provider) : provider_by_name(provider))
when 'Symbol' then provider_by_name(provider)
when 'NilClass' then nil
else
provider
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_service_provider\n @service_provider = ServiceProvider.find(params[:id])\n end",
"def set_service_provider\n @service_provider = ServiceProvider.find(params[:id])\n end",
"def set_provider_service\n @provider_service = ProviderService.find(params[:id])\n end",
"def find_servic... | [
"0.7120375",
"0.7120375",
"0.7066134",
"0.6926658",
"0.6756454",
"0.664944",
"0.64757156",
"0.6442512",
"0.6427198",
"0.6407234",
"0.639914",
"0.62184274",
"0.62003773",
"0.6198943",
"0.61861867",
"0.6149234",
"0.6080506",
"0.60593235",
"0.6016637",
"0.60074884",
"0.59833676"... | 0.8196303 | 0 |
=== Validations === Instance Methods | def to_s
login
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validation; end",
"def validation; end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validator; end",
"def validate\n fail 'sub class to implement'\n end",
"def validate\n end",
"def is_valid; end",
"def validate!; end",
"def v... | [
"0.8152792",
"0.8152792",
"0.81295663",
"0.81295663",
"0.81295663",
"0.81295663",
"0.8064927",
"0.8014242",
"0.7988546",
"0.7982067",
"0.79448813",
"0.79448813",
"0.79448813",
"0.7857196",
"0.78026223",
"0.78026223",
"0.78026223",
"0.7795886",
"0.7775166",
"0.77417326",
"0.77... | 0.0 | -1 |
Creates and initializes a new instance of the Rollouts class. | def initialize(client)
@client = client
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize()\n @rolls = []\n end",
"def initialize \n\t\t @rolls = []\n\t end",
"def initialize\n @lister = Lister.new\n end",
"def initialize\n \n end",
"def initialize\n\t\t\t@numbershowing\n\t\t\t@@rolls = 0\n\t\tend",
"def initialize\n configure_trello\n end",
"def... | [
"0.60734344",
"0.57835203",
"0.54926264",
"0.5415586",
"0.5393725",
"0.5369428",
"0.53643847",
"0.5338317",
"0.531938",
"0.5290521",
"0.52732533",
"0.52668226",
"0.5263349",
"0.5256004",
"0.5256004",
"0.5256004",
"0.5256004",
"0.5256004",
"0.5256004",
"0.5256004",
"0.5254884"... | 0.0 | -1 |
Aaaand here's where I quit writing readable code. Good luck. Here be dragonnes. Abandon all hope, ye who enter here. Don't say I didn't warn you. | def index_of_coincidence(matrix)
matrix.inject([]) do |indices, row_letters|
frequencies = letter_frequencies(row_letters)
indices << ("A".."Z").inject(0) { |a,v|
x = frequencies[v]
a += x*(x-1)
a
} / (row_letters.size * (row_letters.size - 1))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sharp; accidental; end",
"def anchored; end",
"def code_like_crazy\r\n puts \"I'm crushing some code!\"\r\n end",
"def as_you_like_it_quote; end",
"def silly_adjective; end",
"def jack_handey; end",
"def beautify; end",
"def beautify; end",
"def autofinish; end",
"def big_bad; end",... | [
"0.64761376",
"0.6459945",
"0.6401181",
"0.63383317",
"0.6323038",
"0.629742",
"0.6257737",
"0.6257737",
"0.6247281",
"0.623469",
"0.6233748",
"0.6233748",
"0.61176527",
"0.6105489",
"0.6105489",
"0.6105489",
"0.60356885",
"0.60356885",
"0.60326856",
"0.60019815",
"0.5983476"... | 0.0 | -1 |
this logic would probably have made more sense in a `CommentsController`, since it would simplify the `PostsController` and keep it more focused. | def add_new_comment
# Get the object that you want to comment
commentable = Post.find(params[:id])
# Create a comment with the user submitted content
comment = Comment.new(comment_params)
# Add the comment
commentable.comments << comment
@comments = commentable.comments
respond_to do |format|
format.html { redirect_to root_path }
format.js
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n\n redirect_to controller: 'pages', action: 'dashboard', post_id: @post.id and return\n\n if params[:comment_order] == 'newest'\n @comments = @post.comments.order(created_at: :desc)\n elsif params[:comment_order] == 'upvote'\n @comments = @post.comments.sort_by{|x| count_opinion(x.opin... | [
"0.675864",
"0.657712",
"0.64732933",
"0.64732933",
"0.64477986",
"0.6359159",
"0.6296727",
"0.62833905",
"0.6242645",
"0.61736727",
"0.6171855",
"0.6138182",
"0.6129519",
"0.6106882",
"0.6072991",
"0.60716456",
"0.60702604",
"0.6067918",
"0.6061656",
"0.6059156",
"0.60554224... | 0.0 | -1 |
GET /tasks/1 GET /tasks/1.xml | def show
respond_with(@task = Task.find(params[:id]))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.xml { render :xml => @task }\n end\n end",
"def index\n get_tasks\n get_priorities\n get_users\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tasks }\n ... | [
"0.739653",
"0.71483886",
"0.706631",
"0.7033858",
"0.7030175",
"0.70199716",
"0.70163554",
"0.6996634",
"0.69620013",
"0.69607425",
"0.69607425",
"0.69607425",
"0.69607425",
"0.69607425",
"0.69188",
"0.6918308",
"0.6916772",
"0.6878961",
"0.68282247",
"0.6817829",
"0.678755"... | 0.0 | -1 |
GET /tasks/new GET /tasks/new.xml | def new
respond_with(@task = Task.new)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n format.xml { render xml: @tasks }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task }\n ... | [
"0.79913056",
"0.783725",
"0.7735345",
"0.7735345",
"0.7735345",
"0.7735345",
"0.7605314",
"0.7521009",
"0.7475729",
"0.74077904",
"0.7396494",
"0.72603416",
"0.7239029",
"0.7223643",
"0.7221421",
"0.7204809",
"0.71812963",
"0.7151181",
"0.7151181",
"0.7151181",
"0.7151181",
... | 0.0 | -1 |
POST /tasks POST /tasks.xml | def create
@task = params[:task] ? Task.create(params[:task]) : Task.create(:description=>params[:description], :isDone=>params[:isDone], :order=>params[:order] )
respond_with(@task)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tasks\n uri = URI(BASE_URL + TASKS_ENDPOINT)\n\n make_request(uri)\n end",
"def create_task(options = {})\n request(:post, \"tasks\", options)\n end",
"def post(action, task=nil, params={})\n @action = action\n @task = task\n request(:post, params)\n end",
"def add_ta... | [
"0.6856477",
"0.6845752",
"0.65675074",
"0.64086604",
"0.6378109",
"0.6377058",
"0.6344394",
"0.6312993",
"0.63005185",
"0.62720716",
"0.6271131",
"0.6255944",
"0.62371874",
"0.62227607",
"0.6221714",
"0.62177366",
"0.61810756",
"0.6178637",
"0.61708736",
"0.6165702",
"0.6162... | 0.62306863 | 13 |
PUT /tasks/1 PUT /tasks/1.xml | def update
@task = Task.find(params[:id])
params[:task] ? @task.update_attributes(params[:task]) : @task.update_attributes(:description=>params[:description], :isDone=>params[:isDone], :order=>params[:order] )
#@task.save
respond_with(@task)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n flash[:notice] = 'Task was successfully updated.'\n format.html { redirect_to(@task) }\n format.xml { head :ok }\n else\n format.html { render :action =>... | [
"0.66543084",
"0.6609352",
"0.6608818",
"0.65850276",
"0.65850276",
"0.6576394",
"0.65693724",
"0.656838",
"0.6545663",
"0.64219695",
"0.6406723",
"0.639931",
"0.6389918",
"0.6383213",
"0.6354153",
"0.6315247",
"0.63002414",
"0.62886757",
"0.62886757",
"0.62886757",
"0.627805... | 0.60626566 | 56 |
GET /offenses GET /offenses.json | def index
@offenses = Offense.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @expenses = find_expenses.all\n render json: @expenses\n end",
"def index\n @expenses = Expense.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end",
"def index\n @petty_cash_expenses = PettyCashExpense.all... | [
"0.75776654",
"0.71068573",
"0.6749626",
"0.6726666",
"0.6719622",
"0.668571",
"0.6649442",
"0.6632258",
"0.6614437",
"0.66078746",
"0.66050977",
"0.6593806",
"0.65027565",
"0.64805466",
"0.6334884",
"0.63270557",
"0.63270557",
"0.63270557",
"0.6317255",
"0.63116145",
"0.6283... | 0.7563574 | 1 |
GET /offenses/1 GET /offenses/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @offenses = Offense.all\n end",
"def index\n @expenses = find_expenses.all\n render json: @expenses\n end",
"def index\n @expenses = Expense.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end",
"def ind... | [
"0.7490258",
"0.7310726",
"0.70116097",
"0.6912074",
"0.6810443",
"0.6602823",
"0.65834475",
"0.65461856",
"0.65461856",
"0.65461856",
"0.65461856",
"0.65461856",
"0.6539045",
"0.6491504",
"0.6447113",
"0.63997185",
"0.63898754",
"0.63524115",
"0.63280684",
"0.6317086",
"0.63... | 0.0 | -1 |
POST /offenses POST /offenses.json | def create
host_name = begin
Resolv.getname(request.ip)
rescue Resolv::ResolvError
end || 'n/a'
params[:offense].merge!({:ip_address => request.ip, :host_name => host_name})
@offense = Offense.new(offense_params)
respond_to do |format|
if @offense.save
if @offense.email?
self.email
end
if @offense.phone?
self.sms
end
format.html { redirect_to @offense, notice: 'Offense was successfully created.' }
format.json { render :show, status: :created, location: @offense }
else
format.html { render :new }
format.json { render json: @offense.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @expense = Expense.new(expense_params)\n\n if @expense.save\n render json: @expense\n else\n render json: @expense.errors, status: :unprocessable_entity\n end\n end",
"def create\n # Get the variables passed in from params on create\n @expense = Expense.new(expense_param... | [
"0.64397866",
"0.6335863",
"0.62904537",
"0.62583876",
"0.6209672",
"0.6144524",
"0.61436576",
"0.6135067",
"0.61191994",
"0.60927397",
"0.6092162",
"0.5972164",
"0.5953867",
"0.5947",
"0.59128845",
"0.58974355",
"0.58756137",
"0.5847546",
"0.58367676",
"0.58366776",
"0.57520... | 0.0 | -1 |
PATCH/PUT /offenses/1 PATCH/PUT /offenses/1.json | def update
respond_to do |format|
if @offense.update(offense_params)
format.html { redirect_to @offense, notice: 'Offense was successfully updated.' }
format.json { render :show, status: :ok, location: @offense }
else
format.html { render :edit }
format.json { render json: @offense.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_with Expense.update(params[:id], expense_params), status: 204\n end",
"def update\n respond_to do |format|\n if @api_v1_expense.update(api_v1_expense_params)\n format.html { redirect_to @api_v1_expense, notice: 'Expense was successfully updated.' }\n format.json { r... | [
"0.67526627",
"0.6729683",
"0.65609837",
"0.64252037",
"0.63811225",
"0.637187",
"0.6313367",
"0.6313367",
"0.6271081",
"0.6257897",
"0.6251552",
"0.623205",
"0.6222745",
"0.6215098",
"0.6186781",
"0.6168107",
"0.6158371",
"0.6158371",
"0.6158371",
"0.6131059",
"0.6126703",
... | 0.6924017 | 0 |
DELETE /offenses/1 DELETE /offenses/1.json | def destroy
@offense.destroy
respond_to do |format|
format.html { redirect_to offenses_url, notice: 'Offense was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @api_v1_expense.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @expense.destroy\n\n respond_to do |format|\n format.html ... | [
"0.7225612",
"0.7159345",
"0.71342397",
"0.71342397",
"0.7132981",
"0.7132981",
"0.7128484",
"0.7126406",
"0.6981811",
"0.69228697",
"0.6864533",
"0.6864533",
"0.6849043",
"0.6821547",
"0.6811175",
"0.6811175",
"0.6811175",
"0.6811175",
"0.6811175",
"0.6811175",
"0.67957675",... | 0.7256284 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_offense
@offense = Offense.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 offense_params params[:offense] end Whitelisting IP Address | def offense_params
params.require(:offense).permit(:ip_address, :host_name, :email, :phone)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def client_face_ip_params\n params.fetch(:face_ip, {}).permit!\n end",
"def card_ip_params\n params.fetch(:card_ip, {}).permit!\n end",
"def face_ip_params\n params.fetch(:face_ip, {}).permit!\n end",
"def ... | [
"0.6451915",
"0.63072747",
"0.62550074",
"0.6174547",
"0.61519116",
"0.60925585",
"0.606579",
"0.6013168",
"0.5996419",
"0.5991109",
"0.593127",
"0.58840626",
"0.5820846",
"0.5767206",
"0.5748995",
"0.5748386",
"0.5742781",
"0.569169",
"0.56866574",
"0.5674833",
"0.5662369",
... | 0.8244986 | 0 |
Paypal payment request was cancelled, remove the associated transaction | def request_cancelled(source, token)
Transaction.where(community_id: token[:community_id], id: token[:transaction_id]).destroy_all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancel\n begin\n payment = Payment.find_by_token!(params[:token])\n payment.cancel!\n flash[:notice] = \"Sie haben die Bezahlung per Paypal abgebrochen.\"\n\n redirect_to edit_order_url(payment.order)\n rescue Exception => e\n redirect_to sto... | [
"0.69355446",
"0.6841983",
"0.6754656",
"0.6667826",
"0.6615182",
"0.65919185",
"0.6570695",
"0.65464526",
"0.64938396",
"0.6401845",
"0.6380504",
"0.6350311",
"0.63450956",
"0.63450956",
"0.6334871",
"0.6310997",
"0.6289712",
"0.62858653",
"0.62611973",
"0.62432975",
"0.6238... | 0.72221696 | 0 |
Privates TODO source not yet passed here, add when needed | def transition_type(tx, payment)
payment_status = payment[:payment_status]
pending_reason = payment[:pending_reason]
tx_state = tx[:status]
case [tx_state, payment_status, pending_reason]
when ["initiated", :pending, :authorization]
:initiated_to_preauthorized
when ["initiated", :voided, :none]
:initiated_to_voided
when ["preauthorized", :voided, :none]
else
:unknown_transition
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def internal; end",
"def usage; end",
"def usage; end",
"def extra; end",
"def private_method\n end",
"def private_notes\n \n end",
"def example_pending; end",
"def main_description; end",
"def pending?; end",
"def implementation; end",
"def implementation; end",
... | [
"0.68431306",
"0.6068417",
"0.6043124",
"0.6043124",
"0.59161043",
"0.58871865",
"0.5838618",
"0.5833893",
"0.57494",
"0.56986094",
"0.5692667",
"0.5692667",
"0.5692447",
"0.5670363",
"0.56643975",
"0.5653755",
"0.5649849",
"0.564068",
"0.5617287",
"0.56069773",
"0.56069773",... | 0.0 | -1 |
The _render_ method is used within a layout to inject the results of the template render. Ruhl::Engine.new(html, :layout => path_to_layout).render(self) | def _render_
document.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_rhtml(name)\n logmsg \"base_controller::render_rthml rendering #{name}\"\n content = get_rhtml(name)\n #logmsg \"base_controller::render_rhtml_internal() file not found #{name}\" if !content && @@debug\n return nil if !content\n if @body\n temp = body\n @body = \"\... | [
"0.7152846",
"0.69996667",
"0.6934577",
"0.6898046",
"0.6896382",
"0.6864809",
"0.686088",
"0.677647",
"0.67536",
"0.67215997",
"0.67098606",
"0.67098606",
"0.67020935",
"0.6696569",
"0.66872424",
"0.6673592",
"0.6666515",
"0.6646769",
"0.6625404",
"0.6603426",
"0.6600309",
... | 0.0 | -1 |
Here I want to check that the basket matches price. | def create_receipt
total_cost = 0
@basket.each {|item, quantity|
total_cost += price(item,quantity)
}
total_cost
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_price\n end",
"def check_basket(basket)\n increase_support if in_basket?(basket)\n end",
"def test_PPPPQRUVPQRUVPQRUVSU\n basket = Checkout.new.checkout('PPPPQRUVPQRUVPQRUVSU')\n # PPPPPP QQQ RRR S UUUU VVV\n # 250 + [80 + 150(Free Q?)] + 30 + 120 + 130\n # Q=30\n # R5 pricing:... | [
"0.7105521",
"0.6877894",
"0.68416524",
"0.6708596",
"0.6669452",
"0.66378236",
"0.66360927",
"0.64825416",
"0.64629155",
"0.63959813",
"0.6391854",
"0.6332381",
"0.6299121",
"0.62837476",
"0.62683326",
"0.6254401",
"0.62386584",
"0.6222037",
"0.6188844",
"0.61536664",
"0.613... | 0.59118223 | 42 |
Creates and mantains the regular expression | def create_regex_for_preffix(preffix)
@preffix_regexp = /#{preffix}-\d+/
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pattern2regex(pattern); end",
"def create pat, args = Hash.new\n negated = args[:negated]\n ignorecase = args[:ignorecase]\n wholewords = args[:wholewords]\n wholelines = args[:wholelines]\n extended = args[:extended]\n multiline = args[:multiline]\n\n flags = pattern_to_flags pat\... | [
"0.7329675",
"0.72689664",
"0.7261707",
"0.71062505",
"0.70473987",
"0.704684",
"0.6994994",
"0.6994994",
"0.69867474",
"0.6928799",
"0.6920296",
"0.68591547",
"0.6825901",
"0.6807855",
"0.67674977",
"0.67615503",
"0.6721402",
"0.67136043",
"0.6703084",
"0.6640034",
"0.663038... | 0.0 | -1 |
Initialize the basic configuration to start the commit validation | def init
$LOG = Logger.new($STDOUT,:pattern => config.log_pattern)
# repository = ARGV.shift
# transaction = ARGV.shift
# raise 'Bad Arguments' if !transaction or !repository
@projects = create_projects # parse the projects configuration
# @commit = Commit.new(repository,transaction)
@closed_status=config.closed_status
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n @configuring = false\n @validating = false\n end",
"def initialize(configuration)\n super\n require_configuration([:email, :password, :source])\n setup!\n end",
"def init_compile_config\n end",
"def initialize\n @config = DebMaker::Config.new\... | [
"0.67084014",
"0.6101736",
"0.60603243",
"0.6054827",
"0.60223264",
"0.5968312",
"0.5968312",
"0.59331715",
"0.59236073",
"0.59236073",
"0.5909103",
"0.5860426",
"0.58576787",
"0.5824547",
"0.5819913",
"0.58069026",
"0.58011544",
"0.579041",
"0.5743511",
"0.57093674",
"0.5704... | 0.5911225 | 10 |
Reached Summary 4 a simple method | def tame_it( number_of_shrews )
puts "Literally " + number_of_shrews.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suivre; end",
"def p15\n\t\nend",
"def schubert; end",
"def stest_method_1(test); end",
"def zuruecksetzen()\n end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; en... | [
"0.7104674",
"0.69082373",
"0.67580247",
"0.6692698",
"0.66250205",
"0.6539291",
"0.6539291",
"0.6539291",
"0.6539291",
"0.6539291",
"0.6539291",
"0.6539291",
"0.6539291",
"0.6539291",
"0.6539291",
"0.6539291",
"0.6539291",
"0.6513527",
"0.6513527",
"0.6513527",
"0.6513527",
... | 0.0 | -1 |
Finished Summary 5 Complete works of William Shakespeare | def get_shakey
{"William Shakespeare"=>{"1"=>{"title"=>"The Two Gentlemen of Verona", "finished"=>1591}, "2"=>{"title"=>"The Taming of the Shrew", "finished"=>1591}, "3"=>{"title"=>"Henry VI, Part 2", "finished"=>1591}, "4"=>{"title"=>"Henry VI, Part 3", "finished"=>1591}, "5"=>{"title"=>"Henry VI, Part 1", "finished"=>1592}, "6"=>{"title"=>"Titus Andronicus", "finished"=>1592}, "7"=>{"title"=>"Richard III", "finished"=>1593}, "8"=>{"title"=>"Edward III", "finished"=>1593}, "9"=>{"title"=>"The Comedy of Errors", "finished"=>1594}, "10"=>{"title"=>"Love's Labour's Lost", "finished"=>1595}, "11"=>{"title"=>"Love's Labour's Won", "finished"=>1596}, "12"=>{"title"=>"Richard II", "finished"=>1595}, "13"=>{"title"=>"Romeo and Juliet", "finished"=>1595}, "14"=>{"title"=>"A Midsummer Night's Dream", "finished"=>1595}, "15"=>{"title"=>"King John", "finished"=>1596}, "16"=>{"title"=>"The Merchant of Venice", "finished"=>1597}, "17"=>{"title"=>"Henry IV, Part 1", "finished"=>1597}, "18"=>{"title"=>"The Merry Wives of Windsor", "finished"=>1597}, "19"=>{"title"=>"Henry IV, Part 2", "finished"=>1598}, "20"=>{"title"=>"Much Ado About Nothing", "finished"=>1599}, "21"=>{"title"=>"Henry V", "finished"=>1599}, "22"=>{"title"=>"Julius Caesar", "finished"=>1599}, "23"=>{"title"=>"As You Like It", "finished"=>1600}, "24"=>{"title"=>"Hamlet", "finished"=>1601}, "25"=>{"title"=>"Twelfth Night", "finished"=>1601}, "26"=>{"title"=>"Troilus and Cressida", "finished"=>1602}, "27"=>{"title"=>"Sir Thomas More", "finished"=>1604}, "28"=>{"title"=>"Measure for Measure", "finished"=>1604}, "29"=>{"title"=>"Othello", "finished"=>1604}, "30"=>{"title"=>"All's Well That Ends Well", "finished"=>1605}, "31"=>{"title"=>"King Lear", "finished"=>1606}, "32"=>{"title"=>"Timon of Athens", "finished"=>1606}, "33"=>{"title"=>"Macbeth", "finished"=>1606}, "34"=>{"title"=>"Antony and Cleopatra", "finished"=>1606}, "35"=>{"title"=>"Pericles, Prince of Tyre", "finished"=>1608}, "36"=>{"title"=>"Coriolanus", "finished"=>1608}, "37"=>{"title"=>"The Winter's Tale", "finished"=>1611}, "38"=>{"title"=>"Cymbeline", "finished"=>1610}, "39"=>{"title"=>"The Tempest", "finished"=>1611}, "40"=>{"title"=>"Cardenio", "finished"=>1613}, "41"=>{"title"=>"Henry VIII", "finished"=>1613}, "42"=>{"title"=>"The Two Noble Kinsmen", "finished"=>1614}}}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def summary; end",
"def summary; end",
"def summary; end",
"def summary; end",
"def run\n\t\t\tsummary\n\t\tend",
"def finished\n day_noun = (@rubyist.days > 1 ? 'days' : 'day')\n real_noun = (@rubyist.real_ruby_count.zero? || @rubyist.real_ruby_count > 1 ? 'rubies' : 'ruby')\n fake_noun = (@rub... | [
"0.6162224",
"0.6162224",
"0.6162224",
"0.6162224",
"0.6040716",
"0.59971285",
"0.59166753",
"0.58814496",
"0.58805496",
"0.5797787",
"0.56916064",
"0.56916064",
"0.5656195",
"0.56453377",
"0.56308144",
"0.5592461",
"0.5589151",
"0.5585511",
"0.5538737",
"0.5536752",
"0.55327... | 0.0 | -1 |
Lots of chaining of methods | def count_plays(year)
s = get_shakey["William Shakespeare"]
.select { |k, v|
v["finished"] == year
}.each { |key, val|
puts val["title"]
}.count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chained_call(*methods)\n raise \"Not implemented yet.\"\n end",
"def chain\n [self]\n end",
"def calls; end",
"def calls; end",
"def chain_methods(methods)\n methods.inject(nil) do |memo, acc|\n target = memo ? memo : self\n target.respond_to?(acc) ? target.send(acc... | [
"0.6815666",
"0.620446",
"0.5979253",
"0.5979253",
"0.5871489",
"0.5756164",
"0.56570244",
"0.56570244",
"0.5585134",
"0.55830115",
"0.5459933",
"0.54297495",
"0.5356684",
"0.53369784",
"0.5329626",
"0.5321702",
"0.5321702",
"0.5321702",
"0.5321702",
"0.5321702",
"0.5321702",... | 0.0 | -1 |
Adding variables inside of a string, pretty printing | def print_plays(year_from, year_to)
get_shakey["William Shakespeare"]
.select { |k, v|
year_from <= v["finished"] &&
year_to >= v["finished"]
}.each { |k, v|
puts "#{v["title"].ljust(30)} #{v["finished"]}"
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatted_string\n format.dup.tap do |str|\n variables.each {|v| str.gsub!(\"%#{v}\", \"%{#{v}}\") }\n end\n end",
"def info\n str = <<INFO\nScenario: #{ name }\nSummary: #{ summary }\nDescription: #{ description_without_summary }\nINFO\n variables.each do |key, value|\n str << \"#{ ke... | [
"0.6988502",
"0.6172881",
"0.6124512",
"0.6100341",
"0.6099927",
"0.60922194",
"0.608978",
"0.608978",
"0.60632825",
"0.6061175",
"0.60416603",
"0.6027202",
"0.6021073",
"0.59818727",
"0.5979205",
"0.59609663",
"0.59600043",
"0.59533596",
"0.59449375",
"0.5937485",
"0.5916443... | 0.0 | -1 |
Adding variables inside of a string, pretty printing, and changing the way it prints | def print_plays(year_from, year_to)
get_shakey["William Shakespeare"]
.select { |k, v|
year_from <= v["finished"] &&
year_to >= v["finished"]
}.each { |k, v|
puts "#{v["finished"]} -> #{v["title"]}"
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatted_string\n format.dup.tap do |str|\n variables.each {|v| str.gsub!(\"%#{v}\", \"%{#{v}}\") }\n end\n end",
"def pretty_print pp\n pp.pp eval(self.asPPString)\n end",
"def pretty_print pp\n pp.pp eval(self.asPPString)\n end",
"def pretty_print\n puts `ruby -r pp ... | [
"0.69246227",
"0.6361746",
"0.6361746",
"0.6273618",
"0.6260569",
"0.6200668",
"0.61361897",
"0.6125556",
"0.61111057",
"0.6083935",
"0.6042953",
"0.60264343",
"0.601633",
"0.60158217",
"0.5995767",
"0.598452",
"0.59639335",
"0.5956553",
"0.595441",
"0.5952054",
"0.5952018",
... | 0.0 | -1 |
some good control expression docs | def hungry?(time_of_day_in_hours)
if time_of_day_in_hours < 12
puts "Me not hungry."
false
else
puts "Me hungry."
true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expression; end",
"def expressions; end",
"def allow_in_control=(_arg0); end",
"def triple_expression?; false; end",
"def conditions; end",
"def conditions; end",
"def expression\n super\n end",
"def control?(exp)\n exp[0] == :slim && exp[1] == :control\n end",
"def modifier; en... | [
"0.6579489",
"0.6452731",
"0.6260368",
"0.60075295",
"0.59925455",
"0.59925455",
"0.59374917",
"0.5932704",
"0.579051",
"0.57368916",
"0.57368916",
"0.5693686",
"0.5630768",
"0.5630768",
"0.5630768",
"0.5600261",
"0.5600261",
"0.5600261",
"0.5563613",
"0.5550398",
"0.55316633... | 0.0 | -1 |
Returns true if the authentication was successful and returns false otherwise. cs.authok? => true | def authok?
@connection.authok
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authok?\n @authok\n end",
"def authok?\n @authok\n end",
"def authok?\n @authok\n end",
"def authok?\n @authok\n end",
"def authok?\n @connection.authok\n end",
"def authentication_successful?\n current_user.present?\n end",
"def authentication_succes... | [
"0.8491629",
"0.8491629",
"0.8491629",
"0.8491629",
"0.8405789",
"0.7557303",
"0.7496545",
"0.7422437",
"0.72008777",
"0.7148655",
"0.71213865",
"0.7095634",
"0.7065356",
"0.69968003",
"0.69859827",
"0.6938615",
"0.69154394",
"0.68724346",
"0.68598443",
"0.68461335",
"0.68433... | 0.8420339 | 6 |
no options documented in API at Nov 2012 (e.g. like limit/marker as used in Nova for servers) | def list_volumes
response = @connection.req("GET", "/#{@volume_path}")
volumes_hash = JSON.parse(response.body)["volumes"]
volumes_hash.inject([]){|res, current| res << OpenStack::Volume::Volume.new(current); res}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def limit; @opts['limit']; end",
"def default_limit\n 10\n end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def optio... | [
"0.6679065",
"0.63825583",
"0.6315788",
"0.6315788",
"0.6315788",
"0.6315788",
"0.6315788",
"0.6315788",
"0.6315788",
"0.6315788",
"0.6315788",
"0.6315788",
"0.6315788",
"0.6315788",
"0.6315788",
"0.6315788",
"0.6315788",
"0.6315788",
"0.6315788",
"0.6315788",
"0.6315788",
... | 0.0 | -1 |
Lists all backend storage pools that are known to the scheduler service | def get_pools(details = true)
path = details ? "/scheduler-stats/get_pools?detail=true" : "/scheduler-stats/get_pools"
response = @connection.req('GET', path)
OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
JSON.parse(response.body)['pools']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list(mixins = nil)\n # TODO: impl filtering with mixins\n storage = ::Occi::Core::Resources.new\n backend_storage_pool = ::OpenNebula::ImagePool.new(@client)\n rc = backend_storage_pool.info_all\n check_retval(rc, Backends::Errors::ResourceRetrievalError)\n\n backend_s... | [
"0.67979616",
"0.66166264",
"0.6587234",
"0.6476892",
"0.64444256",
"0.63369656",
"0.6303545",
"0.62649304",
"0.6256877",
"0.6221136",
"0.6221136",
"0.612971",
"0.6088823",
"0.60607886",
"0.6053144",
"0.5999974",
"0.5978249",
"0.5918881",
"0.5895538",
"0.5871423",
"0.5857652"... | 0.68537563 | 0 |
fudge... not clear if volumes support is available as 'native' volume API or as the osvolumes extension. Need to probe to find out (for now) see | def check_if_native(entity) #volumes or snapshots
native = extension = false
#check if 'native' volume API present:
begin
response = @connection.req("GET", "/#{entity}")
native = true if response.code.match(/^20.$/)
return true, entity
rescue OpenStack::Exception::ItemNotFound => not_found
native = false
end
#check if available as extension:
begin
response = @connection.req("GET", "/os-#{entity}")
extension = true if response.code.match(/^20.$/)
return false, "os-#{entity}"
rescue OpenStack::Exception::ItemNotFound => not_found
extension = false
end
raise OpenStack::Exception::NotImplemented.new("No Volumes support for this provider", 501, "No #{entity} Support") unless (native || extension)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_logical_volume_management\n super\n end",
"def volume_ls\n help = [\n '',\n \"Use: #{me} volume ls\",\n '',\n 'Lists the names of all cyber-dojo volumes',\n '',\n minitab + '--quiet Only display volume names'\n ]\n\n if ['help','--help'].include? ARGV[2]\n show help\n ... | [
"0.7116416",
"0.67454046",
"0.6697699",
"0.6587313",
"0.656973",
"0.6462391",
"0.6437726",
"0.64210707",
"0.64145184",
"0.6413992",
"0.6393829",
"0.63899267",
"0.6353122",
"0.6324131",
"0.6323875",
"0.62404746",
"0.62152493",
"0.6207825",
"0.6199918",
"0.61632556",
"0.6161689... | 0.6624592 | 3 |
Return a list of ORFs delimited by STOP codons. | def get_stopstop_orfs
get_codon_orfs1(Proc.new { | codon | STOP_CODONS.include?(codon) },false,true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_startstop_orfs \n get_codon_orfs2(\n Proc.new { | codon | STOP_CODONS.include?(codon) },\n Proc.new { | codon | START_CODONS.include?(codon) })\n end",
"def orfs_from_start_stop_markers(start_markers, stop_markers, minimum_orf_length)\n # Split up the st... | [
"0.61452353",
"0.6030899",
"0.5720502",
"0.5501507",
"0.52980685",
"0.5287411",
"0.52649814",
"0.52113324",
"0.5175097",
"0.5095427",
"0.5091915",
"0.5048306",
"0.5045769",
"0.50185513",
"0.49812138",
"0.4937096",
"0.4878456",
"0.48067123",
"0.47399545",
"0.47248435",
"0.4690... | 0.69914395 | 0 |
Return a list of ORFs delimited by STARTSTOP codons | def get_startstop_orfs
get_codon_orfs2(
Proc.new { | codon | STOP_CODONS.include?(codon) },
Proc.new { | codon | START_CODONS.include?(codon) })
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def orfs_from_start_stop_markers(start_markers, stop_markers, minimum_orf_length)\n # Split up the start and stop positions into 3 frames\n frame_starts = [[],[],[]]\n frame_stops = [[],[],[]]\n start_markers.each do |marker|\n frame_starts[marker.position_in_trail % 3].push ma... | [
"0.6551506",
"0.6436381",
"0.5877394",
"0.5872888",
"0.5794939",
"0.55063105",
"0.54942244",
"0.5348923",
"0.529648",
"0.51855886",
"0.5170651",
"0.5106918",
"0.50936687",
"0.504723",
"0.5045142",
"0.5041984",
"0.5006834",
"0.48837626",
"0.4877997",
"0.48402274",
"0.4820959",... | 0.6950187 | 0 |
Splitter for one delimiter function. +include_leftmost+ decides the first sequence is returned when incomplete. +strip_leading+ is used to remove the shared codon with the last sequence. | def get_codon_orfs1 splitter_func,do_include_leftmost_orf,do_strip_leading_codon
orfs = split(@codons,splitter_func)
return [] if orfs.size == 0
# Drop the first sequence, if there is no match on the first position
orfs.shift if !do_include_leftmost_orf and !splitter_func.call(orfs.first[0])
orfs = orfs.map { |codons|
codons = codons.shift if do_strip_leading_codon and splitter_func.call(codons[0])
codons
}
if @reversed == nil
TrackSequenceTrait.update_sequence_pos(orfs,@ntseq_pos) # nail against parent
else
TrackSequenceTrait.update_reversed_sequence_pos(orfs,@ntseq_pos) # nail against parent
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_and_after begin_delimeter, end_delimeter\n\n Throw.if_nil_or_empty_strings [ self, begin_delimeter, end_delimeter ]\n\n before_after_lines = []\n in_middle_bit = false\n\n self.each do |candidate_line|\n\n is_middle_boundary = !in_middle_bit && candidate_line.downcase.include?(begin_del... | [
"0.5947802",
"0.59163254",
"0.59163254",
"0.57690996",
"0.57373065",
"0.5653975",
"0.5632193",
"0.5561947",
"0.5527968",
"0.5478926",
"0.5458706",
"0.5455709",
"0.5450381",
"0.5428848",
"0.5418789",
"0.54041255",
"0.5402338",
"0.53792846",
"0.5364278",
"0.53293383",
"0.532530... | 0.60272354 | 0 |
Splitter for two delimeter functions | def get_codon_orfs2 splitter_func, start_func
orfs = get_codon_orfs1(splitter_func,true,true)
orfs.find_all { | orf | start_func.call(orf[0]) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split(parts); end",
"def split; end",
"def split(pattern=$;, limit=0) end",
"def split(pattern=$;, limit=0) end",
"def make_delimiters\n ((self).split(//)*2+['',''])[0,2] # *2 doubles up single delimiters\n end",
"def splitter(data)\n data.split(%r{(?:@)[^\\s]+|(?:http)s?:\\/[^\\s]+|\\W}).re... | [
"0.70868903",
"0.6954385",
"0.67158985",
"0.67158985",
"0.6710254",
"0.6663027",
"0.63858867",
"0.63685197",
"0.632007",
"0.61797607",
"0.61695415",
"0.6163385",
"0.6155966",
"0.6146926",
"0.6142181",
"0.61408603",
"0.61347556",
"0.60366005",
"0.59695476",
"0.5968167",
"0.596... | 0.0 | -1 |
Return list of codon sequences, split on the +is_splitter+ function. | def split codons, is_splitter_func
list = []
node = []
codons.each_with_index do | c, pos |
# p [c,pos]
if is_splitter_func.call(c)
node.push c
size = node.size
# p node
list.push FrameCodonSequence.new(node,pos+1-size) if size > @min_size_codons
node = []
end
node.push c # always push boundary codon
end
list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_codon_orfs1 splitter_func,do_include_leftmost_orf,do_strip_leading_codon\n orfs = split(@codons,splitter_func)\n return [] if orfs.size == 0\n # Drop the first sequence, if there is no match on the first position\n orfs.shift if !do_include_leftmost_orf and !splitter_func.call(o... | [
"0.63078845",
"0.5879941",
"0.56280047",
"0.5411079",
"0.54092115",
"0.53848314",
"0.52199364",
"0.52010715",
"0.5199242",
"0.5153911",
"0.5153911",
"0.51255774",
"0.5019994",
"0.49772936",
"0.49729",
"0.49275488",
"0.49167195",
"0.48985064",
"0.48963857",
"0.4894775",
"0.489... | 0.8017075 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.