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 |
|---|---|---|---|---|---|---|
after_save callback to handle group_ids | def update_courses
unless course_ids.nil?
self.enrollments.each do |e|
e.destroy unless course_ids.include?(e.course_id.to_s)
course_ids.delete(e.course_id.to_s)
end
course_ids.each do |c|
self.enrollments.create(:course_id => c) unless c.blank?
@cse = Course.fin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform_save\n api.group_save(self)\n end",
"def before_save\n prepare_attributes\n find_song_groups!\n end",
"def save_groups\n self.groups.each { |c| if c.destroy_association? then c.destroy else c.save end }\n self.added_groups.each { |c| c.save unless c.nil? } unless se... | [
"0.66786563",
"0.6583159",
"0.64804435",
"0.63517076",
"0.62737626",
"0.61839855",
"0.6181366",
"0.6084062",
"0.60247976",
"0.59588283",
"0.5953746",
"0.5943064",
"0.5938133",
"0.5905705",
"0.5875486",
"0.5875486",
"0.5875486",
"0.58388996",
"0.5815351",
"0.5815351",
"0.58153... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def article_params
params.require(:category).permit(:title, :description, :weight)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /persona_punto_venta GET /persona_punto_venta.json | def index
@persona_punto_venta = PersonaPuntoVentum.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_persona_punto_ventum\n @persona_punto_ventum = PersonaPuntoVentum.find(params[:id])\n end",
"def persona_punto_ventum_params\n params.require(:persona_punto_ventum).permit(:persona_id, :punto_venta_id)\n end",
"def get_ponto\n render json: Usuario.ultimo_ponto(params[:user_id], params... | [
"0.684093",
"0.6608203",
"0.65238965",
"0.6478566",
"0.63313097",
"0.61472183",
"0.61254483",
"0.6094465",
"0.60358447",
"0.6015532",
"0.5965137",
"0.59626883",
"0.5922764",
"0.5922764",
"0.59172255",
"0.5873233",
"0.5862093",
"0.58567005",
"0.58518165",
"0.5837091",
"0.58153... | 0.70606333 | 0 |
GET /persona_punto_venta/1 GET /persona_punto_venta/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @persona_punto_venta = PersonaPuntoVentum.all\n end",
"def set_persona_punto_ventum\n @persona_punto_ventum = PersonaPuntoVentum.find(params[:id])\n end",
"def persona_punto_ventum_params\n params.require(:persona_punto_ventum).permit(:persona_id, :punto_venta_id)\n end",
"def... | [
"0.6965732",
"0.6760657",
"0.64742833",
"0.6366154",
"0.625891",
"0.6249492",
"0.62033063",
"0.61494434",
"0.603441",
"0.6034205",
"0.6033833",
"0.6009075",
"0.59869224",
"0.59651387",
"0.59385586",
"0.5905865",
"0.5905865",
"0.58713806",
"0.58698404",
"0.5848847",
"0.5848645... | 0.0 | -1 |
POST /persona_punto_venta POST /persona_punto_venta.json | def create
@persona_punto_ventum = PersonaPuntoVentum.new(persona_punto_ventum_params)
respond_to do |format|
if @persona_punto_ventum.save
format.html { redirect_to @persona_punto_ventum.punto_venta, notice: 'Persona punto ventum was successfully created.' }
format.json { render :show, s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def persona_punto_ventum_params\n params.require(:persona_punto_ventum).permit(:persona_id, :punto_venta_id)\n end",
"def set_persona_punto_ventum\n @persona_punto_ventum = PersonaPuntoVentum.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @persona_punto_ventum.updat... | [
"0.7436393",
"0.7049305",
"0.6603138",
"0.6143716",
"0.60707164",
"0.59953636",
"0.595887",
"0.59437424",
"0.5839788",
"0.575266",
"0.57334405",
"0.5713411",
"0.5705717",
"0.56932175",
"0.5684104",
"0.56136143",
"0.5607358",
"0.559614",
"0.5584539",
"0.55763674",
"0.5553745",... | 0.7563744 | 0 |
PATCH/PUT /persona_punto_venta/1 PATCH/PUT /persona_punto_venta/1.json | def update
respond_to do |format|
if @persona_punto_ventum.update(persona_punto_ventum_params)
format.html { redirect_to @persona_punto_ventum, notice: 'Persona punto ventum was successfully updated.' }
format.json { render :show, status: :ok, location: @persona_punto_ventum }
else
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @persona = Persona.find(params[:id])\n \n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.json { head :ok }\n else\n format.json { render :json => @persona.errors,\n :status => :unprocessable_entity }\n end\n end\n end"... | [
"0.6947051",
"0.67096686",
"0.66256475",
"0.66102594",
"0.65836143",
"0.65129006",
"0.6438746",
"0.6425371",
"0.64011145",
"0.63980716",
"0.6397051",
"0.6367387",
"0.6359711",
"0.63567084",
"0.63453615",
"0.6291125",
"0.6271334",
"0.62678224",
"0.6223979",
"0.6216488",
"0.621... | 0.73514277 | 0 |
DELETE /persona_punto_venta/1 DELETE /persona_punto_venta/1.json | def destroy
@punto_venta = PuntoVentum.find(@persona_punto_ventum.punto_venta_id)
@persona_punto_ventum.destroy
respond_to do |format|
format.html { redirect_to @punto_venta, notice: 'Persona punto ventum was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.json { head :ok }\n end\n \n end",
"def destroy\n @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.html { redirect_to personas_url... | [
"0.76277345",
"0.7387782",
"0.7387782",
"0.7387782",
"0.7385074",
"0.7275049",
"0.7166503",
"0.7151515",
"0.71326953",
"0.712416",
"0.7103515",
"0.7092933",
"0.7063283",
"0.70572364",
"0.70177877",
"0.6998521",
"0.6980156",
"0.6980139",
"0.69677246",
"0.69669056",
"0.6955762"... | 0.7592983 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_persona_punto_ventum
@persona_punto_ventum = PersonaPuntoVentum.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 persona_punto_ventum_params
params.require(:persona_punto_ventum).permit(:persona_id, :punto_venta_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.6980957",
"0.6783065",
"0.6747844",
"0.6741468",
"0.67356336",
"0.6592548",
"0.65036845",
"0.64978707",
"0.64825076",
"0.64795035",
"0.64560914",
"0.64397955",
"0.6379666",
"0.6376688",
"0.6366702",
"0.6319728",
"0.6300833",
"0.6300629",
"0.6294277",
"0.6293905",
"0.629117... | 0.0 | -1 |
Eval if the current expression is already a number | def isFloat?
!!Float(exp) rescue false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expr(str)\n return unless str\n eval(str, Math.bind) || 0\n rescue SyntaxError, NameError\n cfg_err(\"#{str} is not number\")\n end",
"def is_number? expr\n return false if expr.nil?\n expr = \"#{expr}\" # we need this condition in case the expr is a number\n expr.match /... | [
"0.7315698",
"0.7027335",
"0.6626165",
"0.6408532",
"0.6296418",
"0.62816715",
"0.6209894",
"0.61475843",
"0.6131619",
"0.6125184",
"0.6049057",
"0.602493",
"0.6009801",
"0.5955635",
"0.5955635",
"0.5930307",
"0.59297365",
"0.5915375",
"0.58854157",
"0.58832747",
"0.5882503",... | 0.0 | -1 |
Returns the string with the expression | def to_s
return @exp
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n @expression.to_s\n end",
"def to_s\n template = indirect? ? \"[%s]\" : \"%s\"\n return template % expr_to_s\n end",
"def to_s\n operator_string + \" \" + @expression.to_s\n end",
"def expr_to_s\n buf = ''\n each_term do |term|\n if term[:operator]\n buf... | [
"0.7602983",
"0.73803777",
"0.71119624",
"0.68511164",
"0.68256235",
"0.67675394",
"0.6749405",
"0.659083",
"0.6572321",
"0.65316355",
"0.65053385",
"0.6425547",
"0.6419921",
"0.64164835",
"0.63943785",
"0.63750696",
"0.6351578",
"0.6273584",
"0.6247334",
"0.62367016",
"0.623... | 0.6759765 | 6 |
Return the float point of the expression, otherwise raise an error | def to_f
if isFloat? then
value = exp.to_f
return value
elsif exp == "Infinity" then return @@MAX_VALUE
elsif exp == "-Infinity" then return @@MIN_VALUE
else
raise "Non-float conversion in expression: " + exp
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Float(p0) end",
"def to_float!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 11 )\n\n type = TO_FLOAT\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 313:11: 'float:'\n match( \"float:\... | [
"0.6644832",
"0.6538606",
"0.65259284",
"0.6385289",
"0.6373016",
"0.63188416",
"0.6293305",
"0.62895405",
"0.62686646",
"0.61740994",
"0.61555135",
"0.6135612",
"0.6124431",
"0.60668963",
"0.606103",
"0.6043514",
"0.59881836",
"0.5977649",
"0.59574723",
"0.5941438",
"0.59347... | 0.65456533 | 1 |
First step: Get OAuth2 Authorization code Once you created a Twitch application you can call this method with your own client_id and client_secret to generate a link to authorize the script to access your Twitch account. After completing the process you will be redirected to a URL including the OAuth2 Authorization Cod... | def generate_login_link
Twitch::Client.new(
client_id: 'YOUR_CLIENT_ID',
client_secret: 'YOUR_CLIENT_SECRET',
scopes: ["channel:manage:broadcast"],
token_type: :user
)
rescue TwitchOAuth2::Error => e
puts e.metadata[:link]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorize\n return credentials if credentials\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = $stdin.gets\n authorizer.get_and_store_credentials_from_c... | [
"0.6999043",
"0.6935346",
"0.69292057",
"0.6870849",
"0.6834623",
"0.68290114",
"0.6819623",
"0.6817486",
"0.6813613",
"0.6813613",
"0.6813613",
"0.6813613",
"0.6810486",
"0.6810486",
"0.6810486",
"0.6810486",
"0.6810486",
"0.6810486",
"0.6810486",
"0.6810486",
"0.6810486",
... | 0.6419732 | 69 |
Second step: Get OAuth2 Access and Refresh tokens With the Authorization code obtained in the previous step, you can get the access_token and the refresh_token | def get_auth_tokens(code)
oauth_client = TwitchOAuth2::Client.new(
client_id: 'YOUR_CLIENT_ID',
client_secret: 'YOUR_CLIENT_SECRET',
scopes: ["channel:manage:broadcast"]
)
puts oauth_client.token(token_type: :user, code: code)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step2\n initialize_vars\n url = \"#{@oauth_vars[:token_url]}?code=#{params[:code]}&grant_type=authorization_code&client_id=#{@oauth_vars[:client_id]}&client_secret=#{@oauth_vars[:client_secret]}&response_type=code&redirect_uri=#{@redirect_uri}\"\n rep = JSON.parse(get_json_from_https(url))\n sessio... | [
"0.80101806",
"0.78447646",
"0.7616425",
"0.7357725",
"0.7316766",
"0.7306432",
"0.7303253",
"0.72949505",
"0.7294063",
"0.7265035",
"0.723964",
"0.7234714",
"0.7213684",
"0.71711695",
"0.7160982",
"0.7092467",
"0.7078341",
"0.7074919",
"0.7053377",
"0.7053071",
"0.7024346",
... | 0.0 | -1 |
Third step: Get your user_id from your login name | def get_user_id(login)
twitch_client = Twitch::Client.new(
client_id: 'YOUR_CLIENT_ID',
client_secret: 'YOUR_CLIENT_SECRET',
access_token: 'YOUR_ACCESS_TOKEN',
refresh_token: 'YOUR_REFRESH_TOKEN',
scopes: ["channel:manage:broadcast"],
token_type: :user
)
puts twitch_client.get_users(login... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_id(user_name)\n return get_value_of(user_name, :id)\n end",
"def get_user_id(username)\n # .........\n end",
"def get_user_id\n # TODO: #6. Complete the function to return your user id\n user_id = 'Put your user ID here'\n end",
"def user_id\n username\n end",
"def user_i... | [
"0.77812105",
"0.7765688",
"0.76521385",
"0.75913304",
"0.7541599",
"0.738873",
"0.7376876",
"0.7328339",
"0.7315179",
"0.7283882",
"0.71611977",
"0.7157964",
"0.7137468",
"0.7137468",
"0.7124738",
"0.7108057",
"0.7098127",
"0.7092423",
"0.7087813",
"0.70851034",
"0.7057295",... | 0.0 | -1 |
GET /dom0s GET /dom0s.json | def index
@dom0s = Dom0.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_domoticz_json(domoticz_uri)\n uri = URI(domoticz_uri)\n response = Net::HTTP.get(uri)\n JSON.parse(response)\nend",
"def get_json\n html = Nokogiri::HTML(@page)\n text = open(\"https://theintercept.com/api/requestSIDDocuments/?orderBy=publishedTime&orderDirection=desc&perPage=2000\").read\n ... | [
"0.6123326",
"0.581122",
"0.5674552",
"0.5660206",
"0.5556566",
"0.5537444",
"0.5526527",
"0.5493284",
"0.546806",
"0.5455959",
"0.5452535",
"0.544711",
"0.54072374",
"0.53764915",
"0.5340168",
"0.5336084",
"0.53206885",
"0.52866936",
"0.52781004",
"0.52780795",
"0.5273331",
... | 0.7176695 | 0 |
GET /dom0s/1 GET /dom0s/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @dom0s = Dom0.all\n end",
"def get_domoticz_json(domoticz_uri)\n uri = URI(domoticz_uri)\n response = Net::HTTP.get(uri)\n JSON.parse(response)\nend",
"def set_dom0\n @dom0 = Dom0.find(params[:id])\n end",
"def dom0_params\n params[:dom0]\n end",
"def service_document\... | [
"0.6847571",
"0.63628334",
"0.6062485",
"0.57496095",
"0.5734541",
"0.5715196",
"0.55990005",
"0.5503167",
"0.55026585",
"0.5459096",
"0.5449624",
"0.5447301",
"0.5413397",
"0.53878415",
"0.5377644",
"0.5362374",
"0.53560823",
"0.53488183",
"0.5337409",
"0.5337409",
"0.533275... | 0.0 | -1 |
POST /dom0s POST /dom0s.json | def create
@dom0 = Dom0.new(dom0_params)
respond_to do |format|
if @dom0.save
format.html { redirect_to @dom0, notice: 'Dom0 was successfully created.' }
format.json { render :show, status: :created, location: @dom0 }
else
format.html { render :new }
format.json { re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dom0_params\n params[:dom0]\n end",
"def index\n @dom0s = Dom0.all\n end",
"def destroy\n @dom0.destroy\n respond_to do |format|\n format.html { redirect_to dom0s_url, notice: 'Dom0 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def set_do... | [
"0.57373255",
"0.571542",
"0.56012785",
"0.551812",
"0.54482204",
"0.5268613",
"0.5030848",
"0.49307495",
"0.4899661",
"0.48912323",
"0.4800201",
"0.47533327",
"0.4743312",
"0.47391972",
"0.4730478",
"0.4728335",
"0.47194347",
"0.47138953",
"0.47062275",
"0.46899125",
"0.4672... | 0.71896154 | 0 |
PATCH/PUT /dom0s/1 PATCH/PUT /dom0s/1.json | def update
respond_to do |format|
if @dom0.update(dom0_params)
format.html { redirect_to @dom0, notice: 'Dom0 was successfully updated.' }
format.json { render :show, status: :ok, location: @dom0 }
else
format.html { render :edit }
format.json { render json: @dom0.errors,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => ... | [
"0.64772713",
"0.634038",
"0.6260748",
"0.6077363",
"0.6016408",
"0.6016157",
"0.58441067",
"0.5841534",
"0.5798322",
"0.5798322",
"0.57883316",
"0.57657605",
"0.57232183",
"0.5708018",
"0.56785774",
"0.56506515",
"0.56330734",
"0.5627697",
"0.56198543",
"0.5617977",
"0.56132... | 0.6755568 | 0 |
DELETE /dom0s/1 DELETE /dom0s/1.json | def destroy
@dom0.destroy
respond_to do |format|
format.html { redirect_to dom0s_url, notice: 'Dom0 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 delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def test_del\n header 'Conte... | [
"0.6924843",
"0.68064195",
"0.66468406",
"0.661468",
"0.6569856",
"0.6568001",
"0.6556821",
"0.65491503",
"0.6527892",
"0.6527892",
"0.6527892",
"0.6527892",
"0.65258557",
"0.65239805",
"0.6523552",
"0.6518982",
"0.64959806",
"0.64850986",
"0.64850986",
"0.647416",
"0.6471033... | 0.7263812 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_dom0
@dom0 = Dom0.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 dom0_params
params[:dom0]
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 |
Optionally add a hash of extra data, called info, to this exception. You can also add the engine's execution context, if available. | def initialize(msg, info = {}, execution_context: nil)
super(msg)
@info = info
@execution_context = execution_context ? execution_context.dup : nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_additional_data\n if Rails.application.secrets[:sentry_dsn].present?\n Raven.user_context(\n id: current_user&.id,\n email: current_user&.email,\n ip_address: request.ip\n )\n\n Raven.tags_context(\n domain: current_account&.domain,\n account_prefix: cur... | [
"0.6149127",
"0.58971643",
"0.5712527",
"0.56362426",
"0.5394363",
"0.53489006",
"0.5314257",
"0.5285059",
"0.52544266",
"0.5241559",
"0.5232666",
"0.52249277",
"0.5220711",
"0.5209646",
"0.51642823",
"0.5163865",
"0.51624244",
"0.513955",
"0.5135657",
"0.51325256",
"0.512733... | 0.46475872 | 77 |
Reading order U, L, R, D | def adjacent(x, y, map)
[[x, y - 1], [x - 1, y], [x + 1, y], [x, y + 1]].select do |x, y|
(0..map.length-1).cover?(y) &&
(0..map[0].length-1).cover?(x)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def book_reading_order\n return 'right-to-left' if stub_object_type.include?('rtl') || stub_object_type.include?('r-l')\n\n 'left-to-right'\n end",
"def read_u4\n (read_u1 << 24) | read_u3\n end",
"def read(str)\n if self.instance_of?(DUID)\n super\n ... | [
"0.5643176",
"0.553698",
"0.55187225",
"0.5505955",
"0.5376297",
"0.5376297",
"0.5376297",
"0.5376297",
"0.5376297",
"0.5376297",
"0.5376297",
"0.53163785",
"0.53087866",
"0.52546924",
"0.52388155",
"0.51963973",
"0.51685804",
"0.513574",
"0.5117141",
"0.5116897",
"0.50997305... | 0.0 | -1 |
Parse options, check arguments, then process the command | def run
if parsed_options? && arguments_valid?
puts "Start at #{DateTime.now}\n\n" if @options.verbose
output_options if @options.verbose # [Optional]
process_arguments
process_command
puts "\nFinished at #{DateTime.now}" if @options.verbose
else
output_usage
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run\n if parsed_options? && arguments_valid? \n process_arguments \n process_command\n else\n output_options\n end\n end",
"def run\n if options_valid? && option_combinations_valid? \n process_arguments \n process_command\n else\n output_usa... | [
"0.8107569",
"0.80522096",
"0.802113",
"0.79491603",
"0.77211124",
"0.7566804",
"0.7491165",
"0.73961675",
"0.7347632",
"0.73112714",
"0.73112714",
"0.73112714",
"0.73112714",
"0.73112714",
"0.73112714",
"0.7295674",
"0.7289842",
"0.72309864",
"0.7212907",
"0.7212537",
"0.720... | 0.69872856 | 30 |
Performs postparse processing on options | def process_options
@options.verbose = false if @options.quiet
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _process_options(options); end",
"def _process_options(options); end",
"def parse_options; end",
"def parse_options; end",
"def parse!() options.parse!(self) end",
"def process_options\n \n end",
"def process_options\n \n end",
"def process_options\n \n end",
"def proces... | [
"0.7552417",
"0.7552417",
"0.74314475",
"0.74314475",
"0.71792066",
"0.7081571",
"0.7081571",
"0.7081571",
"0.6974218",
"0.68648267",
"0.67707926",
"0.67595637",
"0.67076904",
"0.67076904",
"0.6699218",
"0.66534525",
"0.6587343",
"0.65802133",
"0.6535342",
"0.6501349",
"0.648... | 0.59495616 | 54 |
True if required arguments were provided | def arguments_valid?
# TO DO - implement your real logic here
true if @arguments.length == 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_missing_required_arg?\n !missing_required_arguments.empty?\n end",
"def includes_arguments?\n !default_data.empty? || !flags.empty? ||\n !required_args.empty? || !optional_args.empty? ||\n !remaining_arg.nil? || flags_before_args_enforced?\n end",
"def ar... | [
"0.8533331",
"0.84634876",
"0.8193903",
"0.79284185",
"0.7852744",
"0.78392625",
"0.78328884",
"0.782945",
"0.7823655",
"0.78031105",
"0.7782608",
"0.77764374",
"0.77586794",
"0.77535295",
"0.7736395",
"0.7735971",
"0.7722972",
"0.76806915",
"0.76806915",
"0.76514757",
"0.763... | 0.7768861 | 12 |
Use a builtin term list dict: a key in DICTS | def augment_from_dict(dict)
path = DICTS[dict.to_sym] || raise(InvalidDictionaryName, dict)
@word_file = File.open path
puts "#{self.class} will augment AppleSpell with words from #{path}"
augment!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def characterization_terms(omdoc)\n h = {}\n omdoc.class.terminology.terms.each_pair do |key, target|\n # a key is a proxy if its target responds to proxied_term\n next unless target.respond_to? :proxied_term\n begin\n h[key] = omdoc.send(key)\n rescue N... | [
"0.63485163",
"0.6270822",
"0.6042182",
"0.5879882",
"0.5841723",
"0.5702244",
"0.5678703",
"0.55880183",
"0.5579595",
"0.5521153",
"0.5458601",
"0.54581356",
"0.54553336",
"0.5434672",
"0.5431072",
"0.53826547",
"0.5373402",
"0.537219",
"0.5360896",
"0.53560424",
"0.5355689"... | 0.0 | -1 |
Use a custom file of new line separated words. If the words Have spaces in them they'll be split path: absolute path to file | def augment_from_file(path)
begin
@word_file = File.open path
rescue Errno::ENOENT => e
puts "[#{self.class}] could not find new dictionary file at \"#{word_file}\""
exit 1
end
puts "#{self.class} will augment AppleSpell with words from #{path}"
augment!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populate(file)\n words = file.split(\"\\n\")\n insert_words(words)\n end",
"def add_words_from_text_file(file_path)\n words = []\n\n File.open(file_path, 'r') do |file|\n file.each do |line|\n words.push(line.chomp)\n end\n end\n\n add_words(wor... | [
"0.64177763",
"0.6314846",
"0.62469465",
"0.6236361",
"0.621271",
"0.61707276",
"0.60696256",
"0.59244746",
"0.5914247",
"0.5788779",
"0.57681394",
"0.5758809",
"0.57059145",
"0.57059145",
"0.57059145",
"0.5668894",
"0.56483287",
"0.5629003",
"0.56061846",
"0.55933905",
"0.55... | 0.50888014 | 85 |
Insert assets into a gallery or uploader | def insert
@fieldname = params[:fieldname]
@uploader_id = params[:uploader_id]
@assets = Assetabler::Asset.find(params[:asset_ids])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_assets\n num_files = params[:count].to_i\n \n @new_assets = []\n @new_assets_html = []\n num_files.times do |file_num|\n # recreate the file key from the current index\n file = params[\"file-\"+file_num.to_s]\n @asset = Asset.new(:name => file.original_filename)\n @asset.... | [
"0.61756617",
"0.6154996",
"0.61383945",
"0.6001432",
"0.60004574",
"0.59871066",
"0.5963862",
"0.5963862",
"0.5963862",
"0.5954183",
"0.59353906",
"0.59330684",
"0.5869575",
"0.5823433",
"0.5820491",
"0.5820491",
"0.5820491",
"0.57837665",
"0.57716024",
"0.57602334",
"0.5738... | 0.68637425 | 0 |
Create a new asset | def create
# Get the content type
content_type = params[:file].content_type
asset_params = {name: params[:file].original_filename, filename: params[:file]}
# Create the appropriate model
if content_type.split("/").first == "image"
@asset = Assetabler::Image.new(asset_params)
elsif content... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_asset\n @asset = Asset.new\n end",
"def create\n @asset = OtherAsset.new(params[:asset])\n asset_create('other', others_url)\n end",
"def create\n repo = assets_repo\n\n file = (params.has_key?(:file)) ? params[:file] : false\n @v_asset = repo.create file\n\n respond_to do |forma... | [
"0.79199594",
"0.7846794",
"0.7725987",
"0.7721308",
"0.7702766",
"0.768901",
"0.7639895",
"0.7614302",
"0.75789064",
"0.7523736",
"0.7493198",
"0.74887085",
"0.74346286",
"0.74309444",
"0.73962104",
"0.7307768",
"0.7296089",
"0.72891164",
"0.72719765",
"0.72710246",
"0.72691... | 0.6479318 | 62 |
Edit an asset will return the edit form | def edit
@asset = Assetabler::Asset.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n @asset = Asset.find(params[:id])\n end",
"def edit_asset\n @asset = Asset.find(params[:id])\n end",
"def show\n @asset = OtherAsset.find(params[:id])\n @content_title = @title = \"Editing #{@asset.title}\"\n @submit_value = \"Update\"\n asset_show\n end",
"def edit\n @uploa... | [
"0.84800553",
"0.83911324",
"0.77883995",
"0.7457932",
"0.743196",
"0.73515004",
"0.73232806",
"0.7302282",
"0.7232861",
"0.7217202",
"0.7217202",
"0.7217202",
"0.7209364",
"0.72051823",
"0.71942514",
"0.7173698",
"0.7163836",
"0.7160366",
"0.715314",
"0.71491045",
"0.7147524... | 0.8413417 | 1 |
Permitted params for the model | def permitted_params
params.require(params[:asset_type].underscore.gsub('/', '_').to_sym).permit(
:name,
:filename,
:body,
:content_type,
:width,
:height,
:asset_type,
:ratio
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _params\n # params.require(:model).permit(:model:classname, :schema, :tablename, :name)\n params.require(:model).permit(:classname, :schema, :tablename, :name, :default_sort_field)\n end",
"def params\n @_params\n end",
"def params; end",
"def params; end",
"def params; en... | [
"0.7467585",
"0.7439998",
"0.7380314",
"0.7380314",
"0.7380314",
"0.7380314",
"0.7380314",
"0.7380314",
"0.7380314",
"0.7380314",
"0.7380314",
"0.7380314",
"0.7380314",
"0.7380314",
"0.7380314",
"0.7380314",
"0.7380314",
"0.7380314",
"0.7380314",
"0.7347787",
"0.73304486",
... | 0.0 | -1 |
Performs a HTTP request method Request method (:get, :post, :put, :delete) url Target URL payload Delivery content format Delivery format | def request(method, url, payload, format)
opts = {
:method => method,
:url => url,
:payload => payload,
:headers => {:content_type => CONTENT_TYPES[format]},
:timeout => TIMEOUT,
:open_timeout => OPEN_TIMEOUT
}
RestCl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_request url, parameters={}, method=:get, settings={}\n raise 'not implemented'\n end",
"def run_request(method, url, body, headers); end",
"def invoke(options = {})\n defaults = { method: 'get'}\n options = defaults.merge(options)\n\n connection.send(options[:me... | [
"0.68332547",
"0.6700983",
"0.6639594",
"0.6551825",
"0.65194184",
"0.6514597",
"0.6471604",
"0.6460943",
"0.63053584",
"0.626688",
"0.6263862",
"0.62524426",
"0.62160903",
"0.62027645",
"0.62000614",
"0.6195601",
"0.61842906",
"0.6175784",
"0.6171844",
"0.61623764",
"0.61606... | 0.72402686 | 0 |
Ex: to get substring you need to use regex scanning String1 = " " String1.scan( /])>/).last.first | def initialize(sym_str)
# We get the name from the string first
@nom = sym_str.split(" (").first
# Then we get the parenthesis if it exists
parenth_scan = sym_str.scan(/\(([^>]*)\)/)
parenth = parenth_scan.first ? parenth_scan.first.first : nil
if parenth
# ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def substring_up_to_match\n @matches.nil? ? nil : @buffer.match(expr_substring_to_match)[0]\n end",
"def extract_string(range, strscan); end",
"def first(string)\n return string[0]\nend",
"def find_substring_4(string, substring)\n string.match(substring) ? string.match(substring).begin(0) :fals... | [
"0.6596665",
"0.6487462",
"0.61651033",
"0.61589164",
"0.6103066",
"0.6094068",
"0.60571665",
"0.6043849",
"0.5996793",
"0.596414",
"0.5895244",
"0.58793586",
"0.5854926",
"0.5844705",
"0.5834588",
"0.5820077",
"0.58106154",
"0.5806086",
"0.57965606",
"0.579076",
"0.5790085",... | 0.0 | -1 |
GET /vitabus GET /vitabus.json | def index
@vitabus = Vitabu.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vitals\n raise UserNotAuthenticated unless access_token\n\n get('records/vitals')\n end",
"def index\n @vampires = Vampire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @vampires }\n end\n end",
"def show\n @virus = Virus.find(param... | [
"0.695314",
"0.6797506",
"0.6641814",
"0.6636317",
"0.6636317",
"0.66190094",
"0.65613353",
"0.6548526",
"0.65438986",
"0.652484",
"0.65126985",
"0.65052944",
"0.65038717",
"0.6428445",
"0.6414535",
"0.6408994",
"0.63224435",
"0.6299798",
"0.6285904",
"0.6283811",
"0.62795573... | 0.7213476 | 0 |
GET /vitabus/1 GET /vitabus/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @vitabus = Vitabu.all\n end",
"def index\n @vampires = Vampire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @vampires }\n end\n end",
"def vitals\n raise UserNotAuthenticated unless access_token\n\n get('records/vitals')\n ... | [
"0.71154535",
"0.69438815",
"0.68024874",
"0.6783631",
"0.6778577",
"0.675284",
"0.675284",
"0.67367005",
"0.6713769",
"0.67051756",
"0.66494787",
"0.66378397",
"0.6606909",
"0.65858674",
"0.65247554",
"0.6500207",
"0.6495198",
"0.6492084",
"0.6483729",
"0.645896",
"0.6447457... | 0.0 | -1 |
POST /vitabus POST /vitabus.json | def create
@vitabus = Vitabu.new(vitabus_params)
respond_to do |format|
if @vitabus.save
format.html { redirect_to @vitabus, notice: 'Vitabu was successfully created.' }
format.json { render action: 'show', status: :created, location: @vitabus }
else
format.html { render act... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @vitamina = Vitamina.new(vitamina_params)\n\n respond_to do |format|\n if @vitamina.save\n format.html { redirect_to @vitamina, notice: 'Vitamina was successfully created.' }\n format.json { render :show, status: :created, location: @vitamina }\n else\n format.html... | [
"0.6499655",
"0.63951945",
"0.63511556",
"0.6227624",
"0.62136674",
"0.62136674",
"0.6202348",
"0.62002325",
"0.6183671",
"0.6182404",
"0.61244017",
"0.61104494",
"0.60863024",
"0.6044589",
"0.6037201",
"0.60351026",
"0.60107845",
"0.5992457",
"0.59287417",
"0.59257084",
"0.5... | 0.7407548 | 0 |
PATCH/PUT /vitabus/1 PATCH/PUT /vitabus/1.json | def update
respond_to do |format|
if @vitabus.update(vitabus_params)
format.html { redirect_to @vitabus, notice: 'Vitabu was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @vitabus.errors, st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def put!\n request! :put\n end",
"def update!(params)\n res = @c... | [
"0.66542",
"0.66045177",
"0.6471563",
"0.6462322",
"0.6385802",
"0.63763386",
"0.63688964",
"0.6366525",
"0.63304",
"0.6278602",
"0.6255677",
"0.6231925",
"0.61880845",
"0.6171431",
"0.6167253",
"0.6150614",
"0.6140274",
"0.60750055",
"0.60743695",
"0.6070956",
"0.60682815",
... | 0.68498445 | 0 |
DELETE /vitabus/1 DELETE /vitabus/1.json | def destroy
@vitabus.destroy
respond_to do |format|
format.html { redirect_to vitabus_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @vachana = Vachana.find(params[:id])\n @vachana.destroy\n\n respond_to do |format|\n format.html { redirect_to vachanas_url... | [
"0.7228342",
"0.7202471",
"0.70137244",
"0.70137244",
"0.69435054",
"0.6893573",
"0.689157",
"0.68524086",
"0.68480206",
"0.68387157",
"0.6835442",
"0.6819716",
"0.6796227",
"0.67877436",
"0.67875737",
"0.67846715",
"0.67788893",
"0.67628354",
"0.67628354",
"0.67628354",
"0.6... | 0.751043 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_vitabus
@vitabus = Vitabu.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 vitabus_params
params.require(:vitabus).permit(:Name, :title, :dateborrowed)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /navigation_entries/1 GET /navigation_entries/1.xml | def show
if dark_side?
@navigation_entry = NavigationEntry.find(params[:id])
else
@navigation_entry = NavigationEntry.find(params[:id], :include => :container)
@navigation_entry_parent = @navigation_entry.parent
@current_navigation_entry = @navigation_entry
load_misc_stuffs
@... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n get_system\n @nav_entry = NavEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @nav_entry }\n end\n end",
"def new\n @navigation_entry = NavigationEntry.new\n\n respond_to do |format|\n format.html # new.ht... | [
"0.6165826",
"0.60939664",
"0.56854534",
"0.56743675",
"0.5634604",
"0.56317663",
"0.5625504",
"0.5591887",
"0.557813",
"0.5533949",
"0.5523955",
"0.55136216",
"0.55057335",
"0.548531",
"0.543066",
"0.5426167",
"0.53777665",
"0.5370002",
"0.5351255",
"0.53340465",
"0.5289536"... | 0.57701737 | 2 |
GET /navigation_entries/new GET /navigation_entries/new.xml | def new
@navigation_entry = NavigationEntry.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @navigation_entry }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n get_system\n @parent = NavEntry.find(params[:parent_id]) unless params[:parent_id].nil?\n @nav_entry = NavEntry.new(:system => @system, :parent => @parent)\n get_parents\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nav_entry }\n end\n... | [
"0.6963487",
"0.68094933",
"0.6779341",
"0.65997523",
"0.65111494",
"0.6475915",
"0.6453136",
"0.6371884",
"0.6367441",
"0.6349056",
"0.63081664",
"0.6302887",
"0.6284018",
"0.6284018",
"0.6281309",
"0.6276518",
"0.62648857",
"0.62576354",
"0.6250752",
"0.6236876",
"0.621537"... | 0.76766187 | 0 |
POST /navigation_entries POST /navigation_entries.xml | def create
@navigation_entry = NavigationEntry.new(params[:navigation_entry])
respond_to do |format|
if @navigation_entry.save
format.html { redirect_to(@navigation_entry, :notice => 'Navigation entry was successfully created.') }
format.xml { render :xml => @navigation_entry, :status =>... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @navigation_entry = NavigationEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @navigation_entry }\n end\n end",
"def create \n get_system\n @nav_entry = NavEntry.new(params[:nav_entry])\n get_parents\n\n respond_to do |... | [
"0.5658883",
"0.5533778",
"0.50773793",
"0.49485782",
"0.4905544",
"0.4884094",
"0.48772314",
"0.48564732",
"0.48458454",
"0.46960834",
"0.46764162",
"0.46683216",
"0.4659268",
"0.46583784",
"0.46539962",
"0.46283823",
"0.46105677",
"0.4609168",
"0.46084428",
"0.460109",
"0.4... | 0.64855915 | 0 |
PUT /navigation_entries/1 PUT /navigation_entries/1.xml | def update
@navigation_entry = NavigationEntry.find(params[:id])
respond_to do |format|
if @navigation_entry.update_attributes(params[:navigation_entry])
format.html { redirect_to(@navigation_entry, :notice => 'Navigation entry was successfully updated.') }
format.xml { head :ok }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n get_system\n @nav_entry = NavEntry.find(params[:id])\n get_parents\n\n respond_to do |format|\n if @nav_entry.update_attributes(params[:nav_entry])\n format.html { redirect_to(system_nav_entry_path(@system, @nav_entry), :notice => 'Nav entry was successfully updated.') }\n ... | [
"0.59629303",
"0.55001026",
"0.5487206",
"0.5458992",
"0.5433569",
"0.5425323",
"0.5262817",
"0.5261352",
"0.5249022",
"0.5235539",
"0.52352047",
"0.52067214",
"0.51349837",
"0.50847137",
"0.50655854",
"0.5048693",
"0.5015466",
"0.49999553",
"0.4958886",
"0.49584007",
"0.4950... | 0.6453088 | 0 |
DELETE /navigation_entries/1 DELETE /navigation_entries/1.xml | def destroy
@navigation_entry = NavigationEntry.find(params[:id])
@navigation_entry.destroy
respond_to do |format|
format.html { redirect_to(navigation_entries_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def delete; rest_delete(link('self')); end",
"def delete; rest_delete(link('self')); end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n pa... | [
"0.65846765",
"0.65635955",
"0.65635955",
"0.6414862",
"0.63691705",
"0.6178738",
"0.6097885",
"0.60384494",
"0.5999612",
"0.5992182",
"0.5987641",
"0.59374195",
"0.5907902",
"0.59064543",
"0.5905868",
"0.59022814",
"0.5897556",
"0.58923584",
"0.58897096",
"0.5878547",
"0.587... | 0.7221005 | 0 |
def self.sign_up(username, password) User.new(username, password, []) end | def initialize(username, password)
@username = username
@password = password
@tweet_history = []
@followers = []
@following = []
@@all_users.push(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign_up\n @user = User.new\n end",
"def create_user(name, email, password)\n\n # Password is hashed automatically\n user = User.new(name: name, email: email, password: password)\n user.save!\n end",
"def new_user\n User.new({\n email: 'hoge@hoge',\n password: 'hoge',\n passw... | [
"0.8118255",
"0.80356276",
"0.7992348",
"0.7960663",
"0.7943288",
"0.79405856",
"0.79405856",
"0.793993",
"0.7929657",
"0.78989303",
"0.75510544",
"0.7548317",
"0.7538202",
"0.75092083",
"0.75056314",
"0.74841994",
"0.74495775",
"0.74349",
"0.74175125",
"0.7413963",
"0.73957"... | 0.0 | -1 |
Iterates the collection through the given block. | def each
self.num_geometries.times do |n|
yield self.get_geometry_n(n)
end
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each(&block)\n @collection.each(&block)\n end",
"def each(&block)\n internal_collection.each(&block)\n end",
"def each(&block)\n @collection.each(&block)\n end",
"def each(&block)\n @collection.each do |collectable|\n if block_given?\n block.call collect... | [
"0.8226908",
"0.8147401",
"0.8035317",
"0.7822804",
"0.7798454",
"0.7636493",
"0.7485495",
"0.7434723",
"0.7408925",
"0.73424184",
"0.7340868",
"0.72893155",
"0.72893155",
"0.72893155",
"0.72893155",
"0.72893155",
"0.72893155",
"0.72748995",
"0.72555065",
"0.72555065",
"0.724... | 0.0 | -1 |
Returns the nth geometry from the collection. | def [](*args)
self.to_a[*args]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def geometry_n(n)\n raise Error::UnsupportedOperation, \"Method GeometryCollection#geometry_n not defined.\"\n end",
"def last\n self.get_geometry_n(self.num_geometries - 1) if self.num_geometries > 0\n end",
"def last\n self.get_geometry_n(self.num_geometries - 1) if self.num_geometri... | [
"0.721603",
"0.63378745",
"0.63378745",
"0.610177",
"0.5901542",
"0.5901542",
"0.55415785",
"0.5411624",
"0.5410828",
"0.5393923",
"0.5233196",
"0.5220837",
"0.51929516",
"0.51917446",
"0.5190835",
"0.5189134",
"0.516874",
"0.5156625",
"0.5113467",
"0.5098663",
"0.50854063",
... | 0.0 | -1 |
Returns the last geometry from the collection. | def last
self.get_geometry_n(self.num_geometries - 1) if self.num_geometries > 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last\n @collection.size - 1\n end",
"def last\n @features.last\n end",
"def geometry\n @geometry ||= _geometry\n end",
"def last\n @locations.last\n end",
"def last\n @adapter.last(collection)\n end",
"def last_point\n path_points.last\n end",
"def la... | [
"0.68261254",
"0.6805249",
"0.6681199",
"0.6625544",
"0.6611591",
"0.66014403",
"0.6566384",
"0.6534133",
"0.65032506",
"0.6473712",
"0.64014393",
"0.63910794",
"0.6388546",
"0.63861334",
"0.6358029",
"0.6349516",
"0.63397944",
"0.6269032",
"0.6242639",
"0.61935025",
"0.61626... | 0.88753515 | 1 |
Returns a Hash suitable for converting to JSON. | def as_json(options = {})
self.collect do |p|
p.to_jsonable options
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_hash\n validate!\n @hash ||= json\n end",
"def hash_for_json(*)\n to_h\n end",
"def to_hash\n to_a.hash\n end",
"def for_json\n to_hash\n end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",... | [
"0.84804773",
"0.82990366",
"0.7984718",
"0.79791546",
"0.78604966",
"0.78604966",
"0.78604966",
"0.78604966",
"0.78604966",
"0.78604966",
"0.78534746",
"0.78150487",
"0.78150487",
"0.7767882",
"0.7763199",
"0.77063125",
"0.77063125",
"0.77063125",
"0.77063125",
"0.77063125",
... | 0.0 | -1 |
Build some XmlMarkup for KML. | def to_kml(*args)
self.collect do |p|
p.to_kml(*args)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render(xm=Builder::XmlMarkup.new(:indent => 2))\n xm.instruct!\n xm.kml(:xmlns => 'http://www.opengis.net/kml/2.2'){\n objects.each { |o| o.render(xm) }\n }\n end",
"def generatexml()\n merge(gadrgeneratexml: 'true')\n end",
"def xml_builder\n return Builder::XmlMarkup.new... | [
"0.7590852",
"0.63832104",
"0.6277845",
"0.6256495",
"0.6167769",
"0.61499566",
"0.6101771",
"0.60962003",
"0.6065279",
"0.60626996",
"0.60562754",
"0.6036775",
"0.6028168",
"0.6011442",
"0.6005888",
"0.600519",
"0.59457624",
"0.59089285",
"0.59065336",
"0.5900416",
"0.587521... | 0.0 | -1 |
Build some XmlMarkup for GeoRSS. Since GeoRSS is pretty trimed down, we just take the entire collection and use the exterior_ring as a Polygon. Not to bright, mind you, but until GeoRSS stops with the suck, what are we to do. You should include the appropriate georss and gml XML namespaces in your document. | def to_georss(*args)
self.exterior_ring.to_georss(*args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def georss_simple_representation(options)\r\n georss_ns = options[:georss_ns] || \"georss\"\r\n geom_attr = options[:geom_attr]\r\n \"<#{georss_ns}:polygon#{geom_attr}>\" + self[0].georss_poslist + \"</#{georss_ns}:polygon>\\n\"\r\n end",
"def kml_representation(options = {})\r\n ... | [
"0.66493917",
"0.64349955",
"0.6293881",
"0.6192709",
"0.6188419",
"0.60362005",
"0.5991851",
"0.5926231",
"0.58944494",
"0.56539595",
"0.5539931",
"0.55304796",
"0.5376209",
"0.53721005",
"0.5371946",
"0.537116",
"0.5364192",
"0.5338653",
"0.5311812",
"0.5276608",
"0.526631"... | 0.5193002 | 27 |
Dumps points similarly to the PostGIS `ST_DumpPoints` function. | def dump_points(cur_path = [])
self.each do |geom|
cur_path << geom.dump_points
end
cur_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dump_points(cur_path = [])\n cur_path.push(self.dup)\n end",
"def pp_points(points)\n \"[%s]\" % points.map { |point| \"%d: %d,%d\" % point }.join(\" \")\n end",
"def save_point\n @save_points\n end",
"def to_s\n @points.join(' ')\n end",
"def\n\t\tprint_point\n\t\tp \"(... | [
"0.6411781",
"0.6126447",
"0.6121726",
"0.5772761",
"0.5558724",
"0.5546756",
"0.5493614",
"0.543597",
"0.5423503",
"0.5344848",
"0.52858406",
"0.52596927",
"0.52544564",
"0.5251316",
"0.52197444",
"0.52121836",
"0.52052927",
"0.52044517",
"0.5167359",
"0.516649",
"0.51576203... | 0.760294 | 0 |
Obtain IP address from http request header | def src_addr_on_header
request.headers['X-Forwarded-For'] || request.headers['REMOTE_ADDR']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_ip\n return request.headers[\"X-Forwarded-For\"] if request.headers[\"X-Forwarded-For\"]\n return request.headers[\"REMOTE_ADDR\"] if request.headers[\"REMOTE_ADDR\"]\n end",
"def get_ip_address\n request.remote_ip\n end",
"def parse_ip\n @request[FHOST] || BLANK_STR\n end",... | [
"0.7722499",
"0.75440204",
"0.75008315",
"0.7356482",
"0.7319257",
"0.7288718",
"0.7276756",
"0.7239505",
"0.72183764",
"0.72174376",
"0.7175481",
"0.7157487",
"0.71513623",
"0.7093448",
"0.7081977",
"0.6993343",
"0.6965759",
"0.69640845",
"0.6960995",
"0.6924997",
"0.6917261... | 0.7665337 | 1 |
Obtain HOST FQDN from http request header | def host_on_header
request.headers['HTTP_HOST']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def host\n @headers['HTTP_X_FORWARDED_HOST'] || @headers['HTTP_HOST'] \n end",
"def hostname\n (request.env['HTTP_X_FORWARDED_SERVER'] =~ /[a-z]*/) ? request.env['HTTP_X_FORWARDED_SERVER'] : request.env['HTTP_HOST']\n end",
"def host\n @request['Host']\n end",
"def hostname\n protoco... | [
"0.77148664",
"0.7541365",
"0.7495885",
"0.71831733",
"0.71040004",
"0.6984895",
"0.6928435",
"0.68830967",
"0.6800195",
"0.6766139",
"0.67552334",
"0.6754956",
"0.67038345",
"0.6666227",
"0.6666208",
"0.66583365",
"0.66311055",
"0.6595148",
"0.6585325",
"0.6584013",
"0.65806... | 0.82105935 | 0 |
Obtain User Agent from http request header | def user_agent_on_header
request.headers['HTTP_USER_AGENT']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_agent\n @headers['User-Agent']\n end",
"def user_agent\n @headers['User-Agent']\n end",
"def user_agent\n @headers['User-Agent']\n end",
"def user_agent\n @request['User-Agent']\n end",
"def user_agent\n headers[\"HTTP_USER_AGENT\"] || headers[\"USER-AGENT\"]\n ... | [
"0.87297374",
"0.87297374",
"0.87297374",
"0.8564696",
"0.8517576",
"0.8340213",
"0.81074625",
"0.80660886",
"0.7931847",
"0.7921811",
"0.7763692",
"0.77623594",
"0.77623594",
"0.7713474",
"0.7711464",
"0.7711464",
"0.7711464",
"0.7658591",
"0.7531901",
"0.7404778",
"0.732046... | 0.8891262 | 0 |
Renders plain text and html to html. If parse_code isn't true, only runs bluecloth on text outside any ... blocks. | def bluecloth(text, parse_code = true, increment_headers = true)
return text if text.nil?
if parse_code
return BlueCloth::new(text).to_html
end
text = text.dup
out = ''
level = 0
until text.empty? do
if level < 1
# Find start of c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def html\n return if self.text.blank?\n\n html = self.text\n \n # s = StringScanner.new(self.text)\n # html = ''\n # while markup = s.scan_until(/\\[code/) do\n # html += RedCloth.new(markup[0..-6]).to_html\n # s.pos= s.pos-5\n # code = s.scan_until(/\\[\\/code\\]/)\n # if cod... | [
"0.6652656",
"0.6535241",
"0.6412524",
"0.6400033",
"0.6294351",
"0.6195641",
"0.61693525",
"0.6141368",
"0.61001754",
"0.60769266",
"0.60422814",
"0.6006865",
"0.59752667",
"0.592088",
"0.5911805",
"0.589874",
"0.5836841",
"0.582105",
"0.5796861",
"0.5793838",
"0.57308114",
... | 0.6571611 | 1 |
Replace to prevent Erubis injection. | def erubis_filter(text)
return text if text.nil?
t = text.dup
t.gsub!('<%', '<%')
t.gsub!('%>', '%&rt;')
t
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace\n end",
"def erb_escape(text)\n # Do not only replace '<%' ! or <r:t>min</r:t>% ==> <% ...\n text.gsub(SECURE_REGEXP) {|code| SAFE_CODE[code]}\n end",
"def undent!\n replace undent\n end",
"def replace(s)\n s.tr(\"aeiouAEIOU'\",\"!\")\nend",
"def sanitize(string_or_io... | [
"0.66146696",
"0.6485839",
"0.63849676",
"0.61406213",
"0.6053341",
"0.5999961",
"0.5924494",
"0.5890652",
"0.5886605",
"0.5863753",
"0.58428395",
"0.58367366",
"0.5835879",
"0.58172697",
"0.5794907",
"0.5793146",
"0.57822055",
"0.5774545",
"0.57470423",
"0.573602",
"0.571723... | 0.6117327 | 4 |
Macro substitutions Expands [[type:resource][name]] macros. Right now, resource is just an attachment. Included types are: url: returns the URL to an attachment image: returns an image tag link: returns a link to an attachment page_nav: A list of subpages attachments: A list of attachments The default action is a link,... | def macro(text)
return text if text.nil?
copy = text.dup
# Links
#
# Example [[image:foo.png][name]]
# 1. the prefix image
# 2. the link, with colon :foo.png
# 3. the link itself foo.png
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def template_for(action, resource)\n\t\t\t\"#{resource.gsub(\" \",\"_\")}/#{action}\"\n\t\tend",
"def expand\n\t\t\tblock = Glyph::MACROS[@name]\n\t\t\tmacro_error \"Undefined macro '#@name'\" unless block\n\t\t\tinstance_exec(@node, &block).to_s.gsub(/\\\\?([\\[\\]\\|])/){\"\\\\#$1\"}\n\t\tend",
"def content_... | [
"0.5072739",
"0.50537956",
"0.49182448",
"0.49032867",
"0.48522288",
"0.4848557",
"0.4846442",
"0.48158833",
"0.48065653",
"0.47986424",
"0.47954062",
"0.47842097",
"0.47820592",
"0.47547767",
"0.47478554",
"0.4742011",
"0.46857753",
"0.46598318",
"0.4657052",
"0.4650557",
"0... | 0.6145426 | 0 |
Input: List of names(cohort) Output : Groups of no less than 3, no more than 5 made from the list array cohort, ideally 45 per group Steps to complete: See if cohort is divisible by 5 or 4 create a new hash test if group is divisible by 5 and 4 find remainder of group when divided by 4 or 5 go through array and assign ... | def create_groups(cohort)
if cohort.length % 5 == 0
hash = {}
counter = 1
group_count = cohort.length / 5
remainder = cohort.length % 5
# Set to groups(keys) to members(values)
group_count.times do
hash[counter] = cohort.slice!(0..4)
counter += 1
end
else
hash = {}
coun... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def acct_groups(cohort)\n\tgroups_array = []\n\tcohort_array = cohort.split(\", \").shuffle!\n\theadcount = cohort_array.size\n\t\tif headcount < 6\n\t\t\tputs \"Too few students to sort!\"\n\t\telsif headcount == 6 || headcount == 9\n\t\t\tcohort_array.each_slice(3) { |three_person|\tgroups_array.push(three_perso... | [
"0.8172613",
"0.76304543",
"0.7329762",
"0.7263083",
"0.7213749",
"0.7018138",
"0.697309",
"0.6910674",
"0.69004035",
"0.68534166",
"0.67199785",
"0.67139083",
"0.66952914",
"0.6645634",
"0.66045386",
"0.6573632",
"0.65453225",
"0.6532134",
"0.6493227",
"0.64893305",
"0.64716... | 0.806292 | 1 |
GET /military_document_types GET /military_document_types.json | def index
@military_document_types = MilitaryDocumentType.all
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @military_document_types }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @military_document_type = MilitaryDocumentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @military_document_type }\n end\n end",
"def index\n @documenttypes = Documenttype.all\n end",
"def index\n @docume... | [
"0.700759",
"0.6775187",
"0.6644835",
"0.65929484",
"0.6538695",
"0.6527967",
"0.64848167",
"0.636672",
"0.6363027",
"0.63435507",
"0.63435507",
"0.6322925",
"0.6318144",
"0.6280156",
"0.627328",
"0.6246751",
"0.6159099",
"0.6106487",
"0.6097845",
"0.6084949",
"0.60723674",
... | 0.7892265 | 0 |
GET /military_document_types/1 GET /military_document_types/1.json | def show
@military_document_type = MilitaryDocumentType.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @military_document_type }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @military_document_types = MilitaryDocumentType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @military_document_types }\n end\n end",
"def show\n @document_type = DocumentType.find(params[:id])\n\n respond_to do |format|\n ... | [
"0.7853476",
"0.7101261",
"0.68319607",
"0.67287123",
"0.66368157",
"0.66021055",
"0.66021055",
"0.652735",
"0.65189695",
"0.6496666",
"0.64009976",
"0.6394475",
"0.63475245",
"0.6244297",
"0.61611617",
"0.60895705",
"0.60724723",
"0.6066076",
"0.6055568",
"0.60470915",
"0.60... | 0.7510824 | 1 |
GET /military_document_types/new GET /military_document_types/new.json | def new
@military_document_type = MilitaryDocumentType.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @military_document_type }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @document_type = DocumentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document_type }\n end\n end",
"def new\n @document = Document.new\n @document.document_type = 1\n\n respond_to do |format|\n format.html # new.html.e... | [
"0.78218365",
"0.76295704",
"0.74823594",
"0.725441",
"0.71714187",
"0.7168285",
"0.7132817",
"0.69822234",
"0.69702554",
"0.69702554",
"0.69702554",
"0.69702554",
"0.69702554",
"0.69702554",
"0.69702554",
"0.69702554",
"0.69702554",
"0.6969036",
"0.6951032",
"0.6944768",
"0.... | 0.7906374 | 0 |
POST /military_document_types POST /military_document_types.json | def create
@military_document_type = MilitaryDocumentType.new(params[:military_document_type])
respond_to do |format|
if @military_document_type.save
format.html { redirect_to @military_document_type, :notice => 'Tipo de Documento Militar criado com sucesso.' }
format.json { render :json ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @document_type = @enterprise.document_types.new(document_type_params)\n\n respond_to do |format|\n if @document_type.save\n format.html { redirect_to edit_document_type_path(@document_type), notice: 'El tipo de documento ha sido creado satisfactoriamente.' }\n format.json { re... | [
"0.6845149",
"0.67884475",
"0.67559874",
"0.67298055",
"0.6637083",
"0.66122353",
"0.6464347",
"0.6457802",
"0.6367807",
"0.6289234",
"0.62546116",
"0.6250756",
"0.6202728",
"0.6162214",
"0.61429536",
"0.6125838",
"0.6124055",
"0.6120345",
"0.6119991",
"0.6119991",
"0.6066942... | 0.69768006 | 0 |
PUT /military_document_types/1 PUT /military_document_types/1.json | def update
@military_document_type = MilitaryDocumentType.find(params[:id])
respond_to do |format|
if @military_document_type.update_attributes(params[:military_document_type])
format.html { redirect_to @military_document_type, :notice => 'Tipo de Documento Militar atualizado com sucesso.' }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @document_type.update(document_type_params)\n format.html { redirect_to edit_document_type_path(@document_type), notice: 'El tipo de documento ha sido actualizado satisfactoriamente.' }\n format.json { render :edit, status: :ok, location: @document_typ... | [
"0.7216173",
"0.7205511",
"0.7188631",
"0.70816517",
"0.69233686",
"0.69178843",
"0.6869233",
"0.68102914",
"0.6694511",
"0.6675898",
"0.6573239",
"0.65542465",
"0.64890915",
"0.64732486",
"0.64250034",
"0.63367647",
"0.62926567",
"0.62926567",
"0.6212918",
"0.61546224",
"0.6... | 0.7246239 | 0 |
DELETE /military_document_types/1 DELETE /military_document_types/1.json | def destroy
@military_document_type = MilitaryDocumentType.find(params[:id])
@military_document_type.destroy
respond_to do |format|
format.html { redirect_to military_document_types_url, :notice => 'Tipo de Documento Militar excluído com sucesso.' }
format.json { head :no_content }
end
en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @document_type = DocumentType.find(params[:id])\n @document_type.destroy\n\n respond_to do |format|\n format.html { redirect_to document_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @document_type.destroy\n respond_to do |format|\n fo... | [
"0.7619207",
"0.7351393",
"0.73229754",
"0.7293766",
"0.71715677",
"0.70488644",
"0.7026494",
"0.69568884",
"0.68637085",
"0.6821977",
"0.67709005",
"0.67343533",
"0.6725197",
"0.6697152",
"0.668687",
"0.6680535",
"0.6654211",
"0.66144544",
"0.66075844",
"0.65992564",
"0.6585... | 0.76715434 | 0 |
Methods Public: Gets the activity for a given group from SQL Returns an array of Comment and Photo objects | def activity
(self.photos.recent + self.comments.recent).sort_by(&:created_at)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activity\n if !current_group.nil?\n \t ideas = Idea.find_all_by_group_id(current_user.groups.map(&:id))\n else\n ideas = current_user.ideas\n end\n \t@activities = Activity.find_all_by_idea_id(ideas.map(&:id))\n end",
"def show_activities\n @group = Group.find(params[:id])\n end",
"de... | [
"0.63864815",
"0.61024165",
"0.60471046",
"0.5998786",
"0.5988786",
"0.5960128",
"0.5900521",
"0.58484507",
"0.5841096",
"0.57139724",
"0.56552255",
"0.5586474",
"0.5577867",
"0.55759656",
"0.5513484",
"0.54928684",
"0.54928684",
"0.54847103",
"0.5482085",
"0.5448598",
"0.535... | 0.5369756 | 20 |
Public: Marks all notifications as read for the given group Returns an array of notifications | def mark_notifications_as_read!(user)
self.notifications.where(read: false, user_id: user.id).update_all(read: true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notification_groups_mark_all_as_read(opts = {})\n data, _status_code, _headers = notification_groups_mark_all_as_read_with_http_info(opts)\n data\n end",
"def mark_all_as_read\n @notifications = Notification.unread.for_user(current_api_v1_user)\n @notifications.update_all(read_at: Time.now... | [
"0.7475885",
"0.683939",
"0.67202634",
"0.66385",
"0.6509511",
"0.64613986",
"0.6260643",
"0.6224466",
"0.62197",
"0.6179289",
"0.6136045",
"0.60917264",
"0.6022801",
"0.6009525",
"0.6006092",
"0.60002637",
"0.59714174",
"0.5966779",
"0.59492695",
"0.59474695",
"0.59135365",
... | 0.66444993 | 3 |
Public: Gets the events for a group Returns an array of Events | def recent_events
Event.includes(:user).where(group_id: self.id).limit(50).order(created_at: :desc).reverse
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def events\n @events = registered_application.events.group_by(&:name)\n end",
"def group_events\n @group = Group.find(params[:groupId])\n @events = @group.events\n render \"api/events/group_events\"\n end",
"def events\n @events ||= []\n @events\n end",
"def ind... | [
"0.7086922",
"0.7068631",
"0.68852425",
"0.6611587",
"0.65423834",
"0.6539272",
"0.65184",
"0.6447683",
"0.64321035",
"0.6401753",
"0.63984716",
"0.63920224",
"0.6338734",
"0.63113487",
"0.63113487",
"0.62984455",
"0.62915295",
"0.62834764",
"0.6280849",
"0.6279172",
"0.62759... | 0.0 | -1 |
=begin Initialize your data structure here. =end | def initialize()
@hash = {}
@values = []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_data\n end",
"def init_data\n end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def initialize()\n @additional_data = Hash.new\n end",
"def initialize(... | [
"0.7799752",
"0.75177497",
"0.71532923",
"0.71532923",
"0.71532923",
"0.71532923",
"0.70507306",
"0.70324403",
"0.70324403",
"0.70324403",
"0.70324403",
"0.70324403",
"0.70324403",
"0.70324403",
"0.70324403",
"0.7016944",
"0.70064306",
"0.6933887",
"0.6928044",
"0.6923789",
"... | 0.0 | -1 |
=begin Inserts a value to the collection. Returns true if the collection did not already contain the specified element. :type val: Integer :rtype: Boolean =end | def insert(val)
hash[val] = Set.new unless hash[val]
hash[val].add(values.size)
values.push(val)
hash[val].size == 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(val)\n return false if @h[val]\n @a.push(val)\n @h[val] = @a.size - 1\n return true\n end",
"def add(val)\n @set.include?(val) ? nil : @set.push(val)\n end",
"def insert(val)\n return false if @number_index_map.key?(val)\n @number_list << val\n @number_index_map[v... | [
"0.75590783",
"0.7356093",
"0.71431",
"0.7066172",
"0.67980886",
"0.6683719",
"0.66010106",
"0.6525003",
"0.6509468",
"0.6493217",
"0.6231391",
"0.6192678",
"0.6155127",
"0.60978436",
"0.6065289",
"0.59597135",
"0.5879541",
"0.58649284",
"0.58424693",
"0.5828541",
"0.5828429"... | 0.74929804 | 1 |
=begin Removes a value from the collection. Returns true if the collection contained the specified element. :type val: Integer :rtype: Boolean =end | def remove(val)
return false if !hash[val] || hash[val].empty?
# Update values array
idx = hash[val].first
last = values[-1]
values[idx] = last
# Remove last from array
values.pop
# Remove val
hash[val].delete(idx)
# Update last
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(val)\n return false unless @number_index_map.key?(val)\n index = @number_index_map[val]\n last_element = @number_list[-1]\n @number_list[index] = last_element\n\n @number_list.pop\n @number_index_map[last_element] = index\n @number_index_map.delete(val)\n true\n end",
"def rem... | [
"0.7230835",
"0.7229514",
"0.7152616",
"0.7116149",
"0.689907",
"0.6758695",
"0.66874665",
"0.6573358",
"0.6397571",
"0.6345565",
"0.6250748",
"0.6080194",
"0.60422605",
"0.5958605",
"0.59559196",
"0.5946012",
"0.5908866",
"0.58999157",
"0.58809286",
"0.5867662",
"0.58550835"... | 0.75217015 | 0 |
=begin Get a random element from the collection. :rtype: Integer =end | def get_random()
values[rand(values.size)]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random\n if (c = count) != 0\n find(:first, :offset => rand(c))\n end\n end",
"def random_element\n self[self.random_index]\n end",
"def randomItem\n return self[rand(self.length)] # zero based, so this works math-wise...\n end",
"def random_element\n sample\n end",
... | [
"0.7439114",
"0.73322785",
"0.7196328",
"0.7113594",
"0.6999919",
"0.69787073",
"0.6919932",
"0.6907892",
"0.68156815",
"0.6809693",
"0.679305",
"0.6727135",
"0.6713132",
"0.6699841",
"0.66736627",
"0.66583735",
"0.6603407",
"0.6552848",
"0.6528621",
"0.6517848",
"0.6517848",... | 0.63653266 | 22 |
Supported values for options: :region AWS region (e.g. uswest1) :secure true or false, default true. :timeout the timeout, in seconds, when making a request to EMR, default 60. | def initialize(options={})
# There is a cryptic error if this isn't set
if options.has_key?(:region) && options[:region] == nil
raise MissingRegionError, 'A valid :region is required to connect to EMR'
end
options[:region] = 'us-east-1' unless options[:region]
@region = options[:re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aws_options\n options = {\n retry_limit: 7, # default: 3\n retry_base_delay: 0.6, # default: 0.3\n }\n options.merge!(\n log_level: :debug,\n logger: Logger.new($stdout),\n ) if ENV['CFN_STATUS_DEBUG_AWS_SDK']\n options\n end",
"def configure_timeout(op... | [
"0.5818868",
"0.5627236",
"0.5560421",
"0.5550543",
"0.55356747",
"0.54547215",
"0.5405509",
"0.5281793",
"0.52772796",
"0.5249756",
"0.52192575",
"0.5209955",
"0.5119666",
"0.5097042",
"0.5045118",
"0.50450814",
"0.5030702",
"0.502459",
"0.502459",
"0.50037855",
"0.49800667"... | 0.7225927 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_annal
@annal = Annal.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 annal_params
params.require(:annal).permit(:file, :notes, :json, :done)
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 |
x_t is a collectin of vector as such [[x_1, x_2, x_3, x_4, ...], [x_1, x_2, x_3, ...], ...] | def initialize(x_t, y_t)
@m = x_t.length
@x_matrix = Matrix.rows(x_t.map {|row| row.unshift(1)})
@y_vector = Matrix.column_vector(y_t)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def row_vectors\n # (0 .. row_size - 1).collect { |i| row(i) }\n my_rows = @rows\n r_size = my_rows.size\n res = Array.new(r_size)\n vector_cls = Vector\n for i in 0..r_size-1 do\n a_row = my_rows[i]\n res[i] = vector_cls.elements(a_row) \n end\n res\n end",
"def transform(x)\n... | [
"0.54982615",
"0.54753065",
"0.5474616",
"0.5367529",
"0.5355799",
"0.5259143",
"0.5245832",
"0.50957704",
"0.50746346",
"0.5060266",
"0.50580597",
"0.50523525",
"0.502389",
"0.50077343",
"0.49815914",
"0.4902479",
"0.48891896",
"0.4878005",
"0.48765522",
"0.48684144",
"0.485... | 0.5302401 | 5 |
Don't need any normalization | def get_data(dimensions)
data = []
(0...@m).each do |row_idx|
row = []
col_idx = 1
while col_idx <= dimensions
row << @x_matrix[row_idx, col_idx]
col_idx += 1
end
row << @y_vector[row_idx, 0]
data << row
end
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalized; end",
"def unnormalized; end",
"def normalize; end",
"def normalize!; end",
"def normalize!\n end",
"def normalize\n end",
"def normalize!\n end",
"def normalize\n self / self.norm\n end",
"def normalized!\n self\n end",
"def normalize; self.dup.norma... | [
"0.83714485",
"0.8065399",
"0.774859",
"0.76957977",
"0.75532037",
"0.7472144",
"0.7355371",
"0.7354204",
"0.71785045",
"0.7156019",
"0.70889586",
"0.70818394",
"0.7066192",
"0.69365865",
"0.6928838",
"0.68594277",
"0.68553585",
"0.68465894",
"0.6832335",
"0.6832335",
"0.6831... | 0.0 | -1 |
Enqueues the action for a single resource. | def enqueue_action_single_resource(action, type, id)
raise BadRequestError, "Must specify an id for changing a #{type} resource" unless id
physical_switch = resource_search(id, type, collection_class(type))
api_action(type, id) do
begin
desc = "Performing #{action} for #{physical_s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enqueue(action)\n # add our request id for tracing purposes\n action[:messageId] = uid\n unless queue_full = @queue.length >= @max_queue_size\n ensure_worker_running\n @queue << action\n end\n !queue_full\n end",
"def enqueue(action)\n # add our ... | [
"0.6444264",
"0.6344201",
"0.6113562",
"0.5767109",
"0.5728094",
"0.5720891",
"0.57013947",
"0.5664915",
"0.5645009",
"0.5626888",
"0.5567248",
"0.5559725",
"0.5558766",
"0.5555397",
"0.55398643",
"0.5510747",
"0.5496871",
"0.5486329",
"0.5464261",
"0.54426163",
"0.5426837",
... | 0.72336215 | 0 |
Enqueues the action for multiple resources. For multiple resources, when an error occurs, the error messages must be built individually for each resource. Always responding with status 200. | def enqueue_action_multiple_resources(action, type, id)
enqueue_action_single_resource(action, type, id)
rescue ActiveRecord::RecordNotFound => err
action_result(false, _(err.message))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collection_post_action(action)\n action = action.to_s.gsub('bulk_', '').to_sym\n\n raise 'expected post, patch or put http action' unless (request.post? || request.patch? || request.put?)\n raise \"expected #{resource_name} to respond to #{action}!\" if resources.to_a.present? && !resources.firs... | [
"0.5996528",
"0.59655535",
"0.5676235",
"0.5563469",
"0.55244195",
"0.5516578",
"0.5504725",
"0.55009824",
"0.54760396",
"0.54397523",
"0.53459245",
"0.5337982",
"0.52587515",
"0.5235957",
"0.5229544",
"0.5224417",
"0.5215673",
"0.52050513",
"0.5141789",
"0.5130663",
"0.51168... | 0.72910756 | 0 |
GET /exercise_templates GET /exercise_templates.json | def index
@exercise_templates = ExerciseTemplate.all
render json: @exercise_templates
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n render json: @exercise_template\n end",
"def templates\n response = get \"storage/template\"\n data = JSON.parse response.body\n data\n end",
"def list\n @client.make_request :get, templates_path\n end",
"def templates\n response = get 'templates'\n response.map... | [
"0.7126005",
"0.70159036",
"0.68598884",
"0.6789637",
"0.67713577",
"0.6725251",
"0.66778237",
"0.6596028",
"0.65107256",
"0.64400196",
"0.6423538",
"0.6418938",
"0.64132273",
"0.6409025",
"0.6409025",
"0.6352914",
"0.63268644",
"0.6298526",
"0.6271051",
"0.6222909",
"0.61799... | 0.7781126 | 0 |
GET /exercise_templates/1 GET /exercise_templates/1.json | def show
render json: @exercise_template
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @exercise_templates = ExerciseTemplate.all\n render json: @exercise_templates\n end",
"def create\n @exercise_template = ExerciseTemplate.new(exercise_template_params)\n\n if @exercise_template.save\n render json: @exercise_template, status: :created, location: @exercise... | [
"0.76289266",
"0.6616761",
"0.6582318",
"0.65737027",
"0.644448",
"0.64309645",
"0.64309645",
"0.64262646",
"0.641031",
"0.6387172",
"0.6283847",
"0.6283847",
"0.62828577",
"0.62621826",
"0.62445545",
"0.62287426",
"0.6208674",
"0.6191285",
"0.61840236",
"0.61582685",
"0.6134... | 0.72894967 | 1 |
POST /exercise_templates POST /exercise_templates.json | def create
@exercise_template = ExerciseTemplate.new(exercise_template_params)
if @exercise_template.save
render json: @exercise_template, status: :created, location: @exercise_template
else
render json: @exercise_template.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @exercise_templates = ExerciseTemplate.all\n render json: @exercise_templates\n end",
"def create\n @questionnaire_template = QuestionnaireTemplate.new(questionnaire_template_params)\n\n respond_to do |format|\n if @questionnaire_template.save\n format.html { redirect_t... | [
"0.6443866",
"0.6424446",
"0.6355208",
"0.6267342",
"0.62536114",
"0.6245498",
"0.6241469",
"0.6241336",
"0.6221112",
"0.61768353",
"0.6160134",
"0.6144805",
"0.6127116",
"0.60892713",
"0.60494596",
"0.60323447",
"0.6003123",
"0.60004467",
"0.5978884",
"0.5947667",
"0.5939243... | 0.76109755 | 0 |
PATCH/PUT /exercise_templates/1 PATCH/PUT /exercise_templates/1.json | def update
@exercise_template = ExerciseTemplate.find(params[:id])
if @exercise_template.update(exercise_template_params)
head :no_content
else
render json: @exercise_template.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @api_v1_exercise.update(api_v1_exercise_params)\n format.html { redirect_to @api_v1_exercise, notice: 'Exercise was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_exercise }\n else\n format.html { rend... | [
"0.6624844",
"0.6485179",
"0.6468314",
"0.64318746",
"0.64318746",
"0.64318746",
"0.63112164",
"0.63102996",
"0.6307914",
"0.62699884",
"0.62584835",
"0.6257754",
"0.62360495",
"0.61973506",
"0.6182043",
"0.6182043",
"0.61755174",
"0.617128",
"0.61525905",
"0.61441153",
"0.61... | 0.7475527 | 0 |
DELETE /exercise_templates/1 DELETE /exercise_templates/1.json | def destroy
@exercise_template.destroy
head :no_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n super \"/templates/#{template_id}.json\", {}\n end",
"def destroy\n @exercise.destroy\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exercise.destroy\n respond_to do |format|\n ... | [
"0.760863",
"0.73966616",
"0.73966616",
"0.7386129",
"0.73255175",
"0.73255175",
"0.73255175",
"0.73255175",
"0.7325453",
"0.7166219",
"0.7161098",
"0.71421456",
"0.71421456",
"0.7133151",
"0.71203744",
"0.7103718",
"0.7102772",
"0.70902383",
"0.70858175",
"0.7074158",
"0.705... | 0.7792735 | 0 |
Time complexity: O(n) where n is the value of n Space complexity: O(n) where n is the value of n | def factorial(n)
if n < 0
raise ArgumentError
elsif n <= 1
return 1
else
return n * factorial(n-1)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend",
"def amicable_numbers(n)\r\n numbers = Array.new\r\n 2.upto(n) do |... | [
"0.6731546",
"0.6660078",
"0.6575958",
"0.65584093",
"0.64724857",
"0.64456636",
"0.64238524",
"0.64222056",
"0.6416115",
"0.6404088",
"0.63939023",
"0.6387105",
"0.6370853",
"0.6331342",
"0.6323353",
"0.6304718",
"0.6301486",
"0.62843484",
"0.6261167",
"0.6251631",
"0.624727... | 0.0 | -1 |
Time complexity: O(n) where n is the length of s Space complexity: O(n) where n is the length of s | def reverse(s)
if s.length <= 1
return s
else
return s[s.length - 1] + reverse(s[0..-2])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isSymmetricBySpace(s, i) \n return false if i==0\n c=0\n for d in 0..i\n return c==i if i-1-d<0||i+d>=s.length\n return false if s[i+d]!=s[i-1-d]\n c+=1 if s[i+d]==s[i-1-d]\n end\n return false\nend",
"def pseudoIsomorphicSubstrings(s)\n\n size = 1 # this show the current size of the set i\n ... | [
"0.65725124",
"0.65281796",
"0.64984745",
"0.64225525",
"0.63352686",
"0.62447375",
"0.62388307",
"0.62374526",
"0.6226243",
"0.6177557",
"0.61744344",
"0.6164827",
"0.61356336",
"0.6128728",
"0.6126486",
"0.61086375",
"0.61039466",
"0.6090603",
"0.6081216",
"0.60716146",
"0.... | 0.0 | -1 |
Time complexity: O(n) where n is the length of s Space complexity: O(n) where n is the length of s | def reverse_inplace(s)
if s.length <= 1
return s
else
return s[s.length - 1] + reverse(s[0..-2])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isSymmetricBySpace(s, i) \n return false if i==0\n c=0\n for d in 0..i\n return c==i if i-1-d<0||i+d>=s.length\n return false if s[i+d]!=s[i-1-d]\n c+=1 if s[i+d]==s[i-1-d]\n end\n return false\nend",
"def pseudoIsomorphicSubstrings(s)\n\n size = 1 # this show the current size of the set i\n ... | [
"0.6571266",
"0.6527647",
"0.64974415",
"0.6421256",
"0.6334191",
"0.62447935",
"0.6238051",
"0.62372625",
"0.6225252",
"0.61764836",
"0.61744225",
"0.61640054",
"0.61357486",
"0.6128065",
"0.6125138",
"0.6107513",
"0.6103693",
"0.60892355",
"0.6081185",
"0.6071949",
"0.60703... | 0.0 | -1 |
Time complexity: O(n) where n is value of n Space complexity: O(n) where n is value of n | def bunny(n)
if n < 1
return 0
else
return 2 + bunny(n-1)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend",
"def amicable_numbers(n)\r\n numbers = Array.new\r\n 2.upto(n) do |... | [
"0.67394114",
"0.65784717",
"0.654895",
"0.65278155",
"0.64846534",
"0.6437647",
"0.6424175",
"0.6410781",
"0.63709044",
"0.6369165",
"0.63649464",
"0.63544774",
"0.63527805",
"0.63394874",
"0.63230556",
"0.63095427",
"0.62552124",
"0.6236607",
"0.6231398",
"0.62204385",
"0.6... | 0.0 | -1 |
Time complexity: O(n) where n is the length of s Space complexity: O(n) where n is the length of s | def nested(s)
if s.length == 0
return true
else
if s[0] == "(" && s[-1] == ")"
return nested(s[1..-2])
else
return false
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isSymmetricBySpace(s, i) \n return false if i==0\n c=0\n for d in 0..i\n return c==i if i-1-d<0||i+d>=s.length\n return false if s[i+d]!=s[i-1-d]\n c+=1 if s[i+d]==s[i-1-d]\n end\n return false\nend",
"def pseudoIsomorphicSubstrings(s)\n\n size = 1 # this show the current size of the set i\n ... | [
"0.6571891",
"0.6528862",
"0.6498698",
"0.6423003",
"0.63339543",
"0.6245319",
"0.62393063",
"0.6238905",
"0.6227208",
"0.6178182",
"0.61751956",
"0.6164928",
"0.61367065",
"0.6128542",
"0.61255896",
"0.6108107",
"0.61034065",
"0.6089596",
"0.6083017",
"0.60732836",
"0.607255... | 0.0 | -1 |
Time complexity: O(n) where n is the length of array Space complexity: O(n) where n is the length of array | def search(array, value)
if array.empty?
return false
else
if array[0] == value
return true
else
array.shift
return search(array, value)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_unsorted_subarray(nums)\n \nend",
"def naive(array)\n max = -10000\n for i in (0..array.length - 1)\n for j in (i..array.length - 1)\n total = array[i..j].inject { |m,k| m + k }\n max = total if total > max\n end\n end\n max\nend",
"def equalizeArray(arr)\n arr = arr.sort\n ... | [
"0.6641892",
"0.66078013",
"0.65390205",
"0.6517989",
"0.6493659",
"0.6489011",
"0.6447308",
"0.63804346",
"0.63631356",
"0.6342481",
"0.63209987",
"0.6295135",
"0.62942654",
"0.6271129",
"0.6267671",
"0.6253584",
"0.62472445",
"0.62369305",
"0.6217616",
"0.62063706",
"0.6205... | 0.0 | -1 |
Time complexity: O(n) where n is the length of s Space complexity: O(n) where n is the length of s | def is_palindrome(s)
if s.length == 0
return true
else
if s[0] == s[-1]
return is_palindrome(s[1..-2])
else
return false
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isSymmetricBySpace(s, i) \n return false if i==0\n c=0\n for d in 0..i\n return c==i if i-1-d<0||i+d>=s.length\n return false if s[i+d]!=s[i-1-d]\n c+=1 if s[i+d]==s[i-1-d]\n end\n return false\nend",
"def pseudoIsomorphicSubstrings(s)\n\n size = 1 # this show the current size of the set i\n ... | [
"0.6571266",
"0.6527647",
"0.64974415",
"0.6421256",
"0.6334191",
"0.62447935",
"0.6238051",
"0.62372625",
"0.6225252",
"0.61764836",
"0.61744225",
"0.61640054",
"0.61357486",
"0.6128065",
"0.6125138",
"0.6107513",
"0.6103693",
"0.60892355",
"0.6081185",
"0.6071949",
"0.60703... | 0.0 | -1 |
Time complexity: O(n) where n is the length of the smaller integer Space complexity: O(n) where n is the length of the smaller integer | def digit_match(n, m, match = 0)
if n.digits.count == 1 || m.digits.count == 1
if n % 10 == m % 10
return match +=1
else
return match
end
else
if n % 10 == m % 10
match += 1
end
n = n / 10
m = m / 10
return digit_match(n, m, match)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def problem_57\n ret,n,d = 0,1,1\n 1000.times do |i|\n n,d = (n+2*d),(n+d)\n ret += 1 if n.to_s.length > d.to_s.length\n end\n ret\nend",
"def next_smaller(n)\n result = n.digits.permutation.select { |p| p.join.to_i < n && p.first != 0 }\n result.empty? ? -1 : result.last.join.to_i\nend",
"def make... | [
"0.694552",
"0.6893638",
"0.66248393",
"0.6528624",
"0.6471821",
"0.6471151",
"0.6393683",
"0.63389885",
"0.6309311",
"0.6306566",
"0.6285366",
"0.62834203",
"0.625928",
"0.6252865",
"0.6251095",
"0.6234594",
"0.62342674",
"0.620438",
"0.6180211",
"0.61737156",
"0.61720467",
... | 0.0 | -1 |
From Rack from Camping | def escape( s )
s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) do
'%'+$1.unpack('H2'*$1.size).join('%').upcase
end.tr(' ', '+')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rack_builder; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def rack_input ; @env['rack.input'] ... | [
"0.7031487",
"0.6606145",
"0.6606145",
"0.6606145",
"0.6606145",
"0.6606145",
"0.6606145",
"0.6606145",
"0.6606145",
"0.6606145",
"0.6606145",
"0.6606145",
"0.65996605",
"0.649244",
"0.6301462",
"0.6239088",
"0.61803716",
"0.61601365",
"0.61429065",
"0.61401135",
"0.6114718",... | 0.0 | -1 |
Don't know how to properly test this feature, ask for dans help, should also be refactored into it's own rest model | def send_flow
flow = Flowdock::Flow.new(api_token: ENV['LP_FLOW'],
source: "LaunchPairs", from: { name: current_user.first_name, address: current_user.email })
flow.push_to_chat(:content => params[:flow][:question], :external_user_name => current_user.first_name)
flash[:success] = "Your question ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rest_endpoint; end",
"def from_api?; false end",
"def define_restful_api(model)\n get \"/#{model.resource}\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { json model.all }\n end\n\n get \"/#{model.resource}/:id\" do\n sleep settings.fake_latency if settings.fake... | [
"0.60622853",
"0.602124",
"0.5985522",
"0.5901344",
"0.5867935",
"0.5834146",
"0.5834146",
"0.58213454",
"0.58213454",
"0.5779181",
"0.5724512",
"0.5716377",
"0.5697014",
"0.5697014",
"0.5697014",
"0.56918365",
"0.56910825",
"0.56634295",
"0.5626107",
"0.5601423",
"0.5601423"... | 0.0 | -1 |
Merge the current Hash object (self) cloned with a Hash/Array tree contents (data). 'self' is used as original data to merge to. 'data' is used as data to merged to clone of 'self'. If you want to update 'self', use rh_merge! if 'self' or 'data' contains a Hash tree, the merge will be executed recursively. The current ... | def rh_merge(data)
_rh_merge(clone, data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rh_merge(result, data)\n return _rh_merge_choose_data(result, data) unless data.is_a?(Hash)\n\n data.each do |key, _value|\n next if [:__struct_changing, :__protected].include?(key)\n\n _do_rh_merge(result, key, data)\n end\n [:__struct_changing, :__protected].each do |key|\n # Refu... | [
"0.7118564",
"0.70461404",
"0.7019008",
"0.69477296",
"0.6902892",
"0.68409175",
"0.6684241",
"0.6617985",
"0.6593967",
"0.6593967",
"0.6593967",
"0.6560709",
"0.65426683",
"0.65015894",
"0.64709705",
"0.6372555",
"0.63637376",
"0.63613176",
"0.6344908",
"0.6336662",
"0.63165... | 0.728417 | 0 |
Merge the current Hash object (self) with a Hash/Array tree contents (data). For details on this functions, see rh_merge | def rh_merge!(data)
_rh_merge(self, data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rh_merge(data)\n _rh_merge(clone, data)\n end",
"def merge(hash); end",
"def merge(hash); end",
"def merge(hash); end",
"def deep_merge!(data)\n merger = lambda do |_key, v1, v2|\n Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2\n end\n merge!(data, &merger)\n ... | [
"0.7709388",
"0.6946114",
"0.6946114",
"0.6946114",
"0.6810289",
"0.66208786",
"0.66208786",
"0.6526052",
"0.6514497",
"0.65080833",
"0.64784604",
"0.6426913",
"0.64115846",
"0.64077103",
"0.6384978",
"0.63511044",
"0.6344408",
"0.630933",
"0.6307362",
"0.6282395",
"0.6282395... | 0.7381702 | 1 |
Internal function which do the real merge task by rh_merge and rh_merge! See rh_merge for details | def _rh_merge(result, data)
return _rh_merge_choose_data(result, data) unless data.is_a?(Hash)
data.each do |key, _value|
next if [:__struct_changing, :__protected].include?(key)
_do_rh_merge(result, key, data)
end
[:__struct_changing, :__protected].each do |key|
# Refuse merge by de... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge!; end",
"def merge; end",
"def rh_merge!(data)\n _rh_merge(self, data)\n end",
"def merge(source); end",
"def _do_rh_merge(result, key, data, refuse_discordance = false)\n value = data[key]\n\n return if _rh_merge_do_add_key(result, key, value)\n\n return if _rh_merge_recursive(resul... | [
"0.7589137",
"0.75158036",
"0.7012891",
"0.6889406",
"0.67575186",
"0.67201746",
"0.6711104",
"0.66018564",
"0.65267843",
"0.64883494",
"0.6487487",
"0.64487994",
"0.6407289",
"0.6374257",
"0.62840647",
"0.62390435",
"0.6180874",
"0.6174343",
"0.6168958",
"0.6156112",
"0.6141... | 0.6415164 | 12 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.