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 |
|---|---|---|---|---|---|---|
This is a before_filter callback for registering new visitors admin users are ignored | def track_visitor
return if ignore_funnel_tracking?
register_funnel_visitor unless visitor_registered?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_user_is_registered\n unless( user_is_registered)\n redirect_to_login\n end\n end",
"def admin_user\n render_forbidden unless current_user.admin?\n end",
"def admin_restrictions\n unless AdminUser.find(:all).empty?\n redirect_to login_path, :notice => \"Admin user already exis... | [
"0.6606229",
"0.6525457",
"0.63931304",
"0.63324946",
"0.6280296",
"0.6217417",
"0.617769",
"0.61725754",
"0.6136499",
"0.6108576",
"0.60830104",
"0.60790104",
"0.6058918",
"0.604925",
"0.60401785",
"0.60363257",
"0.6035207",
"0.602145",
"0.6017356",
"0.6017356",
"0.6017356",... | 0.0 | -1 |
Workhorse utility method for logging funnel events (This is probably how MOST funnel events will be triggered) checks if we are an admin visitor first sends the funnel event msg to the current user, if we're logged in sets the url, referer, ua data automatically using the request otherwise, sends it to the current visitor if there is no valid current visitor, register one finally... logs an error if we have no current visitor (because that shouldn't happen!) | def log_funnel_event(event, data={})
return if ignore_funnel_tracking?
register_funnel_visitor if current_visitor.nil?
unless current_visitor.nil?
data.reverse_merge!({
:url=>request.request_uri,
:referer=>request.referer,
:user_agent=>request.env["HTTP_USER_AGENT"].to_s
})
current_visitor.log_funnel_event(event, data)
return
end
logger.info "Couldn't Log FunnelCake Event: #{event} No Analytics::Visitor found!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_funnel_page_visit\n log_funnel_event(:view_page)\n end",
"def log_funnel_event(event, data={})\n unless self.valid_events.include?(event.to_sym)\n Rails.logger.info \"#{self.class.to_s} couldn't log FunnelCake event: #{event} This event is not valid for state: #{self.current_state... | [
"0.635289",
"0.6267571",
"0.6267571",
"0.6187196",
"0.55726147",
"0.553493",
"0.54904956",
"0.539742",
"0.53672236",
"0.5338377",
"0.5333843",
"0.5252021",
"0.5244352",
"0.52382517",
"0.520691",
"0.5148758",
"0.51268154",
"0.5083651",
"0.5046718",
"0.5042269",
"0.50162965",
... | 0.7238873 | 0 |
Utility method for logging a page visit | def log_funnel_page_visit
log_funnel_event(:view_page)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def goto_weblog(page)\n #generally speaking, we want to goto \"http://[username].xanga.com/\n\n page = @agent.click page.links.href(\"http://#{@user}.xanga.com/\").first\n end",
"def visited_page(url); end",
"def visited_page(url); end",
"def logVisit record=nil, rateable=false\n return if !valid_b... | [
"0.6675028",
"0.66497064",
"0.66497064",
"0.6556473",
"0.6507742",
"0.6419096",
"0.6418814",
"0.6294446",
"0.61958575",
"0.6167854",
"0.61454034",
"0.61243266",
"0.6122999",
"0.6122999",
"0.6122999",
"0.6122999",
"0.6122999",
"0.6122999",
"0.6122999",
"0.6122999",
"0.60728747... | 0.75481397 | 0 |
Utility method for syncing the current visitor to the current user (This should be called when a user logs in!) Bails out if not logged in otherwise, sets the .user of the current_visitor | def sync_funnel_visitor
return unless FunnelCake.enabled?
if not logged_in?
logger.info "Couldn't sync Analytics::Visitor to nil User"
return
end
if current_visitor.nil?
logger.info "Couldn't sync nil Analytics::Visitor to current User: #{current_user.inspect}"
return
end
current_visitor.user_id = current_user.id
current_visitor.save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_current_user\n if logged_in?\n @current_user = current_user\n end\n end",
"def set_current_user\n if logged_in?\n User.current_user = current_user\n else\n User.current_user = nil\n end\n end",
"def set_current_user\n \t\tif session[:user_id]\n \t\t\tCurrent.user = User.... | [
"0.71031487",
"0.7061895",
"0.7033756",
"0.701274",
"0.6972991",
"0.69189906",
"0.69166034",
"0.6909499",
"0.68816924",
"0.68760806",
"0.6862525",
"0.6862525",
"0.6862525",
"0.6862525",
"0.6857685",
"0.6856365",
"0.6849019",
"0.6849019",
"0.68476367",
"0.68375707",
"0.6801216... | 0.7564509 | 0 |
should we ignore this visitor? | def ignore_funnel_tracking?
return true unless FunnelCake.enabled?
# check user-overrideable methods
return true if respond_to?(:ignore_funnel_visitor?) and ignore_funnel_visitor?
# ignore search engine bots
return true if request.env["HTTP_USER_AGENT"] and request.env["HTTP_USER_AGENT"][/Googlebot|msnbot|Yahoo|Baidu|Teoma/]
return true if funnel_browser_is_bot?
# check funnel-ignore list
return true unless Analytics::Ignore.find_by_ip(request.remote_ip.to_s).nil?
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accept(visitor); end",
"def accept(visitor); end",
"def accept(_visitor)\n raise NotImplementedError\n end",
"def visit_e(node)\n ignore_node(node)\n end",
"def accept visitor\n visitor.accept_hard_break self\n end",
"def accept visitor\r\n visitor.accept_hard_break self\r\n e... | [
"0.71232104",
"0.71232104",
"0.7093048",
"0.6725334",
"0.67078125",
"0.66341066",
"0.65979755",
"0.6550514",
"0.6440139",
"0.630984",
"0.62488705",
"0.6128646",
"0.60373855",
"0.6032037",
"0.5984458",
"0.5982569",
"0.59121907",
"0.58551115",
"0.5832115",
"0.5785707",
"0.57541... | 0.0 | -1 |
Is the current visitor registered? We check the cookie state to find out | def visitor_registered?
cookies[self.class.read_inheritable_attribute(:cookie_name)].nil? == false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_cookie?\n \n cookie = request.cookies[\"kindle\"]\n \n # attempt to look up cookie in registration DB\n reg = Registration.first(:content => cookie)\n \n if $DEBUG\n puts \"Cookie: \" + (cookie.nil? ? \"nil\" : cookie.to_s )\n puts \"Registration: \" + (reg.nil? ? \"nil\" :... | [
"0.74209034",
"0.6884273",
"0.6788344",
"0.6766331",
"0.67409414",
"0.6707545",
"0.6691672",
"0.6680515",
"0.66242874",
"0.66047823",
"0.65944004",
"0.6589199",
"0.6554048",
"0.6549198",
"0.6504574",
"0.6463556",
"0.6415464",
"0.639112",
"0.639112",
"0.63783354",
"0.6376519",... | 0.87935054 | 0 |
Register the current visitor (without checking anything first, just do it) We create a new Analytics::Visitor here, using a new random hex key Set the cookie value for this visitor | def register_funnel_visitor
@current_visitor = FunnelCake.engine.visitor_class.create(
:ip=>request.remote_ip.to_s
)
@current_visitor.user_id = current_user.id if logged_in?
@current_visitor.save
cookies[self.class.read_inheritable_attribute(:cookie_name)] = {
:value => @current_visitor.id,
:expires => 1.year.from_now
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def record_visit\n unless (visit_key = cookies[:id])\n visit_key = SecureRandom.urlsafe_base64(16)\n cookies.permanent[:id] = visit_key\n end\n VisitCounter.record(visit_key)\n end",
"def track_visitor\n visitor_cookie_name = \"teaser.#{@teaser.id}.visitor\"\n if cookies[visitor_coo... | [
"0.73304033",
"0.66246873",
"0.655579",
"0.6404724",
"0.6201737",
"0.61668074",
"0.60564953",
"0.6044377",
"0.60066134",
"0.5912472",
"0.58503366",
"0.57785815",
"0.5758547",
"0.56748974",
"0.5650055",
"0.56169564",
"0.5613965",
"0.5577536",
"0.556677",
"0.5558418",
"0.553838... | 0.7774939 | 0 |
returns the current Analytics::Visitor object, using the visitor's cookie | def current_visitor
return @current_visitor unless @current_visitor.nil?
# Check if we're logged in first, set the current_visitor from the current_user
if logged_in?
@current_visitor = current_user.visitor
end
# If we are not logged in, or if the current_user has no visitor,
# then try to find the visitor by the cookie key
if @current_visitor.nil?
cookie = cookies[self.class.read_inheritable_attribute(:cookie_name)].gsub(/[^0-9a-f]/,'')
if cookie
if cookie.length > '000000000000000000000000'.length
@current_visitor = FunnelCake.engine.visitor_class.find_by_key(cookie)
cookies[self.class.read_inheritable_attribute(:cookie_name)] = {
:value => @current_visitor.id,
:expires => 1.year.from_now
} if @current_visitor
else
begin
@current_visitor = FunnelCake.engine.visitor_class.find(cookie)
rescue Mongo::InvalidObjectID => e
Rails.logger.info e
end
end
end
end
return @current_visitor
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_site_visitor\n @current_site_visitor ||= begin\n code = ensure_code_cookie\n GreenFlag::SiteVisitor.for_visitor_code!(code)\n end\n end",
"def visitor\n @visitor ||= user_signed_in? ? current_user : UserAnon.new(session)\n end",
"def track_visitor\n visitor_cookie_name = \... | [
"0.6747968",
"0.6712068",
"0.62937355",
"0.62856764",
"0.6272715",
"0.61715776",
"0.6121291",
"0.60851467",
"0.60616726",
"0.6061551",
"0.6045324",
"0.6008674",
"0.5947324",
"0.5932483",
"0.58395094",
"0.5770199",
"0.5742773",
"0.57132494",
"0.56777716",
"0.5668247",
"0.56604... | 0.76355803 | 0 |
Parse methods like puts | def parse_methods(line)
line.each do |token|
next unless token[:type] == :IDENTIFIER
return {
identifier: token[:value].to_sym,
value: parse_sub_methods(line - [token])
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_method(*) end",
"def puts(str)\nend",
"def method_that_says(stuff)\n\tputs (stuff)\nend",
"def puts(*args)\nend",
"def puts(*rest) end",
"def puts(*rest) end",
"def puts(*rest) end",
"def puts(*rest) end",
"def say(m); puts m; end",
"def puts\n end",
"def puts(message); end",
"def ... | [
"0.63781714",
"0.6233059",
"0.6194906",
"0.5961395",
"0.5944565",
"0.5944565",
"0.5944565",
"0.5944565",
"0.592678",
"0.5824414",
"0.5754946",
"0.5737878",
"0.5706944",
"0.57040983",
"0.56837654",
"0.56832343",
"0.56503844",
"0.56341773",
"0.56329644",
"0.55789065",
"0.557890... | 0.0 | -1 |
Parse sub methods like to_string, to_integer | def parse_sub_methods(line)
new_line = []
line.each do |token|
next unless token[:type] == :IDENTIFIER
arguments_size = 0
SUBMETHODS.each do |submethod|
next unless submethod[:ikea_name] == token[:value].to_sym
arguments_size = submethod[:arguments]
end
value = [line[line.index(token) + arguments_size]]
line -= value
line[line.index(token)] = {
identifier: token[:value].to_sym,
value: value
}
return line
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method_missing(meth, *args, &block)\n if args.empty? && !block_given? && (match = /\\Ato_(\\w+)\\Z/.match(meth.to_s))\n begin\n convert_to(match[1])\n rescue ExpressionError\n super(meth, *args, &block)\n end\n else\n super(meth, *args, &block)\n end... | [
"0.62768805",
"0.5593435",
"0.5479057",
"0.54323095",
"0.54162294",
"0.5395912",
"0.5358301",
"0.5358301",
"0.5358301",
"0.5296449",
"0.52808195",
"0.5241671",
"0.5241481",
"0.52375126",
"0.5224852",
"0.5208079",
"0.5187549",
"0.51856315",
"0.5183439",
"0.51830095",
"0.516535... | 0.5211597 | 15 |
This is used as a decider. It can return true, false or nil. This particular method ignores the digits(response), but you can use it, for example to verify a string of digits and decide the next state e.g. pin verification, credit card validity, etc. | def tired?(digits=nil)
# ignore the arg, go with your guts
(rand * 10 < 3)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate(password)\n response = {\n status: 'OK', message: ''\n }\n digits = password.split('').map(&:to_i)\n\n if is_in_sequence(digits)\n response[:status] = 'Error'\n response[:message] = \"Numbers cannot consecutively go up or down.\"\n end\n response\nend",
"def success_from(response)\n ... | [
"0.6392427",
"0.6386578",
"0.6290566",
"0.6233181",
"0.6207501",
"0.6184391",
"0.60858285",
"0.5942228",
"0.59190714",
"0.591239",
"0.59107834",
"0.5882406",
"0.5870698",
"0.5856343",
"0.58457804",
"0.58425826",
"0.58239913",
"0.5813238",
"0.57937986",
"0.57839775",
"0.577055... | 0.0 | -1 |
This is an event callback. We use this to gather the digits for future use | def collect_callback(digits=nil)
# do something, either in memory or in DB
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def consume_number; end",
"def digit; end",
"def available_digits\n @available_digits.to_a\n end",
"def number\n HookNumber.new(number_record)\n end",
"def speak_as_digits(element)\n speak_as(element, /[0-9]/, 'digits', method(:operation_speak_as_digits))\n end",
"def on_dec\n end"... | [
"0.6346942",
"0.61031765",
"0.5721756",
"0.57170177",
"0.57105786",
"0.5682282",
"0.5672521",
"0.55692613",
"0.5545136",
"0.55328053",
"0.5531873",
"0.55206746",
"0.549168",
"0.549168",
"0.5469491",
"0.5466268",
"0.545692",
"0.5451973",
"0.5434246",
"0.5434246",
"0.53769916",... | 0.5923783 | 2 |
This is an event callback. | def collect_rating(digits = nil)
# do something, either with object state or DB info.
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event; end",
"def event; end",
"def event; end",
"def callback\n\n end",
"def callback\n end",
"def callback\n\tend",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def hand... | [
"0.8080912",
"0.8080912",
"0.8080912",
"0.78127563",
"0.7773009",
"0.7536711",
"0.74571943",
"0.74571943",
"0.74571943",
"0.74571943",
"0.74571943",
"0.74571943",
"0.74571943",
"0.74571943",
"0.7390024",
"0.7196657",
"0.7196657",
"0.7137596",
"0.70711637",
"0.7008733",
"0.696... | 0.0 | -1 |
Dynamically provide a range of keys options | def num_ratings
5
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def possible_keys(key); end",
"def add_range_opts(fkey, lkey)\n @oparse.on(\"-r\", \"--range=START[:END]\", \n \"Start and optional end range\") do |r|\n\n raise \"-x and -r are mutually exclusive\" if @parser_got_range\n @parser_got_range=true\n\n unless m=/^(-?[0-9]+)(... | [
"0.6546285",
"0.62363833",
"0.62213165",
"0.6019009",
"0.594",
"0.58996177",
"0.58906305",
"0.58818734",
"0.58591413",
"0.5811829",
"0.5779865",
"0.57707435",
"0.5717811",
"0.5707581",
"0.56992894",
"0.5669388",
"0.56571734",
"0.56552714",
"0.5645073",
"0.56189317",
"0.561577... | 0.0 | -1 |
This can provide customized text to say | def greetings
"Greetings. We come in peace."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def say text\n @output.say text\n end",
"def say_that_thing_you_say\n \"#{self.name} always says: #{self.catchphrase}\"\n end",
"def say_that_thing_you_say\n \"#{self.name} always says: #{self.catchphrase}\"\n end",
"def say text\n @output.say text\n end",
"def text(*)... | [
"0.73506445",
"0.7343326",
"0.7308481",
"0.7280095",
"0.7208031",
"0.71001935",
"0.70144916",
"0.70144916",
"0.69812655",
"0.6943222",
"0.69161314",
"0.6890564",
"0.689022",
"0.6850005",
"0.68375355",
"0.68166465",
"0.67786485",
"0.67753893",
"0.6767282",
"0.6765617",
"0.6743... | 0.0 | -1 |
Suggested improvement support a custom mp3 file name | def growl
"Please listen carefully to this recorded growl"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ext_to_mp3(filename)\n\t\tfilename_without_ext = filename.gsub(/[.]\\w+$/, \"\")\n\t\tfilename_without_ext + \".mp3\"\n\tend",
"def get_filename(artist, song)\n \"#{ENCLOSURE_PATH}#{proper_filename(artist)}__#{proper_filename(song)}.mp3\"\n end",
"def mp3_url\n @mp3_url ||= url_for_format('mp3')\n ... | [
"0.73971087",
"0.70001215",
"0.69900435",
"0.69826937",
"0.69017667",
"0.6882844",
"0.6768857",
"0.67635435",
"0.67413765",
"0.6636585",
"0.6566715",
"0.6546137",
"0.6541163",
"0.65353173",
"0.6534353",
"0.6527951",
"0.6521666",
"0.64774466",
"0.6408952",
"0.6397662",
"0.6363... | 0.0 | -1 |
These are generated method for the interaction object, which are used by the view builder to create the XML response. | def says
self.current_state.sayings.map do |phrase|
if phrase.is_a?(String)
phrase.match(/^ivr/) ? I18n.t(phrase) : phrase
elsif phrase.is_a?(Symbol)
self.send(phrase)
end
end.flatten || []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @interaction = Interaction.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @interaction.to_xml }\n end\n end",
"def inspect\n values = @properties.map{|k, v| \"#{k}: #{v}\"}.join(\" \")\n ... | [
"0.5996777",
"0.58324873",
"0.5689121",
"0.56500363",
"0.56149644",
"0.5552172",
"0.5480513",
"0.54485685",
"0.54485685",
"0.54485685",
"0.54064906",
"0.5363855",
"0.5326043",
"0.5322011",
"0.53097326",
"0.5305662",
"0.52977276",
"0.5288128",
"0.5273756",
"0.52723783",
"0.526... | 0.0 | -1 |
Generated method to gather all the accepted keypresses. | def accepts
self.current_state.pressings || {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_pressed( event )\n @keys += [event.key]\n end",
"def key_inputs; end",
"def all\n scan_supported_keys\n end",
"def answer_keys\n [key]\n end",
"def possible_keys(key); end",
"def confirm_newkeys; end",
"def process_keyboard\n ACCEPTED_KEYS.each {|key|\n i... | [
"0.6258688",
"0.62388253",
"0.62344676",
"0.622095",
"0.61351645",
"0.6076193",
"0.60335",
"0.59263134",
"0.59014165",
"0.57416505",
"0.5740689",
"0.5568137",
"0.55486906",
"0.55258614",
"0.54936653",
"0.5469253",
"0.54691386",
"0.54503787",
"0.5425833",
"0.54038084",
"0.5400... | 0.5257775 | 35 |
Accessor for target_path The target_path is the path where the finalizers will put the release | def target_path
Pathname.new(config[:target_path])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def target_path\n Pathname.new(self.config[:target_path])\n end",
"def target_path(target_name)\r\n File.join(package_dir, target_name)\r\n end",
"def path\n File.join(@base, @target)\n end",
"def getPath(target)\n File.expand_path(File.join(File.dirname(__FILE__), target))\nend",
... | [
"0.7227858",
"0.6816888",
"0.6516648",
"0.6437539",
"0.636318",
"0.63157594",
"0.6267534",
"0.6256255",
"0.612292",
"0.5992524",
"0.5947253",
"0.59334385",
"0.59148294",
"0.5802213",
"0.57843894",
"0.57562286",
"0.5748186",
"0.5716268",
"0.57156",
"0.57070684",
"0.5683034",
... | 0.71371746 | 1 |
Accessor for build_path The build_path is a temporary directory where the release will be built | def build_path
Pathname.new(config[:build_path])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_path\n @build_path ||= Pathname.new(source_dir).join(data['build_path'] || './build').to_s\n end",
"def build_path\n @build_path ||= \"#{@ant_path}/#{@config[:build_name]}\"\n end",
"def build_path\n Pathname.new(self.config[:build_path]) \n end",
"def build_dir\n ... | [
"0.843737",
"0.8229959",
"0.79785204",
"0.7757712",
"0.75645447",
"0.74710155",
"0.74291223",
"0.74291223",
"0.7265817",
"0.7152494",
"0.71305054",
"0.6964996",
"0.69643474",
"0.6896351",
"0.6879736",
"0.68020535",
"0.6753839",
"0.6710013",
"0.6710013",
"0.65743065",
"0.65494... | 0.79636157 | 3 |
Accessor for source_path The source path is the root of the project | def source_path
Pathname.new(config[:source_path])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def source_path\n Pathname.new(self.config[:source_path])\n end",
"def source_path\n source[:path]\n end",
"def source_path\n File.expand_path source unless source.nil?\n end",
"def source_path; end",
"def source_dir\n @config.source_dir\n end",
"def source_root\n Fil... | [
"0.8608426",
"0.8587065",
"0.8257665",
"0.8114052",
"0.7738179",
"0.75983936",
"0.7559179",
"0.75341105",
"0.75250554",
"0.73793215",
"0.73064816",
"0.73064816",
"0.72715414",
"0.72698927",
"0.7246265",
"0.7181403",
"0.71596104",
"0.7150219",
"0.7124016",
"0.7124016",
"0.7124... | 0.8483697 | 2 |
Get the current SCM object | def scm(force = false)
return @_scm if @_scm && !force
case config[:scm]
when :git
@_scm = Release::Scm::Git.new(path: source_path)
when :fixed
@_scm = Release::Scm::Fixed.new
else
raise "Unknown SCM #{options[:scm].inspect}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scm\n @defaults[ :scm ] ||= SCM::Git.new\n end",
"def scm\n if(@scm.nil?)\n path = path_to_git\n raise GitTaskError.new(\"We don't appear to be inside of a git repository\") if path.nil?\n @scm = Git.open(path)\n end\n\n @scm\n end",
"def scm(force =... | [
"0.7458993",
"0.6901301",
"0.6887394",
"0.65891117",
"0.65846723",
"0.653226",
"0.6157386",
"0.6155567",
"0.61297804",
"0.60138744",
"0.59655905",
"0.58169913",
"0.5761971",
"0.5724984",
"0.5682817",
"0.5640998",
"0.55145156",
"0.5508112",
"0.5503778",
"0.5501113",
"0.5499637... | 0.67117935 | 3 |
Use a certain preprocessor | def use(processor, options = {})
@stack << [self.class.get_callable(processor, Roger::Release::Processors.map), options]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess(text, defines={})\n defines = defines.dup\n result = []\n active_stack = []\n active = true\n text.each_line do |line|\n case line\n when /^#\\s*define\\s+(\\w+)\\s+(\\w*)\\s*$/\n defines[$1] = $2 if active\n when /^#\\s*if\\s+(\\w+)\\s*$/\n active_stack.p... | [
"0.63092464",
"0.6140463",
"0.60429186",
"0.60429186",
"0.5984884",
"0.5687321",
"0.5481028",
"0.54745466",
"0.54678714",
"0.54376733",
"0.5428714",
"0.53935945",
"0.5370338",
"0.53387177",
"0.5323118",
"0.52336496",
"0.5167644",
"0.51615936",
"0.5161245",
"0.5158813",
"0.508... | 0.0 | -1 |
Write out the whole release into a directory, zip file or anything you can imagine finalize can be called multiple times, it just will run all of them. The default finalizer is :dir | def finalize(finalizer, options = {})
@stack << [self.class.get_callable(finalizer, Roger::Release::Finalizers.map), options]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write()\n entries = Dir.entries(@inputDir); entries.delete(\".\"); entries.delete(\"..\"); entries.delete(\"yamproject.json\"); entries.delete(\".DS_Store\")\n io = Zip::File.open(@outputFile, Zip::File::CREATE);\n writeEntries(entries, \"\", io)\n io.close();\n end",
"def write\n FileUtils.r... | [
"0.6660286",
"0.63722944",
"0.6353809",
"0.63394934",
"0.6303561",
"0.6303561",
"0.6293844",
"0.62638694",
"0.6195404",
"0.6183084",
"0.61787283",
"0.60590243",
"0.6001356",
"0.59868073",
"0.5857162",
"0.5848178",
"0.58416617",
"0.58103895",
"0.5796512",
"0.5764575",
"0.57645... | 0.0 | -1 |
Files to clean up in the build directory just before finalization happens | def cleanup(pattern)
@stack << Cleaner.new(pattern)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup\n remove_files(TEST_INPUT_DIR)\n remove_files(TEST_OUTPUT_DIR)\nend",
"def clean\n #rm_r(srcdir)\n rm_r(blddir)\n #rm_r(libdir)\n end",
"def cleanup(build_dir)\n build_dir = Pathname(build_dir)\n tmp_build_dir = Pathname('.temp-build')\n\n # copy over files we need to keep\n ... | [
"0.74821997",
"0.73111963",
"0.73092467",
"0.7293423",
"0.72630394",
"0.7204535",
"0.7179331",
"0.71490556",
"0.71440876",
"0.7125522",
"0.7108553",
"0.7068123",
"0.7068123",
"0.703793",
"0.703793",
"0.7036852",
"0.7023799",
"0.7000978",
"0.6981148",
"0.68912953",
"0.6888974"... | 0.0 | -1 |
Generates a banner if a block is given, or returns the currently set banner. It automatically takes care of adding comment marks around the banner. The default banner looks like this: ======================= = Version : v1.0.0 = = Date : 20120620 = ======================= | def banner(options = {}, &_block)
options = {
comment: :js
}.update(options)
if block_given?
@_banner = yield.to_s
elsif !@_banner
@_banner = default_banner.join("\n")
end
if options[:comment]
comment(@_banner, style: options[:comment])
else
@_banner
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def banner(options = {}, &block)\n options = {\n :comment => :js\n }.update(options)\n \n if block_given?\n @_banner = yield.to_s\n elsif !@_banner\n banner = []\n banner << \"Version : #{self.scm.version}\"\n banner << \"Date : #{self.scm.date.strftime(... | [
"0.78166753",
"0.70299935",
"0.6992959",
"0.6880235",
"0.68714345",
"0.68714345",
"0.6574665",
"0.656644",
"0.6546895",
"0.63553697",
"0.62773603",
"0.6258911",
"0.6249515",
"0.62452143",
"0.62332374",
"0.621797",
"0.62174773",
"0.620887",
"0.6182099",
"0.6050421",
"0.603197"... | 0.7765645 | 1 |
Actually perform the release | def run!
project.mode = :release
# Validate paths
validate_paths!
# Extract mockup
copy_source_path_to_build_path!
validate_stack!
# Run stack
run_stack!
# Cleanup
cleanup! if config[:cleanup_build]
ensure
project.mode = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def release\n end",
"def release\n end",
"def release\n end",
"def release(resource); end",
"def release!\n @ec.release_temp self\n end",
"def release\n locked? && release!\n end",
"def release\n # @invObj.releaseObj(self)\n end",
"def release(number)\n ... | [
"0.8604901",
"0.85713875",
"0.85713875",
"0.81487435",
"0.7855286",
"0.7627473",
"0.7470292",
"0.744611",
"0.7424807",
"0.7247099",
"0.7226407",
"0.72063375",
"0.72024286",
"0.72024286",
"0.72024286",
"0.72024286",
"0.7184828",
"0.71420467",
"0.71230716",
"0.71191806",
"0.709... | 0.0 | -1 |
============== = The runway = ============== Checks if build path exists (and cleans it up) Checks if target path exists (if not, creates it) | def validate_paths!
ensure_clean_build_path!
ensure_existing_target_path!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_paths!\n if self.build_path.exist?\n log self, \"Cleaning up previous build \\\"#{self.build_path}\\\"\"\n rm_rf(self.build_path)\n end\n \n if !self.target_path.exist?\n log self, \"Creating target path \\\"#{self.target_path}\\\"\"\n mkdir self.targe... | [
"0.6942509",
"0.6190765",
"0.616429",
"0.61332756",
"0.59299403",
"0.5907227",
"0.5828116",
"0.5824962",
"0.57918704",
"0.57817394",
"0.57297724",
"0.57290787",
"0.5717126",
"0.56875616",
"0.56801456",
"0.5677445",
"0.56576836",
"0.56522954",
"0.5643231",
"0.56342417",
"0.563... | 0.6355515 | 1 |
Checks if the project will be runned If config[:blank] is true it will automatically add Mockup processor | def validate_stack!
return if config[:blank]
ensure_mockup_processor_in_stack!
ensure_dir_finalizer_in_stack!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pre_setup_suite()\n @cfg['pre_setup'] =\"defined\"\n return true\n end",
"def setup\n true\n end",
"def setup?\n @setup\n end",
"def configured?; false; end",
"def just_set_up?\n AppConfig[:just_set_up] == true\n end",
"def first_run?\n not File.exists? '/boot/config/.... | [
"0.65366465",
"0.60218596",
"0.5975327",
"0.59612125",
"0.59197545",
"0.584014",
"0.5695137",
"0.56768423",
"0.56666774",
"0.5665043",
"0.56503534",
"0.5592042",
"0.5588963",
"0.55881464",
"0.5581252",
"0.5556007",
"0.5543677",
"0.55401367",
"0.55256236",
"0.5511515",
"0.5508... | 0.52991086 | 54 |
Find a processor in the stack | def find_in_stack(klass)
@stack.find { |(processor, _options)| processor.class == klass }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_processor_by_dataset(dataset)\n processors.values.detect { |p| p.datasets&.include? dataset }\n end",
"def fetch(processor_name)\n idx = processors.index {|processor| processor.name.equal?(processor_name)}\n idx or raise(UnknownProcessor.new(processor_name))\n end",
"def loc... | [
"0.63662827",
"0.62281543",
"0.6001952",
"0.56400645",
"0.5556072",
"0.5550804",
"0.5449586",
"0.5342971",
"0.5336633",
"0.52724665",
"0.5239903",
"0.5185863",
"0.5110354",
"0.5093909",
"0.50866336",
"0.50786215",
"0.50699306",
"0.50662357",
"0.5063109",
"0.50586224",
"0.5004... | 0.7201373 | 0 |
Let's make our own `each` method on AnimalSet. Now, we can have a set of animals and get one at a time. Because the animals is ultimately just an array (look at the initialize method), we're going to cheat a little bit and just take a block to AnimalSet's each method and then | def each(&block)
@animals.each(&block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each(&block)\n to_set.each(&block)\n end",
"def each_set\n \n end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&blk)\n to_a.each(&blk)\n end",
"def each(&blk)\r... | [
"0.74520004",
"0.6771321",
"0.6714319",
"0.6714319",
"0.6714319",
"0.6714319",
"0.6714319",
"0.6714319",
"0.6712648",
"0.6606891",
"0.66025525",
"0.66025525",
"0.6601737",
"0.65995485",
"0.6589604",
"0.6571258",
"0.6534822",
"0.65341634",
"0.6518419",
"0.65175265",
"0.6513707... | 0.7883949 | 0 |
goal ideas: number of consecutive problems solved number of problems solved number of problems solved by language number of problems with an explanation | def initialize
require 'bcrypt'
super
@options.banner = "Usage: #{__FILE__} goals [options]"
@options.on('-i', '--interactive', "Updates display in real-time") do |o|
@interactive = true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def n_solved_problems\n\t\tn_solved_problems=self.user_problem_relations.select{|r| (r.solved_during_free || r.solved_during_premium)}.count\n\tend",
"def getNumberOfSolutions; @solutions.length; end",
"def solve\n t = IO.read( 'resources/0089_roman.txt' ).split.map do |line|\n n = ProjectEuler::Roman.... | [
"0.63234204",
"0.6315762",
"0.61288184",
"0.5832933",
"0.58299303",
"0.5805946",
"0.57894576",
"0.57882416",
"0.5771115",
"0.5752342",
"0.5688124",
"0.56875163",
"0.56603605",
"0.56595415",
"0.56519115",
"0.562449",
"0.5593997",
"0.55732644",
"0.55663335",
"0.55593926",
"0.55... | 0.0 | -1 |
Logs in the given user. | def log_in(user)
session[:user_id] = user.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_login(user)\n click_log_in\n fill_login_credentials(user)\n end",
"def login_as(user)\n login(users(user).email, users(user).password)\n end",
"def sign_in(user)\n login_as user\n end",
"def login(user=:joerg)\r\n login_as(user)\r\n end",
"def log_user_in(user)\n note \"W... | [
"0.79255563",
"0.7896003",
"0.7872409",
"0.7774304",
"0.7651823",
"0.7573199",
"0.7571553",
"0.756544",
"0.75425416",
"0.7480216",
"0.74682415",
"0.74503946",
"0.7436136",
"0.74269396",
"0.7387112",
"0.73547155",
"0.7344561",
"0.73239136",
"0.7320213",
"0.73145443",
"0.730544... | 0.70581007 | 55 |
Returns the current loggedin user (if any). | def current_user
if session[:user_id]
@current_user ||= User.find_by(id: session[:user_id])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_user\n if session[:user_id]\n return User.find(session[:id])\n else\n return nil\n end\n end",
"def current_user\n if session[:user_id]\n User.find(session[:user_id])\n else\n nil\n end\n end",
"def current_user\n return unless session[:user_id... | [
"0.85960984",
"0.8593657",
"0.855797",
"0.8545853",
"0.8534344",
"0.8497545",
"0.847914",
"0.8460573",
"0.8457271",
"0.84556973",
"0.84472865",
"0.8442264",
"0.8441092",
"0.84366953",
"0.8400402",
"0.83765614",
"0.8368829",
"0.8337418",
"0.8337418",
"0.8314651",
"0.8311652",
... | 0.0 | -1 |
Returns true if the user is logged in, false otherwise. | def logged_in?
!current_user.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end",
"def logged_in?\n user._logged_in?\n end",
"def logged_in?\n if session[:username]\n if session[:logged_in?]\n return true\n end\n else\n r... | [
"0.9082417",
"0.8764097",
"0.87552106",
"0.8718715",
"0.86894006",
"0.86498255",
"0.86469626",
"0.86372185",
"0.8631328",
"0.86285406",
"0.86285406",
"0.8582609",
"0.85669243",
"0.85613596",
"0.85613596",
"0.8551865",
"0.85491496",
"0.85443276",
"0.85409296",
"0.8539988",
"0.... | 0.0 | -1 |
go through all the line of the column of the worksheet | def go_through_all_the_lines(worksheet_key)
data = []
worksheet = get_worksheet(worksheet_key)
# create an array called data in order to store all the emails
worksheet.rows.each do |row|
# for each of line of the row we add it into the "data array"
data << row[1].gsub(/[[:space:]]/, '')
end
return data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_column\n end",
"def each_col\n cols.each\n end",
"def increase_columns(column)\n @sheet_data.each do |r|\n r.size.upto(column) do\n r << nil\n end\n end\n end",
"def each_row\n end",
"def steps\n @columns * @rows\n end",
"def each\n @reaktor_rows\n e... | [
"0.68509716",
"0.68227506",
"0.6151273",
"0.60603017",
"0.605372",
"0.5941241",
"0.59393305",
"0.59317684",
"0.59093803",
"0.58688396",
"0.58553386",
"0.5827637",
"0.5761838",
"0.57608",
"0.5758982",
"0.5753964",
"0.57388496",
"0.5709712",
"0.5680023",
"0.56694955",
"0.565800... | 0.58484954 | 11 |
send email methode (and the key as variable) | def send_gmail_to_listing(worksheet_key)
# first we connect to gmail with the $gmail variable (where our logs are stored)
$gmail
#we go through each email adresse
# send we send (deliver) an email with subject + body
go_through_all_the_lines(worksheet_key).each do |email|
$gmail.deliver do
to email
subject "The Hacking Project" # write your subject here
text_part do
body "je suis élève à une formation de code gratuite, ouverte à tous, sans restriction géographique, ni restriction de niveau. La formation s'appelle The Hacking Project (http://thehackingproject.org/). Nous apprenons l'informatique via la méthode du peer-learning : nous faisons des projets concrets qui nous sont assignés tous les jours, sur lesquel nous planchons en petites équipes autonomes. Le projet du jour est d'envoyer des emails à nos élus locaux pour qu'ils nous aident à faire de The Hacking Project un nouveau format d'éducation gratuite.
Nous vous contactons pour vous parler du projet, et vous dire que vous pouvez ouvrir une cellule à {townhall_name}, où vous pouvez former gratuitement 6 personnes (ou plus), qu'elles soient débutantes, ou confirmées. Le modèle d'éducation de The Hacking Project n'a pas de limite en terme de nombre de moussaillons (c'est comme cela que l'on appelle les élèves), donc nous serions ravis de travailler avec {townhall_name} !
Charles, co-fondateur de The Hacking Project pourra répondre à toutes vos questions : 06.95.46.60.80 " #write your message here
content_type 'text/plain; charset=UTF-8'
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_email\n @professor = params[:professor]\n @url = 'http://localhost:3000/sessions/new'\n mail(to: @professor.email, subject: 'Saudações querido(a) professor(a)!')\n end",
"def konsalt_mail params\n build_params params\n send_email t('emails.konsalta_mail.subject')\n end",
"def send_key... | [
"0.6961",
"0.66383123",
"0.6499136",
"0.63284934",
"0.6312559",
"0.6283971",
"0.6281886",
"0.6267166",
"0.6248345",
"0.62237436",
"0.62055105",
"0.6198616",
"0.6192875",
"0.6170979",
"0.61206776",
"0.6116539",
"0.6114065",
"0.6113948",
"0.6109882",
"0.60690725",
"0.60640424",... | 0.5921531 | 37 |
For all responses in this controller, return the CORS access control headers. | def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS'
headers['Access-Control-Max-Age'] = "1728000"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def response_headers(env)\n cors_origin(env) ? cors_headers(env) : {}\n end",
"def cors_set_access_control_headers\n headers['Access-Control-Allow-Origin'] = '*'\n headers['Access-Control-Expose-Headers'] = 'ETag'\n headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS'... | [
"0.7619958",
"0.7606048",
"0.7606048",
"0.75027907",
"0.7487557",
"0.7425582",
"0.74099994",
"0.74074537",
"0.7405096",
"0.7394521",
"0.73921406",
"0.7384172",
"0.73771304",
"0.7372764",
"0.7372764",
"0.7372764",
"0.73598355",
"0.7350838",
"0.7333332",
"0.7333332",
"0.728667"... | 0.7235826 | 53 |
If this is a preflight OPTIONS request, then shortcircuit the request, return only the necessary headers and return an empty text/plain. | def cors_preflight_check
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS'
headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-Prototype-Version'
headers['Access-Control-Max-Age'] = '1728000'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_options\n head(:ok) if request.request_method == \"OPTIONS\"\n end",
"def cors_preflight_check\n if request.method == 'OPTIONS'\n headers['Access-Control-Allow-Origin'] = '*'\n headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS'\n headers['Access-Control-Allow-... | [
"0.76127136",
"0.74680173",
"0.74091864",
"0.74091864",
"0.7308189",
"0.72889477",
"0.7264628",
"0.7240284",
"0.7235438",
"0.721866",
"0.7217812",
"0.7214809",
"0.7213254",
"0.7213254",
"0.7213254",
"0.7213254",
"0.7213254",
"0.7213254",
"0.7213254",
"0.71998173",
"0.7199732"... | 0.6352907 | 66 |
Users Controller HTTP Request Methods Returns a list of all Users GET /users GET /users.json | def index
@users = User.all
render json: @users
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users\n get('get_users')\n end",
"def list_users\n self.class.get('/users')\n end",
"def GetUsers params = {}\n\n params = params.merge(path: 'users.json')\n APICall(params)\n\n end",
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def users(par... | [
"0.8286488",
"0.8226217",
"0.8200115",
"0.80941004",
"0.7992455",
"0.79266506",
"0.79173476",
"0.7858174",
"0.7848147",
"0.7839271",
"0.781122",
"0.7797733",
"0.778675",
"0.77834505",
"0.7778145",
"0.77396375",
"0.7721704",
"0.76198006",
"0.7615688",
"0.7612956",
"0.7581192",... | 0.0 | -1 |
Returns the user with the specific ID GET /users/1 GET /users/1.json | def show
@user = User.find(params[:id])
render json: @user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show(id)\n response = request(:get, \"/users/#{id}.json\")\n response[\"user\"]\n end",
"def show(id)\n response = request(:get, \"/users/#{id}.json\")\n response.first[1]\n end",
"def get_user id, options={}, headers={}\n @connection.get \"users/#{id}.json\", options, he... | [
"0.8705296",
"0.8546368",
"0.853986",
"0.8514078",
"0.8329413",
"0.82746834",
"0.8237801",
"0.81001085",
"0.80971336",
"0.80551195",
"0.8019696",
"0.8013668",
"0.8001796",
"0.7932169",
"0.792641",
"0.7896633",
"0.78872395",
"0.7872276",
"0.7864672",
"0.7859307",
"0.7845869",
... | 0.72758406 | 77 |
Creates a new user with data in the POST body POST /users POST /users.json | def create
@user = User.new(user_params(params))
if @user.save
render json: @user, status: :created, location: @user
else
render json: @user.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end",
"def create\n user = User.new(user_params)\n if user.save\n render json: user\n else\n render json: {errors: \"Cannot create user\"}, :status => 420\n... | [
"0.837674",
"0.83123714",
"0.83068573",
"0.8284226",
"0.8262974",
"0.82519037",
"0.82277703",
"0.81871957",
"0.8186128",
"0.816766",
"0.8167242",
"0.81608427",
"0.8152632",
"0.8146575",
"0.81424874",
"0.81369233",
"0.8123216",
"0.8115891",
"0.81088287",
"0.81073755",
"0.80881... | 0.80172586 | 32 |
Updates a user with data in the PUT body PATCH/PUT /users/1 PATCH/PUT /users/1.json | def update
@user = User.find(params[:id])
if @user.update(user_params(params))
head :no_content
else
render json: @user.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n @user.update(user_params_update)\n json_response(@user)\n end",
"def update\n @user = current_user\n if @user.update(update_user_params)\n ... | [
"0.8303187",
"0.8248406",
"0.82054526",
"0.81798065",
"0.8134207",
"0.809614",
"0.80682826",
"0.80568343",
"0.8042508",
"0.8020912",
"0.799587",
"0.799587",
"0.79676855",
"0.79637045",
"0.796057",
"0.7959517",
"0.7951013",
"0.7947392",
"0.7942937",
"0.79337895",
"0.79263794",... | 0.0 | -1 |
Deletes the user with the specific ID DELETE /users/1 DELETE /users/1.json | def destroy
@user = User.find(params[:id])
@user.destroy
head :no_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end",
"def delete user_id, options={}, headers={}\n @connection.delete \"users/#{user_id}.json\", options, headers\n ... | [
"0.8989289",
"0.8844713",
"0.86481804",
"0.8501752",
"0.84544957",
"0.83500093",
"0.8301986",
"0.82395816",
"0.81958026",
"0.81577766",
"0.81554115",
"0.81507814",
"0.81396246",
"0.8139492",
"0.8123947",
"0.8087602",
"0.808041",
"0.8075921",
"0.8057377",
"0.80557734",
"0.8050... | 0.0 | -1 |
Returns a list of specified user's splatts GET /users/splatts/1 GET /users/splatts/1.json | def splatts
@user = User.find(params[:id])
render json: @user.splatts
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def splatts\n \t@user = User.find(params[:id])\n \t\n \trender json: @user.splatts\n end",
"def splatts_feed\n \t@feed = Splatt.find_by_sql(\"SELECT user_id, body, created_at FROM splatts JOIN follows ON follows.followed_id = splatts.user_id WHERE follows.follower_id = '#{params[:id]}' ORDER BY splatts.crea... | [
"0.84186566",
"0.62961507",
"0.6205785",
"0.6168993",
"0.60175306",
"0.5870528",
"0.5870528",
"0.5860279",
"0.58402807",
"0.57501084",
"0.5745007",
"0.57437515",
"0.5723455",
"0.5719962",
"0.57161933",
"0.56872386",
"0.5676178",
"0.5630771",
"0.5630121",
"0.5619994",
"0.56191... | 0.84677845 | 0 |
Returns the specified user's "news feed" GET /users/splatts_feed/1 | def splatts_feed
@feed = Splatt.find_by_sql("SELECT splatts.user_id, splatts.body, splatts.created_at FROM splatts JOIN follows ON follows.followed_id = splatts.user_id WHERE follows.follower_id = #{params[:id]} ORDER BY splatts.created_at")
render json: @feed
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def newsfeed\n check_auth :newsfeed\n \n response = connection.post do |req|\n req.url '/user/newsfeed'\n req.body = { :format => @format }\n end\n response\n end",
"def feed\n get '/users/self/feed', auth_params\n end",
"def rss\n\n # Get the specified ... | [
"0.73320335",
"0.71323335",
"0.7036603",
"0.7031902",
"0.7019047",
"0.6747547",
"0.6729413",
"0.67033523",
"0.6613464",
"0.6570303",
"0.6514249",
"0.6497581",
"0.6497581",
"0.6497581",
"0.644843",
"0.643915",
"0.64156926",
"0.6384068",
"0.63435745",
"0.63391554",
"0.63391554"... | 0.6777519 | 5 |
Creates a follower/followed rel between users POST /users/follows | def add_follows
#params[:id] is user who follows
#params[:follows_id] is user to be followed
#make follower
@follower = User.find(params[:id])
#make followed
@followed = User.find(params[:follows_id])
if
@follower.follows << @followed
head :no_content
else
render json: @follower.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def follow!(user)\n relationships.create!(:followed_id => user.id)\n end",
"def follow(user_id)\n followee_relationships.create(followee_id: user_id)\n end",
"def follow(user)\n active_relationships.create(followed_id: user.id)\n end",
"def follow(user)\n\tout_followings.create(to_id: user.id)\ne... | [
"0.80411303",
"0.7941248",
"0.7911175",
"0.77704346",
"0.7770313",
"0.77614915",
"0.772184",
"0.76744205",
"0.76594657",
"0.76553077",
"0.76553077",
"0.76553077",
"0.76553077",
"0.76553077",
"0.76371175",
"0.7634871",
"0.76297414",
"0.762898",
"0.7619792",
"0.7587638",
"0.757... | 0.75329614 | 30 |
Returns a list of the users followed by the user GET /users/follow/[:id] | def show_follows
@user = User.find(params[:id])
render json: @user.follows
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_followed_users(user_id, params = {})\n get(\"/v1/users/#{user_id}/followed_users\", params)\n end",
"def user_follows user_id, pages: 1\n url = API + \"users/#{user_id}/follows?access_token=\" + @access_token\n pages.times do\n get(url)['data'].map do |user|\n @user_ids << user... | [
"0.80836886",
"0.80478525",
"0.799923",
"0.79600894",
"0.7885907",
"0.7885907",
"0.7885907",
"0.7885399",
"0.7835323",
"0.7796355",
"0.77958846",
"0.77817684",
"0.77735734",
"0.776926",
"0.7746403",
"0.77456397",
"0.77456397",
"0.7725664",
"0.7721697",
"0.77054805",
"0.770146... | 0.76849973 | 22 |
Returns a list of the users follow the specified user GET /users/follower/[:id] | def show_followers
@user = User.find(params[:id])
render json: @user.followed_by
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_followed_users(user_id, params = {})\n get(\"/v1/users/#{user_id}/followed_users\", params)\n end",
"def followers(user_id = nil)\n twitter_request do\n logger.info \"Get followers of #{user_id || 'me'}\"\n client.follower_ids(user_id).take(5000)\n end\n end",
"def followers(u... | [
"0.84300786",
"0.81395066",
"0.812883",
"0.80016524",
"0.7900078",
"0.7899384",
"0.78491586",
"0.7823466",
"0.7816126",
"0.7796465",
"0.7781863",
"0.77795184",
"0.77795184",
"0.7764248",
"0.77571243",
"0.77571243",
"0.77571243",
"0.7756899",
"0.7745759",
"0.7743099",
"0.77430... | 0.7648264 | 28 |
causes user with id1 to unfollow the user with id2 DELETE | def delete_follows
@follower = User.find(params[:id])
@followed = User.find(params[:follows_id])
@follower.follows.delete(@followed)
head :no_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unfollow(other_user_id)\n \tuser_to_unfollow = User.find_by(id: other_user_id)\n active_relationships.find_by(followed_id: user_to_unfollow.id).destroy\n end",
"def unfollow(other_user)\n \tactive_relationships.find_by(followed_id: other_user.id).destroy\n \tend",
"def unfollow!(other_user)\n ... | [
"0.8186295",
"0.7986248",
"0.79437536",
"0.79437536",
"0.79437536",
"0.79437536",
"0.79437536",
"0.7936696",
"0.79340196",
"0.78898203",
"0.78401005",
"0.7838987",
"0.7838987",
"0.7838987",
"0.782432",
"0.782432",
"0.782432",
"0.776968",
"0.7761406",
"0.7756433",
"0.774717",
... | 0.7006976 | 58 |
GET /admin_panels GET /admin_panels.json | def index
@experiments = Experiment.where(pend_status: [0])
@experiments_wait = Experiment.where(pend_status: [1])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @panels = Panel.all\n end",
"def admin_panel_params\n params[:admin_panel]\n end",
"def set_admin_panel\n @admin_panel = AdminPanel.find(params[:id])\n end",
"def index\n @port_panels = PortPanel.all\n end",
"def index\n @collections = Rack::WebProfiler::Model::Co... | [
"0.6984211",
"0.6706471",
"0.6646405",
"0.65596354",
"0.6087478",
"0.60628635",
"0.6054905",
"0.6020001",
"0.6016398",
"0.58363056",
"0.5819224",
"0.57761025",
"0.5737134",
"0.5718471",
"0.5699787",
"0.56658864",
"0.56512755",
"0.56453633",
"0.5644101",
"0.56278944",
"0.56216... | 0.0 | -1 |
GET /admin_panels/1 GET /admin_panels/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @panels = Panel.all\n end",
"def set_admin_panel\n @admin_panel = AdminPanel.find(params[:id])\n end",
"def admin_panel_params\n params[:admin_panel]\n end",
"def index\n @port_panels = PortPanel.all\n end",
"def show_panel\n @tab_name = params[:panel_name]\n @pane... | [
"0.69977415",
"0.68487227",
"0.66271675",
"0.6569947",
"0.6191715",
"0.6141695",
"0.6110992",
"0.6065194",
"0.59664947",
"0.5952652",
"0.59156317",
"0.5851803",
"0.5850464",
"0.5832145",
"0.58181256",
"0.5817692",
"0.57961076",
"0.5779452",
"0.57725435",
"0.5746137",
"0.57455... | 0.0 | -1 |
POST /admin_panels POST /admin_panels.json | def create
@admin_panel = AdminPanel.new(admin_panel_params)
respond_to do |format|
if @admin_panel.save
format.html { redirect_to @admin_panel, notice: 'Admin panel was successfully created.' }
format.json { render action: 'show', status: :created, location: @admin_panel }
else
format.html { render action: 'new' }
format.json { render json: @admin_panel.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @panel = Panel.new(params[:panel])\n\n respond_to do |format|\n if @panel.save\n format.html { redirect_to(admin_panel_path(@panel), :notice => 'Panel was successfully created.') }\n format.xml { render :xml => @panel, :status => :created, :location => @panel }\n else\n ... | [
"0.6527788",
"0.63824564",
"0.633019",
"0.6245982",
"0.62453824",
"0.5860257",
"0.58516514",
"0.579617",
"0.5777765",
"0.57460743",
"0.57059425",
"0.5699958",
"0.5649252",
"0.5623576",
"0.56196934",
"0.55935884",
"0.5406349",
"0.5383279",
"0.53630465",
"0.5353849",
"0.534657"... | 0.7130741 | 0 |
PATCH/PUT /admin_panels/1 PATCH/PUT /admin_panels/1.json | def update
respond_to do |format|
if @admin_panel.update(admin_panel_params)
format.html { redirect_to @admin_panel, notice: 'Admin panel was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @admin_panel.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @panel = Panel.find(params[:id])\n\n respond_to do |format|\n if @panel.update_attributes(params[:panel])\n format.html { redirect_to(admin_panel_path(@panel), :notice => 'Panel was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render ... | [
"0.6814441",
"0.6558909",
"0.6390522",
"0.6368118",
"0.6266316",
"0.60912967",
"0.6084242",
"0.60687673",
"0.5981208",
"0.5948328",
"0.5786139",
"0.5765855",
"0.57264185",
"0.57002145",
"0.56980145",
"0.56680197",
"0.5658721",
"0.5613816",
"0.561247",
"0.55899686",
"0.5580736... | 0.7056478 | 0 |
DELETE /admin_panels/1 DELETE /admin_panels/1.json | def destroy
@admin_panel.destroy
respond_to do |format|
format.html { redirect_to admin_panels_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @panel = Panel.find(params[:id])\n @panel.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_panels_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @panel = Panel.find(params[:id])\n @panel.destroy\n\n respond_to do |format|\n fo... | [
"0.7414868",
"0.70485306",
"0.689241",
"0.6883058",
"0.6851572",
"0.68437153",
"0.6747899",
"0.66987664",
"0.667577",
"0.6669158",
"0.6649219",
"0.65649974",
"0.6553565",
"0.6524404",
"0.64714277",
"0.6470395",
"0.64145106",
"0.6414252",
"0.639615",
"0.6342583",
"0.6328403",
... | 0.77658314 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_admin_panel
@admin_panel = AdminPanel.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 admin_panel_params
params[:admin_panel]
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 |
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. | def two_sum(nums, target)
result = []
nums.each_with_index do |num, idx|
find_num = target - num
result = [idx, nums.index(find_num)] if nums.include?(find_num) && nums.index(find_num) != idx
return result if result.length > 0
end
if result.length == 0
return "Target sum not found in array"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve(nums, target)\n nums.each_with_index do |e, i|\n nums.each_with_index do |e_, i_|\n return [i, i_] if ((e + e_ == target) && (i != i_))\n end\n end\nend",
"def two_sum(nums, target)\n target_indexes = []\n nums.each_with_index do |primary, index|\n nums.each_with_index do |num... | [
"0.79458165",
"0.7920071",
"0.778021",
"0.7730683",
"0.76339716",
"0.7541881",
"0.75198734",
"0.75039226",
"0.7478158",
"0.747538",
"0.74371535",
"0.7429129",
"0.7428328",
"0.7404742",
"0.73965514",
"0.7393406",
"0.7382433",
"0.7366243",
"0.7348411",
"0.733666",
"0.7316211",
... | 0.7373319 | 17 |
current method of printing tree | def printlewis(node)
puts node.to_s + " ="
if node.nodes?
temp = Array.new
node.nodes.each { |n|
if n == nil
puts ":"
elsif n == node.parent
puts n
elsif !temp.include?(n)
temp << n
puts n
else
puts n
end
}
if !temp.empty?
temp.each { |n|
puts "========"
printlewis(n)
}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_tree\n ''\n end",
"def printTree()\n def pTree(node, i)\n puts node.toString i\n node.children.each do|child|\n pTree(child, i+1)\n end\n end\n pTree(@root, 0)\n end",
"def print_tree(tree)\n return \"-\" if tree.nil?\n puts \"#{tree.value}: \"\n print \"Left... | [
"0.83595693",
"0.79416937",
"0.77512246",
"0.75878114",
"0.75693196",
"0.7517739",
"0.73786217",
"0.735212",
"0.73361164",
"0.72806823",
"0.7255799",
"0.7239917",
"0.71538436",
"0.7136661",
"0.7135993",
"0.7069136",
"0.70629543",
"0.7049791",
"0.70478374",
"0.7041523",
"0.701... | 0.66395026 | 62 |
old method of print tree (uses header() ) | def printnodes(node, level)
header(level)
puts node
if node.nodes?
temp = Array.new
node.nodes.each { |n|
if n == nil
header(level + 1)
puts ":"
elsif n == node.parent
header(level + 1)
puts node
elsif !temp.include?(n)
temp << n
else
header(level + 1)
puts node
end
}
if !temp.empty?
temp.each { |n|
printnodes(n, level + 1)
}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_tree\n ''\n end",
"def print_tree(out = $stdout)\n out.puts \"## Class: #{name}\"\n out.puts \" Visible Name: #{visible_name}\"\n out.puts \" Description : #{description}\"\n tables.each do |table|\n table.print_tree(out)\n end\n end",
"def p... | [
"0.7520265",
"0.73511225",
"0.7191661",
"0.7166378",
"0.70896465",
"0.70646954",
"0.70571697",
"0.6942813",
"0.6904817",
"0.6821833",
"0.6818737",
"0.6801423",
"0.6776815",
"0.675557",
"0.67255574",
"0.6571123",
"0.65693665",
"0.6549814",
"0.6548929",
"0.65363294",
"0.6532557... | 0.68202424 | 10 |
function that fixes bonds in the structure | def fix(node, charge)
# if this node has any children, fix them
if node.next?
# only fix the children that are elements
node.nodes.compact.each { |n|
fix(n, charge)
}
end
# if this element is not the root, and the formal charge has still not been met for both the current element and the parent, make a bond between the current element and its parent
while !node.root? && node.formal_charge != 0
if node.parent.next?
node.next = node.parent
node.parent.next = node
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fix_bikes\n @bikes.each { |bike| bike.working = true }\n end",
"def basic_split(*bonds)\n if bonds.size > 0\n delete_and_restore_bonds(*bonds) do |mol|\n mol.ob.separate.map(&:upcast)\n end\n else\n self.ob.separate.map(&:upcast)\n end\n end",
"def ... | [
"0.606688",
"0.54154354",
"0.52664775",
"0.52664775",
"0.5240525",
"0.52170265",
"0.5197726",
"0.5197726",
"0.5184201",
"0.5111774",
"0.5095374",
"0.5094876",
"0.5085245",
"0.5072558",
"0.5064278",
"0.50623107",
"0.50543255",
"0.49761108",
"0.49743333",
"0.49716952",
"0.49694... | 0.5371729 | 2 |
generates lewis structure, then checks the structure to see if it is correct | def lewis(elements, charge)
# moves all hydrogens from element array to the end, so the core elements can be dealt with
hydrogens = Array.new
elements.delete_if { |element|
if element == "H"
hydrogens << "H"
end
}
if !hydrogens.empty?
elements << hydrogens
end
elements.flatten!
# depending on how many different elements there are (uniq), the structure is made differently
lewistype = elements.uniq.length
case lewistype
# if there is only one element in the compound (ie diatomic, etc)
# bond each element to each other
when 1
root = cur = Element.new(elements.shift, nil)
while !elements.empty?
cur = cur.next = Element.new(elements.shift, cur)
end
fix(root, charge)
# if there are 2 elements in the compound, take the least electronegative and make it the central atom
# attach all other elements onto the central atom
when 2
root = cur = Element.new(elements.shift, nil)
while !elements.empty?
cur.next = Element.new(elements.shift, cur)
end
fix(root, charge)
end
# prints structure
printlewis(root)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_basic_generation\n lf = LinuxFortune.generate\n assert !lf.nil? # fortune should be present\n assert !lf.body.nil? && !lf.body.empty? # body should be present\n assert !lf.source.nil? && !lf.source.empty? # source should be present\n end",
"def check_create_l... | [
"0.602283",
"0.5786843",
"0.5420919",
"0.5378987",
"0.53750634",
"0.53115386",
"0.52449715",
"0.5235955",
"0.5201291",
"0.5135546",
"0.5116663",
"0.51126945",
"0.5069255",
"0.505662",
"0.5051854",
"0.5047134",
"0.50461906",
"0.50410455",
"0.5040217",
"0.5039712",
"0.50251234"... | 0.5221472 | 8 |
Call the method directors_database to retrieve the NDS | def pretty_print_nds(nds)
# Change the code below to pretty print the nds with pp
pp nds
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @dns = Dn.all\n end",
"def db_ddns_access(data={})\n return nil if data.empty? || (!data.has_key?(:id) && !data.has_key?(:device_id) && !data.has_key?(:ip_address) && !data.has_key?(:full_domain))\n \n where_data = data.clone\n\n if data.has_key?(:full_domain) then\n full_domain ... | [
"0.5962282",
"0.5917655",
"0.573061",
"0.573061",
"0.5696976",
"0.5647392",
"0.5623889",
"0.56018966",
"0.5586423",
"0.55815876",
"0.55814934",
"0.5535011",
"0.5483551",
"0.54736954",
"0.5452035",
"0.5441273",
"0.5437387",
"0.5412612",
"0.5402453",
"0.5402453",
"0.5395019",
... | 0.0 | -1 |
Use this to find news sources from Google News. Run it periodically to build up a bank of news sources to include | def find_sources
names = ""
Googlenews.items(100).each do |report|
name = report['title'].match(/ - ([\w. ]+)/)[1]
names << name
unless Source.find_by_name(name)
source = Source.new({
:name => name
})
source.save
end
end
render :text => names
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def googleNewsSearch(name, mins = 720)\n\n type = \"\"\n theRep = Rep.all\n puts \"THE REP! : #{theRep}\"\n if Rep.where(name: name)[0].json.index(\"senate\") != nil\n type = \"Sen\"\n else\n type = \"Rep\"\n end\n\n # fix the name -- so if there is 'ç' or some weird\n # character like that, it turns... | [
"0.68651307",
"0.6719305",
"0.6623156",
"0.6374155",
"0.6352204",
"0.62479985",
"0.62230045",
"0.6161313",
"0.6133828",
"0.60842186",
"0.6056822",
"0.60338753",
"0.59746814",
"0.596958",
"0.5925915",
"0.5919258",
"0.58842796",
"0.5878615",
"0.5840933",
"0.581973",
"0.58051205... | 0.6614735 | 3 |
methods at the root here will become instance methods | def sing
puts "I LOVE VOTING LALALALA"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def methods() end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def instance; end",
"def instance; end",
"def instance; end",
"def startMethods()\n @orderMethods = OrderTree.new(@root) ##Metodos de recorridos\n @addMethods = AddTree.new(@root,@comp... | [
"0.7567448",
"0.72434783",
"0.72434783",
"0.72434783",
"0.72434783",
"0.6615682",
"0.6615682",
"0.6615682",
"0.6561756",
"0.6555613",
"0.65063184",
"0.6475449",
"0.6475449",
"0.6475449",
"0.6475449",
"0.6475449",
"0.6475449",
"0.6475449",
"0.6475449",
"0.6475449",
"0.6475449"... | 0.0 | -1 |
GET /containers GET /containers.json | def index
@containers = Container.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def containers\n @containers ||= Docker::Container.all(\n all: true, # include stopped containers\n filters: { id: container_ids }.to_json\n ).map(&:json)\n end",
"def containers\n TestLab::Container.all\n end",
"def containers(key = nil, options = {})\n key ||= ... | [
"0.7165998",
"0.7068954",
"0.6897867",
"0.6833766",
"0.6760254",
"0.6758191",
"0.67024255",
"0.6604404",
"0.6592616",
"0.6590891",
"0.65503347",
"0.6488054",
"0.6399582",
"0.6274847",
"0.62428796",
"0.62336564",
"0.6215182",
"0.6203278",
"0.61912113",
"0.607803",
"0.6036521",... | 0.7273097 | 0 |
GET /containers/1 GET /containers/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @containers = Container.all\n end",
"def index\n user_session[:current_container]=nil\n if params[:label].blank?\n @containers = Container.list(params[:filter])\n else\n @container = Container.find_by_label(params[:label])\n render action: 'show' and return\n end\n r... | [
"0.7073563",
"0.67935073",
"0.6714441",
"0.65694743",
"0.6517765",
"0.65022904",
"0.6481102",
"0.6479815",
"0.64027053",
"0.6386483",
"0.63101",
"0.6241775",
"0.6180359",
"0.6120906",
"0.6048366",
"0.6031399",
"0.6015925",
"0.6007973",
"0.599529",
"0.5950116",
"0.5936465",
... | 0.0 | -1 |
POST /containers POST /containers.json | def create
begin
#get the server chosen container_params[:server_id]
@currentServer = Server.where(id: container_params[:server_id])
Docker.url = 'tcp://' + @currentServer[0].ip + ":" + @currentServer[0].port
#create the container in docker
if container_params[:exposed_port].blank?
@con = Docker::Container.create(
'name' => container_params[:name],
'Image' => container_params[:image]
)
else
@con = Docker::Container.create(
'name' => container_params[:name],
'Image' => container_params[:image],
'ExposedPorts' => { container_params[:exposed_port]+'/tcp' => {} },
'HostConfig' => {
'PortBindings' => {
container_params[:exposed_port]+'/tcp' => [{ 'HostPort' => container_params[:host_port] }]
}
}
)
end
#adds the container into the database
@container = Container.new(:name => container_params[:name], :image => container_params[:image], :command => container_params[:command], :exposed_port => container_params[:exposed_port],
:host_port => container_params[:host_port], :dockercontainer_id => @con.id, :status => 'Created')
Docker.url = ''
respond_to do |format|
if @container.save
Serverhascontainer.new(:server_id => @currentServer[0].id, :container_id => @container.id).save
format.html { redirect_to root_path, notice: 'Container was successfully created.' }
format.json { render :show, status: :created, location: @container }
else
format.html { render :new }
format.json { render json: @container.errors, status: :unprocessable_entity }
end
end
rescue Docker::Error::ClientError => e
respond_to do |format|
format.html { redirect_to root_path, notice: "Oops: #{e.message}" }
end
rescue Docker::Error::NotFoundError => e
respond_to do |format|
format.html { redirect_to root_path, notice: "Oops: #{e.message}" }
end
rescue Docker::Error::ConflictError => e
respond_to do |format|
format.html { redirect_to root_path, notice: "Oops: #{e.message}" }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n response = post_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers.json\"), params[:container].to_json, (sesh :current_token))\n json_respond response.body \n\n end",
"def create\n response = post_request(URI.parse(\"http://\"+Storage.find(cookies... | [
"0.8195612",
"0.8015509",
"0.7977083",
"0.69968426",
"0.69769883",
"0.6730368",
"0.6479558",
"0.6473718",
"0.6403856",
"0.6397522",
"0.62297755",
"0.60446113",
"0.5989358",
"0.59754825",
"0.59112823",
"0.5880414",
"0.5852181",
"0.58451915",
"0.58311284",
"0.5713688",
"0.56909... | 0.652329 | 6 |
PATCH/PUT /containers/1 PATCH/PUT /containers/1.json | def update
respond_to do |format|
if @container.update(container_params)
format.html { redirect_to @container, notice: 'Container was successfully updated.' }
format.json { render :show, status: :ok, location: @container }
else
format.html { render :edit }
format.json { render json: @container.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @container = Container.find(params[:id])\n\n respond_to do |format|\n if @container.update_attributes(params[:container])\n format.html { redirect_to @container, notice: 'Container was successfully updated.' }\n format.json { head :no_content }\n else\n format.html... | [
"0.6936837",
"0.65907705",
"0.65039676",
"0.6361538",
"0.63550586",
"0.6173861",
"0.6113243",
"0.609286",
"0.60480607",
"0.5989976",
"0.58575135",
"0.583319",
"0.58241105",
"0.5778027",
"0.57750654",
"0.57386357",
"0.5709766",
"0.5704527",
"0.5668994",
"0.5651344",
"0.5637639... | 0.6783597 | 1 |
DELETE /containers/1 DELETE /containers/1.json | def destroy
begin
#finds the current server that the container is on and sets it as Docker.ulr
#@serverid = Serverhascontainer.where(container_id: @container.id)[0].server_id;
#@currentServer = Server.where(id: @serverid)
#Docker.url = 'tcp://' + @currentServer[0]["ip"] + ":" + @currentServer[0]["port"]
Docker.url = findServer()
#removes the container from docker
Docker::Container.get(Container.find(params[:id]).dockercontainer_id).remove;
#removes the Server-container relation from the database
@d = Serverhascontainer.where(container_id: @container.id)
Serverhascontainer.destroy(@d[0].id);
#removes the container from the database
@container.destroy
Docker.url = ''
respond_to do |format|
format.html { redirect_to root_path, notice: 'deleted.' }
format.json { head :no_content }
end
rescue Docker::Error::ConflictError => e
respond_to do |format|
format.html { redirect_to root_path, notice: "Oops: You cannot remove a running container. Stop the container before attempting removal" }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete # rubocop:disable Metrics/AbcSize\n attrcheck = { 'container name' => @options[:container] }\n @validate.attrvalidate(@options, attrcheck)\n containerview = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n if @options[:recurse]\n contents = containervie... | [
"0.77223444",
"0.7654943",
"0.7483602",
"0.73324454",
"0.72308844",
"0.713478",
"0.701006",
"0.6858805",
"0.68261087",
"0.6803036",
"0.67661566",
"0.6749949",
"0.6699148",
"0.6698651",
"0.66778785",
"0.66631824",
"0.66421735",
"0.6640113",
"0.6590578",
"0.6587223",
"0.6537753... | 0.6998827 | 7 |
Use callbacks to share common setup or constraints between actions. | def set_container
@container = Container.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 container_params
params.require(:container).permit(:name, :image, :command, :exposed_port, :host_port, :server_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 |
def get_character_movies_from_api(character_name) make the web request response_string = RestClient.get(' response_hash = JSON.parse(response_string) characters_arr = response_hash["results"] character_idx = nil characters_arr.each_with_index do |hash,idx| if hash["name"] == character_name character_idx = idx end end arr_of_films = characters_arr[character_idx]["films"] arr_of_hashes = [] arr_of_films.each do |film_url| film_str = RestClient.get(film_url) film_hash = JSON.parse(film_str) arr_of_hashes << film_hash end return arr_of_hashes make the web request iterate over the response hash to find the collection of `films` for the given `character` `character` collect those film API urls, make a web request to each URL to get the info for that film return value of this method should be collection of info about each film. i.e. an array of hashes in which each hash reps a given film this collection will be the argument given to `print_movies` and that method will do some nice presentation stuff like puts out a list of movies by title. Have a play around with the puts with other info about a given film. end puts get_character_movies_from_api("Luke Skywalker") puts "" | def parse_url(url)
response_str = RestClient.get(url)
characters_arr = JSON.parse(response_str)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_character_movies_from_api(character)\n #make the web request\n all_characters = RestClient.get('http://www.swapi.co/api/people/')\n character_hash = JSON.parse(all_characters)\n film_urls = get_film_urls(character_hash, character)\n\n parse_character_movies(parse_films(film_urls))\nend",
"def get_ch... | [
"0.9170631",
"0.9160304",
"0.8702584",
"0.869801",
"0.8504424",
"0.8498081",
"0.84607214",
"0.84102666",
"0.83005595",
"0.8273107",
"0.826059",
"0.82492983",
"0.82469255",
"0.82446903",
"0.8232902",
"0.8192176",
"0.8160529",
"0.8107744",
"0.8063357",
"0.80191046",
"0.79642296... | 0.0 | -1 |
GET /participant_quotes GET /participant_quotes.json | def index
@participant_quotes = ParticipantQuote.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @participant_quotes }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @participant_quote = ParticipantQuote.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant_quote }\n end\n end",
"def destroy\n @participant_quote = ParticipantQuote.find(params[:id])\n @participant_quote.destroy... | [
"0.7152615",
"0.6397558",
"0.6345617",
"0.6281185",
"0.6272502",
"0.62399006",
"0.6232049",
"0.62028545",
"0.6193352",
"0.61696094",
"0.60210025",
"0.60089386",
"0.5990835",
"0.5953325",
"0.59272003",
"0.59262174",
"0.59074295",
"0.59029293",
"0.5901017",
"0.5898677",
"0.5870... | 0.75764847 | 0 |
GET /participant_quotes/1 GET /participant_quotes/1.json | def show
@participant_quote = ParticipantQuote.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @participant_quote }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @participant_quotes = ParticipantQuote.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @participant_quotes }\n end\n end",
"def destroy\n @participant_quote = ParticipantQuote.find(params[:id])\n @participant_quote.destroy\n\n re... | [
"0.75045645",
"0.6509631",
"0.6467268",
"0.63699657",
"0.62532365",
"0.6225809",
"0.6214231",
"0.6205739",
"0.6154353",
"0.61189735",
"0.6078182",
"0.6078182",
"0.6078182",
"0.60727996",
"0.60698277",
"0.6067165",
"0.60335726",
"0.59817874",
"0.5975427",
"0.59591585",
"0.5947... | 0.7344995 | 1 |
GET /participant_quotes/new GET /participant_quotes/new.json | def new
@participant_quote = ParticipantQuote.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @participant_quote }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @quote = Quote.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quote }\n end\n end",
"def new\n @quoteable = find_quoteable\n @quote = Quote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { r... | [
"0.7353266",
"0.7290599",
"0.71510077",
"0.69096905",
"0.66836864",
"0.66836864",
"0.66836864",
"0.66770554",
"0.6649301",
"0.66387993",
"0.66115195",
"0.66063255",
"0.66063255",
"0.6601417",
"0.65713185",
"0.6557265",
"0.6540016",
"0.6514769",
"0.6510395",
"0.6504937",
"0.64... | 0.7997766 | 0 |
POST /participant_quotes POST /participant_quotes.json | def create
@participant_quote = ParticipantQuote.new(params[:participant_quote])
@participant_quote.user_id = current_user.id
respond_to do |format|
if @participant_quote.save
format.html { redirect_to @participant_quote, notice: 'Participant quote was successfully created.' }
format.json { render json: @participant_quote, status: :created, location: @participant_quote }
else
format.html { render :new }
format.json { render json: @participant_quote.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @client=Client.find_by_id(params['q_param']['client'])\n title=params['q_param']['title']\n comment=params['q_param']['comment']\n list = [[\"\",\"\",\"1\",\"\"]]\n quote_p={:title=>title,:comment=>comment, :status=>1, :list=>list}\n @quote = @client.quotes.create(quote_p)\n render json: {:quo... | [
"0.65628976",
"0.6458151",
"0.64493793",
"0.6426537",
"0.6315236",
"0.614887",
"0.61268556",
"0.60901684",
"0.60508174",
"0.60490125",
"0.60490125",
"0.60316014",
"0.60283315",
"0.6021632",
"0.59683275",
"0.5949569",
"0.59227866",
"0.5812546",
"0.57873976",
"0.5772727",
"0.57... | 0.74273187 | 0 |
PUT /participant_quotes/1 PUT /participant_quotes/1.json | def update
@participant_quote = ParticipantQuote.find(params[:id])
respond_to do |format|
if @participant_quote.update_attributes(params[:participant_quote])
format.html { redirect_to @participant_quote, notice: 'Participant quote was successfully updated.' }
format.json { head :no_content }
else
format.html { render :edit }
format.json { render json: @participant_quote.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @participant_quote = ParticipantQuote.new(params[:participant_quote])\n @participant_quote.user_id = current_user.id\n\n respond_to do |format|\n if @participant_quote.save\n format.html { redirect_to @participant_quote, notice: 'Participant quote was successfully created.' }\n ... | [
"0.6646239",
"0.6392883",
"0.63439757",
"0.6314633",
"0.6243085",
"0.62193173",
"0.6218981",
"0.6218981",
"0.6170778",
"0.61642927",
"0.6139782",
"0.6139782",
"0.6139782",
"0.6139782",
"0.6139782",
"0.6139782",
"0.6139782",
"0.6123719",
"0.6117449",
"0.60724217",
"0.6052955",... | 0.74743 | 0 |
DELETE /participant_quotes/1 DELETE /participant_quotes/1.json | def destroy
@participant_quote = ParticipantQuote.find(params[:id])
@participant_quote.destroy
respond_to do |format|
format.html { redirect_to participant_quotes_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @quote_line.destroy\n respond_to do |format|\n format.html { redirect_to quote_lines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kid_quote.destroy\n\n respond_to do |format|\n format.html { redirect_to kid_quotes_url }\n format.json { h... | [
"0.7170655",
"0.7156321",
"0.7148859",
"0.7135716",
"0.71331376",
"0.71331376",
"0.71331376",
"0.7118539",
"0.70611763",
"0.70055383",
"0.69864243",
"0.6945002",
"0.6933887",
"0.6926167",
"0.69126016",
"0.69126016",
"0.69126016",
"0.69126016",
"0.69126016",
"0.69126016",
"0.6... | 0.7952621 | 0 |
Determines if a shell command exists by searching for it in ENV['PATH']. | def command_exists?(command)
ENV['PATH'].split(File::PATH_SEPARATOR).any? {|d| File.exists? File.join(d, command) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shell_command_exists?(command)\n ENV['PATH'].split(File::PATH_SEPARATOR).any?{|d| File.exists? File.join(d, command) }\n end",
"def command_exists(cmd)\n exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|\n exts.each { ... | [
"0.86624485",
"0.837481",
"0.8278965",
"0.82658935",
"0.82646716",
"0.81825876",
"0.8114473",
"0.8114473",
"0.7852806",
"0.7778245",
"0.7777762",
"0.7777762",
"0.76492614",
"0.75879896",
"0.75879896",
"0.7575491",
"0.75593084",
"0.7525238",
"0.75060236",
"0.74422103",
"0.7425... | 0.837463 | 2 |
Returns [width, height] of terminal when detected, nil if not detected. Think of this as a simpler version of Highline's Highline::SystemExtensions.terminal_size() | def detect_terminal_size
if (ENV['COLUMNS'] =~ /^\d+$/) && (ENV['LINES'] =~ /^\d+$/)
[ENV['COLUMNS'].to_i, ENV['LINES'].to_i]
elsif (RUBY_PLATFORM =~ /java/ || (!STDIN.tty? && ENV['TERM'])) && command_exists?('tput')
[`tput cols`.to_i, `tput lines`.to_i]
elsif STDIN.tty? && command_exists?('stty')
`stty size`.scan(/\d+/).map { |s| s.to_i }.reverse
else
nil
end
rescue
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detect_terminal_size\n if (ENV['COLUMNS'] =~ /^\\d+$/) && (ENV['LINES'] =~ /^\\d+$/)\n [ENV['COLUMNS'].to_i, ENV['LINES'].to_i]\n elsif (RUBY_PLATFORM =~ /java/ || (!STDIN.tty? && ENV['TERM'])) && command_exists?('tput')\n [`tput cols`.to_i, `tput lines`.to_i]\n elsif STDIN.tty? && command_e... | [
"0.8195988",
"0.80224055",
"0.8019138",
"0.79774195",
"0.7969648",
"0.78469956",
"0.7764037",
"0.77301234",
"0.76883155",
"0.7686057",
"0.76576775",
"0.76383364",
"0.75278836",
"0.7467008",
"0.7451767",
"0.74064183",
"0.74064183",
"0.7364724",
"0.7248816",
"0.7212738",
"0.704... | 0.8007344 | 3 |
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | def production?
ENV["JEKYLL_ENV"] == "production"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ios; end",
"def private; end",
"def platform_endpoint; end",
"def host_os; end",
"def host_os; end",
"def api_mode; end",
"def supports_streaming?; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def versio... | [
"0.56878316",
"0.56781626",
"0.5379542",
"0.50232434",
"0.50232434",
"0.49817264",
"0.49791622",
"0.4956793",
"0.4956793",
"0.4956793",
"0.4956793",
"0.4956793",
"0.4956793",
"0.4956793",
"0.4956793",
"0.4956793",
"0.4956793",
"0.4956793",
"0.4956793",
"0.4956793",
"0.4956793... | 0.0 | -1 |
Marks a key readonly. Returns self. | def read_only! key
set_data! key, :read_only, true
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readonly! #:nodoc:\n @readonly = true\n end",
"def readonly!\n @readonly = true\n end",
"def set_readonly\n readonly! if persisted? && !parent\n end",
"def readonly=(value)\n if value\n self[:readonly] = ''\n else\n remove_attribute :readonly\n end\n ... | [
"0.6546846",
"0.65401816",
"0.59213346",
"0.5785873",
"0.57742524",
"0.56710845",
"0.5644326",
"0.54534036",
"0.545066",
"0.54113257",
"0.5361511",
"0.5348421",
"0.53416693",
"0.5333156",
"0.5306583",
"0.5305598",
"0.5305598",
"0.5305598",
"0.5298332",
"0.52912545",
"0.528633... | 0.7547733 | 0 |
Returns true if the value for key is marked 'inherited'. If so, any attempt to call []= will be ignored and the value returned from [] will the ENV[key] value at initialization. | def inherit? key
! ! (data(key, INHERIT) && data(key, DEFAULT))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inherits_key? k\n !(@hash.key? k) && (!! @parents.find {|parent| parent.key? k } )\n end",
"def inherits_key? k\n !(@hash.key? k) && (!! @parents.find {|parent| parent.key? k } )\n end",
"def env?(key)\n blank?(ENV[key])\n end",
"def key_inheritable_in_parent?(*key)\n ... | [
"0.65181106",
"0.6462525",
"0.63119984",
"0.59950995",
"0.5760447",
"0.57421875",
"0.572275",
"0.5683113",
"0.5676117",
"0.56717056",
"0.56517655",
"0.563552",
"0.5634367",
"0.5627991",
"0.55664897",
"0.5558068",
"0.5545557",
"0.55309534",
"0.54966104",
"0.54808336",
"0.54714... | 0.70132136 | 0 |
Returns true if the value for key is marked 'locked' If so, any attempt to call []= will be ignored. | def locked? key
! ! data(key, LOCKED)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def locked?(key)\n raise NotImplementedError\n end",
"def locked?\n @locked\n end",
"def locked?\n @locked\n end",
"def locked?\n @locked\n end",
"def locked?\n @locked\n end",
"def locked?\n @locked\n end",
"def locked?\n @locked\n end",
... | [
"0.7454825",
"0.7390553",
"0.73161703",
"0.73161703",
"0.73161703",
"0.73161703",
"0.72735626",
"0.72596794",
"0.7245564",
"0.7153851",
"0.7130027",
"0.7127562",
"0.70990014",
"0.70923525",
"0.70795846",
"0.7079581",
"0.70446825",
"0.6998114",
"0.6977817",
"0.69634235",
"0.69... | 0.8380538 | 0 |
Executes block while setting dst with each element of env. dst is restored after completion of the block. nil values are equivalent to deleting the dst element dst defaults to the global ENV NOT THREADSAFE if dst == ENV | def with dst = nil
dst ||= ENV
with_env(@h, dst) do
yield
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_env(options, &block)\n backup = ENV.to_h\n ENV.clear\n ENV.update(options)\n yield\nensure\n ENV.clear\n ENV.update(backup)\nend",
"def withenv(env, &block)\n original = ENV.to_hash\n reset(original.merge(env))\n block.call\n ensure\n reset(original)\n end",
... | [
"0.5675896",
"0.5532706",
"0.5494883",
"0.5427228",
"0.53598213",
"0.5304405",
"0.5263251",
"0.5195921",
"0.5178359",
"0.5156537",
"0.5153828",
"0.51467794",
"0.50784034",
"0.5068004",
"0.5047206",
"0.50176156",
"0.500382",
"0.49426588",
"0.49259073",
"0.49259073",
"0.4914977... | 0.64974326 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_grupo_material
@grupo_material = GrupoMaterial.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def grupo_material_params
params.require(:grupo_material).permit(:codigo, :nome)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
Remembers a user in a persistent session. | def remember(user)
user.set_remember_token
cookies.permanent.signed[:user_id] = user.id
#user.remember_token is the User::remember_token class variable,
#no getters on the rails train...
cookies.permanent[:remember_token] = user.remember_token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_user\n return unless exists?(:previous_user)\n set :user, fetch(:previous_user)\n unset :previous_user\n clear_sessions\n end",
"def change_password\n @user = User.find_by_id(session[:remember_token])\n end",
"def log_in_user!(user)\n session[:session_token] = ... | [
"0.675591",
"0.6644072",
"0.6311052",
"0.6311052",
"0.62816244",
"0.62358135",
"0.6200064",
"0.6200064",
"0.6180077",
"0.61798525",
"0.6169222",
"0.6156497",
"0.6137487",
"0.61251116",
"0.6117853",
"0.6090493",
"0.60684174",
"0.6063047",
"0.60603493",
"0.605217",
"0.6049069",... | 0.0 | -1 |
The current incarnation of the data is each byte is separated by a white space | def save(arr, fname)
f = File.open(fname, 'w')
begin
arr.shift
x = arr.shift
arr.shift
y = arr.shift
f.puts "#{x} #{y}"
end until arr.empty?
f.close
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data\n @buffer.string\n end",
"def data_encoding\n encoded_characters.join(spacing_encoding)\n end",
"def chars; self[:data].to_a ; end",
"def hexdump( data )\n\t\t\tdata.bytes.to_a.map {|byte| sprintf('%#02x',byte) }.join( ' ' )\n\t\tend",
"def packetize_data data\n data = data.ch... | [
"0.6218854",
"0.62049764",
"0.61739343",
"0.6133536",
"0.60920405",
"0.60174584",
"0.60120386",
"0.5925902",
"0.5912589",
"0.58969426",
"0.58807725",
"0.5875881",
"0.58721304",
"0.5837854",
"0.5809333",
"0.5802576",
"0.5789737",
"0.5737537",
"0.5733365",
"0.5729798",
"0.57077... | 0.0 | -1 |
Guarantee to read n bytes | def read_bytes(sd, n)
out = []
while (n > out.size)
data = sd.read_bytes(n - out.size)
break unless data
out = out + data
end
return out
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(n)\n end",
"def read(n)\n Buffer.new(slice!(0, n))\n end",
"def readpartial(size, buffer = T.unsafe(nil)); end",
"def readpartial(size, buffer = T.unsafe(nil)); end",
"def readpartial(size, buffer = T.unsafe(nil)); end",
"def recvExactNBytes(n)\n buffer = \"\" ;\n while(... | [
"0.7577687",
"0.73801863",
"0.7329298",
"0.7329298",
"0.7329298",
"0.7244138",
"0.7131295",
"0.70470035",
"0.70083845",
"0.6996167",
"0.6858447",
"0.6833026",
"0.6775157",
"0.6770802",
"0.6766239",
"0.6728644",
"0.6709728",
"0.66529816",
"0.66504604",
"0.66234726",
"0.6621393... | 0.73996717 | 1 |
GET /user/add GET /user/add.json | def add
@user = current_user
unless current_user.user_info.blank?
current_user.user_info.each do | key , value|
m = "#{key}="
unless key.to_str == "avatar"
@user.send( m, current_user.user_info[key] ) if @user.respond_to?( m )
end
end
end
respond_to do |format|
format.html # add.html.erb
format.json { render json: @user }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add\n @user = User.new(params[:user])\n \n if @user.save\n redirect_to @user, notice: 'User was successfully created.'\n else\n render action: \"new\"\n end\n end",
"def create\n @add = Add.new(add_params)\n @add.user = current_user\n\n respond_to do |format|\n if ... | [
"0.7502071",
"0.71875316",
"0.71781707",
"0.7165432",
"0.7112938",
"0.70435095",
"0.7010005",
"0.69172835",
"0.6905096",
"0.6856762",
"0.67331874",
"0.6704436",
"0.6678484",
"0.66718376",
"0.6659172",
"0.6657718",
"0.6625392",
"0.66139007",
"0.6605221",
"0.6604092",
"0.658831... | 0.6699861 | 12 |
GET /customers GET /customers.json | def index
@customers = Customer.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @customers = @user.customers.all\n render json: @customers\n end",
"def customers(options = {})\n perform_get_with_object('/customers', options, Epages::CustomersResponse)\n end",
"def index\n @user = current_user\n @customers = @user.custo... | [
"0.80477434",
"0.7958279",
"0.78736347",
"0.7785999",
"0.7759871",
"0.7743631",
"0.7737657",
"0.7650475",
"0.7650475",
"0.7644552",
"0.76392215",
"0.7563173",
"0.7439835",
"0.74304175",
"0.74225414",
"0.7395726",
"0.72824943",
"0.72764957",
"0.7261613",
"0.72505057",
"0.72505... | 0.6973055 | 46 |
GET /customers/1 GET /customers/1.json | def show
@customers = Customer.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_customer(id)\n get(\"customers/#{id}\")\n end",
"def get_customer(id)\n get(\"customers/#{id}\")\n end",
"def index\n @customers = @user.customers.all\n render json: @customers\n end",
"def index\n @user = current_user\n @customers = @user.custom... | [
"0.78568625",
"0.78568625",
"0.7680524",
"0.76006114",
"0.7533196",
"0.7516672",
"0.7499743",
"0.7383202",
"0.7336955",
"0.7336955",
"0.7336955",
"0.7336955",
"0.7336955",
"0.7336955",
"0.73160666",
"0.7308929",
"0.7281901",
"0.71956944",
"0.71879476",
"0.7172753",
"0.7169239... | 0.6743695 | 40 |
POST /customers POST /customers.json | def create
# whitelist params
@customer = Customer.new(customer_params)
respond_to do |format|
if @customer.save
format.html { redirect_to customers_path }
format.json { render :show, status: :ok, location: @customer }
format.json { render :json => @objects.map(&:attributes) }
else
format.html { render :new, warning: "Customer record was NOT saved."}
format.json { render json: @customer.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @customer = @user.customers.build(customer_params)\n if @customer.save\n render json: @customer, status: :created\n else\n render json: @customer.errors, status: :unprocessable_entity\n end\n\n ... | [
"0.7583026",
"0.7368963",
"0.72758555",
"0.7225672",
"0.7224766",
"0.7142322",
"0.7116918",
"0.7109281",
"0.7102696",
"0.70753646",
"0.7068943",
"0.7054525",
"0.70359194",
"0.70359194",
"0.70350176",
"0.703466",
"0.70175",
"0.7017294",
"0.7017294",
"0.7017294",
"0.7017294",
... | 0.6992751 | 24 |
PATCH/PUT /customers/1 PATCH/PUT /customers/1.json | def update
respond_to do |format|
if @customer.update(customer_params)
format.html { redirect_to customers_path, success: "Customer record updated"}
else
format.html { render :edit }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_customer(id, data)\n put(\"customers/#{id}\", { body: data })\n end",
"def update\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n #format.html { redirect_to customers_path }\n format.json { head :ok ... | [
"0.6988014",
"0.6921667",
"0.6921389",
"0.6746401",
"0.6746401",
"0.6746401",
"0.6746401",
"0.6746401",
"0.6746401",
"0.6746401",
"0.67379916",
"0.6729548",
"0.669213",
"0.669213",
"0.669213",
"0.6614732",
"0.66107404",
"0.6601309",
"0.6599307",
"0.6581087",
"0.65642476",
"... | 0.62460697 | 67 |
DELETE /customers/1 DELETE /customers/1.json | def destroy
@customer.destroy
respond_to do |format|
format.html { redirect_to customers_url,flash[:success] = "Customer record successfully deleted." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |for... | [
"0.7459997",
"0.7459997",
"0.74485695",
"0.74485695",
"0.74485695",
"0.74485695",
"0.74485695",
"0.74485695",
"0.74485695",
"0.7435839",
"0.7429404",
"0.7429404",
"0.7429404",
"0.7429404",
"0.7429404",
"0.7429404",
"0.7429404",
"0.7429404",
"0.7364333",
"0.732843",
"0.7298528... | 0.69809604 | 65 |
Use callbacks to share common setup or constraints between actions. | def set_customer
@customer = Customer.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 customer_params
params.require(:customer).permit(:first_name, :last_name, :phone, :query, :email,
:street_address, :city, :acct_open_date, :agreement_status, :trans_type,
:last_trans_date, :street_address2, :postal, :province, :notes)
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 |
do eth protocol handshake and return status | def send_handshake(network_id, total_difficulty, head_hash, genesis_hash)
status = Status.new(protocol_version: 63, network_id: network_id,
total_difficulty: total_difficulty, current_block: head_hash, genesis_block: genesis_hash)
@context.send_data(Status::CODE, status.rlp_encode)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connection_status_handshake; end",
"def handshake\n end",
"def handshake\n data = \"email=#{@email}&password=#{@password}\"\n headers = { 'User-agent' => USER_AGENT }\n\n begin\n resp = @http.post(API_HANDSHAKE_PATH, data, headers)\n rescue SocketError\n return false... | [
"0.7307283",
"0.7283943",
"0.70012474",
"0.67481685",
"0.6678453",
"0.66775495",
"0.66749024",
"0.6552309",
"0.64215875",
"0.6379187",
"0.6174187",
"0.6080506",
"0.6062216",
"0.6033216",
"0.60274047",
"0.59281015",
"0.5879561",
"0.5857275",
"0.58226174",
"0.5820995",
"0.58109... | 0.6641958 | 7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.