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 |
|---|---|---|---|---|---|---|
Returns a more optimistic number of days for the advert's number of months than Rails. Advert.new(months: 1).days => 31 days Advert.new(months: 12).days => 366 days | def days
Advert.days_for_months(months)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def months() 30 * days end",
"def days_in_month\n Time.send(\"month_days\", self.year, self.month)\n end",
"def months ; self * 30.days ; end",
"def count_of_days_in(month)\n 28 + (month + (month / 8)) % 2 + 2 % month + 2 * (1 / month)\nend",
"def get_number_of_month\n (1..is_leap?[adjust_set_month... | [
"0.71592736",
"0.69830185",
"0.69499636",
"0.6905726",
"0.6893555",
"0.6877437",
"0.68510085",
"0.67756015",
"0.67756015",
"0.6754806",
"0.6584703",
"0.65720123",
"0.6569128",
"0.6564022",
"0.6537813",
"0.6536414",
"0.65358543",
"0.65118",
"0.64920413",
"0.6485729",
"0.648054... | 0.79915094 | 0 |
Records a view or impression of this advert and saves the model. | def record_view
self.views += 1
save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @advert = Advert.new(advert_params)\n @advert.user = current_user\n @advert.views = 0\n respond_to do |format|\n if @advert.save\n format.html { redirect_to @advert, notice: 'Advert was successfully created.' }\n format.json { render :show, status: :created, location: @a... | [
"0.6418155",
"0.6278408",
"0.6051251",
"0.5970317",
"0.58288646",
"0.57167304",
"0.57050765",
"0.5660665",
"0.5660665",
"0.56592137",
"0.5648502",
"0.56454253",
"0.56358993",
"0.56009614",
"0.55866325",
"0.557197",
"0.5562113",
"0.5551538",
"0.55477655",
"0.55420816",
"0.5522... | 0.65378785 | 0 |
Returns true if this advert both starts at and expires at before now. | def old?
starts_at && (starts_at + days < Time.zone.now && expires_at < Time.zone.now)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expired?(now)\n @expires_at <= now\n end",
"def expires? \n (Time.now.to_f*1000 - Trace.active_time) > @start_time\n end",
"def expired?\n expires_at && expires_at <= Time.now\n end",
"def active?\n starts_at < Time.now && Time.now < ends_at\n end",
"def expired?\n ... | [
"0.76168627",
"0.75977355",
"0.7561602",
"0.74301785",
"0.7407379",
"0.7407379",
"0.73950326",
"0.73773086",
"0.7362334",
"0.7358029",
"0.7341834",
"0.73160005",
"0.73104644",
"0.7290843",
"0.7286016",
"0.727408",
"0.7245331",
"0.7224101",
"0.7224101",
"0.7218024",
"0.7207436... | 0.7398984 | 6 |
euler010 2/21/13 The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. ============================================================================ | def euler010
target = 2e6
sum = 0
each_prime do |p,i|
break if p >= target
sum += p
end
sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def problem10()\n\tsum = 0; Prime.each(2000000) {|i| sum += i}; return sum\nend",
"def sum_primes max_number\n sum = 2\n (3..max_number).each do |test_num|\n next if test_num.even?\n prime = true\n # sqrttest = test_num**0.5\n (2..Math.sqrt(test_num)).each do |factor|\n prime = false if (test_... | [
"0.7787101",
"0.7722434",
"0.7693633",
"0.7683797",
"0.7638183",
"0.7608228",
"0.75145197",
"0.7504184",
"0.7493735",
"0.74179083",
"0.73777896",
"0.73683035",
"0.7321502",
"0.73011",
"0.7298361",
"0.72667754",
"0.72552925",
"0.72253466",
"0.72088355",
"0.71968096",
"0.718226... | 0.7733381 | 1 |
Implementation de la construction de la tache | def build(project_name, auto_install, proxy_option)
# On verifie la presence de ZenTest
Utils.verify_gem_presence("ZenTest", auto_install, proxy_option)
# On lance la generation
puts " Building ZenTest report..."
zentest_report = File.open("#{Continuous4r::WORK_DIR}/zentest-body.html", "w")
zent... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct\n end",
"def constructor; end",
"def initialize() end",
"def initialize\n \n end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
... | [
"0.6724964",
"0.6620649",
"0.65315235",
"0.6447821",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6315361",
"0.62026525",
"0.62026525",
"0.62026525",
"0.62026525",
"0.62026525... | 0.0 | -1 |
0 [ Signature ] | def resourceType
'Provenance'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stored_signature; end",
"def previous_signature?; end",
"def signature_key=(_arg0); end",
"def signature; end",
"def signature; end",
"def signature; end",
"def signature; end",
"def signature; end",
"def signature; end",
"def signature; end",
"def signature; end",
"def signature; end",
... | [
"0.7640547",
"0.7391658",
"0.73697066",
"0.73452175",
"0.73452175",
"0.73452175",
"0.73452175",
"0.73452175",
"0.73452175",
"0.73452175",
"0.73452175",
"0.73452175",
"0.73452175",
"0.7114065",
"0.7104223",
"0.7102134",
"0.7066056",
"0.7066056",
"0.7066056",
"0.7066056",
"0.70... | 0.0 | -1 |
Get the list of Tasks. This method returns the list of Tasks accessible to the current user. | def tasks_get(opts = {})
data, _status_code, _headers = tasks_get_with_http_info(opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_user_tasks\n\t\t@tasks = current_user.get_developer_tasks\n\tend",
"def all_tasks\n @task = Task.get_all_tasks_user_can_see(current_user)\n end",
"def tasks\n task_list.tasks\n end",
"def index\n @tasks = @current_user.tasks\n end",
"def index\n authenticate_user!\n @tasks = ... | [
"0.8279482",
"0.8252811",
"0.7817179",
"0.7803951",
"0.77899593",
"0.7763225",
"0.7763225",
"0.7763225",
"0.76756525",
"0.75892806",
"0.7572166",
"0.7521214",
"0.7478405",
"0.7414249",
"0.73827755",
"0.7379213",
"0.73533195",
"0.73533195",
"0.7352738",
"0.7334749",
"0.7320825... | 0.0 | -1 |
Get the list of Tasks. This method returns the list of Tasks accessible to the current user. | def tasks_get_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: TasksApi.tasks_get ...'
end
# resource path
local_var_path = '/tasks'
# query parameters
query_params = {}
query_params[:'page'] = opts[:'page'] if !op... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_user_tasks\n\t\t@tasks = current_user.get_developer_tasks\n\tend",
"def all_tasks\n @task = Task.get_all_tasks_user_can_see(current_user)\n end",
"def tasks\n task_list.tasks\n end",
"def index\n @tasks = @current_user.tasks\n end",
"def index\n authenticate_user!\n @tasks = ... | [
"0.8279206",
"0.8252565",
"0.7816988",
"0.7803451",
"0.7789283",
"0.7763264",
"0.7763264",
"0.7763264",
"0.767527",
"0.75888807",
"0.7571734",
"0.7521405",
"0.747849",
"0.741351",
"0.7382696",
"0.73792374",
"0.73530006",
"0.73528135",
"0.73528135",
"0.73349255",
"0.7320861",
... | 0.0 | -1 |
Get information on a Task. This method returns information on a Task, including its status, Task restartability and information on where the results are kept. | def tasks_id_get(id, opts = {})
data, _status_code, _headers = tasks_id_get_with_http_info(id, opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_task_status(taskID, request_options = {})\n client.get_task_status(name, taskID, request_options)\n end",
"def get_task(taskid)\n params = {\n 'method' => :get,\n 'command' => \"/task/#{taskid}\"\n }\n\n response, headers = send_request(params)\n\n task = respons... | [
"0.72028774",
"0.7153102",
"0.7153102",
"0.7102974",
"0.69218725",
"0.67799926",
"0.66824955",
"0.6653035",
"0.6638651",
"0.6630999",
"0.6629462",
"0.6617494",
"0.6603199",
"0.6593316",
"0.65116215",
"0.65116215",
"0.65116215",
"0.6504743",
"0.6499741",
"0.64924",
"0.6487518"... | 0.0 | -1 |
Get information on a Task. This method returns information on a Task, including its status, Task restartability and information on where the results are kept. | def tasks_id_get_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: TasksApi.tasks_id_get ...'
end
# verify the required parameter 'id' is set
if @api_client.config.client_side_validation && id.nil?
fail ArgumentError, "Mis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_task_status(taskID, request_options = {})\n client.get_task_status(name, taskID, request_options)\n end",
"def get_task(taskid)\n params = {\n 'method' => :get,\n 'command' => \"/task/#{taskid}\"\n }\n\n response, headers = send_request(params)\n\n task = respons... | [
"0.72028774",
"0.7153102",
"0.7153102",
"0.7102974",
"0.69218725",
"0.67799926",
"0.66824955",
"0.6653035",
"0.6638651",
"0.6630999",
"0.6629462",
"0.6617494",
"0.6603199",
"0.6593316",
"0.65116215",
"0.65116215",
"0.65116215",
"0.6504743",
"0.6499741",
"0.64924",
"0.6487518"... | 0.0 | -1 |
Create a new Task. This method allows the creation of a new Task. | def tasks_post(cbrain_task, opts = {})
data, _status_code, _headers = tasks_post_with_http_info(cbrain_task, opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(task)\n validate_type!(task)\n\n attributes = sanitize(task)\n _, _, root = @client.post(\"/tasks\", attributes)\n\n Task.new(root[:data])\n end",
"def create_task(options = {})\n request(:post, \"tasks\", options)\n end",
"def create\n @task = Task.create!(task... | [
"0.8123522",
"0.80613685",
"0.80187345",
"0.79555815",
"0.79505575",
"0.7766199",
"0.7718251",
"0.7694793",
"0.76863843",
"0.7650353",
"0.7615044",
"0.7615044",
"0.7615044",
"0.7615044",
"0.7615044",
"0.7615044",
"0.7615044",
"0.7615044",
"0.7615044",
"0.7615044",
"0.7615044"... | 0.0 | -1 |
Create a new Task. This method allows the creation of a new Task. | def tasks_post_with_http_info(cbrain_task, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: TasksApi.tasks_post ...'
end
# verify the required parameter 'cbrain_task' is set
if @api_client.config.client_side_validation && cbrain_task.nil?
f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(task)\n validate_type!(task)\n\n attributes = sanitize(task)\n _, _, root = @client.post(\"/tasks\", attributes)\n\n Task.new(root[:data])\n end",
"def create_task(options = {})\n request(:post, \"tasks\", options)\n end",
"def create\n @task = Task.create!(task... | [
"0.8123741",
"0.8062314",
"0.8018728",
"0.7955652",
"0.79511124",
"0.77666306",
"0.7718346",
"0.76954645",
"0.76862764",
"0.7650715",
"0.7614245",
"0.7614245",
"0.7614245",
"0.7614245",
"0.7614245",
"0.7614245",
"0.7614245",
"0.7614245",
"0.7614245",
"0.7614245",
"0.7614245",... | 0.0 | -1 |
for charting of each factor's max score | def factor_max_labs
factors.map do |factor|
factor.max_score
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_maximum_score()\n max_score = 0\n\n self.scores.each { |score| max_score = max_score + score.question.questionnaire.max_question_score }\n\n max_score\n end",
"def max\n @raw.max_by(&:score)\n end",
"def max_total_score\n review_criterions.collect{|c| c.max_score}.sum\n end",
"d... | [
"0.73859614",
"0.6982221",
"0.6979585",
"0.69621515",
"0.68591124",
"0.6827225",
"0.6827225",
"0.6808184",
"0.67091686",
"0.6661919",
"0.66231227",
"0.6568078",
"0.6531222",
"0.6523983",
"0.65169615",
"0.65122384",
"0.64786017",
"0.6477529",
"0.6466661",
"0.64559615",
"0.6392... | 0.81080574 | 0 |
for charting of winner's score | def winner_factor_score
@winner = Decision.find(id).rank_options.first
factors.map do |factor|
@winner.metrics.find_by_factor_id(factor.id).score
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accumulate_series_score(winner)\n if winner == 1\n return @player_1_score +=1\n elsif winner == 2\n return @player_2_score +=1\n end\n end",
"def score\n 2 * won + drawn + noresult\n end",
"def winner_count\n end",
"def score\n return 'love' if @points == 0\n return 'fi... | [
"0.7399918",
"0.72704166",
"0.71115893",
"0.7109138",
"0.7075045",
"0.7066821",
"0.6970935",
"0.6923315",
"0.6885715",
"0.68830127",
"0.6878284",
"0.68423575",
"0.67870647",
"0.67670786",
"0.67366254",
"0.6736408",
"0.67198426",
"0.67166346",
"0.6712003",
"0.6681444",
"0.6678... | 0.70171416 | 6 |
gathering data array for chart js rendering of all stacked data | def score_by_factors_array
@score_by_factors_master_array = []
@factor_ids = Decision.find(id).factors.map(&:id)
@rank_options = options.order(total_score: :desc)
@factor_ids.each { |factor_id|
# start with an empty factor_score array
# for each factor, iterator all options... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stacked_line_chart_data\n battle = Battle.find(params[:battle_id])\n data = []\n\n battle.hashtags.each do |h|\n data << h.get_stacked_evolution_data(from: battle.created_at)\n end\n\n render json: data\n end",
"def chart_data_full\n {\n labels: Array.new(chart_data.length, '')... | [
"0.686991",
"0.6676491",
"0.6676491",
"0.6459198",
"0.6393629",
"0.6359519",
"0.6247336",
"0.62200093",
"0.61426693",
"0.6088192",
"0.6083368",
"0.6075517",
"0.6075517",
"0.6061185",
"0.60410297",
"0.6014287",
"0.59663314",
"0.59580034",
"0.59549236",
"0.59414107",
"0.5932918... | 0.0 | -1 |
Permet au premier utilisateur qui s'inscrit sur l'application d'avoir automatiquement le statut d'administrateur | def set_admin
if User.count == 1
self.statut = "admin"
self.save
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def username\n \"administrator\"\n end",
"def apresentacao\n if @permissao === \"convidado\"\n puts \"o usuário selecionado possui a permissao de Convidado\"\n end\n if @permissao === \"autenticado\"\n puts \"o usuário selecionado... | [
"0.6763711",
"0.67230064",
"0.66857237",
"0.6579733",
"0.65696925",
"0.6508786",
"0.6498843",
"0.644804",
"0.6447126",
"0.64315695",
"0.6407172",
"0.638589",
"0.6381539",
"0.63517725",
"0.63367337",
"0.6336287",
"0.633011",
"0.63212",
"0.63105106",
"0.6300619",
"0.62698126",
... | 0.62401277 | 22 |
Retourne vrai si l'utilisateur est administrateur | def is_admin?
return true if self.statut == "admin"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_administrator?(user)\n user.admin == 2\n end",
"def user_admin?\n \t@admin_user = Usuario.find(session[:user_id]).admin\n end",
"def administrator?\n user.administrator?\n end",
"def is_admin?\n usertype == \"admin\" and id == 0\n end",
"def admin_user?\n self.admin ==true\n end"... | [
"0.78225344",
"0.77713346",
"0.7686629",
"0.7649647",
"0.7590191",
"0.7589056",
"0.75867987",
"0.7575257",
"0.75032866",
"0.74650115",
"0.7464714",
"0.7461423",
"0.7456138",
"0.74492085",
"0.7419098",
"0.74014026",
"0.7386148",
"0.73797715",
"0.7379104",
"0.73715305",
"0.7360... | 0.77336276 | 2 |
Retourne vrai si l'utilisateur a un statut public | def is_public?
return true if self.statut == "public"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public?\n ( new_record? ? username : username_was ) == 'Public'\n end",
"def public_user?\n \tcurrent_user.username.eql? \"public_user\"\n end",
"def is_admin?\n return true if self.statut == \"admin\"\n end",
"def accessible_for?(user)\n user_id == user.id && !user.anonimous?\n end",
"de... | [
"0.723363",
"0.7090591",
"0.662641",
"0.6607279",
"0.65725726",
"0.65725726",
"0.65363634",
"0.64870894",
"0.64791757",
"0.64679927",
"0.6460859",
"0.6434572",
"0.64177173",
"0.63943076",
"0.6378728",
"0.6371272",
"0.636485",
"0.6364111",
"0.63504124",
"0.6349177",
"0.6347732... | 0.73454106 | 0 |
Callbacks Don't allow people to follow themselves | def check_permission
if followable_type == "User"
user = User.find(followable_id)
follower = User.find(follower_id)
errors.add(I18n::t('errors.follow.self_follow')) if user == follower
errors.add(I18n::t('errors.follow.already_following')) if follower.follows?(user)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_is_not_following_themselves\r\n if follower_id == followed_user_id\r\n errors.add(:base, \"Users cannot follow themselves\")\r\n end\r\nend",
"def follow\n\n end",
"def ensure_follower_not_followed \n if follower_id == followed_id \n errors[:follower_id] << 'cannot follow yours... | [
"0.7081814",
"0.70430356",
"0.6983448",
"0.6873079",
"0.6853013",
"0.6702666",
"0.6667752",
"0.6631012",
"0.6602097",
"0.65609664",
"0.64915836",
"0.64581",
"0.6437934",
"0.6431393",
"0.643114",
"0.6412958",
"0.6410162",
"0.6398268",
"0.63880986",
"0.6379561",
"0.63780206",
... | 0.6255022 | 43 |
Increment the counters for the user and the follower when someone starts following | def increment_counters
if followable_type == "User"
user = User.find(followable_id)
follower = User.find(follower_id)
user.update_attribute(:followers_count_cache, user.followers_count)
follower.update_attribute(:following_count_cache, follower.following_users_count)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def increment_counter(following)\n User.increment_counter(:followings_count,following.user_id)\n User.increment_counter(:inverse_followings_count,following.follower_id) \n end",
"def follow!(other_user)\n self.relationships.create!(followed_id: other_user.id)\n self.update_attribute(:followings_... | [
"0.81680316",
"0.743967",
"0.7328876",
"0.7326696",
"0.72223556",
"0.7212452",
"0.7175199",
"0.7095882",
"0.70122737",
"0.6983261",
"0.6960207",
"0.694146",
"0.6898215",
"0.68794024",
"0.6868196",
"0.68412995",
"0.68277633",
"0.6815654",
"0.6812794",
"0.67945445",
"0.679316",... | 0.8265266 | 0 |
Decrement the counters for hte user and the follower when someone stops following | def decrement_counters
if followable_type == "User"
user = User.find(followable_id)
follower = User.find(follower_id)
user.update_attribute(:followers_count_cache, user.followers_count)
follower.update_attribute(:following_count_cache, follower.following_users_count)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decrement_counter(following)\n User.decrement_counter(:followings_count,following.user_id)\n User.decrement_counter(:inverse_followings_count,following.follower_id) \n end",
"def after_destroy(following)\n decrement_counter(following)\n end",
"def unfollow_user\n\t\tauthenticate_current_user\n\t... | [
"0.8003382",
"0.7657648",
"0.7178587",
"0.7151158",
"0.6970672",
"0.68889475",
"0.67929405",
"0.6767074",
"0.67508155",
"0.67448914",
"0.6727632",
"0.66785103",
"0.66750926",
"0.66744643",
"0.66742736",
"0.66742736",
"0.66742736",
"0.66406226",
"0.66220665",
"0.66007996",
"0.... | 0.7901657 | 1 |
Give the reciever a notification that they're being followed | def add_notification
if followable_type == "User"
Notification.create(
target_id: followable_id,
target_type: "User",
notice_id: id,
notice_type: "Follow",
user_id: followable_id,
notifier_id: follower_id
)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def follow_notification\n Notifications.follow_notification\n end",
"def follow\n\n end",
"def follower(relationship)\n @follower = relationship.follower\n @followed = relationship.followed\n mail :to => @followed.email, :subject => \"New follower on EconBloggers\"\n end",
"def send_follow_ema... | [
"0.71932364",
"0.7158816",
"0.7116834",
"0.70900273",
"0.7021804",
"0.69990754",
"0.6896067",
"0.68680334",
"0.6862662",
"0.6839448",
"0.6799678",
"0.6704788",
"0.6676424",
"0.6660962",
"0.6630863",
"0.6626287",
"0.6592679",
"0.65858537",
"0.65839744",
"0.6568329",
"0.6551082... | 0.6794119 | 11 |
I'm wondering if removing notifications is a good idea after a record is deleted. It's nice to have a record of what happened in the past, but I'm going forward with it anyway | def remove_notification
if followable_type == "User"
notice = Notification.where({
target_id: followable_id,
target_type: "User",
notice_id: id,
notice_type: "Follow",
user_id: followable_id,
notifier_id: follower_id
}).first
notice.blank? ? true : n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_from_notification (n)\n logger.debug2 \"comment id #{id}. Notification id #{n.id}. notification key #{n.noti_key}\" if debug_notifications\n # only modify unread notifications\n return unless n.noti_read == 'N'\n cn = notifications.where(\"notification_id = ?\", n.id).first\n logger.debu... | [
"0.67808974",
"0.6778415",
"0.6777557",
"0.67138207",
"0.6678244",
"0.66613215",
"0.65674514",
"0.6561611",
"0.6417793",
"0.63980097",
"0.6397806",
"0.6372498",
"0.6347058",
"0.63350624",
"0.631154",
"0.62981594",
"0.6252542",
"0.62222284",
"0.6213939",
"0.6184063",
"0.617918... | 0.6362764 | 12 |
Test whether a table exists. Caveat: table_exists() returns false if the table exists but you don't have privileges for accessing it. | def table_exists(dbh, db_name, tbl_name)
return !dbh.select_one("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?",
db_name, tbl_name).nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table_exists?(table)\n table_info(table) ? true : false\n end",
"def table_exists?\n db.table_exists?(table_name)\n end",
"def table_exists?(table_name)\n return false unless table_name\n schema, table = split_table_name(table_name)\n tables(nil, schema, table... | [
"0.83472586",
"0.8089047",
"0.80666316",
"0.8027049",
"0.7975607",
"0.78915167",
"0.7885955",
"0.77988964",
"0.7779113",
"0.77554506",
"0.7731803",
"0.76715213",
"0.7600705",
"0.75877494",
"0.7565398",
"0.7554831",
"0.7540279",
"0.75008076",
"0.73470134",
"0.7333072",
"0.7301... | 0.75216496 | 17 |
Convert results to reports +type+:: type of results to be converted(tests, coverage, all) | def convert(type)
case type
when 'tests' then @test_tool.convert
when 'coverage' then @coverage_tool.convert
when 'all'
@test_tool.convert
@coverage_tool.convert
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_result_test_type(test_result)\n test_test_type(test_result.test)\n end",
"def add(result_type)\n mf_debug \"result requested #{result_type}\"\n metric_options = metric_options_for_result_type(result_type)\n generator_class = MetricFu::Generator.get_generator(result_type)\n m... | [
"0.61080295",
"0.5925222",
"0.58508915",
"0.58200145",
"0.575758",
"0.57562846",
"0.5751902",
"0.57382065",
"0.5719091",
"0.5715721",
"0.5709778",
"0.5652873",
"0.5644425",
"0.563306",
"0.56081504",
"0.55995286",
"0.5538893",
"0.5532116",
"0.550959",
"0.54926395",
"0.54373723... | 0.7379444 | 0 |
GET /discipline_class_exam_types GET /discipline_class_exam_types.json | def index
@discipline_class_exam_types = DisciplineClassExamType.all
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @discipline_class_exam_types }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @discipline_types = DisciplineType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @discipline_types }\n end\n end",
"def show\n @discipline_class_exam_type = DisciplineClassExamType.find(params[:id])\n\n respond_to do |format|\n... | [
"0.7217414",
"0.7001436",
"0.67574567",
"0.6607656",
"0.6465737",
"0.63974893",
"0.6296198",
"0.62698483",
"0.62097317",
"0.6146651",
"0.61008954",
"0.6099532",
"0.6042189",
"0.6042189",
"0.60183454",
"0.6000357",
"0.5973961",
"0.59681755",
"0.5965662",
"0.5908237",
"0.588788... | 0.7824928 | 0 |
GET /discipline_class_exam_types/1 GET /discipline_class_exam_types/1.json | def show
@discipline_class_exam_type = DisciplineClassExamType.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @discipline_class_exam_type }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @discipline_class_exam_types = DisciplineClassExamType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @discipline_class_exam_types }\n end\n end",
"def index\n @discipline_types = DisciplineType.all\n\n respond_to do |format|\n ... | [
"0.7882109",
"0.72271156",
"0.68203986",
"0.6758261",
"0.6523203",
"0.64380205",
"0.63933766",
"0.6208396",
"0.61832166",
"0.6128211",
"0.6093311",
"0.6076653",
"0.6076653",
"0.6050418",
"0.60264623",
"0.6018902",
"0.6012678",
"0.6011453",
"0.599214",
"0.59852237",
"0.5944009... | 0.7466543 | 1 |
GET /discipline_class_exam_types/new GET /discipline_class_exam_types/new.json | def new
@discipline_class_exam_type = DisciplineClassExamType.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @discipline_class_exam_type }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @discipline_type = DisciplineType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @discipline_type }\n end\n end",
"def create\n @discipline_class_exam_type = DisciplineClassExamType.new(params[:discipline_class_exam_type])\n\n respo... | [
"0.7670088",
"0.76540774",
"0.70987254",
"0.7073563",
"0.7035666",
"0.7028747",
"0.70047075",
"0.6987768",
"0.6935633",
"0.687447",
"0.68393046",
"0.67914164",
"0.6773943",
"0.67711985",
"0.67474127",
"0.66910976",
"0.66815203",
"0.66792685",
"0.66702825",
"0.66685486",
"0.66... | 0.8101326 | 0 |
POST /discipline_class_exam_types POST /discipline_class_exam_types.json | def create
@discipline_class_exam_type = DisciplineClassExamType.new(params[:discipline_class_exam_type])
respond_to do |format|
if @discipline_class_exam_type.save
format.html { redirect_to @discipline_class_exam_type, :notice => 'Tipo de Exame de Classe de Disciplina criada com sucesso.' }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @discipline_class_exam_types = DisciplineClassExamType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @discipline_class_exam_types }\n end\n end",
"def new\n @discipline_class_exam_type = DisciplineClassExamType.new\n\n respond_... | [
"0.67809063",
"0.6402874",
"0.6233006",
"0.608245",
"0.58496064",
"0.58407223",
"0.582789",
"0.5790321",
"0.5779875",
"0.57782644",
"0.573409",
"0.5683397",
"0.5659672",
"0.5647538",
"0.561605",
"0.56154674",
"0.55750793",
"0.5562775",
"0.55514497",
"0.5539128",
"0.55220276",... | 0.688137 | 0 |
PUT /discipline_class_exam_types/1 PUT /discipline_class_exam_types/1.json | def update
@discipline_class_exam_type = DisciplineClassExamType.find(params[:id])
respond_to do |format|
if @discipline_class_exam_type.update_attributes(params[:discipline_class_exam_type])
format.html { redirect_to @discipline_class_exam_type, :notice => 'Tipo de Exame de Classe de Disciplina ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @discipline_type = DisciplineType.find(params[:id])\n\n respond_to do |format|\n if @discipline_type.update_attributes(params[:discipline_type])\n format.html { redirect_to @discipline_type, :notice => 'Tipo de disciplina atualizado com sucesso.' }\n format.json { head :no_con... | [
"0.65375966",
"0.63820314",
"0.62064236",
"0.6147381",
"0.6082575",
"0.6064758",
"0.6062772",
"0.60456353",
"0.5976742",
"0.59479874",
"0.5925037",
"0.58663124",
"0.58069146",
"0.5789258",
"0.5761736",
"0.57345474",
"0.5725602",
"0.5702171",
"0.5700124",
"0.569673",
"0.569131... | 0.72148424 | 0 |
DELETE /discipline_class_exam_types/1 DELETE /discipline_class_exam_types/1.json | def destroy
@discipline_class_exam_type = DisciplineClassExamType.find(params[:id])
@discipline_class_exam_type.destroy
respond_to do |format|
format.html { redirect_to discipline_class_exam_types_url, :notice => 'Tipo de Exame de Classe de Disciplina excluída com sucesso.' }
format.json { head... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @discipline_type = DisciplineType.find(params[:id])\n @discipline_type.destroy\n\n respond_to do |format|\n format.html { redirect_to discipline_types_url, :notice => 'Tipo de disciplina excluído com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n ... | [
"0.7581504",
"0.73963493",
"0.7288733",
"0.7140322",
"0.702697",
"0.69850415",
"0.69799143",
"0.6956514",
"0.6901266",
"0.6821218",
"0.6819027",
"0.6817713",
"0.6816319",
"0.6815965",
"0.68139756",
"0.68115795",
"0.67966294",
"0.6792167",
"0.6788187",
"0.67778766",
"0.6767587... | 0.81061006 | 0 |
TODO: more helpful snapshot diff in the failure message | def failure_message
if @found
"\nexpected: #{@expect}\n got: #{@actual}\n"
else
"\nCould not find a snapshot at #{snap_path}.\n Failing " \
"instead of creating; save_snapshots is set to #{save_config}."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def failures; end",
"def failures; end",
"def failures; end",
"def failure_message; end",
"def failure_message; end",
"def failure_message; end",
"def failure_message; end",
"def failure_message; end",
"def failure_message; end",
"def failure_message; end",
"def failure_message\n actual ... | [
"0.6927087",
"0.6927087",
"0.6927087",
"0.6874374",
"0.6874374",
"0.6874374",
"0.6874374",
"0.6874374",
"0.6874374",
"0.6874374",
"0.6805725",
"0.6503614",
"0.6503614",
"0.6482618",
"0.64699966",
"0.64699966",
"0.64589447",
"0.64589447",
"0.64589447",
"0.6375824",
"0.6372473"... | 0.754176 | 0 |
Utility methods to add new resources objects | def add_user(name, is_admin, building_id, notify_new_request= false, notify_new_listing=false)
user_id = User.create(
first_name: name,
last_name: 'LNU',
email: 'jack+' + name + '@jackmgill.com',
password: 'foo',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addResources _obj, _args\n \"_obj addResources _args;\" \n end",
"def add(name, resource, attributes = {})\n resources[name] = resource\n resource.update_attributes(attributes) if attributes.any?\n resource\n end",
"def push(*resources)\n relate_resources(resources)\n su... | [
"0.79112977",
"0.71442384",
"0.686679",
"0.6650673",
"0.6632302",
"0.6490173",
"0.6475148",
"0.64660764",
"0.64427435",
"0.63906926",
"0.6367226",
"0.6321275",
"0.6308205",
"0.6308205",
"0.62963814",
"0.62963814",
"0.6290206",
"0.6275684",
"0.62735754",
"0.62636703",
"0.62223... | 0.0 | -1 |
will fire a tracking event even if exceptions are raised | def track_action(*actions)
around_filter ActionTracker, only: actions
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_process_event_tracking_events\n Trackers::Buyer::TRACKING_EVENTS.each do |event|\n process_event_helper(event, @address_doc['_source'])\n end\n end",
"def set_tracking\n end",
"def track_click\n with_monitoring do\n Faraday.post(url_with_params, '')\n end\n rescue =>... | [
"0.63664526",
"0.6256658",
"0.6172037",
"0.6108459",
"0.594274",
"0.59331447",
"0.5931467",
"0.5931467",
"0.5868573",
"0.5868169",
"0.57746524",
"0.5773969",
"0.57582235",
"0.575225",
"0.5748393",
"0.5743076",
"0.5743076",
"0.5647037",
"0.56355876",
"0.5592003",
"0.5580682",
... | 0.0 | -1 |
will fire a tracking event on the start of the action | def track_start(*actions)
before_filter ActionTracker, only: actions
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def track_event(action)\n\t\t\tif params['ga_tracking_id'] and params['ga_client_id']\n\t\t\t\ttracker = Staccato.tracker(params['ga_tracking_id'], params['ga_client_id'], ssl: true, document_hostname: params['ga_hostname'])\n\t\t\t\ttracker.event(category: 'support', action: action, value: 1)\n\t\t\tend\n\t\tend"... | [
"0.684269",
"0.68008083",
"0.66865593",
"0.6675623",
"0.6575847",
"0.64925176",
"0.6477883",
"0.64156824",
"0.64156824",
"0.639445",
"0.63235086",
"0.62504476",
"0.6176903",
"0.60968393",
"0.60699517",
"0.60534793",
"0.60073084",
"0.59676814",
"0.59620875",
"0.5961987",
"0.59... | 0.7379057 | 0 |
will fire a tracking event upon successful completion of an action NOTE: won't fire if action has an exception | def track_finish(*actions)
after_filter ActionTracker, only: actions
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action_complete() self.finished = true; end",
"def track_event(action)\n\t\t\tif params['ga_tracking_id'] and params['ga_client_id']\n\t\t\t\ttracker = Staccato.tracker(params['ga_tracking_id'], params['ga_client_id'], ssl: true, document_hostname: params['ga_hostname'])\n\t\t\t\ttracker.event(category: 'sup... | [
"0.68903804",
"0.6593257",
"0.61960495",
"0.6193463",
"0.60604435",
"0.6025753",
"0.59795773",
"0.5945685",
"0.59242827",
"0.5890912",
"0.5857925",
"0.585642",
"0.58482295",
"0.5827643",
"0.58202785",
"0.5817879",
"0.5802731",
"0.57858545",
"0.57858545",
"0.5784431",
"0.57739... | 0.624444 | 2 |
Check for Machine Learning Modelbased special offers | def check_special_offer(customer, cart)
# Check for potential deals
potential_deals = trigger_deals.where(special: true)
unless potential_deals.empty?
potential_deal = potential_deals.first
# Find the deployment for the the model of this deal's product
if !(cart.include? potent... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recommendable?() false end",
"def training_required?\n return training_required\n end",
"def offer_available?\n #return self.approved? && self.offers.last.present? && self.offers.last.effective?\n return self.offers.last.present? && self.offers.last.effective?\n end",
"def best_offer?\n i... | [
"0.6268116",
"0.58796936",
"0.5841407",
"0.5815271",
"0.5802331",
"0.56201106",
"0.56129164",
"0.5563538",
"0.5554636",
"0.5535618",
"0.55217445",
"0.55143416",
"0.5490359",
"0.5431187",
"0.5422298",
"0.54163176",
"0.5415923",
"0.5405574",
"0.5399967",
"0.53910166",
"0.536332... | 0.0 | -1 |
Once we have the group position, we process the position for every item in it. | def process_texts_position(design_width)
#We too calculate the average point
@x_average_pos = @x_pos + @width/2
@y_average_pos = @y_pos + @height/2
if @alignment == 'left'
text_x_pos = @x_pos
if @has_image
text_x_pos += @text_image.width + Constants::Margin_text_pics
@te... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_capturing_group_position(old_position)\n increment = 0\n added_capturing_groups_after_group.each do |after_n_groups, count|\n increment += count if after_n_groups < old_position\n end\n old_position + increment\n end",
"def positions\n Rails.cache.fetch(\"#{cn... | [
"0.67339444",
"0.6542874",
"0.6209767",
"0.6112684",
"0.5978181",
"0.5971722",
"0.58929014",
"0.5872758",
"0.5865335",
"0.58230954",
"0.5822881",
"0.5818769",
"0.57856417",
"0.5761053",
"0.5760152",
"0.5756616",
"0.568724",
"0.5674593",
"0.56744033",
"0.565685",
"0.5617511",
... | 0.0 | -1 |
Allows access to the hash though methods Provides all getter, setter and query methods for any key in the hash | def method_missing(meth, *args, &blk)
name = meth.to_s
return evaluate(self[meth]) if name.size == 1
# Ruby 1.8.7 doesn't let you do string[-1]
key, suffix = name[0..-2].to_sym, name[-1..-1]
case suffix
when '='
self[key] =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n self.class.name.hash ^ @key.hash\n end",
"def method_missing(method, *args)\n hash.send(method, *args)\n end",
"def method_missing(method, *args)\n hash.send(method, *args)\n end",
"def get(key)\n \n end",
"def hash_method\n super\n end",
"def test_Has... | [
"0.70769805",
"0.6949412",
"0.6949412",
"0.6912158",
"0.6872319",
"0.6807284",
"0.6776442",
"0.66706634",
"0.6608207",
"0.66051495",
"0.6601407",
"0.66010725",
"0.65913653",
"0.65913653",
"0.65913653",
"0.65913653",
"0.6580168",
"0.65609133",
"0.65416837",
"0.6541269",
"0.651... | 0.0 | -1 |
Returns a value or runs a proc depending on the value in the hash | def evaluate(value)
if value.is_a?(Proc)
value.call
else
value
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_if(key_or_proc, key, &block)\n if get(key)\n key_or_proc = key_or_proc.call if key_or_proc.is_a?(Proc)\n value = fetch(key_or_proc, &block)\n else\n value = block.call\n key_or_proc = key_or_proc.call if key_or_proc.is_a?(Proc)\n set(key_or_proc, Marshal.dump(value))\n e... | [
"0.7345389",
"0.6330173",
"0.6114484",
"0.6014682",
"0.5978533",
"0.594738",
"0.59319615",
"0.5931634",
"0.5927059",
"0.5923301",
"0.59217095",
"0.5900591",
"0.58679694",
"0.5865734",
"0.5843477",
"0.58430237",
"0.5798826",
"0.5792287",
"0.5741799",
"0.5706013",
"0.5690932",
... | 0.6552528 | 1 |
Sets the default config values | def load_default_config
self[:disable_html] ||= true
self[:url_target] ||= "_BLANK"
self[:image_alt] ||= "Posted Image"
self[:table_width] ||= "100%"
self[:syntax_highlighter] ||= :raw
self[:coderay_options] ||= {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_defaults!\n __load_config( DEFAULTS )\n end",
"def set_defaults\n end",
"def set_defaults\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"de... | [
"0.8631206",
"0.80384874",
"0.80384874",
"0.79549074",
"0.79549074",
"0.79549074",
"0.79549074",
"0.79549074",
"0.79549074",
"0.76869667",
"0.7685743",
"0.76265174",
"0.7559587",
"0.7535616",
"0.7535616",
"0.74436855",
"0.732581",
"0.72946453",
"0.7231213",
"0.7215404",
"0.71... | 0.7244742 | 18 |
compares two different trees | def <=>(other)
root.data <=> other.root.data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def == other_tree\n one = []\n two = []\n each { |node| one << node }\n other_tree.each { |node| two << node }\n one == two\n end",
"def equal_by_tree?(graph_obj1, graph_obj2)\n check_pre((graph_obj?(graph_obj1) and graph_obj?(graph_obj2)))\n if (not equal_by_dim?(graph_obj1, gra... | [
"0.76330113",
"0.7028865",
"0.6919849",
"0.6917932",
"0.69168425",
"0.67973775",
"0.6683314",
"0.66723555",
"0.66042536",
"0.6553627",
"0.6545586",
"0.6418253",
"0.6366554",
"0.6346022",
"0.63417166",
"0.63304156",
"0.6297019",
"0.62822205",
"0.6256939",
"0.62488675",
"0.6244... | 0.6175281 | 27 |
find the lowest value of a node | def min(key)
key = find(key) if !key.is_a? Node
return key if key.left.nil? && key.right.nil?
min(key.left)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min\n @nodes.first\n end",
"def min_value\n if @head.nil?\n return nil\n else\n if head.left\n min_value = min_search(head.left).data\n else\n min_value = head.data\n end\n end\n return min_value\n end",
"def smallest_value(node)\n small_val = node\n\n w... | [
"0.8348919",
"0.8101562",
"0.8053213",
"0.7982141",
"0.7917274",
"0.77824783",
"0.7664431",
"0.7585653",
"0.75569427",
"0.74224687",
"0.74224687",
"0.741067",
"0.73917735",
"0.7333568",
"0.7296452",
"0.72514534",
"0.7243444",
"0.72327554",
"0.7229373",
"0.7178304",
"0.7157969... | 0.7327003 | 14 |
find the highest value of a node | def max(key)
key = find(key) if !key.is_a? Node
return key if key.right.nil?
max(key.right)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_value\n if @head.nil?\n return nil\n else\n if head.right\n max_value = max_search(head.right).data\n else\n max_value = head.data\n end\n end\n return max_value\n end",
"def get_max\n return if is_empty?\n return @root.val\n end",
"def ... | [
"0.8016268",
"0.79837614",
"0.77705294",
"0.76302075",
"0.7503752",
"0.7503752",
"0.74663615",
"0.74222696",
"0.740424",
"0.7393534",
"0.73867226",
"0.7381027",
"0.73763573",
"0.736884",
"0.73654634",
"0.7329185",
"0.73188776",
"0.731349",
"0.7311543",
"0.7258244",
"0.7253290... | 0.71697825 | 24 |
count the children of the node | def child_count(node, count = 0)
return count if node.nil?
if !node.is_a? Node
child_count(find(node))
else
count += 1 if !node.left.nil?
count += 1 if !node.right.nil?
end
count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_children(node)\n\t\treturn 0 if node.children.nil?\n\t\tnode.children.count + (node.children.map {|child| count_children(child)}).inject(&:+)\n\tend",
"def count_child_nodes(hash = self)\n count = 0\n walk_tree(hash) do\n count += 1\n end\n count\n end",
"def count_child... | [
"0.8624404",
"0.85381854",
"0.8506593",
"0.84587055",
"0.83975345",
"0.8386775",
"0.82553947",
"0.8217885",
"0.82140917",
"0.81372833",
"0.7975459",
"0.79358745",
"0.7866293",
"0.77770185",
"0.7725592",
"0.7669543",
"0.76178586",
"0.75676626",
"0.75578195",
"0.75016975",
"0.7... | 0.7952199 | 11 |
drives left or right from the root node | def left_right(key, node)
case child_count(node)
when 1
node.left.nil? ? node.right : node.left
when 2
node.data > key ? node.left : node.right
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_to_left_of(node)\n move_to node, :left\n end",
"def move_to_left_of(node)\n move_to node, :left\n end",
"def move_to_left_of(node)\n move_to node, :left\n end",
"def move_to_left_of(node)\n self.move_to node, :left\n end",
"def move_to_left_of(node)\n ... | [
"0.7039746",
"0.7039746",
"0.7039746",
"0.70105034",
"0.7010254",
"0.69315785",
"0.68595004",
"0.66734177",
"0.66274565",
"0.66274565",
"0.66274565",
"0.6593367",
"0.6574896",
"0.655282",
"0.65408117",
"0.6537505",
"0.65296406",
"0.65269065",
"0.65252227",
"0.6504758",
"0.650... | 0.69467664 | 5 |
find the parent node of the child node | def find_parent(key, node = root)
return nil if node.nil?
key = find(key) if !key.is_a? Node
if node.left == key || node.right == key
return node
else
find_parent(key, left_right(key.data, node))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent\n self.node && self.node.parent && self.node.parent.content\n end",
"def parent_of node\n\t\treturn is_valid(node) ? node.parent : nil\n\tend",
"def parent\n\t\treturn parent_of @current_node\n\tend",
"def parent_node(node)\n node.find(:xpath, '..', wait: 0, visible: false)\n end",
"def ... | [
"0.7888044",
"0.7864959",
"0.782099",
"0.78009486",
"0.7678447",
"0.7669799",
"0.7608606",
"0.7511882",
"0.75067955",
"0.75067955",
"0.74128234",
"0.7398685",
"0.73869056",
"0.7382601",
"0.7341215",
"0.7308554",
"0.7165034",
"0.70858866",
"0.706981",
"0.7029595",
"0.6972449",... | 0.6457903 | 88 |
find key from the tree nodes | def find(key, node = root)
return nil if node.nil?
if key == node.data
return node
else
find(key, left_right(key, node))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieve key\n\t\tnode = traverse @root, key\n\t\tnode.key\n\tend",
"def get_node(key); end",
"def search_key key\n node = self.head\n while node\n return node if node.key == key\n nc = node.child \n while nc\n return nc if nc.key == key\n ncs = nc.sibling\n whi... | [
"0.7899967",
"0.75018436",
"0.73428214",
"0.7245532",
"0.71973974",
"0.7145989",
"0.7140488",
"0.7102775",
"0.7029461",
"0.694344",
"0.6888399",
"0.6888399",
"0.6791372",
"0.67608076",
"0.67608076",
"0.67608076",
"0.67608076",
"0.67608076",
"0.6751067",
"0.67413044",
"0.67333... | 0.6754657 | 18 |
modify tree; delete key as target then use lower nodes as substitutes | def delete(key)
key = find(key) unless key.is_a? Node
case child_count(key)
when 2
sub = key.right.data == nil ? max(key.left) : min(key.right)
when 1
sub = key.right.nil? ? key.left : key.right
when 0
sub = nil
end
modify(key, sub)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform(tree); end",
"def delete(key)\n node = search key\n if node.l.key == nil && node.r.key == nil\n # It's leaf, just replace it to null-node for its parent.\n if node.p \n null_node = RBNode.new nil, BLACK\n node.p.l == node ? node.p.l = null_node : node.p.r = null_node\n... | [
"0.6224971",
"0.6178873",
"0.58942413",
"0.5865897",
"0.58273166",
"0.5771427",
"0.5753169",
"0.5738453",
"0.57367665",
"0.57367665",
"0.5668929",
"0.56601185",
"0.565223",
"0.5648753",
"0.56025565",
"0.5598201",
"0.5581159",
"0.55786395",
"0.55767924",
"0.55698836",
"0.55459... | 0.61227024 | 2 |
insert a new node into the leaf | def insert(key, node = root)
return node if node.data == key
if child_count(node) == 0
key < node.data ? node.left = Node.new(key) : node.right = Node.new(key)
else
insert(key, left_right(key, node))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_node\n insert_node_helper(@root)\n end",
"def insert(node, &block); end",
"def insert(node, &block); end",
"def insert_node(node)\n raise \"Node must be a leaf\" unless node.is_leaf?\n if (self.view) \n node.position = self.view.get_node_position(node)\n node... | [
"0.7915436",
"0.7680407",
"0.7680407",
"0.76475936",
"0.764134",
"0.76306653",
"0.72695637",
"0.72610074",
"0.7253618",
"0.7253618",
"0.7203738",
"0.71629894",
"0.7159453",
"0.7082904",
"0.70681995",
"0.7041261",
"0.7037799",
"0.7034305",
"0.7012084",
"0.698544",
"0.69663984"... | 0.71445286 | 13 |
return array of ordered values | def preOrder(node = root, arr = [])
return nil unless node.is_a? Node
arr << node.data
preOrder(node.left, arr) if !node.left.nil?
preOrder(node.right, arr) if !node.right.nil?
arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ordered_values; end",
"def get_ordered_values()\n return VALUES.to_a.map { |pair|\n pair.reverse\n }.sort.map { |pair|\n pair[1]\n }\n end",
"def ordered_values\n result = []\n each { |k, v| k == 'Unknown' ? result.push(v) : result.unshift(v) }\n result\n end",
"def ... | [
"0.8301721",
"0.82613546",
"0.7746112",
"0.6954823",
"0.69172764",
"0.67208946",
"0.64602435",
"0.64253014",
"0.641541",
"0.64095926",
"0.63924396",
"0.63588464",
"0.6202055",
"0.6179581",
"0.6149004",
"0.61106837",
"0.60957646",
"0.60943305",
"0.60492885",
"0.6035873",
"0.60... | 0.0 | -1 |
level order method: iteration def level_order(discovered = [root], visited = []) while discovered.length > 0 current = discovered.shift discovered.push(current.left) unless current.left.nil? discovered.push(current.right) unless current.right.nil? visited.push(current.data) end visited end edges between the given key a... | def height(key, count = 0, child = level_order(key).pop)
count += 1
if child == key
return count - 1
else
parent = find_parent(child).data
height(key, count, parent)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def level_order_traversal(root_node)\n queue = Queue.new\n queue.enq root_node\n while(!queue.empty?)\n magic_node = queue.deq\n\n puts magic_node.value\n\n queue.enq(magic_node.left) unless magic_node.left.nil?\n\n queue.enq(magic_node.right) unless magic_node.right.nil?... | [
"0.7031907",
"0.6915075",
"0.6682265",
"0.65889823",
"0.65362036",
"0.6454291",
"0.6390481",
"0.63580716",
"0.6340692",
"0.6301553",
"0.62526673",
"0.62523854",
"0.6225955",
"0.6213957",
"0.61260635",
"0.6108361",
"0.6096127",
"0.6080063",
"0.6064858",
"0.60536164",
"0.602871... | 0.0 | -1 |
edges between the given key and the main root | def depth(key, count = 0, child = key)
count += 1
if root.data == child
return count - 1
else
parent = find_parent(child).data
depth(key, count, parent)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def walk_towards_key(key)\n stack = []\n\n # Start with root node\n in_node = root\n node_id = NodeID.new\n\n # Iterate until node is no longer inner\n while in_node.inner?\n stack.push [in_node, node_id]\n\n return nil, stack if v2? && in_node.common_prefix?(key)\n\n ... | [
"0.66019475",
"0.659664",
"0.6315925",
"0.6080942",
"0.6056942",
"0.59902775",
"0.58284247",
"0.5781566",
"0.5715772",
"0.57101375",
"0.57073516",
"0.56910956",
"0.56904393",
"0.56828886",
"0.56059694",
"0.5597406",
"0.5568903",
"0.5561816",
"0.5557639",
"0.55228883",
"0.5520... | 0.0 | -1 |
create a new record | def create input
table = DB.from(@table) #DB[@table]
result = table.insert input
input[:id] = result
# invalidate a cached range
@@_cached_range = nil
# return an instance of the model class with the data attributes
get :id => input[:id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_record(model, *args)\n record = new_record(model, *args)\n record.save!\n record.reload\n record\n end",
"def create(params = {})\n record = new(params)\n record.save && record\n end",
"def create_record(model, *args)\n record = new_record(model... | [
"0.7981954",
"0.7968254",
"0.79611814",
"0.7900668",
"0.7744809",
"0.7635523",
"0.7619526",
"0.7617779",
"0.7386797",
"0.7364105",
"0.7293404",
"0.7293404",
"0.72901875",
"0.72763",
"0.72400844",
"0.7231395",
"0.7203758",
"0.7193524",
"0.7187589",
"0.7187589",
"0.7180876",
... | 0.0 | -1 |
save the given record | def save input
table = DB.from(@table) # DB[@table]
# invalidate a cached range
@@_cached_range = nil
if input[:id]
table.where(:id => input[:id]).update input.reject{|key,value| key.to_s == 'id'}
get :id => input[:id]
else
self.create input
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_record(record)\n record.save\n end",
"def save_record(record)\n record.save\n end",
"def save; record.save; end",
"def record(record)\n @db.save_doc(record)\n end",
"def save_record\n if !saved_already?\n if valid?\n run_sql(\"INSERT INTO #{table} (#{string_f... | [
"0.8893789",
"0.8893789",
"0.83076674",
"0.79782486",
"0.75563943",
"0.71526223",
"0.70964736",
"0.70880324",
"0.7026032",
"0.6995967",
"0.6995967",
"0.6995967",
"0.6995967",
"0.6995967",
"0.6995967",
"0.6995967",
"0.6995967",
"0.69490385",
"0.6948576",
"0.6925572",
"0.691478... | 0.0 | -1 |
list records from the table optionally starting at a given offset (or page number) | def list(options = nil)
table = DB.from(@table)
if options[:rows]
if options[:offset]
table = table.limit(options[:rows],options[:offset])
elsif options[:page]
offset = options[:page] * options[:rows]
table = table.limit(options[:rows],offset)
en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list(offset = 0, limit = 100)\n api.get('', offset: offset, limit: limit)\n end",
"def list(offset = 0, limit = 100)\n api.get('', offset: offset, limit: limit)\n end",
"def list(offset = 0, limit = 100)\n api.get('', offset: offset, limit: limit)\n end",
"def list(offset = 0, lim... | [
"0.6625507",
"0.6625507",
"0.6625507",
"0.6625507",
"0.65524554",
"0.6287612",
"0.6215714",
"0.62096953",
"0.6122508",
"0.5976375",
"0.5967801",
"0.59489584",
"0.5888559",
"0.5879763",
"0.58604133",
"0.58598757",
"0.58206785",
"0.57676476",
"0.57145554",
"0.56830806",
"0.5675... | 0.590965 | 12 |
find a set of records matching the given options | def find(options)
table = DB.from(@table)
options.each_pair do |method_name,params|
table = table.send(method_name, params)
end
# convert the array of hashes to an array of model objects
table.all.map{|row| @model_class.new row}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def any(options = {})\n\t get_records('-findany', {}, options)\n\t end",
"def find_matching(options)\n find_all {|x| options.map {|k, v| v.nil? || x.send(k) == v}.all?}\n end",
"def where(options = {})\n all.select do |record|\n options.all? { |key, value| record.send(key) == value }\n ... | [
"0.72768694",
"0.7056676",
"0.7009422",
"0.67469734",
"0.6684682",
"0.66128135",
"0.64780253",
"0.6451204",
"0.63943017",
"0.6385622",
"0.62939984",
"0.62932783",
"0.626198",
"0.621012",
"0.61698073",
"0.6161536",
"0.61339897",
"0.6129614",
"0.6108801",
"0.6106895",
"0.609355... | 0.5839383 | 40 |
get a specific instance from the table | def get options
table = DB.from(@table)
result = table.first :id => options[:id]
# return an instance of the model class with the data attributes
@model_class.new result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_instance instance_id\n execute do\n instances.get_instance(\n instance_path(instance_id)\n )\n end\n end",
"def get_instance instance_id\n instances.get_instance name: instance_path(instance_id)\n end",
"def instance(instance_i... | [
"0.73576224",
"0.7194662",
"0.7166897",
"0.6812942",
"0.6702406",
"0.66738564",
"0.6667123",
"0.65155417",
"0.64416623",
"0.63873315",
"0.63213193",
"0.63213193",
"0.629945",
"0.62744266",
"0.62591463",
"0.62489784",
"0.6241576",
"0.62395394",
"0.62265533",
"0.6218224",
"0.62... | 0.0 | -1 |
delete one or more records from the table | def delete options
table = DB.from(@table)
if options[:where]
result = table.where(options[:where]).delete
else
result = table.where(:id => options[:id]).delete
end
# invalidate a cached range
@@_cached_range = nil
return true if result == 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _delete_records\n @ids_to_delete.each do |table, ids|\n delete_from_table(table, ids)\n end\n end",
"def delete_record(table, values)\n delete table_delete_query(table, values)\n end",
"def delete(*records)\n records.each do |record|\n target.delete(record)\n... | [
"0.7794929",
"0.7461326",
"0.7456888",
"0.74441445",
"0.7221976",
"0.72200835",
"0.72011805",
"0.71888417",
"0.7118984",
"0.70962983",
"0.7076991",
"0.70330983",
"0.7013369",
"0.6993739",
"0.69728523",
"0.6965628",
"0.6947615",
"0.69223285",
"0.6904967",
"0.68529314",
"0.6849... | 0.0 | -1 |
get an array of entries that each contain the table ID and a human readable identifier (a title or name) | def range
@cached_range ||= get_range
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ids(table)\r\n valid_ids = []\r\n table_info = @db.execute(\"SELECT * FROM #{table}\")\r\n table_info.each do |line|\r\n line_info = []\r\n line.each do |name, value|\r\n if name == 'id'\r\n valid_ids ... | [
"0.65041876",
"0.63557446",
"0.63225514",
"0.62161505",
"0.6209736",
"0.619918",
"0.6137857",
"0.60679984",
"0.6048846",
"0.60372263",
"0.6024032",
"0.6023994",
"0.6002793",
"0.59719914",
"0.5939172",
"0.59367025",
"0.5935549",
"0.59282684",
"0.5920281",
"0.5898868",
"0.58432... | 0.0 | -1 |
Validate if radius is a number and is within the limit | def valid_radius?
float?(radius) &&
radius.to_f.positive? &&
radius.to_f <= MAXIMUM_SEARCH_RADIUS_IN_KM
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_radius(params, default = \"\")\n return default unless params[:radius]\n return validate_positive_integer(params[:radius])\n end",
"def in_range?(radius:, location:)\n (((location.latitude - @latitude) ** 2) + ((location.longitude - @longitude) ** 2)) < (radius ** 2)\n end",
... | [
"0.7174791",
"0.69351506",
"0.69101447",
"0.68819463",
"0.63981044",
"0.6244821",
"0.6236836",
"0.6189319",
"0.61889243",
"0.611946",
"0.6116388",
"0.61089975",
"0.6077601",
"0.6077601",
"0.6056877",
"0.6026943",
"0.5991501",
"0.59904325",
"0.59656036",
"0.59420204",
"0.59400... | 0.78094876 | 0 |
Build a file rule | def file(name)
Rule::File.new(name.to_s, path(name))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_rule(*args, &block)\n @ProjectFileLoader.CurrentlyLoadedProjectFile().create_rule(*args, &block)\n end",
"def build_filelist(source_file, rule_name)\n basename = source_file.pathmap('%n') # base name without ext\n prefix = \"#{CONF[\"project\"]}-#{rule_name}--#{basename}\"\n src_lines =... | [
"0.60943615",
"0.6067572",
"0.6048278",
"0.6034292",
"0.6023926",
"0.5877565",
"0.57775944",
"0.5762389",
"0.5698455",
"0.5685365",
"0.5639587",
"0.5504952",
"0.55018836",
"0.5451692",
"0.5436869",
"0.5410452",
"0.53584254",
"0.534776",
"0.5337667",
"0.5337667",
"0.5337667",
... | 0.6343932 | 0 |
Return names matching pattern | def glob(pattern)
root = self.root
Pathname.glob(root.join(pattern)).map do |match|
match.relative_path_from(root).to_s
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_names(names = [])\n names.select { |name| name.match /\\w\\s\\w/ }\nend",
"def expand_name_wide(names, pattern)\n re1 = /\\A#{Regexp.quote(pattern)}/i\n names.grep(re1)\n end",
"def find_by_starts_with(name)\n return nil unless name.present?\n names.select {|e| e.starts... | [
"0.70877576",
"0.70188636",
"0.68902636",
"0.67925507",
"0.6733503",
"0.6590051",
"0.6493314",
"0.6470156",
"0.64306146",
"0.6419332",
"0.6419332",
"0.640894",
"0.6378203",
"0.6367501",
"0.6347172",
"0.6264247",
"0.6230621",
"0.6221402",
"0.62172806",
"0.6152123",
"0.6135575"... | 0.0 | -1 |
Return path for name | def path(name)
root.join(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path\n name.split(\"::\").join(\"/\").downcase\n end",
"def path\n name + extension\n end",
"def path\n File.join(@base, @name)\n end",
"def path\n File.join(@base, @name)\n end",
"def path\n [name]\n end",
"def path()\n return ::File.join(@root, @na... | [
"0.8498768",
"0.8206324",
"0.79913837",
"0.7972508",
"0.78714836",
"0.772216",
"0.77032346",
"0.75825655",
"0.75339144",
"0.74435383",
"0.7428756",
"0.7427621",
"0.73642755",
"0.7350977",
"0.7310141",
"0.7268961",
"0.7268961",
"0.7268961",
"0.72660065",
"0.7246179",
"0.721182... | 0.8052777 | 2 |
Build a compile rule | def compile(name)
Rule::Compile.build(file(name))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_compile_rule(src)\n sha = Digest::SHA1.hexdigest(src)\n fn = File.basename(src, '.c')\n dest = \"build/#{sha}_#{fn}.o\"\n SOURCE_LOOKUP[src] = dest\n\n CompileTask.define_task(dest => [src]) do |t|\n sh \"#{TOOLCHAIN}gcc #{t.cflags.join(' ')} -c #{t.prerequisites.first} -o #{t.name}\"\n end\nend"... | [
"0.7613854",
"0.64554757",
"0.64461756",
"0.63355327",
"0.6146135",
"0.59554607",
"0.5943433",
"0.59358174",
"0.5931617",
"0.5878314",
"0.5874064",
"0.58554494",
"0.582651",
"0.5815246",
"0.58022225",
"0.5756067",
"0.57498485",
"0.5737853",
"0.5727403",
"0.56933635",
"0.56456... | 0.6851784 | 1 |
For more complex tasks You can use a method | def fetch_popular
self.with_purchase_rate
.viewed_by_people
.reverse_order(:purchase_rate, :purchases_count)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def operations; end",
"def operations; end",
"def call() end",
"def suivre; end",
"def method\n\t\t# code code\n\tend",
"def call\n\n\tend",
"def call\n\n\tend",
"def calls; end",
"def calls; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def... | [
"0.6537611",
"0.6537611",
"0.6448165",
"0.6415729",
"0.635246",
"0.63289046",
"0.63289046",
"0.63036084",
"0.63036084",
"0.629112",
"0.629112",
"0.629112",
"0.629112",
"0.629112",
"0.629112",
"0.629112",
"0.629112",
"0.6256984",
"0.62215173",
"0.619489",
"0.61451674",
"0.61... | 0.0 | -1 |
All validations goes here | def validate
super
errors.add(:name, "can't be empty") if name.blank?
errors.add(:category_id, "can't be empty") if category_id.blank?
errors.add(:price, "can't be empty") if price.blank?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validation; end",
"def validation; end",
"def validate\n end",
"def validate\r\n\r\n end",
"def validate\n \n \n end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate\n end",
"def validate\n end",
"def validate\n end",
"... | [
"0.846664",
"0.846664",
"0.8399877",
"0.8336741",
"0.8308748",
"0.82665545",
"0.82665545",
"0.82665545",
"0.82665545",
"0.81303406",
"0.81303406",
"0.81303406",
"0.80845565",
"0.8052318",
"0.80476546",
"0.8036758",
"0.7981848",
"0.7981848",
"0.7981848",
"0.7936774",
"0.791018... | 0.0 | -1 |
By default the factory for a test case generates an command option in the form option 'its_valie_value' in case if a programmer needs read only the value part this method is used | def strip_out_command_key(value)
return value.split(' ').last
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value\r\n assert_exists\r\n option_value\r\n end",
"def cli=(value); end",
"def test_add_option04c\n assert_nothing_raised {\n ArgumentManager.add_option(\n [ 'u' ],\n :type => :string,\n :mandatory => true,\n :df_str => 'foo'\n )\n }\n end",
... | [
"0.66966033",
"0.6501722",
"0.6276531",
"0.6179503",
"0.61049646",
"0.6010233",
"0.5988703",
"0.59871364",
"0.59532267",
"0.5927385",
"0.5925981",
"0.58748055",
"0.58710116",
"0.58604044",
"0.5844706",
"0.58065885",
"0.58063686",
"0.580464",
"0.58019274",
"0.58019274",
"0.580... | 0.0 | -1 |
This is a common method for running shell out command | def find_instance_id(instance_name, list_command_output)
file = list_command_output.tap(&:run_command).stdout
puts "searching instance id for instance with name : #{instance_name}..."
# puts file
file.lines.each do |line|
if line.include?("#{instance_name}")
puts "#{line}"
return "#{line}".spli... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shell_out_command(cmd, msg)\n cmd_local = \"#{cmd}\" + \" -c #{knife_config}\" + \"#{grep_cmd}\"\n shell_out = Mixlib::ShellOut.new(\"#{cmd_local}\", :timeout => timeout)\n puts \"#{msg}\"\n puts \"#{cmd_local}\"\n @op = shell_out.tap(&:run_command).stdout\n puts \"#{c... | [
"0.7311906",
"0.7237851",
"0.723278",
"0.72275615",
"0.70630753",
"0.69932896",
"0.6769414",
"0.6763855",
"0.67284834",
"0.6618664",
"0.65767723",
"0.65622056",
"0.65581",
"0.65246356",
"0.6496938",
"0.6477006",
"0.6474788",
"0.6429378",
"0.6425374",
"0.6417787",
"0.64028263"... | 0.0 | -1 |
Confirms the correct user. | def correct_user
@user = User.find(params[:id])
redirect_to(root_url) unless current_user?(@user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_user\n msg = \"You do not have permission to update another user's information\"\n require_correct_user(@user, msg)\n end",
"def correct_user\n\t\t\tauthenticate_user!\n\t\t\tunless @user == current_user || current_user.admin?\n\t\t\t\tredirect_to (root_path)\n\t\t\t\tflash[:alert]\n... | [
"0.7474259",
"0.73411936",
"0.7317917",
"0.7183303",
"0.7174887",
"0.7049758",
"0.70130193",
"0.7012358",
"0.7006517",
"0.7006201",
"0.7003461",
"0.69663024",
"0.69136065",
"0.6911695",
"0.690295",
"0.6892608",
"0.68439376",
"0.6842948",
"0.68397075",
"0.683463",
"0.6826711",... | 0.6658565 | 84 |
Confirms an admin user. | def admin_user
redirect_to(root_url) unless current_user.is_admin?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def confirm_admin\n \tunless session[:admin]\n \t\tflash[:notice] = \"You are not an admin.\"\n \t\tredirect_to(user_path( :id => session[:user_id]))\n \tend\n end",
"def admin_user\n\t\t\tflash_text = \"Administrative privilege required to perform this action.\"\n\t\t\tflash[:danger] = flash_text unless cu... | [
"0.79044944",
"0.767215",
"0.76483077",
"0.76210374",
"0.7605678",
"0.7605678",
"0.75945777",
"0.7588445",
"0.7588445",
"0.7503662",
"0.74675834",
"0.7451482",
"0.7424005",
"0.7411313",
"0.74107665",
"0.7402138",
"0.73993605",
"0.7358812",
"0.7329228",
"0.73179626",
"0.731276... | 0.70904475 | 52 |
Need a version of this for the application helper since `render` is different in the controller vs the view. | def render_for( short_name, options = {})
template = template_for(short_name)
render options.merge(template.to_params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render\n end",
"def render\n end",
"def render\n end",
"def make_render_in_view exp\n make_render exp, true\n end",
"def render\n end",
"def view_renderer; end",
"def view_renderer; end",
"def render\n\n end",
"def render\n end",
"def render; end",
"def render; end",
"... | [
"0.72831666",
"0.72831666",
"0.72831666",
"0.7207154",
"0.72019696",
"0.71990454",
"0.71990454",
"0.71648663",
"0.71244043",
"0.7095918",
"0.7095918",
"0.7095918",
"0.7095918",
"0.7095918",
"0.6956608",
"0.69240004",
"0.68999594",
"0.687665",
"0.6858989",
"0.68311983",
"0.677... | 0.0 | -1 |
expire cache also for dirty objects | def expire_cache
filename = name_changed? ? name_was : name
FileUtils.rm_rf(File.join(Shapes.cache_dir_path, filename))
FileUtils.rm_f(File.join(Shapes.cache_dir_path, "#{filename}.xml"))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_save(object)\n expire_cache_for_all\n end",
"def expire_cache(key)\n end",
"def expire_cache!\n @snapshot = nil\n end",
"def invalidate_cache! now\n end",
"def _expire_cache(*keys)\n Rails.cache.delete( _cache_key(keys) )\n end",
"def expire_cache_for(*args)\n ... | [
"0.76459485",
"0.7586568",
"0.74860454",
"0.7423198",
"0.7188371",
"0.71782666",
"0.7132767",
"0.705312",
"0.70266247",
"0.701545",
"0.70130223",
"0.70106566",
"0.7001815",
"0.6996659",
"0.69926655",
"0.69247496",
"0.69247496",
"0.6913568",
"0.6907528",
"0.69054216",
"0.69044... | 0.0 | -1 |
FIXME: Resource.validate should accept a parameter (the instance error object) and write directly to it. | def validate_shape
base.validate
base.errors.collect{|error|
errors.add_to_base(error.show_message)
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate(resource)\n raise Error::AbstractMethod.new(method: \"Validators::Base#validate\")\n end",
"def validate(resource, &block); end",
"def save_with_validation\n save_without_validation\n true\n rescue ResourceInvalid => error\n errors.from_xml(error.response.body)\n fal... | [
"0.6695475",
"0.6662623",
"0.6577411",
"0.6494797",
"0.6074403",
"0.60270935",
"0.5835389",
"0.57520497",
"0.5752049",
"0.5717939",
"0.5714457",
"0.5689634",
"0.56859154",
"0.56808984",
"0.5650432",
"0.5642343",
"0.56378007",
"0.56378007",
"0.56378007",
"0.56378007",
"0.56338... | 0.0 | -1 |
Description: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Finish the solution so that it returns the sum of all the multiples of 3 or 5 below the number passed in. Courtesy of ProjectEuler.net | def solution(number)
return (0...number).select{ |x| ((x % 3 == 0) || (x % 5 == 0))}.reduce(:+)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multiples_three_five(max_number)\n sum = 0\n max_number = max_number - 1\n (0..max_number).each do |number|\n if number % 3 == 0 || number % 5 == 0\n sum = sum + number\n end\n end\n return sum\nend",
"def sum_of_multiples_3_5_below(n)\n (1...n).select {|x| x%3==0 || x%5==0}.inject(&:+)\nend... | [
"0.81388897",
"0.8135318",
"0.810877",
"0.8097538",
"0.7994434",
"0.7948006",
"0.7918598",
"0.7902253",
"0.78864914",
"0.78723174",
"0.78691334",
"0.7868521",
"0.78635496",
"0.78548545",
"0.78247094",
"0.7824153",
"0.7819668",
"0.7814907",
"0.78084016",
"0.7786238",
"0.778573... | 0.78473544 | 14 |
Condition to determine whether to enable maintenance mode | def enable_only_if(&block)
set_or_return(:enable_only_if, block, kind_of: Proc)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable_maintenance_page?\n maintenance_on_restart? || (migrate? && maintenance_on_migrate?)\n end",
"def bypass_maintenance?\n !!runopts(:bypass_maintenance)\n end",
"def check_for_maintenance_mode\n if current_site.maintenance_mode?\n unless admin_signed_in? && current_admin.has_pr... | [
"0.79241765",
"0.7720885",
"0.76520014",
"0.7568416",
"0.7319304",
"0.7227367",
"0.7110502",
"0.70819646",
"0.7025666",
"0.695852",
"0.695852",
"0.67928904",
"0.6777381",
"0.6693421",
"0.6660678",
"0.6580958",
"0.6556563",
"0.6520724",
"0.6482602",
"0.6353327",
"0.62916595",
... | 0.0 | -1 |
Condition to determine whether to disable maintenance mode | def disable_only_if(&block)
set_or_return(:disable_only_if, block, kind_of: Proc)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disable_maintenance_page?\n enable_maintenance_page?\n end",
"def bypass_maintenance?\n !!runopts(:bypass_maintenance)\n end",
"def check_for_maintenance_mode\n if current_site.maintenance_mode?\n unless admin_signed_in? && current_admin.has_privileges_for?(current_site)\n ra... | [
"0.804399",
"0.78809416",
"0.7578678",
"0.73305583",
"0.72363883",
"0.7218504",
"0.7107789",
"0.7092732",
"0.69309515",
"0.69309515",
"0.68112826",
"0.6764448",
"0.6739831",
"0.66943544",
"0.6629857",
"0.6587069",
"0.6582461",
"0.6551393",
"0.65336156",
"0.65165436",
"0.64114... | 0.0 | -1 |
When compile_time is defined, apply the action immediately and then set the action :nothing to ensure that it does not run a second time. | def after_created
if compile_time
actions = Array(self.action) || [:manage]
actions.each do |action|
next if action == :nothing
self.run_action(:manage)
end
self.action(:nothing)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_created\n if compile_time\n self.run_action(:apply)\n self.action :nothing\n end\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each... | [
"0.7755722",
"0.7338447",
"0.7338447",
"0.7335306",
"0.7335306",
"0.7335306",
"0.66704065",
"0.567134",
"0.5576218",
"0.5495963",
"0.54812217",
"0.54767907",
"0.54577345",
"0.5428008",
"0.53470826",
"0.5282468",
"0.52692956",
"0.523262",
"0.523262",
"0.5227338",
"0.52083784",... | 0.7016636 | 6 |
Perform an HTTP POST request | def post(path, options = {}, raw = false)
request(:post, path, options, raw)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_post_request url, body, headers = []\n make_request url, method: ::Rack::POST, body: body, headers: headers\n end",
"def post url, body, headers = {}\n http_request(url, Net::HTTP::Post, body, headers)\n end",
"def post(url, body, headers = {})\n do_request Net::HTTP::Post, url, hea... | [
"0.8219336",
"0.8101932",
"0.78963655",
"0.7830325",
"0.7689463",
"0.76873493",
"0.7641582",
"0.75474995",
"0.75034285",
"0.74829894",
"0.7459943",
"0.74446553",
"0.74328977",
"0.74057776",
"0.738012",
"0.7367464",
"0.73457575",
"0.7309113",
"0.7301297",
"0.72935265",
"0.7278... | 0.0 | -1 |
Perform an HTTP request | def request(method, path, options, raw = false)
response = connection(raw).send(method) do |request|
options = options.compact
case method
when :get
request.url(path, options)
when :post
request.url(path)
request.body = options unless options.empty?
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_request()\n uri = URI.parse(API_BASE_URL + build_request_path())\n response = Net::HTTP.get_response(uri)\n response.body\n end",
"def run_request(method, url, body, headers); end",
"def make_request(url,headers,query)\n c = HTTPClient.new\n c.get_content(url,query,headers)\nend",
... | [
"0.7807713",
"0.76851505",
"0.765171",
"0.7641738",
"0.7480938",
"0.7303946",
"0.7232041",
"0.72308135",
"0.7189314",
"0.7175213",
"0.71751964",
"0.714659",
"0.7128462",
"0.7099501",
"0.70929027",
"0.70875484",
"0.7084511",
"0.707887",
"0.7076142",
"0.7071604",
"0.70575994",
... | 0.0 | -1 |
scrape the url for wek overview and yield urls | def each_day url, doc=download(url)
doc.css('.heading1 a').each do |week_node|
doc2 = download(url + week_node[:href])
doc2.css('.wd a').each { |a_wday| yield url + a_wday[:href] }
end
doc
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scrape\n google_url = create_google_url\n google_data = Scrubyt::Extractor.define do\n fetch google_url\n\n link_title \"//a[@class='l']\", :write_text => true do\n link_url\n end\n end\n google_data.to_hash.map {|r| r[:link_url]}\n end",
"def scrape\n end",
"def parse_f... | [
"0.68141276",
"0.66241723",
"0.65371144",
"0.64518213",
"0.64441925",
"0.6365669",
"0.6359475",
"0.6319588",
"0.62882304",
"0.62690777",
"0.6228609",
"0.61856437",
"0.61733466",
"0.61352724",
"0.61352724",
"0.61288285",
"0.6127951",
"0.61239254",
"0.6122508",
"0.6118688",
"0.... | 0.59563833 | 30 |
scrape the url for broadcasts and yield times, titles, urls | def each_broadcast url, doc=download(url)
# $stderr.puts "#{self.class}.each_broadcast #{url}"
begin
day_node = doc.at_css('#col-left h1')
day_match = /\s+(\d+)\.(\d+)\.(\d+)/.match day_node.text
raise "Cannot parse day '#{day_node}'" if day_match.nil?
day = day_match[1]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_urls(url, d)\n useragent = \"NotubeMiniCrawler/0.1\"\n u = URI.parse url \n req = Net::HTTP::Get.new(u.request_uri,{'User-Agent' => useragent})\n begin \n res2 = Net::HTTP.new(u.host, u.port).start {|http|http.request(req) }\n ... | [
"0.6478423",
"0.63583577",
"0.6353239",
"0.62955296",
"0.62860924",
"0.62645626",
"0.62237364",
"0.61947423",
"0.6111425",
"0.60556954",
"0.60276455",
"0.60121423",
"0.6008413",
"0.59916615",
"0.59691715",
"0.5922417",
"0.59090686",
"0.58844453",
"0.58758765",
"0.5852351",
"0... | 0.71962625 | 0 |
Simply delegate to == in this example. | def eql?(comparee)
self == comparee
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==\n end",
"def ==(*) end",
"def ==(*) end",
"def ==(*) end",
"def ==(*)\n true\n end",
"def ==(ct); end",
"def ==(ct); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(othe... | [
"0.8532169",
"0.8525601",
"0.8525601",
"0.8525601",
"0.8228274",
"0.81830597",
"0.81830597",
"0.8162983",
"0.8162983",
"0.8162983",
"0.8162983",
"0.8162983",
"0.8162983",
"0.8162983",
"0.8162983",
"0.8162983",
"0.8162983",
"0.8162983",
"0.8162983",
"0.8162983",
"0.8162983",
... | 0.0 | -1 |
Objects are equal if they have the same unique custom identifier. | def ==(comparee)
self.id == comparee.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(object)\n self._id == object._id rescue false\n end",
"def equal?(other)\n object_id == other.object_id\n end",
"def == other\n self.object_id == other.object_id\n end",
"def ==(other)\n self.uuid == other.uuid\n end",
"def ==(comparee)\n guid == comparee.guid\n end",... | [
"0.73386705",
"0.7213114",
"0.7207336",
"0.69900954",
"0.69680446",
"0.6961038",
"0.69321114",
"0.6916859",
"0.69096357",
"0.6906072",
"0.6901109",
"0.68717486",
"0.677088",
"0.6765262",
"0.6765262",
"0.6765262",
"0.67339444",
"0.67339444",
"0.67263067",
"0.67207545",
"0.6715... | 0.6299785 | 62 |
Requires:Room (via id) Passes a room into the show view. | def show
@room = Room.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @room }
format.js {}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @room = Room.find(params[:id])\n end",
"def show\n @room = Room.find(params[:id])\n end",
"def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n end\n end",
"def show\n buildingId = params[:id]\n @room = Room.where(buildin... | [
"0.81886446",
"0.81886446",
"0.7763437",
"0.77552766",
"0.7603857",
"0.75942504",
"0.7501563",
"0.74966604",
"0.7443648",
"0.74423903",
"0.74423903",
"0.74423903",
"0.74133474",
"0.74133474",
"0.7411181",
"0.7383775",
"0.73193556",
"0.7243322",
"0.72323143",
"0.7211477",
"0.7... | 0.70194185 | 61 |
Requires: Longitude, Latitude Updates the user's location and sets the new latitude and longitude coordinates. | def new_location
current_user.update_location(params[:longitude], params[:latitude])
@room = Room.first
respond_to do |format|
format.js {render :nothing => true }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_my_location\n current_user.update(latitude: params[:latitude], longitude: params[:longitude])\n end",
"def update\n super\n\n @user = current_user\n @user.latitude = params[:user][:latitude]\n @user.longitude = params[:user][:longitude]\n @user.save\n end",
"def set_location(lati... | [
"0.81366867",
"0.779908",
"0.7382911",
"0.7267437",
"0.7267437",
"0.7267437",
"0.7267437",
"0.7267437",
"0.7267437",
"0.7267437",
"0.7267437",
"0.7267437",
"0.7267437",
"0.7267437",
"0.7267437",
"0.7267437",
"0.7238244",
"0.7153",
"0.71518314",
"0.7148314",
"0.71341443",
"0... | 0.0 | -1 |
Requires: Room (via room_id) Checks out a room if it's not occupied. | def checkout
@room = Room.find(params[:room_id])
respond_to do |format|
if @room.users.include?(current_user)
current_user.checkin
if @room.users.size == 0
@room.checkin
end
format.html { redirect_to @room, :notice => "Successfully checked room back in" }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vacate_room(room)\n room.occupied = 0\n end",
"def occupy_room(room)\n room.occupied = 1\n end",
"def room_availability\n @problem.never{\n same(:room_id, :weekday_id, :timeframe_id).for(Timetable::Entry, Room::Unavailability)\n }\n end",
"def checkroom(r)\n case r.status\n... | [
"0.72319317",
"0.70755583",
"0.699217",
"0.68405026",
"0.67838746",
"0.67666745",
"0.6755085",
"0.6741467",
"0.67247826",
"0.6693352",
"0.6688847",
"0.66688395",
"0.66633564",
"0.6599589",
"0.65975916",
"0.6519327",
"0.6506871",
"0.6503812",
"0.65014327",
"0.6460126",
"0.6424... | 0.0 | -1 |
Requires: Room (via room_id) Refreshes the room information to show the update status of a room. | def refresh
@room = Room.find(params[:room_id])
respond_to do |format|
format.json { render :json => @room }
format.html
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_room_status\n room.update(:is_available => false)\n end",
"def update\n room = Room.find(params[:id])\n\n if room.update(room_params)\n response_data = {\n room: room,\n txt: ['更新しました!'],\n }\n render json: response_data, status: :ok\n else\n response_dat... | [
"0.7403326",
"0.735676",
"0.7133736",
"0.711931",
"0.7012703",
"0.69289756",
"0.69189256",
"0.6780802",
"0.67697823",
"0.6752921",
"0.6748715",
"0.6745484",
"0.67319435",
"0.6726621",
"0.6726209",
"0.6720386",
"0.6716483",
"0.67085433",
"0.670292",
"0.669788",
"0.66820693",
... | 0.6844739 | 7 |
GET /nhan_xets/1 GET /nhan_xets/1.json | def show
@nhan_xet = NhanXet.where(:chi_tiet_binh_bau_id => params[:id])
respond_to do |format|
format.json { render json: @nhan_xet.collect{|i| {:NoiDung => i.NoiDung, :created_at =>i.created_at.strftime("Ngày %d/%m/%Y lúc %H:%M"), :MaUser => i.user.MaUser,:TenUser => i.user.HoTen, :TenTruong => i.truon... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @xpto = Xpto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @xpto }\n end\n end",
"def index\n @nepals = Nepal.all\n\n render json: @nepals\n end",
"def index\n @money = Money.all\n require 'net/http'\n requ... | [
"0.6121255",
"0.6063892",
"0.6046505",
"0.6012254",
"0.60094804",
"0.5978828",
"0.5938495",
"0.59242046",
"0.5873065",
"0.5844128",
"0.58170855",
"0.5789618",
"0.57760954",
"0.57721025",
"0.5763188",
"0.57595086",
"0.575821",
"0.5751873",
"0.5748492",
"0.5743016",
"0.5740833"... | 0.5908303 | 8 |
GET /nhan_xets/new GET /nhan_xets/new.json | def new
@nhan_xet = NhanXet.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @nhan_xet }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @xpto = Xpto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @xpto }\n end\n end",
"def new\n @dotsmember = Dotsmember.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dotsmember }\n ... | [
"0.7214237",
"0.6986828",
"0.6933185",
"0.6881785",
"0.6869991",
"0.6857847",
"0.685052",
"0.68492836",
"0.6831118",
"0.6823002",
"0.6818346",
"0.68139523",
"0.6810043",
"0.6805893",
"0.6799513",
"0.67855275",
"0.67836046",
"0.67788917",
"0.6768889",
"0.6766213",
"0.67639875"... | 0.75600535 | 0 |
POST /nhan_xets POST /nhan_xets.json | def create
@nhan_xet = NhanXet.new(params[:nhan_xet])
@nhan_xet[:user_id] = session[:FBUser][:id]
respond_to do |format|
if @nhan_xet.save
format.html { render json: {:NoiDung => @nhan_xet.NoiDung, :created_at =>@nhan_xet.created_at.strftime("Ngày %d/%m/%Y lúc %H:%M"), :MaUser => @nhan_xet.use... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @nhan_xet = NhanXet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nhan_xet }\n end\n end",
"def create\n @xinwen = Xinwen.new(params[:xinwen])\n\n respond_to do |format|\n if @xinwen.save\n format.html { redirect_to @xinw... | [
"0.5714105",
"0.56655866",
"0.5553812",
"0.5530269",
"0.5522593",
"0.55037254",
"0.5485798",
"0.5432419",
"0.539347",
"0.5392677",
"0.53880274",
"0.5376328",
"0.5323014",
"0.526642",
"0.5265203",
"0.5231166",
"0.5224977",
"0.520094",
"0.5194504",
"0.5175457",
"0.5161805",
"... | 0.56027544 | 2 |
PUT /nhan_xets/1 PUT /nhan_xets/1.json | def update
@nhan_xet = NhanXet.find(params[:id])
respond_to do |format|
if @nhan_xet.update_attributes(params[:nhan_xet])
format.html { redirect_to [:admin, @nhan_xet], notice: 'Nhan xet was successfully updated.' }
format.json { head :no_content }
else
format.html { render ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def put!\n request! :put\n end",
"def update\n @xinwen = Xinwen.find(params[:id])\n\n respond_to do |format|\n if @xinwen.update_attributes(params[:xinwen])\n format.html { redirect_to @xi... | [
"0.5963682",
"0.5842446",
"0.58117443",
"0.577405",
"0.57713014",
"0.5741027",
"0.57289857",
"0.56824994",
"0.56562304",
"0.5647806",
"0.5623173",
"0.5617575",
"0.5603722",
"0.55966085",
"0.5583574",
"0.5583525",
"0.5574598",
"0.55545324",
"0.5548116",
"0.5480998",
"0.5444913... | 0.65634304 | 0 |
DELETE /nhan_xets/1 DELETE /nhan_xets/1.json | def destroy
@nhan_xet = NhanXet.find(params[:id])
@nhan_xet.destroy
respond_to do |format|
format.html { redirect_to admin_nhan_xets_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.js... | [
"0.70428056",
"0.6982838",
"0.6945251",
"0.6909317",
"0.6868777",
"0.6850633",
"0.68421537",
"0.68134",
"0.68134",
"0.68134",
"0.68134",
"0.6798621",
"0.67352474",
"0.6724143",
"0.6709836",
"0.67071253",
"0.6662239",
"0.66466564",
"0.66441303",
"0.6643071",
"0.6636791",
"0.... | 0.7351528 | 0 |
make product OUT OF STOCK Globally | def out_of_stock_globally
#API body = {:product_id => 1, :status => true}
status = params[:status] == "true" ? true : false
@product = Spree::Product.find(params[:product_id])
variants = @product.variants.present? ? @product.variants : [@product.master]
variants.each do |variant|
Spree::StockI... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_product\n \n end",
"def save_to_spree\n ::Product.save_from_amazon({\n :attributes =>{\n :amazon_id => self.id,\n :sku => self.id,\n ... | [
"0.6332299",
"0.6274607",
"0.61729807",
"0.6135032",
"0.6124454",
"0.6053174",
"0.60417616",
"0.5984514",
"0.5926383",
"0.5924774",
"0.5910453",
"0.590004",
"0.5894021",
"0.5882087",
"0.58801454",
"0.58241385",
"0.5807538",
"0.5771538",
"0.57695514",
"0.5766354",
"0.5765285",... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def campaign_params
params.require(:campaign).permit(:name, :target_group_id)
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 |
Searches load path for rbc files. If a normal Ruby file exists with with a more recent mtime, then that will be loaded instead. Delegates to Ruby's normal require if a file can't be found. | def require_with_rbyte(name)
path = Rbyte.search_for_rbc_file(name)
unless path
return require_without_rbyte(name)
end
# File already loaded?
return false if $".include?(path)
# File is plain ruby
if path =~ /\.rb\Z/
return require_without_rbyte(pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rsc_require(file)\n # Create error object\n load_error = LoadError.new(\"No such file to load -- #{file}\")\n # Tack on the extension if the argument does not already include it.\n file += '.rsc' unless file.split('.')[-1] == 'rsc'\n # Iterate over all require directories\n $:.each do |dir|\n # Make t... | [
"0.63328207",
"0.6305668",
"0.62794447",
"0.62671363",
"0.62451303",
"0.62147975",
"0.6183926",
"0.59819794",
"0.59569323",
"0.58353156",
"0.5816514",
"0.5786009",
"0.5786009",
"0.5786009",
"0.57560366",
"0.5656702",
"0.5618874",
"0.56184405",
"0.56086075",
"0.55833644",
"0.5... | 0.74236876 | 0 |
Read a rbc file and evaluate it | def decompile_file(path)
res = Marshal.load(File.read(path))
RubyVM::InstructionSequence.load_array(res).eval
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_file(file)\n evaluate(parse_file(file))\n end",
"def load_rb( file )\r\n begin\r\n str = IO.read(file)\r\n load_rb_rules_as_string(str)\r\n rescue Exception => e\r\n raise RuleLoadingError, \"loading ruby file\"\r\n end\r\n end",
"def read_binary(file... | [
"0.6359658",
"0.6150587",
"0.59057283",
"0.59036285",
"0.5859326",
"0.577466",
"0.5724367",
"0.5671881",
"0.5607155",
"0.55722547",
"0.55227184",
"0.54911834",
"0.5478143",
"0.5476519",
"0.54129225",
"0.53982157",
"0.5386721",
"0.538518",
"0.5343663",
"0.532805",
"0.53243643"... | 0.0 | -1 |
Compile a Ruby file to a Ruby byte code (rbc) file. The rbc file will be placed next to the Ruby file. If the method returns false, than compilation failed. | def compile_file(path)
path = "#{path}.rb" unless path =~ /\.rb\Z/
res = RubyVM::InstructionSequence.compile_file(path)
data = Marshal.dump(res.to_a)
rbc_path = path + "c"
File.open(rbc_path, "w+") {|f| f.write data }
rescue NotImplementedError
# Ruby bug with terminated objects
false
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile_to_ruby\n \"if \" + indent_c(@condition.compile_to_ruby) + \"\\n\" +\n indent_ruby(@then_part.compile_to_ruby) +\n \"\\nelse\\n\" +\n indent_c(@else_part.compile_to_ruby) +\n \"\\nend\"\n end",
"def compile(infile, outfile, asm)\n\n File.open(infile, 'r') do |inpu... | [
"0.64578444",
"0.64478445",
"0.6418244",
"0.63972795",
"0.63520354",
"0.63292396",
"0.62895465",
"0.6270782",
"0.6194118",
"0.6189642",
"0.6102084",
"0.60623884",
"0.60506296",
"0.6028745",
"0.5999201",
"0.59862524",
"0.5925574",
"0.59004676",
"0.58749795",
"0.58611447",
"0.5... | 0.7997991 | 0 |
Only paths without a extension or with an extension of .rbc are are supported. If you require a file with a rb extension, it's assumed you only want plain ruby files. | def supported_file?(path)
ext = File.extname(path)
return true if ext.empty?
ext =~ /\.rbc\Z/
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_rb_extension\n @requires.map! do |require|\n if(require.end_with?'.rb')\n require.slice(0, require.length - 3)\n end\n end\n end",
"def no_ext(path)\n File.basename(path, \".rb\")\n end",
"def valid_extensions\n %w[.rb .js]\n end",
"def proper_ext?(raw_path)... | [
"0.67169744",
"0.6707599",
"0.6467939",
"0.63991517",
"0.6388884",
"0.627954",
"0.62695026",
"0.62203366",
"0.61531836",
"0.6020794",
"0.6010043",
"0.6010043",
"0.5992208",
"0.5917785",
"0.59042454",
"0.58589095",
"0.5761531",
"0.570619",
"0.5693907",
"0.56844765",
"0.5682403... | 0.6707979 | 1 |
def select_category_from_projects "SELECT category FROM projects;" end Make sure each ruby method returns a string containing a valid SQL statement. | def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name
"SELECT projects.title, SUM (pledges.amount) FROM projects, pledges
GROUP BY pledges.project_id, projects.title
HAVING projects.id=pledges.project_id
ORDER BY projects.title ASC;"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_category_from_projects\n\"SELECT category FROM projects;\"\nend",
"def selects_the_category_names_and_pledge_amounts_of_all_pledges_in_the_music_category\n\"SELECT projects.category, pledges.amount\nFROM pledges\nINNER JOIN projects\nON projects.id = pledges.project_id\nWHERE projects.category = 'musi... | [
"0.91990644",
"0.706833",
"0.6991746",
"0.66513413",
"0.6622611",
"0.6513865",
"0.648775",
"0.63246125",
"0.6061353",
"0.5941253",
"0.5938065",
"0.5936012",
"0.5900571",
"0.5882535",
"0.5870546",
"0.58539015",
"0.58536416",
"0.58402073",
"0.5819098",
"0.57855195",
"0.57821137... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.