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
Lazy read the contact information
def contact @contact ||= get_contact(@data_object.user_contact) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_contact_info\n lambda {\n user.vet360_contact_info\n }\n end", "def contact\n response[\"contact\"]\n end", "def display_one_contact\n contact = retrieve_contact_by_email\n end", "def get_contact\n if self.contact_id\n return self.contact\n end...
[ "0.70533556", "0.69931376", "0.69071925", "0.68375194", "0.6806678", "0.680625", "0.680625", "0.680625", "0.680625", "0.680625", "0.66355497", "0.65883356", "0.65800035", "0.6558589", "0.6556369", "0.65496105", "0.6538455", "0.65359867", "0.64843047", "0.64710087", "0.6471008...
0.69959927
1
Return a new plaintext password
def create_new_password pass = generate_password set_password(pass) pass end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def password=(new_password); end", "def generate_new_password\n chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'\n password = ''\n 10.times { password << chars[rand(chars.size)] }\n self.update_attributes(:encrypted_password => User.encrypt(password, self.salt))\n UserMailer.deliv...
[ "0.77092576", "0.76308435", "0.7462875", "0.7455222", "0.7408781", "0.7340565", "0.7338143", "0.733769", "0.7334692", "0.7314898", "0.72965056", "0.727997", "0.72690785", "0.7247565", "0.7245508", "0.7221308", "0.72191834", "0.7215993", "0.72065794", "0.71724206", "0.71665186...
0.7602719
2
Create a new password for this user, and send notification to the user
def send_new_password(template) pass = create_new_password set_password(pass) save mailer = Mailer.new user_name = @data_object.user_acc_name if user_name.nil? || user_name.empty? user_name = contact.con_email end values = { "user_name" => user_name, "password" => pass } mailer.send_from_template(contact.con_email, "Your DION Registration Information", values, template) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n if user\n user.regenerate_verification_token\n MinimalistAuthenticationMailer.update_password(user).deliver_now\n end\n # always display notice even if the user was not found to prevent leaking user emails\n redirect_to new_session_path, notice: \"Password reset instructions were...
[ "0.7857482", "0.7721347", "0.76196975", "0.73275954", "0.73120856", "0.7282584", "0.72730744", "0.7263136", "0.7245885", "0.7230884", "0.7216805", "0.7216168", "0.719854", "0.71595395", "0.714006", "0.7000592", "0.6999244", "0.6983723", "0.69824904", "0.6931601", "0.6919888",...
0.762455
2
encrypt the given password make it ours
def set_password(pass) self.user_password = User.crypt(pass) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encrypt(password)\n self.class.encrypt(password, Time.now.to_s)\n end", "def encrypt_password(password)\n self.class.secure_digest([password, password_salt])\n end", "def encrypt_password\n self.salt = make_salt if new_record?\n\t self.encrypted_password = encrypt(password)\n end", "def en...
[ "0.8263327", "0.8260091", "0.81787765", "0.81547225", "0.81299", "0.8117264", "0.8100615", "0.80571926", "0.80541736", "0.8046734", "0.80061984", "0.8003397", "0.7999736", "0.7999736", "0.7999736", "0.7958334", "0.7956192", "0.79560286", "0.7955771", "0.7955771", "0.7955771",...
0.0
-1
put this user's stuff into a hash
def add_to_hash(hash) super contact.add_to_hash(hash) hash['user_over_13'] = @user_over_13 || !@new_user hash['last_logged_in'] = fmt_date_time(@data_object.user_last_logged_in) hash['first_logged_in'] = fmt_date_time(@data_object.user_first_logged_in) # aff_opts = Affiliate.options hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_entourage_user_hashes\n User.find_each do |user|\n email_hashes[hash(user.email)] = user.id\n phone_hashes[hash(user.phone)] = user.id\n end\n end", "def as_hash(add_ins = {})\n hash = {\n :id => self.id,\n :name => self.name,\n :user_id => self.user_id,...
[ "0.6760082", "0.67248976", "0.6709168", "0.66285336", "0.66162926", "0.65451276", "0.65352595", "0.64493", "0.63894325", "0.63856786", "0.6376628", "0.6345046", "0.6326804", "0.63162816", "0.63107544", "0.63063264", "0.62908846", "0.6230938", "0.6158729", "0.61488956", "0.614...
0.6772971
0
Return any validation errors from this user or its contact. The contact validation is somewhat stricter if we have no email address, or if we're shipping materials
def error_list(strict=false) errors = [] if @new_user && !@user_over_13 errors << "Users must be 13 or older to register on this system" return errors end if @data_object.user_affiliate == Affiliate::NONE.to_s errors << "Please specify an affiliate" end errors.concat contact.error_list(strict || contact.con_email.empty?) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def contact_errors\n error \"name\"\n error \"age\"\n error \"homepage\"\n end", "def error_list(strict = false)\n c = @data_object\n res = []\n\n res << \"Missing name\" if c.con_first_name.empty? || c.con_last_name.empty?\n\n if strict\n if c.con_day_tel.empty? && c.con_eve_t...
[ "0.6965642", "0.6887497", "0.6777876", "0.6694164", "0.66485244", "0.66387296", "0.6576276", "0.64295673", "0.64295673", "0.6422443", "0.6410808", "0.6402918", "0.6378669", "0.6342053", "0.6328821", "0.62971896", "0.6260525", "0.62498796", "0.6238738", "0.62178165", "0.620991...
0.6498926
7
Recover our state from form fields
def from_hash(hash) @data_object.user_acc_name = hash['user_acc_name'] @data_object.user_affiliate = hash['user_affiliate'] @user_over_13 = hash['user_over_13'] contact.from_hash(hash) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fill_out_form(hash)\n self.institution=hash[:institution]\n self.department=hash[:department]\n self.title_role=hash[:title]\n self.email=hash[:email]\n self.instant_messaging=hash[:im]\n self.phone=hash[:phone]\n self.mobile=hash[:mobile]\n self.fax=hash[:fax]\n self.address=hash[:a...
[ "0.5688627", "0.56832045", "0.5652936", "0.56302154", "0.5623749", "0.55907655", "0.5561478", "0.5555948", "0.55494946", "0.5539554", "0.5538534", "0.552025", "0.55131406", "0.54676306", "0.5460865", "0.54600203", "0.5456774", "0.5435379", "0.5429336", "0.5402344", "0.5374459...
0.0
-1
log to the UserHistory table
def log(notes) @uh_log ||= UserHistory.new @uh_log.log(self, notes) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def history\n\t\t@user.show_log\n\tend", "def set_user_history_record\n @user_history_record = UserHistoryRecord.find(params[:id])\n end", "def index\n @user = User.find(current_user.id)\n @history_logs = @user.history_logs\n end", "def history_log (event, options={})\n\n source = options.d...
[ "0.7338501", "0.6987412", "0.67164034", "0.66679794", "0.640545", "0.6390004", "0.63898313", "0.6293106", "0.62419516", "0.61407214", "0.6101616", "0.6068252", "0.5948694", "0.5944313", "0.5932673", "0.59128094", "0.58401424", "0.58326113", "0.5818913", "0.5818301", "0.581830...
0.7131456
1
Save the user object back to the database the database ID
def save @data_object.user_acc_name.downcase! if @data_object.user_acc_name # unless @data_object.existing_record? tmp = User.with_name(@data_object.user_acc_name) if tmp && (!@data_object.existing_record? || tmp.user_id != @data_object.user_id) raise DionException.new("Sorry, but that nickname has been taken") end # tmp = User.with_email(contact.con_email) # if tmp && (!@data_object.existing_record? || tmp.user_id != @data_object.user_id) # raise DionException.new("A user with that e-mail address already exists" + # " #{tmp.user_id}, #{@data_object.user_id}") # end # end # This is tacky, but I can't see an easy way around it. If we fail inserting the # user record because of a duplicate nickname, then we'll have already written # out the contact record. The rollback will delete that out (or reset its field # values), but the in-store copy won't know that. So, we save away the contact # stuff and restore it in case of an exception # $store.transaction do begin # saved_contact = Marshal.dump(contact) # prev_con_id = @data_object.user_contact @data_object.user_contact = contact.save begin super rescue Exception => e # @contact = Marshal.load(saved_contact) # @data_object.user_contact = saved_contact raise end rescue DBI::ProgrammingError => e $stderr.puts e.message $stderr.puts e.backtrace case e.message when /duplicate key into unique index contact_con_email_key/, /duplicate key violates unique constraint "contact_con_email_key"/ raise DionException.new("A user with that e-mail address already exists") when /duplicate key into unique index user_table_user_acc_name_key/ raise DionException.new("Sorry, but that nickname has been taken") else raise end end # end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_user(user)\n contact = find(user.id)\n\n mapper.save(contact, user.attributes)\n end", "def save\n REDIS.set @user.delete(:key), @user.to_json\n @user # NOTE: SET can't fail (http://redis.io/commands/set)\n end", "def store_user_id(user)\n\t\t@id = user\n\tend", "def save\n\t\t\t...
[ "0.7088505", "0.7059781", "0.69057345", "0.68852574", "0.68643546", "0.68430525", "0.6830865", "0.6760203", "0.6734597", "0.6676327", "0.66465086", "0.6643306", "0.66220933", "0.6618445", "0.661582", "0.6587292", "0.65792453", "0.65593433", "0.6557607", "0.6557344", "0.653550...
0.0
-1
Lazy load an affiliate
def affiliate @affiliate || Affiliate.with_id(@data_object.user_affiliate) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def affiliate\n self.affiliate_class && affiliate_id && self.affiliate_class.find(affiliate_id)\n end", "def affiliate_affiliations\n @affiliate_affiliations ||= Affiliation.find_by_uid(uid)\n end", "def affiliation\n affiliations.try(:first)\n end", "def set_affiliate\n @affiliate...
[ "0.7576979", "0.71180224", "0.7006972", "0.6971306", "0.6971306", "0.69453984", "0.6767858", "0.64777255", "0.6450353", "0.643987", "0.62531483", "0.61321", "0.6087326", "0.60826844", "0.60661167", "0.6044205", "0.60323656", "0.60002416", "0.594913", "0.59291613", "0.5860109"...
0.7796084
0
record the fact that this user is registered in an affiliate
def register_affiliate_role Role.set_user_role(@data_object.user_id, user_affiliate, nil, RoleNameTable::REGISTERED, TargetTable::AFFILIATE, user_affiliate) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def affiliate\n @affiliate || Affiliate.with_id(@data_object.user_affiliate)\n end", "def affiliate\n self.affiliate_class && affiliate_id && self.affiliate_class.find(affiliate_id)\n end", "def set_affiliate\n if affiliate.present?\n account.affiliate_id = affiliate.id\n account.affiliate...
[ "0.7254574", "0.6769462", "0.6681267", "0.6371687", "0.6345233", "0.62661225", "0.62661225", "0.61951137", "0.6160961", "0.6010346", "0.59804493", "0.5948432", "0.5932091", "0.5894587", "0.5877874", "0.5870102", "0.5861741", "0.5842778", "0.579431", "0.5734288", "0.57342726",...
0.68785167
1
Affiliate stuff. A user has one primary and any number of secondary affiliates. Is this user associated with the given affiliate?
def associated_with_affiliate?(aff_id) (aff_id == @data_object.user_affiliate) || role_assoc_with_affiliate?(aff_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def affiliate\n self.affiliate_class && affiliate_id && self.affiliate_class.find(affiliate_id)\n end", "def using_affiliate?(account_type)\n affiliate_account_types.include?(account_type.to_s.classify)\n end", "def advised?\n advisor_company_affiliations.with_access.present?\n end", "def affilia...
[ "0.7297416", "0.6931425", "0.68783474", "0.6763197", "0.67038536", "0.6652632", "0.66468024", "0.6244003", "0.61868554", "0.6166042", "0.6155807", "0.6136479", "0.6134123", "0.6115355", "0.61036", "0.60620564", "0.59963477", "0.59873384", "0.59723717", "0.59443974", "0.592568...
0.79458284
0
ratify_each Define Minimum Length of Array
def min_length(min_size=0, options={}, &block) return length_between(min_size, nil, options, &block) rescue Exception => e validation_error("#{e.message}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def min_max_len_ave(arr)\n\treturn [\n\t\tarr.min,s\n\t\tarr.max,\n\t\tarr.length,\n\t\tarr.instance_eval { reduce(:+) / size.to_f },\n\t]\nend", "def / len\n a = []\n each_with_index do |x,i|\n a << [] if i % len == 0\n a.last << x\n end\n a\n end", "def resize\n # TODO\n # if ara...
[ "0.59102505", "0.58927023", "0.5799461", "0.5795999", "0.5677536", "0.5623666", "0.5575646", "0.55704904", "0.5566038", "0.55656797", "0.55345786", "0.5527902", "0.55126476", "0.5507014", "0.5494597", "0.534957", "0.53488004", "0.533566", "0.53210896", "0.53210896", "0.529203...
0.0
-1
min_length Define Maximum Length of Array
def max_length(max_size=0, options={}, &block) return length_between(0, max_size, options, &block) rescue Exception => e validation_error("#{e.message}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def min_length\n MIN_LENGTH\n end", "def min_length\n 0\n end", "def min_length(length)\n valid_for 'string'\n assert_numeric length, minimum: 0\n set minLength: length\n end", "def minimal_length\n if !self.value.blank? && self.minLength\n errors.add(:va...
[ "0.722355", "0.7100344", "0.6917819", "0.67042035", "0.67041725", "0.66592664", "0.6569845", "0.65107334", "0.64275473", "0.6318443", "0.62963575", "0.62939554", "0.6234337", "0.622518", "0.62153006", "0.62153006", "0.611607", "0.6094361", "0.59763426", "0.59726155", "0.59583...
0.59797907
18
max_length Define length range of Array (inclusive)
def length_between(min_size=0, max_size=nil, options={}, &block) parse_options(options) unless @skip == true unless @unwrap_block == true # Minimum Length Validation unless min_size.to_i >= 0 validation_error("min_length must be a number greater than or equal to 0") return end unless @ratifiable_object.size >= min_size.to_i validation_error("length must be #{min_size} or more") return end # Maximum Length Validation unless max_size.nil? unless max_size.to_i >= 0 validation_error("max_size must be a number greater than or equal to 0") return end if @ratifiable_object.size > max_size.to_i validation_error("length must be less than #{max_size.to_i}") return end unless max_size > min_size validation_error("max_size must be greater than min_size") return end end end#unwrap_block instance_eval(&block) if block_given? end#skip rescue Exception => e validation_error("#{e.message}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_length\n MAX_LENGTH\n end", "def maximal_length\n if !self.value.blank? && self.maxLength\n errors.add(:value, 'is too long!') if self.value.length > self.maxLength\n end\n end", "def max_length=(value)\n @max_length = value\n end", "def max_length\n ...
[ "0.73648006", "0.72176576", "0.718311", "0.71804494", "0.7149568", "0.70981675", "0.7013232", "0.7007006", "0.6930828", "0.68461055", "0.671261", "0.66758", "0.66644603", "0.66342545", "0.65949005", "0.65480626", "0.6534915", "0.6534915", "0.6534915", "0.6534915", "0.65334904...
0.0
-1
image is from seed, photo is from cloudinary
def stallion_params params.require(:stallion).permit( :image, :name, :date_of_birth, :category, :breed, :town, :country, :lineage, :description, :colour, :sperm_only, :stabling, :malt_whisky, :shooting, :owner_bed, :photo, :photo_cache) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cl_photo\n if photo?\n photo\n else\n 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSb0kZ2CA6D46RXZVJ3dvJPusC66fBq1uENE8jN3q8golJ73Ayd'\n end\n end", "def uploadimage \n img = Cloudinary::Uploader.upload(params[:image])\n company = Company.find(params[:id])\n ...
[ "0.69599324", "0.67144156", "0.66969705", "0.66554403", "0.6605963", "0.6512298", "0.6512192", "0.6489418", "0.64851373", "0.64850515", "0.6472816", "0.646482", "0.6450065", "0.6433949", "0.6433592", "0.6407638", "0.6407638", "0.63924044", "0.63838", "0.63771135", "0.63771135...
0.0
-1
renvoie le nombre d'erreur qu'il y a dans la grille (lorsque la case est VIDE, ce n'est pas une erreur)
def nbCasesIncorrect nbErr = 0 newStatutVide = StatutVide.new(VIDE) newStatutArbre = StatutArbre.new(ARBRE) @grille.grille.each do | ligne | ligne.each do | cases | ####################################################################################################### # Là on rajoute 1 erreur si le statut visible de la case n'est pas identique a son statut véritable # et seulement si la case n'est pas vide ou qu'il ne s'agisse pas d'un arbre ####################################################################################################### nbErr += 1 if (cases.statutVisible != cases.statut && cases.statutVisible != newStatutVide && cases.statut != newStatutArbre) # case.estValide? à tester end end return nbErr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def donnerErreur()\n return @grilleEnCours.firstDifference(@grilleBase)\n end", "def image_error_num( max ); \"每則日誌最多可貼 #{max} 張圖片\"; end", "def errores_listado\n if self.errores.to_i > 0\n \"<span class=\\\"error b\\\">#{self.errores}</span>\"\n else\n errores\n end\n end", "def veri...
[ "0.7123804", "0.6417306", "0.6304795", "0.6264157", "0.61889726", "0.61495245", "0.6017268", "0.6011007", "0.600217", "0.5980096", "0.5918367", "0.58979625", "0.5816936", "0.58086663", "0.57995933", "0.5683999", "0.5573926", "0.5525628", "0.5445306", "0.54407257", "0.54245913...
0.5900161
11
renvoie un tableau de cases contenant les erreurs qu'il y a dans la grille (lorsque la case est VIDE, ce n'est pas une erreur)
def casesIncorrect newStatutVide = StatutVide.new(VIDE) newStatutArbre = StatutArbre.new(ARBRE) tabCasesErr = Array.new grille=@grille.grille for i in 0..grille.length-1 for j in 0..grille.length-1 tabCasesErr.unshift(grille[i][j]) if (grille[i][j].statutVisible != grille[i][j].statut && grille[i][j].statutVisible != newStatutVide && grille[i][j].statut != newStatutArbre) end end return tabCasesErr.empty? ? 0 : tabCasesErr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nbCasesIncorrect\n nbErr = 0\n newStatutVide = StatutVide.new(VIDE)\n newStatutArbre = StatutArbre.new(ARBRE)\n @grille.grille.each do | ligne |\n ligne.each do | cases |\n #######################################################################################################\n #...
[ "0.7001326", "0.61590487", "0.5765501", "0.5721783", "0.56755805", "0.55608517", "0.54557705", "0.54555565", "0.5453489", "0.544602", "0.53431416", "0.5324971", "0.53057474", "0.52836895", "0.527121", "0.52535266", "0.5220627", "0.51910824", "0.51883185", "0.51841956", "0.517...
0.74725395
0
renvoie la premiere case qui n'est pas a cote d'un arbre, il s'agit donc de gazon
def casePasACoteArbre newStatutVide = StatutVide.new(VIDE) newStatutArbre = StatutArbre.new(ARBRE) grille=@grille.grille for i in 0..grille.length-1 for j in 0..grille.length-1 ok = true if (grille[i][j].statutVisible == newStatutVide) if (i-1 >= 0 && grille[i-1][j].statut == newStatutArbre) || (j-1 >= 0 && grille[i][j-1].statut == newStatutArbre) || (i+1 <= grille.length-1 && grille[i+1][j].statut == newStatutArbre) || (j+1 <= grille.length-1 && grille[i][j+1].statut == newStatutArbre) ok = false end return grille[i][j] if ok end end end return 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def change_AL_to_R par, run\n sor=run['sor']\n eor_m1=run['eor'] - 1\n chars=par['characters']\n sor.upto eor_m1 do |ind|\n chars[ind]['bidiType']='R' if chars[ind]['bidiType']=='AL'\n end\n end", "def swapcase() end", "def swapcase!() end", "def case_q(word,first_letter )\...
[ "0.62324744", "0.59069633", "0.58755964", "0.579245", "0.5790993", "0.57855433", "0.5721393", "0.567231", "0.56437945", "0.55839187", "0.55611086", "0.5538321", "0.55307895", "0.550234", "0.5498333", "0.54914516", "0.54766744", "0.5474721", "0.54518867", "0.5448358", "0.54258...
0.556529
10
before_action :authenticate_admin! GET /smsloans GET /smsloans.json
def index @smsloans = Smsloan.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n #before_action :authenticate_user\n #if current_user.admin?\n @users = User.all\n render json: @users, status: :ok\n #else\n # render json: [], status: :unauthorized\n #end\n end", "def set_smsloan\n @smsloan = Smsloan.find(params[:id])\n end", "def ...
[ "0.6084872", "0.5992685", "0.5950224", "0.59073937", "0.5903932", "0.58968395", "0.58879375", "0.5825045", "0.5772475", "0.576563", "0.5746611", "0.57387006", "0.5721227", "0.56883454", "0.56805146", "0.56682664", "0.5631794", "0.56197107", "0.56016666", "0.5594652", "0.55607...
0.64864254
0
GET /smsloans/1 GET /smsloans/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @smsloans = Smsloan.all\n end", "def smsmark\n http = get_http_connection() \n post_args = { 'ids' => params[:ids], 'name' => @pysmsd_config.app_name, 'password' => @pysmsd_config.app_password }\n request = Net::HTTP::Post.new('/messages/in.json')\n request.set_form_data(post_args)...
[ "0.7013222", "0.6593142", "0.6473549", "0.64258194", "0.6389333", "0.6325678", "0.62421453", "0.62189496", "0.6208025", "0.61795276", "0.6062503", "0.6048953", "0.6048822", "0.60439247", "0.60359514", "0.60359514", "0.6018181", "0.6014988", "0.5998409", "0.59939134", "0.59865...
0.0
-1
POST /smsloans POST /smsloans.json
def create @smsloan = Smsloan.new(smsloan_params) respond_to do |format| if @smsloan.save format.html { redirect_to @smsloan, notice: 'Smsloan was successfully created.' } format.json { render :show, status: :created, location: @smsloan } else format.html { render :new } format.json { render json: @smsloan.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def smsmark\n http = get_http_connection() \n post_args = { 'ids' => params[:ids], 'name' => @pysmsd_config.app_name, 'password' => @pysmsd_config.app_password }\n request = Net::HTTP::Post.new('/messages/in.json')\n request.set_form_data(post_args)\n resp = http.request(request)\n json = JSON...
[ "0.7023869", "0.6639904", "0.64528984", "0.6450997", "0.64273953", "0.63410354", "0.63087326", "0.62536055", "0.6247069", "0.62145275", "0.61807185", "0.6132906", "0.6081743", "0.604135", "0.60120875", "0.6004979", "0.59997016", "0.59874415", "0.597668", "0.5901986", "0.58878...
0.6576313
2
PATCH/PUT /smsloans/1 PATCH/PUT /smsloans/1.json
def update respond_to do |format| if @smsloan.update(smsloan_params) format.html { redirect_to @smsloan, notice: 'Smsloan was successfully updated.' } format.json { render :show, status: :ok, location: @smsloan } else format.html { render :edit } format.json { render json: @smsloan.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @sms_based.update(sms_based_params)\n format.html { redirect_to @sms_based, notice: 'Sms based was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json...
[ "0.6421635", "0.6216744", "0.6213252", "0.59553605", "0.59518427", "0.5942802", "0.5936722", "0.5927721", "0.585977", "0.581588", "0.5805377", "0.5790092", "0.5775165", "0.576854", "0.5754301", "0.5706977", "0.5704834", "0.5699056", "0.56953347", "0.5671421", "0.5667156", "...
0.657055
0
DELETE /smsloans/1 DELETE /smsloans/1.json
def destroy @smsloan.destroy respond_to do |format| format.html { redirect_to smsloans_url, notice: 'Smsloan was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @sms_based.destroy\n respond_to do |format|\n format.html { redirect_to sms_baseds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sms = Sms.find(params[:id])\n @sms.destroy\n\n respond_to do |format|\n format.html { redirect_to(sms_url) }\n ...
[ "0.72519684", "0.7122071", "0.7115706", "0.69583005", "0.6849772", "0.67845243", "0.6767632", "0.6757643", "0.6752234", "0.6733571", "0.6725113", "0.67103755", "0.67067367", "0.67014", "0.66567254", "0.6650135", "0.66413534", "0.66385674", "0.66344535", "0.6616824", "0.660829...
0.73421055
0
Use callbacks to share common setup or constraints between actions.
def set_smsloan @smsloan = Smsloan.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 smsloan_params params.require(:smsloan).permit(:bank, :min_loanamoun, :max_loanamoun, :mobile_friendly_site, :smsloan_payment_note, :smsloan_min_age, :cost_free_loan, :new_borrower_5K, :new_borrower_10K, :no_uc, :skef_member, :bankid, :open_on_saturdays, :weblink) 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
GET /image_groups/1 GET /image_groups/1.json
def show @image_group = ImageGroup.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @image_group } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @groups = current_user.groups\n @groups = @groups.where('name LIKE ?', \"%#{params[:q]}%\") if params[:q].present?\n @groups = current_user.groups_sorted_by_admin_state_and_name(@groups)\n @groups_pictures = Group.group_images_hash_for_groups @groups\n\n respond_to do |format|\n for...
[ "0.7065757", "0.7058672", "0.6788443", "0.67826885", "0.6775769", "0.6639864", "0.6638153", "0.65698034", "0.65435266", "0.65393406", "0.65324646", "0.65324646", "0.65247214", "0.64920074", "0.6470677", "0.6450721", "0.6435345", "0.6422137", "0.64169836", "0.64140195", "0.638...
0.777888
0
GET /image_groups/new GET /image_groups/new.json
def new @image_group = ImageGroup.new @category_id = params[:category_id] puts ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" puts "xxxx" unless !@image_group.id.nil? puts ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" respond_to do |format| format.html # new.html.erb format.json { render json: @image_group } #format.js { render js:"$('#subpage-pane').html('<%= j render :partial=>form %>')" } format.js {} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @group = Group.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group }\n end\n end", "def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group }\n end\n end", ...
[ "0.74592793", "0.743851", "0.743851", "0.743851", "0.743851", "0.743851", "0.743851", "0.743851", "0.743851", "0.7390495", "0.7381791", "0.7370646", "0.7370646", "0.7342192", "0.7331665", "0.7293258", "0.727606", "0.7187047", "0.71770185", "0.7142491", "0.71134156", "0.7095...
0.0
-1
POST /image_groups POST /image_groups.json
def create @image_group = ImageGroup.new(params[:image_group]) puts params[:image_group] puts params[:image_group][:enabled] respond_to do |format| if @image_group.save format.html { redirect_to @image_group, notice: 'Image group was successfully created.' } format.json { render json: @image_group, status: :created, location: @image_group } format.js else format.html { render action: "new" } format.json { render json: @image_group.errors, status: :unprocessable_entity } format.js end end p @image_group.errors.full_messages end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createGroup(groupName, gid)\r\n uri = sprintf(\"/api/v1/group_categories/%d/groups\", gid) \r\n \r\n dbg(\"POST #{uri}\")\r\n dbg(\"name=#{groupName}\")\r\n newGroup = $canvas.post(uri, {'name' => groupName})\r\n dbg(newGroup)\r\n return newGroup\r\nend", "def createGroup(groupName, gid)\r\n uri = sp...
[ "0.7029938", "0.7029938", "0.6919587", "0.6881138", "0.65274304", "0.6508751", "0.6502947", "0.64811885", "0.64801455", "0.6389315", "0.637187", "0.6312449", "0.6305744", "0.6288897", "0.62772024", "0.62731975", "0.6262509", "0.62478626", "0.6238376", "0.62025803", "0.6172038...
0.57885927
98
PUT /image_groups/1 PUT /image_groups/1.json
def update puts params[:image_group] puts params[:image_group][:promoted] p ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" if !params[:images][:removed].blank? puts "removed images" + params[:images][:removed] removedImages = Image.where(" id in (?)", params[:images][:removed].split(',')) #remove the image from a group removedImages.each do |ri| ri.group_id=nil ri.save end end if !params[:images][:added].blank? puts "new added images" + params[:images][:added] addedImages = Image.where(" id in (?)", params[:images][:added].split(',')) #remove the image from a group addedImages.each do |ai| ai.group_id=params[:id] ai.save end end @image_group = ImageGroup.find(params[:id]) if params[:image_group][:cover_image_id].nil? @image_group.errors.add(:nil_cover, "必须指定封面图片才能使该图组生效") return elsif @image_group.images.nil? @image_group.errors.add(:nil_images, "必须指定内容图片才能使该图组生效") return end respond_to do |format| if @image_group.update_attributes(params[:image_group]) format.html { redirect_to @image_group, notice: 'Image group was successfully updated.' } format.json { head :no_content } format.js {} else format.html { render action: "edit" } format.json { render json: @image_group.errors, status: :unprocessable_entity } format.js {} end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def UpdateGroup params = {}\n \n APICall(path: 'groups.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n logger.info \"Put parameters: #{params.to_json}\"\n @group = Group.find(params[:id])\n\n if @group.update_attributes(params[:group])\n head :no_cont...
[ "0.7013699", "0.68939674", "0.667842", "0.6663909", "0.64881104", "0.64502144", "0.64501834", "0.64057434", "0.6402101", "0.63756186", "0.6371995", "0.63506645", "0.6320838", "0.63092995", "0.62939984", "0.62604725", "0.6259761", "0.6257047", "0.62176615", "0.6217387", "0.621...
0.710447
0
DELETE /image_groups/1 DELETE /image_groups/1.json
def destroy @image_group = ImageGroup.find(params[:id]) @image_group.destroy respond_to do |format| format.html { redirect_to image_groups_url } format.json { head :no_content } format.js {} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @image_gallery_group = ImageGalleryGroup.find(params[:id])\n @image_gallery_group.destroy\n\n respond_to do |format|\n format.html { redirect_to( admin_image_gallery_groups_url ) }\n format.xml { head :ok }\n end\n end", "def DeleteGroup id\n \n APICall(path: \...
[ "0.74013877", "0.738562", "0.7370603", "0.7204914", "0.7173223", "0.71466416", "0.71245694", "0.7096107", "0.7073777", "0.7062585", "0.70428175", "0.703515", "0.7033367", "0.70323575", "0.7032046", "0.702627", "0.702627", "0.7019601", "0.7019601", "0.7019601", "0.7019601", ...
0.7752952
0
Determine if this Windows is 64bit or 32bit. Some CDs can have more than one architecture on multiple install images.
def get_arch if defined?(@arch) then return @arch else @arch = nil end search = File.join(@path, '{*/system32,{i386,amd64}}/ntdll.dll') ntdlls = Dir.glob(search, File::FNM_CASEFOLD) if ntdlls.length > 0 machine = %x{pev -c #{ntdlls.first} | grep -i Machine} if $?.success? @arch = '64-bit' if machine =~ /0x8664/ @arch = '32-bit' if machine =~ /14c/ end else search = File.join(@path, 'sources/{setup.exe,winsetup.dll}') setup = Dir.glob(search, File::FNM_CASEFOLD) setup.each do |file| machine = %x{pev -c #{file} | grep -i Machine} if $?.success? @arch = '64-bit' if machine =~ /0x8664/ @arch = '32-bit' if machine =~ /14c/ break end end # end of setup block begin get_xmlinfo if not defined?(@xmlinfo) arches = REXML::XPath.match(@xmlinfo, '/WIM/IMAGE/WINDOWS/ARCH/text()') arch = arches.first if arches.count(arch) == arches.size arch = Integer(arch.to_s) @arch = '64-bit' if arch == 9 @arch = '32-bit' if arch == 0 else @arch = '32/64-bit' unless @arch end rescue Exception => e # puts "error(get_arch): #{e}" end end @arch end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def determine_if_x86_64\n (identify_windows_architecture =~ /64/) == 0\n end", "def windows_64?\n bool = false\n\n if respond_to?(:IsWow64Process, true)\n pbool = FFI::MemoryPointer.new(:int)\n\n # The IsWow64Process function will return false for a 64 bit process,\n # so we ch...
[ "0.8423886", "0.7693869", "0.7633942", "0.75773686", "0.73920864", "0.7210124", "0.69893414", "0.69893414", "0.69698894", "0.6842776", "0.6842776", "0.6797138", "0.67929024", "0.672215", "0.6721104", "0.66576093", "0.66069937", "0.65872866", "0.64548767", "0.64364624", "0.643...
0.6659159
15
Get the build numbers for this Windows, e.g. 5.2.3790.
def get_build if defined?(@major) and defined?(@minor) and defined?(@build) then return @major, @minor, @build else @major, @minor, @build = nil end search = File.join(@path, '{*/system32,{i386,amd64}}/ntdll.dll') ntdlls = Dir.glob(search, File::FNM_CASEFOLD) if ntdlls.length > 0 dumpvers = %x{pev -p #{ntdlls.first}} if $?.success? major, minor, build = dumpvers.split('.') @major, @minor, @build = Integer(major), Integer(minor), Integer(build) end else search = File.join(@path, 'sources/{setup.exe,winsetup.dll}') setup = Dir.glob(search, File::FNM_CASEFOLD) setup.each do |file| dumpvers = %x{pev -p #{file}} if $?.success? major, minor, build = dumpvers.split('.') @major, @minor, @build = Integer(major), Integer(minor), Integer(build) break end end # end of setup block begin get_xmlinfo if not defined?(@xmlinfo) majors = REXML::XPath.match(@xmlinfo, '/WIM/IMAGE/WINDOWS/VERSION/MAJOR/text()') minors = REXML::XPath.match(@xmlinfo, '/WIM/IMAGE/WINDOWS/VERSION/MINOR/text()') builds = REXML::XPath.match(@xmlinfo, '/WIM/IMAGE/WINDOWS/VERSION/BUILD/text()') major = majors.first # The install.wim image will have multiple sub- minor = minors.first # images. Check to make sure each one has the same build = builds.first # version number. if majors.count(major) == majors.size and minors.count(minor) == minors.size and builds.count(build) == builds.size then @major, @minor, @build = Integer(major.to_s), Integer(minor.to_s), Integer(build.to_s) end rescue Exception => e # puts "error(get_build): #{e}" # raise end end return @major, @minor, @build end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def windows_version_parts\n version = self.version\n if version\n # windows-server-* -> windows-*\n if version.split(\"-\", 2)[0] == \"server\"\n version = version.split(\"-\", 2)[1]\n end\n\n if version =~ /^(\\d+)(r\\d+)?(sp...
[ "0.66530526", "0.66465837", "0.65124017", "0.62614083", "0.62261355", "0.6211239", "0.61503816", "0.6042835", "0.5937323", "0.5921345", "0.5920215", "0.58979684", "0.58693236", "0.58668524", "0.57175726", "0.5705238", "0.56817204", "0.56814253", "0.5673897", "0.56664485", "0....
0.75695336
0
Decide if this is an ISO image or an OS root.
def get_mediatype if defined?(@inst) then return @inst else @inst = nil end search = File.join(@path, 'setup.exe') setup = Dir.glob(search, File::FNM_CASEFOLD) @inst = File.exists?(setup.first) ? 'Install Media' : '' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def os_type\n\n if @ostype\n return @ostype\n end\n\n res = :invalid\n\n Rouster.os_files.each_pair do |os, f|\n [ f ].flatten.each do |candidate|\n if self.is_file?(candidate)\n next if candidate.eql?('/etc/os-release') and ! self.is_in_file?(candidate, os.to_s, 'i') # CentOS...
[ "0.6591263", "0.6532187", "0.6400906", "0.6347807", "0.6327243", "0.6124495", "0.61153", "0.61070794", "0.6100217", "0.6026279", "0.6012151", "0.5999745", "0.5999745", "0.59876275", "0.5974671", "0.5939201", "0.59262204", "0.59128", "0.58902913", "0.5872854", "0.5868344", "...
0.0
-1
Create a description string for this version of Windows.
def get_winstring if defined?(@description) then return @description else @description = nil end get_build if not @major if @major < 6 # Vista and up use install.wim version = "#{@major}.#{@minor}" releases = { '5.0' => { 2195 => 'Windows 2000' }, '5.1' => { 2600 => 'Windows XP' }, '5.2' => { 2600 => 'Windows XP', 3790 => 'Windows Server 2003' } } # Get the closest build. Makes more sense with a bigger table. closest, description = releases[version].first releases[version].each do |build, name| if (build-@build).abs < (closest-@build).abs description = name closest = build end end # end of releases block @description = description else # Only works for ISO images for now. Use hivex for OS-root folders. begin substitutions = { # Products that don't have good descriptions. 'ServerSBSStandard' => 'Windows Small Business Server', 'SERVERSBSSTANDARD' => 'Windows Small Business Server', 'ServerHomeStandard' => 'Windows Home Server', 'ServerHomePremium' => 'Windows Home Server', 'Windows Longhorn' => 'Windows Server 2008', 'Windows Longhorn Client' => 'Windows Vista' } get_xmlinfo if not defined?(@xmlinfo) imagecount = REXML::XPath.match(@xmlinfo, '/WIM/IMAGE').length descriptions = REXML::XPath.match(@xmlinfo, '/WIM/IMAGE/NAME/text()') description = String.new(descriptions.first.to_s) if descriptions.length > 1 # Get common name prefixes to ignore product editions, # like 'Ultimate' or 'Home Basic'. Do this by counting each # individual word from the product names and removing those # words that only appear once. It is important to remove them # longest-word-first, since some editions are substrings of # another, e.g. SERVERSTANDARD and SERVERSTANDARDCORE. If there # are any non-matching versions of Windows, it is too hard to # say which one is going to get installed, so return 'Windows'. descriptions = descriptions.map { |xml| xml.to_s.split } descriptions = descriptions.flatten wordcounts = Hash.new(0) descriptions.each { |word| wordcounts[word] += 1 } wordcounts = wordcounts.reject { |word, count| count == imagecount } sorted = wordcounts.keys.sort_by { |string| string.length } sorted.reverse_each { |word, count| description.slice! word } description.rstrip! end description = 'Windows' if description.empty? @description = substitutions.keys.include?(description) ? substitutions[description] : description rescue @description = "Windows" end end @description end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name\n return \"New Firmware\" if !id\n version + \" (\" + description.to_s + \") \" +\n \" (\" + (for_external ? \"internal\" : \"external\") + \")\"\n end", "def create_description_string(name, host, status, description, bracket)\n output = \"```\\n============\\n#{name}\\n============\\n```...
[ "0.6339469", "0.62865597", "0.6123622", "0.60091484", "0.5989196", "0.59707993", "0.5931438", "0.5895481", "0.58368516", "0.5825027", "0.5809383", "0.58090514", "0.5797265", "0.57905775", "0.5771442", "0.5733858", "0.5726541", "0.57140833", "0.56912464", "0.5685428", "0.56816...
0.6885968
0
Dump [1].xml from a Windows install image.
def get_xmlinfo def do_xmlget(imagepath) xmlinfo = %x{imagex info --xml #{imagepath}} @xmlinfo = REXML::Document.new xmlinfo return @xmlinfo end if defined?(@xmlinfo) then return @xmlinfo else @xmlinfo = nil end search = File.join(@path, 'sources/install.wim') wimage = Dir.glob(search, File::FNM_CASEFOLD) if wimage.length > 0 return do_xmlget(wimage.first) end search = File.join(@path, 'sources/boot.wim') bimage = Dir.glob(search, File::FNM_CASEFOLD) if bimage.length > 0 return do_xmlget(bimage.first) end @xmlinfo end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_manifest_file\n render_template(resource_path(\"AppxManifest.xml.erb\"),\n destination: \"#{windows_safe_path(project.install_dir)}/AppxManifest.xml\",\n variables: {\n name: project.package_name,\n friendly_name: project.friendly_name,\n version: windows_pac...
[ "0.5216315", "0.50499356", "0.5045947", "0.5040317", "0.5033626", "0.5018816", "0.49743646", "0.49232647", "0.49208415", "0.48411864", "0.48012644", "0.47731215", "0.475118", "0.47468966", "0.47458598", "0.47255158", "0.47167185", "0.46811822", "0.46618703", "0.4641244", "0.4...
0.5748545
0
I worked on this challenge [by myself, with: ]. Your Solution Below
def welcome(address) if address.include? ("CA") "Welcome to California" else "You should move to California" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solution4(input)\n end", "def isLucky(n)\r\nhalf1 = []\r\nhalf2 = []\r\nn_string = n.to_s\r\n\r\n\r\nfirsthalf = (n_string.length / 2) - 1\r\nsecondhalfstart = (n_string.length / 2)\r\nsecondhalfend = (n_string.length - 1)\r\n(0..firsthalf).each do |idx|\r\n half1 << n_string[idx].to_i\r\nend\r\n\r\n(sec...
[ "0.62877476", "0.60846186", "0.59898067", "0.5987108", "0.59478503", "0.5904577", "0.5855582", "0.5843953", "0.5840107", "0.5832357", "0.58223367", "0.5812061", "0.5797304", "0.57972187", "0.57929134", "0.5785207", "0.57834065", "0.5782036", "0.5781985", "0.57781845", "0.5759...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_gestor_eixo @gestor_eixo = GestorEixo.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a trusted parameter "white list" through.
def gestor_eixo_params params.require(:gestor_eixo).permit(:eixo_id, :pessoa_id, :data_inicio, :data_termino, :ativo) 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
for the index page of the addresses
def index @addresses=current_user.addresses end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @addresses = Address.paginate :page => params[:page], :order => 'street ASC'\n #@addresses = Address.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @addresses }\n end\n end", "def index ; @index ; end", "def index\n\t\t@addresses ...
[ "0.6875668", "0.68352896", "0.66993386", "0.66972727", "0.6617887", "0.66146606", "0.6570374", "0.6556792", "0.65146565", "0.6501181", "0.6501181", "0.64851296", "0.64019674", "0.6314624", "0.63097966", "0.626487", "0.62306273", "0.6213153", "0.61935216", "0.6192414", "0.6192...
0.0
-1
for the sake of the creation of the new address localhost:3000/address/new httpmethod : GET
def new @address=Address.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @address = Address.new\n @url = { controller: '/addresses', action: :create }\n end", "def new\n @origin = OriginAddr.new\n \n drop_breadcrumb('新增')\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @origin }\n end\n end", "def n...
[ "0.7337138", "0.72494274", "0.7124991", "0.7020129", "0.6793162", "0.6759564", "0.6759564", "0.6759564", "0.674076", "0.67128444", "0.663711", "0.6635296", "0.6531555", "0.6517929", "0.6493711", "0.64865816", "0.6475466", "0.64491254", "0.64300823", "0.6417901", "0.64088583",...
0.6648779
10
localhost:3000/addresses/create http method :post pathnil roles and responsibilites to create the record in the data basse
def create @address=Address.new(address_params) @address.user_id=current_user.id if @address.save redirect_to addresses_path else render action: 'new' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n\t\t@address = current_user.addresses.new(address_params)\n\t\t@earring = Earring.find(@address.detail.earring_id)\n\n\t\trespond_to do |format|\n\t\t\tif @address.save\n\t\t\t\tformat.html { redirect_to \"/confirm\" }\n\t\t\t\tformat.json { render action: 'show', status: :created, location: @address }...
[ "0.7245075", "0.72429365", "0.72294366", "0.7202821", "0.71977246", "0.7148181", "0.71442384", "0.71442384", "0.71360093", "0.7132747", "0.71104234", "0.7057823", "0.70529497", "0.70426553", "0.70026606", "0.6993604", "0.69030267", "0.686027", "0.68338376", "0.68285334", "0.6...
0.67570066
26
localhost:3000/addresses/5/edit http method :GET pathedit_address_path roles and responsibilities
def edit @address=Address.new @address=Address.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit\n\t\t@address = current_user.addresses.find(params[:id])\n\tend", "def edit\n @addresses = @user.addresses\n end", "def edit\n @user = User.find(params[:id])\n @address = @user.address || @user.build_address\n end", "def edit\n# @postalAddress = PostalAddress.find(params[:id])\n ...
[ "0.7930331", "0.7466074", "0.7127007", "0.71117216", "0.69689214", "0.69334215", "0.6909133", "0.6888436", "0.6828675", "0.6812284", "0.6775288", "0.67679226", "0.6715734", "0.6707032", "0.6700996", "0.6684866", "0.6684866", "0.6684866", "0.6684866", "0.6684866", "0.6684866",...
0.74751925
1
EPIC TWEET GEN takes a user hashtag and how many tweets to gen returns the total rating
def generate_tweets(hashtag, how_many) total_stars = 0 how_many.times do stars = rand(5)+1 total_stars += stars Tweet.create( user_handle: Faker::Lorem.words(2).join('_'), user_display: Faker::Name.name, feedback: Faker::Lorem.sentences(2).join << " #{stars}star #doha ##{hashtag} #dmkr", rating: stars, event_hashtag: 'doha', participant_hashtag: "#{hashtag}", timestamp: rand(24.hours).ago ) end total_stars end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tweet_score\n end", "def tweet_score(favorite_count, retweet_count)\n return favorite_count + (retweet_count * 2)\n end", "def index\n number_tweets = if params[\"count\"] then params[\"count\"].to_i else 10 end\n tweet_ids = []\n if @user.interests\n for i in 1..number_tweets\n ...
[ "0.68224704", "0.6513439", "0.62277913", "0.6095222", "0.6057707", "0.60108143", "0.59993434", "0.5982066", "0.59727305", "0.5964091", "0.59188235", "0.5901227", "0.5891925", "0.58751523", "0.5863254", "0.5826423", "0.5814737", "0.58095044", "0.5809347", "0.5746908", "0.57029...
0.7060241
0
accepts single string or array of strings (short_name, e.g. "DEF")
def position(position) where(positions: { short_name: position }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def short=(value)\n raise ArgumentError, _(\"Short names can only be one character.\") if value.to_s.length != 1\n @short = value.to_s\n end", "def short_name\n @short_name ||= name.to_s.split('').shift\n end", "def convert_short_name\n self.short_name = self.short_name.parameterize\n ...
[ "0.62100434", "0.60279834", "0.60020626", "0.58779836", "0.58568823", "0.58365995", "0.5806052", "0.57437354", "0.57418483", "0.5705524", "0.5699493", "0.56346136", "0.55916095", "0.5582249", "0.5560058", "0.5556142", "0.553246", "0.5529869", "0.55294186", "0.55270946", "0.55...
0.0
-1
GET /empleadobitacoras/1 GET /empleadobitacoras/1.xml
def show @empleadobitacora = Empleadobitacora.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @empleadobitacora } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @empleadosautorizado = Empleadosautorizado.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @empleadosautorizado }\n end\n end", "def download_xml\n\t\turi = URI.parse(\"http://www.esmadrid.com/opendata/tiendas_v1_es.xml\")\n...
[ "0.6690581", "0.650327", "0.64298296", "0.6412495", "0.63517797", "0.63387704", "0.6338752", "0.6316721", "0.6310457", "0.6295037", "0.62946427", "0.6285195", "0.6281537", "0.62468046", "0.6231396", "0.6227623", "0.62251335", "0.62229425", "0.6218563", "0.62143284", "0.620982...
0.7056976
0
GET /empleadobitacoras/new GET /empleadobitacoras/new.xml
def new @empleadobitacora = Empleadobitacora.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @empleadobitacora } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @empleadosautorizado = Empleadosautorizado.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @empleadosautorizado }\n end\n end", "def new\n @estabelecimento = Estabelecimento.new\n\n respond_to do |format|\n format.html # new.html...
[ "0.7451674", "0.7325657", "0.7292314", "0.7291293", "0.72706664", "0.7242996", "0.71869254", "0.71869254", "0.717484", "0.7161069", "0.71473974", "0.71384805", "0.71382827", "0.71374106", "0.71200883", "0.7095082", "0.7088232", "0.70869154", "0.70827115", "0.70690966", "0.706...
0.7533226
0
POST /empleadobitacoras POST /empleadobitacoras.xml
def create @empleadobitacora = Empleadobitacora.new(params[:empleadobitacora]) respond_to do |format| if @empleadobitacora.save format.html { redirect_to(@empleadobitacora, :notice => 'Empleadobitacora was successfully created.') } format.xml { render :xml => @empleadobitacora, :status => :created, :location => @empleadobitacora } else format.html { render :action => "new" } format.xml { render :xml => @empleadobitacora.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @empleadosautorizado = Empleadosautorizado.new(params[:empleadosautorizado])\n\n respond_to do |format|\n if @empleadosautorizado.save\n format.html { redirect_to(@empleadosautorizado, :notice => 'Empleadosautorizado was successfully created.') }\n format.xml { render :xml =>...
[ "0.6181944", "0.6055266", "0.60118765", "0.59468913", "0.59388566", "0.59319675", "0.59261525", "0.59180355", "0.59166557", "0.5904606", "0.59009385", "0.5896469", "0.5874492", "0.5858113", "0.5833539", "0.5826745", "0.5803622", "0.58018875", "0.57831913", "0.5769799", "0.576...
0.6678962
0
PUT /empleadobitacoras/1 PUT /empleadobitacoras/1.xml
def update @empleadobitacora = Empleadobitacora.find(params[:id]) respond_to do |format| if @empleadobitacora.update_attributes(params[:empleadobitacora]) format.html { redirect_to(@empleadobitacora, :notice => 'Empleadobitacora was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @empleadobitacora.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update\n @estagio = Estagio.find(params[:id])\n\n respond_to do |format|\n if @estagio.update_attributes(params[:estagio])\n flash[:notice] = 'Estagio was su...
[ "0.64717865", "0.6093532", "0.6090856", "0.60785913", "0.60334915", "0.59933466", "0.59698045", "0.5966531", "0.596525", "0.59421456", "0.5915886", "0.58759004", "0.587027", "0.5851336", "0.5830085", "0.5815557", "0.58107173", "0.5792293", "0.57915837", "0.5786026", "0.577174...
0.6343366
1
DELETE /empleadobitacoras/1 DELETE /empleadobitacoras/1.xml
def destroy @empleadobitacora = Empleadobitacora.find(params[:id]) @empleadobitacora.destroy respond_to do |format| format.html { redirect_to(empleadobitacoras_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @empleadosautorizado = Empleadosautorizado.find(params[:id])\n @empleadosautorizado.destroy\n\n respond_to do |format|\n format.html { redirect_to(empleadosautorizados_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/conten...
[ "0.6800261", "0.6773849", "0.67611444", "0.67357093", "0.6704638", "0.66955584", "0.6689398", "0.66782993", "0.66698104", "0.66680396", "0.6651149", "0.66473156", "0.6627883", "0.66221476", "0.66168123", "0.6615853", "0.6615599", "0.6584773", "0.65734327", "0.65613747", "0.65...
0.7031792
0
Check that a domain exists
def verify_domain(domain) begin Socket.gethostbyname(domain) rescue SocketError return false end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exist?(domain)\n Domain.all(:name => domain).any?\n end", "def a_domain_we_care_about?(url)\n begin\n !@domains.select { |domain| URI.parse(url).host == domain.host }.empty?\n rescue\n !@domains.select { |domain| url.gsub(/https*:\\/\\//,'').starts_with?(domain.host) }.empty?\n ...
[ "0.7785723", "0.76860976", "0.7485511", "0.74388176", "0.74388176", "0.74005896", "0.73079014", "0.73079014", "0.7281119", "0.7251366", "0.71842253", "0.71311045", "0.71124214", "0.70819384", "0.7062265", "0.7054427", "0.70375437", "0.7022726", "0.70078486", "0.6969562", "0.6...
0.77154535
1
Check that every element of an array is an integer
def int_array_check(arr) arr.each do |element| Integer(element) != nil rescue return false end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_integer_array? array\n\t\treturn array.all? {|a| a.is_a? Integer}\n\tend", "def expect_array_of_integers(value, field, subfield)\n return false unless expect_array(value, field, subfield)\n error_count = 0\n value.each_with_index do |v, i|\n error_count += 1 unless expect_integer(v, field, \...
[ "0.8201035", "0.7545777", "0.74823475", "0.7456256", "0.72058266", "0.71517855", "0.69280845", "0.68447506", "0.67445415", "0.67261976", "0.67191446", "0.6716126", "0.67059094", "0.67059094", "0.66723394", "0.6657722", "0.65783113", "0.65762496", "0.6320197", "0.63043535", "0...
0.78944993
1
Expect a commaseparated list of numbers as input. Ex: 45,30,15,7,6,5,4,3,2,1
def fetch_csv_array(str) # instance method #remove whitespace str.gsub!(/\s+/, "") return str.split(',') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_numbers\n puts \"Please enter a list of numbers separated by commas.\"\n puts \"Press enter when done.\"\n # Read string and split on comm. \n # Return array of values as string\n input = gets.strip.split(',')\n # Converts each eleemnt in array to integer and store in new ...
[ "0.66350985", "0.62873816", "0.62172115", "0.61534023", "0.6141241", "0.6092649", "0.6071896", "0.60180694", "0.5998458", "0.5953342", "0.5944284", "0.5944061", "0.5912464", "0.5882271", "0.5866013", "0.5864152", "0.5853406", "0.584662", "0.5843356", "0.58012307", "0.5800897"...
0.0
-1
Returns an array of DomainInfo objects from each row of the worksheet
def fetch_certs_from_worksheet(worksheet) # class method domain_infos = Array.new (2..worksheet.num_rows).each do |row| # first row is header domain = worksheet[row, DOMAIN_COL] days_to_notify = fetch_csv_array(worksheet[row, DAYS_COL]) # Don't use row if it is invalid if domain.empty? || !verify_domain(domain) || !int_array_check(days_to_notify) $stderr.puts("Error, row " + row.to_s + " of spreadsheet could not be parsed") next end if days_to_notify.empty? days_to_notify = DEFAULT_DAYS elsif days_to_notify.size == 1 && days_to_notify[0] == SUPPRESSION_SIGNAL next else days_to_notify.map!(&:to_i) end begin expiry_date = fetch_expiry_date(domain) error = '' rescue => e expiry_date = '' error = e.inspect end pagerduty_keys = fetch_csv_array(worksheet[row, PAGERDUTY_COL]) domain_infos.push(DomainInfo.new(domain, pagerduty_keys, expiry_date, days_to_notify, error)) end return domain_infos end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def domains\n domains = []\n nextToken = nil\n base_options = {:Action => 'ListDomains'}\n continue = true\n \n while continue\n options = base_options.dup\n options[:NextToken] = nextToken unless nextToken.nil?\n \n sdb_query(options) d...
[ "0.5899116", "0.58338934", "0.5830932", "0.5611918", "0.5611415", "0.5598804", "0.558254", "0.5574978", "0.5567311", "0.5497265", "0.5456864", "0.54358953", "0.5430412", "0.5346233", "0.53373265", "0.5312618", "0.53106946", "0.5273791", "0.52662134", "0.525596", "0.5255676", ...
0.73706734
0
for subaction in check_access_right
def index @title = @for_which.sub('_', ' ').pluralize.titleize #ex, Quality Systems @definitions = params[:two_tier_definitionx_definitions][:model_ar_r] @definitions = @definitions.where(:for_which => @for_which) @definitions = @definitions.page(params[:page]).per_page(@max_pagination).order('ranking_index') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_access_control_all\n @user = User.find(params[:user_id])\n\n response_access_denied unless current_user.has_role?(:admin) || current_user.id == @user.id\n rescue\n response_access_denied\n end", "def check_can_access\n res = false\n read_actions = [ \"index\", \"list\", \"edi...
[ "0.68938744", "0.67384493", "0.6637637", "0.6531055", "0.6524994", "0.6513374", "0.64853543", "0.64695", "0.6466892", "0.6466482", "0.6459577", "0.6426386", "0.64249074", "0.6399418", "0.6398919", "0.63588023", "0.6354697", "0.6342695", "0.6338652", "0.6329903", "0.63243455",...
0.0
-1
0 1 2 3 4 5 6 7 1 2 3 4 5 6 7 2 3 4 5 6 7 3 4 5 6 7 4 5 6 7 5 6 7 6 7 7
def faster_my_min(arr) # O(n) min = arr[0] arr.each do |ele| min = ele if ele < min end min end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cracklepop3\n (1..100).zip(Array.new 100, nil).map do |i,x|\n [i%3, i%5].map.with_index do |y, j| \n x = x.to_s + ['crackle','pop'][j] if y==0\n end\n x ? x : i\n end\nend", "def series_up(n) # Got help again. My first code couldn't adapt at al...
[ "0.6200348", "0.61823213", "0.61351705", "0.6132255", "0.6105782", "0.60657483", "0.60655886", "0.60507536", "0.6017837", "0.601605", "0.6014432", "0.60063165", "0.6005154", "0.59914505", "0.5982607", "0.59723574", "0.59643686", "0.5960556", "0.5937396", "0.5937396", "0.59273...
0.0
-1
list = [ 0, 3, 5, 4, 5, 10, 1, 90 ] p my_min(list) => 5 p faster_my_min(list) => 5 puts
def largest_contiguous_sum(arr) largest_sum = nil p_tations = subsets(arr) p_tations.each do |tation| if largest_sum == nil largest_sum = tation.sum elsif tation.sum > largest_sum largest_sum = tation.sum end end largest_sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_min_fast(list)\n smallest = list.first\n\n list[1..-1].each { |n| smallest = n if n < smallest }\n smallest\nend", "def my_min2(list)\n min = 0\n list.each do |el|\n min = el if el < min\n end\n min\nend", "def my_min_better(list)\n min = list.first\n list.each do |el|\n min = el if el < ...
[ "0.8384789", "0.82231927", "0.8215523", "0.8174699", "0.81713325", "0.8143211", "0.8090713", "0.8060159", "0.80517286", "0.8033829", "0.8019452", "0.8008887", "0.80039126", "0.80007476", "0.7988653", "0.79828626", "0.7976922", "0.79642594", "0.79627484", "0.79389185", "0.7928...
0.0
-1
list = [5, 1, 3] p subsets(list) p largest_contiguous_sum(list)
def faster_cont_sum(arr) # debugger sum = arr[0] bool = true run_tot = arr[0] arr[1..-1].each do |e| if bool == false && e > sum sum = e bool = true run_tot = e elsif bool == true && e + sum > sum sum += e run_tot += e elsif bool == true && e > sum sum = e else bool = false run_tot += e end end sum >= run_tot ? sum : run_tot end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def largest_contiguous_subsum(list)\n subsets = []\n (0...list.length).each do |idx1|\n (idx1...list.length).each do |idx2|\n subsets << list[idx1..idx2]\n end\n end\n\n #orignial [1,2,3]\n\n #[1]\n #[1,2]\n #[1,2,3]\n #[2]\n #[2,3]\n #[3]\n\n\n largest = subsets[0].sum\n subsets.each do |su...
[ "0.90684897", "0.8606764", "0.85836786", "0.8582223", "0.8548755", "0.85204977", "0.85172164", "0.8507042", "0.84705657", "0.84668493", "0.8454807", "0.8444789", "0.84433585", "0.8441432", "0.8426824", "0.8424723", "0.8408244", "0.83804077", "0.83785963", "0.836916", "0.83612...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_report @report = Report.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a trusted parameter "white list" through.
def report_params params.require(:report).permit(:clearance_id, :city_id, :title, :body) 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
Returns the ycoordinate which is the number on the board (5 in B5)
def y(from = 0) self[1,2].to_i - 1 + from end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_y\n @piece.color == :white ? @y : 7 - @y\n end", "def bottom_cell_y_at(y); (y + HEIGHT - 1) / HEIGHT; end", "def top_cell_y_at(y); y / HEIGHT; end", "def y\n OFFSET_FROM_TOP + (coordinates.y * 700).to_i\n end", "def y_coord(num)\n (num/65536).to_i\nend", "def get_y\n grid_height...
[ "0.7482858", "0.7441533", "0.7369521", "0.72053385", "0.69391304", "0.67671734", "0.6676353", "0.6605911", "0.6598376", "0.6580589", "0.6579641", "0.65274876", "0.65223825", "0.65223825", "0.6426332", "0.63919497", "0.6389246", "0.6346728", "0.6339443", "0.6324527", "0.632452...
0.5884917
53
Returns the player name as used on the server
def name File.basename(__FILE__, '.rb') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_player\n\t @name\n\tend", "def player_name\n player.name\n end", "def player_name(id)\n name = Player.find(id)\n end", "def name\n \"Player#{@ix}\"\n end", "def get_player_name(name)\n return prompt(\"Player Name? [Player #{name}]\",\"Player #{name}\")\n end", "def get_player...
[ "0.80743104", "0.80316687", "0.79166704", "0.78131676", "0.7783446", "0.76845396", "0.7624314", "0.71422195", "0.7086779", "0.70686686", "0.7015892", "0.6980001", "0.6938531", "0.69126695", "0.6884424", "0.6844345", "0.6809426", "0.67929554", "0.6778035", "0.6736138", "0.6728...
0.0
-1
Returns next position from the sequence to shot at. Examples: A1, B10, J9
def next_target # First shot at the priority positions begin here = @shot_queue.shift end while !shootable?(here) && !@shot_queue.empty? # Then shot according to ship discovery while !shootable?(here) do here = @discovery.next break if here.nil? end field[here] = :shot if here here end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_starting_position\n\t\tpos = @starting_positions[@pos_idx]\n\t\t@pos_idx = (@pos_idx + 1) % @starting_positions.length\n\t\tpos\n\tend", "def next\n last? ? nil : locate + 1\n end", "def to(position)\n first position + 1\n end", "def to(position)\n first position + 1\n end", "def input...
[ "0.74691653", "0.6972149", "0.69141716", "0.69141716", "0.68536675", "0.6752193", "0.673807", "0.6723851", "0.66539335", "0.6590219", "0.655326", "0.646682", "0.64662623", "0.64614713", "0.64523584", "0.6424467", "0.6400507", "0.63645834", "0.6360255", "0.6340886", "0.6324847...
0.0
-1
Returns ships' positions as per server. Includes only the actual positions with no message.
def allocate_ships options =[ "5:A1:V 4:J5:V 3:A8:H 3:I1:V 2:!?:H".sub('!', ('C'..'G').sort_by { rand }.first).sub('?', (1..9).sort_by{ rand }.first.to_s), "5:I1:V 4:H6:V 3:E10:H 3:D7:V 2:!?:V".sub('!', ('A'..'G').sort_by { rand }.first).sub('?', (1..4).sort_by{ rand }.first.to_s), "5:E3:V 4:A2:V 3:A7:V 3:J5:V 2:!?:V".sub('!', ('G'..'I').sort_by { rand }.first).sub('?', (1..9).sort_by{ rand }.first.to_s), "5:F10:H 4:A10:H 3:A2:V 3:H1:H 2:!?:H".sub('!', ('C'..'I').sort_by { rand }.first).sub('?', (3..8).sort_by{ rand }.first.to_s), "5:B1:H 4:J2:V 3:J7:V 3:F10:H 2:A?:V".sub('?', (rand(8)+2).to_s), "5:F6:H 4:D5:V 3:E4:H 3:F9:H 2:!1:H".sub('!', (rand(9)+65).chr), "5:F10:H 4:B1:H 3:A2:V 3:A6:V 2:J?:V".sub('?', (rand(7)+1).to_s), "5:F1:V 4:A6:H 3:H6:H 3:F8:V 2:!?:V".sub('!', ['A','B','C','H','I','J'][rand 6]).sub('?', [1,2,8,9][rand 4].to_s), ] options[rand options.length] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_positions\n all_players = consume_player_data\n keep_position_info(all_players)\n end", "def ship_coordinates\n @ship_squares.map do |squares|\n squares.map { |square| [square.x, square.y] }\n end\n end", "def remains\n @all_ships.each_with_index.map { |x, i| [i, x...
[ "0.7049712", "0.6534757", "0.64949864", "0.6219765", "0.61478496", "0.59926206", "0.59674454", "0.59073025", "0.59050876", "0.58662504", "0.58334935", "0.5829657", "0.5801994", "0.57445455", "0.57286555", "0.57260174", "0.56145954", "0.5600293", "0.5600293", "0.5596348", "0.5...
0.0
-1
Receives count Returns space delimited positions. Such as "A1 J10"
def shot(count) shots = (1..count).map do next_target || 'A1' # Out of shots already, just satisfy min-shots requirement end * ' ' shots end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def indentize!(count, char = ' ')\n tap do |s|\n s.gsub!(/([^\\n]*)(\\n|$)/) do\n s1 = Regexp.last_match(1)\n s2 = Regexp.last_match(2)\n not_empty = s1 != '' || s2 != ''\n \"#{char * count}#{s1}#{s2}\" if not_empty\n end\n ...
[ "0.61809474", "0.6026715", "0.58224976", "0.5754692", "0.57150304", "0.5704381", "0.5620178", "0.56109375", "0.55700773", "0.5554574", "0.55437994", "0.5532034", "0.5523816", "0.5520819", "0.5513871", "0.5506417", "0.55036277", "0.5502637", "0.54989904", "0.5495267", "0.54837...
0.0
-1
Expecting string: "A1:hit B10:miss" Processes the result, marks the field appropriately, changes the sequence of shots accordingly.
def process_shot_result(shot_result) shot_result.split(/:|\s/).each_slice(2) do |location, result| field[location] = result.to_sym has_hit(location) if field[location] == :hit end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_protein_hit(str, desc, query_hits)\n data = str.split(\",\")\n ProteinHitFloatIndicies.each do |index|\n data[index] = data[index].to_f\n end\n data << desc\n data << query_hits\n \n ProteinHit.new(*data)\n end", "def parse_grimm(grimm_outp...
[ "0.5447488", "0.5336484", "0.5196144", "0.5193202", "0.5172869", "0.5167905", "0.5144815", "0.514023", "0.5099147", "0.50526416", "0.5049992", "0.4988325", "0.49721697", "0.49398422", "0.49225911", "0.49178684", "0.49163556", "0.49040356", "0.4890102", "0.488303", "0.48752442...
0.7211474
0
Callback for an ontarget shot
def has_hit(hit) asap = [] asap.push hit.to_left, hit.to_left.to_left if field[hit.to_right] == :hit asap.push hit.to_right, hit.to_right.to_right if field[hit.to_left] == :hit asap.push hit.to_up, hit.to_up.to_up if field[hit.to_dn] == :hit asap.push hit.to_dn, hit.to_dn if field[hit.to_up] == :hit if asap.empty? # Force shooting around asap = [ hit.to_left, hit.to_right, hit.to_up, hit.to_dn ].reject { |l| l.nil? } end asap.each { |l| @shot_queue.push l } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fireAtTarget _obj, _args\n \"_obj fireAtTarget _args;\" \n end", "def shoot\n \tuser_shoot\n\tend", "def tick!\n if target = acquire_target\n shoot_at(target)\n else\n scan_for_targets\n end\n end", "def shoot(at_coordinates, opponent_board)\n opponent_board.register_shot(...
[ "0.60665846", "0.6014906", "0.6010438", "0.5983", "0.5895074", "0.588549", "0.58731693", "0.58648145", "0.58545506", "0.5844319", "0.5840307", "0.5747669", "0.57458043", "0.5666977", "0.56394774", "0.5603566", "0.55389214", "0.5521687", "0.5496951", "0.5493366", "0.545965", ...
0.0
-1
for Rails < 6
def test_works get products_url assert_response :success assert_equal 1, Ahoy::Visit.count assert_equal 1, Ahoy::Event.count event = Ahoy::Event.last assert_equal "Viewed products", event.name assert_equal({}, event.properties) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def version_helper; end", "def version_helper; end", "def version_helper; end", "def version_helper; end", "def dependencies; end", "def dependencies; end", "def dependencies; end", "def vendor; end", "def appraisals; end", "def appraisals; end", "def version; end", "def...
[ "0.65551776", "0.5857164", "0.5857164", "0.5857164", "0.5857164", "0.56520194", "0.56520194", "0.56520194", "0.56059843", "0.5593165", "0.5593165", "0.5574186", "0.5574186", "0.5574186", "0.5574186", "0.5574186", "0.5574186", "0.5574186", "0.5574186", "0.5574186", "0.5574186"...
0.0
-1
::new Application with parameters. Parses options Sets loglevel
def initialize(*args) parse_options(*args) set_log_level @@application = self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(appname = nil)\n @appname = appname\n @log = Logger.new(STDERR)\n @log.progname = @appname\n @level = @log.level\n end", "def initialize app, logger: nil\n @app = app\n @logger = logger\n end", "def app\n # TODO: set logging level shouldn't be a...
[ "0.6818112", "0.64594615", "0.63585734", "0.6309242", "0.6167207", "0.6148861", "0.6115978", "0.6098042", "0.60679907", "0.6032628", "0.6032628", "0.5980173", "0.5972524", "0.59556144", "0.59317595", "0.5912391", "0.59084064", "0.5893129", "0.58828133", "0.5879854", "0.586496...
0.80029
0
Initialize on first call and then return Loggerobject
def logger @@logger ||= Logger.new(ENV['ENVIRONMENT']=="test" ? false : $stdout) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n @logger = Logging::Logger[self]\n end", "def initialize\n @log = Logging::Logger[self]\n end", "def initialize_logger\n return if @logger.blank?\n log = @logger\n log = log.to_s if log.is_a?(Pathname)\n if log.is_a?(String)\n log = File.join(TMP_ROOT_DIR, log...
[ "0.79869616", "0.7852248", "0.76831454", "0.76336807", "0.7570718", "0.7530305", "0.7503324", "0.7495495", "0.7414495", "0.7391725", "0.7359133", "0.7348552", "0.733175", "0.72759444", "0.72759444", "0.72759444", "0.72518873", "0.7250611", "0.72284037", "0.7216499", "0.721267...
0.0
-1
Run the application's outer loop
def run _cmd = built_in_command( options[:args] ) _cmd ||= options[:command] ? CommandRunner.new(options[:command]) : 0 if _cmd.class == CommandRunner _cmd.run do |item| puts "%s:\n %s\n\n" % [ item.class, item.desc ] if item.is_a?(UseCase) && ENV['ENVIRONMENT'] != 'test' end else _cmd end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_loop\n end", "def run\n loop do\n break unless app_loop\n end\n end", "def loop\n end", "def loop\n end", "def loop\n end", "def loop; end", "def parentloop; end", "def main_loop\n\t\t\tbegin\n\t\t\t\tloop {\n\t\t\t\t\titerate\n\t\t\t\t\tlog.debug \"Finished iteratio...
[ "0.7935986", "0.7788451", "0.7568866", "0.7562504", "0.7562504", "0.74086004", "0.7246963", "0.72172534", "0.7097975", "0.70818275", "0.707193", "0.7045728", "0.70312774", "0.69933915", "0.6955586", "0.68950015", "0.6889644", "0.68845767", "0.6849361", "0.668517", "0.6670535"...
0.0
-1
Called on initializer after parsing the arguments. Loglevel is set according to options v or q
def set_log_level logger.level = options[:quiet] ? Logger::FATAL : Logger::WARN logger.level = Logger::INFO if options[:verbose] logger.info("Logger.level set to #{logger.level}") raise OptionsError.new("Option mismatch - you can't provide -v and -q at the same time") if options[:quiet] && options[:verbose] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(*args)\n parse_options(*args)\n set_log_level\n @@application = self\n end", "def parse(arguments)\n super\n\n level = :info\n level = :debug if debug?\n level = :error if quiet?\n Kubetruth::Logging.setup_logging(level: level, color: color?)\n end", "def in...
[ "0.7408011", "0.7201211", "0.71071047", "0.6954102", "0.6954102", "0.689402", "0.6791955", "0.67912066", "0.67372584", "0.6736481", "0.6728084", "0.671521", "0.66979676", "0.6641687", "0.66245246", "0.65881974", "0.65881747", "0.652815", "0.65231496", "0.6520111", "0.6512943"...
0.70134836
3
part 1 input string output new string with words in reverse order rules empty string returns empty string maintain case given a string scan, using space as the delimeter reverse the result and return
def reverse_sentence(str) str.scan(/\w+/).reverse.join(' ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse_word_by_word_naive(s)\n words = s.split(\" \")\n my_reverse(words).join(\" \")\nend", "def reverse_words(s)\n strs = s.split(\" \")\n if strs.length == 0\n return \"\"\n elsif strs.length == 1\n return s\n else\n strs.reverse!\n return strs.join(\" \")\n end\nend", "def reverse_w...
[ "0.7333701", "0.7171058", "0.7168493", "0.71629214", "0.70760584", "0.70382446", "0.70222294", "0.7000654", "0.6996369", "0.695027", "0.69465643", "0.6941701", "0.69275767", "0.6920036", "0.6913219", "0.6903961", "0.6898942", "0.689444", "0.689444", "0.6877937", "0.68773985",...
0.0
-1
ROCHE SPECIFIC FIELDS END.
def parse_field_for_sample_id(fields,index) return false if fields[index].blank? return false if fields[index].strip.blank? self.sample_ids = fields[index].strip.split(/\'/) return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fields; end", "def fields; end", "def fields; end", "def end_field; end", "def start_field; end", "def end_field=(_arg0); end", "def fields?; @fields; end", "def computed_fields; end", "def fields\n nil\n end", "def fields\n @_fields ||= {}\n end", "def fields\n ...
[ "0.7586811", "0.7586811", "0.7586811", "0.7344003", "0.6795982", "0.67171514", "0.6622132", "0.6606985", "0.6510521", "0.6451728", "0.64362925", "0.6433731", "0.63694745", "0.6349932", "0.6319235", "0.6319235", "0.6319235", "0.6319235", "0.6319235", "0.6310776", "0.62928456",...
0.0
-1
each query will build one patient and one order inside it. the order can have many tests.
def build_response(options={}) responses = [] one_response = '' puts "sample ids are:" puts self.sample_ids return responses unless sample_ids self.sample_ids.each_with_index {|sid,key| puts "doing sample id: #{sid}" ## tests are got from the requisitions hash. tests = get_tests(sid) puts "tests are: #{tests}" ## default sequence number is 0 (THIS MAY LEAD TO PROBLEMS.) sequence_number = "#{key.to_s}" ## default patient id: patient_id = "abcde#{Time.now.to_i.to_s}" patient = Patient.new({:sequence_number => sequence_number, :patient_id => patient_id}) order = Order.new({:sequence_number => patient.sequence_number, :specimen_id => sid, :tests => tests, :priority => "R"}) responses << (patient.build_response(options) + order.build_response(options.merge({sequence_number: self.sequence_number, carrier_number: self.carrier_number, position_number: self.position_number, sample_type: self.sample_type, container_type: self.container_type}))) } puts "responses are:" puts responses.to_s return responses end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @ordereds=Ordered.all\n @preparats=Preparat.all\n @order.ordereds.build\n end", "def create\n\n @order = Order.new(:drone_id => Drone.where('name = :dname', dname: 'No Drone Assigned').first.id, :person_id => params[:orderdetail][:person_id], :status => 1)\n if @order.save\n @...
[ "0.57278603", "0.56436294", "0.55604786", "0.5551422", "0.5509067", "0.54993147", "0.54420334", "0.54282135", "0.5423543", "0.5422804", "0.539481", "0.53165156", "0.53143424", "0.52478486", "0.524699", "0.52177745", "0.52145433", "0.5202652", "0.51762056", "0.5151994", "0.514...
0.49952367
36
signs in when already at signin_path
def and_sign_in(player) fill_in 'Email', with: player.email fill_in 'Password', with: player.password click_button 'Sign in' # Sign in when not using Capybara as well. cookies[:remember_token] = player.remember_token end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sign_in\n end", "def sign_in\n\n end", "def signin\n end", "def user_signin_status\n unless user_signed_in?\n redirect_to root_url\n end\n end", "def signed_in_user\n redirect_to signin_path, :status => 302 unless signed_in?\n end", "def signed_in_user\n redirect_to sign...
[ "0.7953672", "0.7797546", "0.77806145", "0.77384025", "0.77195257", "0.77195257", "0.769542", "0.7678544", "0.76002675", "0.7583254", "0.75559705", "0.7545116", "0.75444484", "0.75334984", "0.7509104", "0.7508345", "0.75056875", "0.74942654", "0.7486416", "0.7445531", "0.7408...
0.0
-1
ammount should always be provided in cents!
def initialize(order, account, options = {}) self.credentials = options.delete(:credentials) if options[:credentials] super(order, account, options) add_field 'Ds_Merchant_MerchantCode', credentials[:commercial_id] add_field 'Ds_Merchant_Terminal', credentials[:terminal_id] #add_field mappings[:transaction_type], '0' # Default Transaction Type self.transaction_type = :authorization end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cents; end", "def cents\n (amount * 100).to_i\n end", "def prepare_amount amount\n BigDecimal.new(amount)/100\n end", "def credit_in_cents\n (user.credit * 100).to_i\n end", "def damt_paid\n\tamt_paid/100.0 rescue 0.0 \nend", "def mark_up_amt\n rounder5(self.vehicle.price * 0.0...
[ "0.7395885", "0.6579836", "0.65370005", "0.64695483", "0.6438657", "0.64309907", "0.63770604", "0.63299894", "0.62865436", "0.6248831", "0.6237825", "0.6221687", "0.62170476", "0.62149304", "0.62042636", "0.6201402", "0.6191846", "0.6191414", "0.6186176", "0.6179767", "0.6161...
0.0
-1
Allow credentials to be overwritten if needed
def credentials @credentials || self.class.credentials end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def credentials=(_arg0); end", "def credentials=(_arg0); end", "def credentials=(_arg0); end", "def credentials=(_arg0); end", "def credentials=(_arg0); end", "def credentials; end", "def credentials; end", "def credentials; end", "def credentials; end", "def credentials; end", "def use_demo_cr...
[ "0.7015429", "0.7015429", "0.7015429", "0.7015429", "0.7015429", "0.6920988", "0.6920988", "0.6920988", "0.6920988", "0.6920988", "0.6577597", "0.6570384", "0.6561054", "0.63740367", "0.6316935", "0.62419844", "0.62210935", "0.62152225", "0.62048227", "0.61904293", "0.6159524...
0.57147014
77
Generate a signature authenticating the current request. Values included in the signature are determined by the the type of transaction.
def sign_request # By default OpenSSL generates an all-zero array for the encriptation vector # You can read it here: http://ruby-doc.org/stdlib-1.9.3/libdoc/openssl/rdoc/OpenSSL/Cipher.html#method-i-iv-3D # If you want to declare it, you can take a look at the next couple of lines #bytes = Array.new(8,0) #iv = bytes.map(&:chr).join # We need to decode the secret key key = Base64.strict_decode64(credentials[:secret_key]) # In thee cipher initialization we need to speficy the encryptation like method-length-mode (http://ruby-doc.org/stdlib-1.9.3/libdoc/openssl/rdoc/OpenSSL/Cipher.html#method-c-new). # Sermepa needs DES3 in CBC mode # The direct way the declare it's: des-ede3-cbc # You can also declare like 'des3' wich use CBC mode by default des3 = OpenSSL::Cipher::Cipher.new('des-ede3-cbc') # OpenSSL use by default PKCS padding. But Sermepa (mcrypt_encrypt PHP function) use zero padding. # OpenSSL do not allow zero padding. So we need to disable the default padding and make zero padding by hand # Padding in cryptography is to fill the data with especial characteres in order to use the data in blocks of N (https://en.wikipedia.org/wiki/Padding_(cryptography)) # We need to use blocks of 8 bytes block_length = 8 # We tell OpenSSL not to pad des3.padding = 0 # We want to encrypt des3.encrypt # Key set des3.key = key #des3.iv = iv order_number = @fields["Ds_Merchant_Order"] # Here is the 'magic'. Instead use the default OpenSSL padding (PKCS). We fill with \0 till the data have # a multiple of the block size (8, 16, 24...) order_number += "\0" until order_number.bytesize % block_length == 0 # For example: the string "123456789" will be transform in "123456789\x00\x00\x00\x00\x00\x00\x00" # data must be in blocks of 8 or the update will break key_des3 = des3.update(order_number) + des3.final # The next step is to encrypt in SHA256 the resulting des3 key with the base64 json result = OpenSSL::HMAC.digest('sha256', key_des3, merchant_parameters_base64_json) # The last step is to encode the data in base64 Base64.strict_encode64(result) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def signature\n k_date = Digestor.hmac(\"AWS4\" + secret_key, date[0, 8])\n k_region = Digestor.hmac(k_date, region)\n k_service = Digestor.hmac(k_region, service)\n k_credentials = Digestor.hmac(k_service, \"aws4_request\")\n Digestor.hexhmac(k_credentials, string_to_sign)\n end", "d...
[ "0.74859357", "0.73974746", "0.73694193", "0.735339", "0.71743894", "0.7172763", "0.6953532", "0.6799274", "0.6791234", "0.6732178", "0.6723466", "0.67228794", "0.6680614", "0.6646588", "0.6603755", "0.65994126", "0.6558189", "0.6557101", "0.6551077", "0.65433097", "0.6541689...
0.6041949
78
Send a manual request for the currently prepared transaction. This is an alternative to the normal view helper and is useful for special types of transaction.
def send_transaction body = merchant_parameters_base64_json headers = { } headers['Content-Length'] = body.size.to_s headers['User-Agent'] = "Active Merchant -- http://activemerchant.org" headers['Content-Type'] = 'application/x-www-form-urlencoded' # Return the raw response data ssl_post(Sermepa.operations_url, "entrada="+CGI.escape(body), headers) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_transaction(tx)\n sendrawtransaction(tx)\n end", "def transaction_request(transaction,total=nil)\n transaction_request = Cielo::TransactionRequest.new\n resul = send_request(transaction_request.serialize(transaction))\n end", "def set_txn\n @transaction = Txn.find(params[:id])\...
[ "0.6071131", "0.5830867", "0.5824561", "0.5767469", "0.57332784", "0.572174", "0.5710437", "0.5682048", "0.5644431", "0.5639744", "0.56050134", "0.5590872", "0.55596596", "0.55311394", "0.5530475", "0.5521963", "0.5521963", "0.5521963", "0.5521963", "0.5521963", "0.5521963", ...
0.0
-1
Authenticates a user by their login name and unencrypted password. Returns the user or nil. uff. this is really an authorization, not authentication routine. We really need a Dispatch Chain here or something. This will also let us return a human error message. def self.authenticate(login, password) return nil if login.blank? || password.blank? u = find_by_login(login) need to get the salt u && u.authenticated?(password) ? u : nil end
def login=(value) write_attribute :login, (value ? value.downcase : nil) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticate(login, password)\n u = find_by_login(login) # need to get the salt\n u && u.authenticated?(password) ? u : nil\n end", "def authenticate(login, password)\n u = users.query_for_authenticate(login).as(entity).one\n App.logger.debug \"RW users-repo.authenticate, user:...
[ "0.8199555", "0.7758946", "0.7733583", "0.77321506", "0.7643159", "0.76276475", "0.75650644", "0.7422041", "0.74000347", "0.7353603", "0.73405296", "0.7333466", "0.72923356", "0.72923356", "0.72785985", "0.726604", "0.72153556", "0.7189424", "0.718413", "0.717262", "0.7137016...
0.0
-1
GET /buildings or /buildings.json
def index @buildings = Building.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @buildings = Building.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json :@buildings }\n end\n end", "def getbuildings\n \n puts params\n custid = params[\"custormerid\"]\n puts custid\n \n buildings ...
[ "0.7627638", "0.71269304", "0.6795006", "0.675837", "0.67289567", "0.67020917", "0.66783166", "0.66447204", "0.6616098", "0.65419984", "0.64957136", "0.64730287", "0.6461572", "0.64584154", "0.6346139", "0.63236094", "0.6305294", "0.62001073", "0.61962605", "0.61962605", "0.6...
0.68793
2
GET /buildings/1 or /buildings/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @buildings = Building.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json :@buildings }\n end\n end", "def getbuildings\n \n puts params\n custid = params[\"custormerid\"]\n puts custid\n \n buildings ...
[ "0.73594165", "0.6972951", "0.6827823", "0.6796824", "0.67829406", "0.672795", "0.66243523", "0.661749", "0.6566114", "0.65500695", "0.6529503", "0.6382412", "0.6382412", "0.6378805", "0.63621306", "0.62992597", "0.6290318", "0.6259671", "0.6128736", "0.6113885", "0.609708", ...
0.0
-1
POST /buildings or /buildings.json
def create @building = Building.new(building_params) respond_to do |format| if @building.save format.html { redirect_to @building, notice: "Building was successfully created." } format.json { render :show, status: :created, location: @building } else format.html { render :new, status: :unprocessable_entity } format.json { render json: @building.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @building = Building.new(building_params)\n\n if @building.save\n render json: @building, status: :created, location: @building\n else\n render json: @building.errors, status: :unprocessable_entity\n end\n end", "def create\n @building = Building.new(building_params)\n r...
[ "0.72877383", "0.6967386", "0.6944594", "0.6861559", "0.6552082", "0.6482148", "0.6481757", "0.6374498", "0.63399714", "0.63159066", "0.6311842", "0.6302082", "0.62486374", "0.62443686", "0.6242764", "0.6158093", "0.6128274", "0.60632986", "0.5998109", "0.598286", "0.59651864...
0.69485223
2
PATCH/PUT /buildings/1 or /buildings/1.json
def update respond_to do |format| if @building.update(building_params) format.html { redirect_to @building, notice: "Building was successfully updated." } format.json { render :show, status: :ok, location: @building } else format.html { render :edit, status: :unprocessable_entity } format.json { render json: @building.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @building = Building.find(params[:id])\n\n if @building.update_attributes(building_params)\n head :no_content\n else\n render json: @building.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @building.update(building_params)...
[ "0.7250559", "0.6813738", "0.68066853", "0.6684587", "0.6680801", "0.6656561", "0.63786113", "0.63300896", "0.63297075", "0.6308987", "0.6285002", "0.6258303", "0.62322617", "0.62213004", "0.6217014", "0.6213388", "0.6187155", "0.6130243", "0.61281073", "0.59931046", "0.58844...
0.67374265
3
DELETE /buildings/1 or /buildings/1.json
def destroy @building.destroy respond_to do |format| format.html { redirect_to buildings_url, notice: "Building was successfully destroyed." } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @building = Building.find(params[:id].to_i)\n @building.destroy\n respond_to do |format|\n format.html { redirect_to buildings_url, notice: 'Building destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @building = Building.find(params[:id])\n @...
[ "0.7234771", "0.71095", "0.7079201", "0.70727664", "0.70217735", "0.70195794", "0.70169353", "0.6972529", "0.69528127", "0.69496524", "0.69496524", "0.6856756", "0.67897", "0.67828834", "0.6744567", "0.6741457", "0.6740434", "0.67290276", "0.6657518", "0.6580545", "0.6578945"...
0.7013583
7
Use callbacks to share common setup or constraints between actions.
def set_building @building = Building.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a list of trusted parameters through.
def building_params params.require(:building).permit(:FullNameOfTheBuildingAdministrator, :EmailOfTheAdministratorOfTheBuilding, :PhoneNumberOfTheBuildingAdministrator, :FullNameOfTheTechContactForTheBuilding, :TechContactEmail, :TechContactPhone) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\...
[ "0.69497335", "0.6812623", "0.6803639", "0.6795365", "0.67448795", "0.67399913", "0.6526815", "0.6518771", "0.64931697", "0.6430388", "0.6430388", "0.6430388", "0.63983387", "0.6356042", "0.63535863", "0.63464934", "0.63444513", "0.6337208", "0.6326454", "0.6326454", "0.63264...
0.0
-1
Add Examiner to report on. The report will output results for all added examiners.
def add_examiner(examiner) @total_smell_count += examiner.smells_count @examiners << examiner self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def report_learner\n # I'm using the ! here so we can track down errors faster if there is an issue making\n # the report_learner\n super || create_report_learner!\n end", "def add_report\n # TODO: should traverse listener queue for conditions and callbacks\n if @rain == :warning or @rain == :imm...
[ "0.5348647", "0.52574337", "0.5132551", "0.5118087", "0.5097503", "0.509313", "0.5079046", "0.5067479", "0.50552934", "0.503946", "0.4997131", "0.49837166", "0.49324992", "0.49324992", "0.49324992", "0.49324992", "0.49324992", "0.49136785", "0.49005815", "0.48933992", "0.4859...
0.7533612
0
Render the report results on STDOUT
def show raise NotImplementedError end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def output_report\n report = \"\"\n report << '<html>'\n report << ' <head>'\n report << \" <title>#{@title}</title>\"\n report << ' </head>'\n report << ' <body>'\n @text.each { |line| report << \" <p>#{line}</p>\" }\n report << ' </body>'\n report << '</html>'\n end", "d...
[ "0.77427894", "0.76158184", "0.71735525", "0.71391654", "0.7050066", "0.7028997", "0.69840163", "0.6913772", "0.6765922", "0.6758176", "0.6758176", "0.6758176", "0.6758176", "0.6758176", "0.6752993", "0.67523646", "0.67520016", "0.671204", "0.67066664", "0.6648593", "0.662483...
0.0
-1
def card_id attributes = pivotal_attributes(card.desc) attributes[:id] if attributes && attributes[:id] end
def update_from_pivotal_card(pivotal_card) puts "=> #{pivotal_card.attributes[:name]}" puts "=> #{pivotal_card.attributes[:current_state].upcase}\n\n" set_pivotal_attributes(pivotal_card) @pivotal_attributes.map { |k, v| @card.send("#{k}=", v) } @card.save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def card_id\n card.id\n end", "def id\n attributes.fetch(:id)\n end", "def id\n attributes.fetch(:id)\n end", "def id\n attributes.fetch(:id)\n end", "def card_set_id(c)\n CardSet.find_by(name: c['card_set']).id\nend", "def find_plain_card(id)\n car...
[ "0.813602", "0.6921668", "0.6921668", "0.6921668", "0.6899346", "0.68909174", "0.68149", "0.6782958", "0.67380065", "0.6718253", "0.665398", "0.6568347", "0.6561171", "0.6551776", "0.6551776", "0.6551776", "0.6551776", "0.6551776", "0.6551776", "0.6551776", "0.6551776", "0....
0.0
-1
Use callbacks to share common setup or constraints between actions. def set_daily_activity
def set_dog @dog = Dog.find(params[:dog_id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def action_daily\n # ToDo: Change the hard coded report to a Report setting, or client base\n raise 'Hard coded report implementation' unless RAILS_ENV =~ /susbkk/\n end", "def daily_activity_aaa\n\t\t@work_flows = WorkFlow.where(is_active: true)\n\t\t@workflows = WorkFlow.where(is_active: true, is_in_use...
[ "0.6270626", "0.6170346", "0.5965133", "0.59274125", "0.56509954", "0.5551927", "0.5538971", "0.54896075", "0.545823", "0.545567", "0.5414089", "0.5382067", "0.5381866", "0.53529984", "0.5349888", "0.53257257", "0.5322765", "0.5322765", "0.5322765", "0.5322765", "0.5322332", ...
0.0
-1
Only allow a trusted parameter "white list" through.
def daily_activity_params params.require(:daily_activity).permit(:name, :kind, :date, :description, :dog_id, :time, :id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.638045...
0.0
-1
Initializes the Atari environment
def init_env type: # puts " initializing env" if debug # print "(newenv) " #if debug AtariWrapper.new gym.make(type), downsample: compr.downsample, skip_type: skip_type, preproc: preproc end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init!\n @logger = @config = @database_config = nil\n\n load_application_config\n load_database_config\n note \"Loading #{env} environment (#{Ajaila::VERSION})\"\n load_classes\n note \"Establishing database connection\"\n establish_database_connection\n note \"Running au...
[ "0.7116878", "0.7031185", "0.7031185", "0.6388906", "0.63299775", "0.62325126", "0.62183577", "0.6209452", "0.61974424", "0.6189368", "0.61693674", "0.61678666", "0.6166484", "0.6146462", "0.6058754", "0.6000881", "0.59633607", "0.58558", "0.5848517", "0.5842015", "0.5831085"...
0.6776729
3
Return the fitness of a single genotype
def fitness_one genotype, env: single_env, render: false, nsteps: max_nsteps, aggr_type: :last puts "Evaluating one individual" if debug puts " Loading weights in network" if debug net.deep_reset net.load_weights genotype observation = env.reset # require 'pry'; binding.pry unless observation == env.reset_obs # => check passed, add to tests env.render if render tot_reward = 0 # # set of observations with highest novelty, representative of the ability of the individual # # to obtain novel observations from the environment => hence reaching novel env states # represent_obs = [] puts "IGNORING `nobs_per_ind=#{nobs_per_ind}` (random sampling obs)" if nobs_per_ind represent_obs = observation nobs = 1 puts " Running (max_nsteps: #{max_nsteps})" if debug runtime = nsteps.times do |i| code = compr.encode observation # print code.to_a selected_action = action_for code obs_lst, rew, done, info_lst = env.execute selected_action, skip_frames: skip_frames # puts "#{obs_lst}, #{rew}, #{done}, #{info_lst}" if debug observation = OBS_AGGR[aggr_type].call obs_lst tot_reward += rew ## NOTE: SWAP COMMENTS ON THE FOLLOWING to switch to novelty-based obs selection # # The same observation represents the state both for action selection and for individual novelty # # OPT: most obs will most likely have lower novelty, so place it first # # TODO: I could add here a check if obs is already in represent_obs; in fact # # though the probability is low (sequential markovian fully-observable env) # novelty = compr.novelty observation, code # represent_obs.unshift [observation, novelty] # represent_obs.sort_by! &:last # represent_obs.shift if represent_obs.size > nobs_per_ind # Random sampling for representative obs nobs += 1 represent_obs = observation if rand < 1.0/nobs # Image selection by random sampling env.render if render break i if done end compr.train_set << represent_obs # for novelty: # represent_obs.each { |obs, _nov| compr.train_set << obs } puts "=> Done! fitness: #{tot_reward}" if debug # print tot_reward, ' ' # if debug print "#{tot_reward}(#{runtime}) " tot_reward end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fitness individual\r\n (5 - individual).abs\r\n end", "def fitness\n @fitness ||= (\n outter_bound, inner_bound = @length -2, @length - 1\n (0..outter_bound).inject(0) do |e1, x1|\n y1 = @genes[x1]\n e1 + ((x1+1)..inner_bound).inject(0) do |e2, x2|\n y2 = @genes[x2]\n ...
[ "0.7668033", "0.7638386", "0.7604713", "0.7116792", "0.708517", "0.69775146", "0.68600476", "0.683236", "0.683236", "0.6810001", "0.6671243", "0.66366965", "0.66366965", "0.656321", "0.64838034", "0.6465341", "0.64458907", "0.63760954", "0.62340516", "0.6218323", "0.6193037",...
0.582388
34
Builds a function that return a list of fitnesses for a list of genotypes. Since Parallel runs in separate fork, this overload is needed to fetch out the training set before returning the fitness to the optimizer
def gen_fit_fn type, ntrials: ntrials_per_ind return super unless type.nil? || type == :parallel nprocs = Parallel.processor_count - 1 # it's actually faster this way puts "Running in parallel on #{nprocs} processes" -> (genotypes) do print "Fits: " fits, parall_infos = Parallel.map(0...genotypes.shape.first, in_processes: nprocs, isolation: true) do |i| # env = parall_envs[Parallel.worker_number] env = parall_envs[i] # leveraging dynamic env allocation # fit = fitness_one genotypes[i, true], env: env fits = ntrials.times.map { fitness_one genotypes[i, true], env: env } fit = fits.to_na.mean print "[m#{fit}] " [fit, compr.parall_info] end.transpose puts # newline here because I'm done `print`ing all ind fits puts "Exporting training images" parall_infos.each &compr.method(:add_from_parall_info) puts "Training optimizer" fits.to_na end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gen_fit_fn type, ntrials: nil\n type ||= :parallel\n case type\n # SEQUENTIAL ON SINGLE ENVIRONMENT\n # => to catch problems with `Parallel` env spawning\n when :sequential_single\n -> (genotypes) { genotypes.map &method(:fitness_one) }\n # SEQUENTIAL ON MULTIPLE ENVIRONMEN...
[ "0.73316866", "0.5610868", "0.55328923", "0.5483374", "0.5483374", "0.5461839", "0.542036", "0.5326921", "0.5294536", "0.5168102", "0.49848086", "0.4983288", "0.4887613", "0.48796126", "0.48698297", "0.48691118", "0.47602278", "0.47268122", "0.47265217", "0.4715118", "0.46916...
0.7254702
1
Return an action for an encoded observation The neural network is activated on the code, then its output is interpreted as a corresponding action
def action_for code output = net.activate code nans = output.isnan # this is a pretty reliable bug indicator raise "\n\n\tNaN network output!!\n\n" if nans.any? # action = output[0...6].max_index # limit to 6 actions action = output.max_index end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def action_for observation\n # TODO: continuous actions (checked at `init_env`)\n input = observation.tolist.to_a\n # TODO: probably a function generator here would be notably more efficient\n # TODO: the normalization range depends on the net's activation function!\n output = net.activate...
[ "0.73423195", "0.6029049", "0.57453024", "0.56295407", "0.55935466", "0.55935466", "0.55935466", "0.55935466", "0.5586722", "0.535108", "0.53325653", "0.53325653", "0.53325653", "0.53325653", "0.5329259", "0.5329259", "0.5329259", "0.5329259", "0.53101176", "0.5266695", "0.52...
0.7457633
0
Save experiment current state to file
def dump fname="dumps/atari_#{Time.now.strftime '%y%m%d_%H%M'}.bin" raise NotImplementedError, "doesn't work with BDNES atm" if config[:opt][:type] == :BDNES File.open(fname, 'wb') do |f| Marshal.dump( { config: config, best: opt.best.last, mu: opt.mu, sigma: opt.sigma, centrs: compr.centrs }, f) end puts "Experiment data dumped to `#{fname}`" true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_state file=nil\n App.out.write_text_files file\nend", "def save file='GOL.sav'\n File.open(file,'w') do |f|\n Marshal.dump(state,f)\n end\n end", "def save_state_if_changed\n data = ''\n @state_mutex.synchronize do\n return if @current_version == @saved_version\n data = se...
[ "0.72709334", "0.714959", "0.71045995", "0.70323086", "0.7001762", "0.6900428", "0.68939084", "0.68493694", "0.6837613", "0.6777941", "0.67706263", "0.6675716", "0.6675716", "0.66502476", "0.66332906", "0.6569457", "0.6548317", "0.6497103", "0.64881146", "0.64701843", "0.6439...
0.0
-1
Load experiment state from file
def load fname=Dir["dumps/atari_*.bin"].sort.last hsh = File.open(fname, 'r') { |f| Marshal.load f } initialize hsh[:config] opt.instance_variable_set :@best, hsh[:best] opt.instance_variable_set :@mu, hsh[:mu] opt.instance_variable_set :@sigma, hsh[:sigma] compr.instance_variable_set :@centrs, hsh[:centrs] # Uhm haven't used that yet... # what else needs to be done in order to be able to run `#show_ind` again? puts "Experiment data loaded from `#{fname}`" true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load\n statefile_filename = state_filename\n if File.exist?(statefile_filename) &&\n File.file?(statefile_filename) &&\n File.readable?(statefile_filename)\n $log.debug \"Loading state from #{statefile_filename}\"\n @state = YAML.load_file(statefile_filename)\n el...
[ "0.7093774", "0.7014233", "0.6991194", "0.6873482", "0.67228097", "0.6681344", "0.6655697", "0.64155716", "0.63604575", "0.6351798", "0.63413507", "0.63364935", "0.63364935", "0.62787664", "0.6261359", "0.625404", "0.62057805", "0.61825734", "0.61801845", "0.6169137", "0.6169...
0.6352793
9
go all the way to the right save that node as the 'parent row' go left, try to repeat "go all the way to the right" try to repeat go left go to 'parent row' repeat from 'go left' every node vistited will be nth largest
def kth_largest(node, k) largest = BinarySearchTree.maximum(node) return largest if (k==1) (1...k).each do largest = next_largest(largest) end largest end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_right_child\n # Guard condition for movement not possible\n return nil if blank_x - 1 < 0\n\n # Make the movement\n new_state = swap_right\n\n # Avoids loop\n parents_array = parent_states(3)\n return nil if parents_array.include?(new_state)\n\n # Returns new node\n Node.ne...
[ "0.6511597", "0.6508354", "0.64810616", "0.642226", "0.6399149", "0.6385493", "0.63786757", "0.6341004", "0.63172305", "0.6306539", "0.62997794", "0.6299388", "0.62524074", "0.6251893", "0.6248318", "0.6239566", "0.62389463", "0.61730915", "0.6151419", "0.61332077", "0.612478...
0.0
-1