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 |
|---|---|---|---|---|---|---|
Extract a hash with attributes:values from the http params. source://devise//lib/devise/strategies/authenticatable.rb98 | def http_auth_hash; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def params_auth_hash; end",
"def auth_info\n params[auth_param] || {}\n end",
"def user_params\n allowedParamsKey = [:email, :password, :uid, :name, :nickname, :image]\n resultData = {}\n for key in allowedParamsKey\n resultData[key] = params.fetch(key, \"\")\n end\n ... | [
"0.681905",
"0.6648172",
"0.65387404",
"0.6493386",
"0.6427471",
"0.6361943",
"0.6361943",
"0.6321627",
"0.63036513",
"0.6277582",
"0.62652564",
"0.6228455",
"0.6191444",
"0.61628705",
"0.61628705",
"0.6162765",
"0.6117268",
"0.60296255",
"0.6018161",
"0.5999668",
"0.598125",... | 0.5952069 | 22 |
Check if the model accepts this strategy as http authenticatable. | def http_authenticatable?; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def http_authenticatable?\n mapping.to.http_authenticatable?(authenticatable_name)\n end",
"def http_authenticatable?\n mapping.to.http_authenticatable?(authenticatable_name)\n end",
"def valid_for_http_auth?\n http_authenticatable? && request.authorization && with_authentication... | [
"0.7714816",
"0.7714816",
"0.7639098",
"0.7639098",
"0.70799583",
"0.705905",
"0.69898516",
"0.6965629",
"0.6963274",
"0.6873079",
"0.66216296",
"0.66195005",
"0.6605249",
"0.6597048",
"0.65659785",
"0.6422227",
"0.6373206",
"0.6340653",
"0.63324374",
"0.6297192",
"0.6296414"... | 0.7320356 | 4 |
Extract the appropriate subhash for authentication from params. source://devise//lib/devise/strategies/authenticatable.rb93 | def params_auth_hash; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auth_info\n params[auth_param] || {}\n end",
"def params_auth_hash\n if params[scope].kind_of?(Hash) && params[scope].has_key?(authentication_keys.first)\n params[scope]\n else\n params\n end\n end",
"def userauth_params\n params.fetch(:usera... | [
"0.69534653",
"0.6643797",
"0.64488006",
"0.63779515",
"0.63649166",
"0.62913465",
"0.62913465",
"0.6256124",
"0.6223255",
"0.6201131",
"0.6151858",
"0.60834897",
"0.60197103",
"0.60024333",
"0.59675354",
"0.59362644",
"0.5932256",
"0.58914053",
"0.5891037",
"0.5861723",
"0.5... | 0.7018044 | 0 |
Check if the model accepts this strategy as params authenticatable. | def params_authenticatable?; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_for_params_auth?\n params_authenticatable? && valid_params_request? &&\n valid_params? && with_authentication_hash(:params_auth, params_auth_hash)\n end",
"def params_authenticatable?\n mapping.to.params_authenticatable?(authenticatable_name)\n end",
"def params_authe... | [
"0.78356254",
"0.77617234",
"0.7754954",
"0.71521574",
"0.6824922",
"0.6763126",
"0.66278446",
"0.66224223",
"0.66224223",
"0.64362466",
"0.6386827",
"0.63631034",
"0.63631034",
"0.6335494",
"0.632491",
"0.6299852",
"0.6249548",
"0.62475795",
"0.624461",
"0.6227692",
"0.61861... | 0.72778606 | 3 |
Get values from params and set in the resource. source://devise//lib/devise/strategies/authenticatable.rb51 | def remember_me(resource); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource_params\n user_params = params[:user] || {}\n user_params.merge!(uv_login: params[:uv_login]) if params[:uv_login].present?\n user_params\n end",
"def user_params\r\n end",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n ... | [
"0.6429193",
"0.6329016",
"0.6291739",
"0.62904036",
"0.6256918",
"0.61908996",
"0.61770904",
"0.61507064",
"0.6110684",
"0.61086357",
"0.610245",
"0.6100688",
"0.6069364",
"0.60428405",
"0.6020636",
"0.60164106",
"0.6005251",
"0.59937537",
"0.59812367",
"0.59417033",
"0.5941... | 0.0 | -1 |
Should this resource be marked to be remembered? | def remember_me?; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_yet?\n !!@resource_lock.synchronize { defined? @resource }\n end",
"def sharded?; false; end",
"def remember_me(resource); end",
"def remember_me(resource); end",
"def sharded?; true; end",
"def remember_me(resource)\n resource.remember_me = remember_me? if resource.respond_to?(:re... | [
"0.69278425",
"0.6366755",
"0.6306729",
"0.6306729",
"0.6277261",
"0.6248432",
"0.62062776",
"0.6161842",
"0.6149734",
"0.6043669",
"0.59742296",
"0.59714526",
"0.59713286",
"0.5950257",
"0.59452564",
"0.5932927",
"0.5920795",
"0.590915",
"0.5903682",
"0.58998346",
"0.5892761... | 0.0 | -1 |
Check if this is a valid strategy for http authentication by: Validating if the model allows http authentication; If any of the authorization headers were sent; If all authentication keys are present; | def valid_for_http_auth?; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_for_http_auth?\n http_authenticatable? && request.authorization && with_authentication_hash(:http_auth, http_auth_hash)\n end",
"def valid_for_http_auth?\n http_authenticatable? && request.authorization && with_authentication_hash(:http_auth, http_auth_hash)\n end",
"def valid... | [
"0.78484124",
"0.78484124",
"0.70997375",
"0.70390296",
"0.70184547",
"0.6895594",
"0.6806776",
"0.6793163",
"0.67798525",
"0.67351013",
"0.6707533",
"0.6693844",
"0.6539398",
"0.6508352",
"0.6503394",
"0.64716375",
"0.6468599",
"0.64320695",
"0.64320695",
"0.637331",
"0.6369... | 0.76214534 | 2 |
Check if this is a valid strategy for params authentication by: Validating if the model allows params authentication; If the request hits the sessions controller through POST; If the params[scope] returns a hash with credentials; If all authentication keys are present; | def valid_for_params_auth?; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_for_params_auth?\n params_authenticatable? && valid_params_request? &&\n valid_params? && with_authentication_hash(:params_auth, params_auth_hash)\n end",
"def allow_params_authentication!; end",
"def params_authenticatable?; end",
"def valid_params?\n params_auth_hash.i... | [
"0.7716821",
"0.71465135",
"0.69334435",
"0.6900779",
"0.6868475",
"0.67344296",
"0.65492487",
"0.64993685",
"0.64993685",
"0.6453783",
"0.6416946",
"0.63743716",
"0.6353567",
"0.63052016",
"0.6257188",
"0.62166584",
"0.62166584",
"0.6121203",
"0.61169297",
"0.60684705",
"0.6... | 0.7624465 | 1 |
If the request is valid, finally check if params_auth_hash returns a hash. | def valid_params?; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_params?\n params_auth_hash.is_a?(Hash)\n end",
"def valid_for_params_auth?\n params_authenticatable? && valid_params_request? &&\n valid_params? && with_authentication_hash(:params_auth, params_auth_hash)\n end",
"def valid_for_params_auth?; end",
"def validate\n ... | [
"0.80493057",
"0.7553411",
"0.75525796",
"0.7208551",
"0.6998181",
"0.69931287",
"0.6787177",
"0.67319065",
"0.66606",
"0.66606",
"0.6657574",
"0.6556658",
"0.65482056",
"0.6526344",
"0.65260243",
"0.6518387",
"0.6516572",
"0.6493215",
"0.64548695",
"0.64542687",
"0.6447076",... | 0.0 | -1 |
By default, a request is valid if the controller set the proper env variable. | def valid_params_request?; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid?(request_env)\n\t\t\treturn false unless valid_fields?(request_env)\n\t\t\ttrue\n\t\tend",
"def valid_params_request?\n true\n end",
"def valid_params_request?\n true\n end",
"def validate_env!\n raise Kiwi::NotAcceptable,\n \"Invalid request format `#{@env['kiwi.mim... | [
"0.69372934",
"0.68201685",
"0.68201685",
"0.67595947",
"0.6556469",
"0.64326775",
"0.640171",
"0.6392905",
"0.6386403",
"0.62606514",
"0.61949664",
"0.60908777",
"0.6041075",
"0.59896564",
"0.59839994",
"0.5976279",
"0.59422946",
"0.59338856",
"0.5909128",
"0.5905597",
"0.58... | 0.6477198 | 5 |
Note: unlike `Model.valid_password?`, this method does not actually ensure that the password in the params matches the password stored in the database. It only checks if the password is present. Do not rely on this method for validating that a given password is correct. | def valid_password?; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_password?(password)\n BCrypt::Password.new(self.password_digest).is_password?(password)\n end",
"def valid_password?(password)\n BCrypt::Password.new(self.password_digest).is_password?(password)\n end",
"def valid_password?(password)\n true\n end",
"def valid_password?(password)... | [
"0.8144988",
"0.8144988",
"0.8140854",
"0.81204224",
"0.80736935",
"0.80736935",
"0.8039408",
"0.79249763",
"0.7898306",
"0.78954124",
"0.7869759",
"0.78654706",
"0.78654706",
"0.7862066",
"0.78407353",
"0.7826359",
"0.7796755",
"0.7791233",
"0.7710866",
"0.769379",
"0.769379... | 0.7592447 | 36 |
Receives a resource and check if it is valid by calling valid_for_authentication? A block that will be triggered while validating can be optionally given as parameter. Check Devise::Models::Authenticatable.valid_for_authentication? for more information. In case the resource can't be validated, it will fail with the given unauthenticated_message. source://devise//lib/devise/strategies/authenticatable.rb37 | def validate(resource, &block); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate(resource, &block)\n result = resource && resource.valid_for_authentication?(&block)\n\n if result\n true\n else\n if resource\n fail!(resource.unauthenticated_message)\n end\n false\n end\n end",
"def validate(resource, ... | [
"0.8118112",
"0.7922703",
"0.7012449",
"0.69098693",
"0.69098693",
"0.68331814",
"0.6747219",
"0.6558135",
"0.64857167",
"0.6481216",
"0.6261509",
"0.6181004",
"0.6172088",
"0.6100752",
"0.60959935",
"0.60809416",
"0.6035609",
"0.60119927",
"0.60108626",
"0.5979541",
"0.59676... | 0.631161 | 10 |
Sets the authentication hash and the password from params_auth_hash or http_auth_hash. source://devise//lib/devise/strategies/authenticatable.rb128 | def with_authentication_hash(auth_type, auth_values); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_authentication_hash(hash)\n self.authentication_hash = {:email => hash[:username]}\n self.password = hash[:password]\n end",
"def with_authentication_hash(auth_type, auth_values)\n self.authentication_hash, self.authentication_type = {}, auth_type\n self.password = auth_... | [
"0.8050251",
"0.7552947",
"0.6857729",
"0.66293526",
"0.66224784",
"0.6530933",
"0.6504922",
"0.64597166",
"0.6389289",
"0.6389289",
"0.63765293",
"0.6349616",
"0.6342964",
"0.63393563",
"0.6329528",
"0.6306694",
"0.6262563",
"0.62507886",
"0.62507886",
"0.6231881",
"0.621800... | 0.69566727 | 2 |
Whenever CSRF cannot be verified, we turn off any kind of storage | def store?; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_up_csrf?; end",
"def clean_up_csrf?; end",
"def clean_up_csrf?\n false\n end",
"def clean_up_csrf?\n false\n end",
"def disable_request_forgery_protection; end",
"def clean_up_csrf?\n true\n end",
"def clean_up_csrf?\n true\n end",
"def di... | [
"0.73279715",
"0.73279715",
"0.72398937",
"0.723832",
"0.72034264",
"0.7160972",
"0.7160972",
"0.6875801",
"0.6775025",
"0.673664",
"0.6392637",
"0.6386263",
"0.63685447",
"0.6349139",
"0.63485074",
"0.6341817",
"0.6340424",
"0.633912",
"0.633912",
"0.633912",
"0.633912",
"... | 0.0 | -1 |
No need to clean up the CSRF when using rememberable. In fact, cleaning it up here would be a bug because rememberable is triggered on GET requests which means we would render a page on first access with all csrf tokens expired. | def clean_up_csrf?; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_up_csrf?\n true\n end",
"def clean_up_csrf?\n true\n end",
"def csrf_meta_tags; end",
"def csrf; end",
"def clean_up_csrf?\n false\n end",
"def clean_up_csrf?\n false\n end",
"def csrf_token\n session[:csrf] ||= SecureRandom.hex 32\n ... | [
"0.676709",
"0.676709",
"0.6743108",
"0.6736578",
"0.664619",
"0.6629792",
"0.6439144",
"0.64388686",
"0.6400207",
"0.6371056",
"0.62237847",
"0.6208066",
"0.61979145",
"0.6127952",
"0.6089141",
"0.60736823",
"0.6063838",
"0.6058558",
"0.60508513",
"0.60270983",
"0.60018253",... | 0.72477543 | 1 |
A valid strategy for rememberable needs a remember token in the cookies. | def valid?; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remember_me_login\n validate_token User, cookies[:remember_me]\n end",
"def remember_token; end",
"def remember_me?; end",
"def remember_token?\n remember_token_expires_at && Time.now.utc < remember_token_expires_at\n end",
"def remember_token?\n remember_token_expires_at && Time.no... | [
"0.71223",
"0.6870511",
"0.68574905",
"0.6727406",
"0.6699468",
"0.6675375",
"0.6669733",
"0.6667327",
"0.6661623",
"0.6661623",
"0.6661623",
"0.6657254",
"0.66563714",
"0.6655913",
"0.66390055",
"0.6630805",
"0.6616073",
"0.6607899",
"0.6599437",
"0.65839803",
"0.65791345",
... | 0.0 | -1 |
Override process to consider warden. source://devise//lib/devise/test/controller_helpers.rb34 | def process(*_arg0, **_arg1); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def warden\n env['warden']\n end",
"def warden\n env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def warden\n @warden ||= begin\n env['warden']\n end\n ... | [
"0.67677003",
"0.67677003",
"0.66955197",
"0.66955197",
"0.66955197",
"0.66024566",
"0.65551835",
"0.65441674",
"0.65441674",
"0.65441674",
"0.6272199",
"0.6068683",
"0.6043555",
"0.593299",
"0.5779282",
"0.57606363",
"0.57467663",
"0.568822",
"0.5604814",
"0.5573569",
"0.556... | 0.0 | -1 |
We need to set up the environment variables and the response in the controller. source://devise//lib/devise/test/controller_helpers.rb43 | def setup_controller_for_warden; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup\r\n @controller = ExpenseTypesController.new\r\n @request = ActionController::TestRequest.new\r\n @response = ActionController::TestResponse.new\r\n\r\n @request.user_agent = 'Firefox'\r\n @request.host = \"jose.#{DOMAIN_NAME}\"\r\n login_as :jose\r\n end",
"def setup_request_en... | [
"0.64643145",
"0.6436695",
"0.63970125",
"0.63757867",
"0.63435256",
"0.6175502",
"0.6155247",
"0.6077639",
"0.6054145",
"0.6042302",
"0.60134387",
"0.6000093",
"0.5994797",
"0.59553814",
"0.5954505",
"0.5932311",
"0.59237045",
"0.59059787",
"0.5864622",
"0.58593243",
"0.5850... | 0.550592 | 34 |
sign_in a given resource by storing its keys in the session. This method bypass any warden authentication callback. +resource+ The resource that should be authenticated +scope+ An optional +Symbol+ with the scope where the resource should be signed in with. Examples: sign_in users(:alice) sign_in users(:alice), scope: :admin source://devise//lib/devise/test/controller_helpers.rb67 | def sign_in(resource, deprecated = T.unsafe(nil), scope: T.unsafe(nil)); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign_in(resource_or_scope, resource=nil)\n scope ||= Devise::Mapping.find_scope!(resource_or_scope)\n resource ||= resource_or_scope\n warden.instance_variable_get(:@users).delete(scope)\n warden.session_serializer.store(resource, scope)\n end",
"def sign_in(resource_or_scope, resource=nil)\n... | [
"0.8034034",
"0.7913604",
"0.70929253",
"0.7088172",
"0.695838",
"0.6878202",
"0.67731005",
"0.66403216",
"0.6612854",
"0.6426855",
"0.6162953",
"0.6018126",
"0.6015974",
"0.5888569",
"0.58494407",
"0.58494407",
"0.5809758",
"0.5769287",
"0.56973374",
"0.56973374",
"0.5697337... | 0.54984766 | 57 |
Sign out a given resource or scope by calling logout on Warden. This method bypass any warden logout callback. Examples: sign_out :user sign_out(scope) | def sign_out(resource_or_scope); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logout!(scope: nil)\n if scope\n warden.logout(scope)\n warden.clear_strategies_cache!(scope: scope)\n else\n warden.logout\n warden.clear_strategies_cache!\n end\n end",
"def sign_out(resource_or_scope)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n wa... | [
"0.79710305",
"0.77687436",
"0.77010685",
"0.7538675",
"0.7469497",
"0.74233115",
"0.74233115",
"0.7205574",
"0.71258026",
"0.7006111",
"0.69999343",
"0.6983193",
"0.69324",
"0.6930035",
"0.6909614",
"0.69068664",
"0.68959165",
"0.68948793",
"0.6890865",
"0.6883932",
"0.68562... | 0.7547981 | 3 |
Quick access to Warden::Proxy. source://devise//lib/devise/test/controller_helpers.rb48 | def warden; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def warden\n env['warden']\n end",
"def warden\n env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def using_authenticated_proxy?; end",
"def warden\n request.env['warden'... | [
"0.67264646",
"0.67264646",
"0.65972894",
"0.65972894",
"0.65972894",
"0.648724",
"0.63447875",
"0.62066877",
"0.5986567",
"0.5950651",
"0.57482135",
"0.5729673",
"0.5710209",
"0.5708234",
"0.56514084",
"0.5651092",
"0.5627707",
"0.56183624",
"0.55652446",
"0.5539221",
"0.551... | 0.59421235 | 11 |
Catch warden continuations and handle like the middleware would. Returns nil when interrupted, otherwise the normal result of the block. source://devise//lib/devise/test/controller_helpers.rb103 | def _catch_warden(&block); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _around_rodauth(&block)\n result = nil\n\n rails_controller_rescue do\n rails_controller_callbacks do\n result = catch(:halt) { super(&block) }\n end\n end\n\n if rails_controller_instance.performed?\n rails_controller_response\n elsif result\n resu... | [
"0.62735796",
"0.5607128",
"0.55356616",
"0.5527113",
"0.532101",
"0.5274709",
"0.5245057",
"0.5175487",
"0.51303107",
"0.5121259",
"0.5121259",
"0.5100706",
"0.5084785",
"0.5084785",
"0.5084785",
"0.50111884",
"0.5010909",
"0.50002813",
"0.49504203",
"0.49412203",
"0.4921539... | 0.5894076 | 1 |
Signs in a specific resource, mimicking a successful sign in operation through +Devise::SessionsControllercreate+. +resource+ The resource that should be authenticated +scope+ An optional +Symbol+ with the scope where the resource should be signed in with. source://devise//lib/devise/test/integration_helpers.rb37 | def sign_in(resource, scope: T.unsafe(nil)); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign_in(resource_or_scope, resource=nil)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n resource ||= resource_or_scope\n warden.set_user(resource, :scope => scope)\n end",
"def sign_in(resource_or_scope, *args); end",
"def sign_in_and_redirect(resource_or_scope, r... | [
"0.7654251",
"0.7625113",
"0.7383515",
"0.7250276",
"0.72110313",
"0.7187767",
"0.7101465",
"0.70680755",
"0.70024484",
"0.6936932",
"0.69361544",
"0.6912734",
"0.69106615",
"0.6909854",
"0.6909854",
"0.6909854",
"0.6909854",
"0.6909854",
"0.6909854",
"0.6909854",
"0.6909854"... | 0.7108921 | 6 |
Signs out a specific scope from the session. +resource_or_scope+ The resource or scope that should be signed out. source://devise//lib/devise/test/integration_helpers.rb46 | def sign_out(resource_or_scope); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign_out(resource_or_scope)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n warden.user(scope) # Without loading user here, before_logout hook is not called\n warden.raw_session.inspect # Without this inspect here. The session does not clear.\n warden.logout(scope)\n ... | [
"0.8243276",
"0.78778213",
"0.77604944",
"0.76542157",
"0.74604636",
"0.7411613",
"0.70094126",
"0.68311465",
"0.67743087",
"0.6764469",
"0.67557484",
"0.66655976",
"0.6490673",
"0.6485247",
"0.6468482",
"0.6459305",
"0.6457145",
"0.64546746",
"0.6423036",
"0.64216405",
"0.64... | 0.8185765 | 2 |
With this method we validate the input parameters | def check_params
#User ID must introduced
if params[:uid].blank?
flash[:error] = "User ID cannot be void"
redirect_to :action =>'index' and return
#Page must be a number
elsif (!params[:page].blank? && !(Integer === params[:page]))
flash[:error] = "Page must be a number"
redirect_to :action => 'index' and return
#If page is empty, we set it to 1
elsif params[:page].blank?
@page = '1'
@uid = params[:uid]
@pub0 = params[:pub0]
#Normal assignments
else
@uid = params[:uid]
@pub0 = params[:pub0]
@page = params[:page].to_i
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_params?; end",
"def validate_params(params)\n # This will be implemented by Validators which take parameters\n end",
"def validate params\n validate_params(params)\n validate_coordinates\n validate_color\n validate_dimension\n end",
"def check_params... | [
"0.8146083",
"0.80835253",
"0.80127525",
"0.7832227",
"0.7734135",
"0.7719062",
"0.7684393",
"0.753941",
"0.7515018",
"0.7470152",
"0.7429096",
"0.7402946",
"0.7402946",
"0.7402946",
"0.7402946",
"0.7359438",
"0.7359438",
"0.7345443",
"0.7343727",
"0.7341059",
"0.73254406",
... | 0.0 | -1 |
Returns an array containing all address/data from the given srecord No address manipulation is performed, that is left to the caller to apply any scrambling as required by the target system | def extract_addr_data(options = {})
options = {
data_width_in_bytes: 4
}.merge(options)
# guarantee that the start_address will be the jump address if provided
if @start_address.nil?
start_address
@call_order_warn = @start_record_found ? true : false
end
result = []
lines.each do |line|
# Only if the line is an s-record with data...
if line =~ /^S([1-3])/
type = Regexp.last_match[1].to_i(16) # S-record type, 1-3
# Set the matcher to capture x number of bytes dependent on the s-rec type
addr_matcher = '\w\w' * (1 + type)
line.strip =~ /^S\d\w\w(#{addr_matcher})(\w*)\w\w$/ # $1 = address, $2 = data
addr = Regexp.last_match[1].to_i(16)
data = Regexp.last_match[2]
data_matcher = '\w\w' * options[:data_width_in_bytes]
data.scan(/#{data_matcher}/).each do |data_packet|
result << [addr, data_packet.to_i(16)]
addr += options[:data_width_in_bytes]
end
# If a partial word is left over
if (remainder = data.length % (2 * options[:data_width_in_bytes])) > 0
if @ljust_partial_data
result << [addr, data[data.length - remainder..data.length].ljust(options[:data_width_in_bytes] * 2, '0').to_i(16)]
else
result << [addr, data[data.length - remainder..data.length].to_i(16)]
end
end
end
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieveaddressnameskey(fileonedata)\n arr = Array.new\n fileonedata.each_line.with_index do |single_line, index|\n arr.push(single_line.split[0]) if (single_line.split[5] && index>20)\n end\n return arr\n end",
"def records( quantity = 1 )\n addresses = []\n quantity.time... | [
"0.549314",
"0.5349734",
"0.53302795",
"0.5318069",
"0.5182119",
"0.5142609",
"0.51148087",
"0.50625414",
"0.50619715",
"0.50290227",
"0.5026357",
"0.4987581",
"0.4980323",
"0.49603248",
"0.49258032",
"0.4924828",
"0.49219352",
"0.4897368",
"0.4884585",
"0.4884136",
"0.488148... | 0.6509779 | 0 |
nested array of winning key combinations | def initialize
@squares = {} # call it @squares since a Board will be composed of squares with individual states
reset # RESET METHOD INSERTS A HASH INTO @square
# want to set it to an Square object with marker attribute / value of INITIAL_MARKER, instead of just directly setting it to INITIAL_MARKER.
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def winning_combos\n [[0, 1, 2], [3, 4, 5], [6, 7, 8],\n [0, 3, 6], [1, 4, 7], [2, 5, 8],\n [0, 4, 8], [2, 4, 6]]\n end",
"def win_combos \n row_wins = @board.map { |x| x - 1 }.each_slice(@n).to_a\n column_wins = @columns.flatten.map { |x| x - 1 }.each_slice(@n).to_a \n diagonal_wins = @dia... | [
"0.7519783",
"0.69545454",
"0.6690531",
"0.6542208",
"0.63667154",
"0.63269246",
"0.6292277",
"0.61803764",
"0.6052985",
"0.60504675",
"0.6032583",
"0.6010009",
"0.59968084",
"0.5979499",
"0.5977666",
"0.59722435",
"0.596451",
"0.5959321",
"0.59573287",
"0.5940402",
"0.592842... | 0.0 | -1 |
This belongs in Square class instead of Player class, since we're modifying the value of the Square class | def initialize(marker = INITIAL_MARKER)
@marker = marker # will reveal the state of each square. Whether it has been marked or is empty
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play_square(location,player)\n square = find_square(location)\n square.value=(player.character)\n end",
"def take_square(player, number)\n marker = player.name == 'human' ? 'x' : 'o'\n self.squares[number] = marker\n draw_board\n end",
"def player; end",
"def player; end",
"def player;... | [
"0.6812742",
"0.63719916",
"0.6311631",
"0.6311631",
"0.6311631",
"0.6311631",
"0.6311631",
"0.6311631",
"0.6311631",
"0.6172656",
"0.6126217",
"0.59996766",
"0.5917214",
"0.5870132",
"0.58673096",
"0.58257437",
"0.5803733",
"0.57907677",
"0.5785401",
"0.5750422",
"0.5743899"... | 0.0 | -1 |
duplicate of Square :marker accessor, but serves different use. Chose only to make this a reader, since don't need writer | def initialize(marker)
@marker = marker
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_marker\n return @marker\n end",
"def get_marker\n return @marker\n end",
"def get_marker\n return @marker\n end",
"def []=(key, marker)\n @squares[key].marker = marker #change the square marker of that particular square object\n end",
"def get_marker\n return @marker\n end... | [
"0.65842634",
"0.65842634",
"0.65842634",
"0.644567",
"0.6426597",
"0.6426597",
"0.6426597",
"0.6364895",
"0.62984973",
"0.62589914",
"0.6137002",
"0.6110005",
"0.6100135",
"0.6004452",
"0.6003919",
"0.59839374",
"0.59839374",
"0.59839374",
"0.59839374",
"0.59839374",
"0.5983... | 0.5576398 | 35 |
ENDPOINTS FOR APP BAR | def check_for_user
if current_user
@user = current_user
else
@user = {}
end
render json: @user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def endpoints; end",
"def endpoint; end",
"def endpoint; end",
"def endpoint; end",
"def endpoint; end",
"def rest_endpoint; end",
"def service_endpoint; end",
"def service_endpoint; end",
"def endpoints_list\n get \"endpoints\"\n end",
"def apis; end",
"def api_endpoint\n 'index'\n ... | [
"0.7095638",
"0.6529525",
"0.6529525",
"0.6529525",
"0.6529525",
"0.65152955",
"0.6515103",
"0.6515103",
"0.6485747",
"0.6479891",
"0.64658314",
"0.6373478",
"0.62741446",
"0.6073983",
"0.5992554",
"0.597984",
"0.59766763",
"0.59711814",
"0.59711814",
"0.585802",
"0.5850785",... | 0.0 | -1 |
ENDPOINTS FOR LANDING PAGE | def landing_search_data
@unsorted_data =[]
categories = Category.all
vendors = Vendor.all
organizations = Organization.all
s_s_categories = SuperSuperCategory.all
s_s_categories.each do |ssc|
s_s_category_hash = {
label: ssc.name + " (Umbrella Category)",
value: ssc.name + " (Umbrella Category)",
id: ssc.id,
type: "super_super_categories"
}
@unsorted_data << s_s_category_hash
end
categories.each do |c|
category_hash = {
label: c.suggestion_label,
value: c.suggestion_label,
id: c.id,
type: "categories"
}
@unsorted_data << category_hash
end
vendors.each do |v|
vendor_hash = {
label: v.name + " (Vendor Page)",
value: v.name + " (Vendor Page)",
id: v.id,
type: "vendors"
}
@unsorted_data << vendor_hash
end
organizations.each do |s|
organization_hash = {
label: s.name + " (School Page)",
value: s.name + " (School Page)",
id: s.id,
type: "organizations"
}
@unsorted_data << organization_hash
end
@data = @unsorted_data.sort{|a,b| a[:label]<=>b[:label]}
render json: @data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pages; end",
"def pages\n end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def endpoints; end",
"def sample_page\n\n ... | [
"0.65637076",
"0.6495347",
"0.6402325",
"0.6402325",
"0.6402325",
"0.6402325",
"0.6402325",
"0.6402325",
"0.6402325",
"0.6402325",
"0.6402325",
"0.6402325",
"0.6402325",
"0.6402325",
"0.6377466",
"0.63324577",
"0.6196554",
"0.6089698",
"0.6010704",
"0.60014415",
"0.59697044",... | 0.0 | -1 |
END POINTS FOR TAXONOMY DATA | def building_and_grounds
bag = SuperSuperCategory.find_by(name: "Facilities")
super_categories = bag.super_categories
if params[:org]
@data = build_from_super_super_categories(super_categories, params[:org].to_i)
else
@data = build_from_super_super_categories(super_categories, 0)
end
render json: @data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_point\n raise Error::UnsupportedOperation, \"Method Curve#end_point not defined.\"\n end",
"def end_at(x, y = nil)\n to.coord x, y\n end",
"def set_end(t)\n @end_t = t\n end",
"def end_point; end",
"def points; end",
"def end_line(kind); end",
"def end_line kind\n ... | [
"0.608792",
"0.6024807",
"0.5757591",
"0.57191473",
"0.56061244",
"0.5377054",
"0.5359521",
"0.5351864",
"0.5342215",
"0.53189546",
"0.53144443",
"0.52976054",
"0.52976054",
"0.52810514",
"0.527212",
"0.52574164",
"0.5251169",
"0.52439976",
"0.52136254",
"0.519062",
"0.517847... | 0.0 | -1 |
ENDPOINTS FOR ORGANIZATION SHOW | def org_show_data
org = Organization.find(params[:org])
@data = {
name: org.name,
website: org.website,
logo_link: org.logo_link,
users: user_names_and_emails_from_org(org)
}
render json: @data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_organizations(options = nil)\n require_relative 'telerivet/organization'\n self.cursor(Organization, get_base_api_path() + \"/organizations\", options)\n end",
"def orgs\n client.organizations\n end",
"def GetOrgs params = {}\n\n params = params.merge(path: 'organizations.... | [
"0.7056028",
"0.6808707",
"0.66048837",
"0.6400812",
"0.6391337",
"0.63774014",
"0.6305355",
"0.6300352",
"0.6210934",
"0.6210487",
"0.61929846",
"0.6168134",
"0.61547947",
"0.6140128",
"0.60727775",
"0.60621315",
"0.6046288",
"0.60279566",
"0.59941375",
"0.59938157",
"0.5984... | 0.0 | -1 |
ENDPOINTS FOR REVIEW SHOW | def review_show_data
review = Review.find(params[:review])
@data = {
user_name: review.user.full_name,
user_id: review.user.id,
user_email: review.user.email,
org_name: review.user.organization.name,
org_id: review.user.organization.id,
vendor_name: review.vendor.name,
vendor_id: review.vendor.id,
rating: review.rating,
public_review: review.review_content,
private_review: review.review_private_content,
private_review_permission: private_review_permission(review.user),
logo_link: review.user.organization.logo_link,
days_ago: review.days_old
}
render json: @data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n respond_with :api, @review, @review.comments\n end",
"def view(options = {})\n\t \tget_records('-view', {}, options)\n\t end",
"def views()\n return uri(\"api/views/\")\n end",
"def index\n @reviewers = Reviewer.all\n\n respond_to do |format|\n format.html # index.htm... | [
"0.66014105",
"0.6285805",
"0.62088877",
"0.614456",
"0.6116951",
"0.6116429",
"0.606658",
"0.60662127",
"0.60527855",
"0.6047994",
"0.5989912",
"0.59546494",
"0.59368235",
"0.5930159",
"0.5903922",
"0.5897852",
"0.5896169",
"0.5878332",
"0.58773404",
"0.58623713",
"0.5855419... | 0.0 | -1 |
ENDPOINTS FOR USER SHOW | def user_show_data
user = User.find(params[:user])
@data = {
name: user.full_name,
email: user.email,
title: user.title,
school_name: user.organization.name,
logo_link: user.organization.logo_link,
points: user.points,
reviews: reviews_from_user(user),
protips: protips_from_user(user),
receives_weekly_digest: user.receives_weekly_digest,
active: user.active
}
render json: @data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_users(options={}) path = \"/api/v2/users\"\n get(path, options, AvaTax::VERSION) end",
"def list_users\n self.class.get('/users')\n end",
"def get_users(request); end",
"def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend",
"def list_users_fo... | [
"0.73242354",
"0.73199177",
"0.70855397",
"0.7056486",
"0.7056486",
"0.704903",
"0.70306647",
"0.70243",
"0.6888942",
"0.688186",
"0.685705",
"0.6855818",
"0.684113",
"0.68373734",
"0.68334675",
"0.6820913",
"0.6799318",
"0.6761416",
"0.67281425",
"0.6679518",
"0.6673047",
... | 0.0 | -1 |
ENDPOINTS FOR VENDOR SHOW | def vendor_show_data
vendor = Vendor.find(params[:vendor])
@data = {
id: vendor.id,
name: vendor.name,
cpa_preferred: vendor.preferred,
street: vendor.street,
website: vendor.website,
city_state_and_zip: vendor.city_state_and_zip,
categories_array: categories_from_vendor(vendor),
schools_array: school_relationships_from_vendor(vendor),
point_people_array: point_people_from_vendor(vendor)
}
render json: @data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vendors\n fetch(@config[:sales_path], 'Sales.getVendors')\n end",
"def getVendors\n fetch(@config[:sales_path], 'Sales.getVendors')\n end",
"def index\n @admin_vendors = Vendor.all\n end",
"def show\n \n @product = Product.find(params[:id])\n @vendors = @product.vendor(:all)\... | [
"0.71276915",
"0.6970254",
"0.6654423",
"0.6549704",
"0.6472122",
"0.6472122",
"0.6472122",
"0.645279",
"0.63179594",
"0.63037854",
"0.6262793",
"0.61439794",
"0.6089756",
"0.6039669",
"0.6014477",
"0.5992804",
"0.59864867",
"0.5979668",
"0.59590286",
"0.5951987",
"0.5897339"... | 0.5696897 | 38 |
ENDPOINTS FOR CATEGORY SHOW | def category_show_data
category = Category.find(params[:category])
@data = {
name: category.full_name,
vendors: vendors_data_from_category(category),
protips: protips_from_category(category)
}
render json: @data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCategoryAll()\n params = Hash.new\n return doCurl(\"get\",\"/category/all\",params)\n end",
"def index\n respond_with Category.all\n end",
"def categories\n expose Metadata.categories(@oauth_token)\n end",
"def get_category\n json_response({ message: 'NOT IMPLEMENTED' })\n e... | [
"0.71500504",
"0.7063677",
"0.69246775",
"0.6790988",
"0.663246",
"0.6573214",
"0.6539908",
"0.6531344",
"0.65190494",
"0.65156454",
"0.65152013",
"0.65041834",
"0.6491196",
"0.64877033",
"0.6477225",
"0.647094",
"0.6460429",
"0.64420354",
"0.6441421",
"0.6426239",
"0.641645"... | 0.0 | -1 |
behold! extracting flag flag level and category from icon src because its nowhere to be found. Possible PITA. | def flag_from_img(img_src)
_crap, category, level = /([1-9])_([1-9])/.match(img_src).to_a
{ Tribes::FLAG_CATEGORIES[category.to_i] => level }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def icon\n primary_category ? primary_category[\"icon\"] : \"https://foursquare.com/img/categories/none.png\"\n end",
"def icon\n primary_category ? primary_category[\"icon\"] : \"https://foursquare.com/img/categories/none.png\"\n end",
"def ImageList_ExtractIcon(hi, himl, i)\r\n ImageLi... | [
"0.6134026",
"0.6134026",
"0.60431534",
"0.59672534",
"0.594529",
"0.59039444",
"0.5787242",
"0.5695419",
"0.5681794",
"0.56429297",
"0.5609058",
"0.5544168",
"0.5517843",
"0.54973555",
"0.54915863",
"0.54915863",
"0.54816574",
"0.54714864",
"0.54502755",
"0.54406",
"0.543470... | 0.70758474 | 0 |
GET /spec_types GET /spec_types.json | def index
@spec_types = SpecType.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @specification_types = SpecificationType.all.order(\"display_order\")\n\n render json: @specification_types, each_serializer: Web::V1::SpecificationTypeSerializer\n end",
"def show\n render json: @specification_type, serializer: Web::V1::SpecificationTypeSerializer\n end",
"def spec_type... | [
"0.7307178",
"0.7115818",
"0.68488276",
"0.67915046",
"0.654943",
"0.64228445",
"0.629436",
"0.625062",
"0.6244812",
"0.6226265",
"0.6164064",
"0.6127597",
"0.6115352",
"0.6099166",
"0.6085999",
"0.60817564",
"0.6076774",
"0.60442877",
"0.60073155",
"0.6000154",
"0.59961635",... | 0.7248025 | 1 |
GET /spec_types/1 GET /spec_types/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n render json: @specification_type, serializer: Web::V1::SpecificationTypeSerializer\n end",
"def index\n @spec_types = SpecType.all\n end",
"def index\n @specification_types = SpecificationType.all.order(\"display_order\")\n\n render json: @specification_types, each_serializer: Web::V1:... | [
"0.73448294",
"0.7071844",
"0.70468366",
"0.6670518",
"0.6363673",
"0.63436395",
"0.6339627",
"0.62637466",
"0.62167907",
"0.61923987",
"0.6163569",
"0.6132918",
"0.6117882",
"0.6103355",
"0.6073636",
"0.6062175",
"0.6013483",
"0.60117596",
"0.5976781",
"0.5976781",
"0.597219... | 0.0 | -1 |
POST /spec_types POST /spec_types.json | def create
@spec_type = SpecType.new(spec_type_params)
respond_to do |format|
if @spec_type.save
format.html { redirect_to @spec_type, notice: 'Spec type was successfully created.' }
format.json { render :show, status: :created, location: @spec_type }
else
format.html { render :new }
format.json { render json: @spec_type.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spec_type_params\n params[:spec_type]\n end",
"def create\n @specification_type = SpecificationType.new(specification_type_params)\n\n if @specification_type.save\n audit(@specification_type, current_user)\n render json: @specification_type, status: :created, serializer: Web::V1::Spec... | [
"0.67420185",
"0.64927244",
"0.6341795",
"0.6195768",
"0.619071",
"0.6129462",
"0.60754585",
"0.60294974",
"0.5896319",
"0.5872012",
"0.5859446",
"0.57690704",
"0.57690704",
"0.5745769",
"0.5745769",
"0.5744682",
"0.57230026",
"0.5692729",
"0.56481147",
"0.564453",
"0.5632541... | 0.6962521 | 0 |
PATCH/PUT /spec_types/1 PATCH/PUT /spec_types/1.json | def update
respond_to do |format|
if @spec_type.update(spec_type_params)
format.html { redirect_to @spec_type, notice: 'Spec type was successfully updated.' }
format.json { render :show, status: :ok, location: @spec_type }
else
format.html { render :edit }
format.json { render json: @spec_type.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @specification_type = SpecificationType.find(params[:id])\n\n if @specification_type.update(specification_type_params)\n audit(@specification_type, current_user)\n render json: @specification_type, status: :created, serializer: Web::V1::SpecificationTypeSerializer\n else\n rend... | [
"0.6612324",
"0.63483363",
"0.620205",
"0.61537623",
"0.6052424",
"0.6011914",
"0.60113627",
"0.59829694",
"0.58779943",
"0.5865465",
"0.5856983",
"0.5843561",
"0.58425176",
"0.5820479",
"0.5819448",
"0.5813979",
"0.58093876",
"0.58080965",
"0.5805706",
"0.5785671",
"0.576515... | 0.71187735 | 0 |
DELETE /spec_types/1 DELETE /spec_types/1.json | def destroy
@spec_type.destroy
respond_to do |format|
format.html { redirect_to spec_types_url, notice: 'Spec type was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @ref_diagnostic_test_type = Ref::DiagnosticTestType.find(params[:id])\n @ref_diagnostic_test_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_diagnostic_test_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @testtype.destroy\n r... | [
"0.7179933",
"0.7171601",
"0.7051086",
"0.70505744",
"0.70373565",
"0.69487417",
"0.69423866",
"0.69380033",
"0.6933932",
"0.69169086",
"0.6906474",
"0.69033784",
"0.6888754",
"0.68825257",
"0.6879661",
"0.68530214",
"0.6824261",
"0.68000007",
"0.67935455",
"0.67918843",
"0.6... | 0.7780576 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_spec_type
@spec_type = SpecType.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def spec_type_params
params[:spec_type]
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.6980957",
"0.6783065",
"0.6747844",
"0.6741468",
"0.67356336",
"0.6592548",
"0.65036845",
"0.64978707",
"0.64825076",
"0.64795035",
"0.64560914",
"0.64397955",
"0.6379666",
"0.6376688",
"0.6366702",
"0.6319728",
"0.6300833",
"0.6300629",
"0.6294277",
"0.6293905",
"0.629117... | 0.0 | -1 |
test if the two values match or not | def bar?
# with new cache structure, data is written to cache every frame, so after a couple of frames of not firing, the two values in the cache will be the same.
# Nothing wrong with that though. It's not like you're allocating any more data than before or anything.
# if boolean, return that value instead, ignoring the cache
return @this if !!@this == @this
# there is stored data but it's old, or no data has yet been stored
@prev && @prev != @this or @prev.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def equals(one, two)\n matched_by(one, two)\n matched_by(two, one)\n end",
"def check\n if @value1 == @value2\n @message = \"#{@value1} == #{@value2}\"\n true\n else\n @message = \"#{@value1} != #{@value2}\"\n false\n end\n end",
"def test_not_same_value_as\... | [
"0.7227751",
"0.70846874",
"0.6882077",
"0.6877162",
"0.681408",
"0.6752444",
"0.66699755",
"0.6647723",
"0.66419613",
"0.66240984",
"0.65509623",
"0.6540419",
"0.6474069",
"0.6437279",
"0.6433643",
"0.64331496",
"0.6427681",
"0.64171237",
"0.63864017",
"0.6362724",
"0.633803... | 0.0 | -1 |
save a new value in the cache, kicking out the oldest value | def save(data)
# NOTE: in a low-level implementation of this, you want to have two "save slots", and juggle pointers to figure out what data is "this" and what is "prev", rather moving the data down one slot. (ie, you alternate saving data into the left slot, and the right slot, rather than always saving in the right slot)
@prev = @this
@this = data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(key, value)\n return if @capacity <= 0\n\n @cache_mutex.synchronize do\n @map.delete(key) if @map.key?(key)\n\n @map[key] = CacheElement.new(value)\n\n @map.delete(@map.first[0]) if @map.size > @capacity\n nil\n end\n end",
"def set_cache(value); end",
"de... | [
"0.7240398",
"0.72047436",
"0.72047436",
"0.6981877",
"0.68131745",
"0.68063784",
"0.6657292",
"0.6646581",
"0.6611423",
"0.6610272",
"0.6516248",
"0.6514823",
"0.64915466",
"0.64804405",
"0.6474109",
"0.64461297",
"0.6442895",
"0.6440132",
"0.6377433",
"0.63764703",
"0.63625... | 0.0 | -1 |
I worked on this challenge Julia Giraldi (and Laura Crowe during office hours). | def factorial(number)
if number == 0
return 1
end
product = 1
for number in (1..number)
product = product * number
end
return product
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution(s, p, q)\n # write your code in Ruby 2.2\n g = s.length + 1\n a = (s.length + 1)**3\n c = (s.length + 1)**2\n tmp = []\n res = []\n tmp.push 0\n o = 0\n s.split('').each do |i|\n o += if i == 'T'\n 1\n elsif i == 'G'\n g\n elsif i == 'C'\n c\n ... | [
"0.69811946",
"0.6817478",
"0.66277355",
"0.6526303",
"0.6432947",
"0.6320236",
"0.6273108",
"0.6253722",
"0.62426543",
"0.6236635",
"0.6215046",
"0.621484",
"0.62128776",
"0.6205563",
"0.62034285",
"0.61860853",
"0.618547",
"0.61854297",
"0.61789405",
"0.61735773",
"0.617204... | 0.0 | -1 |
GET /contact GET /contact.json | def index
redirect_to new_contact_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @contact = Contact.find(params[:id])\n\n render json: @contact\n end",
"def show\n render json: @contact\n end",
"def show\n render json: @contact\n end",
"def show\n @contact = Contact.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n form... | [
"0.7936726",
"0.78015804",
"0.78015804",
"0.7721689",
"0.7721689",
"0.7721689",
"0.7579549",
"0.7462664",
"0.73557734",
"0.73085946",
"0.7297218",
"0.7200316",
"0.71695065",
"0.7146676",
"0.71428233",
"0.7142578",
"0.7139203",
"0.71077436",
"0.71077436",
"0.71077436",
"0.7087... | 0.0 | -1 |
GET /contact/formulaire GET /contact/formulaire.json | def new
@contact_form = ContactForm.new
seo_tag_index page
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookup\n respond_to do |format|\n format.json { render json: Crm::ContactLookup.new(view_context) }\n end\n end",
"def index\n @contactable = find_contactable\n @contactos = @contactable.contactos\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render... | [
"0.6179646",
"0.6159316",
"0.5925507",
"0.5883502",
"0.5879162",
"0.5755039",
"0.57363683",
"0.57363683",
"0.57363683",
"0.5688854",
"0.5688854",
"0.5686619",
"0.5654469",
"0.5648161",
"0.56332797",
"0.56330246",
"0.5618351",
"0.5587581",
"0.55757004",
"0.5569158",
"0.5569158... | 0.0 | -1 |
GET /haos/1 GET /haos/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @osoba = Osoba.find(params[:id])\n\n render json: @osoba\n end",
"def show\n @huerto = Huerto.find_by_id(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @huerto }\n end\n end",
"def index\n @hikiyamas = @omatsuri.hikiya... | [
"0.69756824",
"0.6410446",
"0.6405375",
"0.6396164",
"0.639236",
"0.63656783",
"0.63006485",
"0.63004607",
"0.6289397",
"0.6285407",
"0.62272143",
"0.6178297",
"0.6168639",
"0.6163009",
"0.61545795",
"0.61312854",
"0.6119018",
"0.60987496",
"0.60927534",
"0.6092521",
"0.60903... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_hao
@hao = Hao.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def hao_params
params[:hao]
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.6980957",
"0.6783065",
"0.6747844",
"0.6741468",
"0.67356336",
"0.6592548",
"0.65036845",
"0.64978707",
"0.64825076",
"0.64795035",
"0.64560914",
"0.64397955",
"0.6379666",
"0.6376688",
"0.6366702",
"0.6319728",
"0.6300833",
"0.6300629",
"0.6294277",
"0.6293905",
"0.629117... | 0.0 | -1 |
Ruby keyword arguments only after average arguments in method call and method definition. | def example(a,b:,c:5)
[a,b,c]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_kwarg=(_arg0); end",
"def meth(\n **\n ); end",
"def in_kwarg; end",
"def method_with_keyword_arguments(one: 1, two: 'two')\n [one, two]\n end",
"def extra_args; end",
"def **(arg0)\n end",
"def **(arg0)\n end",
"def my_method(*a, **kw)\n p arguments: a, keywords: kw\nend",
"d... | [
"0.7084937",
"0.70146084",
"0.7009015",
"0.6977629",
"0.6890991",
"0.6853093",
"0.6853093",
"0.68326384",
"0.6804488",
"0.67607355",
"0.6688588",
"0.661327",
"0.661327",
"0.661327",
"0.6607254",
"0.6602113",
"0.6505678",
"0.6495558",
"0.6489973",
"0.6476241",
"0.64568347",
... | 0.0 | -1 |
This function validates the mandatory fields in the request. Args : +requestParams+ > the request parameter Returns : +errorArray+ > the error code | def validateRequestParam(requestParams = {})
if requestParams[:pReqType].blank? || isBlankOrNull(requestParams[:pReqType])
return BLANK_REQUEST_TYPE
elsif !(@@requestTypes.include? requestParams[:pReqType])
return INVALID_REQUEST_TYPE
end
if requestParams[:pMerCode].blank? || isBlankOrNull(requestParams[:pMerCode])
return BLANK_MER_CODE
end
if requestParams[:pEncKey].blank? || isBlankOrNull(requestParams[:pEncKey])
return INVALID_KEY
end
if requestParams[:pEncIv].blank? || isBlankOrNull(requestParams[:pEncIv]) || requestParams[:pEncIv].length < 16
return INVALID_IV
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate\n raise ArgumentError, \"Params emtpy\" if @params.nil? \n @errors = []\n @errors << 'reason must be provided' if @params.reason.nil? \n @errors << 'txn_id must be provided' if @params.txn_id.nil? \n @errors << 'order.id must be provided' if @params.order.id.nil? \n @erro... | [
"0.7173365",
"0.7128832",
"0.71212465",
"0.7113148",
"0.70267826",
"0.6999069",
"0.69359785",
"0.67092156",
"0.6673708",
"0.65883684",
"0.65700966",
"0.65494776",
"0.6549366",
"0.6549366",
"0.65255815",
"0.6474811",
"0.646544",
"0.6448392",
"0.64151627",
"0.64083606",
"0.6392... | 0.6907541 | 7 |
This function validates the mandatory fields in the response.. Args : +responseParams+ > the response parameter Returns : +errorArray+ > the error code | def validateResponseParam(responseParams = {})
if responseParams[:pRes].blank? || isBlankOrNull(responseParams[:pRes])
return BLANK_PG_RESPONSE
end
if responseParams[:pEncKey].blank? || isBlankOrNull(responseParams[:pEncKey])
return INVALID_KEY
end
if responseParams[:pEncIv].blank? || isBlankOrNull(responseParams[:pEncIv]) || responseParams[:pEncIv].length < 16
return INVALID_IV
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_endpoint_response\n begin\n return if response.nil?\n res = JSON.parse(response)\n \n if res[\"code\"].present?\n errors.add(:response, 'response code must have value of data type integer') if !res[\"code\"].is_a? Integer\n ... | [
"0.69860464",
"0.681019",
"0.6738128",
"0.67079586",
"0.6701786",
"0.6634733",
"0.6632663",
"0.66182786",
"0.6512523",
"0.64695257",
"0.64693385",
"0.64480644",
"0.64204943",
"0.641793",
"0.6309795",
"0.6261852",
"0.626092",
"0.62516695",
"0.62516695",
"0.62206036",
"0.621272... | 0.66650736 | 5 |
This function checks if a value is blank, null or 'NA' and returns true, else returns false. Args : +param+ > the parameter Returns : +boolean+ > the result | def isBlankOrNull(param = null)
if param.nil? || param==="NA" || param.empty?
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blank?(param)\n param.nil? || param.empty?\n end",
"def any_empty(*params)\n params.each do |param|\n if param == nil or param == ''\n return true\n end\n end\n false\n end",
"def value_empty?\n if value === nil or value === \"\"\n return true\n end\n re... | [
"0.7355396",
"0.70946455",
"0.7066158",
"0.70298797",
"0.69937193",
"0.6835821",
"0.6831294",
"0.6817792",
"0.681066",
"0.6782073",
"0.67507845",
"0.66956055",
"0.6678011",
"0.6667804",
"0.6585512",
"0.65823436",
"0.6575102",
"0.657127",
"0.656242",
"0.656242",
"0.65614396",
... | 0.85502607 | 0 |
Don't put anything above this | def to_param
to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def placebo?; false end",
"def ignores; end",
"def ignore; end",
"def under; end",
"def before; end",
"def naked_top_level?; end",
"def extra; end",
"def anchored; end",
"def naked_top_level; end",
"def private; end",
"def take_place\n super(1)\n end",
"def before() ; end",
"def possibl... | [
"0.6982941",
"0.68191576",
"0.656337",
"0.6533704",
"0.65007114",
"0.6333284",
"0.61852795",
"0.6150176",
"0.6148478",
"0.61115336",
"0.6107089",
"0.6101558",
"0.6092218",
"0.6049842",
"0.60453326",
"0.60359615",
"0.60349536",
"0.6019283",
"0.6019283",
"0.6011442",
"0.6007349... | 0.0 | -1 |
Loads the extensions given by the strings. | def load_extensions(*exts)
exts.each do |ext|
load file_name(ext)
sym = ext_sym(ext)
cfg = @extcfg != nil ? @extcfg[ext] : nil
obj = Object.const_get(sym).new(cfg, @extdb, @server, @irc_proto, @fn_registrar, @botstate, @udb, @cdb)
obj.ext_load if obj.respond_to?(:ext_load)
@extensions[sym] = obj
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_extensions\n # Load the init.rb file\n require root('init.rb') if File.exists?(root('init.rb'))\n\n # Load the gems in the config file\n @config.gems.each { |gem| require gem }\n\n # Load the extensions\n ext_roots = Dir[root(:extensions, '*')].select { |d| File.directory? d... | [
"0.705724",
"0.6660721",
"0.63811004",
"0.62944615",
"0.62944275",
"0.6149996",
"0.6111337",
"0.61005586",
"0.6092781",
"0.6088871",
"0.60877496",
"0.6082909",
"0.6082909",
"0.6073551",
"0.6064482",
"0.6064482",
"0.603119",
"0.600235",
"0.5991117",
"0.5952136",
"0.5952136",
... | 0.76309234 | 0 |
Unloads a loaded extension. | def unload_extensions(*exts)
exts.each do |ext|
sym = ext_sym(ext)
obj = @extensions[sym]
obj.ext_unload if obj.respond_to?(:ext_unload)
obj.unload
Object.send(:remove_const, sym)
@extensions.delete sym
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_extension(extension)\n self.extensions.delete(extension)\n end",
"def unregister_extension(const)\n @@extensions.delete(const)\n end",
"def unregister_extension(const)\n @@extensions.delete(const)\n end",
"def unregister\n Registry.unregister_loader(self)\n Explic... | [
"0.69321036",
"0.6857119",
"0.6857119",
"0.647393",
"0.646589",
"0.64351654",
"0.6433499",
"0.6265598",
"0.6143335",
"0.60911155",
"0.6038763",
"0.5946734",
"0.5945626",
"0.59024876",
"0.58657897",
"0.58336586",
"0.5827383",
"0.582111",
"0.5807627",
"0.57793635",
"0.575354",
... | 0.7001064 | 0 |
Returns a list of loaded extensions. | def extensions
e = []
@extensions.each_key do |k|
e.push k
end
return e
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_extensions\n r = []\n manager.Get.each do |ext|\n r << ext\n end\n r\n end",
"def extensions\n []\n end",
"def extensions\n []\n end",
"def extensions\n @extensions ||= []\n end",
"def extensions\n @ext... | [
"0.8276",
"0.8246343",
"0.8246343",
"0.8075223",
"0.8075223",
"0.798756",
"0.7868441",
"0.7868441",
"0.7868441",
"0.78668505",
"0.77586883",
"0.76802033",
"0.76802033",
"0.7484522",
"0.7459382",
"0.7459382",
"0.7419214",
"0.7335917",
"0.7332636",
"0.7269066",
"0.719918",
"0... | 0.7652824 | 13 |
Gets an extension object by it's name. | def extension(key)
return nil unless @extensions.has_key?(key)
return @extensions[key]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ext_field_by_name(name)\n extension_fields.values.find {|field| field.name == name.to_sym}\n end",
"def get_ext_field_by_name(name)\n name = name.to_sym\n extension_fields.values.find {|field| field.name == name}\n end",
"def by_name( name )\n available.each { |add... | [
"0.6599194",
"0.6577669",
"0.6474541",
"0.64701897",
"0.6353642",
"0.6252796",
"0.6221499",
"0.6221499",
"0.6183296",
"0.6164878",
"0.61124986",
"0.6089733",
"0.6027012",
"0.60074896",
"0.60018724",
"0.59965116",
"0.5977263",
"0.5952194",
"0.59495693",
"0.5905685",
"0.5839382... | 0.66321516 | 0 |
Converts a class or extension name into a file name. | def file_name(name)
return name.to_s.downcase + '.rb' if name.kind_of?(Symbol)
return ext_name(name).downcase + '.rb'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base_filename; class_to_filename(name.gsub(/.*:/, '')); end",
"def class_to_filename (c)\n c.split(/::/).map {|i| i.gsub(/([A-Z])/, '_\\1').sub(/_/, '').downcase}.\n join('/')\nend",
"def to_name\n basename.to_s.sub extname, ''\n end",
"def actionscript_file_to_class_name file\n... | [
"0.78845537",
"0.7603191",
"0.73912436",
"0.7321306",
"0.72890615",
"0.7227069",
"0.71749526",
"0.7094443",
"0.7049833",
"0.6994771",
"0.69838375",
"0.695167",
"0.68786275",
"0.6873001",
"0.6751018",
"0.6723017",
"0.6705899",
"0.6694793",
"0.6693361",
"0.6681071",
"0.6659569"... | 0.7166012 | 7 |
Converts an extension name into a file name. | def ext_sym(name)
return name if name.kind_of?(Symbol)
return ext_name(name).to_sym
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extensionize(fname, ext, opts={})\n extname = File.extname(fname)\n return fname if (extname =~ /\\.?#{ext}$/i) == 0\n fname = fname.gsub(/#{extname}$/, '') if opts[:chomp] == true\n return fname.strip + '.' + ext.to_s.gsub(/^\\./, '')\n end",
"def make_file_name aExtension, *aWords #:... | [
"0.78093946",
"0.7793086",
"0.77875257",
"0.77566844",
"0.7681191",
"0.76433736",
"0.75623244",
"0.75035405",
"0.74765325",
"0.743516",
"0.7413942",
"0.73812175",
"0.73812175",
"0.7353624",
"0.73470175",
"0.73470175",
"0.73285824",
"0.73034984",
"0.7282757",
"0.7281285",
"0.7... | 0.0 | -1 |
Converts an extension name into a class name. | def ext_name(name)
return name.to_s if name.kind_of?(Symbol)
return name.gsub(/\s/, '_')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variable_name_to_class_name(name)\n name.to_s.\n gsub(/\\/(.?)/) { \"::#{$1.upcase}\" }.\n gsub(/(?:^|_)(.)/) { $1.upcase }\n end",
"def variable_name_to_class_name(name)\n name.to_s.\n gsub(/\\/(.?)/) { \"::#{$1.upcase}\" }.\n gsub(/(?:^|_)(.)/) { $1.upcase }\n end",
"def extra... | [
"0.70029724",
"0.70029724",
"0.6962108",
"0.6958684",
"0.68134195",
"0.66921586",
"0.6637349",
"0.6609027",
"0.6589456",
"0.65865016",
"0.65243304",
"0.65216833",
"0.64948285",
"0.64929676",
"0.64029235",
"0.6382814",
"0.63123375",
"0.62973875",
"0.62798995",
"0.6276466",
"0.... | 0.6474285 | 14 |
Cleans the load path dirtied by this instance of ExtensionHost. | def clean_load_path
$:.delete @path unless @path.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup\n File.delete(@path) if @path.is_a?(String) && File.exist?(@path)\n end",
"def clean\n @paths = {}\n @paths[''] = Path.new(self, '')\n @prepares = []\n self\n end",
"def cleanup\n cleanup_unpack_path\n cleanup_download_path\n end",
"def clear!... | [
"0.6458723",
"0.63510746",
"0.6335118",
"0.6253226",
"0.6168288",
"0.6093034",
"0.60341704",
"0.600311",
"0.595398",
"0.594671",
"0.5926544",
"0.58760077",
"0.5852982",
"0.5819992",
"0.57998955",
"0.5796202",
"0.5782216",
"0.57819444",
"0.5767308",
"0.57594824",
"0.5752692",
... | 0.7962232 | 0 |
Responds to .sort method | def <=>(schema)
sort_key <=> schema.sort_key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_entries; end",
"def sort\n return @sort\n end",
"def sorted_results\n results.sort\n end",
"def sort()\n\t\t@events = @events.sort do |a,b| a[0] <=> b[0] end\n\tend",
"def sort!\n sort_if_needed\n self\n end",
"def sort\n @pokers.sort.reverse\n... | [
"0.7760054",
"0.7525783",
"0.7390166",
"0.7366337",
"0.7306448",
"0.72786736",
"0.719479",
"0.71871525",
"0.7109617",
"0.7104191",
"0.7056097",
"0.70484453",
"0.70437247",
"0.70437247",
"0.69962436",
"0.6992695",
"0.6980701",
"0.6948855",
"0.6933568",
"0.6928496",
"0.69251096... | 0.0 | -1 |
Adds query string if a link has a schema property and method is GET | def query_string
if method == "GET" && !request_parameters.empty?
"?#{request_parameters.to_query}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link_params\n CGI::parse(URI.parse(self['href']).query)\n end",
"def add_href\n return if attributes.key?(\"href\")\n return unless attributes.key?(\"id\")\n attributes[\"href\"] = client.connection.api_path(\"#{collection.name}/#{attributes['id']}\")\n end",
"def quer... | [
"0.58647037",
"0.5649685",
"0.55826855",
"0.55436486",
"0.5525937",
"0.5525937",
"0.5506832",
"0.5469202",
"0.54567957",
"0.54567957",
"0.5449152",
"0.5438172",
"0.5403801",
"0.54030675",
"0.5379981",
"0.53741306",
"0.5366104",
"0.536471",
"0.5351713",
"0.53465235",
"0.533051... | 0.53904843 | 14 |
We have a policy that we should not return response body to PUT and DELETE requests. | def has_response_body?
@raw_link.media_type != "null"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_policy\n json_response({ message: I18n.t('authenticate.forbidden_access') }, :forbidden)\n end",
"def forbidden\n respond_with 403\n end",
"def forbidden\n respond_with 403\n end",
"def skip_authorization; end",
"def without_access_control\n previous_state = Authorization.igno... | [
"0.660943",
"0.629914",
"0.6221209",
"0.6154061",
"0.6000024",
"0.5998815",
"0.5961199",
"0.5937003",
"0.5880941",
"0.58737653",
"0.58244115",
"0.5822505",
"0.5808664",
"0.5742009",
"0.57401615",
"0.57388943",
"0.5734784",
"0.57271534",
"0.57220745",
"0.5694782",
"0.569335",
... | 0.0 | -1 |
Listens to an input | def listen(klass, *args)
supervise klass, name, handlers, *args
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listen_for_input\n @log.info \"start listening\"\n while true\n line = @client.gets.chop\n break if !line\n \n msg = JSON.parse(line, :create_additions => true)\n\n case msg.type.to_sym\n when :update_direction\n @lastInput = msg.msg.to_sym\n end\n end\n en... | [
"0.69116414",
"0.6876235",
"0.6870691",
"0.68183935",
"0.6740275",
"0.6538641",
"0.6488872",
"0.6460713",
"0.64464045",
"0.64464045",
"0.64464045",
"0.6428034",
"0.6426924",
"0.64252806",
"0.64252806",
"0.64188474",
"0.6402984",
"0.6374152",
"0.6352623",
"0.6302852",
"0.63018... | 0.0 | -1 |
This action sets values that are used by the list of items page Story: Display list of items( | def index
@items=Item.where(:activated => true) #TODO: Add availability
@categories = Category.all
@search = Item.search(params[:search])
@keyword = params[:search]
@items = @search.where(:activated => true) # or @search.relation to lazy load in view
@items = @items.paginate(:per_page=>16, :page=>params[:page]) #@category.items
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_item_list\n @item_list = ItemList.find(params[:id])\n end",
"def list_items_preview\n end",
"def show\n set_item\n end",
"def make_item_list\n end",
"def index\n @list_items = @list.list_items\n end",
"def render_items(items)\n @list.items = case @footer.filters.selected.valu... | [
"0.683831",
"0.661873",
"0.65930694",
"0.6591053",
"0.65603405",
"0.64788187",
"0.644307",
"0.644307",
"0.63845944",
"0.63803864",
"0.63773334",
"0.63773334",
"0.63773334",
"0.6377309",
"0.6356068",
"0.63508",
"0.63489425",
"0.63489425",
"0.6271861",
"0.6271861",
"0.62625396"... | 0.0 | -1 |
This action sets values that are used by new items page Story: Display new products( | def new_items_list
@items = Item.where(:activated => true).sort{ |b,a| a.created_at <=> b.created_at } #TODO: Add availability
@items = @items.first(16)
#TODO: Once we have populated more data, maybe show 12 items instead of four
@categories = Category.all
@search = Item.search(params[:search])
@keyword = params[:search]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_new_product\n array_product = @view.new_product_info\n new_product = Product.new(array_product[0],array_product[1],array_product[2])\n @seller.save_product_info(new_product)\n input = @view.menu(\"2\")\n seller_actions(input)\n end",
"def products\n end",
"def add_new_product_menu\n ... | [
"0.6945211",
"0.6942863",
"0.68183595",
"0.6817491",
"0.68064654",
"0.67684484",
"0.66934466",
"0.66751987",
"0.66279954",
"0.6503202",
"0.64691997",
"0.6463287",
"0.6455975",
"0.6454887",
"0.6416835",
"0.6388168",
"0.638555",
"0.6374035",
"0.6357163",
"0.63545334",
"0.634991... | 0.0 | -1 |
This action delete an item from database Story: Display new products( | def user_delete_item
@item = Item.find_by_id(params[:id])
if @item.auction_flag
#@auction = Auction.find(@item.auction_id)
#@auction.destroy
redirect_to item_path(@item),:notice => "You can't delete this item, because its auctioned and it has a bidder"
else
@item.destroy
redirect_to(:action => 'user_items_list')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_product\n product_to_delete = @view.delete_product\n @seller.delete_product(product_to_delete)\n input = @view.menu(\"2\")\n seller_actions(input) \n end",
"def destroy\n @product_item.destroy\n end",
"def delete\n \t@item = Item.find(params[:id])\n \t@item.destroy\n ... | [
"0.7680399",
"0.72190475",
"0.7195138",
"0.70908844",
"0.7073573",
"0.7057036",
"0.7052004",
"0.70447594",
"0.701848",
"0.699856",
"0.6971172",
"0.69702005",
"0.69683886",
"0.69674927",
"0.6961126",
"0.6961052",
"0.69568515",
"0.694398",
"0.69366264",
"0.6933725",
"0.6905222"... | 0.0 | -1 |
This action retrieve item value from database Story: Display new products( | def user_edit_item
@item = Item.find_by_id(params[:id])
@disable_auction_flag = true
@categories = Category.all
@item_categories = ItemCategory.find_all_by_item_id(@item.id)
@category_ids = @item_categories.collect{|c| c.category_id}
if(!@category_ids) then @category_ids=[] end
@search = Item.search(params[:search])
@keyword = params[:search]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getItem\n Product.select(:product).find(params[:id])\n end",
"def new\n\t\t@item = Product.new\n\tend",
"def products\n end",
"def item\n @item = Item.find(params[:id])\n end",
"def item\n @new = New.find(params[:id])\n end",
"def new\n @product = Product.init.with_user(... | [
"0.70317197",
"0.6960265",
"0.6883615",
"0.6618395",
"0.66169274",
"0.6557527",
"0.654522",
"0.6531211",
"0.6527399",
"0.65147793",
"0.64786893",
"0.6449036",
"0.6445181",
"0.6443501",
"0.6425824",
"0.6416941",
"0.6393103",
"0.63783216",
"0.6374156",
"0.6348328",
"0.6342286",... | 0.0 | -1 |
This action retrieves all the items belonged to the user Story: Display new products( | def user_items_list
@items = Item.find_all_by_user_id(current_user.id)
@categories = Category.all
@search = Item.search(params[:search])
@keyword = params[:search]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_items_list\n @items = Item.where(:activated => true).sort{ |b,a| a.created_at <=> b.created_at } #TODO: Add availability\n @items = @items.first(16)\n #TODO: Once we have populated more data, maybe show 12 items instead of four\n @categories = Category.all\n @search = Item.search(params[:se... | [
"0.67705184",
"0.6741289",
"0.6701766",
"0.6624291",
"0.6446135",
"0.643651",
"0.64198846",
"0.6419644",
"0.63942975",
"0.6392516",
"0.6390748",
"0.6375287",
"0.6348402",
"0.6347544",
"0.6347471",
"0.63335294",
"0.6318895",
"0.63040113",
"0.62916076",
"0.628253",
"0.62755126"... | 0.0 | -1 |
This action create the item adding form for users Story: Display new products( | def new_item
@item=Item.new
@categories = Category.all
if(!@category_ids) then @category_ids=[] end
@search = Item.search(params[:search])
@keyword = params[:search]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @product = Product.find(params[:product_id])\n @item = current_user.items.new(item_params)\n if @item.save\n redirect_to @product, success: 'Item was successfully created.'\n else\n redirect_to @product, alert: 'Все проебал'\n end\n end",
"def add_new_product\n ... | [
"0.71805793",
"0.70713043",
"0.6925698",
"0.68977505",
"0.6861191",
"0.6843004",
"0.6742233",
"0.6736598",
"0.670994",
"0.66938066",
"0.6651783",
"0.66513383",
"0.6647978",
"0.6633054",
"0.65940845",
"0.6587499",
"0.6557523",
"0.65314007",
"0.6524832",
"0.65247834",
"0.652339... | 0.0 | -1 |
This action sets values that are used by detail of item page Story: Display detail of item( | def show
@item=Item.find(params[:id])
@search = Item.search(params[:search])
@keyword = params[:search]
if @item.nil? or @item.activated==false
redirect_to(:controller => 'home',:action => 'index')
else
@categories=Category.all
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detail_item= item\n @detail_item = item\n configure_view\n end",
"def show\n set_item\n end",
"def show\n @title = @material_item.title\n @meta_keywords = @material_item.meta_keywords\n @meta_description = @material_item.meta_description\n end",
"def show\n \t@item = @orden_item.ite... | [
"0.78373253",
"0.73783684",
"0.68501735",
"0.6783934",
"0.6762676",
"0.6762676",
"0.66243714",
"0.648726",
"0.64572513",
"0.6456295",
"0.6452428",
"0.64067936",
"0.6402815",
"0.637275",
"0.6359945",
"0.6357888",
"0.63498706",
"0.63498706",
"0.63498706",
"0.63498706",
"0.63498... | 0.0 | -1 |
This action retrieves the item information from new item for a seller page and stores it in the database This will be used in a future story card | def create
@item = Item.new(params[:item])
@message = @item.validate();
if(@message)
redirect_to(user_items_new_path,:notice => @message)
else
@search = Item.search(params[:search])
@categories = Category.all
@mycategories = params[:category]
if(!@mycategories) then @mycategories = [] end
int_array = @mycategories.collect{|s| s.to_i}
puts "___________________________________________"
puts @item
if @item.save
@categories.each do|category|
if(int_array.include?(category.id))
then
ItemCategory.create(:category_id=>category.id, :item_id=>@item.id)
end
end
if(@item.auction_flag==true)
@auction = Auction.create(:bid_amount=>@item.price, :item_id=>@item.id, :seller_id=>current_user.id, :state=>0, :end_time=> Time.now+ 1000)
#TODO: Do not hard code end time
@item.auction_id = @auction.id
if !@item.save
end
end
redirect_to(:action => 'show', :id => @item.id)
else
render action: "new_item"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @item = Item.new(item_params)\n @item.seller_id = current_seller.id\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n ... | [
"0.7415695",
"0.7310675",
"0.6945493",
"0.6739858",
"0.66920424",
"0.6540826",
"0.65333796",
"0.65223837",
"0.65217274",
"0.649256",
"0.64877504",
"0.648455",
"0.6466218",
"0.6460836",
"0.64532584",
"0.6442505",
"0.64223987",
"0.64099085",
"0.64001113",
"0.63991034",
"0.63987... | 0.0 | -1 |
This action sets values of item and updates the database This will be used in a future story card | def update
@item = Item.find(params[:id])
int_array = params[:category].collect{|s| s.to_i}
#REset categories
#delete current
@itemcats = ItemCategory.find_all_by_item_id(@item.id)
@itemcats.each{|itemcat|itemcat.destroy}
#add new
#Insert and delete is less expensive than each check probably..TODO: Check
@categories = Category.all
@categories.each do|category|
if(int_array.include?(category.id))
then
ItemCategory.create(:category_id=>category.id, :item_id=>@item.id)
end
end
if @item.update_attributes(params[:item])
redirect_to(:action => 'show', :id => @item.id)
else
redirect_to(:action => 'user_edit_item', :id => @item.id)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_update(item)\n @item = item\n end",
"def update\n @item.update!(item_params)\n end",
"def update\n item = Item.find(params[:item_id])\n\n item.name = params[:name]\n item.details = params[:details]\n item.save\n end",
"def set_item\n # 出品機能未実装のため仮置き\n @... | [
"0.7432029",
"0.7349575",
"0.734418",
"0.7265189",
"0.72412217",
"0.72068214",
"0.7197743",
"0.71254647",
"0.71254647",
"0.71254647",
"0.71254647",
"0.71254647",
"0.71254647",
"0.71254647",
"0.71254647",
"0.71254647",
"0.71254647",
"0.71254647",
"0.71254647",
"0.71254647",
"0... | 0.0 | -1 |
Apply the good records from an uploaded import file | def apply_imports
assert_privileges("ops_settings")
if session[:imports]
begin
session[:imports].apply
rescue => bang
add_flash(_("Error during 'apply': %{error}") % {:error => bang}, :error)
@sb[:show_button] = true
else
add_flash(_("Records were successfully imported"))
@sb[:show_button] = false
session[:imports] = @sb[:imports] = nil
end
else
add_flash(_("Use the Choose file button to locate CSV file"), :error)
@sb[:show_button] = true
end
flash_to_session
redirect_to(:action => 'explorer', :no_refresh => true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import(file = nil)\n # A Hash containthe returning messages (one message for each row)\n # The values are Arrays containing the importing results for each row\n msg = {success: [], info: []} \n\n # If file is nil or blank (nil != blank)\n if file.nil? or file == \"\"\n msg[:success] << f... | [
"0.6513984",
"0.64694023",
"0.63949186",
"0.6226247",
"0.6215294",
"0.6192514",
"0.61721045",
"0.6145368",
"0.61234444",
"0.6103219",
"0.60713553",
"0.6064272",
"0.60252553",
"0.602221",
"0.60043424",
"0.5984261",
"0.59840196",
"0.5983988",
"0.5975014",
"0.5971082",
"0.595272... | 0.0 | -1 |
AJAX driven routine to select a classification entry | def forest_select
assert_privileges("ops_settings")
forest_get_form_vars
if params[:ldaphost_id] == "new"
render :update do |page|
page << javascript_prologue
page.replace("flash_msg_div", :partial => "layouts/flash_msg")
page << "miqScrollTop();" if @flash_array.present?
page.replace("forest_entries_div", :partial => "ldap_forest_entries", :locals => {:entry => "new", :edit => true})
end
session[:entry] = "new"
else
entry = nil
@edit[:new][:authentication][:user_proxies].each do |f|
entry = f if f[:ldaphost] == params[:ldaphost_id]
end
render :update do |page|
page << javascript_prologue
page.replace("flash_msg_div", :partial => "layouts/flash_msg")
page << "miqScrollTop();" if @flash_array.present?
page.replace("forest_entries_div", :partial => "ldap_forest_entries", :locals => {:entry => entry, :edit => true})
end
session[:entry] = entry
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_classification_code\n @classification_code = ClassificationCode.find(params[:id])\n end",
"def classification=(value)\n @classification = value\n end",
"def classification=(value)\n @classification = value\n end",
"def show_add_classificatio... | [
"0.5955622",
"0.5804568",
"0.5804568",
"0.5722311",
"0.56871134",
"0.5668467",
"0.55925167",
"0.55884546",
"0.5582199",
"0.5573716",
"0.5573716",
"0.55556834",
"0.5533747",
"0.55024284",
"0.55024284",
"0.5476848",
"0.5441608",
"0.544021",
"0.54254407",
"0.53907776",
"0.538285... | 0.48506686 | 82 |
AJAX driven routine to delete a classification entry | def forest_delete
assert_privileges("ops_settings")
forest_get_form_vars
idx = nil
@edit[:new][:authentication][:user_proxies].each_with_index do |f, i|
idx = i if f[:ldaphost] == params[:ldaphost_id]
end
@edit[:new][:authentication][:user_proxies].delete_at(idx) unless idx.nil?
@changed = (@edit[:new] != @edit[:current])
render :update do |page|
page << javascript_prologue
page.replace("flash_msg_div", :partial => "layouts/flash_msg")
page << "miqScrollTop();" if @flash_array.present?
page << javascript_for_miq_button_visibility(@changed)
page.replace("forest_entries_div", :partial => "ldap_forest_entries", :locals => {:entry => nil, :edit => false})
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @classification = Classification.find(params[:id])\n @classification.destroy\n\n respond_to do |format|\n format.html { redirect_to classifications_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.classification')) }\n format.json { head :no_content }... | [
"0.7312839",
"0.69070196",
"0.68694365",
"0.68410945",
"0.6817031",
"0.6805132",
"0.6684812",
"0.66745853",
"0.66630816",
"0.6612515",
"0.66072005",
"0.6603169",
"0.6567192",
"0.65652436",
"0.655926",
"0.6550945",
"0.6550208",
"0.654281",
"0.65408593",
"0.6539321",
"0.6501791... | 0.0 | -1 |
AJAX driven routine to add/update a classification entry | def forest_accept
assert_privileges("ops_settings")
forest_get_form_vars
no_changes = true
if @ldap_info[:ldaphost] == ""
add_flash(_("LDAP Host is required"), :error)
no_changes = false
elsif @edit[:new][:authentication][:user_proxies].blank? || @edit[:new][:authentication][:user_proxies][0].blank? # if adding forest first time, delete a blank record
@edit[:new][:authentication][:user_proxies].delete_at(0)
else
@edit[:new][:authentication][:user_proxies].each do |f|
# check to make sure ldaphost already doesn't exist and ignore if existing record is being edited.
next unless f[:ldaphost] == @ldap_info[:ldaphost] && session[:entry] == 'new'
no_changes = false
add_flash(_("LDAP Host should be unique"), :error)
break
end
end
if no_changes
if session[:entry] == "new"
@edit[:new][:authentication][:user_proxies].push(@ldap_info)
else
@edit[:new][:authentication][:user_proxies].each_with_index do |f, i|
@edit[:new][:authentication][:user_proxies][i] = @ldap_info if f[:ldaphost] == session[:entry][:ldaphost]
end
end
end
@changed = (@edit[:new] != @edit[:current])
render :update do |page|
page << javascript_prologue
page << javascript_for_miq_button_visibility(@changed)
page.replace("flash_msg_div", :partial => "layouts/flash_msg")
page << "miqScrollTop();" if @flash_array.present?
page.replace("forest_entries_div", :partial => "ldap_forest_entries", :locals => {:entry => nil, :edit => false}) if no_changes
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_add_classification_to_item\n # retrieve @repositories for instant additions\n @item = Item.find(params[:id])\n @subjects = Subject.concept_list\n @max_position = Classification.maximum(:position, :conditions => ['item_id = ?', params[:id]] ) || 0\n @classification = Classification.new(\n ... | [
"0.6391685",
"0.6298906",
"0.60974646",
"0.5986699",
"0.5980225",
"0.5844179",
"0.5788076",
"0.573864",
"0.5698284",
"0.56306034",
"0.562303",
"0.56141925",
"0.56114835",
"0.5580266",
"0.5577854",
"0.5577463",
"0.55705833",
"0.5520212",
"0.5520212",
"0.55184036",
"0.55140805"... | 0.0 | -1 |
this method get the swaps near the ip parameter. Its called from the static_pages_controller | def swaps_feed(ip)
Swap.near_ip(ip)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_rack_ip_offsets # These Rack base addresses get added to 10.31.0.0 and 172.31.0.0\n base = IPv4.new('0.0.80.0').to_i\n @ip_offset ||= { # Rack, and IP address offset from base\n 'b15'=> (IPv4.new('0.0.82.100') - base).to_i, \n 'd15'=> (IPv4.new('0.0.81.150') -base).to_i ,\n 'e15'=> (IPv4.new('0... | [
"0.6140601",
"0.5965152",
"0.55639493",
"0.5558459",
"0.545419",
"0.5447818",
"0.544545",
"0.54413706",
"0.54301363",
"0.5379883",
"0.5376038",
"0.53602946",
"0.5344832",
"0.533376",
"0.53124964",
"0.53105015",
"0.52475834",
"0.52310044",
"0.5225074",
"0.52078164",
"0.5196212... | 0.66772705 | 0 |
def select_category_from_projects "SELECT category FROM projects;" end Make sure each ruby method returns a string containing a valid SQL statement. | def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name
"SELECT title, SUM(amount)
FROM projects
INNER JOIN pledges
ON projects.id = pledges.project_id
GROUP BY projects.title
ORDER BY projects.title;"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_category_from_projects\n\"SELECT category FROM projects;\"\nend",
"def selects_the_category_names_and_pledge_amounts_of_all_pledges_in_the_music_category\n\"SELECT projects.category, pledges.amount\nFROM pledges\nINNER JOIN projects\nON projects.id = pledges.project_id\nWHERE projects.category = 'musi... | [
"0.9198338",
"0.70682496",
"0.69904196",
"0.6651116",
"0.66223687",
"0.65146846",
"0.6485764",
"0.63234603",
"0.6060352",
"0.5941194",
"0.59390724",
"0.59370667",
"0.590154",
"0.58815116",
"0.58714",
"0.58550173",
"0.5852973",
"0.58412963",
"0.581997",
"0.5783239",
"0.5782976... | 0.5374029 | 67 |
Setup all fixtures in test/fixtures/.yml for all tests in alphabetical order. fixtures :all Helper to create users in the database to being used in the tests to check privilege levels. | def create_users
@user_admin = User.create(:email => "admin@test.tld", :name => "Admin user", :password => "testtest", :password_confirmation => "testtest", :level => User::LEVEL_ADMINISTRATOR)
@user_normal = User.create(:email => "normal@test.tld", :name => "Normal user", :password => "testtest", :password_confirmation => "testtest", :level => User::LEVEL_NORMAL)
@user_guest = User.create(:email => "guest@test.tld", :name => "Guest user", :password => "testtest", :password_confirmation => "testtest", :level => User::LEVEL_GUEST)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_all_fixtures\n \n end",
"def setup_default_fixtures(files = ['sample_actors' , 'users', 'wiki_entries'])\n Fixtures.reset_cache\n files.each do |f|\n Fixtures.create_fixtures( File.dirname(__FILE__) + '/../fixtures' , File.basename( f , '.*'))\n end\nend",
"def load_fixtures\n # f... | [
"0.7683536",
"0.75340164",
"0.7358778",
"0.7003613",
"0.69804454",
"0.6745109",
"0.67060196",
"0.6660457",
"0.6622344",
"0.649012",
"0.6478721",
"0.6460157",
"0.6448435",
"0.64466983",
"0.6407922",
"0.63956076",
"0.6387204",
"0.6349539",
"0.63235945",
"0.62902397",
"0.6258356... | 0.55140275 | 67 |
Helper function to create a host in the DB [Parameters] data The data to create a host | def create_host(data=nil)
if (!data.blank? && data.is_a?(Hash))
@host = Host.create(data)
else
@host = Host.create(:name => "Test Host #{rand(1..1000)}", :type => Host::TYPE_ROUTER, :address => "192.168.0.#{rand(1..200)}", :description => "Test host description.", :active => true)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lsepoch_create_host_record(params, record, _host)\n# site_id is valid, since the operation is invoked from the \"Site\" screen - inherited!!!\n _host = Host.new(params[:host])\n _host[:site_id] = record[:site_id]\n# ironically record[:host_id] holds the hostname value parsed from the epoch table (at th... | [
"0.6863284",
"0.67643905",
"0.6671525",
"0.6619455",
"0.6499137",
"0.64914644",
"0.6365722",
"0.63007057",
"0.6248843",
"0.62192035",
"0.61798334",
"0.6173487",
"0.61419165",
"0.61309195",
"0.60721093",
"0.6055794",
"0.59897417",
"0.59808457",
"0.5977043",
"0.59646076",
"0.59... | 0.82091707 | 0 |
Helper function to create a service in the DB [Parameters] data The data to create a service | def create_service(data=nil)
if (!data.blank? && data.is_a?(Hash))
@service = Service.create(data)
else
@service = Service.create(:name => "Test Service #{rand(1..1000)}", :description => "Test service description.", :active => true, :probe => "dummy", :probe_config => {:value => 1}, :interval => 60, :clean_interval => 86400, :priority => Service::PRIORITY_NORMAL, :resume => :mean_value)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @service = Service.create(service_params)\n end",
"def create\n service = current_account.services.build\n create_service = ServiceCreator.new(service: service)\n create_service.call(service_params.to_h)\n service.reload if service.persisted? # It has been touched\n respond_with(s... | [
"0.7130991",
"0.6724158",
"0.6688275",
"0.6688111",
"0.6644545",
"0.6494095",
"0.64873683",
"0.6455025",
"0.6434602",
"0.64181685",
"0.6375744",
"0.62965333",
"0.6289928",
"0.62892216",
"0.62685174",
"0.62301797",
"0.6219859",
"0.6197706",
"0.61968666",
"0.6169759",
"0.616250... | 0.77970856 | 0 |
Helper function to create an alert in the DB [Parameters] data The data to create a service | def create_alert(data=nil)
if (!data.blank? && data.is_a?(Hash))
@alert = Alert.create(data)
else
create_service
create_host
@service.hosts << @host
@service.save
@alert = Alert.create(:name => "Test Alert #{rand(1..1000)}", :description => "Test alert description.", :active => true, :limit => 600, :condition => :greater_than, :condition_target => Alert::CONDITION_TARGET_ALL, :error_control => true, :service_id => @service.id, :hosts => [@host])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n parameters = alert_params\n parameters[:service] = Service.where(:_id => parameters[:service_id]).first\n parameters[:hosts] = Host.where(:_id.in => parameters[:host_ids]).to_a if (!parameters[:host_ids].blank?)\n\n # Delete string'd id's\n parameters.delete(:service_id)\n parameters... | [
"0.6776906",
"0.6454275",
"0.6393526",
"0.63153845",
"0.62976557",
"0.62765723",
"0.6269094",
"0.6175672",
"0.61017144",
"0.6071836",
"0.60514116",
"0.6040542",
"0.60163593",
"0.6015284",
"0.6005248",
"0.59955287",
"0.5910299",
"0.5845932",
"0.58431375",
"0.5831812",
"0.57919... | 0.8190501 | 0 |
Helper function to destroy all the items in the database | def clean_db
Mongoid::Sessions.default.collections.select {|c| c.name !~ /system/}.each {|c| c.find.remove_all}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy_all\n all.each(&:destroy)\n end",
"def destroy_all\n ids = self.all.map{|item| item.id}\n bulk_update do\n ids.each do |item|\n find(item).destroy\n end\n end\n # Note collection is not emptied, and next_id is not reset.\n ... | [
"0.8058331",
"0.80073225",
"0.79958665",
"0.79379594",
"0.7917818",
"0.78249156",
"0.7765221",
"0.76456314",
"0.7447312",
"0.7352165",
"0.73212653",
"0.7313179",
"0.73008543",
"0.7280139",
"0.72565275",
"0.7247529",
"0.7247529",
"0.72168756",
"0.72168756",
"0.71895045",
"0.71... | 0.0 | -1 |
Helper function to clean Sidekiq queues | def clean_sidekiq
Sidekiq::Worker.clear_all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redis_queues_cleanup!\n Gitlab::Redis::Queues.with(&:flushall)\n end",
"def redis_queues_cleanup!\n Gitlab::Redis::Queues.with(&:flushdb)\n end",
"def clean\n clean_queued\n clean_running\n end",
"def clean!\n clean_queue!\n clean_activity!\n end",
"def clear_queues_ca... | [
"0.8264004",
"0.8174867",
"0.75170165",
"0.74931175",
"0.734488",
"0.7253696",
"0.7235889",
"0.7138078",
"0.7127352",
"0.711059",
"0.71033424",
"0.703653",
"0.703653",
"0.703653",
"0.6979667",
"0.69509596",
"0.6854539",
"0.6843133",
"0.6829785",
"0.6829785",
"0.6743291",
"0... | 0.80950344 | 2 |
above should make gender and archetype enumerable datatypes | def change_character_names(story)
self.archetype === "hero" ? story.content.gsub!("HERO", self.name) : false
self.archetype === "shadow" ? story.content.gsub!("SHADOW", self.name) : false
self.archetype === "friend" ? story.content.gsub!("FRIEND", self.name) : false
self.archetype === "lover" ? story.content.gsub!("LOVER", self.name) : false
self.archetype === "mentor" ? story.content.gsub!("MENTOR", self.name) : false
self.archetype === "trickster" ? story.content.gsub!("TRICKSTER", self.name) : false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gender_types\n @gender_types.each\n end",
"def people_gender\r\n\t\t[[\"Unknown\", \"Unknown\"],[\"Male\", \"Male\"], [\"Female\", \"Female\"]]\r\n\tend",
"def gender_list\n [['Man', 'male'], ['Woman', 'female']]\n end",
"def gender; end",
"def types(types); end",
"def itemtype\n format = ... | [
"0.73003936",
"0.60861206",
"0.6063521",
"0.59471333",
"0.58952653",
"0.58357424",
"0.57617164",
"0.57260627",
"0.5669109",
"0.5577488",
"0.5567861",
"0.553259",
"0.55118877",
"0.55118877",
"0.55118877",
"0.55118877",
"0.55118877",
"0.550571",
"0.5487728",
"0.54458797",
"0.54... | 0.0 | -1 |
we use this method so we can stub it out for testing | def client_class
Stomp::Client
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def stub_implementation; end",
"def spec; end",
"def spec; end",
"def private_method\n end",
"def implementation; end",
"def implementation; end",
"def __mock_reset; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def before_setup;... | [
"0.7089703",
"0.63627577",
"0.6327509",
"0.6327509",
"0.63085747",
"0.6137466",
"0.6137466",
"0.6106157",
"0.6036883",
"0.6036883",
"0.6036883",
"0.6036883",
"0.5945212",
"0.59359396",
"0.58578104",
"0.5856634",
"0.58088255",
"0.58086836",
"0.58086836",
"0.58086836",
"0.58086... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def tag_params
params.require(:tag).permit(:show)
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.71230334",
"0.70530915",
"0.69479465",
"0.6902122",
"0.67367256",
"0.67172784",
"0.6689043",
"0.66784793",
"0.6660117",
"0.6555213",
"0.6528485",
"0.6458438",
"0.6452378",
"0.6451654",
"0.64478326",
"0.6433326",
"0.6413599",
"0.6413599",
"0.63907677",
"0.63787645",
"0.6378... | 0.0 | -1 |
Saves the currently playing background music for later playback. | def bgm_memorize
@memorized_bgm = @playing_bgm
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_playing\n self.play_start = DateTime.now\n self.paused = false\n self.seconds_offset = 0.0\n return ARUtils.save_cmdline(self)\n end",
"def background_save\n Process.detach( fork { save } )\n end",
"def play_music\n $game_system.bgm_memorize2\n Audio.bgm_stop\n Audio.bg... | [
"0.66972154",
"0.6277391",
"0.5995906",
"0.5946753",
"0.59252673",
"0.59206206",
"0.5874071",
"0.5843036",
"0.5802665",
"0.5802665",
"0.58012444",
"0.5746439",
"0.56745833",
"0.56510293",
"0.56244564",
"0.56088305",
"0.5541716",
"0.54460263",
"0.54431",
"0.5409847",
"0.536004... | 0.4799007 | 77 |
Plays the currently memorized background music | def bgm_restore
bgm_play(@memorized_bgm)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play_music\n $game_system.bgm_memorize2\n Audio.bgm_stop\n Audio.bgm_play(Evolve::EVOLVE_MUSIC)\n end",
"def play_title_music\n $data_system.title_bgm.play\n RPG::BGS.stop\n RPG::ME.stop\n end",
"def play_title_music\n $data_system.title_bgm.play\n RPG::BGS.stop\n RPG::... | [
"0.78281635",
"0.7397036",
"0.7397036",
"0.73778623",
"0.727749",
"0.6968716",
"0.6810284",
"0.6802015",
"0.67626494",
"0.6719018",
"0.6715851",
"0.6691686",
"0.66604024",
"0.66188926",
"0.6609012",
"0.65743744",
"0.65608823",
"0.65470344",
"0.6535608",
"0.65214914",
"0.65106... | 0.5884255 | 80 |
Returns an RPG::AudioFile object for the currently playing background music | def getPlayingBGM
return (@playing_bgm) ? @playing_bgm.clone : nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_audio\n return @audio\n end",
"def play_music\n $game_system.bgm_memorize2\n Audio.bgm_stop\n Audio.bgm_play(Evolve::EVOLVE_MUSIC)\n end",
"def audio\n @audio ||= (\n id = @params[:audio_track]\n ::Audio.find(id) if id\n )\n end",... | [
"0.6735958",
"0.6563371",
"0.64784473",
"0.6450973",
"0.6339454",
"0.6158966",
"0.6158435",
"0.6055315",
"0.6055315",
"0.60506207",
"0.5968849",
"0.5938833",
"0.59140754",
"0.5845334",
"0.5770656",
"0.5757217",
"0.57535946",
"0.57488805",
"0.572951",
"0.5716711",
"0.5699398",... | 0.58619857 | 13 |
iterates over collection, passing each element to the block method returns the element, for which the block returned the largest value solution iterate through array, passing each value to the block, compare the return value to max_value if the return value is larger than max_value, then max_value is replaced by that element method returns the max_value variable | def max_by(array)
return nil if array.empty?
max_element = array.first
max_return = yield(array.first)
array[1..-1].each do |element|
block_return = yield(element)
if block_return > max_return
max_element = element
max_return = block_return
end
end
max_element
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max(&block)\n flag = true # 1st element?\n result = nil\n self.each{|*val|\n val = val.__svalue\n if flag\n # 1st element\n result = val\n flag = false\n else\n if block\n result = val if block.call(val, result) > 0\n else\n result =... | [
"0.7870319",
"0.7728349",
"0.75338215",
"0.75244635",
"0.7417176",
"0.736059",
"0.72589713",
"0.7148422",
"0.7146673",
"0.7130707",
"0.7103043",
"0.70864034",
"0.7072057",
"0.7059228",
"0.7057416",
"0.70474875",
"0.6995022",
"0.6993832",
"0.69818515",
"0.6975569",
"0.69658566... | 0.7616087 | 2 |
say hi to everyone | def say_hi
if @names.nil?
puts "..."
elsif @names.respond_to?("each")
#@names is list. iterate.
@names.each do |name|
puts "Hello #{name}!"
end
else puts "Hello #{@names}!"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sayHi\n\t\tputs(greet)\n\tend",
"def say_hi\n\t\tputs 'saying hi'\n\tend",
"def say_hi\n \tputs \"hello user\" #you must call the method by calling. out its name \"say_hi\"\n end",
"def greet\n self.say \"Hello, I am #{@config[:nick]}. I am the resident uber-bot. To learn more, type '.abou... | [
"0.7880603",
"0.7646402",
"0.75421375",
"0.7364657",
"0.7333217",
"0.73037755",
"0.72600377",
"0.7242886",
"0.7207713",
"0.7162793",
"0.71617854",
"0.7118497",
"0.7084572",
"0.70705736",
"0.70638174",
"0.70421696",
"0.70306635",
"0.70202744",
"0.7011164",
"0.6994244",
"0.6905... | 0.0 | -1 |
Say goodbye to everyone | def say_bye
if @names.nil?
puts "..."
elsif @names.respond_to?("join")
puts "Goodbye #{@names.join(", ")}. Come back soon!"
else
puts "Goodbye #{@names}. Come back soon!"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def say_goodbye\n\t\tgoodbye = \"Thanks for playing the Virtual Crazy\" +\n\t\t\t\t\"8-Ball game!\\n\\n\"\n\tend",
"def say_bye\n\t\tif @names.nil?\n\t\t\tputs \"...\"\n\t\telsif @names.respond_to?(\"join\")\n\t\t\t\tputs \"Goodbye #{@names.join(\", \")}. Come back soon!\"\n\n\t\telse\n\t\t\tputs \"Good bye #{... | [
"0.79500306",
"0.78127456",
"0.775759",
"0.77029324",
"0.76021844",
"0.7593056",
"0.7562311",
"0.7558499",
"0.75549096",
"0.75413096",
"0.7504892",
"0.75041276",
"0.745264",
"0.74478894",
"0.7432688",
"0.7405693",
"0.7387379",
"0.7376698",
"0.7368708",
"0.7315142",
"0.7278047... | 0.72323585 | 26 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.