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 |
|---|---|---|---|---|---|---|
PATCH/PUT /kanban_states/1 PATCH/PUT /kanban_states/1.json | def update
authorize @kanban_state
respond_to do |format|
if @kanban_state.update(kanban_state_params)
url = params[:url] || edit_admin_project_path(@kanban_state.project_id, anchor: "kanban_states")
format.html { redirect_to url, notice: t('actions.updated_with_success')}
format... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @api_state = Api::State.find(params[:id])\n\n if @api_state.update(api_state_params)\n head :no_content\n else\n render json: @api_state.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @state.update(state_params)\n render json: @state\n # 'Sta... | [
"0.6396634",
"0.63639635",
"0.6352238",
"0.6239754",
"0.623665",
"0.6213249",
"0.6194978",
"0.61587054",
"0.6128271",
"0.6128271",
"0.61010617",
"0.61010617",
"0.61010617",
"0.6069886",
"0.6066494",
"0.60642266",
"0.60316163",
"0.5944038",
"0.593225",
"0.5906433",
"0.5891107"... | 0.71414375 | 0 |
DELETE /kanban_states/1 DELETE /kanban_states/1.json | def destroy
@project = @kanban_state.project
authorize @kanban_state
@project.tasks.where(kanban_state_id: @kanban_state.id).each do |task|
task.update_attributes(kanban_state_id: nil)
end
@kanban_state.destroy
respond_to do |format|
format.html { redirect_to edit_admin_project_pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @state.destroy\n respond_to do |format|\n format.html { redirect_to states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @state = @country.states.find(params[:id])\n @state.destroy\n\n respond_to do |format|\n format.html { redirect_to(count... | [
"0.70111775",
"0.6973794",
"0.68736976",
"0.68736976",
"0.68008673",
"0.67819875",
"0.6772542",
"0.6751626",
"0.6735832",
"0.6687784",
"0.6687784",
"0.6683995",
"0.66645986",
"0.660522",
"0.6584285",
"0.6582669",
"0.6554614",
"0.65495",
"0.6547408",
"0.65216535",
"0.65199757"... | 0.70316327 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_kanban_state
@kanban_state = KanbanState.where(id: params[:id]).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6165422",
"0.60457647",
"0.5946384",
"0.5916027",
"0.58905005",
"0.583495",
"0.5777223",
"0.56995213",
"0.56995213",
"0.56532377",
"0.5621348",
"0.5422839",
"0.54118705",
"0.54118705",
"0.54118705",
"0.53935355",
"0.5379617",
"0.53577393",
"0.53407264",
"0.53398263",
"0.53... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def kanban_state_params
params.require(:kanban_state).permit(:name, :project_id, :position, :archived)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981273",
"0.6783789",
"0.67460483",
"0.6742222",
"0.67354137",
"0.65934366",
"0.65028495",
"0.6497783",
"0.64826745",
"0.6479415",
"0.6456823",
"0.6440081",
"0.63800216",
"0.6376521",
"0.636652",
"0.6319898",
"0.6300256",
"0.62994003",
"0.6293621",
"0.6292629",
"0.6291586... | 0.0 | -1 |
Inititializes the Winnow instance alpha = Promotion factor beta = Demotion factor default_weights = Initial weight for each feature/attribute | def initialize( alpha=2.0, beta=0.5, default_weight=2.0 )
@model = Model.new
@alpha = alpha
@beta = beta
@default_weight = default_weight
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_model( feature_list, true_class=true, false_class=false, instances=nil )\n @model.true_class, @model.false_class = true_class, false_class\n @model.attributes = feature_list\n @model.weights = Array.new( feature_list.size){ @default_weight }\n\n # Set threshold\n #... | [
"0.6449522",
"0.63870305",
"0.6348738",
"0.59722847",
"0.59518194",
"0.59172684",
"0.5910238",
"0.5870171",
"0.58559805",
"0.5848811",
"0.5843686",
"0.5792286",
"0.5763856",
"0.5743297",
"0.56822056",
"0.56557655",
"0.56437594",
"0.5639737",
"0.562583",
"0.55913323",
"0.55796... | 0.67372596 | 0 |
Using the WekaCompatability mixin, load and instatiate trained model from ARFF file file = The path/name of the file OR the File IO object | def initialize_from_arff( file )
feature_list, t_class, f_class, instances = WekaCompatability.load_arff( file )
initialize_model( feature_list, t_class, f_class )
train_model( instances )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classifier_from_training( filename )\n classifier = Weka::Classifiers::Meta::AdaBoostM1.new # \n \n # http://weka.sourceforge.net/doc.dev/\n\n # java.lang.String[-P, 100, -S, 1, -I, 10, -W, weka.classifiers.trees.DecisionStump]@28c88600\n\n classifier.use_options(\"-I 100 -S #{ (rand * 10).floor }\")... | [
"0.66445494",
"0.6389121",
"0.63055927",
"0.6081682",
"0.5822393",
"0.5818459",
"0.5724368",
"0.5724368",
"0.57179",
"0.570441",
"0.5678653",
"0.56500465",
"0.5593727",
"0.55917907",
"0.55917907",
"0.5591234",
"0.55881745",
"0.55737185",
"0.55674",
"0.55624664",
"0.554466",
... | 0.8049418 | 0 |
Set the feature space structure for this model and initialize weights. feature_list = An array of feature names, must be same order as the features are in the encoded feature space true_class = The name of the true class (ie Cloudy ) false_class = The name of the false class (ie Sunny ) | def initialize_model( feature_list, true_class=true, false_class=false, instances=nil )
@model.true_class, @model.false_class = true_class, false_class
@model.attributes = feature_list
@model.weights = Array.new( feature_list.size){ @default_weight }
# Set threshold
# In Weka's ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n\t\t@training_list=Array.new\n\t\t@w = Array.new(FEATURE_SIZE,0)\n\tend",
"def initialize( floating_points: false )\n @weights = []\n @max_weight = BASE_WEIGHT\n @floating_points = floating_points\n end",
"def initialize(num_units_list)\n @layers = []\n @num_units_list = num... | [
"0.61111075",
"0.5696742",
"0.5507632",
"0.5450483",
"0.5385218",
"0.5343981",
"0.52776307",
"0.52624524",
"0.5196929",
"0.51492715",
"0.5140717",
"0.50474215",
"0.5035222",
"0.4934934",
"0.48943704",
"0.48943704",
"0.48187006",
"0.47976273",
"0.47532985",
"0.47262162",
"0.47... | 0.73182523 | 0 |
Trains a classifier based on the given training data instances = An array of instances OR a single instance | def train_model( instances )
instances = [ instances ] unless instances.class == Array
# First randomize data **TODO** Use GSL for ranomization
instances.sort!{ |xx,yy| rand(3) + 1 }
# Step through each instance.
instances.each do |inst|
# First, predict based on curr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train\n classifiers_initializer = ClassifiersInitializer.load_or_create\n classifiers_initializer.run\n @classifiers = classifiers_initializer.classifiers.map do |name, classifier|\n Classifier.new(classifier, self.class.config, name).train\n end.to_h\n end",
"def tr... | [
"0.6331521",
"0.6219008",
"0.6202452",
"0.60851455",
"0.60747164",
"0.59525555",
"0.5855271",
"0.5804021",
"0.5683998",
"0.56742084",
"0.5529324",
"0.5489353",
"0.54785746",
"0.54322314",
"0.5383626",
"0.53776395",
"0.5373672",
"0.5288272",
"0.52814347",
"0.5278612",
"0.52473... | 0.75746334 | 0 |
Classify instance based on current model. An instance is classified as TRUE if the sum of the represented feature weights (only features present in this instance) is greater than the threshold. instance = instance/sample to classify | def classify_instance( instance )
return score(instance) > threshold ? true : false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classify\n Rails.logger.debug \"Classification #{id}.classify\"\n weights_sum = classifiers.map( &:weight ).reduce( 0, :+ )\n Rails.logger.debug \"weights_sum: #{weights_sum}\"\n\n available_sum = classifiers.reduce( 0.0 ) { |sum, c|\n true_weight = weights_sum / c.weight\n Rails.logger.d... | [
"0.6810143",
"0.65595704",
"0.6520351",
"0.6312668",
"0.62714696",
"0.58105856",
"0.5743934",
"0.5722508",
"0.57036954",
"0.5545211",
"0.5525342",
"0.5517786",
"0.5401032",
"0.53493977",
"0.52232975",
"0.51641357",
"0.51593846",
"0.51575303",
"0.5050279",
"0.49622405",
"0.493... | 0.79915583 | 0 |
Score the given instance based on the current model | def score( instance )
# Sum weights of all features labeled as TRUE
sum = 0.0
instance.each_index{ |jj| sum += @model.weights[jj] if instance[jj] }
return sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def score!\n \"#{self.class}Scorer\".constantize.new(self).score_all!\n end",
"def score\n rate.score\n end",
"def score\n @subject.score\n end",
"def calculate_score\n new_score = self.retweet_count * 10 + self.favorite_count * 10\n new_score += 10 if self.with_image\n self.score = new... | [
"0.68726146",
"0.6792716",
"0.6761697",
"0.6751218",
"0.6722547",
"0.66748375",
"0.6640969",
"0.661251",
"0.661178",
"0.6573049",
"0.6523408",
"0.65163136",
"0.6498333",
"0.647225",
"0.6464313",
"0.64365405",
"0.6428218",
"0.63787985",
"0.635565",
"0.63522524",
"0.63481563",
... | 0.63955104 | 17 |
Promote the current model weights based on the given instance. | def promote!( instance )
# STDERR.puts "Promoting: old weights => #{@model.weights.join(",")}"
# For every feature/attribute present, promote the corresponding weight
instance.each_index{ |ii| @model.weights[ii] *= @alpha if instance[ii] }
#STDERR.puts "\tnew weights => #{@model.weights.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def demote!( instance )\n #STDERR.puts \"Demoting: old weights => #{@model.weights.join(\",\")}\"\n # For every feature/attribute present, demote the corresponding weight\n instance.each_index{ |ii| @model.weights[ii] *= @beta if instance[ii] }\n #STDERR.puts \"\\t\\tnew weights => #{@m... | [
"0.6433138",
"0.553422",
"0.552387",
"0.54446584",
"0.5406355",
"0.53805923",
"0.5320415",
"0.53026986",
"0.52905846",
"0.5259481",
"0.5253615",
"0.5240854",
"0.52323437",
"0.5140503",
"0.51320267",
"0.5114428",
"0.5089941",
"0.5089941",
"0.5089941",
"0.5089941",
"0.5073761",... | 0.78922707 | 0 |
Demote the current model weights based on the given instance. | def demote!( instance )
#STDERR.puts "Demoting: old weights => #{@model.weights.join(",")}"
# For every feature/attribute present, demote the corresponding weight
instance.each_index{ |ii| @model.weights[ii] *= @beta if instance[ii] }
#STDERR.puts "\t\tnew weights => #{@model.weights.joi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def promote!( instance )\n # STDERR.puts \"Promoting: old weights => #{@model.weights.join(\",\")}\"\n # For every feature/attribute present, promote the corresponding weight\n instance.each_index{ |ii| @model.weights[ii] *= @alpha if instance[ii] }\n #STDERR.puts \"\\tnew weights => #{... | [
"0.68388844",
"0.57088006",
"0.56984586",
"0.54216254",
"0.5382767",
"0.53194",
"0.52852654",
"0.5124363",
"0.5113024",
"0.50872713",
"0.50646555",
"0.5042104",
"0.50224054",
"0.5020733",
"0.50151163",
"0.5003146",
"0.4998667",
"0.4987373",
"0.4906897",
"0.49066183",
"0.48789... | 0.80062366 | 0 |
Our method takes in three arguments so we can sent the matches from the regex. | def calculator num1, operator, num2
# Our 'if' statement checks to see if we have found the string of plus or minus and uses the according operator.
if operator == "plus"
return num1 + num2
else
return num1 - num2
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match(pattern); end",
"def post_match() end",
"def pre_match() end",
"def match(input); end",
"def methods_matching(re); end",
"def fnmatch(matcher); end",
"def match(regexp); end",
"def match; end",
"def match; end",
"def matching_lines(regex); end",
"def match_captures; end",
"def subma... | [
"0.7099632",
"0.6931451",
"0.6821509",
"0.6789423",
"0.67893946",
"0.67832446",
"0.67402935",
"0.67375",
"0.67375",
"0.6711336",
"0.6661391",
"0.6645784",
"0.6645784",
"0.65856725",
"0.65856725",
"0.6558231",
"0.6494081",
"0.64731187",
"0.63915044",
"0.6384078",
"0.63322484",... | 0.0 | -1 |
define GET_WM_CTLCOLOR_TYPE(wp,lp,msg) (WORD)(msg WM_CTLCOLORMSGBOX) | def GET_WM_CTLCOLOR_TYPE(_, _, msg) msg - WM::CTLCOLORMSGBOX end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Pager_GetBkColor(hwnd) send_pager_message(hwnd, :GETBKCOLOR) end",
"def TreeView_GetBkColor(hwnd) send_treeview_message(hwnd, :GETBKCOLOR) end",
"def ListView_GetBkColor(hwnd) send_listview_message(hwnd, :GETBKCOLOR) end",
"def GET_SC_WPARAM(wParam) wParam & 0xFFF0 end",
"def ListView_GetTextBkColor(hw... | [
"0.6464628",
"0.6454583",
"0.6366995",
"0.6265628",
"0.60934037",
"0.5812883",
"0.5500348",
"0.5498921",
"0.5473922",
"0.5447521",
"0.5366949",
"0.5351477",
"0.53499854",
"0.53376615",
"0.53171957",
"0.5290235",
"0.52660626",
"0.5214578",
"0.51930034",
"0.51740944",
"0.516156... | 0.9249924 | 0 |
define GET_WM_MDIACTIVATE_FACTIVATE(hwnd,wp,lp) (lp == (LONG)hwnd) | def GET_WM_MDIACTIVATE_FACTIVATE(hwnd, _, lp) lp == hwnd; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def win_is_open?(id)\n (`xwininfo -id #{id}`).match(/Map State:\\s*(IsViewable)/) ? true : false\nend",
"def active_window\n if File.exists?(wmii_namespace)\n 'wmiir cat /client/sel/ctl | sed 1q'\n else\n %q[xprop -root _NET_ACTIVE_WINDOW | awk '/#/ { print $(NF) ; exit } END { exit 1 }' || xdotool ge... | [
"0.63311964",
"0.62439215",
"0.60502255",
"0.60470706",
"0.601849",
"0.5936035",
"0.59166914",
"0.58408535",
"0.583664",
"0.57662886",
"0.57221365",
"0.5721278",
"0.5711982",
"0.5669791",
"0.5645218",
"0.5609238",
"0.5602651",
"0.55969596",
"0.5561223",
"0.5559722",
"0.553993... | 0.96279097 | 0 |
create a randomstring with len chars | def set_unique_random_key(len = 16)
begin
chars = ('a'..'z').to_a + ('A'..'Z').to_a
self.key = (0..(len-1)).collect { chars[Kernel.rand(chars.length)] }.join
end while Key.find_by_key(self.key)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_string(len)\n rand_max = RAND_CHARS.size\n ret = \"\" \n len.times{ ret << RAND_CHARS[rand(rand_max)] }\n ret \n end",
"def random_string(len)\n chars = (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (\"0\"..\"9\").to_a\n str = \"\"\n 1.upto(len) { |i| str << chars[rand(ch... | [
"0.87513286",
"0.8725593",
"0.86918646",
"0.8613939",
"0.8590626",
"0.8588945",
"0.8516664",
"0.8509209",
"0.84804344",
"0.8444706",
"0.83680296",
"0.8361646",
"0.8332956",
"0.8328931",
"0.82924753",
"0.82625836",
"0.82248765",
"0.8205572",
"0.82000226",
"0.81640935",
"0.8115... | 0.0 | -1 |
The code below was refactored and the lessons I learned are:("a.blog") is the anchor html tag is assigned to a CSS class called "blog"; [i] relates to the element of the array(note: the .search method in NOKOGIRI creates an array) ["href"] tells the search method the name of the HTML tag to retrieve the info from blogs... | def get_the_blog_url
blogs = []
all_blog_names = (html.search(".back"))
all_blog_names.each do |i|
if i.search(".blog").text == "Blog"
blogs << i.search(".blog @href")
else
blogs << "none"
end
end
blogs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scrape(para)\n # need SECTION & PLACENAME from para\n # need to follow embedded href to get DESCRIPTION\n links = para.css(\"a\")\n # puts links.length\n # puts links.text\n\n # grabs href from anchor elements\n links.each{|links| puts links['href']}\n #grabs title from anchor elements\n links.each{|l... | [
"0.6422467",
"0.6422467",
"0.6409135",
"0.6394908",
"0.6304841",
"0.62999755",
"0.62999755",
"0.62863845",
"0.62863845",
"0.6225346",
"0.62149185",
"0.6213606",
"0.6197049",
"0.6194017",
"0.6153491",
"0.6133769",
"0.6132326",
"0.6124946",
"0.61131513",
"0.61012226",
"0.608951... | 0.703009 | 0 |
edit extend baseclass to store the invitation token in the session cookie so that we can find it after authenticating with a 3rd party service | def edit
if params[:invitation_token]
session[:invitation_token] = params[:invitation_token]
end
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invitation_token\n \tinvitation.token if invitation\n end",
"def invitation_token\n invitation.token if invitation\n end",
"def invitation_token\n invitation.token if invitation\n end",
"def sign_in identity\n cookies.permanent[:auth_token] = identity.token\n end",
"def set_session\n ... | [
"0.70341957",
"0.6973501",
"0.69711226",
"0.6512284",
"0.6459314",
"0.64525926",
"0.6278982",
"0.62632364",
"0.624727",
"0.62324375",
"0.6142884",
"0.6141722",
"0.6135074",
"0.6109149",
"0.6106261",
"0.608597",
"0.608597",
"0.608597",
"0.6082958",
"0.60674125",
"0.605882",
... | 0.6728328 | 3 |
current_inviter override current_inviter so that it will create a user from the passed in params if the user is not signed in rather than redirect to the devise authentications page. | def current_inviter
if user_signed_in?
super
else
@current_inviter ||= User.new(params[:user])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate_current_user_as_invited_user\n\t unless current_user == @invitation.invited_user\n\t redirect_to :back, alert: 'This invitation is not for you!'\n\t end\n\t end",
"def create\n self.resource = User.find_by(email: params[:user][:email]) || invite_resource\n\n # Set roles, wh... | [
"0.73229927",
"0.65643466",
"0.6469797",
"0.6424026",
"0.6421491",
"0.6416445",
"0.6346172",
"0.6321274",
"0.63064194",
"0.62976545",
"0.62719053",
"0.6253017",
"0.6248531",
"0.6225778",
"0.6201259",
"0.6199186",
"0.61804354",
"0.61623424",
"0.61540735",
"0.61117685",
"0.6086... | 0.8487143 | 0 |
Convert resource to units. Given in Hash | def to(units)
unless self.zero?
case units
when Hash
@mineral=@mineral.to(units[:mineral]) if Unit.new(units[:mineral]).kind == :mass
@ore=@ore.to(units[:ore]) if Unit.new(units[:ore]).kind == :mass
@grade=@grade.to(units[:grade]) if Unit.new(units[:grade]).kind == :unitless
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def units_hash\n {\n \"_hrs\" => \"hours\",\n \"_hours\"=>\"hours\",\n \"_min\"=>\"minutes\",\n \"_minutes\"=>\"minutes\",\n \"_ppm\"=>\"ppm\",\n \"_ppb\"=>\"ppb\",\n \"_mgm3\"=>\"mg/m3\",\n \"_f\"=>\"°f\",\n ... | [
"0.71378654",
"0.6702088",
"0.6096459",
"0.6037315",
"0.5996211",
"0.5986515",
"0.5956099",
"0.574682",
"0.5709418",
"0.56323564",
"0.5606397",
"0.56034875",
"0.55636567",
"0.5542462",
"0.54827553",
"0.5480297",
"0.5448117",
"0.5437693",
"0.5424395",
"0.54168844",
"0.5407681"... | 0.679809 | 1 |
we can't let resque trap signal | def register_signal_handlers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signal_queue; end",
"def trap_deferred(signal)\n trap(signal) do |sig_nr|\n if @waiting_for_reaper && [:INT, :TERM].include?(signal)\n log \"Recieved #{signal}: short circuiting QUIT waitpid\"\n raise QuitNowException\n end\n if sig_queue.size < SIG_QUEUE_MAX_SIZE\... | [
"0.70636463",
"0.70012534",
"0.69716746",
"0.65873384",
"0.6447902",
"0.6447902",
"0.62336254",
"0.62087715",
"0.61939913",
"0.617981",
"0.617981",
"0.61577785",
"0.6124962",
"0.61151",
"0.61112785",
"0.60402495",
"0.603158",
"0.60228467",
"0.5966589",
"0.59647864",
"0.596262... | 0.0 | -1 |
override to_s and separate different workers by there thread id | def to_s
@to_s ||= "#{hostname}:#{Process.pid}-#{Thread.current.object_id}:#{@queues.join(',')}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n \"thread_pool2_job-#{@handler.source_location}-#{@params}\"\n end",
"def worker_id\n self.class.worker_id\n end",
"def to_s\n @to_s || \"#{hostname}(#{local_ip}):#{Process.pid}:#{Thread.current.object_id}:#{Thread.current[:queues]}\"\n end",
"def to_s\n @to_s || \"#{hostname}(... | [
"0.668414",
"0.6122492",
"0.5762507",
"0.57387686",
"0.5728664",
"0.57022023",
"0.57022023",
"0.56767184",
"0.56395274",
"0.5598992",
"0.559436",
"0.5538609",
"0.5529328",
"0.5529154",
"0.551228",
"0.5497238",
"0.5434805",
"0.54240733",
"0.5421312",
"0.5421312",
"0.5404072",
... | 0.5972924 | 2 |
Read in all the versions that are specified by SOFTWARE | def version(version = nil, &block)
$versions << version
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_versions\n http_get(\"#{host}/#{Configuration.versions_file}\").body\n end",
"def available_versions\n return unless @version\n the_gem_line = gem_remote_list_output.scan(/^#{name}\\s.*$/).first\n the_gem_line.scan /\\d+\\.\\d+\\.\\d+/\n end",
"def read_versions\n s... | [
"0.67682475",
"0.6743659",
"0.6709887",
"0.65562004",
"0.6468643",
"0.6319229",
"0.63108474",
"0.62688774",
"0.62688774",
"0.62688774",
"0.625905",
"0.62135744",
"0.61543876",
"0.61383295",
"0.61382645",
"0.613557",
"0.6118656",
"0.60947925",
"0.60861313",
"0.60805255",
"0.60... | 0.0 | -1 |
Ignore all the other DSL methods in the file, we don't care about them now | def method_missing(m, *args, &block)
# ignore
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ignore; end",
"def ignore_me\nend",
"def ignore_method_conflicts; end",
"def exclude\n all - methods\n end",
"def skip_method container\n meth = RDoc::AnyMethod.new \"\", \"anon\"\n parse_method_parameters meth\n parse_statements container, false, meth\n end",
"def ignores; end",
"def... | [
"0.6676943",
"0.6559545",
"0.6548371",
"0.65042686",
"0.6478983",
"0.6400335",
"0.63638675",
"0.6324916",
"0.63026613",
"0.60776407",
"0.59717065",
"0.5947108",
"0.593655",
"0.59085995",
"0.5852419",
"0.5832481",
"0.5823427",
"0.58217216",
"0.58217216",
"0.58217216",
"0.58217... | 0.0 | -1 |
for dbcheck convert db result key to request key | def convert_key dbkey
arr = dbkey.split('_')
arr.each {|s|s[0]=s[0].upcase}
newkey = arr.join('')
newkey[0]=newkey[0].downcase
newkey
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_key(key); end",
"def convert_key(key); end",
"def convert_key(key); end",
"def javaize_key(key)\n key = key.to_s\n case key\n when 'acquirer_transaction_request'\n 'AcquirerTrxReq'\n when 'acquirer_status_request'\n 'AcquirerStatusReq'\n when '... | [
"0.64307654",
"0.64307654",
"0.64307654",
"0.642793",
"0.6301676",
"0.60801387",
"0.60801387",
"0.60603625",
"0.601709",
"0.5999924",
"0.59444517",
"0.5927866",
"0.59005547",
"0.58729047",
"0.58540183",
"0.5837375",
"0.582813",
"0.5822535",
"0.5811166",
"0.577969",
"0.57171",... | 0.62667084 | 5 |
Builds an array containing the project's story | def stories ; @stories || get_stories ; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_stories\n api_url = \"#{CONFIG[:api_location]}/projects/#{@id}/stories\"\n @stories = (Hpricot(open(api_url, {\"X-TrackerToken\" => @token.to_s}))/:story).map {|story| Story.new(:story => story, :project_id => @id, :token => @token)}\n end",
"def stories\n project.stories_in_iteration(self)\n... | [
"0.6707285",
"0.66324884",
"0.661722",
"0.657416",
"0.6557601",
"0.6526962",
"0.6284915",
"0.6259709",
"0.61836004",
"0.61160725",
"0.6105512",
"0.5949913",
"0.5934168",
"0.5913945",
"0.583328",
"0.5832376",
"0.5824942",
"0.57382727",
"0.56823456",
"0.56451714",
"0.56451714",... | 0.5303902 | 59 |
Fetches a story with given id | def story(id)
Story.new(:story_id => id, :project_id => @id, :token => @token)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def story(id, query = {})\n Request.new(self, '/cdn/stories', query, id).get\n end",
"def story(id, query = {})\n Request.new(self, '/cdn/stories', query, id).get\n end",
"def find_by_id(client, id, options: {})\n\n self.new(parse(client.get(\"/stories/#{id}\", options: options)).first... | [
"0.7535983",
"0.7535983",
"0.7457693",
"0.7439351",
"0.73790425",
"0.72903734",
"0.72784644",
"0.72293836",
"0.72094804",
"0.7197222",
"0.7183389",
"0.71818656",
"0.7175823",
"0.714451",
"0.71186584",
"0.70789164",
"0.7037901",
"0.69856703",
"0.6980768",
"0.69052845",
"0.6894... | 0.72992665 | 5 |
Creates a story for this project. Receives a set of valid attributes. Returns a Story object TODO: Validate attributes | def create_story(attributes = {})
api_url = URI.parse("#{CONFIG[:api_location]}/projects/#{@id}/stories")
query_string = attributes.map { |key, value| "story[#{key}]=#{CGI::escape(value)}"}.join('&')
response = Net::HTTP.start(api_url.host, api_url.port) do |http|
http.post(api_url.path, query_string.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_story(attributes = {})\n api_url = URI.parse(\"#{CONFIG[:api_url]}projects/#{@id}/stories\")\n query_string = attributes.map { |key, value| \"story[#{key}]=#{CGI::escape(value)}\"}.join('&')\n begin\n http = Net::HTTP.new(api_url.host, api_url.port)\n http.use_ssl = true\n ... | [
"0.8070327",
"0.7012155",
"0.7006747",
"0.6947192",
"0.68870425",
"0.6863314",
"0.6863314",
"0.6863314",
"0.6852081",
"0.6845522",
"0.6843058",
"0.6843058",
"0.6835034",
"0.681074",
"0.6810379",
"0.6801582",
"0.67803067",
"0.676995",
"0.6740495",
"0.6706367",
"0.6705924",
"... | 0.8274597 | 0 |
Deletes a story given a Story object or a story_id | def delete_story(story)
if story.is_a?(Story)
api_url = URI.parse("#{CONFIG[:api_location]}/projects/#{@id}/stories/#{story.id}")
elsif story.is_a?(Integer) || story.to_i.is_a?(Integer)
api_url = URI.parse("#{CONFIG[:api_location]}/projects/#{@id}/stories/#{story}")
else
raise ArgumentErro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_story(story_id)\n delete_request(\"stories/#{story_id}\")\n end",
"def delete_story(story)\n if story.is_a?(TrackR::Story)\n api_url = URI.parse(\"#{CONFIG[:api_url]}projects/#{@id}/stories/#{story.id}\")\n elsif story.is_a?(Integer) || story.to_i.is_a?(Integer)\n api_u... | [
"0.8587065",
"0.8297598",
"0.8066231",
"0.786545",
"0.7805201",
"0.75794977",
"0.7503526",
"0.7503526",
"0.7460743",
"0.7446335",
"0.7446335",
"0.7446335",
"0.7446335",
"0.7446138",
"0.7412513",
"0.7412513",
"0.7412513",
"0.7362345",
"0.7357675",
"0.73303413",
"0.73126245",
... | 0.836406 | 1 |
Gets the stories for a given iteration | def get_iteration_stories(iteration_type=nil)
get_iterations(type).stories
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stories_in_iteration(iteration)\n stories.in_iteration(iteration)\n end",
"def get_stories_by_iteration(name)\n case name\n when \"icebox\"\n api_url = \"#{CONFIG[:api_url]}projects/#{@id}/stories?filter=current_state%3Aunscheduled\"\n else\n api_url = \"#{CONFIG[:api_url... | [
"0.83121365",
"0.80171376",
"0.7970099",
"0.75881237",
"0.7132219",
"0.7092624",
"0.7092624",
"0.70769906",
"0.70489794",
"0.6939957",
"0.68793947",
"0.67578435",
"0.6704235",
"0.6704235",
"0.6689406",
"0.6667889",
"0.66569847",
"0.66569847",
"0.6629137",
"0.6593183",
"0.6503... | 0.80400527 | 1 |
Builds a project given an hpricot object stored at instance variable | def build_project
@id ||= @project.at('id').inner_html
@api_url ||= "#{CONFIG[:api_location]}/projects/#{@id}"
@url ||= "http://www.pivotaltracker.com/projects/#{@id}"
@name = @project.at('name').inner_html
@iteration_length = @project.at('iteration_le... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_project\n @id ||= @project.at('id').inner_html\n @api_url ||= \"#{CONFIG[:api_url]}projects/#{@id}\"\n @url ||= \"http://www.pivotaltracker.com/projects/#{@id}\"\n @name = @project.at('name').inner_html\n @iteration_length = @projec... | [
"0.70578843",
"0.6844798",
"0.64175624",
"0.63736725",
"0.62847346",
"0.6130873",
"0.61232275",
"0.6056636",
"0.6048874",
"0.60460675",
"0.5986536",
"0.5955174",
"0.5948275",
"0.5944684",
"0.5921143",
"0.59137344",
"0.5902132",
"0.588998",
"0.588998",
"0.58721584",
"0.585925"... | 0.70508116 | 1 |
Builds an array containing the project's stories | def get_stories
api_url = "#{CONFIG[:api_location]}/projects/#{@id}/stories"
@stories = (Hpricot(open(api_url, {"X-TrackerToken" => @token.to_s}))/:story).map {|story| Story.new(:story => story, :project_id => @id, :token => @token)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stories\n @stories ||= DataStore.stories_for_project(self)\n end",
"def stories\n project.stories_in_iteration(self)\n end",
"def get_stories\n api_url = \"#{CONFIG[:api_url]}projects/#{@id}/stories\"\n @stories = (Hpricot(open(api_url, {\"X-TrackerToken\" => @token.to_s}))/:story... | [
"0.76203966",
"0.7609521",
"0.72910166",
"0.728955",
"0.7169523",
"0.6924727",
"0.6845425",
"0.68094933",
"0.6675924",
"0.6673327",
"0.6608635",
"0.6407003",
"0.6407003",
"0.63433796",
"0.6298566",
"0.6186878",
"0.6147229",
"0.6147229",
"0.6147229",
"0.6147229",
"0.6147229",
... | 0.7392337 | 2 |
Produces a gadget from Doraemon. | def gadget
fetch('doraemon.gadgets')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gadget; end",
"def gadget; end",
"def set_gadget\n id = params[:id].split(\"-\").last\n @gadget = Gadget.find(id)\n end",
"def demon\n fetch('naruto.demons')\n end",
"def create\n @gadget = Gadget.new(gadget_params)\n\n respond_to do |format|\n if @gadget.save\n ... | [
"0.73604685",
"0.73604685",
"0.57140684",
"0.5462676",
"0.5348565",
"0.52649",
"0.5172436",
"0.5172436",
"0.5172436",
"0.50754213",
"0.5063272",
"0.5012291",
"0.50062233",
"0.4976758",
"0.4974508",
"0.49648416",
"0.48667607",
"0.48386487",
"0.48322427",
"0.48322427",
"0.48173... | 0.8048621 | 0 |
Produces a location from Doraemon. | def location
fetch('doraemon.locations')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def location\n fetch('how_to_train_your_dragon.locations')\n end",
"def full_location; end",
"def ameem_location\n $ameem_location\n end",
"def location\n fetch('simpsons.locations')\n end",
"def location\n fetch('hey_arnold.locations')\n end",
"def gen... | [
"0.65886736",
"0.6054046",
"0.6042664",
"0.60088015",
"0.5991748",
"0.59510857",
"0.59269196",
"0.588944",
"0.5872642",
"0.58648187",
"0.5798821",
"0.579279",
"0.5779511",
"0.5745096",
"0.57337886",
"0.5720782",
"0.5671332",
"0.5671332",
"0.5665852",
"0.5662141",
"0.5640909",... | 0.7378271 | 0 |
2/ Obtenir les emails de toutes les mairies ! | def get_townhall_email(townhalls_urls_and_cities)
return nil if townhalls_urls_and_cities.nil? || townhalls_urls_and_cities.empty?
# return nil if list_townhall_urls.nil? || list_townhall_urls.empty? || list_cities.empty? || list_cities.nil?
# Pour une meilleur compréhension
list_townhall_urls = townhalls_url... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emails\n self[\"gd$email\"] ? self[\"gd$email\"].map { |e| e.address } : []\n end",
"def recipients\n notified_users.collect(&:mail)\n end",
"def get_mails\n gmail = Gmail.connect @current_user.login, @current_user.password\n return nil unless gmail.logged_in?\n\n mails = gmail.inbox.f... | [
"0.73991746",
"0.73043436",
"0.72953075",
"0.7283603",
"0.72399205",
"0.7212804",
"0.7172907",
"0.7170713",
"0.71174955",
"0.7054547",
"0.70479286",
"0.70404416",
"0.69421464",
"0.6938023",
"0.69298565",
"0.6923423",
"0.6906159",
"0.6881249",
"0.6879913",
"0.6855114",
"0.6848... | 0.0 | -1 |
100 files idx = 75 75..99, 0..54 | def get_training_range(total_size, idx)
num_files = (total_size * TEST_PERCENTAGE) / 100
if (idx + num_files <= total_size)
[idx...(idx + num_files)]
else
[idx...total_size, 0...num_files - (total_size - idx)]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def files_500(files)\n prc = Proc.new { |x, y| x[0] <=> y[0] }\n heap = BinaryMinHeap.new()\n result = []\n\n files.length.time do |i|\n heap.push([files[i][0], i, 0])\n end\n\n while heap.count > 0\n min = heap.extract\n result << min[0]\n\n next_arr_i = min[1]\n next_idx = min[2] + 1\n ne... | [
"0.68032855",
"0.66658044",
"0.65364945",
"0.6161528",
"0.6061869",
"0.5894734",
"0.5872509",
"0.58402723",
"0.5826347",
"0.58250874",
"0.5822231",
"0.5822231",
"0.5789767",
"0.5733469",
"0.5711941",
"0.57028073",
"0.5700254",
"0.5634114",
"0.5600782",
"0.55954736",
"0.556910... | 0.5930666 | 5 |
4. Refactored Solution I don't see how to refactor it further 1. DRIVER TESTS GO BELOW THIS LINE | def assert(statement = "Assertion failed!")
raise statement unless yield
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def driver; end",
"def test_cases; end",
"def spec; end",
"def spec; end",
"def test_007\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n @@pu = Pu.find_by_name('SamplePU1')\n\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to... | [
"0.60001177",
"0.5862025",
"0.58172745",
"0.58172745",
"0.57972336",
"0.5736341",
"0.56853074",
"0.5684296",
"0.564492",
"0.5644727",
"0.5644703",
"0.5633412",
"0.56076324",
"0.56076324",
"0.56076324",
"0.56076324",
"0.56076324",
"0.56076324",
"0.56076324",
"0.56076324",
"0.5... | 0.0 | -1 |
GET /players/1 GET /players/1.xml | def show
@player = Player.find(params[:id])
@page_title = "Meet #{@player.full_name}"
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @player }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n puts params.inspect\n @api_players = Player.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @api_players }\n end\n end",
"def index\n @players = Player.all\n\n respond_to do |format|\n format.html # index.html.erb\n f... | [
"0.7151264",
"0.7148797",
"0.6967249",
"0.69646686",
"0.6842",
"0.6823654",
"0.68182886",
"0.67391425",
"0.66512305",
"0.6517467",
"0.6431865",
"0.6431117",
"0.64302284",
"0.6298674",
"0.62985486",
"0.6282829",
"0.6243095",
"0.6243095",
"0.6243095",
"0.6243095",
"0.6243095",
... | 0.65137875 | 10 |
GET /players/new GET /players/new.xml | def new
@player = Player.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @player }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @games_player = GamesPlayer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @games_player }\n end\n end",
"def new\n @leagueplayer = Leagueplayer.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml ... | [
"0.71394205",
"0.6890059",
"0.68175906",
"0.6799033",
"0.67592144",
"0.67339796",
"0.67339796",
"0.67339796",
"0.67339796",
"0.67339796",
"0.67339796",
"0.67339796",
"0.67339796",
"0.67339796",
"0.67339796",
"0.66931796",
"0.6692971",
"0.66726464",
"0.66624",
"0.66388613",
"0... | 0.74016696 | 2 |
POST /players POST /players.xml | def create
@player = Player.new(params[:player])
respond_to do |format|
if @player.save
flash[:notice] = 'Player was successfully created.'
format.html { redirect_to(@player) }
format.xml { render :xml => @player, :status => :created, :location => @player }
else
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @player = Player.new(params[:player])\n\n respond_to do |format|\n if @player.save\n flash[:notice] = 'Api::Player was successfully created.'\n format.html { redirect_to(@player) }\n format.xml { render :xml => @player, :status => :created, :location => @player }\n ... | [
"0.6353117",
"0.63194764",
"0.627766",
"0.617542",
"0.6167673",
"0.61347395",
"0.6125893",
"0.6038987",
"0.60139346",
"0.59799075",
"0.59689486",
"0.5967234",
"0.5951758",
"0.59314454",
"0.5920516",
"0.59192044",
"0.59050226",
"0.59021074",
"0.589745",
"0.5895414",
"0.5895414... | 0.6271272 | 3 |
PUT /players/1 PUT /players/1.xml | def update
@player = Player.find(params[:id])
respond_to do |format|
if @player.update_attributes(params[:player])
flash[:notice] = 'Player was successfully updated.'
format.html { redirect_to(@player) }
format.xml { head :ok }
else
format.html { render :action => "... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @team = Team.find(params[:id])\n @player = Player.find(params[:player_id])\n if @player.access_key == params[:access_key] && (@team.leader_id == @player.id || @team.game.owner_id == @player.id) then\n @team.name = params[:name]\n @team.leader_id = params[:leader_id]\n\n respond... | [
"0.64573336",
"0.6432195",
"0.6350137",
"0.6350109",
"0.63201773",
"0.62731624",
"0.62502843",
"0.6207475",
"0.6164538",
"0.6144399",
"0.61200637",
"0.6075441",
"0.60736656",
"0.60673934",
"0.60672265",
"0.60672265",
"0.60672265",
"0.60672265",
"0.60672265",
"0.60672265",
"0.... | 0.6518195 | 1 |
DELETE /players/1 DELETE /players/1.xml | def destroy
@player = Player.find(params[:id])
@player.destroy
respond_to do |format|
format.html { redirect_to(players_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @player = Player.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to(api_players_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @player.user.destroy\n\n respond_to do |format|\n format.html { redirect_to(player... | [
"0.70677996",
"0.7024825",
"0.68334705",
"0.67315525",
"0.6675455",
"0.6625119",
"0.65786517",
"0.6490818",
"0.64758426",
"0.64732134",
"0.6432913",
"0.6432913",
"0.64187455",
"0.641455",
"0.641455",
"0.641455",
"0.641455",
"0.641455",
"0.641455",
"0.641455",
"0.641455",
"0... | 0.7140511 | 2 |
Contact Pidgin Creates a contact to save to DB which we will later use to send personalized emails | def contact_pidgin
@contact = Contact.new
@contact.name = params[:name]
@contact.email = params[:email]
@contact.subject = params[:subject]
@contact.mail_message = params[:message]
@contact.save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n # updating the @contact instance variable with the entered parameters (each user's information) to be saved to the db\n # 'contact_params' is a method that is called (outlined below) that says that we will securely save the entered data into the db\n # AKA: Mass assignment of form... | [
"0.80687845",
"0.7648596",
"0.7624812",
"0.7581171",
"0.7560618",
"0.75419587",
"0.75407875",
"0.7537258",
"0.7528827",
"0.7511831",
"0.74890447",
"0.7474403",
"0.7472123",
"0.7472123",
"0.74566644",
"0.7451524",
"0.74215555",
"0.74094564",
"0.74056715",
"0.73447347",
"0.7340... | 0.8136312 | 0 |
Initializes a new Filterrific::ParamSet. This is the core of Filterrific where all the action happens. | def initialize(a_model_class, filterrific_params = {})
self.model_class = a_model_class
@select_options = {}
# Use either passed in filterrific_params or resource class' default_settings.
# Don't merge the hashes. This causes trouble if an option is set to nil
# by the user, then it will ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n @params = {}\n end",
"def initialize\n super()\n @params = {}\n end",
"def initialize_hydration(model_class, requested_fields, request_ctx)\n SuperScopes::ParamSet.new(model_class, requested_fields, request_ctx)\n end",
"def initialize_filters(params)\n ... | [
"0.68201566",
"0.67912",
"0.6675252",
"0.66394436",
"0.66382575",
"0.66186285",
"0.6489151",
"0.6451342",
"0.6376929",
"0.6301543",
"0.62883043",
"0.6245389",
"0.6245389",
"0.6232009",
"0.62302893",
"0.6227903",
"0.61081034",
"0.6105072",
"0.6086446",
"0.6072494",
"0.6064709"... | 0.57477903 | 55 |
A shortcut to run the ActiveRecord query on model_class. Use this if you want to start with the model_class, and not an existing ActiveRecord::Relation. | def find
model_class.filterrific_find(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_query(_model)\n raise 'subclasses should implement this method.'\n end",
"def model_class\n class_name.constantize\n end",
"def run\n all_models_superclass.singleton_class.prepend(Valle::ActiveRecordExt)\n end",
"def model_class\n self.class_name.constantize\n end",
"def ... | [
"0.6416643",
"0.6270556",
"0.6258092",
"0.62447023",
"0.6223438",
"0.61491483",
"0.61012655",
"0.6048762",
"0.598946",
"0.5972984",
"0.5963508",
"0.59248894",
"0.5882447",
"0.5850036",
"0.58248806",
"0.5809962",
"0.5716814",
"0.56759334",
"0.56397414",
"0.5637809",
"0.5561423... | 0.0 | -1 |
Returns Filterrific::ParamSet as hash (used for URL params and serialization) | def to_hash
{}.tap { |h|
model_class.filterrific_available_filters.each do |filter_name|
param_value = send(filter_name)
if param_value.blank?
# do nothing
elsif param_value.is_a?(Proc)
# evaluate Proc so it can be serialized
h[filter_name]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def params_to_hash\n {}\n end",
"def params\n flat = {}\n @options[:params].merge( :track => @options[:filters] ).each do |param, val|\n next if val.to_s.empty? || (val.respond_to?(:empty?) && val.empty?)\n val = val.join(\",\") if val.respond_to?(:join)\n flat[param.to... | [
"0.7106865",
"0.68325484",
"0.67480093",
"0.66523325",
"0.66016513",
"0.65237594",
"0.6520581",
"0.63986856",
"0.6392684",
"0.63883823",
"0.6386676",
"0.6378352",
"0.63574666",
"0.63507867",
"0.6347641",
"0.63034976",
"0.6196711",
"0.6174703",
"0.61477983",
"0.6147435",
"0.60... | 0.6369442 | 12 |
Returns params as JSON string. | def to_json
to_hash.to_json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def js_parms(params) params.map { |p| marshal p }.join(COMMA) end",
"def as_json(*_args)\n to_s\n end",
"def params\n params = {}\n @options[:params].each{|key, value| params[key.to_s] = escape((value.class == Array ? value.join(\",\") : value))}\n params\n end... | [
"0.7385335",
"0.7073402",
"0.697736",
"0.68100065",
"0.6797361",
"0.6778413",
"0.6778328",
"0.6778328",
"0.6778328",
"0.67755514",
"0.6771046",
"0.6771046",
"0.6771046",
"0.6771046",
"0.6771046",
"0.6771046",
"0.6771046",
"0.6771046",
"0.6771046",
"0.6749893",
"0.67403585",
... | 0.0 | -1 |
Conditions params: Evaluates Procs and type casts integer values. | def condition_filterrific_params(fp)
fp.each do |key, val|
if val.is_a?(Proc)
# evaluate Procs
fp[key] = val.call
elsif val.is_a?(Array)
# type cast integers in the array
fp[key] = fp[key].map { |e| e.to_s.match?(integer_detector_regex) ? e.to_i : e }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_conditions\n\t\tclauses = Array.new\n\t\tparty_list.each do |uid, hash|\n\t\t\tcond = hash[:condition]\n\t\t\tif cond[:cond_type] != COND_NONE && cond[:cond_met] == COND_MET\n\t\t\t\tclauses.push({ operands: false, value: uid })\n\t\t\telsif cond[:cond_type] == COND_NUM_ATTENDING\n\t\t\t\tclauses.push({ ... | [
"0.52148694",
"0.50981104",
"0.49899366",
"0.4898363",
"0.48803538",
"0.48527905",
"0.48472697",
"0.4820733",
"0.4814902",
"0.48138553",
"0.48026592",
"0.47947085",
"0.47904637",
"0.47678635",
"0.47526103",
"0.47502553",
"0.4740726",
"0.47305295",
"0.47305295",
"0.47280732",
... | 0.61706233 | 0 |
Regex to detect if str represents and int | def integer_detector_regex
/\A-?([1-9]\d*|0)\z/
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_int_str?(str)\n str =~ /^[+\\-]?[\\d]*$/ # optional sign, then only digits\n end",
"def integer?(str)\n /\\A[+-]?\\d+\\z/ === str\n end",
"def valid_looking_string?(str)\n str =~ /\\d/\n end",
"def validate_str_is_integer(value)\n !!(value =~ /\\A[-+]?[0-9]+... | [
"0.755757",
"0.7340157",
"0.7305028",
"0.7238562",
"0.72300905",
"0.71996325",
"0.71931344",
"0.7020462",
"0.7014626",
"0.6998531",
"0.6974842",
"0.69424134",
"0.69192487",
"0.69119537",
"0.690975",
"0.68774897",
"0.6790687",
"0.6755167",
"0.67485195",
"0.6727426",
"0.6646730... | 0.7149376 | 7 |
Defines attr accessors for each available_filter on self and assigns values based on fp. | def define_and_assign_attr_accessors_for_each_filter(fp)
model_class.filterrific_available_filters.each do |filter_name|
self.class.send(:attr_accessor, filter_name)
v = fp[filter_name]
send("#{filter_name}=", v) if v.present?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_filter_accessors\n @filters.each do |filter|\n singleton_class.class_eval do\n define_method(filter.field_name) { @attributes[filter.field_name] }\n define_method(\"#{filter.field_name}=\") { |value| @attributes[filter.field_name] = value }\n end\n end\n end",
"def apply_at... | [
"0.71337306",
"0.6517046",
"0.6202232",
"0.58918387",
"0.5658672",
"0.56571454",
"0.5585519",
"0.5585519",
"0.5585519",
"0.5585519",
"0.5585519",
"0.55647445",
"0.55134237",
"0.55111843",
"0.54154015",
"0.53847796",
"0.5357387",
"0.53535575",
"0.53024966",
"0.52710426",
"0.52... | 0.8599091 | 0 |
common divisor of the two integers. | def greatest_common_divisor(x, y)
first = [x, y].max
second = [x, y].min
return first if second == 0
rem = first - (first / second) * second
greatest_common_divisor(second, rem)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def common_dividor(num1, num2)\n limit = [num1, num2].min\n limit.downto(1) do |int|\n return int if num1 % int == 0 && num2 % int == 0\n end\nend",
"def gcd( a, b )\r\n\t\t\treturn (b*(a%b))/lcm(b,a%b)\r\n\t\tend",
"def greatest_common_factor(num1, num2)\n divisor = 1\n 2.upto([num1.abs, num2.abs].min... | [
"0.8030188",
"0.7435414",
"0.7252447",
"0.7246254",
"0.7214916",
"0.72128165",
"0.7155471",
"0.713652",
"0.7109544",
"0.7098515",
"0.7093874",
"0.7092822",
"0.7077014",
"0.70558035",
"0.7043563",
"0.7032486",
"0.7028874",
"0.7027627",
"0.70162964",
"0.69690657",
"0.69601744",... | 0.71624374 | 6 |
Alias method 'members' to 'participants'. Use either one. | def members
participants
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def just_members\n members - [owner]\n end",
"def members\n users\n end",
"def members\n users\n end",
"def add_members(members)\n @members.merge!(members)\n end",
"def members\n @members ||= relation_members.map do |member|\n [member.member_type, member.member_id, member.me... | [
"0.6499998",
"0.6494769",
"0.6494769",
"0.6395734",
"0.63910866",
"0.6352586",
"0.6272415",
"0.62254393",
"0.6213665",
"0.6213308",
"0.62065446",
"0.6193286",
"0.6168238",
"0.6128471",
"0.6105824",
"0.6105824",
"0.6035879",
"0.6035422",
"0.5996219",
"0.5967927",
"0.5967927",
... | 0.746026 | 0 |
Should accept a board and a position from the user (remember that the user will input a number 19 but your board is really indexed 08) and return true if the position is within the correct range of 19 and is currently unoccupied by an X or O token. Hint: While not explicitly required by this lab, you might want to enca... | def position_taken?(board, position)
taken = nil
if (board[position] == " " || board[position] == "" || board[position] == nil)
taken = false
else
taken = true
end
taken
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_move?(board, position)\n position.between?(0, 8) && !position_taken?(board, position)\nend",
"def valid_move?(board, position)\n !position_taken?(board, position) && position.between?(0,8)\nend",
"def valid_move?(board, position)\n if position_taken?(board, position) == false && position.to_i.bet... | [
"0.8355912",
"0.8331034",
"0.8329024",
"0.82943285",
"0.82864946",
"0.8282669",
"0.8281951",
"0.8260596",
"0.82574356",
"0.8253703",
"0.82353926",
"0.82319474",
"0.82145715",
"0.8199339",
"0.8199339",
"0.819928",
"0.8179986",
"0.8178324",
"0.8171519",
"0.81691235",
"0.8165882... | 0.0 | -1 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.usermailer.welcome.subject | def welcome(patient)
if !patient.nil?
@patient = patient
mail(:to => patient.email, :subject => "Mayo Clinic")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def translate(mapping, key)\n I18n.t(:\"#{mapping.name}_subject\", :scope => [:devise, :mailer, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def subject\n self['subject'] || msg['subject']\n end",
"def formatted_subject(text)\n name = PersonMailer.global_prefs.app_name\n l... | [
"0.68348837",
"0.67105347",
"0.66832286",
"0.66512865",
"0.6630692",
"0.6564958",
"0.65623605",
"0.65495044",
"0.6545525",
"0.6475421",
"0.6447635",
"0.6441482",
"0.6408579",
"0.64075166",
"0.6394613",
"0.6393526",
"0.6382019",
"0.6377907",
"0.6375698",
"0.6357585",
"0.635633... | 0.0 | -1 |
Instantiate a new SimpleScrobbler instance. If the session key is not supplied, it must be fetched using fetch_session_key before scrobbling is attempted. Your own API key and secret can be obtained from | def initialize(api_key, secret, user, session_key=nil)
@api_key = api_key
@secret = secret
@user = user
@session_key = session_key
@source = "P"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize (api_key)\n\t\t@params = {\n\t\t\t\"key\" => api_key,\n\t\t\t\"wrapper\" => \"cleverbotrb\"\n\t\t}\n\t\t@endpoint = ENDPOINT\n\tend",
"def create_simple_box(key)\n @simple_box ||= RbNaCl::SimpleBox.from_secret_key(RbNaCl::Hash.sha256(key))\n end",
"def new(api_key = nil, secret_key = nil... | [
"0.5625752",
"0.56188333",
"0.5579096",
"0.5571173",
"0.5517835",
"0.54761523",
"0.5472605",
"0.54478836",
"0.5446236",
"0.5281936",
"0.5280837",
"0.52548903",
"0.5246583",
"0.5238902",
"0.523825",
"0.5197219",
"0.519704",
"0.5183807",
"0.5144548",
"0.5093536",
"0.50873125",
... | 0.5721411 | 0 |
The source of the track. Required, must be one of the following codes: P :: Chosen by the user. R :: Nonpersonalised broadcast (e.g. Shoutcast, BBC Radio 1). E :: Personalised recommendation except Last.fm (e.g. Pandora, Launchcast). L :: Last.fm (any mode). | def source=(a)
unless %w[ P R E L ].include?(a)
raise DataError, "source must be one of P, R, E, L (see http://www.last.fm/api/submissions)"
end
@source = a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def track_params\n params.require(:track).permit(:name, :user_id, :url, :source)\n end",
"def on_track_change\n # XXXMLG implement\n end",
"def audio_source_is_provided\n if self.external_url.blank? &&\n self.mp3.file.nil? &&\n self.enco_number.blank? &&\n self.enco_date.blank?\n s... | [
"0.59844774",
"0.5818324",
"0.5664628",
"0.55935687",
"0.55152583",
"0.5493721",
"0.54661334",
"0.5434644",
"0.54186577",
"0.53685004",
"0.5341116",
"0.5248176",
"0.5248176",
"0.52176553",
"0.5217246",
"0.5210321",
"0.5199413",
"0.51914555",
"0.51809907",
"0.51807743",
"0.517... | 0.64829195 | 0 |
Fetch the auth key needed for the application. This can be stored and supplied in the constructor on future occasions. Yields a URL which the user must visit. The block should not return until this is done. | def fetch_session_key(&blk)
doc = last_fm_web_service("method" => "auth.gettoken")
request_token = doc.value_at("//token")
yield "http://www.last.fm/api/auth/?api_key=#{api_key}&token=#{request_token}"
doc = last_fm_web_service("method" => "auth.getsession", "token" => request_token)
@session_key... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def when_auth &block # :yields: abs_url, realm\n @get_auth_details = block\n end",
"def key\n Net::HTTP.get(@uri.host, \"#{@uri.request_uri}key\", @uri.port)\n end",
"def fetch(request_id: self.class.new_req_id)\n # Token base URI may have changed after the class was loaded.\n sel... | [
"0.5962432",
"0.58730215",
"0.5607512",
"0.5597979",
"0.55792296",
"0.553425",
"0.553425",
"0.55178976",
"0.55089194",
"0.55079246",
"0.5420509",
"0.5394441",
"0.5382412",
"0.5301718",
"0.52671266",
"0.5249516",
"0.5217385",
"0.5217385",
"0.52151775",
"0.5210147",
"0.5192468"... | 0.5770419 | 2 |
Scrobble a track. The artist and track are required parameters. Other parameters can be added as options: :time :: Time at which the track started playing. Defaults to now :length :: Length of the track in seconds (required if the source is "P", the default) :album :: Album title :track_number :: Track number :mb_track... | def submit(artist, track, options={})
enforce_keys options, :time, :length, :album, :track_number, :mb_trackid
if @source == "P" && !options[:length]
raise DataError, "Track length must be specified if source is P"
end
handshake
parameters =
generate_scrobbling_parameters(true,
o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def now_playing(artist, track, options={})\n enforce_keys options, :length, :album, :track_number, :mb_trackid\n handshake\n parameters =\n generate_scrobbling_parameters(false,\n options.merge(:artist => artist, :track => track))\n status, = split_plain_text_response(post(@now_playing_url,... | [
"0.6960577",
"0.63955593",
"0.6276685",
"0.6240565",
"0.6212975",
"0.60286695",
"0.600132",
"0.58930266",
"0.58870447",
"0.5873877",
"0.5808191",
"0.5694283",
"0.5667345",
"0.5664261",
"0.56194526",
"0.5587672",
"0.55408823",
"0.5530455",
"0.5529741",
"0.55253434",
"0.5492524... | 0.6583668 | 1 |
"The NowPlaying notification is a lightweight mechanism for notifying Last.fm that a track has started playing. This is used for realtime display of a user's currently playing track, and does not affect a user's musical profile." The artist and track are required parameters. Other parameters can be added as options: :l... | def now_playing(artist, track, options={})
enforce_keys options, :length, :album, :track_number, :mb_trackid
handshake
parameters =
generate_scrobbling_parameters(false,
options.merge(:artist => artist, :track => track))
status, = split_plain_text_response(post(@now_playing_url, parameters... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_now_playing( params )\n LastFM.requires_authentication\n LastFM.post( \"track.updateNowPlaying\", params )\n end",
"def updateNowPlaying(username, password, args = {})\r\n if(args[:artist].to_s.strip.length == 0 || args[:track].to_s.strip.length == 0)\r\n puts \"To update th... | [
"0.70039165",
"0.6742334",
"0.65614104",
"0.6340588",
"0.6283589",
"0.6144293",
"0.5992758",
"0.574806",
"0.5719212",
"0.57079196",
"0.5699681",
"0.5640216",
"0.5547975",
"0.5544589",
"0.5534235",
"0.55325",
"0.5520632",
"0.5518514",
"0.5504747",
"0.54964674",
"0.5480381",
... | 0.714691 | 0 |
Perform handshake with the API. There is usually no need to call this, as it will be called automatically the first time a track is scrobbled. | def handshake
return if @scrobble_session_id
timestamp = Time.now.utc.to_i.to_s
authentication_token = md5(secret + timestamp)
parameters = {
"hs" => "true",
"p" => "1.2.1",
"c" => CLIENT_ID,
"v" => CLIENT_VERSION,
"u" => user,
"t" =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handshake\n end",
"def ssl_handshake_completed\n auth_data = {\n api_key: client.api_key,\n instance: client.instance_name,\n 'user-agent' => \"syncano-ruby-#{Syncano::VERSION}\"\n }\n\n auth_data[:auth_key] = client.auth_key if client.auth_key.present?\n\n client.... | [
"0.7186864",
"0.63363445",
"0.6259812",
"0.6116745",
"0.60962963",
"0.6077779",
"0.590094",
"0.5789357",
"0.5620385",
"0.56134063",
"0.55184215",
"0.5478653",
"0.5429812",
"0.54004115",
"0.54004115",
"0.5395166",
"0.53930897",
"0.5336014",
"0.5319506",
"0.5318256",
"0.5315465... | 0.7844754 | 0 |
def start_pos(pos) target = self[pos] if target == NullPiece.instance raise "No Piece here!" else self[pos].selected = true return target end end def end_pos(pos) target = self[pos] if target != NullPiece.instance raise "can't move here" end end | def check_move(start_pos, end_pos)
# p start_pos
# puts end_pos
if self[[start_pos[0], start_pos[1]]].valid_move?(start_pos, end_pos, self)
self[[start_pos[0], start_pos[1]]].move(start_pos, end_pos, self)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_piece(start_pos, end_pos, color)\n # p self[start_pos].is_a?(NullPiece)\n # p self[end_pos].is_a?(NullPiece)\n # p self[start_pos]\n if !self[start_pos].is_a?(NullPiece) && self[end_pos].is_a?(NullPiece)\n piece = self[start_pos]\n # Piece no longer in tha... | [
"0.7341209",
"0.7338607",
"0.731425",
"0.73035717",
"0.7215146",
"0.7163738",
"0.7163738",
"0.7125656",
"0.71211004",
"0.69376904",
"0.69352365",
"0.6913124",
"0.6896035",
"0.68948305",
"0.6885888",
"0.6856077",
"0.6847155",
"0.6789402",
"0.6786543",
"0.67643076",
"0.6722187"... | 0.6367597 | 39 |
def get_move start_p = start_pos end | def [](pos)
x, y = pos.first, pos[1]
@grid[x][y]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_start_and_end(move)\n mv_start = move[0..1].split('')\n mv_end = move[3..4].split('')\n\n start_row = 8 - mv_start[1].to_i\n start_col = @@horizontal_key[mv_start[0].downcase]\n start_location = [start_row, start_col]\n\n end_row = 8 - mv_end[1].to_i\n end_col = @@horizontal_key[mv_en... | [
"0.73492146",
"0.687643",
"0.686157",
"0.683789",
"0.68214965",
"0.6808856",
"0.6802341",
"0.67947906",
"0.67609227",
"0.67609227",
"0.67609227",
"0.67609227",
"0.66209316",
"0.6615561",
"0.6612829",
"0.6612829",
"0.66115946",
"0.66090584",
"0.6513091",
"0.6505281",
"0.648602... | 0.0 | -1 |
GET /rallies GET /rallies.json | def index
@rallies = Rally.includes(:rank_score).order('rank_scores.value desc').all.paginate(page: params[:page])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @allies = Ally.all\n end",
"def index\n @laws = Law.ordered_roots\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @laws }\n end\n end",
"def index\n @laws = Law.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n... | [
"0.66437083",
"0.6612015",
"0.6529444",
"0.6510944",
"0.6446249",
"0.6389025",
"0.6233748",
"0.62008834",
"0.6139333",
"0.6125064",
"0.6102139",
"0.6083003",
"0.6057065",
"0.60498595",
"0.60472023",
"0.6027201",
"0.60007316",
"0.59843606",
"0.59801525",
"0.5947182",
"0.593391... | 0.5568834 | 89 |
GET /rallies/1 GET /rallies/1.json | def show
if current_user
user_congress_members = CongressMemberFinder.get_all(current_user)
@senator_handles = user_congress_members[:senators] ? user_congress_members[:senators].map { |senator| senator.twitter_handle }.join(" ") : "@YourSenators"
@representative_handle = user_congress_members[:re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @ramal = Ramal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ramal }\n end\n end",
"def show\n @litra = Litra.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render... | [
"0.6583554",
"0.65162605",
"0.6397414",
"0.6357245",
"0.6340888",
"0.6297193",
"0.62597114",
"0.6246525",
"0.6161217",
"0.6158762",
"0.6134271",
"0.60959333",
"0.6071646",
"0.605772",
"0.60529685",
"0.60497826",
"0.60459894",
"0.60414404",
"0.6033875",
"0.6006267",
"0.6000885... | 0.0 | -1 |
POST /rallies POST /rallies.json | def create
@rally = current_user.rallies.build(rally_params)
respond_to do |format|
if @rally.save
format.html { redirect_to @rally, notice: 'Rally was successfully created.' }
format.json { render :show, status: :created, location: @rally }
else
format.html { render :new }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @lyric = Lyric.new(params[:lyric])\n\n respond_to do |format|\n if @lyric.save\n format.html { redirect_to @lyric, notice: 'Lyric was successfully created.' }\n format.json { render json: @lyric, status: :created, location: @lyric }\n else\n format.html { render ac... | [
"0.59840566",
"0.59689945",
"0.5735316",
"0.5617198",
"0.5606401",
"0.5594379",
"0.55858296",
"0.5554809",
"0.5525283",
"0.5524217",
"0.54699385",
"0.546516",
"0.5462803",
"0.5455903",
"0.54501075",
"0.54374933",
"0.5431548",
"0.5403896",
"0.5403447",
"0.5399029",
"0.5389676"... | 0.6109556 | 0 |
PATCH/PUT /rallies/1 PATCH/PUT /rallies/1.json | def update
respond_to do |format|
if @rally.update(rally_params)
format.html { redirect_to @rally, notice: 'Rally was successfully updated.' }
format.json { render :show, status: :ok, location: @rally }
else
format.html { render :edit }
format.json { render json: @rally.e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def patch!\n request! :patch\n end",
"def update\n @lyric = Lyric.find(params[:id])\n\n respond_to do |format|\n if @lyric.update_attributes(params[:lyric])\n format.html { redirect_to @lyric, notic... | [
"0.6535182",
"0.6496139",
"0.638618",
"0.63401365",
"0.62620544",
"0.616533",
"0.6126708",
"0.6105333",
"0.6102118",
"0.60987306",
"0.6093419",
"0.60858",
"0.6051613",
"0.60437375",
"0.60374784",
"0.6031276",
"0.6031276",
"0.60187054",
"0.6003396",
"0.5995828",
"0.5988439",
... | 0.57626384 | 52 |
DELETE /rallies/1 DELETE /rallies/1.json | def destroy
@rally.destroy
respond_to do |format|
format.html { redirect_to rallies_url, notice: 'Rally was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete!\n Recliner.delete(uri)\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @ramal = Ramal.find(params[:id])\n @ramal.destroy\n\n respond_to do |format|\n format.html { redirect_to ... | [
"0.7050458",
"0.6952668",
"0.6823765",
"0.6808273",
"0.66449",
"0.6640104",
"0.6631997",
"0.6616289",
"0.6616289",
"0.66146463",
"0.6602235",
"0.6601623",
"0.65860283",
"0.6554854",
"0.6552472",
"0.65226614",
"0.6521388",
"0.6510491",
"0.6503963",
"0.64859754",
"0.6485382",
... | 0.65509146 | 15 |
Use callbacks to share common setup or constraints between actions. | def set_rally
@rally = Rally.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def rally_params
params.require(:rally).permit(:title, :content, :twitter_template, :user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
check if current payment is a manual payment | def is_manual?
payment_kind == 'manual'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def requires_manual_payment?\n Paykido::Application.config.always_pay_manually or\n !self.payer.registered?\n end",
"def in_payment?\n @in_payment\n end",
"def collect_payment?\n true\n end",
"def deal_with_payment\n if human_amount_due <= 0\n update_attributes!(active: false)\n ... | [
"0.7879028",
"0.73565",
"0.7281793",
"0.7254074",
"0.7199515",
"0.6935673",
"0.69030434",
"0.6895614",
"0.6894103",
"0.6876857",
"0.68706155",
"0.68308496",
"0.68273544",
"0.67914116",
"0.6769628",
"0.67648005",
"0.6755847",
"0.67344284",
"0.67300874",
"0.6728121",
"0.6712991... | 0.8408452 | 0 |
confirm a paypal payments started with prepare paypal | def finish_paypal!(_payer_id, token)
return errors.add(:base, "Invalid paypal payment token.") && false if payment_token != token
response = EXPRESS_GATEWAY.purchase(total_amount*100, {ip: payment_ip, token: payment_token, payer_id: _payer_id})
unless response.success?
Rails.logger.error "********** P... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paypal\n @checkout = Checkout.new(current_user)\n setup_response = gateway.setup_purchase(@checkout.total * 100,\n :ip => request.remote_ip,\n :return_url => paypal_complete_orders_url,\n :cancel_return_url => url_for(:action => :new, :controller => :checkout)\n )\... | [
"0.72218204",
"0.7148402",
"0.69659734",
"0.6965965",
"0.69041866",
"0.68155384",
"0.67356026",
"0.67253125",
"0.665716",
"0.66568935",
"0.66282934",
"0.6604223",
"0.6558166",
"0.6538187",
"0.6503091",
"0.6496427",
"0.6486229",
"0.64610344",
"0.63983434",
"0.63774383",
"0.637... | 0.64455307 | 18 |
completes stripe payment transaction | def finish_stripe!(token, save_card = false, _recurring_period = nil)
data = {:amount => (total_amount * 100).to_i, :currency => Rails.configuration.app_currency.downcase, :description => description}
if save_card
customer = Stripe::Customer.create(:email => user.email, :source => token)
data[:custo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def release(account, merchant, transaction_id)\n delete \"/#{CGI::escape(account)}/transactions/#{transaction_id}\" + \"?merchant=#{merchant}\"\n expect_status! 'CANCELLED'\n end",
"def destroy\n @payment_txn.destroy\n respond_to do |format|\n format.html { redirect_to payment_txns_url }\n ... | [
"0.7043317",
"0.6717193",
"0.65813935",
"0.6548043",
"0.6470679",
"0.6444878",
"0.6444878",
"0.6371565",
"0.63522404",
"0.63510346",
"0.6339401",
"0.6337352",
"0.63227385",
"0.63012785",
"0.6295888",
"0.62936264",
"0.6282784",
"0.6274207",
"0.62613153",
"0.62541765",
"0.62310... | 0.6585765 | 2 |
permit to make a payment using saved token of current user | def payment_by_token! card_id, _recurring_period = nil
card = card_id.is_a?(PaymentCard) ? card_id : user.payment_cards.find_by_id(card_id)
return errors.add(:base, 'Payment card token not found') && false unless card
self.payment_card_id = card.id
case card.kind
when 'rave'
uri = URI.pars... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_buy_token\n # Whitelist parameters for buying tokens\n purchase_params \n end",
"def payment(params)\n check_token\n\n Request.perform(:post, URI.parse(Urls::PAYMENTS_URL), headers_for_other, params.to_json)\n end",
"def payment_params\n params.permit(:amount, :token, :user_emai... | [
"0.7167714",
"0.7061067",
"0.6901966",
"0.6884086",
"0.6793027",
"0.6742208",
"0.673527",
"0.66023386",
"0.6571146",
"0.6568209",
"0.65551615",
"0.65415204",
"0.6514668",
"0.6500135",
"0.6495035",
"0.6481642",
"0.64490783",
"0.6439458",
"0.6436549",
"0.64313686",
"0.64128447"... | 0.6258977 | 38 |
Verify and update a mobile payment by payment token | def confirm_paypal!(token)
begin
p = EXPRESS_GATEWAY.details_for(token)
return errors.add(:base, p.message) && false unless p.success?
_paid = p.params['order_total'].to_f
return errors.add(:base, "The amount paid #{_paid} is different to #{total_amount}") && false if _paid != total_amount
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify(token)\n request = verify_request(token)\n response = PaybywayConnector.check_payment_status(request).parsed_response\n response['result'] == 0\n end",
"def check_token card, token, model\n if token && model.user.acct_token\n Payment::assign_card card, model, token\n car... | [
"0.66459846",
"0.663617",
"0.6609819",
"0.6539378",
"0.65137774",
"0.63684756",
"0.635184",
"0.6334806",
"0.6277955",
"0.61883724",
"0.61862296",
"0.612155",
"0.60361105",
"0.6028154",
"0.6016464",
"0.60088843",
"0.5940551",
"0.5930836",
"0.59260416",
"0.5909798",
"0.58937395... | 0.619468 | 9 |
return the total amount to pay | def total_amount
(payable.try(:total_amount) || amount).to_f
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_total_payment\n\t\tif self.total_amount.blank?\n\t\t\tbalance = 0\n\t\telse\n\t\t\tbalance = (self.total_amount + self.penalty) - paid_total\n\t\tend\n\n\t\tif balance <= 0\n return 0\n else\n return balance\n end\n\tend",
"def total_amount\n t = amount\n t += sub_transactions... | [
"0.8100905",
"0.79382706",
"0.789065",
"0.7709827",
"0.7657929",
"0.76503664",
"0.7649522",
"0.76422983",
"0.76390415",
"0.7624554",
"0.7579496",
"0.7577603",
"0.75773585",
"0.75700665",
"0.7554224",
"0.7532991",
"0.752945",
"0.75151986",
"0.7468371",
"0.74626434",
"0.7462064... | 0.7922934 | 2 |
check if payment has been completed | def paid?
payment_at?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_finish?\n self.payment_status == PTE::PaymentStatus.processing\n end",
"def payment_in_progress?\n\t\t\t\t\treturn !self.payment_id.nil?\n\t\t\t\tend",
"def settled_payment?\n SUCCESSFUL_PAYMENT.include?(response['payment_state'])\n end",
"def paypal_paid?\n self.paypal_transacti... | [
"0.8263236",
"0.7821854",
"0.7467909",
"0.7364501",
"0.73641145",
"0.7334532",
"0.7276411",
"0.72701323",
"0.72630394",
"0.7254286",
"0.72278374",
"0.722421",
"0.72165966",
"0.7184224",
"0.7179494",
"0.71563447",
"0.7094832",
"0.7076029",
"0.7056778",
"0.70456195",
"0.7034058... | 0.6828666 | 39 |
return payment goal humanized | def the_goal
UserGroup::PAYMENT_GOALS[goal.to_sym] if goal
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _spent_on\n return payment\n end",
"def get_payment_message\n final_price =self.subscription.plan_price.to_f\n coupon_found = self.orders.where(state: 'paused').first.coupon.present?\n payment_message = \"You will be charged $#{final_price}/month for this subscription.\"\n payment_message = s... | [
"0.66695297",
"0.63562435",
"0.63393134",
"0.6334298",
"0.62982386",
"0.6293362",
"0.62727076",
"0.62682414",
"0.62681264",
"0.60966593",
"0.6074718",
"0.60529083",
"0.6046112",
"0.6029961",
"0.60261285",
"0.59841114",
"0.5959435",
"0.5947087",
"0.59465116",
"0.591382",
"0.59... | 0.7222695 | 0 |
return the error notification message | def paypal_errors_msg
"We are sorry, but the purchase was not completed due the following errors: #{errors.full_messages.join(', ')}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_message\n error.message\n end",
"def error_message\n return @error_message\n end",
"def error_message; end",
"def error_notification\n @error_notification\n end",
"def error_msg\n name\n end",
"def error_message\n self[:error_message]\n end"... | [
"0.79915637",
"0.7959681",
"0.786197",
"0.77491647",
"0.77323014",
"0.77",
"0.7697156",
"0.76706195",
"0.7667608",
"0.7547774",
"0.7534374",
"0.75129956",
"0.7424433",
"0.7424433",
"0.73975194",
"0.73640746",
"0.7334554",
"0.72457236",
"0.7202255",
"0.71908593",
"0.7190696",
... | 0.0 | -1 |
start recurring payment using current payment as a template | def start_recurring_payment
return unless recurring_period.present?
run_at = nil
if recurring_period.to_s.is_i? # each custom days
run_at = recurring_period.to_i.days.from_now
# run_at = recurring_period.to_i.minutes.from_now
else
case recurring_period
when 'daily'
ru... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def payment\n # FIXME: please constantize the step numbers!\n @step = 5\n session[:step] = 5 if (session[:step].nil? || session[:step] < 5)\n @tipsters = Tipster.where(id: tipster_ids_in_cart)\n unless current_subscriber.subscription.present?\n @subscription = current_subscriber.build_subscript... | [
"0.6529649",
"0.64733624",
"0.6406834",
"0.6350068",
"0.6342187",
"0.6308403",
"0.60762835",
"0.60751325",
"0.6063104",
"0.60547304",
"0.59386307",
"0.59273684",
"0.58945084",
"0.5891776",
"0.5891776",
"0.5871441",
"0.58663994",
"0.5862638",
"0.5851113",
"0.58374107",
"0.5830... | 0.787654 | 0 |
check if current payment is recruging and active | def is_active_recurring
recurring_period? && !recurring_stopped_at?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recurring_supported?\n return !self.recurrent? && [Buckaruby::PaymentMethod::IDEAL, Buckaruby::PaymentMethod::IDEAL_PROCESSING, Buckaruby::PaymentMethod::VISA, Buckaruby::PaymentMethod::MASTER_CARD, Buckaruby::PaymentMethod::MAESTRO, Buckaruby::PaymentMethod::SEPA_DIRECT_DEBIT, Buckaruby::PaymentMethod::PAY... | [
"0.715441",
"0.7114459",
"0.70562536",
"0.70495015",
"0.7009461",
"0.6903681",
"0.68828046",
"0.6876543",
"0.6845582",
"0.68344486",
"0.6831494",
"0.6828456",
"0.6811467",
"0.68056756",
"0.6796346",
"0.6790113",
"0.6783316",
"0.6771985",
"0.67652947",
"0.6762039",
"0.6755748"... | 0.6565547 | 37 |
return the mask for card number | def card_number_mask
"XXX XXXX XXX #{last4}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mask\n raw_value\n end",
"def card_number\n card = full_card_number.scan(/(\\d{4})/)\n card[2] = card[1] = 'X' * 4\n card.join\n end",
"def mask_to_i\n @mask_addr\n end",
"def maskify(cc)\n # your beautiful code goes here\n cc.length <= 4 ? cc : \"#\" *... | [
"0.7003182",
"0.6387896",
"0.6332972",
"0.63106006",
"0.6303501",
"0.62915117",
"0.6206295",
"0.6174796",
"0.61513907",
"0.6117676",
"0.60992825",
"0.60235965",
"0.60015476",
"0.5996125",
"0.5952774",
"0.5936632",
"0.58930624",
"0.5887236",
"0.58706105",
"0.5864452",
"0.58521... | 0.82087 | 0 |
check if current payment is a pledge payment | def is_pledge_payment?
payable_type == 'UserGroup' && goal == 'pledge'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_payment?\n @in_payment\n end",
"def payment_pending?\n payment_state == PAYMENT_PENDING\n end",
"def paid?\n status == 'paid'\n end",
"def paid_up?\n if payment_item.is_a? GeneralPaymentItem\n outstanding_amount <= 0.0\n else\n nil\n end\n en... | [
"0.72062373",
"0.6843458",
"0.6834632",
"0.6806494",
"0.6800522",
"0.67939025",
"0.6791279",
"0.67826104",
"0.67393345",
"0.6732231",
"0.67297",
"0.67297",
"0.6720479",
"0.671762",
"0.67032516",
"0.6699848",
"0.66950357",
"0.66849375",
"0.66849375",
"0.66849375",
"0.66849375"... | 0.83155835 | 0 |
check if current payment is pending or not | def pending?
payment_at.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pending?\n payment_status == 'Pending'\n end",
"def payment_pending?\n payment_state == PAYMENT_PENDING\n end",
"def can_pay_pending?\n conf_payment_enabled = SystemConfiguration::Variable.get_value('booking.payment', 'false').to_bool\n conf_payment_deposit = (['... | [
"0.8913813",
"0.8703912",
"0.8171927",
"0.79970706",
"0.7810532",
"0.7805026",
"0.7767848",
"0.774087",
"0.77193546",
"0.7675726",
"0.7651218",
"0.76456845",
"0.76341504",
"0.7615482",
"0.7598338",
"0.7550721",
"0.75204194",
"0.7516152",
"0.7513935",
"0.7459208",
"0.74583715"... | 0.8378868 | 2 |
return the recurring amount for current payment | def get_recurring_amount
recurring_amount || amount
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_amount\n t = amount\n t += sub_transactions.sum(:amount) if recurring_period\n t\n end",
"def recurring_charges\n data.recurring_charges\n end",
"def payment_price\n recurring_payments? ? (price / recurring_number) : price\n end",
"def save_recurring_amount\n self.recurring... | [
"0.7269642",
"0.7262312",
"0.72457206",
"0.7056836",
"0.68578327",
"0.67339325",
"0.67237777",
"0.66052574",
"0.655268",
"0.6547661",
"0.65378845",
"0.65255964",
"0.64560026",
"0.6362139",
"0.63484675",
"0.633427",
"0.6300612",
"0.62526095",
"0.6181994",
"0.615471",
"0.614914... | 0.8124226 | 0 |
send a pledge reminder email | def send_pledge_reminder!
UserMailer.payment_reminder_pledge(user, self).deliver
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_pledge\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def reminder_email(payment)\n @payment = payment\n @url = generate_url(User.find_by_email(@payment.email))\n #loaner_email = User.find(@payment.user_id).email\n\n mail(:to => @payment.email, :subject => \"Reminder tha... | [
"0.7691392",
"0.75125974",
"0.75108796",
"0.7399268",
"0.73989904",
"0.7244021",
"0.7191051",
"0.7138903",
"0.7088361",
"0.70673555",
"0.7061604",
"0.70579016",
"0.7037351",
"0.70369375",
"0.7012512",
"0.6997216",
"0.69798946",
"0.696602",
"0.69598633",
"0.69297796",
"0.69274... | 0.8538934 | 0 |
make current payment as transferred | def make_transferred!
update_column(:transferred_at, Time.current)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mark_as_transferred\n if @payment.make_transferred!\n render_success_message \"Payment successfully marked as transferred\"\n else\n render_error_model @payment\n end\n end",
"def after_confirmation\n Transfer.create(\n receiver: self,\n amount: 1_000.0,\n source_currenc... | [
"0.7583196",
"0.71115285",
"0.70449233",
"0.69803196",
"0.69282466",
"0.6841832",
"0.6804147",
"0.6774487",
"0.6755527",
"0.6746029",
"0.6730227",
"0.672604",
"0.66951936",
"0.66830945",
"0.66734606",
"0.6660888",
"0.6655684",
"0.66541195",
"0.6620625",
"0.6607798",
"0.660772... | 0.0 | -1 |
make current payment as no transferred | def unmark_transferred!
update_column(:transferred_at, nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unmark_transferred\n if @payment.unmark_transferred!\n render_success_message \"Payment successfully unmarked as transferred\"\n else\n render_error_model @payment\n end\n end",
"def skip_charge!\n return if @plan.trial\n\n charge.update(status: :skipped)\n @account.update(... | [
"0.69241613",
"0.66297895",
"0.65453213",
"0.6441688",
"0.64074963",
"0.6302503",
"0.62811786",
"0.6277461",
"0.6255367",
"0.6217875",
"0.621299",
"0.6209091",
"0.61922765",
"0.6123966",
"0.61211747",
"0.6120495",
"0.6118776",
"0.61095095",
"0.60897404",
"0.60844505",
"0.6080... | 0.0 | -1 |
return the total amount paid with this transaction, this means will include children payments if it is recurring | def total_amount
t = amount
t += sub_transactions.sum(:amount) if recurring_period
t
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paid_total\n paid_total = 0\n unless self.payments.blank?\n for payment in self.payments\n paid_total += payment.amount.blank? ? 0 : payment.amount\n end\n end\n return paid_total\n end",
"def calculate_total_payment\n\t\tif self.total_amount.blank?\n\t\t\tbalance = 0\n\t\telse\... | [
"0.7924669",
"0.7313006",
"0.72757244",
"0.7274013",
"0.7244053",
"0.72302836",
"0.70702755",
"0.7036051",
"0.7021903",
"0.698985",
"0.6978189",
"0.6961576",
"0.69037735",
"0.6802876",
"0.6774897",
"0.67465264",
"0.6739249",
"0.6736649",
"0.66720074",
"0.66346836",
"0.6621564... | 0.7705106 | 1 |
save current transaction token as a card token to be used in the future | def save_payment_card(card_name, token, exp)
card = user.payment_cards.where(kind: payment_kind, last4: last4, name: card_name, exp: exp).first_or_create!(customer_id: token)
self.payment_card = card
start_recurring_payment if save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_token card, token, model\n if token && model.user.acct_token\n Payment::assign_card card, model, token\n card.token = token\n result = card.save\n else\n result = card.save_account \n end\n end",
"def save_token\n self.token = SecureRandom.uuid unless self.token\n ... | [
"0.7075429",
"0.70693415",
"0.696635",
"0.6945454",
"0.67096084",
"0.655786",
"0.6550422",
"0.65266246",
"0.6495899",
"0.64703727",
"0.64518654",
"0.6439364",
"0.6424037",
"0.6383865",
"0.63602215",
"0.63419175",
"0.63384736",
"0.6335049",
"0.6333653",
"0.63167655",
"0.628526... | 0.6526483 | 8 |
register an email alert: "Remind users of their pledge a day before its due. On the chosen date, remind them again" | def register_pledge_alert
if payment_in? && payment_in_changed?
d1 = (payment_in - 1.day).beginning_of_day
d2 = payment_in.beginning_of_day
self.delay(run_at: d1).send_pledge_alert(payment_in, false) if d1 >= Time.current
self.delay(run_at: d2).send_pledge_alert(payment_in, true) if d2 >= Ti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_reminder\r\n\t\tif Date.today == expiration_date - 1\r\n\t\t\tReminderMailer.food_reminder_msg(@user).deliver\r\n \t\tflash[:notice] = \"#{@user.username} has been notified by email.\" \r\n \tend\r\n end",
"def send_day_before_reservation_reminder(email)\n @email = email\n mail(to: em... | [
"0.73617285",
"0.7001274",
"0.6984149",
"0.66397554",
"0.65765536",
"0.6553069",
"0.6546316",
"0.65393806",
"0.6529114",
"0.65193796",
"0.65095055",
"0.65059006",
"0.64650965",
"0.64649975",
"0.6453482",
"0.6431892",
"0.64223164",
"0.64206064",
"0.6412538",
"0.6391784",
"0.63... | 0.6759868 | 3 |
send invoice if payment was completed for user groups | def send_invoice
if payment_at_changed? && payment_at.present?
payable.try(:payment_completed!, self)
if payable_type == 'UserGroup'
UserMailer.payment_completed(user, self).deliver
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def successfully_charged(invoice, user)\n @subscription = invoice.lines.data.first\n @user = user\n @subscription_plan = @subscription.plan.name\n @subscription_amount = format_amount(invoice.total)\n @subscription_start = format_timestamp(@subscription.period.start)\n @subscription_end = format_... | [
"0.6733903",
"0.6222003",
"0.62201315",
"0.6186437",
"0.6129212",
"0.60555136",
"0.6039966",
"0.5994214",
"0.59900355",
"0.59706986",
"0.5965053",
"0.59632933",
"0.5952842",
"0.59505475",
"0.5944754",
"0.5900615",
"0.58944446",
"0.5891947",
"0.58831733",
"0.58736366",
"0.5869... | 0.77304745 | 0 |
If a group is not verified, if someone tries to send a payment to that church/group, show error message | def verify_user_group_status
errors.add(:base, "This #{payable.the_group_label} has not been set up to receive payments yet. You can ask its leaders to contact LoveRealm concerning this.") if payable_type == 'UserGroup' && !payable.is_verified?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validateHandinForGroups_forHTML\n validity = validateHandinForGroups\n\n case validity\n when :valid\n return true\n when :awaiting_member_confirmation\n msg = \"You cannot submit until all group members confirm their group membership\"\n when :group_submission_limit_exceeded\n ms... | [
"0.65554947",
"0.6145241",
"0.6064739",
"0.59697986",
"0.59668905",
"0.58985186",
"0.5870492",
"0.57862216",
"0.57756335",
"0.57519",
"0.5744274",
"0.5735635",
"0.5722856",
"0.5722475",
"0.57180446",
"0.5717845",
"0.56737",
"0.56698644",
"0.5659184",
"0.56114805",
"0.5586534"... | 0.7429656 | 0 |
rescue recurring amount if it is recurring payment | def save_recurring_amount
self.recurring_amount = amount if recurring_period.present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_recurring_amount\n recurring_amount || amount\n end",
"def retry_failed_payment\n end",
"def stripe_invoice_payment_failed(event, req)\n invoice = event['data']['object']\n # NOTE: If no next attempt we are on the last, subscription will be cancelled\n return false unless invoic... | [
"0.68804765",
"0.64478046",
"0.6418149",
"0.63809174",
"0.6365425",
"0.6320232",
"0.62871194",
"0.6128493",
"0.6097943",
"0.6063984",
"0.60554105",
"0.6051057",
"0.6048137",
"0.604725",
"0.60424775",
"0.6041219",
"0.60300964",
"0.6022325",
"0.59870726",
"0.59453213",
"0.58913... | 0.66592175 | 1 |
function require_login! check if users is logged in or not | def require_login!
return true if authenticate_token
render json: { errors: [ { detail: "Access denied" } ] }, status: 401
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def require_login\n end",
"def require_login\n !!current_user || access_denied\n end",
"def needs_login?() false end",
"def login_required\n username, passwd = get_auth_data\n logged_in? && authorized? ? true : access_denied\n end",
"def login_required\n return true unless sessio... | [
"0.8322065",
"0.8186701",
"0.8117254",
"0.81154466",
"0.8093616",
"0.8076708",
"0.8075441",
"0.8011906",
"0.8003113",
"0.80024797",
"0.79699874",
"0.79608107",
"0.79540175",
"0.7945144",
"0.79400533",
"0.79351944",
"0.7934206",
"0.78894395",
"0.788232",
"0.78787",
"0.78781515... | 0.0 | -1 |
function restricted_login! function will check auth and check if token is restricted type | def restricted_login!
return true if authenticate_token_restricted
render json: { errors: [ { detail: "Access denied" } ] }, status: 401
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_is_login_required\n authorized_denied unless logged_in?\n end",
"def login_required\n username, passwd = get_auth_data\n logged_in? && authorized? ? true : access_denied\n end",
"def login_required\n authorized? || access_denied\n end",
"def login_required\n authorized... | [
"0.75254095",
"0.74760246",
"0.74299055",
"0.74299055",
"0.74299055",
"0.74258095",
"0.73741823",
"0.7235595",
"0.7235595",
"0.722745",
"0.72207874",
"0.72188646",
"0.71926636",
"0.715344",
"0.715219",
"0.7124465",
"0.71242315",
"0.71221834",
"0.7112839",
"0.7080577",
"0.7076... | 0.80312294 | 0 |
Function current_user for API Function will assign authenticate_token to current user global variable | def current_user
@_current_user ||= authenticate_token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_user\n\t\t@current_user ||= authenticate_token\n\tend",
"def current_user\n authenticate_token\n end",
"def set_current_user\n # for access to authenticate method\n t = ActionController::HttpAuthentication::Token\n @current_user = t.authenticate(self, &AUTH_PROC)\n end",
"de... | [
"0.8561574",
"0.84435004",
"0.8158719",
"0.81440467",
"0.81331664",
"0.81325376",
"0.8103323",
"0.81011045",
"0.81011045",
"0.80527216",
"0.7918764",
"0.7908768",
"0.78635305",
"0.78567886",
"0.7846868",
"0.7838918",
"0.7835402",
"0.7811583",
"0.7807281",
"0.7791499",
"0.7763... | 0.8599173 | 1 |
Parameters are settings, which is not to be confused with status. | def read_parameter(num)
write { "F21 P#{num}" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status_params\n end",
"def status_params\n params.require(:status).permit(:result_no, :generate_no, :e_no, :style_id, :effect, :mhp, :msp, :landform_id, :condition, :max_condition, :ps)\n end",
"def params_to_pass\n settings\n end",
"def status_params\n params.require(:status).p... | [
"0.7410525",
"0.6645019",
"0.6597065",
"0.6518975",
"0.65114886",
"0.64923364",
"0.64744276",
"0.6445884",
"0.6381893",
"0.63810664",
"0.6368731",
"0.6356594",
"0.63490134",
"0.63490134",
"0.6333185",
"0.63160664",
"0.63160664",
"0.6307666",
"0.6307666",
"0.6307666",
"0.63076... | 0.0 | -1 |
The Arduino uses a different parameter number for each axis. Ex: MOVEMENT_TIMEOUT_X is 11 and MOVEMENT_TIMEOUT_Y is 12. To keep things dry, this method will lookup the correct paramater numer based on the axis provided and the three options available (if_x, if_y, if_z) | def set_paramater_value(axis, value, if_x, if_y, if_z)
param_num = { 'x' => if_x, 'y' => if_y, 'z' => if_z }[axis.to_s.downcase]
raise InvalidAxisEntry, "You entered an invalid axis" unless param_num
write { "F22 P#{param_num} V#{value.to_s}" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_param_values_non_arduino\n\n p = get_param_by_name('MOVEMENT_STEPS_PER_UNIT_X')\n @axis_x_steps_per_unit = p['value_db']\n\n p = get_param_by_name('MOVEMENT_STEPS_PER_UNIT_Y')\n @axis_y_steps_per_unit = p['value_db']\n\n p = get_param_by_name('MOVEMENT_STEPS_PER_UNIT_Z')\n @axis_z_steps_... | [
"0.58720434",
"0.58720434",
"0.5390595",
"0.5194007",
"0.5116571",
"0.50551313",
"0.50109106",
"0.49937758",
"0.4972413",
"0.49001357",
"0.4889991",
"0.4889144",
"0.48881504",
"0.48814026",
"0.4878868",
"0.47735217",
"0.47727707",
"0.47662783",
"0.47397482",
"0.47239235",
"0.... | 0.57688755 | 2 |
It creates missing folders if needed, creates a new zip/word file on the specified location, copies all the files from the template word document and replace the content of the ones to be replaced. It will create a tempfile and return it. The rails app using the gem should decide what to do with it. | def save
Tempfile.open([file_name, FILE_EXTENSION], type: 'application/zip') do |output_file|
Zip::File.open(@template_path) do |template_zip|
Zip::OutputStream.open(output_file.path) do |out|
template_zip.each do |entry|
out.put_next_entry entry.name
if @... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate\n Zip::File.open(@template_path) do |template_zip|\n buffer = Zip::OutputStream.write_buffer do |out|\n template_zip.each do |entry|\n out.put_next_entry entry.name\n if @replaceable_files[entry.name]\n source = entry.get_input_stream.read.sub(/(... | [
"0.70469683",
"0.68263745",
"0.67915076",
"0.61167115",
"0.61142695",
"0.6104195",
"0.6103603",
"0.60351104",
"0.59522164",
"0.59507483",
"0.5933508",
"0.5931858",
"0.58248687",
"0.58006495",
"0.57836187",
"0.5757623",
"0.57122284",
"0.5709879",
"0.5705491",
"0.57027864",
"0.... | 0.69214696 | 1 |
Create a new +Instant+ from an optional nanosecond measurement. Users should generally not pass anything to this function. | def initialize(nanos = Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond))
@ns = Integer(nanos)
freeze
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_millis(millis)\n LocalTime.of(@hour, @minute, @second, millis)\n end",
"def initialize(time, in_ms = false)\n @t = time\n @ms = in_ms\n end",
"def initialize(zone = nil, year = nil, month = nil, day = nil, hour = nil, min = nil, sec = nil)\n\n # Case when all params are nil - c... | [
"0.55076045",
"0.53314954",
"0.5281278",
"0.527619",
"0.5239311",
"0.5163289",
"0.5024513",
"0.501803",
"0.50028485",
"0.4965847",
"0.4950783",
"0.49157798",
"0.4895656",
"0.48875955",
"0.48865855",
"0.48672628",
"0.4866397",
"0.48508063",
"0.48100153",
"0.47880992",
"0.47767... | 0.5653488 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.