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 |
|---|---|---|---|---|---|---|
foursquare rating box logic | def ratings_box(rating)
if rating < 7
color_class = "neutral"
elsif rating >= 7
color_class = "positive"
else
color_class = "neutral"
end
return color_class
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rate\n @box = Box.find(params[:id])\n raise CanCan::AccessDenied unless @box.ordered_by?(current_user)\n @box.update_attributes(params[:box])\n\n flash[:alert] = \"You must provide a rating between 1 and 5\" if params[:box][:rating].blank?\n respond_to do |format|\n if @box.save\n fo... | [
"0.6161557",
"0.61300653",
"0.61072016",
"0.6103325",
"0.6010686",
"0.59859186",
"0.5971162",
"0.59310514",
"0.5904524",
"0.5887436",
"0.5884547",
"0.58781266",
"0.58492756",
"0.5839662",
"0.58066607",
"0.5798203",
"0.57625365",
"0.57581645",
"0.5745872",
"0.57446146",
"0.573... | 0.64562595 | 0 |
GET /supplier_masters GET /supplier_masters.json | def index
#@supplier_masters = SupplierMaster.all
#@supplier_csv = SupplierMaster.all
@q = SupplierMaster.ransack(params[:q])
@supplier_masters = @q.result(distinct: true)
#kaminari用設定
@supplier_masters = @supplier_masters.page(params[:page])
respond_to do |format|
format.html
#csv
format.csv { send_data @supplier_masters.to_csv.encode("SJIS"), type: 'text/csv; charset=shift_jis', disposition: 'attachment' }
#format.csv { send_data SupplierMaster.all.to_csv }
#format.csv do |csv|
# send_posts_csv(@supplier_masters)
#end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @admin_supplier = Admin::Supplier.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_supplier }\n end\n end",
"def show\n @supplier = Supplier.find(params[:id])\n @products = Product.where(:supplier_id => @supplier.i... | [
"0.68183845",
"0.6640195",
"0.6465979",
"0.63195306",
"0.6284423",
"0.62250984",
"0.6212345",
"0.6182546",
"0.6161898",
"0.6129563",
"0.61180216",
"0.60934776",
"0.6080755",
"0.6073286",
"0.60680735",
"0.5998802",
"0.5995027",
"0.59942764",
"0.598485",
"0.5966439",
"0.5957306... | 0.0 | -1 |
GET /supplier_masters/1 GET /supplier_masters/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @admin_supplier = Admin::Supplier.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_supplier }\n end\n end",
"def show\n @supplier = Supplier.find(params[:id])\n @products = Product.where(:supplier_id => @supplier.i... | [
"0.7118339",
"0.68265545",
"0.6762083",
"0.66440016",
"0.65221953",
"0.6493152",
"0.63818896",
"0.6356139",
"0.63292724",
"0.62973964",
"0.62781864",
"0.627286",
"0.62298286",
"0.62148064",
"0.6189538",
"0.61480963",
"0.6145738",
"0.6136858",
"0.61287177",
"0.61287177",
"0.60... | 0.0 | -1 |
POST /supplier_masters POST /supplier_masters.json | def create
#頭文字を必ず半角小文字にする
set_character
@supplier_master = SupplierMaster.new(supplier_master_params)
respond_to do |format|
if @supplier_master.save
format.html { redirect_to @supplier_master, notice: 'Supplier master was successfully created.' }
format.json { render :show, status: :created, location: @supplier_master }
else
format.html { render :new }
format.json { render json: @supplier_master.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @admin_supplier = Admin::Supplier.new(params[:admin_supplier])\n\n respond_to do |format|\n if @admin_supplier.save\n format.html { redirect_to admin_suppliers_url }\n format.json { render json: @admin_supplier, status: :created, location: @admin_supplier }\n else\n ... | [
"0.66188806",
"0.6475608",
"0.64097273",
"0.6397332",
"0.63916796",
"0.63815206",
"0.6375472",
"0.6294127",
"0.6185181",
"0.61835027",
"0.61546814",
"0.61484957",
"0.61364925",
"0.6098042",
"0.60945195",
"0.6060897",
"0.60316825",
"0.60047674",
"0.59947777",
"0.59413743",
"0.... | 0.6887887 | 0 |
PATCH/PUT /supplier_masters/1 PATCH/PUT /supplier_masters/1.json | def update
#頭文字を必ず半角小文字にする
set_character
respond_to do |format|
if @supplier_master.update(supplier_master_params)
format.html { redirect_to @supplier_master, notice: 'Supplier master was successfully updated.' }
format.json { render :show, status: :ok, location: @supplier_master }
else
format.html { render :edit }
format.json { render json: @supplier_master.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @admin_supplier = Admin::Supplier.find(params[:id])\n\n respond_to do |format|\n if @admin_supplier.update_attributes(params[:admin_supplier])\n format.html { redirect_to admin_suppliers_url }\n format.json { head :ok }\n else\n format.html { render action: \"edit\... | [
"0.69393164",
"0.6762187",
"0.6725533",
"0.6639218",
"0.6634355",
"0.6633665",
"0.6620968",
"0.66074544",
"0.6584802",
"0.6542399",
"0.6489756",
"0.6441471",
"0.64382446",
"0.6414385",
"0.6413657",
"0.6404434",
"0.63794464",
"0.6359535",
"0.63330346",
"0.63318413",
"0.6311009... | 0.6887264 | 1 |
DELETE /supplier_masters/1 DELETE /supplier_masters/1.json | def destroy
@supplier_master.destroy
respond_to do |format|
format.html { redirect_to supplier_masters_url, notice: 'Supplier master was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @admin_supplier = Admin::Supplier.find(params[:id])\n @admin_supplier.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_suppliers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @supplier.destroy\n respond_to do |format|\n format.ht... | [
"0.74254036",
"0.73449683",
"0.7329608",
"0.73287225",
"0.72377294",
"0.7123171",
"0.7120199",
"0.7120199",
"0.7120199",
"0.7100528",
"0.7055111",
"0.70475316",
"0.70472324",
"0.70455444",
"0.7038388",
"0.70336926",
"0.70328104",
"0.69218737",
"0.6920298",
"0.6908051",
"0.690... | 0.7725363 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_supplier_master
@supplier_master = SupplierMaster.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 supplier_master_params
params.require(:supplier_master).permit(:supplier_name, :tel_main, :fax_main, :email_main, :responsible1, :email1,
:responsible2, :email2, :responsible3, :email3, :responsible_cc, :email_cc,
:search_character, :outsourcing_flag,
supplier_responsibles_attributes: [:id, :responsible_name, :responsible_email, :_destroy])
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 |
Creates a new user object based on user events | def initialize(username, client)
@client = client
@user = @client.user(username)
@repos = @client.repos(username)
@repos.sort!{|a, b| b.watchers_count <=> a.watchers_count }
process_events @client.user_public_events(username)
language_dist
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_member(events)\n update_object(\n object: new_user,\n user: new_user,\n events: events\n )\n self\n end",
"def create_user\n # provide the interface asking for name, destination and duration\n # then, create and store the User object\n end",
"def create_... | [
"0.7493802",
"0.74165267",
"0.71716726",
"0.7032873",
"0.6869928",
"0.6809527",
"0.67663896",
"0.67122203",
"0.67042667",
"0.66647017",
"0.66436785",
"0.66373384",
"0.6628219",
"0.6626338",
"0.66187465",
"0.661682",
"0.66153115",
"0.6603946",
"0.6587539",
"0.6587298",
"0.6586... | 0.0 | -1 |
Processes the events so that the data is useful to us | def process_events events
@events = Hash.new
# Organize the event based on type
# http://developer.github.com/v3/activity/events/types/ lists event types.
events.each do |event|
@events[event.type] ||= Array.new
@events[event.type] << event
end
@event_types = Hash.new
@events.each do |key,value|
@event_types[key.underscore.humanize.sub(' event', '')] = value.count
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_events(events)\n process_join events['join'] if events.key? 'join'\n process_invite events['invite'] if events.key? 'invite'\n process_leave events['leave'] if events.key? 'leave'\n end",
"def process\n read_events.each {|event| event.callback!}\n end",
"def process_events... | [
"0.73804414",
"0.7070437",
"0.7068625",
"0.70475924",
"0.7020023",
"0.7017573",
"0.69902825",
"0.6943878",
"0.68698585",
"0.68462956",
"0.66678953",
"0.6599833",
"0.6507224",
"0.6507224",
"0.6507224",
"0.6507224",
"0.6507224",
"0.6507224",
"0.6507224",
"0.6507224",
"0.6502744... | 0.6630235 | 11 |
Goes through the languages and makes a hash of how many repos you have per language | def language_dist
@languages = Hash.new(0)
@repos.each do |repo|
@languages[repo.language] += 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repos_languages_data(git_user)\n allRepos = []\n github = Github.new oauth_token: current_employee.github_account.oauth_token\n myRepos = github.repos.list user: git_user\n myRepos.each do |repo|\n repo_languages = github.repos.languages git_user, repo.name\n repoHash = repo_languages.to_... | [
"0.6502187",
"0.6162625",
"0.5820105",
"0.575544",
"0.5712312",
"0.56802523",
"0.5638903",
"0.55461115",
"0.55296373",
"0.5501927",
"0.5450402",
"0.54488",
"0.5440772",
"0.5439813",
"0.5437691",
"0.5399399",
"0.5398798",
"0.5398534",
"0.53971654",
"0.53971654",
"0.5326791",
... | 0.8037993 | 0 |
Runs the java_home command line tool which on osx will return the appropriate JAVA_home value | def run_java_home
`/usr/libexec/java_home`.to_s.strip
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home\n Buildr.application.deprecated 'Use ENV[\\'JAVA_HOME\\'] instead.'\n ENV['JAVA_HOME']\n end",
"def jruby_home\n ENV['JRUBY_HOME'] || RbConfig::CONFIG['prefix']\n end",
"def test_to_bash_replaces_user_home_with_home_environment_variable\n path = Pathname.new( '~/Developer/SDKs'... | [
"0.70461565",
"0.6969667",
"0.6681079",
"0.62325156",
"0.6164963",
"0.6076714",
"0.6007072",
"0.5915261",
"0.5898525",
"0.588754",
"0.5819812",
"0.5778084",
"0.57587224",
"0.5749723",
"0.5749723",
"0.5749402",
"0.5732678",
"0.5666614",
"0.5665492",
"0.5656333",
"0.5649327",
... | 0.81322443 | 0 |
Logic to generate table starts | def table(b, rain_fall_type, _year, ji, compare,legend)
dataset = rain_fall_type.tr('_', ' ')
if rain_fall_type == "#{rain_fall_type}"
hash_data = ji.map do |el|
# if el.to_s == legend
# { title: legend.tr('_', ' '), field: el, headerFilter: true }
# else
# { title: el.to_s.tr('_', ' '), field: el }
# end
{ title: legend.tr('_', ' '), field: el, headerFilter: true }
{ title: el.to_s.tr('_', ' '), field: el, headerFilter: true }
end
else
if compare == 'None'
hash_data = [
{ title: legend.tr('_', ' '), field: legend, headerFilter: true },
{ title: dataset, field: rain_fall_type, headerFilter: true }
]
else
hash_data = [
# {title:compare, field:compare, sorter:"string", },
{ title: legend.tr('_', ' '), field: legend, headerFilter: true },
{ title: dataset, field: rain_fall_type, headerFilter: true }
]
end
end
data = { column: hash_data, data: b }
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_table\r\n n = @char_set.length\r\n t_size = @size\r\n create_table(@char_set, '', n, t_size)\r\n end",
"def generate_tables\n create_characters\n create_kiosks\n create_traps\n create_buttons\n end",
"def table; end",
"def table; end",
"def table; end",
"def table; end",
... | [
"0.6995863",
"0.68878084",
"0.66851234",
"0.66851234",
"0.66851234",
"0.66851234",
"0.6605943",
"0.65431625",
"0.64985347",
"0.6479457",
"0.6448799",
"0.6441871",
"0.643573",
"0.6410358",
"0.63848144",
"0.6340555",
"0.6325655",
"0.6170707",
"0.6126838",
"0.61127084",
"0.60856... | 0.0 | -1 |
The before_action invokes the private method find_post to ensure that we are creating a comment on the porper corresponding post | def index
@comments = @post.comments.order("created_at ASC")
respond_to do |format|
format.html { render layout: !request.xhr? }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def for_post\n @post = Post.find(params[:post_id])\n @comments = @post.comments\n @comment = @post.comments.new(user_id: current_user.id)\n end",
"def can_create_comment?(post); true; end",
"def set_comment\n @post = Post.find(params[:id])\n end",
"def set_post\n @comment = Comment.fin... | [
"0.6952212",
"0.6795393",
"0.6773546",
"0.66260433",
"0.6588568",
"0.6588568",
"0.6588568",
"0.6588568",
"0.658302",
"0.6572132",
"0.654399",
"0.6513294",
"0.65093553",
"0.6507944",
"0.6476005",
"0.6475184",
"0.6472107",
"0.645082",
"0.64469784",
"0.6440366",
"0.6434512",
"... | 0.0 | -1 |
exercise question 3 write a program that includes a method called multiply that takes two arguments and returns the product of two numbers. | def multiply(a, b)
puts a*b
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multiply(num1, num2)\n product = num1 * num2\n puts product\nend",
"def multiply(num1,num2)\n product = num1 * num2\n puts product\nend",
"def multiply(num1, num2)\n\treturn num1 * num2\nend",
"def multiply(num1, num2)\n return num1 * num2\nend",
"def multiply(num1, num2)\n num1 ** num2\nend",
... | [
"0.8573218",
"0.857032",
"0.8484508",
"0.84759843",
"0.8475339",
"0.8466916",
"0.84655267",
"0.84642124",
"0.84188277",
"0.84188277",
"0.84184444",
"0.84074783",
"0.8406752",
"0.8406752",
"0.8394887",
"0.8388601",
"0.8388365",
"0.8388365",
"0.8388365",
"0.8388365",
"0.8388365... | 0.8372306 | 59 |
Use callbacks to share common setup or constraints between actions. | def set_distance_search
@distance_search = DistanceSearch.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 distance_search_params
params.require(:distance_search).permit(:source_zip_code, :destination_zip_code)
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 |
calculate all fuel for all modules | def all_fuel(full = false)
@modules.reduce(0) do |acc, element|
acc + compute_fuel_full(element, full)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_total_fuel_for_modules(module_mass_list)\n\ttotal_fuel = 0\n\n\tmodule_mass_list.each do |module_mass|\n\t\ttotal_fuel += fuel_required_for_mass(module_mass)\n\tend\n\n\ttotal_fuel\nend",
"def calculate_with_fuel\n s = 0\n res = calculate\n until res.zero?\n s += res\n @mass = re... | [
"0.7860762",
"0.7354684",
"0.71966594",
"0.68225384",
"0.6519708",
"0.6332398",
"0.6318716",
"0.6245416",
"0.62245834",
"0.61807257",
"0.6170638",
"0.6077032",
"0.5994652",
"0.59393775",
"0.5893356",
"0.5870751",
"0.5867109",
"0.5857718",
"0.58283246",
"0.5764432",
"0.5762545... | 0.82681066 | 0 |
compute fuel for one module | def compute_fuel(element)
(element/3).floor - 2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_fuel(full = false)\n @modules.reduce(0) do |acc, element|\n acc + compute_fuel_full(element, full)\n end\n end",
"def calculate_total_fuel_for_modules(module_mass_list)\n\ttotal_fuel = 0\n\n\tmodule_mass_list.each do |module_mass|\n\t\ttotal_fuel += fuel_required_for_mass(module_mass)\n\tend\n\... | [
"0.7457541",
"0.7394793",
"0.73131883",
"0.69059116",
"0.6901164",
"0.6775039",
"0.6618725",
"0.66089135",
"0.6591272",
"0.65647554",
"0.65586615",
"0.65242296",
"0.6505932",
"0.64425474",
"0.6417399",
"0.6402244",
"0.630865",
"0.62452745",
"0.6211831",
"0.6185951",
"0.604060... | 0.69031054 | 4 |
compute needed fuel, + fuel for the fuel ! | def compute_fuel_full(fuel, full = false)
# final condition
return 0 if fuel < 7
# short mode
needed = compute_fuel(fuel)
# full mode
needed += compute_fuel_full(needed, full) if full
# return final value
needed
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fuel_required\n fuel = 0.0\n residual = @mass\n # could be done recursively, if you have enough stack, or tail recursion\n while residual > 0.0\n residual = fuel_to_mass(residual)\n raise(StandardError, 'This fuel weighs more than it is worth.') if residual >= @mass\n\n fuel += resid... | [
"0.7941546",
"0.7901722",
"0.7444234",
"0.72873783",
"0.727556",
"0.72406703",
"0.7229913",
"0.7224073",
"0.712441",
"0.70647126",
"0.7058607",
"0.7052929",
"0.6973787",
"0.6887316",
"0.68632174",
"0.68235195",
"0.6810893",
"0.6798725",
"0.6742264",
"0.6741762",
"0.6730061",
... | 0.705422 | 11 |
Generate hash object for survey data | def generate_survey_data
@survey_data = CSV.parse(@survey_file, headers: true, header_converters: :symbol).map(&:to_hash)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hashed_fields_for_export\n hash = {}\n\n self.ordered_questions.map { |q| hash[q.answer_field] = q.text }\n\n hash.merge!({\n location_code: \"Location Code\",\n user_agent: \"User Agent\",\n page: \"Page\",\n referer: \"Referrer\",\n created_at: \"Created At\"\n })\n\n ... | [
"0.66107845",
"0.6589281",
"0.6582948",
"0.65100753",
"0.64935374",
"0.6471167",
"0.6469449",
"0.64558685",
"0.64299214",
"0.6381894",
"0.6368794",
"0.6352215",
"0.63459307",
"0.6345415",
"0.63145286",
"0.63145286",
"0.63145286",
"0.63145286",
"0.63145286",
"0.63145286",
"0.6... | 0.66865873 | 0 |
Generate hash object for survey responses | def generate_survey_responses_data
@survey_responses_data = []
CSV.open(@survey_responses_file).map do |line|
@survey_responses_data << {
email: line[0],
employee_id: line[1],
submitted_at: line[2],
responses: line[3..-1]
}
end
@survey_responses_data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_hash\n {\n response_id: response_id,\n question_id: question_id,\n option_id: option_id,\n question_pipe: question_pipe,\n submitted_at: submitted_at,\n survey_id: survey_id,\n other_text: other_text,\n answer_text: option_id || other_text ? nil :... | [
"0.6820689",
"0.6773349",
"0.66064364",
"0.66006035",
"0.64404863",
"0.6439844",
"0.6388863",
"0.6377905",
"0.6357487",
"0.63503814",
"0.63138455",
"0.6237315",
"0.623387",
"0.6217492",
"0.62138635",
"0.62015146",
"0.6201036",
"0.61932254",
"0.6170137",
"0.61459905",
"0.61398... | 0.5988556 | 61 |
def edit get_order_by_id(params[:id]) get_orders | def upsert
# debug
@param = params.dup
@order = TReceiveOrder.new(order_params)
@detail = TReceiveOrderDetail.new(detail_params)
# @detail = TReceiveOrderDetail.new
@details = get_details('1')
case params[:submit]
when 'save' then
# @order.save
when 'read' then
when 'sort' then
when 'detail_select' then
# @detail = @details[params[:select_detail]]
# @detail = get_detail_by_id(params[:select_detail])
when 'detail_lineup' then
@detail.sort_number -= 1
@detail.save
@details.each do |d|
if d.sort_number == @detail.sort_number
d.sort_number += 1
d.save
break
end
end
when 'detail_linedown' then
@detail.sort_number += 1
@detail.save
@details.each do |d|
if d.sort_number == @detail.sort_number
d.sort_number -= 1
d.save
break
end
end
when 'detail_addfront' then
when 'detail_addback' then
when 'detail_delete' then
update_list = []
sort_num = @detail.sort_number
@detail.destroy
@details.each do |d|
if d.sort_number > sort_num
d.sort_number -= 1
update_list.add(d)
end
end
if update_list.present?
update update_list
end
when 'detail_copy' then
# @detail.id = ''
# @detail.save
when 'detail_save' then
# @detail.save
else
raise e
end
render :new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n @order = Order.find_by(id: params[:id])\n end",
"def edit\n @order_view = Order.find(params[:id])\n end",
"def get_order\n @order = Order.find(params[:id])\n end",
"def get_order\n @order = Order.find(params[:id])\n end",
"def admin_order_details\n @id = params[:id]\n end",
... | [
"0.87096363",
"0.7867072",
"0.76777303",
"0.76777303",
"0.7612495",
"0.7582795",
"0.75192696",
"0.73375976",
"0.73114014",
"0.72248006",
"0.7222939",
"0.7118285",
"0.70926654",
"0.70504874",
"0.70504874",
"0.70504874",
"0.70504874",
"0.70504874",
"0.70504874",
"0.70504874",
"... | 0.0 | -1 |
Serves as a way to call both of the other methods in the class at the same time | def virus_effects
predicted_deaths
speed_of_spread
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calls; end",
"def calls; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call\n # implement in subclasses\n end",
"def method2() end",
"def methods() end",
"def call() end",
"d... | [
"0.67205256",
"0.67205256",
"0.6647614",
"0.6647614",
"0.6647614",
"0.6647614",
"0.6647614",
"0.6647614",
"0.6647614",
"0.6647614",
"0.6634571",
"0.6627544",
"0.6619068",
"0.6586278",
"0.6546347",
"0.6546347",
"0.6507946",
"0.6478347",
"0.6478347",
"0.6454114",
"0.6454114",
... | 0.0 | -1 |
Use the population density to estimate the number of deaths Print out the state and estimated number of deaths in a sentence | def predicted_deaths
# predicted deaths is solely based on population density
if @population_density >= 200
number_of_deaths = (@population * 0.4).floor
elsif @population_density >= 150
number_of_deaths = (@population * 0.3).floor
elsif @population_density >= 100
number_of_deaths = (@population * 0.2).floor
elsif @population_density >= 50
number_of_deaths = (@population * 0.1).floor
else
number_of_deaths = (@population * 0.05).floor
end
# number_of_deaths = @population * ((@population_density / 50).floor / 10)
print "#{@state} will lose #{number_of_deaths} people in this outbreak"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predicted_deaths(population_density, population, state)\n \n number_of_deaths = (@population * 0.05).floor if @population_density < 50\n number_of_deaths = (@population * 0.1).floor if @population_density >= 50\n number_of_deaths = (@population * 0.2).floor if @population_density >= 100\n number... | [
"0.79299206",
"0.79191166",
"0.78873837",
"0.78832304",
"0.7874304",
"0.7874304",
"0.7874304",
"0.7874304",
"0.7874304",
"0.7874304",
"0.7864126",
"0.78534716",
"0.78353935",
"0.78306204",
"0.78229564",
"0.78218216",
"0.78196025",
"0.78171915",
"0.78171915",
"0.78171915",
"0.... | 0.75545675 | 76 |
Use the population density to estimate the speed of spread Print out the state and estimated speed of spread | def speed_of_spread
#in months
# We are still perfecting our formula here. The speed is also affected
# by additional factors we haven't added into this functionality.
speed = 0.0
if @population_density >= 200
speed += 0.5
elsif @population_density >= 150
speed += 1
elsif @population_density >= 100
speed += 1.5
elsif @population_density >= 50
speed += 2
else
speed += 2.5
end
puts " and will spread across the state in #{speed} months.\n\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def speed_of_spread\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n case @population_density\r\n when 200..Float::INFINITY\r\n speed = 0.5\r\n when 150..199\r\n speed = 1\r\n when 100..1... | [
"0.8137616",
"0.8072624",
"0.80327845",
"0.8021543",
"0.8009957",
"0.7980362",
"0.79713273",
"0.7970989",
"0.7956512",
"0.79396075",
"0.79396075",
"0.79396075",
"0.79396075",
"0.7932189",
"0.7928332",
"0.7921696",
"0.79165804",
"0.79165804",
"0.79165804",
"0.79165804",
"0.791... | 0.77968466 | 35 |
define the arguments that the user will enter | def arguments(model)
# create argument vector
args = OpenStudio::Ruleset::OSArgumentVector.new
# measure function
function_choices = OpenStudio::StringVector.new
function_choices << "Add"
function_choices << "Remove"
function_choices << "Replace"
function = OpenStudio::Ruleset::OSArgument::makeChoiceArgument("function", function_choices, true)
function.setDisplayName("Function")
args << function
# facade
facade_choices = OpenStudio::StringVector.new
facade_choices << "All"
facade_choices << "North"
facade_choices << "East"
facade_choices << "South"
facade_choices << "West"
facade = OpenStudio::Ruleset::OSArgument::makeChoiceArgument("facade", facade_choices, true)
facade.setDisplayName("Facade")
args << facade
# window to wall ratio
wwr = OpenStudio::Ruleset::OSArgument::makeDoubleArgument("wwr", true)
wwr.setDisplayName("Window to Wall Ratio (fraction)")
wwr.setDefaultValue(0.4)
args << wwr
# offset
offset = OpenStudio::Ruleset::OSArgument::makeDoubleArgument("offset", true)
offset.setDisplayName("Height Offset from Floor (in)")
offset.setDefaultValue(30.0)
args << offset
# return argument vector
return args
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def arguments; end",
"def arguments; end",
"def arguments; end",
"def arguments\n \"\"\n end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end... | [
"0.7369445",
"0.7369445",
"0.7369445",
"0.7241612",
"0.7091237",
"0.7091237",
"0.7091237",
"0.7091237",
"0.7091237",
"0.7091237",
"0.7091237",
"0.7091237",
"0.7091237",
"0.7091237",
"0.7091237",
"0.7091237",
"0.7091237",
"0.7091237",
"0.7091237",
"0.7091237",
"0.7091237",
"... | 0.0 | -1 |
define what happens when the measure is run | def run(model, runner, user_arguments)
super(model, runner, user_arguments)
# use the built-in error checking
if not runner.validateUserArguments(arguments(model), user_arguments)
return false
end
# assign user inputs to variables
function = runner.getStringArgumentValue("function", user_arguments)
facade = runner.getStringArgumentValue("facade", user_arguments)
wwr = runner.getDoubleArgumentValue("wwr", user_arguments)
offset = runner.getDoubleArgumentValue("offset", user_arguments)
# check arguments fo reasonableness
if wwr <= 0 or wwr >= 1
runner.registerError("Window to wall ratio must be > 0 and < 1.")
return false
end
if offset <= 0
runner.registerError("Height offset must be > 0.")
return false
elsif offset > 360
runner.registerWarning("Height offset seems unusually high: #{offset} inches")
elsif offset > 9999
runner.registerError("Height offset is above the limit for sill height: #{offset} inches")
return false
end
# unit conversions
unit_offset_ip = OpenStudio::createUnit("ft").get
unit_offset_si = OpenStudio::createUnit("m").get
unit_area_ip = OpenStudio::createUnit("ft^2").get
unit_area_si = OpenStudio::createUnit("m^2").get
unit_cost_per_area_ip = OpenStudio::createUnit("1/ft^2").get #$/ft^2 does not work
unit_cost_per_area_si = OpenStudio::createUnit("1/m^2").get
offset_ip = OpenStudio::Quantity.new(offset/12, unit_offset_ip)
offset_si = OpenStudio.convert(offset_ip, unit_offset_si).get
# initialize variables
add_replace_count = 0
remove_count =0
starting_gross_ext_wall_area = 0.0 #includes windows and doors
starting_ext_window_area = 0.0
final_gross_ext_wall_area = 0.0 #includes windows and doors
final_ext_window_area = 0.0
# flag for not applicable
ext_walls = false
windows_added = false
# flag to track notifications of zone multipliers
space_warning_issued = []
# flag to track warning for new windows without construction
empty_const_warning = false
# calculate initial envelope cost as negative value
envelope_cost = 0
constructions = model.getConstructions
constructions.each do |construction|
const_lccs = construction.lifeCycleCosts
const_lccs.each do |const_lcc|
if const_lcc.category == "Construction"
envelope_cost += const_lcc.totalCost * -1
end
end
end
# get model objects
surfaces = model.getSurfaces
# add remove or replace windows
# loop through surfaces finding exterior walls with selected orientation
surfaces.each do |s|
subsurfaces = s.subSurfaces
next if not s.surfaceType == "Wall"
next if not s.outsideBoundaryCondition == "Outdoors"
next if subsurfaces.size > 0 and function == "Add"
if s.space.empty?
runner.registerWarning("Surface doesn't have a parent space and won't be included in the measure: #{s.name}")
next
end
if not facade == "All"
# calculate the absolute azimuth to determine orientation
absolute_azimuth = OpenStudio.convert(s.azimuth,"rad","deg").get + s.space.get.directionofRelativeNorth + model.getBuilding.northAxis
until absolute_azimuth < 360.0
absolute_azimuth = absolute_azimuth - 360.0
end
if facade == "North"
next if not (absolute_azimuth >= 315.0 or absolute_azimuth < 45.0)
elsif facade == "East"
next if not (absolute_azimuth >= 45.0 and absolute_azimuth < 135.0)
elsif facade == "South"
next if not (absolute_azimuth >= 135.0 and absolute_azimuth < 225.0)
elsif facade == "West"
next if not (absolute_azimuth >= 225.0 and absolute_azimuth < 315.0)
else
runner.registerError("Unexpected value of facade: " + facade + ".")
return false
end
end
ext_walls = true
# calculate surface area adjusting for zone multiplier
space = s.space
if not space.empty?
zone = space.get.thermalZone
end
if not zone.empty?
zone_mult = zone.get.multiplier
if zone_mult > 1 and not space_warning_issued.include?(space.get.name.to_s)
runner.registerInfo("Adjusting area calculations for space #{space.get.name.to_s} in zone #{zone.get.name.to_s} due to zone multiplier #{zone_mult}.")
space_warning_issued << space.get.name.to_s
end
else
zone_mult = 1 #space is not in a thermal zone
runner.registerWarning("Space isn't in a thermal zone and won't be included in the simulation. Windows will still be altered with an assumed zone multiplier of 1: #{space.get.name.to_s}")
end
surface_gross_area = s.grossArea * zone_mult
# loop through subsurfaces and add area including multiplier
ext_window_area = 0
subsurfaces.each do |ss|
ext_window_area = ext_window_area + ss.grossArea * ss.multiplier * zone_mult
if ss.multiplier > 1
runner.registerInfo("Adjusting area calculations for subsurface #{ss.name} in space #{space.get.name.to_s} due to subsurface multiplier #{ss.multiplier}.")
end
end
starting_gross_ext_wall_area += surface_gross_area
starting_ext_window_area += ext_window_area
if function == "Remove"
subsurfaces.each do |ss|
ss.remove
remove_count += 1
end
else #function == "Add" or function == "Replace"
new_window = s.setWindowToWallRatio(wwr, offset_si.value, true)
if new_window.empty?
runner.registerWarning("The requested window to wall ratio was too large, fenestration was not altered for surface: #{s.name}")
else
windows_added = true
#warn user if resulting window doesn"t have a construction, as it will result in failed simulation. In the future may use logic from starting windows to apply construction to new window.
if new_window.get.construction.empty? and empty_const_warning == false
runner.registerWarning("One or more resulting windows do not have constructions. This script is intended to be used with models using construction sets versus hard assigned constructions.")
empty_const_warning = true
end
end
add_replace_count += 1
end
end #add remove or replace windows
# report initial condition
# wwr does not currently account for either subsurface or zone multipliers
starting_wwr = sprintf("%.02f",(starting_ext_window_area/starting_gross_ext_wall_area))
runner.registerInitialCondition("Window to wall ratio for #{facade} exterior walls = #{starting_wwr}")
if not ext_walls
runner.registerAsNotApplicable("The model doesn't have exterior walls and was not altered.")
return true
elsif not windows_added and not function == "Remove"
runner.registerAsNotApplicable("The model does have exterior walls, but no windows could be added with the requested window to wall ratio.")
return true
end
# report final condition
# wwr does not currently account for either subsurface or zone multipliers
surfaces.each do |s|
next if not s.surfaceType == "Wall"
next if not s.outsideBoundaryCondition == "Outdoors"
if s.space.empty?
runner.registerWarning("Surface doesn't have a parent space and won't be included in the measure: #{s.name}")
next
end
# calculate the absolute azimuth to determine orientation
absolute_azimuth = OpenStudio.convert(s.azimuth,"rad","deg").get + s.space.get.directionofRelativeNorth + model.getBuilding.northAxis
until absolute_azimuth < 360.0
absolute_azimuth = absolute_azimuth - 360.0
end
if not facade == "All"
if facade == "North"
next if not (absolute_azimuth >= 315.0 or absolute_azimuth < 45.0)
elsif facade == "East"
next if not (absolute_azimuth >= 45.0 and absolute_azimuth < 135.0)
elsif facade == "South"
next if not (absolute_azimuth >= 135.0 and absolute_azimuth < 225.0)
elsif facade == "West"
next if not (absolute_azimuth >= 225.0 and absolute_azimuth < 315.0)
else
runner.registerError("Unexpected value of facade: " + facade + ".")
return false
end
end
# calculate surface area adjusting for zone multiplier
space = s.space
if not space.empty?
zone = space.get.thermalZone
end
if not zone.empty?
zone_mult = zone.get.multiplier
if zone_mult > 1
end
else
zone_mult = 1 #space is not in a thermal zone
end
surface_gross_area = s.grossArea * zone_mult
# loop through subsurfaces and add area including multiplier
ext_window_area = 0
s.subSurfaces.each do |subSurface| #only one and should have multiplier of 1
ext_window_area = ext_window_area + subSurface.grossArea * subSurface.multiplier * zone_mult
end
final_gross_ext_wall_area += surface_gross_area
final_ext_window_area += ext_window_area
end
# short def to make numbers pretty (converts 4125001.25641 to 4,125,001.26 or 4,125,001). The definition be called through this measure
def neat_numbers(number, roundto = 2) #round to 0 or 2)
# round to zero or two decimals
if roundto == 2
number = sprintf "%.2f", number
else
number = number.round
end
# regex to add commas
number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, "\\1,").reverse
end
# calculate change in window area
increase_window_area_si = OpenStudio::Quantity.new(final_ext_window_area - starting_ext_window_area, unit_area_si)
increase_window_area_ip = OpenStudio.convert(increase_window_area_si, unit_area_ip).get
# calculate final envelope cost as positive value
constructions = model.getConstructions
constructions.each do |construction|
const_lccs = construction.lifeCycleCosts
const_lccs.each do |const_lcc|
if const_lcc.category == "Construction"
envelope_cost += const_lcc.totalCost
end
end
end
final_wwr = sprintf("%.02f",(final_ext_window_area/final_gross_ext_wall_area))
runner.registerFinalCondition("Window to wall ratio for #{facade} exterior walls = #{final_wwr}")
if function == "Add" or function == "Replace"
runner.registerWarning("Number of windows added or replaced = #{add_replace_count}")
elsif function == "Remove"
runner.registerWarning("Number of windows removed = #{remove_count}")
end
runner.registerWarning("Window area increased by #{neat_numbers(increase_window_area_ip.value,0)} ft2.")
#runner.registerWarning("The material and construction costs increased by $#{neat_numbers(envelope_cost,0)}.")
# warn user to surface match prior to running measure
runner.registerWarning("Surface match before applying this measure to avoid adding windows to interior partition walls.")
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def measure; end",
"def measure=(_arg0); end",
"def measure\n\t\t1\n\tend",
"def measure(*args, &b)\n end",
"def communicate_measure_result(_ = nil, _ = nil); end",
"def communicate_measure_result(_ = nil, _ = nil); end",
"def called\n self.measurement.called\n end",
"def measure\n ... | [
"0.79848564",
"0.7639647",
"0.76355976",
"0.7170129",
"0.66926914",
"0.66926914",
"0.66718984",
"0.66311747",
"0.6599127",
"0.65870225",
"0.65324444",
"0.6481582",
"0.6405596",
"0.64028287",
"0.6333309",
"0.6283632",
"0.6283632",
"0.6283632",
"0.6281165",
"0.6269874",
"0.6242... | 0.0 | -1 |
short def to make numbers pretty (converts 4125001.25641 to 4,125,001.26 or 4,125,001). The definition be called through this measure | def neat_numbers(number, roundto = 2) #round to 0 or 2)
# round to zero or two decimals
if roundto == 2
number = sprintf "%.2f", number
else
number = number.round
end
# regex to add commas
number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, "\\1,").reverse
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_with_precision\n\t\t\"%.2f\" % number\n\tend",
"def conversion_precision; end",
"def pretty\n cpf_numbers = numeric\n \"%s.%s.%s-%s\" % [cpf_numbers[0..2], cpf_numbers[3..5], cpf_numbers[6..8], cpf_numbers[9..10]]\n end",
"def pretty_metric_value(value)\n case value\n ... | [
"0.6525183",
"0.64999294",
"0.64771897",
"0.64303565",
"0.6301417",
"0.6281109",
"0.62557393",
"0.6254835",
"0.6252896",
"0.6245343",
"0.6242394",
"0.6240805",
"0.62344676",
"0.61771315",
"0.61745554",
"0.61745554",
"0.61745554",
"0.61745554",
"0.61745554",
"0.6160089",
"0.61... | 0.58139986 | 58 |
If a membership is associated with a user, use the user's email instead, since the user can change their email address. | def email
self.user.try(:email) || self.original_email
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email\n user.present? ? user.email : self[:email]\n end",
"def invited_by_wus_user\n user = self.organization.users.where(self.invited_by_id).first\n user.full_name.present? ? user.full_name : user.email\n end",
"def assignee_email\n \tself.assignee.email if self.assignee\n end",
"def email\... | [
"0.6532166",
"0.6361554",
"0.6353833",
"0.6332362",
"0.6331999",
"0.63140106",
"0.6210818",
"0.617914",
"0.6161934",
"0.60939705",
"0.6084134",
"0.60812503",
"0.6076812",
"0.6050831",
"0.6040054",
"0.5990193",
"0.5975999",
"0.597196",
"0.59428823",
"0.59246236",
"0.59069735",... | 0.64458567 | 1 |
Use this if you really want the original email used to sign up for the membership | def original_email
read_attribute(:email)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email\n self.user.try(:email) || self.original_email\n end",
"def email\n self.user.try(:email) || self.original_email\n end",
"def email\n if self[:email] && !@email_name\n self[:email]\n elsif self.email_name && self.email_domain\n self[:email] = \"#{self.email_name}@#{self.email_... | [
"0.7384829",
"0.7384829",
"0.7333018",
"0.7297641",
"0.7162696",
"0.712204",
"0.70609933",
"0.7057359",
"0.70396936",
"0.70315117",
"0.70103115",
"0.69937766",
"0.6955835",
"0.6937012",
"0.691957",
"0.69182885",
"0.69019735",
"0.68987936",
"0.6892192",
"0.6886848",
"0.6875071... | 0.6851139 | 22 |
Membership is invoiceable if a user has been invited and it is outside the grace period. | def invoiceable?
has_user_id = self.user.present?
grace_date = self.created_at.to_date + GRACE_PERIOD
self.employee? && has_user_id && grace_date < Date.today
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_inviter?(user)\n membership_status(user) == StudentMembership::STATUSES[:inviter]\n end",
"def inviter?(user)\n return user.id == inviter_user_id\n end",
"def claimable?\n # can this invite be confirmed!\n ( pending? or declined? ) and !roster.full?\n end",
"def check_invitation \n ... | [
"0.70481986",
"0.6681103",
"0.6446861",
"0.63840383",
"0.62076974",
"0.61988056",
"0.61736625",
"0.61402303",
"0.61328745",
"0.611538",
"0.6080098",
"0.60645455",
"0.605303",
"0.60396963",
"0.6035327",
"0.6031779",
"0.6022199",
"0.5997837",
"0.59949857",
"0.59825873",
"0.5966... | 0.7418854 | 1 |
search combo_changed event handlers for the unique index on this table(extended_fgs) | def extended_fg_fg_code_search_combo_changed
fg_code = get_selected_combo_value(params)
session[:extended_fg_search_form][:fg_code_combo_selection] = fg_code
@fg_mark_codes = ExtendedFg.find_by_sql("Select distinct fg_mark_code from extended_fgs where fg_code = '#{fg_code}'").map{|g|[g.fg_mark_code]}
@fg_mark_codes.unshift("<empty>")
# render (inline) the html to replace the contents of the td that contains the dropdown
render :inline => %{
<%= select('extended_fg','fg_mark_code',@fg_mark_codes)%>
<img src = '/images/spinner.gif' style = 'display:none;' id = 'img_extended_fg_fg_mark_code'/>
<%= observe_field('extended_fg_fg_mark_code',:update => 'units_per_carton_cell',:url => {:action => session[:extended_fg_search_form][:fg_mark_code_observer][:remote_method]},:loading => "show_element('img_extended_fg_fg_mark_code');",:complete => session[:extended_fg_search_form][:fg_mark_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.615853",
"0.6141085",
"0.58082104",
"0.57193846",
"0.5680891",
"0.564917",
"0.5616362",
"0.5615596",
"0.5614281",
"0.55933374",
"0.5588074",
"0.5583387",
"0.55725133",
"0.5567907",
"0.5548175",
"0.55470616",
"0.5506988",
"0.55036086",
"0.54776627",
"0.545757",
"0.544348",
... | 0.59843993 | 2 |
search combo_changed event handlers for the unique index on this table(fg_marks) | def fg_mark_ri_mark_code_search_combo_changed
ri_mark_code = get_selected_combo_value(params)
session[:fg_mark_search_form][:ri_mark_code_combo_selection] = ri_mark_code
@ru_mark_codes = FgMark.find_by_sql("Select distinct ru_mark_code from fg_marks where ri_mark_code = '#{ri_mark_code}'").map{|g|[g.ru_mark_code]}
@ru_mark_codes.unshift("<empty>")
# render (inline) the html to replace the contents of the td that contains the dropdown
render :inline => %{
<%= select('fg_mark','ru_mark_code',@ru_mark_codes)%>
<img src = '/images/spinner.gif' style = 'display:none;' id = 'img_fg_mark_ru_mark_code'/>
<%= observe_field('fg_mark_ru_mark_code',:update => 'tu_mark_code_cell',:url => {:action => session[:fg_mark_search_form][:ru_mark_code_observer][:remote_method]},:loading => "show_element('img_fg_mark_ru_mark_code');",:complete => session[:fg_mark_search_form][:ru_mark_code_observer][:on_completed_js])%>
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extended_fg_fg_code_search_combo_changed\n\tfg_code = get_selected_combo_value(params)\n\tsession[:extended_fg_search_form][:fg_code_combo_selection] = fg_code\n\t@fg_mark_codes = ExtendedFg.find_by_sql(\"Select distinct fg_mark_code from extended_fgs where fg_code = '#{fg_code}'\").map{|g|[g.fg_mark_code]}\n\... | [
"0.5697686",
"0.54653025",
"0.538711",
"0.51934606",
"0.5126749",
"0.51203924",
"0.51004577",
"0.509816",
"0.5086619",
"0.50425375",
"0.5035506",
"0.5030035",
"0.5007528",
"0.4993379",
"0.49888247",
"0.49857074",
"0.49784854",
"0.49738708",
"0.49725375",
"0.49393156",
"0.4923... | 0.6116785 | 0 |
============================== FG PRODUCTS CODE ============================== | def list_fg_products
return if authorise_for_web('fg_product','read') == false
if params[:page]!= nil
session[:fg_products_page] = params['page']
render_list_fg_products
return
else
session[:fg_products_page] = nil
end
list_query = "@fg_product_pages = Paginator.new self, FgProduct.count, @@page_size,@current_page
@fg_products = FgProduct.find(:all,
:limit => @fg_product_pages.items_per_page,
:order => 'fg_product_code',
:offset => @fg_product_pages.current.offset)"
session[:query] = list_query
render_list_fg_products
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def products\n end",
"def set_product\n \n end",
"def product_name; end",
"def create_product(prod)\n\n purchase_price = BigDecimal.new(\"0.0\")\n purchase_price = BigDecimal.new(prod['purchase_price'].to_s) unless prod['purchase_price'].nil?\n sales_price = nil\n sales_price = BigDecimal.... | [
"0.72444004",
"0.7213954",
"0.6959698",
"0.67610925",
"0.6685109",
"0.66765463",
"0.665304",
"0.66140383",
"0.6582618",
"0.6546611",
"0.6534829",
"0.6529321",
"0.65003234",
"0.6493429",
"0.64627737",
"0.64509714",
"0.64463794",
"0.6410814",
"0.6387066",
"0.63533336",
"0.63211... | 0.6066677 | 64 |
search combo_changed event handlers for the unique index on this table(fg_products) | def fg_product_item_pack_product_code_search_combo_changed
item_pack_product_code = get_selected_combo_value(params)
session[:fg_product_search_form][:item_pack_product_code_combo_selection] = item_pack_product_code
@unit_pack_product_codes = FgProduct.find_by_sql("Select distinct unit_pack_product_code from fg_products where item_pack_product_code = '#{item_pack_product_code}'").map{|g|[g.unit_pack_product_code]}
@unit_pack_product_codes.unshift("<empty>")
# render (inline) the html to replace the contents of the td that contains the dropdown
render :inline => %{
<%= select('fg_product','unit_pack_product_code',@unit_pack_product_codes)%>
<img src = '/images/spinner.gif' style = 'display:none;' id = 'img_fg_product_unit_pack_product_code'/>
<%= observe_field('fg_product_unit_pack_product_code',:update => 'carton_pack_product_code_cell',:url => {:action => session[:fg_product_search_form][:unit_pack_product_code_observer][:remote_method]},:loading => "show_element('img_fg_product_unit_pack_product_code');",:complete => session[:fg_product_search_form][:unit_pack_product_code_observer][:on_completed_js])%>
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product_product_subtype_code_search_combo_changed\n\tproduct_subtype_code = get_selected_combo_value(params)\n\tsession[:product_search_form][:product_subtype_code_combo_selection] = product_subtype_code\n\t@tag1s = Product.find_by_sql(\"Select distinct tag1 from products where product_subtype_code = '#{produc... | [
"0.64642626",
"0.6190443",
"0.6003731",
"0.5988849",
"0.59638804",
"0.58458954",
"0.57501113",
"0.5703631",
"0.5590093",
"0.5578126",
"0.55595165",
"0.55389905",
"0.5529483",
"0.55167377",
"0.5506965",
"0.5505987",
"0.5504362",
"0.54861945",
"0.5470979",
"0.5466735",
"0.54591... | 0.67782253 | 0 |
Helper function for get_recently_used_ | def get_recently_used(table, options)
# both the trend_use and question_use tables have the same schema.
limit = "";
if (options.has_key?(:count))
limit = "LIMIT #{options[:count].to_i}"
end
names = []
@database.execute("SELECT name, used_at FROM #{table} ORDER BY used_at DESC #{limit};") do |result|
names << result[0]
end
return names
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def used\n update(last_used: DateTime.now)\n end",
"def last_used\n Date.parse(match(/Last\\sused\\s+:\\s+(\\w+ [0-9]{2} [0-9(:?)]+ [0-9]{4})/)) rescue nil\n end",
"def last_used_at\n begin\n Time.parse(self.last_use_date)\n rescue\n nil\n end\n ... | [
"0.6984359",
"0.6603692",
"0.6282661",
"0.6281279",
"0.61881053",
"0.6079583",
"0.59925383",
"0.5987646",
"0.59789443",
"0.59126157",
"0.59021056",
"0.575969",
"0.57364994",
"0.5717223",
"0.57141787",
"0.56818414",
"0.5681321",
"0.5674328",
"0.566527",
"0.56521344",
"0.564115... | 0.65456796 | 2 |
Helper function for add_recently_used_ | def add_recently_used(table, text)
@database.execute(
"INSERT INTO #{table} (name) VALUES (:name);",
"name" => text);
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def used\n update(last_used: DateTime.now)\n end",
"def added\n @added ||= {}\n end",
"def use\n update_column(:last_used_at, Time.now)\n end",
"def history_added=(_arg0); end",
"def history_added; end",
"def add_new\n self.times_used.unshift(0)\n self.save\n end",
"def added... | [
"0.7454241",
"0.6635385",
"0.6602581",
"0.6190538",
"0.6108024",
"0.6016032",
"0.59580386",
"0.58517236",
"0.58502585",
"0.582013",
"0.57938546",
"0.5777154",
"0.57348675",
"0.57273823",
"0.56865287",
"0.5669054",
"0.56688404",
"0.56525683",
"0.56382364",
"0.56330436",
"0.561... | 0.6239909 | 3 |
calculate contribution of each feature (f) for each class (k) | def calc_contribution(f)
each_class do |k|
a, b, c, d = get_A(f, k), get_B(f, k), get_C(f, k), get_D(f, k)
n = a+b+c+d
s = 0.0
x = (a+b)*(a+c)
s = Math.log2(a*n/x) if not x.zero?
set_feature_score(f, k, s)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_contribution(f)\n each_class do |k|\n a, c = get_A(f, k), get_C(f, k)\n \n s =0.0\n x = a+c\n \n s = a/x if not x.zero?\n \n set_feature_score(f, k, s)\n end\n end",
"def calc_contribution(f)\n each_class do |k|\n a, b, c, ... | [
"0.78788304",
"0.7799466",
"0.7792636",
"0.7778219",
"0.772977",
"0.76803815",
"0.7582821",
"0.7445391",
"0.6979485",
"0.6889027",
"0.6828307",
"0.63680226",
"0.6309623",
"0.62906444",
"0.60808206",
"0.5987632",
"0.5912798",
"0.59023523",
"0.59009403",
"0.5873083",
"0.5818051... | 0.7694428 | 5 |
don't forget g.save! to get proper ID def new | def create
@game = Game.new
@game.answer = WORDS.sample
@game.guessed = ''
@game.save!
redirect_to game_path(@game)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_new\n # Finding a new through the params id\n @new = New.find(params[:id])\n end",
"def set_new_\n @new_ = New.find(params[:id])\n end",
"def new\n\n\t\t\n\tend",
"def new\n\t\t\n\tend",
"def new\n\t\t\n\tend",
"def new\r\n\r\n end",
"def new\r\n \r\n end",
"d... | [
"0.6983442",
"0.6899411",
"0.6804045",
"0.6737127",
"0.6737127",
"0.67210287",
"0.6709119",
"0.67081696",
"0.67081696",
"0.6700945",
"0.66813153",
"0.66813153",
"0.66647565",
"0.6634105",
"0.6634105",
"0.6634105",
"0.6634105",
"0.6634105",
"0.6634105",
"0.6634105",
"0.6634105... | 0.0 | -1 |
In production, the controller is loaded before the routes So, delay looking up the routes until they are loaded | def load!
resources.each { |r| load_resource(r) }
@loaded = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_routing\n configuration.add_controller_paths(extension_loader.paths(:controller))\n configuration.add_eager_load_paths(extension_loader.paths(:eager_load))\n super\n end",
"def load_routes\n\n # get our routes\n routes = Rails.application.routes.routes.to_a\n\n # f... | [
"0.6780621",
"0.6660742",
"0.66195524",
"0.6565833",
"0.6565833",
"0.65452224",
"0.63229966",
"0.6279861",
"0.62181664",
"0.61156964",
"0.6102328",
"0.6097933",
"0.6056261",
"0.60456604",
"0.6034844",
"0.6034844",
"0.6034844",
"0.6034844",
"0.6034844",
"0.6034844",
"0.6034844... | 0.0 | -1 |
Give Swagger::Blocks what it wants | def index
self.class.load! unless self.class.loaded?
render json: Swagger::Blocks.build_root_json([self.class])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blocks_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.blocks ...'\n end\n # resource path\n local_var_path = '/api/v1/blocks'\n\n # query parameters\n query_params = opts[:query_params] || {}\n que... | [
"0.626211",
"0.61843437",
"0.60831624",
"0.5933736",
"0.5845698",
"0.5827726",
"0.5816852",
"0.5806156",
"0.5613886",
"0.56120855",
"0.55123293",
"0.55123293",
"0.54986787",
"0.548154",
"0.5458589",
"0.5449936",
"0.5449936",
"0.54340523",
"0.54292136",
"0.5364834",
"0.5364834... | 0.62185836 | 1 |
this order doesn't matter | def calculate_total_2(info) # info is a hash with expected arguments
taxAmt = info[:price] * info[:tax]
tipAmt = info[:price] * info[:tip]
info[:price] + tipAmt + taxAmt
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def order; end",
"def order; end",
"def private; end",
"def offences_by; end",
"def probers; end",
"def schubert; end",
"def original_order\n end",
"def arrange\n\t\t\n\tend",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def order=(_arg0); end",
"def... | [
"0.71804506",
"0.71804506",
"0.6902442",
"0.67257214",
"0.6675787",
"0.6379923",
"0.61651474",
"0.61627865",
"0.61063325",
"0.61063325",
"0.61063325",
"0.61063325",
"0.61015636",
"0.609795",
"0.60622257",
"0.6054374",
"0.6037571",
"0.6015322",
"0.6008177",
"0.6008177",
"0.596... | 0.0 | -1 |
Creates a new feed only if it does not already exist | def add_feed name, url, type
if Feed.find_by_name(name).nil?
Feed.create(name: name, url: url, feed_type: type, updated_date: Date.yesterday)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feed\n\t feeds[0] = feeds.create unless feeds[0]\n\t feeds[0]\n\tend",
"def create_feed(feed_id, feed_name = nil)\n feed = create_blueprint\n feed[:id] = feed_id\n feed[:name] = feed_name\n\n begin\n return http_post('/feeds/', feed)\n rescue HawkularException => error\n ... | [
"0.7433264",
"0.73706627",
"0.7364857",
"0.7332332",
"0.71956295",
"0.7017786",
"0.7017786",
"0.7017786",
"0.7017786",
"0.6862158",
"0.6726993",
"0.6610957",
"0.6573768",
"0.65333474",
"0.6490009",
"0.64516246",
"0.6431649",
"0.63899755",
"0.6386712",
"0.6377786",
"0.63589096... | 0.7956481 | 0 |
This helper function parses the extension of the requested file and then looks up its content type. | def content_type(path)
ext = File.extname(path).split(".").last
CONTENT_TYPE_MAPPING.fetch(ext, DEFAULT_CONTENT_TYPE)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_extension_content_type filename\n types = MIME::Types.type_for(filename)\n types.empty? ? nil : types.first.content_type\n end",
"def get_content_type(filename)\n ext = File.extname(filename) # get the extension\n type = 'application/octed-stream'\n type = 'text/html' if ext == '.html' ... | [
"0.7903873",
"0.7536399",
"0.7458946",
"0.74176574",
"0.7400843",
"0.7374084",
"0.73597765",
"0.7359364",
"0.7248547",
"0.72484815",
"0.7240564",
"0.72328854",
"0.72308874",
"0.72297895",
"0.7199868",
"0.7194467",
"0.7186682",
"0.71707016",
"0.7164813",
"0.7164813",
"0.714014... | 0.73366606 | 8 |
This helper function parses the RequestLine and generates a path to a file on the server. | def requested_file(request_line)
# ... implementation details to be discussed later ...
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def requested_file(request_line)\n request_uri = request_line.split(\" \")[1]\n # Make it vulnerable\n request_uri = request_uri.gsub(\"%c1%1c\", \"/\")\n path = URI.unescape(URI(request_uri).path)\n\n File.join(WEB_ROOT, path)\nend",
"def requested_file(request_line)\n request_uri = request_... | [
"0.7965744",
"0.7721807",
"0.7136522",
"0.6817853",
"0.67506754",
"0.6340607",
"0.62348384",
"0.6168561",
"0.61246866",
"0.61236453",
"0.6100175",
"0.6042442",
"0.6016296",
"0.6010331",
"0.5888561",
"0.58863974",
"0.5885806",
"0.5861536",
"0.5858268",
"0.5848343",
"0.578508",... | 0.6850371 | 3 |
Method to check each permutation of move orders | def solution_checker(array)
if array.length > 1
# Create a board that can be manipulated without affecting the original board
internal_board = []
column_counter = 1
row_counter = 1
4.times do
4.times do
internal_board.push(Square.new([column_counter, row_counter]))
column_counter = column_counter + 1
end
row_counter = row_counter + 1
column_counter = 1
end
#Label squares on the board as occupied
array.each do |piece|
square = internal_board.find {|s| s.location == piece.location}
square.occupied = true
square.piece = piece
end
array.each_with_index do |piece, index|
if array.include?(piece) && piece != array.last
original_square = internal_board.find {|s| s.location == piece.location}
blocker = piece.impediments?([(array[index + 1]).column, (array[index + 1]).row], internal_board)
if blocker
break
elsif piece.move([(array[index + 1]).column, (array[index + 1]).row])
captured_piece = array[index + 1]
array.uniq!{|piece| piece.location}
original_square.occupied = false
original_square.piece = nil
new_moves = array.permutation.to_a
new_moves.each do |new_array|
new_array.map {|a| a.dup}
end
new_moves.each do |new_array|
solution_checker(array)
end
else
break
end
else
break
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def possible_positions?(already_passed = [])\n possible_positions = []\n Knight::VALID_MOVES.each do |move|\n possible_position = already_passed.last.change(move)\n if possible_position.valid? and\n not already_passed.include?(possible_position) and\n ... | [
"0.6416064",
"0.63325775",
"0.625301",
"0.6244038",
"0.62331784",
"0.62255496",
"0.619623",
"0.6178575",
"0.6128479",
"0.60711294",
"0.6041618",
"0.60388035",
"0.6023383",
"0.6014881",
"0.5982988",
"0.59617054",
"0.59595746",
"0.5958079",
"0.59491843",
"0.59471047",
"0.594371... | 0.6109523 | 9 |
GET /categories GET /categories.json | def index
@categories = Category.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def categories\n\t\tbegin\n\t\t\t@categories = Category.select(:id, :name)\n\t\t\trender json: @categories\n\t\trescue Exception => e\n\t\t\terror_handling_bad_request(e)\n\t\tend\n\tend",
"def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter:... | [
"0.83888507",
"0.8327856",
"0.83211476",
"0.78072983",
"0.7742051",
"0.75669324",
"0.75111455",
"0.74151826",
"0.7386452",
"0.7369945",
"0.7369187",
"0.73691803",
"0.73691803",
"0.73457074",
"0.73304063",
"0.7316772",
"0.72851175",
"0.72663945",
"0.72275496",
"0.7220998",
"0.... | 0.67645466 | 78 |
GET /categories/1 GET /categories/1.json | def show
@images = @category.images
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetCategories params = {}\n\n params = params.merge(path: 'categories.json')\n APICall(params)\n\n end",
"def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter: :json, status: :ok\r\n end",
"def GetCategory id\n\n ... | [
"0.7877691",
"0.7865133",
"0.78486437",
"0.78422695",
"0.7414923",
"0.74083245",
"0.73075056",
"0.7306919",
"0.7306919",
"0.7282217",
"0.7235693",
"0.7186931",
"0.7158298",
"0.7133119",
"0.7122198",
"0.70659566",
"0.70442134",
"0.7036961",
"0.70349413",
"0.70324004",
"0.70126... | 0.0 | -1 |
POST /categories POST /categories.json | def create
@category = Category.new(category_params)
respond_to do |format|
if @category.save
format.html { redirect_to categories_path, notice: 'Category was successfully created.' }
format.json { render :show, status: :created, location: @category }
else
format.html { render :new }
format.json { render json: @category.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CreateCategory params = {}\n \n APICall(path: 'categories.json',method: 'POST',payload: params.to_json)\n \n end",
"def create\n json_create(category_params, Category)\n end",
"def create_category payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post CATE... | [
"0.7738549",
"0.74339235",
"0.72349083",
"0.71634054",
"0.7124031",
"0.70645165",
"0.705568",
"0.695861",
"0.6956783",
"0.6903891",
"0.6838659",
"0.6821712",
"0.68190134",
"0.6807838",
"0.678525",
"0.66138625",
"0.6566919",
"0.65661913",
"0.65567696",
"0.6523676",
"0.65186286... | 0.6507293 | 22 |
PATCH/PUT /categories/1 PATCH/PUT /categories/1.json | def update
@category.assign_attributes(category_params)
respond_to do |format|
if @category.save
format.html { redirect_to edit_category_url(@category), notice: 'Category was successfully updated.' }
format.json { render :show, status: :ok, location: @category }
else
format.html { render :edit }
format.json { render json: @category.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def UpdateCategory params = {}\n \n APICall(path: 'categories.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n json_update(category,category_params, Category)\n end",
"def update_categories(categories, options = {} )\n options.merge!(:docid => self.doci... | [
"0.76931995",
"0.7600433",
"0.721346",
"0.6943123",
"0.6914936",
"0.6817601",
"0.67816055",
"0.6713112",
"0.66984165",
"0.6693479",
"0.66566056",
"0.66523254",
"0.6651486",
"0.6645902",
"0.66068524",
"0.65989816",
"0.6571709",
"0.6571709",
"0.65543723",
"0.65349466",
"0.65002... | 0.0 | -1 |
DELETE /categories/1 DELETE /categories/1.json | def destroy
@category.destroy
respond_to do |format|
format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteCategory id\n \n APICall(path: \"categories/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\n @category.destroy\n render json: @category, status: :ok\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |f... | [
"0.78272814",
"0.77353686",
"0.76392984",
"0.7488916",
"0.74731207",
"0.74233276",
"0.7399541",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7378597",
"0.7378597"... | 0.708277 | 71 |
Use callbacks to share common setup or constraints between actions. | def set_category
@category = Category.find(params[:id])
@image = Image.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def category_params
params.require(:category).permit(:id, :name, images_attributes: [:id, :source, :text, :_destroy])
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 |
cheapskate pseudoassertion, turn into proper assertion/expectation | def preserve_order(page, earlier, later)
page.body.index(earlier.to_s).must_be :<, page.body.index(later.to_s)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assertions; end",
"def assertions; end",
"def assertions=(_arg0); end",
"def assertions=(_arg0); end",
"def assertions\n @@assertions\n end",
"def check_assertion(value,assertion,error_class,mess_prefix,opt_fail_mess = '')\n\tcheck_assertion_args(assertion,opt_fail_mess)\n\tif not asserti... | [
"0.7608541",
"0.7608541",
"0.67025155",
"0.67025155",
"0.66392666",
"0.65621454",
"0.65019345",
"0.6396803",
"0.6336773",
"0.6313367",
"0.6283467",
"0.62662256",
"0.6255796",
"0.624832",
"0.62410605",
"0.6228776",
"0.61840445",
"0.6177234",
"0.61730456",
"0.6166603",
"0.61432... | 0.0 | -1 |
Gets current status of indicator. | def current_state
events.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_status\n return @m_status\n end",
"def getStatus\n @status\n end",
"def getStatus\r\n\t\t\t\t\treturn @status\r\n\t\t\t\tend",
"def status\n @__status\n end",
"def status\n instance_get(:status)\n end",
"def get_status\n\t\tstatus\n\tend",
"def status... | [
"0.73363346",
"0.72214466",
"0.7148005",
"0.7143639",
"0.7124216",
"0.7106403",
"0.7068523",
"0.70587116",
"0.70587116",
"0.70112",
"0.6970631",
"0.69700015",
"0.69700015",
"0.69700015",
"0.69700015",
"0.69700015",
"0.69700015",
"0.69700015",
"0.69700015",
"0.69700015",
"0.69... | 0.0 | -1 |
Used in after_create callback. Sets default state of every new indicator. | def set_on_create
set Status::DEFAULT, "Initialization"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indicator_state=(indicator_state); end",
"def set_default_values\n if new_record?\n self.state = :busy\n end\n end",
"def set_observable_value_on_indicator\n self.indicators.each do |indicator|\n indicator.set_observable_value\n end\n end",
"def set_indicator\n @indicator = I... | [
"0.7030202",
"0.6433038",
"0.60617024",
"0.5924589",
"0.5924377",
"0.59031844",
"0.5895857",
"0.5872019",
"0.5788671",
"0.5788671",
"0.5783762",
"0.574867",
"0.57250994",
"0.56887966",
"0.56479466",
"0.5620437",
"0.56142956",
"0.56122047",
"0.559977",
"0.559977",
"0.55611974"... | 0.58557224 | 8 |
FYI: HAVE NOT DEALT WITH HASHES YET, SO SOME SOLUTIONS HAVE BEEN HARDCODED Will remove hardcoded answers after completing lessons on hashes | def begins_with_r(array)
array.all? {|word| word.start_with?("r")}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_hash_correct\n\t\n\t\tString test_array1 = '2|abb2|George>Amina(16):Henry>James(4):Henry>Cyrus(17):Henry>Kublai(4):George>Rana(1):SYSTEM>Wu(100)|1518892051.753197000|c72d'.split('|').map(&:chomp)\n\n\t\tx = test_array1[0].unpack('U*') + test_array1[1].unpack('U*') + test_array1[2].unpack('U*') + test_arra... | [
"0.6976839",
"0.6778394",
"0.6778394",
"0.6778394",
"0.6778394",
"0.6778394",
"0.6778394",
"0.6778394",
"0.6589125",
"0.6484393",
"0.6483685",
"0.6361126",
"0.6288694",
"0.62832737",
"0.62698656",
"0.6267744",
"0.626206",
"0.62539476",
"0.61601424",
"0.6148945",
"0.6148945",
... | 0.0 | -1 |
like Universe TODO select, where and group_by specific | def load_query
universe.load_query(select_cols)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_by\n\n end",
"def group_by\n end",
"def group\n return if record.respond_to?(:where)\n record.group\n end",
"def group_by?; @group_by; end",
"def employees_select_by(group)\n employees\n end",
"def select_by(how, what); end",
"def summarize_per_subset\n @having = ANY_R... | [
"0.6656312",
"0.66512764",
"0.64260536",
"0.6351117",
"0.61055905",
"0.6095666",
"0.59276146",
"0.5893863",
"0.5853284",
"0.5852039",
"0.58088416",
"0.58069223",
"0.5798105",
"0.57525533",
"0.574298",
"0.5726778",
"0.57083905",
"0.56788397",
"0.5623062",
"0.55352324",
"0.5528... | 0.0 | -1 |
Function Description Complete the aVeryBigSum function in the editor below. It must return the sum of all array elements. aVeryBigSum has the following parameter(s): ar: an array of integers . Input Format The first line of the input consists of an integer . The next line contains spaceseparated integers contained in the array. Output Format Print the integer sum of the elements in the array. Constraints Sample Input 5 1000000001 1000000002 1000000003 1000000004 1000000005 Output 5000000015 Complete the aVeryBigSum function below. | def aVeryBigSum(ar)
ar.reduce(:+)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aVeryBigSum(ar)\n sum = ar.sum\nreturn sum\nend",
"def a_very_big_sum arr\n arr.reduce(:+)\n end",
"def calculate_very_big_sum(\n array:\n )\n\tsum = 0\n\tarray.collect { |single_num| sum += single_num }\n\tsum\nend",
"def sum_of_big_numbers(array_of_integers)\n # TODO\nend",
"def a... | [
"0.7329434",
"0.7216393",
"0.7131882",
"0.6665642",
"0.65937144",
"0.6329305",
"0.6206057",
"0.61569965",
"0.6144826",
"0.6058326",
"0.6033477",
"0.59757537",
"0.59275097",
"0.59229565",
"0.591997",
"0.5911595",
"0.59058124",
"0.5863912",
"0.57841736",
"0.5783799",
"0.5779553... | 0.7293519 | 1 |
Return all association class names | def associations_class_names
self.associations.map{|name,association|
association.class_name
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def association_names\n self.class._associations.keys\n end",
"def associations\n association_reflections.keys\n end",
"def association_names\n @association_names ||= []\n end",
"def class_names\n classes.map &:name\n end",
"def class_names\n descendants.m... | [
"0.7988602",
"0.7386864",
"0.73814577",
"0.7196851",
"0.711542",
"0.7042725",
"0.6944682",
"0.6909982",
"0.67950845",
"0.6772489",
"0.6765103",
"0.6758922",
"0.67526567",
"0.67520165",
"0.67520165",
"0.67279506",
"0.67279506",
"0.66158766",
"0.6596184",
"0.6514218",
"0.645680... | 0.848565 | 0 |
Detect if class reflect on association by name | def reflect_on_association(name)
if orm_association = klass.reflect_on_association(name)
self.class.const_get(:Association).new(orm_association,self)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_association?(attr_name)\n _associations.has_key?(attr_name.to_sym)\n end",
"def has_association_to klass, ident\n @associated_objects[klass].include?(ident)\n end",
"def has_class?(name)\n @class_syms ||= classes.map(&:to_sym)\n @class_syms.include?(name.to_sym)\n end",
"def as... | [
"0.6784058",
"0.6657494",
"0.6602292",
"0.6527029",
"0.6483904",
"0.6443875",
"0.6437574",
"0.64347464",
"0.64234304",
"0.6417831",
"0.64032084",
"0.63922745",
"0.6333632",
"0.6251088",
"0.62468135",
"0.62457573",
"0.62456834",
"0.6239965",
"0.62242395",
"0.6217185",
"0.62040... | 0.6006966 | 37 |
This method is used to paginate, main reason is for list and for index action. Method accepts three arguments page page that should be shown (integer) per how many records there should be in page options Hash with optional information. By default, Lolita::Configuration::List passes request, with current request information. Also it passes :pagination_method that is used to detect if there is special method(s) in model that should be used for creating page. | def paginate(page, per, options = {})
pagination_builder = PaginationBuilder.new(self, page, per, options)
pagination_builder.create_page
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_pagination\n @page_number = 1\n if params[:page] && params[:page].to_i > 0\n @page_number = params[:page].to_i\n end\n @pagination = true\n @pagination_options = { :limit => items_per_page, :offset => (@page_number - 1) * items_per_page }\n @pagination_options = {} if params[:all]\n ... | [
"0.75507605",
"0.73348355",
"0.7333674",
"0.7298499",
"0.71443444",
"0.7140325",
"0.7028139",
"0.70070034",
"0.69209355",
"0.6907176",
"0.6895169",
"0.6851848",
"0.6845041",
"0.68152136",
"0.6813986",
"0.68080693",
"0.6805667",
"0.67618805",
"0.67112744",
"0.66996473",
"0.667... | 0.6759462 | 18 |
GET /schoolings/1 GET /schoolings/1.xml | def show
@schooling = Schooling.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @schooling }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @school = School.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @school }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.haml\n format.xml { render :xml => @school }\n end\n end"... | [
"0.70724",
"0.68346727",
"0.67935276",
"0.665596",
"0.6540381",
"0.6454169",
"0.6416611",
"0.6393005",
"0.63868177",
"0.63809055",
"0.6370036",
"0.636842",
"0.6331306",
"0.6252916",
"0.6246126",
"0.6230603",
"0.6214651",
"0.6205007",
"0.61951894",
"0.61832434",
"0.6175696",
... | 0.74342906 | 0 |
GET /schoolings/new GET /schoolings/new.xml | def new
@schooling = Schooling.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @schooling }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @school = School.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @school }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.haml\n format.xml { render :xml => @school }\n end\n end",
"def new\n\n ... | [
"0.73483646",
"0.7324814",
"0.7322745",
"0.7090487",
"0.7017349",
"0.68075645",
"0.6798462",
"0.67413646",
"0.6696764",
"0.6696764",
"0.6689537",
"0.65238285",
"0.6489853",
"0.6447594",
"0.6442309",
"0.64400095",
"0.64161193",
"0.64155155",
"0.6410504",
"0.6401966",
"0.639713... | 0.7728274 | 0 |
POST /schoolings POST /schoolings.xml | def create
@schooling = Schooling.new(params[:schooling])
respond_to do |format|
if @schooling.save
format.html { redirect_to(@schooling, :notice => 'Schooling was successfully created.') }
format.xml { render :xml => @schooling, :status => :created, :location => @schooling }
else
format.html { render :action => "new" }
format.xml { render :xml => @schooling.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n\n respond_to do |format|\n if @school.save\n flash[:notice] = 'School was successfully created.'\n format.html { redirect_to(@school) }\n format.xml { render :xml => @school, :status => :created, :location => @school }\n else\n format.html { render :action => ... | [
"0.62043345",
"0.61925924",
"0.6154839",
"0.60393786",
"0.60262424",
"0.5970483",
"0.5958465",
"0.5954983",
"0.5950106",
"0.59300375",
"0.59300375",
"0.59300375",
"0.59295446",
"0.5906505",
"0.5897512",
"0.5826972",
"0.5811888",
"0.5800139",
"0.57818294",
"0.57628787",
"0.574... | 0.68654394 | 0 |
PUT /schoolings/1 PUT /schoolings/1.xml | def update
@schooling = Schooling.find(params[:id])
respond_to do |format|
if @schooling.update_attributes(params[:schooling])
format.html { redirect_to(@schooling, :notice => 'Schooling was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @schooling.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n\n respond_to do |format|\n if @school.update_attributes(params[:school])\n flash[:notice] = 'School was successfully updated.'\n format.html { redirect_to(@school) }\n format.xml { head :ok }\n else\n format.html { render :action => \"new\" }\n format.x... | [
"0.671983",
"0.65119416",
"0.6360972",
"0.6360972",
"0.62791234",
"0.6263913",
"0.6233479",
"0.61649513",
"0.6156867",
"0.61274284",
"0.61274284",
"0.61274284",
"0.61274284",
"0.61176866",
"0.61176497",
"0.6112029",
"0.6096599",
"0.60789835",
"0.6011161",
"0.5937673",
"0.5937... | 0.6813331 | 0 |
DELETE /schoolings/1 DELETE /schoolings/1.xml | def destroy
@schooling = Schooling.find(params[:id])
@schooling.destroy
respond_to do |format|
format.html { redirect_to(schoolings_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @school.destroy\n\n respond_to do |format|\n format.html { redirect_to(schools_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @school = School.find(params[:id])\n @school.destroy\n\n respond_to do |format|\n format.html { redirect_to(schools_url) }\... | [
"0.72871107",
"0.7274469",
"0.70821303",
"0.6885253",
"0.6754188",
"0.6720658",
"0.66924304",
"0.6649944",
"0.6649944",
"0.66357225",
"0.6623371",
"0.6578469",
"0.65359396",
"0.6533992",
"0.65329885",
"0.64745075",
"0.64452195",
"0.6413246",
"0.6393177",
"0.6393177",
"0.63931... | 0.7493935 | 0 |
Get specific player's result | def get_dobayashi_result
Anemone.crawl(DOBAYASHI_URL, @options) do |anemone|
anemone.on_every_page do |page|
doc = Nokogiri::HTML.parse(page.body.toutf8)
doc.xpath('//div[@class="PlayerAdBox mb15"]').each do |node|
node.xpath('//tr[@class="yjM"]/td').each do |elem|
p elem.text
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def player\n fetch('football.players')\n end",
"def process_result(player, result)\n result_object = nil\n self.results.to_a.each do |result|\n if result.player == player\n result_object = result\n end\n end\n result_object.value = result\n result_object.save!\n ... | [
"0.67455804",
"0.6732204",
"0.6625955",
"0.65048957",
"0.6472798",
"0.6348107",
"0.63310355",
"0.6328632",
"0.6322905",
"0.6319979",
"0.6314105",
"0.63112116",
"0.63065255",
"0.62959766",
"0.6264064",
"0.6263592",
"0.6259248",
"0.62388766",
"0.6237642",
"0.62116575",
"0.61863... | 0.0 | -1 |
Define presentationspecific methods here. Helpers are accessed through `helpers` (aka `h`). You can override attributes, for example: def created_at helpers.content_tag :span, class: 'time' do object.created_at.strftime("%a %m/%d/%y") end end | def tinhhinh(tenant)
sql = <<-eos
select row_number() OVER(ORDER BY t.ten, t.ho_dem, t.ho) as "stt", t."msv",
concat(t."ho" ,' ', t.ho_dem,' ', t.ten) as "hovaten", to_char(t.ngay_sinh,'DD/MM/YYYY' ) as "ngaysinh",
case when t."T1"=0 then NULL else t."T1" end as "T1", case when t."T2"=0 then NULL else t."T2" end as "T2",
case when t."T3"=0 then NULL else t."T3" end as "T3", case when t."T4"=0 then NULL else t."T4" end as "T4",
case when t."T5"=0 then NULL else t."T5" end as "T5", case when t."T6"=0 then NULL else t."T6" end as "T6",
case when t."T7"=0 then NULL else t."T7" end as "T7", case when t."T8"=0 then NULL else t."T8" end as "T8",
case when t."T9"=0 then NULL else t."T9" end as "T9", case when t."T10"=0 then NULL else t."T10" end as "T10",
case when t."T11"=0 then NULL else t."T11" end as "T11", case when t."T12"=0 then NULL else t."T12" end as "T12",
case when t."T13"=0 then NULL else t."T13" end as "T13", case when t."T14"=0 then NULL else t."T14" end as "T14",
case when t."T15"=0 then NULL else t."T15" end as "T15", case when t."T16"=0 then NULL else t."T16" end as "T16",
COALESCE("T1",0) + COALESCE("T2",0)+ COALESCE("T3",0)+ COALESCE("T4",0)
+ COALESCE("T5",0)+ COALESCE("T6",0)+ COALESCE("T7",0)+ COALESCE("T8",0)+ COALESCE("T9",0)+ COALESCE("T10",0)
+ COALESCE("T11",0)+ COALESCE("T12",0)+ COALESCE("T13",0)+ COALESCE("T14",0)+ COALESCE("T15",0)
+ COALESCE("T16",0) as tonggiovang, t.diemchuyencan, t.diemthuchanh,
t.lan1 as lan1, t.lan2 as lan2, t.lan3 as lan3, round(t.diemgoctbkt, 2) as diemgoctbkt, t.diemtbkt, case when t.diemchuyencan=0 then 0 else t.diemquatrinh end as diemquatrinh,
t.note as note
from
(SELECT "msv", sv1.ho, sv1.ho_dem, sv1.ten, sv1.ngay_sinh , "T1", "T2", "T3", "T4", "T5", "T6", "T7", "T8", "T9", "T10", "T11",
"T12", "T13", "T14", "T15", "T16", COALESCE("T1",0) + COALESCE("T2",0)+ COALESCE("T3",0)+ COALESCE("T4",0)
+ COALESCE("T5",0)+ COALESCE("T6",0)+ COALESCE("T7",0)+ COALESCE("T8",0)+ COALESCE("T9",0)+ COALESCE("T10",0)
+ COALESCE("T11",0)+ COALESCE("T12",0)+ COALESCE("T13",0)+ COALESCE("T14",0)+ COALESCE("T15",0)
+ COALESCE("T16",0) as tonggiovang, sv1.diem_chuyen_can as diemchuyencan, sv1.diem_thuc_hanh as diemthuchanh,
sv1.lan1 as lan1, sv1.lan2 as lan2, sv1.lan3 as lan3, sv1.diem_goc_tbkt as diemgoctbkt, sv1.diem_tbkt as diemtbkt, sv1.diem_qua_trinh as diemquatrinh,
sv1.note as note
FROM crosstab(
'select dd.ma_sinh_vien, l.tuan, sum(CASE WHEN phep THEN 0 ELSE so_tiet_vang END ) as so_vang
from t1.diem_danhs dd
inner join t1.lich_trinh_giang_days l on l.id = dd.lich_trinh_giang_day_id
where l.lop_mon_hoc_id = #{object.id}
and dd.so_tiet_vang > 0
group by ma_sinh_vien, tuan
order by 1,2',
'select m from generate_series(1,16) m')
AS ("msv" text, "T1" int, "T2" int, "T3" int, "T4" int, "T5" int, "T6" int, "T7" int, "T8" int, "T9" int, "T10" int
, "T11" int, "T12" int, "T13" int, "T14" int, "T15" int, "T16" int)
inner join t1.lop_mon_hoc_sinh_viens sv1 on sv1.ma_sinh_vien = msv and sv1.lop_mon_hoc_id = #{object.id}
union all
select ma_sinh_vien as "msv", ho, ho_dem, ten, ngay_sinh, 0 as "T1", 0 as "T2",
0 as "T3", 0 as "T4", 0 as "T5", 0 as "T6",
0 as "T7", 0 as "T8", 0 as "T9", 0 as "T10", 0 as "T11", 0 as "T12",
0 as "T13", 0 as "T14", 0 as "T15", 0 as "T16", 0 as tongiovang , diem_chuyen_can , diem_thuc_hanh as diemthuchanh,
lan1, lan2, lan3, diem_goc_tbkt as diemgoctbkt, diem_tbkt as diemtbkt, diem_qua_trinh as diemquatrinh, note as note
from t1.lop_mon_hoc_sinh_viens where (status is NULL or status != true) and lop_mon_hoc_id=#{object.id} and ma_sinh_vien not in (select dd.ma_sinh_vien
from t1.diem_danhs dd
inner join t1.lich_trinh_giang_days l on l.id = dd.lich_trinh_giang_day_id
where l.lop_mon_hoc_id = #{object.id}
and dd.so_tiet_vang > 0)
) as t
order by t.ten, t.ho_dem, t.ho, t.ngay_sinh
eos
@res = ActiveRecord::Base.connection.execute(sql)
pdf = Prawn::Document.new(:page_layout => :landscape,
:page_size => 'A4', :margin => 20)
#pdf.font "#{Rails.root}/app/assets/fonts/arial.ttf"
pdf.font_families.update(
'Arial' => { :normal => Rails.root.join('app/assets/fonts/arial2.ttf').to_s,
:bold => Rails.root.join('app/assets/fonts/arialbd.ttf').to_s,
:italic => Rails.root.join('app/assets/fonts/arialbi.ttf').to_s}
)
cell_width = 40
row_height = 120
img_path = "#{Rails.root}/public/images/logo.png"
pieces = [[img_path, ""]]
pieces.each do |p|
#pdf.move_down 5 # a bit of padding
cursor = pdf.cursor
p.each_with_index do |v,j|
pdf.bounding_box [cell_width*j, cursor], :height => 80, :width => ( j == 0 ? cell_width : 780) do
if j == 0
pdf.image v, :width => 40
else
pdf.font "Arial"
t1 = pdf.make_table [["BỘ GIÁO DỤC VÀ ĐÀO TẠO"],["TRƯỜNG ĐẠI HỌC DÂN LẬP HẢI PHÒNG"],[""],[""]], :width => 260, :cell_style => {:align => :center, :valign => :center, :size => 10, :height => 20, :borders => []}
t2 = pdf.make_table [[" BẢNG THEO DÕI TÌNH HÌNH MÔN HỌC"]], :width => 480, :cell_style => {:valign => :center, :size => 10, :font_style => :bold, :height => 20, :borders => []} do
row(0).columns(0).padding_left = 40
end
t3 = pdf.make_table [
["Môn học: #{object.ten_mon_hoc}","", "Tổng số tiết:....."],
["Giáo viên phụ trách: #{object.ten_giang_vien}","", "Lý thuyết:....."],
["Lớp: #{object.ma_lop} Kỳ: #{tenant.hoc_ky} Năm học: #{tenant.nam_hoc}","", "Thực hành, thí nghiệm:....."]
], :cell_style => {:size => 9, :height => 20, :borders => []}, :width => 480, :column_widths => { 0 => 210, 1 => 100, 2 => 170} do
row(0).columns(0).font_style = :bold
end
t4 = pdf.make_table [[t2], [t3]], :cell_style => {:borders => []}
t0 = pdf.make_table [[""]], :width => 20, :cell_style => {:borders => []}
pdf.table [
[
t0,
t1,
t0,
t4
]
] , :cell_style => {:borders => []}
end
end
end
end
pdf.move_down(5)
@res = @res.to_a
m = @res.each_slice(19).to_a if @res.count <= 19
if @res.count > 19
m1 = @res[0..18]
m2 = @res[19..-1].each_slice(23).to_a
m = m2.unshift(m1)
end
page_count = m.count
m.each_with_index do |m1, index|
pdf.font "Arial"
items1 = m1.map {|i| [i["stt"], i["msv"], i["hovaten"], i["ngaysinh"]]}
mtable01 = pdf.make_table [["Stt", "Mã SV", "Họ và tên", "Ngày sinh"]], :width => 240, :cell_style => {:align => :center, :valign => :center, :size => 7.5, :height => 50}, :column_widths => {1 => 52, 2 => 115, 3 => 50}
mtable02 = pdf.make_table items1, :width => 240, :cell_style => {:align => :center, :valign => :center, :size => 7.5, :height => 20}, :column_widths => {1 => 52, 2 => 115, 3 => 50} do
(0..items1.length).each do |l|
row(l).columns(2).align = :left
end
end
items2 = m1.map {|item|
[item["T1"],item["T2"],item["T3"],item["T4"],item["T5"],item["T6"],item["T7"],item["T8"],item["T9"],item["T10"],item["T11"],item["T12"],item["T13"],item["T14"],item["T15"],item["T16"],
item["tonggiovang"], item["diemchuyencan"]]}
items3 = @res.map {|item| [item["lan1"], item["lan2"], item["lan3"], item["diemtbkt"]]}
mytable0 = pdf.make_table [["Điểm danh"]], :width => 370, :cell_style => {:align => :center, :valign => :center, :size => 7.5, :height => 20, :font_style => :bold}
mytable01 = pdf.make_table [["T1","T2","T3","T4","T5","T6","T7","T8","T9","T10","T11","T12","T13","T14","T15","T16","Tổng giờ vắng", "Điểm chuyên cần"]] + items2, :width => 370, :cell_style => {:align => :center, :valign => :center, :size => 7, :height => 20}, :header => true do
(0..items2.length).each do |l|
row(l).columns(16).width = 25
row(l).columns(17).width = 25
end
row(0).columns(16).size = 5
row(0).columns(17).size = 5
(0..17).each do |t|
row(0).columns(t).height = 30
end
end
items3 = m1.map {|i| [i["diemthuchanh"]]}
mtable11 = pdf.make_table [["Điểm TH, TN, BTL, ĐA"]] + items3, :width => 22, :cell_style => {:align => :center, :valign => :center, :size => 7, :height => 20} do
row(0).columns(0).height = 50
row(0).columns(0).size = 5
end
items4 = m1.map {|i| [i["lan1"], i["lan2"], i["lan3"], i["diemgoctbkt"], i["diemtbkt"]]}
mtable2 = pdf.make_table [["Điểm kiểm tra thường xuyên"]], :width => 110, :cell_style => {:align => :center, :valign => :center, :size => 7.5, :height => 20}
mtable21 = pdf.make_table [["Lần 1", "Lần 2", "Lần 3", "TB Kiểm tra", "Quy điểm QT"]] + items4, :width => 110, :cell_style => {:align => :center, :valign => :center, :size => 7, :height => 20} do
(0..4).each do |i|
row(0).columns(i).size = 5
row(0).columns(i).height = 30
end
end
items5 = m1.map {|i| [i["diemquatrinh"], i["note"]]}
mtable31 = pdf.make_table [["Tổng điểm QT", "Ghi chú"]] + items5, :cell_style => {:align => :center, :valign => :center, :size => 7, :height => 20}, :column_widths => {0 => 20, 1 => 39} do
(0..1).each do |i|
row(0).columns(i).height = 50
row(0).columns(i).size = 5
end
row(0).columns(1).size = 7.5
end
#mytable1 = pdf.make_table [[mytable0],[mytable01]]
#mtable0 = pdf.make_table [["Điểm kiểm tra thường xuyên"]], :width => 80, :cell_style => {:align => :center, :size => 7}
#mtable01 = pdf.make_table [["Lần 1", "Lần 2", "Lần 3", "TB Kiểm tra"]] + items3, :width => 80, :cell_style => {:align => :center, :size => 7}
pdf.table [
[
[
[mtable01],[mtable02]
],
[
[mytable0],[mytable01]
],
[
[mtable11]
],
[
[mtable2],[mtable21]
],
[
[mtable31]
]
]
]
#pdf.start_new_page(:margin => 20) unless index == page_count
end
pdf.move_down 2
d = DateTime.now
#pdf.text "Duyệt #{object.sosvtucach} sinh viên được dự thi kết thúc học phần", :style => :italic, :size => 8
pdf.table [["Duyệt #{object.sosvtucach} sinh viên được dự thi kết thúc học phần","",""],["","", "Hải phòng, ngày #{d.day} tháng #{d.month} năm #{d.year}"]], :cell_style => {:font_style => :italic, :size => 8, :borders => []}, :column_widths => {0 => 270, 1 => 270, 2 => 260} do
row(1).columns(2).padding_left = 20
end
pdf.move_down 2
str = "Ghi chú:\n- Khi SV vắng đề nghị Thầy, Cô ghi cụ thể số tiết vắng.\nVí dụ V: có nghĩa SV vắng 3 tiết\n-Trước khi thi 7 ngày, giáo viên dạy môn học nộp bảng theo dõi cho Chủ nhiệm Bộm môn để duyệt tư cách dự thi cho sinh viên."
pdf.table [[str, "CHỦ NHIỆM BỘ MÔN","GIÁO VIÊN PHỤ TRÁCH MÔN HỌC"]], :cell_style => {:borders => []}, :column_widths => {0 => 270, 1=> 270, 2 => 260} do
row(0).columns(0).font_style = :italic
row(0).columns(0).size = 8
row(0).columns(1).font_style = :bold
row(0).columns(1).size = 12
row(0).columns(2).font_style = :bold
row(0).columns(2).size = 12
row(0).columns(1).padding_left = 50
#row(0).columns(2).padding_left = 0
end
pdf.repeat(:all) do
pdf.draw_text "QC07-B10", :at => [10, -10]
#pdf.stamp "approved"
end
#items.unshift ["Stt","Mã SV","Họ và tên","Ngày sinh",mytable1, "Điểm TH, TN, BTL, ĐA", mtable1, "Tổng điểm QT", "Ghi chú"]
return pdf
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def created_at_tag\n\t\th.content_tag :span, class: \"time\" do\n\t\t\th.record_time(self.created_at)\n\t\tend\n\tend",
"def time_to_show\n \n end",
"def helper_attr(*attrs); end",
"def helpers; end",
"def helpers; end",
"def helpers; end",
"def helper_method(*methods); end",
"def generic_datetim... | [
"0.56274575",
"0.55946475",
"0.5579922",
"0.5577153",
"0.5577153",
"0.5577153",
"0.54848754",
"0.5463937",
"0.5424053",
"0.53894657",
"0.53867865",
"0.53251934",
"0.5260905",
"0.52599233",
"0.525774",
"0.52575165",
"0.52547544",
"0.52439296",
"0.52416784",
"0.5238507",
"0.522... | 0.0 | -1 |
this sets up Postgres and Redis with Docker | def setup_databases
postgres_user = app_name
postgres_pass = SecureRandom.urlsafe_base64
postgres_port = find_open_port
redis_port = find_open_port
add_env "REDIS_URL",
"redis://localhost:#{redis_port}"
add_env "DATABASE_URL",
"postgres:///#{postgres_user}:#{postgres_pass}@localhost:#{postgres_port}",
skip_secrets: true
template "database.yml",
"#{app_name}/config/database.yml",
force: true
template "docker-compose.yml",
"#{app_name}/docker-compose.yml",
postgres_user: postgres_user,
postgres_pass: postgres_pass,
postgres_port: postgres_port,
redis_port: redis_port
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def docker_rebuild\n docker_composersh(true)\n docker_npmsh(true)\n docker_updb\n docker_compose_stop(false)\n docker_compose_up\n end",
"def install_postgres(ssh)\n ssh.exec! 'sudo docker exec advocatedefencepayments apt-get update'\n ssh.exec! 'sudo docker exec advocatedefencepaym... | [
"0.5880681",
"0.57654816",
"0.5752665",
"0.5746349",
"0.5708063",
"0.5683921",
"0.5682463",
"0.5658939",
"0.56256086",
"0.56075984",
"0.55506337",
"0.54528856",
"0.5438421",
"0.54377085",
"0.5432454",
"0.54306495",
"0.5412008",
"0.5389455",
"0.5367762",
"0.5360638",
"0.535770... | 0.7244435 | 0 |
this is an attempt to prevent port collisions when multiple postgres databases are being run on the same development machine. finding a free port: | def find_open_port
server = TCPServer.new('127.0.0.1', 0)
port = server.addr[1]
server.close
port
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_instance_port\n data[:db_instance_port]\n end",
"def port\n @port || 5432\n end",
"def port\n @port || 5439\n end",
"def listening_port\n @dbi.endpoint.port\n end",
"def listening_port\n @dbi.endpoint.port\n end",
"def host_with_port;... | [
"0.7233625",
"0.7096149",
"0.7014172",
"0.66743547",
"0.66743547",
"0.6663044",
"0.6596927",
"0.6596927",
"0.6476827",
"0.6458341",
"0.6435473",
"0.642774",
"0.63843924",
"0.63820136",
"0.6297182",
"0.62127936",
"0.6211216",
"0.62015885",
"0.6162978",
"0.614856",
"0.6136325",... | 0.5801421 | 58 |
Keys are grades, values are arrays of names. | def add(name, grade)
rosters[grade] <<= name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def final_letter_grades(grade_hash)\n letter_grade_array = grade_hash.map do |key, value|\n average = value.sum / value.length\n letter_grade = letter_grade(average)\n [key, letter_grade]\n end\n letter_grade_array.to_h\nend",
"def gradeAll( studentArr, keyString )\n grades = []\n studentArr.... | [
"0.6690197",
"0.6642959",
"0.6589186",
"0.658145",
"0.6543291",
"0.65139455",
"0.64985377",
"0.6465862",
"0.64612156",
"0.6343726",
"0.62517935",
"0.6213951",
"0.61614376",
"0.61542577",
"0.6131761",
"0.61124223",
"0.6096612",
"0.6069909",
"0.6053535",
"0.6049203",
"0.6033695... | 0.0 | -1 |
Returns empty array if no students exist in the grade. | def students(grade)
sorted_roster[grade] || []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def students\n @students ||= []\nend",
"def student_array\n @students1 = []\n @selected_students = User.only_students\n @students1 << @selected_students\n end",
"def social_students\n students = @students.keys\n Array.new(@matrix.size) do |i|\n @matrix[i].one?(0) ? students[i] : nil\n... | [
"0.6682656",
"0.66452193",
"0.6545231",
"0.6378535",
"0.61933607",
"0.6142368",
"0.61257654",
"0.61257654",
"0.61237615",
"0.6091389",
"0.6040423",
"0.59985054",
"0.5998347",
"0.5997794",
"0.59873915",
"0.5983654",
"0.59682333",
"0.593241",
"0.5901921",
"0.58921057",
"0.58912... | 0.75225896 | 0 |
Sort keys and values in the roster. | def sorted_roster
@sorted_roster ||= rosters.transform_values(&:sort).sort.to_h
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort\r\n @roster.each do |key, value|\r\n value.sort!\r\n end\r\n end",
"def sort\n self.roster.reduce({}) do |roster, (key,value)|\n roster[key] = value.sort\n roster\n end\n end",
"def sort\n@roster.each do |key,value|\n value.sort!\nend \nend",
"de... | [
"0.81699806",
"0.80964416",
"0.7564693",
"0.7157187",
"0.7131608",
"0.69609636",
"0.69609636",
"0.69325775",
"0.69243205",
"0.69122845",
"0.69102556",
"0.68778086",
"0.68132234",
"0.6806685",
"0.66725475",
"0.66668344",
"0.6608377",
"0.6600274",
"0.6559181",
"0.6472502",
"0.6... | 0.688988 | 11 |
Looks up the title with the IMDb ID `imdb_id` and returns a FilmBuff::Title object with information on that title. | def find_by_id(imdb_id)
result = self.class.get('/title/maindetails', :query => {
:tconst => imdb_id, :locale => @locale
}).parsed_response
Title.new(result['data'])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_title(imdb_id, refresh: false)\n query = build_load_title_query(imdb_id)\n ensure_call(query, refresh)\n end",
"def get_movie_bio(id)\n doc = Nokogiri::HTML(open(IMDB_URL + \"/title/\" + id))\n title = doc.css(\"h1.header\").text.split(\"\\n\").delete_if {|x| x==\"\"}.first\n bio = doc.c... | [
"0.6822921",
"0.6317282",
"0.6086545",
"0.59984475",
"0.59519434",
"0.59348744",
"0.592834",
"0.592834",
"0.5815147",
"0.5793296",
"0.57099706",
"0.57077503",
"0.5679168",
"0.56737316",
"0.5623866",
"0.56177694",
"0.56177694",
"0.56177694",
"0.56177694",
"0.56177694",
"0.5614... | 0.7925968 | 0 |
Searches IMDb for `title` and returns an array with results. | def find_by_title(title, options = {})
options = {
limit: nil,
types: %w(title_popular title_exact title_approx title_substring)
}.merge!(options)
result = self.class.get('http://www.imdb.com/xml/find', :query => {
:q => title,
:json => '1',
:tt => 'on'
}).parsed_response
results = []
options[:types].each do |key|
if result[key]
result[key].each do |row|
break unless results.size < options[:limit] if options[:limit]
next unless row['id'] && row['title'] && row['description']
title = {
type: key,
imdb_id: row['id'],
title: row['title'],
release_year: row['description'].scan(/\A\d{4}/).first
}
results << title
end
end
end
results
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def info_by_title(title)\n for book in @array_of_books\n return book if :title == title\n end\n end",
"def by_title(title)\n Pages::Finder.by_title(title)\n end",
"def search_for_title(title)\n parameters = {\n 'folderId' => find_public_folder,\n 'q'... | [
"0.72640723",
"0.70671767",
"0.6986813",
"0.6945485",
"0.6863569",
"0.6781755",
"0.67399883",
"0.66593623",
"0.6651993",
"0.6566961",
"0.65431374",
"0.6515415",
"0.65057635",
"0.6482987",
"0.64660704",
"0.63759863",
"0.6372576",
"0.6355444",
"0.63532907",
"0.6352684",
"0.6344... | 0.79815954 | 0 |
ie only one 001 for ESE 451 other_obj is either a Section Timing or Recitation object if self overlaps with other_section, it returns TRUE | def overlaps_with?(other_obj)
self.meetings.each do |self_meeting|
other_obj.meetings.each do |other_meeting|
return true if self_meeting.overlaps_with? other_meeting
end
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def meeting_conflict?(other)\n return false if self.start_time.nil? or other.start_time.nil?\n section_days = other.days.split(\"\")\n section_days.each do |day|\n if( self.days.include?(day) )\n if (self.start_time.to_i >= other.start_time.to_i and self.start_time.to_i <= other.end_time.to_i)... | [
"0.63493615",
"0.631084",
"0.62181866",
"0.62181866",
"0.62181866",
"0.6085366",
"0.6005303",
"0.5991096",
"0.5991096",
"0.58462954",
"0.5816342",
"0.580519",
"0.580519",
"0.579803",
"0.57301986",
"0.57259583",
"0.57114613",
"0.5701823",
"0.5696924",
"0.5653547",
"0.56518596"... | 0.66300875 | 0 |
Configures consumer key/secret pair and OAuth access token/secret pair | def authenticate
client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV['CONSUMER_KEY']
config.consumer_secret = ENV['CONSUMER_SECRET']
config.access_token = ENV['ACCESS_TOKEN']
config.access_token_secret = ENV['ACCESS_TOKEN_SECRET']
end
return client
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def consumer_secret; config[:consumer_secret]; end",
"def configure(consumer_key, consumer_secret, oauth_version = nil, oauth_cipher = nil, twitter_api = nil)\n @consumer_key = consumer_key\n @consumer_secret = consumer_secret\n\n @oauth_version = oauth_version || OAUTH_VERSION\n @oauth_ciphe... | [
"0.78987855",
"0.765192",
"0.76461506",
"0.7514115",
"0.75032663",
"0.742006",
"0.732101",
"0.7271736",
"0.72071326",
"0.7134413",
"0.7134413",
"0.7134413",
"0.7134413",
"0.7134413",
"0.7134413",
"0.7134413",
"0.7134413",
"0.7134413",
"0.7134413",
"0.7134413",
"0.7134413",
... | 0.0 | -1 |
Returns tweet IDs of the search results | def search_tweets
results = []
client = authenticate
# Search tweets using 'twitter' gem
client.search('100DaysOfCode -rt Day' + @day.to_s, result_type: 'recent')
.take(5).each do |tweet|
results.push(tweet.id)
end
return results
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_search_results\n response = twitter_account.client.search(query, search_options)\n statuses = response.statuses\n tweets = TweetMaker.many_from_twitter(statuses, project: project, twitter_account: twitter_account, state: state)\n update_max_twitter_id(tweets.map(&:twitter_id).max)\n tweets... | [
"0.7092528",
"0.68861765",
"0.68849635",
"0.67591304",
"0.66997623",
"0.6674551",
"0.66521615",
"0.66448486",
"0.6610626",
"0.6603498",
"0.65283054",
"0.65199375",
"0.6481842",
"0.6480454",
"0.64713687",
"0.64683264",
"0.644055",
"0.63642406",
"0.63503593",
"0.63416386",
"0.6... | 0.76077104 | 0 |
rubocop:disable CyclomaticComplexity rubocop:disable AbcSize | def message_valid?(lti_message)
# check for duplicate nonce
return false if nonce_exists?(lti_message.oauth_nonce)
# check if nonce too old
return false if DateTime.strptime(lti_message.oauth_timestamp, "%s") < 5.minutes.ago
# check if required params are provided
return false unless VALID_MESSAGE_TYPES.include? lti_message.lti_message_type
return false unless VALID_LTI_VERSIONS.include? lti_message.lti_version
# check required params for message type
if lti_message.lti_message_type == "basic-lti-launch-request"
return false unless lti_message.resource_link_id
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def implementation; end",
"def implementation; end",
"def big_bad; end",
"def my_size\n 1\n end",
"def private_method\n end",
"def probers; end",
"def size=(_); end",
"def size=(_); end",
"def size; end",
"def size; end",
"def size; end",
"def size; end",
... | [
"0.7175343",
"0.59358597",
"0.59358597",
"0.5840731",
"0.5724961",
"0.57191986",
"0.5687614",
"0.56592673",
"0.56592673",
"0.5657667",
"0.5657667",
"0.5657667",
"0.5657667",
"0.5657667",
"0.5657667",
"0.5657667",
"0.5657667",
"0.5657667",
"0.5657667",
"0.5657667",
"0.5657667"... | 0.0 | -1 |
rubocop:enable AbcSize rubocop:enable CyclomaticComplexity | def save_message(lti_message)
nonce = lti_message.oauth_nonce
scoped = scoped_nonce(nonce)
if @redis_store.set(scoped, lti_message.to_json)
nonce
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def implementation; end",
"def implementation; end",
"def probers; end",
"def schubert; end",
"def used?; end",
"def common\n \n end",
"def strategy; end",
"def operations; end",
"def operations; end",
"def executor; end",
"def executor; end",
"def executor; end",
... | [
"0.73168564",
"0.6148597",
"0.6148597",
"0.59668696",
"0.58779424",
"0.58350354",
"0.57743883",
"0.57664084",
"0.5756395",
"0.5756395",
"0.5742986",
"0.5742986",
"0.5742986",
"0.5738895",
"0.5732215",
"0.5732215",
"0.5732215",
"0.5732215",
"0.57264286",
"0.57264286",
"0.57216... | 0.0 | -1 |
Returns a nonce unique across LMSs | def scoped_nonce(nonce)
"#{@consumer_key}-#{nonce}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nonce\n ((Time.now.to_f * 1000000).to_i << 10).to_s\n end",
"def nonce\n Array.new( 5 ) { rand(256) }.pack('C*').unpack('H*').first\n end",
"def nonce\n Array.new( 5 ) { rand(256) }.pack('C*').unpack('H*').first\n end",
"def nonce\n @nonce ||= Digest::SHA1.hexdigest random_st... | [
"0.8423879",
"0.83863264",
"0.8379633",
"0.82966995",
"0.82966995",
"0.81646377",
"0.77559257",
"0.7751358",
"0.7662128",
"0.7555174",
"0.7515458",
"0.7355668",
"0.73279417",
"0.7293969",
"0.72141784",
"0.7091497",
"0.700404",
"0.6973476",
"0.68822783",
"0.68709964",
"0.66708... | 0.62577206 | 30 |
before_action :require_user, only: [:new, :create] | def index
@subjects = Subject.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def require_user\n end",
"def require_user\n unless current_user\n flash[:error] = 'Es necesario que te identifiques primero.'\n redirect_to root_path\n end\n end",
"def require_user\n redirect_to '/login' unless current_user\n end",
"def require_user\n redirect_to '/login' unless cu... | [
"0.79028857",
"0.7129006",
"0.7083276",
"0.7083276",
"0.70722985",
"0.7054356",
"0.7043774",
"0.7043774",
"0.70374304",
"0.6989052",
"0.69869244",
"0.6912618",
"0.68770516",
"0.6875016",
"0.68725246",
"0.68310297",
"0.68278766",
"0.681795",
"0.6806629",
"0.67950714",
"0.67948... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def subject_params
params.require(:subject).permit(:name, :grade, :tutor_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6980629",
"0.67819995",
"0.67467666",
"0.67419875",
"0.67347664",
"0.65928614",
"0.6504013",
"0.6498014",
"0.64819515",
"0.64797956",
"0.64562726",
"0.64400834",
"0.6380117",
"0.6377456",
"0.63656694",
"0.6320543",
"0.63002014",
"0.62997127",
"0.629425",
"0.6293866",
"0.62... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_ocr
@ocr = Ocr.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 ocr_params
params.require(:ocr).permit(:image_ref)
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 |
Put backup file (path_to_backup_file) to destination No return value is expected | def backup(path_to_backup_file)
logger.info "Uploading backup to FTP: #{worker.user_host_and_dir}"
@worker.connect_and_put_file path_to_backup_file
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backup\n FileUtils.cp options[:file], backup_file if File.file? options[:file]\n end",
"def backup\n self.keep_backup && !File.exists?( backup_path ) && FileUtils.cp( self.resource.path, backup_path )\n end",
"def backup_existing_file(file_path)\n FileUtils.move(file_path, \"#{file_pat... | [
"0.7891723",
"0.73758966",
"0.7373626",
"0.7373298",
"0.7322145",
"0.72343874",
"0.70861584",
"0.70764875",
"0.7018867",
"0.70106435",
"0.6966551",
"0.69650525",
"0.69589335",
"0.6896354",
"0.68834597",
"0.68570846",
"0.68024176",
"0.6765157",
"0.66924",
"0.66020775",
"0.6589... | 0.7850304 | 1 |
Shows the list of files stored currently at destination with file names starting with 'backup_name' Returns an array of twoelement arrays: [backup_file_name, modification_time] | def get_backups_list(backup_name)
logger.info "Getting the list of backups from FTP: #{worker.user_host_and_dir}"
@worker.get_files_list backup_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list\n \tputs \"The list of backups for #{self.name}\"\n \tself.each do |bck|\n \t puts bck.filepath\n \tend\n end",
"def all_backup_names(backup_options = nil)\n backup_options ||= @backup_options\n all_possible_file_names = []\n total_possible_file_names = backup_options[:backups... | [
"0.71325743",
"0.6801945",
"0.6401834",
"0.63968277",
"0.6317206",
"0.6194479",
"0.61843896",
"0.6165175",
"0.6040318",
"0.59034085",
"0.59023494",
"0.58517957",
"0.5844049",
"0.583708",
"0.57658046",
"0.5740823",
"0.57377887",
"0.5728378",
"0.56935996",
"0.5656098",
"0.56529... | 0.7641654 | 0 |
Restoring: put backup file into dir | def restore(backup_name, dir)
logger.info "Downloading backup from FTP: #{worker.user_host_and_dir}"
@worker.connect_and_get_file backup_name, File.join(dir, backup_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backup\n self.keep_backup && !File.exists?( backup_path ) && FileUtils.cp( self.resource.path, backup_path )\n end",
"def backup!(file=nil)\n file = file || FILENAME\n dir = root + BACKUP_DIRECTORY\n FileUtils.mkdir(dir.dirname) unless dir.dirname.directory?\n FileUtils.mkdir(dir) unl... | [
"0.7100377",
"0.69689095",
"0.6772103",
"0.67137116",
"0.66304153",
"0.66145474",
"0.66052413",
"0.65967804",
"0.65820855",
"0.65776044",
"0.6569594",
"0.6558253",
"0.6486892",
"0.6474438",
"0.63681847",
"0.63473314",
"0.633907",
"0.6322108",
"0.62455875",
"0.6243888",
"0.624... | 0.634835 | 15 |
Schema for the root scope of the client | def schema
@schema ||= Schema::Scope.new(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schema\n []\n end",
"def schema\n @schema ||= []\n end",
"def schema\n connection.schema\n end",
"def schema\n self.class.schema\n end",
"def schema\n self\n end",
"def structure\n {\n domain_name: @name,\n schemas: @schemas... | [
"0.6800913",
"0.6740712",
"0.6539227",
"0.649422",
"0.6463711",
"0.64139605",
"0.64033926",
"0.6360223",
"0.6350978",
"0.63280797",
"0.6313201",
"0.6229393",
"0.62260014",
"0.6141348",
"0.6136951",
"0.6130272",
"0.61109364",
"0.60941",
"0.60519797",
"0.6049266",
"0.60222644",... | 0.6776674 | 1 |
Logger for the root scope | def logger
@scope.logger
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"... | [
"0.7359987",
"0.7359987",
"0.7359987",
"0.7359987",
"0.7359987",
"0.7359987",
"0.7359987",
"0.7359987",
"0.7359987",
"0.7359987",
"0.7359987",
"0.7359987",
"0.7359987",
"0.7359987",
"0.7359987",
"0.7359987",
"0.7359987",
"0.7359987",
"0.7359987",
"0.7324177",
"0.7246443",
"... | 0.69510186 | 26 |
Sets logger to the client | def logger=(logger)
@scope.logger = logger
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_logger\n logger = CarrotRpc::ServerRunner::Logger.configured\n CarrotRpc.configuration.logger = logger\n\n logger\n end",
"def set_logger(logger)\n LOGGER.set_logger(logger)\n end",
"def set_logger(logger)\n @logger = logger\n end",
"def set_logger(logger)\n @lo... | [
"0.7774117",
"0.7764709",
"0.7746512",
"0.7728797",
"0.7653686",
"0.76300746",
"0.76085836",
"0.7598259",
"0.749433",
"0.749433",
"0.749433",
"0.749433",
"0.749433",
"0.749433",
"0.749433",
"0.749433",
"0.7485997",
"0.7485997",
"0.7460973",
"0.74333924",
"0.74333924",
"0.74... | 0.6810033 | 40 |
Operations defined at the root of the client | def operations
@scope.operations
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def operations\n # Base URI works as-is.\n end",
"def operations\n @client.operations\n end",
"def operations; end",
"def operations; end",
"def subcommands() __subcommands__ end",
"def root_updates\n @root_update_operations\n end",
"def operation; end",
"def cli... | [
"0.69526553",
"0.6883848",
"0.68611926",
"0.68611926",
"0.6522155",
"0.64091384",
"0.6329956",
"0.6081247",
"0.6081247",
"0.6076223",
"0.60736346",
"0.6012883",
"0.6012883",
"0.6001326",
"0.6001326",
"0.5998186",
"0.5998186",
"0.5998186",
"0.5998186",
"0.593058",
"0.593058",
... | 0.5396094 | 99 |
Subscopes of client root | def scopes
@scope.scopes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subsets_scopes\n @subsets_scopes\n end",
"def namespace_scopes\n super\n end",
"def scopes; end",
"def policy_scopes; end",
"def subsets_scope name\n subsets_scopes[name] || []\n end",
"def subscope\n self.clone\n end",
"def default_scopes\n Doorkeeper.config.... | [
"0.65956974",
"0.6492547",
"0.6219309",
"0.59139943",
"0.5833284",
"0.58062905",
"0.5768138",
"0.56281006",
"0.5606272",
"0.5563817",
"0.5538551",
"0.5508693",
"0.5485623",
"0.5475097",
"0.546129",
"0.54605603",
"0.54605556",
"0.5454376",
"0.54187566",
"0.54168034",
"0.541584... | 0.55363894 | 11 |
Settings of the client | def settings
@scope.settings
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_clients_setting\n @clients = current_client\n end",
"def connection_status_client_setting; end",
"def configure_client(options={})\n socket.client.set(options)\n end",
"def set_settings(args)\n XingApi::Client.configure do |config|\n config.consumer_key = arg... | [
"0.710436",
"0.70911056",
"0.70498204",
"0.689776",
"0.67488545",
"0.6743251",
"0.6684325",
"0.66840816",
"0.66799635",
"0.66793007",
"0.66793007",
"0.6664358",
"0.66497785",
"0.6645994",
"0.659106",
"0.65843004",
"0.65113854",
"0.6498173",
"0.64821875",
"0.6467688",
"0.64482... | 0.0 | -1 |
Options assigned to the client | def options
@scope.options
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def options() end",
"def client_options \n []\n end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def op... | [
"0.7876262",
"0.7856268",
"0.78001267",
"0.78001267",
"0.78001267",
"0.78001267",
"0.78001267",
"0.78001267",
"0.78001267",
"0.78001267",
"0.78001267",
"0.78001267",
"0.78001267",
"0.78001267",
"0.78001267",
"0.78001267",
"0.78001267",
"0.78001267",
"0.78001267",
"0.78001267",
... | 0.0 | -1 |
Humanreadable representation of the client | def inspect
vars = options.map { |k, v| "@#{k}=#{v}" }.join(", ")
"#<#{self.class}:#{format('0x%014x', object_id)} #{vars}>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n \"#<#{self.class.name}:0x#{object_id.to_s(16).rjust(14, \"0\")} host='#{client.host}'>\"\n end",
"def client_name; end",
"def server\n @server.to_s\n end",
"def to_s\n \"#{@client ? 'Connected' : 'Connection not currently established'} to #{host} on #{port}\"\n end",
"def... | [
"0.7123565",
"0.68343747",
"0.6706288",
"0.6689706",
"0.6688653",
"0.66627264",
"0.6641018",
"0.6623178",
"0.66078067",
"0.6577009",
"0.656763",
"0.6538871",
"0.6530192",
"0.64746946",
"0.6471959",
"0.6465178",
"0.64207155",
"0.6393898",
"0.6376882",
"0.6366806",
"0.6347",
... | 0.0 | -1 |
Import the test cases for this test set | def import test_cases
raise TypeError, "File list must be an Array, got #{test_cases.class}" unless test_cases.is_a? Array
test_cases.each do |test_case|
puts "%20s : %s" % ['Adding ' + self.class.type, test_case] if RubyUnit.debug
require test_case
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_cases\n @test_cases ||= Dir.glob(model.spec_dir + '**/**/?*Spec.as')\n end",
"def tests\n @tests ||= begin\n require \"m/test_collection\"\n require \"m/test_method\"\n # With each suite and array of tests,\n # and with each test method present in this test file,\n ... | [
"0.6650046",
"0.6586982",
"0.6494648",
"0.6475976",
"0.6284801",
"0.62732685",
"0.6201985",
"0.6155451",
"0.61497474",
"0.61301845",
"0.60653716",
"0.6032892",
"0.6011453",
"0.6011453",
"0.6003718",
"0.5963905",
"0.59533954",
"0.59193456",
"0.5912376",
"0.5911937",
"0.5863195... | 0.8207525 | 0 |
Deprecated: this method was not present in the io.adafruit.com API. This method will be removed in v2.0.0 | def groups(*args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ios; end",
"def EVIOCGLED(len); _IOC(_IOC_READ, 'E', 0x19, len);end",
"def data_battler\n return nil\n end",
"def data_battler\n return nil\n end",
"def cycle_level_arduino_code\n []\n end",
"def chip_api\n Settings.check_in.chip_api\n end",
"def check_devices\n\n\n en... | [
"0.56760323",
"0.5426041",
"0.5271605",
"0.5271605",
"0.52657557",
"0.5219956",
"0.5212765",
"0.51636183",
"0.51478237",
"0.5127218",
"0.51167345",
"0.5108486",
"0.5086694",
"0.5044204",
"0.5043849",
"0.50344044",
"0.50304824",
"0.50058776",
"0.4996052",
"0.49612105",
"0.4947... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.