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 |
|---|---|---|---|---|---|---|
GET /list_invites/1 GET /list_invites/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @invites = Invite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n end",
"def index\n @invites = Invite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites ... | [
"0.783392",
"0.783392",
"0.783392",
"0.7665716",
"0.7665716",
"0.7665716",
"0.7665716",
"0.7665716",
"0.7593002",
"0.7571785",
"0.748109",
"0.7428276",
"0.7377974",
"0.7314764",
"0.72087216",
"0.7208569",
"0.71678585",
"0.71645445",
"0.71438724",
"0.70629054",
"0.7059363",
... | 0.0 | -1 |
POST /list_invites POST /list_invites.json | def create
@list_invite = ListInvite.new(list_invite_params.merge(user_id: current_user.id))
respond_to do |format|
if @list_invite.save
format.html { redirect_to lists_path, notice: 'List invite was successfully created.' }
format.json { render action: 'show', status: :created, location: @list_invite }
else
format.html { render action: 'new' }
format.json { render json: @list_invite.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @invites = Invite.all\n end",
"def index\n @invites = Invite.all\n end",
"def index\n @invites = Invite.all\n end",
"def index\n @invites = Invite.all\n end",
"def index\n @invites = Invite.all\n end",
"def index\n @invites = Invite.all\n\n respond_to do |format|\n ... | [
"0.7562937",
"0.7562937",
"0.7562937",
"0.7562937",
"0.7562937",
"0.74954313",
"0.74954313",
"0.74954313",
"0.7424402",
"0.73826724",
"0.7326685",
"0.73035353",
"0.72660786",
"0.6934265",
"0.69220006",
"0.69176203",
"0.686093",
"0.6793714",
"0.6766695",
"0.67482245",
"0.67386... | 0.0 | -1 |
PATCH/PUT /list_invites/1 PATCH/PUT /list_invites/1.json | def update
ListUser.create!(user: User.where(email: @list_invite.email).last, list: @list_invite.list)
respond_to do |format|
if @list_invite.update(list_invite_params)
format.html { redirect_to lists_path, notice: 'List invite was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @list_invite.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @invite_list = InviteList.find(params[:id])\n\n respond_to do |format|\n if @invite_list.update_attributes(params[:invite_list])\n format.html { redirect_to @invite_list, notice: 'Invite list was successfully updated.' }\n format.json { head :no_content }\n else\n ... | [
"0.71500707",
"0.6453307",
"0.6387229",
"0.6387229",
"0.6387229",
"0.6381915",
"0.6373369",
"0.6336115",
"0.629756",
"0.62940776",
"0.6284023",
"0.62697524",
"0.62616867",
"0.6201426",
"0.61371064",
"0.61371064",
"0.6110206",
"0.6110206",
"0.6110206",
"0.6110206",
"0.6056468"... | 0.637834 | 6 |
DELETE /list_invites/1 DELETE /list_invites/1.json | def destroy
@list_invite.destroy
respond_to do |format|
format.html { redirect_to list_invites_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @invite_list = InviteList.find(params[:id])\n @invite_list.destroy\n\n respond_to do |format|\n format.html { redirect_to invite_lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite = Invite.find(params[:id])\n @invite.destroy\n\n respo... | [
"0.7614332",
"0.7483555",
"0.7483555",
"0.7483555",
"0.7483555",
"0.7312825",
"0.7312825",
"0.72277004",
"0.72108185",
"0.71746373",
"0.7099659",
"0.7077111",
"0.7051402",
"0.7051402",
"0.7051402",
"0.7051402",
"0.6994812",
"0.6852885",
"0.68522215",
"0.6768387",
"0.6764497",... | 0.7661324 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_list_invite
@list_invite = ListInvite.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 list_invite_params
params.require(:list_invite).permit(:list_id, :user_id, :email, :complete)
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.6981537",
"0.67835593",
"0.6748275",
"0.67436063",
"0.6736311",
"0.65937173",
"0.6503359",
"0.6498499",
"0.6482832",
"0.6478776",
"0.645703",
"0.6439998",
"0.63802195",
"0.6377008",
"0.6366287",
"0.632018",
"0.63016284",
"0.63011277",
"0.62932974",
"0.62919617",
"0.6290564... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = User.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def user_params
params.permit(:first_name, :last_name, :email, :phone, :base_currency, :token_id, :balance)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
require 'admin_template' include AdminTemplate protected ssl_required :admin_authorize if SSL_ENABLE | def set_locale
# session[:locale] = params[:locale] if params[:locale]
# session[:locale] = "zh" if session[:locale].blank?
# session[:locale] = "zh"
# I18n.locale = session[:locale] || I18n.default_locale
I18n.locale = 'zh'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def require_admin\n end",
"def require_admin\n if Rails.env.production? && is_market? && Rails.configuration.admin_hostname != request.host\n render plain: \"ADMIN_HOSTNAME setting does not match your host header.\"\n else\n unless is_admin?\n flash[:alert] = \"Access not authorized. Need... | [
"0.6793391",
"0.6157994",
"0.611231",
"0.6007195",
"0.5996177",
"0.59879786",
"0.5939336",
"0.59091264",
"0.5906301",
"0.58824813",
"0.58821917",
"0.58766514",
"0.582218",
"0.58077264",
"0.57807684",
"0.5780454",
"0.5776235",
"0.5772891",
"0.5772891",
"0.57704055",
"0.5764316... | 0.0 | -1 |
Returns the permissions associated with the role | def permissions
Roles.type_map[role_type].permissions
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def role_permissions\n return @role_permissions\n end",
"def permissions\n if @permissions.nil?\n perm_array = []\n roles.each { |r| perm_array << r.permission_ids }\n @permissions = perm_array.flatten.uniq\n else\n @permissions\n end\n end"... | [
"0.83612496",
"0.7967314",
"0.7944717",
"0.7577825",
"0.7563391",
"0.74145716",
"0.74088514",
"0.72138083",
"0.71344703",
"0.7127846",
"0.7009284",
"0.69980043",
"0.6966114",
"0.69469106",
"0.6939263",
"0.6932439",
"0.68984014",
"0.68984014",
"0.689288",
"0.689288",
"0.688554... | 0.81939876 | 1 |
Sets the nearest timeframe | def set_time_frame time, time_slot = 30.minutes
Time.at(((time.to_i / time_slot).round * time_slot) + time_slot).to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_timeframe(timeframe)\n timeframe\n end",
"def timeframe=(val)\n raise(ArgumentError, 'timeframe value must be in the days_ago_list') unless days_ago_list.include? val\n\n @timeframe = val\n refresh_data\n\n end",
"def set_timeframe\n @timeframe = Timeframe.find(params[:id]... | [
"0.67763716",
"0.5833987",
"0.5665923",
"0.5644117",
"0.5591518",
"0.5580752",
"0.5405682",
"0.53374815",
"0.53036475",
"0.52960515",
"0.5290458",
"0.5290458",
"0.5290458",
"0.5290458",
"0.5290458",
"0.5290458",
"0.5290458",
"0.5290458",
"0.5276369",
"0.5274024",
"0.5274024",... | 0.59649295 | 1 |
TODO: Needs to take into account the amount that one is owed :( | def total_owed_amount(ower)
return data[ower] ? data[ower].values.reduce(:+) : 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def amount_owed\n total_price - amount_paid\n end",
"def owes_amount\n loans=@loans\n net_worth=@net_worth\n @balance = net_worth-loans\n print \"the balance is : \",balance,\"\\n\"\n is_developer_solvent?\n end",
"def net_payments(current_user_id)\n payments = ... | [
"0.6368402",
"0.63607574",
"0.62984735",
"0.62647045",
"0.6234975",
"0.6222604",
"0.62193406",
"0.6215096",
"0.61938524",
"0.61914426",
"0.61813277",
"0.6152021",
"0.60807174",
"0.60623497",
"0.6049904",
"0.6031863",
"0.59963197",
"0.59942365",
"0.5992578",
"0.59881175",
"0.5... | 0.0 | -1 |
as_is transformation of input Copy values from input hash to output hash for keys specified by keys attribute. | def run(input)
{}.tap do |result|
keys.each do |key|
result[key] = input[key]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform_keys!(hash)\n return enum_for(:transform_keys!, hash) unless block_given?\n hash.keys.each do |key|\n hash[yield(key)] = hash.delete(key)\n end\n hash\n end",
"def hash_to_hash(hash_from, hash_to)\n hash_from.each do |key, value|\n hash_to[key] ... | [
"0.6288772",
"0.6115494",
"0.60285205",
"0.5999685",
"0.5984444",
"0.5965115",
"0.5906839",
"0.58621645",
"0.5849198",
"0.58331937",
"0.58055055",
"0.57818747",
"0.5772143",
"0.5772143",
"0.57685286",
"0.5765048",
"0.57573473",
"0.5752304",
"0.5740258",
"0.5737534",
"0.573363... | 0.0 | -1 |
Returns the recipe classes in order based on the Gemfile order | def ordered_recipes
return @ordered_recipes if @ordered_recipes
names = Bundler.load.dependencies.map(&:name)
# Setup a hash with the recipe name and the recipe class
recipe_pool = recipes.dup.inject({}) {|memo,recipe| memo[recipe.gem_name] = recipe ; memo }
# Go through the gems in the order they are in the Gemfile, then
# add them to the ordered list
@ordered_recipes = []
names.each do |name|
if recipe_pool[name]
@ordered_recipes << recipe_pool[name]
recipe_pool.delete(name)
end
end
# Add the remaining recipes (load them after everything else)
@ordered_recipes += recipe_pool.values
return @ordered_recipes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def depends_all\n pkg_depends = self.class.depends_all\n if self.class.omnibus_package\n self.class.omnibus_recipes.each { |omni_recipe|\n recipe_file = File.expand_path(omni_recipe + '.rb', File.dirname(filename))\n\n Book.instance.load_recipe(recipe_file, config) do |... | [
"0.663816",
"0.663816",
"0.647818",
"0.6027255",
"0.5872339",
"0.57335997",
"0.57302433",
"0.5720733",
"0.57169104",
"0.5702004",
"0.56983083",
"0.56872267",
"0.56674826",
"0.56643623",
"0.5659114",
"0.5616627",
"0.55957377",
"0.5593597",
"0.5582223",
"0.55817837",
"0.5573044... | 0.79110026 | 0 |
Returns the list of classes that match the current list of roles in the correct run order | def recipe_classes_with_roles(roles)
# Check to make sure some recipes have been added
if ordered_recipes.size == 0
raise Thor::InvocationError, 'no recipes have been defined'
end
if (roles.is_a?(Array) && roles.size == 0) || roles == :all
# Use all classes
role_classes = ordered_recipes
else
# Remove classes that don't fit the roles being used
role_classes = ordered_recipes.reject do |recipe_class|
![roles].flatten.map(&:to_s).include?(recipe_class.class_role)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roles\n Jak.role_klass.where(id: grants.pluck(:role_ids).compact.flatten)\n end",
"def roles\n @run_list.select do |rl|\n rl.start_with?('r_', 'p_', 'base_', 'os_', 'os-')\n end\n end",
"def roles\n self.class.roles.map do |name|\n __send__(name)\n end\n end",
"def... | [
"0.6776941",
"0.656379",
"0.6520467",
"0.6483397",
"0.64126897",
"0.6331103",
"0.63098425",
"0.6295739",
"0.6293623",
"0.6227268",
"0.6221702",
"0.61961675",
"0.6187308",
"0.61219615",
"0.6045106",
"0.60402143",
"0.60402143",
"0.6031308",
"0.5972891",
"0.5972758",
"0.59591484... | 0.7155205 | 0 |
Invokes all recipes that implement the passed in role | def invoke_roles(task_name, roles, options={})
role_classes = self.recipe_classes_with_roles(roles)
# Run the taks on each role class
role_classes.each do |recipe_class|
# This class matches the role, so we should run it
recipe = recipe_class.new([], options)
task = recipe_class.tasks[task_name.to_s]
recipe.invoke_task(task)
# Copy back and updated options
options = recipe.options
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tell(role_name, method_name, ...)\n if context == self || context.contains?(self)\n context.dispatch(role(role_name), method_name, ...)\n end\n end",
"def method_missing(meth_name, *args, &block)\n raise \"No method named: #{meth_name}\" unless recipe.respond_to? meth_name\n ... | [
"0.5542909",
"0.5435228",
"0.5433466",
"0.5427825",
"0.52657735",
"0.5257147",
"0.5225269",
"0.5148291",
"0.50860053",
"0.50795543",
"0.50388676",
"0.50357753",
"0.4998903",
"0.49958935",
"0.49937195",
"0.49792033",
"0.497508",
"0.4946387",
"0.4942964",
"0.4920764",
"0.491855... | 0.61740804 | 0 |
GET /air_moistures GET /air_moistures.json | def index
@air_moistures = AirMoisture.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @air_qualities = AirQuality.all\n\n render json: @air_qualities\n end",
"def index\n @soil_moistures = SoilMoisture.all\n end",
"def show\n render json: @air_quality\n end",
"def set_air_moisture\n @air_moisture = AirMoisture.find(params[:id])\n end",
"def index\n @cap... | [
"0.6477318",
"0.6322574",
"0.6238727",
"0.6140732",
"0.6136393",
"0.61150396",
"0.6083614",
"0.60437167",
"0.60434604",
"0.6033698",
"0.60279095",
"0.6005438",
"0.59941566",
"0.5992053",
"0.5980522",
"0.59371537",
"0.59309715",
"0.5927996",
"0.59212065",
"0.59185755",
"0.5907... | 0.75258315 | 0 |
GET /air_moistures/1 GET /air_moistures/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @air_moistures = AirMoisture.all\n end",
"def index\n @air_qualities = AirQuality.all\n\n render json: @air_qualities\n end",
"def show\r\n @imobiliaria = Imobiliaria.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.json { render json: @imobiliaria }\r\n end\r\n ... | [
"0.72442585",
"0.6445022",
"0.64213204",
"0.63258666",
"0.6315291",
"0.62367606",
"0.6211252",
"0.62108004",
"0.61827606",
"0.6172943",
"0.6165749",
"0.615278",
"0.61441934",
"0.61220115",
"0.6120221",
"0.61193347",
"0.61040413",
"0.6091801",
"0.6057288",
"0.6049138",
"0.6037... | 0.0 | -1 |
POST /air_moistures POST /air_moistures.json | def create
@air_moisture = AirMoisture.new(air_moisture_params)
respond_to do |format|
if @air_moisture.save
format.html { redirect_to @air_moisture, notice: 'Air moisture was successfully created.' }
format.json { render :show, status: :created, location: @air_moisture }
else
format.html { render :new }
format.json { render json: @air_moisture.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @air_moistures = AirMoisture.all\n end",
"def create\n @soil_moisture = SoilMoisture.new(soil_moisture_params)\n\n respond_to do |format|\n if @soil_moisture.save\n format.html { redirect_to @soil_moisture, notice: 'Soil moisture was successfully created.' }\n format.json... | [
"0.6157518",
"0.6023888",
"0.59428394",
"0.5910758",
"0.5841418",
"0.57893306",
"0.57763255",
"0.5775427",
"0.57316273",
"0.5690711",
"0.56655085",
"0.5650385",
"0.5640944",
"0.56387323",
"0.5595094",
"0.5562408",
"0.555145",
"0.55506915",
"0.5550431",
"0.553902",
"0.55364805... | 0.7118669 | 0 |
PATCH/PUT /air_moistures/1 PATCH/PUT /air_moistures/1.json | def update
respond_to do |format|
if @air_moisture.update(air_moisture_params)
format.html { redirect_to @air_moisture, notice: 'Air moisture was successfully updated.' }
format.json { render :show, status: :ok, location: @air_moisture }
else
format.html { render :edit }
format.json { render json: @air_moisture.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n respond_to do |format|\n if @mile.update(mile_params)\n format.html { redirect_to @mile, notice: 'Mile was succes... | [
"0.6274479",
"0.62224776",
"0.6215002",
"0.61873496",
"0.6130231",
"0.61201",
"0.6114338",
"0.60977507",
"0.6090425",
"0.6045212",
"0.60351163",
"0.60275054",
"0.5998368",
"0.59876174",
"0.598102",
"0.5971419",
"0.596839",
"0.59681946",
"0.59681946",
"0.59334207",
"0.5931079"... | 0.67266005 | 0 |
DELETE /air_moistures/1 DELETE /air_moistures/1.json | def destroy
@air_moisture.destroy
respond_to do |format|
format.html { redirect_to air_moistures_url, notice: 'Air moisture was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 destroy\n @soil_moisture.destroy\n respond_to do |format|\n format.html { redirect_to soil_moistures_url, notice: 'Soil moisture was successfully ... | [
"0.7003927",
"0.70035815",
"0.69732076",
"0.695011",
"0.6943842",
"0.6917684",
"0.6902483",
"0.6899357",
"0.6897867",
"0.68952644",
"0.68856806",
"0.68581945",
"0.6854098",
"0.6851745",
"0.6819654",
"0.68140924",
"0.68092847",
"0.6798806",
"0.679734",
"0.678996",
"0.6787179",... | 0.72552097 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_air_moisture
@air_moisture = AirMoisture.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.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.533008... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def air_moisture_params
params.require(:air_moisture).permit(:min, :max, :disease_id, :cf)
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 |
show stops for line | def show_stops(lines, line1)
lines.each do |line|
if line[:lines] == line1
puts line[:stops]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLineStops (l)\n @lines[l][:stops]\nend",
"def get_line_stops(lines, origin_line)\n lines[origin_line.to_sym]\nend",
"def draw_line\n print H_SEP * columns\n end",
"def list_stops(line)\n puts line\n return \"all the stops on a line\"\nend",
"def draw_alt_line\n @dim.times do |i|\n if... | [
"0.6607579",
"0.6488185",
"0.6245445",
"0.6132525",
"0.6111507",
"0.6092206",
"0.6056067",
"0.5993023",
"0.5974445",
"0.59705985",
"0.5965411",
"0.59442824",
"0.5943782",
"0.59269977",
"0.5841553",
"0.58251005",
"0.57955676",
"0.57708865",
"0.5755447",
"0.57397103",
"0.569606... | 0.6886917 | 0 |
show total number of stops | def show_total(lines, line1, stops1, line2, stops2)
index1 = []
index2 = []
#get index for first stop
lines.each do |line|
if line[:lines] == line1
index1.push(line[:stops].index(stops1))
if line1 == "f"
index1.push(line[:stops].index("herald_square") + 1)
else
index1.push(line[:stops].index("union_square"))
end
end
end
#get index for second stop
lines.each do |line|
if line[:lines] == line2
index2.push(line[:stops].index(stops2))
if line2 == "f"
index2.push(line[:stops].index("herald_square") + 1)
else
index2.push(line[:stops].index("union_square"))
end
end
end
#calculate number of stops
if index1[0] == index1[1]
index1 = 0
else
index1 = (index1[0] - index1[1]).abs
end
if index2[0] == index2[1]
index2 = 0
else
index2 = (index2[0] - index2[1]).abs
end
puts index1 + index2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_stations\n total=($start-$end).abs\n p \"total of stations of your trip is #{total}\"\n end",
"def numStops( x , y )\n (x - y).abs\n end",
"def flight_segment_tally\n all_flights.length\n end",
"def number(bus_stops)\n entries = []\n exits = []\n bus_stops.each { |x| ent... | [
"0.6675247",
"0.6542983",
"0.6333986",
"0.6329348",
"0.6324554",
"0.63127315",
"0.62659895",
"0.6246094",
"0.62302047",
"0.61082006",
"0.6081763",
"0.6075929",
"0.6075929",
"0.6075929",
"0.6068978",
"0.6053711",
"0.6053061",
"0.6048437",
"0.60428387",
"0.60287166",
"0.6004004... | 0.629494 | 6 |
somehow registration does not work out (at least not under windows) the . is also not accepted by unix as seperator | def tag(name)
if $crossover then "_CTX_K_S_#{name}_" else "TEXMFSTART.#{name}" end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filesystem_safe_name\n name.\n gsub(ReservedCharacters) {|sub| '%%%02X' % sub.ord }.\n gsub(ReservedFilenameRegexp) {|sub| sub.gsub(/[^.]/) {|c| '%%%02X' % c.ord } }\n end",
"def start_registering_extension\n @register_path = caller_files[2]\n end",
"def extname; end",
"... | [
"0.57724786",
"0.55778706",
"0.5521576",
"0.5521576",
"0.5521576",
"0.5521576",
"0.55095315",
"0.55071396",
"0.54648894",
"0.54400605",
"0.5389148",
"0.5389148",
"0.5381623",
"0.5356727",
"0.5327964",
"0.5285881",
"0.5278135",
"0.52696717",
"0.5261767",
"0.5251551",
"0.524354... | 0.0 | -1 |
Search through provided list of trips and filter optionally by service_id and route_id | def search_trips(trips, opts = {})
service_id = opts[:service_id]
route_id = opts[:route_id]
service_id ||= 'S1'
valid_trips = trips.select { |trip|
trip[:service_id].eql? service_id
}
trips_with_route = valid_trips.select{ |trip|
if !route_id.nil? then
trip[:route_id].eql? route_id
else
true
end
}
trips_with_route.map {|trip| trip[:trip_id]}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trips\n Trip.where(:route_id => self.route_id)\n end",
"def trips\n Trip.where(:route_id => self.route_id)\n end",
"def trips_by_route_id(route_id)\n get \"/gtfs/trips/routeid/#{route_id}\"\n end",
"def trips\n Trip.all.filter do |trip|\n trip.listing == self\n en... | [
"0.6388643",
"0.6388643",
"0.60504746",
"0.59264445",
"0.58997303",
"0.5855909",
"0.58192116",
"0.5799047",
"0.57825017",
"0.57342863",
"0.57100093",
"0.56728137",
"0.567088",
"0.5621909",
"0.5620392",
"0.5618179",
"0.56052136",
"0.5541512",
"0.5539852",
"0.5518571",
"0.55021... | 0.8140789 | 0 |
FYI The methods below are basically just glorified getters from the | def trips(opts = {})
begin
ret_stops = @gtfs_parser.parse_file(@data_dir + @@trips_file)
rescue CSV::MalformedCSVError
raise "InvalidCSV"
end
ret_stops
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getters; end",
"def private; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def get()\n \n end",
"def getter_method_names; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def properties; end",
"def pr... | [
"0.7597988",
"0.7509741",
"0.667236",
"0.667236",
"0.667236",
"0.667236",
"0.65832084",
"0.65743643",
"0.6520891",
"0.6520891",
"0.6520891",
"0.6520891",
"0.64719146",
"0.64719146",
"0.64719146",
"0.64719146",
"0.64719146",
"0.64719146",
"0.64719146",
"0.64719146",
"0.6423191... | 0.0 | -1 |
private def user_params params.require(:user).permit(:firstName, :lastName, ) end | def show
if (session[:user_id] == nil)
flash[:alert] = "You are not logged in";
redirect_to login_path
else
@user = User.find(session[:user_id])
@events = @user.events
@points = @user.getPoints
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_params\n params.require(:user).permit(:first_name, :last_name)\n end",
"def user_params\n params.require(:user).permit(:firstname, :lastname)\n end",
"def user_params\n params.require(:user).permit(:email, :password, :password_confirmation, :firstName, :lastName) ... | [
"0.94102263",
"0.9395141",
"0.93017864",
"0.93015873",
"0.9288069",
"0.9209122",
"0.92067933",
"0.9199963",
"0.91942114",
"0.91783005",
"0.91783005",
"0.91783005",
"0.91783005",
"0.91672474",
"0.91672474",
"0.9137191",
"0.91322863",
"0.91108054",
"0.90707314",
"0.9061668",
"0... | 0.0 | -1 |
Analyze the structure of the HTML document and score content blocks for likelihood of containing useful content | def analyze
opt = DEFAULTS.clone
opt.merge!(@options)
@sections = []
factor = continuous = 1.0
body = ''
score = 0
# The content is split into blocks of divs
list = @raw_content.split(/<\/?(?:div)[^>]*>/)
list.each do |block|
next unless block
block.gsub!(/\n/, '')
# Ignore blocks that have no text
next if has_only_tags?(block)
# Each new block iterated over makes it less likely for it to belong
# to the existing block
continuous /= opt[:continuous_factor] if body.length > 0
# Clean up and strip block of html tags for scoring
clean = clean_block(block)
#clean = strip_tags(block)
next if clean.length < opt[:min_length]
# Calculate scores for clustering of blocks
# c represents how probable it is for this block to be a content block
c = (clean.length + clean.scan(opt[:punctuations]).length * opt[:punctuation_weight]) * factor
# The further down the document we go (i.e. the more blocks we see),
# the less likely they are to be valid content blocks
factor *= opt[:decay_factor]
# The not body rate represents how likely this is to be a junk block
not_body_rate = block.scan(opt[:waste_expressions]).length
# The block score is reduced if there is a not_body_rate
c *= (opt[:no_body_factor] ** not_body_rate) if not_body_rate>0
# c1 represents how probable it is for this block to belong to the
# existing block or if it is a new one
c1 = c * continuous
puts "----- #{c}*#{continuous}=#{c1} #{clean.length} \n\n" if opt[:debug]
if c1 > opt[:threshold]
# Treat continuous blocks as cluster
body += block + "\n"
score += c1
continuous = opt[:continuous_factor]
elsif c > opt[:threshold]
# Continuous block end
@sections << { :body => body, :score => score }
body = block + "\n"
score = c
continuous = opt[:continuous_factor]
else
# We drop blocks that don't have a high enough c score
end
end
# Add the last block as we've finished iterating
@sections << { :body => body, :score => score } if body
# Sort the sections by score
sorted_sections = @sections.sort_by { |section| section[:score] }
# Convert to nokogiri representation for compatibility with the content method
@content_candidates = sorted_sections.reverse.map { |section| Nokogiri::HTML(section[:body], nil, 'utf-8') }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rate_content(content)\n contents = Hash.new\n for i in 0...content.size\n contents[\"#{i}\"] = 0.0\n\n # chceking if div does not contain whole document\n contents[\"#{i}\"] += -20 if content[i].to_s.lines.count > @@lines*0.95\n\n # rating contents for tags they contain\n content... | [
"0.71152675",
"0.61536187",
"0.6008303",
"0.5928885",
"0.5910866",
"0.58664024",
"0.5846169",
"0.5725032",
"0.57192284",
"0.55903924",
"0.5530526",
"0.5488424",
"0.5479663",
"0.547885",
"0.54749924",
"0.53934646",
"0.5374359",
"0.5365443",
"0.5345734",
"0.5332543",
"0.5323156... | 0.7070175 | 1 |
Checks if the given block has only tags without text. | def has_only_tags?(block)
block.gsub(/<[^>]*>/im, '').strip.length == 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_paragraph_tag?(text)\n text !~ /^\\<p/\n end",
"def no_paragraph_tag?(text)\n text !~ /^\\<p/\n end",
"def element_is_text?\n !self[:is_tag]\n end",
"def should_spit_text?\n @tags_chain.size > 0 && \n #(not @text.empty?) &&\n [\"body\", \"p\", \"br\", \... | [
"0.6701398",
"0.6701398",
"0.66280824",
"0.63980025",
"0.62248796",
"0.6039487",
"0.5998476",
"0.58188146",
"0.5800965",
"0.5753922",
"0.5720263",
"0.57176304",
"0.5709449",
"0.5692271",
"0.56789213",
"0.565085",
"0.5638347",
"0.5638347",
"0.56019056",
"0.55812377",
"0.557687... | 0.86452794 | 0 |
Eliminates link heavy blocks and blocks that are lists of links and then returns block stripped of tags | def clean_block(block)
# Return empty block if it is a list of links
return "" if is_link_list?(block)
# Return empty block if it is a very link heavy block
count = 0
no_links = block.gsub(/<a\s[^>]*>.*?<\/a\s*>/im){count+=1;''}.gsub(/<form\s[^>]*>.*?<\/form\s*>/im, '')
return "" if no_links.length < 20 * count
strip_tags(no_links)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_links(html); end",
"def strip_links(html); end",
"def strip_links(html); end",
"def remove_links(block)\n inline_block = block.gsub(LINK_PATTERN) do |s|\n url = URL_PATTERN.match(s)[2]\n extension = File.extname(url)\n /\\.js|\\.css/.match(extension) && !URI.... | [
"0.6566711",
"0.6566711",
"0.6566711",
"0.6559199",
"0.6457174",
"0.63547766",
"0.62854224",
"0.6244661",
"0.6109296",
"0.6030028",
"0.6029686",
"0.59956944",
"0.59488803",
"0.59488803",
"0.59488803",
"0.5935917",
"0.58676153",
"0.5801457",
"0.57909024",
"0.5735019",
"0.57316... | 0.78719556 | 0 |
Determines whether a block is link list or not | def is_link_list?(st)
if st =~ /<(?:ul|dl|ol)(.+?)<\/(?:ul|dl|ol)>/im
listpart = $1
outside = st.gsub(/<(?:ul|dl)(.+?)<\/(?:ul|dl)>/imn, '').gsub(/<.+?>/mn, '').gsub(/\s+/, ' ')
list = listpart.split(/<li[^>]*>/)
list.shift
rate = evaluate_list(list)
outside.length <= st.length / (45 / rate)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_link?\n [1,2].include?(link_type)\n end",
"def is_linktype?(); @type == GRT_LINKTYPE; end",
"def link?\n !link.nil? && !link.empty?\n end",
"def link?\n !link.nil? && !link.empty?\n end",
"def linked?\n return BlizzABS::Alignments::LINKED_GROUPS.include?(@group)\n ... | [
"0.6915274",
"0.66692495",
"0.6214611",
"0.6214611",
"0.6208301",
"0.6073194",
"0.60092074",
"0.59285074",
"0.5898732",
"0.58811426",
"0.5844004",
"0.58385414",
"0.583644",
"0.58260036",
"0.581676",
"0.58014876",
"0.5760968",
"0.5760968",
"0.5759168",
"0.5751555",
"0.57247365... | 0.6971343 | 0 |
Estimates how much degree of link list | def evaluate_list(list)
return 1 if list.length == 0
hit = 0
list.each do |line|
hit +=1 if line =~ /<a\s+href=(['"]?)([^"'\s]+)\1/imn
end
return 9 * (1.0 * hit / list.length) ** 2 + 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def n_degree(node, counts=false, k=2)\n d = n_indegree(node,counts,k) + n_outdegree(node,counts,k)\n if l=@links[[node,node]]\n # to be repaired!\n case counts\n when true, :add\n d -= l.weight\n when false, nil, :nodes\n d -= 1\n else\n raise \"fixme: no self li... | [
"0.69526744",
"0.64286536",
"0.63070405",
"0.6292629",
"0.6245483",
"0.6236725",
"0.621429",
"0.6208246",
"0.6104611",
"0.60904217",
"0.6069165",
"0.6044643",
"0.60417974",
"0.6020638",
"0.5985121",
"0.59732026",
"0.5939222",
"0.5925733",
"0.5900319",
"0.5884814",
"0.5870445"... | 0.0 | -1 |
Removes all html tags and attributes from html | def strip_tags(html)
strip(Sanitize.clean(html, :elements => [], :attributes => []))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_html\n gsub(HTML_TAG_PATTERN, \"\")\n end",
"def strip_tags(html); end",
"def strip_tags(html); end",
"def strip_tags(html); end",
"def html_remove\n gsub(/<\\/?[^>]+>/, '')\n end",
"def remove_html_tag(tag_name); end",
"def strip_tags(html)\n return html if html.blank?\n if... | [
"0.8129619",
"0.80492145",
"0.80492145",
"0.80492145",
"0.78930527",
"0.76796126",
"0.76238716",
"0.7623648",
"0.7594436",
"0.7538369",
"0.75369114",
"0.7335301",
"0.7327459",
"0.72364163",
"0.7226362",
"0.7218428",
"0.71832067",
"0.71705854",
"0.7168116",
"0.7168116",
"0.707... | 0.8016258 | 4 |
optional methods below, wheeeeee | def preferred_vendor
# returns the vendor with the highest revenue
vendors.max_by {|vendor| FarMar::Vendor.find(vendor.id).revenue}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def optional; end",
"def extra; end",
"def custom; end",
"def custom; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def missing; end",
"def missing?; end",
"def who_we_are\r\n end",
"def ignores; end",
"def sc... | [
"0.7547798",
"0.7169128",
"0.7168276",
"0.7073493",
"0.68971825",
"0.68971825",
"0.6857012",
"0.6857012",
"0.6857012",
"0.6857012",
"0.68427056",
"0.68347",
"0.67881846",
"0.66595197",
"0.6634924",
"0.65769935",
"0.6560613",
"0.6551691",
"0.64930123",
"0.64930123",
"0.6472366... | 0.0 | -1 |
We might have to remove certain characters, but for now we just CGI.escape it and remove any periods | def clean_name(name)
CGI.escape(name).gsub('.', '')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize(name)\n #name.gsub(\".\", \"_\").gsub(/<.+>/, \"\")\n name.gsub(\".\", \"_\").gsub(\"$\", \"_\")\nend",
"def cgi_escape(input); end",
"def safe(str)\n CGI.unescape(str)\n end",
"def sanitize_as_filename\n self.gsub(/^.*(\\\\|\\/)/, '').transliterate.downcase.gsub(/[^a-z0-9\\. ]/, ' ... | [
"0.7022107",
"0.666911",
"0.6618527",
"0.65766394",
"0.64787436",
"0.642227",
"0.6407414",
"0.63973",
"0.6377207",
"0.63030505",
"0.629229",
"0.6253363",
"0.62434715",
"0.6239274",
"0.6201699",
"0.61980134",
"0.6189996",
"0.615272",
"0.61382097",
"0.613641",
"0.611482",
"0.... | 0.74023795 | 0 |
FIXME a lot more could be done with "by citations". identities gives summaries of the most popular works as well as other descriptive information like subject headings. This might be able to be used for enhancing metadata. | def extract_works(doc)
works = []
doc.search("by/citation/title").each_with_index do |t, i|
works << t.inner_text
break if @num_of_works == i + 1
end
return nil if works.blank?
"most widely held #{works.length == 1 ? "work" : "works"}: " + works.join("; ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def known_identities; end",
"def author_identities_set\n author_identities.map do |ident|\n normalize_author_identity(ident.first_name, ident.middle_name || 'None',\n ident.last_name, ident.institution || 'None')\n end.to_s\n end",
"def doi_metadata\n # This must... | [
"0.6208201",
"0.6206581",
"0.61612713",
"0.60307264",
"0.60089326",
"0.59893966",
"0.5927606",
"0.5844971",
"0.57987094",
"0.578479",
"0.5783206",
"0.5743252",
"0.5741871",
"0.57245195",
"0.5666496",
"0.5633242",
"0.5633153",
"0.5630021",
"0.56274056",
"0.5617466",
"0.5608743... | 0.0 | -1 |
createsa minimal openurl to make a new request to umlaut | def create_openurl(request, wh)
metadata = request.referent.metadata
co = OpenURL::ContextObject.new
cor = co.referent
cor.set_format(wh['record_type'])
cor.add_identifier("info:oclcnum/#{wh['oclcnum']}")
cor.set_metadata('aulast', metadata['aulast'] ) if metadata['aulast']
cor.set_metadata('aufirst', metadata['aufirst']) if metadata['aufirst']
cor.set_metadata('aucorp', metadata['aucorp']) if metadata['aucorp']
cor.set_metadata('title', wh['title'])
link = @openurl_base + '?' + co.kev
return link
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def openurl(url)\n runcmd 'openurl', url\n end",
"def open_url\n opts = [config.oui_full_url]\n opts << { 'User-Agent' => config.user_agent } if config.user_agent\n open(*opts).read\n rescue OpenURI::HTTPError\n ''\n end",
"def autoname_url(url)\n request('POST', @uri.request_uri, ... | [
"0.6623941",
"0.65541255",
"0.6551269",
"0.64429736",
"0.6367715",
"0.6367715",
"0.63302237",
"0.6289301",
"0.6288969",
"0.62307286",
"0.6196741",
"0.6196741",
"0.6196741",
"0.6196741",
"0.6196741",
"0.6196741",
"0.6196741",
"0.617224",
"0.6110351",
"0.6063315",
"0.60149294",... | 0.6584969 | 1 |
We just link to worldcat using the oclc number provided FIXME this might need special partial if we incorporate a cover image | def create_worldcat_widely_held(request, xml)
# try to prevent circular links
top_holding_info = get_widely_held_info(xml)
return nil if circular_link?(request, top_holding_info)
# http://www.worldcat.org/links/
most = top_holding_info['most']
title = top_holding_info['title']
oclcnum = top_holding_info['oclcnum']
link = 'http://www.worldcat.org/oclc/' << oclcnum
cover_image_link = extract_cover_image_link(request, most)
notes = "this author's most widely held work in WorldCat"
if cover_image_link
display_text = '<img src="' << cover_image_link << '" style="width:75px;"/>'
notes = title << ' is ' << notes
else
display_text = title
end
request.add_service_response(
:service=>self,
:url=>link,
:display_text=> display_text,
:notes => notes,
:service_type_value => :highlighted_link)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_rdf_catlink(b,ty)\n ul = \"http://catalog.library.cornell.edu/catalog/#{id}\"\n # if no elect access data, 'description' field.\n b.dc(:description,ul)\n end",
"def category\n path = @path_remote.split('/')\n return path[3] # Could require changes depending on the structure of the m... | [
"0.58421445",
"0.57172924",
"0.54939795",
"0.54489636",
"0.5408253",
"0.5284518",
"0.52164835",
"0.5123847",
"0.50671166",
"0.50663817",
"0.50655955",
"0.5063098",
"0.50439924",
"0.5029098",
"0.4994209",
"0.49723473",
"0.4956977",
"0.4947813",
"0.49284944",
"0.49106896",
"0.4... | 0.66617954 | 0 |
Create a new csv differ, this differ can then be used to create a split and a unified view. The raw csv strings are decoded and the csv header is extracted. If the table has more than 100 rows, a simplified version of the table will be rendered this will limit the performance hit of a very long table. | def initialize(generated, expected)
@generated = CSV.parse((generated || '').lstrip, nil_value: '')
@expected = CSV.parse((expected || '').lstrip, nil_value: '')
@gen_headers, *@generated = @generated
@gen_headers ||= []
@exp_headers, *@expected = @expected
@exp_headers ||= []
@simplified_table = @generated.length > 100 || @expected.length > 100
@gen_header_indices, @exp_header_indices, @gen_headers, @exp_headers, @combined_headers = diff_header_indices(@gen_headers, @exp_headers)
@diff = unless @simplified_table
Diff::LCS.sdiff(@generated, @expected).map do |chunk|
gen_result = chunk.old_element || []
exp_result = chunk.new_element || []
if chunk.action == '!'
gen_result, exp_result = diff_arrays(gen_result, exp_result)
else
gen_result = gen_result.map { |el| CGI.escape_html el }
exp_result = exp_result.map { |el| CGI.escape_html el }
end
Diff::LCS::ContextChange.new(chunk.action, chunk.old_position, gen_result, chunk.new_position, exp_result)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_build_table(builder, headers, is_generated_output)\n builder.table(class: 'split-diff diff csv-diff') do\n builder.colgroup do\n builder.col(class: 'line-nr')\n builder.col(span: headers.length)\n end\n builder.thead do\n if is_generated_output\n icon_cls =... | [
"0.6365711",
"0.617779",
"0.5809265",
"0.5763582",
"0.5737592",
"0.57320434",
"0.5729515",
"0.567915",
"0.5666242",
"0.5646566",
"0.56349075",
"0.5598919",
"0.55255604",
"0.52926606",
"0.5253105",
"0.52371824",
"0.52362704",
"0.52265257",
"0.5223451",
"0.52117753",
"0.5191535... | 0.63552666 | 1 |
Render a unified table view based on the data passed when creating the CsvDiffer instance. | def unified
builder = Builder::XmlMarkup.new
builder.table(class: 'unified-diff diff csv-diff') do
builder.colgroup do
builder.col(class: 'line-nr')
builder.col(class: 'line-nr')
builder.col(span: @combined_headers.length)
end
builder.thead do
builder.tr do
builder.th(class: 'line-nr', title: I18n.t('submissions.show.your_output')) do
builder.i(class: 'mdi mdi-18 mdi-file-account')
end
builder.th(class: 'line-nr', title: I18n.t('submissions.show.expected')) do
builder.i(class: 'mdi mdi-18 mdi-file-check')
end
builder.th(colspan: @combined_headers.length)
end
builder.tr do
builder.th(class: 'line-nr')
builder.th(class: 'line-nr')
builder << @combined_headers.join
end
end
builder.tbody do
if @simplified_table
unified_simple_body builder
else
@diff.each do |chunk|
is_empty, row = old_row chunk
unless is_empty
full_row = Array.new(@combined_headers.length) { |i| @gen_header_indices.index(i) }.map { |idx| idx.nil? ? '<td></td>' : row[idx] }
builder << %(<tr>
<td class="line-nr">#{chunk.old_position + 1}</td>
<td class="line-nr"></td>
#{full_row.join}
</tr>)
end
is_empty, row = new_row chunk
next if is_empty
full_row = Array.new(@combined_headers.length) { |i| @exp_header_indices.index(i) }.map { |idx| idx.nil? ? '<td></td>' : row[idx] }
builder << %(<tr>
<td class="line-nr"></td>
<td class="line-nr">#{chunk.new_position + 1}</td>
#{full_row.join}
</tr>)
end
end
end
end.html_safe
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_build_table(builder, headers, is_generated_output)\n builder.table(class: 'split-diff diff csv-diff') do\n builder.colgroup do\n builder.col(class: 'line-nr')\n builder.col(span: headers.length)\n end\n builder.thead do\n if is_generated_output\n icon_cls =... | [
"0.6573815",
"0.6189673",
"0.5929262",
"0.58629036",
"0.5862575",
"0.5783196",
"0.5720341",
"0.56802416",
"0.56705254",
"0.56525594",
"0.5648546",
"0.56348133",
"0.56308836",
"0.562267",
"0.56099725",
"0.55963296",
"0.5580589",
"0.55315",
"0.5478361",
"0.54780394",
"0.5438503... | 0.7310779 | 0 |
Render a split table view based on the data passed when creating the CsvDiffer instance. The split view renders two tables, that individually have a horizontal scrollbar. | def split
builder = Builder::XmlMarkup.new
builder.div do
split_build_table(builder, @gen_headers, true)
split_build_table(builder, @exp_headers, false)
end.html_safe
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_build_table(builder, headers, is_generated_output)\n builder.table(class: 'split-diff diff csv-diff') do\n builder.colgroup do\n builder.col(class: 'line-nr')\n builder.col(span: headers.length)\n end\n builder.thead do\n if is_generated_output\n icon_cls =... | [
"0.7004308",
"0.6201249",
"0.56568396",
"0.56285596",
"0.55700326",
"0.5349006",
"0.5320473",
"0.5285839",
"0.52177036",
"0.5211179",
"0.5185852",
"0.5173145",
"0.5152573",
"0.51514953",
"0.5122979",
"0.51103246",
"0.5064794",
"0.50607324",
"0.5060666",
"0.50437343",
"0.50365... | 0.65478545 | 1 |
Build one of the two tables of the split table view (see function 'split') | def split_build_table(builder, headers, is_generated_output)
builder.table(class: 'split-diff diff csv-diff') do
builder.colgroup do
builder.col(class: 'line-nr')
builder.col(span: headers.length)
end
builder.thead do
if is_generated_output
icon_cls = 'mdi-file-account'
title = I18n.t('submissions.show.your_output')
else
icon_cls = 'mdi-file-check'
title = I18n.t('submissions.show.expected')
end
builder.tr do
builder.th(class: 'line-nr', title: title) do
builder.i(class: %(mdi mdi-18 #{icon_cls}))
end
builder.th(title, colspan: headers.length)
end
builder.tr do
builder.th(class: 'line-nr')
builder << headers.join
end
end
builder.tbody do
if @simplified_table
if is_generated_output
split_simple_body(builder, @generated, 'del')
else
split_simple_body(builder, @expected, 'ins')
end
else
@diff.each do |chunk|
builder.tr do
if is_generated_output
is_empty, row = old_row(chunk)
position = chunk.old_position
else
is_empty, row = new_row(chunk)
position = chunk.new_position
end
builder << %(<td class="line-nr">#{position + 1 unless is_empty}</td>)
builder << row.join
end
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split\n builder = Builder::XmlMarkup.new\n\n builder.div do\n split_build_table(builder, @gen_headers, true)\n split_build_table(builder, @exp_headers, false)\n end.html_safe\n end",
"def slice(table)\n head, body, array_h, array_b = 4.times.map { [] }\n index = ... | [
"0.7009416",
"0.56848836",
"0.56125796",
"0.555878",
"0.54818606",
"0.5472032",
"0.5456454",
"0.5423256",
"0.5380515",
"0.53663176",
"0.53643316",
"0.534272",
"0.534272",
"0.534272",
"0.534272",
"0.53099674",
"0.52941924",
"0.527488",
"0.5260239",
"0.5258009",
"0.52463865",
... | 0.6669901 | 1 |
Build a simplified version of the unified table body This simplified view combines all rows in a column into 1 row with newlines. The columns are still separate, but the diff is less accurate. | def unified_simple_body(builder)
gen_cols = @generated.transpose.map { |col| col.join("\n") }
builder.tr do
builder.td(class: 'line-nr') do
builder << (1..@generated.length).to_a.join("\n")
end
builder.td(class: 'line-nr')
builder << Array.new(@combined_headers.length) { |i| @gen_header_indices.index(i) }.map do |idx|
if idx.nil?
'<td></td>'
else
%(<td class="del">#{CGI.escape_html gen_cols[idx]}</td>)
end
end.join
end
exp_cols = @expected.transpose.map { |col| col.join("\n") }
builder.tr do
builder.td(class: 'line-nr')
builder.td(class: 'line-nr') do
builder << (1..@expected.length).to_a.join("\n")
end
builder << Array.new(@combined_headers.length) { |i| @exp_header_indices.index(i) }.map do |idx|
if idx.nil?
'<td></td>'
else
%(<td class="ins">#{CGI.escape_html exp_cols[idx]}</td>)
end
end.join
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unified\n builder = Builder::XmlMarkup.new\n builder.table(class: 'unified-diff diff csv-diff') do\n builder.colgroup do\n builder.col(class: 'line-nr')\n builder.col(class: 'line-nr')\n builder.col(span: @combined_headers.length)\n end\n builder.thead do\n buil... | [
"0.7234448",
"0.6947831",
"0.69122547",
"0.6492349",
"0.64286786",
"0.62928003",
"0.62743044",
"0.61191356",
"0.6065495",
"0.6048436",
"0.60426545",
"0.60366195",
"0.6035253",
"0.599704",
"0.5990995",
"0.5968515",
"0.5957089",
"0.5931741",
"0.5895767",
"0.588607",
"0.5869061"... | 0.7181176 | 1 |
Build a simplified version of the split table body This simplified view combines all rows in a column into 1 row with newlines. The columns are still separate, but the diff is less accurate. | def split_simple_body(builder, data, cls)
gen_cols = data.transpose.map { |col| col.join("\n") }
builder.tr do
builder.td(class: 'line-nr') do
builder << (1..data.length).to_a.join("\n")
end
gen_cols.each do |col|
builder.td(class: cls) do
builder << CGI.escape_html(col)
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_build_table(builder, headers, is_generated_output)\n builder.table(class: 'split-diff diff csv-diff') do\n builder.colgroup do\n builder.col(class: 'line-nr')\n builder.col(span: headers.length)\n end\n builder.thead do\n if is_generated_output\n icon_cls =... | [
"0.703649",
"0.66588366",
"0.6583324",
"0.65022963",
"0.64263666",
"0.6323259",
"0.6167681",
"0.60666615",
"0.59544784",
"0.58305293",
"0.5770722",
"0.5667127",
"0.5666934",
"0.5651298",
"0.55769366",
"0.55761003",
"0.5564571",
"0.5550563",
"0.55431837",
"0.54857373",
"0.5461... | 0.6910786 | 1 |
Wrap the row elements (cells) in html td tags. Determine what class to use based on the row chunk action. This way the row will be correctly formatted (eg. green background). | def old_row(chunk)
old_class = {
'-' => 'del',
'+' => '',
'=' => 'unchanged',
'!' => 'del'
}[chunk.action]
[old_class.empty?, chunk.old_element.map { |el| %(<td class="#{old_class}">#{el}</td>) }]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_row(chunk)\n new_class = {\n '-' => '',\n '+' => 'ins',\n '=' => 'unchanged',\n '!' => 'ins'\n }[chunk.action]\n [new_class.empty?, chunk.new_element.map { |el| %(<td class=\"#{new_class}\">#{el}</td>) }]\n end",
"def table_row_helper(cells, opts={})\n if cells[0] == :div... | [
"0.7510548",
"0.7364384",
"0.66827005",
"0.66615427",
"0.6320908",
"0.6252681",
"0.6111531",
"0.6109477",
"0.6099684",
"0.6079694",
"0.60587615",
"0.60540134",
"0.60315174",
"0.5992878",
"0.59632367",
"0.5950665",
"0.59503984",
"0.58869535",
"0.5861187",
"0.5830213",
"0.57275... | 0.68154114 | 2 |
Wrap the row elements (cells) in html td tags. Determine what class to use based on the row chunk action. This way the row will be correctly formatted (eg. green background). | def new_row(chunk)
new_class = {
'-' => '',
'+' => 'ins',
'=' => 'unchanged',
'!' => 'ins'
}[chunk.action]
[new_class.empty?, chunk.new_element.map { |el| %(<td class="#{new_class}">#{el}</td>) }]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table_row_helper(cells, opts={})\n if cells[0] == :divider\n # this is not very nice..\n \"<tr><td colspan='#{cells[1]}' class='divider'><div></div></td></tr>\".html_safe\n else\n # Tried making this with content_tag but couldn't get the html_safe to work right... :S\n \"<tr>#{cells.c... | [
"0.73626834",
"0.6815915",
"0.6682152",
"0.66611123",
"0.6319589",
"0.6253161",
"0.61102957",
"0.6108904",
"0.6099915",
"0.60796154",
"0.60580844",
"0.60535693",
"0.6032365",
"0.5991391",
"0.5962249",
"0.5950943",
"0.5949478",
"0.58862174",
"0.58611566",
"0.5829479",
"0.57268... | 0.75109816 | 0 |
Calculate the differences between two arrays (rows) an enclose these differences in strong html tags. Also, html escape the raw table data before enclosing. | def diff_arrays(generated, expected)
gen_result = []
exp_result = []
Diff::LCS.sdiff(generated, expected) do |chunk|
case chunk.action
when '-'
gen_result << %(<strong>#{CGI.escape_html chunk.old_element}</strong>)
when '+'
exp_result << %(<strong>#{CGI.escape_html chunk.new_element}</strong>)
when '='
gen_result << (CGI.escape_html chunk.old_element)
exp_result << (CGI.escape_html chunk.new_element)
when '!'
gen_result << %(<strong>#{CGI.escape_html chunk.old_element}</strong>)
exp_result << %(<strong>#{CGI.escape_html chunk.new_element}</strong>)
end
end
[gen_result, exp_result]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unified\n builder = Builder::XmlMarkup.new\n builder.table(class: 'unified-diff diff csv-diff') do\n builder.colgroup do\n builder.col(class: 'line-nr')\n builder.col(class: 'line-nr')\n builder.col(span: @combined_headers.length)\n end\n builder.thead do\n buil... | [
"0.6884463",
"0.6313503",
"0.6285979",
"0.61260605",
"0.6093102",
"0.57066536",
"0.5673564",
"0.5631533",
"0.5617306",
"0.557994",
"0.5558415",
"0.5512505",
"0.5511733",
"0.54913265",
"0.5454809",
"0.54534966",
"0.5448401",
"0.54331577",
"0.537509",
"0.53118265",
"0.53113043"... | 0.61839837 | 3 |
Compare the table headers of the generated and expected table. The combined headers is the minimal set of headers that include the generated and expected headers (including duplicates). The indices arrays can be used to map the original input headers to the correct headers in the combined header list. | def diff_header_indices(generated, expected)
counter = 0
gen_indices = []
exp_indices = []
gen_headers = []
exp_headers = []
combined_headers = []
Diff::LCS.sdiff(generated, expected) do |chunk|
case chunk.action
when '-'
gen_indices << counter
counter += 1
gen_headers << %(<th class="del"><strong>#{CGI.escape_html chunk.old_element}</strong></th>)
combined_headers << %(<th class="del"><strong>#{CGI.escape_html chunk.old_element}</strong></th>)
when '+'
exp_indices << counter
counter += 1
exp_headers << %(<th class="ins"><strong>#{CGI.escape_html chunk.new_element}</strong></th>)
combined_headers << %(<th class="ins"><strong>#{CGI.escape_html chunk.new_element}</strong></th>)
when '='
gen_indices << counter
exp_indices << counter
counter += 1
gen_headers << %(<th>#{CGI.escape_html chunk.old_element}</th>)
exp_headers << %(<th>#{CGI.escape_html chunk.new_element}</th>)
combined_headers << %(<th>#{CGI.escape_html chunk.new_element}</th>)
when '!'
gen_indices << counter
counter += 1
gen_headers << %(<th class="del"><strong>#{CGI.escape_html chunk.old_element}</strong></th>)
combined_headers << %(<th class="del"><strong>#{CGI.escape_html chunk.old_element}</strong></th>)
exp_indices << counter
counter += 1
exp_headers << %(<th class="ins"><strong>#{CGI.escape_html chunk.new_element}</strong></th>)
combined_headers << %(<th class="ins"><strong>#{CGI.escape_html chunk.new_element}</strong></th>)
end
end
[gen_indices, exp_indices, gen_headers, exp_headers, combined_headers]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_header_names(key, models_columns, header)\n normalized_header = []\n\n got_error = false\n header.each_with_index do |h, i|\n logger.debug \"verify header: #{h}\"\n if h == \"id\"\n error(cur_sheet_name, 1, \"Header column #{h} not allowed, update not supported yet\")\n next\n end\... | [
"0.63184196",
"0.6097423",
"0.58528733",
"0.5850958",
"0.5802083",
"0.5683103",
"0.56407815",
"0.5597162",
"0.5579819",
"0.55273336",
"0.552548",
"0.55186576",
"0.55001485",
"0.5480812",
"0.54472744",
"0.5439384",
"0.54330105",
"0.54320794",
"0.5423372",
"0.5401045",
"0.53941... | 0.741105 | 0 |
register a timeout listener that will be called in given seconds (aprox). Returns a listener object that can be used with clear_timeout to remove the listener | def set_timeout(seconds, block)
listener = { seconds: seconds, block: block, time: @time, target: @time + seconds }
@timeout_listeners.push listener
listener
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timer(timeout,options={},&callback)\n bot.timer.add_timer(:timestamp=>Time.now+timeout.to_i, :requestor=>options[:requestor]||name,&callback)\n end",
"def _add_timeout_arg(a_func, timeout)\n proc do |request, **kwargs|\n kwargs[:timeout] = timeout\n a_func.call(request, **kwargs)\n ... | [
"0.6580678",
"0.6283373",
"0.6205954",
"0.615535",
"0.6121049",
"0.6081951",
"0.60530937",
"0.5976984",
"0.59044105",
"0.5765276",
"0.57223237",
"0.5713267",
"0.56706756",
"0.5661123",
"0.5660976",
"0.5628078",
"0.56160533",
"0.5572752",
"0.55707353",
"0.5554352",
"0.5530285"... | 0.707152 | 0 |
Returns an array with two values, the first being a hash of edges with a number containing their class assignment, the second valud is a boolean which states whether or not the graph is a comparability graph Complexity in time O(d|E|) where d is the maximum degree of a vertex Complexity in space O(|V|+|E|) | def gamma_decomposition
k = 0; comparability=true; classification={}
edges.map {|edge| [edge.source,edge.target]}.each do |e|
if classification[e].nil?
k += 1
classification[e] = k; classification[e.reverse] = -k
comparability &&= plexus_comparability_explore(e, k, classification)
end
end; [classification, comparability]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gamma_decomposition\r\n k = 0; comparability=true; classification={}\r\n edges.map {|edge| [edge.source,edge.target]}.each do |e|\r\n if classification[e].nil?\r\n k += 1\r\n classification[e] = k; classification[e.reverse] = -k\r\n comparability &&= gratr_comparabil... | [
"0.65403706",
"0.61264944",
"0.5824513",
"0.5689655",
"0.5675924",
"0.56293416",
"0.55407304",
"0.5478084",
"0.54539037",
"0.54467845",
"0.5397665",
"0.5392294",
"0.5370198",
"0.5340261",
"0.5313673",
"0.5300132",
"0.52891475",
"0.52799016",
"0.5260608",
"0.52445084",
"0.5239... | 0.6402958 | 1 |
Returns one of the possible transitive orientations of the UndirectedGraph as a Digraph | def transitive_orientation(digraph_class=Digraph)
raise NotImplementError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transitive_orientation(digraph_class=Digraph)\r\n raise NotImplementError\r\n end",
"def to_rgl_oriented\n RGL::ImplicitGraph.new do |g|\n g.vertex_iterator do |block|\n self.each_segment do |segment|\n [:+, :-].each do |orient|\n block.call([segment, orie... | [
"0.6486657",
"0.6296205",
"0.62370664",
"0.5971184",
"0.57780004",
"0.560419",
"0.5532907",
"0.54530483",
"0.5427812",
"0.5420133",
"0.5372397",
"0.5330243",
"0.53203136",
"0.53184295",
"0.52453",
"0.5230286",
"0.52212965",
"0.51883",
"0.51729876",
"0.51539457",
"0.5146304",
... | 0.64383256 | 1 |
Taken from Figure 5.10, on pg. 130 of Martin Golumbic's, _Algorithmic_Graph_ _Theory_and_Perfect_Graphs. | def plexus_comparability_explore(edge, k, classification, space='')
ret = plexus_comparability_explore_inner(edge, k, classification, :forward, space)
plexus_comparability_explore_inner(edge.reverse, k, classification, :backward, space) && ret
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_07\n @dg = DiGraph.new([0,0],[6,0],[6,8],[2,6],[8,8],[3,4],[3,2],[3,9],[9,4],[9,6],[4,3],[4,8])\n @paths = Hash.new\n @paths[0] = [0]\n @paths[6] = [0,8]\n @paths[2] = [6]\n @paths[8] = [8]\n @paths[3] = [4,2,9]\n @paths[9] = [4,6]\n @paths[4]... | [
"0.64346105",
"0.6398724",
"0.6208612",
"0.6197937",
"0.61747503",
"0.6088391",
"0.6077693",
"0.6058904",
"0.6004932",
"0.59683543",
"0.5968108",
"0.596783",
"0.5966691",
"0.59432596",
"0.586969",
"0.5836332",
"0.5834974",
"0.58266145",
"0.58245474",
"0.58133066",
"0.58031946... | 0.0 | -1 |
searches books.google.com for books by isbn. returns either a hash, or if given an object providing a from_hash(hash) method will fill it with the data. the object members must be named like the keys in the hash. | def search_by_isbn(isbn, object = nil)
return nil if (isbn = isbn.gsub(/-/,"")).nil?
@client = HTTPClient.new
@book_hash = std_entry
@isbn = isbn
ol_hash = search_open_library
isbndb_hash = search_isbndb
gb_hash = search_google_books
@book_hash.each {|k,v|
@book_hash[k] = ol_hash[k] if @book_hash[k].blank?
}
@book_hash.each {|k,v|
@book_hash[k] = isbndb_hash[k] if @book_hash[k].blank?
}
@book_hash.each {|k,v|
@book_hash[k] = gb_hash[k] if @book_hash[k].blank?
}
if !object.nil? and object.respond_to? :from_hash
puts @book_hash.inspect
object.from_hash(@book_hash)
object
else
@book_hash
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def book_by_isbn(isbn)\n\t\t\tresponse = request('/book/isbn', :isbn => isbn)\n\t\t\tHashie::Mash.new(response['book'])\t\t\t\t\n\t\tend",
"def search_url\n \"http://books.google.com/books/feeds/volumes?q=ISBN#{ isbn }\"\n end",
"def get_book( book_id )\n response = if book_id.to_s.length >= 10\n ... | [
"0.6751553",
"0.6086912",
"0.60364693",
"0.5924739",
"0.59067893",
"0.57909685",
"0.561289",
"0.55804366",
"0.55078435",
"0.5490632",
"0.5490632",
"0.5488336",
"0.5474147",
"0.54411167",
"0.5440768",
"0.54307944",
"0.54307944",
"0.5427307",
"0.5415426",
"0.5379322",
"0.537349... | 0.7637749 | 0 |
Called by the event loop when a remote TCP connection attempt completes successfully. | def connection_completed
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connection_completed\n log_debug '[client-cnxn] Established server connection, sending request'\n send_request unless error?\n rescue\n fail(:RPC_ERROR, 'Connection error: %s' % $!.message) unless failed?\n end",
"def connection_successful\n @authenticating =... | [
"0.7353997",
"0.72152746",
"0.7053522",
"0.6949944",
"0.6949624",
"0.6855503",
"0.67274",
"0.671445",
"0.65525144",
"0.64445853",
"0.64123917",
"0.64009845",
"0.63158876",
"0.6298302",
"0.62887657",
"0.62887657",
"0.62276804",
"0.6226778",
"0.62242013",
"0.61590016",
"0.61296... | 0.64256036 | 10 |
Called by the event loop whenever data has been received by the network connection. It's called with a single parameter, a String containing the network protocol data, which may of course be binary. You will generally overwrite this method to perform your own processing of the incoming data. | def receive_data(data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def receive_binary_data data\n # no-op\n end",
"def receive_data(data)\n self.received_data += data\n process_data if data.end_with?(\"\\n\")\n end",
"def receive data\n data.each_char do |char|\n @buffer.concat char\n if @in_header\n prepare_to_parse_messag... | [
"0.7287591",
"0.6997978",
"0.6995834",
"0.69918716",
"0.69918716",
"0.6922707",
"0.6887814",
"0.6799326",
"0.67842966",
"0.676754",
"0.6760229",
"0.67588294",
"0.6680338",
"0.66706926",
"0.66583735",
"0.6651172",
"0.66433084",
"0.6616395",
"0.66030884",
"0.6594346",
"0.657230... | 0.69325876 | 5 |
Send the data to the remote end of the connection asynchronously. | def send_data(data)
@impl.send_data data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_data(*args)\n EM.next_tick do\n @socket.send_data(*args)\n end\n end",
"def send(data)\r\n @connected.callback { send_data data }\r\n end",
"def send(data)\r\n @connected.callback { send_data data }\r\n end",
"def send_data(*args)\n EM.next_tick... | [
"0.66698295",
"0.6628655",
"0.6628655",
"0.6627564",
"0.6500473",
"0.6366982",
"0.63434035",
"0.62043387",
"0.6151476",
"0.6076242",
"0.6041061",
"0.6027718",
"0.6026118",
"0.60195225",
"0.60195225",
"0.59812474",
"0.5958997",
"0.59378445",
"0.5886627",
"0.5858122",
"0.585672... | 0.5897386 | 18 |
Creates a new AESPipe object with the given _options_. If a _block_ is given, it will be passed the newly created AESPipe object. _options_ may contain the following keys: :mode:: The mode of the cipher, either :encrypt or :decrypt. Defaults to :encrypt. :block_size:: The blocksize to use with the cipher. Defaults to 4096. :key_size:: The keysize of the cipher. Defaults to 256. :iv:: The Initial Vector (IV) to use with the cipher. Defaults to 19070547872603305. :hash:: The hash to use with the cipher. Defaults to SHA256. :key:: The key to use with the cipher. :password:: If :key is not given, :password can be given. The password will be hashed and used as the key. AESPipe.new(:mode => :encrypt, :password => 'pants') do |aes| aes.cipher do |cipher| aes.process_output(output_file) do |output| aes.process_input(input_file) do |text| output << cipher.update(text) end output << cipher.final end end end | def initialize(options={},&block)
@mode = options.fetch(:mode,:encrypt).to_sym
@block_size = options.fetch(:block_size,DEFAULT_BLOCK_SIZE).to_i
@key_size = options.fetch(:key_size,DEFAULT_KEY_SIZE).to_i
@iv = options.fetch(:iv,DEFAULT_IV).to_s
@hash = options.fetch(:hash,DEFAULT_HASH).to_s.downcase
@key = if options[:key]
options[:key].to_s
elsif (password = options[:password])
begin
Digest.const_get(@hash.upcase).hexdigest(password)
rescue RuntimeError => e
raise(InvalidHash,"invalid hash name #{@hash.dump}")
end
end
yield self if block_given?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cipher\n aes = OpenSSL::Cipher::Cipher.new(\"aes-#{@key_size}-cbc\")\n\n case @mode\n when :encrypt\n aes.encrypt\n when :decrypt\n aes.decrypt\n else\n raise(InvalidMode,\"invalid mode #{@mode}\")\n end\n\n aes.key = @key\n aes.iv = @iv\n\n yie... | [
"0.6165562",
"0.5306818",
"0.52144134",
"0.51730794",
"0.51517487",
"0.51302695",
"0.5126202",
"0.49991134",
"0.4973685",
"0.49599954",
"0.49546283",
"0.49170345",
"0.49100235",
"0.49000397",
"0.4895201",
"0.4837976",
"0.483294",
"0.4815814",
"0.47978482",
"0.47694778",
"0.47... | 0.64230424 | 0 |
Returns a new AES cipher object. If a _block_ is given it will be passed the newly created cipher. | def cipher
aes = OpenSSL::Cipher::Cipher.new("aes-#{@key_size}-cbc")
case @mode
when :encrypt
aes.encrypt
when :decrypt
aes.decrypt
else
raise(InvalidMode,"invalid mode #{@mode}")
end
aes.key = @key
aes.iv = @iv
yield aes if block_given?
return aes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cipher\r\n aes = OpenSSL::Cipher::AES.new(128, :CBC)\r\n aes.encrypt\r\n aes.key = key\r\n aes.iv = iv\r\n return aes\r\n end",
"def encrypt_with(name, &block)\n @encryptor = get_class_from_scope(Encryptor, name).new(&block)\n end",
"def get_cipher\n Ope... | [
"0.68026704",
"0.6411067",
"0.6362697",
"0.6215968",
"0.6100016",
"0.60487854",
"0.5936557",
"0.5882147",
"0.583795",
"0.5776261",
"0.5725184",
"0.57234573",
"0.56403446",
"0.56391084",
"0.5605318",
"0.5602889",
"0.5559221",
"0.5432213",
"0.53685135",
"0.53601974",
"0.5337855... | 0.7284387 | 0 |
Processes an input stream of the given _file_ and the specified _block_. If _file_ is not given +STDIN+ will be used instead. The specified _block_ will be passed each block of data from the stream. Once the _block_ has returned the input stream will be closed. | def process_input(file=nil)
input = if file
File.new(file.to_s)
else
STDIN
end
loop do
text = input.read(@block_size)
break unless text
yield text
end
input.close
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_input_stream(&block); end",
"def read_file(block=0)\n Rula.log(Logger::DEBUG,\"Reading file #{filename} block #{block}\",self)\n return nil if(block >= @file_size)\n return nil if(block < 0)\n file_handle = File.open(@filename,'rb')\n file_handle.pos = block\n @previous_bloc... | [
"0.64599484",
"0.62070936",
"0.60026777",
"0.5932396",
"0.5922345",
"0.5884504",
"0.5769879",
"0.57655627",
"0.57385254",
"0.5722197",
"0.56439584",
"0.55800575",
"0.5545476",
"0.54967123",
"0.54726946",
"0.5436581",
"0.540953",
"0.5375816",
"0.5365595",
"0.5356251",
"0.53208... | 0.73888326 | 0 |
Opens an output stream of the given _file_ and the specified _block_. If _file_ is not given +STDOUT+ will be used instead. The specified _block_ will be passed the newly opened output stream. Once the _block_ has returned the output stream will be flushed and closed. | def process_output(file=nil)
output = if file
File.new(file.to_s,'w')
else
STDOUT
end
yield output if block_given?
output.flush
output.close
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_output_file(&block)\r\n outfile = options[:outfile]\r\n if outfile\r\n File.open(outfile, 'w') { |f| block.call(f) }\r\n else\r\n block.call(STDOUT)\r\n end\r\n end",
"def output(file, &block)\n @outfile = File.expand_path(file)\n @block = block\n self\n end",
... | [
"0.7268191",
"0.65893984",
"0.60492516",
"0.5772207",
"0.57595426",
"0.5591552",
"0.54906857",
"0.5461353",
"0.54451644",
"0.5399881",
"0.5226066",
"0.5196414",
"0.51919144",
"0.5190104",
"0.51548654",
"0.5147926",
"0.5137622",
"0.49896684",
"0.4972093",
"0.4962156",
"0.49604... | 0.5548416 | 6 |
Only allow a list of trusted parameters through. | def score_params
params.require(:score).permit(:user_id, :time, :difficulty)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
input: string of items separated by spaces (example: "carrots apples cereal pizza") steps: call the method food_list set default quantity (quantity = 0) creat a hash, where key is item and value is quantity print the list to the console [can you use one of your other methods here?] use print method for this step output: [what data type goes here, array or hash?] hash, a list in the form of strings | def food_list
list = Hash.new
list ["carrots"] = 0
list ["apples"] = 0
list ["pizza"] = 0
list ["cereal"] = 0
list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_list(user_list)\n# input: string of items separated by spaces (example: \"carrots apples cereal pizza\")\n# puts \"\"\n# steps:\n # [fill in any steps here]\n list_array = user_list.split(\",\")\n # set default quantity\n quanity = 1\n # print the list to the console [can you use one of your other ... | [
"0.8018821",
"0.7789958",
"0.7782452",
"0.7751206",
"0.76809716",
"0.7590905",
"0.7558388",
"0.7521826",
"0.74911404",
"0.7400093",
"0.7395199",
"0.73887795",
"0.73873955",
"0.7338917",
"0.7330641",
"0.7198168",
"0.7170075",
"0.71476734",
"0.7140248",
"0.7133668",
"0.7127238"... | 0.0 | -1 |
Method to add an item to a list input: item name and optional quantity steps: create add_item method, add items to list output: new item with quantiy | def add_item(list, item, quant)
list[item] = quant
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend",
"def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend",
"def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend",
"def add_item(list, item_name, quantity)... | [
"0.8221033",
"0.8221033",
"0.8220495",
"0.8195609",
"0.8195609",
"0.8170519",
"0.8040089",
"0.80394185",
"0.80090946",
"0.79906535",
"0.79727846",
"0.79109496",
"0.788369",
"0.78822744",
"0.7871026",
"0.7856891",
"0.77859944",
"0.7764603",
"0.7728242",
"0.77267337",
"0.769046... | 0.0 | -1 |
p add_item("item", 1) Method to remove an item from the list input: item to delete steps: using hash delete method to remove an item output: new list without the items that were removed | def delete_item(list, item)
del_list = list.delete(item)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_item(my_list, item)\r\n# input: an item (something already in the list)\r\n# steps:\r\n my_list.delete(item)\r\n \r\n my_list\r\n# declare hash\r\n# delete method for item\r\n# output: hash with removed item\r\nend",
"def remove_item(new_list, item)\n \n new_list.delete(item)\n \n new_l... | [
"0.848525",
"0.8275207",
"0.82061034",
"0.81854343",
"0.81593275",
"0.81582993",
"0.81442285",
"0.8132168",
"0.81233776",
"0.80977386",
"0.80896837",
"0.8056447",
"0.8051242",
"0.8040771",
"0.80405915",
"0.80348045",
"0.80348045",
"0.80348045",
"0.80348045",
"0.8031067",
"0.8... | 0.7823024 | 64 |
Method to update the quantity of an item input: take new value for specified key steps: Input a value and assign that to the specified key output: item with new quantity | def update_quantity(list, item, quant)
list[item] = quant
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_item_quantity(hash_of_items, item, quantity)\n hash_of_items[item] = quantity\n hash_of_items\nend",
"def update_quantity (item, quantity)\n item_hash[item] = quantity\nend",
"def update_quantity(list, upd_item, new_quantity)\n# steps:\n # reassign key (item) a new value (quantity)\n list[upd_i... | [
"0.8285092",
"0.8272936",
"0.82564175",
"0.82188153",
"0.8082456",
"0.80262333",
"0.8025164",
"0.79247564",
"0.79122823",
"0.7903981",
"0.78727496",
"0.78636533",
"0.7854685",
"0.78466725",
"0.7846255",
"0.7839987",
"0.78146607",
"0.78135145",
"0.78080344",
"0.7803778",
"0.77... | 0.77860636 | 21 |
Method to print a list and make it look pretty input: list of hash we want to print steps: print keys as strings with corresponding value output: keys as strings and their quantity | def print_list(list)
list.each do |item, quantity| puts "#{item}: #{quantity}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pretty_list(hash)\r\n puts \"Grocery List:\"\r\n puts \" \"\r\n hash.each do |item_name, quantity|\r\n puts \"#{item_name}: #{quantity}\"\r\n end\r\nend",
"def print_list(my_list)\r\n# input: \r\n \r\n# steps:\r\n# print to screen: iterate through hash item - quantity\r\n puts '------'\r\n puts \"G... | [
"0.779294",
"0.77135444",
"0.7693041",
"0.7674169",
"0.75049746",
"0.7443091",
"0.74092066",
"0.7384402",
"0.7371843",
"0.7335432",
"0.73260117",
"0.7290909",
"0.7282052",
"0.7278292",
"0.7254332",
"0.7251003",
"0.7221183",
"0.7197294",
"0.7186273",
"0.7186273",
"0.7172586",
... | 0.67041886 | 52 |
Select instances by role, with optional name constraints. Select the "master" app instance: select_instances(app_master: true) Select the "master" db instance on a solo or multiinstance env: select_instances(solo: true, db_master: true) Select app, app_master, or utils (only if they are named resque or redis): select_instances(app_master: true, app: true, util: %w[resque redis]) Select all instances (same as the method instances): select_instances(all: true) See instances_by_role for a simpler interface. | def select_instances(options)
instances_by_role(options.keys).select do |inst|
# get the value of the string/symbol key that matches without losing nil/false values
val = options.fetch(inst.role.to_sym) { options.fetch(inst.role.to_s, false) }
case val
when true, false then val
when inst.name then true
when nil, '' then [nil, ''].include?(inst.name)
when Array then val.include?(inst.name)
else false
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instances_by_role(*roles)\n roles = roles.flatten.map(&:to_s)\n instances.select { |inst| roles.include?(inst.role.to_s) }\n end",
"def get_instances_by_role(group, role)\n get_instances(group).select do |instance|\n if not instance.tags['role'].nil? and instance.ready?\n in... | [
"0.6815968",
"0.6587964",
"0.62072724",
"0.60657895",
"0.5951953",
"0.5241145",
"0.5208313",
"0.51693743",
"0.5148964",
"0.514775",
"0.5121972",
"0.50967026",
"0.50681746",
"0.5068069",
"0.5065728",
"0.5056514",
"0.5054837",
"0.50277025",
"0.5013069",
"0.49788684",
"0.4978006... | 0.69315934 | 0 |
Simple version of select_instances that only selects roles, not names instances_by_role(:app_master, :app) same instances_by_role(%w[app_master app]) same select_instances(app_master: true, app: true) same | def instances_by_role(*roles)
roles = roles.flatten.map(&:to_s)
instances.select { |inst| roles.include?(inst.role.to_s) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_instances(options)\n instances_by_role(options.keys).select do |inst|\n # get the value of the string/symbol key that matches without losing nil/false values\n val = options.fetch(inst.role.to_sym) { options.fetch(inst.role.to_s, false) }\n\n case val\n when tr... | [
"0.7207731",
"0.6452275",
"0.60056883",
"0.5485831",
"0.54808927",
"0.54168063",
"0.51426065",
"0.50724375",
"0.5028341",
"0.50074726",
"0.5005638",
"0.5005568",
"0.49344948",
"0.4933732",
"0.49306875",
"0.49236944",
"0.48968926",
"0.48968926",
"0.48505467",
"0.48051736",
"0.... | 0.66395384 | 1 |
Throws a POST request at the API to /add_instances and adds one instance to this environment. Usage example: api = EY::CloudClient.new(token: 'your token here') env = api.environment_by_name('your_env_name') env.add_instance(role: "app") env.add_instance(role: "util", name: "foo") Note that the role for an instance MUST be either "app" or "util". No other value is acceptable. The "name" parameter can be anything, but it only applies to utility instances. Note also that if you add a util instance, you must specify a name. This method will raise if you don't. | def add_instance(opts)
unless %w[app util].include?(opts[:role].to_s)
# Fail immediately because we don't have valid arguments.
raise InvalidInstanceRole, "Instance role must be one of: app, util"
end
# Sanitize the name to remove whitespace if there is any
if opts[:name]
name = opts[:name].gsub(/\s+/, '')
end
if opts[:role] == 'util'
unless name && name.length > 0
raise InvalidInstanceName, "When specifying a util instance you must also specify a name."
end
end
request = { "role" => opts[:role], "name" => opts[:name] }
request['snapshot_id'] = opts[:snapshot_id] if opts.key?(:snapshot_id)
request['instance_size'] = opts[:instance_size] if opts.key?(:instance_size)
# We know opts[:role] is right, name can be passed straight to the API.
# Return the response body for error output, logging, etc.
return api.post("/environments/#{id}/add_instances", :request => request)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_instance(instance)\n register_response = client.register_instances_with_load_balancer(load_balancer_name: name,\n instances: [{instance_id: instance.ec2_instance_id}])\n remaining_instance_count = register_response.instances.si... | [
"0.5855038",
"0.56592315",
"0.5599796",
"0.5410954",
"0.54064155",
"0.5356072",
"0.5354687",
"0.5354005",
"0.5349306",
"0.5331099",
"0.5286285",
"0.5285621",
"0.5262432",
"0.525653",
"0.5237013",
"0.5153389",
"0.51446885",
"0.5136719",
"0.50980014",
"0.50849426",
"0.5069928",... | 0.74952036 | 0 |
Gets an instance's Amazon ID by its "id" attribute as reported by AWSM. When an instance is added via the API, the JSON that's returned contains an "id" attribute for that instance. Developers may save that ID so they can later discover an instance's Amazon ID. This is because, when an instance object is first created (see add_instance above), its Amazon ID isn't yet known. The object is created, and then later provisioned, so you can't get an Amazon ID until after provisioning has taken place. This method allows you to send an ID to it, and then returns the instance object that corresponds to that ID, which will have an Amazon ID with it if the instance has been provisioned at the time the environment information was read. Note that the ID passed in must be an integer. Usage example: api = EY::CloudClient.new(token: 'token') env = api.environment_by_name('my_env') env.instance_by_id(12345) => | def instance_by_id(id)
instances.detect { |x| x.id == id } # ID should always be unique
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookup_instance_id\n metadata_endpoint = 'http://169.254.169.254/latest/meta-data/'\n instance_id = Net::HTTP.get( URI.parse( metadata_endpoint + 'instance-id' ) )\n end",
"def get_instance_by_id(id)\n get_instances_description.select {|a| a.instance_id == id}[0] rescue nil\n end",
"de... | [
"0.7058864",
"0.6903498",
"0.6760356",
"0.6712818",
"0.65552324",
"0.6551474",
"0.64552534",
"0.64234865",
"0.64192617",
"0.64016587",
"0.6384004",
"0.6369302",
"0.62412006",
"0.61051005",
"0.60986656",
"0.60986656",
"0.6096984",
"0.60841715",
"0.6081782",
"0.6020195",
"0.596... | 0.6362426 | 12 |
Sends a request to the API to remove the instance specified by its "provisioned_id" (Amazon ID). Usage example: api = EY::CloudClient.new(token: 'token') env = api.environment_by_name('my_app_production') bad_instance = env.instance_by_id(12345) instance ID should be saved upon creation env.remove_instance(bad_instance) Warnings/caveats: + The API is responsible for actually removing this instance. All this does is send an appropriate request to the API. + You should look carefully at the API response JSON to see whether or not the API accepted or rejected your request. If it accepted the request, that instance should be removed as soon as possible. + Note that this is a client that talks to an API, which talks to an API, which talks to an API. Ultimately the IaaS provider API has the final say on whether or not to remove an instance, so a failure there can definitely affect how things work at every point down the line. + If the instance you pass in doesn't exist in the live cloud environment you're working on, the status should be rejected and thus the instance won't be removed (because that instance isn't there). This is important to keep in mind for scheduled/auto scaling; if for some reason the automatically added instance is removed before a "scale down" event that you might trigger, you may wind up with an unknown/unexpected number of instances in your environment. + Only works for app/util instances. Raises an error if you pass one that isn't valid. | def remove_instance(instance)
unless instance
raise ArgumentError, "A argument of type Instance was expected. Got #{instance.inspect}"
end
# Check to make sure that we have a valid instance role here first.
unless %w[app util].include?(instance.role)
raise InvalidInstanceRole, "Removing instances is only supported for app, util instances"
end
# Check to be sure that instance is actually provisioned
# TODO: Rip out the amazon_id stuff when we have IaaS agnosticism nailed down
unless instance.amazon_id && instance.provisioned?
raise InstanceNotProvisioned, "Instance is not provisioned or is in unusual state."
end
response = api.post("/environments/#{id}/remove_instances", :request => {
:provisioned_id => instance.amazon_id,
:role => instance.role,
:name => instance.name
})
# Reset instances so they are fresh if they are requested again.
@instances = nil
# Return the response.
return response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_instance(instance)\n deregister_response = client.deregister_instances_from_load_balancer(load_balancer_name: name,\n instances: [{instance_id: instance.ec2_instance_id}])\n remaining_instance_count = deregister_response... | [
"0.6574653",
"0.65076655",
"0.64812964",
"0.6419181",
"0.6399379",
"0.6380492",
"0.62758684",
"0.62361205",
"0.6062782",
"0.6051841",
"0.60133886",
"0.5980715",
"0.59735763",
"0.59555346",
"0.5934122",
"0.59037524",
"0.5877481",
"0.5844952",
"0.579769",
"0.5739661",
"0.573119... | 0.76562095 | 0 |
Creating an AppEnvironment will come back and call add_app_environment (above) to associate this model with the AppEnvironment. (that's why we don't save anything here.) | def set_apps(apps_attrs)
(apps_attrs || []).each do |app|
AppEnvironment.from_hash(api, {'app' => app, 'environment' => self})
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @environment = Environment.new(params[:environment])\n @environment.organization = current_user.organization\n @environment.user = current_user\n\n respond_to do |format|\n if @environment.save\n format.html { redirect_to @environment, notice: 'Instance record was successfully ... | [
"0.65256363",
"0.6304114",
"0.6261735",
"0.62174433",
"0.610232",
"0.59940475",
"0.5989094",
"0.5982823",
"0.588807",
"0.5872824",
"0.58559215",
"0.581713",
"0.57413065",
"0.5702332",
"0.5695882",
"0.56542456",
"0.5649217",
"0.56359166",
"0.5634262",
"0.5627825",
"0.55960923"... | 0.5359012 | 44 |
Get last weather update | def last_weather
weathers.last
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_updated\n self.dig_for_datetime(\"lastUpdateOn\")\n end",
"def last_update_at\n connection.get_metric_last_update_at(@id)\n end",
"def last_updated_time\n data[:last_updated_time]\n end",
"def current_weather_data\n get_weather[:currently]\n end",
"def last_updated\n\t\tupd... | [
"0.73394704",
"0.7171134",
"0.7029702",
"0.7011882",
"0.69019264",
"0.68487895",
"0.6818536",
"0.6809728",
"0.6807462",
"0.6783188",
"0.67661095",
"0.67661095",
"0.67661095",
"0.67661095",
"0.6732376",
"0.65903205",
"0.6580078",
"0.65748245",
"0.65702015",
"0.65686506",
"0.65... | 0.7867124 | 0 |
User get read access to device ( owner or public device) | def get_read_access( u)
return (u == self.user) || (self.public)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_allowed?(user)\n true\n end",
"def read_access_check\n resource_check('read')\n end",
"def read_access_check\n resource_check('read')\n end",
"def read_access_check\n resource_check('read')\n end",
"def permits_read_acccess_for(user)\n end",
... | [
"0.6786784",
"0.6721274",
"0.6721274",
"0.6721274",
"0.6633686",
"0.660852",
"0.6447477",
"0.6434396",
"0.64334863",
"0.6424191",
"0.6318311",
"0.61437434",
"0.6141246",
"0.6107873",
"0.6100798",
"0.6100798",
"0.6100798",
"0.6083467",
"0.6074477",
"0.6074477",
"0.6059687",
... | 0.7119225 | 0 |
def select_category_from_projects "SELECT category FROM projects;" end Make sure each ruby method returns a string containing a valid SQL statement. | def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name
'select p.title, sum(pl.amount) from projects p
LEFT JOIN pledges pl
where p.id = pl.project_id
group by p.title
order by p.title;'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_category_from_projects\n\"SELECT category FROM projects;\"\nend",
"def selects_the_category_names_and_pledge_amounts_of_all_pledges_in_the_music_category\n\"SELECT projects.category, pledges.amount\nFROM pledges\nINNER JOIN projects\nON projects.id = pledges.project_id\nWHERE projects.category = 'musi... | [
"0.9197428",
"0.70681554",
"0.69905895",
"0.6650687",
"0.6622008",
"0.65134215",
"0.6487074",
"0.63231736",
"0.60595876",
"0.59397984",
"0.5938012",
"0.59359765",
"0.59009475",
"0.58821595",
"0.58702105",
"0.58538514",
"0.5852772",
"0.58400726",
"0.58187836",
"0.5783952",
"0.... | 0.0 | -1 |
given a decimal amount, returns an array with coins for that amount | def make_change(amount)
amount = amount * 100
change = []
@currency.each do |key, value|
num_coins, amount = coins_per_amount(value, amount)
change << [key] * num_coins
end
change.flatten
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def changer(amount)\n\n coins = []\n\n [25, 10, 5, 1].each do |denomination|\n coins = amount / denomination\n returned_coins += [denomination] * coins\n amount -= coins * denomination\n end\n returned_coins\nend",
"def coinConverter(num, coins)\n coinArray = []\n\n coins.each do |coin|\n while... | [
"0.73457354",
"0.6974007",
"0.6707121",
"0.659889",
"0.65441865",
"0.6542102",
"0.6515395",
"0.6466573",
"0.64550436",
"0.64414227",
"0.6422158",
"0.64182836",
"0.6365127",
"0.63566446",
"0.6352055",
"0.6340109",
"0.63165",
"0.6303894",
"0.6264675",
"0.62573713",
"0.62111396"... | 0.6947926 | 2 |
GET /album_genres/1 GET /album_genres/1.json | def show
@album_genre = AlbumGenre.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @album_genre }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @song_genre = SongGenre.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @song_genre }\n end\n end",
"def album\n album = Album.find(params[:id])\n render json: album\n end",
"def index\n @pictures = @album.pictures... | [
"0.7151078",
"0.7113311",
"0.6989473",
"0.68686765",
"0.6833885",
"0.6801455",
"0.6775186",
"0.67685854",
"0.67642325",
"0.6763039",
"0.6731936",
"0.66824716",
"0.6646332",
"0.66308904",
"0.65979886",
"0.65918297",
"0.6586351",
"0.6584316",
"0.6570412",
"0.65621275",
"0.65616... | 0.7639327 | 0 |
GET /album_genres/new GET /album_genres/new.json | def new
@album_genre = AlbumGenre.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @album_genre }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end",
"def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end"... | [
"0.7584945",
"0.7584945",
"0.7580584",
"0.7531309",
"0.7515149",
"0.7432592",
"0.74296856",
"0.7324332",
"0.7315353",
"0.73125166",
"0.7295713",
"0.72591764",
"0.7183082",
"0.7149219",
"0.7142825",
"0.71232575",
"0.7122416",
"0.7118146",
"0.71158403",
"0.7112992",
"0.70868117... | 0.7940656 | 0 |
POST /album_genres POST /album_genres.json | def create
@album_genre = AlbumGenre.new(params[:album_genre])
respond_to do |format|
if @album_genre.save
format.html { redirect_to @album_genre, notice: 'Album genre was successfully created.' }
format.json { render json: @album_genre, status: :created, location: @album_genre }
else
format.html { render action: "new" }
format.json { render json: @album_genre.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updategenres\n @album = Album.find(params[:id])\n album_param = params[:albums] \n album_param[:genres].each do |genre_id|\n genre = Genre.find(genre_id)\n @album.genres << genre \n end \n respond_to do |format|\n format.html { redirect_to(@album) }\n f... | [
"0.71542436",
"0.6566338",
"0.6526033",
"0.6405078",
"0.64028573",
"0.63616914",
"0.6355944",
"0.63066816",
"0.6290948",
"0.62879986",
"0.62090665",
"0.62071955",
"0.62071955",
"0.62071955",
"0.62004757",
"0.6187991",
"0.61867565",
"0.6170445",
"0.6166137",
"0.6166137",
"0.61... | 0.70034546 | 1 |
PUT /album_genres/1 PUT /album_genres/1.json | def update
@album_genre = AlbumGenre.find(params[:id])
respond_to do |format|
if @album_genre.update_attributes(params[:album_genre])
format.html { redirect_to @album_genre, notice: 'Album genre was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @album_genre.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updategenres\n @album = Album.find(params[:id])\n album_param = params[:albums] \n album_param[:genres].each do |genre_id|\n genre = Genre.find(genre_id)\n @album.genres << genre \n end \n respond_to do |format|\n format.html { redirect_to(@album) }\n f... | [
"0.7517497",
"0.6779685",
"0.6500512",
"0.64261913",
"0.6375227",
"0.6329442",
"0.630047",
"0.6285673",
"0.62521976",
"0.62448126",
"0.6172432",
"0.61572176",
"0.61572176",
"0.61572176",
"0.6157158",
"0.61494976",
"0.6118786",
"0.6111482",
"0.6111482",
"0.6111482",
"0.6111482... | 0.6718243 | 2 |
DELETE /album_genres/1 DELETE /album_genres/1.json | def destroy
@album_genre = AlbumGenre.find(params[:id])
@album_genre.destroy
respond_to do |format|
format.html { redirect_to album_genres_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @album.destroy\n render json: @album\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @album.destroy\n\n respond_... | [
"0.7602658",
"0.7382387",
"0.7377284",
"0.736904",
"0.736904",
"0.736904",
"0.736904",
"0.736904",
"0.7354127",
"0.7354127",
"0.7354127",
"0.73396933",
"0.731502",
"0.7314097",
"0.7297047",
"0.72846013",
"0.7272589",
"0.7244382",
"0.7243497",
"0.72404754",
"0.7213964",
"0.7... | 0.7826642 | 0 |
crear un metodo initialize que inicialice las variables de instancia "revenue" y "costs" a cero | def initialize
@revenue = 0
@costs = 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(discount = 0) #new optionally takes an employee discount on initialization\n @total = 0 #SETS AN INSTANCE VARIABLE @TOTAL ON INITIALIZATION TO ZERO\n @discount = discount # CashRegister ::new optionally takes an employee discount on initialization\n @items = [] #returns an array contain... | [
"0.69509363",
"0.69056004",
"0.6743452",
"0.67419595",
"0.66899025",
"0.6654327",
"0.6624689",
"0.6618325",
"0.64908767",
"0.6467",
"0.6452923",
"0.6414348",
"0.6412228",
"0.640696",
"0.6346843",
"0.6342039",
"0.6328918",
"0.6324803",
"0.63179314",
"0.63158774",
"0.631197",
... | 0.8083272 | 0 |
crear un metodo "credit" que reciba un parametro "amount" y se lo sume a la variable de instancia "revenue" | def credit(amount)
@revenue += amount
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def credit(postive_amount)\n Credit.create!(team: team,\n room_type: room_type,\n amount: postive_amount)\n end",
"def credit *args\n warn_on_positional args\n\n options = args.last.is_a?(Hash) ? args.pop : {}\n amount = args[0] || options.fetch(:amount) { n... | [
"0.70318425",
"0.6715307",
"0.6713559",
"0.6667777",
"0.664224",
"0.6625338",
"0.66235304",
"0.6605122",
"0.6574353",
"0.6569881",
"0.6449399",
"0.6412946",
"0.64040864",
"0.63758034",
"0.6359669",
"0.63437325",
"0.63192797",
"0.63162225",
"0.622324",
"0.62189704",
"0.6201884... | 0.74697095 | 0 |
include ActiveMerchant::Billing::Integrations require 'crypto42' require 'money' GET /users GET /users.xml | def index
@users = User.find(:all, :conditions => ["company = ?", session[:company].id])
p 'users index'; y session #debug
@thiscompany = Company.find(session[:company_id])
puts "\n\n\n @thiscompany.id = " + @thiscompany.id.to_s ##debug
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @users }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merchant_end_point; end",
"def billing\n request('billing', :get)\n end",
"def merchant_endpoint; end",
"def billing\n user_agent = request.env['HTTP_USER_AGENT']\n billing_request_body = Billing.request_body(@session)\n parameter = Parameter.first\n\n request = Typhoeus::Request.new(... | [
"0.6329442",
"0.6167065",
"0.6106312",
"0.60678077",
"0.59957707",
"0.59438646",
"0.5920874",
"0.5914747",
"0.58899504",
"0.5880816",
"0.58687776",
"0.58658886",
"0.58092993",
"0.5776161",
"0.57417345",
"0.57306224",
"0.571197",
"0.57082313",
"0.5689404",
"0.56693846",
"0.566... | 0.0 | -1 |
GET /users/1 GET /users/1.xml | def show
# puts "\n\n\n DEBUG: @thiscompany.id = " + @thiscompany.id.to_s ##debug
@user = User.find(params[:id])
y session #debug
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @user }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @users = LinkedData::Client::Models::User.all\n respond_to do |format|\n format.html\n format.xml { render xml: @users.to_xml }\n end\n end",
"def me\n users(request(\"users/authenticate.xml\", :auth => true))\n end",
"def index\n @users = User.all\n render :xml ... | [
"0.7207758",
"0.71160614",
"0.7054628",
"0.70484746",
"0.6916555",
"0.6916146",
"0.6915502",
"0.6890011",
"0.68641984",
"0.68633956",
"0.6853434",
"0.68511736",
"0.68511736",
"0.68511736",
"0.6828291",
"0.68280435",
"0.68278646",
"0.68065727",
"0.6801009",
"0.6786165",
"0.676... | 0.0 | -1 |
GET /users/new GET /users/new.xml | def new
@user = User.new
@user.credits = 0 ## Stop form from complaining that "credits" is not a number.
@thiscompany = session[:company]
puts "\n\n\n @thiscompany.id = " + @thiscompany.id.to_s ##debug
y session #debug
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @user }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n logger.debug(\"Create a new user\")\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.xml { render xml: @user}\n end\n end"... | [
"0.77330446",
"0.7697235",
"0.7628986",
"0.75933844",
"0.7592385",
"0.75490505",
"0.7536828",
"0.7530958",
"0.7530958",
"0.7508645",
"0.7508645",
"0.7508645",
"0.7508645",
"0.7508645",
"0.7508645",
"0.7508645",
"0.7508645",
"0.7508645",
"0.7508645",
"0.7508645",
"0.7508645",
... | 0.0 | -1 |
POST /users POST /users.xml | def create
@user = User.new(params[:user])
@thiscompany = Company.find(session[:company_id])
puts "\n\n\n @thiscompany.id = " + @thiscompany.id.to_s ##debug
y session #debug
respond_to do |format|
if @user.save
flash[:notice] = 'User was successfully created.'
format.html { redirect_to(@user) }
format.xml { render :xml => @user, :status => :created, :location => @user }
else
format.html { render :action => "new" }
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end",
"def post body=nil, headers={}\n @connection.post \"users.json\", body, headers\n end",
"def CreateUser params = {}\n \n ... | [
"0.71678036",
"0.6338476",
"0.6224363",
"0.61548346",
"0.6088076",
"0.6079892",
"0.60536397",
"0.60094374",
"0.5940851",
"0.59352076",
"0.59313804",
"0.59236705",
"0.59006655",
"0.58788294",
"0.5857175",
"0.58492076",
"0.58427423",
"0.58262956",
"0.58248377",
"0.5821217",
"0.... | 0.0 | -1 |
PUT /users/1 PUT /users/1.xml | def update
@user = User.find(params[:id])
# puts "\n\n\n @thiscompany.id = " + @thiscompany.id.to_s ##debug
y session #debug
respond_to do |format|
if @user.update_attributes(params[:user])
flash[:notice] = 'User was successfully updated.'
format.html { redirect_to(@user) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @user = V1::User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = 'V1::User was successfully updated.'\n format.html { redirect_to(@user) }\n format.xml { head :ok }\n else\n format.html { render :a... | [
"0.66364235",
"0.6546457",
"0.63642347",
"0.62584895",
"0.62213796",
"0.6219046",
"0.6173277",
"0.61331743",
"0.6132418",
"0.6126342",
"0.61099374",
"0.6105844",
"0.61055833",
"0.6056526",
"0.603532",
"0.60333353",
"0.60158837",
"0.6012399",
"0.60051805",
"0.59823406",
"0.598... | 0.0 | -1 |
DELETE /users/1 DELETE /users/1.xml | def destroy
@user = User.find(params[:id])
@user.destroy
respond_to do |format|
format.html { redirect_to(users_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n @user = User.find(params[:id])\n @user.rvsps.delete_all()\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.xml { head :ok }\n end\n end",
"def delete_users\n delete(users_path)\n end",
"def destroy\n @user = ... | [
"0.7177572",
"0.7172003",
"0.70611066",
"0.70607454",
"0.7031703",
"0.70033735",
"0.69609874",
"0.68964374",
"0.68964374",
"0.68916017",
"0.68899393",
"0.68882316",
"0.6878408",
"0.6876417",
"0.68727493",
"0.6872259",
"0.6872259",
"0.6872259",
"0.686118",
"0.6858945",
"0.6841... | 0.6912414 | 48 |
These methods are to be called via RubyAMF only (params[0][:whatever]) | def chargecredit
@user = User.find_by_username(params[0][:username])
user=User.authenticate(params[0][:username],params[0][:password])
if user
# make sure we charge at least 1 credit
if params[0][:module_cost] < 1
params[0][:module_cost] = 1
end
@user.credits -= params[0][:module_cost]
if @user.save
render :amf => { :id => @user.id,
:firstname => @user.firstname,
:lastname => @user.lastname,
:credits => @user.credits,
:company => @user.company
}
@userhistory=UserHistory.new
@userhistory.userid =user.id
@userhistory.module =params[0][:module]
@userhistory.credits_spent =params[0][:module_cost]
@userhistory.credits_remaining =@user.credits
@userhistory.save
else
render :amf => "Not enough credits to complete transaction"
end
else
render :amf => "Login Failed"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"... | [
"0.70036066",
"0.70036066",
"0.70036066",
"0.70036066",
"0.70036066",
"0.70036066",
"0.70036066",
"0.70036066",
"0.70036066",
"0.70036066",
"0.70036066",
"0.70036066",
"0.70036066",
"0.70036066",
"0.70036066",
"0.70036066",
"0.70036066",
"0.6961356",
"0.6961356",
"0.6866602",
... | 0.0 | -1 |
has many clients through appointments | def clients
Appointments.all.collect do |appointment|
appointment.client
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def client_appointments\n self.clients.map(&:appointments)\n end",
"def create\n # Create new client object, with nested appointment object\n @client = Client.new(client_params)\n # Set the new appointment's user_id equal to the current_user's id. This completes the association\n # between the c... | [
"0.76485354",
"0.68745774",
"0.66267776",
"0.65794945",
"0.654963",
"0.650973",
"0.6493033",
"0.6463341",
"0.6451692",
"0.64151096",
"0.64056396",
"0.638461",
"0.638461",
"0.63814384",
"0.6379531",
"0.63785684",
"0.63550484",
"0.63399714",
"0.63325363",
"0.63052034",
"0.62588... | 0.74405485 | 1 |
The root frame maintains a cache of inflected element names. | def inflect element_name
@inflected[element_name] ||= Inflection.ruby_name(element_name).to_sym
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def naming_context\n @naming_context ||= blank_context(:this => self) do\n def method_missing(sym, *args)\n @this.element_names[sym] = *args\n end\n end\n end",
"def element_names\n @element_names ||= { }\n end",
"def element_root\n name.demodulize.underscore.... | [
"0.6115307",
"0.5649695",
"0.5585458",
"0.5366385",
"0.5331974",
"0.52540797",
"0.5131589",
"0.51292133",
"0.5065743",
"0.5063234",
"0.50502616",
"0.5047234",
"0.49618095",
"0.4950259",
"0.49476597",
"0.49397922",
"0.4916368",
"0.4910693",
"0.49059927",
"0.4901552",
"0.485807... | 0.53718483 | 3 |
recursively crawls the parser rules and looks for elements that index values. Adds an empty index for each of these. | def setup_indexes rules
if rules[:children]
rules[:children].each_pair do |child_name,child_rules|
if index = child_rules[:index]
@indexes[index[:name]] = {}
end
setup_indexes(child_rules)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match parser, index\r\n raise \"no children added to sequence\" unless @list\r\n each do |element|\r\n index = element.match parser, index\r\n return NO_MATCH unless index\r\n end\r\n report index\r\n end",
"def first_nil_parse_index_assert\n idx = @children.index{... | [
"0.60973424",
"0.56917083",
"0.54896015",
"0.54325575",
"0.5408188",
"0.5391383",
"0.51944095",
"0.51584613",
"0.51584613",
"0.51584613",
"0.51584613",
"0.5144807",
"0.5136883",
"0.5091499",
"0.5091499",
"0.5091499",
"0.5091499",
"0.50706524",
"0.5065484",
"0.50407165",
"0.50... | 0.67908156 | 0 |
GT guia de tranporte lista todos los estado de GT en un select | def get_list_state
TransportGuideState.get_list_guide_state
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_tiporelacion\n [ \n [\"BENEFICIARIO\",\"BENEFICIARIO\"],\n [\"INTEGRANTE\",\"INTEGRANTE\"],\n [\"PROPIETARIO\",\"PROPIETARIO\"],\n [\"APODERADO\",\"APODERADO\"]\n ] \n end",
"def envia_taxones_seleccionados\n end",
"def selected_options; end",
"def selected_options; ... | [
"0.63645893",
"0.6325184",
"0.59422565",
"0.59422565",
"0.5866912",
"0.5832182",
"0.5787936",
"0.56868905",
"0.5631731",
"0.5596491",
"0.55846053",
"0.5493009",
"0.5490691",
"0.54853266",
"0.54208004",
"0.5347446",
"0.5342118",
"0.5326624",
"0.53191257",
"0.5318892",
"0.53046... | 0.0 | -1 |
lista todos las ciudades disponibles en un select | def get_list_cities
City.get_all_cities
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @selecionados = Selecionado.all\n end",
"def index\n @coleccion = Caracteristica.all\n end",
"def select_list; end",
"def set_collection_select\n @facultades = Facultad.all\n @programas = Programa.all\n @grupos = Grupo.all\n @semilleros = Semillero.all\n @investig... | [
"0.6396304",
"0.63183856",
"0.6278303",
"0.61796707",
"0.61702967",
"0.6152788",
"0.6144997",
"0.61194223",
"0.61095107",
"0.6108852",
"0.6096879",
"0.60926783",
"0.6042244",
"0.5979015",
"0.5973464",
"0.5929909",
"0.59114",
"0.58922",
"0.58922",
"0.5885817",
"0.5881717",
"... | 0.0 | -1 |
lista todos los tipo de servicios disponibles en un select | def get_list_service_types
ServiceType.get_list_service_types
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_service_types()\n types = []\n @client.services.each do |type|\n types << type.label\n end\n\n types\n end",
"def get_service_types\n if @servicetypes.any?\n @servicetypes.flat_map(&:servicetype).compact\n elsif @servicetype\n [@servicetype]\n else\n ... | [
"0.68860745",
"0.6843919",
"0.67053306",
"0.6339248",
"0.61899334",
"0.6172209",
"0.6148775",
"0.61228436",
"0.60997295",
"0.60421866",
"0.60223836",
"0.6022306",
"0.6009809",
"0.6005978",
"0.598768",
"0.5978137",
"0.5886875",
"0.5878637",
"0.5790964",
"0.5789346",
"0.5788618... | 0.6650234 | 3 |
lista todos las formas de pagos disponibles en un select | def get_list_payments_methods
PaymentMethod.get_list_payment_methods
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @formularios = Formulario.search\n @select_options = Formulario.get_name_folder\n end",
"def index\n @formasdepagos = current_user.empresa.formasdepagos.page params[:page]\n end",
"def index\n @option_types = OptionType.page params[:page]\n end",
"def forms_fields(form, action)\n ... | [
"0.70502144",
"0.65846807",
"0.62755746",
"0.62076336",
"0.60679555",
"0.5987666",
"0.59851193",
"0.59438115",
"0.5889661",
"0.58763105",
"0.58543265",
"0.5821864",
"0.5809577",
"0.5808571",
"0.58028024",
"0.579181",
"0.5764639",
"0.5684009",
"0.5683008",
"0.5647019",
"0.5622... | 0.0 | -1 |
combo_changed event handlers for composite foreign key: carton_pack_type_id combo_changed event handlers for composite foreign key: basic_pack_id search combo_changed event handlers for the unique index on this table(carton_pack_products) | def carton_pack_product_type_code_search_combo_changed
type_code = get_selected_combo_value(params)
session[:carton_pack_product_search_form][:type_code_combo_selection] = type_code
@basic_pack_codes = CartonPackProduct.find_by_sql("Select distinct basic_pack_code from carton_pack_products where type_code = '#{type_code}'").map{|g|[g.basic_pack_code]}
@basic_pack_codes.unshift("<empty>")
# render (inline) the html to replace the contents of the td that contains the dropdown
render :inline => %{
<%= select('carton_pack_product','basic_pack_code',@basic_pack_codes)%>
<img src = '/images/spinner.gif' style = 'display:none;' id = 'img_carton_pack_product_basic_pack_code'/>
<%= observe_field('carton_pack_product_basic_pack_code',:update => 'carton_pack_style_code_cell',:url => {:action => session[:carton_pack_product_search_form][:basic_pack_code_observer][:remote_method]},:loading => "show_element('img_carton_pack_product_basic_pack_code');",:complete => session[:carton_pack_product_search_form][:basic_pack_code_observer][:on_completed_js])%>
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fg_product_item_pack_product_code_search_combo_changed\n\titem_pack_product_code = get_selected_combo_value(params)\n\tsession[:fg_product_search_form][:item_pack_product_code_combo_selection] = item_pack_product_code\n\t@unit_pack_product_codes = FgProduct.find_by_sql(\"Select distinct unit_pack_product_code ... | [
"0.62615204",
"0.61642337",
"0.6071932",
"0.6042467",
"0.60266316",
"0.60185677",
"0.59009135",
"0.58595985",
"0.57825226",
"0.5760937",
"0.56612283",
"0.56465",
"0.55218667",
"0.5261049",
"0.5147732",
"0.5133886",
"0.5129493",
"0.51280886",
"0.51261866",
"0.51144844",
"0.509... | 0.6645778 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.