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
INSTANCE METHODS Authenticate the current user
def authenticate!(password) auth = User.perform_request User.api_url("users/authenticate", {}), :post, { email: self.email, password: password }, true # A bit of additional code here to keep the initialization tidy if auth if(self.respond_to? :token=) self.token = auth['data']['token'] else self.class.send(:define_method, "token=") { |value| @token=value } self.class.send(:define_method, "token") { @token } self.token = auth['data']['token'] end true else false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticate_user!\n payload = decode_token\n return unless payload.is_a? Hash\n\n @current_user = User.find payload[:user_id]\n end", "def authenticate!\n raise error!({meta: {code: RESPONSE_CODE[:unauthorized], message: I18n.t(\"errors.not_authenticated\"), debug_info: ''}}...
[ "0.772912", "0.7673397", "0.76531994", "0.7625688", "0.7597252", "0.75373906", "0.7482106", "0.7482106", "0.7462088", "0.74590456", "0.74522614", "0.7427254", "0.7424541", "0.7424541", "0.7424541", "0.7424541", "0.74108946", "0.7406121", "0.73870516", "0.73756385", "0.7353389...
0.0
-1
Updates a user. It modifies the caller! Beware: here be dragons. If you add a custom attribute, this method will try to assign a value to a non existing instance variable Create a sub class and add all the required custom attributes to it.
def update!(options: {}) user = User.perform_request User.api_url("users/#{id}"), :put, options, true if user options.each do |key, value| self.send("#{key}=", user['data']["#{key}"]) end else nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_user(user_or_id, attributes)\n instantize_user(user_or_id).update(attributes)\n end", "def update_user\n end", "def update_user(user, attributes)\n user.update(attributes)\n end", "def update!\n unless id\n raise \"user can not be updated before it is created.\"\n ...
[ "0.7490753", "0.7476488", "0.7265453", "0.7125352", "0.71129286", "0.7083976", "0.705805", "0.7056475", "0.70549613", "0.7020849", "0.70014805", "0.69993776", "0.69923437", "0.69824857", "0.6952048", "0.6951711", "0.6945839", "0.6938514", "0.6917871", "0.69131416", "0.6884946...
0.6864258
21
:secret => 'db056ca471351bf7eb01b6307b5398e0' See ActionController::Base for details Uncomment this to filter the contents of submitted sensitive data parameters from your application log (in this case, all fields with names like "password"). filter_parameter_logging :password
def admin_required session[:user_id] && (user = User.find(session[:user_id])) && user.is_admin end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter_password_confirmation\n log :filter_password_confirmation, \"\"\n replace_in_file 'config/initializers/filter_parameter_logging.rb',\n 'Rails.application.config.filter_parameters += [:password]',\n 'Rails.application.config.filter_parameters += [:password, :password_c...
[ "0.67581946", "0.6740676", "0.66263384", "0.66263384", "0.65260535", "0.6446736", "0.6412639", "0.63110465", "0.6268169", "0.6173105", "0.61639184", "0.61204135", "0.61126405", "0.61126405", "0.6102974", "0.6102785", "0.60894984", "0.6087785", "0.6084603", "0.60735214", "0.60...
0.0
-1
Protect controllers with code like: before_filter :admin_required, :only => [:suspend, :unsuspend, :destroy, :purge]
def admin_required current_user.respond_to?('is_admin') && current_user.send('is_admin') || access_denied end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def skip_authorization_check(*args)\n before_action(*args) do |controller|\n controller.instance_variable_set(:@_authorized, true)\n end\n end", "def admin_authorize\n unless admin?\n unauthorized_access\n end\n end", "def only_authorize_admin!\n authorize!(is...
[ "0.67758894", "0.67619455", "0.66918486", "0.6659264", "0.6575221", "0.6526861", "0.6524851", "0.6515409", "0.65095216", "0.64790773", "0.64790773", "0.64790773", "0.6453839", "0.6448013", "0.6448013", "0.6448013", "0.6448013", "0.6446916", "0.64450574", "0.6441122", "0.64315...
0.0
-1
use `tools/android list sdk extended all` to get a list of available packages
def sdk_packages [ ["platform-tools", 'platform-tools'], ["build-tools-23.0.3", 'build-tools/23.0.3'], ["android-#{@api_version}", "platforms/android-#{@api_version}"], ["addon-google_apis-google-#{@api_version}", "add-ons/addon-google_apis-google-#{@api_version}"], ["sys-img-armeabi-v7a-addon-google_apis-google-#{@api_version}", "system-images/android-#{@api_version}/google_apis/armeabi-v7a"], ["extra-android-support", 'extras/android/support'] ] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apt_packages\n PRE_INSTALLED_OS_PACKAGES[@app.release].join(\" #{NL_TAB}\")\n end", "def get_packages(adb_opts = {})\n packages = []\n run_adb_shell(\"pm list packages -f\", adb_opts) do |pout|\n pout.each do |line|\n @log.debug(\"{stdout} #{line}\") unless @log.nil?\n ...
[ "0.6317287", "0.6276006", "0.623922", "0.62276304", "0.60173744", "0.58197", "0.57239467", "0.566168", "0.5655301", "0.5638089", "0.5636539", "0.5568224", "0.55633", "0.55545783", "0.55459887", "0.5521234", "0.5481258", "0.545158", "0.543471", "0.5396431", "0.5370915", "0.5...
0.7649553
0
having problem with mocha, possibly Ruby 2 related.
def dummy_generator(result) Object.new.tap { |o| o.define_singleton_method(:generate) { |*args| result } } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uses_mocha(test_name)\n unless Object.const_defined?(:Mocha)\n gem 'mocha', '>= 0.9.5'\n require 'mocha'\n end\nrescue LoadError => load_error\n $stderr.puts \"Skipping #{test_name} tests. `gem install mocha` and try again.\"\nelse\n yield\nend", "def uses_mocha(test_name)\n require 'mocha' unless...
[ "0.63727826", "0.6329637", "0.6314666", "0.60019034", "0.60019034", "0.59696275", "0.59666574", "0.59666574", "0.5729956", "0.56953824", "0.5655932", "0.5650662", "0.56420434", "0.56420434", "0.5629743", "0.5629743", "0.5621014", "0.55798674", "0.5546065", "0.5542874", "0.553...
0.0
-1
Replaces SPARQL query variable `?graphName` with the provided `graph_name` URI to identify, which graph should be queried.
def add_graph(query, graph_name) graph_uri = "<#{graph_name}>" query.gsub(/\?validatedGraph/i, graph_uri) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_graph(graph_name)\n @sparql_update.clear(:graph, graph_name)\n end", "def add_graph(query_template)\n query_template.gsub(/\\?graph/i, \"<#{@named_graph}>\")\n end", "def name(name)\n @graph_name = name\n self\n end", "def graph_name=(name)\n formulae[name] = self\n @...
[ "0.6520261", "0.6208744", "0.5916594", "0.5869182", "0.58667487", "0.58667487", "0.5754367", "0.5557972", "0.5550149", "0.54677993", "0.51732403", "0.50450736", "0.5033111", "0.5012443", "0.5012443", "0.49952966", "0.493606", "0.48204702", "0.4816851", "0.4719867", "0.4719867...
0.73585975
0
Timestamps the provided `graph` identified with `graph_name`
def add_timestamp(graph_name, graph) now = RDF::Literal::DateTime.new DateTime.now.iso8601 graph << RDF::Statement.new(RDF::URI(graph_name), RDF::DC.issued, now) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def updated_time( params={} )\n updated_time = get_connections(\"updated_time\", params)\n return map_connections updated_time, :to => Facebook::Graph::Generic\n end", "def graph t\n puts \"graphing #{@graphname}\"\n $end_time = Time.now.to_i - @step + 1\n $start_time = $end_time - 3600 #one hour...
[ "0.56504506", "0.5509907", "0.54478157", "0.5300815", "0.52966267", "0.5275051", "0.5235053", "0.5184955", "0.5171625", "0.51687694", "0.5041701", "0.5041701", "0.5041701", "0.5041701", "0.5041701", "0.5041701", "0.50090104", "0.5002943", "0.49890962", "0.49210632", "0.490388...
0.72010756
0
Clears the graph identified with `graph_name`
def clear_graph(graph_name) @sparql_update.clear(:graph, graph_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_graph(graphname)\n update(\"WITH <#{graphname}> DELETE { ?s ?p ?o } WHERE { ?s ?p ?o .}\")\nend", "def fill_destroy_graph( graph )\n fill_save_graph( graph )\n end", "def clear_graph\n @g_inputs = []\n end", "def clear(graph_uri = nil)\n req_params = {}\n req_params[:para...
[ "0.8287032", "0.738639", "0.7060489", "0.6621692", "0.66062725", "0.64314234", "0.64175487", "0.63717335", "0.6309183", "0.62075263", "0.6185912", "0.6128895", "0.6115272", "0.60973656", "0.5998604", "0.58493835", "0.58439285", "0.5826593", "0.5825943", "0.58204097", "0.58109...
0.8817236
0
Converts validated `graph` into JSONLD
def convert_to_json(graph) # Ugly conversion to string and back to JSON, # however, other approaches don't respect @context. error_hash = JSON.parse graph.dump(:jsonld, context: JSONLD_CONTEXT.dup) error_list = error_hash["@graph"] || [error_hash] error_list.map do |item| item.delete_if { |key, value| IGNORED_ATTRS.include? key} item["@context"] = "#{@base_uri}context.jsonld" item end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_to_json(graph)\n hash = JSON.parse graph.dump(:jsonld, context: ValidatorApp.jsonld_context[:file].dup)\n hash.key?(\"@graph\") ? nest(hash) : []\n end", "def as_jsonld\n provenance\n JSON::LD::API::fromRDF(@graph)\n end", "def to_jsonld( hash )\n JSON::LD::API.expand( ...
[ "0.74671113", "0.6986429", "0.59655577", "0.5893633", "0.57965463", "0.56197625", "0.5584123", "0.5565764", "0.5468483", "0.54596055", "0.5429376", "0.54289496", "0.5397736", "0.5322343", "0.5309435", "0.5248647", "0.523075", "0.51897305", "0.5180021", "0.5170829", "0.5096105...
0.7450981
1
Loads `data` into a named graph, returns URI of the newly created graph with containing the data
def load_data(data) sha1 = Digest::SHA1.hexdigest data.dump(:turtle) graph_name = RDF::URI.new(@namespace + sha1) data = add_timestamp(graph_name, data) @sparql_update.insert_data(data, graph: graph_name) graph_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def data_graph_uri(slug)\n \"http://#{PublishMyData.local_domain}/graph/#{slug}\"\n end", "def build_from_string(data)\n\n # Check if string representation of the graph is valid\n raise ArgumentError, 'String representation of the graph is invalid' unless data =~ /\\A(|([a-z0-0A-Z]+=>[a-z0-0A-Z...
[ "0.63632184", "0.5914667", "0.56077415", "0.5456536", "0.5456536", "0.5456536", "0.54500455", "0.54500455", "0.54467773", "0.5443514", "0.5404968", "0.5344902", "0.532338", "0.53223485", "0.52751434", "0.52642334", "0.5252166", "0.51917374", "0.51909935", "0.51776356", "0.517...
0.7514408
0
Run a single `test` formalized as SPARQL query on the validated data stored in `graph_name`
def run_test(test, graph_name) query = File.read test query = add_graph(query, graph_name) results = @sparql.query query graph = RDF::Graph.new graph << results if graph.empty? {} else convert_to_json graph end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_test\n rdfa_string = input\n \n # Run\n @rdfa_parser = RdfaParser::RdfaParser.new\n yield(rdfa_string, rdfa_parser)\n\n query_string = results\n\n triples = self.triples rescue nil\n \n if (query_string.match(/UNION|OPTIONAL/) || title.match(/XML/)) && triples\n...
[ "0.7253056", "0.6144356", "0.57979655", "0.57561165", "0.5714529", "0.55502754", "0.55135477", "0.55042094", "0.54233396", "0.5417177", "0.5383945", "0.535673", "0.53179646", "0.53152955", "0.5306837", "0.5292223", "0.52045417", "0.5168607", "0.51238465", "0.5121762", "0.5108...
0.80892444
0
Validate input `parsed_data` with SPARQLbased tests
def validate(parsed_data) graph_name = load_data parsed_data begin results = @tests.map do |test| run_test(test, graph_name) end ensure clear_graph graph_name end # Remove empty results results.flatten.reject(&:empty?) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_test\n rdfa_string = input\n \n # Run\n @rdfa_parser = RdfaParser::RdfaParser.new\n yield(rdfa_string, rdfa_parser)\n\n query_string = results\n\n triples = self.triples rescue nil\n \n if (query_string.match(/UNION|OPTIONAL/) || title.match(/XML/)) && triples\n...
[ "0.667054", "0.59963167", "0.570665", "0.56189144", "0.55292624", "0.55135006", "0.5504733", "0.5466863", "0.54390323", "0.5366752", "0.5364879", "0.5354181", "0.53322834", "0.52761775", "0.52758545", "0.5261994", "0.5261994", "0.5226985", "0.5226985", "0.5221339", "0.5216152...
0.6963143
0
POST id. Required. The ID of the status to favorite. Ex: or
def create end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def favorite(id)\n post(\"/favorites/create/#{id}.json\")\n end", "def create_favorite(id)\n post \"favorites/create/#{id}\", {}\n end", "def change_favorite_status\r\n\t\t\tProject.update_favorite_status params[:id], params[:is_favorite]\r\n\r\n\t\t\trender json: { status: 0 }\r\n\t\tend", "def ...
[ "0.7152173", "0.68760675", "0.63178813", "0.63049525", "0.6289387", "0.6196214", "0.61899394", "0.61759263", "0.6161575", "0.6160793", "0.6160793", "0.61522055", "0.61522055", "0.61522055", "0.61522055", "0.61522055", "0.61522055", "0.6151924", "0.60981953", "0.60981566", "0....
0.0
-1
POST, DELETE id. Required. The ID of the status to unfavorite. Ex: or
def destroy end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_status(id)\n delete(\"/statuses/#{id}\")\n end", "def unfavorite(id)\n post(\"/favorites/destroy/#{id}.json\")\n end", "def destroy_status(status_id)\n delete \"statuses/destroy/#{status_id}\"\n end", "def delete_status(status_id)\n\t\t\tdata = oauth_request(\"/user_status/...
[ "0.72752786", "0.7070454", "0.68769014", "0.6852058", "0.6839362", "0.6699654", "0.66824615", "0.66812325", "0.6631598", "0.65690213", "0.65616935", "0.6549714", "0.653552", "0.653126", "0.65310836", "0.64913154", "0.6474335", "0.6443647", "0.64114666", "0.6405594", "0.639986...
0.0
-1
used by rake cron task to broadcast newsletters
def broadcast(contact) self.processing! ApplicationMailer.newsletters(contact, self).deliver_now rescue self.failed! self.sent! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def daily_morning\n logger.info \" daily_morning\"\n run('Newsletter', :send!)\n end", "def perform\n @newsletter = create_newsletter\n send_emails\n end", "def weekly\n @greeting = \"Hello\"\n mail subject: args[:subject], to: args[:emails]\n mail to: \"to@example.org\"\n end", ...
[ "0.75021946", "0.7004595", "0.6737247", "0.67184937", "0.6588943", "0.6546344", "0.6438934", "0.6361757", "0.63449216", "0.6321769", "0.6308988", "0.62956786", "0.629298", "0.6283073", "0.6258638", "0.62533915", "0.62407166", "0.62404615", "0.62124705", "0.6198466", "0.618744...
0.6758849
2
SimpleCov formatter for idobata.io
def initialize @hook_url = self.class.hook_url || ENV['SIMPLECOV_IDOBATA_HOOK_URL'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format!\n SimpleCov.formatter.new.format(self)\n end", "def format!\n SimpleCov.formatter.new.format(self)\n end", "def format!\n SimpleCov.formatter.new.format(self)\n end", "def format(result)\n json = SimpleCov::FormatResult.call(result, OUTPUT_FILE_PATH)\n puts S...
[ "0.8101925", "0.8101925", "0.8101925", "0.6497728", "0.6208528", "0.60782975", "0.58777446", "0.5819737", "0.5729155", "0.5720789", "0.56983143", "0.56975526", "0.5605132", "0.5572701", "0.5525398", "0.5525398", "0.54913586", "0.5373023", "0.53704554", "0.53704554", "0.537045...
0.0
-1
format coverage result, then post result to idobata.io
def format(result) client.send(Badge.new(result).to_s, format: :html) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @coverage = Coverage.new(coverage_params)\n\n respond_to do |format|\n if @coverage.save\n format.html { redirect_to @coverage, notice: 'Coverage was successfully created.' }\n format.json { render :show, status: :created, location: @coverage }\n else\n format.html...
[ "0.65205705", "0.63193846", "0.6281978", "0.6251065", "0.6242339", "0.6242339", "0.61436176", "0.596456", "0.59477377", "0.5916986", "0.5863341", "0.58586735", "0.5834669", "0.579967", "0.56979465", "0.5657497", "0.56272984", "0.5619089", "0.5618716", "0.56152403", "0.5611989...
0.0
-1
the following methods are not intended for public use, but rather by Spec and Parser instances in this module
def _call_vet(what_to_check) if @vet.nil? then what_to_check else @vet.call what_to_check end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def spec; end", "def spec; end", "def standard_specs; end", "def private; end", "def pluggable_parser; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def parser; end", "def parser; end", "def parser; end", "def parser; end", "def spec=(_arg0); end", "...
[ "0.72186357", "0.72186357", "0.69021916", "0.6497888", "0.64820063", "0.64592934", "0.64592934", "0.64592934", "0.64592934", "0.63817406", "0.63817406", "0.63817406", "0.63817406", "0.6330905", "0.62505776", "0.62505776", "0.62505776", "0.62505776", "0.62152076", "0.62152076", ...
0.0
-1
Adding end markers, help, and version info
def add_end_marker_here(marker='--') register_a_parm End.new(marker, howmany: :NONE, debug: @debug) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def help\n lines = []\n end", "def help\n rez = \":ge setup - init .git directory in /etc folder\\n\"\n rez << \":ge diff - show diff for current changes\\n\"\n rez << \":ge commit COMMENT - will commit changes\\n\"\n rez << \":ge status - will run git status\\n\"\n end", "de...
[ "0.6463772", "0.6448885", "0.6312437", "0.6309255", "0.6293723", "0.62883097", "0.62277687", "0.62250453", "0.6147904", "0.6126225", "0.6102495", "0.6102495", "0.6102495", "0.6074346", "0.6058158", "0.60491616", "0.6037557", "0.6029886", "0.6018706", "0.60055685", "0.6003683"...
0.0
-1
Methods required by the parser
def finalize() if @ready_to_go return end if @needs_help add_help end @attributes.sort! dups = [] previous = nil @attributes.each do |an_attr| if an_attr == previous dups.push(an_attr) else previous = an_attr end end if dups.length > 0 raise "Duplicate attribute names, #{dups}, for command line options." end @positionals.push(@parms_list.length) @attributes.freeze @defaults.freeze @parms_list.freeze @parms_hash.freeze @positionals.freeze @ready_to_go = true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parser; end", "def parser; end", "def parser; end", "def parser; end", "def parse; end", "def parse; end", "def parse; end", "def parsed; end", "def parsed; end", "def pluggable_parser; end", "def parse!\n raise NotImplementedError, \"this class is intended to be a top class, not a u...
[ "0.8120399", "0.8120399", "0.8120399", "0.8120399", "0.7715559", "0.7715559", "0.7715559", "0.7643554", "0.7643554", "0.75777364", "0.75063425", "0.73162514", "0.7286733", "0.72758543", "0.7229573", "0.7171644", "0.70573944", "0.7000156", "0.7000156", "0.7000156", "0.7000156"...
0.0
-1
=== Images Methods ===
def imgs obj Image.find(obj.image_ids) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def images; end", "def images\n end", "def image; end", "def image\n\n end", "def image\n end", "def image\n end", "def images\n []\n end", "def image\n end", "def image\n end", "def images\n @images = super || []\n end", "def set_img\n\n end", "def img(*) # :nodo...
[ "0.84653085", "0.82592577", "0.7665665", "0.76652676", "0.7635363", "0.7635363", "0.7443061", "0.73192775", "0.73192775", "0.7285348", "0.7091011", "0.7027154", "0.70265406", "0.7019263", "0.6962551", "0.6961665", "0.6943656", "0.68687356", "0.68545556", "0.68480545", "0.6809...
0.69043505
17
How would you modify the function to print all numbers between 1 and 1000, 10000, or n ?
def counter_2(x) (1..x).each { |n| puts n } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def range_print_10\n (0..9).step(1) do |n| \n puts n \n end \n \nend", "def print_range\n\n\tsum = 0\n\t\n\tfor i in 1...1000 do\n\t\t\t\t\n\t\tif i%3 == 0 or i%5 == 0\n\t\t\t\n\t\t\tsum += i\n\t\t\t\n\t\t\t#just for initial tracing\n\t\t\t#puts i \n\n\t\tend\t\n\n\tend\t \n\t\t\n\tputs sum\n\t\t\nend", ...
[ "0.6946657", "0.68157715", "0.67884487", "0.6643968", "0.6518978", "0.6513654", "0.6449722", "0.64270234", "0.6419027", "0.6355781", "0.6355781", "0.62414896", "0.6239319", "0.62268406", "0.62095827", "0.6120726", "0.6095927", "0.6094953", "0.6056794", "0.605005", "0.6037683"...
0.0
-1
drag_to() will make it so you can dragndrop the source_widget onto the target widget. You may pass a reference to a widget object, or a String that gives the name of the widget on your glade form. So, it functions the same as this statement: widget_source.drag_to(widget_target) It also functions the same as this statement:
def set_drag_drop(hash) hash.each do |key,val| src = key.is_a?(Gtk::Widget) ? key : @builder[key] target = @builder[val] src.extend(VR::Draggable) unless src.is_a?(VR::Draggable) src.add_target_widget(target) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def drag_and_drop(source, target, device: T.unsafe(nil)); end", "def drag_to(target)\n raise Gridium::InvalidTypeError, \"source element selector must be ':css'\" unless self.by == :css\n raise Gridium::InvalidTypeError, \"target element selector must be ':css'\" unless target.by == :css\n\n Log.debug(\...
[ "0.70739025", "0.6911271", "0.686278", "0.68455976", "0.66368634", "0.6488718", "0.6124987", "0.5963129", "0.5856418", "0.57682616", "0.570696", "0.56288207", "0.56226796", "0.5612682", "0.5607106", "0.5577752", "0.5527587", "0.5522805", "0.55105466", "0.544645", "0.53473556"...
0.52809024
22
This will Load the glade form according to the naming convention: MyClass.rb => MyClass.glade. It will create a Gtk::Builder object from your glade file.
def load_glade() caller__FILE__ = my_class_file_path() file_name = File.join(File.split(caller__FILE__)[0] , "glade", class_name(self) + ".glade") @builder = Gtk::Builder.new @builder << file_name @builder.connect_signals{ |handle| method(handle) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_ui(file_name)\n gtk_builder_add_from_file(@builder, file_name, FFI::MemoryPointer::NULL)\n connect_signals\n end", "def show_glade(parent = nil)\r\n load_glade()\r\n if parent then\r\n @builder[:window1].transient_for = parent.builder[:window1]\r\n end\r\n before_show() ...
[ "0.65036833", "0.63665056", "0.62790495", "0.5906967", "0.58494174", "0.57898813", "0.5715965", "0.5667131", "0.5645705", "0.54957974", "0.54114354", "0.5390123", "0.53220713", "0.5286374", "0.5190307", "0.5190307", "0.51136684", "0.5104905", "0.5052585", "0.50520974", "0.501...
0.88080204
0
Connects gtk's signals to your methods according to the naming convention widget__signal. For example, when you place a button called "button1" in your glade form, and declare a method called "button1__clicked", they aren't connected to each other. Clicking on the button does nothing and the method never gets called. After running parse_signals(), the "clicked" signal is connected to the method named "button1__clicked" so when the user clicks the button, the method is called.
def parse_signals() meths = self.class.instance_methods() meths.each do |meth| meth = meth.to_s #bug fix ruby 1.9 gives stmbol glade_name, signal_name = *(meth.split("__")) next if (signal_name.to_s == "" or glade_name.to_s == "") #covers nil if @builder @builder.objects.each do |obj| next unless obj.respond_to?(:builder_name) if obj.builder_name == glade_name or obj.builder_name =~ /^(?:#{class_name(self)}\.|)#{glade_name}\[[a-zA-Z\d_-]+\]$/ #arrays obj.signal_connect(signal_name) { |*args| method(meth.to_sym).call(*args) } end end end obj = glade_name == "self" ? self : self.instance_variable_get("@" + glade_name) obj ||= eval(glade_name) if respond_to?(glade_name) and method(glade_name.to_sym).arity == 0 # no arguments! if obj.respond_to?("signal_connect") obj.signal_connect(signal_name) { |*args| method(meth.to_sym).call(*args) } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connect_signals\n @glade['drawingarea'].signal_connect('expose_event') { print }\n @glade['eventbox'].events = Gdk::Event::BUTTON_PRESS_MASK\n @glade['eventbox'].signal_connect('button_press_event') {|w, e| add_point(Point[e.x.to_i, e.y.to_i])}\n @glade['mainwindow'].signal_connect('destroy'){Gtk...
[ "0.66696537", "0.6540574", "0.6364604", "0.5879452", "0.58626664", "0.5816632", "0.57837266", "0.5641825", "0.5606676", "0.5555276", "0.5551549", "0.55421126", "0.51843035", "0.5080046", "0.50687766", "0.5032885", "0.49500644", "0.49433744", "0.4921931", "0.47387674", "0.4731...
0.7189284
0
parses instance variables added in before_show def parse_instance_signals(dig = true) instance_variables.each do |var| obj = instance_variable_get(var) if obj.respond_to?(:load_glade) obj.load_glade obj.parse_signals dig one level obj.parse_instance_signals(false) if dig never ending loop if instance vaiables are in 2 objects end end end This method is the most useful method to populate a glade form. It will populate from active_record fields and instance variables. It will simply call both of these methods: set_glade_active_record() set_glade_variables() So, to set all the values of a form, simply call the set_glade_all() method instead.
def set_glade_all(obj = self) set_glade_active_record(obj) set_glade_variables(obj) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_signals()\r\n meths = self.class.instance_methods()\r\n meths.each do |meth|\n meth = meth.to_s #bug fix ruby 1.9 gives stmbol\r\n glade_name, signal_name = *(meth.split(\"__\"))\r\n next if (signal_name.to_s == \"\" or glade_name.to_s == \"\") #covers nil\r\n if @builder\r\n ...
[ "0.66795236", "0.6619495", "0.63035905", "0.53254855", "0.5193349", "0.5157633", "0.5121468", "0.5015188", "0.49918738", "0.4901401", "0.47705492", "0.46947604", "0.46850902", "0.4670521", "0.46612477", "0.46477708", "0.46199134", "0.46155262", "0.4607414", "0.4587327", "0.45...
0.5660652
3
This method is the most useful method to retreive values from a glade form. It will populate from active_record fields and instance variables. It will simply call both of these methods: get_glade_active_record() get_glade_variables() So, to retreive all the values of a form back into your ActiveRecord object and instance variables, simply call the set_glade_all() method instead.
def get_glade_all(obj = self) get_glade_active_record(obj) get_glade_variables(obj) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_glade_all(obj = self) \r\n set_glade_active_record(obj)\r\n set_glade_variables(obj)\r\n end", "def get_glade_variables(obj = self)\r\n obj.instance_variables.each do |var_name|\n next if var_name == :@builder or var_name == :@top_level_window\n var = obj.instance_variable_get(var_nam...
[ "0.6234088", "0.6209407", "0.5971967", "0.59625804", "0.5835695", "0.5789007", "0.5739942", "0.57168674", "0.5700989", "0.5695639", "0.56948835", "0.56760174", "0.56738585", "0.5668976", "0.5629696", "0.56075555", "0.56002", "0.5598221", "0.55926913", "0.5584008", "0.5577583"...
0.71224344
0
Matches names in glade form to keys in a Hash.
def set_glade_hash(hash) return unless hash.is_a?(Hash) hash.each { |key,val| fill_control( key.to_s, val.to_s) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def matching_keys(name)\n matched_keys = []\n @all_se.each_key do |k|\n if /#{name}/.match(k)\n matched_keys << k\n end\n end\n matched_keys\n end", "def check_name(hash, name_to_check)\n hash.each_key do |name|\n if name == name_to_check\n true\n else\n false\n ...
[ "0.6833061", "0.6287518", "0.61020285", "0.6043875", "0.5921624", "0.5733593", "0.5627251", "0.55030674", "0.54904777", "0.5469656", "0.5431803", "0.54228765", "0.5405435", "0.5397231", "0.5387118", "0.53635156", "0.5354769", "0.5335571", "0.53334033", "0.531978", "0.5319746"...
0.49440527
82
Populates the glade form from the instance variables of the class. So instead of having to assign each widget a value:
def set_glade_variables(obj = self) obj.instance_variables.each do |name| name = name.to_s #ruby 1.9 passes symbol! v = obj.instance_variable_get(name) name = name.gsub('@', '') if v.is_a?(Array) v.each_index do |i| fill_control("#{name}[#{i.to_s}]", v[i] ) end elsif v.is_a?(Hash) v.each_pair do |key, val| fill_control("#{name}[#{key.to_s}]", val) end else fill_control(name, v) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(form_values, options)\n @form_values = form_values\n @form_args = options.dup\n @g = Gestalt.new\n end", "def widgets= mine_widgets\n @form.wigets = mine_widgets\n end", "def fill_inputs\n update(:all,'input').with do\n if ...
[ "0.60622215", "0.6025517", "0.5999877", "0.59791344", "0.59721774", "0.59474057", "0.59174013", "0.58832335", "0.5878164", "0.5854412", "0.58301723", "0.57900804", "0.5788395", "0.5783269", "0.57719785", "0.5771863", "0.5739014", "0.57361794", "0.57359254", "0.57175964", "0.5...
0.63345915
0
Populates your instance variables from the glade form. This works for Gtk:Button, Gtk::Entry, Gtk::Label and Gtk::Checkbutton. So instead of having to assign instance variable:
def get_glade_variables(obj = self) obj.instance_variables.each do |var_name| next if var_name == :@builder or var_name == :@top_level_window var = obj.instance_variable_get(var_name) var_name = var_name.to_s.gsub("@", "") #fix for ruby 1.9 giving symbols if var.is_a? Hash var.each_pair do |key, val| if glade_value = get_control_value("#{var_name}[#{key.to_s}]", obj) var[key] = glade_value end end obj.instance_variable_set("@"+ var_name, var) elsif var.is_a? Array var.each_index do |i| if glade_value = get_control_value("#{var_name}[#{i.to_s}]", obj) var[i] = glade_value end end obj.instance_variable_set("@"+ var_name, var) else glade_value = get_control_value(var_name, obj) obj.instance_variable_set("@"+ var_name, glade_value) unless glade_value.nil? end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_vars\n @hbox = Gtk::HBox.new\n @mode_vbox = Gtk::VBox.new\n @idiom_vbox = Gtk::VBox.new\n @geral_vbox = Gtk::VBox.new\n @new_btn = Gtk::Button.new('')\n @quit_btn = Gtk::Button.new('')\n self.resizable = false\n self.modal = true\n @mode_rdo = []\n (0..4).each{|i|\n @mod...
[ "0.6349929", "0.61988336", "0.6104339", "0.58542556", "0.5808911", "0.5721402", "0.5607525", "0.55946183", "0.55850744", "0.5578518", "0.55732864", "0.55536795", "0.55454993", "0.547914", "0.5464775", "0.5462236", "0.5455543", "0.545123", "0.54298455", "0.5415321", "0.5394893...
0.54972976
13
The method you call to show the glade form. It loads the glade form, sets all the form's widgets to your instance variables, connects all your methods to their signals, and starts Gtk.main loop if necessary.
def show_glade(parent = nil) load_glade() if parent then @builder[:window1].transient_for = parent.builder[:window1] end before_show() if respond_to? :before_show parse_signals() set_glade_all() @builder[:window1].show #show_all can't hide widgets in before_show @top_level_window = Gtk.main_level == 0 ? true : false Gtk.main if @top_level_window or @builder[:window1].modal? # need new Gtk.main for blocking! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_glade() \r\n caller__FILE__ = my_class_file_path() \r\n file_name = File.join(File.split(caller__FILE__)[0] , \"glade\", class_name(self) + \".glade\")\r\n @builder = Gtk::Builder.new\r\n @builder << file_name\r\n @builder.connect_signals{ |handle| method(handle) }\r\n end", "def initial...
[ "0.70793504", "0.6656819", "0.63367146", "0.62562424", "0.60327923", "0.6025181", "0.6019112", "0.59034467", "0.58893543", "0.58858246", "0.58802235", "0.5813053", "0.57941264", "0.57941264", "0.57941264", "0.5781111", "0.57742643", "0.57420754", "0.5701015", "0.56994724", "0...
0.7682451
0
Convenience method so you can just make a button named "buttonCancel" and it will work. This method isn't called in code, its triggered by a user clicking a button named "buttonCancel".
def buttonCancel__clicked(*a) @builder[:window1].destroy end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cancel\n begin\n $results.log_action(\"button(#{@params[0]})\")\n # Cancel button can be either a link or an actual button object\n begin\n if @driver.find_element(:id, \"lnk-cancel\").displayed?\n @driver.find_element(:id, \"lnk-cancel\").click\n $results.success\n ...
[ "0.7872163", "0.7753562", "0.7496165", "0.72539634", "0.718454", "0.718454", "0.71736026", "0.7044793", "0.6860197", "0.684876", "0.6822248", "0.68041956", "0.6782086", "0.667918", "0.66676617", "0.6661764", "0.66390043", "0.66170925", "0.6561873", "0.65547854", "0.64691406",...
0.71641266
7
retrieves the key inside a glade control name. Useful when handling events where the control name is returned, and you need to match it to an actual hash.
def extract_key(widget) widget.builder_name.scan(/\[(.+?)\]/).flatten[0] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key_name\n data[:key_name]\n end", "def key\n name.underscore.tr('/', '_').to_sym\n end", "def key\n @key ||= name.to_s\n end", "def getKey; argSetTextual.to_sym end", "def key\n (key_name || name).to_sym\n end", "def key\n params.k\n end", "def k...
[ "0.67622155", "0.6629844", "0.65193367", "0.65151405", "0.6442582", "0.64163435", "0.63802165", "0.6370469", "0.6329291", "0.6323531", "0.62756974", "0.62183565", "0.62044007", "0.6140959", "0.61196", "0.61159825", "0.61043817", "0.60978633", "0.60894966", "0.6087803", "0.608...
0.69389087
0
Populates the glade form from the fields of an ActiveRecord object. So instead of having to assign each widget a value:
def set_glade_active_record(obj = self) return if not defined? obj.attributes obj.attributes.each_pair { |key, val| fill_control(class_name(obj) + "." + key, val) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dynamic_form_fields(builder)\n # Allow dynamic fields in our Project to be processed by form_for\n create_virtual_attributes!\n\n @object.fields.each do |field|\n h.haml_concat process_field(builder, field)\n end\n end", "def fill_in_form(fields)\n fields.each do |field, value|\n ...
[ "0.6710754", "0.66584444", "0.6586746", "0.62520474", "0.6116846", "0.6088128", "0.5973156", "0.58923894", "0.5876099", "0.58751696", "0.5838978", "0.57892257", "0.575915", "0.57421696", "0.57256556", "0.571422", "0.5699848", "0.56909156", "0.5674296", "0.56606483", "0.562878...
0.63381284
3
Waits for all penting events to finish before continuing.
def clear_events() while (Gtk.events_pending?) Gtk.main_iteration end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wait_done\n sleep 0.01 until done?\n end", "def process_events_until_done\n call_subscribers(*event_list.shift) until event_list.empty?\n end", "def wait\n @t.each{|t| t.join}\n end", "def process_events\n while (Gtk.events_pending?)\n Gtk.main_iteration\n end\n end", ...
[ "0.65068066", "0.6495677", "0.6248584", "0.6177621", "0.6149994", "0.6136741", "0.61337715", "0.6119938", "0.6012008", "0.59892863", "0.5985583", "0.59312415", "0.5905204", "0.5900535", "0.5883703", "0.5824588", "0.5820568", "0.5791479", "0.5791479", "0.5791479", "0.5785471",...
0.0
-1
Feel free to google "how to generate a random number in ruby"
def roll rand(6) #=> gives a random number between 0 and 6 inclusively rand(1..6) #=> gives a random number between 1 and 6 inclusively end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_number\r\n return randomNumber = 1 + rand(100)\r\n end", "def get_random_number()\n rand(0x7fffffff).to_s\nend", "def gen_num\n rand(1..100)\nend", "def random_number\n t = Time.now.to_f / (Time.now.to_f % Time.now.to_i)\n random_seed = t * 1103515245 + 12345;\n (random_seed / 655...
[ "0.8495664", "0.83661103", "0.8313143", "0.8223487", "0.81888056", "0.81034255", "0.8082594", "0.80462444", "0.80339515", "0.80311567", "0.80311567", "0.8012156", "0.7966379", "0.7956103", "0.7935751", "0.7910181", "0.7877693", "0.7872219", "0.7863298", "0.7854499", "0.781815...
0.0
-1
Authenticates a new application and returns the token. Authenticates a new application and returns the token
def authenticate_application(opts = {}) data, _status_code, _headers = authenticate_application_with_http_info(opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticate_app\n payload = {\n # The time that this JWT was issued, _i.e._ now.\n iat: Time.now.to_i,\n\n # JWT expiration time (10 minute maximum)\n exp: Time.now.to_i + (10 * 60),\n\n # Your GitHub App's identifier number\n iss: APP_IDENTIFIER\n ...
[ "0.6956823", "0.68318737", "0.6783047", "0.66389996", "0.6572564", "0.6520071", "0.64995337", "0.6472993", "0.6449581", "0.640806", "0.6406053", "0.63940734", "0.63705313", "0.6283722", "0.6223485", "0.6223485", "0.6199262", "0.6181198", "0.61609554", "0.61583245", "0.6142404...
0.0
-1
Authenticates a new application and returns the token. Authenticates a new application and returns the token
def authenticate_application_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AuthenticationServiceApi.authenticate_application ...' end # resource path local_var_path = '/authentication/application' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body(opts[:'body']) # return_type return_type = opts[:return_type] || 'JsonMDNToken' # auth_names auth_names = opts[:auth_names] || [] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: AuthenticationServiceApi#authenticate_application\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticate_app\n payload = {\n # The time that this JWT was issued, _i.e._ now.\n iat: Time.now.to_i,\n\n # JWT expiration time (10 minute maximum)\n exp: Time.now.to_i + (10 * 60),\n\n # Your GitHub App's identifier number\n iss: APP_IDENTIFIER\n ...
[ "0.6957931", "0.683319", "0.6784181", "0.663925", "0.65733594", "0.6522246", "0.6502017", "0.64739805", "0.6450877", "0.64067477", "0.64059806", "0.6395632", "0.6372112", "0.6285735", "0.6224204", "0.6224204", "0.6199239", "0.61831385", "0.61634904", "0.61578435", "0.614352",...
0.0
-1
Authenticates a new user and returns the token ( forbidden if the credentials cannot be validated ). Authenticates a new user and returns the token ( forbidden if the credentials cannot be validated )
def authenticate_user(opts = {}) data, _status_code, _headers = authenticate_user_with_http_info(opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n user = User.find_for_authentication(email: user_params[:email])\n\n if user && user.valid_password?(user_params[:password])\n user.generate_authentication_token\n\n expose({\n user_id: user.id,\n token: user.authentication_token\n })\n els...
[ "0.79074514", "0.7507615", "0.74978244", "0.73751605", "0.73112005", "0.7139667", "0.7090082", "0.70808023", "0.70613885", "0.70162904", "0.70162904", "0.6935824", "0.6934444", "0.6914979", "0.6865663", "0.6864429", "0.6862596", "0.68557185", "0.6840068", "0.67993647", "0.679...
0.0
-1
Authenticates a new user and returns the token ( forbidden if the credentials cannot be validated ). Authenticates a new user and returns the token ( forbidden if the credentials cannot be validated )
def authenticate_user_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AuthenticationServiceApi.authenticate_user ...' end # resource path local_var_path = '/authentication' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body(opts[:'body']) # return_type return_type = opts[:return_type] || 'JsonMDNToken' # auth_names auth_names = opts[:auth_names] || [] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: AuthenticationServiceApi#authenticate_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n user = User.find_for_authentication(email: user_params[:email])\n\n if user && user.valid_password?(user_params[:password])\n user.generate_authentication_token\n\n expose({\n user_id: user.id,\n token: user.authentication_token\n })\n els...
[ "0.7907597", "0.750828", "0.7498281", "0.7375742", "0.7311189", "0.71392804", "0.7091101", "0.7081595", "0.7062113", "0.70166934", "0.70166934", "0.6936785", "0.69351447", "0.69155777", "0.68668616", "0.6864494", "0.6863133", "0.6856628", "0.6841177", "0.6799786", "0.67926747...
0.0
-1
Returns the AUthorization URL to verify a Twitter Accounts. Returns the AUthorization URL to verify a Twitter Accounts
def get_fractal_authentication_url(opts = {}) data, _status_code, _headers = get_fractal_authentication_url_with_http_info(opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def twitter_url; \"https://twitter.com/#{twitter}\" end", "def twitter_url\n twitter_user.blank? ? nil : \"#{TWITTER_URL}#{twitter_user}\"\n end", "def base_url\n \"https://api.twitter.com\"\n end", "def main_url\n return nil unless twitter\n \"http://twitter.com/#{twitter.downcase}\"\n en...
[ "0.7546892", "0.7190639", "0.7092497", "0.69991124", "0.68396217", "0.67324185", "0.6599785", "0.6565017", "0.63878524", "0.6371813", "0.6354215", "0.62596524", "0.6244645", "0.6241036", "0.623741", "0.6116047", "0.606739", "0.6066744", "0.6053066", "0.6052869", "0.60273564",...
0.0
-1
Returns the AUthorization URL to verify a Twitter Accounts. Returns the AUthorization URL to verify a Twitter Accounts
def get_fractal_authentication_url_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AuthenticationServiceApi.get_fractal_authentication_url ...' end # resource path local_var_path = '/authentication/fractal' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'File' # auth_names auth_names = opts[:auth_names] || [] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: AuthenticationServiceApi#get_fractal_authentication_url\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def twitter_url; \"https://twitter.com/#{twitter}\" end", "def twitter_url\n twitter_user.blank? ? nil : \"#{TWITTER_URL}#{twitter_user}\"\n end", "def base_url\n \"https://api.twitter.com\"\n end", "def main_url\n return nil unless twitter\n \"http://twitter.com/#{twitter.downcase}\"\n en...
[ "0.7548516", "0.719271", "0.7094029", "0.7000908", "0.68408424", "0.673302", "0.6601334", "0.65658313", "0.6389468", "0.63737005", "0.63555133", "0.62607145", "0.6245762", "0.62426734", "0.6238052", "0.6116916", "0.6068736", "0.60667133", "0.6055635", "0.6055233", "0.60287535...
0.0
-1
Returns a nonce for the client which is used as content for the to be created signature. Returns a nonce for the client which is used as content for the to be created signature
def get_nonce_for_ethereum_wallet(wallet, opts = {}) data, _status_code, _headers = get_nonce_for_ethereum_wallet_with_http_info(wallet, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nonce\n ((Time.now.to_f * 1000000).to_i << 10).to_s\n end", "def nonce\n @nonce ||= Digest::SHA1.hexdigest random_string + timestamp\n end", "def nonce\n @nonce ||= Digest::SHA1.hexdigest random_string + timestamp\n end", "def nonce\n Array.new( 5 ) { rand(256) }.pack('C*...
[ "0.7816999", "0.773821", "0.773821", "0.76802135", "0.75357956", "0.7365072", "0.7314532", "0.7294667", "0.71795684", "0.7100958", "0.7070443", "0.69342667", "0.6886841", "0.683009", "0.6820128", "0.6772561", "0.67509395", "0.67509395", "0.67472225", "0.6714203", "0.667545", ...
0.0
-1
Returns a nonce for the client which is used as content for the to be created signature. Returns a nonce for the client which is used as content for the to be created signature
def get_nonce_for_ethereum_wallet_with_http_info(wallet, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AuthenticationServiceApi.get_nonce_for_ethereum_wallet ...' end # verify the required parameter 'wallet' is set if @api_client.config.client_side_validation && wallet.nil? fail ArgumentError, "Missing the required parameter 'wallet' when calling AuthenticationServiceApi.get_nonce_for_ethereum_wallet" end # resource path local_var_path = '/authentication/ethereum/{wallet}'.sub('{' + 'wallet' + '}', CGI.escape(wallet.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) header_params[:'Authorization'] = opts[:'authorization'] if !opts[:'authorization'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'JsonMDNToken' # auth_names auth_names = opts[:auth_names] || [] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: AuthenticationServiceApi#get_nonce_for_ethereum_wallet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nonce\n ((Time.now.to_f * 1000000).to_i << 10).to_s\n end", "def nonce\n @nonce ||= Digest::SHA1.hexdigest random_string + timestamp\n end", "def nonce\n @nonce ||= Digest::SHA1.hexdigest random_string + timestamp\n end", "def nonce\n Array.new( 5 ) { rand(256) }.pack('C*...
[ "0.78162956", "0.77378744", "0.77378744", "0.76792043", "0.75349206", "0.7364107", "0.731374", "0.7294313", "0.7179597", "0.71002567", "0.70696026", "0.693388", "0.6886562", "0.6829619", "0.68196625", "0.6773059", "0.6751727", "0.6751727", "0.6746874", "0.6714188", "0.6675601...
0.0
-1
Used to validate the active connection with the API. Used to validate the active connection with the API
def get_object(opts = {}) data, _status_code, _headers = get_object_with_http_info(opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connection_valid?\n client('v1').api_valid?\n rescue StandardError\n false\n end", "def connection_valid?\n if status.untested? or (changed? and (changes.keys & @@status_fields).empty?)\n begin\n test_connection\n status.success!\n rescue => e\n error_str = m...
[ "0.7363311", "0.7009748", "0.6780091", "0.6762244", "0.6739436", "0.6716362", "0.6694204", "0.6660668", "0.6476406", "0.64176", "0.6381489", "0.6348189", "0.6347687", "0.61315763", "0.60872453", "0.6084624", "0.60403794", "0.6026897", "0.6026897", "0.60050935", "0.5990143", ...
0.0
-1
Used to validate the active connection with the API. Used to validate the active connection with the API
def get_object_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AuthenticationServiceApi.get_object ...' end # resource path local_var_path = '/authentication' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'Hash<String, Object>' # auth_names auth_names = opts[:auth_names] || [] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: AuthenticationServiceApi#get_object\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connection_valid?\n client('v1').api_valid?\n rescue StandardError\n false\n end", "def connection_valid?\n if status.untested? or (changed? and (changes.keys & @@status_fields).empty?)\n begin\n test_connection\n status.success!\n rescue => e\n error_str = m...
[ "0.73627436", "0.7009189", "0.67797077", "0.67617154", "0.6737458", "0.67146385", "0.66923654", "0.6660239", "0.6476227", "0.64151025", "0.6382077", "0.63478935", "0.63476366", "0.61314416", "0.608585", "0.6083535", "0.6041969", "0.60260004", "0.60260004", "0.6004036", "0.598...
0.0
-1
Returns the AUthorization URL to verify a Twitter Accounts. Returns the AUthorization URL to verify a Twitter Accounts
def get_twitter_authentication_url(opts = {}) data, _status_code, _headers = get_twitter_authentication_url_with_http_info(opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def twitter_url; \"https://twitter.com/#{twitter}\" end", "def twitter_url\n twitter_user.blank? ? nil : \"#{TWITTER_URL}#{twitter_user}\"\n end", "def base_url\n \"https://api.twitter.com\"\n end", "def main_url\n return nil unless twitter\n \"http://twitter.com/#{twitter.downcase}\"\n en...
[ "0.75473624", "0.7191596", "0.70933235", "0.7000585", "0.683967", "0.6731578", "0.6600234", "0.65648156", "0.63874996", "0.6372541", "0.63553834", "0.62599987", "0.6244732", "0.6242197", "0.6116308", "0.6068254", "0.606578", "0.60546124", "0.6053643", "0.6028568", "0.6019042"...
0.6237169
14
Returns the AUthorization URL to verify a Twitter Accounts. Returns the AUthorization URL to verify a Twitter Accounts
def get_twitter_authentication_url_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AuthenticationServiceApi.get_twitter_authentication_url ...' end # resource path local_var_path = '/authentication/twitter' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'File' # auth_names auth_names = opts[:auth_names] || [] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: AuthenticationServiceApi#get_twitter_authentication_url\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def twitter_url; \"https://twitter.com/#{twitter}\" end", "def twitter_url\n twitter_user.blank? ? nil : \"#{TWITTER_URL}#{twitter_user}\"\n end", "def base_url\n \"https://api.twitter.com\"\n end", "def main_url\n return nil unless twitter\n \"http://twitter.com/#{twitter.downcase}\"\n en...
[ "0.75465775", "0.71912724", "0.709213", "0.6999329", "0.68397754", "0.67335963", "0.65996695", "0.6565563", "0.6388169", "0.6372578", "0.63554007", "0.6259215", "0.6244586", "0.62423265", "0.6237841", "0.6116655", "0.6068223", "0.606624", "0.6053999", "0.6052716", "0.60285366...
0.5666036
48
Used as Callback URL when users have successfully authorized their facbeook account. Used as Callback URL when users have successfully authorized their facbeook account
def set_facebook_uid(opts = {}) data, _status_code, _headers = set_facebook_uid_with_http_info(opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def callback\n rpx_auth\n after_auth(params[:on_complete_url])\n end", "def fbauthorize\n redirect_to fb_auth_login_url.to_s\n end", "def callback_url\n options.authorize_params.callback_url or super\n end", "def callback\n self.oaw_callback(params[:oauth_verifier], params[:oauth_to...
[ "0.6898244", "0.68648124", "0.64785415", "0.6430791", "0.64251614", "0.639312", "0.6389942", "0.6347167", "0.6331869", "0.63304037", "0.6330178", "0.63040626", "0.62337357", "0.62314725", "0.62038344", "0.619302", "0.61878765", "0.61862", "0.6183993", "0.6168068", "0.61648303...
0.0
-1
Used as Callback URL when users have successfully authorized their facbeook account. Used as Callback URL when users have successfully authorized their facbeook account
def set_facebook_uid_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AuthenticationServiceApi.set_facebook_uid ...' end # resource path local_var_path = '/authentication/facebook' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body(opts[:'body']) # return_type return_type = opts[:return_type] || 'File' # auth_names auth_names = opts[:auth_names] || [] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: AuthenticationServiceApi#set_facebook_uid\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def callback\n rpx_auth\n after_auth(params[:on_complete_url])\n end", "def fbauthorize\n redirect_to fb_auth_login_url.to_s\n end", "def callback_url\n options.authorize_params.callback_url or super\n end", "def callback\n self.oaw_callback(params[:oauth_verifier], params[:oauth_to...
[ "0.68982095", "0.6865438", "0.64795005", "0.6430965", "0.64243", "0.63949364", "0.6390984", "0.63475513", "0.63334495", "0.6332068", "0.6331922", "0.63048136", "0.6234171", "0.62313825", "0.62046784", "0.619393", "0.618767", "0.618615", "0.6185337", "0.6168581", "0.6165418", ...
0.0
-1
=begin Given two numbers, which can be positive and negative, is the sum of all the numbers between them, including those numbers too. If the two numbers are equal, returns one of the two. =end
def get_sum(a, b) (b < a) ? a : (a..b).to_a.inject(:+) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_sum(a,b)\n a == b ? a : a < b ?\n (a..b).to_a.sum : \n (b..a).to_a.sum\nend", "def get_sum(a,b)\n return a if a == b\n \n result = 0\n min = a < b ? a : b\n max = min == a ? b : a\n num = min\n \n until num == max\n result += num\n num += 1\n end\n \n result + max\nend", "def get_su...
[ "0.7821901", "0.78023845", "0.77789193", "0.7766465", "0.76248974", "0.75818783", "0.744542", "0.7434632", "0.7429091", "0.73833", "0.7358453", "0.7338352", "0.726259", "0.72612697", "0.71313334", "0.7118445", "0.70731896", "0.70660734", "0.7062492", "0.69382083", "0.6893196"...
0.756843
6
=begin Create a method that receives a sentence and return one string pointing out the number of words and characters it contains, without blanks, your method must pass the following tests: =end
def char_word_counter(sentence) words_array = sentence.split(' ') how_many_words = words_array.length how_many_chars = sentence.gsub(/\s+/, "").length "This sentence has #{how_many_words} words & #{how_many_chars} characters" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def word_counter(sentence)\n return sentence.split(' ').length #makes it an array, .length counts items\nend", "def word_lengths(sentence)\n # Write your code here\nend", "def word_counter\n \"This is a string\".split.size\nend", "def word_count(text)\n return text.split.count\nend", "def find_freq...
[ "0.82707256", "0.7901788", "0.76770914", "0.76746225", "0.7634617", "0.7603699", "0.7587691", "0.75492144", "0.75468934", "0.7537955", "0.75367135", "0.75367135", "0.75367135", "0.75367135", "0.7519367", "0.75154734", "0.75025254", "0.74972373", "0.74972373", "0.74725497", "0...
0.81835014
1
=begin Now we will take the hashes as an organizing tool to distinguish food by food group. For this you must create a method that takes as a parameter string containing a meal, and look at the next hash, returning her key as a return value, if you do not find the food must return "food not found". =end
def food_group(str) food_groups = { "grain" => ['Rice', 'Trigo', 'Avena', 'Barley', 'Flour'], "vegetable" => ['Carrot', 'corn' 'Corn', 'Pumpkin', 'Papa'], "fruit" => ['Apple', 'Mango', 'Strawberry', 'Peaches', 'Pineapple'], "meat" => ['Beef', 'Chicken', 'Salmon', 'Fish', 'Pig'], "dairy" => ['Milk', 'Yogurt', 'Cheese', 'Cream'] } food_groups.each do |k,array| array.each { |food| return k if food == str } end return 'food not found' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def true_for_food(hash, item)\n food= hash[:favourites][:things_to_eat]\n\n for i in hash\n if i == food\n\n return \"Yes I like this food\"\n end\n end\n return \"No I don't like this\"\n end", "def find_single_bay(hash,lookup)\n\n for key,value in hash\n\n if value[:item] == loo...
[ "0.66430074", "0.6629404", "0.6602891", "0.6502921", "0.6465965", "0.6367667", "0.63485837", "0.633282", "0.6298035", "0.62824845", "0.6237614", "0.6200412", "0.61707366", "0.61547", "0.61359155", "0.6096927", "0.60774034", "0.6075146", "0.5998521", "0.5981482", "0.5958805", ...
0.72471845
0
def delete_user manageable_users = User.where(invited_by_id: current_user.id)
def identities render json: current_user.identities end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_user_todos\n user = self.id\n Todo.where({\"user_id\" => user}).delete_all\n end", "def delete\n\t\tcurrent_user\n\t\tcurrent_user.regexpressions.destroy_all\n\t\tcurrent_user.tasks.destroy_all\n\t\tcurrent_user.clouds.destroy_all\n\t\tcurrent_user.platforms.destroy_all\n\t\tcurrent_user.demos....
[ "0.7154737", "0.7114011", "0.69425", "0.68024486", "0.6770085", "0.6730412", "0.67291385", "0.6724901", "0.6573422", "0.6555834", "0.65442204", "0.6519828", "0.6469015", "0.6452897", "0.6446806", "0.6403908", "0.63788694", "0.6371636", "0.636246", "0.6352811", "0.6343719", ...
0.0
-1
For errors, add our prefix to all messages
def error(*progname, &block) if block_given? Rails.logger.error(*progname) { "#{ERROR_PREFIX}#{yield}".gsub(/\n/,"\n#{ERROR_PREFIX}") } else Rails.logger.error "#{ERROR_PREFIX}#{progname}".gsub(/\n/,"\n#{ERROR_PREFIX}") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prefix (prefix, message)\n yield(prefix, message)\n end", "def optional_prefix(prefix, message)\n [prefix + message, message]\nend", "def keep_errors(prefix = \"\")\n original_errors = errors.respond_to?(:messages) ? errors.messages.dup : errors.dup\n result = yield\n merge_er...
[ "0.6489433", "0.6355417", "0.6348507", "0.6332675", "0.63253945", "0.62757534", "0.61022407", "0.6088787", "0.6068332", "0.6029662", "0.6012724", "0.6009304", "0.5994179", "0.5994179", "0.59507877", "0.593595", "0.5928654", "0.5900084", "0.5884831", "0.5849194", "0.58121926",...
0.0
-1
Handle everything else with base object
def method_missing(m, *args, &block) Rails.logger.send m, *args, &block end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inherited(base); end", "def initialize(obj)\n @base = obj\n end", "def inherited(_sub)\n raise Error, \"cannot subclass #{self}\" unless self == Object\n end", "def base; self; end", "def proxy\n super\n end", "def full_object\n fail NotImplementedError\n ...
[ "0.6963095", "0.65463156", "0.6407889", "0.6309609", "0.6252875", "0.6231762", "0.6188301", "0.6181964", "0.61771184", "0.61690414", "0.61668307", "0.61189777", "0.61189777", "0.6088273", "0.607881", "0.6070823", "0.60639805", "0.6062341", "0.6033498", "0.60333115", "0.601334...
0.0
-1
Created a bonus method here that will add a hash of students
def add_hash_of_students(student_hash) student_hash.each do |grade, students| @roster[grade] ||= [] students.each {|student| @roster[grade] << student} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_student(student, grade_num) #adds student into roster hash\n if @roster[grade_num]\n @roster[grade_num] << student\n else\n @roster[grade_num] = [student]\n end\nend", "def add_student(student, grade_num) #adds student into roster hash\n if @roster[grade_num]\n @roster[grade_num] << student\n ...
[ "0.7346915", "0.7346915", "0.7302284", "0.7275997", "0.70445675", "0.7043122", "0.69970506", "0.6981233", "0.6929459", "0.6925385", "0.6920503", "0.6893093", "0.6889038", "0.6881075", "0.6860726", "0.683737", "0.68144435", "0.6781012", "0.6766958", "0.6765818", "0.67642844", ...
0.74446166
0
helpers for devise sessions
def resource_name :user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def session\n end", "def sign_in\n current_session || sign_user_in\nend", "def sign_in\n session[:user_id] = @user.id\n end", "def session; end", "def session; end", "def session; end", "def session; end", "def valid_session\n { \"warden.user.user.key\" => session[\"warden.user.user.key\"]...
[ "0.6959048", "0.691217", "0.6860945", "0.6856657", "0.6856657", "0.6856657", "0.6856657", "0.6804514", "0.67686355", "0.67437255", "0.67212814", "0.67205745", "0.6695948", "0.6680773", "0.6658871", "0.6658871", "0.6647527", "0.6636189", "0.66174805", "0.66002256", "0.66002256...
0.0
-1
ads for swapping code
def get_banner_header if (@banner_ad.nil? || @banner_ad.empty?) "" else render :partial => 'layouts/ads/dfp_header', :locals => {:banner_ad => @banner_ad, :banner_id => @banner_id} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def swap; end", "def swapd\n\t\t\tpush [:swap]\n\t\t\tdip\n\t\tend", "def swap(a,b)\na,b = b,a\nend", "def swap(index1, index2)\n #YOUR WORK HERE\n end", "def swap(a, b)\n\ta,b=b,a\nend", "def swap_elements_from_to(array,a,b)\n array[a] = array[a]^array[b]\n array[b] = array[b]^array[a]\n array[a] = ...
[ "0.7606896", "0.69189084", "0.6643528", "0.66331416", "0.6613082", "0.6484808", "0.6445032", "0.6436929", "0.6415725", "0.6408865", "0.6391982", "0.6366817", "0.6344511", "0.63220376", "0.6309258", "0.63079315", "0.62955415", "0.6279107", "0.622372", "0.61869794", "0.6169199"...
0.0
-1
viddler helpers was originally it's own class
def viddler_files(viddler_id, episode_id) # @viddler ||= Viddler::Client.new(viddler_id) @viddler = Viddler::Client.new(viddler_id) # traceout("instantiate viddler wtih #{viddler_id}") # puts @viddler.inspect @viddler.authenticate! ENV['VIDDLER_USER'], ENV['VIDDLER_PASSWORD'] videoData = @viddler.get 'viddler.videos.getDetails', :video_id => "#{episode_id}" # traceout(videoData) return videoData end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def weber; end", "def http; end", "def helpers; end", "def helpers; end", "def helpers; end", "def wrapper; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request;...
[ "0.6665735", "0.6360857", "0.6304474", "0.6304474", "0.6304474", "0.6283703", "0.61687654", "0.61687654", "0.61687654", "0.61687654", "0.61687654", "0.61687654", "0.61687654", "0.61687654", "0.61687654", "0.61687654", "0.61687654", "0.60976166", "0.6095541", "0.60921586", "0....
0.0
-1
using helper method to determin path, get possible link / sidebar and display
def draw_if_sidebar Link.sidebar_from_link(request.original_fullpath) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def path(controller,folder, link_to_self,matter=nil)\n # the base url for a path is always the same:\n unless folder==nil\n url = url_for(:controller => controller, :action => 'folder_list', :id => nil)\n # start with the deepest folder and work your way up\n if link_to_self\n path = h(...
[ "0.64985955", "0.64949954", "0.63631916", "0.6149049", "0.61165005", "0.6058545", "0.5981082", "0.59415144", "0.5915239", "0.57658523", "0.57656735", "0.57561904", "0.5750748", "0.5750748", "0.5735282", "0.5729544", "0.57248235", "0.57227296", "0.571972", "0.5708342", "0.5700...
0.6995931
0
determine if friend feature is first view of page
def is_friend_return_view? @prevURL = session[:previous_url].nil? ? "" : session[:previous_url].split('/')[0..2].join('/') @curURL = request.fullpath.split('/')[0..2].join('/') return ( @curURL == @prevURL) # return false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def first_page?\n current_page == 1\n end", "def first_page?\n current_page == 1\n end", "def first_page?\n current_page == 1\n end", "def first_page?\n current_page == 1\n end", "def first_page?\n current_page == 1\n end", "def first_page?\n current_pag...
[ "0.70023566", "0.70023566", "0.70023566", "0.70023566", "0.69785213", "0.69785213", "0.69767535", "0.6939453", "0.6690538", "0.668022", "0.6608608", "0.6590158", "0.65702426", "0.6518073", "0.63817394", "0.6379837", "0.6361643", "0.6320691", "0.62729216", "0.6239459", "0.6227...
0.6349572
17
TODO private methods could be extracted into another class TODO it's not the controller responsibility to tell how many pages should be shown
def search_items @resources = current_company.items.search_for(params[:name]).limit(10) @resources = Admin::InventoryItemDecorator.decorate(@resources) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pages\n end", "def pages; end", "def index\n get_own_documents\n if @page > @pages_amount && @pages_amount != 0\n @page = @pages_amount\n get_own_documents\n end\n render_js_or_html_index\n end", "def max_pages() 1 end", "def index\n respond_with(@pages = Page.all.paginate(:p...
[ "0.739138", "0.7331139", "0.71329755", "0.7020172", "0.7008272", "0.6892484", "0.68578106", "0.68117565", "0.68117565", "0.68117565", "0.68117565", "0.68117565", "0.68117565", "0.68117565", "0.68117565", "0.68117565", "0.68117565", "0.68117565", "0.68117565", "0.6697739", "0....
0.0
-1
before_action :authorized, except: [:issue_token, :decode, :logged_in?]
def issue_token(payload) JWT.encode(payload, Rails.application.credentials.secret_key_base) # JWT.encode(payload, ENV["SOME_SECRET"], ENV["SOME_SUPER_SECRET"]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def skip_authorization_check(*args)\n before_action(*args) do |controller|\n controller.instance_variable_set(:@_authorized, true)\n end\n end", "def unauthorized\n end", "def skip_authorization; end", "def authenticate\n authenticate_token || render_unauthorized\nend", ...
[ "0.71576416", "0.7123765", "0.701791", "0.70004845", "0.6852413", "0.6844437", "0.68346965", "0.6797021", "0.6797021", "0.675293", "0.6748238", "0.6741411", "0.6728515", "0.67172676", "0.6716306", "0.6716306", "0.6716306", "0.6716306", "0.6716306", "0.6716306", "0.6716306", ...
0.0
-1
Loads the Core homepage
def load_page logger.info 'Loading Core homepage' get ConfigCore.base_url when_exists(page_heading, Config.medium_wait) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main_homepage\n\t\t\t@section = Section.homepage\n\t\t\t@main_homepage = @page = Asset.find_by_section_id_and_resource_type(@section.id, 'Homepage')\n\t\t\t@is_homepage = true\n\t\t\thomepage\n end", "def homepage\n end", "def homepage\n end", "def homepage\n Bbc_homepage.new(@browser)\n ...
[ "0.7288464", "0.6845803", "0.6845803", "0.6665816", "0.6640204", "0.6640204", "0.66212624", "0.65959257", "0.65875936", "0.6431552", "0.6392498", "0.6370867", "0.6340402", "0.63234204", "0.6302416", "0.62859595", "0.62859595", "0.6268118", "0.62627846", "0.6188863", "0.617932...
0.81496716
0
Logs in from homepage
def log_in(username, password) logger.info "Logging in as #{username}" wait_for_element_and_type(username_input, username) wait_for_element_and_type(password_input, password) wait_for_element_and_click sign_in_button when_exists(sign_out_link, Config.short_wait) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loginpage\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n redirect_to lato_core.root_path if core_controlS...
[ "0.75892043", "0.75688404", "0.75184625", "0.75184625", "0.75184625", "0.75184625", "0.75184625", "0.75184625", "0.75184625", "0.75184625", "0.75184625", "0.75045127", "0.74222744", "0.7396262", "0.73627234", "0.7326675", "0.7326675", "0.731663", "0.7253417", "0.72487605", "0...
0.0
-1
recursively build categories specific to each product
def build_categories(product, mapped_categories) collection = [] product[:categories].each do |category_name| mapped_categories.each do |mapped_category| build_category_tree(collection, category_name, mapped_category) end end collection end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_categories(product)\n categories = value('category').split('&')\n\n categories.each do |category_string|\n category_string.strip!\n subcategories = category_string.split('>')\n parent_id = self.root_category.id\n subcategories.each do |category_url_key|\n cate...
[ "0.69015265", "0.63359106", "0.6062785", "0.5985178", "0.5905654", "0.589622", "0.5875007", "0.58473384", "0.58378196", "0.5826368", "0.5800109", "0.57940173", "0.57741886", "0.57717365", "0.5751802", "0.5750642", "0.569158", "0.56822324", "0.56738114", "0.5650582", "0.560308...
0.8027991
0
Who this users is following
def followed_users cached_followed_users end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def follower_username\n self.following_user.username\n end", "def following\n return @following\n end", "def following\n @following||= get(\"/user/show/#{login}/following\")['users'].map { |u| User.new(connection, :login => u) }\n end", "def following_usernames\n ...
[ "0.78541875", "0.72116417", "0.70376563", "0.69407135", "0.6913698", "0.6813146", "0.6813123", "0.6804465", "0.6802457", "0.67841774", "0.67138904", "0.67065483", "0.6679849", "0.6677966", "0.66746587", "0.66609067", "0.66566026", "0.6652882", "0.6647286", "0.66391945", "0.66...
0.0
-1
Who is following this user
def followers User.where("following @> ARRAY[#{id}]").to_a end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def follower_username\n self.following_user.username\n end", "def following\n return @following\n end", "def following?(other_user)\n following.include?(other_user)\n end", "def following?\n user.present?\n end", "def following_user?(other_user)\n ...
[ "0.77735823", "0.71969444", "0.71457064", "0.71306205", "0.7123045", "0.7122178", "0.7106257", "0.70957065", "0.70957065", "0.70957065", "0.70854276", "0.7068732", "0.70496416", "0.70496416", "0.70496416", "0.70496416", "0.7049389", "0.70485455", "0.7038835", "0.70043546", "0...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_skill @skill = policy_scope(Skill).find(params[:id]) authorize(@skill) 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.6163927", "0.6046165", "0.59465253", "0.59167755", "0.58904207", "0.58346355", "0.577713", "0.5703502", "0.5703502", "0.56531286", "0.56215113", "0.54224145", "0.5410795", "0.5410795", "0.5410795", "0.53924775", "0.5379919", "0.53580743", "0.53401667", "0.53397506", "0.533...
0.0
-1
Retrieves a list of payments taken by the account making the request. Max results per page: 100
def test_test_list_payments() # Parameters for the API call begin_time = nil end_time = nil sort_order = nil cursor = nil location_id = nil total = nil last_4 = nil card_brand = nil # Perform the API call through the SDK function result = @controller.list_payments(begin_time: begin_time, end_time: end_time, sort_order: sort_order, cursor: cursor, location_id: location_id, total: total, last_4: last_4, card_brand: card_brand) # Test response code assert_equal(200, @response_catcher.response.status_code) # Test headers expected_headers = {} expected_headers['content-type'] = 'application/json' assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def payments(account_id = nil)\n query_api_object Payment, account_id.nil? ? \"/rest/payments\" : \"/rest/accounts/#{account_id}/payments\", nil, \"GET\", \"payments\"\n end", "def payments\n @session.payments @account_id\n end", "def index\n\t\t@payments = @user.payments.order(\"date desc\").p...
[ "0.7137743", "0.711859", "0.7092813", "0.7068501", "0.6759412", "0.67561436", "0.67231905", "0.66791797", "0.66374886", "0.6597602", "0.648462", "0.6408131", "0.6327258", "0.6295491", "0.6288719", "0.62814146", "0.62814146", "0.62814146", "0.62814146", "0.62814146", "0.628141...
0.58162487
68
Helper to create links with basic tooltip capability (tooltip message should be defined after this call)
def link_to_with_tooltip(name, target, *args, &proc) args << returning(args.extract_options!) do |options| options[:class] = 'tooltip-target ' + options[:class].to_s options[:rel] = default_prototip_options end link_to name, target, *args, &proc end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def link_with_tooltip(link_target, link_text, tooltip_text)\n \"<a href='#{link_target}'><span data-tooltip class='has-tip', title='#{tooltip_text}'>#{link_text}</span></a>\".html_safe\n end", "def tooltip_tag content, title, url = \"#\", placement = \"right\", css_classes = \"help-inline record-help\"\n ...
[ "0.7973254", "0.7414626", "0.66824496", "0.6641689", "0.65933776", "0.654808", "0.64785933", "0.642116", "0.64097583", "0.6302612", "0.62912905", "0.6284192", "0.6280714", "0.6258682", "0.6258682", "0.6247794", "0.6199889", "0.6199575", "0.61882305", "0.6187047", "0.6184608",...
0.72275245
2
Returns false if no avaiable tuners Returns tuner number if recordable
def record(recording) if recordable?(recording) tuner = open_tuner current_recordings[tuner] = recording current_recordings[tuner].record! tuner else false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def open_tuner\n tuners.times do |tuner|\n return tuner if current_recordings[tuner].nil?\n end\n\n nil\n end", "def check_recordings\n tuners.times do |tuner|\n recording = current_recordings[tuner]\n\n next if recording.nil? || recording.recordable?\n\n stop_a...
[ "0.6510883", "0.64606845", "0.6039347", "0.5715465", "0.56211567", "0.5398032", "0.5281567", "0.5247588", "0.5241347", "0.5237521", "0.52360857", "0.5186604", "0.51750505", "0.51653886", "0.5160089", "0.51578546", "0.51352763", "0.5117952", "0.5111841", "0.51084936", "0.51066...
0.56264526
4
Are there any tuners that aren't recording? Can the full size of the recording fit?
def recordable?(recording) !!open_tuner && (recording.full_size < space_available) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_recordings\n tuners.times do |tuner|\n recording = current_recordings[tuner]\n\n next if recording.nil? || recording.recordable?\n\n stop_and_store_recording(recording)\n free_up_tuner(tuner)\n end\n end", "def check_max_samples_exceeded\n # loop over each st...
[ "0.6805013", "0.6023161", "0.60119516", "0.5923075", "0.5852646", "0.55729514", "0.55473334", "0.553898", "0.5516487", "0.55139816", "0.55040437", "0.54978764", "0.54508555", "0.54485685", "0.5437759", "0.5331331", "0.5317156", "0.5312962", "0.5294359", "0.5286079", "0.527820...
0.6975403
0
Returns the index of the open tuner TODO: Refactor into Tuner object
def open_tuner tuners.times do |tuner| return tuner if current_recordings[tuner].nil? end nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_station_index\n current_station_index + 1\n end", "def current_station_index\n @route.stations.find_index(@current_station)\n end", "def index\n @raw_data[:FlightIndex].to_i\n end", "def idx\n @ob.get_idx\n end", "def ta_index\n end", "def index\n @raw_data[:F...
[ "0.56832534", "0.56785285", "0.560765", "0.55342", "0.5468247", "0.54665154", "0.5429857", "0.5406161", "0.5342045", "0.53382796", "0.5281057", "0.52750397", "0.5254027", "0.5243816", "0.5236542", "0.5223069", "0.5222817", "0.52183414", "0.52056897", "0.52022743", "0.51886666...
0.7143693
0
NOTE: This makes approximations based on the FULL recording size of shows. Again, partial recordings will be approximated with there full size. The reason for this is because we will want to capture the entire show in subsequent recording attempts. We want that space to be reserved
def space_available used = 0 if recordings.any? used = recordings.map(&:full_size).reduce(:+) end total_space - used end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_size(show)\n print \"\\rcalculating size for #{show}\".ljust(120)\n size = directory_size \"#{PATH}/#{show}\"\n if SHOWS.include? show\n anime = SHOWS[show]\n anime.bytes += size\n else\n anime = Anime.new(show, size)\n RESULTS << anime\n SHOWS[anime.name] = anime\n end\nend", "...
[ "0.5721383", "0.5679425", "0.56688285", "0.5471276", "0.538588", "0.538434", "0.5345573", "0.5277346", "0.5275411", "0.5185242", "0.51768583", "0.5158122", "0.511725", "0.5115435", "0.509348", "0.5045647", "0.5045476", "0.4993621", "0.49886242", "0.49798602", "0.4969885", "...
0.51311576
12
Update receives new recordings It checks to see current recordings and free those up After, it attempts to start recording the array passed
def update(new_recordings = []) new_recordings ||= [] # if nil is passed check_recordings new_recordings.each { |recording| record recording } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_recordings\n tuners.times do |tuner|\n recording = current_recordings[tuner]\n\n next if recording.nil? || recording.recordable?\n\n stop_and_store_recording(recording)\n free_up_tuner(tuner)\n end\n end", "def refresh!\n records true\n self\n end",...
[ "0.616494", "0.58869547", "0.5764435", "0.5725247", "0.57116747", "0.56718975", "0.56658936", "0.5663742", "0.56364596", "0.5631303", "0.5571284", "0.55143785", "0.5488412", "0.54725367", "0.54506963", "0.54370725", "0.54018414", "0.5374615", "0.53578734", "0.53547543", "0.53...
0.70705295
0
TODO: Check if current recording is lower priority than new request
def check_recordings tuners.times do |tuner| recording = current_recordings[tuner] next if recording.nil? || recording.recordable? stop_and_store_recording(recording) free_up_tuner(tuner) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recorded?\n return ignoring_recorded? if ignoring_request?\n\n @recorded\n end", "def record_request\n now = Time.now\n diff = (now - @start)\n @active_time += diff\n @requests += 1\n\n reset_horizon if now - horizon > @window\n rescue => boom\...
[ "0.60060424", "0.5910615", "0.5718446", "0.5639616", "0.56115866", "0.5437126", "0.5384224", "0.5362841", "0.5322888", "0.53063846", "0.53063846", "0.53063846", "0.52735704", "0.5259102", "0.5254211", "0.5236874", "0.52265984", "0.5210512", "0.5188782", "0.5188226", "0.514265...
0.0
-1
Creates a new reader object, opening a file.
def initialize(filename, verbose) begin @file = File.open(filename, 'r') {|f| f.read} puts Compiler::color_out("Opened file #{filename}", :green) if @verbose rescue Exception => ex puts Compiler::color_out("[error] Couldn't open file #{filename}", :red) end # Marks the next character to be read in the file. @pos = 0 # Counter for the line. @line = 0 # Counter for the column. @column = 0 # Holds the option that was passed. @verbose = verbose end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def open(file, locale)\n new(File.open(file), locale)\n end", "def _open(filename)\n File.open(filename, 'rb')\n end", "def open(filename, mode = 'r', &block)\n raise NotImplementedError\n end", "def initialize(name)\n @fh = File.open(name, 'r')\n end", "...
[ "0.6770429", "0.6763743", "0.6684145", "0.66807795", "0.66690856", "0.6667623", "0.6591398", "0.6562737", "0.65228724", "0.6519875", "0.6478005", "0.64674985", "0.64426905", "0.64426905", "0.6430971", "0.63715106", "0.63647306", "0.63569015", "0.6350012", "0.6313734", "0.6295...
0.0
-1
Reads the next token and returns it.
def next_token # Early return if there is nothing to be read. This means we've reached the end of the file. unless @file[@pos] return nil end # This is the token that will be returned. token = Compiler::Token.new # Initializes a new instance of the automaton. automaton = Automaton.new # Will be set inside the loop, if necessary. increment_next = false # Will be set inside the loop. Marks whether we've reached the end of the file. eof = false # Build a new token while we don't have a new word yet and isn't in the failed state while ((automaton.state != :A || automaton.word.empty?) && automaton.state != :failed) # The next input for the automaton char = @file[@pos] if char # Moves the pointer to the next char @pos += 1 automaton.transition(char) # While the automaton hasn't started to build a new word yet, increments the line and column numbers. # In this phase, we're just skipping blank characters if automaton.word.empty? if increment_next if char == "\n" increment_next = true else increment_next = false end @line += 1 @column = 0 elsif char == "\n" @column += 1 increment_next = true else @column += 1 end end else eof = true puts "breaking" break end end if eof automaton.transition("\n") else @pos -= 1 end if (automaton.type == :identifier) && (Compiler.reserved_words.is_reserved?(automaton.word)) token.type = :reserved_word else token.type = automaton.type end token.value = automaton.word token.line = @line token.column = @column return token end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next\n\t\tif @next_token\n\t\t\ttoken = @next_token\n\t\t\t@next_token = nil\n\t\t\treturn token\n\t\telse\n\t\t\ttoken = read_token\n\t\t\treturn token\n\t\tend\n\tend", "def get_token\n @tokenbuf << read_token if @tokenbuf.length == 0\n return @tokenbuf.shift\n end", "def next_token\n tokens.sh...
[ "0.85137594", "0.83284795", "0.76289797", "0.75773525", "0.75446236", "0.745714", "0.74274457", "0.7396812", "0.73394054", "0.7333171", "0.72810614", "0.72770405", "0.7269252", "0.72438675", "0.722983", "0.7136048", "0.707978", "0.7051579", "0.70159256", "0.7007398", "0.69972...
0.6555857
37
Neue Methode zur Sortierung, geht erst nach Orten, auch wenn kein Startort drin. Hilfsmethoden im PrivateTeil.
def sort_abschnitte_and_umschlaege abschnitt_umschlag_list = [] # Hilfsmethode, baut einen nach Orten sortierten Hash auf. ort_to_detail = sort_abschnitte_and_umschlaege_by_ort File.open("log/transport.log","w"){|f| f.puts "Ort to detail #{ort_to_detail}" } unless self.start_anlage.nil? if self.start_anlage.ort ort_aktuell = self.start_anlage.ort if ort_aktuell.nil? || ort_to_detail[ort_aktuell.id].nil? ort_aktuell = abschnitt_only_start_ort(ort_to_detail.keys) end counter = 0 while not (ort_aktuell.nil? || ort_to_detail.empty? || counter > 100) counter += 1 next_ort = nil ort_aktuell_id = ort_aktuell.nil? ? 0 : ort_aktuell.id unless ort_to_detail[ort_aktuell_id].nil? ort_to_detail[ort_aktuell_id].each do |abschnitt_umschlag| File.open("log/transport.log","a"){|f| f.puts abschnitt_umschlag.attributes } abschnitt_umschlag_list << abschnitt_umschlag next_ort = abschnitt_umschlag.end_ort if abschnitt_umschlag.kind_of? Transportabschnitt end ort_to_detail.delete(ort_aktuell_id) ort_aktuell = next_ort end end # Rest nach Datum sortieren unless ort_to_detail.empty? File.open("log/transport.log","a"){|f| f.puts "Rest nach Datum" } abschnitt_umschlag_list = abschnitt_umschlag_list.concat(sort_abschnitte_and_umschlaege_by_date(ort_to_detail.values.flatten)) end else #File.open("log/transport.log","a"){|f| f.puts "Alles nach Datum" } abschnitt_umschlag_list = abschnitt_umschlag_list.concat(sort_abschnitte_and_umschlaege_by_date(ort_to_detail.values.flatten)) end end #File.open("log/transport.log","a"){|f| f.puts "Transport #{id}: #{abschnitt_umschlag_list.to_s}" } abschnitt_umschlag_list end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort!\n sort_if_needed\n self\n end", "def sort\n return @sort\n end", "def sortable_sort\n @sortable_sort\n end", "def sort\n self[:sort]\n end", "def sort_entries; end", "def sort_order\n super\n end", "def bigSorting(unsort...
[ "0.71970403", "0.71704113", "0.7039452", "0.68838406", "0.6880601", "0.6780432", "0.668855", "0.66365135", "0.663075", "0.65946895", "0.65714157", "0.65668344", "0.6558374", "0.6536777", "0.6536777", "0.65207404", "0.65130645", "0.65114856", "0.65101016", "0.6501846", "0.6483...
0.607021
62
Sammelt alle Durchfahrtsorte zusammen, aus Anlagenorten, Umschlagsorten, Abschnitten und zugeordneten Beobachtungen
def get_known_orte orte = [] check_ort_ll(orte, start_anlage.ort) check_ort_ll(orte, ziel_anlage.ort) transportabschnitte.each do |abschnitt| abschnitt.orte.each do |ort| check_ort_ll(orte, ort) end end umschlaege.each do |umschlag| check_ort_ll(orte, umschlag.ort) end orte end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort_abschnitte_and_umschlaege_by_ort\n ort_to_detail = {}\n self.umschlaege.each do |umschlag|\n ort = umschlag.ort\n ort_id = ort.nil? ? 0 : ort.id\n ort_to_detail[ort_id] ||= []\n ort_to_detail[ort_id] << umschlag\n end \n self.transportabschnitte.each do |abs...
[ "0.6285908", "0.6282542", "0.604449", "0.5906285", "0.58523184", "0.5763519", "0.57453233", "0.5744887", "0.5728028", "0.57207257", "0.56594574", "0.5609961", "0.55795807", "0.5566564", "0.5559516", "0.55353373", "0.553387", "0.5520942", "0.5505037", "0.54290265", "0.5416605"...
0.6246861
2
Sammelt alle Durchfahrtsorte zusammen, aus Anlagenorten, Umschlagsorten, Abschnitten und zugeordneten Beobachtungen
def get_known_orte_with_props orte = {} strecken = [] # Transportabschnitte inklusive Beobachtungsorte und Strecke der Route transportabschnitte.each do |abschnitt| if abschnitt.route && abschnitt.route.name != "Unbekannt" strecken.concat(abschnitt.route.get_strecken) else if abschnitt.start_ort && abschnitt.end_ort && abschnitt.start_ort.lat && abschnitt.end_ort.lat strecken << [abschnitt.start_ort, abschnitt.end_ort] end end check_ort_p(orte, abschnitt.start_ort, "Abschnitt") check_ort_p(orte, abschnitt.end_ort, "Abschnitt") abschnitt.beobachtungen.each do |beob| check_ort_p(orte, beob.ort, "Beobachtung") end end # Umschlaege umschlaege.each do |umschlag| check_ort_p(orte, umschlag.ort, "Umschlag") end # Start und Zielanlage zuletzt, damit auf jeden Fall das aktuellste, andere werden ggf. ueberschrieben check_ort_p(orte, start_anlage.ort, "Start-Anlage") check_ort_p(orte, ziel_anlage.ort, "Ziel-Anlage") if strecken.empty? if umschlaege.empty? && start_anlage.ort && ziel_anlage.ort && start_anlage.ort.lat && ziel_anlage.ort.lat strecken << [start_anlage.ort, ziel_anlage.ort] elsif start_anlage.ort && start_anlage.ort.lat ort_aktuell = start_anlage.ort umschlaege.each do |umschlag| if umschlag.ort strecken << [ort_aktuell, umschlag.ort] ort_aktuell = umschlag.ort end end if ziel_anlage.ort && ziel_anlage.ort.lat strecken << [ort_aktuell, ziel_anlage.ort] end end end return orte, strecken end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort_abschnitte_and_umschlaege_by_ort\n ort_to_detail = {}\n self.umschlaege.each do |umschlag|\n ort = umschlag.ort\n ort_id = ort.nil? ? 0 : ort.id\n ort_to_detail[ort_id] ||= []\n ort_to_detail[ort_id] << umschlag\n end \n self.transportabschnitte.each do |abs...
[ "0.62862504", "0.62471354", "0.6044639", "0.5905612", "0.5852106", "0.5764521", "0.57459384", "0.57434684", "0.5728496", "0.5721294", "0.56581503", "0.560934", "0.55794823", "0.55665576", "0.55592704", "0.55363", "0.5533778", "0.55196124", "0.5505692", "0.5428804", "0.5416437...
0.6282484
1
Wozu ist das da?
def union_scope(*scopes) id_column = "#{table_name}.id" sub_query = scopes.map { |s| s.select(id_column).to_sql }.join(" UNION ") where "#{id_column} IN (#{sub_query})" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def suivre; end", "def zuruecksetzen()\n end", "def verdi; end", "def schubert; end", "def schumann; end", "def terpene; end", "def mi_carrera\n\n\tend", "def berlioz; end", "def sichtbar_machen()\n end", "def pessoavai(lugar)\n puts \"indo para \" + lugar\nend", "def hambriento?\n # Los...
[ "0.7137959", "0.710734", "0.63303626", "0.6330051", "0.6242765", "0.612253", "0.600601", "0.5932082", "0.5880782", "0.58561146", "0.58340615", "0.58340615", "0.5825893", "0.58197296", "0.5800823", "0.57970655", "0.5783055", "0.5767753", "0.5760175", "0.5756281", "0.5754307", ...
0.0
-1
Hilfsmethoden zur Sortierung von Umschlag und Transportkette Sortiert alle Umschlaege und Transportabschnitte in einen Hash, der jeweils den (Start)Ort einer Liste aus Umschlaegen/Abschnitten zuordnet. Umschlaege kommen dabei automatisch zuerst.
def sort_abschnitte_and_umschlaege_by_ort ort_to_detail = {} self.umschlaege.each do |umschlag| ort = umschlag.ort ort_id = ort.nil? ? 0 : ort.id ort_to_detail[ort_id] ||= [] ort_to_detail[ort_id] << umschlag end self.transportabschnitte.each do |abschnitt| ort = abschnitt.start_ort ort_id = ort.nil? ? 0 : ort.id ort_to_detail[ort_id] ||= [] ort_to_detail[ort_id] << abschnitt end ort_to_detail end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort_abschnitte_and_umschlaege\n abschnitt_umschlag_list = []\n # Hilfsmethode, baut einen nach Orten sortierten Hash auf.\n ort_to_detail = sort_abschnitte_and_umschlaege_by_ort\n File.open(\"log/transport.log\",\"w\"){|f| f.puts \"Ort to detail #{ort_to_detail}\" }\n unless self.start_anlage.n...
[ "0.6825506", "0.6770284", "0.6577108", "0.6315837", "0.6312216", "0.61442226", "0.6119186", "0.610977", "0.60954654", "0.60612357", "0.60432863", "0.6029642", "0.60282475", "0.6026845", "0.6002718", "0.596766", "0.5964441", "0.5929854", "0.5928069", "0.5918229", "0.59152645",...
0.6884483
0
Ermittelt den Ort aus dem uebergebenen Array, der kein EndOrt eines Transportabschnitts ist (also der Start der Eingabe)
def abschnitt_only_start_ort orte orte.each do |ort_id| if !ort_id==0 && self.transportabschnitte.where(end_ort_id: ort_id).empty? return ort end end nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_known_orte\n orte = []\n check_ort_ll(orte, start_anlage.ort)\n check_ort_ll(orte, ziel_anlage.ort)\n transportabschnitte.each do |abschnitt|\n abschnitt.orte.each do |ort|\n check_ort_ll(orte, ort)\n end\n end\n umschlaege.each do |umschlag|\n check_ort_ll(orte, ums...
[ "0.5638894", "0.53874624", "0.53819674", "0.5165623", "0.50170946", "0.5015461", "0.49940002", "0.49748528", "0.49748528", "0.49654493", "0.49164858", "0.48458615", "0.48347014", "0.48263434", "0.48260978", "0.48255122", "0.48218706", "0.48143843", "0.47848248", "0.47738844", ...
0.58861893
0
Sortiert die uebergebene List mit Umschlaegen und Abschnitten nach dem EndDatum. Eintraege ohne werden ans Ende gehaengt.
def sort_abschnitte_and_umschlaege_by_date start_liste abschnitt_umschlag_list = [] mit_end_datum = start_liste.select{|element| element.end_datum } #File.open("log/transport.log","a"){|f| f.puts "Mit Ende #{mit_end_datum.to_s}" } abschnitt_umschlag_list.concat(mit_end_datum.sort_by{|element| element.end_datum} ) ohne_end_datum = start_liste.select{|element| element.end_datum.nil? } #File.open("log/transport.log","a"){|f| f.puts "Ohne Ende: #{ohne_end_datum.to_s}" } abschnitt_umschlag_list.concat(ohne_end_datum) #File.open("log/transport.log","a"){|f| f.puts "Liste bei Date #{abschnitt_umschlag_list.to_s}" } abschnitt_umschlag_list end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort_entries; end", "def sort_abschnitte_and_umschlaege_by_ort\n ort_to_detail = {}\n self.umschlaege.each do |umschlag|\n ort = umschlag.ort\n ort_id = ort.nil? ? 0 : ort.id\n ort_to_detail[ort_id] ||= []\n ort_to_detail[ort_id] << umschlag\n end \n self.trans...
[ "0.62856615", "0.6089975", "0.59793365", "0.59428084", "0.5938043", "0.58046347", "0.5739227", "0.573167", "0.57070583", "0.5667715", "0.55733466", "0.550901", "0.54742354", "0.54700524", "0.54565024", "0.5429345", "0.5364981", "0.53395605", "0.5309679", "0.5307433", "0.52731...
0.75931126
0
Hilsmethoden fuers Sammeln der Orte
def check_ort_ll(ort_array, ort) unless ort_array.include? ort ort_array << ort if ort and ort.lon and ort.lat end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toronto\n\n end", "def suivre; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def zuruecksetzen()\n end", "def fOOrth\r\n end", "def fOOrth\r\n end", "def geodatos\n end", "def romeo_and_juliet; end", "def relatorios\n end", "def vehicle; en...
[ "0.6214536", "0.6111044", "0.6037245", "0.6037245", "0.6037245", "0.6037245", "0.59230155", "0.5863991", "0.5863991", "0.58432007", "0.5839328", "0.5807034", "0.5799381", "0.5799381", "0.5799381", "0.5799381", "0.5799381", "0.5782712", "0.57480836", "0.57356644", "0.56457144"...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_user @user = User.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.5...
0.0
-1
Only allow a trusted parameter "white list" through.
def user_params new_hash = {} params[:data][:attributes].each do |key, value| new_hash[key.to_s.gsub("-","_")] = value end if !params[:data][:relationships].nil? params[:data][:relationships].each do |key, value| if value[:data].kind_of?(Array) new_hash[(key.to_s.gsub("-","_").singularize) + "_id"] = value[:data].map {|i| i[:id]} else new_hash[(key.to_s.gsub("-","_").singularize) + "_id"] = value[:data][:id] end end end new_params = ActionController::Parameters.new(new_hash) new_params.permit( :name, :email, :user_type, :user_id, :books_id, :password ) 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.71217275", "0.7052942", "0.6947555", "0.6903013", "0.6735074", "0.67167085", "0.6687677", "0.66765445", "0.66602796", "0.65548825", "0.6524274", "0.6455697", "0.6451343", "0.645123", "0.64465624", "0.6433475", "0.64118403", "0.64118403", "0.6390524", "0.6378871", "0.637887...
0.0
-1
Override Devise method to redirect to dashboard after signing in
def after_sign_in_path_for(resource) sufia.dashboard_index_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_sign_in_path_for(resource)\n dashboard_path || super\n end", "def after_sign_in_path_for(resource_or_scope)\n #Redirect to Dashboard Controller\n dashboard_index_path\n end", "def after_sign_in_path_for(_resource)\n '/dashboard'\n end", "def redirect_to_dashboard_if_logged_in\n if...
[ "0.8014545", "0.7553893", "0.7549594", "0.7532787", "0.75255704", "0.7504837", "0.7504837", "0.7436978", "0.7401057", "0.73998576", "0.7363065", "0.7275049", "0.72434723", "0.72121817", "0.71014494", "0.7084276", "0.70809007", "0.7077479", "0.70350474", "0.70346546", "0.70274...
0.7119276
14
Hook which is overridden in Sufia::Ldap::Controller
def has_access? true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ldap_before_save\n self.email = Devise::LDAP::Adapter.get_ldap_param(self.username, \"mail\").first\n self.encrypted_password = Devise::LDAP::Adapter.get_ldap_param(self.username, \"userPassword\").first\n display_name = Devise::LDAP::Adapter.get_ldap_param(self.username, \"displayName\" )\n if dis...
[ "0.6186267", "0.5959065", "0.5958466", "0.5910203", "0.5910203", "0.584688", "0.5830305", "0.57840824", "0.57649755", "0.57577115", "0.5751258", "0.5739085", "0.57167476", "0.57035655", "0.57015204", "0.5556366", "0.551688", "0.5500935", "0.5490689", "0.5452671", "0.5451868",...
0.0
-1
Do not allocate extra space for another array, you must do this by modifying the input array inplace with O(1) extra memory. Example 1: Given nums = [1,1,2], Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively. It doesn't matter what you leave beyond the returned length. Example 2: Given nums = [0,0,1,1,1,2,2,3,3,4], Your function should return length = 5, with the first five elements of nums being modified to 0, 1, 2, 3, and 4 respectively. It doesn't matter what values are set beyond the returned length.
def remove_duplicates(nums) return 0 if nums.length === 0 curr_idx = 0 j = 0 val = nums[j] while curr_idx < nums.length curr_val = nums[curr_idx] if curr_val === val curr_idx += 1 next else val = curr_val j += 1 nums[j] = curr_val end end j + 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def length_finder(array)\n num_array = []\n array.each do |i|\n num_array.insert(-1,i.length)\n end\n return num_array\nend", "def length_finder(array)\n iterator = 0\n new_array = []\n while iterator < array.length\n new_array << array[iterator].length\n iterator += 1\n end\n new_arr...
[ "0.7248774", "0.6878875", "0.6851354", "0.6750325", "0.6750325", "0.66892046", "0.66438293", "0.6611813", "0.6553832", "0.65508866", "0.65190154", "0.65007913", "0.6474407", "0.6430764", "0.64295167", "0.6425059", "0.6394124", "0.63471335", "0.63398707", "0.63231087", "0.6293...
0.0
-1
Write a method that doubles each element in an array
def doubler(array) array.map { |num| num * 2 } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_doubles(arr)\n arr.map {|a|a*2}\n\nend", "def double_array(array)\n array*2\nend", "def calculate_doubles!(array)\n\t\n\tarray.map! { |num| num * 2}\nend", "def calculate_doubles(arr)\n array = []\n arr.each {|x| array << x + x}\n array\n\nend", "def calculate_doubles!(arr)\n\n arr.ma...
[ "0.78794396", "0.78159004", "0.77839226", "0.76714575", "0.765855", "0.7657117", "0.7644488", "0.76381516", "0.752618", "0.7505966", "0.7437052", "0.7436159", "0.73710144", "0.73264545", "0.7319353", "0.72939056", "0.72790027", "0.71698576", "0.7146905", "0.71308154", "0.7123...
0.6521323
64
Given a grade_hash and assignment number, return all scores for that assignment. Note that Ruby counts arrays from 0, but we are referring to them as 110.
def assignment_scores(grade_hash, assignment_num) grade_hash.map do |student, marks| marks[assignment_num - 1] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assignment_scores(grade_hash, assignment_num)\n a = []\n grade_hash.values.each { |name| a.push(name[assignment_num - 1]) }\n a\nend", "def assignment_scores(grade_hash, assignment_num)\n outArray = []\n grade_hash.each do |key, value|\n outArray.push(value[assignment_num-1])\n\n end\n ...
[ "0.83151335", "0.8272983", "0.814126", "0.80909526", "0.80310076", "0.80189383", "0.800149", "0.7969273", "0.7937633", "0.76114005", "0.76109165", "0.7594158", "0.7568089", "0.756527", "0.75648314", "0.7538011", "0.75132674", "0.7344956", "0.7310454", "0.7274471", "0.7274285"...
0.760292
11
Given a grade_hash and assignment number, return the average score for that assignment. Note that Ruby counts arrays from 0, but we are referring to them as 110.
def assignment_average_score(grade_hash, assignment_num) marks = assignment_scores(grade_hash, assignment_num) marks.sum / marks.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assignment_average_score(grade_hash, assignment_num)\n assignment = grade_hash.map do |key, value|\n value[assignment_num - 1]\n end\n\n sum = assignment.reduce do |sum, x|\n sum += x\n end\n\n sum / assignment.length\nend", "def assignment_average_score(grade_hash, assignment_num)\n a = []\n gr...
[ "0.9109706", "0.9074288", "0.90641165", "0.9055428", "0.89904875", "0.8978579", "0.8958803", "0.8855718", "0.8777972", "0.8731957", "0.8276149", "0.7820606", "0.7698085", "0.7590732", "0.7590732", "0.7590732", "0.7590732", "0.7590732", "0.75853384", "0.75819963", "0.75176793"...
0.89088017
7
Return a hash of students and their average score. TIP: To convert an array like [[:indiana, 90], [:nevada, 80]] to a hash, use .to_h. Also look at Hashtransform_values.
def averages(grade_hash) grade_hash.transform_values { |marks| marks.inject {|sum, n| sum + n } / marks.length } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def averages(grade_hash)\n student_average_array = grade_hash.map do |key, value|\n average = value.sum / value.length\n [key, average]\n end\n student_average_array.to_h\nend", "def averages(grade_hash)\n\n averages = grade_hash.map do |key, value|\n total = 1\n sum = grade_hash[key].reduce do |...
[ "0.75405383", "0.7045323", "0.69985765", "0.69742346", "0.6856095", "0.6760799", "0.6706752", "0.67057437", "0.665328", "0.66252494", "0.6591957", "0.65469205", "0.6479361", "0.6476152", "0.6472911", "0.6454798", "0.6446286", "0.64321405", "0.638457", "0.635152", "0.63483834"...
0.67456746
6
Return a letter grade for a numerical score. 90+ => A 8089 => B 7079 => C 6069 => D F
def letter_grade(mark) case mark when 90..1000 "A" when 80..89 "B" when 70..79 "C" when 60..69 "D" else "F" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def letter_grade(score)\n if score>90\n \"A\"\n elsif score>=80 && score<=89\n \"B\"\n elsif score>=70 && score<=79\n \"C\"\n elsif score>=60 && score<=69\n \"D\"\n else\n \"F\"\n end\nend", "def letter_grade(score)\n if score >= 90\n return \"A\"\n elsif score >= 80 && score <= 89\n ...
[ "0.8516908", "0.8446878", "0.8414356", "0.84088415", "0.8391743", "0.8365784", "0.8348283", "0.8333557", "0.8243077", "0.820097", "0.8191554", "0.8165062", "0.80988467", "0.7919422", "0.7898124", "0.7887183", "0.7847319", "0.7768562", "0.7761602", "0.7758619", "0.77499914", ...
0.7435126
45
Return a hash of students and their final letter grade, as determined by their average.
def final_letter_grades(grade_hash) averages(grade_hash).transform_values{ |marks| letter_grade(marks)} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def final_letter_grades(grade_hash)\n averages = grade_hash.inject({}) { |h, (k,v)| h[k] = letter_grade(v.reduce{|x,n| x += n}/v.length) ; h}\nend", "def final_letter_grades(grade_hash)\n letter_grade averages grade_hash\nend", "def final_letter_grades(grade_hash)\n averages = averages(grade_hash)\n\n fina...
[ "0.7814751", "0.7780114", "0.7737784", "0.7596652", "0.7564736", "0.7560241", "0.7505347", "0.7385984", "0.72480476", "0.7098098", "0.70480067", "0.6964807", "0.6957521", "0.6919024", "0.69028676", "0.69000435", "0.68883234", "0.6882915", "0.6862444", "0.6828487", "0.68096834...
0.75707203
4