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 |
|---|---|---|---|---|---|---|
cyclic convolution modulo 2^n+1 n % ary.size == 0 | def cyclic_convolution(ary1, ary2, n)
t = bit_size(ary1.size()) - 1 # ary.size == 1 << t
if ary1.size() != 1 << t || ary2.size() != 1 << t
raise Exception.new("array size error")
end
if (n & ((1 << (t-1)) - 1)) != 0
raise Exception.new "2n = #{2 * n} is not divisible by ary1.size() = #{1 << t}"
end
# if ary1.size = ary2.size = 2^t, (2^k) ^ (2^(t-1)) = -1 (mod 2^n+1)
k = n >> (t - 1)
tary1 = fft_array(ary1, k, n)
tary2 = fft_array(ary2, k, n)
mod = (1 << n) + 1
tary3 = (0...ary1.size()).map{|i| (tary1[i] * tary2[i]) % mod}
cyc = fft_array(tary3, 2 * n - k, n)
shift = (- t) % (2 * n)
return cyc.map{|v| (v << shift) % mod}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cycle(n)\n RGL::ImplicitGraph.new { |g|\n g.vertex_iterator { |b| 0.upto(n - 1, &b) }\n g.adjacent_iterator { |x, b| b.call((x + 1) % n) }\n g.directed = true\n }\nend",
"def odd_occurances_in_array(a)\n res = 0\n a.each { |el| res ^= el }\n res\nend",
"def lights(n)\n arr = Array.new(n, fal... | [
"0.55054945",
"0.5475597",
"0.546741",
"0.54607236",
"0.54607236",
"0.5438385",
"0.54237103",
"0.5420741",
"0.54118574",
"0.53859615",
"0.53709435",
"0.5359481",
"0.5356478",
"0.5319074",
"0.5312995",
"0.5293206",
"0.5273345",
"0.5263234",
"0.525757",
"0.52497417",
"0.5229323... | 0.7657259 | 0 |
return nil if key not found | def search key, lambda = {}
node = head
while node.next_ != nil && node.key != key
node = node.next_
end
node
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(key)\n # TODO(himanshujaju) - possible improvement by not checking for contains.\n if contains?(key)\n return @key_data[key].value\n end\n\n return nil\n end",
"def get_key(key)\n return self.has_key?(key) ? self[key] : nil\n end",
"def [](key)\n entry = find_entry(key)\n ... | [
"0.764595",
"0.7531202",
"0.74527586",
"0.71697634",
"0.715943",
"0.7109091",
"0.7109091",
"0.7099716",
"0.7099716",
"0.7099716",
"0.7099716",
"0.7079075",
"0.7076702",
"0.7063363",
"0.70388335",
"0.70062685",
"0.70062685",
"0.6944243",
"0.6919608",
"0.69032305",
"0.6876623",... | 0.0 | -1 |
cases: head, middle, tail | def prev node_or_key
key = String.new
case node_or_key
when Node
key = node_or_key.key
when String
key = node_or_key
else
p "only accept String or Node type"
end
prev = node = @head
while node.next_ != nil && node.key != key
prev = node
node = node.next_
end
prev == node ? nil : prev
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def middle\n midpoint = list.length / 2\n end",
"def find_middle(a,b,c)\n # 1. declare variable middle\n # 2. loop through and check if middle is greater than one and less than the other\n\n middle = a\n\n if (b > a && b < c) || (b < a && b > cc)\n middle = b\n elsif (c > a && c < b) || (c < a && c >... | [
"0.62489176",
"0.62103444",
"0.61520547",
"0.6081897",
"0.6081897",
"0.5959004",
"0.5935482",
"0.59344673",
"0.5929618",
"0.5918859",
"0.5915154",
"0.5907069",
"0.5896174",
"0.58671296",
"0.58571255",
"0.5834754",
"0.5807077",
"0.57990414",
"0.5759156",
"0.5748365",
"0.574464... | 0.0 | -1 |
GET /sitio_entregas/1 GET /sitio_entregas/1.json | def show
@sitio_entrega = SitioEntrega.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @sitio_entrega }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @sitio_entrega = SitioEntrega.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sitio_entrega }\n end\n end",
"def show\n @ventas_seguimiento = Ventas::Seguimiento.find(params[:id])\n\n respond_to do |format|\n format.html # show.ht... | [
"0.67359674",
"0.6590937",
"0.6519723",
"0.6406275",
"0.6382886",
"0.6335316",
"0.6302145",
"0.62437135",
"0.62402153",
"0.62351805",
"0.6204664",
"0.62025803",
"0.6200174",
"0.6188148",
"0.6177987",
"0.6139789",
"0.61218244",
"0.61195296",
"0.61144066",
"0.6103776",
"0.61029... | 0.72258466 | 0 |
GET /sitio_entregas/new GET /sitio_entregas/new.json | def new
@sitio_entrega = SitioEntrega.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @sitio_entrega }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @sitio = Sitio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sitio }\n end\n end",
"def create\n @sitio_entrega = SitioEntrega.new(params[:sitio_entrega])\n\n respond_to do |format|\n if @sitio_entrega.save\n format.html ... | [
"0.7530848",
"0.74498546",
"0.7192133",
"0.7138677",
"0.7137307",
"0.7127602",
"0.71206623",
"0.7069516",
"0.7060682",
"0.7044356",
"0.70427996",
"0.70310795",
"0.7019095",
"0.70156276",
"0.6983367",
"0.6981057",
"0.6979328",
"0.69790643",
"0.6977481",
"0.6960423",
"0.6960273... | 0.8073723 | 0 |
POST /sitio_entregas POST /sitio_entregas.json | def create
@sitio_entrega = SitioEntrega.new(params[:sitio_entrega])
respond_to do |format|
if @sitio_entrega.save
format.html { redirect_to @sitio_entrega, notice: 'Sitio entrega was successfully created.' }
format.json { render json: @sitio_entrega, status: :created, location: @sitio_entrega }
else
format.html { render action: "new" }
format.json { render json: @sitio_entrega.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @solicitacao_repass = SolicitacaoRepasse.new(solicitacao_repasse_params)\n @entregas_externas = EntregaExterna.all\n @entregas_externas_usuario = []\n @entregas_externas.each { |entrega|\n if !@current_user.isMorador || entrega.encomenda.usuario.id == @current_user.id\n @entreg... | [
"0.66160685",
"0.63405",
"0.6112896",
"0.60575485",
"0.6039311",
"0.59959024",
"0.5985231",
"0.5969566",
"0.59591013",
"0.59528667",
"0.58831346",
"0.5870345",
"0.5828811",
"0.5826429",
"0.5818192",
"0.58138317",
"0.5808772",
"0.5791608",
"0.57794034",
"0.57789963",
"0.575841... | 0.7169737 | 0 |
PUT /sitio_entregas/1 PUT /sitio_entregas/1.json | def update
@sitio_entrega = SitioEntrega.find(params[:id])
respond_to do |format|
if @sitio_entrega.update_attributes(params[:sitio_entrega])
format.html { redirect_to @sitio_entrega, notice: 'Sitio entrega was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @sitio_entrega.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @sitio = Sitio.find(params[:id])\n\n respond_to do |format|\n if @sitio.update_attributes(params[:sitio])\n format.html { redirect_to @sitio, notice: 'Sitio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit... | [
"0.6501239",
"0.6408283",
"0.63286036",
"0.62558913",
"0.6212504",
"0.62105477",
"0.61563617",
"0.61542404",
"0.6153415",
"0.61470985",
"0.61047465",
"0.6057104",
"0.6007606",
"0.60025126",
"0.59903616",
"0.59795505",
"0.5951171",
"0.59373635",
"0.59272146",
"0.5926578",
"0.5... | 0.7085303 | 0 |
DELETE /sitio_entregas/1 DELETE /sitio_entregas/1.json | def destroy
@sitio_entrega = SitioEntrega.find(params[:id])
@sitio_entrega.destroy
respond_to do |format|
format.html { redirect_to sitio_entregas_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @sitio = Sitio.find(params[:id])\n @sitio.destroy\n\n respond_to do |format|\n format.html { redirect_to sitios_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @estatuto = Estatuto.find(params[... | [
"0.73021334",
"0.71570635",
"0.71375793",
"0.7129222",
"0.70199007",
"0.70123994",
"0.7004512",
"0.6987175",
"0.69804126",
"0.69774526",
"0.6959447",
"0.6948954",
"0.6926444",
"0.69222456",
"0.69222456",
"0.69182587",
"0.69179994",
"0.6905242",
"0.68983155",
"0.68756455",
"0.... | 0.7713222 | 0 |
although if that is true... | def average(numbers)
numbers.inject(&:+) / numbers.size.to_f # denominator here doesn't need to also be a float. appears that ruby will do a float operation as long as one of the numbers is a float
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check ; true ; end",
"def semact?; false; end",
"def missing?; false; end",
"def cond; end",
"def cond; end",
"def cond; end",
"def delicious?\n\t\treturn true\n\tend",
"def usable?; end",
"def delicious?\n #its automattically true\n true\n end",
"def ordinary?\n raise \"Not imp... | [
"0.7033626",
"0.67321324",
"0.64670956",
"0.63800216",
"0.63800216",
"0.63800216",
"0.63795036",
"0.6355983",
"0.63369423",
"0.6316404",
"0.6299604",
"0.62877285",
"0.62870985",
"0.6242616",
"0.62039644",
"0.6187153",
"0.6163032",
"0.61591196",
"0.61360645",
"0.61360645",
"0.... | 0.0 | -1 |
Creates a new project repository tag. | def create_tag(project, tag_name, ref)
post("/projects/#{project}/repository/tags", body: {tag_name: tag_name, ref: ref})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_git_tag\n assignment_repository.write do |git|\n git.add_tag git_tag\n end\n end",
"def create(project_name, repo_name, description) ; end",
"def create(*args)\n arguments(args, required: [:owner, :repo]) do\n assert_required :tag_name\n end\n\n post_request(\"/repo... | [
"0.77811885",
"0.7370256",
"0.6962069",
"0.66232294",
"0.6618189",
"0.6568815",
"0.65004575",
"0.64824104",
"0.6393642",
"0.63905096",
"0.6390205",
"0.63577193",
"0.6356802",
"0.63217884",
"0.63169396",
"0.6292334",
"0.6240523",
"0.6213849",
"0.6201555",
"0.60921854",
"0.6050... | 0.7295457 | 2 |
Gets a list of project commits. | def commits(project, options={})
get("/projects/#{project}/repository/commits", :query => options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commits\n @commits ||= data[:commits].map { |commit| project.commit(commit[:id]) }.reverse\n end",
"def commits\n if !@commits\n @commits = []\n x = 0\n loop do\n x += 1\n response = get(\"/commits/list/#{repo.owner.login}/#{repo.name}/#{name}?page=#{x}\")\... | [
"0.8059043",
"0.79601496",
"0.7731593",
"0.7360178",
"0.7218156",
"0.7217594",
"0.7202937",
"0.7174616",
"0.7017912",
"0.69887525",
"0.6985754",
"0.69642884",
"0.6937219",
"0.69228375",
"0.6864471",
"0.68420595",
"0.68070865",
"0.6732473",
"0.6726813",
"0.6630062",
"0.6627834... | 0.7511629 | 3 |
Gets a specific commit identified by the commit hash or name of a branch or tag. | def commit(project, sha)
get("/projects/#{project}/repository/commits/#{sha}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_commit(key, id)\n key = key_for(key)\n commit = git.commit(id)\n blob = commit.tree / key\n decode(blob.data) if blob\n end",
"def commit_hash(branch_or_tag = nil)\n git 'rev-parse', branch_or_tag || 'HEAD'\n end",
"def commit\n @commit ||= $repo.log.object(@rev || 'master').pat... | [
"0.7138344",
"0.70694304",
"0.678169",
"0.6779558",
"0.67632335",
"0.6541586",
"0.6531885",
"0.6518555",
"0.650949",
"0.6470585",
"0.6470031",
"0.63821596",
"0.6296212",
"0.62617964",
"0.62053144",
"0.61952734",
"0.61750686",
"0.6172559",
"0.6172032",
"0.61455774",
"0.6144231... | 0.56619275 | 50 |
Get the diff of a commit in a project. | def commit_diff(project, sha)
get("/projects/#{project}/repository/commits/#{sha}/diff")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diff\n @diff ||= begin\n commit.diffs.collect{|diff| diff.diff}.join(\"\\n\")\n end\n end",
"def diff(v1, v2)\n repos.git.diff(v1, v2, path)\n end",
"def project_commit(project, commit_id)\n get(\"/projects/#{project}/commits/#{commit_id}\")\n end",
"def de... | [
"0.748449",
"0.6550465",
"0.65012527",
"0.64549226",
"0.64403826",
"0.6407527",
"0.63548017",
"0.6296128",
"0.61614954",
"0.6129504",
"0.61057484",
"0.60760957",
"0.5980195",
"0.59370506",
"0.5935673",
"0.59257317",
"0.59093183",
"0.5906715",
"0.58954155",
"0.58913726",
"0.58... | 0.81532735 | 0 |
Only allow a trusted parameter "white list" through. | def twitter_auth_params
twitter_auth = request.env['omniauth.auth']
params[:twitter_token] = twitter_auth.credentials.token
params[:twitter_secret] = twitter_auth.credentials.secret
params[:name] = twitter_auth.info.name
params[:twitter_user_name] = twitter_auth.extra.access_token.params[:user_id]
params.permit(:twitter_token, :twitter_secret, :name, :twitter_user_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7123669",
"0.7054077",
"0.69472784",
"0.6902165",
"0.6736001",
"0.671985",
"0.6687218",
"0.6676269",
"0.66602534",
"0.6556639",
"0.6527985",
"0.645892",
"0.645072",
"0.64494324",
"0.6445436",
"0.64350927",
"0.6415061",
"0.6415061",
"0.6393001",
"0.6378958",
"0.6378958",
... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def github_auth_params
github_auth = request.env['omniauth.auth']
params[:github_token] = github_auth.credentials.token
params[:github_secret] = github_auth.credentials.secret
params.permit(:github_token, :github_secret)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
GET /poi_string_infos GET /poi_string_infos.json | def index
@poi_string_infos = PoiStringInfo.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_poi_string_info\n @poi_string_info = PoiStringInfo.find(params[:id])\n end",
"def create\n @poi_string_info = PoiStringInfo.new(poi_string_info_params)\n\n respond_to do |format|\n if @poi_string_info.save\n format.html { redirect_to @poi_string_info, notice: 'Poi string info wa... | [
"0.6653215",
"0.6394821",
"0.6214205",
"0.5891895",
"0.5565177",
"0.5505382",
"0.5453317",
"0.54525816",
"0.54396355",
"0.54217255",
"0.54191065",
"0.5374068",
"0.5374068",
"0.5374068",
"0.5312309",
"0.530637",
"0.5296154",
"0.5290894",
"0.5290894",
"0.5251553",
"0.52461123",... | 0.7199299 | 0 |
GET /poi_string_infos/1 GET /poi_string_infos/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @poi_string_infos = PoiStringInfo.all\n end",
"def set_poi_string_info\n @poi_string_info = PoiStringInfo.find(params[:id])\n end",
"def create\n @poi_string_info = PoiStringInfo.new(poi_string_info_params)\n\n respond_to do |format|\n if @poi_string_info.save\n format... | [
"0.6983725",
"0.6685613",
"0.6396974",
"0.62368155",
"0.60564965",
"0.5741987",
"0.5658269",
"0.55948246",
"0.5521714",
"0.5487671",
"0.5468613",
"0.5426213",
"0.5406299",
"0.53830665",
"0.5374716",
"0.53723174",
"0.53510445",
"0.53245926",
"0.5312426",
"0.5272522",
"0.526465... | 0.0 | -1 |
POST /poi_string_infos POST /poi_string_infos.json | def create
@poi_string_info = PoiStringInfo.new(poi_string_info_params)
respond_to do |format|
if @poi_string_info.save
format.html { redirect_to @poi_string_info, notice: 'Poi string info was successfully created.' }
format.json { render :show, status: :created, location: @poi_string_info }
else
format.html { render :new }
format.json { render json: @poi_string_info.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def poi_string_info_params\n params.require(:poi_string_info).permit(:title_name, :description, :image_url, :guage, :length, :color, :price, :stock, :image)\n end",
"def set_poi_string_info\n @poi_string_info = PoiStringInfo.find(params[:id])\n end",
"def update\n respond_to do |format|\n ... | [
"0.64825046",
"0.64744556",
"0.6394621",
"0.60644656",
"0.59239477",
"0.5407977",
"0.53541064",
"0.53218555",
"0.52623856",
"0.51999587",
"0.519422",
"0.5174476",
"0.5174476",
"0.5109533",
"0.51033324",
"0.50932765",
"0.5087993",
"0.5066947",
"0.50057995",
"0.49962658",
"0.49... | 0.7515538 | 0 |
PATCH/PUT /poi_string_infos/1 PATCH/PUT /poi_string_infos/1.json | def update
respond_to do |format|
if @poi_string_info.update(poi_string_info_params)
format.html { redirect_to @poi_string_info, notice: 'Poi string info was successfully updated.' }
format.json { render :show, status: :ok, location: @poi_string_info }
else
format.html { render :edit }
format.json { render json: @poi_string_info.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_poi_string_info\n @poi_string_info = PoiStringInfo.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @poi.update(poi_params)\n format.html { redirect_to @poi, notice: 'Poi was successfully updated.' }\n format.json { render :show, status: :ok, location: @po... | [
"0.62457955",
"0.60186386",
"0.60102487",
"0.58884627",
"0.5881059",
"0.5847038",
"0.5818213",
"0.58061725",
"0.58061725",
"0.5776465",
"0.5748342",
"0.5706756",
"0.57019717",
"0.5681039",
"0.5667468",
"0.56432045",
"0.5620928",
"0.56058794",
"0.5600469",
"0.5595869",
"0.5588... | 0.7607941 | 0 |
DELETE /poi_string_infos/1 DELETE /poi_string_infos/1.json | def destroy
@poi_string_info.destroy
respond_to do |format|
format.html { redirect_to poi_string_infos_url, notice: 'Poi string info was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_respons... | [
"0.66738385",
"0.6656586",
"0.6540769",
"0.6501973",
"0.6490474",
"0.6468278",
"0.6464689",
"0.64131516",
"0.6400209",
"0.63855326",
"0.63680327",
"0.6361325",
"0.63546157",
"0.63346773",
"0.6299952",
"0.6283255",
"0.62779725",
"0.62779725",
"0.62779725",
"0.62779725",
"0.626... | 0.7442672 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_poi_string_info
@poi_string_info = PoiStringInfo.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 poi_string_info_params
params.require(:poi_string_info).permit(:title_name, :description, :image_url, :guage, :length, :color, :price, :stock, :image)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981606",
"0.6784227",
"0.6746523",
"0.67439264",
"0.67361516",
"0.6593381",
"0.6506166",
"0.64994407",
"0.6483518",
"0.64797056",
"0.64578557",
"0.6441216",
"0.63811713",
"0.63773805",
"0.6366333",
"0.63217646",
"0.6301816",
"0.63009787",
"0.6294436",
"0.62940663",
"0.629... | 0.0 | -1 |
provide query string to search for result types str are > recent, popular or mixed finally total number of responses to be returned | def search_tweets(result_type, number_of_responses)
searchORstring = @searchArray.map { |hashtagElement| hashtagElement.to_s + " OR"}.join(" ")
search = @twitter_client.search(searchORstring, result_type: result_type).take(number_of_responses)
if search.empty? == false
search.each do |tweet|
@tweets << tweet
end
else
raise('Your search returned no tweets')
end
@tweets
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_process\n @search_text =params[:q].to_s\n all =params[:all].to_s\n exact =params[:exact].to_s\n any =params[:any].to_s\n none =params[:none].to_s\n advanced_query=\"\"\n\n if all != \"\"\n all =all.split(' ')\n all_like ... | [
"0.61585927",
"0.61147815",
"0.60973406",
"0.60973406",
"0.59958017",
"0.59958017",
"0.595409",
"0.5935756",
"0.5932532",
"0.5921634",
"0.59048563",
"0.5900984",
"0.58967066",
"0.5889535",
"0.5886544",
"0.5879159",
"0.5839543",
"0.5829515",
"0.5828318",
"0.58018595",
"0.57761... | 0.5600028 | 46 |
Returns the full name of a class. The interpretation of method names is: MyObjecttest An method defined in a class test A method defined in a singleton class. test A method defined in a singleton module. test A method defined in a singleton object. | def full_name
decorated_class_name = case self.klass_flags
when 0x2
"<Class::#{klass_name}>"
when 0x4
"<Module::#{klass_name}>"
when 0x8
"<Object::#{klass_name}>"
else
klass_name
end
"#{decorated_class_name}##{method_name}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_name method_name\n segments = method_name.split('::')\n return segments[0..-2].join('::') if segments.count > 1\n \"Object\"\nend",
"def full_class_name\n @class_names.join(\"::\")\n end",
"def class_name\n self.fullname[/\\A(.*)([\\.\\#])([^\\.\\#]+)\\z/, 1]\n end",
"def pretty_class_na... | [
"0.77164525",
"0.74373955",
"0.7428082",
"0.7224641",
"0.7197407",
"0.71511126",
"0.6973046",
"0.6969003",
"0.6956157",
"0.69556135",
"0.69529665",
"0.69419175",
"0.6937779",
"0.69260484",
"0.68456644",
"0.6835254",
"0.67754096",
"0.67656225",
"0.6740255",
"0.67367965",
"0.66... | 0.7411372 | 3 |
The number of times this method was called | def called
self.measurement.called
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_method\n @method_count += 1\n end",
"def call_count ; @call_count ||= 0 end",
"def count\n @count ||= 0\n @count += 1\n end",
"def count\n @count\n end",
"def count\n run.count\n end",
"def count; end",
"def count; end",
"def count; end",
"... | [
"0.7982139",
"0.787622",
"0.74983895",
"0.743834",
"0.742907",
"0.7385784",
"0.7385784",
"0.7385784",
"0.73351216",
"0.7330723",
"0.7303618",
"0.72688544",
"0.72688544",
"0.72688544",
"0.7242625",
"0.7242625",
"0.7218144",
"0.72035223",
"0.71944034",
"0.71796674",
"0.7158869"... | 0.0 | -1 |
The total time this method took includes self time + wait time + child time | def total_time
self.measurement.total_time
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children_time\n self.total_time - self.self_time - self.wait_time\n end",
"def time_elapsed\n\t\treturn Time.now - self.start_time\n\tend",
"def time_elapsed\n if !self.finished.blank?\n ((self.finished - self.started) / 60).to_i\n end\n end",
"def runtime_latency\n (finished_a... | [
"0.8160026",
"0.7312089",
"0.7233545",
"0.7214876",
"0.72101194",
"0.71424437",
"0.71276414",
"0.7086959",
"0.70382786",
"0.70088744",
"0.6994853",
"0.6922477",
"0.6794284",
"0.6760764",
"0.676059",
"0.67573965",
"0.674654",
"0.67451644",
"0.673573",
"0.6719414",
"0.6674986",... | 0.59417593 | 98 |
The time this method took to execute | def self_time
self.measurement.self_time
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time\n building_time + execution_time\n end",
"def time_elapsed\n\t\treturn Time.now - self.start_time\n\tend",
"def runtime_lat... | [
"0.7724427",
"0.7724427",
"0.7724427",
"0.7724427",
"0.7724427",
"0.7724427",
"0.7724427",
"0.7724427",
"0.7724427",
"0.7646601",
"0.7534093",
"0.75280577",
"0.7453578",
"0.7431644",
"0.73505443",
"0.73298925",
"0.7280433",
"0.7206121",
"0.7202744",
"0.7173293",
"0.7138406",
... | 0.0 | -1 |
The time this method waited for other fibers/threads to execute | def wait_time
self.measurement.wait_time
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_waiting\n end",
"def num_waiting\n end",
"def num_waiting\n synchronize do\n @num_waiting\n end\n end",
"def num_waiting\n synchronize do\n @num_waiting\n end\n end",
"def waitTime()\n time = Time.now().to_i / 60\n\n ... | [
"0.70912427",
"0.70912427",
"0.7053937",
"0.7053937",
"0.70439744",
"0.6989723",
"0.6931288",
"0.6824506",
"0.6572898",
"0.65671897",
"0.6550315",
"0.6520576",
"0.648258",
"0.64514256",
"0.641395",
"0.6377081",
"0.6377081",
"0.63668895",
"0.630222",
"0.6301624",
"0.6301624",
... | 0.68007267 | 8 |
The time this method's children took to execute | def children_time
self.total_time - self.self_time - self.wait_time
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children_duration; end",
"def total_time=(_arg0); end",
"def time\n building_time + execution_time\n end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def build_timing; ... | [
"0.7163077",
"0.7135039",
"0.710068",
"0.7007456",
"0.7007456",
"0.7007456",
"0.7007456",
"0.7007456",
"0.7007456",
"0.7007456",
"0.7007456",
"0.7007456",
"0.70040524",
"0.69814277",
"0.69470215",
"0.6806608",
"0.6801934",
"0.67708063",
"0.6766517",
"0.6762028",
"0.67349684",... | 0.79307455 | 0 |
IO to write to. | def io
@io ||= $stdout
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_to(io)\n end",
"def write_to(io)\n end",
"def write_to(io, *options); end",
"def write_to(io)\n open {|i|\n FileUtils.copy_stream(i, io)\n }\n end",
"def to_io() end",
"def _do_write(io)\n raise NotImplementedError\n end",
"def write(io)\n io = BinData::... | [
"0.8552005",
"0.8552005",
"0.78806746",
"0.773885",
"0.75552183",
"0.7545632",
"0.75155586",
"0.74931383",
"0.74794644",
"0.74650437",
"0.74640566",
"0.74451756",
"0.743397",
"0.7423803",
"0.73737204",
"0.73737204",
"0.73121643",
"0.7299923",
"0.7289191",
"0.7213779",
"0.7197... | 0.0 | -1 |
Use ANSI Control chars to reset prompt position for async output SEE | def print_line(msg = '')
# TODO: there are unhandled quirks in async output buffering that
# we have not solved yet, for instance when loading meterpreter
# extensions, supporting Windows, printing output from commands, etc.
# Remove this guard when issues are resolved.
=begin
if (/mingw/ =~ RUBY_PLATFORM)
print(msg + "\n")
return
end
print("\033[s") # Save cursor position
print("\r\033[K" + msg + "\n")
if input and input.prompt
print("\r\033[K")
print(input.prompt.tr("\001\002", ''))
print(input.line_buffer.tr("\001\002", ''))
print("\033[u\033[B") # Restore cursor, move down one line
end
=end
print(msg + "\n")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def partial_reset_terminal\n # Reset the terminal to a useable state (undo all changes).\n # '\\e[?7h': Re-enable line wrapping.\n # '\\e[?25h': Unhide the cursor.\n # '\\e[2J': Clear the terminal.\n # '\\e[;r': Set the scroll region to its default value.\n # Also sets cursor to (0,0).\n # '... | [
"0.70391345",
"0.6988649",
"0.6668308",
"0.6656264",
"0.66470915",
"0.6632336",
"0.66018045",
"0.65135866",
"0.649151",
"0.64698446",
"0.64364356",
"0.6402325",
"0.6399535",
"0.6387702",
"0.63806814",
"0.631608",
"0.6297576",
"0.628552",
"0.6281484",
"0.6274265",
"0.6258602",... | 0.0 | -1 |
Prints the supplied message to standard output. | def print_raw(msg = '')
if (Rex::Compat.is_windows and supports_color?)
WindowsConsoleColorSupport.new(io).write(msg)
else
io.print(msg)
end
io.flush
msg
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print(message)\n output.print(message)\n end",
"def puts(message)\n output.puts(message)\n end",
"def msg(message)\n stdout.puts message\n end",
"def puts(message)\n @out.puts message\n end",
"def print_message(msg)\n print \">> #{msg.to_s} \\n\"\n end",
"def... | [
"0.8524964",
"0.8167509",
"0.8108144",
"0.8010842",
"0.7976165",
"0.7934623",
"0.76430786",
"0.76136833",
"0.7602504",
"0.7587884",
"0.7587884",
"0.7581592",
"0.7580928",
"0.7574266",
"0.75528234",
"0.7535238",
"0.75060874",
"0.7473425",
"0.7434829",
"0.7434829",
"0.7430863",... | 0.0 | -1 |
GET /measurements GET /measurements.json | def index
@measurements = Measurement.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_measurements\n render json: @data_source.measurements\n end",
"def measurements_get(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: MeasurementApi#measurements_get ...\"\n end\n \n # resource path\n path = \"/measurements\".sub('{for... | [
"0.8182932",
"0.76638734",
"0.7288916",
"0.7128829",
"0.7030691",
"0.6826435",
"0.6779082",
"0.66834295",
"0.65405023",
"0.6538133",
"0.65258586",
"0.6518774",
"0.65174687",
"0.6479581",
"0.6467566",
"0.64651126",
"0.6461223",
"0.64146775",
"0.6412921",
"0.64020455",
"0.63874... | 0.69395006 | 7 |
GET /measurements/1 GET /measurements/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_measurements\n render json: @data_source.measurements\n end",
"def measurements_get(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: MeasurementApi#measurements_get ...\"\n end\n \n # resource path\n path = \"/measurements\".sub('{for... | [
"0.7923314",
"0.7458722",
"0.7430683",
"0.7127137",
"0.7073703",
"0.70128",
"0.6878834",
"0.68431467",
"0.6790905",
"0.6790905",
"0.6790905",
"0.6697087",
"0.66968346",
"0.66930157",
"0.66553426",
"0.6624585",
"0.6611417",
"0.6601687",
"0.65761304",
"0.65630513",
"0.64140636"... | 0.0 | -1 |
POST /measurements POST /measurements.json | def create
@measurement = Measurement.new(measurement_params)
respond_to do |format|
if @measurement.save
format.html { redirect_to @measurement, notice: 'Measurement was successfully created.' }
format.json { render :show, status: :created, location: @measurement }
else
format.html { render :new }
format.json { render json: @measurement.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def measurements_post(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: MeasurementApi#measurements_post ...\"\n end\n \n # resource path\n path = \"/measurements\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n q... | [
"0.7463286",
"0.70937914",
"0.7051505",
"0.69515663",
"0.6901001",
"0.6760174",
"0.66289425",
"0.66050494",
"0.66018677",
"0.65507644",
"0.65150756",
"0.65088737",
"0.64564294",
"0.64365596",
"0.64039403",
"0.6378345",
"0.6378031",
"0.6370461",
"0.6354153",
"0.63474035",
"0.6... | 0.7008744 | 4 |
PATCH/PUT /measurements/1 PATCH/PUT /measurements/1.json | def update
respond_to do |format|
if @measurement.update(measurement_params)
format.html { redirect_to @measurement, notice: 'Measurement was successfully updated.' }
format.json { render :show, status: :ok, location: @measurement }
else
format.html { render :edit }
format.json { render json: @measurement.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @measurement = Measurement.find(params[:id])\n\n respond_to do |format|\n if @measurement.update_attributes(params[:measurement])\n format.html { redirect_to body_measurement_path(@measurement), notice: 'Measurement was successfully updated.' }\n format.json { head :... | [
"0.68399465",
"0.6789872",
"0.6757394",
"0.66979384",
"0.66298884",
"0.6561728",
"0.654879",
"0.6473929",
"0.6467713",
"0.64453006",
"0.64453006",
"0.6443512",
"0.6412808",
"0.64087486",
"0.63905334",
"0.6375102",
"0.63676035",
"0.6317141",
"0.63092536",
"0.6237801",
"0.62361... | 0.68152285 | 3 |
DELETE /measurements/1 DELETE /measurements/1.json | def destroy
@measurement.destroy
respond_to do |format|
format.html { redirect_to measurements_url, notice: 'Measurement was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @measurement = Measurement.find(params[:id])\n @measurement.destroy\n\n respond_to do |format|\n format.html { redirect_to body_measurements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @k_measurement.destroy\n respond_to do |forma... | [
"0.7637748",
"0.75193834",
"0.7415383",
"0.7409122",
"0.7408486",
"0.7408399",
"0.73095185",
"0.72895634",
"0.7284229",
"0.7247026",
"0.7236325",
"0.72333264",
"0.72162807",
"0.72162807",
"0.7130605",
"0.70659244",
"0.6988571",
"0.6923675",
"0.6923675",
"0.6923675",
"0.690624... | 0.7415015 | 5 |
Use callbacks to share common setup or constraints between actions. | def set_measurement
@measurement = Measurement.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.61642385",
"0.60448",
"0.5945487",
"0.5915654",
"0.58890367",
"0.58330417",
"0.5776098",
"0.5703048",
"0.5703048",
"0.5654613",
"0.5620029",
"0.5423114",
"0.540998",
"0.540998",
"0.540998",
"0.5393666",
"0.53783023",
"0.53568405",
"0.53391176",
"0.5339061",
"0.53310865",
... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def measurement_params
params.require(:measurement).permit(:temperature, :humidity, :lightLevel, :device_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Hack used when importing old Topica email | def add_time
if (date.hour == 0 or date.hour == 12) and date.min == 0 and date.sec == 0
self.date = date + id
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inbound_email; end",
"def inbound_email; end",
"def include_csv_in_email; include_csv_in_email? rescue include_csv_in_email; end",
"def patch_mail_port(port)\n return nil if port.nil?\n\n msg = nil\n use_raw_message = true\n begin\n mail = TMail::Mail.new(port)\n \n if ma... | [
"0.60604495",
"0.60604495",
"0.59096134",
"0.57988524",
"0.56758344",
"0.56434774",
"0.5633379",
"0.5584186",
"0.55832505",
"0.55601674",
"0.55551594",
"0.5548235",
"0.55438924",
"0.55369145",
"0.5531459",
"0.5520202",
"0.5504799",
"0.54936045",
"0.54792523",
"0.5476809",
"0.... | 0.0 | -1 |
Replace a couple letters from email addresses to avoid spammers | def sender_obscured
if sender.blank? or !topica_message_id.blank?
return sender
end
sender_parts = sender.split("@")
if sender_parts.size > 1
user_name = sender_parts.first
if user_name.length > 2
return user_name[0..(user_name.length - 3)] + "..@" + sender_parts.last
else
return "..@" + sender_parts.last
end
end
return sender
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize_email(email)\n email.gsub(/@/, \"_at_\").gsub(/\\./, \"_dot_\")\n end",
"def normalize_email_address email_address\n email_address.downcase.sub(/swan\\.ac\\.uk/,'swansea.ac.uk')\nend",
"def obfuscate_email(email)\n return nil if email.blank?\n parts = email.split(\"@\")\n \n local... | [
"0.74586105",
"0.7435353",
"0.7299783",
"0.71879745",
"0.7137203",
"0.707343",
"0.7054633",
"0.7024764",
"0.6988438",
"0.6978625",
"0.69681895",
"0.6962235",
"0.69324625",
"0.68090767",
"0.67585474",
"0.67342526",
"0.6718909",
"0.67158836",
"0.6711552",
"0.6573368",
"0.655757... | 0.0 | -1 |
Used by Topica import only? | def update_sender
if !@from_name.blank? and from_email_address and !@from_email_address.empty? and !(@from_name.to_s == @from_email_address.to_s )
self.sender = "#{@from_name} <#{@from_email_address}>"
else
self.sender = @from_email_address.to_s
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import()\n # TODO\n end",
"def import\n end",
"def import\n end",
"def import\n end",
"def import\n end",
"def before_import ; end",
"def import_show \n end",
"def private; end",
"def import_csv_full\n \n end",
"def prepare_pre_import\n end",
"def pre_export\n en... | [
"0.64086604",
"0.6327908",
"0.6327908",
"0.6327908",
"0.6327908",
"0.6121667",
"0.6043677",
"0.6031991",
"0.5815691",
"0.5765118",
"0.57504255",
"0.57322544",
"0.5709853",
"0.57063645",
"0.56262434",
"0.56245804",
"0.5569714",
"0.55491793",
"0.55491793",
"0.5534346",
"0.55058... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_volunteer_work
@volunteer_work = VolunteerWork.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def volunteer_work_params
params.require(:volunteer_work).permit( :name, :company, :dates => [], :city => [], :province => [], :skills => [], :tags => [] )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
def anyeong UserMailer.welcome(self).deliver_now end | def set_color
self.color = ["#7AD8E5", "#63b4d1", "6da7d3", "#7699d4", "#816ec4", "#8658bc", "#602278", "#34023C"].sample
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_welcome_mail\n UserMailer.welcome(self).deliver_now\n end",
"def send_welcome_email\n UserMailer.welcome(self).deliver_now\n end",
"def welcome_send\n UserMailer.welcome_email(self).deliver_now\n end",
"def send_welcome\n UserMailer.welcome_email(self).deliver!\n end",
"def send_we... | [
"0.9322437",
"0.9300937",
"0.92675996",
"0.92045844",
"0.9191218",
"0.9134269",
"0.87171483",
"0.8679482",
"0.8635882",
"0.8626103",
"0.85938036",
"0.8381311",
"0.8381311",
"0.8362826",
"0.8226842",
"0.8217412",
"0.8195386",
"0.8191968",
"0.81709266",
"0.8167631",
"0.8093004"... | 0.0 | -1 |
puts same_first_last([1,2,1]) puts same_first_last([1,2,3]) puts same_first_last([1]) | def middle(list)
if list.size%2 == 1 # odd length sorted
return list[list.size/2]
else # even length sorted
return (list[list.size/2] + list [list.size / 2 -1]) / 2.0
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def same_first_last(list)\n if list[0] == list[list.size - 1]\n return true\n end \n \n return false\n\nend",
"def same_first_last(list) # done\n if list.size < 1\n return false\n end\n\n if list[0] != list[list.size - 1]\n return false\n end\n \n return true\ne... | [
"0.80049926",
"0.7945362",
"0.7919264",
"0.79059166",
"0.7905464",
"0.78929585",
"0.7886183",
"0.7789196",
"0.7699547",
"0.70792353",
"0.7063506",
"0.64577127",
"0.6382212",
"0.6367017",
"0.62049186",
"0.62049186",
"0.6203478",
"0.61590344",
"0.61583847",
"0.6139788",
"0.6128... | 0.0 | -1 |
puts count_code("code cope hi great") > 2 puts count_code("four") | def threed(list)
count3 = 0
next_to = 0
list.each do |n|
if n == 3
count3 += 1
end
end
(list.size-1).times do |n|
if list[n] == list[n+1]
return false
end
end
if count3 == 3
return true
elsif count3 > 3 || count3 < 3
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_code(str)\n\n\n\nend",
"def count_code(string)\n count = 0\n empty = []\n (string.size - 3).times do |i|\n slice = string[i..(i + 3)]\n if slice == \"code\" \n count += 1\n end\n end\n return count \nend",
"def count_code(str)\n times = 0\n str.size.times do |... | [
"0.7489371",
"0.7028103",
"0.6944962",
"0.6940298",
"0.6762865",
"0.66944903",
"0.6621032",
"0.6593418",
"0.6581127",
"0.6315155",
"0.6148184",
"0.6142316",
"0.60966897",
"0.60906667",
"0.60906667",
"0.60666436",
"0.6057095",
"0.6056152",
"0.60495955",
"0.60223454",
"0.601440... | 0.0 | -1 |
puts threed([3,3,3]) false puts threed([3,4,5,3,9,3]) true puts threed([3]) false | def either_2_4(list)
count_2 = 0
count_4 = 0
list.size.times do |n|
if list[n] == 2 && list[n+1] == 2
count_2 += 1
end
if list[n] == 4 && list[n+1] == 4
count_4 += 1
end
end
if (count_2 > 0) ^ (count_4 > 0)
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def threed(list)\n hasthree = 0\n inarow = 0\n list.size.times do |i|\n if list[i] == 3\n hasthree += 1\n end\n if list[i] == 3 && list[i+1] == 3 && i != (list.size - 1)\n inarow += 1\n end\n end\n if hasthree == 3 && inarow == 0\n return true... | [
"0.68010557",
"0.66388476",
"0.64433193",
"0.64287955",
"0.6371611",
"0.6196692",
"0.6173719",
"0.6163767",
"0.61615145",
"0.614795",
"0.6133929",
"0.60760295",
"0.60419285",
"0.6036737",
"0.60236853",
"0.597517",
"0.5961445",
"0.5947091",
"0.5906475",
"0.58933914",
"0.582622... | 0.0 | -1 |
puts either_2_4([2,2,4,4]) false puts either_2_4([2,2,3,4,5]) true puts either_2_4([4,4,2,3]) true puts either_2_4([2,3,4]) false | def g_happy(string)
count_g = 0
next_to = 0
string.size.times do |n|
if string[n] == "g"
count_g += 1
end
if string[n] == "g" && string[n+1] == "g"
next_to += 1
end
end
if next_to == (count_g-1)
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def either_2_4(list)",
"def either_2_4(list)\n count = 0\n i = 0\n list.each do |num|\n if num == 2 && count == 0\n if num == list[i + 1]\n count += 2\n end\n elsif num == 4 && count == 0\n if num == list[i + 1]\n count += 1\n ... | [
"0.72736794",
"0.7264446",
"0.72506666",
"0.7220779",
"0.70912075",
"0.7059292",
"0.70482785",
"0.691898",
"0.6632149",
"0.65230185",
"0.6494494",
"0.64317244",
"0.63974535",
"0.6387432",
"0.6375101",
"0.6363252",
"0.6354962",
"0.6306087",
"0.6300578",
"0.6274005",
"0.6259593... | 0.0 | -1 |
puts g_happy("ggg")true puts g_happy("ggh")true puts g_happy("h")false puts g_happy("gghg")false puts g_happy("fff")false | def shift_left(string)
new_string = string[1..string.size]
last_number = string[0]
print new_string.insert(-1,last_number)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def g_happy(str)\n i = 0\n g = 0\n while i < str.size\n if str[i] == \"g\"\n g = 1\n if str[i - 1] != \"g\" && str[i + 1] != \"g\"\n return false\n end\n end\n i += 1\n end\n if g == 1\n return true\n end\nend",
"def g_... | [
"0.6975056",
"0.68028826",
"0.66570306",
"0.66441786",
"0.66078323",
"0.66078323",
"0.66032684",
"0.66032684",
"0.65773726",
"0.65539235",
"0.65015465",
"0.64984334",
"0.64846843",
"0.64355826",
"0.64298373",
"0.6374262",
"0.6374012",
"0.63487494",
"0.63477075",
"0.63443094",
... | 0.0 | -1 |
this function protects us to going to url like users/edit directly and trying to edit it from there | def require_user
if !logged_in?
flash[:alert] = "You must be logged in to perform that action"
redirect_to login_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_user\n redirect_to(root_url) unless current_user.edit?\n end",
"def user_edits\n redirect_to home_path if current_user != User.find(params[:id])\n end",
"def edit\n redirect_back_or_default(\"/\") if\n !@user&.admin && session[:real_user_id].blank?\n end",
"def edit\n if cu... | [
"0.75381124",
"0.7521729",
"0.75193965",
"0.7420151",
"0.73785657",
"0.73145485",
"0.73120826",
"0.7311876",
"0.7204518",
"0.7191402",
"0.7190579",
"0.71894675",
"0.7160426",
"0.715692",
"0.70915407",
"0.705454",
"0.70277244",
"0.7018715",
"0.6961616",
"0.6930012",
"0.6928093... | 0.0 | -1 |
GET /admin_notifications GET /admin_notifications.json | def index
response.headers['X-Total-Count'] = @admin_notifications.count.to_s
response.headers['X-Unread-Count'] = @admin_notifications.unread.count.to_s
@admin_notifications = @admin_notifications.page(params[:page] || 1)
@admin_notifications = @admin_notifications.per(params[:per] || 8)
_render collection: @admin_notifications
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notifications\n query_api_object Notification, \"/rest/notifications\", nil, \"GET\", \"notifications\"\n end",
"def get_notifications\n begin\n response = notifications_api.get\n [parse_json(response), nil]\n rescue RestClient::Unauthorized\n [{}, Unauthorized]\n end\n end",... | [
"0.8003657",
"0.79020095",
"0.75761664",
"0.7197119",
"0.7169508",
"0.7169508",
"0.716485",
"0.70994294",
"0.70314884",
"0.69874656",
"0.6957934",
"0.69464636",
"0.6944871",
"0.6928412",
"0.6928412",
"0.6928412",
"0.6928412",
"0.6928412",
"0.6928412",
"0.6921202",
"0.6886105"... | 0.6470933 | 51 |
GET /admin_notifications/1 GET /admin_notifications/1.json | def show
_render member: @admin_notification
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notifications\n query_api_object Notification, \"/rest/notifications\", nil, \"GET\", \"notifications\"\n end",
"def get_notifications\n begin\n response = notifications_api.get\n [parse_json(response), nil]\n rescue RestClient::Unauthorized\n [{}, Unauthorized]\n end\n end",... | [
"0.7704337",
"0.7571825",
"0.7326361",
"0.7030606",
"0.69473433",
"0.68925023",
"0.68925023",
"0.6877836",
"0.6877836",
"0.6877836",
"0.6877836",
"0.6877836",
"0.6877836",
"0.6851496",
"0.6844139",
"0.68436307",
"0.6829322",
"0.68271995",
"0.68068516",
"0.6795541",
"0.6794230... | 0.0 | -1 |
POST /admin_notifications POST /admin_notifications.json | def create
@admin_notification = AdminNotification.new(admin_notification_params)
if @admin_notification.save
render json: @admin_notification, status: :created, location: @admin_notification
else
render json: @admin_notification.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_notification(attributes)\n begin\n response = notifications_api.post(encode_json(attributes))\n [parse_json(response), nil]\n rescue RestClient::UnprocessableEntity => e\n [parse_json(e.response), InvalidNotification]\n rescue RestClient::Unauthorized\n [{}, Unauthorized]\n ... | [
"0.7138121",
"0.6886588",
"0.6886118",
"0.68697685",
"0.6767496",
"0.6733808",
"0.67185163",
"0.6693988",
"0.66155106",
"0.65390414",
"0.64953727",
"0.6484782",
"0.64844364",
"0.6458643",
"0.6456943",
"0.6456943",
"0.6456671",
"0.6452646",
"0.644767",
"0.6356449",
"0.63468283... | 0.7616035 | 0 |
PATCH/PUT /admin_notifications/1 PATCH/PUT /admin_notifications/1.json | def update
@admin_notification = AdminNotification.find(params[:id])
if @admin_notification.update(admin_notification_params)
head :no_content
else
render json: @admin_notification.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_many\n if @admin_notifications.update_all(admin_notification_params)\n render json: @admin_notifications, status: :ok, location: admin_notifications_url\n else\n render json: @admin_notifications.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @notification.... | [
"0.72737104",
"0.7040323",
"0.69660634",
"0.69210505",
"0.6890913",
"0.67889357",
"0.67794514",
"0.67794514",
"0.67794514",
"0.67610556",
"0.6755111",
"0.6752075",
"0.6752075",
"0.672022",
"0.67076397",
"0.6706347",
"0.6650512",
"0.6650512",
"0.6650512",
"0.6650512",
"0.66505... | 0.7434872 | 0 |
DELETE /admin_notifications/1 DELETE /admin_notifications/1.json | def destroy
@admin_notification.destroy
head :no_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n @notification = Users::Notification.find_by_id(params[:id])\n @notification.set_status_deleted\n\n respond_to do |format|\n format.html { redirect_to notification_path }\n format.json { head :no_content }\n end\n end",
"def delete_Notification\n ... | [
"0.7534156",
"0.7377496",
"0.736814",
"0.7356761",
"0.73550665",
"0.73550665",
"0.73550665",
"0.73550665",
"0.7341548",
"0.732397",
"0.73096806",
"0.72913986",
"0.7225187",
"0.7219184",
"0.7212782",
"0.7201877",
"0.715719",
"0.7134006",
"0.71266514",
"0.7112317",
"0.71058166"... | 0.7710944 | 0 |
PATCH/PUT /admin_notifications PATCH/PUT /admin_notifications.json | def update_many
if @admin_notifications.update_all(admin_notification_params)
render json: @admin_notifications, status: :ok, location: admin_notifications_url
else
render json: @admin_notifications.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @admin_notification = AdminNotification.find(params[:id])\n\n if @admin_notification.update(admin_notification_params)\n head :no_content\n else\n render json: @admin_notification.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @notification.update(noti... | [
"0.74815065",
"0.7005151",
"0.70048636",
"0.6968359",
"0.69168967",
"0.69091284",
"0.6860783",
"0.6856318",
"0.67660147",
"0.6704624",
"0.6704624",
"0.6704624",
"0.668592",
"0.66737497",
"0.66363215",
"0.6630739",
"0.6630739",
"0.66172695",
"0.66168547",
"0.66168547",
"0.6616... | 0.75510406 | 0 |
Make application name available ex: Rails.application.name => 'loonystay' refer to db/config.yml for example usage | def name
@name ||= Rails.application.class.parent_name.underscore
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def application_name\n @application_name ||= t('application.name')\n end",
"def application_name\n @application_name || _application_name_from_namespace || _default_application_name\n end",
"def appname\n \"Application\"\n end",
"def app_name\n @app_name || Sapience.app_name\n end... | [
"0.79986113",
"0.7928216",
"0.7853529",
"0.7851118",
"0.78489566",
"0.7819406",
"0.78000504",
"0.77857316",
"0.77808577",
"0.7766148",
"0.77653325",
"0.7679764",
"0.7679764",
"0.7675186",
"0.76657385",
"0.7649656",
"0.7629634",
"0.7629634",
"0.756973",
"0.75205797",
"0.751867... | 0.70512635 | 34 |
count the number of likes and dislikes for the current recipe object | def thumbs_up_total
self.likes.where(like: true).size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def likes_count\n self.likes.size\n end",
"def total_like\n self.likes.where(like: true).size\n end",
"def likes_count\n self.likes_count_field\n end",
"def likes_count\n Recommendable.config.ratable_classes.inject(0) do |sum, klass|\n sum + liked_count_for(klass)\n end... | [
"0.7822416",
"0.765125",
"0.7608864",
"0.7576145",
"0.7481628",
"0.74583393",
"0.7449182",
"0.7440581",
"0.7426327",
"0.73970413",
"0.7334916",
"0.7313863",
"0.7264407",
"0.72591794",
"0.71020424",
"0.7067989",
"0.7058356",
"0.6977899",
"0.69290036",
"0.6897675",
"0.68730193"... | 0.6699191 | 30 |
If the number is a multiple of 5 it is "buzz" | def is_buzz?(number)
number % 5 == 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mult_five(number)\n if number%5 === 0\n puts \"#{number} is a multiple of 5.\"\n else\n puts \"#{number} is not a multiple of 5.\" # You need the hash stuff here because you can't add an integer to a string, you idiot.\n end\nend",
"def fizzbuzz(number)\n if (number % 5 == 0 && number % 3 == 0)\n ... | [
"0.7572428",
"0.7556022",
"0.7473894",
"0.74111325",
"0.7409725",
"0.739679",
"0.7342342",
"0.733991",
"0.73387915",
"0.73267126",
"0.73241323",
"0.73129654",
"0.72944975",
"0.7288359",
"0.7266641",
"0.7265508",
"0.7263424",
"0.72539985",
"0.72510064",
"0.72142565",
"0.721168... | 0.7812979 | 0 |
Calculate the fizzbuzz result for a particular value | def fizz_buzz(n)
fizz = is_fizz?(n)
buzz = is_buzz?(n)
if fizz and buzz
"FizzBuzz"
elsif fizz
"Fizz"
elsif buzz
"Buzz"
else
n
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fizzbuzz(value)\n result = nil\n if (value % 3 == 0 && value % 5 == 0 )\n result = \"FizzBuzz\"\n elsif (value % 3 == 0)\n result = \"Fizz\"\n elsif (value % 5 == 0 )\n result = \"Buzz\"\n end\n result\n end",
"def fizzbuzz(value)\n answer = \" \"\n failure = 0\n if(value... | [
"0.807601",
"0.7863567",
"0.754134",
"0.75078726",
"0.7485758",
"0.7479727",
"0.74040514",
"0.73897874",
"0.7301668",
"0.7274537",
"0.72722596",
"0.7244526",
"0.7201841",
"0.71882004",
"0.71871835",
"0.7158659",
"0.7141604",
"0.71361446",
"0.71248925",
"0.7105273",
"0.7105273... | 0.68363297 | 89 |
Return an array containing the results for each value in the specified range | def fizz_buzz_for_range(from, to)
results = []
(from..to).each do |n|
results.push fizz_buzz(n)
end
results
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def values(range = nil)\n result_unflatten = if !::RANGES_JRUBY_BUG\n map { |x| x.v }\n else\n self.v\n end\n result = result_unflatten.flatten\n if range\n relevant_result = []\n result.each_with_index { |row_or_column, i| relevant_result << row_or_column if ra... | [
"0.70765126",
"0.6839177",
"0.67661774",
"0.67589754",
"0.66950136",
"0.6615476",
"0.660844",
"0.6598367",
"0.6591617",
"0.6589212",
"0.65838253",
"0.65646404",
"0.65456986",
"0.65239453",
"0.6507816",
"0.64890844",
"0.6486111",
"0.64520025",
"0.6449094",
"0.6420811",
"0.6407... | 0.64117926 | 20 |
Legg bruker uid til gruppe groupId | def addUserToGroup(uid, groupId)
uri = sprintf("/api/v1/groups/%d/memberships", groupId)
$canvas.post(uri, {'user_id' => uid})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_uid\n if self.id && !self.uid\n self.uid = \"cld-#{self.id}\"\n Group.update_all({uid:self.uid}, {id: self.id})\n end\n return true\n end",
"def account_gid; account.gid end",
"def gid\n \"##{id}\"\n end",
"def check_group_exists(doc, group, uid, gid)\n ... | [
"0.7082153",
"0.6631695",
"0.6588505",
"0.648164",
"0.6458812",
"0.6456437",
"0.6440437",
"0.64222264",
"0.64203024",
"0.63957125",
"0.6391444",
"0.638188",
"0.6369305",
"0.6342881",
"0.6321457",
"0.6285423",
"0.6200832",
"0.6196351",
"0.6177491",
"0.6142895",
"0.61238474",
... | 0.61505795 | 19 |
Opprett gruppe med navn groupName i gruppesettet gid. | def createGroup(groupName, gid)
uri = sprintf("/api/v1/group_categories/%d/groups", gid)
dbg("POST #{uri}")
dbg("name=#{groupName}")
newGroup = $canvas.post(uri, {'name' => groupName})
dbg(newGroup)
return newGroup
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_group(gid)\n\t\t\t@group_name=GROUPS[gid.to_s]\n\t\tend",
"def gid() end",
"def gid\n \"##{id}\"\n end",
"def gid=(p0) end",
"def gid=(p0) end",
"def gid(*) end",
"def gid(*) end",
"def change_group(gid_text)\n gid = Etc.getgrnam((gid_text+\"\").untaint).gid\n Process::Sys.s... | [
"0.7279122",
"0.69866914",
"0.69861335",
"0.68678963",
"0.68678963",
"0.6701085",
"0.6701085",
"0.6612894",
"0.6451883",
"0.6254403",
"0.6254403",
"0.6249284",
"0.62364835",
"0.6162842",
"0.6114758",
"0.6114758",
"0.6075717",
"0.6061465",
"0.6056004",
"0.5986517",
"0.5986517"... | 0.57090235 | 56 |
Returner enrollment type for en seksjon s | def getEnrollmentType(s)
# //The enrollment type. One of 'StudentEnrollment', 'TeacherEnrollment',
# //'TaEnrollment', 'DesignerEnrollment', 'ObserverEnrollment'.
# "type": "StudentEnrollment",
type = ""
case s["type"]
when "StudentEnrollment"
type = "student"
when "TeacherEnrollment"
type = "teacher"
end
return type
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enrollment_class\n (params[:enrollment].blank? || params[:enrollment][:type].blank? ? 'Enrollment' : params[:enrollment][:type]).constantize\n end",
"def enrollment_code_for(subject)\n Enrollment.find(:first, :conditions => {\n :user_id => self.id, :school_id => subject.school.id\n }).enrollme... | [
"0.7187711",
"0.63840365",
"0.6271871",
"0.6170893",
"0.6142005",
"0.6110634",
"0.6069084",
"0.5920033",
"0.5822918",
"0.5783087",
"0.5783087",
"0.5761107",
"0.5754447",
"0.5754272",
"0.57431734",
"0.5708474",
"0.5702752",
"0.5690099",
"0.5678745",
"0.5657737",
"0.5630255",
... | 0.7800354 | 0 |
Returner profilen til bruker uid | def getUserProfile(uid)
uri = sprintf("/api/v1/users/%d/profile",uid)
dbg(uri)
profile = $canvas.get(uri)
return profile
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile(username = nil, uid = nil)\n\n end",
"def set_profil\n @profil = User.find(params[:id])\n end",
"def get_user_profile(uid,fields)\n begin\n @user_details = graph.get_object(\"#{uid}\",\"fields\" => \"#{fields}\")\n rescue Exception => e\n error(\"get_user_prof... | [
"0.65845126",
"0.64243823",
"0.64191717",
"0.63251555",
"0.61535406",
"0.61147803",
"0.6105539",
"0.6021457",
"0.60086656",
"0.60065466",
"0.5903292",
"0.5897859",
"0.5897859",
"0.5888002",
"0.58378714",
"0.5832414",
"0.5824317",
"0.5824317",
"0.5812505",
"0.5809936",
"0.5795... | 0.56265247 | 38 |
Returner de to siste karakterene i seksjonsnavnet. Tanken er at seksjonene er nummerert "Seksjon 01" etc. | def getSectionNo(section)
return section["name"][-2,2]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kode_dan_kecamatan\n \"#{kode} - #{nama}\"\n end",
"def to_s()\n return \"Zug Laenge=#{self.count()}: [#@lok]\"\n end",
"def cobranca_interna_formatada\n\t\t\t\tcobranca_interna = { '21' => '21 – Cobrança Interna Com Registro', '22' => '22 – Cobrança Interna sem registro' }\n\t\t\t\tcobranca_... | [
"0.60457045",
"0.5808455",
"0.5806275",
"0.57128096",
"0.56028116",
"0.5555246",
"0.5524397",
"0.5486747",
"0.54459053",
"0.5424109",
"0.54177576",
"0.5414467",
"0.53699726",
"0.53309274",
"0.53247356",
"0.53052855",
"0.52948993",
"0.52926964",
"0.5287019",
"0.52861893",
"0.5... | 0.0 | -1 |
Returner en liste av kommentarer. | def getComments(list)
comments = ""
dbg("Kommentarer:")
list.each { |s|
dbg("Kommentar:")
dbg(s)
dbg(s["comment"])
comments = comments + "<p>" + s["author_name"] + ":" + s["comment"] + "</p>"
dbg(s["comment"])
}
return comments
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def liste()\n puts(\"LISTE DES ORDRES\\n\");\n printf(\"%8s %8s %5s %10s\\n\",\n \"ID\", \"DEBUT\", \"DUREE\", \"PRIX\")\n printf(\"%8s %8s %5s %10s\\n\",\n \"--------\", \"-------\", \"-----\", \"----------\")\n @listOrdre = @listOrdre.sort{ |a,b| a.debut <=> b.deb... | [
"0.65208894",
"0.6497185",
"0.64436233",
"0.63333046",
"0.62906855",
"0.62906855",
"0.62906855",
"0.62155735",
"0.6199007",
"0.6176992",
"0.615173",
"0.61489713",
"0.6137061",
"0.608948",
"0.60541594",
"0.6036336",
"0.6027775",
"0.6027775",
"0.6027775",
"0.6027775",
"0.602777... | 0.63654304 | 3 |
Returner en liste av enrollments i seksjon sid. | def getEnrollmentsInSection(sid)
uri = sprintf("/api/v1/sections/%d/enrollments?type[]=StudentEnrollment&per_page=999", sid)
enrollments = $canvas.get(uri)
return enrollments
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n set_enrolment\n if @enrolment\n @student_ids = @enrolment.student_ids\n else\n @student_ids = StudentId.all\n @notice = \"Displaying All Ids\"\n end\n end",
"def lasids\n render json: Student.all.pluck(:local_id) # not just active students\n end",
"def lasids\n re... | [
"0.64046454",
"0.6375124",
"0.6124821",
"0.5792812",
"0.570467",
"0.5677944",
"0.566025",
"0.5618372",
"0.5605166",
"0.55899096",
"0.5575739",
"0.55582684",
"0.55582684",
"0.5548243",
"0.55336076",
"0.55238193",
"0.55145574",
"0.55104864",
"0.55036575",
"0.5492298",
"0.547550... | 0.66680396 | 0 |
Creates a filter given a type. | def initialize(filter_type)
@filter_type = filter_type
begin
filter_module = self.class.const_get(filter_type.to_s.gsub(/^([a-z])/) {|e| $1.upcase })
self.extend(filter_module)
rescue NameError
raise FilterNotFoundError
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(filter_type, &block)\n if FILTER_TYPES.include?(filter_type)\n @filter_type = filter_type\n else\n raise ArgumentError, \"invalid type #{filter_type}, allowed: #{FILTER_TYPES.join(', ')}\"\n end\n @block = block\n end",
"def filter(type, &b)\n @app.filters[type] << b\n ... | [
"0.71374077",
"0.71287036",
"0.71227556",
"0.7077341",
"0.69634664",
"0.65462303",
"0.6463565",
"0.64408875",
"0.6424925",
"0.64201576",
"0.63477373",
"0.6279549",
"0.62118185",
"0.61770594",
"0.6065138",
"0.6037612",
"0.59476477",
"0.5938949",
"0.5727521",
"0.57095087",
"0.5... | 0.70843244 | 3 |
Takes an an array of hashes representing database records and converts them to a string for editing. | def hashes_to_string(hashes)
raise AbstractMethodError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize(row)\n row\n .map { |c| db_format(c) }\n .join(\",\")\nend",
"def to_s\n out = ''\n database.each_value do |v|\n out+= \"#{v}\"\n end\n\n out\n end",
"def format_field_names_as_string(array)\n array.map{ |k| \"'#{k}'\" }.join(',')\n end",
"def build_update(data)... | [
"0.6373397",
"0.6198929",
"0.5769161",
"0.561814",
"0.5616196",
"0.5555549",
"0.5483409",
"0.54459655",
"0.5418169",
"0.5371103",
"0.5353248",
"0.53298",
"0.53215206",
"0.531808",
"0.5311524",
"0.53108615",
"0.5310474",
"0.5296723",
"0.5287806",
"0.5272054",
"0.52618575",
"... | 0.0 | -1 |
Takes the string from the updated file and converts back to an array of hashes. | def string_to_hashes(string)
raise AbstractMethodError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_into_hash(file_content)\n # apt-history file is seperated by double new line\n file_sections = file_content.split(\"\\n\\n\")\n\n # split the sections by line within them\n file_sections.map! { |section| section.split(\"\\n\") }\n\n # split each line of the sections by : seperator\n fil... | [
"0.64850354",
"0.6294764",
"0.6165285",
"0.6156503",
"0.59073496",
"0.5797451",
"0.57889926",
"0.57494074",
"0.5661496",
"0.56478745",
"0.5632952",
"0.5632952",
"0.56121397",
"0.5578677",
"0.55747646",
"0.5563435",
"0.5529547",
"0.5527857",
"0.5504168",
"0.5482216",
"0.545922... | 0.54117715 | 24 |
Rate of rdvs taken in autonomy | def compute_rate_of_autonomous_applicants
(autonomous_applicants.count / (
@applicants.count.nonzero? || 1
).to_f) * 100
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rate; end",
"def rate; end",
"def vat_rate\n end",
"def rates; end",
"def rates; end",
"def rms\n sum = @data.inject(0) do |accu, hash|\n accu + (hash[:prediction] - hash[:rating]) ** 2\n end\n return Math.sqrt(sum.to_f / @data.size)\n end",
"def effective_rate; end",
"def rat... | [
"0.7035796",
"0.7035796",
"0.68279374",
"0.66614527",
"0.66614527",
"0.65346605",
"0.65153193",
"0.64848965",
"0.6462009",
"0.6426671",
"0.6339993",
"0.6248279",
"0.6248279",
"0.6241833",
"0.6239981",
"0.61846995",
"0.61595273",
"0.6147488",
"0.61074483",
"0.6106015",
"0.6101... | 0.61194634 | 18 |
Create a getter for the books | def test_get_books
assert_equal(@initial_books, @library1.books)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_books()\n @books_out\n end",
"def get_books()\n @books_out\n end",
"def books \n @books\n end",
"def get_books()\n @checked_books\n end",
"def book\n fetch('harry_potter.books')\n end",
"def get_book(book_num)\n return @books_list[book_num]\n end",
"def od... | [
"0.75632054",
"0.75632054",
"0.7462846",
"0.7402425",
"0.71093804",
"0.70679814",
"0.69850194",
"0.68886214",
"0.6747004",
"0.6714513",
"0.6701532",
"0.6700445",
"0.6699748",
"0.6670824",
"0.66496897",
"0.6626742",
"0.66219944",
"0.66219944",
"0.6594683",
"0.6568562",
"0.6562... | 0.0 | -1 |
Create a method that takes in a book title and returns all of the information about that book. | def test_get_book_instance
book_by_title = @library1.get_book_instance("catch_22")
assert_equal(@book2, book_by_title)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_book_title(book)\nend",
"def book_info(book_title)\n for book in @books\n return book if book[:title] == book_title\n end\n return nil\n end",
"def get_book_details(title)\n for book in @all_books\n return book if book[:title] == title\n end\n end",
"def get_title(book)\n bo... | [
"0.8184806",
"0.76194656",
"0.7440119",
"0.73004407",
"0.7289328",
"0.7281496",
"0.72017014",
"0.71296936",
"0.7106743",
"0.70838",
"0.7022409",
"0.697409",
"0.6859718",
"0.68309563",
"0.68154424",
"0.6798666",
"0.67555594",
"0.6692877",
"0.6669635",
"0.66400546",
"0.6633266"... | 0.0 | -1 |
Create a method that takes in a book title and returns only the rental details for that book. | def test_rental_details_for_title
rental_details = @library1.rental_details_for_title("lord_of_the_rings")
assert_equal({student_name: "Jeff", date: "25/05/19"}, rental_details)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rental_info(book_title)\n for book in @books\n return book[:rental_details] if book[:title] == book_title\n end\n return nil\n end",
"def rental_info_by_title(title)\n book = info_by_title(title)\n rental_info = \"Student name: #{book[0][:rental_details][:student_name]}, Date due: #{... | [
"0.8090207",
"0.7866912",
"0.7543238",
"0.74662787",
"0.74433553",
"0.7278995",
"0.7030291",
"0.6935946",
"0.67731327",
"0.6548042",
"0.65192413",
"0.6347379",
"0.6334467",
"0.62730706",
"0.62611955",
"0.6258693",
"0.62201035",
"0.62198114",
"0.6198102",
"0.6155756",
"0.61189... | 0.5900369 | 31 |
Create a method that takes in a book title and adds it to our book list (add a new hash for the book with the student name and date being left as empty strings) | def test_add_new_book
@library1.add_new_book("ready_player_one")
book_count = @library1.books.count
assert_equal(3, book_count)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_book(title)\n new_book = {\n title: title,\n rental_details: {\n student_name: \"\",\n date: \"\"\n }\n }\n @books.push(new_book)\n return @books.length\n end",
"def add_book(book_title_str)\n # is the book not already present in @books list?\n for book_has... | [
"0.74832976",
"0.74513656",
"0.74430615",
"0.7214016",
"0.70667213",
"0.6825221",
"0.6780452",
"0.67750376",
"0.660526",
"0.6592099",
"0.65542394",
"0.64897853",
"0.6452822",
"0.64475536",
"0.63069767",
"0.6275919",
"0.6263858",
"0.6249792",
"0.6226577",
"0.62008125",
"0.6196... | 0.0 | -1 |
Create a method that changes the rental details of a book by taking in the title of the book, the student renting it and the date it's due to be returned. | def test_change_rental_details
@library1.change_rental_details("catch_22", "Steve", "05/06/19")
expected_hash = {
title: "catch_22",
rental_details: {
student_name: "Steve",
date: "05/06/19"
}
}
assert_equal(expected_hash, @library1.books[1])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_rental_details(title, name, date)\n for book in @books\n if book[:title] == title\n book[:rental_details][:student_name] = name\n book[:rental_details][:date] = date\n return book\n end\n end\n end",
"def rent_out(book_title, student, due_date)\n for book in @b... | [
"0.7307449",
"0.72189015",
"0.67984444",
"0.6503444",
"0.6458273",
"0.6457386",
"0.6447601",
"0.6432663",
"0.6223772",
"0.61576676",
"0.60488844",
"0.6009467",
"0.5933914",
"0.58953047",
"0.58837694",
"0.5860927",
"0.5832794",
"0.58079904",
"0.5729274",
"0.5726665",
"0.569845... | 0.59515435 | 12 |
output: hash with keys = words in the str, values = times word appears | def split_words(str)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_count(string)\n words=string.split()\n unique=words.uniq\n amount={}\n unique.each do |word|\n amount[word.to_sym]=words.count(word)\n end\n p amount\nend",
"def substrings(input, dictionary)\n\thash = {}\t\t\t\t\t# Initialize empty hash\n\tdictionary.each do |word|\n\t\t# For each word,... | [
"0.7749027",
"0.76362413",
"0.75955963",
"0.75615007",
"0.75463235",
"0.7544781",
"0.75432944",
"0.7524121",
"0.74428713",
"0.7369023",
"0.7362588",
"0.73430157",
"0.7335498",
"0.72784954",
"0.7267691",
"0.7245592",
"0.72295827",
"0.72255415",
"0.72171795",
"0.72127104",
"0.7... | 0.0 | -1 |
oldschool roman numeral method I = 1, V = 5, X = 10, L = 50, C = 100, D = 500, M = 1000 | def old_school_roman (y)
roman = ""
roman << "M" * (y / 1000)
roman << "D" * (y % 1000 / 500)
roman << "C" * (y % 500 / 100)
roman << "L" * (y % 100 / 50)
roman << "X" * (y % 50 / 10)
roman << "V" * (y % 10 / 5)
roman << "I" * (y % 5 / 1)
roman
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_roman_numeral num\n number = \"\"\n if (num / 1000) > 0\n number = \"M\" * (num / 1000)\n end\n if (num % 1000) >= 900 \n number += \"CM\"\n end\n if (num % 1000) >= 500 && (num % 1000) < 900\n number += \"D\"\n end\n if (num % 1000) >= 400 && (num % 1000) < 500\n number += \"CD\"\n en... | [
"0.82450175",
"0.8151233",
"0.814216",
"0.81207615",
"0.8117544",
"0.8115878",
"0.81077814",
"0.80226254",
"0.7971888",
"0.7937661",
"0.79253125",
"0.79243594",
"0.7911654",
"0.7902359",
"0.789271",
"0.78846556",
"0.7881164",
"0.78807616",
"0.7880147",
"0.7870496",
"0.7869562... | 0.74716663 | 57 |
modern roman numeral method I = 1, V = 5, X = 10, L = 50, C = 100, D = 500, M = 1000 | def modern_roman (z)
first = (z / 1000)
second = (z % 1000 / 100)
third = (z % 100 / 10)
last = (z % 10 )
roman = ""
roman << "M" * first
if second == 9
roman << "CM"
elsif second == 4
roman << "CD"
else
roman << "D" * (z % 1000 / 500)
roman << "C" * (z % 500 / 100)
end
if third == 9
roman << "XC"
elsif third == 4
roman << "XL"
else
roman << "L" * (z % 100 / 50)
roman << "X" * (z % 50 / 10)
end
if last == 9
roman << "IX"
elsif last == 4
roman << "IV"
else
roman << "V" * (z % 10 / 5)
roman << "I" * (z % 5 / 1)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_roman_numeral num\n number = \"\"\n if (num / 1000) > 0\n number = \"M\" * (num / 1000)\n end\n if (num % 1000) >= 900 \n number += \"CM\"\n end\n if (num % 1000) >= 500 && (num % 1000) < 900\n number += \"D\"\n end\n if (num % 1000) >= 400 && (num % 1000) < 500\n number += \"CD\"\n en... | [
"0.82981634",
"0.82494587",
"0.82418454",
"0.8226495",
"0.8223186",
"0.8136992",
"0.81277186",
"0.8083307",
"0.8028177",
"0.8016057",
"0.7995345",
"0.7995345",
"0.7987103",
"0.79845566",
"0.797416",
"0.7969743",
"0.7966504",
"0.7961807",
"0.79561377",
"0.7955054",
"0.7954107"... | 0.7423235 | 66 |
return a single Company by id expects id in params[0] | def find_by_id
respond_to do |format|
format.amf { render :amf => Company.find(params[0]) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_company\n Company.find(params[:company_id].to_i)\n end",
"def find_company(company_id)\n company = Company.find_by_id(company_id)\n halt 404 unless company\n\n company\n end",
"def get_company\n @company = Company.find(params[:company_id])\n end",
"def byId\n @company = Comp... | [
"0.8010362",
"0.7825889",
"0.7811783",
"0.78064954",
"0.7701896",
"0.7581974",
"0.75442755",
"0.7490469",
"0.7191984",
"0.71522313",
"0.7134843",
"0.7134843",
"0.7134843",
"0.7134843",
"0.7134843",
"0.7134843",
"0.7134843",
"0.7134843",
"0.7102523",
"0.7030264",
"0.702452",
... | 0.6265613 | 100 |
saves new or updates existing Company expect params[0] to be incoming Company | def save
respond_to do |format|
format.amf do
@company = params[0]
if @company.save
render :amf => @company
else
render :amf => FaultObject.new(@company.errors.full_messages.join('\n'))
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def company_params\n params.require(:company).permit(:company_id, :company_name, :company_info)\n end",
"def set_company\n id = params[:company_id] ? params[:company_id] : params[:id]\n @company = Company.find(id)\n end",
"def set_company\n @company = Company.find(params[:company])\n end",
... | [
"0.71682453",
"0.7144294",
"0.7010191",
"0.6985099",
"0.69515175",
"0.69353145",
"0.69235253",
"0.6922824",
"0.69180363",
"0.69144505",
"0.6873418",
"0.68686706",
"0.6865245",
"0.68538773",
"0.68234575",
"0.6807706",
"0.68015444",
"0.6786779",
"0.67778003",
"0.67762417",
"0.6... | 0.0 | -1 |
destroy a Company expects id in params[0] | def destroy
respond_to do |format|
format.amf do
@company = Company.find(params[0])
@company.destroy
render :amf => true
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n flash[:success] = \"Company was successfully deleted.\"\n redirect_to crm_path\n end",
"def destroy\n @company = Company.find(params[:id])\n\n respond_to do |format|\n if @company.destroy\n format.htm... | [
"0.80656564",
"0.79689103",
"0.7909778",
"0.79033625",
"0.7903204",
"0.7891664",
"0.7854675",
"0.7820319",
"0.7813504",
"0.7813504",
"0.7813504",
"0.7813504",
"0.7813504",
"0.7813504",
"0.7813504",
"0.7807913",
"0.7796187",
"0.7796187",
"0.7796187",
"0.7796187",
"0.7796187",
... | 0.0 | -1 |
GET /fx_pairs GET /fx_pairs.json | def index
@fx_pairs = FxPair.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def market_pairs(**args)\n valid_params?(args)\n params = convert_params(args)\n client.get(\"#{ENDPOINT}/market-pairs/latest\", options: params.compact).tap do |resp|\n resp.body = [resp.body]\n end\n end",
"def market_pairs(**args)\n valid_params?(args)\n ... | [
"0.6500341",
"0.6500341",
"0.6398434",
"0.63522846",
"0.63320285",
"0.61935824",
"0.6074744",
"0.5984444",
"0.59562993",
"0.5913955",
"0.5835928",
"0.5729946",
"0.572043",
"0.5645617",
"0.55803436",
"0.55388075",
"0.5516886",
"0.55093527",
"0.55048287",
"0.5497292",
"0.549712... | 0.66831654 | 0 |
GET /fx_pairs/1 GET /fx_pairs/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @fx_pairs = FxPair.all\n end",
"def show\n params[:id] ||= Pair.find_by_key(params[:key]).id\n @pair = Pair.find(params[:id])\n\n respond_to do |format|\n format.html { render :template => 'pairs/show' }\n format.xml { render :xml => @pair }\n format.json { render :json =... | [
"0.6535737",
"0.64891565",
"0.63225096",
"0.63225096",
"0.6306881",
"0.6302849",
"0.6280084",
"0.6045307",
"0.6042775",
"0.5990004",
"0.5968207",
"0.59374666",
"0.5880666",
"0.5791265",
"0.5759406",
"0.5754667",
"0.5706842",
"0.5637758",
"0.56377447",
"0.55668586",
"0.5530259... | 0.0 | -1 |
POST /fx_pairs POST /fx_pairs.json | def create
@fx_pair = FxPair.new(fx_pair_params)
respond_to do |format|
if @fx_pair.save
format.html { redirect_to @fx_pair, notice: 'Fx pair was successfully created.' }
format.json { render :show, status: :created, location: @fx_pair }
else
format.html { render :new }
format.json { render json: @fx_pair.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @pair = Pair.new(pair_params)\n\n respond_to do |format|\n if @pair.save\n format.html { redirect_to pairs_path }\n format.json { render :show, status: :created, location: @pair }\n else\n format.html { render :new }\n format.json { render json: @pair.errors... | [
"0.6467058",
"0.62887657",
"0.6269039",
"0.60386366",
"0.6024118",
"0.5987139",
"0.59311163",
"0.5920877",
"0.5790625",
"0.5754665",
"0.5714604",
"0.5673453",
"0.565654",
"0.5596338",
"0.54781514",
"0.54212373",
"0.54197514",
"0.537973",
"0.53083193",
"0.5289104",
"0.52793473... | 0.6621658 | 0 |
PATCH/PUT /fx_pairs/1 PATCH/PUT /fx_pairs/1.json | def update
respond_to do |format|
if @fx_pair.update(fx_pair_params)
format.html { redirect_to @fx_pair, notice: 'Fx pair was successfully updated.' }
format.json { render :show, status: :ok, location: @fx_pair }
else
format.html { render :edit }
format.json { render json: @fx_pair.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @pair = @store.pairs.find(params[:id])\n\n respond_to do |format|\n attrs = params[:pair]\n if @pair.update_attributes({:key => attrs[:key], :value => attrs[:value]})\n format.html { redirect_to organization_store_pairs_url(@store.organization, @store), notice: 'Pair was success... | [
"0.659585",
"0.6515691",
"0.6485506",
"0.6365998",
"0.61842424",
"0.5919234",
"0.5917941",
"0.58916354",
"0.5890835",
"0.57009214",
"0.56804496",
"0.5646265",
"0.5576937",
"0.5560091",
"0.5533936",
"0.5529059",
"0.5525755",
"0.5514146",
"0.55114603",
"0.54637486",
"0.54534584... | 0.69660366 | 0 |
DELETE /fx_pairs/1 DELETE /fx_pairs/1.json | def destroy
@fx_pair.destroy
respond_to do |format|
format.html { redirect_to fx_pairs_url, notice: 'Fx pair was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @pair = Pair.find(params[:id])\n @pair.destroy\n\n respond_to do |format|\n format.html { redirect_to(pairs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pair.destroy\n respond_to do |format|\n format.html { redirect_to pairs_url, notice: 'Pair wa... | [
"0.69342023",
"0.6879681",
"0.6871947",
"0.68322754",
"0.6765457",
"0.66647357",
"0.63590926",
"0.6344775",
"0.6282607",
"0.62503636",
"0.6197107",
"0.6165138",
"0.6158561",
"0.61441565",
"0.61268264",
"0.6078939",
"0.60722727",
"0.6072176",
"0.60703844",
"0.6066402",
"0.6065... | 0.73493016 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_fx_pair
@fx_pair = FxPair.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.61642385",
"0.60448",
"0.5945487",
"0.5915654",
"0.58890367",
"0.58330417",
"0.5776098",
"0.5703048",
"0.5703048",
"0.5654613",
"0.5620029",
"0.5423114",
"0.540998",
"0.540998",
"0.540998",
"0.5393666",
"0.53783023",
"0.53568405",
"0.53391176",
"0.5339061",
"0.53310865",
... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def fx_pair_params
params.require(:fx_pair).permit(:base, :target, :rate, :last_updated_at)
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 |
Convert uuencoded sections in a text/plain message | def convert_uu(msg)
nmsg = nil
nbody = msg.decode.gsub(UU_RE) { |s|
filename, data = $1, $2.unpack('u')
$stderr.puts "%sFound a uuencoded section!\n" % [ $indent ] if $DEBUG
unless nmsg
# Now that we know there's a uuencoded section, build up a
# multipart message
nmsg = RMail::Message.new
nmsg.header.replace(msg.header.dup)
nmsg.header.delete('Content-Transfer-Encoding')
nmsg.header.delete('Content-Length')
nmsg.header.delete('Lines')
nmsg.header.set('Content-Type', 'multipart/mixed',
'boundary' => '=-=-=-=-uu2mime-boundary-'+nmsg.object_id.to_s)
nmsg.header.set('Content-Disposition', 'inline')
nmsg.preamble = "This is a multipart message converted by uu2mime\n"
nmsg.epilogue = ''
# This will eventually be the text/plain portion
nmsg.add_part(RMail::Message.new)
end
# Convert this uuencoded section to an attachment
npart = RMail::Message.new
npart.header.set('Content-Type', 'application/octet-stream')
npart.header.set('Content-Disposition', 'attachment',
'filename' => filename)
npart.header.set('Content-Transfer-Encoding', 'base64')
npart.body = data.pack('m')
nmsg.add_part(npart)
# Replace the uuencoded section with a note
'[-- uu2mime snipped ' + filename + ' --]'
}
if nmsg
# Tack the text/plain portion on the front.
# Remove the old Content-Transfer-Encoding header since we've
# decoded the section (is this the best?)
nmsg.part(0).header.set('Content-Type', 'text/plain',
'charset' => 'us-ascii')
nmsg.part(0).header.set('Content-Disposition', 'inline')
nmsg.part(0).body = nbody
end
return nmsg
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uniToHtml(messageText)\r\n escapeCharacters=\"<>&\"\r\n html=\"\"\r\n i=0\r\n l=messageText.length\r\n s=0\r\n while i < l\r\n c = messageText[i]\r\n if !c.ascii_only? or escapeCharacters.index(c)\r\n cp = c.codepoints[0]\r\n if s != i\r\n ... | [
"0.6208324",
"0.6168571",
"0.6148171",
"0.58298385",
"0.5695243",
"0.569504",
"0.5483169",
"0.5409598",
"0.5247266",
"0.52444315",
"0.52289385",
"0.5158521",
"0.515429",
"0.51497436",
"0.51286286",
"0.5089384",
"0.5079488",
"0.5073865",
"0.50653607",
"0.50561553",
"0.5051354"... | 0.7424751 | 0 |
Convert PGP signed/encrypted sections in a text/plain message. In reality this just changes the ContentType of the part since conversion to OpenPGP would insert headers into the signed part, causing the signature to be invalid. | def convert_pgp(msg)
nmsg = nil
x_action = nil
if msg.decode =~ PGP_ENCRYPTED_RE
$stderr.puts "%sFound an encrypted section" % [ $indent ] if $DEBUG
x_action = 'encrypted'
elsif msg.decode =~ PGP_SIGNED_RE
$stderr.puts "%sFound a signed section" % [ $indent ] if $DEBUG
x_action = 'signed'
end
if x_action
# Duplicate the message
nmsg = RMail::Message.new
nmsg.header.replace(msg.header)
nmsg.body = msg.body
# Fix the Content-Type according to
# http://www.tldp.org/HOWTO/Mutt-GnuPG-PGP-HOWTO-8.html#ss8.2
nmsg.header.set('Content-Type', 'application/pgp',
'format' => 'text', 'x-action' => x_action)
end
return nmsg
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _convert_part_body_to_text(part)\n if part.nil?\n text = \"[ Email has no body, please see attachments ]\"\n text_charset = \"utf-8\"\n else\n text = part.body\n text_charset = part.charset\n if part.content_type == 'text/html'\n ... | [
"0.6300189",
"0.5872823",
"0.5763076",
"0.5626345",
"0.55294013",
"0.5523955",
"0.5415919",
"0.54001975",
"0.53599083",
"0.53545946",
"0.5289285",
"0.528052",
"0.52480996",
"0.52404034",
"0.5219393",
"0.5156749",
"0.5145459",
"0.51245725",
"0.51215875",
"0.51020247",
"0.50707... | 0.67895913 | 0 |
Recursive function to convert uuencoded sections to MIME parts Returns the new message | def convert_message(msg)
$stderr.puts "%sConverting message:\n%s" %
[ $indent, msg.header.to_s.gsub(/^/, $indent+' ') ] if $DEBUG
# Text/plain messages are subject to conversion
case msg.header.content_type
when nil, %r{^text/plain}, %r{^message/rfc822}
$stderr.puts "%sThis is a text/plain message" % [ $indent ] if $DEBUG
# Start by doing PGP ... if this matches then we don't want to
# mess with uuencoded stuff because that would break the signature
nmsg = convert_pgp(msg)
nmsg = convert_uu(msg) unless nmsg
msg = nmsg if nmsg
end
# Multi-part messages are converted part by part, depth-first.
# Note this could be acting on a converted text/plain message from
# above, which is good, because it means we'll fix the
# Content-Length and Lines headers (as well as convert embedded
# message, but what are the chances of that?)
if msg.multipart?
# Convert each part
unless msg.header.content_type =~ %r{^multipart/signed}
# Create the new message. Start by duplicating the headers.
nmsg = RMail::Message.new
nmsg.header.replace(msg.header.dup)
nmsg.preamble, nmsg.epilogue = msg.preamble, msg.epilogue
$indent << ' ' # for $DEBUG
msg.each_part { |part| nmsg.add_part(convert_message(part)) }
$indent[0,2] = '' # for $DEBUG
# This is now the message
msg = nmsg
end
# Add length headers; requires serializing at this point
s = msg.to_s # this is the full serialized message
h = msg.header.to_s
content_length = s.length - h.length - 1
if content_length > 0
msg.header.set('Content-Length', content_length.to_s)
lines = s.count("\n") - h.count("\n") - 1
msg.header.set('Lines', lines.to_s)
end
end
return msg
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_uu(msg)\n nmsg = nil\n\n nbody = msg.decode.gsub(UU_RE) { |s|\n filename, data = $1, $2.unpack('u')\n\n $stderr.puts \"%sFound a uuencoded section!\\n\" % [ $indent ] if $DEBUG\n\n unless nmsg\n # Now that we know there's a uuencoded section, build up a\n # multipart message\n ... | [
"0.7807727",
"0.6131965",
"0.6115026",
"0.6064921",
"0.6043103",
"0.6021373",
"0.59677887",
"0.58940226",
"0.58354396",
"0.5816944",
"0.58155",
"0.57490146",
"0.572752",
"0.5714033",
"0.57090783",
"0.5685793",
"0.56791395",
"0.56616557",
"0.5644551",
"0.5628049",
"0.5567411",... | 0.6643357 | 1 |
Creates and saves a song | def show
@song = Song.find_by(id: params[:id])
@comments = @song.comments
render :show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n files = MyBiaDJ::Table(:files)\n record = files.create(:path => relative_path, :name => name)\n tracks.each do |track|\n track.save(record) if track.mp3?\n end\n end",
"def add_song(song,status)\n\tSong.create(song_name:song,status:status)\nend",
"def create\n @song ... | [
"0.7230755",
"0.7159495",
"0.7141419",
"0.7126867",
"0.7065077",
"0.7047677",
"0.6999101",
"0.69762754",
"0.6962767",
"0.6962767",
"0.6962767",
"0.6946991",
"0.6941908",
"0.6941908",
"0.69396913",
"0.6918664",
"0.69186395",
"0.6906518",
"0.6906518",
"0.6905668",
"0.68661726",... | 0.0 | -1 |
Returns a requested song | def index
if params[:user_id]
@user = User.find_by(id: params[:user_id])
@songs = @user.songs
else
@songs = Song.last(10)
end
# debugger
render :index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def song\n fetch('cowboy_bebop.song')\n end",
"def song\n fetch('bossa_nova.songs')\n end",
"def current_song\n Song.find(params[:id])\n end",
"def getSong\n\t\tid = params[:songId]\n\t\tresult = GetSongFromSpotify.build.call(id)\n\t\trender json: result\n\tend",
"def have_s... | [
"0.7793418",
"0.7573441",
"0.7316042",
"0.7114317",
"0.70443004",
"0.7024708",
"0.7024708",
"0.7000286",
"0.6985441",
"0.6812375",
"0.6812375",
"0.6812375",
"0.6812375",
"0.6812375",
"0.6812375",
"0.6812375",
"0.6812375",
"0.67796373",
"0.6746442",
"0.6657075",
"0.6644388",
... | 0.0 | -1 |
Returns 10 songs for the discover page | def destroy
@song = Song.find_by(id: params[:id])
@song.destroy
render :show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @songs = Song.search((params[:search] || {})[:query]).page(params[:page]).per(30)\n end",
"def index\n @search = Song.search(params[:q]) #Using the Ransack Gem\n @page = params[:page] || 1\n @songs = @search.result.includes(:artist).paginate(:page => @page, :per_page => 50)\n end",
"d... | [
"0.6652741",
"0.6596209",
"0.6579166",
"0.6578775",
"0.656787",
"0.654157",
"0.6511856",
"0.6390565",
"0.63522106",
"0.6351281",
"0.6319131",
"0.62635976",
"0.6262371",
"0.6260283",
"0.62540835",
"0.62247235",
"0.61984",
"0.61429626",
"0.6117356",
"0.6105031",
"0.609211",
"... | 0.0 | -1 |
Deletes a requested song | def update
@song = Song.find_by(id: params[:id])
if @song.update(song_params)
render 'api/songs/show'
else
# debugger
render json: @song.errors.full_messages, status: 401
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(songpos)\n send_request('delete %s' % songpos)\n end",
"def delete_song(song)\n @queue.find { |x| x == song }.delete\n @queue.delete(song)\n end",
"def destroy\r\n @song = Song.find(params[:id])\r\n @song.destroy\r\n flash[:success] = \"\\\"#{@song.title}\\\" song has... | [
"0.81171685",
"0.7928998",
"0.7861182",
"0.77313644",
"0.77171445",
"0.7715297",
"0.7636323",
"0.7618381",
"0.7616358",
"0.7608682",
"0.76012105",
"0.76012105",
"0.76012105",
"0.76012105",
"0.76012105",
"0.76012105",
"0.7586539",
"0.75650704",
"0.75650704",
"0.75650704",
"0.7... | 0.0 | -1 |
Updates a requested song with the new information provided | def search
@songs = Song.ransack(name_cont: params[:q]).result(distinct: true).limit(5)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_song\n head :ok\n end",
"def update\n \n \n respond_to do |format|\n updated_params = song_params\n if (@song.artist != song_params[:artist] || @song.songname != song_params[:songname])\n uri = 'http://developer.echonest.com/api/v4/song/search?api_key=6XUOAXHJOW28GGGRH&fo... | [
"0.78050303",
"0.78013325",
"0.776485",
"0.7758112",
"0.7550397",
"0.75353354",
"0.75127995",
"0.74909025",
"0.7464191",
"0.7462166",
"0.7455313",
"0.74351174",
"0.7429703",
"0.7429703",
"0.7429703",
"0.7429703",
"0.7429703",
"0.7429703",
"0.7429703",
"0.7429703",
"0.7407567"... | 0.0 | -1 |
GET /picture_comments GET /picture_comments.json | def index
@picture_comments = PictureComment.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @profile_picture = ProfilePicture.find(params[:id])\n @commentable = @profile_picture\n @comments = @commentable.comments\n @comment = Comment.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @profile_picture }\n end\n end",
"def co... | [
"0.7173869",
"0.71290916",
"0.7107311",
"0.70535356",
"0.7045394",
"0.7039749",
"0.69868904",
"0.69011205",
"0.68919635",
"0.6887271",
"0.68526435",
"0.66660535",
"0.66660535",
"0.66335946",
"0.66266876",
"0.6612075",
"0.6598619",
"0.65779203",
"0.6542449",
"0.651173",
"0.649... | 0.71461296 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.