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
failsafe check incase there are no users that are admin
def has_no_admin? if e = Employee.find_by_employee_type("Administrator") if User.find_by_employee_id(e) return false else return true end else return true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deny_admin_suicide\n raise 'admin suicided' if User.count(&:admin) <= 1\n end", "def deny_admin_suicide\n raise 'admin suicided' if User.count(&:admin) <= 1\n end", "def verify_admin\n admin_is_logged_in? || not_found\n end", "def admin_restrictions\n unless AdminUser.find(:all).empty?\n ...
[ "0.7964057", "0.7964057", "0.7953502", "0.7910416", "0.7910005", "0.7908496", "0.7761762", "0.7755899", "0.7755899", "0.77503484", "0.7716926", "0.7698057", "0.7679258", "0.7679258", "0.7663989", "0.7630013", "0.76122206", "0.7603283", "0.7599724", "0.7594981", "0.75853705", ...
0.76701146
14
Use callbacks to share common setup or constraints between actions.
def set_quiz @quiz = Quiz.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.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
Only allow a trusted parameter "white list" through.
def quiz_params params.require(:quiz).permit(:status, :course_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.638045...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_board_and_task_group @board = Board.find(params[:board_id]) @task_group = TaskGroup.find(params[:task_group_id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def task_params params.require(:task).permit(:board_id, :task_group_id, :id, :title) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.6980629", "0.67819995", "0.67467666", "0.67419875", "0.67347664", "0.65928614", "0.6504013", "0.6498014", "0.64819515", "0.64797956", "0.64562726", "0.64400834", "0.6380117", "0.6377456", "0.63656694", "0.6320543", "0.63002014", "0.62997127", "0.629425", "0.6293866", "0.62...
0.0
-1
This method will call `user_logged_out` and may supply an URL that should be presented to the user. As per specification, the URL specified by "url" SHOULD be on the logout page with descriptive text. For example, "The application you just logged out of has provided a link it would like you to follow. Please click here to access
def process(params = nil, cookies = nil, user_agent = nil) params ||= {} cookies ||= {} remove_ticket_granting_ticket(cookies[:tgt], user_agent) if params[:service] && CASino::ServiceRule.allowed?(params[:service]) @listener.user_logged_out(params[:service], true) else @listener.user_logged_out(params[:url]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logout\n logout_redirect = Settings.logout_redirect\n if logout_redirect == 'NONE'\n page_not_found\n return\n end\n MarkusLogger.instance.log(\"User '#{real_user.user_name}' logged out.\")\n clear_session\n if logout_redirect == 'DEFAULT'\n redirect_to action: 'login'\n els...
[ "0.6793703", "0.6770693", "0.6770693", "0.6757364", "0.66374665", "0.6601186", "0.6601186", "0.6601186", "0.6519576", "0.64567596", "0.64556545", "0.64495003", "0.6442229", "0.6434947", "0.64084774", "0.640385", "0.63797617", "0.6361612", "0.6339115", "0.6319637", "0.63118523...
0.0
-1
short title for lists and callback for ...ables
def list_title(n=40) st = name[0..n].to_s st += "..." unless name.length <= n st end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def title_for_list(object)\n return \"List of \" + MyAdmin.prepare_title(object)\n end", "def title=(_arg0); end", "def title=(_arg0); end", "def title=(_arg0); end", "def title_name; end", "def title; end", "def title; end", "def title; end", "def title; end", "def title; end", "def title;...
[ "0.68663794", "0.6500497", "0.6500497", "0.6500497", "0.64935803", "0.6426945", "0.6426945", "0.6426945", "0.6426945", "0.6426945", "0.6426945", "0.6426945", "0.6426945", "0.6426945", "0.6426945", "0.6426945", "0.6426945", "0.6426945", "0.6426945", "0.6426945", "0.6426945", ...
0.0
-1
TODO: Check if user allowed to read this posting This callback is used by tagables and therefor it is defined as this simple placeholder yet
def read_allowed?(user) true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def raw_post; end", "def process_post(post)\n # No-op.\n end", "def post_reader; end", "def process_post\n true\n end", "def fetch_create_post\n end", "def view_post\n content \n end", "def force_post\n @type = \"post\"\n @post = \"\"\n end", "def post; end", "def po...
[ "0.6901791", "0.65994835", "0.63145477", "0.61551404", "0.6060221", "0.59365666", "0.5908595", "0.59006", "0.58948976", "0.5867928", "0.5842847", "0.57946175", "0.5772395", "0.5694198", "0.5686122", "0.5663522", "0.5640944", "0.5637536", "0.5626762", "0.55764174", "0.5574192"...
0.0
-1
If attachment deleted destroy meta data
def save if (not @queued_for_delete.empty?) and @queued_for_write.empty? instance_write(:meta, ActiveSupport::Base64.encode64(Marshal.dump({}))) if instance.respond_to?(:"#{name}_meta=") end original_save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @attachment.detach\n head :no_content\n end", "def destroy_attachment\n a = Attachment.find(1) rescue nil\n if !a.nil?\n a.destroy\n end\n end", "def delete\n model.delete_attachment(@path)\n end", "def destroy\n @attachment.file.purge\n @attachment.d...
[ "0.7505327", "0.72655946", "0.72537184", "0.722451", "0.7019613", "0.6984565", "0.6864259", "0.68231374", "0.68230915", "0.68118167", "0.67784214", "0.6778171", "0.6775958", "0.67725444", "0.6767854", "0.67676735", "0.67615664", "0.6760627", "0.675868", "0.6757567", "0.671788...
0.0
-1
get styles sorted by size from largest to smallest :original if it exists is always first
def weighted_styles(input) Hash[input.sort_by do |meta_style_name,meta_style| r = if meta_style_name == :original -9999999999999 else 0 - (meta_style[:width].to_i + meta_style[:height].to_i) end end] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def styles\n return if @styles.empty?\n @styles.uniq.sort\n end", "def closest_size(object, size)\n sizes = object.options[:styles].values.collect{ |x| { x => parse_size(x) } }.sort_by{ |x| x.values }\n closest_size_hash = sizes.min_by { |x| ( x.values.first.to_f - Column.sizes[size] ).abs }\n ...
[ "0.69042706", "0.60257554", "0.57862645", "0.5618286", "0.5600652", "0.5464023", "0.54195535", "0.53988194", "0.5328606", "0.5220255", "0.51080793", "0.5108019", "0.5072314", "0.5069812", "0.5060404", "0.49429885", "0.48961172", "0.48839307", "0.48715746", "0.48672637", "0.48...
0.67744756
1
if this attachment is a remote url (i.e. not local filesystem)
def remote_url?(style_name = default_style) return (meta and meta.has_key?(style_name) and meta[style_name][:url]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_file_source_a_remote_url?\n !self.remote_url.blank?\n end", "def remote?\n uri = URI.parse url\n %w( http https ).include?(uri.scheme)\n rescue URI::BadURIError\n false\n rescue URI::InvalidURIError\n if @type == \"image\"\n @ignored = true\n ret...
[ "0.77162385", "0.7581699", "0.74921334", "0.74285215", "0.6818109", "0.67042357", "0.6699845", "0.66079175", "0.66022384", "0.6597251", "0.6596749", "0.65823776", "0.6537149", "0.6506146", "0.64927673", "0.6371597", "0.6349688", "0.63333774", "0.63324314", "0.6287656", "0.625...
0.63316256
19
overwrite paperclips URL so we check meta for a url and use that if it's set otherwise fallback to paperclip standard behavior
def url(style_name = default_style, use_timestamp = @use_timestamp) if remote_url?(style_name) meta[style_name][:url] else default_url = @default_url.is_a?(Proc) ? @default_url.call(self) : @default_url url = original_filename.nil? ? interpolate(default_url, style_name) : interpolate(@url, style_name) use_timestamp && updated_at ? [url, updated_at].compact.join(url.include?("?") ? "&" : "?") : url end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def base_photo_url\n \"#{URL}#{self.photo.url}/\".gsub('/original/','/large/')\n end", "def photo_src\n self.photo.present? ? self.photo.picture_url : Prize::DEFAULT_IMG\n end", "def imgurl\n picref.imgurl if picref\n end", "def photo_url\n defined?(object.photo) ? object.photo.url : ''\n end",...
[ "0.6498706", "0.6480759", "0.6438075", "0.64338565", "0.63937163", "0.63923943", "0.6307063", "0.62669975", "0.62540394", "0.62483495", "0.6216716", "0.6198377", "0.61982334", "0.6194582", "0.61869264", "0.6185021", "0.6149988", "0.6143334", "0.61148214", "0.60870934", "0.608...
0.0
-1
Baseline implementation for the abandon_instances REST call
def abandon_instances request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_abandon_instances_request request_pb response = @client_stub.make_post_request( uri: uri, body: body, params: query_string_params, options: options ) result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unmonitor_instances( options = {} )\n options = { :instance_id => [] }.merge(options)\n raise ArgumentError, \"No :instance_id provided\" if options[:instance_id].nil? || options[:instance_id].empty?\n params = pathlist(\"InstanceId\", options[:instance_id])\n return response_genera...
[ "0.60044473", "0.59776807", "0.5977602", "0.5635921", "0.5525691", "0.55182695", "0.55030507", "0.54494196", "0.5436976", "0.541044", "0.5407295", "0.5401262", "0.539516", "0.5370092", "0.5358628", "0.53511506", "0.5342512", "0.5342512", "0.5320943", "0.5306046", "0.5306046",...
0.7635395
0
Baseline implementation for the aggregated_list REST call
def aggregated_list request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, _body, query_string_params = transcode_aggregated_list_request request_pb response = @client_stub.make_get_request( uri: uri, params: query_string_params, options: options ) result = ::Google::Cloud::Compute::V1::InstanceGroupManagerAggregatedList.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def aggregated_list request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_aggregated_list_request request_pb\n query_string_params = if query_string_params.any?...
[ "0.677039", "0.6543518", "0.64048564", "0.6356955", "0.6265128", "0.60694504", "0.5953424", "0.5902644", "0.5884521", "0.5846486", "0.5786312", "0.5777131", "0.57170635", "0.5693815", "0.56825435", "0.5665302", "0.5664142", "0.56616646", "0.5660386", "0.56501734", "0.5619399"...
0.66661304
1
Baseline implementation for the apply_updates_to_instances REST call
def apply_updates_to_instances request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, _query_string_params = transcode_apply_updates_to_instances_request request_pb response = @client_stub.make_post_request( uri: uri, body: body, options: options ) result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update!(**args)\n @instances = args[:instances] if args.key?(:instances)\n @parameters = args[:parameters] if args.key?(:parameters)\n end", "def update!(**args)\n @instances = args[:instances] if args.key?(:instances)\n end", "def update!(**args)\n @instan...
[ "0.6883882", "0.68352866", "0.6265813", "0.62466383", "0.6238221", "0.6211436", "0.6211436", "0.6191201", "0.61702627", "0.6146737", "0.61356735", "0.6107843", "0.61044765", "0.60995483", "0.60612357", "0.5985783", "0.5940671", "0.5932814", "0.59143525", "0.59143525", "0.5914...
0.774701
0
Baseline implementation for the create_instances REST call
def create_instances request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_create_instances_request request_pb response = @client_stub.make_post_request( uri: uri, body: body, params: query_string_params, options: options ) result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_instances(count)\n fail DTK::Error::Usage, \"Attribute 'admin_state' cannot be set to powered_off if node not created\" if admin_state_powered_off?\n aws_api_operation(:create).create_instances(count)\n end", "def list_instances\n puts \"OK, Listing instances..\"\n\n respons...
[ "0.6584818", "0.6575652", "0.6542225", "0.6496084", "0.6481429", "0.6430838", "0.6359172", "0.6347453", "0.631569", "0.6275118", "0.6216435", "0.6196346", "0.6187581", "0.6183696", "0.6154394", "0.6144067", "0.6094609", "0.60598737", "0.6059305", "0.6059305", "0.6059305", "...
0.6957502
0
Baseline implementation for the delete REST call
def delete request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, _body, query_string_params = transcode_delete_request request_pb response = @client_stub.make_delete_request( uri: uri, params: query_string_params, options: options ) result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deleteRequest\n\n end", "def delete(*rest) end", "def delete endpoint\n do_request :delete, endpoint\n end", "def delete\n \n end", "def delete\n request(:delete)\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n ...
[ "0.7802069", "0.77865505", "0.77285236", "0.76946294", "0.76316744", "0.7574076", "0.7574076", "0.7574076", "0.7574076", "0.75177145", "0.7461495", "0.74103874", "0.7405241", "0.7404677", "0.73817897", "0.73817897", "0.73817897", "0.73817897", "0.73817897", "0.73817897", "0.7...
0.0
-1
Baseline implementation for the delete_instances REST call
def delete_instances request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_delete_instances_request request_pb response = @client_stub.make_post_request( uri: uri, body: body, params: query_string_params, options: options ) result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @instance = @provider.instances.find(params[:id])\n InstanceOperations.terminate_instances(@provider.connect!, @instance)\n @instance.destroy\n redirect_to cloud_provider_path(@provider) \n end", "def delete_instance request_pb, options = nil\n raise ::ArgumentError, \...
[ "0.7173356", "0.69271666", "0.6916623", "0.6858635", "0.68051195", "0.67992944", "0.6747067", "0.6720948", "0.66915864", "0.6668431", "0.661892", "0.6613864", "0.66122", "0.65790457", "0.65720403", "0.6541037", "0.6516814", "0.65114725", "0.65038973", "0.6482585", "0.64782053...
0.75676584
0
Baseline implementation for the delete_per_instance_configs REST call
def delete_per_instance_configs request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, _query_string_params = transcode_delete_per_instance_configs_request request_pb response = @client_stub.make_post_request( uri: uri, body: body, options: options ) result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n results = submit_cmd('delete app instance',:db, \" -env #{self.belongs_to.env} -app_instance #{self.name}\")\n\n\t if ( results.to_s =~ /failure/i || results.to_s =~ /error/i)\n\t \t raise \"update attribute failed\" \n\t else\n\t \t self.belongs_to.appTemplates.delete(self)\n\t ...
[ "0.666113", "0.6406594", "0.63268644", "0.63054687", "0.6301974", "0.6280173", "0.622278", "0.6214791", "0.61849886", "0.6165851", "0.6144899", "0.6134959", "0.61263174", "0.61263174", "0.60994625", "0.6043661", "0.6042849", "0.602909", "0.602001", "0.6015857", "0.6013635", ...
0.7935633
0
Baseline implementation for the get REST call
def get request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, _body, _query_string_params = transcode_get_request request_pb response = @client_stub.make_get_request( uri: uri, options: options ) result = ::Google::Cloud::Compute::V1::InstanceGroupManager.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get; end", "def _get\n http_method(:get)\n end", "def rest_endpoint; end", "def rest_get(base_uri,params)\n begin\n @response = RestClient.get(base_uri,params)\n rescue => e\n puts @response.code\n end\n return @response\n end", "def http_method\n :get\n end", "def ...
[ "0.73324287", "0.7292981", "0.70138574", "0.693026", "0.6865241", "0.6816611", "0.6803572", "0.6795961", "0.6773166", "0.6773166", "0.6769716", "0.67421967", "0.6724426", "0.664156", "0.6633361", "0.66158813", "0.6603196", "0.65990484", "0.65990484", "0.65959835", "0.65769184...
0.0
-1
Baseline implementation for the insert REST call
def insert request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_insert_request request_pb response = @client_stub.make_post_request( uri: uri, body: body, params: query_string_params, options: options ) result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert()\n\n end", "def _insert(*)\n fail NotImplementedError\n end", "def handle_insert action, result; end", "def insert(*args)\n json_op(:insert, self, *path_value_args(args))\n end", "def do_insert options = {}\n\t\t\t\tif !options[:local]\n\t\t\t\t\tattr_hash = build_a...
[ "0.68304694", "0.67885107", "0.65469646", "0.6455043", "0.6447416", "0.62639767", "0.62388176", "0.62276345", "0.6207762", "0.61992866", "0.6194636", "0.61918", "0.6161281", "0.6146445", "0.6061359", "0.6021233", "0.60108995", "0.5947294", "0.5913008", "0.58946455", "0.586934...
0.54105353
67
Baseline implementation for the list REST call
def list request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, _body, query_string_params = transcode_list_request request_pb response = @client_stub.make_get_request( uri: uri, params: query_string_params, options: options ) result = ::Google::Cloud::Compute::V1::InstanceGroupManagerList.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list(params={})\n super params\n end", "def list(params={})\n super params\n end", "def list\n url = prefix + \"list\"\n return response(url)\n end", "def list(params)\n raise NotImplementedError\n end", "def list\n url = prefix + \"list\"\n return response(...
[ "0.7385454", "0.7385454", "0.7107155", "0.70807445", "0.70114005", "0.6957106", "0.69419384", "0.6810357", "0.6810357", "0.6801985", "0.6793892", "0.6779634", "0.67378944", "0.669565", "0.66605836", "0.66365844", "0.6626355", "0.66235787", "0.66235787", "0.66235787", "0.66149...
0.0
-1
Baseline implementation for the list_managed_instances REST call
def list_managed_instances request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, _body, query_string_params = transcode_list_managed_instances_request request_pb response = @client_stub.make_post_request( uri: uri, params: query_string_params, options: options ) result = ::Google::Cloud::Compute::V1::InstanceGroupManagersListManagedInstancesResponse.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def instances\n IbmCloudRest.get \"#{@uri}/instances\"\n end", "def list_instances request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_instances_request reque...
[ "0.6785314", "0.6707827", "0.67024165", "0.66163045", "0.6592045", "0.6518914", "0.6486547", "0.6375934", "0.6336464", "0.62879074", "0.6271091", "0.62462926", "0.6223105", "0.61295605", "0.6087064", "0.6024314", "0.5995872", "0.5994039", "0.5987333", "0.594529", "0.59224355"...
0.72735983
0
Baseline implementation for the list_per_instance_configs REST call
def list_per_instance_configs request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, _body, query_string_params = transcode_list_per_instance_configs_request request_pb response = @client_stub.make_post_request( uri: uri, params: query_string_params, options: options ) result = ::Google::Cloud::Compute::V1::InstanceGroupManagersListPerInstanceConfigsResp.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def describe_instances\n return { reservations: [] } unless configured?\n\n @client.describe_instances.to_h\n end", "def enum_configs\n host = session.session_host\n port = session.session_port\n exec_commands = [\n {\n 'cmd' => '/export verbose',\n 'fn' => 'get_config',\n ...
[ "0.5900954", "0.5900258", "0.5876186", "0.57415944", "0.5683448", "0.56613314", "0.5642259", "0.55652124", "0.5553273", "0.55482", "0.55456716", "0.5534673", "0.5513303", "0.5498094", "0.54680383", "0.5464475", "0.5461902", "0.5444085", "0.54376256", "0.5437029", "0.53954875"...
0.72597617
0
Baseline implementation for the patch REST call
def patch request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_patch_request request_pb response = @client_stub.make_patch_request( uri: uri, body: body, params: query_string_params, options: options ) result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch; end", "def patch; end", "def patch\n end", "def rest_patch(base_uri,json_payload,params)\n begin\n @response = RestClient.patch(base_uri,json_payload,params)\n rescue => e\n puts @response.code\n end\n return @response\n end", "def patch(*args, &block); end", "def patch...
[ "0.76958907", "0.76958907", "0.7610176", "0.7416563", "0.71885127", "0.7109683", "0.6967185", "0.6799357", "0.6794835", "0.669967", "0.666242", "0.665489", "0.6611944", "0.6583517", "0.6557374", "0.65187", "0.6514116", "0.6513869", "0.6441081", "0.6395429", "0.6363385", "0....
0.61150473
32
Baseline implementation for the patch_per_instance_configs REST call
def patch_per_instance_configs request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_patch_per_instance_configs_request request_pb response = @client_stub.make_post_request( uri: uri, body: body, params: query_string_params, options: options ) result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_per_instance_configs request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, body, query_string_params = transcode_update_per_instance_configs_request request_pb\n response = @client_stub.make_post_request(\...
[ "0.68494856", "0.5918646", "0.5859882", "0.5859882", "0.5806079", "0.57658654", "0.57304156", "0.56215", "0.560534", "0.5602159", "0.55409354", "0.5531964", "0.5418074", "0.54102844", "0.54032946", "0.53555703", "0.53555167", "0.5332237", "0.5299539", "0.5297913", "0.5275466"...
0.7523682
0
Baseline implementation for the recreate_instances REST call
def recreate_instances request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_recreate_instances_request request_pb response = @client_stub.make_post_request( uri: uri, body: body, params: query_string_params, options: options ) result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_instances(num_vms, opts, roles, disks)\n # Make a copy (the options are a simple hash so shallow copy does the\n # trick) to not modify the original.\n options = opts.clone\n options['num_vms'] = num_vms.to_s\n\n uri = URI(\"http://#{@ip}:#{SERVER_PORT}/instances\")\n headers = {'Content-...
[ "0.6358541", "0.60766006", "0.5926458", "0.59236604", "0.58288854", "0.5812304", "0.58088934", "0.5766058", "0.575676", "0.5708074", "0.5683103", "0.5616821", "0.56145215", "0.5608361", "0.55885017", "0.5580009", "0.55400705", "0.55069363", "0.54900926", "0.5471066", "0.54499...
0.75045586
0
Baseline implementation for the resize REST call
def resize request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, _body, query_string_params = transcode_resize_request request_pb response = @client_stub.make_post_request( uri: uri, params: query_string_params, options: options ) result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resize!\n end", "def resize\n image = ManagedImage.from_path(params[:image])\n width = params[:width].to_i\n height = params[:height].to_i\n render json: image.resize(width, height)\n end", "def resize(width, height); end", "def check_for_resize; end", "def resize(width, height)\n end", ...
[ "0.7590879", "0.7240322", "0.7187216", "0.71148086", "0.7111367", "0.69803596", "0.69200355", "0.6864851", "0.68391937", "0.67687315", "0.676854", "0.6744202", "0.6657108", "0.6625247", "0.6620215", "0.65799457", "0.6576061", "0.65647846", "0.648442", "0.64669526", "0.6464831...
0.6321908
25
Baseline implementation for the set_instance_template REST call
def set_instance_template request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_set_instance_template_request request_pb response = @client_stub.make_post_request( uri: uri, body: body, params: query_string_params, options: options ) result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_template\n end", "def set_instance_template_properties# {{{\n\t # if we got here, it means some of parameters changed\n\t # it does not matter which one - we just need to create another template\n\t # and generate refresh event (automatically)\n\t #\n\t #\tXXX may be we should have ensure propert...
[ "0.7187446", "0.66969496", "0.6479128", "0.6347294", "0.6330435", "0.6271301", "0.62692606", "0.6266801", "0.6229911", "0.6229911", "0.6229911", "0.6229911", "0.6229911", "0.6229911", "0.6229911", "0.6229911", "0.622791", "0.6210036", "0.61730504", "0.61678326", "0.6100469", ...
0.77391225
0
Baseline implementation for the set_target_pools REST call
def set_target_pools request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_set_target_pools_request request_pb response = @client_stub.make_post_request( uri: uri, body: body, params: query_string_params, options: options ) result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pools\n @pools ||= {}\n end", "def pools\n @pools ||= {}\n end", "def get_pool_names\n JSON.parse(get(\"http://#{@host}/loadbalancers/tenant/#{@tenant}/pools\"))['tenantpools']['pools']\n end", "def list_pools\n handle_action_exceptions(__method__) do\n cmd_line = ...
[ "0.64109004", "0.64109004", "0.6296743", "0.6281177", "0.62099504", "0.6116906", "0.60760635", "0.5974923", "0.5969901", "0.5969901", "0.5969901", "0.59464973", "0.5939732", "0.5929891", "0.5927853", "0.59101754", "0.59054935", "0.58772707", "0.58763534", "0.58741593", "0.587...
0.80211663
0
Baseline implementation for the update_per_instance_configs REST call
def update_per_instance_configs request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_update_per_instance_configs_request request_pb response = @client_stub.make_post_request( uri: uri, body: body, params: query_string_params, options: options ) result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true yield result, response if block_given? result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch_per_instance_configs request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, body, query_string_params = transcode_patch_per_instance_configs_request request_pb\n response = @client_stub.make_post_request(\n ...
[ "0.6811642", "0.6776814", "0.6315448", "0.62597513", "0.62576294", "0.6195071", "0.61715454", "0.6149493", "0.6065071", "0.60359526", "0.6019862", "0.6013464", "0.6013131", "0.5985889", "0.5985889", "0.5879221", "0.5803371", "0.57976645", "0.57976645", "0.579598", "0.5788356"...
0.7395426
0
This filter is used to set the selected tab for the New and Create actions.
def register_layout_setup @tab = :register end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_selected_tab\n end", "def create_tabs\n end", "def prepare_project_tabs(selected)\n nav_bar(:tabs) do |nb|\n nb.nav_item :overview, project_path(@project)\n nb.nav_item :budget, budget_project_path(@project)\n nb.nav_item :history, history_project_path(@project)\n nb.nav_it...
[ "0.68872184", "0.6220431", "0.6060745", "0.60167944", "0.5969301", "0.5876113", "0.5799229", "0.57912546", "0.5746225", "0.5733679", "0.56440645", "0.55861306", "0.55856234", "0.5566003", "0.5561013", "0.5534241", "0.5528404", "0.5491456", "0.5487351", "0.5459731", "0.5402871...
0.0
-1
This filter is used to set the selected tab for the Edit and Update actions.
def user_layout_setup @tab = :user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_selected_tab\n end", "def change_tab\n assert_privileges('my_settings_admin')\n @tabform = \"ui_\" + params['uib-tab'] if params['uib-tab'] != \"5\"\n edit\n render :action => \"show\"\n end", "def select_tab\n select find_by_id(handles.selected.tab_id)\n end", "def selected_tab...
[ "0.6978443", "0.6668546", "0.6193674", "0.6178964", "0.6078628", "0.6039708", "0.5849016", "0.58365387", "0.5812621", "0.57447326", "0.5705294", "0.5659168", "0.5634589", "0.562936", "0.562936", "0.55709714", "0.5528786", "0.5498414", "0.54894584", "0.54866666", "0.5477907", ...
0.0
-1
GET /users Action method to display a list of all the users. The presentation of this remains to be decided.
def index @users = User.all @user = retrieve_authenticated_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_users\n self.class.get('/users')\n end", "def users\n get('get_users')\n end", "def list\n # ask the user_repository for a list of all the users\n users = @user_repository.all\n # pass that list to the view to display\n @view.list_users(users)\n end", "def users_list(opt...
[ "0.84645474", "0.8256386", "0.8199175", "0.8184251", "0.8104956", "0.80996245", "0.8073911", "0.8057535", "0.80385315", "0.8036241", "0.8028134", "0.8020411", "0.80035895", "0.7985874", "0.7971822", "0.7950718", "0.79107404", "0.790762", "0.790762", "0.790762", "0.7894006", ...
0.788455
27
GET /users/:id Action method to display detailed information about a specific user.
def show @user = User.find(params[:id]) @user_me = retrieve_authenticated_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show(id)\n response = request(:get, \"/users/#{id}.json\")\n response[\"user\"]\n end", "def show\n\t\t@user = User.find(params[:id]) rescue nil\n\t\tif @user\n\t\t\tapi_response(@user, 'User Details', :ok)\n\t\telse\n\t\t\tapi_response(nil, 'User id not present in the database', :bad_request)\n...
[ "0.8396419", "0.82655483", "0.8114963", "0.80285114", "0.79702365", "0.79603076", "0.79362625", "0.7909691", "0.79018164", "0.78963256", "0.78963256", "0.78963256", "0.78963256", "0.78963256", "0.7865521", "0.78457457", "0.7791582", "0.778364", "0.7773355", "0.7770669", "0.77...
0.0
-1
GET /users/:id/edit Action method to edit a specific user. TODO: Manage authorizations to filter who can access this page.
def edit @user = User.find(params[:id]) @countries = Country.all.map { |country| [country.name, country.id] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit\n @userToEdit = User.find(params[:id])\n end", "def edit\n \n @user = User.find(params[:id])\n \n end", "def edit\n @user = User.find(params[:id])\n end", "def edit\n @user = User.find(params[:id])\n end", "def edit\n # find the user we want to edit by id\n ...
[ "0.8620834", "0.857214", "0.8517691", "0.8517691", "0.84981936", "0.84946084", "0.8467813", "0.8467813", "0.8467304", "0.8460322", "0.8460322", "0.8460322", "0.8460322", "0.84502554", "0.8447095", "0.84469664", "0.84469664", "0.84469664", "0.84469664", "0.84469664", "0.844696...
0.0
-1
GET /users/new Action method to register.
def new @user = User.new @countries = Country.all.map { |country| [country.name, country.id] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n # When a http GET request to '/users/new' is received, have it render:\n # a view file with an empty form to create a new user.\n end", "def new_user\n\t\t@resource = User.new\n\t\t@resource_name = 'user'\n\tend", "def new_user\n \trender action: 'new_user'\n end", "def newUser\n end", ...
[ "0.8076337", "0.7715464", "0.7386647", "0.7380369", "0.7378444", "0.7368971", "0.7364209", "0.7349267", "0.7338118", "0.7318484", "0.7299228", "0.72966444", "0.72891223", "0.7279196", "0.7219849", "0.7209128", "0.718016", "0.7176632", "0.71715134", "0.71701187", "0.7169588", ...
0.0
-1
POST /users Action method to send the registration form.
def create @user = User.new(params[:user]) if @user.save redirect_to root_url, :notice => { :title => "Success!", :message => "Your are now a Purerasmus member." } else render :new end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def registration\n \tif request.post?\n user = User.new(user_params)\n if user.valid?\n user.save\n flash[:notice] = \"Registration Successful. Please Sign In!\"\n redirect_to root_url\n else\n flash[:alert] = user.errors.first[1]\n redirect_to users_registration_...
[ "0.76302934", "0.7442694", "0.72688663", "0.7257634", "0.7227401", "0.71505135", "0.7111431", "0.7016545", "0.7011914", "0.70106393", "0.69532365", "0.6944105", "0.69163346", "0.6853445", "0.6845185", "0.67922807", "0.6788142", "0.67836565", "0.67671555", "0.6760115", "0.6756...
0.0
-1
PUT /users/:id Action method to send the "edit user" form.
def update @user = User.find(params[:id]) if @user.update_attributes(params[:user]) redirect_to @user, :notice => { :message => "Your profile was updated." } else render :edit end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit(id, options={})\n request(:put, \"/users/#{id}.json\", default_params(options))\n end", "def edit\n # return an HTML form for editing a specific user\n @user = User.find(params[:id])\n end", "def edit\n @user = User.find(params[:id])\n @user.update(user_params)\n end", "def edi...
[ "0.88036335", "0.81233704", "0.8091911", "0.807804", "0.7990107", "0.79332477", "0.7912022", "0.7912022", "0.7894047", "0.7890822", "0.7890822", "0.7890822", "0.7890822", "0.78784555", "0.78749394", "0.7865389", "0.7857433", "0.784533", "0.784533", "0.784533", "0.784533", "...
0.0
-1
DELETE /users/:id Action method to delete a specific user.
def destroy User.find(params[:id]).destroy redirect_to users_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(user_id)\n self.class.delete(\"/#{@api_ver}/users/#{user_id}\", default_options_to_merge_with)\n end", "def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end", "def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end", ...
[ "0.8521025", "0.8508597", "0.8504509", "0.8502862", "0.8423555", "0.8379913", "0.83688205", "0.83614385", "0.83509684", "0.83306587", "0.8323528", "0.8323184", "0.8271494", "0.8265458", "0.8265458", "0.8243315", "0.8242431", "0.824241", "0.82377124", "0.8235619", "0.82222617"...
0.8089882
44
convert Kata in input to Hira in output
def convertFile(inputName, outputName) # output file outputFile = File.open(outputName, "w") # input file File.open(inputName, "r") do |inputFile| pattern = /^(\S+?,){#{READ_FORM_INDEX}}/ while line = inputFile.gets startIndex = line[pattern].size endIndex = line.index(',', startIndex) x = startIndex while x < endIndex do kata = line[x,2] if $kataHira[kata] line[x,2] = $kataHira[kata] else puts "line: #{inputFile.lineno}, unkown katakana: #{kata}" end x += 2 end outputFile.puts line end end outputFile.close end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preprocess(input); end", "def kesha_maker(array)\n array.map {|item| item[2]=\"$\"}\n array\nend", "def hk(str)\n \"(?:#{Moji.kata_to_hira(str)}|#{Moji.hira_to_kata(str)})\"\n end", "def kesha_maker(array)\n kesha_array = []\n\n array.each do |name|\n name_array = name.split(\"\")\n ...
[ "0.5797281", "0.55033416", "0.54750913", "0.5437725", "0.54106593", "0.5397252", "0.5396641", "0.53965914", "0.5274228", "0.52720547", "0.5245476", "0.5235038", "0.52141094", "0.5209762", "0.5170602", "0.51662713", "0.5155222", "0.51332945", "0.51222545", "0.5111949", "0.5105...
0.5815053
0
Use callbacks to share common setup or constraints between actions.
def set_subtask @subtask = Subtask.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.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
Only allow a trusted parameter "white list" through.
def subtask_params params.require(:subtask).permit(:description, :cost_time, :task_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.638045...
0.0
-1
Devise methods Authentication key(:username) and password field will be added automatically by devise.
def configure_permitted_parameters added_attrs = [:email, :first_name, :last_name] devise_parameter_sanitizer.permit :sign_up, keys: added_attrs devise_parameter_sanitizer.permit :account_update, keys: added_attrs end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_key\n send(Devise.authentication_keys.first)\n end", "def user_key\n send(Devise.authentication_keys.first)\n end", "def fetch_details_from_devise\n self.username = 'devise_user'\n self.save\n end", "def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, k...
[ "0.7034508", "0.7034508", "0.6708608", "0.6698475", "0.66124535", "0.66058046", "0.6540802", "0.64991665", "0.64823794", "0.648107", "0.648107", "0.6417993", "0.6414918", "0.6413039", "0.63835347", "0.6364552", "0.635979", "0.63527083", "0.6326488", "0.62807804", "0.62553966"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def note_params params.require(:note).permit(:description,:instance_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.6980629", "0.67819995", "0.67467666", "0.67419875", "0.67347664", "0.65928614", "0.6504013", "0.6498014", "0.64819515", "0.64797956", "0.64562726", "0.64400834", "0.6380117", "0.6377456", "0.63656694", "0.6320543", "0.63002014", "0.62997127", "0.629425", "0.6293866", "0.62...
0.0
-1
MSSID MSSName LastUpdated PREFIXTREESELECTOR DIGITPATTERN TRANSLATIONGROUP EXPECTEDDIGITCOUNT DIGITFENCEINDEX DESCRIPTION SELECTOR_TYPE
def load_entries_from_edw STDERR.puts "Loading PrefixFence data from EDW for #{mss_name}." data = [] SqlServer.create(EDW::SOURCE, EDW::DM_ALCATEL::DATABASE) do |db| db.query sql # puts db.fields data = db.data end data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mssql_parse_info(data, info)\n\t\tlen = data.slice!(0,2).unpack('v')[0]\n\t\tbuff = data.slice!(0,len)\n\n\t\terrno,state,sev,elen = buff.slice!(0,8).unpack('VCCv')\n\t\temsg = buff.slice!(0,elen * 2)\n\t\temsg.gsub!(\"\\x00\", '')\n\n\t\tinfo[:infos]||= []\n\t\tinfo[:infos] << \"SQL Server Info ##{errno} (St...
[ "0.45805863", "0.4469986", "0.44453862", "0.44422075", "0.44422075", "0.44394162", "0.44261467", "0.43739456", "0.43332532", "0.43332532", "0.43279734", "0.42882293", "0.426376", "0.4237518", "0.42119703", "0.42118752", "0.41906482", "0.41897145", "0.41853672", "0.4184058", "...
0.0
-1
Add a IIFE around our javascript
def call(input) path = input[:environment].context_class.new(input).pathname.to_s data = input[:data] # Only discourse or admin paths return data unless (path =~ /\/javascripts\/nilavu/ || path =~ /\/javascripts\/admin/ || path =~ /\/test\/javascripts/) # Ignore the js helpers return data if (path =~ /test\_helper\.js/) return data if (path =~ /javascripts\/helpers\//) # Ignore ES6 files return data if (path =~ /\.es6/) # Ignore translations return data if (path =~ /\/translations/) # We don't add IIFEs to handlebars return data if path =~ /\.handlebars/ return data if path =~ /\.shbrs/ return data if path =~ /\.hbrs/ return data if path =~ /\.hbs/ "(function () {\n\nvar $ = window.jQuery;\n// IIFE Wrapped Content Begins:\n\n#{data}\n\n// IIFE Wrapped Content Ends\n\n })(this);" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inject_js=(_arg0); end", "def initializer_function\n %{<script type=\"text/javascript\">\n var map_options = #{options_to_json};\n onload_before_#{name} = typeof window.onload == 'function' ? window.onload : function(){};\n window.onload = function(){\n onload_before_#{name...
[ "0.63017625", "0.6093915", "0.6088926", "0.6069681", "0.5878559", "0.58464724", "0.5798484", "0.5696495", "0.5678798", "0.56658477", "0.56475675", "0.56444037", "0.55942184", "0.5500175", "0.5484742", "0.5475648", "0.545346", "0.5435584", "0.54086", "0.5400418", "0.5390058", ...
0.0
-1
GET /locations/1 GET /locations/1.json
def show_location end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def locations\n get('locations')\n end", "def get_location\n as_json(get_results('/locations.json'))\n end", "def index\n locations = Location.all\n render json: locations\n end", "def index\n locations = @project.locations.all\n render json: { locations: locations }\n end", "def show...
[ "0.77431786", "0.7690497", "0.7402892", "0.7278375", "0.72128636", "0.7179753", "0.71755373", "0.7158328", "0.71116275", "0.70961183", "0.70597774", "0.7054361", "0.7042809", "0.7010643", "0.6969208", "0.6925418", "0.69004", "0.68884706", "0.6884856", "0.6876957", "0.68584985...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_location @location = Location.find_by(slug: params[:slug]) 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.6163754", "0.6045816", "0.5944853", "0.59169096", "0.58892167", "0.58342934", "0.5776148", "0.57057375", "0.57057375", "0.56534296", "0.56209534", "0.54244673", "0.54101455", "0.54101455", "0.54101455", "0.53951085", "0.5378493", "0.53563684", "0.53399915", "0.5338049", "0...
0.0
-1
TODO: Divide File storage and JSON storage
def load_penalties JSON.parse(File.read(@filename)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query_filedata(uid)\n json = {}\n id = uid.to_i\n dir = id%100\n dir = \"#{fs_root}/#{dir.to_s}/#{id}_lastread\"\n FileUtils.makedirs(dir)\n fname = \"#{dir}/jsondata\" \n #p \"query_filedata:filename #{fn...
[ "0.6610833", "0.6363594", "0.6320678", "0.62873787", "0.61746603", "0.6161367", "0.6160252", "0.6144845", "0.60812116", "0.60648906", "0.6064373", "0.6022529", "0.60019684", "0.5991042", "0.592704", "0.5915643", "0.5892252", "0.5880232", "0.58681875", "0.586502", "0.58333635"...
0.0
-1
Return an error message if the name is invalid. Return nil if name is valid.
def error_for_todo(name) if !(1..100).cover? name.size "Todo must be between 1 and 100 characters." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name_invalid\n errors.add(:name, :unknown)\n end", "def name_is_valid\n errors.add(:name,\"Invalid string for name.\") unless name_is_valid?\n end", "def valid_name!\n return unless @name.blank?\n\n @success = false\n @error = 'Error: site name must be present'\n end", "def name...
[ "0.79099447", "0.76210326", "0.7459701", "0.7411183", "0.7291553", "0.7206568", "0.71990484", "0.71447146", "0.70809114", "0.7019362", "0.7010315", "0.6998964", "0.6928259", "0.6885302", "0.68643504", "0.6819798", "0.67752254", "0.6697896", "0.6697896", "0.66621554", "0.66545...
0.0
-1
Creating New method to access the array of questions It takes one parameter
def run_test(questions) answer = "" # create a variable called answer empty string score = 0 # keeping track of the questions they get right # looping through the questions for question in questions puts question.prompt # get answer from the user answer = gets.chomp() if answer == question.answer score += 1 end end puts ("You got " + score.to_s + " / " + questions.length().to_s) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def questions\n \n end", "def questions\r\n return @questions \r\nend", "def question(q, a)\n qu = Question.new(q,a)\n questions << qu\n @counter = 0 #Se inicializa el contador\n end", "def check_questions\n response = Request.get_request(URL_QUESTION)\n questions = []\n if response.suc...
[ "0.7177782", "0.6959165", "0.68871486", "0.67830104", "0.67192394", "0.66747355", "0.6670768", "0.6659711", "0.6505509", "0.64900553", "0.6470867", "0.6448659", "0.64248973", "0.6381592", "0.63748884", "0.63702905", "0.63639313", "0.6353912", "0.63293844", "0.63016564", "0.62...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_roster @roster = Roster.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.6163754", "0.6045816", "0.5944853", "0.59169096", "0.58892167", "0.58342934", "0.5776148", "0.57057375", "0.57057375", "0.56534296", "0.56209534", "0.54244673", "0.54101455", "0.54101455", "0.54101455", "0.53951085", "0.5378493", "0.53563684", "0.53399915", "0.5338049", "0...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def roster_params params.require(:roster).permit(:ranking, :name, :position) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.6978086", "0.6780264", "0.6742658", "0.6738813", "0.67338693", "0.65908474", "0.6501793", "0.6495506", "0.64796513", "0.64755446", "0.6454826", "0.6437561", "0.6377127", "0.63722163", "0.6364058", "0.63178706", "0.62979764", "0.62968165", "0.62913024", "0.6289789", "0.6289...
0.0
-1
Retrieve the file from its store path
def retrieve!(identifier) HesCloudStorage::HesCloudStorageEngine::File.new(uploader, self, ::File.basename(uploader.store_path(identifier), uploader.root)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stored_file_path\n File.join(path, stored_name)\n end", "def retrieve!(identifier)\n self.class.configure_qcloud_sdk(uploader)\n\n if uploader.file # file is present after store!\n uploader.file\n else\n file_path = uploader.store_path(identifier)\n File.ne...
[ "0.7184737", "0.6933105", "0.6897425", "0.68497217", "0.68366075", "0.6806873", "0.6781202", "0.67683166", "0.674818", "0.6735283", "0.66854334", "0.6645019", "0.66161555", "0.661403", "0.6595408", "0.6567676", "0.65410316", "0.65409553", "0.65246934", "0.65191454", "0.650736...
0.63679856
38
Return extension of file
def extension path.split('.').last end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def file_extension\n filename.split(\".\").last\n end", "def extension\n split_extension(filename)[1] if filename\n end", "def ext\n b,e = split_extension(filename)\n e\n end", "def extname\n File.extname(filename)\n end", "def file_ext(filename)\n File.extname...
[ "0.9140418", "0.9051006", "0.90327877", "0.8933805", "0.8828073", "0.8802823", "0.8769988", "0.87578386", "0.87093997", "0.8706713", "0.8705118", "0.8700549", "0.8668049", "0.8666507", "0.8664546", "0.86570174", "0.8589137", "0.8586352", "0.8586352", "0.8586352", "0.857835", ...
0.85181767
23
Read content of file from service
def read file.read end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read file\n File.open file\n end", "def get_file_contents(file_path)\n input_file = File.open(file_path, 'r')\n input_file_contents = input_file.read\n input_file.close\n input_file_contents\n end", "def read\n file\n end", "def read_file(path)\n ...
[ "0.6942226", "0.6918413", "0.68825406", "0.6756848", "0.6721985", "0.66687095", "0.66477853", "0.66344404", "0.6601488", "0.6588402", "0.6564696", "0.6547748", "0.6547513", "0.65394527", "0.65264535", "0.6518738", "0.64775133", "0.64700466", "0.64466804", "0.6442191", "0.6431...
0.6678593
5
Return size of file body
def size file.size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def body_size\n request = $postgres.exec_prepared('wsfile_body_size', [self.id])\n request[0].map{|k,v| v.to_i || 0}.inject(:+)\n end", "def size\n file.content_length\n end", "def file_size\n stream.size\n end", "def size\n file.try(:size) || 0\n en...
[ "0.8270475", "0.81801385", "0.8065057", "0.7790245", "0.76991624", "0.7686959", "0.7622092", "0.7609221", "0.7600904", "0.7563286", "0.7554654", "0.75229394", "0.75200886", "0.7513806", "0.7499982", "0.7495545", "0.74775636", "0.7416581", "0.74047905", "0.7396711", "0.7392453...
0.784759
3
Returns the url of the HES Cloud file
def url(options = {}) file.path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def url\n expiration = Time.now + 60.seconds\n fog_file.url(expiration)\n end", "def url\n host = @uploader.ucloud_cdn_host || @uploader.ucloud_bucket_host\n return nil unless host\n [host, @path].join(\"/\")\n end", "def url\n File.join(\"https://#{service}.#{regi...
[ "0.712241", "0.70841485", "0.70060563", "0.687602", "0.6849365", "0.6796431", "0.67554015", "0.67363876", "0.67178905", "0.67024964", "0.6693854", "0.6636098", "0.6634491", "0.66317755", "0.6624361", "0.6621251", "0.65612906", "0.65604335", "0.65560824", "0.65089506", "0.6484...
0.68323445
5
Returns the filename of the HES Cloud file
def filename(options = {}) if file_url = url(options) file_url.gsub(/.*\/(.*?$)/, '\1') end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filename\n @file.basename.to_s\n end", "def filename\n @file\n end", "def filename\n unless @filename\n @filename = @path.basename.to_s\n end\n\n @filename\n end", "def filename\n @filename\n end", "def filename\n @filename\n end"...
[ "0.7311467", "0.70024866", "0.6926199", "0.6891018", "0.6891018", "0.68831396", "0.68720573", "0.68610597", "0.68587834", "0.6847574", "0.6847548", "0.68457556", "0.68457556", "0.6841847", "0.6816037", "0.681349", "0.6808939", "0.6804824", "0.6804453", "0.6798572", "0.6797761...
0.0
-1
Check if the file exists on the remote service
def exists? file.exists? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remote_file_exists?(aPath)\n\t\tremote_ruby(\"puts File.exists?('#{aPath}').to_s\")==\"true\\n\"\n\tend", "def remote_file_exists?(full_path)\n remote_filetest_passes?('-e', full_path)\n end", "def remote_file_exists?(url)\n url = URI.parse(url)\n Net::HTTP.start(url.host, url.port) do |http|\n ...
[ "0.82512003", "0.81856614", "0.7972522", "0.7827835", "0.76086557", "0.7567244", "0.7542273", "0.75172436", "0.7482934", "0.7464115", "0.7442973", "0.7374424", "0.73136747", "0.72920734", "0.7268947", "0.72373176", "0.722994", "0.71856153", "0.71856153", "0.71856153", "0.7162...
0.67577136
46
Write file to HES Cloud service
def store(new_file) @file = HesCloudStorage::HesCloudFile.new(new_file.to_file, :folder_path => @uploader.store_dir == "uploads" ? nil : @uploader.store_dir, :parent_model => @uploader.model.class) @file.save @path = @file.path true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_host_file\n puts \"Writing Apocalypse host file...\"\n host_config = {\n :hostname => @hostname,\n :server_address => @address, \n :port => @port, \n ...
[ "0.637532", "0.6284256", "0.62711525", "0.6216451", "0.6167251", "0.6134082", "0.6102896", "0.60947955", "0.60822815", "0.6080689", "0.6062848", "0.60550624", "0.6017146", "0.59939396", "0.59484094", "0.5936753", "0.592109", "0.59206164", "0.5919976", "0.591165", "0.59104013"...
0.0
-1
Remove the file from HES Cloud return [Boolean] true for success or raises error
def delete @file = nil # file.delete end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rm!( path )\r\n got = @ndev.rpc.file_delete( :path => path )\r\n return true if got.nil? # got no error\r\n # otherwise, there was an error, check output\r\n raise IOError, got.text\r\n end", "def delete\n begin\n uy_connection.delete(@path)\n true\n r...
[ "0.7716231", "0.7504146", "0.74812394", "0.7218528", "0.71563137", "0.7110333", "0.7027781", "0.70242804", "0.70097935", "0.6966738", "0.69342357", "0.69336563", "0.69042295", "0.6900661", "0.68955016", "0.687362", "0.6871935", "0.68573064", "0.6854268", "0.68464446", "0.6842...
0.64833033
58
node itself isn't thread safe
def moved_node current_tree.find(node_2.id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lock; end", "def lock; end", "def lock; end", "def thread; end", "def thread; end", "def thread; end", "def executor; end", "def executor; end", "def executor; end", "def thread()\n #This is a stub, used for indexing\n end", "def lock!; end", "def refork; end", "def pr...
[ "0.6581202", "0.6581202", "0.6581202", "0.649587", "0.649587", "0.649587", "0.64387697", "0.64387697", "0.64387697", "0.6392424", "0.6216859", "0.61738676", "0.611367", "0.6079616", "0.6079616", "0.6079616", "0.6079616", "0.6046087", "0.6027823", "0.6027823", "0.6010629", "...
0.0
-1
Handle the middle buttons on the add/edit forms pass in member list symbols (i.e. :policies)
def handle_selection_buttons(members, members_chosen = :members_chosen, choices = :choices, choices_chosen = :choices_chosen) if params[:button].ends_with?("_left") handle_selection_buttons_left(members, members_chosen, choices, choices_chosen) elsif params[:button].ends_with?("_right") handle_selection_buttons_right(members, members_chosen, choices, choices_chosen) elsif params[:button].ends_with?("_allleft") handle_selection_buttons_allleft(members, members_chosen, choices, choices_chosen) elsif params[:button].ends_with?("_up") handle_selection_buttons_up_down(members, members_chosen, choices, choices_chosen, true) elsif params[:button].ends_with?("_down") handle_selection_buttons_up_down(members, members_chosen, choices, choices_chosen, false) elsif params[:button].ends_with?("_sync") handle_selection_buttons_sync_async(members, members_chosen, choices, choices_chosen, true) elsif params[:button].ends_with?("_async") handle_selection_buttons_sync_async(members, members_chosen, choices, choices_chosen, false) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_item_controls\n @control_help_window.add_control(Vocab::CONFIRM, Input::Keys::A) \n @control_help_window.add_control(Vocab::BACK, Input::Keys::B)\n @control_help_window.add_control(Vocab::CHANGE_CATEGORY, Input::Keys::L, Input::Keys::R)\n @control_help_window.add_control(V...
[ "0.5779444", "0.57479364", "0.56166595", "0.5536536", "0.54597074", "0.5421022", "0.53814834", "0.5361289", "0.53436184", "0.5329671", "0.53201103", "0.52537054", "0.522222", "0.5217496", "0.52133673", "0.51971143", "0.51971143", "0.51971143", "0.51971143", "0.51971143", "0.5...
0.0
-1
Get list of folder contents
def folder_get_info(folder_node) nodetype, nodeid = folder_node.split("_") @sb[:mode] = nil @sb[:nodeid] = nil @sb[:folder] = nodeid.nil? ? nodetype.split("-").last : nodeid if x_active_tree == :policy_tree if nodeid.nil? && %w[compliance control].include?(nodetype.split('-').last) # level 1 - compliance & control _, mode = nodetype.split('-') @folders = UI_FOLDERS.collect do |model| "#{model.name.titleize} #{mode.titleize}" end @right_cell_text = case mode when 'compliance' then _('Compliance Policies') when 'control' then _('Control Policies') else _("%{typ} Policies") % {:typ => mode.titleize} end else # level 2 - host, vm, etc. under compliance/control - OR deeper levels @sb[:mode] = nodeid.split("-")[1] @sb[:nodeid] = nodeid.split("-").last @sb[:folder] = "#{nodeid.split("-")[1]}-#{nodeid.split("-")[2]}" set_search_text policy_get_all if folder_node.split("_").length <= 2 @right_cell_text = _("All %{typ} Policies") % {:typ => ui_lookup(:model => @sb[:nodeid].try(:camelize))} @right_cell_div = "policy_list" end elsif x_active_tree == :alert_profile_tree @alert_profiles = MiqAlertSet.where(:mode => @sb[:folder]).sort_by { |as| as.description.downcase } set_search_text @alert_profiles = apply_search_filter(@search_text, @alert_profiles) if @search_text.present? @right_cell_text = _("All %{typ} Alert Profiles") % {:typ => ui_lookup(:model => @sb[:folder].try(:camelize))} @right_cell_div = "alert_profile_list" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_dir_contents(path)\n\tfolder_metadata = @client.metadata(path)\n\tcontents = folder_metadata['contents']\n\n\tcontents_paths = []\n\tfor i in contents\n\t\tcontents_paths << i['path']\n\tend\n\tcontents_paths\nend", "def get_contents \n @contents = []\n\n sub_directory_names = Dir[CONTENT_ROOT_DIRE...
[ "0.7714473", "0.7663608", "0.7606409", "0.7468133", "0.74349385", "0.74313146", "0.7398123", "0.73818266", "0.7310131", "0.7293059", "0.72461253", "0.72320044", "0.7229761", "0.7177502", "0.706697", "0.703115", "0.6997947", "0.6979118", "0.69628465", "0.6955327", "0.6911305",...
0.0
-1
"Now we have 1 students", whereas it should be "Now we have 1 student". How can you fix it so that it used singular form when appropriate and plural form otherwise?
def input_students puts "Please enter the names of the students" puts "To finish, just hit return twice" # create an empty array students = [] # get the first name name = gets.chomp # while the name is not empty, repeat this code while !name.empty? do # add the student hash to the array students << {name: name, cohort: :november} if students.count == 1 puts "Now we have #{students.count} student" else puts "Now we have #{students.count} students" end # get another name from the user name = gets.chomp end # return the array of students students end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name_plural() name_singular + 's' end", "def singularize\n @name.pluralize.singularize\n end", "def pluralize amount, singular\n \"#{amount} #{singular}#{amount == 1 ? '' : 's'}\"\n end", "def pluralize(singularStr, num)\n if num == 1\n return singularStr\n else\n if singu...
[ "0.7358244", "0.7048985", "0.6884443", "0.6814316", "0.6781599", "0.6774531", "0.66924506", "0.6687421", "0.6637264", "0.66333646", "0.6627698", "0.66138667", "0.66124827", "0.6603577", "0.65987253", "0.65987253", "0.6568178", "0.65628666", "0.65573555", "0.65541774", "0.6502...
0.0
-1
inits a new FormVersion with same form_id increments sequence sets self.is_current = false
def upgrade! upgraded = self.class.new(form_id: form_id, is_current: true) self.is_current = false save upgraded.save! upgraded end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_new_revision\n new_revision = Form.new(version_independent_id: version_independent_id,\n description: description, parent_id: parent_id, status: status,\n version: version + 1, name: name, oid: oid,\n created_by: created_...
[ "0.6447004", "0.6347048", "0.61970085", "0.6055881", "0.588652", "0.58547413", "0.58372754", "0.5676159", "0.56503123", "0.5439611", "0.5434107", "0.54320484", "0.54302776", "0.54217315", "0.5354525", "0.53467596", "0.5339406", "0.53387105", "0.53312725", "0.53083193", "0.529...
0.6391297
1
generates the unique random code
def generate_code # only need to do this if code not set return if code ensure_unique_code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generateCode()\n require 'securerandom'\n return SecureRandom.hex\n end", "def generate_code\n self.code = Digest::SHA1.hexdigest(\"--#{Time.now.to_s}--#{user_id}--#{rand(256)}\")[0,32]\n end", "def generate_code\n self.code = SecureRandom.uuid if code.blank?\n end", "def build_hash_code\n...
[ "0.8666963", "0.8338893", "0.82497144", "0.80795825", "0.8049352", "0.8024638", "0.79506874", "0.7906737", "0.7785307", "0.77364963", "0.76968473", "0.7676983", "0.76174927", "0.7614243", "0.76129884", "0.75998694", "0.7580592", "0.7567691", "0.75506324", "0.7545974", "0.7536...
0.73581445
44
double checks that code is still unique
def ensure_unique_code # keep trying new random codes until no match while self.class.find_by_code(self.code = Random.letters(CODE_LENGTH)); end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ensure_unique_code\n # keep trying new random codes until no match\n while self.class.find_by_code(self.code = Random.letters(CODE_LENGTH)); end\n return true\n end", "def generate_code\n # only need to do this if code not set\n return if code\n ensure_unique_code\n end", "def v...
[ "0.8103135", "0.7022466", "0.68688595", "0.68060386", "0.66699076", "0.6409783", "0.64094245", "0.63625747", "0.62836593", "0.60936177", "0.60100603", "0.6002641", "0.6001788", "0.59650755", "0.5952886", "0.5931408", "0.59253776", "0.5901258", "0.5879698", "0.5866913", "0.584...
0.8073653
1
Updates the portlets hash from the routes and configuration options. Changes the path variables to a format supported by the Railsportlet.
def portlets(routes=@routes) raise 'No configuration' unless @config portlets = [] @config.instances.flatten.each do |portlet| ### route to path if portlet[:path] # take user-given path & do not parse routes path = portlet[:path] # # parse the requirements - controller & action # ( this is too difficult -- no navigation for user-given paths ) # # begin # #recognized_request_for(path) # #builder = ActionController::Routing::RouteBuilder.new # #r = ActionController::Routing::Routes.recognize_path(path, { :method => :get }) # #puts r.inspect # #req_path = builder.segments_for_route_path(r) # #STDERR.puts req_path.inspect # rescue # STDERR.puts $!.message # end portlet.update( :reqs => {} ) portlet.update( :vars => [] ) else # parse path from routes begin _r = routes.select{ |route| route[:name]==portlet[:name].to_sym } path = _r.first[:path] # take only the first segments raise if path.nil? rescue $stderr.puts ' !! no route for %s' % portlet[:name] next end # getting de default values from wildcards (:controller, :action, :other) portlet.update(:defaults => _r.first[:defaults]) ### requirements - controller & action portlet.update( :reqs => _r.first[:reqs] ) ### variables # take just the ones that are required in the path! vars = [] _r.first[:vars].each do |var| # variables that are not defined in reqs are required to be inserted by the rails-portlet vars << var unless _r.first[:reqs][var] end portlet.update( :vars => vars ) # delete the route from routes if routes _r.each do |r| routes.delete(r) end end end portlet.update( :path => path ) ### javascripts # append portlet's javascripts to global javascripts javascripts = (portlet[:javascripts].nil? ? @config.javascripts : @config.javascripts + portlet[:javascripts].to_a) portlet.update( :javascripts => javascripts.flatten ) portlets << portlet end # leftover named routes if @config.include_all_named_routes==true portlets << routes end # sanity check portlets.flatten! portlets.compact! portlets.each do |portlet| ### hostname portlet[:host] ||= @config.host ### servlet portlet[:servlet] ||= @config.servlet ### category portlet[:category] ||= @config.category ### title _title = portlet[:title] || portlet[:name].to_s.gsub('_',' ').capitalize # strip illegal characters title = _title.gsub(/ä/,'a').gsub(/ö/,'o').gsub(/Ä/,'A').gsub(/Ö/,'O') portlet.update( :title => title ) portlet[:edit_mode] ||= nil portlet[:instanceable] ||= false ### unless defined, use default javascripts portlet[:javascripts] ||= @config.javascripts # fix path variables to be replaced by rails-portlet at runtime path = portlet[:path] path.gsub!(/:uid/,'%UID%') path.gsub!(/:gid/,'%GID%') # TODO: notify user of unsupported variables portlet.update( :path => path ) end return portlets end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_routes\n insert_into_file 'config/routes.rb', %(\n root :to => 'portal#page'\n DrgCms.routes\n\n put '/portal/process_login'\n post '/reports/diary'\n\n resources :init # remove after initial run\n\n get '*path' => 'portal#page'\n\n),\n after: 'Rails.application.routes.draw do'\nend", "def p...
[ "0.54691124", "0.54313755", "0.5422103", "0.52584773", "0.52584773", "0.5255144", "0.52341664", "0.5232783", "0.5198125", "0.51792955", "0.51554805", "0.5000673", "0.49684203", "0.49314374", "0.48687118", "0.48135903", "0.4780192", "0.47723714", "0.47446775", "0.4742579", "0....
0.64452714
0
Moves the :max, :min, :before, and :after options to data attributes, formats the value, and merges this with any other options.
def input_html_options data = {} data[:min] = options[:min] if options[:min].present? data[:max] = options[:max] if options[:max].present? data[:before] = options[:before] if options[:before].present? data[:after] = options[:after] if options[:after].present? super.deep_merge( value: format_value(@builder.object.send(attribute_name)), type: 'text', data: data ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_data # :nodoc:\n if @y_axis_increment && !@hide_line_markers\n self.maximum_value = [@y_axis_increment, maximum_value, (maximum_value.to_f / @y_axis_increment).round * @y_axis_increment].max\n self.minimum_value = [minimum_value, (minimum_value.to_f / @y_axis_increment).round * @y_axis...
[ "0.59231603", "0.5723215", "0.56251204", "0.5608272", "0.55394286", "0.5490469", "0.54865164", "0.5455183", "0.5399323", "0.53972495", "0.5333362", "0.5323261", "0.52647763", "0.512813", "0.51078725", "0.51040256", "0.51040256", "0.51040256", "0.51040256", "0.51040256", "0.51...
0.7302364
0
Add conflicts to the ConflictList. Duplicate or blank conflicts will be ignored. Use the :parse option to add an unparsed conflict string. Example: conflict_list.add("Fun", "Happy") conflict_list.add("Fun, Happy", :parse => true)
def add(*names) extract_and_apply_options!(names) concat(names) clean! self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_conflict(name, specifics)\n @conflicts << Requirement.parse(name, specifics)\n end", "def conflict(val)\n conflicts << val\n conflicts.dup\n end", "def conflict(val)\n conflicts << val\n conflicts.dup\n end", "def add_conflict(entity, id, attr, o, c, p)\n lo...
[ "0.6009051", "0.57616585", "0.57616585", "0.5406556", "0.5394252", "0.5394252", "0.52639306", "0.49110156", "0.48640347", "0.48111224", "0.47594014", "0.46849656", "0.46749014", "0.46438017", "0.46429068", "0.46175203", "0.45756584", "0.4426399", "0.4426399", "0.44198412", "0...
0.46183246
16
Add conflicts to the conflict_list. Duplicate or blank conflicts will be ignored. Use the :parse option to add an unparsed conflict string. Example: conflict_list.add("Fun", "Happy") conflict_list.add("Fun, Happy", :parse => true)
def add(*names) extract_and_apply_options!(names) concat(names) clean! self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_conflict(name, specifics)\n @conflicts << Requirement.parse(name, specifics)\n end", "def conflict(val)\n conflicts << val\n conflicts.dup\n end", "def conflict(val)\n conflicts << val\n conflicts.dup\n end", "def conflicts\n @conflicts ||= []\n end", "...
[ "0.59939474", "0.5860045", "0.5860045", "0.55704325", "0.55704325", "0.5373239", "0.53591925", "0.49797013", "0.49109834", "0.48764688", "0.47883013", "0.47106072", "0.46698946", "0.4666219", "0.45752895", "0.45750764", "0.44634843", "0.44634843", "0.44492346", "0.4431701", "...
0.44807523
16
Remove specific conflicts from the conflict_list. Use the :parse option to add an unparsed conflict string. Example: conflict_list.remove("Sad", "Lonely") conflict_list.remove("Sad, Lonely", :parse => true)
def remove(*names) extract_and_apply_options!(names) delete_if { |name| names.include?(name) } self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove(*names)\r\n extract_and_apply_options!(names)\r\n delete_if { |name| names.include?(name) }\r\n self\r\n end", "def remove_item(grcy_list, string)\n grcy_list.delete(string)\nend", "def remove_item(list, string)\n\tlist.delete(string.to_sym)\n\tlist\nend", "def remove(*names); end", "d...
[ "0.6092978", "0.57151985", "0.57040054", "0.54154533", "0.5376303", "0.5375382", "0.5375382", "0.5310719", "0.52998656", "0.5270083", "0.5243265", "0.5234724", "0.5183906", "0.51521015", "0.5139484", "0.51394594", "0.5112362", "0.5074133", "0.5056825", "0.5041495", "0.5029751...
0.61348784
0
Transform the conflict_list into a conflict string suitable for edting in a form. The conflicts are joined with conflictList.delimiter and quoted if necessary. Example: conflict_list = conflictList.new("Round", "Square,Cube") conflict_list.to_s 'Round, "Square,Cube"'
def to_s conflicts = frozen? ? self.dup : self conflicts.send(:clean!) conflicts.map do |name| name.include?(delimiter) ? "\"#{name}\"" : name end.join(delimiter.ends_with?(" ") ? delimiter : "#{delimiter} ") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_to_delimited_string(list, delimiter = '|')\n str = \"\"\n list.each do |e|\n str << e\n str << delimiter unless e == list.last\n end\n str\n end", "def to_s\r\n clean!\r\n \r\n map do |name|\r\n name.include?(delimiter) ? \"\\\"#{name}\\\"\" : name\r\n end.join(de...
[ "0.62634116", "0.59690505", "0.59026366", "0.5868843", "0.58570594", "0.56341285", "0.5612332", "0.5567862", "0.55377406", "0.553639", "0.5528089", "0.55161923", "0.5475692", "0.5423438", "0.5410157", "0.5407309", "0.53934014", "0.53701013", "0.5269722", "0.5250278", "0.52325...
0.7489193
0
Remove whitespace, duplicates, and blanks.
def clean! reject!(&:blank?) map!(&:strip) uniq! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean!\r\n reject!(&:blank?)\r\n map!(&:strip)\r\n uniq!\r\n end", "def strip\n lambda do |rec, acc|\n acc.collect! do |v|\n # unicode whitespace class aware\n v.sub(/\\A[[:space:]]+/,'').sub(/[[:space:]]+\\Z/, '')\n end\n end\n end", "de...
[ "0.7524463", "0.7369265", "0.72860473", "0.7224176", "0.7224176", "0.71872914", "0.71574855", "0.71574855", "0.71334136", "0.71145606", "0.7099433", "0.7046403", "0.7019657", "0.69951665", "0.69925207", "0.6948776", "0.6926586", "0.6926586", "0.69107604", "0.689238", "0.68513...
0.7433913
1
Configure how to run remote SSH commmands on server.
def config_ssh(username, host, options = nil) @ssh = SSH.new(username, host, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def configure_serverspec(node)\n set :backend, :ssh\n host = node.ssh_info[:host].to_s\n options = Net::SSH::Config.for(host)\n options[:user] = node.ssh_info[:username].to_s\n options[:keys] = node.ssh_info[:private_key_path][0].to_s\n options[:port] = node.ssh_info[...
[ "0.6837605", "0.6781286", "0.6702748", "0.6665643", "0.6654404", "0.6588082", "0.6540874", "0.6530356", "0.65055656", "0.6496589", "0.6444951", "0.64258236", "0.63801986", "0.6363892", "0.635593", "0.63513607", "0.6343348", "0.6331936", "0.63174146", "0.6316927", "0.62806", ...
0.7224722
0
Configure how to communicate with GitHub
def config_github(api_key) @github = GitHub.new(api_key) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def configure_github_access\n settings = ::GitReview::Settings.instance\n if settings.oauth_token && settings.username\n @github = Octokit::Client.new(\n :login => settings.username,\n :access_token => settings.oauth_token,\n :auto_traversal => true\n ...
[ "0.7129416", "0.70996153", "0.7029434", "0.7017209", "0.6754193", "0.6749698", "0.6732055", "0.65345645", "0.64636636", "0.6334358", "0.6310106", "0.6276585", "0.62754583", "0.6262421", "0.6260535", "0.6244621", "0.62389463", "0.6169483", "0.6135728", "0.612746", "0.6100987",...
0.6886085
4
Configure how to communicate with Travis
def config_travis(api_key, private_repo) @travis = TravisCI.new(api_key: api_key, private_repo: private_repo) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def travis\n Log.fatal('You did not configure Travis yet.') unless @travis\n @travis\n end", "def create_travis(name, platforms)\n\n File.open('.travis.yml', 'w') { |file| \n file.puts(\"language: objective-c\")\n file.puts(\"osx_image: xcode8.2\")\n file.puts(\"env:\")\n fi...
[ "0.74411035", "0.6312183", "0.6096012", "0.6034233", "0.5999066", "0.5999066", "0.58172834", "0.57950306", "0.57585853", "0.5740117", "0.5728505", "0.5686742", "0.5658344", "0.5652492", "0.5639438", "0.5622121", "0.561829", "0.561829", "0.561829", "0.561829", "0.561829", "0...
0.6768809
1
While working with bash commands, some commands are not added to the path. That's annoying. Convenient method to assign a command to a path for replacing. Example: ci.path("dockercompose", "/opt/bin/dockercompose") Now, when you use ci.sh("dockercompose f ... up d"), it will run "/opt/bin/dockercompose f ... up d" instead.
def path(command, path) @paths[command] = path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sh(cmd)\n `#{cmd}`\nend", "def cmd(str)\n return `cd #{APP_DIR}; #{str}`\nend", "def sh(command)\n provider.sh command\n end", "def absolute_command(cmd, path: nil)\n was_array = cmd.is_a?(Array)\n cmd = if was_array\n cmd.dup\n else\n Shellwords.split(cmd)\n e...
[ "0.667388", "0.6390395", "0.6312157", "0.6225742", "0.6223535", "0.62004584", "0.6104248", "0.60336757", "0.6032072", "0.6018608", "0.6009152", "0.60063404", "0.6006277", "0.59779495", "0.59766763", "0.5976449", "0.59693587", "0.59463567", "0.59161353", "0.59161353", "0.58258...
0.5940168
18
Run local bash command
def sh(command, fail_non_success: true) command = Command.path_replace(command, @paths) puts command.colorize(@color) result = @sh.run(command) process_shell_result(result, fail_non_success) result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_local(cmd)\n system(cmd)\n end", "def run_locally(cmd)\n logger.trace \"executing locally: #{cmd.inspect}\" if logger\n `#{cmd}`\n end", "def run(cmd, opts={})\n cmd = \"sh -c '#{cmd.gsub(\"'\"){%q{'\"'\"'}}}'\"\n if opts[:env]\n sh \"touch .env.local .env.test.local\", verbose:...
[ "0.7503483", "0.7030775", "0.6901969", "0.6830279", "0.68067735", "0.68067735", "0.67737836", "0.6672249", "0.6651613", "0.6622743", "0.65806544", "0.6553135", "0.6543106", "0.65413254", "0.6526818", "0.64763725", "0.64187855", "0.6403069", "0.6397678", "0.6377587", "0.636655...
0.0
-1
Get instance of GitHub class to run commands against GitHub
def travis Log.fatal('You did not configure Travis yet.') unless @travis @travis end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def github\n\n @github = Github.new({ client_id: CONFIG[:GITHUB_CLIENT_ID], client_secret: CONFIG[:GITHUB_CLIENT_SECRET] })\n end", "def github\n Log.fatal('You did not configure GitHub yet.') unless @github\n @github\n end", "def github_client\n Octokit::Client.new(:login => username, :oauth...
[ "0.68239033", "0.64671826", "0.64665717", "0.6461043", "0.6412371", "0.6291616", "0.6260287", "0.62471646", "0.62171435", "0.6216496", "0.61708087", "0.61430794", "0.61316955", "0.6023944", "0.6015977", "0.60138416", "0.5982394", "0.59594345", "0.59146583", "0.58963484", "0.5...
0.0
-1
Get instance of GitHub class to run commands against GitHub
def github Log.fatal('You did not configure GitHub yet.') unless @github @github end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def github\n\n @github = Github.new({ client_id: CONFIG[:GITHUB_CLIENT_ID], client_secret: CONFIG[:GITHUB_CLIENT_SECRET] })\n end", "def github_client\n Octokit::Client.new(:login => username, :oauth_token => token)\n end", "def github\n @github ||= begin\n if username.present? && github_...
[ "0.68239033", "0.64665717", "0.6461043", "0.6412371", "0.6291616", "0.6260287", "0.62471646", "0.62171435", "0.6216496", "0.61708087", "0.61430794", "0.61316955", "0.6023944", "0.6015977", "0.60138416", "0.5982394", "0.59594345", "0.59146583", "0.58963484", "0.589361", "0.589...
0.64671826
1
Since this controller is a nested resource under the cars resource, all invocations will include a `:car_id` parameter to tell us which car we are working with.
def fetch_car @car = current_user.cars.find(params[:car_id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_car\n\t\t\t@car = Car.find(params[:car_id])\n\t\tend", "def set_car\n @car = Car.find(params[:id])\n end", "def set_car\n @car = Car.find(params[:id])\n end", "def set_car\n @car = Car.find(params[:id])\n end", "def set_car\n @car = Car.find(params[:id])\n end", "...
[ "0.7178004", "0.7138821", "0.71370673", "0.71370673", "0.71370673", "0.71370673", "0.71370673", "0.71370673", "0.71370673", "0.71370673", "0.71370673", "0.71370673", "0.71370673", "0.71370673", "0.71370673", "0.71370673", "0.71370673", "0.71370673", "0.71370673", "0.71370673", ...
0.65505254
43
on initialise la variable de classe
def initialize(email_to_save) @email = email_to_save @@user_count += 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init; end", "def init; end", "def init; end", "def init; end", "def init\n end", "def init\n end", "def init\n end", "def initialize\n\n\tend", "def initialize\n\n\tend", "def initialize\n\t\t\n\tend", "def initialize() end", "def at_init\n\n\t\tend", "def initialize\n \...
[ "0.78016263", "0.78016263", "0.78016263", "0.78016263", "0.77336735", "0.77336735", "0.77336735", "0.7728234", "0.7728234", "0.77251285", "0.76989883", "0.7646746", "0.760654", "0.7588378", "0.7574087", "0.7568045", "0.7517965", "0.75092226", "0.74332494", "0.7433073", "0.743...
0.0
-1
Generate a sitemap.xml file We reimplement the default Jekyll sitemap generator, because we want to leverage the GTN::ModificationTimes class to obtain the last modification date of a page, in a more efficient way than the default Jekyll sitemap Params: +site+:: The +Jekyll::Site+ object
def generate(site) puts '[GTN/Sitemap] Generating' result = '<?xml version="1.0" encoding="UTF-8"?>' result += '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' \ 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 ' \ 'http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" ' \ 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' site.pages.reject { |t| t.path =~ /ipynb$/ }.each do |t| begin d = Gtn::ModificationTimes.obtain_time(t.path) d.format = '%FT%T%:z' formatted_date = d.to_s rescue StandardError d = Time.new formatted_date = d.strftime('%FT%T%:z') end result += "<url><loc>#{site.config['url'] + site.config['baseurl'] + t.url}</loc>" \ "<lastmod>#{formatted_date}</lastmod></url>" end result += '</urlset>' page2 = PageWithoutAFile.new(site, '', '.', 'sitemap.xml') page2.content = result site.pages << page2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate(site)\n puts \"Generating sitemap...\"\n @site = site\n @site.config[\"time\"] = Time.new\n @site.config[\"html_files\"] = html_files.map(&:to_liquid)\n unless sitemap_exists?\n write\n @site.keep_files ||= []\n @site.keep_files << \"sitemap.xml\...
[ "0.8111135", "0.7054567", "0.698701", "0.688247", "0.6801285", "0.6734294", "0.66676944", "0.6653475", "0.6587433", "0.6587433", "0.6539907", "0.65021485", "0.6482737", "0.63853204", "0.6373777", "0.6358131", "0.6342161", "0.6325158", "0.6301099", "0.627928", "0.62694514", ...
0.8603455
0
Translates na identifier, such as "sysDescr", into an OID
def oid(identifier) prefix, *suffix = case identifier when Array identifier.map(&:to_s) else identifier.split(".", 2).map(&:to_s) end return unless prefix # early exit if it's an OID already unless prefix.integer? load_defaults # load module if need be idx = prefix.index("::") if idx mod = prefix[0..(idx - 1)] type = prefix[(idx + 2)..-1] return if mod && !module_loaded?(mod) && !load(mod) else type = prefix end return if type.nil? || type.empty? prefix = @object_identifiers[type] || raise(Error, "can't convert #{type} to OID") end [prefix, *suffix].join(".") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_oid(name, id)\n OIDPrefix + '.' + OIDMap[name].to_s + \".#{id}\"\n end", "def name2oid(name)\n\t\toid = @manager.mib.oid(name)\n\t\tt = [['OID', 'Symbolic Name'], [\"#{oid}\", \"#{name}\"]]\n\t\ttable = t.to_table(:first_row_is_head => true)\n\t\tputs table.to_s\n\tend", "def oid2name(oid)\n\t\tnam...
[ "0.7137624", "0.71049565", "0.64631265", "0.63861", "0.62184274", "0.596728", "0.58594346", "0.5699174", "0.5697396", "0.5671295", "0.56686276", "0.56226635", "0.56219476", "0.5611143", "0.5595667", "0.5567362", "0.55576074", "0.5551407", "0.5551407", "0.55500597", "0.5546227...
0.6338959
4
Loads a MIB. Can be called multiple times, as it'll load it once. Accepts the MIB name in several ways: MIB.load("SNMPv2MIB") MIB.load("SNMPv2MIB.txt") MIB.load("/path/to/SNMPv2MIB.txt")
def load(mod) unless File.file?(mod) moddir = nil MIBDIRS.each do |mibdir| if File.exist?(File.join(mibdir, mod)) moddir = File.join(mibdir, mod) break elsif File.extname(mod).empty? && File.exist?(File.join(mibdir, "#{mod}.txt")) moddir = File.join(mibdir, "#{mod}.txt") break end end return false unless moddir mod = moddir end return true if @modules_loaded.include?(mod) do_load(mod) @modules_loaded << mod true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def importMib( mib, path )\n puts \"Copying MIB from MIBS/#{mib} to #{path} ...\"\n FileUtils.cp_r(\"MIBS/#{mib}\", path)\n puts \"Importing MIB: #{mib} ...\"\n SNMP::MIB.import_module(\"MIBS/#{mib}\")\nend", "def read_mib_dic(filename)\n mib = eval_mib_dic(filename)\n\n raise(SnmpMibError, \"inval...
[ "0.7022308", "0.6241425", "0.5965714", "0.5669535", "0.5637181", "0.54845876", "0.5429251", "0.5347654", "0.53442574", "0.5343759", "0.52839375", "0.5254179", "0.5247249", "0.5174308", "0.51561916", "0.5149515", "0.5110713", "0.509119", "0.5051834", "0.50386494", "0.50239736"...
0.5329932
10
Loads the MIB all the time, where +mod+ is the absolute path to the MIB.
def do_load(mod) data = @parser_mutex.synchronize { PARSER.parse(File.read(mod)) } imports = load_imports(data[:imports]) declarations = Hash[ data[:declarations].reject { |dec| !dec.key?(:name) || !TYPES.include?(dec[:type]) } .map { |dec| [String(dec[:name]), String(dec[:value]).split(/ +/)] } ] declarations.each do |nme, value| store_oid_in_identifiers(nme, value, imports: imports, declarations: declarations) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load(mod)\n unless File.file?(mod)\n moddir = nil\n MIBDIRS.each do |mibdir|\n if File.exist?(File.join(mibdir, mod))\n moddir = File.join(mibdir, mod)\n break\n elsif File.extname(mod).empty? && File.exist?(File.join(mibdir, \"#{mod}.txt\"))\n ...
[ "0.7247165", "0.6535154", "0.6500938", "0.63160044", "0.63154864", "0.6253659", "0.6235684", "0.60242665", "0.59732884", "0.5677587", "0.5643955", "0.5626259", "0.5529572", "0.55291384", "0.5526095", "0.54911745", "0.5489903", "0.5435723", "0.52894247", "0.5279787", "0.526790...
0.5642057
11
Reformats the import lists into an hash indexed by module name, to a list of imported names
def load_imports(imports) return unless imports imports = [imports] unless imports.respond_to?(:to_ary) imports.each_with_object({}) do |import, imp| imp[String(import[:name])] = case import[:ids] when Hash [String(import[:ids][:name])] else import[:ids].map { |id| String(id[:name]) } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def importer_names\n importers.map{|e| e.const_name }\n end", "def module_names\n @cache[:modules]\n end", "def list_imported(regex=//, mib_dir=DEFAULT_MIB_PATH)\n list = []\n Dir[\"#{mib_dir}/*.#{MODULE_EXT}\"].each do |name|\n module_name = File.basename(name,...
[ "0.6870428", "0.6631317", "0.63896877", "0.63423765", "0.6150625", "0.6150625", "0.6108314", "0.59824467", "0.59716856", "0.5908272", "0.58734876", "0.5854943", "0.5854943", "0.5841487", "0.5826468", "0.57332796", "0.5672499", "0.5651493", "0.5612056", "0.55503696", "0.553859...
0.6493703
2
POST /friends or /friends.json
def create current_user.friends.create( friend_id: @user.id ) redirect_to root_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def friends(options={})\n get('/friends', options)\n end", "def add_friend\n # byebug\n #we get user_id from jwt!\n user = User.find(decode_jwt(cookies.signed[:jwt])[\"user_id\"])\n #we get friend_id from frontend\n if !Block.where(blocker_id: user.id, blockee_id:follow_params[:user2])...
[ "0.69640195", "0.6908395", "0.6708779", "0.6706744", "0.66924226", "0.66683054", "0.6653443", "0.66467404", "0.66056013", "0.6602584", "0.6577616", "0.65341544", "0.65245163", "0.6522975", "0.6521179", "0.65166366", "0.6514117", "0.6514117", "0.6511053", "0.65071595", "0.6477...
0.63800323
30
def date_cannot_be_in_the_past if date.present? && date.past? errors.add(:date, "can't be in the past") end end
def start_date_cannot_be_in_the_past if self.start_date && self.start_date < DateTime.now errors.add(:date, "invalid. Start date can't be in the past") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_date_in_past\n if date.nil?\n errors.add(:date, \"cannot be null\")\n else\n if date.past?\n errors.add(:date, \"cannot be in the past\")\n end\n end\n\n end", "def dateordered_cannot_be_in_the_past\n errors.add(:dateOrdered, \"can't be in the past\") if\n !dateOrde...
[ "0.8995073", "0.8790652", "0.8623019", "0.85883373", "0.85616505", "0.8532153", "0.8494483", "0.846856", "0.8407514", "0.8376288", "0.83178365", "0.8291237", "0.82882917", "0.8220547", "0.8211279", "0.81945646", "0.81247854", "0.81158876", "0.8115762", "0.80910254", "0.804546...
0.8589923
3
SQL to BEGIN a transaction.
def begin_transaction_sql SQL_BEGIN end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def begin_db_transaction\n execute(\"BEGIN\")\n end", "def begin_db_transaction\n execute(\"BEGIN\")\n end", "def TransactionBegin()\n\t@dbh.do(\"BEGIN\")\nend", "def begin_db_transaction\n log('BEGIN', 'TRANSACTION') { @connection.begin }\n end", "def start_tran...
[ "0.86671495", "0.86671495", "0.8375693", "0.82687974", "0.8057486", "0.79135376", "0.7744375", "0.7534514", "0.72651887", "0.72571343", "0.71396583", "0.7085154", "0.7085154", "0.70602703", "0.6879832", "0.67659235", "0.66905415", "0.66577226", "0.66577226", "0.6538267", "0.6...
0.8599903
2
SQL to COMMIT a transaction.
def commit_transaction_sql SQL_COMMIT end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def commit_db_transaction\n execute(\"COMMIT\")\n end", "def commit_db_transaction\n execute(\"COMMIT\")\n end", "def commit_transaction(tx)\n tx.execute\n end", "def commit()\n check_return_code(PureHailDB.ib_trx_commit(@trx_ptr))\n end", "def commit_db_tran...
[ "0.8168222", "0.8168222", "0.76139814", "0.7527497", "0.74450666", "0.7280488", "0.7276991", "0.7221815", "0.721497", "0.7214349", "0.71709657", "0.7129977", "0.71051455", "0.7083729", "0.7083729", "0.7081063", "0.7064411", "0.70503277", "0.7020082", "0.69886315", "0.69886315...
0.838998
1
SQL to ROLLBACK a transaction.
def rollback_transaction_sql SQL_ROLLBACK end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rollback_db_transaction\n execute(\"ROLLBACK\")\n end", "def rollback_db_transaction\n execute(\"ROLLBACK\")\n end", "def exec_rollback_db_transaction\n log('ROLLBACK', 'TRANSACTION') { @connection.rollback }\n end", "def rollback\n @MySQLConnection.quer...
[ "0.8181803", "0.8181803", "0.77769566", "0.74661136", "0.7351645", "0.7266504", "0.72538483", "0.7232466", "0.7177316", "0.71110255", "0.70692456", "0.701413", "0.701413", "0.7002328", "0.69809246", "0.6975738", "0.6967255", "0.6929481", "0.6900461", "0.6873134", "0.68212163"...
0.8284415
1
Allows you to do .nolock on a query
def nolock clone(:with => "(NOLOCK)") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nolock\n clone(:table_options => \"(NOLOCK)\")\n end", "def without_locking(&block)\n current = ActiveRecord::Base.lock_optimistically\n ActiveRecord::Base.lock_optimistically = false if current\n begin\n block.call\n ensure\n ...
[ "0.7786487", "0.72194034", "0.70768726", "0.70123297", "0.65658885", "0.6484154", "0.62651074", "0.622901", "0.60817206", "0.6000754", "0.59971285", "0.5988265", "0.59627455", "0.5884127", "0.5852311", "0.5837362", "0.5772591", "0.5771919", "0.5766119", "0.5766119", "0.576611...
0.7499212
1
Formats a SELECT statement using the given options and the dataset options.
def select_sql(opts = nil) opts = opts ? @opts.merge(opts) : @opts if sql = opts[:sql] return sql end # ADD TOP to SELECT string for LIMITS if limit = opts[:limit] top = "TOP #{limit} " raise Error, "Offset not supported" if opts[:offset] end columns = opts[:select] # We had to reference const WILDCARD with its full path, because # the Ruby constant scope rules played against us (it was resolving it # as Sequel::Dataset::DatasetMethods::WILDCARD). select_columns = columns ? column_list(columns) : Sequel::Dataset::WILDCARD if distinct = opts[:distinct] distinct_clause = distinct.empty? ? "DISTINCT" : "DISTINCT ON (#{expression_list(distinct)})" sql = "SELECT #{top}#{distinct_clause} #{select_columns}" else sql = "SELECT #{top}#{select_columns}" end if opts[:from] sql << " FROM #{source_list(opts[:from])}" end # ADD WITH to SELECT string for NOLOCK if with = opts[:with] sql << " WITH #{with}" end if join = opts[:join] join.each{|j| sql << literal(j)} end if where = opts[:where] sql << " WHERE #{literal(where)}" end if group = opts[:group] sql << " GROUP BY #{expression_list(group)}" end if order = opts[:order] sql << " ORDER BY #{expression_list(order)}" end if having = opts[:having] sql << " HAVING #{literal(having)}" end if union = opts[:union] sql << (opts[:union_all] ? \ " UNION ALL #{union.sql}" : " UNION #{union.sql}") end raise Error, "Intersect not supported" if opts[:intersect] raise Error, "Except not supported" if opts[:except] sql end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def select_sql(opts = nil)\n opts = opts ? @opts.merge(opts) : @opts\n\n if sql = opts[:sql]\n return sql\n end\n\n columns = opts[:select]\n select_columns = columns ? column_list(columns) : '*'\n sql = opts[:distinct] ? \\\n \"SELECT DISTINCT #{select_col...
[ "0.6971295", "0.6947242", "0.6841219", "0.67124456", "0.61597085", "0.6125864", "0.6049496", "0.6039606", "0.60335106", "0.6030042", "0.59272957", "0.58418024", "0.5811762", "0.58023846", "0.579844", "0.57814145", "0.574884", "0.5740213", "0.56984234", "0.56884044", "0.566159...
0.68679446
2
depends_on "cmake" => :build
def install bin.install "#{PACKAGE_NAME}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def package_depends_on\n depends_on\n end", "def install\n# Dependency tracking only, uncomment this section only if you know what you\n# are doing!\n#\n# mkdir 'build'\n# cd 'build' do\n# system \"cmake .. #{std_cmake_parameters}\"\n# system \"make package\"\n# end\nend", "def ...
[ "0.6862918", "0.67779785", "0.6605081", "0.6427604", "0.6401638", "0.6370821", "0.62428576", "0.6164104", "0.6164104", "0.6134335", "0.6026515", "0.6026515", "0.6026515", "0.594891", "0.59437174", "0.5839825", "0.5780695", "0.5748207", "0.57473993", "0.57118607", "0.56998265"...
0.0
-1
Delete file. ==== Options +path+:: Path to delete
def rm(path) run_via "rm #{path}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_file(path)\n path = File.join('/', path)\n raise ArgumentError if path == '/'\n self.class.delete(path, request_options)\n end", "def file_delete(path)\n params = {\n \"root\" => @root,\n \"path\" => format_path(path, false),\n }\n r...
[ "0.8407309", "0.81522477", "0.81036603", "0.79300404", "0.778736", "0.778736", "0.7774574", "0.7636546", "0.7590984", "0.75753653", "0.75179183", "0.74867314", "0.7411207", "0.73821634", "0.7351604", "0.73277605", "0.7283918", "0.7283918", "0.7267925", "0.71940285", "0.714805...
0.7109298
23