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
Return true if one of the sample attachments is document
def contains_document? result = false sample_attachments.map{|sa| result = true if sa.is_document?} result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def document?\n self.type == \"Document\"\n end", "def document?\n self.type == \"Assetabler::Document\"\n end", "def attachments?\n self.primary_attachment.file? || self.secondary_attachment.file?\n end", "def has_attachment?\n @has_attachment ||=\n mime_parts(\"text/plain\").any? do...
[ "0.7421489", "0.72226393", "0.6975207", "0.68808115", "0.6841749", "0.6834438", "0.6796937", "0.6764376", "0.675387", "0.6752013", "0.67345655", "0.6716876", "0.6655362", "0.66215694", "0.6601603", "0.6555731", "0.65441716", "0.65441716", "0.6525107", "0.65045315", "0.6482741...
0.865764
0
Return true if one of the sample attachments is image
def contains_image? result = false sample_attachments.map{|sa| result = true if sa.is_image?} result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def image?\n attachment_content_type =~ %r{^(image|(x-)?application)/(bmp|gif|jpeg|jpg|pjpeg|png|x-png)$}\n end", "def image?\n self.file_content_type == 'image/png' || self.file_content_type == 'image/jpeg'\n end", "def is_image?\n !(attachment_content_type =~ /^image.*/).nil?\n end", "def image...
[ "0.80624455", "0.790793", "0.7903999", "0.7877861", "0.7830063", "0.77670777", "0.77140826", "0.7678046", "0.7607985", "0.75995284", "0.7590618", "0.7553504", "0.75505286", "0.7527717", "0.75230056", "0.75034297", "0.7499868", "0.74776083", "0.7396043", "0.737016", "0.7362303...
0.8637065
0
Human readable version for website
def copyright result = "" if !sample_copyright.blank? result = "&copy; " result << sample_copyright result.gsub!('(c)', '') end result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end", "def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end", "def version\n \"Version: #{VERSION.split[1]} Created on: \...
[ "0.6603192", "0.6603192", "0.660115", "0.65384257", "0.64710367", "0.6386315", "0.63385993", "0.6333561", "0.62705165", "0.62705165", "0.6260029", "0.6237924", "0.61900145", "0.61819655", "0.61813587", "0.613929", "0.61325026", "0.6128944", "0.61099386", "0.61081773", "0.6072...
0.0
-1
code should be MCH, MGL, SIB or TOD
def language=(code) self[code.downcase.to_sym] = true if code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def codes; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code(a_code)\n\t\ta_code\n\tend", "def sic_code; end", "def human_code(code)\n case code\n when 'ADM1' then :region\n when 'ADM2', 'ADM3', ...
[ "0.68896043", "0.6836776", "0.6836776", "0.6836776", "0.6836776", "0.6836776", "0.6836776", "0.6836776", "0.6798997", "0.66308326", "0.6561833", "0.6498621", "0.6476809", "0.6474828", "0.63261956", "0.6290812", "0.62755275", "0.62755275", "0.61910254", "0.6190563", "0.6177425...
0.0
-1
Get a number def prime_factors(num) Find all its factorals and add to a new array factors = [] digit = 0 num.times do digit += 1 if num % digit == 0 factors 2 factors = factors [first_factors] [1] end end return factors.reverse end
def prime_factors(num) require "prime" primes = [] Prime.each{|prime| primes << prime if num % prime ==0 ; break if prime > num } primes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prime_factors(num)\n factors = factors(num)\n result = []\n factors.each do |fac|\n if prime?(fac)\n result << fac\n end\n end\n result\nend", "def prime_factors(num)\n\tfactors = []\n\tfactor = 2\n\tremainder = num\n\n\twhile (remainder > 1) && (factor <= num)\n\t\twhile (remainder % factor...
[ "0.889975", "0.8894254", "0.885274", "0.88250196", "0.8816862", "0.87470865", "0.8746341", "0.87385416", "0.8718557", "0.87147826", "0.8710355", "0.8687355", "0.8602018", "0.85616946", "0.8514911", "0.8511658", "0.85089713", "0.8479783", "0.8447313", "0.84451723", "0.8440414"...
0.86428857
12
returns the winning player of this game
def play_recursive(deck) seen = Set.new (1..).each do key = (deck[0] + [-1] + deck[1]).join(",") return 0 if seen.include?(key) seen.add(key) cards = deck.map(&:shift) winner = if cards[0] <= deck[0].size && cards[1] <= deck[1].size d0 = deck[0].take(cards[0]) d1 = deck[1].take(cards[1]) if d0.max > d1.max 0 # P1 has to win this subgame else play_recursive([deck[0].take(cards[0]), deck[1].take(cards[1])]) end elsif cards[0] > cards[1] 0 else 1 end deck[winner] += winner.zero? ? cards : cards.reverse return 1 if deck[0].empty? return 0 if deck[1].empty? end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_winning_player\n # if one player has all the cards\n players.map{|p| @winning_player = p if p.num_cards_remaining == Deck.num_cards}\n\n # if that's not the case, take the player with the highest number of cards\n if @winning_player.blank?\n @winning_player = CardFuncs::player_with_highest...
[ "0.81247383", "0.7826455", "0.78164566", "0.7606249", "0.76027817", "0.75129366", "0.7469096", "0.7408419", "0.74073845", "0.7345442", "0.7331577", "0.73048496", "0.7299158", "0.72871983", "0.7281244", "0.7275059", "0.7268144", "0.7256346", "0.72409457", "0.72084075", "0.7202...
0.0
-1
Get the channel ID
def get_channel_id key channel = 'PewDiePie' channels = Youtube.get('/search?part=snippet&q=' + channel + '&maxResults=1&type=channel&key=' + key) #channels.each do |channel| name = channels.parsed_response['items'][0]['snippet']['title'] id = channels.parsed_response['items'][0]['id']['channelId'] p name + ': ' + id #end get_channel_vidios key end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_id(channel_name)\n return get_value_of(channel_name, :id)\n end", "def get_channel_by_name(client, channel_name)\n channel_data = client.channels_info(channel: \"#\" + channel_name.to_s)\n channel_data.channel.id\nend", "def channel id = nil\n id ||= \"#{current_user.organisation_id}#{env[...
[ "0.8354333", "0.7768983", "0.7748966", "0.7501064", "0.73682964", "0.732222", "0.729672", "0.723044", "0.7212555", "0.72069585", "0.71056676", "0.7068812", "0.7000713", "0.6901377", "0.685235", "0.6773973", "0.67490244", "0.6682024", "0.66494", "0.6642741", "0.6634713", "0....
0.73939675
4
Get the uploads playlist ID
def get_channel_vidios key channel_details = Youtube.get('/channels?part=contentDetails&id=UC-lHJZR3Gqxm24_Vd_AJ5Yw&key' + key) p channel_details get_vidio_playlist key id end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def playlist_id\n @ole.playlistID\n end", "def playlist_id\n @ole.playlistID\n end", "def playlist_id\n @ole.playlistID\n end", "def playlist_id\n @ole.playlistID\n end", "def unique_id\n playlist_id[/playlists\\/([^<]+)/, 1]\n end", "def playlist_id;\treturn @...
[ "0.81064886", "0.81064886", "0.81064886", "0.81064886", "0.7607116", "0.7586083", "0.65761936", "0.6515089", "0.6373016", "0.6358073", "0.6325484", "0.61991924", "0.619332", "0.6189471", "0.6142936", "0.61340433", "0.61340433", "0.61340433", "0.61340433", "0.61340433", "0.613...
0.0
-1
Get videos using playlist ID
def get_vidio_playlist key id #playlstId is the Uploads ID in channel_details channel_vidios = Youtube.get('/playlistItems?part=snippet&playlistId=UU-lHJZR3Gqxm24_Vd_AJ5Yw&key=' + key) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_folder_videos folder_id, **args\n get(\"/projects/#{folder_id}/videos\", args)\n end", "def get_playlist_vids(playlist)\n Log.log.debug \"Returning playlist vids\"\n vids = Array.new\n playlist.playlist_items.each {|item| vids << item.video_id}\n return vids\nend", "def get_album_videos...
[ "0.7393167", "0.7364249", "0.72655493", "0.72349536", "0.7198465", "0.7108157", "0.70506155", "0.6948062", "0.69414", "0.68620986", "0.6840494", "0.6794294", "0.6747574", "0.67393523", "0.67171973", "0.6639431", "0.65199244", "0.6486782", "0.645982", "0.6438722", "0.6438313",...
0.76672584
0
GET /work_articles GET /work_articles.json
def index @search_work_articles = policy_scope(WorkArticle).ransack(params[:q]) @work_articles = @search_work_articles.result.paginate(page: params[:page], per_page: 20).order(:name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def articles\n @articles = Article.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @administration }\n end\n end", "def get_works\n tag = params['query']\n\n @articles = get_articles(tag)\n \n @found = 1 \n if @articles.nil?\n @ms...
[ "0.73301977", "0.7054169", "0.7041821", "0.695864", "0.689784", "0.689784", "0.689784", "0.689784", "0.689784", "0.689784", "0.67780364", "0.6772931", "0.66936994", "0.66910684", "0.65991527", "0.659814", "0.659814", "0.65616906", "0.65373474", "0.65065885", "0.6460646", "0...
0.6166993
93
GET /work_articles/1 GET /work_articles/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def articles\n @articles = Article.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @administration }\n end\n end", "def show\n @article = Article.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n form...
[ "0.7132787", "0.69501626", "0.6840519", "0.6797638", "0.6797638", "0.6797638", "0.6797638", "0.6797638", "0.6797638", "0.67430466", "0.6661601", "0.6661601", "0.66515404", "0.6640694", "0.6640694", "0.6621609", "0.6612178", "0.6611792", "0.66049486", "0.6583861", "0.6583861",...
0.0
-1
POST /work_articles POST /work_articles.json
def create @work_article = WorkArticle.new(work_article_params) respond_to do |format| if @work_article.save format.html { redirect_to @work_article, notice: t('notifications_masc.success.resource.created', resource: t('work_articles.form.resource')) } format.json { render :show, status: :created, location: @work_article } else format.html { render :new } format.json { render json: @work_article.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CreateArticle params = {}\n \n APICall(path: 'help_center/articles.json',method: 'POST',payload: params.to_json)\n \n end", "def create\n @article = article_create(params[:article])\n @article.save\n respond_with(@article)\n end", "def new\n 1.times { @work.work_docum...
[ "0.6688001", "0.6559612", "0.64289474", "0.6302313", "0.6291157", "0.62713116", "0.6265053", "0.6246627", "0.62459236", "0.62459236", "0.62459236", "0.62459236", "0.62459236", "0.62459236", "0.62459236", "0.62459236", "0.62459236", "0.62459236", "0.62459236", "0.6245551", "0....
0.7352004
0
PATCH/PUT /work_articles/1 PATCH/PUT /work_articles/1.json
def update respond_to do |format| if @work_article.update(work_article_params) format.html { redirect_to @work_article, notice: t('notifications_masc.success.resource.updated', resource: t('work_articles.form.resource')) } format.json { render :show, status: :ok, location: @work_article } else format.html { render :edit } format.json { render json: @work_article.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def UpdateArticle id,params = {}\n \n APICall(path: \"help_center/articles/#{id}.json\",method: 'PUT',payload: params.to_json)\n \n end", "def update\n @article = article_get(params[:id])\n @article.update(params[:article])\n respond_with(@article)\n end", "def update\n@arti...
[ "0.683489", "0.66110164", "0.6573552", "0.65556955", "0.651049", "0.65005606", "0.65005606", "0.65005606", "0.65005606", "0.65005606", "0.65005606", "0.65005606", "0.65005606", "0.65005606", "0.65005606", "0.6486083", "0.64733094", "0.64401406", "0.6435243", "0.6435243", "0.6...
0.71084225
0
DELETE /work_articles/1 DELETE /work_articles/1.json
def destroy @work_article.destroy respond_to do |format| format.html { redirect_to work_articles_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @journalarticle.destroy\n respond_to do |format|\n format.html { redirect_to journalarticles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @article = Article.find(params[:id]) \n @article.destroy\n\n respond_to do |format|\n format.html {...
[ "0.7500433", "0.7470679", "0.7420912", "0.74196225", "0.74196225", "0.74196225", "0.74196225", "0.74196225", "0.74196225", "0.74196225", "0.74196225", "0.74196225", "0.74196225", "0.74196225", "0.74196225", "0.74196225", "0.74196225", "0.74196225", "0.74196225", "0.74196225", ...
0.7961522
0
Use callbacks to share common setup or constraints between actions.
def set_work_article @work_article = WorkArticle.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 work_article_params params.require(:work_article).permit(:name) 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
authenticate user from Authorization in header with exception
def authenticate_user_from_token! raise AuthorizationError unless http_auth_token.present? result = find_user raise BadRequestError, result.errors if result.failure? @current_user = result.current_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n\n if auth_token\n authenticate_with_auth_token auth_token\n # else\n # authentication_error\n end\n end", "def api_auth\n api_response(403, \"Invalid Authorization header\") unless api_user\n end", "...
[ "0.75618136", "0.7310267", "0.72970605", "0.7292798", "0.7292798", "0.7277463", "0.7274242", "0.72593033", "0.72115874", "0.719499", "0.71845114", "0.7161912", "0.7058513", "0.7043703", "0.7036322", "0.70192903", "0.6994457", "0.6993735", "0.69927114", "0.6984404", "0.6971709...
0.0
-1
we use this method for pundit
def current_user @current_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pundit_user\n \t\tcurrent_admin # current_user to Pundit\n \tend", "def pundit_user\n \tcurrent_usuario\n end", "def pundit_user\n current_admin\n end", "def pundit_user\n current_identity\n end", "def pundit_user\n current_account\n end", "def pundit_user\n current_account\n end"...
[ "0.7515788", "0.7068918", "0.69680405", "0.69364405", "0.68814635", "0.68814635", "0.68785286", "0.6876919", "0.6798753", "0.6723019", "0.6526726", "0.652256", "0.650269", "0.62754637", "0.61722434", "0.6142716", "0.603697", "0.60058165", "0.59591097", "0.59526634", "0.594908...
0.0
-1
get token from Authorization in header
def http_auth_token auth_token = request.env["HTTP_AUTHORIZATION"] auth_token.split(" ").last if auth_token.present? && auth_token.split(" ").first.downcase == "bearer" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_token\n request.headers[\"Authorization\"]\n end", "def token\n request.headers['Authorization']\n end", "def token\n request.headers[\"Authorization\"]\n end", "def get_token\n if params.has_key?(:token) && params[:token] != ''\n return params[:token]\n end\n return nil if ...
[ "0.88675475", "0.8747401", "0.87448275", "0.84464043", "0.839679", "0.8341332", "0.82408357", "0.8167599", "0.81653386", "0.8159444", "0.8159444", "0.8128708", "0.8114116", "0.80961823", "0.8070175", "0.80604315", "0.8044625", "0.8034098", "0.80182904", "0.80138147", "0.79972...
0.79289484
23
This function promises not to raise an error
def render(gist_file_key) # REFACTOR I'd rather be composing functions. @renders_code.render(@downloads_gist.download(gist_file_key)) rescue => oops # I tried to do this with an HTML comment, # but a RubyPants filter ate my --> delimeters, # so I opted for Javascript comments, instead. # Wow. StringIO.new.tap { |canvas| canvas.puts "<script>", "/*", oops.message, oops.backtrace, "*/", "</script>" }.string end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __force__\n if @result.equal?(NOT_SET)\n @mutex.synchronize do\n if @result.equal?(NOT_SET)\n begin\n @result = @promise.wait_for_result(@timeout)\n @result = @result[@attr] if @attr && !@result[\"error\"]\n rescue ::Exception => exc\n @result =...
[ "0.6044188", "0.59794044", "0.5940914", "0.59208167", "0.5868734", "0.5860352", "0.5850743", "0.5813882", "0.5788706", "0.5780877", "0.5777846", "0.57516354", "0.5740844", "0.5732468", "0.57182896", "0.57182896", "0.57182896", "0.56993973", "0.5693436", "0.56570125", "0.56503...
0.0
-1
REFACTOR Move this onto a collaborator
def http_get(base, uri) faraday_with_default_adapter(base) { | connection | connection.use FaradayMiddleware::FollowRedirects, limit: 1 }.get(uri) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_collaborator\n @collaborator = Collaborator.find(params[:id])\n end", "def set_collaborator\n @collaborator = Collaborator.find(params[:id])\n end", "def set_collaborator\n @collaborator = Collaborator.find(params[:id])\n end", "def set_collaborator\n @collaborator = Collabor...
[ "0.6215534", "0.6173932", "0.6173932", "0.6173932", "0.6173932", "0.6173932", "0.6081682", "0.59296286", "0.59296286", "0.5867952", "0.5777919", "0.570344", "0.5636567", "0.5628484", "0.5604114", "0.5604114", "0.55919105", "0.55676323", "0.5567253", "0.555775", "0.55244964", ...
0.0
-1
REFACTOR Move this into Faraday REFACTOR Rename this something more intentionrevealing
def faraday_with_default_adapter(base, &block) Faraday.new(base) { | connection | yield connection # IMPORTANT Without this line, nothing will happen. connection.adapter Faraday.default_adapter } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def faraday_builder(builder)\n end", "def faraday\n @faraday ||= Faraday.new ssl: { verify: ssl_verify } do |faraday|\n authenticate!(faraday)\n\n faraday.request(:retry, max: retries) if retries\n faraday.options.timeout = read_timeout if read_timeout\n faraday.options.open_tim...
[ "0.6377548", "0.5850608", "0.562706", "0.5443524", "0.5443524", "0.54413295", "0.5253775", "0.5184856", "0.51795983", "0.51782435", "0.5157986", "0.51531726", "0.51531726", "0.51531726", "0.51385236", "0.5100713", "0.5086503", "0.50772566", "0.5066887", "0.5066887", "0.505272...
0.501084
24
Add aditional paths where the plugin should be looking for .less files with `LessForRails.paths << "my/path/here"`.
def paths @paths ||= [STYLESHEETS_PATH] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def append_paths\n @append_paths ||= begin\n Wedge::Opal.append_path method(:assets_url).source_location.first.sub('/wedge.rb', '')\n Wedge::Opal.append_path \"#{Dir.pwd}/#{config.app_dir}\"\n end\n end", "def append_paths\n @append_paths ||= begin\n Wedge::Op...
[ "0.6465885", "0.6345045", "0.6204859", "0.6059806", "0.59756106", "0.5825569", "0.57737875", "0.5720633", "0.56951225", "0.5692893", "0.5688428", "0.56875986", "0.55963564", "0.5575312", "0.55725056", "0.55489904", "0.5537281", "0.55282354", "0.5524732", "0.5520578", "0.54976...
0.0
-1
Converts all .less files in +paths+ to STYLESHEETS_PATH/[filename].css. Options: compress Remove all newlines? `true` or `false`.
def run(options = {}) paths.map {|path| Dir["#{path}/*.less"]}.flatten.each {|less_source| destination_filename = "#{File.basename(less_source, File.extname(less_source))}.css" destination = "#{STYLESHEETS_PATH}/#{destination_filename}" if !File.exists?(destination) || File.stat(less_source).mtime > File.stat(destination).mtime engine = Less::Engine.new(File.read(less_source)) css = Less.version > "1.0" ? engine.to_css : engine.to_css(:desc) css.delete!("\n") if options[:compress] File.open(destination, "w") {|file| file.write HEADER % [destination_filename] if Rails.env == "development" file.write css } end } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(options = {})\n paths.each do |path|\n Dir.chdir(path) do\n Dir[\"**/*.less\"].each do |less_sheet|\n directory = File.dirname(less_sheet)\n target_filename = File.basename(less_sheet, File.extname(less_sheet)) + \".css\"\n destination = \"#{directory}/#{target_fil...
[ "0.7510991", "0.6587842", "0.648634", "0.6003342", "0.58771884", "0.57534343", "0.57087606", "0.5706346", "0.564547", "0.5538915", "0.5530495", "0.5498455", "0.5482426", "0.54446524", "0.5368469", "0.5366193", "0.5358923", "0.53150177", "0.5286185", "0.52545947", "0.52465004"...
0.74376744
1
GET /activities GET /activities.json
def index # default show activities starting two months ago from_date = Time.now - 2.months to_date = Time.now + 2.months if(params.has_key?(:start_date)) from_date = Time.parse(params[:start_date]) - 3.months to_date = Time.parse(params[:start_date]) + 3.months end @activities = Activity.includes(:activity_type).where("user_id=? and start>=? and start<=?", current_user.id, from_date, to_date) total_duration = Activity.where("user_id=?", current_user.id).group(:user_id).sum(:duration)[1] @total_hours = 0 @total_minutes = 0 if !total_duration.nil? @total_hours = total_duration / 60 @total_minutes = total_duration % 60 end #total calories sql = <<-SQL SELECT activities.user_id, SUM(activities.duration*activity_types.calories_factor) as calories FROM activities JOIN activity_types ON activities.activity_type_id = activity_types.id WHERE activities.user_id=#{ActiveRecord::Base.connection.quote(current_user.id)} GROUP BY activities.user_id SQL first = Activity.find_by_sql(sql).first @total_calories = first.nil? ? 0 : first.calories # favorite activity calculated as activity type with longest duration favorite = ActivityType.select('activity_types.id, activity_types.name') .left_joins(:activities) .where("activities.user_id=?", current_user.id) .group('activity_types.id') .sum('activities.duration') sql = <<-SQL SELECT activity_types.id, activity_types.name, SUM(activities.duration) as duration FROM activity_types JOIN activities ON activities.activity_type_id = activity_types.id WHERE activities.user_id=#{ActiveRecord::Base.connection.quote(current_user.id)} GROUP BY activity_types.id ORDER BY duration DESC SQL first = ActivityType.find_by_sql(sql).first @favorite_activity_type = first.nil? ? "-" : first.name # duration per day for last 30 days if Rails.env.production? sql = <<-SQL SELECT date_trunc('day', start) "start_date", SUM(duration) as duration FROM activities WHERE user_id=#{ActiveRecord::Base.connection.quote(current_user.id)} AND start<=#{ActiveRecord::Base.connection.quote(Time.now)} AND start>=#{ActiveRecord::Base.connection.quote(Time.now - 31.days)} GROUP BY 1 SQL data = Activity.find_by_sql(sql).map{ |i| {start: i[:start_date].strftime("%F"), duration: i[:duration]} } .each_with_object({}) { |k, h| h[k[:start]] = {:duration => k[:duration] } } else sql = <<-SQL SELECT SUM(duration) as duration, date(start) as start_date FROM activities WHERE user_id=#{ActiveRecord::Base.connection.quote(current_user.id)} AND start<=#{ActiveRecord::Base.connection.quote(Time.now)} AND start>=#{ActiveRecord::Base.connection.quote(Time.now - 31.days)} GROUP BY date(start) SQL data = Activity.find_by_sql(sql).index_by { |t| t.start_date } end @minutes_data = {} (0..30).each { |i| i = 30 - i day = (Time.now - i.days).to_date count = 0 if !data[day.strftime("%F")].nil? count = data[day.strftime("%F")][:duration] end @minutes_data[day.strftime("%b %d")] = count } # calories per day for last 30 days if Rails.env.production? sql = <<-SQL SELECT date_trunc('day', start) "start_date", SUM(activities.duration*activity_types.calories_factor) as calories FROM activities JOIN activity_types ON activities.activity_type_id = activity_types.id WHERE user_id=#{ActiveRecord::Base.connection.quote(current_user.id)} AND start<=#{ActiveRecord::Base.connection.quote(Time.now)} AND start>=#{ActiveRecord::Base.connection.quote(Time.now - 31.days)} GROUP BY 1 SQL data = Activity.find_by_sql(sql).map{ |i| {start: i[:start_date].strftime("%F"), calories: i[:calories]} } .each_with_object({}) { |k, h| h[k[:start]] = {:calories => k[:calories] } } else sql = <<-SQL SELECT SUM(activities.duration*activity_types.calories_factor) as calories, date(start) as start_date FROM activities JOIN activity_types ON activities.activity_type_id = activity_types.id WHERE activities.user_id=#{ActiveRecord::Base.connection.quote(current_user.id)} AND start<=#{ActiveRecord::Base.connection.quote(Time.now)} AND start>=#{ActiveRecord::Base.connection.quote(Time.now - 31.days)} GROUP BY date(activities.start) SQL data = Activity.find_by_sql(sql).index_by { |t| t.start_date } end @calories_data = {} (0..30).each { |i| i = 30 - i day = (Time.now - i.days).to_date count = 0 if !data[day.strftime("%F")].nil? count = data[day.strftime("%F")][:calories] end @calories_data[day.strftime("%b %d")] = count } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def activities\n get_call(\"1/activities.json\")\n end", "def activities(params = {})\n scope 'default'\n get('activities/', params)\n end", "def activity(id)\n get(\"/activities/#{id}.json\")\n end", "def activity(id)\n get(\"/activities/#{id}.json\")\n end", "def acti...
[ "0.87229973", "0.8237991", "0.8174613", "0.8174613", "0.81609166", "0.8031665", "0.7980325", "0.79700005", "0.795089", "0.7611846", "0.7541555", "0.752615", "0.7450007", "0.74256104", "0.74131006", "0.7386156", "0.73540217", "0.7342527", "0.7318892", "0.7318892", "0.72758335"...
0.0
-1
GET /activities/1 GET /activities/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def activity(id)\n get(\"/activities/#{id}.json\")\n end", "def activity(id)\n get(\"/activities/#{id}.json\")\n end", "def activities\n get_call(\"1/activities.json\")\n end", "def show\n begin\n @activity = PublicActivity::Activity.all.find(params[:id])\n rescue ActiveRec...
[ "0.83788407", "0.83788407", "0.8096585", "0.7685623", "0.7667807", "0.76401794", "0.7609177", "0.75712854", "0.75329125", "0.74525696", "0.74308854", "0.7332175", "0.73110914", "0.72872484", "0.7285642", "0.7231286", "0.7206347", "0.7206347", "0.7189005", "0.7184855", "0.7056...
0.0
-1
POST /activities POST /activities.json
def create @activity = Activity.new(activity_params) @activity.user = current_user respond_to do |format| if @activity.save format.html { redirect_to activities_path, notice: 'Activity was successfully created.' } format.json { render :show, status: :created, location: @activity } else format.html { render :new } format.json { render json: @activity.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @activity = @user.activities.create(activity_params)\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to @activity, notice: 'Exercise event was successfully created.' }\n format.json { render :show, status: :created, location: @activity }\n else\n ...
[ "0.7249106", "0.70048165", "0.6964346", "0.6956599", "0.69475126", "0.6929332", "0.69046366", "0.6889496", "0.6862793", "0.6838635", "0.68081975", "0.68079776", "0.68079776", "0.6798919", "0.677082", "0.6740217", "0.67014927", "0.6675203", "0.6665923", "0.6659741", "0.6649729...
0.68420047
9
PATCH/PUT /activities/1 PATCH/PUT /activities/1.json
def update respond_to do |format| if @activity.update(activity_params) format.html { redirect_to activities_path, notice: 'Activity was successfully updated.' } format.json { render :show, status: :ok, location: @activity } else format.html { render :edit } format.json { render json: @activity.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n @activity.status = Activity::SETTED if @activity.setting?\n if @activity.update(activity_params)\n format.html { redirect_to activities_url, notice: 'Activity was successfully updated.' }\n format.json { head :no_content }\n else\n format...
[ "0.68846226", "0.6830872", "0.68169534", "0.6812194", "0.6807588", "0.6776597", "0.67556393", "0.67556393", "0.67556393", "0.67556393", "0.67556393", "0.66643053", "0.66625977", "0.66621685", "0.6638061", "0.6626543", "0.6626543", "0.6626543", "0.66030794", "0.659587", "0.658...
0.6700775
11
DELETE /activities/1 DELETE /activities/1.json
def destroy @activity.destroy respond_to do |format| format.html { redirect_to activities_url, notice: 'Activity was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @activity.destroy\n respond_to do |format|\n format.html { redirect_to activities_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @activity.destroy\n respond_to do |format|\n format.html { redirect_to activities_url }\n format.json { head :n...
[ "0.7712568", "0.7712568", "0.7712568", "0.7712568", "0.7712568", "0.76978153", "0.7688336", "0.7663404", "0.7663404", "0.76458544", "0.76458544", "0.7643713", "0.7564872", "0.75457203", "0.745816", "0.73909366", "0.73904556", "0.73481995", "0.73416245", "0.7341086", "0.733206...
0.73731923
21
Use callbacks to share common setup or constraints between actions.
def set_activity @activity = Activity.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 activity_params params.fetch(:activity, {}).permit( :name, :start, :duration, :activity_type_id ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.6981269", "0.6783559", "0.6746007", "0.67423046", "0.6735905", "0.6593568", "0.6504213", "0.649792", "0.6482664", "0.6478558", "0.64566684", "0.64392304", "0.6380194", "0.6376366", "0.636562", "0.63208145", "0.63006365", "0.63001287", "0.6292953", "0.62927175", "0.62911004...
0.0
-1
convert_to_bytes(512, 'KB') => 524288 convert_to_bytes(1, 'MB') => 1048576
def convert_to_bytes(size, unit) size.to_f * UNITS_FACTOR[unit] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bytes_to_mb bytes=0\n bytes / MEGABYTE\n end", "def bytes_from_kb kb\n\tb = (kb * 1024.0).round\nend", "def input_to_bytes(size)\n case size\n when /m|mb/i\n size.to_i * (1024**2)\n when /t|tb/i\n size.to_i * (1024**4)\n else\n # default is gigabytes\n si...
[ "0.8044445", "0.780757", "0.7569341", "0.7409043", "0.7400507", "0.7327545", "0.7217593", "0.7189837", "0.71879673", "0.7100591", "0.7099529", "0.6972461", "0.6972461", "0.6749323", "0.6644065", "0.6630765", "0.6593968", "0.6512339", "0.6504098", "0.6500832", "0.6498892", "...
0.71189374
9
execute cassandra's nodetool and return output as string
def nodetool_cmd(cmd) `nodetool -h #{config[:hostname]} -p #{config[:port]} #{cmd}` end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nodetool_info()\n out = `/opt/cassandra/bin/nodetool info`\n if $? == 0\n props = {}\n out.split(\"\\n\").each do |line|\n p = line.split(':')\n props[p.first.strip] = p.last.strip\n end\n return props\n else\n Chef::Log.warn(\"nodetool info failed with #{out}\")...
[ "0.729716", "0.7255151", "0.65591836", "0.64272225", "0.62905943", "0.6068972", "0.55621904", "0.5561114", "0.553326", "0.5374738", "0.53602976", "0.5345723", "0.533696", "0.5305658", "0.5277773", "0.52724266", "0.5243136", "0.5241147", "0.51969904", "0.5177964", "0.5145338",...
0.7289284
1
$ nodetool status Datacenter: LON5 ================ Status=Up/Down |/ State=Normal/Leaving/Joining/Moving Address Load Tokens Owns Host ID Rack UN 172.16.1.1 1.88 GB 256 ? 5uu5274d0c1c46f1b73cc28ffdcad10e A125 DN 172.16.1.2 2.55 GB 256 ? 4uu6478c0e29468cad38f417ccbcf403 A125 UL 172.16.1.3 3.24 GB 256 ? fuu0063da0334a7895e840a479d99a6b A125 UJ 172.16.1.4 4.92 GB 256 ? 1uuace8eaf9c4eff99771a34c09c5535 A125 UN 172.16.1.5 5.22 GB 256 ? 7uu9ee6cf0934fa0874b3f5bcaa5b952 A125
def parse_ndstatus# rubocop:disable all nodestatus = nodetool_cmd('status') nodestatus.each_line do |line| next if line.match(/^Datacenter:/) next if line.match(/^=======/) next if line.match(/^Status/) next if line.match(/State/) next if line.match(/^--/) next if line.match(/^Note/) if m = line.match(/^UN\s\s(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/)# rubocop:disable all address = m[1] ndstatus_attr = {"node.#{address}.status" => 'UN'} else m = line.match(/(\w+)\s\s(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/) address = m[2] ndstatus = m[1] ndstatus_attr = {"node.#{address}.status" => ndstatus} critical ndstatus_attr.to_json end ok ndstatus_attr.to_json end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nodetool_status()\n out = `/opt/cassandra/bin/nodetool status`\n raise 'nodetool status failed' if $? != 0\n rows = out.split(\"\\n\")\n hash = {}\n dc_exp = /Datacenter: (.*)/\n #vnode\n #-- Address Load Tokens Owns Host ID Rack\n #non-v...
[ "0.7737813", "0.6181872", "0.61708474", "0.6081172", "0.60521984", "0.60478556", "0.60059553", "0.5970989", "0.5956296", "0.59406185", "0.587981", "0.58758706", "0.5836375", "0.5666798", "0.5561863", "0.55394286", "0.5536466", "0.553646", "0.5511233", "0.55034906", "0.5483987...
0.6368932
1
Return the default locale for the object
def default_locale evaluate_localization_option!(:default_locale) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_locale\n @default_locale ||= self.languages.get_default.code.to_sym\n end", "def default_locale\n return nil unless localized?\n u_lc = I18n.locale.to_sym\n available_locales.include?(u_lc) ? u_lc : available_locales[0]\n end", "def default_locale\n self.found_l...
[ "0.85959285", "0.85721165", "0.8507327", "0.84019864", "0.84001434", "0.8325649", "0.8325224", "0.8095079", "0.8036071", "0.7681259", "0.7654299", "0.76017535", "0.7587714", "0.7577989", "0.7527154", "0.75127846", "0.74955946", "0.74854386", "0.74854386", "0.74168646", "0.738...
0.8614655
0
Return if the object falls back on translations
def locale_fallback? evaluate_localization_option!(:fallback) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translated?(name)\r\n self.class.translated?(name)\r\n end", "def translated?(name)\n self.class.translated?(name)\n# self.class.instance_variable_get(translated_attribute_names).include?(name.to_sym)\n end", "def translated?\n return false if obsolete? || fuzzy?\n not ...
[ "0.7918369", "0.7449263", "0.7323963", "0.72721076", "0.7149266", "0.6986841", "0.6977304", "0.6875715", "0.6785967", "0.6759831", "0.6674717", "0.6673803", "0.6640978", "0.6640877", "0.6577027", "0.6575014", "0.65712094", "0.6516844", "0.65053403", "0.64069664", "0.639928", ...
0.62136817
30
Return the missing translation placeholder
def missing_translation_placeholder field evaluate_localization_option!(:placeholder, field) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def t(key, default = '')\n c = I18n.t(key)\n if c.match(/translation missing/i)\n c = I18n.t(key, locale: 'en') \n # Still not found. Return default if set\n c = default unless default.blank?\n end\n c\nend", "def missing_translations\n @translations.select { |x, v| v.nil? or v.blank? }\n en...
[ "0.69179493", "0.69086456", "0.68666464", "0.64853626", "0.6466796", "0.63806796", "0.6345606", "0.63341725", "0.62771535", "0.62229925", "0.61943775", "0.619145", "0.6030112", "0.60056806", "0.5980776", "0.5962088", "0.5919397", "0.5820558", "0.58130896", "0.58051103", "0.57...
0.8087824
0
Return if a translation in the language is stored in all translated fields
def has_locale? locale locales.include?(locale.to_sym) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def localized?\n self.entries_custom_fields.where(localized: true).count > 0\n end", "def translated\n find_all do |entry|\n entry.translated?\n end\n end", "def fully_translated?\n locale_counts.all? do |locale_code, _|\n fully_translated_in?(locale_code)\n e...
[ "0.74261355", "0.7330008", "0.7063302", "0.6832085", "0.68235123", "0.6786202", "0.6767671", "0.67632145", "0.6759438", "0.6566927", "0.64375037", "0.6410383", "0.6357061", "0.6337027", "0.6288107", "0.62561125", "0.62122977", "0.6181754", "0.61224574", "0.6075228", "0.605644...
0.0
-1
Return all the available locales
def available_locales evaluate_localization_option!(:available_locales) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_locales\n configatron.full_locales | preferred_locales\n end", "def available_locales\n self.locales.map { |locale| locale.to_sym }\n end", "def locales\n map(&:locale)\n end", "def available_locales\n resource.translations.all(:fields => [:locale_tag], :unique => true).map {...
[ "0.82769537", "0.82641137", "0.82060885", "0.81328046", "0.8121446", "0.80905735", "0.80225116", "0.79661775", "0.7942778", "0.7942778", "0.7938168", "0.79207426", "0.7909326", "0.7909326", "0.78533924", "0.78366935", "0.7824782", "0.7758507", "0.76867324", "0.7621388", "0.75...
0.8062866
6
Return if a locale is theoretically available in all translated fields
def has_available_locale? locale available_locales.include?(locale.to_sym) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def localized?\n self.entries_custom_fields.where(localized: true).count > 0\n end", "def locale_available?(locale); end", "def fully_translated?\n locale_counts.all? do |locale_code, _|\n fully_translated_in?(locale_code)\n end\n end", "def localized?\n self.loca...
[ "0.7883965", "0.77944505", "0.76884496", "0.7644414", "0.7344893", "0.732136", "0.7238932", "0.7126837", "0.7065136", "0.70281917", "0.700737", "0.69955033", "0.69032913", "0.6899956", "0.6871603", "0.686387", "0.68426937", "0.68056726", "0.67910546", "0.6739507", "0.6736319"...
0.6986671
12
needed by Layouter code, but slots are no physical elements so they
def update_position end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_slot\n @sol.to_parfait\n @sol.to_slot(nil)\n end", "def initialize:\n\t\t@slots = []", "def slot(slot, node, carrier)\n type =\n if slot.carrier == :loss\n :loss\n elsif slot.is_a?(Atlas::Slot::Elastic)\n :elastic\n elsif slot.is_a?(At...
[ "0.6658211", "0.6370766", "0.6256086", "0.62354", "0.61396736", "0.61171", "0.6086028", "0.5884372", "0.5861047", "0.5823541", "0.57861555", "0.57166207", "0.5708245", "0.568806", "0.5628054", "0.55974954", "0.5574558", "0.5559149", "0.55546427", "0.5508113", "0.5505619", "...
0.0
-1
Initialize an empty deque
def initialize @size = 0 @head = nil @tail = nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n @queue = []\n end", "def initialize()\n @head = nil\n @tail = nil\n @size = 0\n end", "def initialize\n\t\t@head = nil\n\t\t@tail = nil\n\t\t@size = 0\n\tend", "def initialize\r\n @head = nil\r\n @tail = nil\r\n @size = 0\r\n end", ...
[ "0.6575215", "0.64758325", "0.6460147", "0.637764", "0.63326675", "0.6329373", "0.6318055", "0.6318055", "0.6314551", "0.62854624", "0.6274274", "0.62731194", "0.6252542", "0.6235091", "0.6157755", "0.6149349", "0.6145578", "0.61340404", "0.61147696", "0.6090631", "0.6083209"...
0.6464164
2
Add an element at the head of the deque
def add_first(elt) @head = Node.new(elt, @head, nil) if @size == 0 @tail = @head else @head.next.previous = @head end @size += 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_first element\n if empty?\n @head = @tail = Node.new(element, nil, nil)\n else\n @head.prev_node = Node.new(element, nil, @head)\n @head = @head.prev_node\n end\n @size += 1\n\n return nil\n end", "def add_first element\n if empty?\n @head = @tail = Node.new(element...
[ "0.71718776", "0.7152099", "0.709413", "0.7020722", "0.69583607", "0.6908876", "0.6885184", "0.6850977", "0.6790398", "0.67551196", "0.67534876", "0.6712128", "0.668987", "0.66831625", "0.6667313", "0.6644701", "0.6644701", "0.6639194", "0.66376436", "0.66360104", "0.66278607...
0.6736225
11
Add an element at the end of the deque
def add_last(elt) @tail = Node.new(elt, nil, @tail) if @size == 0 @head = @tail else @tail.previous.next = @tail end @size += 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add element\n add_last(element)\n end", "def add element\n add_last(element)\n end", "def add_to_end(arr, element)\n arr.push(element)\nend", "def add_last element\n if empty?\n @head = @tail = Node.new(element, nil)\n else\n @tail.next_node = Node.new(element, nil)\n @tail ...
[ "0.71994746", "0.71994746", "0.69432664", "0.68547195", "0.6836447", "0.6803938", "0.67154723", "0.66582334", "0.65827245", "0.65765584", "0.6573239", "0.65594447", "0.6558524", "0.65470135", "0.6528902", "0.64545286", "0.64086086", "0.6403032", "0.6402555", "0.64009315", "0....
0.6241681
33
Remove the node at the end of the list and returns its value
def remove_last raise 'No such element' if @size == 0 elt = @tail.value if @size == 1 @head = nil @tail = nil else @tail = @tail.previous @tail.next.previous = nil @tail.next = nil end @size -= 1 return elt end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_last\n raise 'Cannot remove element from an empty list.' if empty?\n\n # Extract the data off of the tail node\n # Move the tail to the previous node\n data = @tail.data\n @tail = @tail.prev_node\n @size -= 1\n\n # removes the same element from @head, if it was final element/node\n ...
[ "0.76912916", "0.76468843", "0.76380104", "0.7616181", "0.7535436", "0.7535436", "0.7514628", "0.746096", "0.7437617", "0.7427888", "0.7426113", "0.7405219", "0.7369827", "0.73540777", "0.73195404", "0.72737217", "0.7241131", "0.7230956", "0.7210715", "0.7208132", "0.71975386...
0.7675069
1
Remove the node at the head of the list and returns its value
def remove_first raise 'No such element' if @size == 0 elt = @head.value if @size == 1 @head = nil @tail = nil else @head = @head.next @head.previous.next = nil @head.previous = nil end @size -= 1 return elt end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def removeHead\n\t\tif @head != nil\n\t\t\tn = @head\n\t\t\t@head = n.nnode\n\t\t\tn.nnode = nil\n\t\t\treturn n.value\n\t\tend\n\tend", "def remove_head\n\t\t\n\t\told_head = @head\n\n\t\tif old_head == nil\n\t\t\treturn nil\n\t\telse\n\t\t\t@head = old_head.next_node\n\t\tend\n\n\t\t# puts old_head.value\n\t\t...
[ "0.8311415", "0.8106559", "0.7862039", "0.77952874", "0.76625776", "0.76200795", "0.76066524", "0.7597276", "0.75774556", "0.7534276", "0.75270677", "0.74867284", "0.7445589", "0.7428676", "0.74150246", "0.7396701", "0.73635495", "0.7359819", "0.7347589", "0.7334746", "0.7326...
0.7544278
9
Return the first element without removing it
def peek_first raise 'No such element' if @size == 0 @head.value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def first\n @elements.empty? ? nil : @elements[0]\n end", "def remove_first\n raise 'No such element' if @size == 0\n elt = @head.value\n if @size == 1\n @head = nil\n @tail = nil\n else\n @head = @head.next\n @head.previous.next =...
[ "0.8110836", "0.76667196", "0.76622605", "0.76447797", "0.7541724", "0.7410077", "0.7369735", "0.73661494", "0.7344158", "0.7320723", "0.7298379", "0.72421014", "0.72421014", "0.72261304", "0.71881384", "0.71868694", "0.7156937", "0.71438116", "0.71323836", "0.7078111", "0.70...
0.7434083
5
Return the last element without removing it
def peek_last raise 'No such element' if @size == 0 @tail.value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def last\n all[all.size - 1]\n end", "def last\n @ordered_elements.last\n end", "def last\n self.slice(self.size - 1)\n end", "def remove_last\n raise 'No such element' if @size == 0\n elt = @tail.value\n if @size == 1\n @head = nil\n @tail = nil\n ...
[ "0.80725735", "0.7964494", "0.79640603", "0.79158497", "0.7905291", "0.7895912", "0.78623027", "0.78465277", "0.7833645", "0.7832916", "0.7814255", "0.7789193", "0.7780709", "0.7772687", "0.77211624", "0.7698924", "0.7688206", "0.7605398", "0.7603993", "0.7597297", "0.7584099...
0.7988893
1
Is the deque empty ?
def empty? @size == 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def empty?\n @que.empty?\n end", "def empty?\n @que.empty?\n end", "def empty?\n @que.empty?\n end", "def empty?\n @que.empty?\n end", "def is_empty()\n @queue.count { _1 } == 0\n end", "def is_empty()\n @queue.size == 0\n end", "def empty?\n # @head and @tail are equal t...
[ "0.8433691", "0.83238953", "0.83238953", "0.83238953", "0.815359", "0.8150619", "0.8074313", "0.79508775", "0.79508775", "0.79508775", "0.7940231", "0.79050887", "0.78901756", "0.7872357", "0.7866937", "0.77244616", "0.77026004", "0.7689538", "0.76545227", "0.76545227", "0.76...
0.75520414
32
Iterate through the elements from first to last
def each current = @head while current != nil yield current.value current = current.next end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each(&block)\n (@first .. @last).each(&block)\n end", "def each(first = 0, last = @rows.count - 1)\n index = first\n while index <= last\n yield(@rows[index], index)\n\n index += 1\n end\n end", "def each\n (@first..@last).each {|addr| yield addr}\n end", "...
[ "0.73530495", "0.6462952", "0.6411263", "0.64104784", "0.6395315", "0.63842976", "0.63316", "0.6263833", "0.6259264", "0.62401015", "0.6222621", "0.619506", "0.6147945", "0.6143022", "0.61424553", "0.61396587", "0.6113857", "0.61133415", "0.60955346", "0.60798615", "0.6020969...
0.57602304
36
Initialize a node with value v, previous p and next n
def initialize(v, n, p) @value = v @next = n @previous = p end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(value, prev_node = nil, next_node = nil)\n @prev_node = prev_node\n @next_node = next_node\n @value = value\n end", "def initialize(value = nil, next_node = nil, prev_node = nil)\n @value = value\n @next = next_node\n @prev = prev_node\n end", "def ini...
[ "0.71622914", "0.70657563", "0.6996835", "0.69682926", "0.6892347", "0.6859073", "0.6813041", "0.6787243", "0.6725085", "0.65873814", "0.6585844", "0.6493821", "0.6493821", "0.6493821", "0.6493821", "0.6420695", "0.62953573", "0.6289484", "0.6244451", "0.6244451", "0.6136073"...
0.8784927
0
Yield the content for a given block. If the block yiels nothing, the optionally specified default text is shown. yield_or_default(:user_status) yield_or_default(:sidebar, "Sorry, no sidebar") +target+ specifies the object to yield. +default_message+ specifies the message to show when nothing is yielded. (Default: "")
def yield_or_default(message, default_message = "") message.nil? ? default_message : message end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main_content\n yield if block_given?\n end", "def block_message_printer\n message = \"Welcome to Block Message Printer\"\n if block_given?\n yield\n end\n puts \"But in this function/method message is :: #{message}\"\nend", "def default(&block)\n if block_given?\n @...
[ "0.5673951", "0.56270355", "0.555966", "0.55463994", "0.5436744", "0.5310355", "0.53080225", "0.528811", "0.52762586", "0.52422786", "0.52124465", "0.52066976", "0.52036643", "0.5186709", "0.5175928", "0.5163236", "0.51529163", "0.5126678", "0.5107156", "0.5102283", "0.508888...
0.6673743
4
Evaluates the content of block and stores the result as content_for :sidebar. Because content_for concatenates the block, you can call sidebar multiple time and yield all the final content once. See ActionView::Helpers::CaptureHelpercontent_for for the full API documentation. ==== Examples Sidebar => Sidebar
def sidebar(&block) content_for :sidebar, &block end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sidebar!\n content_for(:layout_sidebar) do\n 'true'\n end\n end", "def content_for(capture)\n @layout_block.call(capture)\n end", "def main_content\n yield if block_given?\n end", "def sidebar(classes: ['col-xs-7', 'col-sm-3', 'col-md-2'])\n sidebar!\n\n render l...
[ "0.66405404", "0.6490057", "0.63716316", "0.6263863", "0.6109316", "0.6081218", "0.6054966", "0.60003746", "0.5991545", "0.59018505", "0.58933085", "0.5887339", "0.5884539", "0.5819926", "0.5818763", "0.57900333", "0.57422894", "0.5738098", "0.56696993", "0.5635347", "0.56198...
0.77649873
0
results of dividing the first by the second. The second number must not be 0, and both numbers should be validated using this method: =begin def valid_number?(number_string) number_string.to_i.to_s == number_string end =end
def valid_number?(number_string) number_string.to_i.to_s == number_string end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def divideme(first_number,second_number) # divides the numbers\r\n if second_number.to_i == 0\r\n puts \"Sorry cannot divide by zero\"\r\n else\r\n if first_number.to_i % second_number.to_i == 0\r\n puts (\"#{first_number} / #{second_number} is :\" + (first_number.to_i / second_number.to_i).to_s)\r\n ...
[ "0.7217604", "0.717387", "0.6883382", "0.67826974", "0.67763966", "0.6748561", "0.6748561", "0.6748561", "0.6748561", "0.6748561", "0.6748561", "0.6748561", "0.6748561", "0.6748561", "0.6748561", "0.6748561", "0.6748561", "0.6748561", "0.6748561", "0.6748561", "0.6748561", ...
0.6624613
51
Returns the elapsed real time used to execute the given block.
def realtime # :yield: r0 = Process.clock_gettime(Process::CLOCK_MONOTONIC) yield Process.clock_gettime(Process::CLOCK_MONOTONIC) - r0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def profile block_description, &block\n start_time = Time.new\n block.call\n duration = Time.new - start_time\n puts \"#{block_description}: #{duration} seconds\"\nend", "def profile (block_description, &block)\n start_time = Time.new\n block.call\n duration = Time.new - start_time\n puts \"#{block_descr...
[ "0.73021805", "0.72987777", "0.7210578", "0.71865946", "0.71553665", "0.71465886", "0.70108515", "0.6995364", "0.6894388", "0.6865751", "0.6838222", "0.68350494", "0.6816504", "0.68063885", "0.6723908", "0.6585309", "0.6579548", "0.65690345", "0.65644985", "0.65201676", "0.65...
0.0
-1
GET /meeting_follow_ups GET /meeting_follow_ups.json
def index @meeting_follow_ups = MeetingFollowUp.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_meeting_follow_up\n @meeting_follow_up = MeetingFollowUp.find(params[:id])\n end", "def follows\n @follows = @user.follows\n\n respond_to do |format|\n format.html\n format.json { render :json => { :follows => @follows.map{|x| x.as_json(:json => 'friendship')}, :user => @user.as_j...
[ "0.7167343", "0.6800076", "0.65426886", "0.6451123", "0.64492124", "0.6442069", "0.6425024", "0.6414452", "0.63749695", "0.6348674", "0.63486063", "0.63486063", "0.63213414", "0.6321218", "0.63194114", "0.63147223", "0.6311293", "0.6299652", "0.6295459", "0.6282238", "0.62232...
0.76104784
0
GET /meeting_follow_ups/1 GET /meeting_follow_ups/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @meeting_follow_ups = MeetingFollowUp.all\n end", "def set_meeting_follow_up\n @meeting_follow_up = MeetingFollowUp.find(params[:id])\n end", "def show\n @followup = Followup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { rende...
[ "0.74620175", "0.7320256", "0.6817791", "0.6717157", "0.6709369", "0.65778625", "0.6546399", "0.653914", "0.65276587", "0.6478934", "0.6467102", "0.6433175", "0.64047045", "0.6389909", "0.6389909", "0.63867295", "0.63516414", "0.6351426", "0.63359404", "0.6323726", "0.6283783...
0.0
-1
POST /meeting_follow_ups POST /meeting_follow_ups.json
def create @meeting_follow_up = MeetingFollowUp.new(meeting_follow_up_params) respond_to do |format| if @meeting_follow_up.save format.html { redirect_to meeting_follow_up_record_employee_plans_path(plan_id: params[:meeting_follow_up][:employee_plan_id]), notice: 'Meeting follow up was successfully created.' } format.json { render :show, status: :created, location: @meeting_follow_up } else format.html { render :new } format.json { render json: @meeting_follow_up.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_meeting_follow_up\n @meeting_follow_up = MeetingFollowUp.find(params[:id])\n end", "def create\n @followup = Followup.new(params[:followup])\n\n respond_to do |format|\n if @followup.save\n format.html { redirect_to @followup, notice: 'Followup was successfully created.' }\n ...
[ "0.7173046", "0.70722497", "0.6831158", "0.680749", "0.67757136", "0.67615384", "0.6730447", "0.6703397", "0.6695028", "0.6619811", "0.65630436", "0.6536067", "0.6532339", "0.65041983", "0.6481618", "0.6477108", "0.6424949", "0.6374317", "0.63689923", "0.6357284", "0.63559866...
0.740117
0
PATCH/PUT /meeting_follow_ups/1 PATCH/PUT /meeting_follow_ups/1.json
def update respond_to do |format| if @meeting_follow_up.update(meeting_follow_up_params) format.html { redirect_to @meeting_follow_up, notice: 'Meeting follow up was successfully updated.' } format.json { render :show, status: :ok, location: @meeting_follow_up } else format.html { render :edit } format.json { render json: @meeting_follow_up.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @followup.update(followup_params)\n format.html { redirect_to @job, notice: 'Follow Up was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n end\n end\n end", "def set_meeting_follow_up\n @meeting_fo...
[ "0.71014017", "0.7076065", "0.68999743", "0.67279977", "0.6709095", "0.6685333", "0.6641011", "0.66218376", "0.662026", "0.66142136", "0.65985835", "0.6596244", "0.6591943", "0.65765494", "0.6532943", "0.6532943", "0.65260845", "0.65260845", "0.6520211", "0.650386", "0.645504...
0.77513665
0
DELETE /meeting_follow_ups/1 DELETE /meeting_follow_ups/1.json
def destroy @meeting_follow_up.destroy respond_to do |format| format.html { redirect_to meeting_follow_ups_url, notice: 'Meeting follow up was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @meetup = Meetup.find(params[:id])\n @meetup.destroy\n\n respond_to do |format|\n format.html { redirect_to meetups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @followup = Followup.find(params[:id])\n @followup.destroy\n\n respond_to do |for...
[ "0.7540107", "0.75148785", "0.7488016", "0.743424", "0.73862845", "0.73069745", "0.7246522", "0.7242107", "0.72354347", "0.7194497", "0.7190162", "0.71547395", "0.71210456", "0.71198684", "0.7102919", "0.7101492", "0.709414", "0.70831645", "0.70728", "0.70728", "0.70470136", ...
0.7894181
0
Use callbacks to share common setup or constraints between actions.
def set_meeting_follow_up @meeting_follow_up = MeetingFollowUp.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 meeting_follow_up_params params.require(:meeting_follow_up).permit(:employee_plan_id, :contact_person, :contact_no, :follow_up_response, :date, :time, :next_date, :next_time) 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
Ignore situations where the href is an interpolated string with something before the user input
def ignore_interpolation? arg, suspect return unless string_interp? arg return true unless arg[1].chomp.empty? # plain string before interpolation first_interp = arg.find_nodes(:evstr).first return unless first_interp first_interp[1].deep_each do |e| if suspect == e return false end end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_special_HYPERLINK(special)\n url = special.text\n gen_url url, url\n end", "def my_auto_link(text, href_options = {})\n extra_options = tag_options(href_options.stringify_keys) || \"\"\n text.gsub(AUTO_LINK_RE) do\n all, a, b, c, d = $&, $1, $2, $3, $5\n if a =~ /<a\\s/i # don't...
[ "0.62515604", "0.62191594", "0.6155229", "0.60872567", "0.60739326", "0.5880266", "0.58740336", "0.58256066", "0.5809149", "0.5802326", "0.57969165", "0.57874554", "0.5785121", "0.5758095", "0.57289004", "0.5707168", "0.57000476", "0.5664405", "0.5628528", "0.5627714", "0.562...
0.0
-1
Internal: Appends stylus mixin for asset_url and asset_path support
def evaluate(scope, locals, &block) @data = build_mixin_body(scope) + data super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_assets_relative!\n @style.gsub! \"url(/assets\", \"url(assets\"\n @style.gsub! \"url(../\", \"url(assets/\"\n end", "def style_tag(asset)\n return stylesheet_link_tag asset, media: \"all\" if production?\n\n javascript_include_tag asset\n end", "def stylesheet_link_tag(string_or_array, *...
[ "0.6445581", "0.6112271", "0.5983845", "0.597307", "0.59570974", "0.59058756", "0.58836734", "0.58254826", "0.5773968", "0.5767201", "0.576631", "0.5755464", "0.57539576", "0.57532495", "0.57497036", "0.5747364", "0.5731913", "0.5716231", "0.56792885", "0.5658945", "0.5651142...
0.0
-1
Internal: Builds body of a mixin Returns string representation of a mixin with asset helper functions
def build_mixin_body(scope) @mixin_body ||= if assets_hash(scope).values.all? {|value| value != '' } <<-STYL asset-url(key) return pair[1] if pair[0] == key for pair in #{assets_hash(scope)[:url]} () asset-path(key) return pair[1] if pair[0] == key for pair in #{assets_hash(scope)[:path]} () STYL else '' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mixin(object) \n mixin_name = split(object)\n \"@mixin #{mixin_name} {}\"\n end", "def mixin!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n\n type = MIXIN\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule bloc...
[ "0.59575987", "0.5882066", "0.5737601", "0.56425184", "0.5620741", "0.5512886", "0.5392681", "0.5277109", "0.52173066", "0.5085455", "0.50521475", "0.5029077", "0.500078", "0.49996826", "0.49738535", "0.49738535", "0.49738535", "0.49738535", "0.49738535", "0.49738535", "0.497...
0.7738047
0
Internal: Construct Hash with absolute/relative paths in stylus syntax. Returns string representations of hash in Stylus syntax
def assets_hash(scope) @assets_hash ||= scope.environment.each_logical_path.each_with_object({ :url => '', :path => '' }) do |logical_path, assets_hash| extensions = EXCLUDED_EXTENSIONS.join('|') unless File.extname(logical_path) =~ Regexp.new("^(\.(#{extensions})|)$") path_to_asset = scope.path_to_asset(logical_path) assets_hash[:url] << "('#{logical_path}' url(\"#{path_to_asset}\")) " assets_hash[:path] << "('#{logical_path}' \"#{path_to_asset}\") " end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_css(style_hash)\n q = ''\n q << style_hash.collect { |k, v|\n if not v.empty?\n q2 = ( k =~ /\\./ ? ( k[-1..-1] == '.' ? \"#{k[0..-2]}\" : \"#{k}\" ) : \"##{k}\" )\n q2 << ' {' << v.collect{| k2, v2 | \" #{k2}: #{v2}\" }.join( ';' ) << ' }'\n q2\n end\n ...
[ "0.5837432", "0.5796475", "0.5699433", "0.559131", "0.55184674", "0.55111015", "0.5477846", "0.5453129", "0.541904", "0.53824323", "0.5343552", "0.53176486", "0.5303612", "0.52916044", "0.5248433", "0.520948", "0.5208275", "0.5196126", "0.51933354", "0.5190468", "0.5186896", ...
0.5186216
21
Gets information about VMs defined for a user. It caches new VMs and takes out from the cache deleted VMs
def update_user(user) @users[user]=Hash.new if !@users[user] vmpool=OpenNebula::VirtualMachinePool.new(@client, user) vmpool.info one_ids=vmpool.map {|vm| vm.id } vms=@users[user] user_ids=vms.keys deleted_vms=user_ids-one_ids added_vms=one_ids-user_ids deleted_vms.each {|vmid| vms.delete(vmid) } added_vms.each do |vmid| vm=OpenNebula::VirtualMachine.new( OpenNebula::VirtualMachine.build_xml(vmid), @client) vm.info usage=VmUsage.new(vm['TEMPLATE/CPU'].to_f, vm['TEMPLATE/MEMORY'].to_i) vms[vmid.to_i]=usage end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vms(user)\n vms=@users[user]\n @users[user]=vms=Hash.new if !vms\n vms\n end", "def getVMs\n @vms = VirtualMachine.all(@ip_address)\n end", "def load_vms!\n\t\t\tresult = {}\n\n\t\t\t# Load the VM UUIDs from the local data store\n\t\t\t(local_data[:active] || {}).each do |name, ...
[ "0.6959804", "0.6455871", "0.6388029", "0.6315075", "0.62986934", "0.62986934", "0.61010176", "0.61010176", "0.6089927", "0.6030115", "0.59905654", "0.5979743", "0.5840897", "0.58175826", "0.5802259", "0.5791306", "0.5781072", "0.57736045", "0.5747812", "0.57079655", "0.56584...
0.6091959
8
Returns the cache of defined VMs for a user. It is a hash with VM id as key and VmUsage as value
def vms(user) vms=@users[user] @users[user]=vms=Hash.new if !vms vms end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_by_ued_memcache_key_object\n MemcacheKey.new('user.user_kyc_comparison_detail')\n end", "def total(user)\n usage=VmUsage.new(0.0, 0, 0)\n \n @users[user].each do |id, vm|\n usage.cpu+=vm.cpu\n usage.memory+=vm.memory\n usage.num_vms+=1\n ...
[ "0.58682954", "0.5799822", "0.5727434", "0.5687913", "0.56238204", "0.5487336", "0.5487336", "0.5391021", "0.5336172", "0.5331508", "0.5326577", "0.5312997", "0.5299143", "0.52479255", "0.5247538", "0.52272415", "0.5207831", "0.51692975", "0.51444256", "0.51214546", "0.511293...
0.6922262
0
Returns total consumption by a user into a VmUsage object
def total(user) usage=VmUsage.new(0.0, 0, 0) @users[user].each do |id, vm| usage.cpu+=vm.cpu usage.memory+=vm.memory usage.num_vms+=1 end if @users[user] usage end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total_billable_usage\n @attributes[:total_billable_usage]\n end", "def user_cost\n @attributes[:user_cost]\n end", "def usage_cost\n @attributes[:usage_cost]\n end", "def monthly_print_usage_by_user\n return @monthly_print_usage_by_user\n end", "def dro...
[ "0.6384523", "0.635422", "0.63443184", "0.6292223", "0.6256888", "0.62505805", "0.61222386", "0.6118661", "0.6085477", "0.60595334", "0.60502285", "0.5998154", "0.5955037", "0.59361607", "0.59205896", "0.58673525", "0.5851864", "0.57405496", "0.5729764", "0.5720738", "0.57084...
0.82086825
0
GET /hp_searches GET /hp_searches.json
def index @hp_searches = HpSearch.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @searches = @website.searches.all\n\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @searches }\n end\n end", "def search\n spotyfy_client = SpotyfyClient.new(params[:search])\n spotyfy_client.perform\n items = SpotyfyService.parse_hash...
[ "0.7296706", "0.70765066", "0.69592625", "0.6931639", "0.69005084", "0.6898424", "0.68895966", "0.6795751", "0.6735968", "0.6694264", "0.6690708", "0.66719383", "0.6662774", "0.6654845", "0.66119957", "0.6576677", "0.6557585", "0.6506874", "0.64949286", "0.6491554", "0.648044...
0.7465054
0
GET /hp_searches/1 GET /hp_searches/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @searches = @website.searches.all\n\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @searches }\n end\n end", "def index\n @hp_searches = HpSearch.all\n end", "def search\n spotyfy_client = SpotyfyClient.new(params[:search])\n spotyf...
[ "0.72191834", "0.7054289", "0.6822875", "0.6784442", "0.6742803", "0.67366177", "0.6702711", "0.66310084", "0.6585139", "0.6505133", "0.6501061", "0.6494939", "0.6490935", "0.64756835", "0.6471487", "0.6469693", "0.6468954", "0.64571583", "0.6388359", "0.6385724", "0.6367741"...
0.0
-1
POST /hp_searches POST /hp_searches.json
def create @hp_search = HpSearch.new(hp_search_params) respond_to do |format| if @hp_search.save format.html { redirect_to @hp_search, notice: 'Hp search was successfully created.' } format.json { render :show, status: :created, location: @hp_search } else format.html { render :new } format.json { render json: @hp_search.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_saved_search(query)\n post(\"/saved_searches/create.json\", :query => query)\n end", "def create\n @search = @website.searches.new params[:search]\n\n\t\t@search.url = @website.search_url(params[:search_terms]) if params[:search_terms]\n\n @search.terms = @search.description.split(' ') i...
[ "0.67871493", "0.6487988", "0.64730036", "0.64707506", "0.6438359", "0.63838005", "0.6288693", "0.6272228", "0.6264629", "0.62407804", "0.61506045", "0.6135573", "0.61323357", "0.6046458", "0.60401076", "0.6008405", "0.6001088", "0.5994454", "0.59741265", "0.5971785", "0.5968...
0.6966397
0
PATCH/PUT /hp_searches/1 PATCH/PUT /hp_searches/1.json
def update respond_to do |format| if @hp_search.update(hp_search_params) format.html { redirect_to @hp_search, notice: 'Hp search was successfully updated.' } format.json { render :show, status: :ok, location: @hp_search } else format.html { render :edit } format.json { render json: @hp_search.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @advance_search.update(advance_search_params)\n format.html { redirect_to @advance_search, notice: 'Advance search was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n forma...
[ "0.64139813", "0.6264316", "0.6264315", "0.6244814", "0.6235557", "0.61979836", "0.6161067", "0.6154005", "0.6151688", "0.6132266", "0.61019284", "0.61019284", "0.61019284", "0.61019284", "0.60997224", "0.60997224", "0.60997224", "0.6085722", "0.6074767", "0.6025214", "0.5983...
0.67113817
0
DELETE /hp_searches/1 DELETE /hp_searches/1.json
def destroy @hp_search.destroy respond_to do |format| format.html { redirect_to hp_searches_url, notice: 'Hp search was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @advance_search.destroy\n respond_to do |format|\n format.html { redirect_to advance_searches_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @search.destroy\n respond_to do |format|\n format.html { redirect_to searches_url }\n format.json {...
[ "0.7428843", "0.710959", "0.710959", "0.710959", "0.710959", "0.710959", "0.70994884", "0.7082889", "0.70809025", "0.7042368", "0.700188", "0.6971907", "0.6955675", "0.6955675", "0.6955675", "0.6955675", "0.6933841", "0.6917134", "0.6901846", "0.6892551", "0.6835365", "0.68...
0.74369824
0
Use callbacks to share common setup or constraints between actions.
def set_hp_search @hp_search = HpSearch.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 hp_search_params params.require(:hp_search).permit(:name, :zipcode) 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
one_task.rake one_task task will run another_task.rake another_task task will run my_tasks_all_mine.rake mine:task1 task will run mine:task2 task has a duplicate (will not run) mine:task3 task has a duplicate (will not run) mine:task4 task will run other_tasks_run_all.rake other_task1_run_me task will run other_task2_run_me task has a duplicate (will not run) other_task3_run_me task has a duplicate (will not run) other_task_not_run_yet task will run other_tasks_mixed_duplicates.rake other_task2_run_me task has a duplicate (will not run) other_task3_run_me task has a duplicate (will not run) task2_duplicate.rake mine:task2 task has a duplicate (will not run) task4_duplicate.rake mine:task4 task has a duplicate (will not run)
def create_rake_files(base_dir) one_task_fn = File.join(base_dir, 'one_task.rake') make_tasks_in_file(['one_task'], one_task_fn) if ok_to_create?(one_task_fn) another_task_fn = File.join(base_dir, 'another_task.rake') make_tasks_in_file(['another_task'], another_task_fn) if ok_to_create?(another_task_fn) my_tasks_mine_fn = File.join(base_dir, 'my_tasks_all_mine.rake') make_tasks_in_file(['task1', 'task2', 'task3', 'task4'], my_tasks_mine_fn, namespace: 'mine') if ok_to_create?(my_tasks_mine_fn) tasks_run_all_fn = File.join(base_dir, 'other_tasks_run_all.rake') make_tasks_in_file(['other_task1_run_me', 'other_task2_run_me', 'other_task3_run_me', 'other_task_not_run_yet'], tasks_run_all_fn) if ok_to_create?(tasks_run_all_fn) tasks_mixed_duplicates_fn = File.join(base_dir, 'other_tasks_mixed_duplicates.rake') make_tasks_in_file(['other_task2_run_me', 'other_task3_run_me'], tasks_mixed_duplicates_fn) if ok_to_create?(tasks_mixed_duplicates_fn) task2_duplicate_fn = File.join(base_dir, 'task2_duplicate.rake') make_tasks_in_file(['task2'], task2_duplicate_fn, namespace: 'mine') if ok_to_create?(task2_duplicate_fn) task4_duplicate_fn = File.join(base_dir, 'task4_duplicate.rake') make_tasks_in_file(['task4'], task4_duplicate_fn, namespace: 'mine') if ok_to_create?(task4_duplicate_fn) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_tasks_to_run\n self.all_tasks - all_tasks_previously_run - all_tasks_duplicates\n end", "def files_with_tasks_to_run\n\n # load all tasks into self.all_tasks\n get_tasks_from_rakefiles\n\n set_and_log_tasks_already_ran(self.all_tasks)\n set_and_log_duplicate_tasks(self.all_tas...
[ "0.668701", "0.6261065", "0.6249257", "0.6139295", "0.61092496", "0.60806847", "0.60745454", "0.6054341", "0.5837602", "0.58354", "0.5820692", "0.58128023", "0.58128023", "0.5773079", "0.5767463", "0.57456684", "0.57239646", "0.5723327", "0.5699236", "0.56813097", "0.5676584"...
0.6910386
0
If the file exists, ask if it's ok to overwrite. return true only if they said it was ok to overwrite. If the file does not exist, return true (it's ok to create it)
def ok_to_create?(filepath) File.exist?(filepath) ? prompt_to_overwrite?(filepath) : true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def overwrite?(path)\n if File.exist?(path)\n return yes? \"A file already exists at '#{ path }'. Do you want to overwrite? [y/n]\"\n end\n true\n end", "def write_prep outfile\n return true unless File.exists? outfile\n\n # OK, file exists. See if we can clobber ...
[ "0.787595", "0.7612725", "0.6988596", "0.69432896", "0.6587998", "0.65100396", "0.6501122", "0.6500705", "0.6461536", "0.6434471", "0.6405404", "0.6359023", "0.6343919", "0.6288038", "0.620873", "0.61942965", "0.6192671", "0.61546654", "0.6145405", "0.61445737", "0.6137306", ...
0.8330788
0
Make rake tasks for of the tasks in tasknames, in the file named filepath. Makes all directories needed for the filepath if they don't already exist.
def make_tasks_in_file(tasknames = [], filepath = '.', task_body = "\n", namespace: '') indent = "" filedir = File.dirname(filepath) FileUtils.mkdir_p(filedir) unless Dir.exist?(filedir) File.open(filepath, 'w') do |f| unless namespace.empty? indent = " " f.puts namespace_start(namespace) end tasknames.each do |taskname| f.puts simple_rake_task(taskname, indent: indent, task_body: task_body) end f.puts namespace_end unless namespace.empty? end filepath end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_rake_files(base_dir)\n\n one_task_fn = File.join(base_dir, 'one_task.rake')\n make_tasks_in_file(['one_task'], one_task_fn) if ok_to_create?(one_task_fn)\n\n another_task_fn = File.join(base_dir, 'another_task.rake')\n make_tasks_in_file(['another_task'], another_task_fn) if ok_to_create?(an...
[ "0.6867006", "0.65400964", "0.6450239", "0.6214098", "0.5953491", "0.5820577", "0.5759924", "0.5693695", "0.56675607", "0.56675607", "0.56378096", "0.5621367", "0.56165826", "0.5611207", "0.5603605", "0.5560159", "0.5543449", "0.5492799", "0.54762465", "0.5452826", "0.5451332...
0.71497864
0
Code for a simple task. The body of the task is given :task_body
def simple_rake_task(task_name = 'test_task', indent: '', task_body: "\n") "\n" + indent + "desc 'task named #{task_name}'\n" + indent + "task :#{task_name} do\n" + indent + " " + task_body + indent + "end\n\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def simpleTasks _args\n \"simpleTasks _args;\" \n end", "def task\n end", "def description\n \"This is an example Tapir task. It associates a random host with the calling entity.\"\nend", "def createSimpleTask _obj, _args\n \"_obj createSimpleTask _args;\" \n end", "def description\n ...
[ "0.70842534", "0.70090413", "0.69444466", "0.69333863", "0.69081366", "0.681818", "0.67373914", "0.6728013", "0.67245424", "0.6723103", "0.66986424", "0.6596913", "0.6589006", "0.65321743", "0.65222645", "0.644586", "0.6442598", "0.643196", "0.63979", "0.6396713", "0.6366232"...
0.81454754
0
Init a new TargetIntegrator
def initialize(target, use_input_output_paths: true) @target = target @use_input_output_paths = use_input_output_paths end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize_target\n end", "def initialize( target )\n\t\t@target = target\n\tend", "def initialize(target)\n @target = target\n end", "def target_init\n @scope = Scope.new('GLOBAL')\n @references = References.new\n end", "def _target\n @_target ||= @_initializer.call\n end",...
[ "0.67424154", "0.6059745", "0.6043873", "0.60437787", "0.60348547", "0.6023471", "0.6023471", "0.59501505", "0.59501505", "0.5716559", "0.55885744", "0.55348617", "0.5514497", "0.53949964", "0.53949964", "0.53949964", "0.5391593", "0.5381198", "0.5354775", "0.531701", "0.5280...
0.54106754
13
Sets the input & output paths for the given script build phase.
def set_input_output_paths(phase, input_paths_by_config, output_paths_by_config) if input_output_paths_use_filelist?(phase) [input_paths_by_config, output_paths_by_config].each do |hash| hash.each do |file_list, files| generator = Generator::FileList.new(files) Xcode::PodsProjectGenerator::TargetInstallerHelper.update_changed_file(generator, file_list.file_list_path) end end phase.input_paths = nil phase.output_paths = nil phase.input_file_list_paths = input_paths_by_config.each_key.map(&:file_list_relative_path).uniq phase.output_file_list_paths = output_paths_by_config.each_key.map(&:file_list_relative_path).uniq else input_paths = input_paths_by_config.values.flatten(1).uniq output_paths = output_paths_by_config.values.flatten(1).uniq TargetIntegrator.validate_input_output_path_limit(input_paths, output_paths) phase.input_paths = input_paths phase.output_paths = output_paths phase.input_file_list_paths = nil phase.output_file_list_paths = nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_input_path_to_script_phase(script_phase, name, platform)\n input_path = \"$(SRCROOT)/#{make_carthage_build_path(name, platform)}\"\n script_phase.input_paths << input_path\nend", "def create_or_update_copy_xcframeworks_script_phase_to_target(native_target, script_path, input_paths_by_config = {}, o...
[ "0.70612246", "0.62567437", "0.599926", "0.58901983", "0.5833597", "0.5638008", "0.5605595", "0.54814017", "0.5459682", "0.5343731", "0.5314638", "0.53031904", "0.5272214", "0.52284694", "0.5151068", "0.51070803", "0.5095115", "0.50818783", "0.5044566", "0.5038619", "0.502718...
0.6996949
1
Adds a shell script build phase responsible to copy (embed) the frameworks generated by the TargetDefinition to the bundle of the product of the targets.
def create_or_update_embed_frameworks_script_phase_to_target(native_target, script_path, input_paths_by_config = {}, output_paths_by_config = {}) phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, BUILD_PHASE_PREFIX + EMBED_FRAMEWORK_PHASE_NAME) phase.shell_script = %("#{script_path}"\n) TargetIntegrator.set_input_output_paths(phase, input_paths_by_config, output_paths_by_config) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_or_update_copy_xcframeworks_script_phase_to_target(native_target, script_path, input_paths_by_config = {}, output_paths_by_config = {})\n phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, BUILD_PHASE_PREFIX + COPY_XCFRAMEWORKS_PHASE_NAME)\n phase.she...
[ "0.75586873", "0.7514414", "0.74466515", "0.71640784", "0.71406937", "0.6862795", "0.67884266", "0.6667996", "0.66675264", "0.65609175", "0.63986677", "0.6295784", "0.6211545", "0.60069865", "0.5860862", "0.58416116", "0.570433", "0.5699439", "0.56527185", "0.56426", "0.55678...
0.74220175
3
Delete a 'Embed Pods Frameworks' Script Build Phase if present
def remove_embed_frameworks_script_phase_from_target(native_target) remove_script_phase_from_target(native_target, EMBED_FRAMEWORK_PHASE_NAME) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_copy_xcframeworks_script_phase_from_target(native_target)\n remove_script_phase_from_target(native_target, COPY_XCFRAMEWORKS_PHASE_NAME)\n end", "def create_embed_frameworks_phase(project, t)\n \n t.build_phases.delete_if { |phase| \n phase.to_s == 'Embed Frameworks'\n...
[ "0.7098056", "0.67912596", "0.6777354", "0.65161484", "0.63132244", "0.62601656", "0.6252111", "0.6181388", "0.6180695", "0.59834546", "0.5946267", "0.58439374", "0.5722547", "0.56842804", "0.5630349", "0.55702645", "0.55023277", "0.54310054", "0.54300886", "0.5404655", "0.53...
0.6804209
1
Adds a shell script build phase responsible to copy the xcframework slice to the intermediate build directory.
def create_or_update_copy_xcframeworks_script_phase_to_target(native_target, script_path, input_paths_by_config = {}, output_paths_by_config = {}) phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, BUILD_PHASE_PREFIX + COPY_XCFRAMEWORKS_PHASE_NAME) phase.shell_script = %("#{script_path}"\n) TargetIntegrator.set_input_output_paths(phase, input_paths_by_config, output_paths_by_config) reorder_script_phase(native_target, phase, :before_compile) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_copy_xcframeworks_script_phase(native_target)\n script_path = \"${PODS_ROOT}/#{target.copy_xcframeworks_script_path.relative_path_from(target.sandbox.root)}\"\n\n input_paths_by_config = {}\n output_paths_by_config = {}\n\n xcframeworks = target.xcframeworks.valu...
[ "0.75888526", "0.700123", "0.6526602", "0.64533275", "0.64480674", "0.63587296", "0.6202722", "0.61730415", "0.6154149", "0.5999833", "0.59893095", "0.5960087", "0.5894985", "0.57374066", "0.5666484", "0.56215286", "0.56177515", "0.5610106", "0.55437547", "0.55349827", "0.551...
0.7424395
1
Delete a 'Copy XCFrameworks' Script Build Phase if present
def remove_copy_xcframeworks_script_phase_from_target(native_target) remove_script_phase_from_target(native_target, COPY_XCFRAMEWORKS_PHASE_NAME) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_embed_frameworks_phase(project, t)\n \n t.build_phases.delete_if { |phase| \n phase.to_s == 'Embed Frameworks'\n }\n\n embed_frameworks_build_phase = project.new(\n Xcodeproj::Project::Object::PBXCopyFilesBuildPhase\n )\n\n embed_frameworks_build_phase.name = 'Embed Frame...
[ "0.67660594", "0.6628715", "0.6527245", "0.6347394", "0.6079273", "0.6024978", "0.5963984", "0.590165", "0.58984447", "0.58905786", "0.58841264", "0.58121765", "0.58029467", "0.5783603", "0.57787454", "0.5745195", "0.57395023", "0.5721305", "0.5674515", "0.5672167", "0.565794...
0.7573576
0
Removes a script phase from a native target by name
def remove_script_phase_from_target(native_target, phase_name) build_phase = native_target.shell_script_build_phases.find { |bp| bp.name && bp.name.end_with?(phase_name) } return unless build_phase.present? native_target.build_phases.delete(build_phase) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_copy_xcframeworks_script_phase_from_target(native_target)\n remove_script_phase_from_target(native_target, COPY_XCFRAMEWORKS_PHASE_NAME)\n end", "def remove_embed_frameworks_script_phase_from_target(native_target)\n remove_script_phase_from_target(native_target, EMBED_FR...
[ "0.75342923", "0.72990423", "0.6754826", "0.66617566", "0.6188673", "0.6130282", "0.6057574", "0.60063744", "0.5924827", "0.5904603", "0.5879518", "0.5789481", "0.5708207", "0.5695094", "0.5688474", "0.56761956", "0.5633179", "0.5575318", "0.552158", "0.55161124", "0.5427239"...
0.84856915
0
Adds a shell script build phase responsible to copy the resources generated by the TargetDefinition to the bundle of the product of the targets.
def create_or_update_copy_resources_script_phase_to_target(native_target, script_path, input_paths_by_config = {}, output_paths_by_config = {}) phase_name = COPY_PODS_RESOURCES_PHASE_NAME phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, BUILD_PHASE_PREFIX + phase_name) phase.shell_script = %("#{script_path}"\n) TargetIntegrator.set_input_output_paths(phase, input_paths_by_config, output_paths_by_config) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_copy_resources_script_phase\n phase_name = \"Copy Pods Resources\"\n native_targets.each do |native_target|\n phase = native_target.shell_script_build_phases.select { |bp| bp.name == phase_name }.first ||\n native_target.new_shell_script_build_phase(phase_nam...
[ "0.8050094", "0.7693876", "0.73843217", "0.68813026", "0.67852515", "0.66807365", "0.6571424", "0.63070256", "0.6141709", "0.6019487", "0.5993383", "0.5974492", "0.5965559", "0.58010083", "0.56748414", "0.56272906", "0.5598798", "0.5587804", "0.5576478", "0.5576071", "0.55501...
0.7521419
2
Delete a 'Copy Pods Resources' script phase if present
def remove_copy_resources_script_phase_from_target(native_target) build_phase = native_target.shell_script_build_phases.find { |bp| bp.name && bp.name.end_with?(COPY_PODS_RESOURCES_PHASE_NAME) } return unless build_phase.present? native_target.build_phases.delete(build_phase) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_copy_resources_script_phase\n phase_name = \"Copy Pods Resources\"\n native_targets.each do |native_target|\n phase = native_target.shell_script_build_phases.select { |bp| bp.name == phase_name }.first ||\n native_target.new_shell_script_build_phase(phase_nam...
[ "0.66800314", "0.6514744", "0.62775815", "0.62116045", "0.6128252", "0.6071449", "0.6038747", "0.5961787", "0.596162", "0.5850976", "0.56830734", "0.56733406", "0.5597245", "0.5553472", "0.5553455", "0.5506269", "0.5488788", "0.5477906", "0.5455514", "0.54488474", "0.54360884...
0.7444011
0
Creates or update a shell script build phase for the given target.
def create_or_update_shell_script_build_phase(native_target, script_phase_name, show_env_vars_in_log = '0') build_phases = native_target.build_phases.grep(Xcodeproj::Project::Object::PBXShellScriptBuildPhase) build_phases.find { |phase| phase.name && phase.name.end_with?(script_phase_name) }.tap { |p| p.name = script_phase_name if p } || native_target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase).tap do |phase| UI.message("Adding Build Phase '#{script_phase_name}' to project.") do phase.name = script_phase_name unless show_env_vars_in_log.nil? phase.show_env_vars_in_log = show_env_vars_in_log end native_target.build_phases << phase end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_or_update_copy_xcframeworks_script_phase_to_target(native_target, script_path, input_paths_by_config = {}, output_paths_by_config = {})\n phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, BUILD_PHASE_PREFIX + COPY_XCFRAMEWORKS_PHASE_NAME)\n phase.she...
[ "0.71108156", "0.70612246", "0.68617845", "0.6617549", "0.6260934", "0.61934084", "0.61624455", "0.61587083", "0.60037637", "0.5873172", "0.5734559", "0.56950223", "0.5687578", "0.564136", "0.5554124", "0.5553439", "0.5534892", "0.55276144", "0.55210054", "0.5406049", "0.5378...
0.7815728
0
Updates all target script phases for the current target, including creating or updating, deleting and reordering.
def create_or_update_user_script_phases(script_phases, native_target) script_phase_names = script_phases.map { |k| k[:name] } # Delete script phases no longer present in the target. native_target_script_phases = native_target.shell_script_build_phases.select do |bp| !bp.name.nil? && bp.name.start_with?(USER_BUILD_PHASE_PREFIX) end native_target_script_phases.each do |script_phase| script_phase_name_without_prefix = script_phase.name.sub(USER_BUILD_PHASE_PREFIX, '') unless script_phase_names.include?(script_phase_name_without_prefix) native_target.build_phases.delete(script_phase) end end # Create or update the ones that are expected to be. script_phases.each do |script_phase| name_with_prefix = USER_BUILD_PHASE_PREFIX + script_phase[:name] phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, name_with_prefix, nil) phase.shell_script = script_phase[:script] phase.shell_path = script_phase[:shell_path] || '/bin/sh' phase.input_paths = script_phase[:input_files] phase.output_paths = script_phase[:output_files] phase.input_file_list_paths = script_phase[:input_file_lists] phase.output_file_list_paths = script_phase[:output_file_lists] phase.dependency_file = script_phase[:dependency_file] # At least with Xcode 10 `showEnvVarsInLog` is *NOT* set to any value even if it's checked and it only # gets set to '0' if the user has explicitly disabled this. if (show_env_vars_in_log = script_phase.fetch(:show_env_vars_in_log, '1')) == '0' phase.show_env_vars_in_log = show_env_vars_in_log end execution_position = script_phase[:execution_position] reorder_script_phase(native_target, phase, execution_position) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def script_phase(options)\n raise Informative, 'Script phases can only be added within target definitions.' if current_target_definition.root?\n raise Informative, 'Script phases cannot be added to abstract targets.' if current_target_definition.abstract?\n current_target_definition.store_scri...
[ "0.63583726", "0.62636495", "0.5819461", "0.5693116", "0.53878206", "0.5370115", "0.53251547", "0.51669663", "0.5162826", "0.51525044", "0.5150043", "0.5125245", "0.509572", "0.5056488", "0.50558585", "0.5055266", "0.50393206", "0.50080436", "0.50064206", "0.49988577", "0.495...
0.61944157
2
Script phases can have a limited number of input and output paths due to each one being exported to `env`. A large number can cause a build failure because of limitations in `env`. See issue
def validate_input_output_path_limit(input_paths, output_paths) if (input_paths.count + output_paths.count) > MAX_INPUT_OUTPUT_PATHS input_paths.clear output_paths.clear end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_input_path_to_script_phase(script_phase, name, platform)\n input_path = \"$(SRCROOT)/#{make_carthage_build_path(name, platform)}\"\n script_phase.input_paths << input_path\nend", "def set_input_output_paths(phase, input_paths_by_config, output_paths_by_config)\n if input_output_paths_use...
[ "0.60355467", "0.56423974", "0.56022626", "0.54793984", "0.5365936", "0.53175676", "0.5295065", "0.5276283", "0.5276283", "0.5263879", "0.52030784", "0.51513475", "0.50949955", "0.50942737", "0.5063275", "0.5042499", "0.5011748", "0.50103825", "0.50097215", "0.49844083", "0.4...
0.49453065
22
Returns the resource output paths for all given input paths.
def resource_output_paths(resource_input_paths) resource_input_paths.map do |resource_input_path| base_path = '${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}' extname = File.extname(resource_input_path) basename = extname == '.xcassets' ? 'Assets' : File.basename(resource_input_path) output_extension = Target.output_extension_for_resource(extname) File.join(base_path, File.basename(basename, extname) + output_extension) end.uniq end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _output_paths(file)\n input_file_dir = File.dirname(file)\n file_name = _output_filename(file)\n file_name = \"#{file_name}.erb\" if _append_html_ext_to_output_path?(file_name)\n input_file_dir = input_file_dir.gsub(Regexp.new(\"#{options[:input]}(\\/){0,1}\"), '') if options[:input]\n\n ...
[ "0.66897076", "0.65654", "0.63224965", "0.63178664", "0.624684", "0.61743546", "0.61714906", "0.6109313", "0.60726273", "0.60675794", "0.60056865", "0.5977739", "0.5953805", "0.5951337", "0.59202105", "0.59168273", "0.59031516", "0.58494526", "0.5840587", "0.58181113", "0.574...
0.76816154
0
Returns the framework input paths for the given framework paths
def embed_frameworks_input_paths(framework_paths, xcframeworks) input_paths = framework_paths.map(&:source_path) # Only include dynamic xcframeworks as the input since we will not be copying static xcframework slices xcframeworks.select { |xcf| xcf.build_type.dynamic_framework? }.each do |xcframework| name = xcframework.name input_paths << "#{Pod::Target::BuildSettings.xcframework_intermediate_dir(xcframework)}/#{name}.framework/#{name}" end input_paths end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def embed_frameworks_output_paths(framework_paths, xcframeworks)\n paths = framework_paths.map do |framework_path|\n \"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{File.basename(framework_path.source_path)}\"\n end.uniq\n # Static xcframeworks are not copied to the ...
[ "0.70226055", "0.6260233", "0.60946685", "0.60912216", "0.6058688", "0.6053993", "0.60456896", "0.6024619", "0.6005011", "0.59711254", "0.59552926", "0.5936528", "0.5935329", "0.5934319", "0.59150016", "0.59048796", "0.58765805", "0.5876535", "0.58716", "0.58592844", "0.58506...
0.787345
0
Returns the framework output paths for the given framework paths
def embed_frameworks_output_paths(framework_paths, xcframeworks) paths = framework_paths.map do |framework_path| "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{File.basename(framework_path.source_path)}" end.uniq # Static xcframeworks are not copied to the build dir # so only include dynamic artifacts that will be copied to the build folder xcframework_paths = xcframeworks.select { |xcf| xcf.build_type.dynamic_framework? }.map do |xcframework| "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{xcframework.name}.framework" end paths + xcframework_paths end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def embed_frameworks_input_paths(framework_paths, xcframeworks)\n input_paths = framework_paths.map(&:source_path)\n # Only include dynamic xcframeworks as the input since we will not be copying static xcframework slices\n xcframeworks.select { |xcf| xcf.build_type.dynamic_framewor...
[ "0.70253336", "0.6675473", "0.653083", "0.6499567", "0.63632137", "0.62908715", "0.6255764", "0.62101877", "0.6208901", "0.6195849", "0.6144477", "0.61337125", "0.60706973", "0.6053972", "0.5964605", "0.5962045", "0.58769554", "0.5866441", "0.58415556", "0.5834538", "0.583432...
0.7923304
0
Updates a projects native targets to include on demand resources specified by the supplied parameters. Note that currently, only app level targets are allowed to include on demand resources.
def update_on_demand_resources(sandbox, project, native_targets, file_accessors, parent_odr_group, target_odr_group_name) category_to_tags = {} file_accessors = Array(file_accessors) native_targets = Array(native_targets) # Target no longer provides ODR references so remove everything related to this target. if file_accessors.all? { |fa| fa.on_demand_resources.empty? } old_target_odr_group = parent_odr_group[target_odr_group_name] old_odr_file_refs = old_target_odr_group&.recursive_children_groups&.each_with_object({}) do |group, hash| hash[group.name] = group.files end || {} native_targets.each do |native_target| native_target.remove_on_demand_resources(old_odr_file_refs) update_on_demand_resources_build_settings(native_target, nil => old_odr_file_refs.keys) end old_target_odr_group&.remove_from_project return end target_odr_group = parent_odr_group[target_odr_group_name] || parent_odr_group.new_group(target_odr_group_name) current_file_refs = target_odr_group.recursive_children_groups.flat_map(&:files) added_file_refs = file_accessors.flat_map do |file_accessor| target_odr_files_refs = Hash[file_accessor.on_demand_resources.map do |tag, value| tag_group = target_odr_group[tag] || target_odr_group.new_group(tag) category_to_tags[value[:category]] ||= [] category_to_tags[value[:category]] << tag resources_file_refs = value[:paths].map do |resource| odr_resource_file_ref = Pathname.new(resource).relative_path_from(sandbox.root) tag_group.find_file_by_path(odr_resource_file_ref.to_s) || tag_group.new_file(odr_resource_file_ref) end [tag, resources_file_refs] end] native_targets.each do |native_target| native_target.add_on_demand_resources(target_odr_files_refs) end target_odr_files_refs.values.flatten end # if the target ODR file references were updated, make sure we remove the ones that are no longer present # for the target. remaining_refs = current_file_refs - added_file_refs remaining_refs.each do |ref| native_targets.each do |user_target| user_target.resources_build_phase.remove_file_reference(ref) end ref.remove_from_project end target_odr_group.recursive_children_groups.each { |g| g.remove_from_project if g.empty? } attributes = project.root_object.attributes attributes['KnownAssetTags'] = (attributes['KnownAssetTags'] ||= []) | category_to_tags.values.flatten project.root_object.attributes = attributes native_targets.each do |native_target| update_on_demand_resources_build_settings(native_target, category_to_tags) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_on_demand_resources(native_target, app_spec)\n dependent_targets = target.dependent_targets_for_app_spec(app_spec)\n parent_odr_group = native_target.project.group_for_spec(app_spec.name)\n\n # Add ODRs of the app spec dependencies first.\n dependent_targets.each...
[ "0.58724767", "0.576779", "0.56466395", "0.5448475", "0.53682774", "0.5301318", "0.5281299", "0.524073", "0.5163851", "0.5163851", "0.5134046", "0.5074465", "0.5057932", "0.5053632", "0.50389576", "0.5038832", "0.50362545", "0.50297695", "0.49729547", "0.49286824", "0.4923264...
0.63340986
0
Integrates the user project targets. Only the targets that do not already have the Pods library in their frameworks build phase are processed.
def integrate! UI.section(integration_message) do XCConfigIntegrator.integrate(target, native_targets) remove_obsolete_script_phases add_pods_library add_embed_frameworks_script_phase remove_embed_frameworks_script_phase_from_embedded_targets add_copy_resources_script_phase add_check_manifest_lock_script_phase add_user_script_phases add_on_demand_resources end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def integrate!\n return if native_targets.empty?\n UI.section(integration_message) do\n add_xcconfig_base_configuration\n add_pods_library\n add_copy_resources_script_phase\n add_check_manifest_lock_script_phase\n user_project.save\n ...
[ "0.68618494", "0.6431814", "0.61181307", "0.6089441", "0.6005235", "0.5990041", "0.5967321", "0.59235245", "0.5868064", "0.5854593", "0.573813", "0.5709021", "0.57025945", "0.56905353", "0.5647538", "0.5612214", "0.5580844", "0.55664855", "0.5518145", "0.5497048", "0.54194576...
0.60180163
4
Find or create a 'Copy Pods Resources' build phase
def add_copy_resources_script_phase unless target.includes_resources? native_targets.each do |native_target| TargetIntegrator.remove_copy_resources_script_phase_from_target(native_target) end return end script_path = target.copy_resources_script_relative_path input_paths_by_config = {} output_paths_by_config = {} if use_input_output_paths target.resource_paths_by_config.each do |config, resource_paths| input_paths_key = XCFileListConfigKey.new(target.copy_resources_script_input_files_path(config), target.copy_resources_script_input_files_relative_path) input_paths_by_config[input_paths_key] = [script_path] + resource_paths output_paths_key = XCFileListConfigKey.new(target.copy_resources_script_output_files_path(config), target.copy_resources_script_output_files_relative_path) output_paths_by_config[output_paths_key] = TargetIntegrator.resource_output_paths(resource_paths) end end native_targets.each do |native_target| # Static library targets cannot include resources. Skip this phase from being added instead. next if native_target.symbol_type == :static_library TargetIntegrator.create_or_update_copy_resources_script_phase_to_target(native_target, script_path, input_paths_by_config, output_paths_by_config) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_copy_resources_script_phase\n phase_name = \"Copy Pods Resources\"\n native_targets.each do |native_target|\n phase = native_target.shell_script_build_phases.select { |bp| bp.name == phase_name }.first ||\n native_target.new_shell_script_build_phase(phase_nam...
[ "0.7506854", "0.63259166", "0.60588396", "0.60438776", "0.5913537", "0.5913537", "0.5906089", "0.58915305", "0.5888176", "0.5858439", "0.5802226", "0.57770187", "0.5769325", "0.5739297", "0.5723602", "0.5702394", "0.5684604", "0.5683808", "0.56771743", "0.5666653", "0.5651197...
0.6852865
1
Removes the embed frameworks build phase from embedded targets
def remove_embed_frameworks_script_phase_from_embedded_targets return unless target.requires_host_target? native_targets.each do |native_target| if AggregateTarget::EMBED_FRAMEWORKS_IN_HOST_TARGET_TYPES.include? native_target.symbol_type TargetIntegrator.remove_embed_frameworks_script_phase_from_target(native_target) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_embed_frameworks_script_phase_from_target(native_target)\n remove_script_phase_from_target(native_target, EMBED_FRAMEWORK_PHASE_NAME)\n end", "def add_embed_frameworks_script_phase\n unless target.includes_frameworks? || (target.xcframeworks_by_config.values.flatten.any? {...
[ "0.74486816", "0.74412745", "0.7373841", "0.676171", "0.6487609", "0.6229096", "0.6203047", "0.6107716", "0.6092439", "0.59680283", "0.592779", "0.58669883", "0.5771275", "0.57394516", "0.57358813", "0.57039696", "0.5666438", "0.55424386", "0.5411368", "0.5410671", "0.5361785...
0.81939775
0
Find or create a 'Embed Pods Frameworks' Copy Files Build Phase
def add_embed_frameworks_script_phase unless target.includes_frameworks? || (target.xcframeworks_by_config.values.flatten.any? { |xcf| xcf.build_type.dynamic_framework? }) native_targets_to_embed_in.each do |native_target| TargetIntegrator.remove_embed_frameworks_script_phase_from_target(native_target) end return end script_path = target.embed_frameworks_script_relative_path input_paths_by_config = {} output_paths_by_config = {} if use_input_output_paths? configs = Set.new(target.framework_paths_by_config.keys + target.xcframeworks_by_config.keys).sort configs.each do |config| framework_paths = target.framework_paths_by_config[config] || [] xcframeworks = target.xcframeworks_by_config[config] || [] input_paths_key = XCFileListConfigKey.new(target.embed_frameworks_script_input_files_path(config), target.embed_frameworks_script_input_files_relative_path) input_paths_by_config[input_paths_key] = [script_path] + TargetIntegrator.embed_frameworks_input_paths(framework_paths, xcframeworks) output_paths_key = XCFileListConfigKey.new(target.embed_frameworks_script_output_files_path(config), target.embed_frameworks_script_output_files_relative_path) output_paths_by_config[output_paths_key] = TargetIntegrator.embed_frameworks_output_paths(framework_paths, xcframeworks) end end native_targets_to_embed_in.each do |native_target| TargetIntegrator.create_or_update_embed_frameworks_script_phase_to_target(native_target, script_path, input_paths_by_config, output_paths_by_config) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_embed_frameworks_phase(project, t)\n \n t.build_phases.delete_if { |phase| \n phase.to_s == 'Embed Frameworks'\n }\n\n embed_frameworks_build_phase = project.new(\n Xcodeproj::Project::Object::PBXCopyFilesBuildPhase\n )\n\n embed_frameworks_build_phase.name = 'Embed Frame...
[ "0.7226446", "0.6934137", "0.6832498", "0.6476361", "0.64477134", "0.63966286", "0.6256283", "0.620393", "0.61002606", "0.6098845", "0.60831237", "0.60745466", "0.60294366", "0.60056895", "0.60056895", "0.6001569", "0.5983567", "0.5962374", "0.5947271", "0.5947271", "0.593958...
0.64469993
5