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
Use this property to set your application ID if you did not provide one at initialization time.
def appid=(appid) if (appid.nil? or appid.empty?) fatal("Error: appid: Null application ID.") end if (not appid =~ /^\w+$/) fatal("Error: appid: Application ID must be alpha-numeric: " + appid) end @appid = appid end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def application_id=(value)\n @application_id = value\n end", "def app_id=(value)\n @app_id = value\n end", "def app_id=(value)\n @app_id = value\n end", "def app_id=(value)\n @app_id = value\n end", "def...
[ "0.8277004", "0.817122", "0.817122", "0.817122", "0.81007695", "0.80319995", "0.7559075", "0.7559075", "0.7559075", "0.7559075", "0.7559075", "0.7559075", "0.7559075", "0.7559075", "0.7559075", "0.7525839", "0.7453115", "0.74212396", "0.7363324", "0.7329188", "0.7017668", "...
0.7371801
18
Returns the application ID.
def appid if (@appid.nil? or @appid.empty?) fatal("Error: appid: App ID was not set. Aborting.") end @appid end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def application_id\n return @application_id\n end", "def app_identifier\n return @app_identifier\n end", "def application_id\n get_key('ALGOLIA_APPLICATION_ID', 'application_id')\n end", "def app_id\n @app.id\n end", "def app_id\n ...
[ "0.85831577", "0.8552138", "0.846309", "0.8432432", "0.838213", "0.838213", "0.838213", "0.8336402", "0.78346896", "0.77440476", "0.75955623", "0.7572558", "0.7538376", "0.7464202", "0.7460958", "0.7341734", "0.7341734", "0.7341734", "0.7315682", "0.7315682", "0.7288015", "...
0.8196249
8
Use this property to set your secret key if you did not provide one at initialization time.
def secret=(secret) if (secret.nil? or secret.empty? or (secret.size < 16)) fatal("Error: secret=: Secret must be non-null and at least 16 characters.") end @signkey = derive(secret, "SIGNATURE") @cryptkey = derive(secret, "ENCRYPTION") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_secret_key\n @secret_key = SecretKey.find(params[:id])\n end", "def secret_key=(key)\n configatron.ramazon.secret_key = key\n end", "def secret_key; end", "def secret_key=(secret_key)\n actual_key = ENV.fetch(\"SECRET_KEY\", User.secret_key_default)\n self.is_student = !(sec...
[ "0.80377424", "0.750576", "0.74892455", "0.7486055", "0.7483587", "0.7263467", "0.7230162", "0.71432716", "0.7082599", "0.70695186", "0.70695186", "0.705636", "0.705636", "0.705636", "0.705636", "0.70001405", "0.69477755", "0.6936296", "0.6936296", "0.6930344", "0.692389", ...
0.6989428
16
Processes the login response from Windows Live Login. 'query' contains the preprocessed POST table such as that returned by CGI.params or by Rails (the unprocessed POST string might also be used here but we do not recommend it). The method returns a User object on successful login; otherwise nil.
def processLogin(query) query = parse query unless query debug("Error: processLogin: Failed to parse query.") return end action = query['action'] unless action == 'login' debug("Warning: processLogin: query action ignored: #{action}.") return end token = query['stoken'] context = CGI.unescape(query['appctx']) if query['appctx'] processToken(token, context) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_login_response(email, password, response)\n @email = email\n @password = password\n @token = Parser.extract_user_token response\n @id = Parser.login_object_id response\n @xp = Parser.extract_xp response\n end", "def mssql_parse_login( data )\n status = data.slice!(0,1).unpack('C')[...
[ "0.64101493", "0.62186843", "0.607636", "0.6073617", "0.58467793", "0.5785018", "0.57692057", "0.5732156", "0.5619241", "0.5597066", "0.5578833", "0.5560396", "0.5556798", "0.5544963", "0.5528954", "0.55257267", "0.54738307", "0.5452557", "0.5418772", "0.5417434", "0.5417233"...
0.7210024
0
Returns the sign in URL to use for Windows Live Login. We recommend that you use the Sign In control instead. If you specify it, 'context' will be returned asis in the login response for sitespecific use.
def getLoginUrl(context=nil) url = baseurl + "wlogin.srf?appid=#{appid}" url += "&alg=#{securityalgorithm}" url += "&appctx=#{CGI.escape(context)}" if context url end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_login_url\n client = OAuth2::Client.new(CLIENT_ID,\n CLIENT_SECRET,\n :site => 'https://login.microsoftonline.com',\n :authorize_url => '/common/oauth2/v2.0/authorize',\n :token_ur...
[ "0.63973886", "0.6394544", "0.63663894", "0.63637626", "0.63618356", "0.62533516", "0.6235935", "0.6221486", "0.61892045", "0.6148634", "0.61156213", "0.6032322", "0.6030715", "0.60246867", "0.5973245", "0.5967262", "0.5954301", "0.58876354", "0.58760905", "0.58620197", "0.58...
0.73321176
0
Returns the signout URL to use for Windows Live Login. We recommend that you use the Sign In control instead.
def getLogoutUrl baseurl + "logout.srf?appid=#{appid}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def signout_url\n {:controller => 'auth', :action => 'signout'}\n end", "def logout_url\n return @logout_url\n end", "def auth0_logout_url\n # auth0_client.logout_url(root_url.to_s, include_client: true).to_s\n auth0_client.logout_url(root_url.to_s).to_s\n end", "def getT...
[ "0.72259426", "0.7151123", "0.6907367", "0.6801029", "0.67777586", "0.674799", "0.6741841", "0.67073745", "0.6664136", "0.6628351", "0.66178346", "0.65988636", "0.65929955", "0.6558004", "0.6558004", "0.65537596", "0.6548527", "0.65476865", "0.6471767", "0.642422", "0.6409025...
0.68520045
3
Decodes and validates a Web Authentication token. Returns a User object on success. If a context is passed in, it will be returned as the context field in the User object.
def processToken(token, context=nil) if token.nil? or token.empty? debug("Error: processToken: Null/empty token.") return end stoken = decodeToken token stoken = validateToken stoken stoken = parse stoken unless stoken debug("Error: processToken: Failed to decode/validate token: #{token}") return end sappid = stoken['appid'] unless sappid == appid debug("Error: processToken: Application ID in token did not match ours: #{sappid}, #{appid}") return end begin user = User.new(stoken['ts'], stoken['uid'], stoken['flags'], context, token) return user rescue Exception => e debug("Error: processToken: Contents of token considered invalid: #{e}") return end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_user_from_auth_token\n @user = decode_auth_token ? User.find(decode_auth_token['user_id']) : nil\n errors.add(:token, 'invalid token') if @user.nil?\n @user\n end", "def user\n @user ||= User.find(decoded_auth_token[:user_id]) if decoded_auth_token\n @user || errors.add(:token, 'Invalid...
[ "0.7168519", "0.69986945", "0.6748731", "0.65587443", "0.65553015", "0.65211195", "0.6463288", "0.6443721", "0.6402856", "0.63865834", "0.628275", "0.6259999", "0.62578785", "0.6251611", "0.62302315", "0.6227669", "0.6218266", "0.6191184", "0.6191184", "0.6187849", "0.6176318...
0.719658
0
When a user signs out of Windows Live or a Windows Live application, a besteffort attempt is made at signing out the user from all other Windows Live applications the user might be logged in to. This is done by calling the handler page for each application with 'action' set to 'clearcookie' in the query string. The application handler is then responsible for clearing any cookies or data associated with the login. After successfully logging out the user, the handler should return a GIF (any GIF) as response to the action=clearcookie query. This function returns an appropriate content type and body response that the application handler can return to signify a successful signout from the application.
def getClearCookieResponse() type = "image/gif" content = "R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAEALAAAAAABAAEAAAIBTAA7" content = Base64.decode64(content) return type, content end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logout\n #TODO: add extra logic if required\n delete_cookie(GlobalConstant::Cookie.user_cookie_name)\n render_api_response(Result::Base.success({}))\n end", "def user_logout\n res = http_delete(:uri=>\"/session\", :fields=>x_cookie)\n return res.code\n end", "def logout\n \n # ...
[ "0.730592", "0.7197474", "0.71418506", "0.6960559", "0.6931937", "0.6913665", "0.6811513", "0.6807316", "0.6806629", "0.6762617", "0.67430586", "0.67389333", "0.6728694", "0.6706371", "0.6647889", "0.66167307", "0.6613179", "0.6527107", "0.6520968", "0.65153825", "0.65106106"...
0.0
-1
Decode the given token. Returns nil on failure. First, the string is URL unescaped and base64 decoded. Second, the IV is extracted from the first 16 bytes of the string. Finally, the string is decrypted by using the encryption key.
def decodeToken(token) if (@cryptkey.nil? or @cryptkey.empty?) fatal("Error: decodeToken: Secret key was not set. Aborting.") end token = u64(token) if (token.nil? or (token.size <= 16) or !(token.size % 16).zero?) debug("Error: decodeToken: Attempted to decode invalid token.") return end iv = token[0..15] crypted = token[16..-1] begin aes128cbc = OpenSSL::Cipher::AES128.new("CBC") aes128cbc.decrypt aes128cbc.iv = iv aes128cbc.key = @cryptkey decrypted = aes128cbc.update(crypted) + aes128cbc.final rescue Exception => e debug("Error: decodeToken: Decryption failed: #{token}, #{e}") return end decrypted end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decode(token)\n key = \"IOUWHEIJHDLKJHPiuhpsdih98392hjhsad\"\n decipher = OpenSSL::Cipher::AES.new(128, :CBC)\n decipher.decrypt\n decipher.key = key\n decipher.iv = key\n plain = decipher.update(Base64.decode64(token)) + decipher.final\n plain.split(\"|\")\n end", "def decode_token(tok...
[ "0.7597639", "0.69577426", "0.6544236", "0.6514142", "0.6473481", "0.6400813", "0.6393597", "0.6346292", "0.63426423", "0.63349575", "0.6285962", "0.6247357", "0.62250423", "0.62195003", "0.6212333", "0.61973614", "0.61848575", "0.61698127", "0.6156153", "0.61307895", "0.6111...
0.7602891
0
Creates a signature for the given string by using the signature key.
def signToken(token) if (@signkey.nil? or @signkey.empty?) fatal("Error: signToken: Secret key was not set. Aborting.") end begin digest = OpenSSL::Digest::SHA256.new return OpenSSL::HMAC.digest(digest, @signkey, token) rescue Exception => e debug("Error: signToken: Signing failed: #{token}, #{e}") return end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def signature_for(string)\n format('sha1=%s'.freeze, generate_hmac(string))\n end", "def generate_signature(string_to_sign)\n digest = OpenSSL::Digest.new('sha256')\n OpenSSL::HMAC.hexdigest(digest, @api_secret, string_to_sign)\n end", "def signature_for(string)\n format('sha1=%s'...
[ "0.74240404", "0.73088264", "0.72971517", "0.71045744", "0.7065757", "0.7002721", "0.6712629", "0.66858095", "0.66358507", "0.6549493", "0.6546979", "0.6506545", "0.65034926", "0.6502035", "0.6423556", "0.6400151", "0.63337636", "0.62865746", "0.62825996", "0.62637544", "0.61...
0.0
-1
Extracts the signature from the token and validates it.
def validateToken(token) if (token.nil? or token.empty?) debug("Error: validateToken: nil/empty token.") return end body, sig = token.split("&sig=") if (body.nil? or sig.nil?) debug("Error: validateToken: Invalid token: #{token}") return end sig = u64(sig) return token if (sig == signToken(body)) debug("Error: validateToken: Signature did not match.") return end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verify_signature\n return_code, response = send_command(\"verify_signature\", token)\n return_code == \"200\"\n end", "def signature_valid?; end", "def verify_signature(result); end", "def valid_signature?(token)\n return false unless token =~ /&HMACSHA256=(.*)$/\n original_signatu...
[ "0.69256896", "0.6737397", "0.6732493", "0.6550796", "0.6527263", "0.6522467", "0.6494987", "0.64163303", "0.634485", "0.63407254", "0.6321816", "0.6308899", "0.6298884", "0.6298884", "0.6269522", "0.62395346", "0.62395346", "0.6208952", "0.6175401", "0.61685306", "0.61681896...
0.772585
0
Returns a string that can be passed to the getTrustedParams function as the 'retcode' parameter. If this is specified as the 'retcode', the application will be used as return URL after it finishes trusted login.
def getAppRetCode "appid=#{appid}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getTrustedLoginUrl\n secureurl + \"wlogin.srf\"\n end", "def security_key\n params['RETURN_AUTHCODE']\n end", "def getTrustedParams(user, retcode=nil)\n token = getTrustedToken(user)\n return unless token\n token = %{<wst:RequestSecurityTokenResponse xmlns:wst=\"http://sche...
[ "0.6481394", "0.63911384", "0.59961337", "0.5981623", "0.5864558", "0.58485264", "0.58405125", "0.5830964", "0.5794528", "0.5634897", "0.5624907", "0.55531347", "0.5523676", "0.5517026", "0.5455011", "0.53236127", "0.5314947", "0.52695024", "0.52616775", "0.52417517", "0.5230...
0.58643675
5
Returns a table of keyvalue pairs that must be posted to the login URL for trusted login. Use HTTP POST to do this. Be aware that the values in the table are neither URL nor HTML escaped and may have to be escaped if you are inserting them in code such as an HTML form. User to be trusted on the local site is passed in as string 'user'. Optionally, 'retcode' specifies the resource to which successful login is redirected, such as Windows Live Mail, and is typically a string in the format 'id=2000'. If you pass in the value from getAppRetCode instead, login will be redirected to the application. Otherwise, an HTTP 200 response is returned.
def getTrustedParams(user, retcode=nil) token = getTrustedToken(user) return unless token token = %{<wst:RequestSecurityTokenResponse xmlns:wst="http://schemas.xmlsoap.org/ws/2005/02/trust"><wst:RequestedSecurityToken><wsse:BinarySecurityToken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">#{token}</wsse:BinarySecurityToken></wst:RequestedSecurityToken><wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"><wsa:EndpointReference xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"><wsa:Address>uri:WindowsLiveID</wsa:Address></wsa:EndpointReference></wsp:AppliesTo></wst:RequestSecurityTokenResponse>} params = {} params['wa'] = securityalgorithm params['wresult'] = token params['wctx'] = retcode if retcode params end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login\n page = agent.get('http://login.live.com/login.srf?id=2')\n form = page.forms.first\n form.login = options[:username]\n form.passwd = options[:password]\n form.PwdPad = ( \"IfYouAreReadingThisYouHaveTooMuchFreeTime\"[0..(-1 - options[:password].to_s.size )])\n query_string = page.b...
[ "0.58001155", "0.5788647", "0.5627614", "0.56195426", "0.5533368", "0.54813737", "0.5475987", "0.5460751", "0.5452799", "0.5442366", "0.54334235", "0.53904605", "0.5383663", "0.5369421", "0.5366126", "0.53615016", "0.53609365", "0.53318244", "0.5331551", "0.5326727", "0.53050...
0.515247
41
Returns the trusted login token in the format that is needed by a control doing trusted login. User to be trusted on the local site is passed in as string 'user'.
def getTrustedToken(user) if user.nil? or user.empty? debug('Error: getTrustedToken: Null user specified.') return end token = "appid=#{appid}&uid=#{CGI.escape(user)}&ts=#{timestamp}" token += "&sig=#{e64(signToken(token))}" CGI.escape token end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login_token(expire, target_user=nil)\n target_user ||= @options[:srv_user]\n token_txt = \"#{@options[:srv_user]}:#{target_user}:#{expire}\"\n\n token = encrypt(token_txt)\n token64 = Base64::encode64(token).strip.delete(\"\\n\")\n\n return \"#{@options[:srv_user]}:#{ta...
[ "0.67274153", "0.6524272", "0.63731164", "0.628952", "0.60528266", "0.60426486", "0.5943037", "0.5787221", "0.5784507", "0.57456094", "0.57272243", "0.57187355", "0.57174355", "0.5717183", "0.57077575", "0.5648105", "0.5551832", "0.5548856", "0.5535382", "0.55308986", "0.5523...
0.787101
0
Returns the trusted signin URL to use for Windows Live Login.
def getTrustedLoginUrl secureurl + "wlogin.srf" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_login_url\n client = OAuth2::Client.new(CLIENT_ID,\n CLIENT_SECRET,\n :site => 'https://login.microsoftonline.com',\n :authorize_url => '/common/oauth2/v2.0/authorize',\n :token_ur...
[ "0.6110511", "0.60972184", "0.60664225", "0.6062476", "0.6018684", "0.5890429", "0.5876816", "0.5866468", "0.586374", "0.5830568", "0.5816381", "0.5771454", "0.5747807", "0.57270265", "0.56978095", "0.5675226", "0.5674305", "0.5594671", "0.5590295", "0.55298615", "0.5516508",...
0.75443554
0
Returns the trusted signout URL to use for Windows Live Login.
def getTrustedLogoutUrl secureurl + "logout.srf?appid=#{appid}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getTrustedLoginUrl\n secureurl + \"wlogin.srf\"\n end", "def auth0_logout_url\n # auth0_client.logout_url(root_url.to_s, include_client: true).to_s\n auth0_client.logout_url(root_url.to_s).to_s\n end", "def logout_url\n return @logout_url\n end", "def default_redirect...
[ "0.65467715", "0.6066032", "0.60452795", "0.602472", "0.5952062", "0.5891592", "0.5863794", "0.5802973", "0.57728964", "0.5756296", "0.5729752", "0.5729752", "0.5684871", "0.5657452", "0.5641936", "0.5622903", "0.55558", "0.5530776", "0.55238944", "0.55150867", "0.54941493", ...
0.7174158
0
Derive the key, given the secret key and prefix as described in the SDK documentation.
def derive(secret, prefix) begin fatal("Nil/empty secret.") if (secret.nil? or secret.empty?) key = prefix + secret key = OpenSSL::Digest::SHA256.digest(key) return key[0..15] rescue Exception => e debug("Error: derive: #{e}") return end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_secret_key\n r = Aws::Kms.new('saas', 'saas').decrypt(@client.api_salt)\n return r unless r.success?\n\n api_salt_d = r.data[:plaintext]\n\n client_api_secret_d = SecureRandom.hex\n\n r = LocalCipher.new(api_salt_d).encrypt(client_api_secret_d)\n return r unle...
[ "0.64601755", "0.62765664", "0.62494075", "0.6161934", "0.6121936", "0.6121936", "0.6108348", "0.6108348", "0.6108348", "0.6108348", "0.60910314", "0.6086225", "0.6085", "0.60610837", "0.605582", "0.605582", "0.604447", "0.6031439", "0.6028146", "0.6016201", "0.5999857", "0...
0.767483
0
Generates a timestamp suitable for the application verifier token.
def timestamp Time.now.to_i.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_timestamp\n Time.now.strftime(\"%Y-%m-%dT%T.%N%:z\")\n end", "def generate_token\n\t\tUUIDTools::UUID.timestamp_create.to_s\n\tend", "def generate_token\n self.perishable_token = Digest::MD5.hexdigest(\"#{Time.now}\")\n end", "def get_token\n ((Time.now.to_f - Time.mktime(...
[ "0.74981606", "0.7210176", "0.7038668", "0.6940546", "0.6919247", "0.6853072", "0.6769264", "0.67420995", "0.6648201", "0.6648201", "0.65423214", "0.6470207", "0.64544225", "0.6446803", "0.6422307", "0.6418764", "0.63357973", "0.63064", "0.62981343", "0.6297496", "0.6279629",...
0.6318782
17
Base64encode and URLescape a string.
def e64(s) return unless s CGI.escape Base64.encode64(s) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def urlsafe_encode64(bin)\n strict_encode64(bin).tr(\"+/\", \"-_\")\n end", "def encode(string)\n URI.escape(string)\n end", "def base64_encode(string)\n SSL.base64_encode(string)\n end", "def base64_encode(string)\n SSL.base64_encode(string)\n end", "def b64_encode(string)\n ...
[ "0.82151335", "0.79889876", "0.79728556", "0.79728556", "0.7941476", "0.7887878", "0.78239703", "0.78091717", "0.78091717", "0.77820784", "0.7742422", "0.76816463", "0.7633929", "0.751233", "0.74506587", "0.7379803", "0.7372888", "0.72996277", "0.729072", "0.72083074", "0.706...
0.79262185
5
URLunescape and Base64decode a string.
def u64(s) return unless s Base64.decode64 CGI.unescape(s) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def base64_url_decode(str)\n str += '=' * (4 - str.length.modulo(4))\n Base64.decode64(str.tr('-_', '+/'))\n end", "def base64_url_decode(str)\n \"#{str}==\".tr(\"-_\", \"+/\").unpack(\"m\")[0]\n end", "def decode(string)\n Base64.decode64(string)\n end", "def base64_de...
[ "0.83523804", "0.8116885", "0.80301297", "0.79901886", "0.79901886", "0.7786382", "0.76241696", "0.7415235", "0.7257895", "0.71308875", "0.7000905", "0.69785607", "0.69033855", "0.6888165", "0.6878193", "0.68714046", "0.68538207", "0.68396187", "0.67572075", "0.675507", "0.67...
0.7180591
9
Fetch the contents given a URL.
def fetch(url) url = URI.parse url http = Net::HTTP.new(url.host, url.port) http.use_ssl = (url.scheme == "https") http.request_get url.request_uri end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_from_url url\n require \"net/http\"\n\n uri = URI.parse(url)\n\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new(uri.request_uri)\n\n request['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari...
[ "0.8186875", "0.79177684", "0.79177684", "0.7831366", "0.7805613", "0.7763746", "0.74626505", "0.73015654", "0.72296023", "0.71729624", "0.71712685", "0.71437645", "0.70839196", "0.70330566", "0.7021246", "0.69590294", "0.694961", "0.690498", "0.69009656", "0.68478495", "0.68...
0.7677
6
grab likes from yesterday
def todays_likes dayEnd = DateTime.now.beginning_of_day dayStart = dayEnd - 1.day likes.where("likes.created_at > ? and likes.created_at < ?", dayStart, dayEnd) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def previous_tweets\n model.previous_tweets.sort_by(&:created_at)\n end", "def followers_history; counter_per_day(:followers); end", "def receive_likers\n media = instagram_service.media_by_shortcode(event.url)\n media_id = media['data']['id']\n likes = instagram_service.media_likes(me...
[ "0.60466987", "0.5933825", "0.59185225", "0.5778807", "0.5764836", "0.5762797", "0.57621896", "0.57602346", "0.5725603", "0.5697936", "0.56364685", "0.55990434", "0.55655414", "0.55576384", "0.55509365", "0.5548458", "0.55339324", "0.5515068", "0.5505095", "0.5504594", "0.550...
0.70552945
0
gets the next video in the order. accepts an id.
def next_video(current_id) @video_ids = airings.map {|a| a.video_id } @current_index = @video_ids.index current_id.to_i if @current_index next_index = (@current_index + 1) % self.videos.count Video.find(@video_ids[next_index]) else # give the next video or the first if current_index not set. Video.find(@video_ids[rand(self.videos.count)]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next\n\t\tself.class.where(\"id > ?\", id).first\n\tend", "def next\n \tself.class.where(\"id > ?\", id).first\n \tend", "def next\n room.players.where(\"id > ?\", id).first || room.players.first\n end", "def next_video\n if episode?\n episode = content.next_ep\n unless episode.nil?\...
[ "0.69828856", "0.69269556", "0.6831194", "0.6784713", "0.6774003", "0.66639847", "0.6660575", "0.65003794", "0.6432579", "0.63965386", "0.6365845", "0.62642115", "0.622143", "0.62100786", "0.62015307", "0.6150377", "0.6130871", "0.6088212", "0.6073662", "0.5991493", "0.596576...
0.803972
0
Method that define item is present or not ensure that there is no line items referencing this product
def ensure_not_referenced_by_any_line_item if line_items.empty? return true else errors.add(:base, 'Line Items present') return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ensure_not_referenced_by_any_line_item\n\t\tif line_items.empty?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'Product sedang di referensikan oleh Line Item')\n\t\t\treturn false\n\t\tend\n\tend", "def ensure_not_referenced_by_any_line_item \n if line_items.empty?\n return true \n e...
[ "0.8178421", "0.80856377", "0.8071649", "0.80705714", "0.8060181", "0.80565995", "0.80502605", "0.8048612", "0.8034292", "0.80205095", "0.80174375", "0.8017026", "0.80118316", "0.80104095", "0.80079013", "0.8002724", "0.8000611", "0.79978424", "0.7992991", "0.79922014", "0.79...
0.79852164
20
A contact's name & email
def summary "#{name} (#{email})" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def contact_name\n attributes[:contact] && attributes[:contact][:name]\n end", "def contact_name\n contact['name']\n end", "def contact_email\n contact['email_address']\n end", "def formatted_email(contact)\n \"#{contact.username} <#{contact.email}>\"\n end", "def contact_email\...
[ "0.75632703", "0.75236076", "0.74743336", "0.744476", "0.74264604", "0.7391655", "0.7374895", "0.7207071", "0.71628326", "0.71339154", "0.7080016", "0.7080016", "0.7072156", "0.7022994", "0.6963751", "0.69393384", "0.6897494", "0.68818593", "0.6862308", "0.6853104", "0.684246...
0.0
-1
All the shows where the contact is the promoter.
def promoter_shows Show.where(promoter_id: id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @promoters = Promoter.find(:all).sort_by{|p| p.name_or_contact_info}\n end", "def show\r\n # @provider_masters = ProvierMaster.all\r\n end", "def show\n @pdestaf = Mercadorium.where fabricante: @fabrica.name\n\n end", "def show\n @presenters = Presenter.all\n @meetings = Meeting.al...
[ "0.63855946", "0.62670064", "0.59467316", "0.5840493", "0.58328736", "0.58328736", "0.57074666", "0.5696384", "0.56671005", "0.5632648", "0.56320554", "0.5624344", "0.5603016", "0.5592168", "0.55871433", "0.55705273", "0.5558642", "0.5556958", "0.5537548", "0.5531207", "0.552...
0.7458325
0
Connect a venue to the contact.
def connect(venue) ContactVenueRelationship.create(contact_id: id, venue_id: venue.id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_venue\n @venue = Venue.find(params[:id])\n end", "def set_venue\n @venue = Venue.find(params[:id])\n end", "def set_venue\n @venue = Venue.find(params[:id])\n end", "def set_venue\n @venue = Venue.find(params[:id])\n end", "def set_venue\n @venue = Venue.find(pa...
[ "0.60933495", "0.60933495", "0.60933495", "0.60933495", "0.60933495", "0.60421574", "0.6031163", "0.6031163", "0.59471613", "0.59471613", "0.59378403", "0.59378403", "0.59378403", "0.59378403", "0.58844155", "0.58124757", "0.58124757", "0.5761003", "0.5761003", "0.56730825", ...
0.8409064
0
Unconnects the contact and a venue.
def unconnect relationship = ContactVenueRelationship.find_by(contact_id: id, venue_id: venue.id) relationship.destroy end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unfollow(user, contact)\n destroy(conn(user, contact))\n other_connection = conn(contact, user)\n if !other_connection.nil?\n if other_connection.status == ACCEPTED\n other_connection.status = PENDING\n other_connection.save\n elsif other_connection.st...
[ "0.6354718", "0.6132487", "0.5783989", "0.57795966", "0.5773787", "0.5703839", "0.5615233", "0.55814004", "0.5576573", "0.55573374", "0.55552423", "0.5515391", "0.5503913", "0.5503913", "0.54789364", "0.5447988", "0.5444858", "0.5421188", "0.54152054", "0.5400742", "0.5400669...
0.8274814
0
The venues that are not connected to the contact.
def unconnected_venues unconnected = [] Venue.all.each do |venue| unconnected << venue if venues.exclude? venue end return unconnected end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_nearby_venues\n Venue.where([\"neighbourhood_id = ? and id <> ?\", self.neighbourhood_id, self.id])\n end", "def is_not_at_facility\n Venue.all - self.venues\n end", "def blockable_venues\n venues = Venue.joins(\"JOIN centers_venues ON venues.id = centers_venues.venue_id\").where('center...
[ "0.7064674", "0.6641354", "0.619172", "0.5953587", "0.59016824", "0.58992624", "0.58362865", "0.5779905", "0.57712513", "0.5760179", "0.56878024", "0.56847376", "0.56773937", "0.5638697", "0.56229407", "0.55814725", "0.5548656", "0.5518197", "0.55110043", "0.5488991", "0.5486...
0.78305715
0
results accumulator stores the results we have fetched so far, recursively
def find_by_sql(options, results_accumulator=nil, &block) # SugarCRM REST API has a bug (fixed in release _6.4.0.patch as indicated in SugarCRM bug number 43338) # where, when :limit and :offset options are passed simultaneously, # :limit is considered to be the smallest of the two, and :offset is the larger # In addition to allowing querying of large datasets while avoiding timeouts (by fetching results in small slices), # this implementation fixes the :limit - :offset bug so that it behaves correctly offset = options[:offset].to_i >= 1 ? options[:offset].to_i : nil # if many results are requested (i.e. multiple result slices), we call this function recursively # this array keeps track of which slice we are retrieving (by updating the :offset and :limit options) local_options = {} # ensure results are ordered so :limit and :offset option behave in a deterministic fashion local_options[:order_by] = :id unless options[:order_by] # we must ensure limit <= offset (due to bug mentioned above) if offset local_options[:limit] = [offset.to_i, SLICE_SIZE].min local_options[:offset] = offset if offset else local_options[:limit] = options[:limit] ? [options[:limit].to_i, SLICE_SIZE].min : SLICE_SIZE end local_options[:limit] = [local_options[:limit], options[:limit]].min if options[:limit] # don't retrieve more records than required local_options = options.merge(local_options) query = query_from_options(local_options) result_slice = connection.get_entry_list(self._module.name, query, local_options) return results_accumulator unless result_slice result_slice_array = Array.wrap(result_slice) if block_given? result_slice_array.each{|r| yield r } else results_accumulator = [] unless results_accumulator results_accumulator = results_accumulator.concat(result_slice_array) end # adjust options to take into account records that were already retrieved updated_options = {:offset => options[:offset].to_i + result_slice_array.size} updated_options[:limit] = (options[:limit] ? options[:limit] - result_slice_array.size : nil) updated_options = options.merge(updated_options) # have we retrieved all the records? if (updated_options[:limit] && updated_options[:limit] < 1) || local_options[:limit] > result_slice_array.size return results_accumulator else find_by_sql(updated_options, results_accumulator, &block) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_results (results)\n\t\t\tresults.each do |result|\n\t\t\t\tresult = process_result(result)\n\t\t\tend\n\t\t\treturn results\n\t\tend", "def collect_results\n while collect_next_line; end\n end", "def results\n fetch unless @results\n @results\n end", "def merge_resu...
[ "0.7082534", "0.65451133", "0.6451944", "0.63702637", "0.63702524", "0.63702524", "0.6341012", "0.62825733", "0.62793326", "0.61854804", "0.61854804", "0.61854804", "0.6109766", "0.60838366", "0.6050446", "0.60304284", "0.602739", "0.59968144", "0.5994033", "0.5962388", "0.59...
0.0
-1
return the opposite of the provided order clause this is used for the :last find option in other words SugarCRM::Account.last(:order_by => "name") is equivalent to SugarCRM::Account.first(:order_by => "name DESC")
def reverse_order_clause(order) raise "reversing multiple order clauses not supported" if order.split(',').size > 1 raise "order clause format not understood; expected 'column_name (ASC|DESC)?'" unless order =~ /^\s*(\S+)\s*(ASC|DESC)?\s*$/ column_name = $1 reversed_order = {'ASC' => 'DESC', 'DESC' => 'ASC'}[$2 || 'ASC'] return "#{column_name} #{reversed_order}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inverse\n OrderBy.new(@field, @dir == :asc ? :desc : :asc)\n end", "def last_partitions_order_by_clause\n unless @last_partitions_order_by_clause\n @last_partitions_order_by_clause = collect_first(&:last_partitions_order_by_clause)\n end\n return @last_partitions...
[ "0.6550195", "0.6467464", "0.6445405", "0.6413968", "0.63971084", "0.6358113", "0.6353227", "0.61858314", "0.6161178", "0.6121973", "0.6082452", "0.6079295", "0.6058379", "0.6020136", "0.597479", "0.59333694", "0.5932905", "0.5839925", "0.58194983", "0.5805568", "0.5751297", ...
0.6184766
8
Enables dynamic finders like find_by_user_name(user_name) and find_by_user_name_and_password(user_name, password) that are turned into find(:first, :conditions => ["user_name = ?", user_name]) and find(:first, :conditions => ["user_name = ? AND password = ?", user_name, password]) respectively. Also works for find(:all) by using find_all_by_amount(50) that is turned into find(:all, :conditions => ["amount = ?", 50]). It's even possible to use all the additional parameters to +find+. For example, the full interface for +find_all_by_amount+ is actually find_all_by_amount(amount, options). Also enables dynamic scopes like scoped_by_user_name(user_name) and scoped_by_user_name_and_password(user_name, password) that are turned into scoped(:conditions => ["user_name = ?", user_name]) and scoped(:conditions => ["user_name = ? AND password = ?", user_name, password]) respectively. Each dynamic finder, scope or initializer/creator is also defined in the class after it is first invoked, so that future attempts to use it do not run through method_missing.
def method_missing(method_id, *arguments, &block) if match = DynamicFinderMatch.match(method_id) attribute_names = match.attribute_names super unless all_attributes_exists?(attribute_names) if match.finder? finder = match.finder bang = match.bang? self.class_eval <<-EOS, __FILE__, __LINE__ + 1 def self.#{method_id}(*args) options = args.extract_options! attributes = construct_attributes_from_arguments( [:#{attribute_names.join(',:')}], args ) finder_options = { :conditions => attributes } validate_find_options(options) #{'result = ' if bang}if options[:conditions] with_scope(:find => finder_options) do find(:#{finder}, options) end else find(:#{finder}, options.merge(finder_options)) end #{'result || raise(RecordNotFound, "Couldn\'t find #{name} with #{attributes.to_a.collect {|pair| "#{pair.first} = #{pair.second}"}.join(\', \')}")' if bang} end EOS send(method_id, *arguments) elsif match.instantiator? instantiator = match.instantiator self.class_eval <<-EOS, __FILE__, __LINE__ + 1 def self.#{method_id}(*args) attributes = [:#{attribute_names.join(',:')}] protected_attributes_for_create, unprotected_attributes_for_create = {}, {} args.each_with_index do |arg, i| if arg.is_a?(Hash) protected_attributes_for_create = args[i].with_indifferent_access else unprotected_attributes_for_create[attributes[i]] = args[i] end end find_attributes = (protected_attributes_for_create.merge(unprotected_attributes_for_create)).slice(*attributes) options = { :conditions => find_attributes } record = find(:first, options) if record.nil? record = self.new(unprotected_attributes_for_create) #{'record.save' if instantiator == :create} record else record end end EOS send(method_id, *arguments, &block) end else super end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def finder(*finders)\r\n finders.each do |finder|\r\n instance_eval <<CODE, __FILE__, __LINE__ + 1\r\n#--\r\n# FIXME: This can probably be refactored as:\r\n#\r\n# scoped(args.extract_options!).\\#{finder} *args, &block\r\n#++\r\ndef #{finder}(*args, &block)\r\n options = args.extract_options!\r\n\r\n...
[ "0.7117951", "0.6938023", "0.6840446", "0.68306816", "0.67749023", "0.67614865", "0.66215134", "0.65522325", "0.65301746", "0.64287704", "0.64254075", "0.63622934", "0.6319908", "0.6259415", "0.6109502", "0.61088145", "0.61066574", "0.6098097", "0.60145175", "0.6007208", "0.5...
0.6502808
9
inserts based of another table. useful when copying rows between tables. DO NOT USE...
def insert_select(params = {}) db_str = GenInsert.insert_select(params) #@log.debug db_str @client.run db_str return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert_into(table, data)\n\t\tkeys = \"(#{data.keys.join(', ')})\"\n\t\tvalues = \"(#{data.values.map{ |value| \"'#{value}'\" }.join(', ')})\"\n\t\texecute_with_retry \"INSERT INTO #{table} #{keys} VALUES #{values}; \"\n\tend", "def insert(object, table)\n sql = object.to_sql(table)\n execute(sql)\n e...
[ "0.7146172", "0.7024446", "0.68548423", "0.6767777", "0.67498416", "0.67214227", "0.67088115", "0.6475774", "0.64506775", "0.64421725", "0.6380909", "0.63599294", "0.6357327", "0.6353127", "0.63519925", "0.63034964", "0.62900496", "0.6283792", "0.6277418", "0.6251403", "0.620...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def event_params params.require(:event).permit(:name, :date, :time, :location, :purpose) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Initialize the EC2 Client object
def initialize(aws_region:) @ec2_client ||= Aws::EC2::Client.new(region: aws_region) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(config)\n @aws_ec2 = AWS::EC2.new(config)\n end", "def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})\n init({ :name => 'EC2',\n :default_host => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).host : DEFAULT_HOST,\n ...
[ "0.74037623", "0.7393521", "0.7350949", "0.7343247", "0.73235685", "0.7240159", "0.7196345", "0.7194741", "0.71862525", "0.7168115", "0.71036536", "0.6996494", "0.69579196", "0.6937662", "0.6897118", "0.6885941", "0.6849786", "0.6848727", "0.68415356", "0.67978597", "0.676124...
0.77925855
0
(transformed) nodes are arrays, that look like: [:type, attribute hash or array of nodes]
def to_sexp(node) node && send("#{node.first}_to_sexp", node.last) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_a\n @nodes\n end", "def to_a\n collect { |node| node.data }\n end", "def to_a\n nodes.map(&:at)\n end", "def transform(tree); end", "def transfer_node_attributes(nodes, attributes); end", "def node_to_ary(node)\n node.to_s.split(\"\\n\")\n end", "def to_a\n ...
[ "0.68029875", "0.66428435", "0.66304606", "0.6411438", "0.6351273", "0.6283534", "0.61893195", "0.6041019", "0.6031766", "0.5967229", "0.5937935", "0.5906308", "0.5896435", "0.58795154", "0.58666766", "0.58360076", "0.5822168", "0.58167756", "0.5808693", "0.5757867", "0.57509...
0.0
-1
fixed argument lists are represented as :array nodes, e.g. [:array, [argnode1, argnode2, ...]]
def process_args(args_node) return [] unless args_node if args_node.first == :array args_node.last.map { |node| to_sexp(node) } else raise "variable arguments not allowed" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def aryfy(arg)\n ast AST::ASTArray, :children => [arg]\n end", "def convert_args_node(node)\n if node.kind_of?(String) || node.kind_of?(Symbol) || node.kind_of?(Numeric) || \n node.kind_of?(TrueClass) || node.kind_of?(FalseClass) || node.kind_of?(NilClass)\n node\n elsif node.instance_of?(Ar...
[ "0.7347744", "0.6768978", "0.64906603", "0.63761955", "0.6326545", "0.6276517", "0.61711496", "0.60801065", "0.6058233", "0.6034769", "0.60234267", "0.60181403", "0.6016173", "0.6003154", "0.5987587", "0.5978011", "0.59675026", "0.59292954", "0.5909316", "0.5908178", "0.57782...
0.6949441
1
Internal: Receives a collection of inputs and interpolates the values to fit the end year of the new scenario. For example, if the start year is 2020 and the source scenario is 2050, and an input starts and 0 and the source value is 100, and the new scenario is based in 2030, the input value will be 50. Returns the interpolated inputs.
def interpolate_input_collection(collection) num_years = @scenario.end_year - @year total_years = @scenario.end_year - @scenario.start_year collection.each_with_object(collection.class.new) do |(key, value), interp| if (input = Input.get(key)) interp[key] = interpolate_input(input, value, total_years, num_years) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def interpolate_input(input, value, total_years, num_years)\n return value if input.enum?\n\n start = input.start_value_for(@scenario)\n change_per_year = (value - start) / total_years\n\n start + change_per_year * (total_years - num_years)\n end", "def interpolate(frequency, operation)\n # puts \...
[ "0.7225483", "0.5076649", "0.5070885", "0.50320387", "0.49417526", "0.49219903", "0.48959297", "0.4779482", "0.4729065", "0.4681909", "0.46788168", "0.46556127", "0.46552408", "0.46462598", "0.46358004", "0.4625349", "0.46188203", "0.45875785", "0.45875785", "0.45736602", "0....
0.70665866
1
Internal: Calculates the interpolated value of an input based on its current value in the original scenario. Returns a Numeric or String value for the new user values.
def interpolate_input(input, value, total_years, num_years) return value if input.enum? start = input.start_value_for(@scenario) change_per_year = (value - start) / total_years start + change_per_year * (total_years - num_years) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def value_of element\n element = super # eval Procs\n case element\n when Numeric then @value.transpose(element) if @value # add interval\n when PitchClass then @value.nearest(element) if @value\n else element\n end\n end", "def convert_value_by_type\n case...
[ "0.5457691", "0.5402587", "0.5399055", "0.5345718", "0.5322939", "0.5307462", "0.52730906", "0.5248776", "0.52367425", "0.5236653", "0.52281356", "0.5223321", "0.521307", "0.51618254", "0.51554567", "0.5151672", "0.51174605", "0.50771004", "0.5070582", "0.50676274", "0.503541...
0.7015107
0
def destroy User.find(params[:id]).destroy flash[:success]="User destroyed" redirect_to users_path end
def signed_in_user unless signed_in? store_location redirect_to signin_path, notice: "Please sign in." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n User.find(params[:id]).destroy\n flash[:success] = \"User deleted :(\"\n redirect_to users_url\n end", "def destroy\n User.find_by(id: params[:id]).destroy\n flash.now[:succes] = \"User was succesfully deleted\"\n redirect_to users_url\n end", "def destroy\n User.find(param...
[ "0.9574851", "0.9496986", "0.94106025", "0.9393822", "0.93867934", "0.93867934", "0.93867934", "0.93867934", "0.93743587", "0.93654495", "0.93589276", "0.9351379", "0.93324345", "0.9327146", "0.9327131", "0.9324323", "0.9324323", "0.93209183", "0.93204254", "0.9318777", "0.93...
0.0
-1
creating the new product
def create product = Product.new(product_params) product.save ? (redirect_to products_path, flash: {notice: 'Product created successfully'}) : (redirect_to new_product_path, flash: {error: 'product.errors.full_messages.to_sentence'}) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n data = self.class.create_product(self)\n self.id = data.id\n data\n end", "def add_new_product\n aProduct = Product.new(@product_title, @product_price, @customer_id)\n aProduct.create_new_product\n end", "def create_full_product\n generate_product_name...
[ "0.81571627", "0.8154615", "0.8041338", "0.7931761", "0.78155005", "0.7790225", "0.7756185", "0.77470464", "0.7726958", "0.7695504", "0.76150906", "0.7613154", "0.75994223", "0.7598772", "0.7591698", "0.7583223", "0.7583223", "0.7583223", "0.7583223", "0.7583223", "0.75413734...
0.7269491
58
and a result which is also an array that is empty at first. The all_perms method is a recursive method. We make a list of the elements that are not present in the result. We add the first element from this to the result. All the permutations of the prefix in the result with the remaining elements are printed. The added element is popped off. The next candidate is now added to the result and all the permutations with this prefix are printed, and so on.
def perms(arr) result = [] all_perms(arr, 0, result) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def permutations(base, result = [])\n base = base.dup\n base.empty? ? [result] : base.shift.map { |value| permutations(base, result + [value]) }.flatten(1)\n end", "def permutations(arr)\n # return nil if arr.empty?\n return [arr] if arr.length == 1\n # grab first element to app...
[ "0.67402077", "0.67389166", "0.67088866", "0.6592986", "0.6546746", "0.6484407", "0.64838177", "0.6465498", "0.64506906", "0.6434295", "0.641186", "0.6406546", "0.6396502", "0.63918483", "0.639125", "0.6358306", "0.63490385", "0.63415337", "0.63324124", "0.6324909", "0.628236...
0.728698
0
Define a method in the Show class called actors_list that returns an Array of the full names of each actor associated with a show. Remember, a show should have many actors through characters.
def actors_list self.actors.map do |actor| "#{actor.first_name} #{actor.last_name}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def actors_list\n # characters.where(show_id: self.id)\n self.characters.map do |character|\n character.actor.full_name\n end\n end", "def actors_list\n self.characters.map do |c|\n \"#{c.actor.full_name}\"\n end\n end", "def actors_list\n actor_names = []\n self.char...
[ "0.86174464", "0.8328058", "0.79615504", "0.783769", "0.69107985", "0.6803531", "0.67539036", "0.6601669", "0.65573156", "0.65573156", "0.6429673", "0.6329611", "0.6312276", "0.6294817", "0.6294218", "0.6261144", "0.6207178", "0.61932343", "0.6165172", "0.61563313", "0.612222...
0.80675256
2
GET /image_position_templates GET /image_position_templates.json
def index @image_position_templates = ImagePositionTemplate.ordered respond_to do |format| format.html # index.html.erb format.json { render json: @image_position_templates } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @image_position_template = ImagePositionTemplate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @image_position_template }\n end\n end", "def new\n @image_position_template = ImagePositionTemplate.new\n\n respond_to do ...
[ "0.68678117", "0.63442534", "0.6235765", "0.61869854", "0.6064893", "0.5938527", "0.5885065", "0.5804216", "0.56918854", "0.562584", "0.5612658", "0.55722386", "0.5570342", "0.55579114", "0.55075425", "0.55052894", "0.5487735", "0.5479869", "0.5471034", "0.5466857", "0.543403...
0.738866
0
GET /image_position_templates/1 GET /image_position_templates/1.json
def show @image_position_template = ImagePositionTemplate.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @image_position_template } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @image_position_templates = ImagePositionTemplate.ordered\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @image_position_templates }\n end\n end", "def new\n @image_position_template = ImagePositionTemplate.new\n\n respond_to do |forma...
[ "0.73890805", "0.68279374", "0.6288571", "0.62319326", "0.6127538", "0.60175127", "0.59898174", "0.5963749", "0.5944063", "0.58987486", "0.581372", "0.5775024", "0.5762081", "0.57003486", "0.56834006", "0.5639023", "0.563465", "0.5609671", "0.55893975", "0.5556625", "0.554252...
0.7391674
0
GET /image_position_templates/new GET /image_position_templates/new.json
def new @image_position_template = ImagePositionTemplate.new respond_to do |format| format.html # new.html.erb format.json { render json: @image_position_template } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @image_position_template = ImagePositionTemplate.new(params[:image_position_template])\n\n respond_to do |format|\n if @image_position_template.save\n format.html { redirect_to @image_position_template, notice: 'Image position template was successfully created.' }\n format.jso...
[ "0.74638766", "0.69190323", "0.68910676", "0.66938114", "0.6672162", "0.66231436", "0.6608281", "0.6594944", "0.65694916", "0.65694916", "0.65694916", "0.64584553", "0.6456591", "0.641446", "0.6414122", "0.63989407", "0.6364294", "0.63399637", "0.6293575", "0.62831295", "0.62...
0.81139064
0
POST /image_position_templates POST /image_position_templates.json
def create @image_position_template = ImagePositionTemplate.new(params[:image_position_template]) respond_to do |format| if @image_position_template.save format.html { redirect_to @image_position_template, notice: 'Image position template was successfully created.' } format.json { render json: @image_position_template, status: :created, location: @image_position_template } else format.html { render action: "new" } format.json { render json: @image_position_template.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @position = Position.new(position_params)\n respond_to do |format|\n if @position.save\n @position.create_images(params[:images]) if params[:images]\n format.html { redirect_to @position, notice: 'Position was successfully created.' }\n format.json { render :show, statu...
[ "0.63672435", "0.6351562", "0.6257164", "0.61694825", "0.6147034", "0.57744765", "0.5747771", "0.56924856", "0.5689383", "0.56399775", "0.5632281", "0.5597104", "0.55703723", "0.55645263", "0.54897726", "0.54753214", "0.54661465", "0.54628426", "0.5450453", "0.54218036", "0.5...
0.7288086
0
PUT /image_position_templates/1 PUT /image_position_templates/1.json
def update @image_position_template = ImagePositionTemplate.find(params[:id]) respond_to do |format| if @image_position_template.update_attributes(params[:image_position_template]) format.html { redirect_to @image_position_template, notice: 'Image position template was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @image_position_template.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_template_with_image_id(template)\n params = template.parameters\n params.each do |key, value|\n update_params_with_image_id(params, key, value)\n end\n end", "def create\n @image_position_template = ImagePositionTemplate.new(params[:image_position_templa...
[ "0.6828326", "0.6690431", "0.6384763", "0.63631153", "0.6201784", "0.615003", "0.6104498", "0.608083", "0.6065748", "0.59648013", "0.5955816", "0.5943629", "0.5906332", "0.5838658", "0.580589", "0.5748051", "0.57070994", "0.5676574", "0.5656723", "0.56497896", "0.5598645", ...
0.70944154
0
DELETE /image_position_templates/1 DELETE /image_position_templates/1.json
def destroy @image_position_template = ImagePositionTemplate.find(params[:id]) @image_position_template.destroy respond_to do |format| format.html { redirect_to image_position_templates_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n super \"/templates/#{template_id}.json\", {}\n end", "def destroy\n @item_template.destroy\n respond_to do |format|\n format.html { redirect_to item_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @template.destroy\n respond_to do |...
[ "0.74777067", "0.6999338", "0.692979", "0.6883951", "0.6875389", "0.6872521", "0.6865867", "0.68420476", "0.68387175", "0.68291", "0.6822052", "0.6822051", "0.68148935", "0.681022", "0.679123", "0.67889833", "0.6770979", "0.67598546", "0.675668", "0.6750477", "0.6746375", "...
0.79537046
0
def initialize(widget, opts) super end
def content super @renderer = @widget.content div :id => 'doc3' do if @renderer.render? :header div :id => 'hd' do if @renderer.render? :top_line render_top_line end if @renderer.render? :title h1 @page_title || 'Missing :page_title' end end end div :id => 'bd' do render_body end if @renderer.render? :footer div :id => 'ft' do render_footer end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize()\n # override parent\n end", "def initialize(object, **opts)\n super\n end", "def initialize(*_)\n super\n end", "def initialize\n super\n end", "def initialize\n super\n end", "def initialize\n super\n end", "def initializ...
[ "0.7743177", "0.7499705", "0.73761314", "0.7375761", "0.7375761", "0.7375761", "0.7370563", "0.7370563", "0.7370563", "0.7364574", "0.7364129", "0.7364129", "0.7334906", "0.7334906", "0.7334906", "0.7334906", "0.7334906", "0.7334906", "0.7334906", "0.7334906", "0.7334906", ...
0.0
-1
verify :method => :put, :only => [ :enable, :disable, :update_password ]
def index query, conditions = [], [] unless params[:show_expired] query << "expires_at IS NULL OR expires_at >= ?" conditions << Time.now.utc end unless params[:key_word].blank? query << %w(login email first_name last_name).collect { |f| "lower(#{f}) LIKE lower(?)" }.join(" OR ") 4.times { conditions << "%#{params[:key_word]}%" } end unless params[:group_id].to_i == 0 query << "#{UserGroupMembership.table_name}.group_id = ?" conditions << params[:group_id] end query.collect! { |q| "(#{q})"} conditions = conditions.unshift(query.join(" AND ")) per_page = params[:per_page] || 10 @users = User.paginate(:page => params[:page], :per_page => per_page, :include => :user_group_memberships, :conditions => conditions, :order => "first_name, last_name, email") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def password_needed?\n resource.authentications.empty? \\\n ? resource.update_with_password(params[resource_name])\\\n : resource.update_attributes(params[resource_name])\n end", "def test_change_password_unsuccessful\n data = {\n current_password: \"1234567890\",\n password: \"new...
[ "0.64985526", "0.64874226", "0.6343194", "0.6342289", "0.6246252", "0.6240209", "0.6216999", "0.6196389", "0.61618775", "0.6156174", "0.6149351", "0.6110989", "0.6067343", "0.60439074", "0.60166764", "0.60154086", "0.60154086", "0.601519", "0.5997419", "0.5976615", "0.5968554...
0.0
-1
filter group enabled attributes
def group_params params.permit(:name, :description, :kind, :privacy_level, :image, :banner, :request_root_branch, :latitude, :longitude, counselor_ids: [], meetings_attributes: [:_destroy, :id, :title, :hour, :day], new_participant_ids: [], new_admin_ids: [], delete_participant_ids: [], hashtag_ids: []) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean_attributes\n return attributes if group.nil? || !group.empty?\n\n filtered_attributes = attributes.dup\n filtered_attributes.delete(:group)\n end", "def attributes\n @enabled\n end", "def group_admins_enabled\n @attributes[:group_admins_enabled]\n end", ...
[ "0.61272585", "0.61108524", "0.61067", "0.60683024", "0.5968416", "0.5955396", "0.5916999", "0.588814", "0.5854326", "0.58454305", "0.58391696", "0.5759866", "0.5756406", "0.5670165", "0.5669306", "0.5669306", "0.5630359", "0.56222266", "0.5608819", "0.5571818", "0.55392826",...
0.0
-1
GET /games GET /games.json
def index @games = Game.all.order("date DESC") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @games = Game.available\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end", "def index\n @games = Game.all\n render json: @games\n end", "def index\n @games = current_user.games\n \n respond_to do |format|...
[ "0.801388", "0.7969819", "0.7854131", "0.7795904", "0.77952725", "0.77952725", "0.77952725", "0.7618289", "0.75276613", "0.74230546", "0.74158394", "0.7390365", "0.73540944", "0.7318076", "0.72921306", "0.7247407", "0.7209582", "0.7190768", "0.7177297", "0.7177297", "0.717729...
0.0
-1
GET /games/1 GET /games/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @game = Game.find(params[:id])\n render json: @game, status: 200\n end", "def index\n @games = Game.available\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end", "def index\n @games = Game.all\n render json: @...
[ "0.77774805", "0.77492905", "0.77341574", "0.75965285", "0.75962996", "0.75962996", "0.75962996", "0.7543047", "0.74719816", "0.74719816", "0.74719816", "0.74719816", "0.74719816", "0.74719816", "0.74719816", "0.7428268", "0.74045074", "0.7395587", "0.73370796", "0.733467", "...
0.0
-1
Check to see if the virtual machine is in execute mode.
def execute_mode? @context[:mode] == :execute end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def execute?(cmd)\n execution_result = execute(cmd)\n !execution_result.nil? && execution_result\n end", "def executable?\n @executable || (@executable.nil? && !garbage? && plan && plan.executable?)\n end", "def exec?(cmd, options={})\n exit_status, stdout, stderr, cmd = exec(cm...
[ "0.68815583", "0.6647718", "0.66271204", "0.65706", "0.6523622", "0.6426441", "0.6400111", "0.6391803", "0.6379353", "0.6357611", "0.6354427", "0.63116443", "0.6283339", "0.62677944", "0.6232029", "0.61867726", "0.61867726", "0.6167567", "0.61664593", "0.612819", "0.6090543",...
0.74717116
0
Normal sinatra session method just returns request.session which passes through to env['rack.session'] but I don't initialize the request object until just before the route lookkup, so I need to skip directly to env.
def session raise Sinatra::Unit::SessionsDisabledError unless test_sessions_enabled? env['rack.session'] ||= {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def session\n env['rack.session'] ||= {}\n end", "def session\n @session ||= @app.config[:session_from_rack_env].call(@env)\n end", "def session\n @session ||= Session.new( req )\n end", "def session\n env[\"rack.session\"] || {}\n end", "def session\n @session ||= Session.new(re...
[ "0.79946643", "0.7950045", "0.76238835", "0.7594641", "0.7587598", "0.7587598", "0.7587598", "0.7587598", "0.7587598", "0.75550073", "0.7481431", "0.74600905", "0.74600905", "0.74600905", "0.7389183", "0.73747015", "0.73545957", "0.7308764", "0.72780275", "0.7244397", "0.7233...
0.7878158
2
This doesn't exist in regular sinatra, but it's convenient for some tests
def session=(session) raise Sinatra::Unit::SessionsDisabledError unless test_sessions_enabled? env['rack.session'] = session end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_something_used_in_sinatra_app(var) end", "def app\n Sinatra::Application # It is must and tell rspec that test it running is for sinatra\nend", "def print_routes \n \n # Create a new hash\n h = Hash.new()\n\n # Use Sinatra advanced routes\n # to build out a hash based on the routes\n S...
[ "0.63572", "0.5874639", "0.5802666", "0.5739776", "0.570703", "0.5657517", "0.55728424", "0.55590314", "0.5553015", "0.5535025", "0.5535025", "0.55182016", "0.5504447", "0.5498304", "0.5498304", "0.5498304", "0.5498304", "0.5498304", "0.5498304", "0.5498304", "0.54797447", ...
0.0
-1
test_request comes mostly from the guts of route! in Sinatra::Base
def test_request(method, path, params={}) @params = indifferent_params(params) @request = Sinatra::Request.new(env) @request.path_info = path # sinatra 1.3.3 @__protected_ivars = instance_variables + ["@__protected_ivars"] # routes are stored by uppercase method, but I wanted the test interface # to accept :get or 'get' as well as 'GET' test_request_internal self.class, method.to_s.upcase end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call(request)\n test request\n end", "def setup\n @requester = Rack::MockRequest.new(SampleApp)\n end", "def test_request\n get \"/example/route\"\n assert last_response.ok?\n body = last_response.body\n assert body[\"Hello\"]\n end", "def test_request\n if defined?(Action...
[ "0.72975296", "0.7008018", "0.6993671", "0.6619649", "0.6544158", "0.6453145", "0.64409834", "0.6398676", "0.63839465", "0.62799424", "0.6253341", "0.6247639", "0.6230568", "0.62281245", "0.6222703", "0.6220136", "0.6187071", "0.61861247", "0.617266", "0.617266", "0.617266", ...
0.7403231
0
gets called from the form to enqueue a new job
def create arg = params[:email] counter = Job.enqueue(arg) render :status => :accepted, :json => { jobId: counter } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def queue_job; end", "def enqueue\n # We need to save before passing to perform_later b/c perform_later will need our ID.\n # For this reason, the job_id col can't have a null constraint.\n save! unless persisted?\n job = job_class.constantize.perform_later(self, **job_params)\n update!(job_id: jo...
[ "0.70713866", "0.70490044", "0.70153135", "0.70076525", "0.6959974", "0.69463587", "0.69284946", "0.6899085", "0.68229795", "0.6789745", "0.6780809", "0.6766544", "0.67414296", "0.6725607", "0.66737664", "0.6652128", "0.66479874", "0.6635255", "0.66175157", "0.66040653", "0.6...
0.70989615
0
gets called from the form in the polling
def fetch counter = params[:counter] if Job.isDone?(counter) render :status => 200, :text => Job.getResult(counter) else render :status => 202, :text => '' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fbo_updated_form\n end", "def event; end", "def event; end", "def event; end", "def refresh!; end", "def updated()\n # ICLA file form\n # TODO: why not used?\n _valid = %w(pubname email).all? do |name|\n document.querySelector(\"input[name=#{name}]\").validity.valid\n end\n\n # w...
[ "0.667066", "0.6419415", "0.6419415", "0.6419415", "0.6202607", "0.6192236", "0.6189758", "0.6168873", "0.610192", "0.610192", "0.6077125", "0.59955543", "0.597969", "0.5974196", "0.5974196", "0.59524745", "0.5950488", "0.5918588", "0.59022856", "0.59022856", "0.587252", "0...
0.0
-1
GET /procedures GET /procedures.json
def index if current_user.prosecutor.present? @pagy, @procedures = pagy(Procedure.where(:state => 0, :local_prosecution_in_charge_id => current_user.prosecutor.local_prosecution.id).or(Procedure.where(:state => 2, :creator_id => current_user.id, :local_prosecution_in_charge_id => current_user.prosecutor.local_prosecution.id)).order(created_at: :desc)) elsif current_user.police_unit.present? @pagy, @procedures = pagy(Procedure.where(:state => 2, :creator_id => current_user.id, :police_unit_in_charge_id => current_user.police_unit.id).or(Procedure.where(:state => 3, :police_unit_in_charge_id => current_user.police_unit.id)).order(created_at: :desc)) puts(@procedures) elsif current_user.admin? @procedures = [] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n render json: Procedure.all, status: :ok\n end", "def stored_procedure(name)\n get \"#{base_url}/storedprocedures/#{name}\"\n end", "def show\n @procedures = @property.procedures\n end", "def index\n @procedures = Procedure.all\n\n respond_to do |format|\n format.htm...
[ "0.6926617", "0.6695462", "0.65038925", "0.6443691", "0.6385713", "0.63339657", "0.6220527", "0.6173331", "0.61091673", "0.6095725", "0.6051873", "0.6050506", "0.5918805", "0.5873979", "0.5844729", "0.5791556", "0.56895703", "0.5684501", "0.5575923", "0.5549793", "0.5515017",...
0.5503553
21
GET /procedures/1 GET /procedures/1.json
def show #save list with all accuseds person of the procedure @preponderant_crime = @procedure.crime_in_accuseds.find_by(preponderant: true) @crimes = @procedure.crime_in_accuseds.where(preponderant: false).uniq { |s| s.crime.id } accuseds_in_procedure = @procedure.person_in_procedures.where(role: 0) @accuseds = [] accuseds_in_procedure.each do |accused| @accuseds.append([Person.find(accused.person_id), accused.state, accused.id, accused.prosecutor_pronounced]) end #save list with all victims person of the procedure victims_in_procedure = @procedure.person_in_procedures.where(role: 2) @victims = [] victims_in_procedure.each do |victim| @victims.append([Person.find(victim.person_id), victim.witness_declaration]) end #save list with all witnesses person of the procedure witnesses_in_procedure = @procedure.person_in_procedures.where(role: 1) @witnesses = [] witnesses_in_procedure.each do |witness| @witnesses.append([Person.find(witness.person_id), witness.witness_declaration]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n render json: Procedure.all, status: :ok\n end", "def stored_procedure(name)\n get \"#{base_url}/storedprocedures/#{name}\"\n end", "def show\n @procedure = Procedure.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xm...
[ "0.6947637", "0.6503618", "0.649327", "0.62670565", "0.6245129", "0.62362295", "0.6146888", "0.61010695", "0.60372376", "0.59715754", "0.5901738", "0.5835837", "0.5796559", "0.5788477", "0.5762257", "0.56458664", "0.5637257", "0.5575732", "0.55729455", "0.55626374", "0.555946...
0.0
-1
POST /procedures POST /procedures.json
def create authorize! :create, Procedure if procedure_params[:classification] == "ODP" classification_procedure = 1 elsif procedure_params[:classification] == "Flagrancia" classification_procedure = 0 else classification_procedure = 2 end selected_region = "" selected_sector = "" get_regiones @regiones.each do |region| if region[:codigo].to_s == procedure_params[:region].to_s selected_region = region[:nombre] end region[:comunas].each do |comuna| if comuna[:codigo].to_s == procedure_params[:sector].to_s selected_sector = comuna[:nombre] end end end d = procedure_params[:date].to_date t = procedure_params[:time].to_time dateOfArrest = Time.zone.local(d.year, d.month, d.day, t.hour, t.min, t.sec) @procedure = Procedure.new(classification: classification_procedure, creator: current_user, police_in_charge: PoliceMan.find(procedure_params[:police_in_charge]), police_unit_in_charge: PoliceUnit.find(procedure_params[:police_unit_in_charge]), local_prosecution_in_charge: LocalProsecution.find(procedure_params[:prosecution_in_charge]), story: procedure_params[:story], address: procedure_params[:address], sector: selected_sector, region: selected_region, state: params[:state].to_i, date_of_arrest: dateOfArrest, involves_deceased: procedure_params[:involves_deceased]) respond_to do |format| if procedure_params[:accuseds] if @procedure.save! if procedure_params[:photos] != nil procedure_params[:photos].each_with_index do |photo,i| @photo = Photo.new(description: procedure_params[:photo_descriptions][i], procedure: @procedure) @photo.photo.attach(photo) @photo.save! end end if procedure_params[:videos] != nil procedure_params[:videos].each_with_index do |video,i| @video = Video.new(description: procedure_params[:video_descriptions][i], procedure: @procedure) @video.video.attach(video) @video.save! end end if procedure_params[:documents] != nil procedure_params[:documents].each_with_index do |document,i| @document = Document.new(description: procedure_params[:document_descriptions][i],name: procedure_params[:document_names][i], procedure: @procedure) @document.document.attach(document) @document.save! end end procedure_params[:tag_ids][1..procedure_params[:tag_ids].size].each do |tag| @tag = Tagging.new(tag: Tag.find_by_name(tag), procedure: @procedure) @tag.save end procedure_params[:accuseds].each do |accused| @criminal = Person.new(name: accused[:name], rut: accused[:rut]) if @criminal.save! @criminal_in_procedure = PersonInProcedure.new(role: 0, person: @criminal, procedure: @procedure, state: 0) @criminal_in_procedure.save @criminal_alias = AliasAccused.new(alias: accused[:alias], person: @criminal) @criminal_alias.save if procedure_params[:crimes] procedure_params[:crimes].each do |crime| @crime_in_accused = CrimeInAccused.new(preponderant: false, crime: Crime.find_by_name(crime), person: @criminal, procedure: @procedure) @crime_in_accused.save end end @preponderan_crime_in_accused = CrimeInAccused.new(preponderant: true, crime: Crime.find_by_name(procedure_params[:preponderant_crime]), person: @criminal, procedure: @procedure) @preponderan_crime_in_accused.save end end if procedure_params[:victims] procedure_params[:victims].each do |victim| @victim = Person.new(name: victim[:name], rut: victim[:rut], deceased: victim[:deceased], contact: victim[:contact] ) if @victim.save! @victim_in_procedure = PersonInProcedure.new(role: 2, person: @victim, procedure: @procedure, witness_declaration: victim[:story]) @victim_in_procedure.save end end end if procedure_params[:witness] procedure_params[:witness].each do |witness| @witness = Person.new(name: witness[:name], rut: witness[:rut], contact: witness[:contact] ) if @witness.save! @witness_in_procedure = PersonInProcedure.new(role: 1, person: @witness, procedure: @procedure, witness_declaration: witness[:story]) @witness_in_procedure.save end end end #si el procedimiento se envia, se mandan las notificaciones pertinentes if @procedure.state == "Open" #si el usuario actual es policia, mandar notificaccion al fiscal y alrevez para lo otro if current_user.police_unit.present? prosecutors = Prosecutor.not_deleted.where(local_prosecution_id: @procedure.local_prosecution_in_charge.id) prosecutors.each { |pros| Notification.create(user: pros.user, notification_type: 0, reference_id: @procedure.id, seen: false) } elsif current_user.prosecutor.present? @procedure.police_unit_in_charge.users.each { |police_user| Notification.create(user: police_user, notification_type: 0, reference_id: @procedure.id, seen: false) } end end format.html { redirect_to @procedure, notice: 'Procedimiento ha sido creado con éxito.' } format.json { render :show, status: :created, location: @procedure } else format.html { render :new } format.json { render json: @procedure.errors, status: :unprocessable_entity } end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @procedure = Procedure.new(procedure_params)\n\n respond_to do |format|\n if @procedure.save\n format.json { render json: @procedure, status: :created }\n else\n format.json { render json: @procedure.errors, status: :unprocessable_entity }\n end\n end\n end", "...
[ "0.7220727", "0.6374066", "0.63201404", "0.62896657", "0.62554693", "0.6184696", "0.6103198", "0.60569865", "0.6044619", "0.59392524", "0.58748585", "0.58275014", "0.58001006", "0.57722145", "0.576249", "0.57224643", "0.57030386", "0.5642818", "0.55450994", "0.5518501", "0.54...
0.55497617
18
PATCH/PUT /procedures/1 PATCH/PUT /procedures/1.json
def update if params[:petition] == "update_borrador" if procedure_params[:classification] == "ODP" classification_procedure = 1 elsif procedure_params[:classification] == "Flagrancia" classification_procedure = 0 else classification_procedure = 2 end selected_region = "" selected_sector = "" get_regiones @regiones.each do |region| if region[:codigo].to_s == procedure_params[:region].to_s selected_region = region[:nombre] end region[:comunas].each do |comuna| if comuna[:codigo].to_s == procedure_params[:sector].to_s selected_sector = comuna[:nombre] end end end d = procedure_params[:date].to_date t = procedure_params[:time].to_time dateOfArrest = Time.zone.local(d.year, d.month, d.day, t.hour, t.min, t.sec) respond_to do |format| if @procedure.update!(classification: classification_procedure, police_in_charge: PoliceMan.find(procedure_params[:police_in_charge]), police_unit_in_charge: PoliceUnit.find(procedure_params[:police_unit_in_charge]), local_prosecution_in_charge: LocalProsecution.find(procedure_params[:prosecution_in_charge]), story: procedure_params[:story], address: procedure_params[:address], sector: selected_sector, region: selected_region, state: params[:state].to_i, date_of_arrest: dateOfArrest, involves_deceased: procedure_params[:involves_deceased]) if procedure_params[:deletedAccusseds] != nil if procedure_params[:deletedAccusseds].length() < @procedure.person_in_procedures.where(role: 0).length() + procedure_params[:accuseds].length() procedure_params[:deletedAccusseds].each do |accussed| personInProcedure = PersonInProcedure.find(accussed[:id]) personInProcedure.destroy! end else @procedure.errors.add(:person_in_procedure, "se necesita al menos un imputado") format.json { render json: @procedure.errors, status: :unprocessable_entity } return end end if procedure_params[:deletedVictims] != nil procedure_params[:deletedVictims].each do |victim| personInProcedure = PersonInProcedure.find(victim[:id]) personInProcedure.destroy! end end if procedure_params[:deletedWitnesses] != nil procedure_params[:deletedWitnesses].each do |witness| personInProcedure = PersonInProcedure.find(witness[:id]) personInProcedure.destroy! end end if procedure_params[:deleted_photos] != nil procedure_params[:deleted_photos].each do |photo| photoInProcedure = Photo.find(photo) photoInProcedure.destroy! end end if procedure_params[:deleted_videos] != nil procedure_params[:deleted_videos].each do |video| videoInProcedure = Video.find(video) videoInProcedure.destroy! end end if procedure_params[:deleted_documents] != nil procedure_params[:deleted_documents].each do |doc| docInProcedure = Document.find(doc) docInProcedure.destroy! end end if procedure_params[:photos] != nil procedure_params[:photos].each_with_index do |photo,i| @photo = Photo.new(description: procedure_params[:photo_descriptions][i], procedure: @procedure) @photo.photo.attach(photo) @photo.save! end end if procedure_params[:videos] != nil procedure_params[:videos].each_with_index do |video,i| @video = Video.new(description: procedure_params[:video_descriptions][i], procedure: @procedure) @video.video.attach(video) @video.save! end end if procedure_params[:documents] != nil procedure_params[:documents].each_with_index do |document,i| @document = Document.new(description: procedure_params[:document_descriptions][i],name: procedure_params[:document_names][i], procedure: @procedure) @document.document.attach(document) @document.save! end end @procedure.taggings.destroy_all procedure_params[:tag_ids][1..procedure_params[:tag_ids].size].each do |tag| @tag = Tagging.new(tag: Tag.find_by_name(tag), procedure: @procedure) @tag.save end #destruimos todos los crimenes, para asi crearlos denuevo y no tener problemas @procedure.crime_in_accuseds.destroy_all #si hay imputados nuevos if procedure_params[:accuseds] procedure_params[:accuseds].each do |accused| #los creamos @criminal = Person.new(name: accused[:name], rut: accused[:rut]) if @criminal.save! #lo agregamos al procedimiento @criminal_in_procedure = PersonInProcedure.new(role: 0, person: @criminal, procedure: @procedure, state: 0) @criminal_in_procedure.save @criminal_alias = AliasAccused.new(alias: accused[:alias], person: @criminal) @criminal_alias.save #si hay crimenes nuevos if procedure_params[:crimes] procedure_params[:crimes].each do |crime| #se los agregamos al acusado @crime_in_accused = CrimeInAccused.new(preponderant: false, crime: Crime.find_by_name(crime), person: @criminal, procedure: @procedure) @crime_in_accused.save end end #le agregamos el delito preponderante al acusado @preponderan_crime_in_accused = CrimeInAccused.new(preponderant: true, crime: Crime.find_by_name(procedure_params[:preponderant_crime]), person: @criminal, procedure: @procedure) @preponderan_crime_in_accused.save end end end #si ya teniamos imputados if @procedure.person_in_procedures.where(role: 0) @procedure.person_in_procedures.where(role: 0).each do |criminal| #les agregamos el delito preponderante @preponderan_crime_in_accused = CrimeInAccused.new(preponderant: true, crime: Crime.find_by_name(procedure_params[:preponderant_crime]), person: criminal.person, procedure: @procedure) @preponderan_crime_in_accused.save #si hay delitos nuevos if procedure_params[:crimes] #le agregamos los delitos nuevos a los imputados existentes procedure_params[:crimes].each do |crime| @crime_in_accused = CrimeInAccused.new(preponderant: false, crime: Crime.find_by_name(crime), person: criminal.person, procedure: @procedure) @crime_in_accused.save end end end end if procedure_params[:victims] procedure_params[:victims].each do |victim| @victim = Person.new(name: victim[:name], rut: victim[:rut], deceased: victim[:deceased], contact: victim[:contact] ) if @victim.save! @victim_in_procedure = PersonInProcedure.new(role: 2, person: @victim, procedure: @procedure, witness_declaration: victim[:story]) @victim_in_procedure.save end end end if procedure_params[:witness] procedure_params[:witness].each do |witness| @witness = Person.new(name: witness[:name], rut: witness[:rut], contact: witness[:contact] ) if @witness.save! @witness_in_procedure = PersonInProcedure.new(role: 1, person: @witness, procedure: @procedure, witness_declaration: witness[:story]) @witness_in_procedure.save end end end #mandar las notificaciones correspondientes if @procedure.state == "Open" #si el usuario actual es fiscal, mandar una notificacion de creacion al policia, sino mandarle al fiscal if current_user.prosecutor.present? @procedure.police_unit_in_charge.users.each { |police_user| Notification.create(user: police_user, notification_type: 0, reference_id: @procedure.id, seen: false) } elsif current_user.police_unit.present? prosecutors = Prosecutor.not_deleted.where(local_prosecution_id: @procedure.local_prosecution_in_charge.id) prosecutors.each { |pros| Notification.create(user: pros.user, notification_type: 0, reference_id: @procedure.id, seen: false) } end end format.html { redirect_to @procedure, notice: 'Procedimiento ha sido actualizado con éxito.' } format.json { render :show, status: :ok, location: @procedure } else format.json { render json: @procedure.errors, status: :unprocessable_entity } end end elsif params[:petition] == "change_state" respond_to do |format| $aux = @procedure.state if @procedure.update(state: params[:state]) #If procedure was closed, notify the police unit if @procedure.state == "Close" && $aux == "Open" police_unit_id = @procedure.police_unit_in_charge.id police_unit_users = User.not_deleted.where(police_unit_id: police_unit_id) police_unit_users.each { |user| Notification.create(user_id: user.id, notification_type: 1, reference_id: @procedure.id, seen: false) } #Si el procedimiento pasa a estado borrador (se esta solicitando informacion) else #Crear mensaje con el contenido del text area del modal @message = Message.new(user_id: current_user.id, procedure_id: @procedure.id, content: params[:message]) if @message.content.strip != "" @message.save end if @procedure.creator != current_user @procedure.police_unit_in_charge.users.each { |user| Notification.create(user_id: user.id, notification_type: 2, reference_id: @procedure.id, seen: false) } end end format.html { redirect_to procedures_path, notice: 'Procedimiento ha sido actualizado con éxito.' } format.json { render :show, status: :ok, location: @procedure } else format.json { render json: @procedure.errors, status: :unprocessable_entity } end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @procedure.update(procedure_params)\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n end\n end\n end", "def update\n @procedure = Procedure.find(params[:id])\n @options = Option.new\n @types =...
[ "0.71203756", "0.6445126", "0.6178145", "0.61032337", "0.60540265", "0.60316867", "0.5933768", "0.59329295", "0.5920824", "0.58815384", "0.58682835", "0.58248216", "0.58048916", "0.5791856", "0.57559204", "0.57352924", "0.57352924", "0.57272714", "0.5699198", "0.56599414", "0...
0.5274123
69
DELETE /procedures/1 DELETE /procedures/1.json
def destroy @procedure.destroy respond_to do |format| format.html { redirect_to procedures_url, notice: 'Procedimiento ha sido eliminado con éxito.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @procedure.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @procedure = Procedure.find(params[:id])\n @procedure.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/procedures\" }\n format.xml { head :...
[ "0.71648514", "0.6946582", "0.6905413", "0.66724515", "0.66357803", "0.6536717", "0.65070456", "0.6495447", "0.6474534", "0.64603686", "0.6454383", "0.6355719", "0.63376004", "0.6315889", "0.6264774", "0.6262492", "0.62152237", "0.61697316", "0.61622554", "0.6155662", "0.6153...
0.68802035
3
Use callbacks to share common setup or constraints between actions.
def set_procedure @procedure = Procedure.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
GET /projetos GET /projetos.json
def index @projetos = Projeto.accessible_by(current_ability).order('created_at DESC') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @projetos = Projeto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projetos }\n end\n end", "def show\n \n @projetos = Projeto.all\n \n end", "def index\n @projetos = Projeto.all\n end", "def index\n @projetos = Projeto.a...
[ "0.7755959", "0.7210779", "0.7150677", "0.7150677", "0.71394736", "0.6997981", "0.6973732", "0.6936124", "0.6931593", "0.6912539", "0.68707955", "0.6835493", "0.681063", "0.6809929", "0.6803478", "0.6802129", "0.67864394", "0.67864394", "0.67864394", "0.67864394", "0.67864394...
0.0
-1
GET /projetos/1 GET /projetos/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @projetos = Projeto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projetos }\n end\n end", "def show\n \n @projetos = Projeto.all\n \n end", "def index\n @projetos = Projeto.all\n end", "def index\n @projetos = Projeto.a...
[ "0.7665047", "0.71193683", "0.70544946", "0.70544946", "0.7035905", "0.6999275", "0.6980091", "0.69235367", "0.6900078", "0.6898801", "0.6893538", "0.6886277", "0.6846206", "0.6834716", "0.68269885", "0.68269885", "0.68269885", "0.68269885", "0.68269885", "0.68269885", "0.682...
0.0
-1
POST /projetos POST /projetos.json
def create @projeto = Projeto.new(projeto_params) respond_to do |format| if @projeto.save flash[:success] = @@msgs format.html { redirect_to @projeto, notice: @@msgs } format.json { render :show, status: :created, location: @projeto } else flash[:danger] = @@msge format.html { render :new } format.json { render json: @projeto.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @projeto = Projeto.new(params[:projeto])\n @projeto.usuario = current_usuario\n\n respond_to do |format|\n if @projeto.save\n format.html { redirect_to @projeto, notice: 'Projeto was successfully created.' }\n format.json { render json: @projeto, status: :created, location:...
[ "0.74662536", "0.7367792", "0.72404784", "0.7181806", "0.7120532", "0.7057297", "0.70012474", "0.6977039", "0.6956628", "0.69551855", "0.6951154", "0.689565", "0.6763483", "0.6743231", "0.67369705", "0.6734531", "0.6734531", "0.6734531", "0.6734531", "0.6720741", "0.6655952",...
0.7000703
7
PATCH/PUT /projetos/1 PATCH/PUT /projetos/1.json
def update respond_to do |format| if @projeto.update(projeto_params) flash[:success] = @@msgs format.html { redirect_to @projeto, notice: @@msgs } format.json { render :show, status: :ok, location: @projeto } else flash[:danger] = @@msge format.html { render :edit } format.json { render json: @projeto.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @projeto = Projeto.find(params[:id])\n\n respond_to do |format|\n if @projeto.update_attributes(params[:projeto])\n format.html { redirect_to @projeto, notice: 'Projeto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ac...
[ "0.70798904", "0.703509", "0.685305", "0.67047", "0.6671396", "0.6603742", "0.65753555", "0.6571406", "0.6536701", "0.6519937", "0.65121806", "0.6456487", "0.641822", "0.63953286", "0.6342533", "0.6334362", "0.63297814", "0.63150567", "0.6279236", "0.62690955", "0.62596184", ...
0.6511085
11
DELETE /projetos/1 DELETE /projetos/1.json
def destroy if @projeto.destroy flash[:success] = @@msgs else flash[:danger] = @@msge end respond_to do |format| format.html { redirect_to projetos_url, notice: @@msgs } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @projeto = Projeto.find(params[:id])\n @projeto.destroy\n\n respond_to do |format|\n format.html { redirect_to projetos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @projeto.destroy\n respond_to do |format|\n format.html { redirect_to proje...
[ "0.7912271", "0.7896868", "0.76828504", "0.76585937", "0.7652262", "0.757353", "0.7556995", "0.75497425", "0.75180286", "0.7469653", "0.74605656", "0.7458692", "0.745469", "0.7440776", "0.74129784", "0.7377082", "0.7372995", "0.7356703", "0.7326029", "0.7319453", "0.7285888",...
0.71400845
78
Use callbacks to share common setup or constraints between actions.
def set_projeto @projeto = Projeto.accessible_by(current_ability).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 projeto_params params.require(:projeto).permit(:departamento_id, :local, :metodo, :custo, :data_inicial, :data_final, :objetivo, :nome, :resumo, :status, :publicado, :user_id, {:user_ids => []} ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def authorize_user if !user_signed_in? || !current_user.admin? raise ActionController::RoutingError.new("Not Found") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a trusted parameter "white list" through.
def car_params params.require(:car).permit(:name, :description) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.638045...
0.0
-1
initializes with a nervous mood
def initialize(name, owner) @name = name @owner = owner @mood = "nervous" @@all << self @owner.dogs << self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(name, mood=\"nervous\")\n @name = name\n @mood = mood\n end", "def initialize(name, mood=\"nervous\")\n @name = name\n @mood = mood\n end", "def initialize(name, mood = \"nervous\")\n @name=name\n @mood = mood \n end", "def initialize(name, mood = \"nervous\")\n @name =...
[ "0.7180146", "0.7180146", "0.7125503", "0.7063701", "0.7063701", "0.7063701", "0.697618", "0.69642234", "0.69642234", "0.69642234", "0.69101995", "0.66320884", "0.6576283", "0.617197", "0.6086757", "0.60819185", "0.60811454", "0.59800637", "0.59403425", "0.5930632", "0.590533...
0.51853275
86
GET /users GET /users.json
def index unless user_signed_in? flash[:notice]= "You must be signed in to see other users" redirect_to root_path end @users = User.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def users(args = {})\n get(\"/users.json\",args)\n end", "def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end", "def GetUsers params = {}\n\n para...
[ "0.82109934", "0.7873764", "0.7860689", "0.78108346", "0.78067017", "0.7678852", "0.76586664", "0.76318866", "0.7582366", "0.75291824", "0.7487637", "0.74485743", "0.7439024", "0.7437192", "0.7427442", "0.73978853", "0.73978853", "0.73978853", "0.73978853", "0.7377353", "0.73...
0.0
-1
GET /users/1 GET /users/1.json
def show unless @user==User.find(params[:id]) flash[:notice]= "You can only see your own profile." redirect_to root_path end @user=User.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ...
[ "0.81046426", "0.7703556", "0.77011716", "0.76262826", "0.7582106", "0.74818", "0.7461394", "0.7446168", "0.730656", "0.7300699", "0.72902125", "0.72781444", "0.72358584", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.722...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_user @user = current_user 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 user_params params.require(:user).permit(:name, :email, :password) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Creates a new response.
def initialize(header, body, code) @header = header @body = body @code = code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_response(request)\n response = Response.new\n end", "def response_factory(data)\n\t\t\t\t\t\treturn Response.new(data)\n\t\t\t\t\tend", "def create_response(request, http_response, body = nil)\n HttpOperationResponse.new(request, http_response, body)\n end", "def response(argum...
[ "0.80498314", "0.7282625", "0.7129241", "0.7067617", "0.67621446", "0.6731786", "0.67310524", "0.67046076", "0.67041206", "0.6701308", "0.66116863", "0.66003984", "0.6586602", "0.6572353", "0.6538835", "0.6517463", "0.6514374", "0.6458323", "0.64482534", "0.6439314", "0.64392...
0.0
-1
Returns the body as Ruby Hash.
def to_h JSON.parse(@body, symbolize_names: true) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_hash\n body.to_hash\n end", "def to_body\n to_hash\n end", "def to_body\n to_hash\n end", "def to_body\n to_hash\n end", "def to_body\n to_hash\n end", "def to_body\n to_hash\n end", "def to_body\n to_hash\n end", "def to_body\n to_h...
[ "0.84918356", "0.7862615", "0.7861887", "0.7861887", "0.7861887", "0.7861887", "0.7861887", "0.7861887", "0.7861887", "0.7861887", "0.7861887", "0.7861887", "0.7861887", "0.7861887", "0.7861887", "0.7861887", "0.7861887", "0.7861887", "0.7861887", "0.7861887", "0.7861887", ...
0.0
-1
Returns the body as String.
def to_s @body.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n body.to_s\n end", "def to_s\n @body\n end", "def to_s\n body\n end", "def to_s\n @body\n end", "def to_s\n @body\n end", "def body\n if @parsed_body\n parsed_body.to_s\n else\n @body\n end\n end", "def to_s\n body\n end", "def...
[ "0.8695328", "0.85691285", "0.8489503", "0.84837383", "0.84837383", "0.82008815", "0.81878483", "0.8039237", "0.77034086", "0.76867884", "0.76867884", "0.76867884", "0.76867884", "0.76742005", "0.7669744", "0.76410764", "0.7593768", "0.75935155", "0.7587039", "0.75865614", "0...
0.8647939
1
POST /users POST /users.json
def create @user = User.new(user_params) @user.build_profile if @user.save sign_in @user Notifier.welcome(@user).deliver flash[:success] = 'Thanks for signing up!' redirect_to @user else render 'new' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end", "def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end", "def post b...
[ "0.77179813", "0.75206673", "0.73831296", "0.72405374", "0.719841", "0.7140812", "0.71038526", "0.7058827", "0.7041636", "0.70236504", "0.7003128", "0.70021695", "0.70021695", "0.70021695", "0.69936967", "0.6990463", "0.6980393", "0.6979075", "0.69788617", "0.69788617", "0.69...
0.0
-1
GET /users GET /users.json
def index @users = User.paginate(page: params[:page]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def users(args = {})\n get(\"/users.json\",args)\n end", "def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end", "def GetUsers params = {}\n\n para...
[ "0.82109934", "0.7873764", "0.7860689", "0.78108346", "0.78067017", "0.7678852", "0.76586664", "0.76318866", "0.7582366", "0.75291824", "0.7487637", "0.74485743", "0.7439024", "0.7437192", "0.7427442", "0.73978853", "0.73978853", "0.73978853", "0.73978853", "0.7377353", "0.73...
0.0
-1
PATCH/PUT /users/1 PATCH/PUT /users/1.json
def update @user = User.find(params[:id]) respond_to do |format| if @user.update_attributes(user_params) format.html { flash[:success] = "Profile updated" } #format.json { head :no_content } redirect_to @user else format.html { render 'edit' } format.json { render json: @user.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end", "def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end", "def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end", "de...
[ "0.7225568", "0.7129473", "0.70036036", "0.6903525", "0.6821961", "0.68157715", "0.6708618", "0.66936064", "0.66810983", "0.6673763", "0.6672601", "0.6664346", "0.6664346", "0.6659468", "0.6659468", "0.6654875", "0.66486204", "0.66436917", "0.6641295", "0.6635214", "0.6618464...
0.0
-1
DELETE /users/1 DELETE /users/1.json
def delete @user = User.find(params[:id]) respond_to do |format| format.html { redirect_to action: 'new', status: 303 } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end", "def delete\n render json: User.delete(params[\"id\"])\n end", "def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end", "def delete\n render json: Users.delete(params[\"id\...
[ "0.78750724", "0.77518034", "0.7713981", "0.7610077", "0.747295", "0.74073994", "0.74073994", "0.7369968", "0.7346072", "0.7340465", "0.7328618", "0.7309635", "0.73095363", "0.7306841", "0.7297868", "0.72917855", "0.7291585", "0.7289111", "0.7284347", "0.7250935", "0.7250935"...
0.0
-1
DELETE /users/1 DELETE /users/1.json
def destroy User.find(params[:id]).destroy flash[:success] = "User deleted." redirect_to users_url end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end", "def delete\n render json: User.delete(params[\"id\"])\n end", "def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end", "def delete\n render json: Users.delete(params[\"id\...
[ "0.78750724", "0.77518034", "0.7713981", "0.7610077", "0.747295", "0.74073994", "0.74073994", "0.7369968", "0.7346072", "0.7340465", "0.7328618", "0.7309635", "0.73095363", "0.7306841", "0.7297868", "0.72917855", "0.7291585", "0.7289111", "0.7284347", "0.7250935", "0.7250935"...
0.0
-1
GET /users/1 GET /users/1.json
def show @user = User.find(params[:id]) # @playlist = current_user.playlists.build redirect_to_good_slug(@user) and return if bad_slug?(@user) # @playlists = @user.playlists.paginate(page: params[:page]) @groks = @user.groks.paginate(page: params[:page]) # @user.favs end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ...
[ "0.81046426", "0.7703556", "0.77011716", "0.76262826", "0.7582106", "0.74818", "0.7461394", "0.7446168", "0.730656", "0.7300699", "0.72902125", "0.72781444", "0.72358584", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.722...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_user @user = User.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.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 user_params params.require(:user).permit(:name, :first_name, :last_name, :email, :password, :password_confirmation, :salt, :encrypted_password, profile_attributes: [:id, :city, :state, :website]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
before_filter :set_current_user def set_current_user binding.pry User.current = current_user end
def index serialized_paths = ActiveModel::ArraySerializer.new(MODEL.all, each_serializer: PathSerializer).serializable_array serialized = ActiveModel::ArraySerializer.new(Item.all, each_serializer: ItemSerializer).serializable_array user_paths = ActiveModel::ArraySerializer.new(UserPath.all, each_serializer: UserPathSerializer).serializable_array render json: { paths: serialized_paths, items: serialized, user_paths: user_paths } # , meta: { current_user: current_user } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_current_user\n if logged_in?\n @current_user = current_user\n end\n end", "def set_current_user\n User.current = current_user\n end", "def set_current_user\n @user = current_user\n end", "def set_current_user\n @user = current_user\n end", "def set_current_user\n Use...
[ "0.80238974", "0.79611784", "0.7885648", "0.7885648", "0.7876195", "0.78582555", "0.78463835", "0.78387994", "0.7817579", "0.77648425", "0.77432", "0.77432", "0.77432", "0.77432", "0.7725944", "0.77168924", "0.76982564", "0.7696088", "0.7694775", "0.7652443", "0.76371366", ...
0.0
-1
updates tag string cache
def cache_tags self[:tag_s] = self.tags.collect{|tag| tag.pattern}.reject{|p| p.starts_with?('wait') }.sort.join(' ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cache_tag_list\n set_cached_tag_list\n save\n end", "def update_tag_file\n make_cache_dir\n begin\n tag_array = read_tag_file(@tag_file)\n yield(tag_array)\n write_tag_file(tag_array)\n end\n end", "def store\n @by_cache.each{|cache, tags| cache[:tags] = t...
[ "0.716618", "0.6731208", "0.6596318", "0.6567877", "0.65493464", "0.6498991", "0.62206054", "0.62206054", "0.6215541", "0.6185727", "0.6176137", "0.61690265", "0.61624104", "0.6145499", "0.6136719", "0.6076733", "0.60397196", "0.58448696", "0.58448696", "0.582949", "0.5765647...
0.6689888
3
override tag_s accessor to set self.tags from given string where input is just tags, a la "machine challenges good bad"
def tag_s=(text) text ||= "" # coerce nil values to empty strings # standardize white-space and strip out the octothorpe text = text.strip.gsub(/#/, '') # dont use strip! will return nil if not modified new_tags = [] Tag.find(:all).each do |t| if text[/#{t.pattern}/i] new_tags << t end end self.tags = new_tags.uniq.compact # exclude any duplicate and nil values self.score = self.tags.inject(0) { |sum, t| sum+t.score } self.cache_tags # cache tags string end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tags=(tag_string)\n # tag_array = tag_string.split(/,\\s*/)\n # story.add_tags(tag_array)\n story.set_tag_string(tag_string)\n end", "def tags!(str)\n str.strip!\n tags = str.split(\",\").map { |tag|\n self.tags.find_or_create_by_value(tag.strip.downcase)\n }\n self.tags << tags\n ...
[ "0.7514243", "0.71550465", "0.71046567", "0.7040175", "0.70397997", "0.7021614", "0.70192045", "0.6996078", "0.69692415", "0.6927975", "0.6927975", "0.68893254", "0.6795511", "0.6760451", "0.6732776", "0.6692041", "0.6654514", "0.6650355", "0.6649944", "0.6649065", "0.6642582...
0.7154296
3
Subsititute text for reports that have none
def display_text return self.text unless self.text.blank? [wait_time ? "#{wait_time} minute wait time" : nil, rating ? "rating #{rating}" : nil, polling_place ? "polling place: #{polling_place.name}" : nil].compact.join(', ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def text\n @text || @report\n end", "def nothing_text\n nil\n end", "def text_only\n @text_only = @text.gsub(@@PRIREG, '')\n #.gsub(@@CONREG, '').gsub(@@PROREG, '')\n end", "def test_no_text_samples\n no_text_samples = [\"go.mod\", \"go.sum\"]\n Samples.each do |sample|\n if sam...
[ "0.6474945", "0.64028114", "0.59267384", "0.59255177", "0.5915293", "0.58711326", "0.5841709", "0.5841709", "0.5841709", "0.5781059", "0.5755428", "0.5732838", "0.5721059", "0.5707525", "0.57028747", "0.5688036", "0.5683634", "0.5667491", "0.5663682", "0.56600434", "0.5655464...
0.5163468
98
Detect and geocode any location information present in the report text
def detect_location if self.text LOCATION_PATTERNS.find { |p| self.text[p] } self.location = Location.geocode($1) if $1 self.zip = location.postal_code if !self.zip && (self.location && location.postal_code) end if !self.location && self.zip self.location = Location.geocode(self.zip) end self.location = self.reporter.location if !self.location && self.reporter && self.reporter.location ll, self.location_accuracy = self.latlon.split(/:/) if self.latlon true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_location(str)\n u=URI.encode(\"http://maps.google.com/maps/api/geocode/xml?sensor=false&address=#{str}\")\n loc=(Hpricot.XML(open(u)))/'//location'\n h={} \n h['lat']=(loc/:lat).inner_text\n h['lng']=(loc/:lng).inner_text\n h\n end", "def test_location_detection\n # Google geocoder ...
[ "0.64249235", "0.636456", "0.6233864", "0.6180585", "0.6166833", "0.61370474", "0.59910446", "0.596455", "0.59637463", "0.5858849", "0.57827604", "0.577601", "0.571293", "0.57094467", "0.56417775", "0.5622916", "0.55897534", "0.5581972", "0.55818427", "0.557348", "0.5544919",...
0.7488999
1
append tag_string to report text if supplied (iphone, android)
def append_tags self.text += (" "+self.tag_string) if !self.tag_string.blank? true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def see_tag(text); end", "def add_string(_tag, _val)\n raise NotImplementedError\n end", "def note_tag(text); end", "def tag(string); end", "def abstract_tag(text); end", "def tag_text=(value)\n self.tag=(value)\n end", "def api_tag(text); end", "def return_tag(text); end", "def append_...
[ "0.6162789", "0.59935844", "0.5926792", "0.5882301", "0.583451", "0.57093275", "0.56849265", "0.56290036", "0.5609136", "0.5569981", "0.5550646", "0.55478644", "0.5528541", "0.55203676", "0.55201995", "0.5513261", "0.5477375", "0.5472482", "0.54571325", "0.54562527", "0.54432...
0.669592
1
What tags are associated with this report? Find them and store for easy reference later
def assign_tags if self.text self.tag_s = self.text.scan(/\s+\#\S+/).join(' ') save end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tags() ; info[:tags] ; end", "def tags() ; info[:tags] ; end", "def tags\n data[:tags]\n end", "def tags\n data[:tags]\n end", "def tags\n data[:tags]\n end", "def tags\n data[:tags]\n end", "def tags\n dat...
[ "0.7527412", "0.7527412", "0.7263756", "0.7263756", "0.7263756", "0.7263756", "0.7263756", "0.7153606", "0.7124647", "0.7079581", "0.7079581", "0.7079581", "0.7079581", "0.7079581", "0.6832683", "0.68256915", "0.6784533", "0.67660135", "0.6737665", "0.6703148", "0.66972995", ...
0.0
-1
What location filters apply to this report? US, MD, etc?
def assign_filters if self.location_id && self.location.filter_list values = self.location.filter_list.split(',').map { |f| "(#{f},#{self.id})" }.join(',') self.connection.execute("INSERT DELAYED INTO report_filters (filter_id,report_id) VALUES #{values}") if !values.blank? end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index \n @page = params.fetch(:page, 0).to_i - 1\n @locations = \n case params[:filter_by_region]\n when \"england\"\n Location.where(\"area_code LIKE 'E%' \")\n when \"scotland\"\n Location.where(\"area_code LIKE 'S%' \")\n when \"wales\"\n Location.where(\"are...
[ "0.6615434", "0.6361893", "0.6272898", "0.62468433", "0.6195903", "0.6128753", "0.6037819", "0.59964734", "0.59734243", "0.5958469", "0.5867461", "0.5854296", "0.5816783", "0.5811774", "0.5799572", "0.57848537", "0.5780321", "0.5777612", "0.5771566", "0.5754402", "0.57297873"...
0.0
-1
def test_that_ship_can_be_placed_on_cell c = Cell.new ship = c.content[1][2].take(Ship.new(2,"Bot")) assert_equal("", c.take(ship).content) end
def test_that_cell_status_changes_when_hit c = Cell.new assert_equal("missed", c.if_hit()) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_cell_then_place(ship, attempt_x, attempt_y, starts_at)\n alpha, numb = starts_at.split(\"\")\n coordinates = \"#{get_alpha(get_index(alpha) + attempt_y)}#{numb.to_i + attempt_x}\"\n cells[coordinates].accept ship\n end", "def test_it_can_return_when_human_wins\n board = Board.new\n cruis...
[ "0.67413217", "0.65839976", "0.61723715", "0.6138236", "0.6100978", "0.6062735", "0.6048128", "0.6046373", "0.5951299", "0.58557755", "0.583321", "0.5826784", "0.580248", "0.5783715", "0.57801574", "0.57786584", "0.57476443", "0.57392013", "0.5734896", "0.57188714", "0.571760...
0.5568397
39