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 |
---|---|---|---|---|---|---|
GET /gifts/1 GET /gifts/1.xml
|
def show
@gift = Gift.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @gift }
format.json { render :layout => false, :json => @gift.to_json }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @gifts = current_host.gifts\n end",
"def show\n @indexed_gif = IndexedGif.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indexed_gif }\n end\n end",
"def show\n @tag = Tag.find(params[:id])\n @gifs = @tag.getGifsPaginated(params);\n end",
"def show\n @next_gif = @gif.next\n @prev_gif = @gif.prev\n\n respond_to do |format|\n format.html\n format.json { render json: @gif }\n format.gif { redirect_to @gif.url }\n end\n end",
"def modify_gif(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end",
"def index\n @gifts = Gift.all\n end",
"def index\n @gifts = Gift.all\n end",
"def index\n @gifs = Gif.sorted.paginate(page: params[:page], per_page: 12)\n\n respond_to do |format|\n format.html\n format.json { render json: @gifs }\n end\n end",
"def getgpx\n trek = Trek.find_by_id(params[:id])\n send_file trek.get_gpx(), :type => \"text/xml\", :disposition => \"inline\"\n end",
"def get_svg\n\t expires_in(1.hours, :private => false, :public => true)\n\t source_fedora_object = Multiresimage.find(params[:id])\n\t authorize! :show, source_fedora_object\n\t @svg = source_fedora_object.DELIV_OPS.content()\n gon.url = DIL_CONFIG['dil_js_url']\n respond_to do |wants|\n wants.xml { render :xml => @svg }\n end\n end",
"def get_svg\n\t expires_in(1.hours, :private => false, :public => true)\n\t source_fedora_object = Multiresimage.find(params[:id])\n\t authorize! :show, source_fedora_object\n\t @svg = source_fedora_object.DELIV_OPS.content()\n gon.url = DIL_CONFIG['dil_js_url']\n respond_to do |wants|\n wants.xml { render :xml => @svg }\n end\n end",
"def show\n @gif = Gif.find(params[:id])\n render layout: false\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def fetch_gif!\n Giphy::Configuration.configure do |config|\n config.api_key = \"dc6zaTOxFJmzC\" \n end \n Giphy.search(@result).first.id\n end",
"def index\n @gifs = Gif.all.order(\"created_at DESC\")\n respond_to do |format|\n format.html {}\n format.js {}\n end\n end",
"def show\n\n # Get random gif from Giphy (http://giphy.com)\n response = HTTParty.get('http://api.giphy.com/v1/gifs/search?' +\n 'q=' + @boolio.val.to_s +\n '&api_key=dc6zaTOxFJmzC' + # provided for public beta testing via (https://github.com/Giphy/GiphyAPI#public-beta-key)\n '&limit=1' + # only want 1\n '&offset=' + rand(30).to_s + # pull from the top 10 most relevant images\n '&rating=pg' + # afraid if this is any higher\n '&fmt=json' # seems to return JSON anyway, but just in case\n )\n\n if response.code == 200\n\n # conver to JSON\n json = JSON.parse response.body, object_class: OpenStruct\n\n # set image from returned results\n @image = json.data[0].images if json.data.count > 0\n end\n\n end",
"def import_gifts_inst\n end",
"def index\n if params[:tag]\n @gifs = Gif.tagged_with(params[:tag]).order(:total_score => :desc).all\n elsif params[:user]\n @gifs = User.find_by_username(params[:user]).gifs.order(:total_score => :desc).all\n else\n @gifs = Gif.order(:total_score => :desc).all\n end\n respond_to do |format|\n format.html {}\n format.js {}\n end\n end",
"def new\n @indexed_gif = IndexedGif.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @indexed_gif }\n end\n end",
"def index\n\n if params[:tag]\n #puts \"TAG IS \" + params[:tag]\n #puts \"PARMAS ARE \" + params[:sort].to_s\n if params[:sort] == \"most_recent\"\n @gifs = Gif.tagged_with(params[:tag]).where(\"approved = ? AND deleted = ?\", true, false).order(\"created_at DESC\")\n else\n @gifs = Gif.tagged_with(params[:tag]).where(\"approved = ? AND deleted = ?\", true, false).order(\"ratio DESC\")\n end\n else\n @gifs = Gif.tagged_with(\"main\").where(\"approved = ? AND deleted = ?\", true, false).order(\"ratio DESC\")\n end\n\n @gifdex = @gifs.map{|gif| gif.id}\n session[:gifdex] = @gifdex\n session[:position] = 0\n if params[:tag]\n \n else\n session[:tag] = params[:tag]\n end\n\n @gif = Gif.fetch_gif_and_next(session[:gifdex], session[:position])[0]\n @next_gif = Gif.fetch_gif_and_next(session[:gifdex], session[:position])[1]\n\n render \"show\"\n end",
"def index_by_user\n @gifts = @current_user.gifts\n render json: @gifts, include: :ages, status: :ok\n end",
"def gif\n size = FFI::MemoryPointer.new(:pointer)\n ptr = ::GD2::GD2FFI.send(:gdImageGifPtr, image_ptr, size)\n ptr.get_bytes(0, size.get_int(0))\n ensure\n ::GD2::GD2FFI.send(:gdFree, ptr)\n end",
"def index\n @graphics = Graphic.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @graphics }\n end\n end",
"def index\n @in_game_gifts = InGameGift.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @in_game_gifts }\n end\n end",
"def index\n @shots = Shot.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @shots }\n end\n end",
"def set_gif_link\n @gif_link = GifLink.find(params[:id])\n end",
"def index\n @ganglia_graphs = GangliaGraph.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ganglia_graphs }\n end\n end",
"def index_by_age\n @age = Age.find(params[:age_id])\n @gifts = @age.gifts\n render json: @gifts, include: :ages, status: :ok\n end",
"def show\n @gtd = Gtd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @gtd }\n end\n end",
"def show\n @ganglia_graph = GangliaGraph.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ganglia_graph }\n end\n end",
"def print_each_photo(api_key, tag)\n # Build the URI\n uri = \"http://www.flickr.com/services/rest?method=flickr.photos.search\" +\n \"&api_key=#{api_key}&tags=#{tag}\"\n\n # Make the HTTP request and get the entity-body.\n response = open(uri).read\n\n # Parse the entity-body as an XML document.\n doc = REXML::Document.new(response)\n\n # For each photo found...\n REXML::XPath.each(doc, '//photo') do |photo| \n # ...generate and print its URI\n puts small_photo_uri(photo) if photo\n end\nend",
"def titles\n get_gifs_from_api[\"data\"].map do |gif|\n gif[\"title\"]\n end\n end",
"def get(options = {})\n with_cache(options) do |xml|\n Rails.logger.info \"[INFO] Picasa response for #{options.inspect}: #{xml}\" if @debug\n class_from_xml(xml)\n end\n end",
"def index\n @pictures = Picture.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pictures }\n end\n end",
"def import_gifts_step_two\n end",
"def destroy\n @gif.destroy\n respond_to do |format|\n format.html { redirect_to gifs_url }\n format.json { head :no_content }\n end\n end",
"def show\n @shot = Shot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @shot }\n end\n end",
"def search_giphy_for query\n\n Giphy::Configuration.configure do |config|\n config.api_key = ENV[\"GIPHY_API_KEY\"]\n end\n\n results = Giphy.search(query, {limit: 20})\n\n unless results.empty?\n #puts results.to_yaml\n gif = results.sample.original_image.url\n return gif.to_s\n\n else\n return nil\n end\n\nend",
"def create_modified_gif(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end",
"def new\n # Add second slash to url that rails routing eats\n url = request.fullpath.gsub(/\\/http(s?)\\:/, 'http:/')\n\n gif = Gif.find_or_initialize_by(url: url){|g| g.remote_gif_url = url}\n\n if gif.new_record? && gif.save\n load_index_data\n flash.now[:success] = thumb_flash(gif, \"Created gif!\")\n else\n if gif.errors.include? :checksum\n found = Gif.where(checksum: gif.checksum).first\n flash.now[:notice] = thumb_flash(found, \"We've got that GIF!\")\n end\n end\n \n load_index_data\n render action: 'index'\n end",
"def show\n @action = session[:current_friend].nil? ? 'index' : 'select_friend'\n respond_to do |format|\n # work out named path at some point\n format.html { redirect_to :controller => 'gifts', :action => \"#{@action}\", :registry_id => params[:id] }\n format.xml { render :xml => @registry }\n end\n end",
"def gist(id)\n get \"/gists/#{id}\"\n end",
"def show\n @gifdex = session[:gifdex]\n session[:position] = session[:gifdex].index(@gif.id)\n if params[:gif_id]\n @last_gif = Gif.find(params[:gif_id])\n puts \"last_gif \"+@last_gif.id.to_s\n if params[:v] == \"true\"\n puts \"up vote\"\n @last_gif.upvotes += 1\n elsif params[:v] == \"false\"\n puts \"down vote\"\n @last_gif.downvotes += 1\n end\n @last_gif.views += 1\n @last_gif.save\n end\n @next_gif = Gif.fetch_gif_and_next(session[:gifdex], session[:position])[1]\n end",
"def show\n @gallery = Gallery.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @gallery }\n end\n end",
"def show\n @images_index = ImagesIndex.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @images_index }\n end\n end",
"def show\n @gig = Gig.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gig, callback: params[:callback] }\n format.xml { render xml: @gig }\n end\n end",
"def create\n @gif = Gif.new(gif_params)\n @gif.avatar_remote_url(@gif.url)\n @gif.approved = false\n @gif.deleted = false\n @gif.upvotes = 0\n @gif.downvotes = 0\n @gif.ratio = 0\n @gif.views = 0\n\n respond_to do |format|\n if @gif.save\n format.html { redirect_to @gif, notice: 'Gif was successfully created.' }\n format.json { render action: 'show', status: :created, location: @gif }\n else\n format.html { render action: 'new' }\n format.json { render json: @gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @galerie = Galerie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @galerie }\n end\n end",
"def index\n @images = @owner.images\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @images }\n end\n end",
"def show\n @gallery = Gallery.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @gallery }\n end\n end",
"def show\n @gallery = Gallery.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @gallery }\n end\n end",
"def show\n @icon = MavenJnlp::Icon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @icon }\n end\n end",
"def show\n @im = Im.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @im }\n end\n end",
"def show\n @gig = Gig.find(params[:id])\n\n respond_to do |format|\n format.html {render json: @gig, status: :ok}\n format.json { render json: @gig, status: :ok }\n end\n end",
"def destroy\n @indexed_gif = IndexedGif.find(params[:id])\n @indexed_gif.destroy\n\n respond_to do |format|\n format.html { redirect_to indexed_gifs_url }\n format.json { head :no_content }\n end\n end",
"def show\n @gear = Gear.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @gear }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @welcome_images }\n end\n end",
"def index\n @galleries = Gallery.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @galleries }\n end\n end",
"def show\n @gallion = Gallion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @gallion }\n end\n end",
"def index\n @images = Image.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @images }\n end\n end",
"def getimagesinfo\n trek = Trek.find_by_id(params[:id])\n send_data(trek.get_images_info.to_json,\n {:type => \"application/json\", :disposition => \"inline\"})\n end",
"def test_users_can_view_random_gifs\n u = User.create! name: \"username\"\n g = Gif.create! url: \"http://giphy.com/gifs/kitten-pixel-pikachu-2s9zkB4NawQlq\", creator_id: u.id, seen_count: 0\n i = Gif.create! url: \"http://giphy.com/gifs/batman-shocked-what-11LPqjefhW3ACk\", creator_id: u.id, seen_count: 0\n f = Gif.create! url: \"http://giphy.com/gifs/kanye-west-interview-hip-hop-9cmVjltMzhPUY\", creator_id: u.id, seen_count: 0\n s = Gif.create! url: \"http://giphy.com/gifs/archer-reactiongifs-mrw-AckmGL4e1i7M4\", creator_id: u.id, seen_count: 0\n\n get \"/get_gif\"\n random_gif = JSON.parse last_response.body\n\n assert_equal 200, last_response.status\n assert_equal 1, random_gif[\"seen_count\"]\n end",
"def show\n @gpath = Gpath.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gpath }\n end\n end",
"def show\n @img_info = ImgInfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @img_info }\n end\n end",
"def getgenres(artist = \"\")\n @check = false\n @artist = RSpotify::Artist.search(artist).first\n unless @artist.nil? || @artist.genres.empty?\n session[:artist] = @artist.name\n session[:id] = @artist.id\n @check = true\n getimage\n end\nend",
"def images() \n uri = URI.parse(\"http://\" + @location.host + \":9292/v2/images\")\n return get_request(uri, @token)\n end",
"def index\n @imagens = Imagen.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @imagens }\n end\n end",
"def show\n @iconset = Iconset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @iconset }\n end\n end",
"def get_bgg_game\n response = HTTParty.get('https://www.boardgamegeek.com/xmlapi2/thing?id='+ @gameid)\n end",
"def show\n @rig = Rig.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @rig }\n end\n end",
"def show\n @gallery_item = GalleryItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @gallery_item }\n end\n end",
"def update\n @indexed_gif = IndexedGif.find(params[:id])\n\n respond_to do |format|\n if @indexed_gif.update_attributes(params[:indexed_gif])\n format.html { redirect_to @indexed_gif, notice: 'Indexed gif was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @indexed_gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def read(id=nil)\r\n request = Net::HTTP.new(@uri.host, @uri.port)\r\n if id.nil?\r\n response = request.get(\"#{@uri.path}.xml\") \r\n else\r\n response = request.get(\"#{@uri.path}/#{id}.xml\") \r\n end\r\n response.body\r\n end",
"def get(url); end",
"def show\n @graphic = Graphic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @graphic }\n end\n end",
"def show\n @graphic = Graphic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @graphic }\n end\n end",
"def show\n respond_to do |format|\n format.html\n format.xml { render xml: @gadget_file.html }\n end\n end",
"def method_missing(meth, *_args, &_block)\n args = meth.to_s.split(\"_\", 2)\n find_gif(Gif.where(github_type: args[0], activate: args[1]))\n end",
"def show\n @grm_pic = GrmPic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @grm_pic }\n end\n end",
"def index\n @photos = @album.photos\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @photos }\n end\n end",
"def index\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @badges }\n end\n end",
"def show\n @jpeg_folder = JpegFolder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @jpeg_folder }\n end\n end",
"def index\n @occasion = Occasion.find params[:occasion_id]\n \t @gifts = Gift.all\n end",
"def show\n @gig_request = GigRequest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gig_request }\n end\n end",
"def show\n @gene_ontology = GeneOntology.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @gene_ontology }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @my_badge }\n end\n end",
"def show\n @gallery_asset = GalleryAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @gallery_asset }\n end\n end",
"def show\n @badge = Badge.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @badge }\n end\n end",
"def get_image(image_id)\n request(\n :expects => 200,\n :method => 'GET',\n :parser => Fog::Parsers::Compute::Slicehost::GetImage.new,\n :path => \"images/#{image_id}.xml\"\n )\n end",
"def request(resource, method = \"get\", args = nil)\n \t \n \t @now_playing_url = 'http://62.216.251.203:80/nowplaying'\n \t @submission_url = 'http://62.216.251.205:80/protocol_1.2'\n \t @session_id = '17E61E13454CDD8B68E8D7DEEEDF6170'\n \t \n \t if @base_url == Scrobbler::API_URL\n \t pieces = resource.split('/')\n pieces.shift\n \t api_version = pieces.shift\n if api_version == \"1.0\"\n folder = pieces.shift\n file = pieces.last[0, pieces.last.index('.xml')]\n base_pieces = pieces.last.split('?')\n\n file = if base_pieces.size > 1\n # if query string params are in resource they are underscore separated for filenames\n base_pieces.last.split('&').inject(\"#{file}_\") { |str, pair| str << pair.split('=').join('_') + '_'; str }.chop!\n else\n file\n end\n\n File.read(File.dirname(__FILE__) + \"/../fixtures/xml/#{folder}/#{file}.xml\")\n elsif api_version == \"2.0\"\n method_pieces = pieces.last.split('&')\n api_method = method_pieces.shift\n if api_method == '?method=artist.search'\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/search/artist.xml\")\n elsif api_method == '?method=album.search'\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/search/album.xml\")\n elsif api_method == '?method=track.search'\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/search/track.xml\")\n elsif pieces.last =~ /[?&]method=album\\.getinfo/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/album/info.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.gettoptags/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/toptags.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.search/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/search.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.gettopfans/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/fans.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.gettoptracks/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/toptracks.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.gettopalbums/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/topalbums.xml\")\n elsif pieces.last =~ /[?&]method=artist\\.getsimilar/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/artist/similar.xml\")\n elsif pieces.last =~ /[?&]method=album\\.search/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/album/search.xml\")\n elsif pieces.last =~ /[?&]method=tag\\.gettoptracks/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/tag/toptracks.xml\")\n elsif pieces.last =~ /[?&]method=tag\\.gettopartists/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/tag/topartists.xml\")\n elsif pieces.last =~ /[?&]method=tag\\.gettopalbums/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/tag/topalbums.xml\")\n elsif pieces.last =~ /[?&]method=track\\.gettoptags/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/track/toptags.xml\")\n elsif pieces.last =~ /[?&]method=track\\.gettopfans/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/track/fans.xml\")\n elsif pieces.last =~ /[?&]method=track\\.search/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/track/search.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getlovedtracks/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/lovedtracks.xml\")\n elsif pieces.last =~ /[?&]method=user\\.gettopartists/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/topartists.xml\")\n elsif pieces.last =~ /[?&]method=user\\.gettopalbums/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/topalbums.xml\")\n elsif pieces.last =~ /[?&]method=user\\.gettoptracks/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/toptracks.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getfriends/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/friends.xml\")\n elsif pieces.last =~ /[?&]method=user\\.gettoptags/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/toptags.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getneighbours/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/neighbours.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getrecenttracks/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/recenttracks.xml\")\n elsif pieces.last =~ /[?&]method=user\\.playlists/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/playlists.xml\")\n elsif pieces.last =~ /[?&]method=event\\.getinfo/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/event/event.xml\")\n elsif pieces.last =~ /[?&]method=event\\.getshouts/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/event/shouts.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getweeklyalbumchart/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/weeklyalbumchart.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getweeklyartistchart/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/weeklyartistchart.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getweeklytrackchart/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/weeklytrackchart.xml\")\n elsif pieces.last =~ /[?&]method=user\\.getevents/\n return File.read(File.dirname(__FILE__) + \"/../fixtures/xml/user/events.xml\")\n else\n old_request(resource, method, args)\n end\n end\n \t elsif @base_url == Scrobbler::AUTH_URL\n if args[:hs] == \"true\" && args[:p] == Scrobbler::AUTH_VER.to_s && args[:c] == 'rbs' &&\n args[:v] == '0.2.13' && args[:u] == 'chunky' && !args[:t].blank? &&\n args[:a] == Digest::MD5.hexdigest('7813258ef8c6b632dde8cc80f6bda62f' + args[:t])\n \n \"OK\\n#{@session_id}\\n#{@now_playing_url}\\n#{@submission_url}\"\n end\n elsif @base_url == @now_playing_url\n if args[:s] == @session_id && ![args[:a], args[:t], args[:b], args[:n]].any?(&:blank?)\n 'OK'\n end \n elsif @base_url == @submission_url\n if args[:s] == @session_id && \n ![args['a[0]'], args['t[0]'], args['i[0]'], args['o[0]'], args['l[0]'], args['b[0]']].any?(&:blank?)\n 'OK'\n end\n\t end\n\t end",
"def create\n @indexed_gif = IndexedGif.new(params[:indexed_gif])\n\n respond_to do |format|\n if @indexed_gif.save\n format.html { redirect_to @indexed_gif, notice: 'Indexed gif was successfully created.' }\n format.json { render json: @indexed_gif, status: :created, location: @indexed_gif }\n else\n format.html { render action: \"new\" }\n format.json { render json: @indexed_gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @imagem = Imagem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @imagem }\n end\n end",
"def run\n ::SimpleHttp.get(@url).tap do |response|\n status, headers, blob = *response\n response[2] = Magick::Image.from_blob(blob).first if status == 200\n end\n end",
"def get_image1(doc, image)\n x = doc.xpath(image).to_s\n end",
"def index\n @gifdays = Gifday.all\n \n end",
"def gif_params\n params.require(:gif).permit(:id, :url, :preview, :src, :title, :collection_id)\n end",
"def show\n @pictures = TaxiSevice.find(params[:id]).taxi_images\n end"
] |
[
"0.6863615",
"0.6595635",
"0.6563485",
"0.6487047",
"0.6266359",
"0.6160782",
"0.6160782",
"0.6150649",
"0.6147858",
"0.61192554",
"0.61192554",
"0.61090267",
"0.6100445",
"0.6100445",
"0.6100445",
"0.6100445",
"0.6100445",
"0.60973257",
"0.58278924",
"0.5814098",
"0.57243335",
"0.57029134",
"0.5686228",
"0.5674975",
"0.5602088",
"0.5596466",
"0.55940723",
"0.5588893",
"0.5559865",
"0.55596673",
"0.55403924",
"0.547595",
"0.5474218",
"0.5472279",
"0.54491234",
"0.5433771",
"0.54231775",
"0.5423177",
"0.541408",
"0.54103726",
"0.5399665",
"0.5394086",
"0.53858244",
"0.5377944",
"0.5367024",
"0.5366349",
"0.5365358",
"0.5360442",
"0.5358405",
"0.53439254",
"0.5341217",
"0.5336989",
"0.533608",
"0.53231835",
"0.53231835",
"0.53229046",
"0.5320589",
"0.5317894",
"0.5308112",
"0.5302911",
"0.5301609",
"0.5295233",
"0.5285274",
"0.528171",
"0.5276626",
"0.5274358",
"0.5266405",
"0.5265104",
"0.5263129",
"0.5260751",
"0.52553695",
"0.5255239",
"0.5242872",
"0.5240862",
"0.52389175",
"0.5237214",
"0.5235519",
"0.5232029",
"0.52155846",
"0.52155846",
"0.5202529",
"0.51955044",
"0.51935345",
"0.51886797",
"0.51810014",
"0.5171292",
"0.51702917",
"0.5165355",
"0.5163069",
"0.5156217",
"0.5154005",
"0.5153841",
"0.51405233",
"0.51375306",
"0.51371163",
"0.5135695",
"0.5134279",
"0.51337016",
"0.5129339",
"0.5118297",
"0.5112788"
] |
0.0
|
-1
|
GET /gifts/new GET /gifts/new.xml
|
def new
@gift = Gift.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @gift }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n # Add second slash to url that rails routing eats\n url = request.fullpath.gsub(/\\/http(s?)\\:/, 'http:/')\n\n gif = Gif.find_or_initialize_by(url: url){|g| g.remote_gif_url = url}\n\n if gif.new_record? && gif.save\n load_index_data\n flash.now[:success] = thumb_flash(gif, \"Created gif!\")\n else\n if gif.errors.include? :checksum\n found = Gif.where(checksum: gif.checksum).first\n flash.now[:notice] = thumb_flash(found, \"We've got that GIF!\")\n end\n end\n \n load_index_data\n render action: 'index'\n end",
"def new\n @indexed_gif = IndexedGif.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @indexed_gif }\n end\n end",
"def create_modified_gif(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end",
"def new\n @img = Img.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @img }\n end\n end",
"def new\n @gig_request = GigRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gig_request }\n end\n end",
"def new\n @shot = Shot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shot }\n end\n end",
"def new\n @gig = Gig.new()\n @gig.build_attachment\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gig }\n end\n end",
"def new\n @pic = Pic.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pic }\n end\n end",
"def new\n @gallery = Gallery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gallery }\n end\n end",
"def new\n @gallery = Gallery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gallery }\n end\n end",
"def create\n @gif = Gif.new(gif_params)\n @gif.avatar_remote_url(@gif.url)\n @gif.approved = false\n @gif.deleted = false\n @gif.upvotes = 0\n @gif.downvotes = 0\n @gif.ratio = 0\n @gif.views = 0\n\n respond_to do |format|\n if @gif.save\n format.html { redirect_to @gif, notice: 'Gif was successfully created.' }\n format.json { render action: 'show', status: :created, location: @gif }\n else\n format.html { render action: 'new' }\n format.json { render json: @gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @img_info = ImgInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @img_info }\n end\n end",
"def new\n @picture = Picture.new\n\n respond_to do |wants|\n wants.html # new.html.erb\n wants.xml { render :xml => @picture }\n end\n end",
"def new\n @gpath = Gpath.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gpath }\n end\n end",
"def new\n @icon = MavenJnlp::Icon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @icon }\n end\n end",
"def new\n @title = t :'view.pigs.new_title'\n @pig = Pig.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pig }\n end\n end",
"def new\n @jpeg_folder = JpegFolder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @jpeg_folder }\n end\n end",
"def new\n @bg = Bg.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bg }\n end\n end",
"def new\n @image_path = ImagePath.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @image_path }\n end\n end",
"def new\n @gear = Gear.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gear }\n end\n end",
"def new\n expire_page :action => :index\n expire_page :action => :show\n \n @ganglia_graph = GangliaGraph.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ganglia_graph }\n end\n end",
"def new\n @graphic = Graphic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @graphic }\n end\n end",
"def create\n @indexed_gif = IndexedGif.new(params[:indexed_gif])\n\n respond_to do |format|\n if @indexed_gif.save\n format.html { redirect_to @indexed_gif, notice: 'Indexed gif was successfully created.' }\n format.json { render json: @indexed_gif, status: :created, location: @indexed_gif }\n else\n format.html { render action: \"new\" }\n format.json { render json: @indexed_gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @galerie = Galerie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @galerie }\n end\n end",
"def new\n @gallery_item = GalleryItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gallery_item }\n end\n end",
"def new\n @images_index = ImagesIndex.new nil\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @images_index }\n end\n end",
"def new\n @gtd = Gtd.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gtd }\n end\n end",
"def new\n @gene_ontology = GeneOntology.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gene_ontology }\n end\n end",
"def new\n @picture = Picture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @picture }\n end\n end",
"def new\n @picture = Picture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @picture }\n end\n end",
"def modify_gif(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end",
"def new\n @badge = Badge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @badge }\n end\n end",
"def new\n @gallery_image = @project.gallery_images.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gallery_image }\n end\n end",
"def create\n @gif = Gif.new(gif_params)\n\n respond_to do |format|\n if @gif.save\n format.html { redirect_to @gif, notice: 'Gif was successfully created.' }\n format.js {@gifs = Gif.all.order('created_at DESC')}\n else\n format.js {render :new }\n end\n end\n end",
"def new\n @gist = Gist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gist }\n end\n end",
"def new\n @nif = Nif.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nif }\n end\n end",
"def new\n @action_graphic = ActionGraphic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @action_graphic }\n end\n end",
"def new\n @gallion = Gallion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gallion }\n end\n end",
"def new\n @iconset = Iconset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @iconset }\n end\n end",
"def new\n @image = Image.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @image }\n end\n end",
"def new\n @gallery_asset = GalleryAsset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gallery_asset }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @welcome_image }\n end\n end",
"def new\n @gig = Gig.new\n @venue = Venue.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gig }\n end\n end",
"def new\n @gitem = Gitem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gitem }\n end\n end",
"def new\n @galeria = Galeria.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @galeria }\n end\n end",
"def new\n @rig = Rig.new\n @main_header = \"New Rig\"\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rig }\n end\n end",
"def index\n @gifts = current_host.gifts\n end",
"def show\n @indexed_gif = IndexedGif.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indexed_gif }\n end\n end",
"def new\n @tags_songs = TagsSongs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tags_songs }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end",
"def new\n @uploaded_image = UpdatedImage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @uploaded_image }\n end\n end",
"def new\n @pdig = Pdig.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pdig }\n end\n end",
"def new\n @geocache = Geocache.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @geocache }\n end\n end",
"def new\n @genre = Genre.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @genre }\n end\n end",
"def new\n @image = Image.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @image }\n end\n end",
"def new\n @grm_pic = GrmPic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @grm_pic }\n end\n end",
"def new\n# @fossil = Fossil.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fossil }\n end\n end",
"def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stat }\n end\n end",
"def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stat }\n end\n end",
"def create\n @gif = Gif.new(gif_params)\n @gif.user = current_user\n\n respond_to do |format|\n if @gif.save\n format.html { redirect_to @gif, notice: 'Gif was successfully created.' }\n format.json { render action: 'show', status: :created, location: @gif }\n else\n format.html { render action: 'new' }\n format.json { render json: @gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @phot = Phot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @phot }\n end\n end",
"def new\n @nspirefile = Nspirefile.new\n @categories = get_categories\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nspirefile }\n end\n end",
"def new\n @icon = Icon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @icon }\n end\n end",
"def new\n @good = Good.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @good }\n end\n end",
"def new\n @gnode = Gnode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gnode }\n end\n end",
"def new\n @svg_file = Cmtool::SvgFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @svg_file }\n end\n end",
"def new\n @path = Path.new({:layer => @layer})\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @path }\n end\n end",
"def new\n @upload = Upload.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @upload }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def new\n @ganho = Ganho.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ganho }\n end\n end",
"def new\n @thing = Thing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing }\n end\n end",
"def new\n @gossip = Gossip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gossip }\n end\n end",
"def new\n @gift = Gift.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gift }\n end\n end",
"def new2\n #does not allow attaching a picture\n @listing = Listing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.fbml # new.fbml.erb\n format.xml { render :xml => @listing }\n end\n end",
"def new\n get_status\n @tag = Tag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tag }\n end\n end",
"def new\n @giftstate = Giftstate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @giftstate }\n end\n end",
"def create_url\n \"#{api_url}/gists\"\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @infraction_type }\n end\n end",
"def new\n @good = Good.new\n\n @good.fuimage = Fuimage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @good }\n end\n end",
"def new\n @thumb = Thumb.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thumb }\n end\n end",
"def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end",
"def get_svg\n\t expires_in(1.hours, :private => false, :public => true)\n\t source_fedora_object = Multiresimage.find(params[:id])\n\t authorize! :show, source_fedora_object\n\t @svg = source_fedora_object.DELIV_OPS.content()\n gon.url = DIL_CONFIG['dil_js_url']\n respond_to do |wants|\n wants.xml { render :xml => @svg }\n end\n end",
"def get_svg\n\t expires_in(1.hours, :private => false, :public => true)\n\t source_fedora_object = Multiresimage.find(params[:id])\n\t authorize! :show, source_fedora_object\n\t @svg = source_fedora_object.DELIV_OPS.content()\n gon.url = DIL_CONFIG['dil_js_url']\n respond_to do |wants|\n wants.xml { render :xml => @svg }\n end\n end",
"def create\n @cat_gif = CatGif.new(cat_gif_params)\n\n respond_to do |format|\n if @cat_gif.save\n format.html { redirect_to @cat_gif, notice: 'Cat gif was successfully created.' }\n format.json { render :show, status: :created, location: @cat_gif }\n else\n format.html { render :new }\n format.json { render json: @cat_gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @tag = Tag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tag }\n end\n end",
"def new\n @tag = Tag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tag }\n end\n end",
"def new\n @tag = Tag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tag }\n end\n end",
"def new\n @drop = Drop.new\n @breadcrumbs = [{\"home\" => drops_url}, {\"new file\" => nil}]\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @drop }\n end\n end",
"def new\n @file_upload = FileUpload.new\n\n respond_to do |wants|\n wants.html # new.html.erb\n wants.xml { render :xml => @file_upload }\n end\n end",
"def new\n @components_grip = Components::Grip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @components_grip }\n end\n end",
"def new_rest\n @instrument_version = InstrumentVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instrument_version }\n end\n end",
"def new\n @image = Image.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @console_image }\n end\n end",
"def new\n @project_image = ProjectImage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project_image }\n end\n end",
"def new\n @image_set = ImageSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @image_set }\n end\n end"
] |
[
"0.69246763",
"0.6854227",
"0.63873047",
"0.63285905",
"0.62631756",
"0.6238503",
"0.6180873",
"0.6167866",
"0.6145787",
"0.6145787",
"0.6131883",
"0.61310136",
"0.6106022",
"0.60948694",
"0.60822564",
"0.6079595",
"0.60792994",
"0.6073825",
"0.60673827",
"0.6059845",
"0.60585225",
"0.6047909",
"0.60290104",
"0.6018814",
"0.6018751",
"0.60129833",
"0.6009069",
"0.600082",
"0.5990755",
"0.59892845",
"0.59892845",
"0.5977187",
"0.597266",
"0.5951153",
"0.5943632",
"0.5943557",
"0.59174037",
"0.591618",
"0.5916083",
"0.5902613",
"0.5880509",
"0.58780724",
"0.58765775",
"0.5875207",
"0.58685905",
"0.58616257",
"0.58398044",
"0.58385015",
"0.5818262",
"0.5816109",
"0.5814164",
"0.58104247",
"0.5807744",
"0.58025175",
"0.57888603",
"0.57672447",
"0.57616276",
"0.5756919",
"0.57420325",
"0.57420325",
"0.5738653",
"0.57351273",
"0.57346255",
"0.57295907",
"0.57250124",
"0.5722225",
"0.5719748",
"0.5715304",
"0.57142025",
"0.57133126",
"0.57133126",
"0.57133126",
"0.57133126",
"0.57133126",
"0.57133126",
"0.5705712",
"0.5692474",
"0.56896806",
"0.56865364",
"0.5685813",
"0.5685436",
"0.5680993",
"0.567748",
"0.5677328",
"0.5674494",
"0.5671783",
"0.5663251",
"0.5662126",
"0.5662126",
"0.56556433",
"0.56547284",
"0.56547284",
"0.56547284",
"0.5645502",
"0.56417537",
"0.5639708",
"0.5638718",
"0.5638307",
"0.56372607",
"0.5630218"
] |
0.6123608
|
12
|
POST /gifts POST /gifts.xml
|
def create
@user = current_user
@gift = @user.gifts.create(params[:gift])
respond_to do |format|
if @gift.save
flash[:notice] = 'Gift idea was successfully added.'
#format.html { redirect_to :action => :index }
format.html { render :partial => 'gift', :locals => { :gift => @gift } }
format.xml { render :xml => @gift, :status => :created, :location => @gift }
format.json { render :json => @gift.to_json, :status => :created }
else
format.json { render :json => @gift.to_json }
format.html { render :action => "new" }
format.xml { render :xml => @gift.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @gif = Gif.new(gif_params)\n @gif.avatar_remote_url(@gif.url)\n @gif.approved = false\n @gif.deleted = false\n @gif.upvotes = 0\n @gif.downvotes = 0\n @gif.ratio = 0\n @gif.views = 0\n\n respond_to do |format|\n if @gif.save\n format.html { redirect_to @gif, notice: 'Gif was successfully created.' }\n format.json { render action: 'show', status: :created, location: @gif }\n else\n format.html { render action: 'new' }\n format.json { render json: @gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_modified_gif(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end",
"def create\n @indexed_gif = IndexedGif.new(params[:indexed_gif])\n\n respond_to do |format|\n if @indexed_gif.save\n format.html { redirect_to @indexed_gif, notice: 'Indexed gif was successfully created.' }\n format.json { render json: @indexed_gif, status: :created, location: @indexed_gif }\n else\n format.html { render action: \"new\" }\n format.json { render json: @indexed_gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gif = Gif.new(gif_params)\n @gif.user = current_user\n\n respond_to do |format|\n if @gif.save\n format.html { redirect_to @gif, notice: 'Gif was successfully created.' }\n format.json { render action: 'show', status: :created, location: @gif }\n else\n format.html { render action: 'new' }\n format.json { render json: @gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def gif_params\n params.require(:gif).permit(:url, :tag_list)\n end",
"def create\n @gif = Gif.new(gif_params)\n\n respond_to do |format|\n if @gif.save\n format.html { redirect_to @gif, notice: 'Gif was successfully created.' }\n format.js {@gifs = Gif.all.order('created_at DESC')}\n else\n format.js {render :new }\n end\n end\n end",
"def gif_params\n params.require(:gif).permit(:id, :url, :preview, :src, :title, :collection_id)\n end",
"def gif_params\n params.require(:gif).permit( :url, :user_id, :file)\n end",
"def create\n @cat_gif = CatGif.new(cat_gif_params)\n\n respond_to do |format|\n if @cat_gif.save\n format.html { redirect_to @cat_gif, notice: 'Cat gif was successfully created.' }\n format.json { render :show, status: :created, location: @cat_gif }\n else\n format.html { render :new }\n format.json { render json: @cat_gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def gif_params\n params.require(:gif).permit(:caption, :upvotes, :downvotes, :views, :ratio, :avatar, :url, :tag_list)\n end",
"def gif_params\n params.require(:gif).permit(:name)\n end",
"def modify_gif(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def repost_pixi\n listing = Listing.new(get_attr(true))\n listing = add_photos false, listing\n listing.generate_token\n listing.status, listing.repost_flg = 'active', true\n listing.set_end_date\n listing.save!\n end",
"def import_gifts_inst\n end",
"def write_gif_data(utm_url, time_stamp, visitor_id)\n header = {}\n\n header[\"Content-Type\"] = \"image/gif\"\n header[\"Cache-Control\"] = \"private, no-cache, no-cache=Set-Cookie, proxy-revalidate\"\n header[\"Pragma\"] = \"no-cache\"\n header[\"Expires\"] = \"Wed, 17 Sep 1975 21:32:10 GMT\"\n\n #If the debug parameter is on, add a header to the response that contains\n #the url that was used to contact Google Analytics.\n header[\"X-GA-MOBILE-URL\"] = utm_url if $cgi[\"utmdebug\"] != \"\"\n\n #Always try and add the cookie to the response.\n header[\"cookie\"] = CGI::Cookie.new({\n \"name\" => COOKIE_NAME,\n \"value\" => visitor_id,\n \"expire\" => time_stamp + COOKIE_USER_PERSISTENCE.to_s,\n 'path' => COOKIE_PATH\n })\n\n $cgi.out(header){GIF_DATA.pack(\"C35\")}\nend",
"def new\n @indexed_gif = IndexedGif.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @indexed_gif }\n end\n end",
"def index\n @gifts = current_host.gifts\n end",
"def destroy\n @gif.destroy\n respond_to do |format|\n format.html { redirect_to gifs_url }\n format.json { head :no_content }\n end\n end",
"def create\n gig = Gig.new()\n respond_to do |format|\n if update_gig(gig)\n format.html { render json: gig, status: :created, location: gig }\n format.json { render json: gig, status: :created, location: gig }\n else\n format.html { render action: \"new\" }\n format.json { render json: gig.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @indexed_gif = IndexedGif.find(params[:id])\n\n respond_to do |format|\n if @indexed_gif.update_attributes(params[:indexed_gif])\n format.html { redirect_to @indexed_gif, notice: 'Indexed gif was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @indexed_gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @gif.update(gif_params)\n format.html do\n if params[:commit].include? \"More\"\n redirect_to edit_gif_path(Gif.untagged.first), notice: 'Gif was successfully updated.'\n else\n redirect_to @gif, notice: 'Gif was successfully updated.'\n end\n end\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @gifts = Gift.all\n end",
"def index\n @gifts = Gift.all\n end",
"def getgpx\n trek = Trek.find_by_id(params[:id])\n send_file trek.get_gpx(), :type => \"text/xml\", :disposition => \"inline\"\n end",
"def cat_gif_params\n params.require(:cat_gif).permit(:title, :url, :score)\n end",
"def create\n @gift = @user.gifts.new(params[:gift])\n\n @gift.null_gates\n respond_to do |format|\n if @gift.save\n flash[:notice] = 'Gift is now part of your collection.'\n format.html { redirect_to( edit_gift_path(@gift) ) }\n format.xml { render :xml => @gift, :status => :created, :location => @gift }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @gift.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :index, @user, :message => 'Not authorized as an administrator.'\n respond_to do |format|\n if @gif.update(gif_params)\n format.html { redirect_to @gif, notice: 'Gif was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gifday = Gifday.new(gifday_params)\n\n respond_to do |format|\n if @gifday.save\n format.html { redirect_to @gifday, notice: 'Gifday was successfully created.' }\n format.json { render :show, status: :created, location: @gifday }\n else\n format.html { render :new }\n format.json { render json: @gifday.errors, status: :unprocessable_entity }\n end\n end\n end",
"def example(request,response2)\n `rsvg-convert /tmp/chart.svg -o /tmp/chart.png`### Conversion of charts from .svg format provided by GerbilCharts to .png format\n file=File.read(\"/tmp/chart.png\")\n response2[\"Content-Type\"] = \"image/png\"\n response2.write(file)\n response2.finish\n end",
"def import_gifts_step_two\n end",
"def gifify\n\tframes = 50\n gif = ImageList.new\n\tframes.times do |i|\n\t gif.concat(ImageList.new(\"tempImages/image#{i}.png\"))\n\tend\n\tgif.delay = 20\n\tgif.ticks_per_second = 50 \n\tgif.write(\"DOORCAPTURE.gif\")\n end",
"def set_gif_link\n @gif_link = GifLink.find(params[:id])\n end",
"def modify_gif_and_upload_to_storage\n puts('Update parameters of a GIF image and upload to cloud storage')\n\n upload_sample_image_to_cloud\n\n background_color_index = 5\n color_resolution = 4\n has_trailer = true\n interlaced = false\n is_palette_sorted = true\n pixel_aspect_ratio = 4\n from_scratch = nil\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ModifyGifRequest.new(\n get_sample_image_file_name, background_color_index, color_resolution, has_trailer, interlaced,\n is_palette_sorted, pixel_aspect_ratio, from_scratch, folder, storage)\n\n puts(\"Call ModifyGif with params: background color index: #{background_color_index}, color resolution: \" +\n \"#{color_resolution}, has trailer: #{has_trailer}, interlaced: #{interlaced}}, is palette sorted: \" +\n \"#{is_palette_sorted}, pixel aspect ratio: #{pixel_aspect_ratio}\")\n\n updated_image = @imaging_api.modify_gif(request)\n upload_image_to_cloud(get_modified_sample_image_file_name, updated_image)\n puts\n end",
"def show\n @next_gif = @gif.next\n @prev_gif = @gif.prev\n\n respond_to do |format|\n format.html\n format.json { render json: @gif }\n format.gif { redirect_to @gif.url }\n end\n end",
"def create\n @vote = Vote.new(vote_params)\n @gif=Gif.find(@vote.gif_id)\n respond_to do |format|\n if @vote.save\n format.js { }\n else\n format.js { }\n end\n end\n end",
"def create\n\t\t @business_gifting = Spree::BusinessGifting.new(params[:business_gifting])\n\n\t\t respond_to do |format|\n\t\t if @business_gifting.save\n\t\t format.html { redirect_to \"/business_gifting_confirmation\" }\n\t\t format.json { render json: @business_gifting, status: :created, location: @business_gifting }\n\t\t else\n\t\t format.html { render action: \"new\" }\n\t\t format.json { render json: @business_gifting.errors, status: :unprocessable_entity }\n\t\t end\n\t\t end\n\t\tend",
"def create\n @g_file = GFile.new(g_file_params)\n\n respond_to do |format|\n if @g_file.save\n format.html { redirect_to @g_file, notice: 'G file was successfully created.' }\n format.json { render :show, status: :created, location: @g_file }\n else\n format.html { render :new }\n format.json { render json: @g_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @gif.destroy\n respond_to do |format|\n format.html { redirect_to gifs_url, notice: 'Gif was successfully destroyed.' }\n format.js {}\n end\n end",
"def new\n # Add second slash to url that rails routing eats\n url = request.fullpath.gsub(/\\/http(s?)\\:/, 'http:/')\n\n gif = Gif.find_or_initialize_by(url: url){|g| g.remote_gif_url = url}\n\n if gif.new_record? && gif.save\n load_index_data\n flash.now[:success] = thumb_flash(gif, \"Created gif!\")\n else\n if gif.errors.include? :checksum\n found = Gif.where(checksum: gif.checksum).first\n flash.now[:notice] = thumb_flash(found, \"We've got that GIF!\")\n end\n end\n \n load_index_data\n render action: 'index'\n end",
"def gif_link_params\n params.require(:gif_link).permit(:title, :url, :description)\n end",
"def create\n @gift = Gift.new(gift_params)\n #画像が登録されていなかったらid1の画像を設定する\n if params[:gift][:img] !=nil\n @gift.img = params[:gift][:img].read # <= バイナリをセット\n @gift.img_content_type = params[:gift][:img].content_type # <= ファイルタイプをセット\n else\n @gift.img = Gift.find(1).img\n @gift.img_content_type = Gift.find(1).img_content_type\n end\n\n respond_to do |format|\n if @gift.save\n format.html { redirect_to @gift, notice: 'Gift was successfully created.' }\n format.json { render :show, status: :created, location: @gift }\n else\n format.html { render :new }\n format.json { render json: @gift.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_modified_svg(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end",
"def new\n @gig = Gig.new()\n @gig.build_attachment\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gig }\n end\n end",
"def destroy\n @indexed_gif = IndexedGif.find(params[:id])\n @indexed_gif.destroy\n\n respond_to do |format|\n format.html { redirect_to indexed_gifs_url }\n format.json { head :no_content }\n end\n end",
"def upload_gpx\n upload_file(params[:gpx_file]) if params[:gpx_file]\n end",
"def update\n respond_to do |format|\n if @cat_gif.update(cat_gif_params)\n format.html { redirect_to @cat_gif, notice: 'Cat gif was successfully updated.' }\n format.json { render :show, status: :ok, location: @cat_gif }\n else\n format.html { render :edit }\n format.json { render json: @cat_gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def process_gif(video, output_key, tmpdir)\n local_output_path = \"#{tmpdir}/#{File.basename output_key}\"\n\n video.gif(local_output_path)\n\n upload(local_output_path, output_key)\n\n local_output_path\n end",
"def get_svg\n\t expires_in(1.hours, :private => false, :public => true)\n\t source_fedora_object = Multiresimage.find(params[:id])\n\t authorize! :show, source_fedora_object\n\t @svg = source_fedora_object.DELIV_OPS.content()\n gon.url = DIL_CONFIG['dil_js_url']\n respond_to do |wants|\n wants.xml { render :xml => @svg }\n end\n end",
"def get_svg\n\t expires_in(1.hours, :private => false, :public => true)\n\t source_fedora_object = Multiresimage.find(params[:id])\n\t authorize! :show, source_fedora_object\n\t @svg = source_fedora_object.DELIV_OPS.content()\n gon.url = DIL_CONFIG['dil_js_url']\n respond_to do |wants|\n wants.xml { render :xml => @svg }\n end\n end",
"def update_gif\r\n @gif_handle.update(bitmap)\r\n end",
"def show\n @indexed_gif = IndexedGif.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indexed_gif }\n end\n end",
"def post_new_gist content \n\t\t\t\turl = GITHUB_API_GIST_LINK \n\t\t\t\tresponse = https_open_for ({url: url, mthd:\"post\", content: content})\n \t\t\t\tJSON.parse response.body\n\t\t\tend",
"def gif\n size = FFI::MemoryPointer.new(:pointer)\n ptr = ::GD2::GD2FFI.send(:gdImageGifPtr, image_ptr, size)\n ptr.get_bytes(0, size.get_int(0))\n ensure\n ::GD2::GD2FFI.send(:gdFree, ptr)\n end",
"def create\n @gig_request = GigRequest.new(params[:gig_request])\n\n respond_to do |format|\n if @gig_request.save\n format.html { redirect_to @gig_request, notice: 'Gig request was successfully created.' }\n format.json { render json: @gig_request, status: :created, location: @gig_request }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gig_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @shot = Shot.new(shot_params)\n @shot.save\n respond_with @shot\n end",
"def index\n @gifs = Gif.sorted.paginate(page: params[:page], per_page: 12)\n\n respond_to do |format|\n format.html\n format.json { render json: @gifs }\n end\n end",
"def postFlatpackIcon( flatpack_id, filedata)\n params = Hash.new\n params['flatpack_id'] = flatpack_id\n params['filedata'] = filedata\n return doCurl(\"post\",\"/flatpack/icon\",params)\n end",
"def put_images_extract_as_gif_with_http_info(name, page_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_images_extract_as_gif ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PdfApi.put_images_extract_as_gif\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.put_images_extract_as_gif\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/images/extract/gif\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'destFolder'] = opts[:'dest_folder'] if !opts[:'dest_folder'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n # Fix header in file\n post_body = nil\n\n # http body (model)\n # Fix header in file\n # post_body = nil\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_images_extract_as_gif\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @gifs = Gif.all.order(\"created_at DESC\")\n respond_to do |format|\n format.html {}\n format.js {}\n end\n end",
"def post_file_to_server id, content, size, page_count, extension = \".jpg\"\n\n @s.execute_file_post @s.url_for(\"system/pool/createfile.#{id}.page#{page_count}-#{size}\"), \"thumbnail\", \"thumbnail\", content, related_mimetype(extension)\n alt_url = @s.url_for(\"p/#{id}/page#{page_count}.#{size}\" + extension)\n @s.execute_post alt_url, {\"sakai:excludeSearch\" => true}\n log \"Uploaded image to curl #{alt_url}\"\nend",
"def convert_to_gif_with_http_info(image_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertApi.convert_to_gif ...'\n end\n # verify the required parameter 'image_file' is set\n if @api_client.config.client_side_validation && image_file.nil?\n fail ArgumentError, \"Missing the required parameter 'image_file' when calling ConvertApi.convert_to_gif\"\n end\n # resource path\n local_var_path = '/image/convert/to/gif'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['imageFile'] = image_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertApi#convert_to_gif\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def getimagesinfo\n trek = Trek.find_by_id(params[:id])\n send_data(trek.get_images_info.to_json,\n {:type => \"application/json\", :disposition => \"inline\"})\n end",
"def element\n image_name_list = get_image_name_list ORIGINALS_PATH\n image_name_list.each { |image_name| post(image_name) }\n end",
"def index\n @in_game_gifts = InGameGift.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @in_game_gifts }\n end\n end",
"def create_modified_gif_from_request_body\n puts('Update parameters of a GIF image from request body')\n\n background_color_index = 5\n color_resolution = 4\n has_trailer = true\n interlaced = false\n is_palette_sorted = true\n pixel_aspect_ratio = 4\n from_scratch = nil\n storage = nil # We are using default Cloud Storage\n out_path = nil # Path to updated file (if this is empty, response contains streamed image)\n\n input_stream = File.open(File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, get_sample_image_file_name), 'r')\n request = AsposeImagingCloud::CreateModifiedGifRequest.new(\n input_stream, background_color_index, color_resolution, has_trailer, interlaced, is_palette_sorted,\n pixel_aspect_ratio, from_scratch, out_path, storage)\n\n puts(\"Call CreateModifiedGif with params: background color index: #{background_color_index}, color resolution: \" +\n \"#{color_resolution}, has trailer: #{has_trailer}, interlaced: #{interlaced}}, is palette sorted: \" +\n \"#{is_palette_sorted}, pixel aspect ratio: #{pixel_aspect_ratio}\")\n\n updated_image = imaging_api.create_modified_gif(request)\n save_updated_sample_image_to_output(updated_image, true)\n puts\n end",
"def index\n if params[:tag]\n @gifs = Gif.tagged_with(params[:tag]).order(:total_score => :desc).all\n elsif params[:user]\n @gifs = User.find_by_username(params[:user]).gifs.order(:total_score => :desc).all\n else\n @gifs = Gif.order(:total_score => :desc).all\n end\n respond_to do |format|\n format.html {}\n format.js {}\n end\n end",
"def create\n @svgpost = Svgpost.new(params[:svgpost])\n\n respond_to do |format|\n if @svgpost.save\n format.html { redirect_to @svgpost, notice: 'Svgpost was successfully created.' }\n format.json { render json: @svgpost, status: :created, location: @svgpost }\n else\n format.html { render action: \"new\" }\n format.json { render json: @svgpost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @task_tag = TaskTag.new(task_tag_params)\n attach_file(:icon)\n respond_to do |format|\n if @task_tag.save\n format.html { redirect_to @task_tag, notice: 'Task tag was successfully created.' }\n format.json { render :show, status: :created, location: @task_tag }\n else\n format.html { render :new }\n format.json { render json: @task_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_cat_gif\n @cat_gif = CatGif.find(params[:id])\n end",
"def gig_params\n params.require(:gig).permit(:name, :price, :photo_url, :start_time, :gig_image, :remote_gig_image_url, :user_id, :location_id)\n end",
"def process_gif(data, filename)\n type = 'gif'\n x_dpi = 96\n y_dpi = 96\n\n width = data[6, 2].unpack1(\"v\")\n height = data[8, 2].unpack1(\"v\")\n\n raise \"#{filename}: no size data found in gif image.\\n\" if height.nil?\n\n [type, width, height, x_dpi, y_dpi]\n end",
"def put_image_extract_as_gif_with_http_info(name, image_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_image_extract_as_gif ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PdfApi.put_image_extract_as_gif\"\n end\n # verify the required parameter 'image_id' is set\n if @api_client.config.client_side_validation && image_id.nil?\n fail ArgumentError, \"Missing the required parameter 'image_id' when calling PdfApi.put_image_extract_as_gif\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/images/{imageId}/extract/gif\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'imageId' + '}', image_id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'destFolder'] = opts[:'dest_folder'] if !opts[:'dest_folder'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n # Fix header in file\n post_body = nil\n\n # http body (model)\n # Fix header in file\n # post_body = nil\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_image_extract_as_gif\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def put_images_extract_as_gif(name, page_number, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = put_images_extract_as_gif_with_http_info(name, page_number, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = put_images_extract_as_gif_with_http_info(name, page_number, opts)\n else\n raise\n end\n return data\n end",
"def postMultipackLogo( multipack_id, filedata)\n params = Hash.new\n params['multipack_id'] = multipack_id\n params['filedata'] = filedata\n return doCurl(\"post\",\"/multipack/logo\",params)\n end",
"def show\n @tag = Tag.find(params[:id])\n @gifs = @tag.getGifsPaginated(params);\n end",
"def vote_params\n params.require(:vote).permit(:gif_id)\n end",
"def create\n @gosok = Gosok.new(gosok_params)\n\n respond_to do |format|\n if @gosok.save\n format.html { redirect_to gosoks_url, notice: 'Gosok was successfully created.' }\n format.json { render :show, status: :created, location: @gosok }\n else\n format.html { render :new }\n format.json { render json: @gosok.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n params, setlist_songs, media = prepare_params()\n \n optimize_images(params)\n \n @gig = Gig.new(params)\n \n if @gig.save\n\n if setlist_songs.present?\n @gig.gigsets.create(setlist_songs)\n end\n\n if media.present?\n @gig.gigmedia.create(media)\n end\n \n redirect_to(@gig)\n \n else\n # This line overrides the default rendering behavior, which\n # would have been to render the \"create\" view.\n render \"new\"\n end\n\n end",
"def create\n @shot = Shot.new(shot_params)\n\n if @shot.save\n render json: @shot, status: :created, location: @shot\n else\n render json: @shot.errors, status: :unprocessable_entity\n end\n end",
"def create\n @gift = Gift.new(params[:gift])\n\n respond_to do |format|\n if @gift.save\n format.html { redirect_to @gift, notice: 'Gift was successfully created.' }\n format.json { render json: @gift, status: :created, location: @gift }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gift.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gtd = Gtd.new(params[:gtd])\n\n respond_to do |format|\n if @gtd.save\n flash[:notice] = 'Gtd was successfully created.'\n format.html { redirect_to(@gtd) }\n format.xml { render :xml => @gtd, :status => :created, :location => @gtd }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @gtd.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put_image_extract_as_gif(name, image_id, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = put_image_extract_as_gif_with_http_info(name, image_id, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = put_image_extract_as_gif_with_http_info(name, image_id, opts)\n else\n raise\n end\n return data\n end",
"def images_to_gif(directory_name, gif_name)\n puts \"converting to gif\"\n sequence = Magick::ImageList.new\n Dir.glob(\"#{directory_name}/*.jpg\").each do |image|\n sequence << Magick::Image.read(\"#{image}\").first\n# Sets the delay between images. Lower number = less delay between image change\n sequence.cur_image.delay = 10\n end\n end",
"def post_storage(request)\n # --- Check OCCI XML from POST ---\n if request.params['occixml'] == nil\n error_msg = \"OCCI XML representation of Image\" +\n \" not present in the request\"\n error = OpenNebula::Error.new(error_msg)\n return error, 400\n end\n\n # --- Create and Add the new Image ---\n occixml = request.params['occixml']\n occixml = occixml[:tempfile].read if occixml.class == Hash\n\n image = ImageOCCI.new(\n Image.build_xml,\n @client,\n occixml,\n request.params['file'])\n\n # --- Generate the template and Allocate the new Instance ---\n template = image.to_one_template\n return template, 500 if OpenNebula.is_error?(template)\n\n rc = image.allocate(template, @config[:datastore_id]||1)\n if OpenNebula.is_error?(rc)\n return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]\n end\n\n image.info\n #wait until image is ready to return\n while (image.state_str == 'LOCKED') && (image['RUNNING_VMS'] == '0') do\n sleep IMAGE_POLL_SLEEP_TIME\n image.info\n end\n\n # --- Prepare XML Response ---\n return to_occi_xml(image, :code=>201)\n end",
"def generate(gift_data, request_id, attempts = 0)\n @request = setup_request \"#{@@resource_url}/generateEGift\", request_id, true, attempts\n @request.body = gift_data\n @request\n end",
"def create\n @gpath = Gpath.new(params[:gpath])\n\n respond_to do |format|\n if @gpath.save\n format.html { redirect_to @gpath, notice: 'Gpath was successfully created.' }\n format.json { render json: @gpath, status: :created, location: @gpath }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gpath.errors, status: :unprocessable_entity }\n end\n end\n end",
"def upload\r\n \r\n end",
"def create\n @gitem = Gitem.new(params[:gitem])\n\n respond_to do |format|\n if @gitem.save\n format.html { redirect_to @gitem, notice: 'Gitem was successfully created.' }\n format.json { render json: @gitem, status: :created, location: @gitem }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gitem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def process_gpx!\n trail_gpx_processor = TrailGPXProcessor.new(@trail)\n trail_gpx_processor.process_route!(TrailsController::GPX, upload_gpx)\n end",
"def to_gif(*a)\n to_blob('gif', *a)\n end",
"def create\n @grm_pic = GrmPic.new(params[:grm_pic])\n\n respond_to do |format|\n if @grm_pic.save\n format.html { redirect_to @grm_pic, notice: 'Your picture has been successfully saved.' }\n format.json { render json: @grm_pic, status: :created, location: @grm_pic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @grm_pic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def video_convert_to_gif_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VideoApi.video_convert_to_gif ...'\n end\n # resource path\n local_var_path = '/video/convert/to/gif'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'maxWidth'] = opts[:'max_width'] if !opts[:'max_width'].nil?\n header_params[:'maxHeight'] = opts[:'max_height'] if !opts[:'max_height'].nil?\n header_params[:'preserveAspectRatio'] = opts[:'preserve_aspect_ratio'] if !opts[:'preserve_aspect_ratio'].nil?\n header_params[:'frameRate'] = opts[:'frame_rate'] if !opts[:'frame_rate'].nil?\n header_params[:'startTime'] = opts[:'start_time'] if !opts[:'start_time'].nil?\n header_params[:'timeSpan'] = opts[:'time_span'] if !opts[:'time_span'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VideoApi#video_convert_to_gif\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create_fax_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end",
"def create_image_frame(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end",
"def postFlatpackLogo( flatpack_id, filedata)\n params = Hash.new\n params['flatpack_id'] = flatpack_id\n params['filedata'] = filedata\n return doCurl(\"post\",\"/flatpack/logo\",params)\n end"
] |
[
"0.6623407",
"0.64636165",
"0.6253868",
"0.62518555",
"0.6072979",
"0.6064172",
"0.59968555",
"0.5976434",
"0.59526384",
"0.5950958",
"0.5943235",
"0.5844419",
"0.5771671",
"0.5771671",
"0.5771671",
"0.5771671",
"0.5771671",
"0.5767186",
"0.5713671",
"0.56062675",
"0.55512667",
"0.54384947",
"0.5406591",
"0.5393907",
"0.53496575",
"0.5346613",
"0.5314257",
"0.5314257",
"0.53044903",
"0.5290126",
"0.5284735",
"0.5277528",
"0.5267309",
"0.52358955",
"0.52207375",
"0.5202709",
"0.5193056",
"0.5180939",
"0.51742774",
"0.5168247",
"0.5159736",
"0.51576436",
"0.5136108",
"0.51087713",
"0.51009434",
"0.5097808",
"0.50942624",
"0.5094144",
"0.50918144",
"0.5090859",
"0.5066963",
"0.50575036",
"0.50483996",
"0.50483996",
"0.5043981",
"0.50406516",
"0.5028976",
"0.5011023",
"0.5002022",
"0.49990708",
"0.4985624",
"0.49836972",
"0.49756867",
"0.49449587",
"0.49201047",
"0.49123663",
"0.48707786",
"0.4862683",
"0.48568985",
"0.48563328",
"0.4855864",
"0.48507723",
"0.48490608",
"0.48452643",
"0.48405468",
"0.4838516",
"0.48363546",
"0.48320097",
"0.48309425",
"0.4802003",
"0.47927994",
"0.479066",
"0.4768926",
"0.47669062",
"0.47654533",
"0.4764849",
"0.4762149",
"0.47579384",
"0.47520274",
"0.47462887",
"0.4743563",
"0.47354335",
"0.47351488",
"0.47306556",
"0.472499",
"0.47229314",
"0.47194222",
"0.47159427",
"0.47019434",
"0.47008193"
] |
0.510715
|
44
|
PUT /gifts/1 PUT /gifts/1.xml
|
def update
@gift = Gift.find(params[:id])
respond_to do |format|
if @gift.update_attributes(params[:gift])
flash[:notice] = 'Gift was successfully updated.'
format.html { redirect_to(@gift) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @gift.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @indexed_gif = IndexedGif.find(params[:id])\n\n respond_to do |format|\n if @indexed_gif.update_attributes(params[:indexed_gif])\n format.html { redirect_to @indexed_gif, notice: 'Indexed gif was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @indexed_gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :index, @user, :message => 'Not authorized as an administrator.'\n respond_to do |format|\n if @gif.update(gif_params)\n format.html { redirect_to @gif, notice: 'Gif was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def modify_gif(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def set_gif\n @gif = Gif.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @gif.update(gif_params)\n format.html do\n if params[:commit].include? \"More\"\n redirect_to edit_gif_path(Gif.untagged.first), notice: 'Gif was successfully updated.'\n else\n redirect_to @gif, notice: 'Gif was successfully updated.'\n end\n end\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cat_gif.update(cat_gif_params)\n format.html { redirect_to @cat_gif, notice: 'Cat gif was successfully updated.' }\n format.json { render :show, status: :ok, location: @cat_gif }\n else\n format.html { render :edit }\n format.json { render json: @cat_gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_modified_gif(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end",
"def put(path = '/files/', params = {})\n request :put, path, params\n end",
"def create\n @gif = Gif.new(gif_params)\n @gif.avatar_remote_url(@gif.url)\n @gif.approved = false\n @gif.deleted = false\n @gif.upvotes = 0\n @gif.downvotes = 0\n @gif.ratio = 0\n @gif.views = 0\n\n respond_to do |format|\n if @gif.save\n format.html { redirect_to @gif, notice: 'Gif was successfully created.' }\n format.json { render action: 'show', status: :created, location: @gif }\n else\n format.html { render action: 'new' }\n format.json { render json: @gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @gig = Gig.find(params[:id])\n\n respond_to do |format|\n if @gig.update_attributes(params[:gig])\n flash[:notice] = 'Gig was successfully updated.'\n format.html { redirect_to(@gig) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @gig.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update_gif\r\n @gif_handle.update(bitmap)\r\n end",
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def put(path, options={})\n request :put, path, options\n end",
"def create\n @indexed_gif = IndexedGif.new(params[:indexed_gif])\n\n respond_to do |format|\n if @indexed_gif.save\n format.html { redirect_to @indexed_gif, notice: 'Indexed gif was successfully created.' }\n format.json { render json: @indexed_gif, status: :created, location: @indexed_gif }\n else\n format.html { render action: \"new\" }\n format.json { render json: @indexed_gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @gig = Gig.find(params[:id])\n\n respond_to do |format|\n if update_gig(@gig)\n format.html { redirect_to @gig, notice: 'Gig was successfully updated.' }\n format.json { render json: @gig, status: :ok, location: @gig }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gig.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(*args)\n request :put, *args\n end",
"def set_gif_link\n @gif_link = GifLink.find(params[:id])\n end",
"def update\n @shot = Shot.find(params[:id])\n @shot.update_attributes(shot_params)\n respond_with @shot\n end",
"def modify_gif_and_upload_to_storage\n puts('Update parameters of a GIF image and upload to cloud storage')\n\n upload_sample_image_to_cloud\n\n background_color_index = 5\n color_resolution = 4\n has_trailer = true\n interlaced = false\n is_palette_sorted = true\n pixel_aspect_ratio = 4\n from_scratch = nil\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ModifyGifRequest.new(\n get_sample_image_file_name, background_color_index, color_resolution, has_trailer, interlaced,\n is_palette_sorted, pixel_aspect_ratio, from_scratch, folder, storage)\n\n puts(\"Call ModifyGif with params: background color index: #{background_color_index}, color resolution: \" +\n \"#{color_resolution}, has trailer: #{has_trailer}, interlaced: #{interlaced}}, is palette sorted: \" +\n \"#{is_palette_sorted}, pixel aspect ratio: #{pixel_aspect_ratio}\")\n\n updated_image = @imaging_api.modify_gif(request)\n upload_image_to_cloud(get_modified_sample_image_file_name, updated_image)\n puts\n end",
"def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend",
"def update\n @shot = Shot.find(params[:id])\n\n respond_to do |format|\n if @shot.update_attributes(params[:shot])\n format.html { redirect_to(@shot, :notice => 'Shot was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @shot.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end",
"def update(options: {}, **data)\n\n refresh_with(parse(client.put(\"/tags/#{gid}\", body: data, options: options)).first)\n end",
"def gif_params\n params.require(:gif).permit(:id, :url, :preview, :src, :title, :collection_id)\n end",
"def gif_params\n params.require(:gif).permit(:name)\n end",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}/volumes\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.request_uri)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n\n end",
"def put(path, options={}, format=format)\n request(:put, path, options, format)\n end",
"def put(path, data=nil)\n request(:put, path, data)\n end",
"def gif_params\n params.require(:gif).permit( :url, :user_id, :file)\n end",
"def put(path, options={})\n send_request 'put', path, options\n end",
"def update\n @shot = Shot.find(params[:id])\n\n if @shot.update(shot_params)\n head :no_content\n else\n render json: @shot.errors, status: :unprocessable_entity\n end\n end",
"def edit_gist(id, files={}, options={:public => true})\n options.merge!(files)\n patch \"/gists/#{id}\", :body => options\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def destroy\n @indexed_gif = IndexedGif.find(params[:id])\n @indexed_gif.destroy\n\n respond_to do |format|\n format.html { redirect_to indexed_gifs_url }\n format.json { head :no_content }\n end\n end",
"def put(path, opts = {})\n request(:put, path, opts).body\n end",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def update\n @task_tag.assign_attributes(task_tag_params)\n attach_file(:icon)\n respond_to do |format|\n if @task_tag.save\n format.html { redirect_to @task_tag, notice: 'Task tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @task_tag }\n else\n format.html { render :edit }\n format.json { render json: @task_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_put(path, data = {})\n api_request(:put, path, :data => data)\n end",
"def update\n @tagg = Tagg.find(params[:id])\n\n respond_to do |format|\n if @tagg.update_attributes(params[:tagg])\n format.html { redirect_to @tagg, notice: 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tagg.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @gif.destroy\n respond_to do |format|\n format.html { redirect_to gifs_url }\n format.json { head :no_content }\n end\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put_storage(request, params)\n xmldoc = XMLElement.build_xml(request.body, 'STORAGE')\n image_info = XMLElement.new(xmldoc) if xmldoc != nil\n\n image = ImageOCCI.new(\n Image.build_xml(params[:id]),\n @client)\n\n rc = nil\n if image_info['PERSISTENT'] && image_info['PUBLIC']\n error_msg = \"It is not allowed more than one change per request\"\n return OpenNebula::Error.new(error_msg), 400\n elsif image_info['PERSISTENT'] == 'YES'\n rc = image.persistent\n elsif image_info['PERSISTENT'] == 'NO'\n rc = image.nonpersistent\n elsif image_info['PUBLIC'] == 'YES'\n rc = image.publish\n elsif image_info['PUBLIC'] == 'NO'\n rc = image.unpublish\n end\n\n if OpenNebula.is_error?(rc)\n return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]\n end\n\n # --- Prepare XML Response ---\n image.info\n return to_occi_xml(image, :code=>202)\n end",
"def put(*args)\n request(:put, *args)\n end",
"def update\n @song = Song.find(params[:id])\n\n params[:song].each do |tag, value|\n if TagInfo::USEFULL_TAGS.include?(tag)#tag on file is a useful tag\n @song[tag] = value #update the useful tag in DB\n end\n end\n respond_to do |format|\n begin\n Song.transaction do #update both file and DB or neither\n @song.update_tags_on_file(params[:song])\n @song.save!\n end\n format.html { redirect_to @song, notice: 'Song was successfully updated.' }\n format.json { head :ok }\n rescue Exception=>e\n format.html { render action: \"edit\" }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @indexed_gif = IndexedGif.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indexed_gif }\n end\n end",
"def update\n @gift = Gift.find(params[:id])\n\n respond_to do |format|\n if @gift.update_attributes(params[:gift])\n format.html { redirect_to @gift, notice: 'Gift was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gift.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @gig_request = GigRequest.find(params[:id])\n\n respond_to do |format|\n if @gig_request.update_attributes(params[:gig_request])\n format.html { redirect_to @gig_request, notice: 'Gig request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gig_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end",
"def update\n respond_to do |format|\n if @gig.update(gig_params)\n format.html { redirect_to @gig, notice: \"Gig was successfully updated.\" }\n format.json { render :show, status: :ok, location: @gig }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @gig.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.path)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n end",
"def gif_params\n params.require(:gif).permit(:caption, :upvotes, :downvotes, :views, :ratio, :avatar, :url, :tag_list)\n end",
"def create\n @gif = Gif.new(gif_params)\n @gif.user = current_user\n\n respond_to do |format|\n if @gif.save\n format.html { redirect_to @gif, notice: 'Gif was successfully created.' }\n format.json { render action: 'show', status: :created, location: @gif }\n else\n format.html { render action: 'new' }\n format.json { render json: @gif.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @gift.update(gift_params)\n if params[:gift][:img] !=nil\n @gift.update(:img => params[:gift][:img].read) # <= バイナリをセット\n @gift.update(:img_content_type => params[:gift][:img].content_type) # <= ファイルタイプをセット\n else\n # @gift.update(:img => Gift.find(1).img) # <= バイナリをセット\n # @gift.update(:img_content_type => Gift.find(1).img_content_type) # <= ファイルタイプをセット\n end\n format.html { redirect_to @gift, notice: 'Gift was successfully updated.' }\n format.json { render :show, status: :ok, location: @gift }\n else\n format.html { render :edit }\n format.json { render json: @gift.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def test_putpoi_update_valid\n nd = create(:node)\n cs_id = nd.changeset.id\n user = nd.changeset.user\n amf_content \"putpoi\", \"/1\", [\"#{user.email}:test\", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, nd.visible]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 5, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal nd.id, result[2]\n assert_equal nd.id, result[3]\n assert_equal nd.version + 1, result[4]\n\n # Now try to update again, with a different lat/lon, using the updated version number\n lat = nd.lat + 0.1\n lon = nd.lon - 0.1\n amf_content \"putpoi\", \"/2\", [\"#{user.email}:test\", cs_id, nd.version + 1, nd.id, lon, lat, nd.tags, nd.visible]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/2\")\n\n assert_equal 5, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal nd.id, result[2]\n assert_equal nd.id, result[3]\n assert_equal nd.version + 2, result[4]\n end",
"def update\n @gist = Gist.find(params[:id])\n\n respond_to do |format|\n if @gist.update_attributes(params[:gist])\n format.html { redirect_to @gist, notice: 'Gist was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def gif_params\n params.require(:gif).permit(:url, :tag_list)\n end",
"def put(path, data={})\n request(:put, path, data)\n end",
"def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end",
"def orchio_put(jdoc)\n response = client.send_request :put, inst_args(json: jdoc)\n if cache.enabled?\n simple_cache.save(\n Document.new(\n response.body.to_hash,\n Metadata.new(\n :collection => ocollection,\n :key => @id,\n :ref => response.header.etag\n )))\n end\n set_ref_value response\n orchio_status response, 201\n end",
"def set_cat_gif\n @cat_gif = CatGif.find(params[:id])\n end",
"def put url, object = nil\n request url, HTTP::Put, object\n end",
"def perform_put(path, options = {})\n perform_request(:put, path, options)\n end",
"def update\n @inventario = Inventario.find(params[:id])\n @foto = @inventario.foto\n \n @service = InventarioService.new(@inventario, @foto)\n respond_to do |format|\n\n if @inventario.update_attributes(params[:inventario],params[:foto_file])\n format.html { redirect_to(@inventario, :notice => 'Inventario was successfully updated.') }\n format.xml { head :ok }\n else\n\t @foto = @service.foto\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @inventario.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end",
"def update\n respond_to do |format|\n if @g_file.update(g_file_params)\n format.html { redirect_to @g_file, notice: 'G file was successfully updated.' }\n format.json { render :show, status: :ok, location: @g_file }\n else\n format.html { render :edit }\n format.json { render json: @g_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_put(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end",
"def update\n @ginasio = Ginasio.find(params[:id])\n\n respond_to do |format|\n if @ginasio.update_attributes(params[:ginasio])\n format.html { redirect_to @ginasio, :flash => { :success => 'Dados do ginasio alterados com successo!' } }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @ginasio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def repost_pixi\n listing = Listing.new(get_attr(true))\n listing = add_photos false, listing\n listing.generate_token\n listing.status, listing.repost_flg = 'active', true\n listing.set_end_date\n listing.save!\n end",
"def put(path, doc = nil, options = {})\n execute('PUT', path, options, doc)\n end",
"def put_request(path, params={}, options={})\n request(:put, path, params, options)\n end",
"def update_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end",
"def put(path, **args); end",
"def update\n @shot = Shot.find(params[:id])\n\n respond_to do |format|\n if @shot.update_attributes(params[:shot])\n format.html { redirect_to @shot, notice: 'Shot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, params)\n request(:put, path, params)\n end",
"def update\n respond_to do |format|\n if @gist.update(gist_params)\n format.html { redirect_to @gist, notice: 'Gist was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @gist.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.65804076",
"0.62795484",
"0.61840004",
"0.60494983",
"0.60494983",
"0.60494983",
"0.60494983",
"0.60494983",
"0.6016912",
"0.5980135",
"0.5884269",
"0.57653874",
"0.57609326",
"0.5712998",
"0.5695316",
"0.55285156",
"0.55110425",
"0.5485869",
"0.5466479",
"0.5464026",
"0.5441035",
"0.5399468",
"0.53983206",
"0.53886783",
"0.53878057",
"0.53787756",
"0.53757846",
"0.53737795",
"0.53696537",
"0.5358689",
"0.5353965",
"0.5353133",
"0.5350537",
"0.5343301",
"0.5343301",
"0.53296363",
"0.53295404",
"0.5321184",
"0.53177714",
"0.53116626",
"0.52909225",
"0.52865005",
"0.52835786",
"0.5279869",
"0.5279869",
"0.5279869",
"0.5277462",
"0.5274473",
"0.5271839",
"0.5271839",
"0.52595854",
"0.52462184",
"0.52363855",
"0.52267283",
"0.5224422",
"0.5224422",
"0.5224422",
"0.5224422",
"0.5224422",
"0.5224422",
"0.5224422",
"0.5224422",
"0.52022564",
"0.520167",
"0.5198561",
"0.5196515",
"0.51930016",
"0.51909876",
"0.51878023",
"0.51878023",
"0.51800424",
"0.5169489",
"0.5168245",
"0.5167107",
"0.516444",
"0.5163076",
"0.5162895",
"0.5162431",
"0.51558673",
"0.5155706",
"0.51493883",
"0.514715",
"0.51468176",
"0.5146154",
"0.5137746",
"0.51376194",
"0.5135808",
"0.5133278",
"0.51121926",
"0.51087254",
"0.51083374",
"0.5090379",
"0.5086213",
"0.5080722",
"0.5076392",
"0.5075514",
"0.5071304",
"0.50630623",
"0.50601375",
"0.50577885"
] |
0.5362907
|
29
|
DELETE /gifts/1 DELETE /gifts/1.xml
|
def destroy
@gift = Gift.find(params[:id])
@gift.destroy
respond_to do |format|
format.html { redirect_to(:action => :index) }
format.xml { head :ok }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @indexed_gif = IndexedGif.find(params[:id])\n @indexed_gif.destroy\n\n respond_to do |format|\n format.html { redirect_to indexed_gifs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gif.destroy\n respond_to do |format|\n format.html { redirect_to gifs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gig = Gig.find(params[:id])\n @gig.destroy\n\n respond_to do |format|\n format.html { redirect_to(gigs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @cat_gif.destroy\n respond_to do |format|\n format.html { redirect_to cat_gifs_url, notice: 'Cat gif was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gif.destroy\n respond_to do |format|\n format.html { redirect_to gifs_url, notice: 'Gif was successfully destroyed.' }\n format.js {}\n end\n end",
"def destroy\n @img = Img.find(params[:id])\n @img.destroy\n\n respond_to do |format|\n format.html { redirect_to(imgs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @image_path = ImagePath.find(params[:id])\n @image_path.destroy\n\n respond_to do |format|\n format.html { redirect_to(image_paths_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n authorize! :index, @user, :message => 'Not authorized as an administrator.'\n #ToDo This (v) should use destroy but the the life of me I cannot understand why it doesn't work with rolify\n @gif.delete\n respond_to do |format|\n format.html { redirect_to gifs_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @g_file.destroy\n respond_to do |format|\n format.html { redirect_to g_files_url, notice: 'G file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gpath = Gpath.find(params[:id])\n @gpath.destroy\n\n respond_to do |format|\n format.html { redirect_to gpaths_url }\n format.json { head :no_content }\n end\n end",
"def delete()\n\n client.delete(\"/tags/#{gid}\") && true\n end",
"def destroy\n @jpeg_folder = JpegFolder.find(params[:id])\n @jpeg_folder.destroy\n\n respond_to do |format|\n format.html { redirect_to(jpeg_folders_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n ImagesIndex.delete params[:id]\n respond_to do |format|\n format.html { redirect_to(\"/images_indices\") }\n format.xml { head :ok }\n end\n end",
"def delete(filename); end",
"def destroy\n @pig = Pig.find(params[:id])\n @pig.destroy\n\n respond_to do |format|\n format.html { redirect_to(pigs_url) }\n format.xml { head :ok }\n end\n end",
"def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end",
"def destroy\n @rig = Rig.find(params[:id])\n @rig.destroy\n\n respond_to do |format|\n format.html { redirect_to(rigs_url) }\n format.xml { head :ok }\n end\n end",
"def delete(id)\n request = Net::HTTP::Delete.new(\"#{@url}/#{id}.xml\")\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def destroy\n @svg_file = Cmtool::SvgFile.find(params[:id])\n @svg_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(cmtool.svg_files_url, notice: I18n.t('cmtool.action.destroy.successful', model: Cmtool::SvgFile.model_name.human)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @img_info = ImgInfo.find(params[:id])\n @img_info.destroy\n\n respond_to do |format|\n format.html { redirect_to(img_infos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @gig = Gig.find(params[:id])\n @gig.destroy\n\n respond_to do |format|\n format.html { redirect_to gigs_url }\n format.json { render json: nil, status: :ok }\n end\n end",
"def delete(session, id)\n write_task('rvpe.image.delete', session) do\n err_msg = \"You don't have permission to delete the image.\"\n sanity_check(session, id, err_msg) do\n call_one_xmlrpc('one.image.delete', session, id)\n end\n end\n end",
"def destroy\n @gig_request = GigRequest.find(params[:id])\n @gig_request.destroy\n\n respond_to do |format|\n format.html { redirect_to gig_requests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gift = Gift.find(params[:id])\n @gift.destroy\n\n respond_to do |format|\n format.html { redirect_to(gifts_url) }\n end\n end",
"def destroy\n @path = Path.find(params[:id])\n @path.destroy\n\n respond_to do |format|\n format.html { redirect_to(layer_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @shot = Shot.find(params[:id])\n @shot.destroy\n\n respond_to do |format|\n format.html { redirect_to(shots_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bdig = Bdig.find(params[:id])\n @bdig.destroy\n\n respond_to do |format|\n format.html { redirect_to(bdigs_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n delete_from_server single_url\n end",
"def destroy\n @gallery_item = GalleryItem.find(params[:id])\n @gallery_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(gallery_items_url) }\n format.xml { head :ok }\n end\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def delete(container_name, file_name)\n validate_path_elements(container_name, file_name)\n\n client.request(\n method: :delete,\n path: \"#{container_name}/#{file_name}\",\n expected: 204\n )\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n Rails.logger.debug {\"destroying gridfs file #{@id}\"}\n if persisted?\n Photo.mongo_client.database.fs.find(:_id=>BSON::ObjectId.from_string(@id)).delete_one\n end\n end",
"def destroy\n @gifday.destroy\n respond_to do |format|\n format.html { redirect_to gifdays_url, notice: 'Gifday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @genbank_file.destroy\n\n respond_to do |format|\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @gadget_file.destroy\n respond_to do |format|\n format.html { redirect_to gadget_files_url, notice: 'Gadget file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete!\n Recliner.delete(uri)\n end",
"def destroy\n @gtd = Gtd.find(params[:id])\n @gtd.destroy\n\n respond_to do |format|\n format.html { redirect_to(gtds_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @im = Im.find(params[:id])\n @im.destroy\n\n respond_to do |format|\n format.html { redirect_to(ims_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @nif = Nif.find(params[:id])\n @nif.destroy\n\n respond_to do |format|\n format.html { redirect_to(nifs_url) }\n format.xml { head :ok }\n end\n end",
"def delete_image(id)\n uri = URI.parse(\"http://\" + @location.host + \":\" + @location.port.to_s + \"/v2/images/\" + id)\n return delete_request(uri, @token)\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def delete(path = '/files/', params = {})\n request :delete, path, params\n end",
"def destroy\n @client = Client.find(params[:id])\n Client.transaction do\n FileUtils.rm Dir[\"#{Rails.root}/public/files/logo_files/\"+@client.logo.to_s]\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully deleted.' }\n format.json { head :no_content }\n end\n end\n end",
"def deletef\n url = prefix + \"deletef\" + id_param\n return response(url)\n end",
"def destroy\n @pic.destroy\n\n notifications = Notification.find(:all, :conditions => ['notification_type = ? and object_id = ?', \"comment\", @pic.id])\n notifications.each do |n|\n n.destroy\n end\n respond_to do |format|\n format.html { redirect_to(root_url) }\n format.xml { head :ok }\n end\n end",
"def delete_storage(request, params)\n # --- Get the Image ---\n image = ImageOCCI.new(\n Image.build_xml(params[:id]),\n @client)\n\n # --- Delete the Image ---\n rc = image.delete\n if OpenNebula.is_error?(rc)\n return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]\n end\n\n return \"\", 204\n end",
"def delete(path)\n request(:delete, path)\n end",
"def destroy\n @galerie = Galerie.find(params[:id])\n @galerie.destroy\n\n respond_to do |format|\n format.html { redirect_to(galeries_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @gallery_image = GalleryImage.find(params[:id])\n @gallery_image.destroy\n\n respond_to do |format|\n format.html { redirect_to(home_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @nspirefile = Nspirefile.find(params[:id])\n @nspirefile.destroy\n\n respond_to do |format|\n format.html { redirect_to(nspirefiles_url) }\n format.xml { head :ok }\n end\n end",
"def deleteEntityImage( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/image\",params)\n end",
"def destroy\n @gallion = Gallion.find(params[:id])\n @gallion.destroy\n\n respond_to do |format|\n format.html { redirect_to(gallions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @gallery_asset = GalleryAsset.find(params[:id])\n @gallery_asset.destroy\n\n respond_to do |format|\n format.html { redirect_to(gallery_assets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pdig = Pdig.find(params[:id])\n @pdig.destroy\n\n respond_to do |format|\n format.html { redirect_to(pdigs_url) }\n format.xml { head :ok }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n @image_set = ImageSet.find(params[:id])\n @image_set.destroy\n\n respond_to do |format|\n format.html { redirect_to(image_sets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @gallery = Gallery.find(params[:id])\n @gallery.destroy\n\n respond_to do |format|\n format.html { redirect_to(galleries_url) }\n format.xml { head :ok }\n end\n end",
"def delete(command)\n pp @client.files.delete(clean_up(command[1]))\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def delete(*uris); end",
"def destroy\n @ganho = Ganho.find(params[:id])\n @ganho.destroy\n\n respond_to do |format|\n format.html { redirect_to(ganhos_url) }\n format.xml { head :ok }\n end\n end",
"def rm path\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @song = Song.find(params[:id])\n #@song.remove_file_path!\n @song.destroy\n\n respond_to do |format|\n format.html { redirect_to songs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @gallery = Gallery.find(params[:id])\n @gallery.destroy\n\n respond_to do |format|\n format.html { redirect_to(galleries_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @gallery = Gallery.find(params[:id])\n @gallery.destroy\n\n respond_to do |format|\n format.html { redirect_to(galleries_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @gallery = Gallery.find(params[:id])\n @gallery.destroy\n\n respond_to do |format|\n format.html { redirect_to(galleries_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(badges_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n\n client.delete(\"/stories/#{gid}\") && true\n end",
"def delete\n model.delete_attachment(@path)\n end",
"def destroy\n @gallery = Gallery.find(params[:id])\n @gallery.destroy\n\n respond_to do |format|\n format.html { redirect_to( new_gallery_path ) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tagg = Tagg.find(params[:id])\n @tagg.destroy\n\n respond_to do |format|\n format.html { redirect_to taggs_url }\n format.json { head :no_content }\n end\n end",
"def delete_file(path)\n \n puts \"Sending path via MCollective Files client\"\n @mc.delete(:path => path)\n printrpcstats\n \n end",
"def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end",
"def destroy\n @action_graphic = ActionGraphic.find(params[:id])\n @action_graphic.destroy\n\n respond_to do |format|\n format.html { redirect_to(action_graphics_url) }\n format.xml { head :ok }\n end\n end",
"def file_delete(path)\n params = {\n \"root\" => @root,\n \"path\" => format_path(path, false),\n }\n response = @session.do_post build_url(\"/fileops/delete\", params)\n parse_response(response)\n end",
"def destroy\n @gasto = Gasto.find(params[:id])\n @gasto.destroy\n\n respond_to do |format|\n format.html { redirect_to gastos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n conn.delete(escaped_path)\n true\n rescue StandardError => e\n puts \"carrierwave-upyun delete failed: #{e.inspect}\"\n nil\n end",
"def destroy\n @upload = Upload.find(params[:id])\n @upload.destroy\n\n respond_to do |format|\n format.html { redirect_to(uploads_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @upload = Upload.find(params[:id])\n @upload.destroy\n\n respond_to do |format|\n format.html { redirect_to(uploads_url) }\n format.xml { head :ok }\n end\n end",
"def deleteEntityLogo( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/logo\",params)\n end",
"def destroy\n @file_upload = FileUpload.find(params[:id])\n @file_upload.destroy\n\n respond_to do |format|\n format.html { redirect_to(file_uploads_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(organization_segment_badges_url) }\n format.xml { head :ok }\n end\n end",
"def delete_file(filename,repo)\n curl_delete(\"#{self.host}/api2/repos/#{repo}/file/?p=#{filename}\").body_str\n end",
"def delete_tag tag\n delete \"tag/#{tag}\"\n end",
"def destroy\n @groupe_aile.destroy\n respond_to do |format|\n format.html { redirect_to groupe_ailes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @graphic = Graphic.find(params[:id])\n @graphic.destroy\n\n respond_to do |format|\n format.html { redirect_to(graphics_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @gene_ontology = GeneOntology.find(params[:id])\n @gene_ontology.destroy\n\n respond_to do |format|\n format.html { redirect_to(gene_ontologies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n\n respond_to do |format|\n format.html { redirect_to(images_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n\n respond_to do |format|\n format.html { redirect_to(images_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n\n respond_to do |format|\n format.html { redirect_to(images_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def destroy\n @grm_pic = GrmPic.find(params[:id])\n @grm_pic.destroy\n\n respond_to do |format|\n format.html { redirect_to grm_pics_url }\n format.json { head :no_content }\n end\n end",
"def delete\n \n end",
"def delete_gist(id)\n boolean_request :delete, \"/gists/#{id}\"\n end",
"def destroy\n @upload_picture = UploadPicture.find(params[:id])\n @upload_picture.destroy\n\n respond_to do |format|\n format.html { redirect_to(upload_pictures_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end"
] |
[
"0.6930396",
"0.68820477",
"0.656696",
"0.65352404",
"0.6352554",
"0.6331118",
"0.6320864",
"0.62355936",
"0.62319374",
"0.61706966",
"0.6152128",
"0.6144117",
"0.6138728",
"0.61348796",
"0.6134773",
"0.60982907",
"0.6088722",
"0.60817313",
"0.6077572",
"0.60680246",
"0.6058727",
"0.6056786",
"0.6044494",
"0.6041707",
"0.60404867",
"0.6034573",
"0.6034391",
"0.6026101",
"0.60183495",
"0.6016826",
"0.60099494",
"0.6006113",
"0.6004478",
"0.6000035",
"0.59994113",
"0.5988492",
"0.5984423",
"0.5981773",
"0.59730685",
"0.5968019",
"0.5966519",
"0.59649795",
"0.5954013",
"0.5953214",
"0.5950658",
"0.59481585",
"0.59474486",
"0.59460515",
"0.59394073",
"0.59338164",
"0.59329057",
"0.5931401",
"0.59284925",
"0.59247434",
"0.59138477",
"0.59138304",
"0.5907483",
"0.5904701",
"0.59028894",
"0.5897415",
"0.5889241",
"0.58867115",
"0.588665",
"0.5878168",
"0.587525",
"0.58725727",
"0.5869415",
"0.5868906",
"0.5868906",
"0.5868906",
"0.5866898",
"0.58640325",
"0.5852859",
"0.58476293",
"0.5847318",
"0.58449286",
"0.58419704",
"0.5841672",
"0.5838162",
"0.5833385",
"0.58287364",
"0.58283985",
"0.58283985",
"0.5820656",
"0.58200216",
"0.58188593",
"0.58158416",
"0.58150554",
"0.5814",
"0.58125776",
"0.58089703",
"0.5808762",
"0.5808762",
"0.5808762",
"0.5806506",
"0.58001524",
"0.5797007",
"0.579693",
"0.5796612",
"0.5795361"
] |
0.5990248
|
35
|
Public: Adds a Line and returns it. Also sets the parent on the line and for simplicity adds the current_line number. Returns the line that was added.
|
def add_line(line)
@lines << line
line
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add(context, line)\n\t\t\t@lines << @line.new(context, line)\n\t\tend",
"def add_line\n @layout.add_widget(HLine.new)\n end",
"def add_line(line)\n\t\t@lines << line\n\tend",
"def append_line(line)\n @lines.push(line)\n @current = false\n @current_pos = 0\n end",
"def line(&block)\n attributes[:lines] << Line.build(&block)\n end",
"def append_new_line(new_line)\n # Append 'line' into position 'line_number'\n puts ' append_new_line ...' if $verbose > 1\n @lines << new_line\n @line_count += 1\n end",
"def line\n @line ||= Line.get(@attrs['Line'])\n end",
"def line\n @line ||= Line.get(@attrs['LineCode'])\n end",
"def new_line\n @source_lines << []\n end",
"def add_line(line)\n @entries << line\n end",
"def add_line_item(args=nil)\n line_item = Wheretocard::LineItem.new(args)\n line_items << line_item\n return line_item\n end",
"def add_line(line)\n @tip.string_content += line.slice(@offset, line.length) + '\\n'\n end",
"def from_line\n position.new_line\n end",
"def append_line(line)\n @entries.last.line << line\n end",
"def insert_line\n down\n\n @lines = lines.insert_line(Vedeu::Editor::Line.new, y)\n\n bol\n\n refresh\n end",
"def push(line)\n line_number = @lines.any? ? @lines.last.lineno + 1 : 1\n @lines.push(LOC.new(line, line_number))\n end",
"def addline(line, order)\n\t\t#steps.create(installation_id: self, line_id: line.id, order: order)\n\t\tactive_steps.create(line_id: line.id, order: order)\n\tend",
"def line(node = @current_node)\n\t\treturn is_valid(node) ? node.line : nil\n\tend",
"def push(line, line_num=nil)\n line_num = @lines.last.last + 1 unless line_num\n @lines.push([line.chomp, line_num])\n line\n end",
"def line_to(x, y)\n update_bounds_rect(@x, @y, x, y)\n @x, @y = x, y\n @gui.line_to(x, y)\n self\n end",
"def add_line(line)\n unless @parsing\n if line =~ /^(---|\\+\\+\\+) (.*)$/\n self.file_name = $2\n elsif line =~ /^@@ (\\+|\\-)(\\d+)(,\\d+)? (\\+|\\-)(\\d+)(,\\d+)? @@/\n @line_num_l = $2.to_i\n @line_num_r = $5.to_i\n @parsing = true\n end\n else\n if %r{^[^\\+\\-\\s@\\\\]}.match?(line)\n @parsing = false\n return false\n elsif line =~ /^@@ (\\+|\\-)(\\d+)(,\\d+)? (\\+|\\-)(\\d+)(,\\d+)? @@/\n @line_num_l = $2.to_i\n @line_num_r = $5.to_i\n else\n parse_line(line, @type)\n end\n end\n return true\n end",
"def to_previous_line\n @history.save_line(line || \"\")\n\n if @history.to_previous_line and line = @history.current_line\n replace_line line\n end\n end",
"def to_next_line\n @history.save_line(line || \"\")\n\n if @history.to_next_line and line = @history.current_line\n replace_line line\n end\n end",
"def add_line(line)\n @text_lines << line.upcase_trim\n end",
"def line_id\n @line_number - 1\n end",
"def line\n\t\t\t@line.set(buffer.line.start, buffer.line.end)\n\t\tend",
"def add_parsed_line (parsed_line)\n value_hash = parsed_line[:line_definition].convert_captured_values(parsed_line[:captures], self)\n value_hash[:line_type] = parsed_line[:line_definition].name\n value_hash[:lineno] = parsed_line[:lineno]\n add_line_hash(value_hash)\n end",
"def dup_adding_state(line)\n self.class.new(queue, codec, path).add_state(line)\n end",
"def add(*args)\n clear_line\n super(*args)\n end",
"def add_line_item(line_item)\n raise(TypeError) unless line_item.is_a?(LineItem)\n @line_items << line_item if line_item.validate\n end",
"def add_line(line_index, str, align = 0, outlinesize = Text::Util::DEFAULT_OUTLINE_SIZE, type: Text, color: nil, dx: 0)\n sprite_stack.add_line(line_index, str, align, outlinesize, type: type, color: color, dx: dx)\n end",
"def <<(line)\n line.blank? ? (@lines << line) : (self[line.key] = line) ; self\n end",
"def current_line\n @lines[@current_index]\n end",
"def add(product, qty)\n l = LineItem.new\n l.set_from_product(product, qty)\n @lines << l\n end",
"def current_line\n load_rest_of_line\n backup.current_line\n end",
"def add_line(s=nil)\n @string << \"\\n#{@@indenation * @indentation_level}#{s}\"\n end",
"def _IndentedLine\n\n _save = self.pos\n while true # sequence\n _tmp = apply(:_Indent)\n unless _tmp\n self.pos = _save\n break\n end\n _tmp = apply(:_Line)\n unless _tmp\n self.pos = _save\n end\n break\n end # end sequence\n\n set_failed_rule :_IndentedLine unless _tmp\n return _tmp\n end",
"def draw_line; draw_horizontal_line(@draw_y + (line_height / 2) - 1, 2); end",
"def <<(line)\n @extra << line\n end",
"def set_line\n @line = Line.find(params[:id])\n end",
"def set_line\n @line = Line.find(params[:id])\n end",
"def set_line\n @line = Line.find(params[:id])\n end",
"def add_or_create_line_item(item_id)\n if line_item = self.line_items.find_by(item_id: item_id)\n line_item.increment\n line_item\n else\n LineItem.new(cart_id: self.id, item_id: item_id)\n end\n end",
"def below!(addend)\n theBelow = TextRect.new(addend)\n @theLines.concat(theBelow.lines)\n return self\n end",
"def create\n parent_line_item = get_parent_line_item\n if parent_line_item\n @line_item = parent_line_item.dup\n @line_item.line_item = parent_line_item\n @line_item.searchable = false\n @line_item.admin_verified = false\n @line_item.section_id = line_item_params[\"section_id\"]\n else\n @line_item = LineItem.new(line_item_params);\n end\n\n if @line_item.save\n render json: @line_item, status: :created, location: @line_item\n else\n render nothing: true, status: :bad_request\n end\n end",
"def line\n lines.line(y)\n end",
"def append_line\n File.open(path, 'w') do |fh|\n lines.each do |l|\n fh.puts(l)\n end\n fh.puts line\n end\n end",
"def <<(lo)\n lo.line_number = size\n super(lo)\n end",
"def add_line(point1, point2)\n end",
"def add_line_details(line_doc)\n id = parse_xml(line_doc/'id') if (line_doc/'id').first\n line = bank_transaction_lines.find_or_build(id) if line_doc.name == 'bank_transaction_line'\n if line\n line.apply_attributes(line_doc) \n line.fill_default_detail_values\n self.max_serial_no = line.serial_no = (self.max_serial_no.to_i + 1).to_s if line.new_record?\n end\n line\n end",
"def insert_line lineno=@current_index\n prompt = \"Insert: \"\n maxlen = 80\n #config={}; \n #config[:default] = line\n #ret, str = rb_getstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config)\n ret, str = input_string prompt\n #ret, str = rb_getstr(@form.window, @row+@height-1, @col+1, prompt, maxlen, config)\n $log.debug \" rb_getstr returned #{ret} , #{str} \"\n return if ret != 0\n\n # pad based expect @content not list\n # remove list after a while FIXME\n @list ||= @content\n @list.insert lineno, str\n ## added handler on 2010-05-23 11:46 - undo works - tested in testlistbox.rb\n fire_handler :CHANGE, InputDataEvent.new(0,str.length, self, :INSERT_LINE, lineno, str)\n fire_dimension_changed\n end",
"def line(pos=pos())\n lines[line_index(pos)]\n end",
"def <<(line)\n add(UnorderedListItem.new(line))\n end",
"def set_line\r\n @line = Line.find_by_id(params[:id])\r\n end",
"def add_line_item_from_string(input_line)\n parsed_line = /(?<quantity>\\d+) (?<item>.+) at (?<price>\\d*\\.\\d{2})?/.match(input_line)\n new_line_item = LineItem.new(parsed_line['quantity'],parsed_line['item'],parsed_line['price'])\n @line_items << new_line_item\n end",
"def line(x, y, angle, length)\n cur_page.line(x, y, angle, length)\n end",
"def line(pos=pos)\n lines[line_index(pos)]\n end",
"def add_line(x, y, label=\"data #{@dataxy.length + 1}\")\n @dataxy << [label, x, y]\n end",
"def setLine (line)\n @line = line\n end",
"def line (distance, direction=nil)\n x1, y1 = position\n move distance, direction\n x2, y2 = position\n canvas.line(x1, y1, x2, y2, color)\n end",
"def get_line\n @lines.shift\n end",
"def add_item(line_item_from_cart)\n current_item = cart.line_items.find_by(line_item_id: line_item.id)\n\n if current_item\n current_item = cart.line_items.find_by(line_item_id: line_item.id)\n else\n current_item = cart.line_items.find_by(line_item_id: line_item.id)\n end\n\n current_item\n end",
"def editor_insert_line!\n Vedeu.bind(:_editor_insert_line_) do |name|\n Vedeu.documents.by_name(name).insert_line\n end\n end",
"def new_line(command)\n if command[1] == command[3]\n if command[2].to_i > @canvas.width - 2 || command[4].to_i > @canvas.width - 2\n puts 'you can not create the line because it is larger than the canvas'\n return\n else\n line_shape = :horizontal\n end\n elsif command [2] == command[4]\n if command[1].to_i > @canvas.height - 2 || command[3].to_i > @canvas.height - 2\n puts 'you can not create the line because it is larger than the canvas'\n return\n else\n line_shape = :vertical\n end\n else\n puts 'The line you are trying to create is not horizontal or vertical'\n return\n end\n @canvas.commands.new_line(command[1], command[2], command[3], command[4], line_shape)\n end",
"def draw_horizontal_line(y, h = 2)\n contents.fill_rect(0, y, contents_width, h, text_color(QuestData::COLOURS[:line]))\n contents.fill_rect(0, y + h, contents_width, [h / 2, 1].max, text_color(QuestData::COLOURS[:line_shadow]))\n end",
"def add_comment_line line\n @strings << line\n end",
"def begin_line kind\n if style = @span_for_kinds[@last_opened ? [kind, *@opened] : kind]\n if style['class=\"']\n @out << style.sub('class=\"', 'class=\"line ')\n else\n @out << style.sub('>', ' class=\"line\">')\n end\n else\n @out << '<span class=\"line\">'\n end\n @opened << kind\n @last_opened = kind if @options[:css] == :style\n end",
"def insert_after\r\n @lines.insert(@line_num, TextLineBuffer.new(\"\"))\r\n @line_num = @line_num + 1\r\n end",
"def add_location(path, line); end",
"def line_one\n return @line_one\n end",
"def line_number\n\t\t\t@line_index + 1\n\t\tend",
"def link_line_item(line_item)\n self.spree_line_item_id = line_item.id\n self.save!\n end",
"def insert_line\n\t\t@first = params[:placement]['first'].to_f\n\t\t@second = params[:placement]['second'].to_f\n\t\t@new_order_number = @first + ( @second - @first ) / 2\n\t\t@lyric_id = params[:lyric_id]\n\t\t@lyric_line = LyricLine.new lyric_id: @lyric_id, order_number: @new_order_number\n\t\t@new = true\n\tend",
"def to_line(*args)\n raise NotImplementedError.new 'No line conversion method defined!'\n end",
"def line_one\n @line_one\n end",
"def exec_env_current_line\n get('insert linestart', 'insert lineend')\n end",
"def hline y, c, x1 = 0, x2 = h\n line x1, y, x2, y, c\n end",
"def hline y, c, x1 = 0, x2 = h\n line x1, y, x2, y, c\n end",
"def add_cart_line_item(newitem, options={})\n return nil if newitem.nil?\n item = find(:first, newitem)\n if item\n # existing item found, update item quantity and add total_price\n item.quantity += newitem.quantity\n else\n # not in cart yet\n item = newitem\n @line_items << item\n end\n item\n end",
"def add_product(product)\n current_item = line_items.find_by(product_id: product.id) # find the current item in the line items. find_by() returns an existing LineItem or nil.\n if current_item # if the current item is present...\n current_item.quantity += 1 # ...increment by one.\n else\n current_item = line_items.build(product_id: product.id) # If the item isn't present then build the line_item.\n current_item.price = product.price # Take the current_item and capture the price attribute.\n end\n current_item # Return the current item.\n end",
"def add_to_line_item(line_item, variant, quantity, currency=nil, shipment=nil, price=nil)\n if line_item\n line_item.target_shipment = shipment\n line_item.quantity += quantity.to_i\n line_item.currency = currency unless currency.nil?\n line_item.save\n else\n line_item = order.line_items.new(quantity: quantity, variant: variant)\n # line_item = Spree::LineItem.new(quantity: quantity)\n line_item.target_shipment = shipment\n line_item.variant = variant\n if currency\n line_item.currency = currency unless currency.nil?\n line_item.price = price || variant.price_in(currency).amount\n else\n line_item.price = price || variant.price\n end\n # order.line_items << line_item\n # line_item\n end\n \n line_item.save\n order.reload\n line_item\n end",
"def initialize(line, parent)\n @line = line\n @parent = parent\n @cmds = []\n @children = []\n end",
"def possibly_add_line_number_comment(line)\n if @state[:ll_end]\n return line + \" # WPLINE_#{@state[:line_number]}\"\n else\n return line\n end\n end",
"def add_product(product_id)\n \n #Check if the current item is in our current line items\n current_item = line_items.find_by_product_id(product_id)\n if current_item\n #If it is already in our line items, increment the quantity\n current_item.quantity += 1\n else\n #Otherwise, build the relationship\n current_item = line_items.build(product_id: product_id)\n end\n \n #return the current item\n current_item\n end",
"def add(text)\n @lines ||= []\n @lines.push text\n end",
"def line\n\t\t\tself.src.line\n\t\tend",
"def horizontal_line(y, options = {})\n with options do\n at = y + @bottom\n @pdf.stroke_horizontal_line left, @pdf.bounds.right - right, at: at\n end\n end",
"def create_line(frag)\n who = fragments.find_by order: frag.order - 1, f_type: 24\n Line.create! fragment_id: frag.id, who: (who.nil? ? nil : who.orig_text), content: frag.orig_text\n 1\n end",
"def line_one=(line_one)\n @line_one = line_one\n end",
"def add_item(item_id)\n self.add_or_create_line_item(item_id)\n end",
"def line_code\n @attrs['Line']\n end",
"def add_line_item_to_order( variant )\n duplicate_line_item = line_item_exists?( variant )\n duplicate_line_item.quantity += 1 and return duplicate_line_item if duplicate_line_item\n\n line_items.build :name => variant.good.name, \n :price => variant.price, \n :options => variant.option_values_to_s,\n :sku => variant.sku\n end",
"def current_line\n\n seek_line_head\n @file.gets\n end",
"def new_line(count=1)\n cur_page.new_line(count)\n end",
"def create\n #@line = Line.new(params[:line])\n\n @line = current_user.lines.build(params[:line])\n respond_to do |format|\n if @line.save\n\n\nif @line.parent_id\n\nuser_id = Line.find(@line.parent_id).user_id\n@user_parent = User.find(user_id)\n@user_parent.messages.create!(:line_id => @line.id)\nend\n format.html {\n\n redirect_to lines_path, :flash => { :success => \"line created!\" } }\n format.xml { render :xml => @line, :status => :created, :location => @line }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @line.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_line(instance_name, class_name, which=0)\n raise StandardError, \"Line object already exists. (#{instance_name})\" if self.instance_variables.include?(\"@#{instance_name}\".to_sym)\n new_line_name = instance_name\n make_accessor(:\"#{instance_name}\")\n klas = OLE_QA::Framework::OLEFS.const_get(:\"#{class_name}\")\n instance_variable_set(:\"@#{new_line_name}\", klas.new(@ole, which))\n end",
"def unshift(line)\n @lines.unshift(line) if line\n nil\n end",
"def line(canvas, p1, p2, color)\n canvas.line(\n clamp(p1[0].round, 0, canvas.width-1),\n clamp(p1[1].round, 0, canvas.height-1),\n clamp(p2[0].round, 0, canvas.width-1),\n clamp(p2[1].round, 0, canvas.height-1),\n color)\n end",
"def build_first_line\n @number = Qt::Label.new\n add_widget(@number)\n end",
"def draw_line(index)\n rect = Rect.new(0, 0, 0, 0)\n rect.x += 4\n rect.y += index * WLH\n rect.width = contents.width - 8\n rect.height = WLH\n self.contents.clear_rect(rect)\n self.contents.font.color = normal_color\n self.contents.draw_text(rect, @lines[index])\n end"
] |
[
"0.6668727",
"0.6592262",
"0.6482159",
"0.64409804",
"0.6272245",
"0.6220798",
"0.620202",
"0.61966985",
"0.6170827",
"0.6003752",
"0.5966348",
"0.592102",
"0.59197515",
"0.590428",
"0.5867356",
"0.5836515",
"0.5802996",
"0.5754109",
"0.5743829",
"0.57004714",
"0.5695685",
"0.5689779",
"0.5662494",
"0.5601619",
"0.5573427",
"0.5571057",
"0.5566902",
"0.5540906",
"0.5535577",
"0.55173707",
"0.5490197",
"0.54820323",
"0.54708046",
"0.54524064",
"0.5451778",
"0.5440285",
"0.5430923",
"0.5425266",
"0.5422481",
"0.5396016",
"0.5396016",
"0.5396016",
"0.53172183",
"0.5315563",
"0.53142077",
"0.531085",
"0.52902913",
"0.52882266",
"0.5277374",
"0.52644694",
"0.523746",
"0.5195758",
"0.5193552",
"0.5192194",
"0.5188241",
"0.51841116",
"0.51563597",
"0.5154445",
"0.51519835",
"0.5151557",
"0.5146455",
"0.5135062",
"0.51348686",
"0.51185006",
"0.51146376",
"0.5111785",
"0.50995207",
"0.5092578",
"0.50861764",
"0.5082741",
"0.507094",
"0.50688934",
"0.50600076",
"0.5059244",
"0.50584286",
"0.5045458",
"0.50333214",
"0.50333214",
"0.50306",
"0.50278306",
"0.5023955",
"0.50157905",
"0.5010513",
"0.50057274",
"0.49784684",
"0.49724275",
"0.49688095",
"0.49587753",
"0.4948302",
"0.494427",
"0.49431878",
"0.493528",
"0.4932032",
"0.49231994",
"0.49176574",
"0.49157006",
"0.49011847",
"0.48998588",
"0.48987493",
"0.4884492"
] |
0.67920893
|
0
|
Internal: Given an array of parsed blocks, converts the properties within the blocks into a single hash. Returns a hash.
|
def blocks_to_hash(blocks)
blocks.each_with_object({}) do |block, hash|
hash.merge!(block.to_hash)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_h(&block)\n if block_given?\n @properties.each_with_object({}) do |(key, val), acc|\n k, v = *block.(key, val)\n acc[k] = v\n end\n else\n DeepDup.deep_dup(@properties)\n end\n end",
"def json_adjustments\n @blockss.each do |rsrc, blocks|\n blocks.each do |block|\n block.starttime = block.starttime.to_i\n block.endtime = block.endtime.to_i\n end\n end\n @blockss['meta'] = {\n rsrcs: @rsrcs, min_time: min_time, max_time: max_time,\n t1: @t1.to_i, t2: @t2.to_i, inc: @inc,\n }\n end",
"def cms_blocks_attributes\n self.cms_blocks.inject([]) do |arr, block|\n block_attr = {}\n block_attr[:label] = block.label\n block_attr[:content] = block.content\n block_attr[:id] = block.id\n arr << block_attr\n end\n end",
"def parse_block(b)\n results = {}\n b.each do |line|\n\n if line =~ /^Location \\[(\\d+),(\\d+)\\]$/\n results['beginning'] = $1\n results['end'] = $2\n elsif line =~ /^tmRNA Sequence in\\s(\\w+)/\n results['sequence_acc'] = $1\n elsif line =~ /^Tag peptide:\\s+(.+)/\n results['tag_peptide'] = $1\n end\n end\n\n return results\n end",
"def items_to_hash(items, &block)\n result = {}\n if items.count == @headers.count\n each_result = items.map.with_index { |item, index|\n [@headers[index].to_s, item]\n }.flatten\n if block_given? and !each_result.empty?\n block.yield(Hash[*each_result]) unless each_result.empty?\n end\n end\n result\n end",
"def parse_info(block)\r\n\t\tinfo = Hash.new\r\n\t\tinfo['original'] = block\r\n\r\n\t\tblock = block.split('|')\t# splits the block by the regex '|'\r\n\t\tif block.length != 5\r\n\t\t\tputs 'Invalid block format, should consist of only 5 elements'\r\n\t\t\tputs 'BLOCKCHAIN INVALID'\r\n\t\t\texit()\r\n\t\tend\t\t\r\n\r\n\t\tinfo['id'] = block[0].to_i\r\n\t\tinfo['prev_hash'] = block[1]\r\n\t\tinfo['transaction'] = block[2].split(':')\t# splits transaction by the regex ':'\r\n\t\tinfo['ts'] = {'sec': block[3].split('.')[0].to_i, 'nsec': block[3].split('.')[1].to_i}\r\n\t\t#puts info['ts']\r\n\t\tinfo['self_hash'] = block[4]\r\n\t\treturn info\r\n\tend",
"def to_hash\n JSON.parse(properties).to_h\n end",
"def parse\n result = {}\n content = file_content\n\n s = content.index(BLOCK_START_DELIMITER)\n e = content.index(BLOCK_END_DELIMITER)\n\n while s && e\n s += BLOCK_START_DELIMITER.size\n block = content[s..e-1]\n\n key, value = parse_block(block)\n result[key] = value\n\n e += BLOCK_END_DELIMITER.size\n content = content[e..-1]\n\n s = content.index(BLOCK_START_DELIMITER)\n e = content.index(BLOCK_END_DELIMITER)\n end\n\n return result\n end",
"def to_h\n { languages: languages.map(&:to_h), break_type: break_type,\n prefix_break: prefix_break?, width: width, height: height,\n blocks: blocks.map(&:to_h) }\n end",
"def to_configurable_hash(properties, type, &block)\n assertion_hash = {}\n assertion_hash.merge! block: block if block_given?\n assertion_hash.merge! type: type if type\n\n zip_to_hash(assertion_hash, *properties)\n end",
"def attributes\n {\n :block_size => @block_size, :block_count => @blocks,\n :blocks => @block_data.map(&:dup)\n }\n end",
"def block_to_hash(default = {}, &block)\n default.merge((yield HashWithAccessors.new(default)).to_hash) if block_given?\n end",
"def all_property_hash\n hash = {}\n items = @all_properties\n for prop in items\n hash[prop] = {}\n end\n return hash\n end",
"def to_configurable_hash(properties, type, &block)\n assertion_hash = {}\n assertion_hash.merge! block: block if block_given?\n assertion_hash.merge! type: type if type\n\n assertions = ([assertion_hash] * properties.size)\n Hash[properties.zip(assertions)]\n end",
"def map_into_hash(&block)\n Hash[*map {|x| [x[0], block.call(x)]}.inject([], &:concat)]\n end",
"def properties\n hash = {}\n Parser::PROPERTIES.each { |property| hash[property] = send(property) }\n hash\n end",
"def to_hash\n Hash[sort_tuples(section_tuples)]\n end",
"def raw_hash\n @raw_hash ||= raw_hash_with_cycles[:block]\n end",
"def calculate_block_hash(block)\n Digest::SHA256.hexdigest(block.block_index.to_s + block.previous_block_hash + block.timestamp + block.data)\n end",
"def to_hash(overrides = {})\n defaults = {interpolate: true, context: self}\n overrides = defaults.merge(overrides)\n hash = {}\n @children.each_pair do |name, child|\n if child.kind_of?(BranchNode)\n hash[name] = child.to_hash(overrides)\n elsif child.kind_of?(PropertyNode)\n hash[name] = child.get_value(overrides)\n end\n end\n # Return the hash.\n hash\n end",
"def groupProperties(sblock, index, properties)\n if properties[:net].nil?\n return sblock;\n end\n start = index\n properties[:net].each do |k,v|\n v.each do |pkey, pvalue|\n next if (pvalue.size == 0)\n sblock[start] = node_property(k, pkey, pvalue)\n start += 1;\n end\n end\n return sblock;\n end",
"def create_hash(&block); end",
"def create_hash(&block); end",
"def res_prop_hash(nodoc)\n props = {}\n statement[1].entries.each do |e|\n next if e == false\n if %i[var_ref array].include?(e.type)\n props[:type] = e.source\n elsif e.type == :symbol_literal\n props[:identifier] = e.source.delete(':')\n elsif e.type == :list\n props[:options] = parse_option_list(e)\n end\n end\n props[:docstring] = nodoc ? '' : statement.docstring\n\n props\n end",
"def hash\n [prefix, postfix, snippet_count, fragment_size, max_analyzed_chars, merge_contiguous, use_phrase_highlighter, fields].hash\n end",
"def to_h\n return props.reduce(Hash.new) do |h, d|\n h[d.first] = send(d.first)\n h\n end\n end",
"def to_h\n hash = Hash.new\n hash[:flowcell_id] = self.id\n hash[:samples] = []\n each_sample_with_lane do |sample, lane|\n hash[:samples] << sample.to_h\n end\n hash[:paths] = self.paths.to_h\n hash\n end",
"def hash_by_uri\n @hash_by_uri ||= begin\n result = {}\n flatten_hierarchy.each do |c|\n result[c.uri.to_s]=c\n end\n result\n end\n end",
"def hash\n { hash: @hash, hashType: @hash_type }\n end",
"def to_h\n hash = {\n description: description,\n sections: sections.map(&:to_h)\n }\n hash[:id] = id if id\n hash[:encrypted] = encrypted?\n hash[:views] = views if views\n hash[:created_at] = created_at if created_at\n hash[:expires_at] = expires_at if expires_at\n\n hash\n end",
"def new_blocks_attributes\n return [] if @new_blocks_attributes.empty?\n\n blocks_attributes = if @new_blocks_attributes.is_a?(Hash)\n @new_blocks_attributes.values\n else\n @new_blocks_attributes\n end\n\n if home_page? || footer?\n return blocks_attributes + include_srcset_block(blk_attrs: blocks_attributes)\n end\n\n convert_content_to_html(blocks_attributes)\n\n blocks_attributes\n end",
"def to_hash\n {:hashes => @hashes}\n end",
"def render_block(block)\n block.map do |prop, value|\n render_property prop, value\n end.join('')\n end",
"def to_hash; @caesars_properties.to_hash; end",
"def hash\n [links, organization_id].hash\n end",
"def partial_blocks_total\n partial_blocks_total = {}\n\n ancestros = (self.is_a? Module) ? ancestors : self.singleton_class.ancestors\n ancestros.reverse_each do |ancestro|\n partial_blocks_total.delete_if do |multimetodo, _|\n ancestro.instance_methods(false).include? multimetodo and not ancestro.partial_blocks.keys.include? multimetodo\n end\n\n ancestro.partial_blocks.each do |multimetodo, hash_tipos|\n hash_tipos.each do |lista_tipos, block|\n partial_blocks_total[multimetodo] ||= {}\n partial_blocks_total[multimetodo][lista_tipos] = block\n end\n end\n end\n\n partial_blocks_total\n end",
"def hash\n [format, display_header, display_from_email_address, display_email_address, display_to_email_address, display_cc_email_address, display_bcc_email_address, time_zone_offset, convert_attachments, field_labels, preserve_original_date].hash\n end",
"def hashify(*args, &block)\n key_value_pairs = args.map {|a| yield(a) }\n\n # if using Ruby 1.9,\n # Hash[ key_value_pairs ]\n # is all that's needed, but for Ruby 1.8 compatability, these must\n # be flattened and the resulting array unpacked. flatten(1) only\n # flattens the arrays constructed in the block, it won't mess up\n # any values (or keys) that are themselves arrays.\n Hash[ *( key_value_pairs.flatten(1) )]\n end",
"def to_hash\n @parsed_body ||= JSON.parse(@body, symbolize_names: true)\n end",
"def to_hash\n { name => properties.except(:name) }\n end",
"def raw_hash_with_cycles\n @raw_hash_with_cycles ||= self.class.fetch_raw_hash_with_cycles block_hash\n end",
"def hash(block)\n Digest::SHA256.hexdigest(block.to_s.encode)\n end",
"def nested_merge_not_configured_hash(*properties, &block)\n nested = properties.last.is_a?(Hash) ? properties.pop : {}\n nested = ingest_configuration_block!(nested, &block)\n props = zip_to_hash(block, *properties)\n\n @not_configured.merge! nested, &method(:configuration_deep_merge)\n @not_configured.merge! props, &method(:configuration_deep_merge)\n end",
"def make_pp_hash(pp_array, pp_start_line, pp_length, pp_transid_field, pp_amt_field)\n\tthe_hash={}\n\tfor i in (pp_start_line..(pp_length-1))\n\n\t\ttransaction_id = pp_array[i][pp_transid_field]\n\t\ttransaction_amt = pp_array[i][pp_amt_field]\n\t\ttransaction_amt = transaction_amt.delete(\",\") \t\t\t#get rid of the comma in the string\n\t\ttransaction_amt_f=transaction_amt.to_f\t\t\t\t\t#now you can convert the string to floating point\n\t\n\t\tif transaction_amt_f > 0\t\t\t\t\t\t\t\t\t\t\t#we don't look at negative transactions because salesforce only records positives. Go figure.\n\t\t\tthe_hash[transaction_id]=transaction_amt_f\n\t\t\t@paypal_total += transaction_amt_f\n\t\tend\n\tend\n\treturn the_hash\nend",
"def hash\n [article_number, name, quantity, unit_price, discount_percent, vat_percent, unit, temporary_reference, row_number, merchant_data].hash\n end",
"def to_hash # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity\n hash = {}\n hash[\"type\"] = type if type\n hash[\"formattedref\"] = formattedref.to_hash if formattedref\n hash[\"title\"] = title.to_hash\n hash[\"place\"] = place if place\n hash[\"organization\"] = organization if organization\n hash[\"abbreviation\"] = abbreviation.to_hash if abbreviation\n hash[\"from\"] = from if from\n hash[\"to\"] = to if to\n hash[\"number\"] = number if number\n hash[\"partnumber\"] = partnumber if partnumber\n hash[\"run\"] = run if run\n hash\n end",
"def to_hash\n hash = {}\n\n hash[:name] = name\n hash[:file] = file\n hash[:line] = line\n\n hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring)\n hash[:properties] = properties.sort_by(&:name).map(&:to_hash) if properties && !properties.empty?\n hash[:parameters] = parameters.sort_by(&:name).map(&:to_hash) if parameters && !parameters.empty?\n hash[:checks] = checks.sort_by(&:name).map(&:to_hash) if checks && !checks.empty?\n hash[:features] = features.sort_by(&:name).map(&:to_hash) if features && !features.empty?\n hash[:providers] = providers.sort_by(&:name).map(&:to_hash) if providers && !providers.empty?\n\n hash\n end",
"def hashify(string)\n hash = Hash.new\n if string != nil\n string = string.split(/\\n(?=\\{)/)\n string.each do |section|\n hash[ ( section.slice(/[\\w\\d\\_\\#]+(?=\\})/) ) ] = section[(section.index('}')+1)..-1].strip\n end\n end\n return hash\nend",
"def hashes(log)\n return log.split(\"\\n\").map{|line| parser(line) }\n end",
"def to_hash\n hash = { :lead_selector => @lead_selector.to_hash,\n :attributes! => { :lead_selector => { 'xsi:type' => @lead_selector.type } } }\n hash[:last_updated_at] = @last_updated_at.strftime(\"%Y-%m-%dT%H:%M:%S-00:00\") if @last_updated_at\n hash[:stream_position] = @stream_position if @stream_position\n hash[:batch_size] = @batch_size if @batch_size\n hash[:include_attributes] = @include_attributes if @include_attributes\n hash\n end",
"def hashes_convert(array)\n Array.new(array).map do |elem|\n Hash.new elem\n end\n end",
"def hashes_convert(array)\n Array.new(array).map do |elem|\n Hash.new elem\n end\n end",
"def to_hash\n # Drop the probes into the report\n probe_sets.inject({}) { |report, set|\n report[set.name.to_s] = set.probes.inject({}) { |memo, (_, probe)|\n # round the values to 2 decimal places\n memo[probe.name] = (probe.value.to_f * 100).round().to_f/100\n memo\n }\n report\n }\n end",
"def to_hash\n body.to_hash\n end",
"def to_hash\r\n result = {}\r\n each do |elt|\r\n result[elt] = yield(elt)\r\n end\r\n result\r\n end",
"def to_h\n { languages: languages.map(&:to_h), break_type: break_type,\n prefix_break: prefix_break?, bounds: bounds.map(&:to_h),\n paragraphs: paragraphs.map(&:to_h), block_type: block_type }\n end",
"def to_hash\n result = {}\n [[:tn, :tn], [:epg, :epg], [:cnam, :cnam], [:refId, :ref_id]].each do |garbage, pretty|\n # Make sure that this thing ain't nil\n if self.send(pretty)\n result[garbage] = self.send(pretty)\n end\n end\n result\n end",
"def compound_list_to_hash(sample, name)\n sample.keys.each do |key|\n row = sample.delete(key)\n FIELDS[name].each_with_index do |field, idx|\n sample[\"#{key}.#{field}\"] = row[idx] if row[idx]\n end\n end\n sample\n end",
"def to_hash\n case node\n in SyntaxTree::HashLiteral[assocs:]\n in SyntaxTree::BareAssocHash[assocs:]\n else\n raise CompilationError, \"Unexpected node type: #{node.class.name}\"\n end\n\n assocs.to_h do |assoc|\n case assoc\n in SyntaxTree::Assoc[key:, value:]\n [RenderNode.new(key), RenderNode.new(value)]\n else\n raise CompilationError, \"Unexpected node type: #{node.class.name}\"\n end\n end\n end",
"def file_hashes\n @file_hashes ||= file_field_sets.map do |file_field_set|\n instantiation_fields, file_fields = file_field_set.partition do |field|\n instantiation_header?(field.header)\n end\n\n file_hash = fields_to_hash(file_fields)\n file_hash['files'] = [fields_to_hash(instantiation_fields)]\n\n file_hash\n end\n end",
"def hash\n [additional_properties, currency_code, description, inventory, min_inventory_threshold, not_available, not_displayable, original_price, price, published, sale_id, sale_name, sku, start_date, stop_date].hash\n end",
"def hash\n [amount.hash, currency.hash].hash\n end",
"def hash\n [amount.hash, currency.hash].hash\n end",
"def block_hash\n\t\tdigest = Digest::SHA2.new\n\n\t\tdigest << '%d' % [ self.index ]\n\t\tdigest << self.timestamp.strftime( '%s%N' )\n\t\tdigest << self.payload\n\t\tdigest << self.payload_hash\n\t\tdigest << self.proof.to_s\n\t\tdigest << self.previous_hash\n\t\t\n\t\treturn digest.hexdigest\n\tend",
"def hash\n [property_code, property_name, location, address, total_price, min_daily_rate, contacts, amenities, awards, images, rooms, more_rooms_at_this_hotel].hash\n end",
"def ingest_configuration_block!(hash, &block)\n hash.each do |k, v|\n value = if v.is_a?(Hash)\n ingest_configuration_block!(v, &block)\n else\n zip_to_hash(block, *Array(v))\n end\n\n hash.merge! k => value\n end\n end",
"def to_hash(description='String::to_hash() made by genious RCarlesso (give a better description if u dont like this!)')\n arr = Hash.new\n arr['_meta'] = Hash.new\n arr['_meta']['description'] = description\n arr['_meta']['time'] = Time.now\n self.split(\"\\n\").each{|line| \n k,v = line.split(': ') \n arr[k.strip] = v.strip \n } rescue arr['_meta']['errors'] = $! \n arr\n end",
"def blocks\n object.blocks.map{ |x|\n ShallowBlockSerializer.new(x)\n }\n end",
"def hash\n [monitor_tags].hash\n end",
"def hashes\n return @hashes\n end",
"def hash\n [duration, rrule, start].hash\n end",
"def hash\n [host_list, total_matching, total_returned].hash\n end",
"def hash\n [type, hide_placeholders, base_justification, min_column_width, column_gap_rule, column_gap, row_gap_rule, row_gap, items].hash\n end",
"def hash_of_hashes\n Hash.new do |h1, k1|\n h1[k1] = Hash.new { |h, k| h[k] = [] }\n end\n end",
"def hash\n [comments, invoice_number, purchase_order_number, disbursement_trans_type, wallet_provider, receipts, additional_response_data].hash\n end",
"def properties\n map(element_type: :hash) { |v| v.properties }\n end",
"def parse_metadata_body(body)\n body.lines.each_with_object({}) do |line, hsh|\n k, v = line.strip.split\n hsh[k.to_sym] = v\n end\n end",
"def to_hash\n memoize(:to_hash) do\n _process_hashed(structures.inject({}) { |acc, elem| Utils.merge(acc, elem) })\n end\n end",
"def hash\n [ data, type ].hash\n end",
"def data_hash\n primary, included =\n resources_processor.process(Array(@data), @include, @fields)\n {}.tap do |hash|\n hash[:data] = @data.respond_to?(:to_ary) ? primary : primary[0]\n hash[:included] = included if included.any?\n end\n end",
"def set_blocks hash\n\t\t\t@blocks = hash\n\t\tend",
"def hash\n [item_id, error_details].hash\n end",
"def hash\n lists.inject({}){ |hash, p| hash[p[0]] ||= []; hash[p[0]] << p[1]; hash }\n end",
"def to_hash\n hash = attributes.to_hash\n hash['location'] = location.first.to_hash if location.size == 1\n hash\n end",
"def to_hash\n result = super\n result[:source_type] = :git\n result[:location] = location\n result[:commitish_type] = commitish_type\n result[:commitish] = commitish\n result\n end",
"def hash(block, stored_hash, hash_calc, block_check, line)\r\n return 'Block empty' if block.nil?\r\n\r\n # calculate hash value for line\r\n error = \"Line #{line}: Invalid hash set to #{stored_hash.strip}\"\r\n\r\n # if hash stored as with capital letters, return error\r\n stored_hash = stored_hash.strip # get rid of trailing white space\r\n int_hash = stored_hash.to_i(16) # get stored hash and convert to decimal\r\n # check lenght of stored hash(max4)...may be optiaml to place elsewhere\r\n return error + \"\\nHash length is too big\" if stored_hash.size >= 5\r\n\r\n # check hash for leading 0's\r\n return error + \"\\nHash contains leading zeros\" if stored_hash[0] == '0' && stored_hash.size > 1\r\n\r\n # check to make sure value is valid hex values\r\n return error + \"\\nInvalid hex value, must be lowercase and from 0-f\" unless block_check.check_hex(stored_hash)\r\n\r\n # see if calculated hash and stored has match\r\n hash = block_check.get_hash(block, hash_calc) # get hash value\r\n # removes last hash from string\r\n output_string = block_check.parse(block, '|' + stored_hash)\r\n error_two = \"Line #{line}: String '#{output_string[0]}' hash set to #{stored_hash.strip},\"\\\r\n \"should be #{hash.to_s(16)}\"\r\n return error_two unless block_check.check_hash(hash, int_hash)\r\n\r\n nil\r\n end",
"def make_hash item_or_array_or_hash\n return {} if item_or_array_or_hash.nil? \n return strip_nil_keys(item_or_array_or_hash) if item_or_array_or_hash.kind_of?(Hash)\n hash = {}\n [item_or_array_or_hash].flatten.each do |element| \n unless element.nil?\n hash[element] = block_given? ? yield(element) : nil\n end\n end\n hash\n end",
"def parse_hash_list(hash_list)\n hash_list.map { |hash| Base.parse_hash(hash) }.compact\n end",
"def to_properties_hash\n self.class.send(:property_list).inject({}) do |hash, property|\n hash.merge(property.to_hash(self))\n end\n end",
"def each_property(&block)\n properties.each { |k, v| block.call(k, v) }\n end",
"def from_array_of_hashes(hashes, hlines: false, **types)\n heads = hashes.first.keys\n result = new(*heads, **types)\n hashes.each do |hsh|\n if hsh.nil?\n unless hlines\n msg = 'found an hline in input: try setting hlines true'\n raise UserError, msg\n end\n result.mark_boundary\n next\n end\n result << hsh.to_h\n end\n result.normalize_boundaries\n result\n end",
"def parse(filenames)\r\n properties = {}\r\n filenames.each do |filename|\r\n if (File.exists?(filename))\r\n file = File.open(filename, \"r\")\r\n file.read.each_line do |line|\r\n line.strip!\r\n if (line[0] != ?# and line[0] != ?=)\r\n i = line.index(\"=\")\r\n if (i)\r\n key = line[0..i - 1].strip\r\n value = line[i + 1..-1].strip\r\n properties[key] = value.strip\r\n else\r\n key = line\r\n value = \"\"\r\n properties[key] = value\r\n end\r\n end\r\n end\r\n file.close\r\n file = nil\r\n end\r\n end\r\n properties\r\nend",
"def props\n ret = {}\n iter = @internal_node.getPropertyKeys.iterator\n while (iter.hasNext) do\n key = iter.next\n ret[key] = @internal_node.getProperty(key)\n end\n ret\n end",
"def hash\n [aws_elastic_block_store, azure_disk, azure_file, cephfs, cinder, config_map, downward_api, empty_dir, fc, flex_volume, flocker, gce_persistent_disk, git_repo, glusterfs, host_path, iscsi, name, nfs, persistent_volume_claim, photon_persistent_disk, portworx_volume, projected, quobyte, rbd, scale_io, secret, storageos, vsphere_volume].hash\n end",
"def extract_parts_hash\n parts_hash = {}\n\n @header_string.sub!(/\\ARange:\\s*/, '')\n\n range_spec_string, params_strings = split_header_string(@header_string)\n\n parts_hash.merge! extract_range_spec_hash(range_spec_string)\n parts_hash.merge! extract_params_hash(params_strings)\n\n return parts_hash\n end",
"def format_as_yaml\n\t\tobjects = {}\n\t\tself.instance_variables.each do |k|\n\t\t\tobjects[k.to_s.gsub('@','')] = instance_eval(k.to_s)\n\t\tend\n\t\tobjects.delete(\"filename\")\n\t\tobjects.delete(\"previous_file\")\n\t\treturn objects\n\tend",
"def hash\n [first_row_index, first_cell_index, last_row_index, last_cell_index, allow_splitting].hash\n end",
"def array_to_hash(array, hash= [])\n array.each do |item|\n x = item.is_a?(OpenStruct) ? openstruct_to_hash(item) : item.is_a?(Array) ? array_to_hash(item) : item\n hash << x\n end\n hash\n end",
"def hash\n [configured_alert_ids, created_at, creator, description, groups, id, modified_at, monitor_ids, monitor_tags, name, query, tags, target_threshold, thresholds, timeframe, type, warning_threshold].hash\n end",
"def process_lines\n\t#file_string is a string array,\n\t#extendable_hash is a hash that is created through this method\n\t\tneeded_lines = []\n\t\t@lines.each do |line|\n\t\t\tunless line.strip.length == 0 || line[0] == '#' #filters empty lines and comments\n\t\t\t\tneeded_lines << line\n\t\t\tend\n\t\tend\n\n\t\t@hash = {}\n\t\tneeded_lines.map do |line| #splits every line at empty spaces\n\t\t\tline = line.split(\" \")\n\t\t\t@hash[line[0]] = line.drop(1) #line.drop(1) returns line without the first (0th) entry\n\t\tend\n\n\n\t\t# needed_lines.map do |line|\n\t\t# \thash[line[0]] = line.drop(1) #line.drop(1) returns line without the first (0th) entry\n\t\t# end\n\n\t\treturn @hash\n\tend"
] |
[
"0.6046544",
"0.55548185",
"0.54865503",
"0.5469761",
"0.546405",
"0.54541075",
"0.5424585",
"0.5415328",
"0.5398357",
"0.53873974",
"0.53280497",
"0.53262925",
"0.52941555",
"0.5293148",
"0.52784747",
"0.5266053",
"0.5253693",
"0.5234994",
"0.5224278",
"0.5202144",
"0.5202028",
"0.5176949",
"0.5176949",
"0.51614136",
"0.51520103",
"0.5150105",
"0.5143736",
"0.5131737",
"0.51048255",
"0.5094822",
"0.5090429",
"0.509009",
"0.5066662",
"0.5066266",
"0.50558543",
"0.50536275",
"0.50527877",
"0.5024513",
"0.5022955",
"0.5019676",
"0.501744",
"0.5016026",
"0.5009908",
"0.50049675",
"0.4984928",
"0.49842593",
"0.49798414",
"0.49537513",
"0.49510783",
"0.49507967",
"0.49491343",
"0.49491343",
"0.49407035",
"0.49388903",
"0.4931452",
"0.4927597",
"0.4923499",
"0.49221867",
"0.49152896",
"0.49037343",
"0.48981926",
"0.48783898",
"0.48783898",
"0.48718065",
"0.4869662",
"0.48695597",
"0.48639426",
"0.48495597",
"0.4831832",
"0.4823528",
"0.48208433",
"0.48164406",
"0.48147872",
"0.4814367",
"0.4813526",
"0.4801264",
"0.4799331",
"0.47924876",
"0.47890243",
"0.4783955",
"0.47756985",
"0.47739214",
"0.47732702",
"0.47686306",
"0.4757669",
"0.47570837",
"0.47557586",
"0.4741385",
"0.47391212",
"0.47386473",
"0.47347718",
"0.4734703",
"0.47307953",
"0.4729027",
"0.47194156",
"0.47188583",
"0.47116363",
"0.4711363",
"0.47076848",
"0.47069332"
] |
0.73259133
|
0
|
FIXME: belongs to Blog engine
|
def full_permalink
raise "can not create full_permalink for an article that belongs to a non-blog section" unless section.is_a? Blog
# raise "can not create full_permalink for an unpublished article" unless published?
date = [:year, :month, :day].map { |key| [key, (published? ? published_at : created_at).send(key)] }.flatten
Hash[:permalink, permalink, *date]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def blog\n object._blog\n end",
"def blog(which_blog)\n blog_object\n end",
"def posts; end",
"def scraper\n blog.scraper\n end",
"def index\n #binding.pry\n #@blogs = Blog.new_first\n @blogs = Blog.new_first.page(params[:page]).per(5)\n #byebug\n #@blogs = Blog.featured_blogs\n #binding.pry\n @page_title = \"Blogs\"\n end",
"def add_blog(date, text)\n\t\tBlog.new date, self, text\n\tend",
"def get_blog_posts\n\t\treturn @blog_posts\n\tend",
"def is_blog_post?\n self.type == 'Blog'\n end",
"def is_blog_post?\n self.type == 'Blog'\n end",
"def links; end",
"def links; end",
"def permalink; end",
"def permalink; end",
"def add_blog(date, text) # this method should accept date and text and store it in an array.\n # So I guess two objects - the date and then the blog object.\n # So, it needs to instantiate a blog object, which in turn\n # will create variables at its instantiation (initialize).\n added_blog = Blog.new(date, self, text)\n blogs << added_blog\n self.blogs = blogs.sort_by { |blog| blog.date }.reverse #investigate if self needs to be specified. calling blogs will surely default to a call on self\n added_blog\n end",
"def index\n # Load the latest full blog feed for Frank's blog as per \n @latest_blog_posts = load_blog_feed_for_url('http://blog.rietta.com/feeds/posts/default?alt=rss')\n \n # Load the latest posts for the Marketing label feed. Labels are case sensitive - Marketing != marketing\n # Please note that the example of the Google website has an error on its label example. The alt=rss comes after\n # the label in the feed URL\n @latest_marketing_posts = load_blog_feed_for_url('http://blog.rietta.com/feeds/posts/default/-/Marketing?alt=rss')\n \n # Load the latest posts for the SQL Converter label feed (space in the tag)\n @latest_sql_converter_posts = load_blog_feed_for_url('http://blog.rietta.com/feeds/posts/default/-/SQL%20Converter?alt=rss')\n end",
"def import_blog\n raw = Feedzirra::Feed.fetch_and_parse(self.feed)\n if (raw && raw.entries)\n raw.entries[0..4].each do |i|\n slug = slug_process(i.url.split('/').last.gsub(/\\...*/, '') + \"_\" + self.author.name)\n post = Post.where(:slug => slug, :author_id => self.author_id).first\n post = entry2post(i, slug) if not post\n end\n end\n end",
"def index\n # find the blog for the id provided\n@blog = Blog.find(params[:blog_id])\n# Get all the posts associated with this blog\n@posts = @blog.posts \n end",
"def home\n\n# find_all_blog_posts\n#\n# find_blog_post\n#\n# find_tags\n (@blog_posts = BlogPost.live.includes(:comments, :categories).all) if request.format.rss? \n respond_with (@blog_posts) do |format|\n format.html\n format.rss\n end\n\n error_404 unless (@page = Page.where(:link_url => '/').first).present?\n end",
"def noter_blog_handle\n\t\tnoter.main_blog.nil? ? nil : noter.main_blog.handle\n\tend",
"def blogs_weblog_explain; \"List your weblogs.\"; end",
"def all_post\n end",
"def show\n @bolg = set_blog\n end",
"def articles\n\n end",
"def pages; end",
"def index\n @blog_articles = Blog::Article.all\n end",
"def blog_search\n @tab = \"blog\"\n @sub = \"blogsearch\"\n \t\t@blog_search_results = Array.new\n \t @blog_search_results = BlogPost.search( Riddle::Query.escape(params[:search_param] || \"memorize\") )\n \tend",
"def index\r\n @blogposts = Blogpost.all\r\n #used for current day and date.\r\n #@WeatherRss = WeatherRSS.new()\r\n @weather_rss = WeatherRSS.weather_rss\r\n end",
"def set_blog\n # this is shows the blogs, is like this code where written in show method\n @blog = Blog.friendly.find(params[:id])\n end",
"def index_by_date\n @enable_blog_edit = true\n authorize! :read, Roxiware::Blog::Post\n @page = (params[:page] || 1).to_i\n @blog_class = params[:blog_class] || \"blog\"\n conditions = {:blog_class=>@blog_class}\n if params[:format] == \"rss\"\n @num_posts = [(params[:max] || @blog_posts_per_feed).to_i, @max_blog_posts_per_feed].min\n else\n @num_posts = [(params[:max] || (@posts_per_page || @blog_posts_per_page)).to_i, @max_blog_posts_per_page].min\n end\n\n if params.has_key?(:year)\n start_date = DateTime.new(params[:year].to_i,\n (params[:month] || 1).to_i,\n (params[:day] || 1).to_i,\n 0, 0, 0)\n end_date = DateTime.new(params[:year].to_i,\n (params[:month] || -1).to_i,\n (params[:day] || -1).to_i,\n -1, -1, -1)\n conditions[:post_date] =start_date..end_date\n end\n\n if params.has_key?(:category)\n conditions[:terms] = {:term_taxonomy_id=>Roxiware::Terms::TermTaxonomy.taxonomy_id(Roxiware::Terms::TermTaxonomy::CATEGORY_NAME), :seo_index=>params[:category]}\n end\n if params.has_key?(:tag)\n conditions[:terms] = {:term_taxonomy_id=>Roxiware::Terms::TermTaxonomy.taxonomy_id(Roxiware::Terms::TermTaxonomy::TAG_NAME), :seo_index=>params[:tag]}\n end\n\n if conditions.has_key?(:terms)\n @posts = Roxiware::Blog::Post.joins(:terms).visible(current_user).includes(:term_relationships, :terms).where(conditions).order(\"post_date DESC\")\n else\n @posts = Roxiware::Blog::Post.visible(current_user).includes(:term_relationships, :terms).where(conditions).order(\"post_date DESC\")\n end\n\n @num_posts_total = @posts.count\n @posts = @posts.limit(@num_posts+1).offset(@num_posts*(@page-1))\n @num_pages = (@num_posts_total.to_f/@num_posts.to_f).ceil.to_i\n @link_params = {}\n @link_params[:max] = params[:max] if params[:max].present?\n @page_images = [@posts.first.post_image] if @posts.first.present?\n @og_url = @posts.first.post_link if @posts.first.present?\n @og_video_url = @posts.first.post_video if @posts.first.present? && @posts.first.post_video.present?\n if (@posts.length == @num_posts+1)\n @posts.pop\n @next_page_link = url_for({:page=>@page+1}.merge @link_params)\n end\n if(@page > 1)\n @prev_page_link = url_for({:page=>@page-1}.merge @link_params)\n end\n\n respond_to do |format|\n format.html do\n @page_title = @title\n @posts.each do |post|\n @meta_keywords = @meta_keywords + \", \" + post.post_title\n end\n render :action=>\"index\"\n end\n format.json do\n clean_posts = []\n @posts.each do |post|\n clean_posts << post.ajax_attrs(@role)\n end\n render :json => clean_posts\n end\n format.rss { render :layout => false, :action=>\"index\", :content_type=>\"application/rss+xml\" }\n end\n end",
"def blog_description\n Settings.blog_description\n end",
"def index\n if logged_in?(:site_admin) #logged_in is a PEtergate method\n @blogs ||= Blog.recent.page(params[:page]).per(5) # Kaminari gem to have pagination recent is a scope\n else\n @blogs ||= Blog.recent.published.page(params[:page]).per(5)\n end\n @page_title = \"My Blog\" # to dynamically change the title of the site\n end",
"def view_post\n content \n end",
"def newsfeed\n Post.newsfeed_for(self)\n end",
"def is_blog? itm\n is_kind? :blog, itm\nend",
"def index\n @blog_links = BlogLink.all\n end",
"def index\n @posts = BlogPost.all\n end",
"def set_blog\n # @blog = Blog.find(params[:id])\n @blog = Blog.friendly.find(params[:id]) \n end",
"def published?; end",
"def published?; end",
"def show\n @page_title = @blog.title\n # this works because of the before_action method that calls set_blog to retrieve the actual blog title\n @seo_keywords = @blog.body\n end",
"def index\n\n @blog_articles = BlogArticle.all\n end",
"def get_blog_posts\n return @items.select { |item| item.identifier.index('/blog/') == 0 && item[:published] }.reverse\nend",
"def blog_title\n Settings.blog_title\n end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def blogit_conf\n self.class.blogit_conf\n end",
"def set_blog_post\n @blog_post = BlogPost.find(params[:id])\n end",
"def index\n # @blogs = Blog.all \n # could change this to @blogs = Blog.limit(1) \n # to limit the app to just one blog.\n # binding.pry # set break point \n @blogs = Blog.page(params[:page]).per(5) \n # set to use Kaminari gem for pagination, 5 items per page\n # will define how many blog entries to process\n \n @page_title = \"My Portfolio Blog\" # reset the page title as appropriate for Blogs site.\n # used in the applicatoin.html.erb layout code\n end",
"def reblog\n @post = Post.find_by(id: params[:id])\n end",
"def blog\n #@posts = Post.search(params[:search], params[:page])\n \n @search = Post.active_posts.search(params[:search])\n @posts = @search.all.paginate :page => params[:page], :per_page => 30\n \n session[:single_blog] = nil\n session[:page] = params[:page]\n \n render(:layout => 'application')\n end",
"def index\n @blogs = CMS::BlogPage.featured.order(created_at: :desc)\n @categories = CMS::BlogCategory.order(name: :asc)\n @unpublished_blogs = CMS::BlogPage.where(author: current_person).unpublished if user_signed_in?\n end",
"def index\n @pages = Page.find(:all, :order => 'updated_at DESC', :limit => 5)\n @blogs = Blog.all\n end",
"def links_feed\n end",
"def initialize\n @blog_number=0\n @my_blogposts={}\n @time=Time.now\n end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def site; end",
"def index\n @my_blogs = MyBlog.all\n end",
"def content; end",
"def content; end",
"def content; end",
"def content; end",
"def content; end",
"def content; end",
"def content; end",
"def content; end",
"def content; end"
] |
[
"0.6993421",
"0.6791575",
"0.6632702",
"0.6337447",
"0.60823256",
"0.6058488",
"0.60539734",
"0.60349554",
"0.60349554",
"0.5976926",
"0.5976926",
"0.5976534",
"0.5976534",
"0.5949663",
"0.5939723",
"0.59332806",
"0.59308183",
"0.59299666",
"0.5924941",
"0.5916103",
"0.5901975",
"0.5892803",
"0.58893406",
"0.58821195",
"0.58801067",
"0.5878537",
"0.5878517",
"0.5872005",
"0.5864579",
"0.5859997",
"0.58316123",
"0.5815133",
"0.58052945",
"0.5805236",
"0.5801978",
"0.5792783",
"0.57797706",
"0.5775922",
"0.5775922",
"0.57737535",
"0.5762336",
"0.5752997",
"0.5748459",
"0.574293",
"0.574293",
"0.574293",
"0.574293",
"0.574293",
"0.574293",
"0.574293",
"0.574293",
"0.574293",
"0.574293",
"0.574293",
"0.574293",
"0.5740109",
"0.5737625",
"0.57275784",
"0.57190037",
"0.5710623",
"0.56977415",
"0.5696508",
"0.56937754",
"0.5692201",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.56864524",
"0.5684611",
"0.56825304",
"0.56825304",
"0.56825304",
"0.56825304",
"0.56825304",
"0.56825304",
"0.56825304",
"0.56825304",
"0.56825304"
] |
0.0
|
-1
|
Write encoded record to the handle
|
def write(record)
@fh.puts(encode(record))
self
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def write(record)\n @fh.write(MARC::Writer.encode(record))\n end",
"def record_write bytes\n @reader.record_write bytes, @state\n end",
"def write(record)\n @writer.write(MARC::XMLWriter.encode(record), @fh)\n @fh.write(\"\\n\")\n end",
"def write(record)\n @writer.write(MARC::XMLWriter.encode(record), @fh)\n @fh.write(\"\\n\")\n end",
"def record_write bytes, state=nil\n begin\n do_record_write bytes, state\n rescue\n nil\n end\n end",
"def record=(record)\n self.record_data = Base64.encode64(Marshal.dump(record))\n end",
"def writeencoding; end",
"def write(record)\n @worker.enqueue record\n end",
"def write\n file = ::File.open(@file, 'w')\n file.write(Bencode.encode(@data))\n file.close\n end",
"def write(data); end",
"def write(data); end",
"def write(data); end",
"def write(data); end",
"def write(record)\n case record\n when FlatKit::Jsonl::Record\n write_record(record)\n when FlatKit::Record\n converted_record = ::FlatKit::Jsonl::Record.from_record(record)\n write_record(converted_record)\n else\n raise FlatKit::Error, \"Unable to write records of type #{record.class}\"\n end\n rescue FlatKit::Error => fe\n raise fe\n rescue => e\n ::FlatKit.logger.error \"Error reading jsonl records from #{output.name}: #{e}\"\n raise ::FlatKit::Error, e\n end",
"def write\n write_data\n end",
"def write(value)\n record.send(\"#{name}_data=\", value)\n end",
"def write; end",
"def write; end",
"def write(data)\n @handle.writeData(data)\n end",
"def write(data)\n end",
"def write_record(num,args)\r\n\t\t\toffset=self.get_record_offset(num)\r\n\t\t\treturn if offset==nil\r\n\t\t\tw=self.write_to(offset,args)\r\n\t\t\treturn if w==nil\r\n\t\t\tnum==0 ? '0E0' :num\r\n\t\tend",
"def write(chunk)\n tag = chunk.metadata.tag\t\t\n $real_container = extract_placeholders(@container, chunk)\n\t\tarrays_2 = chunk_convert(chunk)\n\t\thandle_record(tag, DateTime.now, arrays_2)\n end",
"def write_raw(obj,encoding = 3)\n\t @stream = \"\" #new output stream\n\t RequestStore.amf_encoding = (encoding == 3) ? 'amf3' : 'amf0'\n\t reset_referencables\n\t write(obj)\n\t @stream\n\tend",
"def dump\n _dump do |row|\n codec.encode( row.values, io ) unless dry_run?\n end\n ensure\n io.flush\n end",
"def writer(record)\n replace(record)\n end",
"def write\n end",
"def []=(id, record)\n @h.seek(id * @record_size, IO::SEEK_SET)\n\n # # Padding\n @h.write(record)\n end",
"def process record\n $stdout.puts record\n $stdout.flush\n end",
"def write\n row.set_attribute(attr_name, contents)\n end",
"def write(buf); end",
"def encode_new_value(record)\n record.new_value.force_encoding('utf-8')\n\n record.new_value =\n record.new_value.encode('utf-8', invalid: :replace, undef: :replace, replace: '_')\n rescue StandardError => e\n Rollbar.error(e, 'Failed to encode value to UTF-8', record: record) if report_to_rollbar\n\n nil\n end",
"def write\n open(@fname,\"wb\") do |file|\n Marshal.dump(@data,file)\n end\n end",
"def save\n if (not @queued_for_delete.empty?) and @queued_for_write.empty?\n instance_write(:meta, ActiveSupport::Base64.encode64(Marshal.dump({}))) if instance.respond_to?(:\"#{name}_meta=\")\n end\n original_save\n end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n writer.write_object_value(\"newText\", @new_text)\n writer.write_object_value(\"numBytes\", @num_bytes)\n writer.write_object_value(\"oldText\", @old_text)\n writer.write_object_value(\"startNum\", @start_num)\n writer.write_additional_data(@additional_data)\n end",
"def write(*data); end",
"def write\n\n # output to disk\n File.open(@outfile, 'w:UTF-8') { |file|\n file.write(@buffer)\n }\n end",
"def write(handle, offset, data)\n send_request(FXP_WRITE, :string, handle, :int64, offset, :string, data)\n end",
"def write(bytes)\r\n end",
"def write(io)\n io.write [@value].pack(format)\n end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_object_value(\"details\", @details)\n writer.write_string_value(\"identityType\", @identity_type)\n end",
"def write(buffer)\n QRUtil.stringToBytes(self.getData() ).each { |d|\n buffer.put(d, 8)\n }\n end",
"def write_struct\n @struct.connection.set(@struct.key, 'foo')\n end",
"def write()\n f = File.open(\"#{@directory}/#{@filename}\", \"w\")\n f.write(@raw)\n f.close()\n end",
"def write\n begin\n buf = [ @flags, @length, @id, @crc].pack(FORMAT)\n crc = Zlib.crc32(buf, 0)\n @file.seek(@addr)\n @file.write(buf + [ crc ].pack('L'))\n rescue IOError => e\n PEROBS.log.fatal \"Cannot write blob header into flat file DB: \" +\n e.message\n end\n end",
"def write object\n if open?\n @reader.close\n @writer.write Marshal.dump(object)\n @writer.close\n end\n end",
"def perform( handle, data, offset=0 )\n @handle = handle\n @offset = offset\n @data = data\n @pos = 0\n\n @driver.write( nil, handle, offset, data[0,CHUNK_SIZE] )\n end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_date_time_value(\"createdDateTime\", @created_date_time)\n writer.write_string_value(\"deviceId\", @device_id)\n writer.write_string_value(\"key\", @key)\n writer.write_enum_value(\"volumeType\", @volume_type)\n end",
"def write(name, value, options = nil)\n options ||= {}\n name = expanded_key name\n if options.delete(:raw)\n options[:format] = :plain\n value = value.to_s\n value.force_encoding(Encoding::BINARY) if defined?(Encoding)\n end\n\n instrument(:write, name, options) do |payload|\n write_entry(name, value, options)\n end\n end",
"def write(io)\n @values.each {|field|\n field.write io\n }\n end",
"def store_field(data)\n @io.write [data.size].pack(\"V\") \n offset = @io.pos\n @io.write data\n @io.write \"\\0\"\n offset \n end",
"def write_binary(buf)\n raise NotImplementedError\n end",
"def write data\n _data[:out].write data\n _data[:out].flush\n end",
"def write(record)\n raise NotImplementedError, \"#{self.class} needs to implement #write that returns Position\"\n end",
"def save_data(rec, table_name, file, stream, divider = '; ', finalizer = nil)\n @current_rev[table_name] = rec.GetValAsLongByIndex(1)\n\n fields = stream.TableSet.FieldList(table_name) #\"deal\"]\n file.puts fields.split(',').map { |f| \"#{f}=#{rec.GetValAsString(f)}\" }.join divider\n file.puts(finalizer) if finalizer\n file.flush\n end",
"def to_file( f )\n buf = [@name, @ref.binary_role(), @ref.binary_type(), @ref.name,\n @type, TYPE_SIZES[@type], \n @data.length()].pack(PFORMAT)\n f.write(buf)\n\n fmt_str = \"%s%d\" % [TYPES[@type], data.length]\n buf = data.pack(fmt_str)\n f.write(buf)\n end",
"def write_recordset_page(asrpage)\t\n\t\twrite_byte(16) #write custom object flag\n\t\twrite_utf('RecordSetPage') #write the specific class type\n\n\t\t#write cursor position\n\t\twrite_utf('Cursor')\n\t\twrite_number(asrpage.cursor)\n\n\t\t#write the page data\n\t\twrite_utf('Page')\n\n\t\t#writed the data\n\t\twrite_array(asrpage.value) #write the data\n\n\t\t#end outer object\n\t\twrite_int16_network(0)\n\t\twrite_byte(9)\n\tend",
"def write(chunk)\n # dummy\n end",
"def process(record)\n $stdout.puts record\n end",
"def write_record\n route53.change_resource_record_sets(options)\n end",
"def emit record\n $stdout.puts(record.to_s)\n end",
"def write(string)\n @handle.write(string)\n end",
"def save_record(record)\n record.save\n end",
"def save_record(record)\n record.save\n end",
"def close_write() end",
"def close_write() end",
"def close_write() end",
"def write( object )\n if object.responds_to?(:write_to) then\n object.write_to(@stream)\n else\n @stream << object.to_s\n end\n end",
"def write(buf, *args)\n Polyphony.backend_write(self, buf, *args)\n end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_date_time_value(\"createdDateTime\", @created_date_time)\n writer.write_object_value(\"device\", @device)\n writer.write_string_value(\"displayName\", @display_name)\n writer.write_enum_value(\"keyStrength\", @key_strength)\n end",
"def write_record ids, attributes, options = {}\n remote.write ids, attributes, options[:context]\n end",
"def write_external(out_stream)\n # out.writeShort (fieldNumber);\n # out.writeUTF (value);\n puts value.to_s\n end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_string_value(\"appId\", @app_id)\n writer.write_string_value(\"displayName\", @display_name)\n writer.write_string_value(\"objectId\", @object_id_escaped)\n writer.write_string_value(\"publisher\", @publisher)\n end",
"def put_record(stream, key, value)\n raise NotImplementedError\n end",
"def write(data)\n @data << data\n end",
"def write_object(object)\n @encoder.encode(object, @sock)\n end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n writer.write_object_value(\"customKeyIdentifier\", @custom_key_identifier)\n writer.write_string_value(\"displayName\", @display_name)\n writer.write_date_time_value(\"endDateTime\", @end_date_time)\n writer.write_string_value(\"hint\", @hint)\n writer.write_guid_value(\"keyId\", @key_id)\n writer.write_string_value(\"@odata.type\", @odata_type)\n writer.write_string_value(\"secretText\", @secret_text)\n writer.write_date_time_value(\"startDateTime\", @start_date_time)\n writer.write_additional_data(@additional_data)\n end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n writer.write_string_value(\"columnId\", @column_id)\n writer.write_string_value(\"@odata.type\", @odata_type)\n writer.write_string_value(\"qualityId\", @quality_id)\n writer.write_additional_data(@additional_data)\n end",
"def write(data)\n # black hole, because we don't actually care about what gets written\n end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n writer.write_string_value(\"content\", @content)\n writer.write_string_value(\"@odata.type\", @odata_type)\n writer.write_string_value(\"transportKey\", @transport_key)\n writer.write_additional_data(@additional_data)\n end",
"def __bson_dump__(io, key)\n io << Types::OBJECT_ID\n io << key.to_bson_cstring\n io << data\n end",
"def write(p0) end",
"def write(p0) end",
"def write_entry(key, entry, raw: false, **options)\n write_serialized_entry(key, serialize_entry(entry, raw: raw, **options), raw: raw, **options)\n end",
"def write(p0) end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n writer.write_string_value(\"id\", @id)\n writer.write_string_value(\"@odata.type\", @odata_type)\n writer.write_additional_data(@additional_data)\n end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n writer.write_object_value(\"customKeyIdentifier\", @custom_key_identifier)\n writer.write_string_value(\"displayName\", @display_name)\n writer.write_date_time_value(\"endDateTime\", @end_date_time)\n writer.write_object_value(\"key\", @key)\n writer.write_guid_value(\"keyId\", @key_id)\n writer.write_string_value(\"@odata.type\", @odata_type)\n writer.write_date_time_value(\"startDateTime\", @start_date_time)\n writer.write_string_value(\"thumbprint\", @thumbprint)\n writer.write_string_value(\"type\", @type)\n writer.write_string_value(\"usage\", @usage)\n writer.write_additional_data(@additional_data)\n end",
"def write(rawmsg)\r\n @connection.send(rawmsg)\r\n end",
"def close_write; end",
"def write(&block)\n @write_block = block\n end",
"def write(data, *args, **kwd); end",
"def encode(obj); end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n writer.write_string_value(\"displayName\", @display_name)\n writer.write_string_value(\"locale\", @locale)\n writer.write_string_value(\"@odata.type\", @odata_type)\n writer.write_additional_data(@additional_data)\n end",
"def conv_to_write_ary ( orig_key, orig_val, orig_typ, orig_dat )\n\n reg_key = value_buffer(orig_key)\n reg_val = value_buffer(orig_val)\n reg_typ = self.class.reg_type_conv_pol_rev(orig_typ).encode('UTF-8')\n if reg_typ == \"\\u0001\"\n reg_dat = orig_dat.encode('UTF-8')\n else\n $log.debug \"Conv_to_write_ary (show conversion): #{orig_dat} : #{orig_dat.encoding.name}\" if $DEBUG\n if orig_dat[/\\H/]\n reg_dat = orig_dat\n else\n reg_dat = Integer(orig_dat).chr.force_encoding('UTF-8')\n end\n end\n reg_siz = value_reg_siz(reg_dat)\n reg_dat = value_buffer(reg_dat)\n write_ary = [ reg_key , reg_val ,reg_typ ,reg_siz, reg_dat ]\n write_ary\n end",
"def encode_chunk(chunk); end",
"def record(message)\n results_write.puts(message)\n results_write.flush\n end",
"def send_record_data(record)\n send_data record.content_string, :type => record.mime_type,\n :disposition => 'inline',\n :filename => record.location\n end",
"def serialize(io)\n Encoder.encode(io, self)\n io\n end",
"def write item\n @f.write \">\"+item.id+' '+item.descr+\"\\n\"\n @f.write item.seq.strip+\"\\n\"\n end",
"def process(record)\n @output << record\n end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n writer.write_string_value(\"dataLocationCode\", @data_location_code)\n writer.write_string_value(\"hostname\", @hostname)\n writer.write_string_value(\"@odata.type\", @odata_type)\n writer.write_object_value(\"root\", @root)\n writer.write_additional_data(@additional_data)\n end"
] |
[
"0.7382807",
"0.7094003",
"0.6921319",
"0.6921319",
"0.68935287",
"0.67133904",
"0.6448053",
"0.63763046",
"0.6352201",
"0.63295764",
"0.63295764",
"0.63295764",
"0.63295764",
"0.62227345",
"0.6185086",
"0.6112052",
"0.6030467",
"0.6030467",
"0.6028497",
"0.6021128",
"0.59768265",
"0.59724844",
"0.5952741",
"0.59490454",
"0.59413195",
"0.59156144",
"0.58999753",
"0.58823186",
"0.586637",
"0.58601356",
"0.58322906",
"0.58219314",
"0.58013874",
"0.5799137",
"0.579714",
"0.5792337",
"0.5785408",
"0.5771712",
"0.57518476",
"0.5712828",
"0.5711671",
"0.5697696",
"0.5680824",
"0.56600416",
"0.56479746",
"0.5637303",
"0.5624568",
"0.56133604",
"0.56111765",
"0.56046075",
"0.55899477",
"0.55866486",
"0.55838174",
"0.5578892",
"0.5575357",
"0.5573981",
"0.5569353",
"0.5553769",
"0.55519575",
"0.5550095",
"0.5542001",
"0.55370724",
"0.55370724",
"0.5536227",
"0.5536227",
"0.5536227",
"0.55070275",
"0.5506834",
"0.5504115",
"0.54726005",
"0.54703224",
"0.5468905",
"0.5463675",
"0.5447774",
"0.5446403",
"0.5442264",
"0.5427198",
"0.5425952",
"0.5423351",
"0.5408426",
"0.5381863",
"0.5381863",
"0.5381149",
"0.53803235",
"0.5379506",
"0.5375408",
"0.53736424",
"0.5370164",
"0.5369733",
"0.5368215",
"0.5362714",
"0.5361809",
"0.5359729",
"0.5351862",
"0.5349623",
"0.5342057",
"0.53268033",
"0.53260344",
"0.53210133",
"0.53063136"
] |
0.7957822
|
0
|
Esto es un atributo virtual.
|
def edad
hoy = Date.today
hoy.year - fecha_de_nacimiento.year -
((hoy.month > fecha_de_nacimiento.month ||
(hoy.month == fecha_de_nacimiento.month && hoy.day >= fecha_de_nacimiento.day)) ? 0 : 1)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def attr; end",
"def override\n attributes.override\n end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def virtual; end",
"def attributes(_record)\n raise 'Abstract method attributes should be overriden'\n end",
"def attr(name); end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attr_info; end",
"def method_missing(method_name, *args, &block)\n return super unless define_attribute_methods\n self.send(method_name, *args, &block)\n end",
"def attribute(name); end",
"def virtual_attribute? c\n raise NotImplementedError\n end",
"def attributes\n end",
"def is_attribute?; end",
"def custom_data\n super.attributes\n end",
"def serialize\n super(ATTR_NAME_ARY)\n end",
"def serialize\n super(ATTR_NAME_ARY)\n end",
"def serialize\n super(ATTR_NAME_ARY)\n end",
"def serialize\n super(ATTR_NAME_ARY)\n end",
"def serialize\n super(ATTR_NAME_ARY)\n end",
"def attributes\n end",
"def allowed_attributes=(_arg0); end",
"def allowed_attributes=(_arg0); end",
"def has_attribute?(name)\n return true if self.class._has_virtual_column?(name)\n return super\n end",
"def attrs\n self.class.attrs\n end",
"def editable_attribute_names; super + additional_fields end",
"def editable_attribute_names; super + additional_fields end",
"def editable_attribute_names; super + additional_fields end",
"def attribute_name=(_arg0); end",
"def attribute_name=(_arg0); end",
"def attribute_name=(_arg0); end",
"def attributes=(_arg0); end",
"def attribute=(_arg0); end",
"def attribute=(_arg0); end",
"def instance_attributes; end",
"def create_accessible_attributes\n read_inheritable_attribute(:attr_create_accessible)\n end",
"def virtual?\n attributes[\"virtual\"] == \"1\"\n end",
"def get_attribute(name); end",
"def get_attribute(name); end",
"def attribute_name; end",
"def attribute_name; end",
"def attribute_name; end",
"def attribute_name; end",
"def attribute_name; end",
"def attribute_name; end",
"def attribute_name; end",
"def attribute(_name)\n raise Orocos::NotFound, \"#attribute is not implemented in #{self.class}\"\n end",
"def attribute_method\n method_options = options\n\n lambda do |name, type = Object, options = {}|\n super(name, type, method_options.update(options))\n end\n end",
"def initialize(attr={})\n super\n end",
"def properties\n super\n end",
"def attrs\n @attrs\n end",
"def class_attributes; end",
"def initialize\n @attribute = 'truite'\n @accessor = 'pouet'\n end",
"def create_virtual_attributes!\n project_attributes = @object.project_type.fields_attributes_list\n @object.class_eval do\n attr_accessor *project_attributes\n end\n end",
"def define_attr_accessor(attr)\n attr_accessor(attr)\n end",
"def model_attributes\n raise NotImplementedError\n end",
"def attrs\n @attrs\n end",
"def readonly_attributes\n read_inheritable_attribute(:attr_readonly)\n end",
"def attr(symbol, writable=false) end",
"def attribute_method?(attr)\n super || attributes.keys.include?(attr)\n end",
"def method_missing(name, *args, &block)\n unless self.attributes.include?(name.to_s)\n super(name, *args, &block)\n else\n self.attributes[name.to_s]\n end\n end",
"def method_missing(name, *args, &block)\n unless self.attributes.include?(name.to_s)\n super(name, *args, &block)\n else\n self.attributes[name.to_s]\n end\n end",
"def define_attribute_methods\n if super\n define_nilify_blank_methods\n end\n end",
"def define_attribute_methods\n super\n self.generated_methods.each do |method|\n if method.to_s =~ Regexp.new(\"^#{self.to_s.underscore}__\")\n new_method_name = $~.post_match\n alias_method(new_method_name, method)\n private method\n self.generated_methods << new_method_name\n end\n end\n end",
"def attributes\n super.merge({ 'visibility' => @visibility })\n end",
"def method_missing(meth, *args, &blk)\n if args.length > 0\n self.class.add_custom_attribute meth\n send meth, *args, &blk\n else\n super meth, *args, &blk\n end\n end",
"def initialize\n super\n self.class.attributes.reject { |attr| attr.default.nil? }.each do |attr|\n send(\"#{attr.method_name}=\", attr.default)\n end\n end",
"def my_attribute\n @my_attribute\n end",
"def method_missing(method_name, *_args)\n if attrs.key?(method_name.to_s)\n attrs[method_name.to_s]\n else\n super(method_name)\n end\n end",
"def print_attribute(*) end",
"def super_attr(name, opts={})\n\t\t\t\t\n\t\t\t\t# Defines getter\n\t\t\t\tdefine_method(\"#{name}\") do\n\t\t\t\t\tinstance_variable_get(\"@#{name}\")\n\t\t\t\tend\n\n\t\t\t\t# Defines setter\n\t\t\t\tdefine_method(\"#{name}=\") do |arg|\n\t\t\t\t\t# If the arg is a kind of opts[:type]\n\t\t\t\t\t# it sets the value, otherwise, it will\n\t\t\t\t\t# raise a StandardError.\n\t\t\t\t\tif arg.is_a? opts[:type]\n\t\t\t\t\t\tinstance_variable_set(\"@#{name}\", arg)\n\t\t\t\t\telse\n\t\t\t\t\t\traise StandardError.new(\"The value for #{name} is not a type #{opts[:type]}\")\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# If the attribute is required, it will\n\t\t\t\t# push its name to the @@required_attrs array\n\t\t\t\t@@required_attrs << name if opts.has_key?(:required) && opts[:required]\n\n\t\t\tend",
"def derived_attributes\n @derive_attribute ||= {}\n end",
"def initialize attr={}\n super\n self.attributes = attr\n end",
"def method_missing(method_name, *args, &block)\n if attrs.keys.include? method_name.to_s\n attrs[method_name.to_s]\n else\n super(method_name)\n end\nend",
"def attribute_to_set; end",
"def ext_attr\n attribute_prop(10)\n end",
"def purely_virtual?\n attributes[\"pure_virtual\"] == \"1\"\n end",
"def attributes=(*args)\n define_dynamic_answer_setters!\n super(*args)\n end",
"def owner_class_attribute_default; end",
"def attribs\n\t\t@attributes\n\tend",
"def attribute(name)\n attributes << name\n\n if !method_defined?(name) || name == :id\n attr_accessor name\n end\n end",
"def method_missing(meth, *args, &block)\n if attributes.has_key?(meth)\n attributes[meth]\n else\n super\n end\n end",
"def setup_object_attributes; end",
"def attribute_accessor?\n false\n end",
"def data_attributes\n end",
"def special_attribute(name)\n @special_attributes[name]\n end"
] |
[
"0.7080885",
"0.70752454",
"0.6895608",
"0.6895608",
"0.6895608",
"0.6895608",
"0.6895608",
"0.6895608",
"0.6895608",
"0.68803865",
"0.6640529",
"0.6617597",
"0.66158897",
"0.66158897",
"0.66158897",
"0.66158897",
"0.66158897",
"0.66158897",
"0.66158897",
"0.66158897",
"0.66158897",
"0.66158897",
"0.66158897",
"0.66073185",
"0.65756464",
"0.6534118",
"0.65256405",
"0.64358574",
"0.6380748",
"0.6246863",
"0.6245265",
"0.6245265",
"0.6245265",
"0.6245265",
"0.6245265",
"0.62126946",
"0.61602086",
"0.61602086",
"0.6149466",
"0.61173254",
"0.611155",
"0.611155",
"0.611155",
"0.61107403",
"0.61107403",
"0.61107403",
"0.6110396",
"0.61007285",
"0.61007285",
"0.6089828",
"0.6089638",
"0.6053831",
"0.6032188",
"0.6032188",
"0.5995643",
"0.5995643",
"0.5995643",
"0.5995643",
"0.5995643",
"0.5995643",
"0.5995643",
"0.5975401",
"0.5975124",
"0.5970137",
"0.5968888",
"0.5952691",
"0.5945381",
"0.5939133",
"0.5917428",
"0.5907437",
"0.59018576",
"0.5885483",
"0.58813375",
"0.5878633",
"0.58544827",
"0.5843455",
"0.5843455",
"0.5836859",
"0.58330905",
"0.5823089",
"0.5818167",
"0.58063555",
"0.5806112",
"0.5804948",
"0.58012515",
"0.57911587",
"0.57850856",
"0.5782536",
"0.57760185",
"0.5775638",
"0.5768736",
"0.5763581",
"0.57629806",
"0.5761576",
"0.5747827",
"0.5713471",
"0.57067275",
"0.5703383",
"0.5700659",
"0.5699465",
"0.56979954"
] |
0.0
|
-1
|
combine bishop and rook for queen moves
|
def bishop_moves(x, y, game)
own_spaces = game[game[:turn]].keys
opponent_spaces = game[@opp_turn[game[:turn]]].keys
moves = []
# up right
temp_x = x + 1
temp_y = y + 1
while temp_x < 5 && temp_y < 5 && !own_spaces.include?([temp_x, temp_y])
moves.push([temp_x, temp_y])
break if opponent_spaces.include?([temp_x, temp_y])
temp_x += 1
temp_y += 1
end
# up left
temp_x = x - 1
temp_y = y + 1
while temp_x > 0 && temp_y < 5 && !own_spaces.include?([temp_x, temp_y])
moves.push([temp_x, temp_y])
break if opponent_spaces.include?([temp_x, temp_y])
temp_x -= 1
temp_y += 1
end
# down right
temp_x = x + 1
temp_y = y - 1
while temp_x < 5 && temp_y > 0 && !own_spaces.include?([temp_x, temp_y])
moves.push([temp_x, temp_y])
break if opponent_spaces.include?([temp_x, temp_y])
temp_x += 1
temp_y -= 1
end
# down left
temp_x = x - 1
temp_y = y - 1
while temp_x > 0 && temp_y > 0 && !own_spaces.include?([temp_x, temp_y])
moves.push([temp_x, temp_y])
break if opponent_spaces.include?([temp_x, temp_y])
temp_x -= 1
temp_y -= 1
end
moves
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def moves_queen(color, a, b)\n\t\t_moves = []\n\t\t(continue_left(color, a, b)).each{|move| _moves << move}\n\t\t(continue_right(color, a, b)).each{|move| _moves << move}\n\t\t(continue_up(color, a, b)).each{|move| _moves << move}\n\t\t(continue_down(color, a, b)).each{|move| _moves << move}\n\t\t(continue_up_left(color, a, b)).each{|move| _moves << move}\n\t\t(continue_up_right(color, a, b)).each{|move| _moves << move}\n\t\t(continue_down_left(color, a, b)).each{|move| _moves << move}\n\t\t(continue_down_right(color, a, b)).each{|move| _moves << move}\n\t\t_moves.compact\n\tend",
"def possible_bishop_moves(start_arr)\n\t\tx = start_arr[1]\n\t\ty = start_arr[0]\n\t\tcandidates = []\n\t\t# Checks how many spaces rook can move up & right\n\t\tmove_up_right = true\n\t\ti = 1\t\t\n\t\twhile move_up_right && i < 8\n\t\t\tpos = [y+i, x+i]\n\t\t\tif pos[0] >= 8 || pos[1] >= 8\n\t\t\t\tmove_up_right = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_up_right = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_up_right = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\n\t\t# Checks how many spaces rook can move down & right\n\t\tmove_down_right = true\t\t\n\t\ti = 1\t\n\t\twhile move_down_right && i < 8\n\t\t\tpos = [y-i, x+i]\n\t\t\tif pos[0] < 0 || pos[1] >= 8\n\t\t\t\tmove_down_right = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_down_right = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_down_right = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\n\t\t# Checks how many spaces rook can move up & left\n\t\tmove_up_left = true\t\t\n\t\ti = 1\t\n\t\twhile move_up_left && i < 8\n\t\t\tpos = [y+i, x-i]\n\t\t\tif pos[0] >= 8 || pos[1] < 0\t\n\t\t\t\tmove_up_left = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_up_left = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_up_left = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\n\t\t# Checks how many spaces rook can move down & left\n\t\tmove_down_left = true\t\t\n\t\ti = 1\t\n\t\twhile move_down_left && i < 8\n\t\t\tpos = [y-i, x-i]\n\t\t\tif pos[0] < 0 || pos[1] < 0\t\n\t\t\t\tmove_down_left = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_down_left = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_down_left = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\t\t\n\t\tcandidates\n\tend",
"def iposition(b, n, q)\n base = %w(R R R R R R)\n @board = %w(B B B B B B B B)\n # put the queen in its place in \"all-but-bishops\"\n base[queen(q)] = \"Q\"\n # put the knights in their place in \"all-but-bishops\"\n nights(n).each do |x|\n (x < queen(q) && base[x] = \"N\") or (base[x+1] = \"N\")\n end\n # place the King: substitute the middle Rook by a King\n # and finish (simpler than reading the code)\n king = false\n base.each_with_index do |p,i|\n (king == true and base[i] == \"R\" and base[i] = \"K\" and break)\n (p == \"R\" && king = true)\n end\n\n # and now put the bishops in place, ie: keeping the\n # bishops in their place, put all the other pieces\n # in their order\n minus = 0\n bish = bishop(b)\n (0..7).each do |i|\n if bish.include?(i)\n minus += 1\n next\n end\n @board[i] = base[i-minus]\n end\n return @board\n end",
"def gen_bishop_moves(color, piece=:bishop)\n moves = []\n if color == :white\n position = @position.white \n comrades = @position.white_pieces\n enemy = @position.black_pieces\n else\n position = @position.black\n comrades = @position.black_pieces\n enemy = @position.white_pieces\n end\n\n # no work to do when there are no pieces\n return moves if position[piece].nil?\n \n # for each piece\n position[piece].set_bits.each do |from| \n # [i,j] = current position\n i = from / 8\n j = from % 8\n\n #dirs flags which directions the piece is blocked\n dirs = 0\n for k in 1..7\n break if dirs == 0xf\n \n # try moving north-east\n if (dirs & 0x1) != 0x1\n to = from+k*9\n if i+k>7 || j+k>7 || comrades.set?(to)\n # no further north-east moves possible\n dirs = dirs | 0x1\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further north moves possible\n dirs = dirs | 0x1 if enemy.set?(to) \n end\n end\n \n # try moving south-west\n if (dirs & 0x2) != 0x2\n to = from-k*9\n if i<k || j<k || comrades.set?(to)\n # no further south-west moves possible\n dirs = dirs | 0x2\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further south-west moves possible\n dirs = dirs | 0x2 if enemy.set?(to) \n end\n end\n \n # try moving north-west\n if (dirs & 0x4) != 0x4\n to = from+k*7\n if i+k>7 || j<k || comrades.set?(to)\n # no further north-west moves possible\n dirs = dirs | 0x4\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further north-west moves possible\n dirs = dirs | 0x4 if enemy.set?(to) \n end\n end \n \n # try moving south-east\n if (dirs & 0x8) != 0x8\n to = from-k*7\n if i<k || j+k>7 || comrades.set?(to)\n # no further south-east moves possible\n dirs = dirs | 0x8\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further south-east moves possible\n dirs = dirs | 0x8 if enemy.set?(to) \n end\n end\n \n end\n end \n moves\n end",
"def move( from_square, to_square, promote_to = nil )\n\t\t\t@squares[to_square] = @squares[from_square]\n\t\t\t@squares[from_square] = nil\n\t\t\n\t\t\t@squares[to_square].square = to_square\n\n\t\t\t# handle en-passant captures\n\t\t\tif @squares[to_square].is_a?(Pawn) and to_square == @en_passant\n\t\t\t\t@squares[\"#{to_square[0, 1]}#{from_square[1, 1]}\"] = nil\n\t\t\tend\n\t\t\t# track last move for future en-passant captures\n\t\t\tif @squares[to_square].is_a?(Pawn) and\n\t\t\t (from_square[1, 1].to_i - to_square[1, 1].to_i).abs == 2\n\t\t\t\tif from_square[1, 1] == \"2\"\n\t\t\t\t\t@en_passant = \"#{from_square[0, 1]}3\"\n\t\t\t\telse\n\t\t\t\t\t@en_passant = \"#{from_square[0, 1]}6\"\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t@en_passant = nil\n\t\t\tend\n\t\t\t\n\t\t\tif @squares[to_square].is_a?(King) and # queenside castles\n\t\t\t from_square[0, 1] == \"e\" and to_square[0, 1] == \"c\"\n\t\t\t\trank = to_square[1, 1]\n\t\t\t\t@squares[\"d#{rank}\"] = @squares[\"a#{rank}\"]\n\t\t\t\t@squares[\"a#{rank}\"] = nil\n\n\t\t\t\t@squares[\"d#{rank}\"].square = \"d#{rank}\"\n\t\t\telsif @squares[to_square].is_a?(King) and # kingside castles\n\t\t\t from_square[0, 1] == \"e\" and to_square[0, 1] == \"g\"\n\t\t\t\trank = to_square[1, 1]\n\t\t\t\t@squares[\"f#{rank}\"] = @squares[\"h#{rank}\"]\n\t\t\t \t@squares[\"h#{rank}\"] = nil\n\n\t\t\t\t@squares[\"f#{rank}\"].square = \"f#{rank}\"\n\t\t\telsif not promote_to.nil? # pawn promotion\n\t\t\t\t@squares[to_square] = promote_to.new(self, to_square, @turn)\n\t\t\tend\n\t\t\t\n\t\t\t# advance the turn indicator\n\t\t\tnext_turn\n\t\t\t\n\t\t\tself\n\t\tend",
"def valid_black_rook(start,dest)\n x = start[0]; y = start[1]\n x1 = dest[0]; y1 = dest[1]\n\n xtrans = x\n ytrans = y\n\n return false if black_owned(x1,y1)\n\n #Getting the one space moves for the square around the rook\n if x1 == x+1 && y1 == y\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x-1 && y1 == y\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x && y1 == y+1\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x && y1 == y-1\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n end\n\n #The spaces that are +1 further away\n if x1 > x+1 && y1 == y\n while xtrans < x1-1 do\n xtrans += 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 < x-1 && y1 == y\n while xtrans > x1+1 do\n xtrans -= 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x && y1 > y+1\n while ytrans < y1-1 do\n ytrans += 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x && y1 < y-1\n while ytrans > y1+1 do\n ytrans -= 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n end\n return false\n end",
"def long_castling?(rook)\n return false unless rook.instance_of?(Rook)\n\n king = rook.COLOR == 'black' ? board[0][4].piece : board[7][4].piece\n return false unless king.instance_of?(King)\n\n og_pos = king.position\n color = rook.COLOR == 'black' ? 'white' : 'black'\n pieces = get_pieces_by_color(color)\n result = nil\n\n # Return false if kign and rook have move, the square between them aren't empty and king is in check\n\n return false if !king.number_of_move.zero? || !rook.number_of_move.zero? || king.check?(pieces) || !board[king.position[0]][king.position[1] - 1].piece.nil? || !board[king.position[0]][king.position[1] - 2].piece.nil?\n\n # This loop check that any piece can move to the square between rook and king. Move king temporaly.\n\n 1.upto(2) do |num|\n\n board[og_pos[0]][og_pos[1] - num].piece = king\n board[og_pos[0]][og_pos[1] - num].piece.position = [og_pos[0], og_pos[1] - num]\n update_possible_movement_all_pieces()\n\n result = board[king.position[0]][king.position[1]].piece.check?(pieces)\n board[king.position[0]][king.position[1]].piece = nil\n \n break if result\n end\n\n # Restore king to his original position\n\n board[og_pos[0]][og_pos[1]].piece.position = og_pos\n update_possible_movement_all_pieces()\n\n !result\n end",
"def possible_rook_moves(start_arr)\n\t\tx = start_arr[1]\n\t\ty = start_arr[0]\n\t\tcandidates = []\n\t\t# Checks how many spaces rook can move up\n\t\tmove_up = true\n\t\ti = 1\t\t\n\t\twhile move_up && i < 8\n\t\t\tpos = [y+i, x]\n\t\t\tif pos[0] >= 8\t\n\t\t\t\tmove_up = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_up = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_up = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\n\t\t# Checks how many spaces rook can move down\n\t\tmove_down = true\t\t\n\t\ti = 1\t\n\t\twhile move_down && i < 8\n\t\t\tpos = [y-i, x]\n\t\t\tif pos[0] < 0\t\n\t\t\t\tmove_down = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_down = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_down = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\n\t\t# Checks how many spaces rook can move right\n\t\tmove_right = true\t\t\n\t\ti = 1\t\n\t\twhile move_right && i < 8\n\t\t\tpos = [y, x+1]\n\t\t\tif pos[1] > 7\t\n\t\t\t\tmove_right = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_right = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_right = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\n\t\t# Checks how many spaces rook can move left\n\t\tmove_left = true\t\t\n\t\ti = 1\t\n\t\twhile move_left && i < 8\n\t\t\tpos = [y, x+1]\n\t\t\tif pos[1] > 7\t\n\t\t\t\tmove_left = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_left = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_left = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\t\t\n\t\tcandidates\n\tend",
"def valid_white_rook(start,dest)\n x = start[0]; y = start[1]\n x1 = dest[0]; y1 = dest[1]\n\n xtrans = x\n ytrans = y\n\n return false if white_owned(x1,y1)\n\n #Getting the one space moves for the square around the rook\n if x1 == x+1 && y1 == y\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 == x-1 && y1 == y\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 == x && y1 == y+1\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 == x && y1 == y-1\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n end\n\n #The spaces that are +1 further away\n if x1 > x+1 && y1 == y\n while xtrans < x1-1 do\n xtrans += 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 < x-1 && y1 == y\n while xtrans > x1+1 do\n xtrans -= 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 == x && y1 > y+1\n while ytrans < y1-1 do\n ytrans += 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n elsif x1 == x && y1 < y-1\n while ytrans > y1+1 do\n ytrans -= 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @black_piece.push(@b[x1][y1]) if black_owned(x1,y1)\n @b[x][y] = \" \"\n @wht_rook_left_move = true if x == 0 && y == 0\n @wht_rook_right_move = true if x == 7 && y == 0\n @b[x1][y1] = @WR\n return true\n end\n return false\n end",
"def moves_rook(color, a, b)\n \t_moves = []\n \t(continue_up(color, a, b)).each{|move| _moves << move} \n \t(continue_down(color, a, b)).each{|move| _moves << move}\n \t(continue_right(color, a, b)).each{|move| _moves << move}\n \t(continue_left(color, a, b)).each{|move| _moves << move}\n \t_moves.compact\n end",
"def place_bishops\r\n $board[2][0] = Bishop.new('white')\r\n\t\t$board[5][0] = Bishop.new('white')\r\n\t\t$board[2][7] = Bishop.new('black')\r\n\t\t$board[5][7] = Bishop.new('black')\r\n end",
"def moves_bishop(color, a, b)\n\t\t_moves = []\n\t\t(continue_up_right(color, a, b)).each{|move| _moves << move}\n\t\t(continue_up_left(color, a, b)).each{|move| _moves << move}\n\t\t(continue_down_right(color, a, b)).each{|move| _moves << move} \n\t\t(continue_down_left(color, a, b)).each{|move| _moves << move}\n\t\t_moves.compact\n end",
"def gen_rook_moves(color, piece=:rook)\n moves = []\n if color == :white\n position = @position.white \n comrades = @position.white_pieces\n enemy = @position.black_pieces\n else\n position = @position.black\n comrades = @position.black_pieces\n enemy = @position.white_pieces\n end\n\n # no work to do when there are no pieces\n return moves if position[piece].nil?\n \n # for each piece\n position[piece].set_bits.each do |from| \n # [i,j] = current position\n i = from / 8\n j = from % 8\n\n #dirs flags which directions the piece is blocked\n dirs = 0\n for k in 1..7\n break if dirs == 0xf\n \n # try moving north\n if (dirs & 0x1) != 0x1\n to = from+k*8\n if i+k>7 || comrades.set?(to)\n # no further north moves possible\n dirs = dirs | 0x1\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further north moves possible\n dirs = dirs | 0x1 if enemy.set?(to) \n end\n end\n \n # try moving south\n if (dirs & 0x2) != 0x2\n to = from-k*8\n if i<k || comrades.set?(to)\n # no further south moves possible\n dirs = dirs | 0x2\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further north moves possible\n dirs = dirs | 0x2 if enemy.set?(to) \n end\n end\n \n # try moving east\n if (dirs & 0x4) != 0x4\n to = from+k\n if j+k>7 || comrades.set?(to)\n # no further east moves possible\n dirs = dirs | 0x4\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further east moves possible\n dirs = dirs | 0x4 if enemy.set?(to) \n end\n end\n \n # try moving west\n if (dirs & 0x8) != 0x8\n to = from-k\n if j-k<0 || comrades.set?(to)\n # no further east moves possible\n dirs = dirs | 0x8\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further west moves possible\n dirs = dirs | 0x8 if enemy.set?(to) \n end\n end \n end\n end \n moves\n end",
"def possible_queen_moves(start_arr)\n\t\tchildren = []\n\t\tchildren << possible_rook_moves(start_arr)\n\t\tchildren << possible_bishop_moves(start_arr)\n\t\tchildren = children.flatten(1)\n\tend",
"def next_state(state, move)\n # Deep copy position (is this the easiest way?)\n position = Marshal.load(Marshal.dump(state[:position]))\n player = state[:player]\n opp = opponent(player)\n pieces = Marshal.load(Marshal.dump(state[:pieces]))\n from = move[0]\n to = move[1]\n force_analysis = false\n check = false\n moving_piece = pieces[player].find { |piece| piece.location == from }\n if !moving_piece\n puts \"ERROR--no piece to move!\"\n end\n # Check for capture\n if position[to[0]][to[1]] != \".\"\n # Remove enemy piece\n pieces[opp].delete_if { |piece| piece.location == to }\n # Force AI to continue analysis\n force_analysis = true\n end\n # Check for promotion\n if moving_piece.class == Pawn && to[0] == end_row(player)\n # Replace pawn with queen\n # (Underpromotion not yet implemented)\n pieces[player].delete(moving_piece)\n moving_piece = Queen.new(self, to, player)\n pieces[player] << moving_piece\n end\n # Move piece\n position[from[0]][from[1]] = \".\"\n position[to[0]][to[1]] = moving_piece.icon\n moving_piece.location = to\n # Complete castling by moving rook\n if moving_piece.class == ChessKing && (from[1] - to[1]).abs == 2\n rook_column = to[1] == 6 ? 7 : 0\n castling_rook = pieces[player].find { |piece| piece.location == [from[0], rook_column] }\n if castling_rook\n rook_dest = to[1] == 6 ? 5 : 3\n position[from[0]][rook_column] = \".\"\n position[to[0]][rook_dest] = castling_rook.icon\n castling_rook.location = [to[0], rook_dest]\n else\n puts \"Castling error -- can't find rook!\"\n end\n end\n # Switch active player\n next_player = opp\n # # Create new state for testing whether king is in check\n # new_position_state = {\n # :position => position,\n # :player => player,\n # :pieces => pieces,\n # :check => false,\n # :force_analysis => false\n # }\n # # Test whether opponent's king is now in check\n # check = check?(new_position_state)\n # force_analysis = true if check\n # Return new state\n {\n :position => position,\n :player => next_player,\n :pieces => pieces,\n :check => check,\n :force_analysis => force_analysis\n }\n end",
"def knight_moves(src_sqr = [0, 0], tgt_sqr = [0, 0])\n # Init the board and a Knight piece\n board = Board.new\n knight = Knight.new\n \n puts \"\\nFrom #{src_sqr} to #{tgt_sqr}...\"\n \n unless board.valid_position?(src_sqr[0], src_sqr[1]) && board.valid_position?(tgt_sqr[0], tgt_sqr[1])\n puts \"Invalid starting or ending positions!\\nPlease, provide only valid positions in range [0, 0] to [7, 7] to find a solution!\"\n\treturn\n end\n \n # Mark the source square on the board and set its distance to 0\n board.mark_square(src_sqr[0], src_sqr[1], knight.to_sym)\n board.set_square_distance(src_sqr[0], src_sqr[1], 0)\n # Enqueue the source square\n queue = [src_sqr]\n \n # BFS algorithm \n while !queue.empty?\n cur_sqr = queue.shift \n \n\tbreak if cur_sqr == tgt_sqr\n\t\n # Get all possible moves from current position\t\n\tknight.set_position(cur_sqr[0], cur_sqr[1])\n\tknight.get_possible_moves.each do |move| \n\t next unless board.is_square_empty?(move[0], move[1]) \n\t \n\t # Enqueue all possible moves whose related squares are not visited yet\n\t queue << move \n\t board.mark_square(move[0], move[1], knight.to_sym)\n\t board.set_square_distance(move[0], move[1], board.get_square_distance(cur_sqr[0], cur_sqr[1]) + 1)\n\t board.set_square_parent(move[0], move[1], cur_sqr)\n\tend\n end\n \n # Build the reverse path from src_sqr to tgt_sqr, starting from tgt_sqr\n path = [tgt_sqr]\n parent = board.get_square_parent(tgt_sqr[0], tgt_sqr[1])\n while !parent.nil?\n path << parent\n\tparent = board.get_square_parent(parent[0], parent[1])\n end\n \n # Print the solution\n puts \"Solution obtained in #{path.length - 1} move#{path.length - 1 != 1 ? 's' : ''}! The path is:\"\n path.reverse.each {|move| p move}\n \nend",
"def gen_king_moves white\n\t\tmoves = []\n\t\tkings = @bitboards[white ? WKING : BKING]\n\t\tbits_to_positions(kings).each do |king|\n\t\t\tmoves += gen_rook_type_moves( white, king, 1)\n\t\t\tmoves += gen_bishop_type_moves( white, king, 1)\n\t\t\tmoves += gen_castle_moves( white, king)\n\t\tend\n\t\tmoves\n\tend",
"def play_move!( m )\n self.delete_if { |pos, piece| pos == m.to_coord || pos == m.captured_piece_coord }\n\n piece_moved = self.delete(m.from_coord)\n self[m.to_coord] = piece_moved\n\n if m.castled==1\n castling_rank = m.to_coord.rank.to_s\n [['g', 'f', 'h'], ['c', 'd', 'a']].each do |king_file, new_rook_file, orig_rook_file|\n #update the position of the rook corresponding to the square the king landed on\n\tif m.to_coord.file == king_file \n\t rook = self.delete(\"#{orig_rook_file}#{castling_rank}\")\n\t self[\"#{new_rook_file}#{castling_rank}\"] = rook\n\tend\n end\n end\n \n #TODO investigate why this method is getting called multiply per moves << Move.new\n return unless piece_moved\n ep_from_rank, ep_to_rank, ep_rank = EN_PASSANT_CONFIG[ piece_moved.side ]\n @en_passant_square = ( piece_moved.function == :pawn &&\n m.from_coord.rank == ep_from_rank && \n m.to_coord.rank == ep_to_rank ) ? m.from_coord.file + ep_rank.to_s : nil\n\n #reflect promotion\n if piece_moved && piece_moved.function == :pawn && m.to_coord.to_s.rank == piece_moved.promotion_rank\n self.delete(m.to_coord)\n self[m.to_coord] = Queen.new(piece_moved.side, :promoted)\n #puts self.to_s if m.to_coord == 'a8'\n #debugger if m.to_coord == 'a8'\n end\n \n self\n end",
"def move_pile(play1, play2)\n if play2.empty?\n play2.concat(play1)\n play1.clear\n elsif (within_one?(play1[0].rank.to_i, play2[-1].rank.to_i))\n play2.concat(play1)\n play1.clear\n else\n end\nend",
"def castle_rook_queenside\n @castle_rook_queenside = game.pieces.where(x_position: 0 , y_position: y_position, user_id: user_id, type: 'Rook').first\n end",
"def branches\n @board.free_moves.map do |pos|\n move pos\n end.compact\n end",
"def move(dest, crown?) # called in :turn > active_piece.move()\n # updates dest in board array\n # updates piece with new coordinates\n # updates jumped pieces?\nend",
"def move_piece!(start_pos, end_pos)\n null = NullPiece.instance\n if self[start_pos].class == King\n if self[start_pos].color == :black\n @black_king_pos = end_pos\n else\n @white_king_pos = end_pos\n end\n end\n if pawn_promotion?(start_pos, end_pos)\n color = self[start_pos].color\n self[start_pos] = null\n Queen.new(self, end_pos, color)\n else\n self[start_pos].pos = end_pos\n self[end_pos], self[start_pos] = self[start_pos], null\n end\n end",
"def knight_moves\n\t\tnode = Square.new(@start)\n\t\t@queue << node\n\t\twhile @queue.empty? == false\n\t\t\tcurrent = @queue[0]\n\t\t\tif current.value == @final\n\t\t\t\tdisplay_result(current)\t\t\t\n\t\t\telse\n\n\t\t\t\t8.times do |num|\n\t\t\t\t\tx = current.value[0] + @row[num]\n\t\t\t\t\ty = current.value[1] + @col[num]\n\t\t\t\t\tif (x.between?(1,8) && y.between?(1,8)) && @revised.include?([x, y]) == false\n\t\t\t\t\t\tnode = Square.new([x, y])\n\t\t\t\t\t\tnode.parent = current\n\t\t\t\t\t\tnode.count = current.count + 1\n\t\t\t\t\t\t@queue << node\n\t\t\t\t\telse\n\t\t\t\t\t\tnext\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t@revised << current.value\n\t\t\t\t@queue.shift\n\t\t\tend\n\t\tend\n\t\tputs \"NOT FOUND !!!\"\n\t\tputs \"This program presumes a 8x8 Chess Board\"\n\t\tputs \"Therefore your coordinates must be between (1, 1) and (8, 8).\"\n\tend",
"def place_queens(column=0, row=0, queen_count=8)\n square = board.select_column(column)[row]\n board.place_queen(square)\n\n next_column = board.select_column(column + 1)\n if\n if board.next_empty_square\n place_queens\n else\n board.remove_queen(square)\n square.status = :tried\n return\n end\n end\nend",
"def run(n)\n return \"Really? Run me with a real number greater than 3!\" if n<4\n @board = GameBoard.build(n,n) {|i| i = 0}\n @board.row(0).each_index {|c| @board.new_queen([0,c])}\n @last_move=nil\n z = 0\n witty_remarks = [\"Working...\",\"Busy...\",\"Reticulating splines...\",\"Counting vector articulation...\",\"Pleasing the masses...\",\"Getting a coffee...\",\"Finding a safe place...\",\"Moving...\",\"There's #{n} queens in the room, it's gonna be a while...\",\"Being greedy...\"]\n while true\n max_collisions = @board.queens.max_by {|x| x.collisions}.collisions\n problem_queens = @board.queens.select {|x| x.collisions == max_collisions}.shuffle\n if problem_queens.size > 1\n queen = problem_queens.select {|x| x.position[1]!=@last_move}.last\n else\n queen = problem_queens.first\n end\n if queen.move_count > (n*100)/10\n # print \"~\"\n @board.queens.each do |e|\n r = Random.rand(n)\n until r!=e.position[0]\n r = Random.rand(n)\n end\n e.move_to(r,e.position[1])\n e.reset_move_count\n end\n next\n end\n # print \"*\"\n puts witty_remarks.shuffle.first if z%200==0 && z>0\n if queen.collisions == 0\n print \"\\n\"\n puts \"WIN!\"\n puts @board.valid_move_mask.pretty\n break\n end\n move = @board.best_available_position(queen.position)\n @last_move=move[1]\n @board[*queen.position].move_to(*move)\n z+=1\n end\n\n @board\nend",
"def bishop_check(board, current, destination)\n tx = 0\n ty = 0\n ob = 0\n temp = nil\n if current[0] < destination[0] && current[1] < destination[1]\n tx = current[0] + 1\n ty = current[1] + 1\n array_to_check = [tx, ty]\n while tx <= destination[0] && ty <= destination[1]\n board.array.each do |item|\n puts 'k' if item.coord == array_to_check\n if item.coord == array_to_check\n unless item.piece_status.nil?\n puts'gudda kathalu 2'\n ob = 1\n return false\n end\n end\n tx += 1\n ty += 1\n end\n next unless ob == 0\n end\n board.array.each do |item|\n if item.coord == current\n temp = item.piece_status\n item.piece_status = nil\n end\n item.piece_status = temp if item.coord == destination\n end\n elsif current[0] > destination[0] && current[1] < destination[1]\n tx = current[0] - 1\n ty = current[1] + 1\n array_to_check = [tx, ty]\n while tx >= destination[0] && ty <= destination[1]\n board.array.each do |item|\n puts 'k' if item.coord == array_to_check\n if item.coord == array_to_check\n unless item.piece_status.nil?\n puts'gudda kathalu 2'\n ob = 1\n return false\n end\n end\n tx -= 1\n ty += 1\n end\n next unless ob == 0\n end\n board.array.each do |item|\n if item.coord == current\n temp = item.piece_status\n item.piece_status = nil\n end\n item.piece_status = temp if item.coord == destination\n end\n elsif current[0] < destination[0] && current[1] > destination[1]\n tx = current[0] + 1\n ty = current[1] - 1\n array_to_check = [tx, ty]\n while tx <= destination[0] && ty >= destination[1]\n board.array.each do |item|\n puts 'k' if item.coord == array_to_check\n if item.coord == array_to_check\n unless item.piece_status.nil?\n puts'gudda kathalu 2'\n ob = 1\n return false\n end\n end\n tx += 1\n ty -= 1\n end\n next unless ob == 0\n end\n board.array.each do |item|\n if item.coord == current\n temp = item.piece_status\n item.piece_status = nil\n end\n item.piece_status = temp if item.coord == destination\n end\n\n elsif current[0] > destination[0] && current[1] > destination[1]\n tx = current[0] - 1\n ty = current[1] - 1\n array_to_check = [tx, ty]\n while tx <= destination[0] && ty >= destination[1]\n board.array.each do |item|\n puts 'k' if item.coord == array_to_check\n if item.coord == array_to_check\n unless item.piece_status.nil?\n puts'gudda kathalu 2'\n ob = 1\n return false\n end\n end\n tx -= 1\n ty -= 1\n end\n next unless ob == 0\n end\n board.array.each do |item|\n if item.coord == current\n temp = item.piece_status\n item.piece_status = nil\n end\n item.piece_status = temp if item.coord == destination\n end\n end\n board\nend",
"def moves\n # All pieces can stay in place\n [[0,0]]\n end",
"def castling_moves(pos, board)\n return [] if @owner.check || pos[1] != 4 || !@owner.can_castle\n\n home_rank = (0..7).map { |index| board.locate_piece([pos[0], index]) }\n [castle_queenside(home_rank[0..3], pos, board), castle_kingside(home_rank[5..7], pos, board)].compact\n end",
"def test_move_turns_matzburgh\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_matzburgh\n assert_includes ['Monkey Patch City', 'Duck Type Beach', 'Hash Crossing', 'Dynamic Palisades'], ruby_rush.city\n end",
"def put_black\n i = 0\n while i<=7 do\n n = Pawn.new([i,6],\"\\u265F\",false)\n put_piece(n)\n i+=1\n end\n n = Rook.new([0,7],\"\\u265C\",false)\n put_piece(n)\n n = Rook.new([7,7],\"\\u265C\",false)\n put_piece(n)\n n = Knight.new([1,7],\"\\u265E\",false)\n put_piece(n)\n n = Knight.new([6,7],\"\\u265E\",false)\n put_piece(n)\n n = Bishop.new([2,7],\"\\u265D\",false)\n put_piece(n)\n n = Bishop.new([5,7],\"\\u265D\",false)\n put_piece(n)\n n = Queen.new([3,7],\"\\u265B\",false)\n put_piece(n)\n n = King.new([4,7],\"\\u265A\",false)\n put_piece(n,true)\n end",
"def moves_pawn(color, a, b)\n \t_moves = []\n \tif color == :white\n \t\tif @board[a][b].piece.double == \"true\"\n \t\t\t_moves << [a, b + 2] if @board[a][b + 2].piece == nil \t\t\n \t\tend\n\n \t\tx, y = up(a, b)\n \t\tif off_board(x, y) == false\n \t\t\t_moves << up(a, b) if @board[x][y].piece == nil\n \t\tend\n\n \t\tx, y = up_left(a, b)\n \t\tif off_board(x, y) == false\n \t\t\t_moves << up_left(a, b) if (@board[x][y].piece != nil && @board[x][y].piece.color != color) || en_passant_left(a, b)\n \t\tend\n \t\t\n \t\tx, y = up_right(a, b)\n \t\tif off_board(x, y) == false\n \t\t\t_moves << up_right(a, b) if (@board[x][y].piece != nil && @board[x][y].piece.color != color) || en_passant_right(a, b)\n \t\tend\n\n \telse\n \t\tif @board[a][b].piece.double == \"true\"\n \t\t\t_moves << [a, b - 2] if @board[a][b - 2].piece == nil\n \t\tend\n\n \t\tx, y = down(a, b)\n \t\tif off_board(x, y) == false\n \t\t\t_moves << down(a, b) if @board[x][y].piece == nil\n \t\tend\n\n \t\tx, y = down_left(a, b)\n \t\tif off_board(x, y) == false\n \t\t\t_moves << down_left(a, b) if (@board[x][y].piece != nil || @board[a][b].piece.color != color) || en_passant_left(a, b)\n \t\tend\n\n \t\tx, y = down_right(a, b)\n \t\tif off_board(x, y) == false\n \t\t\t_moves << down_right(a, b) if (@board[x][y].piece != nil || @board[a][b].piece.color != color) || en_passant_right(a, b)\n \t\tend\n \tend\n \treturn _moves.compact\n end",
"def place_rooks\r\n $board[0][0] = Rook.new('white')\r\n\t\t$board[7][0] = Rook.new('white')\r\n\t\t$board[0][7] = Rook.new('black')\r\n\t\t$board[7][7] = Rook.new('black')\r\n end",
"def move_castling(short, color)\n\n if short\n if color == 'black'\n board[0][5].piece, board[0][6].piece = board[0][7].piece, board[0][4].piece\n board[0][7].piece, board[0][4].piece = nil, nil\n board[0][5].piece.position, board[0][6].piece.position = [0,5], [0,6]\n update_possible_movement_all_pieces()\n turns[board[0][5].piece.COLOR.to_sym] += 1\n board[0][5].piece.number_of_move += 1 if board[0][5].piece.instance_of?(Rook)\n board[0][6].piece.number_of_move += 1 if board[0][6].piece.instance_of?(King)\n \n return board[0][5].piece\n else\n board[7][5].piece, board[7][6].piece = board[7][7].piece, board[7][4].piece\n board[7][7].piece, board[7][4].piece = nil, nil\n board[7][5].piece.position, board[7][6].piece.position = [7,5], [7,6]\n update_possible_movement_all_pieces()\n turns[board[7][5].piece.COLOR.to_sym] += 1\n board[7][5].piece.number_of_move += 1 if board[7][5].piece.instance_of?(Rook)\n board[7][6].piece.number_of_move += 1 if board[7][6].piece.instance_of?(King)\n \n return board[7][5].piece\n end\n else\n if color == 'black'\n board[0][3].piece, board[0][2].piece = board[0][0].piece, board[0][4].piece\n board[0][0].piece, board[0][4].piece = nil, nil\n board[0][3].piece.position, board[0][2].piece.position = [0,3], [0,2]\n update_possible_movement_all_pieces()\n\n turns[board[0][3].piece.COLOR.to_sym] += 1\n board[0][3].piece.number_of_move += 1 if board[0][3].piece.instance_of?(Rook)\n board[0][2].piece.number_of_move += 1 if board[0][2].piece.instance_of?(King)\n\n return board[0][3].piece\n else\n board[7][3].piece, board[7][2].piece = board[7][0].piece, board[7][4].piece\n board[7][0].piece, board[7][4].piece = nil, nil\n board[7][3].piece.position, board[7][2].piece.position = [7,3], [7,2]\n update_possible_movement_all_pieces()\n \n turns[board[7][3].piece.COLOR.to_sym] += 1\n board[7][3].piece.number_of_move += 1 if board[7][3].piece.instance_of?(Rook)\n board[7][2].piece.number_of_move += 1 if board[7][2].piece.instance_of?(King)\n\n return board[7][3].piece\n end\n end\n\n end",
"def moves\r\n # pos = [0,0]\r\n # row, col = pos\r\n all_h = []\r\n all_d = []\r\n HORIZONTAL_DIRS.each do |h_pos|\r\n h_row, h_col = h_pos\r\n all_h += grow_unblocked_moves_in_dir(h_row, h_col) #returns all moves in h_pos\r\n end\r\n DIAGONAL_DIRS.each do |d_pos|\r\n h_row, h_col = d_pos\r\n all_d += grow_unblocked_moves_in_dir(h_row, h_col) #returns all moves in d_pos\r\n end\r\n if self.class == Queen\r\n return all_h + all_d\r\n elsif self.class == Bishop\r\n return all_d\r\n elsif self.class == Rook\r\n return all_h\r\n end\r\n end",
"def moves_king(color, a, b, check)\n\t\t_moves = []\n\t\t(_moves << up(a, b) << down(a, b) << left(a, b) << right(a, b) << up_right(a, b) << up_left(a, b) << down_right(a, b) << down_left(a, b))\n\t\t_moves.map! do |spot|\n\t\t\tx, y = spot\n\t\t\tnext if (x < 0 || x > 7 || y < 0 || y > 7)\n\t\t\tspot if @board[x][y].piece == nil || @board[x][y].piece.color != color\n\t\tend\n\t\t_moves << ([a + 2, b] if castling_right(a, b, check) == true) << ([a - 2, b] if castling_left(a, b, check) == true)\n\t\t_moves.compact\n\tend",
"def test_move_turns_hash_crossing\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_hash_crossing\n assert_includes ['Matzburg', 'Nil Town', 'Dynamic Palisades'], ruby_rush.city\n end",
"def get_moves_2(piece, board)\n valid_col = case piece.name\n when ?A then 3\n when ?B then 5\n when ?C then 7\n when ?D then 9\n else 11\n end\n moves = []\n\n # If in hallway\n if piece.row == 1\n cols = valid_col < piece.col ? (valid_col...piece.col).to_a : (piece.col+1..valid_col).to_a\n if cols.count{|c| board[[1, c]] == ?.} == cols.length\n if board[[2, valid_col]] == ?. && board[[3, valid_col]] == piece.name && board[[4, valid_col]] == piece.name && board[[5, valid_col]] == piece.name\n moves << [[2, valid_col], (cols.count + 1) * piece.cost]\n elsif board[[2, valid_col]] == ?. && board[[3, valid_col]] == ?. && board[[4, valid_col]] == piece.name && board[[5, valid_col]] == piece.name\n moves << [[3, valid_col], (cols.count + 2) * piece.cost]\n elsif board[[2, valid_col]] == ?. && board[[3, valid_col]] == ?. && board[[4, valid_col]] == ?. && board[[5, valid_col]] == piece.name\n moves << [[4, valid_col], (cols.count + 3) * piece.cost]\n elsif board[[2, valid_col]] == ?. && board[[3, valid_col]] == ?. && board[[4, valid_col]] == ?. && board[[5, valid_col]] == ?.\n moves << [[5, valid_col], (cols.count + 4) * piece.cost]\n end\n end\n # If right column and something is underneath and nothing above\n # If in wrong column completely and nothing above\n elsif piece.row >= 2\n below = (piece.row+1..5).to_a\n above = (2..piece.row-1).to_a\n if ((piece.col == valid_col && below.count{|c| board[[c, piece.col]] != piece.name} != 0 && below.length != 0) || (piece.col != valid_col)) && (above.count{|c| board[[c, piece.col]] == ?.} == above.length)\n 2.times do |t|\n dir = t == 0 ? -1 : 1\n curr = piece.col\n steps = 1 + above.length\n while board[[1, curr]] == ?.\n moves << [[1, curr], steps * piece.cost] if ![3, 5, 7, 9].include?(curr)\n steps += 1\n curr += dir\n end\n end\n end\n end\n moves\nend",
"def play_move(from, to)\n #create duplicate of board, to correct pass by reference error\n #add top disk on from tower to the top of to tower\n to_dup = @board[to].dup\n to_dup.unshift(@board[from][0]) \n @board[to] = to_dup\n @board[from].shift\n \n if won?\n render\n puts \"congratulations you won!\\n\\n\"\n else\n get_move\n end\n end",
"def valid_black_pawn(start,dest)\n x = start[0]; y = start[1]\n x1 = dest[0]; y1 = dest[1]\n\n pawncross = \"\"\n\n return false if black_owned(x1,y1)\n\n if x1 == x && y1 == y-1 && @b[x1][y1] == \" \"\n @b[x][y] = \" \"\n @b[x1][y1] = @BP\n if y1 == 0\n puts \"You made it to the other side! Choose: Queen 'Q' or Knight 'K'\"\n pawncross = gets.chomp\n pawncross.upcase!\n unless pawncross == \"K\" || pawncross == \"Q\"\n puts \"Please choose 'Q' for queen, or 'K' for knight\"\n pawncross = gets.chomp\n pawncross.upcase!\n end\n if pawncross == \"K\"\n @b[x1][y1] = @BK\n elsif pawncross == \"Q\"\n @b[x1][y1] = @BQ\n end\n end\n return true\n elsif x1 == x && y1 == y-2 && y == 6 && @b[x1][y1] == \" \" && @b[x][y-1] == \" \"\n @b[x][y] = \" \"\n @b[x1][y1] = @BP\n return true\n elsif x1 == x-1 && y1 == y-1 && white_owned(x1,y1)\n @white_piece.push(@b[x1][y1])\n @b[x1][y1] = @WP\n @b[x][y] = \" \"\n if y1 == 0\n puts \"You made it to the other side! Choose: Queen 'Q' or Knight 'K'\"\n pawncross = gets.chomp\n pawncross.upcase!\n unless pawncross == \"K\" || pawncross == \"Q\"\n puts \"Please choose 'Q' for queen, or 'K' for knight\"\n pawncross = gets.chomp\n pawncross.upcase!\n end\n if pawncross == \"K\"\n @b[x1][y1] = @BK\n elsif pawncross == \"Q\"\n @b[x1][y1] = @BQ\n end\n end\n return true\n elsif x1 == x+1 && y1 == y-1 && white_owned(x1,y1)\n @white_piece.push(@b[x1][y1])\n @b[x1][y1] = @BP\n @b[x][y] = \" \"\n if y1 == 0\n puts \"You made it to the other side! Choose: Queen 'Q' or Knight 'K'\"\n pawncross = gets.chomp\n pawncross.upcase!\n unless pawncross == \"K\" || pawncross == \"Q\"\n puts \"Please choose 'Q' for queen, or 'K' for knight\"\n pawncross = gets.chomp\n pawncross.upcase!\n end\n if pawncross == \"K\"\n @b[x1][y1] = @BK\n elsif pawncross == \"Q\"\n @b[x1][y1] = @BQ\n end\n end\n return true\n end\n return false\n end",
"def flag_moved_rook_or_king(board = gameboard.board_array)\n board.flatten.each do |space|\n space.has_moved = true if moved_rook_or_king?(space)\n end\n end",
"def move_piece(move)\n curr_piece = @board[move[0]]\n if curr_piece.non_check_moves.include?(move[1])\n #if en passant, remove captured piece\n if curr_piece.class == Pawn\n #puts curr_piece.can_en_passant?\n #puts \"HELKFDSJLFKD\"\n if curr_piece.can_en_passant?\n #puts \"HOMFDMSKFDFLSJFKDSLFJSDKLF JDSFKLSJFKLEJ FE FJSKLF\"\n rank = move[0][0]\n col = move[1][1]\n captured_pawn_pos = [rank,col]\n #puts captured_pawn_pos.inspect\n @board[captured_pawn_pos] = nil\n end\n end\n @board[move[1]] = curr_piece\n @board[move[0]] = nil\n curr_piece.move_history << move\n curr_piece.pos = move[1]\n #if castling, move rook too\n if curr_piece.class == King && (move[0][1] - move[1][1]).abs == 2\n #find the appropriate rook to move\n start_rank = move[0][0]\n start_file = move[1][1] == 2 ? 0 : 7\n start_pos = [start_rank, start_file]\n rook = @board[start_pos]\n #determine its final location, then move it.\n end_file = start_file == 0 ? 3 : 5\n end_pos = [start_rank, end_file]\n @board[end_pos] = rook\n @board[start_pos] = nil\n rook.move_history << end_pos\n rook.pos = end_pos\n end\n return true\n else\n puts \"Your king is still in check!\" if @board.in_check?(curr_piece.color)\n puts \"Not a legal move for this #{curr_piece.color} #{curr_piece.class}!\"\n puts\n return false\n end\n end",
"def move_castle(start_item, end_item)\n if start_item.type_piece !=:re\n raise \"castle move can't find the king\"\n end\n # move the king\n BoardInfoItem.exchange(start_item, end_item)\n # move the rook\n king_row = end_item.row_start\n king_end_col = end_item.column_start\n rook_start_col = 0\n if king_end_col == 6\n # short castle\n rook_start_col = 7\n rook_end_col = king_end_col - 1\n else\n # long castle\n rook_start_col = 0\n rook_end_col = king_end_col + 1\n end\n \n rook_start_item = @infosquare[king_row][rook_start_col]\n if rook_start_item.type_piece !=:torr\n raise \"castle can't find the rook\"\n end\n rook_end_item = @infosquare[king_row][rook_end_col]\n BoardInfoItem.exchange(rook_start_item, rook_end_item)\n end",
"def move_joker_b\n\t\t# find the index of the 'b' joker\n\t\tindex_b = @deck_of_cards.index(Card.new(:joker, 2))\n\t\t# if the 'b' joker is the last card in the deck, move it below the first card\n\t\tif index_b == 53\n\t\t\tjoker_b = @deck_of_cards.delete_at(index_b)\n\t\t\t@deck_of_cards.insert(2, joker_b)\n\n\t\t\t# new position of the 'b' joker\n\t\t\tnew_b = 2\n\t\telsif index_b == 52\n\t\t\t# if the 'b' joker is the second to last in the deck, move it below the first card\n\t\t\tjoker_b = @deck_of_cards.delete_at(index_b)\n\t\t\t@deck_of_cards.insert(1, joker_b)\n\n\t\t\t# new position of the 'b' joker\n\t\t\tnew_b = 1\n\t\telse # move the 'b' joker down two cards\n\t\t\t@deck_of_cards[index_b], @deck_of_cards[index_b + 1] = @deck_of_cards[index_b + 1], @deck_of_cards[index_b] \n\t\t\t@deck_of_cards[index_b + 1], @deck_of_cards[index_b + 2] = @deck_of_cards[index_b + 2], @deck_of_cards[index_b + 1]\n\t\t\t\n\t\t\t#new positon of the 'b' joker\n\t\t\tnew_b = index_b + 2\n\t\tend\n\tend",
"def explore\n rover_bay.each do |r|\n if pass_path_check?(r)\n move(r)\n else\n raise \"There is a collision\\nin placement #{r.coordinate.inspect}, please revise instruction set #{r.command.inspect}\"\n end\n end\n end",
"def output_moves(piece_type, location, moves)\n #setting up location coordinates\n location_coords = location.split(//)\n x = location_coords[0].ord - 96\n y = location_coords[1].to_i\n\n if x < 1 || y < 1 || y > 8 || x > 8 || location.length!=2\n puts 'please provide a valid location for the piece'\n exit\n end\n\n#calculating possible moves of rook\n all_possible_moves = moves[piece_type].flat_map do |move|\n (1..move[:steps]).collect do |step|\n new_x = x + (move[:x] * step)\n new_y = y + (move[:y] * step)\n [new_x, new_y]\n end\n end.sort do |m1, m2|\n c = (m1[1] <=> m2[1])\n c == 0 ? (m1[0] <=> m2[0]) : c\n end\n\n board_possible_moves = all_possible_moves.reject { |p| p[0] < 1 || p[1] < 1 || p[0] > 8 || p[1] > 8 }\n movesList = []\n board_possible_moves.collect { |m|\n x = (m[0] + 96).chr\n y = m[1]\n movesList<< x + y.to_s\n }\n movesList\nend",
"def moves_for_piece(board, src, check_forward=true)\n srcpiece = board[src[0]][src[1]]\n moves = []\n\n if srcpiece == 'b' or srcpiece == 'B'\n # check for down left jump\n if src[1] - 2 >= 0 and src[0] + 2 < board.length and src[1] - 2 >= 0\n r = src[0] + 2\n c = src[1] - 2\n\n if board[r][c] == ' ' and board[r - 1][c + 1].downcase == 'r'\n moves << [src, [r, c]]\n end\n end\n\n # check for down right jump\n if src[1] + 2 < board[0].length and src[0] + 2 < board.length and src[1] + 2 < board.length\n r = src[0] + 2\n c = src[1] + 2\n\n if board[r][c] == ' ' and board[r - 1][c - 1].downcase == 'r'\n moves << [src, [r, c]]\n end\n end\n\n # If the piece is a king\n if srcpiece == 'B'\n # check up left\n if src[1] - 2 >= 0 and src[0] - 2 >= 0 and src[1] - 2 >= 0\n r = src[0] - 2\n c = src[1] - 2\n\n if board[r][c] == ' ' and board[r + 1][c + 1].downcase == 'r'\n moves << [src, [r, c]]\n end\n end\n\n # check up right\n if src[1] + 2 <= board[0].length and src[0] - 2 >= 0 and src[1] + 2 < board.length\n r = src[0] - 2\n c = src[1] + 2\n\n if board[r][c] == ' ' and board[r + 1][c - 1].downcase == 'r'\n moves << [src, [r, c]]\n end\n end\n end\n\n elsif srcpiece == 'r' or srcpiece == 'R'\n # check for up left jump\n if src[1] - 2 >= 0 and src[0] - 2 >= 0 and src[1] - 2 >= 0\n r = src[0] - 2\n c = src[1] - 2\n\n if board[r][c] == ' ' and board[r + 1][c + 1].downcase == 'b'\n moves << [src, [r, c]]\n end\n end\n\n # check for up right jump\n if src[1] + 2 < board[0].length and src[0] - 2 >= 0 and src[1] + 2 < board.length\n r = src[0] - 2\n c = src[1] + 2\n\n if board[r][c] == ' ' and board[r + 1][c - 1].downcase == 'b'\n moves << [src, [r, c]]\n end\n end\n\n # If the piece is a king\n if srcpiece == 'R'\n # check down left\n if src[1] - 2 >= 0 and src[0] + 2 < board.length and src[1] - 2 >= 0\n r = src[0] + 2\n c = src[1] - 2\n\n if board[r][c] == ' ' and board[r - 1][c + 1].downcase == 'b'\n moves << [src, [r, c]]\n end\n end\n\n # check down right\n if src[1] + 2 <= board[0].length and src[0] + 2 < board.length and src[1] + 2 < board.length \n r = src[0] + 2\n c = src[1] + 2\n\n if board[r][c] == ' ' and board[r - 1][c - 1].downcase == 'b'\n moves << [src, [r, c]]\n end\n end\n end\n end\n \n # check for forward moves \n if moves.length == 0 and check_forward\n if srcpiece == 'b' or srcpiece == 'B'\n # check for down left jump\n if src[1] - 1 >= 0 and src[0] + 1 < board.length and src[1] - 1 >= 0\n r = src[0] + 1\n c = src[1] - 1\n\n if board[r][c] == ' '\n moves << [src, [r, c]]\n end\n end\n\n # check for down right jump\n if src[1] + 1 < board[0].length and src[0] + 1 < board.length and src[1] + 1 < board.length\n r = src[0] + 1\n c = src[1] + 1\n\n if board[r][c] == ' '\n moves << [src, [r, c]]\n end\n end\n\n # If the piece is a king\n if srcpiece == 'B'\n # check up left\n if src[1] - 1 >= 0 and src[0] - 1 >= 0 and src[1] - 1 >= 0\n r = src[0] - 1\n c = src[1] - 1\n\n if board[r][c] == ' '\n moves << [src, [r, c]]\n end\n end\n\n # check up right\n if src[1] + 1 <= board[0].length and src[0] - 1 >= 0 and src[1] + 1 < board.length\n r = src[0] - 1\n c = src[1] + 1\n\n if board[r][c] == ' '\n moves << [src, [r, c]]\n end\n end\n end\n\n elsif srcpiece == 'r' or srcpiece == 'R'\n # check for up left jump\n if src[1] - 1 >= 0 and src[0] - 1 >= 0 and src[1] - 1 >= 0\n r = src[0] - 1\n c = src[1] - 1\n\n if board[r][c] == ' '\n moves << [src, [r, c]]\n end\n end\n\n # check for up right jump\n if src[1] + 1 < board[0].length and src[0] - 1 >= 0 and src[1] + 1 < board.length\n r = src[0] - 1\n c = src[1] + 1\n\n if board[r][c] == ' '\n moves << [src, [r, c]]\n end\n end\n\n # If the piece is a king\n if srcpiece == 'R'\n # check down left\n if src[1] - 1 >= 0 and src[0] + 1 < board.length and src[1] - 1 >= 0\n r = src[0] + 1\n c = src[1] - 1\n\n if board[r][c] == ' '\n moves << [src, [r, c]]\n end\n end\n\n # check down right\n if src[1] + 1 < board[0].length and src[0] + 1 < board.length and src[1] + 1 < board.length \n r = src[0] + 1\n c = src[1] + 1\n\n if board[r][c] == ' '\n moves << [src, [r, c]]\n end\n end\n end\n end\n end\n \n return moves \n end",
"def move(start, finish)\n\t\ta, b = start\n\t\tx, y = finish\n\t\tif @board[a][b].piece.class.name == \"Pawn\"\n\t\t\t@board[a][b].piece.double = \"false\"\n\t\t\tif y - b == 2 || y - b == -2\n\t\t\t\t@board[a][b].piece.en_passant = true\n\t\t\tend\n\t\tend\n\t\tif @board[a][b].piece.class.name == \"King\" || @board[a][b].piece.class.name == \"Rook\"\n\t\t\t@board[a][b].piece.castling = false\n\t\tend\n\t\tif @board[a][b].piece.class.name == \"King\" && (x - a >= 2 || x - a <= 2)\n\t\t\tif (x - a >= 2)\n\t\t\t\tcastle_right(a, b, x, y)\n\t\t\telse\n\t\t\t\tcastle_left(a, b, x, y)\n\t\t\tend\n\t\t\treturn\n\t\tend\n\t\t@board[x][y].piece = @board[a][b].piece\n\t\t@board[a][b].piece = nil\n\t\tremove_en_passant(x, y)\n\t\tif @board[x][y].piece.class.name == \"Pawn\"\n\t\t\tcheck_promotion(x, y)\n\t\tend\n\tend",
"def move_castle(start_item, end_item)\r\n # move the king\r\n BoardInfoItem.exchange(start_item, end_item)\r\n # move the rook\r\n king_row = end_item.row\r\n king_end_col = end_item.col\r\n rook_start_col = 0\r\n if king_end_col == 6\r\n # short castle\r\n rook_start_col = 7\r\n rook_end_col = king_end_col - 1\r\n else\r\n # long castle\r\n rook_start_col = 0\r\n rook_end_col = king_end_col + 1\r\n end\r\n \r\n rook_start_item = @infosquare[king_row][rook_start_col]\r\n rook_end_item = @infosquare[king_row][rook_end_col]\r\n BoardInfoItem.exchange(rook_start_item, rook_end_item)\r\n end",
"def group_possible_moves_bishop(pm)\n result = []\n\n result << pm.select do |p|\n p[0] < position[0] && p[1] < position[1]\n end\n\n result << pm.select do |p|\n p[0] < position[0] && p[1] > position[1]\n end\n\n result << pm.select do |p|\n p[0] > position[0] && p[1] < position[1]\n end\n\n result << pm.select do |p|\n p[0] > position[0] && p[1] > position[1]\n end\n result[0].reverse!\n result[1].reverse!\n result\n end",
"def movement(row1, col1, board)\n\n possible_moves=Array.new\n if @color==\"white\"\n # checking square in front\n if row1+1<8 && board.get_square(row1+1,col1).occupied==false\n possible_moves <<[row1+1,col1]\n\n #checking 2 squares forward\n if @position==\"initial\" && !board.get_square(row1+2,col1).occupied\n possible_moves <<[row1+2,col1]\n end\n end\n\n # checking attacking squares\n if row1+1<8 && col1-1>=0\n atk_sq1 = board.get_square(row1+1,col1-1)\n\n if atk_sq1.occupied && atk_sq1.piece.color != @color || !atk_sq1.occupied && atk_sq1.en_passanted\n possible_moves <<[row1+1,col1-1]\n end\n end\n if row1+1<8 && col1+1<8\n atk_sq2 = board.get_square(row1+1,col1+1)\n if atk_sq2.occupied && atk_sq2.piece.color != @color || !atk_sq2.occupied && atk_sq2.en_passanted\n possible_moves <<[row1+1,col1+1]\n end\n end\n\n elsif @color==\"black\"\n # checking square in front\n if row1-1>=0 && board.get_square(row1-1,col1).occupied==false\n possible_moves <<[row1-1,col1]\n\n # checking for 2 squares forward\n if @position==\"initial\" && board.get_square(row1-2,col1).occupied==false\n possible_moves <<[row1-2,col1]\n end\n end\n\n # checking attacking squares\n if row1-1>=0 && col1-1>=0\n atk_sq1 = board.get_square(row1-1,col1-1)\n if (atk_sq1.occupied && atk_sq1.piece.color != @color) || (!atk_sq1.occupied && atk_sq1.en_passanted)\n possible_moves <<[row1-1,col1-1]\n end\n end\n if row1-1>=0 && col1+1<8\n atk_sq2 = board.get_square(row1-1,col1+1)\n if (atk_sq2.occupied && atk_sq2.piece.color != @color) || (!atk_sq2.occupied && atk_sq2.en_passanted)\n possible_moves <<[row1-1,col1+1]\n end\n end\n end\n\n #removing moves that go off the board\n possible_moves = possible_moves.select do |a|\n a[0]>=0 && a[0]<8 && a[1]>=0 && a[1]<8\n end\n\n return possible_moves\n\n end",
"def castle_move\r\n return false if @sx.abs != 2\r\n # If the king is moving two spaces to the left:\r\n if @x1 < @x0\r\n @target_rook = game.pieces.where(x_position: 1, y_position: @y0).first\r\n # If the king is moving two spaces to the right:\r\n else\r\n @target_rook = game.pieces.where(x_position: 8, y_position: @y0).first\r\n end\r\n return false if @target_rook.nil?\r\n # Neither the king nor the rook have moved:\r\n return false if !first_move? || !@target_rook.first_move?\r\n # Move the rook to the other side of the moved king:\r\n if @target_rook.x_position == 1\r\n @target_rook.update_attributes(x_position: 4)\r\n Move.create(game_id: game.id, piece_id: @target_rook.id, move_count: 1, old_x: 1, new_x: 4, old_y: @y0, new_y: @y0)\r\n else\r\n @target_rook.update_attributes(x_position: 6)\r\n Move.create(game_id: game.id, piece_id: @target_rook.id, move_count: 1, old_x: 8, new_x: 6, old_y: @y0, new_y: @y0)\r\n end\r\n true\r\n end",
"def valid_white_pawn(start,dest)\n x = start[0]; y = start[1]\n x1 = dest[0]; y1 = dest[1]\n\n pawncross = \"\"\n\n return false if white_owned(x1,y1)\n\n if x1 == x && y1 == y+1 && @b[x1][y1] == \" \"\n @b[x][y] = \" \"\n @b[x1][y1] = @WP\n if y1 == 7\n puts \"You made it to the other side! Choose: Queen 'Q' or Knight 'K'\"\n pawncross = gets.chomp\n pawncross.upcase!\n unless pawncross == \"K\" || pawncross == \"Q\"\n puts \"Please choose 'Q' for queen, or 'K' for knight\"\n pawncross = gets.chomp\n pawncross.upcase!\n end\n if pawncross == \"K\"\n @b[x1][y1] = @WK\n elsif pawncross == \"Q\"\n @b[x1][y1] = @WQ\n end\n end\n return true\n elsif x1 == x && y1 == y+2 && y == 1 && @b[x1][y1] == \" \" && @b[x][y+1] == \" \"\n @b[x][y] = \" \"\n @b[x1][y1] = @WP\n return true\n elsif x1 == x+1 && y1 == y+1 && black_owned(x1,y1)\n @black_piece.push(@b[x1][y1])\n @b[x1][y1] = @WP\n @b[x][y] = \" \"\n if y1 == 7\n puts \"You made it to the other side! Choose: Queen 'Q' or Knight 'K'\"\n pawncross = gets.chomp\n pawncross.upcase!\n unless pawncross == \"K\" || pawncross == \"Q\"\n puts \"Please choose 'Q' for queen, or 'K' for knight\"\n pawncross = gets.chomp\n pawncross.upcase!\n end\n if pawncross == \"K\"\n @b[x1][y1] = @WK\n elsif pawncross == \"Q\"\n @b[x1][y1] = @WQ\n end\n end\n return true\n elsif x1 == x-1 && y1 == y+1 && black_owned(x1,y1)\n @black_piece.push(@b[x1][y1])\n @b[x1][y1] = @WP\n @b[x][y] = \" \"\n if y1 == 7\n puts \"You made it to the other side! Choose: Queen 'Q' or Knight 'K'\"\n pawncross = gets.chomp\n pawncross.upcase!\n unless pawncross == \"K\" || pawncross == \"Q\"\n puts \"Please choose 'Q' for queen, or 'K' for knight\"\n pawncross = gets.chomp\n pawncross.upcase!\n end\n if pawncross == \"K\"\n @b[x1][y1] = @WK\n elsif pawncross == \"Q\"\n @b[x1][y1] = @WQ\n end\n end\n return true\n end\n return false\n end",
"def computer_places_piece!(brd)\n square = nil\n\n WINNING_LINES.each do |line|\n square = find_two_sqrs(line, brd, PLAYER_MARKER)\n break if square\n end\n\n if !square\n WINNING_LINES.each do |line|\n square = find_two_sqrs(line, brd, COMPUTER_MARKER)\n break if square\n end\n end\n\n if !square\n square = empty_squares(brd).sample\n end\n\n brd[square] = COMPUTER_MARKER\nend",
"def promote!(x, y)\n if promotable?(x, y)\n piece = piece_at(x, y)\n piece.update_attributes(x_position: nil, y_position: nil)\n piece.reload\n game.pieces.create(piece_type: \"Queen\", x_position: x, y_position: y, state: 'promoted-piece', color: color)\n else\n false\n end\n end",
"def testing_checkmate(board)\n\n test_pieces = [\n King.new(:w, [0,0], board),\n King.new(:b, [1,0], board),\n Queen.new(:b, [0,1], board)\n ]\n\n test_pieces.each do |test_piece|\n board[test_piece.position] = test_piece\n end\n\n board\n\nend",
"def shared_king_squares(game_state)\n all = game_state.squares.occupied_by_piece(JustShogi::OuBase).map { |s| s.piece.base_destinations(s, game_state) }\n\n all.reduce(nil) do |memo, set|\n if memo\n memo & set\n else\n set\n end\n end\n end",
"def promote_pawn!(piece)\n return unless piece.is_a?(Pawn)\n\n self[piece.position] = Queen.new(self, piece.color, piece.position)\n end",
"def castling_right(a, b, check)\n\t\tteam_color = (@board[a][b].piece.color == :white ? :white : :black)\n\t\tking = king(team_color)\n\t\tstart = [a, b]\n\t\treturn false if check\n\t\treturn false if king.piece.castling == false\n\t\treturn false if @board[a + 1][b].piece != nil || @board[a + 2][b].piece != nil || @board[a + 3][b].piece != nil\n\t\treturn false if @board[a + 4][b].piece == nil || @board[a + 4][b].piece.color != team_color || @board[a + 4][b].piece.class.name != \"Rook\" || @board[a + 4][b].piece.castling == false\n\t\treturn false if can_move_piece(start, a + 1, b, team_color, check) == false\n\t\treturn true\n\tend",
"def pawn_promotion(move, current)\n if current.piece.class.name == \"Board::Pawn\"\n if current.piece.color == \"white\"\n if move[-1].to_i == 8\n promotion_piece = promotion_validity_check\n\n case promotion_piece\n when \"Q\"\n current.piece = Queen.new(current, \"♕\", \"white\" )\n when \"R\"\n current.piece= Rook.new(current, \"♖\", \"white\")\n when \"B\"\n current.piece = Bishop.new(current, \"♗\", \"white\")\n when \"N\"\n current.piece = Knight.new(current, \"♘\", \"white\")\n end\n end\n end\n\n if current.piece.color == \"black\"\n if move[-1].to_i == 1\n promotion_piece = promotion_validity_check\n\n case promotion_piece\n when \"Q\"\n current.piece = Queen.new(current, \"♛\", \"black\" )\n when \"R\"\n current.piece= Rook.new(current, \"♜\", \"black\")\n when \"B\"\n current.piece = Bishop.new(current, \"♝\", \"black\")\n when \"N\"\n current.piece = Knight.new(current, \"♞\", \"black\")\n end\n end\n end\n\n end\nend",
"def update_promotion_field\n return unless @piece_moving and @piece_moving.kind_of?(Pawn)\n other_side = Sides.opposite_of(@piece_moving.side)\n if Position.new(to_coord).rank == Sides[other_side].back_rank\n self[:promotion_piece] ||= Piece.role_to_abbrev(:queen)\n end\n end",
"def obstructed?(current_pos,other_pos,board)\n # debugger\n tester = other_pos\n # puts tester\n # sleep 2\n\n #\n # (-1..1).each do |i|\n # (-1..1).each do |j|\n\n\n if other_pos[0] > current_pos[0] #New position is below us\n if other_pos[1] > current_pos[1] #new position is on our right--bishop move\n tester[0] -= 1\n tester[1] -= 1\n until tester == current_pos\n # puts board.grid[tester[0]][tester[1]]\n # puts !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n # sleep 2\n return false if !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n # return false if the piece at tester is not a nul piece\n tester[0] -= 1\n tester[1] -= 1\n end\n\n elsif other_pos[1] < current_pos[1] #new position on our left\n until tester == current_pos\n tester[0] -= 1\n tester[1] += 1\n return false if !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n end\n elsif other_pos[1] == current_pos[1] #new position is on our level horizontally\n until tester == current_pos\n tester[1] -= 1\n return false if !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n end\n end\n\n elsif other_pos[0] < current_pos[0] #New position is above us\n if other_pos[1] > current_pos[1] #new position is on our right\n until tester == current_pos\n tester[0] += 1\n tester[1] -= 1\n return false if !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n end\n\n elsif other_pos[1] < current_pos[1] #new position on our left\n until tester == current_pos\n tester[0] += 1\n tester[1] += 1\n return false if !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n end\n\n else #new position is on our level horizontally\n until tester == current_pos\n tester[0] += 1\n return false if !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n end\n end\n\n else #new position is at our level vertically\n if other_pos[1] > current_pos[1] #new position is on our right\n until tester == current_pos\n tester[1] -= 1\n return false if !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n end\n\n elsif other_pos[1] < current_pos[1] #new position on our left\n until tester == current_pos\n tester[1] += 1\n return false if !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n end\n\n end\n end\n\n return false if board.grid[other_pos[0]][other_pos[1]].color == self.color\n # puts \"hello\"\n # sleep(2)\n true\n\n end",
"def promote(p1)\n puts \"Promote to: [Q]ueen, [K]night, [R]ook, [B]ishop\"\n while true\n promo_piece = gets.chomp.downcase\n if promo_piece == \"q\" || promo_piece == \"queen\"\n @@piece_locations_buffer[p1][\"type\"] = \"queen\"\n break\n elsif promo_piece == \"k\" || promo_piece == \"knight\"\n @@piece_locations_buffer[p1][\"type\"] = \"knight\"\n break\n elsif promo_piece == \"r\" || promo_piece == \"rook\"\n @@piece_locations_buffer[p1][\"type\"] = \"rook\"\n break\n elsif promo_piece == \"b\" || promo_piece == \"bishop\"\n @@piece_locations_buffer[p1][\"type\"] = \"bishop\"\n break\n else\n puts \"Please enter one of: [Q]ueen, [K]night, [R]ook, [B]ishop\"\n end\n end\n end",
"def position_queen(q_placed)\t\n\twhile(q_placed.row <= $nQ && !q_placed.is_good)\n\t\tif(attack_check(q_placed))\n\t\t\tq_placed.row += 1\n\t\telse\n\t\t\tq_placed.is_good = true\n\t\t\t#puts \"this one is good:\"\n\t\t\t#q_placed.show\n\t\t\tnextcol = q_placed.column + 1\n\t\t\tnextindex = q_placed.id\n\t\t\tif(nextcol > $nQ)\n\t\t\t\treturn q_placed.is_good\n\t\t\tend\n\t\t\tn_queen = Queen.new(q_placed.id + 1)\n\t\t\tn_queen.row = 1\n\t\t\tn_queen.column = nextcol\n\t\t\t$q_array << n_queen\n\t\t\tis_good = position_queen(n_queen) \n\t\t\tif(!is_good)\n\t\t\t\t$q_array.pop\n\t\t\t\tq_placed.row += 1\n\t\t\t\tq_placed.is_good = false\n\t\t\tend\n\t\tend\n\tend\n\treturn q_placed.is_good\nend",
"def conflict_check(player, opponent, start, dest)\n idx = player.find_piece_index(start[0], start[1])\n opp_idx = opponent.find_piece_index(dest[0], dest[1])\n opp_king_idx = nil\n opponent.pieces.each_with_index{ |val, index| opp_king_idx = index if val.is_a? King }\n\n copy_start = start.dup\n copy_dest = dest.dup\n if player.pieces[idx].is_a? Knight \n player.pieces.each do |piece|\n if dest[0] == piece.x && dest[1] == piece.y\n return nil\n end\n end\n pos_moves = player.pieces[idx].get_valid_moves\n pos_moves.each do |move|\n if move[0] == opponent.pieces[opp_king_idx].x && move[1] == opponent.pieces[opp_king_idx].y\n return 'bop'\n end \n end\n return 'bo'\n end\n\n if player.pieces[idx].is_a? Pawn\n player.pieces.each do |piece|\n if dest[0] == piece.x && dest[1] == piece.y\n return nil\n end\n end\n pos_moves = player.pieces[idx].get_valid_moves\n pos_moves.each do |move|\n if move[0] == opponent.pieces[opp_king_idx].x && move[1] == opponent.pieces[opp_king_idx].y && move[1] != start[1]\n return 'bop'\n end \n end\n return 'bo'\n end\n \n if (copy_start[0] < copy_dest[0] && copy_start[1] < copy_dest[1])\n until copy_start == copy_dest do\n copy_start[0] += 1\n copy_start[1] += 1\n if copy_start == copy_dest && !opp_idx.nil?\n if opponent.pieces[opp_idx].x == dest[0] && opponent.pieces[opp_idx].y == dest[1] && player.pieces[idx].valid_move?(dest)\n return 'bop'\n end\n end\n if @board_visual[copy_start[0]][copy_start[1]] != CYAN_BLOCK && @board_visual[copy_start[0]][copy_start[1]] != RED_BLOCK\n return nil\n end\n end\n elsif (copy_start[0] > copy_dest[0] && copy_start[1] > copy_dest[1])\n until copy_start == copy_dest do\n copy_start[0] -= 1\n copy_start[1] -= 1\n if copy_start == copy_dest && !opp_idx.nil?\n if opponent.pieces[opp_idx].x == dest[0] && opponent.pieces[opp_idx].y == dest[1] && player.pieces[idx].valid_move?(dest)\n return 'bop'\n end\n end\n if @board_visual[copy_start[0]][copy_start[1]] != CYAN_BLOCK && @board_visual[copy_start[0]][copy_start[1]] != RED_BLOCK\n return nil\n end\n end\n elsif (copy_start[0] < copy_dest[0] && copy_start[1] > copy_dest[1])\n until copy_start[0] == copy_dest[0] do\n copy_start[0] += 1\n copy_start[1] -= 1\n if copy_start == copy_dest && !opp_idx.nil?\n if opponent.pieces[opp_idx].x == dest[0] && opponent.pieces[opp_idx].y == dest[1] && player.pieces[idx].valid_move?(dest)\n return 'bop'\n end\n end\n if @board_visual[copy_start[0]][copy_start[1]] != CYAN_BLOCK && @board_visual[copy_start[0]][copy_start[1]] != RED_BLOCK\n return nil\n end\n end\n elsif (copy_start[0] > copy_dest[0] && copy_start[1] < copy_dest[1])\n until copy_start == copy_dest do\n copy_start[0] -= 1\n copy_start[1] += 1\n if copy_start == copy_dest && !opp_idx.nil?\n if opponent.pieces[opp_idx].x == dest[0] && opponent.pieces[opp_idx].y == dest[1] && player.pieces[idx].valid_move?(dest)\n return 'bop'\n end\n end\n if @board_visual[copy_start[0]][copy_start[1]] != CYAN_BLOCK && @board_visual[copy_start[0]][copy_start[1]] != RED_BLOCK\n return nil\n end\n end\n elsif (copy_start[0] < copy_dest[0] && copy_start[1] == copy_dest[1])\n until copy_start[0] == copy_dest[0] do\n copy_start[0] += 1\n if copy_start == copy_dest && !opp_idx.nil?\n if opponent.pieces[opp_idx].x == dest[0] && opponent.pieces[opp_idx].y == dest[1] && player.pieces[idx].valid_move?(dest)\n return 'bop'\n end\n end\n if @board_visual[copy_start[0]][copy_start[1]] != CYAN_BLOCK && @board_visual[copy_start[0]][copy_start[1]] != RED_BLOCK\n return nil\n end\n end\n elsif (copy_start[0] > copy_dest[0] && copy_start[1] == copy_dest[1])\n until copy_start[0] == copy_dest[0] do\n copy_start[0] -= 1\n if copy_start == copy_dest && !opp_idx.nil?\n if opponent.pieces[opp_idx].x == dest[0] && opponent.pieces[opp_idx].y == dest[1] && player.pieces[idx].valid_move?(dest)\n return 'bop'\n end\n end\n if @board_visual[copy_start[0]][copy_start[1]] != CYAN_BLOCK && @board_visual[copy_start[0]][copy_start[1]] != RED_BLOCK\n return nil\n end\n end\n elsif (copy_start[0] == copy_dest[0] && copy_start[1] < copy_dest[1])\n until copy_start[1] == copy_dest[1] do\n copy_start[1] += 1\n if copy_start == copy_dest && !opp_idx.nil?\n if opponent.pieces[opp_idx].x == dest[0] && opponent.pieces[opp_idx].y == dest[1] && player.pieces[idx].valid_move?(dest)\n return 'bop'\n end\n end\n if @board_visual[copy_start[0]][copy_start[1]] != CYAN_BLOCK && @board_visual[copy_start[0]][copy_start[1]] != RED_BLOCK\n return nil\n end\n end\n elsif (copy_start[0] == copy_dest[0] && copy_start[1] > copy_dest[1])\n until copy_start[1] == copy_dest[1] do\n copy_start[1] -= 1\n if copy_start == copy_dest && !opp_idx.nil?\n if opponent.pieces[opp_idx].x == dest[0] && opponent.pieces[opp_idx].y == dest[1] && player.pieces[idx].valid_move?(dest)\n return 'bop'\n end\n end\n if @board_visual[copy_start[0]][copy_start[1]] != CYAN_BLOCK && @board_visual[copy_start[0]][copy_start[1]] != RED_BLOCK\n return nil\n end\n end\n end\n return 'boo'\n end",
"def eight_queens_possibilities(current_row, taken_columns, positions)\n\nend",
"def castle_queenside?(x,y)\n x == 2 && y == y_position && castle_rook_queenside && \\\n castle_rook_queenside.never_moved? && \\\n castle_rook_queenside.path_blocked?(4, y_position) == false\n end",
"def each_move\n SQ.select { |i| @colors[i] == @mx }.each do |f|\n if @pieces[f] == PAWN\n t = f + UP[@mx]\n yield(f, t + 1) if @colors[t + 1] == @mn && SQ120[SQ64[t] + 1] != NULL\n yield(f, t - 1) if @colors[t - 1] == @mn && SQ120[SQ64[t] - 1] != NULL\n next unless @colors[t] == EMPTY\n yield(f, t)\n yield(f, t + UP[@mx]) if @colors[t + UP[@mx]] == EMPTY && (f >> 3) == (SIDE[@mx] - 1).abs\n next\n end\n STEPS[@pieces[f]].each do |s|\n t = SQ120[SQ64[f] + s]\n while t != NULL\n yield(f, t) if @colors[t] != @mx\n break if @pieces[f] == KING || @pieces[f] == KNIGHT || @colors[t] != EMPTY\n t = SQ120[SQ64[t] + s]\n end\n end\n end\n end",
"def jump_moves\n moves = [] # initializes empty move array\n\n # choses \"forward\" y direction based on piece team\n if @team == \"l\"\n dir = 1\n else\n dir = -1\n end\n\n # looks at the two forward far diagonal positions and adds them to moves array if there are no pieces there and an opponent piece in between\n pos1 = [@x_pos + 2, @y_pos + 2*dir]\n moves << pos1 if Piece.all.find{|p| p.x_pos == @x_pos + 1 && p.y_pos == @y_pos + dir && p.team != @team} && Piece.all.none?{|p| [p.x_pos, p.y_pos] == pos1}\n pos2 = [@x_pos - 2, @y_pos + 2*dir]\n moves << pos2 if Piece.all.find{|p| p.x_pos == @x_pos - 1 && p.y_pos == @y_pos + dir && p.team != @team} && Piece.all.none?{|p| [p.x_pos, p.y_pos] == pos2}\n \n\n # deletes any moves with coordinates that aren't on the board\n moves.delete_if{|move| move.find{|n| n < 0 || n > 7}}\n return moves\n end",
"def position_for_next_harvest()\n turn_right()\n move()\n turn_right()\n end",
"def moves\n sliding_moves + jumping_moves\n end",
"def group_possible_moves_rook(pm)\n result = []\n\n result << pm.select do |p|\n p[0] == position[0] && p[1] < position[1]\n end\n\n result << pm.select do |p|\n p[0] == position[0] && p[1] > position[1]\n end\n\n result << pm.select do |p|\n p[1] == position[1] && p[0] < position[0]\n end\n\n result << pm.select do |p|\n p[1] == position[1] && p[0] > position[0]\n end\n result[0].reverse!\n result[2].reverse!\n result\n end",
"def move_up_right\n i = 1\n until false\n x, y = @pos\n x -= i\n y += i\n pos = [x, y]\n break if x > 7 || x < 0 || y > 7 || y < 0 || @board[pos].color == @color\n @moves << pos\n break if @board[pos].color != @color\n i += 1\n end\n end",
"def move_joker_b\n b_pos = $deck.find_index('B')\n $deck.delete('B')\n if b_pos == 51\n $deck << 'B'\n else\n $deck.insert (b_pos + 2) % 53, 'B'\n end\nend",
"def test_move_turns_duck_type_beach\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_duck_type_beach\n assert_includes ['Enumerable Canyon', 'Matzburg'], ruby_rush.city\n end",
"def legal_moves\n # Fill this in\n end",
"def move_piece(move, color) \n squares = find_start_and_end(move) # [start, end]\n\n return false if @display[squares[0][0]][squares[0][1]].guest == ' '\n\n start_piece = @display[squares[0][0]][squares[0][1]].guest\n\n return false if start_piece.color != color \n\n moves = get_legal_moves(squares[0], start_piece, start_piece.poss_moves(squares[0]))\n\n\n if moves.include?(squares[1])\n\n # castling\n if start_piece.id == 'king' && start_piece.color == 'white' && squares[1] == [7, 1] \n make_move(squares[0], squares[1], start_piece)\n make_move([7, 0], [7, 2], @display[0][0].guest)\n elsif start_piece.id == 'king' && start_piece.color == 'black' && squares[1] == []\n make_move(squares[0], squares[1], start_piece)\n make_move([0, 0], [0, 2], @display[7][0].guest)\n\n # pawn -> queen upgrade\n elsif start_piece.id == 'pawn' && start_piece.color == 'white' && squares[1][0].zero?\n make_move(squares[0], squares[1], Queen.new('white'))\n elsif start_piece.id == 'pawn' && start_piece.color == 'black' && squares[1][0] == 7\n make_move(squares[0], squares[1], Queen.new('black'))\n\n else\n make_move(squares[0], squares[1], start_piece)\n end\n else\n false\n end\n end",
"def knight_moves(position, final)\n position == final ? result = [final] : result = 0\n position = [position]\n queue = []\n while result == 0\n pm = possible_movements(position.last)\n if pm.include?(final)\n result = position << final\n else\n pm.each do |move|\n queue << (position + [move])\n end\n position = queue.delete_at(0)\n end\n end\n pretty_result(result)\nend",
"def botTurn\n # check if we can win with one move or need to block\n if positions = winOrBlock?(currentPlayer) || positions = winOrBlock?( (currentPlayer == 'X')? 'O' : 'X')\n takeLastSpot(positions)\n \n # check if there is a chance for bot to create a fork, or block oponent from making fork \n elsif forks = possibleFork?(currentPlayer) || forks = possibleFork?((currentPlayer == 'X')? 'O' : 'X')\n \n \n if forks.size == 1\n # find the most common index and move there\n commonElement = forks.max_by {|i| forks.count(i)}\n move(commonElement, currentPlayer)\n else\n # more than one fork possible,\n # find optimal block point, move there\n move(blockPoint(forks), currentPlayer)\n end\n \n # take the center if its available\n elsif !position_taken?(4)\n move(4, currentPlayer)\n \n # take an opposite corner from the oponent. If not available, take any corner\n elsif corner = cornerMove\n move(corner, currentPlayer)\n \n # play in a middle square on any of the sides \n else\n SIDE_MIDDLE.each do |position|\n if !position_taken?(position)\n move(position, currentPlayer)\n break\n end\n end\n end\n puts \"#{(currentPlayer == 'X')? 'O': 'X'}'s move: \"\n displayBoard\n end",
"def computer_places_piece!(brd)\n square = nil\n # Defence\n WINNING_LINES.each do |line|\n square = find_at_risk_square(line, brd, COMPUTER_MARKER)\n break if square\n end\n # Offence\n if !square\n WINNING_LINES.each do |line|\n square = find_at_risk_square(line, brd, PLAYER_MARKER)\n break if square\n end\n end\n # Pick square 5 if its available\n if !square\n square = 5 if empty_squares(brd).include?(5)\n end\n # just pick a square\n if !square\n square = empty_squares(brd).sample\n end\n brd[square] = COMPUTER_MARKER\n sleep_to_make_game_nicer(1)\nend",
"def backtrack_board\n @chess_board.board = @backtrack_board.board\n move_piece_back\n remove_test_piece\n end",
"def move\n start_show_thinking\n @board.move(best_moves.first)\n stop_show_thinking\n board.last_move\n end",
"def perfect_move(marker, index)\r\n\t\tif board[index] == perfect_move\r\n\t\t\tboard[index] = marker\r\n\tend\r\n\r\n\t#final moves in order to win\r\n\tdef win(board, marker)\r\n\t\t#horizontal top\r\n\t\tif board[0] && board[1] == marker\r\n\t\t\tboard[2] == perfect_move\r\n\t\telsif board[0] && board[2] == marker\r\n\t\t\tboard[1] == perfect_move\r\n\t\telsif board[1] && board[2] == marker\r\n\t\t\tboard[0] == perfect_move\r\n\t\t#horiz middle\r\n\t\telsif board[3] && board[4] == marker\r\n\t\t\tboard[5] == perfect_move\r\n\t\telsif board[3] && board[5] == marker\r\n\t\t\tboard[4] == perfect_move\r\n\t\telsif board[4] && board[5] == marker\r\n\t\t\tboard[3] == perfect_move\r\n\t\t#horiz bottom\r\n\t\telsif board[6] && board[7] == marker\r\n\t\t\tboard[8] == perfect_move\r\n\t\telsif board[6] && board[8] == marker\r\n\t\t\tboard[7] == perfect_move\r\n\t\telsif board[7] && board[8] == marker\r\n\t\t\tboard[6] == perfect_move\r\n\t\t#vertical left\r\n\t\telsif board[0] && board[3] == marker\r\n\t\t\tboard[6] == perfect_move\r\n\t\telsif board[3] && board[6] == marker\r\n\t\t\tboard[0] == perfect_move\r\n\t\telsif board[0] && board[6] == marker\r\n\t\t\tboard[3] == perfect_move\r\n\t\t#vert middle\r\n\t\telsif board[1] && board[4] == marker\r\n\t\t\tboard[7] == perfect_move\r\n\t\telsif board[1] && board[7] == marker\r\n\t\t\tboard[4] == perfect_move\r\n\t\telsif board[4] && board[7] == marker\r\n\t\t\tboard[1] == perfect_move\r\n\t\t#vert right\r\n\t\telsif board[2] && board[5] == marker\r\n\t\t\tboard[8] == perfect_move\r\n\t\telsif board[2] && board[8] == marker\r\n\t\t\tboard[5] == perfect_move\r\n\t\telsif board[5] && board[8] == marker\r\n\t\t\tboard[2] == perfect_move\r\n\t\t#diagonal top left \r\n\t\telsif board[0] && board[4] == marker\r\n\t\t\tboard[8] == perfect_move\r\n\t\telsif board[0] && board[8] == marker\r\n\t\t\tboard[4] == perfect_move\r\n\t\telsif board[4] && board[8] == marker\r\n\t\t\tboard[0] == perfect_move\r\n\t\t#diag bottom left\r\n\t\telsif board[2] && board[4] == marker\r\n\t\t\tboard[6] == perfect_move\r\n\t\telsif board[2] && board[6] == marker\r\n\t\t\tboard[4] == perfect_move\r\n\t\telsif board[4] && board[6] == marker\r\n\t\t\tboard[2] == perfect_move\r\n\t\telse\r\n\r\n\t\tend\r\n\tend\r\n\r\n\t#blocks an opponent from making the winning move\r\n\tdef block(human, marker, index)\r\n\t\tif human[marker] == win\r\n\t\t\tboard[index] = perfect_move\r\n\t\t\ttrue\r\n\t\telse\r\n\t\t\tfalse\r\n\t\tend\r\n\tend\r\n\r\n\tdef fork()\r\n\tend\r\n\r\n\tdef fork_block()\r\n\tend\r\n\r\n\tdef opposite_corner()\r\n\tend\r\n\r\n\tdef empty_corner()\r\n\tend\r\n\r\n\tdef empty_side()\r\n\tend\r\n\r\nend",
"def greedy(rows, cols)\n board = Array.new(rows.length) { Array.new(cols.length) }\n rows.each_with_index { |r, r_idx|\n cols.each_with_index { |c, c_idx|\n board[r_idx][c_idx] = if (r > 0 and c > 0)\n rows[r_idx] -= 1\n cols[c_idx] -= 1\n 'x'\n else\n 'o'\n end\n }\n }\n board\nend",
"def lengthTwoMove(usersMove)\n if usersMove == \"oo\" || usersMove == \"Oo\"\n @colour == :white ? to = \"g1\" : to = \"g8\"\n return Move.new(@board, King.new(@colour), to)\n else\n to = usersMove\n return Move.new(@board, Pawn.new(@colour), to)\n end\n end",
"def move_piece_in_square(from_square, to_square)\n to_square.checker_piece = from_square.checker_piece\n from_square.checker_piece = nil\n end",
"def move_piece_in_square(from_square, to_square)\n to_square.checker_piece = from_square.checker_piece\n from_square.checker_piece = nil\n end",
"def populate_board\n back_row = [Rook, Knight, Bishop, Queen, King, Bishop, Knight, Rook]\n\n black_back_row = []\n back_row.each_with_index do |piece_class, j|\n black_back_row << piece_class.new(self, :black, [0, j])\n end\n board[0] = black_back_row\n \n black_front_row = []\n (0..7).each {|idx| black_front_row << Pawn.new(self, :black, [1, idx])}\n board[1] = black_front_row\n \n (2..5).each do |row|\n board[row] = Array.new(8) {NullPiece.instance} \n end\n \n white_front_row = []\n 8.times {|idx| white_front_row << Pawn.new(self, :white, [6, idx])}\n board[6] = white_front_row\n \n white_back_row = []\n back_row.each_with_index do |piece_class, j|\n white_back_row << piece_class.new(self, :white, [7, j])\n end\n board[7] = white_back_row\n end",
"def move_B\r\n 2.times { move_down( @deck.index( 'B' ) ) }\r\n end",
"def computer_places_piece!(brd)\n square = nil\n\n # offensive move\n Board::WINNING_LINES.each do |line|\n square = find_at_risk_square(line, brd, Board::CPU_MARKER)\n break if square\n end\n\n # defensive move\n if !square\n Board::WINNING_LINES.each do |line|\n square = find_at_risk_square(line, brd, Board::PLAYER_MARKER)\n break if square\n end\n end\n\n # optimized first move, choose the center\n if empty_squares(brd).include?(5)\n square = 5\n end\n\n # neutral move\n if !square\n square = empty_squares(brd).sample\n end\n\n brd.position_values[square] = Board::CPU_MARKER\n end",
"def towerofhanoi(pieces, sourcepeg, destinationpeg, extrapeg)\n if pieces == 0 then\n return \"no pieces to move\"\n end\n towerofhanoi(pieces-1,sourcepeg,extrapeg,destinationpeg)\n puts \"moved #{pieces} from \" + \"#{sourcepeg} to #{destinationpeg}\"\n towerofhanoi(pieces-1,extrapeg,destinationpeg,sourcepeg)\nend",
"def generate_possible_moves(state)\n end",
"def perfect_move(marker, index)\n\t\tif board[index] == perfect_move\n\t\t\tboard[index] = marker\n\tend\n\n\t#final moves in order to win\n\tdef win(board, marker)\n\t\t#horizontal top\n\t\tif board[0] && board[1] == marker\n\t\t\tboard[2] == perfect_move\n\t\telsif board[0] && board[2] == marker\n\t\t\tboard[1] == perfect_move\n\t\telsif board[1] && board[2] == marker\n\t\t\tboard[0] == perfect_move\n\t\t#horiz middle\n\t\telsif board[3] && board[4] == marker\n\t\t\tboard[5] == perfect_move\n\t\telsif board[3] && board[5] == marker\n\t\t\tboard[4] == perfect_move\n\t\telsif board[4] && board[5] == marker\n\t\t\tboard[3] == perfect_move\n\t\t#horiz bottom\n\t\telsif board[6] && board[7] == marker\n\t\t\tboard[8] == perfect_move\n\t\telsif board[6] && board[8] == marker\n\t\t\tboard[7] == perfect_move\n\t\telsif board[7] && board[8] == marker\n\t\t\tboard[6] == perfect_move\n\t\t#vertical left\n\t\telsif board[0] && board[3] == marker\n\t\t\tboard[6] == perfect_move\n\t\telsif board[3] && board[6] == marker\n\t\t\tboard[0] == perfect_move\n\t\telsif board[0] && board[6] == marker\n\t\t\tboard[3] == perfect_move\n\t\t#vert middle\n\t\telsif board[1] && board[4] == marker\n\t\t\tboard[7] == perfect_move\n\t\telsif board[1] && board[7] == marker\n\t\t\tboard[4] == perfect_move\n\t\telsif board[4] && board[7] == marker\n\t\t\tboard[1] == perfect_move\n\t\t#vert right\n\t\telsif board[2] && board[5] == marker\n\t\t\tboard[8] == perfect_move\n\t\telsif board[2] && board[8] == marker\n\t\t\tboard[5] == perfect_move\n\t\telsif board[5] && board[8] == marker\n\t\t\tboard[2] == perfect_move\n\t\t#diaginal top left \n\t\telsif board[0] && board[4] == marker\n\t\t\tboard[8] == perfect_move\n\t\telsif board[0] && board[8] == marker\n\t\t\tboard[4] == perfect_move\n\t\telsif board[4] && board[8] == marker\n\t\t\tboard[0] == perfect_move\n\t\t#diag bottom left\n\t\telsif board[2] && board[4] == marker\n\t\t\tboard[6] == perfect_move\n\t\telsif board[2] && board[6] == marker\n\t\t\tboard[4] == perfect_move\n\t\telsif board[4] && board[6] == marker\n\t\t\tboard[2] == perfect_move\n\t\telse\n\n\t\tend\n\tend\n\n\t#blocks an opponent from making the winning move\n\tdef block(human, marker, index)\n\t\tif human[marker] == win\n\t\t\tboard[index] = perfect_move\n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend\n\n\tdef fork()\n\tend\n\n\tdef fork_block()\n\tend\n\n\tdef opposite_corner()\n\tend\n\n\tdef empty_corner()\n\tend\n\n\tdef empty_side()\n\tend\n\nend",
"def get_moves(piece, board)\n valid_col = case piece.name\n when ?A then 3\n when ?B then 5\n when ?C then 7\n when ?D then 9\n else 11\n end\n moves = []\n\n # If in hallway\n if piece.row == 1\n cols = valid_col < piece.col ? (valid_col...piece.col).to_a : (piece.col+1..valid_col).to_a\n if cols.count{|c| board[[1, c]] == ?.} == cols.length\n if board[[2, valid_col]] == ?.\n if board[[3, valid_col]] == ?.\n moves << [[3, valid_col], (cols.count + 2) * piece.cost]\n elsif board[[3, valid_col]] == piece.name\n moves << [[2, valid_col], (cols.count + 1) * piece.cost]\n end\n end\n end\n # If not in its column (can never stand in hallway anf column at same time)\n elsif (piece.col == valid_col && piece.row == 2 && board[[piece.row + 1, piece.col]] != piece.name) || (piece.col != valid_col && piece.row == 2)\n 2.times do |t|\n dir = t == 0 ? -1 : 1\n curr = piece.col\n steps = 1\n while board[[1, curr]] == ?.\n moves << [[1, curr], steps * piece.cost] if ![3, 5, 7, 9].include?(curr)\n steps += 1\n curr += dir\n end\n end\n elsif piece.row == 3 && piece.col != valid_col && board[[2, piece.col]] == ?.\n 2.times do |t|\n dir = t == 0 ? -1 : 1\n curr = piece.col\n steps = 2\n while board[[1, curr]] == ?.\n moves << [[1, curr], steps * piece.cost] if ![3, 5, 7, 9].include?(curr)\n steps += 1\n curr += dir\n end\n end\n end\n moves\nend",
"def update\r\n\r\n # check for an abort flag\r\n if defined? ABORT\r\n close\r\n end\r\n\r\n # has final state already been determined?\r\n if !@board.is_final_state()\r\n\r\n # determine final state\r\n if !@board.determine_final_state(@queens)\r\n\r\n # Action: limit number of queen moves\r\n @limiter += 1\r\n if @limiter >= @limit\r\n puts \"Solution Not Found or Queen Moves Exceded Limit of \"+@limiter.to_s+\".\"\r\n @board.force_final_state()\r\n end\r\n\r\n # select a new queen, rearrange it towards solving 8queens problem\r\n @curr_index = @board.search_next_and_move(@curr_index,@queens)\r\n\r\n @board.clear_hits()\r\n @board.update_hits(@queens)\r\n\r\n\r\n else\r\n puts \"\\nSolution Found!\\n\"\r\n self.print_queens()\r\n puts \"\\n\"\r\n end\r\n end\r\n end",
"def open_squares(p1_moves, p2_moves)\n avail_moves = Array.new\n SQUARES.each { |n| avail_moves << n unless p1_moves.include?(n) || p2_moves.include?(n) }\n return avail_moves\n end",
"def move(board)\n if !board.taken?(\"5\")\n board = \"5\"\n elsif board.turn_count == 1\n board = \"1\"\n elsif board.turn_count == 2\n board = [\"3\", \"7\", \"9\"].detect do |position|\n !board.taken?(position)\n end\n elsif board.turn_count > 2 && board.turn_count < 6\n win_combo_array = []\n Game::WIN_COMBINATIONS.select do |win_combo|\n if ((board.position((win_combo[0] + 1).to_s) == opponent_token) && (board.position((win_combo[1] + 1).to_s) == opponent_token)) ||\n ((board.position((win_combo[1] + 1).to_s) == opponent_token) && (board.position((win_combo[2] + 1).to_s) == opponent_token)) ||\n ((board.position((win_combo[2] + 1).to_s) == opponent_token) && (board.position((win_combo[0] + 1).to_s) == opponent_token)) == true\n win_combo_array << win_combo\n end\n end\n number_at_index = win_combo_array[0].select do |number|\n position_number = (number + 1).to_s\n if board.position(position_number) != opponent_token\n position_number\n end\n end\n board = (number_at_index[0] + 1).to_s\n else\n win_combo_array = []\n Game::WIN_COMBINATIONS.select do |win_combo|\n if ((board.position((win_combo[0] + 1).to_s) == token) && (board.position((win_combo[1] + 1).to_s) == token)) ||\n ((board.position((win_combo[1] + 1).to_s) == token) && (board.position((win_combo[2] + 1).to_s) == token)) ||\n ((board.position((win_combo[2] + 1).to_s) == token) && (board.position((win_combo[0] + 1).to_s) == token)) == true\n win_combo_array << win_combo\n end\n end\n number_at_index = win_combo_array[0].select do |number|\n position_number = (number + 1).to_s\n if board.position(position_number) != opponent_token\n position_number\n end\n end\n board_n = (number_at_index[0] + 1).to_s\n board = final_moves(board, board_n)\n end\n end",
"def move_r6(wins, player, opponent)\n taken = player + opponent # all occupied board positions\n open_corners = (@corners - (taken & @corners)) # all open corners\n open_edges = (@edges - (taken & @edges)) # all open edges\n if adj_cor_op_edg?(player, opponent) # if opponent has adjacent corners and opposing edge\n position = open_edges.sample # take a random open edge\n elsif adj_edg_op_cor?(player, opponent) # if opponent has adjacent edges and opposing corner\n position = open_corners.sample # take a random open corner, or use win/block/edge logic\n else\n position = win_check(wins, player, opponent) # otherwise use win/block/edge logic\n end\n end",
"def populate_board\n black = \"black\"\n white = \"white\"\n\n white_pawns = [\"A2\", \"B2\", \"C2\", \"D2\", \"E2\", \"F2\", \"G2\", \"H2\"]\n black_pawns = [\"A7\", \"B7\", \"C7\", \"D7\", \"E7\", \"F7\", \"G7\", \"H7\"]\n\n # create white pawns\n white_pawns.each do |pos|\n @board.nodes[pos].piece = create_pawn(white, pos)\n end\n\n # create white pieces\n @board.nodes[\"E1\"].piece = create_king(white, \"E1\")\n @board.nodes[\"D1\"].piece = create_queen(white, \"D1\")\n @board.nodes[\"C1\"].piece = create_bishop(white, \"C1\")\n @board.nodes[\"F1\"].piece = create_bishop(white, \"F1\")\n @board.nodes[\"B1\"].piece = create_knight(white, \"B1\")\n @board.nodes[\"G1\"].piece = create_knight(white, \"G1\")\n @board.nodes[\"A1\"].piece = create_rook(white, \"A1\")\n @board.nodes[\"H1\"].piece = create_rook(white, \"H1\")\n\n # create black pawns\n black_pawns.each do |pos|\n @board.nodes[pos].piece = create_pawn(black, pos)\n end\n\n # create black pieces\n @board.nodes[\"E8\"].piece = create_king(black, \"E8\")\n @board.nodes[\"D8\"].piece = create_queen(black, \"D8\")\n @board.nodes[\"C8\"].piece = create_bishop(black, \"C8\")\n @board.nodes[\"F8\"].piece = create_bishop(black, \"F8\")\n @board.nodes[\"B8\"].piece = create_knight(black, \"B8\")\n @board.nodes[\"G8\"].piece = create_knight(black, \"G8\")\n @board.nodes[\"A8\"].piece = create_rook(black, \"A8\")\n @board.nodes[\"H8\"].piece = create_rook(black, \"H8\")\n\n end",
"def play_round(heaps)\n winning_move_from_state(heaps: heaps)\n end"
] |
[
"0.6793946",
"0.6759593",
"0.66348326",
"0.63150096",
"0.6277755",
"0.62528765",
"0.62267834",
"0.61691153",
"0.615425",
"0.6122588",
"0.6058275",
"0.60339695",
"0.6012107",
"0.6009247",
"0.59959733",
"0.59870994",
"0.59814507",
"0.5959321",
"0.5917923",
"0.5909152",
"0.5892974",
"0.58891493",
"0.58826375",
"0.5866554",
"0.585689",
"0.5830634",
"0.5826593",
"0.58243406",
"0.5807355",
"0.58021224",
"0.57897776",
"0.5779111",
"0.5753627",
"0.5742106",
"0.57207125",
"0.57168555",
"0.57139695",
"0.5695485",
"0.568424",
"0.567842",
"0.5649373",
"0.56418854",
"0.5636567",
"0.563156",
"0.56303173",
"0.5629211",
"0.56272954",
"0.56267583",
"0.5612553",
"0.5605943",
"0.55898756",
"0.5585904",
"0.5583388",
"0.5579649",
"0.5560786",
"0.5558989",
"0.5541929",
"0.55379045",
"0.5515845",
"0.5513349",
"0.5507581",
"0.550135",
"0.5500872",
"0.5493777",
"0.54881597",
"0.5486024",
"0.5485059",
"0.5468735",
"0.54663616",
"0.546482",
"0.54589707",
"0.54579794",
"0.5456729",
"0.54492795",
"0.5448008",
"0.5442245",
"0.5433219",
"0.5425743",
"0.5411792",
"0.5407292",
"0.54047877",
"0.54008394",
"0.5399052",
"0.5396173",
"0.53939193",
"0.5392422",
"0.5392422",
"0.53871393",
"0.53840685",
"0.5380752",
"0.5378179",
"0.5373343",
"0.53723806",
"0.53716177",
"0.53647316",
"0.5363291",
"0.53573036",
"0.53572726",
"0.5346124",
"0.53427136"
] |
0.6824487
|
0
|
move will be in format of [type, start, end] e.g. ["N", [1,1], [2,3]]
|
def make_move(game, move, turn)
new_game = game.clone
# remove piece from the board
new_game[turn].delete(move[1])
# add it to the board in new position
new_game[turn][move[2]] = move[0]
# remove opponent's piece
new_game[@opp_turn[turn]].delete(move[2])
# a move has been made, decrement the limit, switch the turns
new_game[:limit] -= 1
new_game[:turn] = @opp_turn[turn]
# record the move made
new_game[:moves].push([turn, move])
return new_game
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def parse_move(move)\n #Is this enough of a repetition for me to iterate? It seemed more\n #tedious for me to iterate in this situation\n from = [(8-(move[0][1].to_i)), ((\"a\"..\"h\").to_a.index(move[0][0]))]\n to = [(8-(move[1][1].to_i)), ((\"a\"..\"h\").to_a.index(move[1][0]))]\n [from, to]\n end",
"def move(start_peg, end_peg) #nums 0,1,2\n piece = @pegs[start_peg].shift\n @pegs[end_peg].unshift(piece)\n end",
"def parse_move\n s0 = @scanner.pos\n s1 = parse_line\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n s2 = []\n s3 = parse_comment\n while s3 != :failed\n s2 << s3\n s3 = parse_comment\n end\n parse_pointer\n @reported_pos = s0\n s0 = transform_move(s1, s2)\n end\n s0\n end",
"def parse_move\n s0 = @scanner.pos\n s1 = parse_line\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n s2 = []\n s3 = parse_comment\n while s3 != :failed\n s2 << s3\n s3 = parse_comment\n end\n parse_pointer\n s4 = []\n s5 = parse_nl\n s5 = match_space if s5 == :failed\n while s5 != :failed\n s4 << s5\n s5 = parse_nl\n s5 = match_space if s5 == :failed\n end\n @reported_pos = s0\n s0 = -> (line, c) do\n ret = { 'move' => line }\n ret['comments'] = c unless c.empty?\n ret\n end.call(s1, s2)\n end\n\n s0\n end",
"def move_piece(board, move)\n # norm: <file_start><rank_start></file_end><rank_end>\n file_start = move.notation[0]\n rank_start = move.notation[1].to_i\n file_end = move.notation[2]\n rank_end = move.notation[3].to_i\n board[file_end][rank_end - 1] = board[file_start][rank_start - 1]\n board[file_start][rank_start - 1] = nil\n\n board\n end",
"def moves; [] end",
"def putmove(movetype,column,gen) #column refers to leftmost column in move\n #put pieces on board\n if movetype == 1\n @board.droppiece(currpieces[0],column)\n @board.droppiece(currpieces[1],column)\n elsif movetype == 2\n @board.droppiece(currpieces[1],column)\n @board.droppiece(currpieces[0],column)\n elsif movetype == 3\n @board.droppiece(currpieces[0],column)\n @board.droppiece(currpieces[1],column+1)\n elsif movetype == 4\n @board.droppiece(currpieces[1],column)\n @board.droppiece(currpieces[0],column+1)\n end \n setcurr(@nextpieces[0],@nextpieces[1])\n if gen\n gennext\n end\n end",
"def move(start, end_pos)\n piece = self[start]\n available_moves = piece.valid_moves\n raise MoveNotAvailableError unless available_moves.include?(end_pos)\n piece.move_to(end_pos)\n rescue MoveNotAvailableError => e\n puts \"Piece cannot move to that location!\"\n raise e\n end",
"def move_dirs\n [[-1,2], [1,2], [2,1], [2,-1], [1,-2], [-1,-2], [-2,-1], [-2,1]]\n end",
"def move!(start, end_pos)\n if self[start].moves.include?(end_pos)\n self[end_pos] = self[start]\n self[end_pos].pos = end_pos\n self[start] = NullPiece.new\n else\n puts \"Invalid Move! Try again.\"\n sleep(2)\n end\n end",
"def smove(source, destination, member); end",
"def smove(source, destination, member); end",
"def move!(start_pos, end_pos)\n #save removed piece and then remove it\n @removed_pieces << self[end_pos]\n self[end_pos] = NullPiece.instance\n\n self[start_pos], self[end_pos] = self[end_pos], self[start_pos]\n\n self[end_pos].position = end_pos\n end",
"def move(move)\n @moves << move\n end",
"def generate_moves\n @delta.each do |step|\n new_pos = [@pos[0] + step[0], @pos[1] + step[1]]\n @move_list << new_pos if valid_coord?(new_pos)\n end\n end",
"def move_dirs\n [[-1,1], [1,1], [1,-1], [-1,-1]]\n end",
"def lmove(source, destination, where_source, where_destination); end",
"def lmove(source, destination, where_source, where_destination); end",
"def move; end",
"def move; end",
"def do_the_move(move)\n @log.debug \"do_the_move #{move.move_to_str}\"\n color, row_s, col_s, row_e, col_e, movetype = strip_pos_argument(move)\n \n if check_if_moveisvalid(move) == :invalid\n @log.debug \"invalid move #{argument}, info#{@last_move_error}\"\n return\n end\n start_item = @infosquare[row_s][col_s]\n end_item = @infosquare[row_e][col_e]\n if movetype == :shortcastle or movetype ==:longcastle\n move_castle(start_item, end_item)\n elsif movetype == :enpassant\n col_enp = end_item.column_start\n row_enp = start_item.row_start\n eated_item = @infosquare[row_enp][col_enp]\n eated_item.clear\n BoardInfoItem.exchange(start_item, end_item)\n elsif movetype == :promotion\n BoardInfoItem.exchange(start_item, end_item)\n end_item.setinfo(move.promoted, move.color)\n else\n if @infosquare[row_s][col_s].type_piece == :vuoto\n raise \"Invalid board state, try to move an empty cell\"\n end\n BoardInfoItem.exchange(start_item, end_item)\n end\n move.fen_after_move = calculate_current_fen\n \n @last_moved_item = end_item\n @moves_in_match << move\n end",
"def make_move start_pos, end_pos\n piece = get_board_piece(start_pos)\n @board[end_pos[0]][end_pos[1]] = piece\n piece.position = end_pos\n @board[start_pos[0]][start_pos[1]] = nil\n end",
"def move_type_path\n return if @path == :pending\n return unless movable?\n while (command = @path[@move_route_index])\n # @move_route_index += 1\n break if move_type_custon_exec_command(command)\n end\n end",
"def move\n # removing first element from the snake body\n unless @is_growing\n # list.shift removes the first element within a list\n @positions.shift\n end\n # after growing, snake should stop growing, it grows one at a time\n @is_growing = false\n # reading direction\n case @direction\n when 'down'\n # push insert an element in last position of the list\n # adding one to y in snake head\n @positions.push([head[0],\n (head[1] + 1) % GRID_HEIGHT])\n when 'up'\n @positions.push([head[0],\n (head[1] - 1) % GRID_HEIGHT])\n when 'left'\n @positions.push([(head[0] - 1) % GRID_WIDTH,\n head[1]])\n when 'right'\n @positions.push([(head[0] + 1) % GRID_WIDTH,\n head[1]])\n else\n puts 'error: another key inside case else'\n end\n end",
"def move(dir, travel, coord, arr, snail)\n inc = (dir == 'n' || dir == 'w') ? -1 : 1\n cur = (dir == 'n' || dir == 's') ? coord[0] : coord[1]\n spot = (dir == 'n' || dir == 'w') ? cur - travel : cur + travel\n until cur == spot\n cur += inc\n (dir == 'n' || dir == 's') ? snail.push(arr[cur][coord[1]]) : snail.push(arr[coord[0]][cur])\n end\n coord = (dir == 'n' || dir == 's') ? [coord[0]+(inc*travel), coord[1]] : [coord[0], coord[1]+(inc*travel)]\n return [coord, snail]\nend",
"def move\n @positions.shift\n case @direction\n when 'down'\n @positions.push(new_coords(head[0], head[1] + 1))\n when 'up'\n @positions.push(new_coords(head[0], head[1] - 1))\n when 'left'\n @positions.push(new_coords(head[0] - 1, head[1]))\n when 'right'\n @positions.push(new_coords(head[0] + 1, head[1]))\n end\n end",
"def move_piece(start_pos,end_pos)\n # debugger\n raise \"No piece at start position\" if self[start_pos].is_a?(NullPiece)\n raise \"Piece can not move there\" unless valid_move?(start_pos)\n current_piece = self[start_pos]\n\n self[end_pos] = current_piece\n self[start_pos] = NullPiece.instance\n end",
"def move\n move_by a, m\n end",
"def move_pieces(move_pos)\n current_pos, next_pos = move_pos\n\n @board[next_pos[0]][next_pos[1]] = @board[current_pos[0]][current_pos[1]]\n @board[current_pos[0]][current_pos[1]] = nil\n end",
"def move_pieces(move_pos)\n current_pos, next_pos = move_pos\n\n @board[next_pos[0]][next_pos[1]] = @board[current_pos[0]][current_pos[1]]\n @board[current_pos[0]][current_pos[1]] = nil\n end",
"def move_dirs\n [[0,1], [1,0], [0,-1], [-1,0]]\n end",
"def move(n, from_array, to_array)\n return if n <= 0\n to_array << from_array.shift # this mutates both arrays\n move(n - 1, from_array, to_array)\nend",
"def move(start, finish)\n unless @board.valid_position?(start) && @board.valid_position?(finish)\n return invalid_inputs\n end\n\n queue = [Node.new(start)]\n node = Node.new\n\n until node.data == finish\n node = queue.shift\n @board.moves_as_children(node)\n node.children.each { |child| queue << child }\n end\n\n print_path(create_path(node))\n end",
"def move_dirs\n [[0,1], [1,0], [0,-1], [-1,0], [-1,1], [1,1], [1,-1], [-1,-1]]\n end",
"def move_dirs\n [[0,1], [1,0], [0,-1], [-1,0], [-1,1], [1,1], [1,-1], [-1,-1]]\n end",
"def moves(*move_dirs)\n possible_moves = []\n\n end",
"def move(pos, down, right)\n\t\t[pos[0] + down, pos[1] + right]\n\tend",
"def move_piece!(start_pos, end_pos)\n piece = self[start_pos]\n raise 'piece cannot move like that' unless piece.moves.include?(end_pos)\n\n self[end_pos] = piece\n self[start_pos] = sentinel\n piece.pos = end_pos\n\n nil\n end",
"def move_piece!(start_pos, end_pos)\n piece = self[start_pos]\n raise 'piece cannot move like that' unless piece.moves.include?(end_pos)\n\n self[end_pos] = piece\n self[start_pos] = sentinel\n piece.pos = end_pos\n\n nil\n end",
"def do_the_move(argument)\r\n color, row_s, col_s, row_e, col_e = strip_pos_argument(argument)\r\n start_item = @infosquare[row_s][col_s]\r\n end_item = @infosquare[row_e][col_e]\r\n if movetype == :shortcastle or movetype ==:longcastle\r\n move_castle(start_item, end_item)\r\n elsif movetype == :enpassant\r\n col_enp = end_item.col\r\n row_enp = start_item.row\r\n eated_item = @infosquare[row_enp][col_enp]\r\n eated_item.clear\r\n else\r\n BoardInfoItem.exchange(start_item, end_item)\r\n end\r\n @last_moved_item = end_item\r\n \r\n end",
"def parse_move(str)\n case str[0]\n when \"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\"\n idx = str[0].to_i - 1\n from = @tableau[idx]\n case str[1]\n when \"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\"\n to = @tableau[str[1].to_i - 1]\n num = find_number(from,to)\n raise \"NOPE #{str}\" unless num\n when \"F\",\"f\"\n num = 1\n to = find_foundation(from)\n else\n puts \"try again #{str}\"\n end\n from.move(num, to)\n when \"D\", \"d\"\n if str.length == 2\n @stock.draw(@discard)\n else\n case str[1]\n when \"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\"\n to = @tableau[str[1].to_i-1]\n @discard.move(1, to)\n when \"F\",\"f\"\n to = find_foundation(@discard)\n @discard.move(1, to)\n else\n raise \"NOPE #{str}\"\n end\n end\n end\n end",
"def user_move(start, finish)\n start , finish = Board.pos_to_coord(start), Board.pos_to_coord(finish)\n self[finish] = self[start]\n self[start] = NullPiece.instance\n self[finish].position = finish\n end",
"def make_move(move)\n @moves << move\n end",
"def moves\n # All pieces can stay in place\n [[0,0]]\n end",
"def move_piece!(start_pos,end_pos)\n piece=self[start_pos]\n raise 'Piece cannot move like that' unless piece.moves.include?(end_pos)\n self[end_pos]=piece\n self[start_pos]=sentinel\n piece.pos=end_pos\n nil\n end",
"def move_piece(start_pos, end_pos)\n raise InvalidMoveError unless valid_move?(start_pos, end_pos)\n if capture_move?(start_pos, end_pos)\n self[end_pos] = self[start_pos]\n self[start_pos] = NullPiece.instance\n else\n self[end_pos], self[start_pos] = self[start_pos], self[end_pos]\n end\n self[end_pos].pos = end_pos\n end",
"def move(move)\n to_word = move[0]\n from_words = move[1]\n\n # remove each of the \"from words\" from the board exactly once\n words_copy = @words.dup\n from_words.each do |word|\n index = words_copy.index(word)\n if index then\n words_copy.delete_at(index)\n else\n return \"Invalid move #{dictionary.format_move(move)} : Not enough #{word.inspect}s on the table.\"\n end\n end\n @words = words_copy\n\n # add the \"to word\" to the board\n @words << to_word\n\n return true\n end",
"def move\n\n\t\t# check landmarks and error variation inputs\n\t\tif !in_range || @error < 0\n\t\t\tstr = check_inputs(\"Move\")\n\t\t\treturn str\n\t\tend\n\n\t\t# traverse points array from 1 to 30\n\t\t@points.each_with_index do |point, index|\n\n\t\t\t# assign 1 if sensor reads current point as included in error variation\n\t\t\tif readSensor(index)\n\t\t\t\tpoint = 1\n\t\t\t\t@points[index] = point\n\t\t\tend\n\t\tend\n\tend",
"def move(direction)\n \n end",
"def get_move\n print \"Your move, #{@name}\\n\"\n from = select\n to = select\n [from,to]\n end",
"def move(from, to)\n @tasks.insert(index(to), @tasks.delete_at(index(from)))\n end",
"def move_dirs\n [\n [2, 1],\n [1, 2],\n [-1, 2],\n [-2, 1],\n [-2, -1],\n [-1, -2],\n [1, -2],\n [2, -1]\n ]\n end",
"def move_piece(start_pos,end_pos)\n begin \n raise \"No piece here to move\" if grid[start_pos[0]][start_pos[1]].nil?\n raise \"Can't move to this spot\" if end_pos[0] > 7 || end_pos[0] < 0 || end_pos[1] > 7 || end_pos[1] < 0 \n self[start_pos], self[end_pos] = self[end_pos],self[start_pos]\n end\n end",
"def add_turn(player_move, player_type)\n @@count = 0\n until @board.game_board[player_move][@@count] == \" \"\n @@count += 1\n end\n @board.game_board[player_move][@@count] = player_type\n @move_list.delete(player_move) if @@count == 5\n end",
"def format_move(move)\n to_word = move[0]\n from_words = move[1].join(\"+\")\n return \"#{from_words} -> #{to_word}\" \n end",
"def slide_move!(end_pos)\n board[end_pos] = self\n board.set_to_empty(self.pos)\n self.pos = end_pos\n end",
"def make_move(move)\n if @max_depth == @prev_rows.size\n puts(\"max_depth of #{@max_depth} reached\") if @verbose\n return nil\n end\n\n offset = move[GS_PLAY_IDX]\n from = move[GS_PLAY_PAT]\n to = move[GS_PLAY_REPL]\n\n if @cur_row.index(from, offset) != offset\n dump_plays\n raise \"invalid replacement: cur_row=#{@cur_row}, from=#{from}, offset=#{offset}\"\n end\n raise \"too wide: maxwidth= #{@max_width}\" if @cur_row.size - from.size + to.size > max_width\n\n cached_move = move.dup\n\n cached_raw_row = @cur_raw_row.dup\n @prev_rows.push(cached_raw_row)\n @played_moves.push(cached_move)\n @cur_raw_row[offset...offset + from.size] = to\n @cur_row = compute_cur_row(@cur_raw_row)\n cached_row = @cur_row.dup\n cached_move[GS_PLAY_RESULT] = cached_row\n @cur_row\n end",
"def move!(move)\n from = move[0]\n to = move[1]\n piece = self[from]\n\n #puts 'Moving piece from ' + from.to_s + ' to ' + to.to_s\n\n clear!(to)\n self[to] = piece\n self[from] = nil\n\n self\n end",
"def smove(*arguments)\n\t\t\t\t\tcall(\"SMOVE\", *arguments)\n\t\t\t\tend",
"def move(x_pos, y_pos, type)\n # convert y_pos and x_pos to proper array index integer!\n y_pos = y_pos.ord - 65\n x_pos = x_pos.to_i - 1\n\n # inputs move of type Z at X,Y (if not illegal!)\n return false unless @board[x_pos][y_pos].type == TYPE_EMPTY\n\n @board[x_pos][y_pos].type = type\n true\n end",
"def move\n\n end",
"def moves(board, start_pos)\n end",
"def move\n @position.shift unless @growing\n case @direction\n when 'down'\n @position.push(new_coords(head[0], head[1] + 1))\n when 'up'\n @position.push(new_coords(head[0], head[1] - 1))\n when 'left'\n @position.push(new_coords(head[0] - 1, head[1]))\n when 'right'\n @position.push(new_coords(head[0] + 1, head[1]))\n end\n @growing = @turned = false\n end",
"def move(arr, letter)\nresult = []\narr.each{|a|\nlist = get_transition(a, letter)\nif list != nil\nresult = result | list\nend\n}\nresult\nend",
"def move_piece!(start_pos, end_pos)\n null = NullPiece.instance\n if self[start_pos].class == King\n if self[start_pos].color == :black\n @black_king_pos = end_pos\n else\n @white_king_pos = end_pos\n end\n end\n if pawn_promotion?(start_pos, end_pos)\n color = self[start_pos].color\n self[start_pos] = null\n Queen.new(self, end_pos, color)\n else\n self[start_pos].pos = end_pos\n self[end_pos], self[start_pos] = self[start_pos], null\n end\n end",
"def slide_moves\n dirs = (@dir == :up ? UP_DIRS : DOWN_DIRS)\n dirs = DOWN_DIRS + UP_DIRS if king\n\n dirs.each_with_object([]) do |dir, moves|\n new_square = add_dir(pos, dir)\n unless !@board.on_board?(new_square) || @board[*new_square]\n moves << [pos, new_square]\n end\n end\n end",
"def move_to(x, y); end",
"def move(start, final_pos)\n raise MoveError.new \"There is no piece at that start position\" if self[start] == nil\n raise MoveError.new \"You can't move there.\" unless self[start].moves.include?(final_pos)\n raise MoveError.new \"You cannot put yourself in check\" if self[start].move_into_check?(final_pos)\n\n @taken_pieces << self[final_pos] if self[final_pos]\n make_move(start, final_pos)\n end",
"def move(array, position ,value = \"X\")\n position = position.to_i\n position = position - 1\n if array[position] != \"X\" and array[position] != \"O\"\n array[position] = value\n end\n return array\nend",
"def interpret_move(command)\n ensure_placed\n @robot.move_forward\n end",
"def move()\n case @mov_dir\n when :right\n if @coord_x == @max_x\n @max_x += 1 # Moving out of bounds. No need to do anything because Ruby rocks! :P\n end\n @coord_x += 1\n \n when :up\n if @coord_y == 0\n @map.unshift [] # Moving out of bounds. Adds a new line to the top\n @max_y += 1\n else\n @coord_y -= 1\n end\n \n when :down\n if @coord_y == @max_y\n @max_y += 1\n @map.push [] # Moving out of bounds. Adds a new line to the bottom\n end\n @coord_y += 1\n \n when :left\n if @coord_x == 0\n @map.each do |a| # Moving out of bounds. Adds a new line to the left\n a.unshift ' ' \n end\n @max_x += 1\n else\n @coord_x -= 1\n end\n end\n end",
"def change(move)\n value = self.dup\n value[0] += move[0]\n value[1] += move[1]\n Position.new(value)\n end",
"def move(from, to)\n index = self.delete_at(from)\n self.insert(to, index)\n end",
"def move\n check_placement\n\n new_position = make_move(current_position, direction)\n position(new_position[0], new_position[1], @table.size)\n end",
"def get_move\n cols = %w(a b c d e f g h)\n rows = %w(8 7 6 5 4 3 2 1)\n\n from_pos, to_pos = nil, nil\n until from_pos && to_pos\n @display.draw\n if from_pos\n row, col = from_pos\n piece = @display.board[from_pos].class\n puts \"#{piece} at #{cols[col]}#{rows[row]} selected. Where to move to?\"\n to_pos = @display.get_keyboard_input\n else\n @display.reset_errors_notification\n puts \"#{@color.capitalize}'s move\"\n puts 'What piece do you want to move?'\n selection = @display.get_keyboard_input\n from_pos = selection if selection && valid_selection?(selection)\n end\n end\n [from_pos, to_pos]\n end",
"def move_piece(start_pos, end_pos)\n unless self.valid_position?(start_pos)\n raise ArgumentError.new(\"Invalid start position, must be between '[0, 0]' and '[7, 7]'\") \n end\n unless self.valid_position?(end_pos)\n raise ArgumentError.new(\"Invalid end position, must be between '[0, 0]' and '[7, 7]'\") \n end\n if self[end_pos].is_a?(NullPiece)\n self[start_pos], self[end_pos] = self[end_pos], self[start_pos]\n end\n end",
"def moves\n # warn \"Explorer: #{explorer.last}\"\n # warn @robots.map(&:last)\n # warn @items.map(&:last)\n\n clear_tasks\n assign_tasks\n\n @my_bots.map(&:next_command)\n end",
"def parse_moves\n s0 = @scanner.pos\n s1 = parse_firstboard\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n parse_split\n s2 = []\n s3 = parse_move\n while s3 != :failed\n s2 << s3\n s3 = parse_move\n end\n parse_result\n @reported_pos = s0\n s0 = s2.unshift(s1)\n end\n s0\n end",
"def move2end\n iword = $indexy[0]\n $indexy.delete_at(0)\n $indexy.push(iword)\nend",
"def move(move = {})\n begin\n move!(move)\n rescue => e\n errors.add :base, e.message\n return false\n end\n end",
"def move_to_index(move)\n Game.index_to_row_column(MOVE_NAMES.index(move))\n end",
"def move!(start, end_pos)\n # move without checking if it puts you in check\n old_x, old_y = start\n new_x, new_y = end_pos\n piece = @board[old_x][old_y]\n piece.position = end_pos\n \n # update board\n @board[new_x][new_y] = piece\n @board[old_x][old_y] = nil\n end",
"def move(source, destination)\n if isLegal?(source,destination)\n if source==1\n disk_to_move = @@tower_1.pop\n elsif source==2\n disk_to_move = @@tower_2.pop\n elsif source==3\n disk_to_move = @@tower_3.pop\n else\n puts(\"the source should be 1,2,or 3.\")\n end\n \n if destination ==1 \n @@tower_1.push(disk_to_move)\n elsif destination == 2 \n @@tower_2.push(disk_to_move)\n elsif destination == 3 \n @@tower_3.push(disk_to_move)\n end \n else\n puts(\"Sorry that was an incorrect move. Please review the rules and try again.\")\n end\n end",
"def moves\n # overridden in slideable/stepable modules\n end",
"def move\n \n end",
"def move\n \n end",
"def find_start_and_end(move)\n mv_start = move[0..1].split('')\n mv_end = move[3..4].split('')\n\n start_row = 8 - mv_start[1].to_i\n start_col = @@horizontal_key[mv_start[0].downcase]\n start_location = [start_row, start_col]\n\n end_row = 8 - mv_end[1].to_i\n end_col = @@horizontal_key[mv_end[0].downcase]\n end_location = [end_row, end_col]\n\n [start_location, end_location]\n end",
"def move(key, options = {})\n if options.include?(:position)\n options[:position] = options[:position].downcase.capitalize\n end\n fetch({:method => :post, :key => \"#{key}/move\", :body => options})\n end",
"def assign_move\n move = gets.chomp\n assign_move unless valid_input?(move)\n move.split(',').map(&:to_i)\n end",
"def move(direction = 'NEXT')\n statement = \"move #{direction} from #{@name}\"\n @connection.exec(statement)\n end",
"def move(array,position,value = \"X\")\n array[position.to_i - 1] = value\nend",
"def move_piece(piece, start_arr, finish_arr)\n\t\tputs \"#{piece} at #{start_arr} moves to #{finish_arr}.\"\n\t\t@board[finish_arr] = @board[start_arr]\n\t\t@board[start_arr] = \"*\"\t\t\n\tend",
"def advance_move_route_index\n @move_route_index += 1 if @move_succeed || @move_route.skippable\n end",
"def move arr, pos\n while arr[pos] == -1\n pos += 1\n end\n pos\nend",
"def move # takes (x, y, direction) from Rover\n\t\tif direction == \"N\"\n\t\t\t@y += 1\n\t\telsif direction == \"W\"\n\t\t\t@x -= 1\n\t\telsif direction == \"S\"\n\t\t\t@y -= 1\n\t\telsif direction == \"E\"\n\t\t\t@x += 1\n\t\telse \n\t\t\treturn \"The input direction enterned is wrong\"\n\t\tend\n\tend",
"def move(start, finish)\n\t\ta, b = start\n\t\tx, y = finish\n\t\tif @board[a][b].piece.class.name == \"Pawn\"\n\t\t\t@board[a][b].piece.double = \"false\"\n\t\t\tif y - b == 2 || y - b == -2\n\t\t\t\t@board[a][b].piece.en_passant = true\n\t\t\tend\n\t\tend\n\t\tif @board[a][b].piece.class.name == \"King\" || @board[a][b].piece.class.name == \"Rook\"\n\t\t\t@board[a][b].piece.castling = false\n\t\tend\n\t\tif @board[a][b].piece.class.name == \"King\" && (x - a >= 2 || x - a <= 2)\n\t\t\tif (x - a >= 2)\n\t\t\t\tcastle_right(a, b, x, y)\n\t\t\telse\n\t\t\t\tcastle_left(a, b, x, y)\n\t\t\tend\n\t\t\treturn\n\t\tend\n\t\t@board[x][y].piece = @board[a][b].piece\n\t\t@board[a][b].piece = nil\n\t\tremove_en_passant(x, y)\n\t\tif @board[x][y].piece.class.name == \"Pawn\"\n\t\t\tcheck_promotion(x, y)\n\t\tend\n\tend",
"def moves \r\n move = []\r\n move_directions do |dir|\r\n move += grow_unblocked_moves_in_dir(*dir)\r\n end\r\n move\r\n end",
"def move(start, finish, board)\n if start.is_a?(Integer) || start.length != 2\n 'Invalid start location'\n elsif !finish.is_a?(Array) || finish.length != 2\n 'Invalid finish location'\n else\n valid_moves = valid_moves(start, board)\n check_move_validity(start, finish, board, valid_moves)\n end\n end",
"def moves_array\n\t\t@field[1]\n\tend",
"def moves\n # create array to collect moves\n final_array = []\n\n\n\n pos = self.move_dirs\n\n pos.each do |optional_pos|\n\n end\n\n # Note do these logics for all the optional positions \n spec_dx = pos[0]\n spec_dy = pos[1]\n\n possible_movements = grow_unblocked_moves_in_dir(spec_dx, spec_dy)\n possible_movements\n # ending\n\n\n # iterate over each of the directions in which a slideable piece can move\n # use the Piece subclass' `#move_dirs` method to get this info\n # for each direction, collect all possible moves in that direction\n # and add them to your moves array \n # (use the `grow_unblocked_moves_in_dir` helper method)\n\n # return the final array of moves (containing all possible moves in all directions)\n end",
"def move_disk(from,to)\n @towers[to] << @towers[from][-1]\n @towers[from].pop\n nil\nend"
] |
[
"0.6621405",
"0.6583248",
"0.6370971",
"0.626844",
"0.6234827",
"0.6213427",
"0.61882627",
"0.6156398",
"0.61142164",
"0.60907453",
"0.6069991",
"0.6069991",
"0.6053732",
"0.6040931",
"0.6036183",
"0.6024046",
"0.6011319",
"0.6011319",
"0.60095996",
"0.60095996",
"0.6006472",
"0.59853417",
"0.5978227",
"0.5967561",
"0.5936421",
"0.5895988",
"0.5865001",
"0.58629674",
"0.585526",
"0.585526",
"0.58481187",
"0.58452797",
"0.5838019",
"0.58353144",
"0.58353144",
"0.58287495",
"0.581015",
"0.5801432",
"0.5801432",
"0.5797108",
"0.57947123",
"0.5782064",
"0.57812756",
"0.5761647",
"0.57577455",
"0.57520324",
"0.5749449",
"0.57483995",
"0.57433647",
"0.5734904",
"0.57222617",
"0.57098097",
"0.56974506",
"0.5684443",
"0.5662898",
"0.5653381",
"0.5647532",
"0.5642819",
"0.56411374",
"0.56163996",
"0.56109023",
"0.5609225",
"0.56027234",
"0.5602289",
"0.55857676",
"0.55811507",
"0.5569229",
"0.55600715",
"0.5555069",
"0.5549891",
"0.55349594",
"0.55288184",
"0.5528091",
"0.5517752",
"0.5514637",
"0.55123913",
"0.54976624",
"0.5492892",
"0.5490004",
"0.5484848",
"0.54824436",
"0.54772675",
"0.547706",
"0.54711586",
"0.547097",
"0.547097",
"0.5469424",
"0.5462302",
"0.54603887",
"0.5458711",
"0.5457481",
"0.54541504",
"0.54474264",
"0.54464304",
"0.5446391",
"0.54447633",
"0.54440093",
"0.54433507",
"0.54402804",
"0.54397714",
"0.5438475"
] |
0.0
|
-1
|
pull value of letter from index
|
def score(word)
point_values_hash = point_values
point_values(word)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get index\n @letters[index]\n end",
"def char_at(index)\n self.to_array[index.to_i]\n end",
"def char_at(index)\n self.to_array[index.to_i]\n #@word = TILE_VALUES[index]\n end",
"def char_at(index)\n\tself.to_array[index.to_i]\n end",
"def index_to_letter(index)\n alphabet_array[index]\n end",
"def char_at(index)\n\tself.to_array[index.to_i]\nend",
"def index_letter\n last_name[0..0]\n end",
"def index_to_letter(index)\n ALPHA26[index]\n end",
"def get_character(full_string, index)\n full_string[index]\nend",
"def get_char at\n index = range_correct_index(at)\n return internal_object_get(index + 1)\n end",
"def get_letter(word, index)\n if word[index] == 'Q' && index+1 < word.length && word[index+1] == 'U'\n return 'Qu'\n end\n\n return word[index]\n end",
"def character(index = nil)\n return '' if collection && collection.empty?\n return collection[-1] unless index\n\n by_index(index)\n end",
"def get_character(full_string, index) # defines a method get_character with two parameters full_string and index\n full_string[index] # looks for index within the variable full_string ????\nend",
"def [](letter)\n @letters[letter]\n end",
"def az_index c\n c.upcase.ord - 'A'.ord\nend",
"def character(index = nil)\n return '' if line && line.empty?\n return line[-1] unless index\n\n Vedeu::Editor::Item.by_index(line, index)\n end",
"def letter_to_index(letter)\n ALPHA26.index(letter.upcase)\n end",
"def letter_value(letter, tile_vals)\n\t\treturn tile_vals[letter]\n\tend",
"def letter_to_index(letter)\n alphabet_array.index(letter.upcase)\n end",
"def index_to_letter(idx)\n letter = \"\"\n while true\n idx -= 1\n r = idx % 26\n idx /= 26\n letter = (r + 97).chr + letter\n break if idx <= 0\n end\n letter\n end",
"def [](index)\n to_s[index]\n end",
"def current_letter\n @letters[self.position]\n end",
"def get_rowcol_from_index(index)\n letter = get_col_from_index(index)\n number = get_row_from_index(index)\n \"#{letter}#{number}\"\n end",
"def letter_index(letter)\n @places = []\n @split_word.each_with_index do |char, index|\n if char == letter\n @places << index\n end\n end\n end",
"def [](index)\r\n words[index]\r\n end",
"def reverse_letter(letter)\r\n alphabet = (\"a\"..\"z\").to_a\r\n index = alphabet.index(letter) \r\n alphabet[index-1]\r\nend",
"def [](word)\n @index[word]\n end",
"def get_index key, vsz=999\n i = $IDX.index(key)\n return i+$stact if i\n #sz = $IDX.size\n zch = nil\n if vsz > 25\n if key == \"z\" || key == \"Z\"\n #print key\n zch = get_char\n #print zch\n i = $IDX.index(\"#{key}#{zch}\")\n return i+$stact if i\n end\n end\n return nil\nend",
"def at(index)\n self[index]\n end",
"def current()\n @string[@index...(@index+1)]\n end",
"def last_index(str, char)\n\tarr = str.split(\"\")\n \tarr2 = []\n \t# print arr\n \tarr.map.with_index do |letter, i|\n \tif letter == char\n \tarr2 << i\n end\n end\n \tputs\n \treturn arr2[-1]\nend",
"def get_index key, vsz=999\n i = $IDX.index(key)\n return i+$stact if i\n #sz = $IDX.size\n zch = nil\n if vsz > 25\n if key == \"z\" || key == \"Z\"\n print key\n zch = get_char\n print zch\n i = $IDX.index(\"#{key}#{zch}\")\n return i+$stact if i\n end\n end\n return nil\nend",
"def char_at(column)\n line[column, 1]\n end",
"def [](index)\n case index\n when Integer\n values[index]\n when self\n values[index.index]\n else\n name = index.to_s\n case name\n when /\\A(\\d+)\\Z/\n return values[$1.to_i]\n when /\\A[a-z]/\n name = name.to_str.gsub(/(?:\\A|_)(.)/) { $1.upcase }\n end\n with_name(name)\n end\n end",
"def locate(letter)\n key_loc = @key.index(letter)\n [key_loc/ 5, key_loc % 5]\n end",
"def at(index); end",
"def by_index(index)\n @arr[index]\n end",
"def uindex_to_index(char_index)\n return nil if char_index.nil?\n if char_index < 0 || char_index > jlength\n raise RangeError, 'index out of range'\n end\n \n chars = split('')\n byte_index = 0\n char_index.times do |i|\n byte_index += chars[i].length\n end\n byte_index\n end",
"def [](word1)\n @index[word1]\n end",
"def findARG(thing, index)\r\n\r\n aux = thing.strip.downcase\r\n result = aux.split\r\n\r\n first_word = result[0]\r\n second_word = result[1]\r\n\r\n len = first_word.length\r\n\r\n if index == 0 && first_word.start_with?(\"!\")\r\n target = first_word.slice(1..len)\r\n return target\r\n end\r\n\r\n if index == 1\r\n return second_word\r\n end\r\nend",
"def at(index)\n each.with_index { |v, i| return v if i == index }\n return nil\n end",
"def change chars, value\n if chars.index(value) == chars.size - 1\n chars[0]\n else\n chars[chars.index(value) + 1]\n end\n\tend",
"def [](index)\n @words[index].word\n end",
"def get_char\n @look = @expression[@number]\n @number +=1\nend",
"def get_index key, vsz=999\n # @log.debug \"Etners get_index with #{key}\"\n i = convert_key_to_index key\n return i if i\n\n if vsz > 25\n if key == 'z' || key == 'Z'\n last_line\n print key\n zch = get_char\n print zch\n i = convert_key_to_index(\"#{key}#{zch}\")\n # @log.debug \"convert returned #{i} for #{key}#{zch}\"\n return i if i\n # i = IDX.index\n # return i + @stact if i\n end\n end\n nil\nend",
"def extract_word_index\n self.word_index = self.title[0].upcase\n end",
"def last_cell_letter\n return unless @dimension\n\n @dimension.scan(/:([A-Z]+)/)&.first&.first || 'A'\n end",
"def vowel(vowel_letter)\r\n vowel = \"aeiou\"\r\n current_location = vowel.index(vowel_letter)\r\n new_vowel = current_location + 1\r\n if vowel.index(vowel_letter) == 4\r\n results = vowel[0]\r\n else\r\n results = vowel[new_vowel]\r\n end\r\n results\r\nend",
"def get_col_from_index(idx)\n idx%cols\n end",
"def index(key, size)\n char_value = 0\n # Adds together all of the ASCII values for each character into char_value.\n for letter in key.chars do\n char_value += letter.ord\n end\n # Increments char_value until its length equals desired size.\n until char_value.to_s.length == 7\n char_value*=11\n end\n\n return char_value%size\n end",
"def charChange(char)\n alpha = \"abcdefghijklmnopqrstuvwxyz\"\n charPosition = alpha.index(char)\n newChar = alpha[charPosition - 1]\n return newChar\nend",
"def get_col_from_index(index)\n if index % 8 == 0\n return 8\n else\n return index % 8\n end\n end",
"def nth_char(arr)\n arr.map.with_index { |word, idx| word[idx] }.join\nend",
"def get_view_by_index(idx)\n value = idx / 4 + (idx % 4 == 0 ? 1 : 2)\n case\n when value <= 10\n return value.to_s\n when value == 11\n return 'J'\n when value == 12\n return 'Q'\n when value == 13\n return 'K'\n when value == 14\n return 'A'\n end\n end",
"def get_swapped_char (letter)\n\tif is_vowel(letter)\n\t\tget_next_vowel(letter)\n\telse\n\t\tget_next_consonant(letter)\n\tend\nend",
"def get_swapped_char (letter)\n\tif is_vowel(letter)\n\t\tget_next_vowel(letter)\n\telse\n\t\tget_next_consonant(letter)\n\tend\nend",
"def char\n self[@char]\n end",
"def [](index)\n unless index > (size - 1)\n if numeric?\n to_i[index]\n else\n char = val[val.size - 1 - index]\n if char == 'x'\n X.new\n elsif char == 'z'\n Z.new\n else\n char.to_i\n end\n end\n end\n end",
"def getChar\n if @index <= @code.size - 1\n return @code[@index] if !@code[@index].nil?\n end\n # If nil return empty string.\n return nil\n end",
"def lastChar(str, l_index)\n if alpha(str[l_index])\n return str[l_index], l_index\n end\n lastChar(str, l_index -= 1)\n end",
"def getCharByOffset(char, offset=0)\n # Chars could be in the upper alphabet, the lower alphabet, or neither.\n indexUpper = $ALPHABET.index(char)\n indexLower = $alphabet.index(char)\n if indexUpper\n i = calculateOffset(indexUpper, offset)\n char = $ALPHABET[i] # Get the char at that index\n elsif indexLower\n i = calculateOffset(indexLower, offset)\n char = $alphabet[i]\n end\n char\n end",
"def index(element); end",
"def [](n)\n @chars[n]\n end",
"def subone(x)\n counter=0\n alphabet=\"abcdefghijklmnopqrstuvwxyz\"\n while counter < x.length\n letter=x[counter]\n indexnumber=alphabet.index(letter)\n indexnumber-=1\n alphabet[indexnumber]\n x[counter] = alphabet[indexnumber]\n counter+=1\n end\n puts x\nend",
"def get_map_letter_index(x_value)\n\tif x_value >= 0 && x_value <= 50\n\t\treturn 'A'\n\telsif x_value >= 50 && x_value <= 100\n\t\treturn 'B'\n\telsif x_value >= 100 && x_value <= 150\n\t\treturn 'C'\n\telsif x_value >= 150 && x_value <= 200\n\t\treturn 'D'\n\telsif x_value >= 200 && x_value <= 250\n\t\treturn 'E'\n\telsif x_value >= 250 && x_value <= 300\n\t\treturn 'F'\n\telsif x_value >= 300 && x_value <= 350\n\t\treturn 'G'\n\telsif x_value >= 350 && x_value <= 400\n\t\treturn 'H'\n\telsif x_value >= 400 && x_value <= 450\n\t\treturn 'I'\n\telsif x_value >= 450 && x_value <= 500\n\t\treturn 'J'\t\t\n\telse\n\t\treturn '?'\n\tend\nend",
"def arrayplace (letter)\n array= \"abcĉdefgĝhĥijĵklmnoprsŝtuŭvz \".chars\n array.find_index(letter)\nend",
"def last_index(str, char)\n return str.chars.each_with_index.select { |key, value| key == char }.map { |found| found.last }.last\nend",
"def print_index\n\t\t#zet de index nr in text_index\n\t\ttext_index = \"Hello, Ruby.\".index /Ruby/\n\t\t#print text_index\n\t\tputs text_index\n\tend",
"def char(char, other_alphabet)\n self[other_alphabet.index(char)]\n end",
"def at(index)\n \t@array[index]\n end",
"def get_col_from_index(index)\n index % 8 == 0 ? 8 : index % 8\n end",
"def char(index)\n s = case @raw_text[index + 1].ord\n when 0x4f, 0x0b, 0x32; :normal_protected\n when 0x6e, 0x22; :normal_unprotected\n when 0x50, 0x3a; :intensified_protected\n when 0x4e, 0x2a; :intensified_unprotected\n else @raw_text[index + 1,1].retain_to_user\n end\n s\n end",
"def letter_select array, letter\n # iterates\n array.each do |value|\n # checks for letter at each index\n if value.include?(letter)\n # if letter is included in value at index, puts value\n puts value\n end\n end\n end",
"def sub_char(entry)\n\t\t\tcol, row = coord(entry)\n\t\t\tADFGVX[row] + ADFGVX[col]\n\t\tend",
"def get_index(index)\n return self.at(index)\n end",
"def index(p0) end",
"def index(p0) end",
"def get(key)\n row = key >> 10\n column = @a[row].index{|(i,v)| i == key}\n if column\n return @a[row][column][1] \n else\n return -1\n end\n end",
"def strip_index(input); end",
"def get_actor(index)\n @data[index]\n end",
"def shift_character_by(char, index)\n new_ord = (char.ord + index)\n if new_ord > LAST_CHARACTER_ORD\n new_ord -= ALPHABET_SIZE\n elsif new_ord < FIRST_CHARACTER_ORD\n new_ord += ALPHABET_SIZE\n end\n new_ord.chr\n end",
"def last_index(str, char)\n \tarry = []\n\tstr.split(\"\").map.with_index do|i, indx|\n\tif i == char\n arry << indx\n end\n end\n return arry[-1]\nend",
"def guess_letter\n @unused_letters.pop\n end",
"def last_index(str, char)\n arr = str.chars\n\n setupArr = arr.map.with_index do |ele, idx|\n\n if ele == char\n idx\n else\n 0\n end\n end\n\n returnStr = setupArr.select { |ele| ele > 0 }\n\n return returnStr[-1]\n\nend",
"def [](index)\n line[index]\n end",
"def translate_column(letter)\n @column = letter.downcase.ord - 97\n end",
"def retrieve_element_from_index(array, index_number)\n array[index_number]\nend",
"def retrieve_element_from_index(array, index_number)\n array[index_number]\nend",
"def index_of_char(string, letter)\n i = 0\n while i < string.length\n if string[i] == letter\n return i\n end\n i += 1\n end\n return nil\nend",
"def get_letter\n\t\t# move the 'a' and 'b' jokers \n\t\tmove_joker_a\n\t\tmove_joker_b\n\n\t\t# get their new positons\n\t\tnew_a = @deck_of_cards.index(Card.new(:joker, 1))\n\t\tnew_b = @deck_of_cards.index(Card.new(:joker, 2))\n\n\t\t# perform a triple split around the positions of the jokers\n\t\ttriple_split(new_a, new_b) if new_a < new_b\n\t\ttriple_split(new_b, new_a) if new_b < new_a\n\n\t\t# perform a count cut with the value of the bottom card\n\t\tcount_cut(@deck_of_cards[53].value)\n\n\t\t# now that the deck has been properly mutated, we can now\n\t\t# get the output lettere by getting the value of the top card in the deck\n\t\t# and stepping down that many cards (including the top) and converting\n\t\t# the value of the ending card to a letter\n\t\tfinal_val = @deck_of_cards[@deck_of_cards[0].value].value\n\tend",
"def firstChar(str, f_index)\n if alpha(str[f_index])\n return str[f_index], f_index\n end\n firstChar(str, f_index += 1) \n end",
"def find_missing_letter(arr)\n alphabets = (arr[0]..arr[-1]).to_a # [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]\n \n (alphabets - arr)[0] # \"e\"\nend",
"def nieuwe_letter(i, nummer)\n alfabet = ('a'..'z').to_a\n alfabet_hoog = ('A'..'Z').to_a\n\n# index van letter krijgen\nif alfabet.index i\n huidig_nummer = alfabet.index i\nelse\n huidig_nummer = alfabet_hoog.index i\nend\n\n# Index van vertaalde letter krijgen\nif nummer > 0\n nieuw_nummer = huidig_nummer + nummer\nif nieuw_nummer > 26\n nieuw_nummer = nieuw_nummer - 26\nend\nend\n\n# Gebruik index voor letters (vertaald)\nif alfabet.index\n new_let = alfabet[nieuw_nummer]\nelse\n new_let = alfabet_hoog[nieuw_nummer]\nend\n\nend",
"def remove_nth_letter(string, n)\n\nend",
"def [](index)\n @val[index]\n end",
"def [](word_index)\n word_list[word_index]\n end",
"def rl_get_char()\r\n if (@push_index == @pop_index)\r\n return nil\r\n end\r\n key = @ibuffer[@pop_index]\r\n @pop_index += 1\r\n\r\n if (@pop_index >= @ibuffer_len)\r\n @pop_index = 0\r\n end\r\n\r\n return key\r\n end",
"def test_index word, guess, index\r\n (word[index] == guess)? \"!\" : \"?\" #if the indexes match it means outputs a \"!\", else it means the letter exists in the word but not in that exact index and outputs a \"?\" \r\nend",
"def string_extractor(array, index=0)\n\t\t\t\tstring = String.new; next_index = nil\n\t\t\t\t(index..index+9000).each do |item|\n\t\t\t\t\tcurr = array[item]; next_index = item+1\n\t\t\t\t\tnext_item = array[next_index]\n\t\t\t\t\tif not curr.nil? \n\t\t\t\t\t\tstring << curr.chr\n\t\t\t\t\telsif next_item.nil? && string.length >= 1\n\t\t\t\t\t\tbreak \n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t@index = next_index\n\t\t\t\tstring.chomp\n\t\t\tend",
"def get(index)\n \n end",
"def index(key, size)\n value = ascii_value(key) % size\n return value\n end"
] |
[
"0.7765185",
"0.735024",
"0.73303735",
"0.71796054",
"0.71541905",
"0.7127811",
"0.7054758",
"0.69439024",
"0.6931822",
"0.69289386",
"0.68637824",
"0.6779648",
"0.6716979",
"0.66540015",
"0.6607392",
"0.6531172",
"0.6512586",
"0.6456748",
"0.6415772",
"0.641529",
"0.6389533",
"0.63565415",
"0.6304663",
"0.62613773",
"0.62509006",
"0.6230009",
"0.61394656",
"0.6128353",
"0.61176133",
"0.6100838",
"0.60989106",
"0.6090844",
"0.6075877",
"0.60756713",
"0.6057896",
"0.60393816",
"0.6039301",
"0.6023192",
"0.60142124",
"0.59991693",
"0.5989872",
"0.5988519",
"0.5985765",
"0.59857494",
"0.5984383",
"0.5971661",
"0.59497905",
"0.5947942",
"0.5946289",
"0.5944292",
"0.5929195",
"0.5909789",
"0.5909514",
"0.59071594",
"0.5890983",
"0.5890983",
"0.58868796",
"0.5881818",
"0.58786654",
"0.58713764",
"0.5870547",
"0.58490825",
"0.5835391",
"0.5832162",
"0.58228475",
"0.5819407",
"0.5813112",
"0.58052224",
"0.58036906",
"0.5801958",
"0.5795975",
"0.5792796",
"0.5791798",
"0.5787389",
"0.57842636",
"0.57696044",
"0.57696044",
"0.57691455",
"0.57636595",
"0.57631356",
"0.5762674",
"0.5758069",
"0.57575697",
"0.57517153",
"0.57500815",
"0.5748646",
"0.5747208",
"0.5747208",
"0.57464564",
"0.5739511",
"0.5735257",
"0.57310647",
"0.5728472",
"0.57225776",
"0.5719238",
"0.5703441",
"0.5702689",
"0.5695375",
"0.56893724",
"0.5688935",
"0.5685369"
] |
0.0
|
-1
|
need to order through the hash according to the assigned key in the point_values method hash
|
def point_values
{
"A"=>1, "B"=>3, "C"=>3, "D"=>2,
"E"=>1, "F"=>4, "G"=>2, "H"=>4,
"I"=>1, "J"=>8, "K"=>5, "L"=>1,
"M"=>3, "N"=>1, "O"=>1, "P"=>3,
"Q"=>10, "R"=>1, "S"=>1, "T"=>1,
"U"=>1, "V"=>4, "W"=>4, "X"=>8,
"Y"=>4, "Z"=>10
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ordered_values; end",
"def hash\n @points.inject(0) { |sum, point| sum += point.x + point.y }\n end",
"def move_points(hash)\n\n\t\tpoints = Hash.new\n\n\t\tgc_hash = hash.select { |k,v| k.to_s.include?('gc') }\n\t\toc_hash = gc_hash.select { |k,v| v.include?('OC') }\n\n\t\t# Calculate OC count to calculate probablity.\n\t\tpoints[:oc_enumerator] = prob_points(oc_hash)\n\t\tpoints[:oc_probability] = return_rational(points[:oc_enumerator]).to_f\n\t\tpoints[:dc] = calculate_gc_dc_roll_probability(points[:oc_enumerator])\n\n\t\t# Calculate TT Roll in GC\n\t\tpoints[:gc_tt_enumerator] = calculate_gc_tt_roll_probability(hash)\n\t\tpoints[:gc_tt_roll] = return_rational(calculate_gc_tt_roll_probability(hash))\n\t\t\n\t\t# Create Symbols for Points\n\t\tfor i in 2..12 do\n\t\t\tdc_points = \"dc%02d_points\" % i\n\t\t\tpoints[dc_points.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\t\t\n\t\tpoints[:reverse] = 0\n\t\tpoints[:specialty_roll_probability_in_oc] = 0\n\n \t\tfor i in 1..6 do\n\t\t\ts_points = \"s#{i}_points\"\n\t\t\tpoints[s_points.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n \t\tpoints[:s_roll_prob_dq] = 0\n\t\tpoints[:s_roll_prob_pa] = 0\n\t\tpoints[:s_roll_prob_sub] = 0\n\t\tpoints[:s_roll_prob_xx] = 0\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\toc_points = \"oc%02d_points\" % i\n\t\t\tpoints[oc_points.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\toc_dq = \"oc%02d_dq\" % i\n\t\t\tpoints[oc_dq.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\toc_pa = \"oc%02d_pa\" % i\n\t\t\tpoints[oc_pa.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\toc_sub = \"oc%02d_sub\" % i\n\t\t\tpoints[oc_sub.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\toc_xx = \"oc%02d_xx\" % i\n\t\t\tpoints[oc_xx.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\t\t\n \t\tpoints[:oc_ropes_roll_probability] = 0\n \t\tpoints[:ropes_s_roll_probability] = 0\n\n \t\t# TODO: Refactor this into one method\n \t\tfor i in 2..12 do\n\t\t\tr_points = \"ro%02d_points\" % i\n\t\t\tpoints[r_points.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\tr_dq = \"ro%02d_dq\" % i\n\t\t\tpoints[r_dq.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\tr_pa = \"ro%02d_pa\" % i\n\t\t\tpoints[r_pa.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\tr_sub = \"ro%02d_sub\" % i\n\t\t\tpoints[r_sub.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\tr_xx = \"ro%02d_xx\" % i\n\t\t\tpoints[r_xx.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\tpoints[:sub_numerator] = 0\n\t\tpoints[:tag_save_numerator] = 0\n\n\t\t# Determine Points for DC Rolls\n\t\tdc_hash = hash.select { |k,v| k.to_s.include?('dc') }\n\t\tdc_hash.each { | k,v|\n\t\t\tif v == \"A\"\n\t\t\t\tpoints[\"#{k}_points\".to_sym] = DC_A\n\t\t\telsif v == \"C\"\n\t\t\t\tpoints[\"#{k}_points\".to_sym] = DC_C\n\t\t\telse\n\t\t\t\tpoints[\"#{k}_points\".to_sym] = DC_B\n\t\t\tend\n\t\t}\n\n\t\t# Calculate Reverse Roll in DC\n\t\treverse_roll = 0\n\t\tr_hash = hash.select { |k,v| k.to_s.include?('dc') && v.downcase.include?('reverse') }\n\t\tpoints[:reverse] = prob_points(r_hash)\n\n\t\t# Determine (S) Points\n\t\tpoints[:s1_points] = hash[:s1].split[0].to_i\n \t\tpoints[:s2_points] = hash[:s2].split[0].to_i\n \t\tpoints[:s3_points] = hash[:s3].split[0].to_i\n \t\tpoints[:s4_points] = hash[:s4].split[0].to_i\n \t\tpoints[:s5_points] = hash[:s5].split[0].to_i\n \t\tpoints[:s6_points] = hash[:s6].split[0].to_i\n\n \t\to_moves = hash.select { |k,v| k.to_s.include?('oc') }\n \t\to_moves.each { |k,v|\n \t\t\tkey = \"#{k}_points\".to_sym\n \t\t\tm = remove_move(v)\n \t\t\tpoints[key] = m\n \t\t}\n\n \t\tr_moves = hash.select { |k,v| k.to_s.include?('ro') }\n \t\tr_moves.each { |k,v|\n \t\t\tkey = \"#{k}_points\".to_sym\n \t\t\tm = remove_move(v)\n \t\t\tpoints[key] = m\n \t\t}\n\n \t\t# Get Specialty Roll Numerator in OC\n \t\ts = hash.select { |k,v| k.to_s.include?('oc') && v.include?('(S)') }\n \t\tpoints[:specialty_roll_enumerator_in_oc] = prob_points(s)\n \t\tpoints[:specialty_roll_probability_in_oc] = return_rational(points[:specialty_roll_enumerator_in_oc])\n\n \t\t# Get Specialty Roll Probability-DQ (x/6)\n \t\tpoints[:s_roll_prob_dq] = get_s_extra_values(hash, '(DQ)')\n \t\tpoints[:s_roll_prob_pa] = get_s_extra_values(hash, 'P/A')\n\t\tpoints[:s_roll_prob_sub] = get_s_extra_values(hash, '*')\n\t\tpoints[:s_roll_prob_xx] = get_s_extra_values(hash, '(xx)')\n \t\t\t\n\t\t# Find DQ, P/A, * and XX Values in OC and Ropes\n\t\t\n \t\tdq_hash = create_value_hash(hash, \"(DQ)\")\n \t\tpa_hash = create_value_hash(hash, \"P/A\")\n \t\tsub_hash = create_value_hash(hash, \"*\")\n \t\txx_hash = create_value_hash(hash, \"(xx)\")\n\n \t\tdq_hash.each { |k,v| \n \t\t\tkey = k.to_s + \"_dq\"\n \t\t\tpoints[key.to_sym] = 1\n \t\t}\n\n\t\tpa_hash.each { |k,v| \n \t\t\tkey = k.to_s + \"_pa\"\n \t\t\tpoints[key.to_sym] = 1\n \t\t} \t\n\n \t\tsub_hash.each { |k,v| \n \t\t\tkey = k.to_s + \"_sub\"\n \t\t\tpoints[key.to_sym] = 1\n \t\t}\n\n \t\txx_hash.each { |k,v| \n \t\t\tkey = k.to_s + \"_xx\"\n \t\t\tpoints[key.to_sym] = 1\n \t\t}\n\n \t\t# Determine Ropes Roll Enumerator\n \t\toc_ropes_hash = hash.select { |k,v| v == 'Ropes' }\n\n \t\tpoints[:oc_ropes_roll_probability] = prob_points(oc_ropes_hash)\n\n \t\t# Determine Enumerator of (S) rolls in Ropes\n \t\tropes_s_hash = hash.select { |k,v| k.to_s.include?(\"ro\") && v.include?('(S)') }\n \t\tpoints[:ropes_s_roll_probability] = prob_points(ropes_s_hash)\n\n \t\tpoints[:prioritys] = hash[:prioritys].to_i\n \t\tpoints[:priorityt] = hash[:priorityt].to_i\n\n \t\tpoints[:sub_numerator] = sub_tag_numerator(hash[:sub])\n \t\tpoints[:tag_save_numerator] = sub_tag_numerator(hash[:tag])\n\n \t\tpoints[:sub_prob] = return_rational(points[:sub_numerator]).to_f\n \t\tpoints[:tag_prob] = return_rational(points[:tag_save_numerator]).to_f\n\n\t\treturn points\n\tend",
"def hash_keys\n [:x, :y]\n end",
"def point_keys\n @_point_keys\n end",
"def sorted_keys; end",
"def key_map\r\n hash = {}\r\n hash['total'] = total\r\n hash['values'] = values\r\n hash\r\n end",
"def sort_points(args)\n points\n .sort_by { |point| point[:distance] }\n .first(args[:k])\n .map do |point|\n point[:weight] = calc_point_weight(args[:weight], point[:distance])\n point\n end\n end",
"def getLastPoint myhash\n\t\t\t#sort the hash and get the x values\n\t\t\tdummy = myhash.keys.sort\n\t\t\t#save the x value of the last point \n\t\t\txval = dummy.last\n\t\t\t#get the y value of the last point\n\t\t\tyval = myhash[xval]\n\t\t\treturn [xval, yval]\n\tend",
"def my_hash_sorting_method(source)\n p source.sort_by { |key, value| value }\nend",
"def sort_each_pair(&block)\n\t\tnew_hash = int_sort\n\t\tnew_hash.each do |info|\n\t\t\tyield info.key, info.value if block_given?\n\t\tend\n\tend",
"def get_point_order\n order = Array.new(@feature.length)\n @feature.each_with_index.sort_by(&:first).each_with_index { |f_and_index, i| order[f_and_index[1]] = i }\n order\n end",
"def sort_dimension_keys_values(serieses_results)\n dimension_keys_values_list = serieses_results.values\n sorted_dimension_keys_values = dimension_keys_values_list.map do |dimension_keys_values|\n dimension_keys_values = dimension_keys_values.sort_by do |dimension_key, value|\n is_boolean = dimension_key.is_a?(TrueClass) || dimension_key.is_a?(FalseClass)\n is_boolean ? (dimension_key ? 0 : 1) : dimension_key\n end\n Hash[dimension_keys_values]\n end\n sorted_dimension_keys_values\n end",
"def hvals(key); end",
"def hvals(key); end",
"def key_for_min_value(hash)\n array = []\n hash.each do |key, value|\n array << value\n end\n array.sort!\n hash.key(array[0])\nend",
"def my_hash_sorting_method(source)\n source.sort {|k,v| k[1]<=>v[1]}\nend",
"def hash\n [group, x, y].hash\n end",
"def hash\n [model, pk.nil? ? @values.sort_by{|k,v| k.to_s} : pk].hash\n end",
"def values\n{\n :A => 1, :B => 3, :C => 3, :D => 2,\n :E => 1, :F => 4, :G => 2, :H => 4,\n :I => 1, :J => 8, :K => 5, :L => 1,\n :M => 3, :N => 1, :O => 1, :P => 3,\n :Q => 10, :R => 1, :S => 1, :T => 1,\n :U => 1, :V => 4, :W => 4, :X => 8,\n :Y => 4, :Z => 10\n}\nend",
"def key_for_min_value(name_hash)\nlowest_value = 0 \n\nname_hash.index do |(x,y)|\n\nx = key \ny = value \nend",
"def basic_values_keys\n basic_values_tuple.keys.sort{|a,b| a.to_s <=> b.to_s}\n end",
"def map(hash); end",
"def collate!\n @buckets = @buckets.sort { |a,b| b.time <=> a.time }\n @ordered = {}\n @buckets.map { |o| o.identity }.uniq.each do |identity|\n @ordered[identity] = @buckets.select { |o| o.identity == identity }\n end\n return @buckets\n end",
"def save_hash_field_order; end",
"def key_for_min_value(name_hash)\n newArray1 = []\n name_hash.collect do |key, value|\n newArray1 << value\n end\n newArray2 = []\n newArray2 = newArray1.sort { |x,y| x <=> y }\n return name_hash.index(newArray2[0]) \nend",
"def ordered_entity_hash\n hash = ActiveSupport::OrderedHash.new\n DC::VALID_KINDS.each {|kind| hash[kind] = [] }\n entities.each do |e|\n hash[e.kind].push :value => e.value, :relevance => e.relevance\n end\n hash.each do |key, list|\n hash[key] = list.sort_by {|e| -e[:relevance] }\n end\n hash\n end",
"def sort_ranking\n @sorted_hash = @hash_ranking.sort_by { |_name, points| -points }\n @sorted_hash = @sorted_hash.first(10)\n @sorted_hash.map { |k, v| \"#{k}\\t#{v}\" }.join(\"\\n\")\n end",
"def key_for_min_value(name_hash)\n reference = nil\n vref = 1000\n name_hash.collect do |key, value|\n if value < vref\n reference = key\n end\n if vref > value\n vref = value\n end\n # binding.pry\n end\n reference\nend",
"def get_direct_link_shorage_value(hash,source,child_hash)\r\n child_result = {}\r\n hash.each do|k,v_hash|\r\n v_hash.each do |ki,v|\r\n if ki == source\r\n if child_hash[ki] and child_hash[ki][0] < v[0]\r\n else\r\n child_result[k] = [v,ki]\r\n\t end\r\n end\r\n end \r\n end\r\n return child_result \r\n end",
"def values_at(*keys); end",
"def sort_and_include_index\n #get sorted values and indexes based and return 2 dimension array [value, index]\n self.map.with_index.sort.map {|v,i| [v,i]}\n end",
"def shuffled_order\n \tnow = DateTime.now\n \t( p.hash + now.hour + now.day*100 ).hash\n end",
"def sort_series_keys(values)\n output = {}\n values.each do |uuid, name_series|\n output[uuid] = {}\n name_series.each do |name, series|\n output[uuid][name] = {}\n series.keys.sort.each do |ts|\n output[uuid][name][ts] = series[ts]\n end\n end\n end\n\n output\n end",
"def key_for_min_value(name_hash)\n #name_hash.collect do|key, value|\n #name_hash.sort\n hash1={}\n hash1=Hash[name_hash.sort_by{|k,v| v}]\n hash1.keys[0]\nend",
"def key(tuple)\n @by.map{|by| tuple[by] }\n end",
"def points\n @points ||= begin\n h = Hash.new\n Point::ABS_POINTS_DATA.each do |pt_name|\n h.merge!(pt_name => Point.new(film, pt_name))\n end\n h\n end\n end",
"def hash\n values.hash ^ known_data.hash\n end",
"def sort_vals h\n out = Hash.new\n h.each do |k,v|\n out[k] = v.sort\n end\n out\nend",
"def key_for_min_value(name_hash)\n #return nil if empty hash\n if name_hash == {}\n return nil\nelse\n #store keys and values in arrays for original order comparison (cannot use key/value methods)\n name_array = name_hash.collect do |key, value|\n key\n end\n value_array = name_hash.collect do |key, value|\n value\n end\n\n #create new array to sort the values min to max\n sorted_value_array = name_hash.collect do |key, value|\n value\n end\n \n\n \n #initialize and build array to keep track of switching values using spaceship operator\n i_swap_array = []\n i = 0\n while i < sorted_value_array.length - 1\n i_swap_array[i] = sorted_value_array[i] <=> sorted_value_array[i + 1]\n i += 1\n end\n\n #Loop to switch index values until they are ordered from smallest to largest\n index = 0\n while i_swap_array.include?(1) == true\n i_swap_array.each_index {|index|\n if i_swap_array[index] == 1\n sorted_value_array[index], sorted_value_array[index + 1] = sorted_value_array[index + 1], sorted_value_array[index]\n end }\n\n #Update i_swap array in order to continue through while loop until array is fully ordered\n i = 0\n while i < i_swap_array.length\n i_swap_array[i] = sorted_value_array[i] <=> sorted_value_array[i + 1]\n i += 1\n end\n index = 0\n end\n\n #find the minimum value in the sorted array, find the appropriate index in the original array, and look up that index in the name array\n min_value = sorted_value_array[0]\n name_index = value_array.index(min_value)\n return name_array[name_index]\n\n\n #checking sorting in tests\n puts name_array\n puts value_array\n puts i_swap_array\n puts sorted_value_array\nend\nend",
"def distancematrix(hash,order )\r\n\r\n h = Hash.new{|hsh,key| hsh[key] = {} }\r\n for i in 0...order.length\r\n for j in (i+1)...order.length\r\n point1= order[i]\r\n point2= order[j]\r\n # puts \"point1 = #{point1}\"\r\n # puts \"point2 = #{point2}\"\r\n distance = distance2points2(hash,point1,point2)\r\n h[point1][point2]= distance\r\n # puts \"this is h = #{h}\"\r\n end\r\n end\r\n return h\r\nend",
"def to_a\n @sorted_points.map { |p|\n if p.hull.nil?\n c = nil\n else\n id = (p.hull.hash ^ p.hull.hull_id) % 64 # XXX p.hull.hull_id % 64\n\n r = (id % 4) / 6.0 + 0.25\n g = ((id / 4) % 4) / 6.0 + 0.25\n b = (id / 16) / 6.0 + 0.25\n a = 0.8\n\n c = [r, g, b, a]\n end\n\n {\n x: p.x, y: p.y,\n color: c,\n name: p.name,\n neighbors: p.neighbors.map { |n| { x: n.x, y: n.y, color: n == p.first ? [0.9, 0.1, 0.1, 0.9] : nil } }\n }\n }\n end",
"def key_for_min_value(name_hash)\n \n if name_hash.size == 0\n x = nil\n \n else\n \n y = name_hash.map {|item,num| num}\n y = y[0]\n\n name_hash.each do |item, num|\n \n if num < y\n \n x = item\n y = num\n \n elsif num == y\n x = item\n \n end\n\n end\n\nend\nx\n\n\nend",
"def puppetsort(hash)\n # TODO(sissel): Implement sorting that follows the puppet style guide\n # Such as, 'ensure' goes first, etc.\n return hash.to_a\n end",
"def sort_each(&block)\n\t\tnew_hash = int_sort\n\t\tnew_hash.each do |info|\n\t\t\tyield [info.key, info.value] if block_given?\n\t\tend\n\tend",
"def sort_pair(hash_to_check)\n arr = hash_to_check[:arr]\n if arr[0] > arr[1]\n hash_to_check[:flag] = true\n sorted_arr = [arr[1], arr[0]]\n else\n hash_to_check[:flag] = false\n sorted_arr = arr\n end\nend",
"def find_bays_and_picking_order(hash,item_array)\n\n #Step 1 - get the list of bays for the items\n bays = find_multiple_bays(hash,item_array)\n\n #Step 2, for each bay get the position\n ordered_hash = Hash.new\n for bay_id in bays\n ordered_hash[bay_id.to_sym]=hash[bay_id.to_sym][:position]\n end\n\n #Create an array from the hash, ordered by position of each bay\n ordered_nested_array= ordered_hash.sort_by { |bay, position| position }\n\n #Then use this to create the ordered list of bays \n ordered_bays = Array.new\n for value in ordered_nested_array\n ordered_bays << value[0]\n\n end\n\n return ordered_bays\n\nend",
"def geohash(key, member); end",
"def ordered_by_qualifications(candidates)\n ordered_candidates = candidates.sort_by { |candidate| [candidate[:years_of_experience], candidate[:github_points]] }\n return (ordered_candidates).reverse\n\n # @ordered_by_qualifications = []\n\n # candidates.each do |candidate|\n # years_exp s=candidate[:years_of_experience]\n # @ordered_by_qualifications << years_exp\n # if years_exp == years_exp += 1\n # candidate[:github_points] > candidate[github_points] += 1\n # end \n \n # end\n # return @ordered_by_qualifications.sort!.reverse\n #This line returns the values 12..1 \n # return @ordered_by_qualifications.sort!.reverse\nend",
"def key_for_min_value(hash)\n value_only_array = []\n hash.each_pair do |key, value|\n value_only_array << value\n end\n value_only_array.sort!\n hash.key(value_only_array[0])\nend",
"def generate_hash\n @groups.flatten.inject([]) {|hash, stone| hash << stone.to_s}.sort.hash\n end",
"def calculate\n set_last_key_as_key\n set_last_present_value_as_key\n set_first_value_as_key_in_string_format\n set_first_value_as_key_in_float_format\n set_number_of_commissions\n set_values_for_commision_types\n @hash\n end",
"def key_for_min_value(name_hash)\n low_key = nil\n low_value = nil\n name_hash.each do |key,value|\n\n if low_value == nil || value < low_value\n low_value = value\n low_key = key\n #binding.pry\n #if price < price && price\n #puts name_hash\"#{object}\"\n#else name_hash == {}\n #nil\nend\n end\n low_key\n end",
"def key_for_min_value(name_hash)\n key = nil\n value = nil\n name_hash.collect do |x ,y| \n if value == nil || y < value\n key = x\n value = y\n end\nend\nkey\nend",
"def key_for_min_value(name_hash)\n num = []\n key = nil\n name_hash.each do |x,y|\n if num.length > 0\n y > num.first ? num << y : (num.unshift(y) ; key = x)\n else\n num << y\n key = x\n end\n \n end \n key\nend",
"def key_order\n # order(key: :asc)\n all.to_a.sort_by {|n| n.key }\n end",
"def key_for_min_value(birthday_hash)\n min_kid = nil\n min_age = nil\n\n#using each will allow you to return the single value\n\n birthday_hash.each do |kids_name, age|\n if min_age == nil || age < min_age \n \n#how to sort age as a min_value\n \n min_kid = kids_name\n min_age = age\n end\n end\n min_kid\nend",
"def key_for_min_value(name_hash)\n loname = nil\n lovalue = nil\nname_hash.each do |name, value|\n if lovalue ==nil || value<lovalue\n lovalue = value\n loname = name\nend\nend\nloname\nend",
"def order_by_value\n @hand = @hand.sort_by{|card| card.point }\n end",
"def proc_ordered_hash(ordered_hash)\n updated_els = Hash.new\n ordered_hash.each do |k,v|\n unless is_scalar_type?(v)\n updated_els[k] = convert_to_string_form(v)\n end\n end\n \n ordered_hash.merge(updated_els)\n end",
"def key_map\n hash = {}\n hash['upc'] = self.upc\n hash['quantity'] = self.quantity\n hash\n end",
"def my_hash_sorting_method(source)\n source.sort_by {|name, age| age}\nend",
"def hash\n @hash || @hash = (value.hash * -1)\n end",
"def hash\n [auto_points, teleop_points, foul_points, adjust_points, total_points, robot1_auto, robot2_auto, robot3_auto, rotor1_auto, rotor2_auto, auto_fuel_low, auto_fuel_high, auto_mobility_points, auto_rotor_points, auto_fuel_points, teleop_fuel_points, teleop_fuel_low, teleop_fuel_high, teleop_rotor_points, k_pa_ranking_point_achieved, teleop_takeoff_points, k_pa_bonus_points, rotor_bonus_points, rotor1_engaged, rotor2_engaged, rotor3_engaged, rotor4_engaged, rotor_ranking_point_achieved, tech_foul_count, foul_count, touchpad_near, touchpad_middle, touchpad_far].hash\n end",
"def my_hash_sorting_method(source)\n source.sort_by { |name, age| age }\nend",
"def sort_and_print(hash, type=\"visits\")\n new_hash = hash.sort_by { |page, visits| -visits}.to_h\n # Print into console to check\n new_hash.each do |page, number_of_visits|\n print page + \" \" + number_of_visits.to_s + \" \" + type + \" \"\n end\n # Return sorted hash\n return new_hash\nend",
"def values_hash\n @_values.dup\n end",
"def key_for_min_value(name_hash)\n lk = nil\n lv = nil\n name_hash.each do |k, v|\n if lv == nil || v < lv\n lv = v\n lk = k\n end\n\n end\n lk\nend",
"def add_all\n outputhash = Hash.new\n\n # Count up all values\n @output.each do |key, value|\n count = 0\n value.each{|k,v| count+= v}\n outputhash[key] = count\n end\n\n keeparr = Array.new\n outputhash.sort_by{|k, v| v}.reverse[0..@keys_to_format].each{|i| keeparr.push(i[0])}\n @output = @output.keep_if{|k, v| keeparr.include?(k)}\n end",
"def order_hash(h)\n keys = h.keys.sort { | k1,k2 |\n if k1 == 'count'\n ret = -1\n elsif k2 == 'count'\n ret = 1\n else\n # Cities level is slightly different form, if hash at this level then compare\n # count value within hash, otherwise just compare values. mult by -1 to reverse\n # ordering\n if h[k1].class == Hash\n ret = ( h[k1]['count'] <=> h[k2]['count'] ) * -1\n ret = k1 <=> k2 if ret == 0 && k1!=nil && k2!=nil\n else\n ret = ( h[k1] <=> h[k2] ) * -1\n ret = k1 <=> k2 if ret == 0 && k1!=nil && k2!=nil\n end\n end\n ret\n }\n\n # build up return hash\n ret_hash = {}\n keys.each do | key |\n ret_hash[key] = h[key]\n end\n\n ret_hash\n end",
"def key_for_min_value(name_hash)\n if name_hash.empty?\n nil\nelsif new_array = name_hash.sort_by {|name, value| value}\n new_array[0].shift\nend\n end",
"def point_key(point_key)\n @_point_keys[point_key]\n end",
"def my_hash_sorting_method(source)\n source.sort_by { |pet, age| age }\nend",
"def getSortListFrom dict\n dict.to_a.sort {|x, y| x[1]<=>y[1]}\nend",
"def key_for_min_value(name_hash)\n value_store = nil\n key_store = nil\n\n name_hash.each do |key, value|\n if value_store.nil? && key_store.nil?\n value_store = value\n key_store = key\n end\n\n if value <= value_store\n value_store = value\n key_store = key\n end\n end\n\n key_store\nend",
"def keys\n \t[ranking,val_count(@cards).reverse]\n end",
"def hash\n code = 17\n code = 37*code + @x.hash\n code = 37*code + @y.hash\n # Add lines like this for each significant instance variable\n code # Return the resulting code\n end",
"def sort\n self.location_hash = location_hash.sort_by { |hsh| hsh[\"user_id\"] }\n self\n end",
"def adjust_prob(hash, position)\n hash.each_key do | pos |\n diff = (pos - position).abs\n # 1 Mb is the cut off on either side\n cutoff = 1000000\n if diff < cutoff\n adj = hash[pos] * (diff/cutoff)\n hash[pos] = adj.to_i\n end\n end\n hash\nend",
"def get_ographhash(ographobj)\n ographhash = Hash[\n 'display' => ographobj.at_xpath(\"displayprio\").text,\n 'name' => ographobj.at_xpath(\"name\").text,\n 'yaxis' => ographobj.at_xpath(\"verticallabel\").text,\n 'datapoints' => ographobj.xpath('datapoints/overviewgraphdatapoint'),\n ]\n\n return Hash[ographhash.sort]\n end",
"def key_for_min_value(hash)\nhash = {:iphone => 300, :samsung => 555, :nokia => 1000}\nhash.each.collect do |price| \n puts \"this phone is #{price}\"\nend",
"def key_for_min_value(name_hash)\n low_key = nil\nlow_value = nil\nname_hash.each do |key, value|\n # binding.pry\n if low_value == nil or low_value > value\n low_value = value\n low_key = key\n end \nend\nlow_key\nend",
"def key_for_min_value(name_hash)\nlow_value=nil\nlow_key=nil\n\nname_hash.each do |value, key|\n if low_value == nil || key < low_key\n low_value=value\n low_key=key\n end\n \nend\nlow_value\nend",
"def ph(hash)\n hash.sort { |a, b| a[1]<=>b[1]}.each { |a| puts \"#{a[0]} : #{a[1]}\"}\nend",
"def key_for_min_value(name_hash)\n bottom_value = 0\n bottom_key = nil\n \n name_hash.each { |name, number|\n \n if bottom_value == 0 || number < bottom_value\n bottom_value = number\n bottom_key = name\n end\n }\n bottom_key\n\nend",
"def values\n (@hash.values + @converted.values)\n end",
"def key_for_min_value(name_hash)\n l_value = 999\n key = nil\n name_hash.collect do |name,value|\n if value < l_value \n l_value = value\n key = name\n \n end\n \n end \n return key \nend",
"def value_map\n value_pairs = tags.map { |t| [t.value, t.character] }\n mapping = new_hash_of_arrays\n value_pairs.each do |value, character|\n mapping[value] << character\n end\n mapping.map { |value, characters|\n [value, characters.sort_by { |c| c.name }]\n }.sort\n end",
"def hash\n from_end.hash + to_end.hash + overlap.hash + reverse_overlap.to_s.hash\n end",
"def organizeData data_filename\n if validFile? data_filename\n else\n Logger.instance.logError(\"The file \" + data_filename + \" is invalid.\")\n raise ArgumentError, \"The file is invalid. Make sure the file exists and is readable\"\n end\n\n data_file = File.open(data_filename)\n\n data_hash = Hash.new\n data_arr = []\n $result_hash = Hash.new\n\n data_file.each do |segment|\n value = segment.split(\"\\t\") # tab is our delimeter\n if value.size != 3\n Logger.instance.logError(\"The segment \" + segment + \" is not in the format [lat] [long] [streetname] delimited by tabs.\")\n else\n if float?(value[0]) and float?(value[1])\n data_hash[Coordinate.new(value[0],value[1])] = value[2].chomp\n else\n Logger.instance.logError(\"Either \" + value[0] + \" or \" + value[1] + \" is not a float.\")\n end\n end\n end\n\n data_file.close\n\n sorted_data = data_hash.sort{|a,b| a[0] <=> b[0]}\n \n cur_coo = Coordinate.new\n sorted_data << [cur_coo,\"END\"] # a special marker at the end so we know we have looked at all the elements\n \n sorted_data.each do |coo|\n if coo[0] != cur_coo\n if data_arr.size > 1\n combo = data_arr.combination(2).to_a # get all possible pairs\n combo.each do |s1,s2|\n if s1 < s2\n key = s1.capitalize + \"_\" + s2.capitalize # capitalize for case-insensitive search\n Logger.instance.log(\"Added key \" + key)\n elsif s2 < s1\n key = s2.capitalize + \"_\" + s1.capitalize\n Logger.instance.log(\"Added key \" + key)\n else\n next\n end\n if $result_hash.has_key? key\n a = $result_hash[key]\n $result_hash[key] << cur_coo if !a.index cur_coo\n else\n $result_hash[key] = [cur_coo]\n end\n end\n end\n data_arr.clear\n data_arr << coo[1]\n cur_coo = coo[0]\n else\n data_arr << coo[1]\n end\n end\nend",
"def get_ordered_values()\n return VALUES.to_a.map { |pair|\n pair.reverse\n }.sort.map { |pair|\n pair[1]\n }\n end",
"def key_for_min_value(name_hash)\nlowest_key = nil \nlowest_value = Float::INFINITY\nname_hash.each do |x,y|\n if y < lowest_value\n lowest_value = y \n lowest_key = x\n end\nend\nlowest_key\nend",
"def key_for_min_value(name_hash)\n lowest_price = 0\n lowest_key = nil\n\nname_hash.each do |key, value|\n if lowest_price == 0 || value < lowest_price\n lowest_price = value\n lowest_key = key\n end\nend\nlowest_key\n\nend",
"def hkey(h)\n h.sort_by{|x| x[0].to_s}\n end",
"def list\n to_hash.keys.sort\n end",
"def key_for_min_value(name_hash)\n lowestkey = nil #if less I want to change make comparison each time I have one of the key values via the iteration, if my placeholder is less than this current one I've got while I'm iteratingand then set them equal\n lowestvalue = nil #established two buckets with default value outside of iterator\n name_hash.map do |key, value| #this iterates over the hash\n if lowestvalue == nil || value < lowestvalue #overwrote the two new buckets only if these two conditions were met\n lowestvalue = value\n lowestkey = key #grabbing it's label while we're holding teh value, got changed above\n end\n #\n # key.each do |key1, key2|\n # if key1 < key2\n # key1\n # end\n #now I need to compare the value of the elements in the set of keys\n #now I need to return the key in the set with the smallest value\n end\n lowestkey\nend",
"def num_points_scored(name)\n game_hash.each do |location, team_hash|\n \n #the below is actually iterating through the keys of the hash containing the team info, because the value of game_hash is....another hash\n team_hash.each do |key, vals|\n if key == :players # this makes sure I'm only iterating through the right pair to begin with\n return vals[name][:points] if vals[name] # the return keyword ensures it will pop out of the method once the answer has been found \n end\n end\n end\nend",
"def index\n @key_indicate_map_indicator_keys = KeyIndicateMap::IndicatorKey.order(sort_column + \" \" + sort_direction)\n end",
"def hash\n model.hash + key.hash\n end"
] |
[
"0.6455059",
"0.64427334",
"0.63348913",
"0.6192054",
"0.6153559",
"0.6088921",
"0.59997576",
"0.59171265",
"0.58849764",
"0.58649707",
"0.58617437",
"0.58029777",
"0.57773423",
"0.57769984",
"0.57769984",
"0.5754508",
"0.57528013",
"0.5749163",
"0.57380855",
"0.5702592",
"0.56091154",
"0.5606596",
"0.5602813",
"0.55909085",
"0.5572635",
"0.55672115",
"0.5562911",
"0.55607826",
"0.55484164",
"0.55447954",
"0.55284506",
"0.55253506",
"0.55221266",
"0.55195653",
"0.55140746",
"0.55095893",
"0.5502765",
"0.5502551",
"0.5501519",
"0.54916483",
"0.5483357",
"0.5479229",
"0.54618025",
"0.5457462",
"0.54517245",
"0.5451375",
"0.54489106",
"0.54481685",
"0.5447747",
"0.5439251",
"0.5430417",
"0.54277325",
"0.5426614",
"0.5422192",
"0.5411145",
"0.5394133",
"0.5393484",
"0.53909475",
"0.53898305",
"0.5387656",
"0.53860176",
"0.53857243",
"0.53776896",
"0.5376826",
"0.5367846",
"0.5353343",
"0.5349031",
"0.5344782",
"0.5344588",
"0.5343013",
"0.5342349",
"0.53389627",
"0.5329762",
"0.5328463",
"0.5325392",
"0.5321297",
"0.53162843",
"0.5312756",
"0.5302435",
"0.5291141",
"0.52904284",
"0.5289",
"0.5288884",
"0.528275",
"0.528241",
"0.5281438",
"0.5279621",
"0.5278663",
"0.5275",
"0.5271563",
"0.52702916",
"0.52695954",
"0.5262987",
"0.52610385",
"0.52560705",
"0.5254446",
"0.5253045",
"0.5250483",
"0.5248662"
] |
0.6493413
|
1
|
multiply that value by the corresponding multiplier value, do an enumerable to cycle through array applying multiplier to each in the array using map
|
def multiply_word_with_letter_multiplier(word,letter_multiplier)
local_array = score(word)
local_array.map do |number|
number * letter_multiplier
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def multiply_by(num,arr)\n arr.map do |x|\n x * num\n end\nend",
"def multiply_by(array)\n return array.map { |el| el * 3}\nend",
"def multiply(array,mult)\n array.map{|num| num*mult}\nend",
"def multiply_each (array, product=1)\n array.each do |x|\n product *= x\n end\n return product\nend",
"def multiply(arr)\n arr.map { |i| i * 2 }\nend",
"def multiply_element(array)\n array.each do |x|\n x=x*x\n end\n end",
"def multiply_by(number, array)\n product_array = []\n array.map do |item|\n product_array.push(item * number)\n end\n puts product_array\nend",
"def mult5 array\n array.map do |value| \n value * 5 \n end\nend",
"def custom_multiply(array, number)\n result = []\n number.times { array.each { |element| result << element}}\n result\nend",
"def my_map_mult_two(arr)\n arr.map { |num| num * 2 }\nend",
"def *(multiplier)\n return map {|currency, money| money * multiplier}\n end",
"def multiply_els(arr)\n\tarr.my_inject(1) do |res, i| \n\t\tres * i \n\tend\nend",
"def multiply_all_by(array, num)\n\n result = []\n array.each do |elem|\n result << elem * num\n end\n result\nend",
"def multiply_me(array, int)\r\n\r\n arr = [] # empty array created\r\n\r\n i = 0 # iteration starts to multiply each item\r\n while i < array.length\r\n arr << array[i] * int # products collected\r\n i += 1\r\n end\r\n\r\n arr # result\r\nend",
"def multiply_els(array)\n\tarray.inject(1) { |num, item| num * item }\n\nend",
"def multiply (array)\n\tarray.inject(1) do |result, element|\n\t\tresult * element\n\tend\nend",
"def multiply_by x,y,n\n (1..n).map {|i| x * y**i}\nend",
"def multiplier(n)\n lambda { |data| data.collect { |x| x * n } }\nend",
"def custom_multiply(array, number)\n # Return a new array with the array that's passed in\n # as an argument multiplied by the number argument\n result = []\n number.times { array.each { |elem| result << elem } }\n result\nend",
"def multiply_els(array)\n array.my_inject(1) { |product, i| product * i }\nend",
"def multiply(array)\n array.inject(:*)\nend",
"def multiply\n yield 10\n yield 75\n yield 879\nend",
"def multiply_els(arr)\n\n arr.my_inject { |memo, e| memo * e }\n\n end",
"def multiply_els(array)\n array.my_inject { |product, power| product * power }\nend",
"def solution5(input)\n # Approach\n # Map over the initial array (to return a transformed array)\n # Map over each interal array (to return a transformed array)\n # Creates an enumerable range up to the value in the array\n # Multiple each value in the range using the inject method\n # which iterates and keeps the running total\n\n # Final solution\n # Uses shorthand version of inject\n # Remove the useless multiple by 1\n # Note the use of the starting value of 1 for inject\n # which makes this work properly for all values (including 0, 1)\n input.map do |ary|\n ary.map do |value|\n (2..value).inject(1, :*)\n end\n end\n\n # First solution\n # Mostly optimized\n # Does 1 more multiplication than needed (mult by 1)\n #\n # input.map do |ary|\n # ary.map do |value|\n # (1..value).inject(1) do |factorial, value|\n # factorial *= value\n # end\n # end\n # end\n end",
"def multiply\n inject(1) { |p,x| p * x }\n end",
"def multiply_els(array)\n array.my_inject { |item, next_item| item * next_item }\nend",
"def multiplier(n)\nlambda {|data| data.collect{|x| x*n } }\nend",
"def multiply(*arr)\n\tproduct, i = 1, 0\n\n while i < arr.length\n \tproduct *= arr[i]\n \ti += 1\n end\n\n # could also just use reduce, just keeping fundamentals sharp\n product\nend",
"def multiply_list(array1, array2)\n array1.each_with_index.map do |current_integer, index|\n current_integer * array2[index]\n end\nend",
"def multiply!(numbers, multiplier)\n counter = 0\n\n loop do\n break if counter == numbers.size\n \n numbers[counter] *= multiplier\n\n counter += 1\n end\n\n numbers\nend",
"def multiply_els(list)\n list.my_inject(1) { |product, i| product * i }\nend",
"def powers(values, max)\n\tvalues.each do |v|\n\t\tpowers = (1..max).to_a.map do |i|\n\t\t\tv**i\n\t\tend\n\t\tyield *powers\n\tend\nend",
"def multiply(data, n)\n data.collect { |x| x * n }\nend",
"def multiply_els(array)\n array.my_inject { |memo, current| memo * current }\nend",
"def multiply(numbers, transformation_criteria)\n counter = 0\n transformed_numbers = []\n\n loop do\n break if counter == numbers.size\n transformed_numbers << numbers[counter] * transformation_criteria\n counter += 1\n end\n\n transformed_numbers\nend",
"def multiply_els(arr)\n # multiplies all the elements of the array together by using my_inject\n return arr.my_inject(:*)\nend",
"def multiply_els(arr)\n # multiplies all the elements of the array together by using my_inject\n return arr.my_inject(:*)\nend",
"def square_map(array)\n array.map{ |elem| elem**2 }\nend",
"def multiply_els(arr)\n arr.my_inject(1) { |total, x| total * x }\nend",
"def multiply_els(array)\n array.my_inject {|product, n| product * n}\nend",
"def doubler(array)\n array.map do |num|\n num *= 2\n end\n\nend",
"def multiply_els(array)\n array.my_inject(:*)\nend",
"def multiply_els(array)\n array.my_inject(:*)\nend",
"def multiply_els(array)\n array.my_inject(:*)\nend",
"def multiply(num)\n product = 1\n num.each do |x|\n product *= x\n end\n product\nend",
"def multipliers(*args)\n x = nil\n args.map {|x| lambda {|y| x*y }} \nend",
"def multiply\n (100..999).each do |x|\n (x..999).each do |y|\n z = x * y\n yield z\n end\n end\nend",
"def multipliers(*args)\nx = nil\nargs.map {|x| lambda {|y| x*y }}\nend",
"def multiply_els(arr)\n return arr.my_inject { |product, num| product * num}\nend",
"def multiply_els(array)\n array.my_inject { |multi, n| multi * n }\nend",
"def multiply_els(array)\n array.my_inject { |multi, n| multi * n }\nend",
"def product(numbers)\n result = 1\n numbers.each do |number|\n result *= number\n end\n result\nend",
"def multiply_by_any_number(numbers, multiplier)\n multiplied_numbers = []\n counter = 0\n\n loop do\n break if counter == numbers.size\n\n multiplied_numbers << numbers[counter] * multiplier\n counter += 1\n end\n\n multiplied_numbers\nend",
"def multiply_list(array1, array2)\n array1.map.with_index { |_, i| array1[i] * array2[i] }\nend",
"def multiply_els(array)\n array.my_inject { |total, number| total * number }\nend",
"def multiply_els\n my_inject do |x, y|\n x * y\n end\n end",
"def multiply_els(arr)\n arr.my_inject { |acc, val| acc * val }\nend",
"def custom_multiply(array,number)\n new_array = []\n number.times {new_array+=array}\n return new_array\nend",
"def multiply(numbers)\n numbers.inject { |sum, n| sum * n }\n end",
"def multiply(nums)\r\n nums.reduce(:*)\r\nend",
"def multiply(numbers, factor)\n multiplied_numbers = []\n counter = 0\n\n loop do\n break if counter == numbers.size\n multiplied_numbers << (numbers[counter] * factor)\n counter += 1\n end\n\n multiplied_numbers\nend",
"def simp_mt(arr1)\n arr1.map {|el| el ** 3} #passing BLOCK to map method, method on Arr\nend",
"def multipliers(*args)\n x = nil \n args.map {|x| lambda{|y| x*y} }\nend",
"def multiply_els(arr)\n arr.my_inject('*')\nend",
"def multiply_els(arr)\n arr.my_inject('*')\nend",
"def multiply_els(arr)\n arr.my_inject('*')\nend",
"def multiply_num(arr) # The round brakets gives the starting value\n arr.inject(1) do |quot, num| #quot survive, num gets multiplied on\n quot * num\n end\nend",
"def product(arr)\n product = 1\n for i in 0...arr.length\n product *= arr[i]\n end\n product\nend",
"def multiply_by_two(array)\n array.map { |n| n * 2 }\nend",
"def product(array) \n sum = 1\n array.each { |x| \n sum = sum * x\n\n } \n sum \n \n \nend",
"def Multiply(val)\n self.value *= val\n end",
"def *(value)\n mul(value) ;\n end",
"def product_machine(array_input)\nindex = 0\nproduct = 1\nnumber_of_loops = array_input.length\n\nnumber_of_loops.times do\n product = product * array_input[index]\n index = index + 1\nend\noutput = product\nreturn output\nend",
"def multiply_list(array1, array2)\n array1.map.with_index {|e, i| e * array2[i] }\nend",
"def 😀 value\n self.map {|d| d * value}\n end",
"def multiply *array\n puts array.inspect\n array.flatten.inject(:*)\n end",
"def double_it(numbers)\n numbers.map{|number| number * 2}\nend",
"def array_element_mult(array_a, array_b)\n array_a.zip(array_b).map {|x,y| x*y}\n end",
"def multiply_els(arr)\n arr.my_inject(:*)\nend",
"def multiply_els(arr)\n arr.my_inject(:*)\nend",
"def multiply_els(arr)\n arr.my_inject(:*)\nend",
"def multiply_els(arr)\n arr.my_inject(:*)\nend",
"def multiply_els(arr)\n arr.my_inject { |result, element| result * element }\nend",
"def multiply_els(arr)\n arr.my_inject { |result, element| result * element }\nend",
"def multiply_els(arr)\n arr.my_inject { |result, element| result * element }\nend",
"def double_all array\n array.map { |i| i*2 }\nend",
"def multiply_by_two(array)\n # double_numbers = []\n # array.each do |number|\n # double_numbers << number * 2\n # end\n # double_numbers\n array.map { |number| number * 2 }\nend",
"def element_times_index(numbers)\n\tfor i in 0..numbers.length-1\n numbers[i] *= i\n end\n return numbers\nend",
"def multiply_els(arr)\n arr.my_inject { |memo, i | memo * i }\nend",
"def multiply_els(arr)\n arr.my_inject { |i, j| i * j }\nend",
"def multiply_els(arr)\n arr.my_inject { |result, elem| result * elem }\nend",
"def multiply_els(arr)\n arr.my_inject(1, :*)\nend",
"def product_inject(numbers_array)\n numbers_array.inject {|accumulator, element| accumulator *= element}\nend",
"def multiply_list(array1, array2)\n array1.map.with_index { |num, index| num * array2[index] }\nend",
"def multiply_els\n\t\tself.my_inject(:*, self[0])\n\tend",
"def multiply_els(ary = nil)\n\t\treturn self.my_inject(1) { |product, x| product * x }\n\tend",
"def walk\n 1.upto( self.map(&:abs).max ) do |mult|\n yield [ basis[0] * mult, basis[1] * mult ]\n end\n end",
"def power_araray(array)\n ## recorrer el arreglo con map\n ## hacer la operatorio con ** 2\n ## map entrega un copia lista\nend",
"def multiply_els(arr)\n arr.my_inject :*\nend",
"def product_method(array)\n array.reduce(:*)\nend"
] |
[
"0.77951574",
"0.76585543",
"0.7645251",
"0.7509173",
"0.7409304",
"0.7376546",
"0.73750705",
"0.7367438",
"0.72560304",
"0.71724063",
"0.7166922",
"0.71196467",
"0.7073315",
"0.7044117",
"0.70420086",
"0.70188105",
"0.70101374",
"0.69665265",
"0.69500333",
"0.6941966",
"0.689799",
"0.6890876",
"0.6889871",
"0.68635476",
"0.68413633",
"0.6840974",
"0.68343014",
"0.68166876",
"0.68085206",
"0.67924094",
"0.6782758",
"0.67756605",
"0.67715853",
"0.67588055",
"0.6745859",
"0.67102396",
"0.67026997",
"0.67026997",
"0.6670146",
"0.66685236",
"0.6665005",
"0.66624576",
"0.66591",
"0.66591",
"0.66591",
"0.6651051",
"0.66462153",
"0.6643953",
"0.66354424",
"0.6629331",
"0.66167337",
"0.66167337",
"0.66103095",
"0.6609038",
"0.66045535",
"0.66044986",
"0.6596889",
"0.65941465",
"0.6594142",
"0.6592805",
"0.6590199",
"0.65864694",
"0.6585754",
"0.6584831",
"0.6576748",
"0.6576748",
"0.6576748",
"0.65640813",
"0.6561187",
"0.65610933",
"0.65582734",
"0.65539926",
"0.6547392",
"0.6547047",
"0.6540841",
"0.6533013",
"0.65297866",
"0.6524661",
"0.6524656",
"0.6501231",
"0.6501231",
"0.6501231",
"0.6501231",
"0.6500144",
"0.6500144",
"0.6500144",
"0.6493416",
"0.64925015",
"0.6484934",
"0.64821476",
"0.6471534",
"0.64612466",
"0.6460723",
"0.6460499",
"0.64483964",
"0.6443596",
"0.6436635",
"0.64192015",
"0.6415335",
"0.6402313",
"0.640022"
] |
0.0
|
-1
|
sum it up, set summed array to a plus equals of that array plus the next number in the array
|
def sum
local_array = multiply_word_with_letter_multiplier
local_array.inject(:+)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def summing_method\n @summed_array = @single_digit_array.sum\n end",
"def arr_sum(array)\n sum = 0 # Declares initial value for variable 'sum' as 0\n array.each do |i| # Begin iterating each item of arr\n sum += i # add each number in array to the next item, continue until items exhausted\n end\n return sum # Returns new sum value\nend",
"def sum_of_sums(array)\n sequence_total = 0\n sum = 0\n array.each do |n|\n sequence_total += n\n sum += sequence_total\n end\n sum\nend",
"def running_total(input_array)\n sum = 0 # => 0, 0, 0, 0\n new_array = input_array.map do |value| # => [2, 5, 13], [14, 11, 7, 15, 20], [3], []\n sum += value # => 2, 7, 20, 14, 25, 32, 47, 67, 3\n end # => [2, 7, 20], [14, 25, 32, 47, 67], [3], []\nend",
"def sum array\n\tsum = 0\n\tarray.each do |number|\n\t\tsum = sum + number\n\tend\n\tsum\nend",
"def reduce_to_total(source_array, starting_point = 0)\n \n source_array.sum + starting_point\n \nend",
"def sum arr\n sum_array = 0 \n arr.each { |x| sum_array = sum_array + x } \n return sum_array\nend",
"def sum_of_sums(array)\n n = 1\n running_total = 0\n while n <= array.size\n running_total += array.first(n).reduce(:+)\n n += 1\n end\n running_total\nend",
"def sum(array)\n array.reduce(0) {|base, ele|\n base+=ele\n }\n end",
"def sum_of_sums(array)\n sum = 0\n array.length.times do |index|\n sum += array[0, index + 1].reduce(&:+)\n end\n sum\nend",
"def add_numbers(array)\n#add first in array to next in array. replace next in array\n#until array.length < 1\n return array[0] if array.length <= 1\n num1, num2 = array.pop, array.pop\n sum = num1.to_i + num2.to_i\n array.unshift(sum)\n add_numbers(array)\nend",
"def sum(array)\n s = 0\n\tarray.each {|x| s+= x}\n\ts\nend",
"def running_total(array)\n sum = 0\n new_array = []\n array.each do |num|\n sum += num\n new_array << sum\n end\n new_array\nend",
"def reduce_to_total(source_array, starting_point = 0)\n #source_array.reduce(starting_point) {|sum, n| sum + n}\n i = 0\n sum = starting_point\n while i < source_array.length do\n sum = sum + source_array[i]\n i += 1\n end\n return sum\nend",
"def sum(array)\n sum = 0\n array.each { |n| sum += n } \n sum\nend",
"def total(array)\n sum = 0\n array.each do |number|\n sum = sum += number\n end\n sum\nend",
"def running_total(array)\n sum = 0\n running_total = []\n\n array.each do |element|\n sum += element\n running_total << sum\n end\n\n running_total\nend",
"def adjacent_sum(arr)\n result = []\n\n arr.each_with_index do |num, idx|\n counter = 0\n if idx < arr.length-1\n counter += num + arr[idx+1]\n result << counter\n end\n end\n\n return result\n\nend",
"def running_total(array)\n sum = 0\n\n array.each_with_object([]) do |number, new_array|\n new_array << sum += number\n end\nend",
"def sum(array)\n y = 0\n array.each do |x|\n y += x\n end\n y\nend",
"def sum_of_sums(int_arr)\n sum = 0\n current_numbers = []\n int_arr.each { |int|\n current_numbers << int\n sum += current_numbers.sum\n }\n sum\nend",
"def sum_numbers(numbers)\r\n # Your code here\r\n #initalize the sum\r\n sum = 0\r\n #iterate through every element of a given array\r\n numbers.each do |number|\r\n #add the previous sum and next number in the array\r\n sum += number\r\n end\r\n \r\n return sum\r\nend",
"def sum1(array)\r\n sum = 0\r\n array.each do |number|\r\n sum += number\r\n end\r\n sum\r\nend",
"def sum(array)\n\ttotal = 0\n\tfor number in array #could do each do instead of for loop\n\t\ttotal += number\n\tend\n\treturn total\nend",
"def sum_of_sums(array)\n total = 0\n\n 1.upto(array.size) do |num|\n total += array.slice(0, num).reduce(:+)\n end\n total\nend",
"def sum_array(array)\n sum = 0\n array.each do |number|\n sum += number\n end\n sum\nend",
"def sum_array a\n t = 0\n a.each{|i|t+=i.to_i}\n [a,t]\nend",
"def sum_array( numbers )\r\n numbers.inject(0, :+)\r\nend",
"def sum_it_up(array)\n sum_of_array = 0\n array.each do |num|\n sum_of_array += num\n end\n return sum_of_array\nend",
"def sum_of_sums(array)\n supersum = 0\n array.each_with_index do |_, index|\n supersum += array[0, index + 1].inject(:+)\n end\n supersum\nend",
"def running_total(array)\n sum = 0\n array.each_with_object([]) do |el, new_array|\n new_array << sum += el\n end\nend",
"def sum_of_sums(array)\n new_array = []\n array.size.times do |n|\n new_array << array[0..n]\n end\n new_array.flatten.reduce(:+)\nend",
"def adjacent_sums(arr)\n result = []\n (0...arr.length - 1).each do |i|\n result << arr[i] + arr[i + 1]\n end\n\n result\nend",
"def sum (arr)\n\treturn arr.inject(0, :+)\nend",
"def sum_of_sums(array)\n\n sums_array = []\n\n sum = 0\n array.each do |value|\n sum += value\n sums_array << sum\n end\n \n sums_array.sum\nend",
"def sum arr\n result = 0\n arr.each do |num|\n \tresult += num\n end\n result\nend",
"def running_total_2 arr\n arr.each_with_index { |elm, idx| idx == 0 ? next : arr[idx] += arr [idx-1] }\nend",
"def running_total(array)\n # new_array = []\n sum = 0\n array.inject([]) do |arr, val| \n sum += val\n arr << sum \n arr\n end\nend",
"def sum_of_sums(array)\r\n total = array[0]\r\n new_arr = []\r\n array.each do |x|\r\n if new_arr.empty?\r\n new_arr << x\r\n else\r\n total += x\r\n new_arr << total\r\n end\r\n end\r\n new_arr.reduce(:+)\r\nend",
"def sum(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n sum\nend",
"def sum_array(array)\n return array.sum\n\n # sum_total_of_array = 0\n # for number in array\n # sum_total_of_array += number\n # end\n # return sum_total_of_array\nend",
"def sum_of_sums(array)\n total = 0\n until array.size == 0\n total += array.reduce(:+)\n array.pop\n end\n total\nend",
"def iterative_sum(array)\n sum = 0\n array.each do |ele|\n sum += ele\n end\n sum\nend",
"def sum_of_sums(numbers)\n numbers_to_add = Array.new\n numbers.each_index do |index|\n numbers_to_add += numbers[0..index]\n end\n numbers_to_add.reduce(:+)\nend",
"def sum(array)\n array.inject(0){|sum, n| sum + n}\n end",
"def sum_of_sums(arr)\n new_arr = []\n \n arr.each_with_index do |num, idx|\n new_arr << arr[0..idx].reduce(:+)\n end\n \n p new_arr.reduce(:+)\nend",
"def my_sum(arr)\n accumulator = arr.first # store first element as accumulator\n\n arr.each_index do |idx|\n next if idx == 0 # skip first element: it's already the accumulator\n accumulator += arr[idx] # increment accumulator by current element\n end\n\n accumulator\nend",
"def running_total1(array)\n array_new = []\n loop do\n break if array.empty?\n array_new << array[0]\n array[1] = array[0] + array[1] if array.size >= 2\n array.shift\n end\n array_new\nend",
"def arraysum\n return self.inject(0){|acc,i|acc +i}\n end",
"def sum(array)\n sum = 0\n\n array.each { |number|\n sum += number\n }\n\n return sum\nend",
"def sum_array(array)\n sum = 0\n array.each do |num|\n sum = sum + num\n end\n sum\nend",
"def iterative_sum(array)\n sum = 0\n array.each do |ele|\n sum += ele\n end\n sum\nend",
"def sum(array)\n\tarray.reduce(:+)\nend",
"def running_total3(array)\n sum = 0\n array.map do |num|\n sum = [sum, num].inject(:+)\n end\nend",
"def sum(arr)\n return 0 if arr.empty?\n el = arr.shift\n total = sum(arr)\n total + el\nend",
"def running_total(array_of_nums)\n increment = 0\n running_total_array = []\n\n array_of_nums.each do |num|\n running_total_array << num + increment\n increment += num\n end\n\n running_total_array\nend",
"def array_to_sum(input)\n arr_sum = []\n\n input.each_with_index do |x,y| \n arr_sum << x*10**(input.size - (y + 1))\n end\n\n arr_sum.sum\nend",
"def sum_array(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n sum\nend",
"def running_total(array)\n run_total = []\n \n index = 1\n while index <= array.length\n element = array.slice(0,index)\n run_total << element.inject(:+)\n index += 1\n end\n run_total\nend",
"def total(array)\n\tsum = array.inject(0, :+)\nend",
"def sum (array)\n y=array.inject(:+).to_i\nend",
"def sum arr\n sum = 0\n arr.each do |n|\n sum+= n\n end\n return sum\nend",
"def total(array)\n\tarray.inject(:+)\nend",
"def reduce_to_total(source_array, starting_point = 0)\n new_sum = source_array.reduce(starting_point, :+)\n return new_sum\nend",
"def adjacent_sums(arr)\n sums = []\n (0...arr.length-1).each do |i|\n sums << arr[i] + arr[i + 1]\n end\n sums\nend",
"def sum\n inject(0) { |acc, i| acc + i }\n end",
"def sum(array)\n return 0 if array.empty?\n array.first + sum(array[1..-1])\nend",
"def sum_it_up(array)\n return array if array.size == 1\n\n new_array = []\n\n array.size.times do |number|\n if (number + 1) < array.size\n new_array << (array[number] + array[number + 1])\n end\n end\n\n new_array\nend",
"def sum(array)\n\treturn array.reduce(:+)\nend",
"def running_total(arr)\n return [] if arr.empty?\n running_sum = [arr[0]]\n counter = 1\n loop do \n break if counter == arr.size\n \n current_value = arr[counter]\n last_number = running_sum.last\n running_sum << current_value + last_number\n \n counter += 1\n end\n running_sum\nend",
"def running_total(arr)\n new_arr = []\n running_total = arr[0]\n arr.each_with_index do |element, index|\n new_arr.push(running_total)\n running_total = running_total + arr[index + 1].to_s.to_i\n end\n new_arr\nend",
"def running_total(array)\r\n new_arr = []\r\n total = 0\r\n array.map do |x|\r\n total += x\r\n new_arr << total\r\n end\r\n new_arr\r\n end",
"def running_total(arr)\n running_total_arr = []\n sum = 0\n arr.each do |num|\n sum += num\n running_total_arr << sum\n end\n running_total_arr\nend",
"def adjacent_sum(arr)\n \tsum = []\n\tarr.each.with_index do |num, i|\n \tnextNum = arr[i+1]\n \tif nextNum != nil\n \t\tsum.push(num + nextNum)\n end\n end\n \treturn sum\nend",
"def sum_of_sums(array)\n sum = 0\n sum_array = array.map { |x| sum += x }\n sum_array.inject(:+)\nend",
"def sum_array(array)\n sum = 0\n array.each do |value|\n sum += value\n end\n sum\nend",
"def sum_array (arr)\n result = 0\n arr.each do |value|\n result +=value\n end\n result\nend",
"def total(array)\n sum = 0\n array.each do |n|\n sum += n\n end\n sum\nend",
"def add_all_numbers(array)\n array.inject(:+)\nend",
"def total(array)\n sum = 0\n array.each do |x|\n sum = sum + x\n end\n sum\nend",
"def sum_array(array)\n sum = 0\n\n array.each do |number|\n sum += number\n end\n\n return sum\nend",
"def sum(array)\n array.reduce(0, :+)\n=begin\n res =0\n array.each { |a| res += a }\n res.to_i\n=end\nend",
"def running_total(numbers)\n index = 1\n while index < numbers.length\n numbers[index] = numbers[index] + numbers[index - 1]\n index += 1\n end\n numbers\nend",
"def my_sum(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n sum\nend",
"def total(array)\n sum = 0\n array.inject(:+)\nend",
"def total(array)\n sum = 0\n array.inject(:+)\nend",
"def sum_array(array)\n sum = 0\n array.each do |num|\n sum+=num\n end\n sum\nend",
"def sum_array(array)\n sum = 0\n array.each{ |num| sum += num }\n sum\nend",
"def running_total(array)\n result = []\n sum = 0\n index = 0\n\n while array.size > index\n result << sum += array[index]\n index += 1\n end\n result\nend",
"def add_array(array)\n sum = 0\n for i in array do\n sum += i\n end\n sum\nend",
"def reduce_to_total(source_array, starting_point = 0)\n return source_array.reduce() {|sum,n| sum + n}\nend",
"def adjacent_sum(arr)\r\n sum = []\r\n (1...arr.length).each do |i|\r\n sum[i - 1] = arr[i - 1] + arr[i]\r\n end\r\n return sum\r\nend",
"def sum_of_sums(arr)\n sum = 0\n total = 0\n\n arr.each do |num|\n sum += num\n total += sum\n end\n total\nend",
"def sum_of_sums(arr)\n sum = 0\n total = 0\n\n arr.each do |num|\n sum += num\n total += sum\n end\n total\nend",
"def running_total(array)\n new_array = []\n sum = 0\n count = 0\n\n while count < array.size\n array.each do |num|\n sum += num\n new_array << sum\n count += 1\n end\n end\n new_array\nend",
"def sum_array(array)\n total = 0\n array.each do |num|\n total += num\n end\n total\nend",
"def sum(array)\n sum = 0\n array.each do |a|\n sum += a\n end\n return sum\nend",
"def sum_array(array)\n sum = 0\n array.each do |element|\n sum += element\n end\n sum\nend",
"def total(array)\n \n len = array.length\n i = 0\n sum = 0\n \n while i < len do\n sum = sum + array[i]\n i = i + 1\n end\n return sum\nend",
"def iterative_sum(arr)\n total = 0\n arr.each {|num| total += num}\n return total\nend",
"def running_total(old_array)\n counter = 0\n new_array = []\n loop do \n break if counter >= old_array.length\n if counter == 0\n new_array[counter] = old_array[counter]\n else \n new_array[counter] = old_array[counter] + new_array[counter-1]\n end\n counter += 1\n end\n new_array\nend"
] |
[
"0.7631964",
"0.76146305",
"0.7520379",
"0.7515969",
"0.74783814",
"0.7439132",
"0.7411004",
"0.7403761",
"0.7395291",
"0.73907554",
"0.7353599",
"0.73473287",
"0.73310477",
"0.73274606",
"0.7296245",
"0.7295351",
"0.727139",
"0.7268158",
"0.7264415",
"0.72617936",
"0.7259751",
"0.7255576",
"0.725382",
"0.72470677",
"0.72468454",
"0.7245329",
"0.7233496",
"0.72305274",
"0.7222358",
"0.7222094",
"0.7222085",
"0.72218317",
"0.72182035",
"0.7217197",
"0.7216782",
"0.72142816",
"0.72092324",
"0.7207984",
"0.72057647",
"0.7197496",
"0.71955353",
"0.7190096",
"0.71877664",
"0.7185549",
"0.7177383",
"0.7176267",
"0.71712667",
"0.71666396",
"0.7165197",
"0.71633554",
"0.7159762",
"0.71585244",
"0.7157235",
"0.71496165",
"0.71486366",
"0.7146432",
"0.71439075",
"0.71419966",
"0.71380085",
"0.71378094",
"0.7136643",
"0.7120762",
"0.7120049",
"0.7116727",
"0.7109512",
"0.71094126",
"0.71094",
"0.7104762",
"0.71046215",
"0.71019334",
"0.7101007",
"0.7099874",
"0.70994174",
"0.7099387",
"0.7095898",
"0.70924616",
"0.70919585",
"0.7091818",
"0.7090069",
"0.70900583",
"0.70877445",
"0.7086504",
"0.70854956",
"0.7083943",
"0.7083393",
"0.7083393",
"0.70819044",
"0.7081729",
"0.7079691",
"0.7076912",
"0.70761406",
"0.7074914",
"0.7074264",
"0.7074264",
"0.70736164",
"0.7073025",
"0.7066717",
"0.70618427",
"0.7059609",
"0.70582527",
"0.70574516"
] |
0.0
|
-1
|
multiply that sum by the provided 3rd argument multiplier
|
def multiply_sum_by_3rd_argument
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def multiply(*all_args)\n all_args.inject(1) { |sum, value| sum *= value}\nend",
"def mult(*args)\n\tprod = 1\n\targs.each do |arg|\n\t\tprod *= arg\n\tend\n\tprod\nend",
"def multiply(nums)\r\n nums.reduce(:*)\r\nend",
"def multiply\n inject(1) { |p,x| p * x }\n end",
"def mul!(*args)\n dotop!(RAtlas::method(:mul!), RAtlas::method(:mmul!),\n *args)\n end",
"def multiply\n match '*'\n factor\n emit_ln 'MULS (SP)+,D0'\nend",
"def summul n, x\n count = n / x\n x * (count * (1 + count) / 2)\nend",
"def multiply(*input)\n\t\tinput.flatten.inject(:*)\n\tend",
"def multiplies (*args)\n multi=1\n args.each do |item|\n multi *=item\n end\n multi\nend",
"def multiply_each (array, product=1)\n array.each do |x|\n product *= x\n end\n return product\nend",
"def Multiply(val)\n self.value *= val\n end",
"def multiplier(num1, num2)\n num1 * num2\nend",
"def multiply(*nums)\n return nums.reduce(:*)\nend",
"def multiply(*multiplicands)\n multiplicands.flatten.inject(1, :*)\n end",
"def multiplier(num1, num2)\nnum1 * num2\nend",
"def multiplier(num1, num2)\nnum1 * num2\nend",
"def multiply(*arr)\n\tproduct, i = 1, 0\n\n while i < arr.length\n \tproduct *= arr[i]\n \ti += 1\n end\n\n # could also just use reduce, just keeping fundamentals sharp\n product\nend",
"def summul(n, x)\n count = n // x\n x * (count * (1 + count) // 2)\nend",
"def multiply(numbers)\n numbers.inject { |sum, n| sum * n }\n end",
"def mul(lhs, rhs)\n numeric_operation(:mul, lhs, rhs)\n end",
"def multiply(a, b)\r\n a * b\r\n end",
"def multiply(input_number)\n $number *= input_number\n return $number\nend",
"def multiply(a, b)\nend",
"def multiplicationby3(a)\n return a*3\nend",
"def multiply(first, second)\n first * second\nend",
"def multiply(number_1, number_2, number_3)\n output = number_1 * number_2 * number_3\n return output\nend",
"def multiply(*numbers)\n numbers.reduce(1, :*)\n end",
"def multiply(*nums)\n nums.reduce(1, :*)\nend",
"def *(multiplier)\n return map {|currency, money| money * multiplier}\n end",
"def multiply(num)\n product = 1\n num.each do |x|\n product *= x\n end\n product\nend",
"def multiply(array)\n array.inject(:*)\nend",
"def *(arg)\n case arg\n when Numeric\n mul(arg)\n when RNum::Base\n inner(arg)\n else\n raise ArgumentError, \"Can not multiply #{self.class} with #{arg.class}\"\n end\n end",
"def multiplier\n Misc.pos_neg_read_multip(pos,neg,read)\n end",
"def *(a)\n if a.class == Vector # inner product\n product = 0\n self.each_index{|k| product += self[k]*a[k]}\n else\n product = Vector.new # scalar product\n self.each_index{|k| product[k] = self[k]*a}\n end\n product\n end",
"def mult(a, b)\n a * b\nend",
"def multiply(number1, number2)\n number1 * number2\n end",
"def multiply(first_parameter, second_parameter)\n (first_parameter * second_parameter).to_i\n end",
"def multiply(a, b)\n\ta * b\nend",
"def mul(a, b)\n res = []\n res << a[0]*b[0] + a[1]*b[2]\n res << a[0]*b[1] + a[1]*b[3]\n res << a[2]*b[0] + a[3]*b[2]\n res << a[2]*b[1] + a[3]*b[3]\n res\nend",
"def product(numbers)\n result = 1\n numbers.each do |number|\n result *= number\n end\n result\nend",
"def multiply(*nums)\n total = 1\n\n num_of_args = nums.length\n\n if(num_of_args == 1)\n total = nums[0]\n else\n nums.each do |n|\n total *= n\n end\n end\n return total\nend",
"def mult_numbers(a,b)\n\ta*b\nend",
"def product\n inject(nil) { |mul, x| mul ? mul * x : x }\n end",
"def Multiply(x)\n (x * 3)\nend",
"def transmogrifier num1,num2,num3\n\t(num1 * num2) ** num3\nend",
"def multiply(num1, num2)\n num1 * num2\n end",
"def cubed(num)\n multiplier(num, num, num)\nend",
"def custom_multiply(array, number)\n result = []\n number.times { array.each { |element| result << element}}\n result\nend",
"def multiply(num1, num2)\n num1 ** num2\nend",
"def multiply (array)\n\tarray.inject(1) do |result, element|\n\t\tresult * element\n\tend\nend",
"def multiply(nums)\n\treturn 0 if nums == []\n\tnums.reduce(:*)\nend",
"def transmogrifier(num1, num2, num3)\n\t(num1 * num2) ** num3\nend",
"def multiply (b, c)\n a = b * c \n return a \nend",
"def multiply(first_number, second_number)\n first_number * second_number\nend",
"def *(value)\n mul(value) ;\n end",
"def multiply(num_a, num_b)\n num_a * num_b\nend",
"def multiply(num_a, num_b)\n num_a * num_b\nend",
"def multiply(number_1, number_2)\n number_1 * number_2\nend",
"def multiply(number_1, number_2)\n number_1 * number_2\nend",
"def mult num1, num2\n num1 * num2\nend",
"def mult(num1, num2)\n num1 * num2\nend",
"def product(nums)\n nums.inject(1) { |product, n| product * n }\nend",
"def multiply(a,b)\n\treturn a * b\nend",
"def mult(x,y)\n\tx * y\nend",
"def multiply(first_num, second_num)\n first_num * second_num\nend",
"def add_mul\n\t\tpos = 0\n\t\twhile pos < @instructions.length - 6\n\t\t\tsix = @instructions[pos, 6]\n\t\t\tif six.map { |instr| instr[:type] } == CONST_MULT &&\n\t\t\t\t\t[six[0][1], six[0][2], six[1][1], six[4][1]].uniq.length == 4 &&\n\t\t\t\t\t[six[0][2], six[2][1], six[2][1]].uniq.length == 1 &&\n\t\t\t\t\tsix[4][1] == six[5][1] &&\n\t\t\t\t\tsix[3][2] == -2 && six[5][2] == -5\n\t\t\t\t@instructions[pos] = {:type => :mul, 1 => six[0][1], 2 => six[4][1], 3 => six[1][1]}\n\t\t\t\t@instructions[pos + 1] = {:type => :cpy, 1 => 0, 2 => six[2][1]}\n\t\t\t\t@instructions[pos + 2] = {:type => :cpy, 1 => 0, 2 => six[4][1]}\n\t\t\t\t((pos + 3)..(pos + 5)).each do |i|\n\t\t\t\t\t@instructions[i] = {:type => :none}\n\t\t\t\tend\n\t\t\tend\n\t\t\tpos += 1\n\t\tend\n\tend",
"def multiply\n yield 10\n yield 75\n yield 879\nend",
"def multiply(n1, n2)\n n1 * n2\nend",
"def multiply(n1, n2)\n n1 * n2\nend",
"def multiply(n1, n2)\n n1 * n2\nend",
"def multiply(n1, n2)\n n1 * n2\nend",
"def multiply (a,b)\n a * b\nend",
"def multiply (a,b)\n a * b\nend",
"def multiply(num_1, num_2)\n num_1 * num_2\nend",
"def multiply(num_1, num_2)\n num_1 * num_2\nend",
"def multiply(arr_in)\n\treturn nil if arr_in.empty?\n\ttotal = arr_in.first\n\tarr_in.delete_at(0)\n\tarr_in.each { |elem| total *= elem }\n\ttotal\nend",
"def multiply(*args) # multiple arguments\n array = args.to_a #convert to array\n array.reduce(:*)\nend",
"def multiply(first_number, second_number)\n return first_number * second_number\nend",
"def multiply(first_number, second_number)\n return first_number * second_number\nend",
"def multiply(n1, n2)\n n1 * n2\nend",
"def on_mul(ast_node, context)\n left, right = *ast_node\n\n return on_call_number(context, left) * on_call_number(context, right)\n end",
"def multiply(first_number , second_number)\n return first_number * second_number\nend",
"def multiply(num1, num2)\n\treturn num1 * num2\nend",
"def multiply (a b)\r\n a * b\r\nend",
"def multiply(num1, num2)\n\tnum1 * num2\nend",
"def multiply(num1, num2)\n\tnum1 * num2\nend",
"def multiply(a, b)\n\t\treturn a*b\n\tend",
"def prod(x,y)\n x*y\nend",
"def multiply(nb1,nb2)\n\treturn nb1*nb2\nend",
"def multiply(a,b)\n a * b\nend",
"def multiply(a,b)\n a * b\nend",
"def multiply(a, b)\n a * b\nend",
"def multiply(a, b)\n a * b\nend",
"def multiply(a, b)\n a * b\nend",
"def multiply(a, b)\n a * b\nend",
"def multiply(a, b)\n a * b\nend",
"def multiply(a, b)\n a * b\nend",
"def multiply(a, b)\n a * b\nend",
"def multiply(a, b)\n a * b\nend",
"def multiply(a, b)\n a * b\nend"
] |
[
"0.7444188",
"0.7357048",
"0.71049494",
"0.70804065",
"0.7065773",
"0.7042493",
"0.7042044",
"0.70210147",
"0.7015285",
"0.69790494",
"0.6963095",
"0.69568056",
"0.6918573",
"0.6889177",
"0.6886552",
"0.6886552",
"0.6879731",
"0.68562347",
"0.68267405",
"0.6789354",
"0.6784073",
"0.6775094",
"0.67616045",
"0.6748198",
"0.67392373",
"0.6715985",
"0.6711279",
"0.67078096",
"0.6688864",
"0.6688532",
"0.66807294",
"0.6661426",
"0.66493165",
"0.66334254",
"0.66329956",
"0.6622087",
"0.6617404",
"0.660651",
"0.6605815",
"0.6603992",
"0.6595569",
"0.659025",
"0.6578992",
"0.65770274",
"0.65702003",
"0.6565353",
"0.65651804",
"0.65610355",
"0.65582407",
"0.6537871",
"0.65352386",
"0.6529765",
"0.65293735",
"0.652728",
"0.6518614",
"0.65050584",
"0.65050584",
"0.65020746",
"0.65020746",
"0.64919126",
"0.648969",
"0.64887893",
"0.6485361",
"0.64844674",
"0.647936",
"0.6472752",
"0.6472327",
"0.6472141",
"0.6472141",
"0.6472141",
"0.6472141",
"0.6469362",
"0.6468327",
"0.6467313",
"0.6467313",
"0.6466849",
"0.6466163",
"0.6464345",
"0.6464345",
"0.64610124",
"0.6458392",
"0.64349216",
"0.64329815",
"0.642605",
"0.6421312",
"0.6421312",
"0.6412223",
"0.64094305",
"0.6408839",
"0.6408589",
"0.6408589",
"0.64066035",
"0.64066035",
"0.64066035",
"0.64066035",
"0.64066035",
"0.64066035",
"0.64066035",
"0.64066035",
"0.64066035"
] |
0.78995043
|
0
|
Catches when the user presses the get started button
|
def get_started
intro_and_request_permissions
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def start\n\t\tself.sender.start\n\tend",
"def on_start\n end",
"def starting?; event(:start).pending? end",
"def started?; end",
"def did_start_up\n end",
"def start\n restart\n update\n Tk.mainloop\n end",
"def start\n @actions << :start\n end",
"def start\n end",
"def start\n end",
"def start\n end",
"def start\n end",
"def start\n end",
"def start\n end",
"def start\n end",
"def start\n end",
"def start\n true\n end",
"def start\n end",
"def start\n end",
"def start\n end",
"def start\n end",
"def start\n \n\tend",
"def start\n while not @stopped\n puts \"Waiting for something to happen\"\n sleep 1\n end\n end",
"def started; end",
"def start\n noth\n end",
"def start\n main_loop\n end",
"def start\n end",
"def start\n end",
"def autostart; end",
"def start() @root.mainloop end",
"def start\n\t\tend",
"def start!\n \t@initial_queue = Dispatch::Queue.current\n event :start\n end",
"def start\n display = Swt::Widgets::Display.get_current\n \n # until the window (the Shell) has been closed\n while !@shell.isDisposed\n \n # check for and dispatch new gui events\n display.sleep unless display.read_and_dispatch\n end\n\n display.dispose\n end",
"def start\n display = Swt::Widgets::Display.get_current\n \n # until the window (the Shell) has been closed\n while !@shell.isDisposed\n \n # check for and dispatch new gui events\n display.sleep unless display.read_and_dispatch\n end\n\n display.dispose\n end",
"def start\n end",
"def can_start?\n true\n end",
"def start\n display = Swt::Widgets::Display.get_current\n \n # until the window (the Shell) has been closed\n while !@shell.isDisposed\n # check for and dispatch new gui events\n display.sleep unless display.read_and_dispatch\n end\n display.dispose\n end",
"def stopped?; end",
"def stopped?; end",
"def stopped?; end",
"def stopped?; end",
"def start()\n\n\t\tend",
"def start\n\n end",
"def start args\n change_value \"status\", \"started\", args\n 0\n end",
"def starting; end",
"def start\n put :start\n end",
"def start\n super\n end",
"def start\n super\n end",
"def start\n super\n end",
"def start\n super\n end",
"def start\n super\n end",
"def will_start_up\n end",
"def onStart\r\n end",
"def start\n display = Swt::Widgets::Display.get_current\n while !@shell.isDisposed\n display.sleep unless display.read_and_dispatch\n end\n\n display.dispose\n end",
"def start_handler\n end",
"def applicationDidFinishLaunching notification\n start_output\n start_input\n end",
"def start\n display = ::Swt::Widgets::Display.get_current\n \n # until the window (the Shell) has been closed\n while !@shell.isDisposed\n # check for and dispatch new gui events\n display.sleep unless display.read_and_dispatch\n end\n \n display.dispose\n end",
"def start\n begin\n Ui.print_formatted WELCOME_MESSAGE\n loop do\n choice = UserInputHandler.request_input @options_msg.join(\"\\n\")\n execute_choice(choice)\n end\n rescue StandardError => e\n handle_error(e)\n end\n end",
"def initial_setup_pause\n puts\n say \"Thanks, #{human.name}, I have everything I need to get started.\\n\" \\\n \"Please hit any key when you are ready to begin.\"\n getchar\n end",
"def start\n super\n end",
"def on_status_ok\n @slot_window.activate.select(0)\n set_controls_help\n end",
"def starting(worker)\n end",
"def start\n puts \"Press Ctrl-C to close.\"\n @server.start\n end",
"def handle_start\n loop until get_player_output.size > 1\n @state.handle_start\n end",
"def command_start; end",
"def command_start; end",
"def command_start; end",
"def start_handler\n\tend",
"def started?\n @continue\n end",
"def start \n @Done = false \n end",
"def start!\n return if started?\n\n self.status = \"started\"\n self.start = Time.now.to_s\n end",
"def began msg\n end",
"def start\n Thread.new do\n loop do\n action, x, y = @monome.read\n toggle_led(x,y) if action == :keydown\n end\n end\n end",
"def signal\n end",
"def start\n @config[:start]\n end",
"def startup\n log \"#{name} is starting\"\n trap(\"INT\") { shutdown_soon }\n end",
"def start\n ucommand(:start)\n end",
"def start\n\t\tinit\n\t end",
"def _active_start!\n self\n end",
"def start?\r\n start\r\n end",
"def keyscan_start\n\t\trequest = Packet.create_request('stdapi_ui_start_keyscan')\n\t\tresponse = client.send_request(request)\n\t\treturn true\n\tend",
"def autostart=(_arg0); end",
"def action_start\n proxy_action(:start)\n end",
"def start\n\t\t@state=\"started\"\n\t\tp \"Car has started\"\n\tend",
"def start\n puts \"\"\n puts Rainbow(\"*\").blue * 70\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts Rainbow(\"Welcome to UPTIME!\").bright.underline\n puts \"\"\n puts \"You may type \\\"quit\\\" at any time to leave UPTIME.\"\n puts \"\"\n puts \"Have you used UPTIME on this computer before?\"\n puts \"\"\n puts \" 1. Yes\"\n puts \" 2. No\"\n puts \"\"\n used_before = gets.strip\n self.quit if used_before == \"quit\"\n if used_before == \"1\"\n self.user_already_exists\n elsif used_before == \"2\"\n self.create_new_user\n else\n self.what_was_that?\n self.start\n end\n end",
"def start(*)\n self\n end",
"def on_start\n yield self\n end",
"def start\n setup_ui\n setup_mediator\n attach_to_mediator\n start_ui\n @result\n end",
"def start!\n\t\t\t@started ||= Clock.now\n\t\tend",
"def start(mode)\n end",
"def start\n jammit\n end",
"def stop; self.app.stop end",
"def onStart()\n\t\t\tputs 'onStart method has not been overridden!'\n\t\tend",
"def start\n return self.class.get(\"/action/start\") == \"Downloads started\"\n end",
"def start()\n @state = RUNNING\n @loop.wakeup() unless @loop.nil?\n end",
"def start\n return if @started\n @started = true\n end",
"def on_quitting\n end",
"def stop\t\n\tend",
"def wake_event_loop!\n super\n end",
"def wake_event_loop!\n super\n end",
"def auto_start?\n autostart\n end",
"def example_started(notification)\n reset_output\n end"
] |
[
"0.707153",
"0.70216453",
"0.68119097",
"0.6781285",
"0.6635531",
"0.6622585",
"0.6546701",
"0.6542525",
"0.6542525",
"0.6542525",
"0.6542525",
"0.6542525",
"0.6542525",
"0.6542525",
"0.6542525",
"0.65326494",
"0.6480295",
"0.6480295",
"0.6480295",
"0.6480295",
"0.6452129",
"0.6441659",
"0.63939786",
"0.6382012",
"0.62849",
"0.62800604",
"0.62800604",
"0.6264327",
"0.62507904",
"0.62414855",
"0.62161964",
"0.61996186",
"0.61995214",
"0.61845565",
"0.61650705",
"0.61512536",
"0.6133447",
"0.6133447",
"0.6133447",
"0.6133447",
"0.6127801",
"0.61234474",
"0.6084472",
"0.608029",
"0.6057339",
"0.6056352",
"0.6056352",
"0.6056352",
"0.6056352",
"0.6056352",
"0.6042148",
"0.60332024",
"0.60286963",
"0.600901",
"0.6003647",
"0.5978033",
"0.59563565",
"0.5955573",
"0.5937518",
"0.5937238",
"0.5934953",
"0.5923548",
"0.59103173",
"0.5910113",
"0.5910113",
"0.5910113",
"0.5907831",
"0.590358",
"0.5875649",
"0.5873758",
"0.5867109",
"0.58448845",
"0.58437496",
"0.5837081",
"0.58244324",
"0.58224773",
"0.58150226",
"0.5809151",
"0.5801257",
"0.57913035",
"0.57834125",
"0.57807595",
"0.57805914",
"0.57779276",
"0.57699037",
"0.5759033",
"0.5756008",
"0.5746344",
"0.57317793",
"0.57142305",
"0.5706314",
"0.5697043",
"0.5695998",
"0.56934166",
"0.56913185",
"0.5686541",
"0.5679652",
"0.5674481",
"0.5674481",
"0.5672074",
"0.5660613"
] |
0.0
|
-1
|
gets a list of users
|
def all(params = {})
begin
parse get nil, params
rescue Exception => e
[]
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def list\n get('users')['users']\n end",
"def list_users\n http_get(:uri=>\"/users\", :fields=>x_cookie)\n end",
"def list\n response = @client.get(\"/users\")\n response[\"users\"].map {|u| User.new(@client, u) }\n end",
"def list_users\n self.class.get('/users')\n end",
"def list\n log \"retrieving users list from #{users_path}\"\n response = identity_client.get(users_path)\n records = JSON.load(response.body)[\"users\"]\n records.map { |record|\n record[\"username\"]\n }.map { |username|\n Raca::User.new(@account, username)\n }\n end",
"def user_list\n\t\tget_call = Curl::Easy.http_get(\"#{@ip_address}:#{@port_2}/v2.0/users/\"\n\t\t) do |curl| curl.headers['x-auth-token'] = @token end\n\t\t\n\t\tputs \"Here is a list of users...\"\n\t\tparsed_json = JSON.parse(get_call.body_str)\n\t\t\n\t\tputs parsed_json\n\t\treturn parsed_json\n\tend",
"def list\n\t\t# retrieve all users\n @users = User.find(:all)\n end",
"def user_list(offset = 0, limit = 100)\n api.get('user', offset: offset, limit: limit)\n end",
"def users_list\n\t\t\tpost= { \"token\" => @token }\n\t\t\tdocxml = nil\n\t\t\tdocxml=nessus_request('users/list', post)\n\t\t\tif docxml.nil?\n\t\t\t\treturn\n\t\t\tend\n\t\t\tusers=Array.new\n\t\t\tdocxml.root.elements['contents'].elements['users'].each_element('//user') { |user|\n\t\t\t\tentry=Hash.new\n\t\t\t\tentry['name']=user.elements['name'].text\n\t\t\t\tentry['admin']=user.elements['admin'].text\n\t\t\t\tentry['lastlogin']=user.elements['lastlogin'].text\n\t\t\t\tusers.push(entry)\n\t\t\t}\n\t\t\treturn users\n\t\tend",
"def get_users\n users = call(CMD_GET_USERS)[:users]\n users.map {|account| User.new(account) }\n end",
"def list_users\n @users = User.find(:all)\n end",
"def users\n get('get_users')\n end",
"def all_users()\n @endpoint = \"/users.json?limit=100\"\n setup_get\n res = @http.request(@req)\n return JSON.load(res.body)[\"users\"].sort_by { |user| user[\"lastname\"] }\n end",
"def list\n @all_users = User.find(:all)\n end",
"def users_list(options = {})\n if block_given?\n Pagination::Cursor.new(self, :users_list, options).each do |page|\n yield page\n end\n else\n get(\"users\", options)\n end\n end",
"def users(list_id)\n Iterable.request(conf, '/lists/getUsers', listId: list_id).get\n end",
"def list_users\n BrickFTP::API::User.all\n end",
"def list_users\n BrickFTP::API::User.all\n end",
"def users\n unless @users\n userListService = $viewContext.getViewService(OTUserListService.java_class)\n @users = userListService.getUserList().sort_by { |user| #sort users by name\n (user.name && !user.name.empty?) ? user.name.downcase.split.values_at(-1, 0) : [''] \n }\n end\n @users\n end",
"def users\n unless @users\n userListService = $viewContext.getViewService(OTUserListService.java_class)\n @users = userListService.getUserList().sort_by { |user| #sort users by name\n (user.name && !user.name.empty?) ? user.name.downcase.split.values_at(-1, 0) : [''] \n }\n end\n @users\n end",
"def users\n self.class.get(\"/user\", @options).parsed_response[\"items\"]\n end",
"def getUsers() #:name, :default_currency, :locale\r\n returnArray = []\r\n retrieveData(\"/v1/users\")[\"data\"].each do |item|\r\n returnArray << User.new(item[\"name\"], item[\"default_currency\"], item[\"locale\"])\r\n end\r\n return returnArray\r\n end",
"def all\n result = Client.request(:get, 'users')\n\n if result.is_a?(Result::Success)\n result.body[:users].map { |data| User.new(data) }\n else\n []\n end\n end",
"def list_all_users\n\n end",
"def get_user_list\n return User.find(:all, :order => 'last_name ASC').collect {|user| [user.full_name, user.id]}\n end",
"def list_users(user_id)\n self.class.get(\"/users/#{user_id}\")\n end",
"def users\n\t\t\telems = []\n\t\t\tget_resource_link(:users, \"users\", \"user\").each do |data|\n\t\t\t\telems << data\n\t\t\t\t# elems << User.new(data)\n\t\t\tend\n\t\t\telems\n\t\tend",
"def get_users\n\t\t\t@users = User.all.where(:on_beverage_list => true).order('firstname, lastname')\n\t\tend",
"def users\n users = Backlogjp.base._command \"getUsers\", self.id\n users.map {|hash| User.new(hash)}\n end",
"def list_users\n tp @users, :real_name, :slack_id, :user_name => {:display_method => :name}\n end",
"def getAllUsers()\n puts \"\\nUSERS:\"\n puts \"-------------------------------------------------\"\n @users.each {|user| puts \"ID: \" + user.id.to_s + \" Name: \" + user.name}\n puts \"-------------------------------------------------\"\n end",
"def get_users(request); end",
"def get_users_list\n service_response = AdminManagement::Users::UserList.new(params).perform\n render_api_response(service_response)\n end",
"def get_list(params = {})\n http_helper.send_get_request(\"#{@url_prefix}/#{get_user_id!(params)}#{@url_suffix}\", params)\n end",
"def all_users(**args)\n params = parameters(args) do\n optional_params\n end\n request(:get, 'users', params)\n end",
"def list\n # ask the user_repository for a list of all the users\n users = @user_repository.all\n # pass that list to the view to display\n @view.list_users(users)\n end",
"def users(params = {})\n make_get_request('/account/users', params)\n end",
"def users_list\r\n @users_list = User.order_by_asc('name').find(:all, :conditions => [\"group_id <> ?\", Group.get_guest.id])\r\n if params[:users]\r\n @users_list = User.get_user_list params\r\n end\r\n end",
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def users()\n\t\t\t\tusers = UserList.new()\n\n if dscl?\n # The dscl version is still limited\n idlist = `#{DSCLBIN} . -list /Users UniqueID`\n grouplist = `#{DSCLBIN} . -list /Users PrimaryGroupID`\n idlist.each do | line |\n user = UserInfo.new()\n name,id = line.split\n user.username = name\n user.uid = id.to_i\n users[name] = user\n end\n else\n # get the list of users using niutil\n textlist = `niutil -list . /users`\n textlist.each() { |line|\n line.strip!()\n user = UserInfo.new()\n user.username = line[/^[0-9]+\\s+(\\S+)$/, 1]\n userlist = `niutil -read . /users/#{user.username}`\n userlist.each() { |subline|\n subline.strip!()\n case(subline)\n when(/^home:/)\n user.homedir = subline[/:\\s*(.*)$/, 1]\n when(/^uid:/)\n user.uid = subline[/:\\s*(.*)$/, 1].to_i()\n when(/^gid:/)\n user.gid = subline[/:\\s*(.*)$/, 1].to_i()\n when(/^realname:/)\n user.fullname = subline[/:\\s*(.*)$/, 1]\n end\n }\n users[user.username] = user\n }\n end\n\t\t\t\treturn(users)\n\t\t\tend",
"def get_users\r\n # Prepare query url.\r\n _path_url = '/users'\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n decoded.map { |element| User.from_hash(element) }\r\n end",
"def list_users(offset=0, limit=20)\n target = \"#{self.base_url}/user/\"\n options = {\n basic_auth: self.auth,\n query: {\n _limit: limit,\n _offset: offset\n }\n }\n self.class.get(target, options)\n end",
"def get_all\n @user_repository.get_all_users\n end",
"def all\n response = conn.get do |request|\n request.url \"/v1/admin/users.json\"\n end\n\n response.body[\"users\"].map {|attributes| Nuwe::User.new(attributes)}\n end",
"def user_list\n execute('dscacheutil -q user') do |result|\n users = []\n result.stdout.each_line do |line|\n users << line.split(': ')[1].strip if /^name:/.match?(line)\n end\n\n yield result if block_given?\n\n users\n end\n end",
"def fremont_users\n\ttmp = Array.new\n\tres = Array.new\n\ti = 0\n\twhile (tmp = TOKEN.get('/v2/campus/7/users', params: { page: i, per_page: 100 }).parsed).length > 0\n\t\tputs 'user request page is ' + i.to_s\n\t\ttmp.each do |page|\n\t\t\tres.push(page)\n\t\tend\n\t\ti += 1\n\tend\n\treturn res\nend",
"def list_users(json_payload={})\n conn = @client.get do |req|\n req.url '/api/v2/user/list?'\n req.headers[\"Authorization\"] = @token\n req.params = json_payload\n end\n conn.body\n end",
"def get_all_users(params = {})\n res = call_api(:method => :get, :uri => @api_base.merge(\"user\"), :query_params => params)\n return unless res.successful?\n Users.new(res.data)\n end",
"def get_user_info(list)\n\trequire 'net/http'\n\tNet::HTTP.get(ENV[\"VERITAS-USER-SERVER\"] + \"/users?user_ids=#{list}\")\nend",
"def users\n @users = User.find(:all)\n end",
"def index\n @users = UserService.getAllUserList\n end",
"def get_users(options)\n @client.raw('get', '/config/users', options)\n end",
"def list_of_users\n\tusers=[]\n\tfor username in Dir.entries(\"/Users\")\n\t\tif !username.start_with?(\".\")\n\t\t\tusers.push(username)\n\t\tend\n\tend\n\treturn users\nend",
"def getUserList\n @userList\n end",
"def index\n @users = UserService.all_users\n end",
"def list_users()\n response = HTTParty.get(\"https://graph.microsoft.com/v1.0/users\", { \n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Host\" => 'graph.microsoft.com' \n }\n })\n return JSON.parse response.read_body\n end",
"def list_current_users *args\r\n puts \"not implemented yet\"\r\n end",
"def list(garbage, start)\n @all_user = session_user.agency.users\n @start = start.to_i || 0\n @limit = request.params[\"limit\"] || UserListingLength\n @user = @all_user[@start .. (@start+@limit)-1] # FIXME: Do it with sequel!\n @uparted = @user.partition{|u| @user.index(u) % 2 == 0 }\n end",
"def all_users\n `dscl . list /Users`.split(\"\\n\").delete_if { |e| e =~ /^_/ }\n end",
"def all(instance)\n data = service.list_users(instance).to_h[:items] || []\n load(data)\n end",
"def users(params = {})\n params.merge!(key: 'users')\n objects_from_response(Code42::User, :get, 'user', params)\n end",
"def users(params = {})\n response = get('users/lookup.json', params)\n response.map {|user| Croudia::Object::User.new(user) }\n end",
"def list_users\n response = @connection.dbreq(\"GET\", @lbmgmthost, \"#{@lbmgmtpath}/instances/#{CloudDB.escape(@id.to_s)}/users\",@lbmgmtport,@lbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n CloudDB.symbolize_keys(JSON.parse(response.body)[\"users\"])\n end",
"def users\n get(:users)['Users'].map do |details|\n User.new(details['Url'], party: self, details: details)\n end\n end",
"def users\n @users ||= begin\n users = client.team_members ENV[\"GITHUB_TEAM_ID\"], :per_page => 100\n while client.last_response.rels[:next] && client.rate_limit.remaining > 0\n users.concat client.get client.last_response.rels[:next].href\n end\n users.map { |u| User.new u[:login] }\n end\n end",
"def get_users\n res = search(@config[:userdn])\n \n if (res[:message] != \"Success\")\n # tbd handle error\n return nil\n end\n \n if (res[:values] == [])\n return nil\n end\n \n users = []\n \n res[:values].each do |user|\n begin\n uid = user.uidnumber.first\n gid = user.gidnumber.first\n rescue\n uid = 0\n gid = 0\n end\n \n users << {\n :username => user.uid.first,\n :uid => uid,\n :gid => gid,\n :first => user.givenname.first,\n :last => user.sn.first\n }\n end\n \n return users\n end",
"def users\n []\n end",
"def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend",
"def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend",
"def list_users(workspace)\n puts \"\\nUser List\\n\\n\"\n tp workspace.users, \"id\", \"name\", \"real_name\", \"status_text\", \"status_emoji\"\nend",
"def get_all_user_names\n @user_manager.get_all_user_names\n end",
"def list_user_names(iam)\r\n list_users_response = iam.list_users\r\n list_users_response.users.each do |user|\r\n puts user.user_name\r\n end\r\nend",
"def user_list\n @user=User.all\n end",
"def find_all_usernames\n execute_sql(:read, :user) do\n table.select(:username).map do |row|\n row[:username]\n end\n end\n end",
"def returning_users\n []\n end",
"def view_all_users\n # !! get all user so can interact after viewing them? all_users\n # User.select(:username).each_with_index {|user, index| puts \"#{index+1}. #{user.username}\"}\n #??????\n User.select(:username).each {|user| puts user.username}\n end",
"def all_users\n result = []\n api.search(accounts_dn, ::LDAP::LDAP_SCOPE_SUBTREE, accounts_filter) do |user|\n result << user.to_hash\n end\n result\n end",
"def users(query)\n get_endpoint('users', nil, {'q' => query})[\"users\"].map{|u| \n Bibliovore::User.new(u, self)\n }\n end",
"def get_users(filter: {}, includes: nil, limit: nil, sort: nil)\n params = users_request_client.build_params(filter: filter, includes: includes, limit: limit, sort: sort)\n users_request_client.get(\"users\", params)\n end",
"def users(passwords=false)\n if passwords\n doc = request(\"user-list_users\")\n else\n doc = request(\"user-list_users_no_pw\")\n end\n api_error?(doc)\n (doc/:data).inject([]) { |users, user| users << User.new_from_xml(user); users }\n end",
"def list(queries: nil, search: nil)\n path = '/users'\n\n params = {\n queries: queries,\n search: search,\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'GET',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::UserList\n )\n end",
"def all_users\n return [] if @json_data['users'].nil?\n @json_data['users'].collect { |user| [user['first'], user['last']].join(' ') }\n end",
"def list(filter=KalturaNotImplemented, pager=KalturaNotImplemented)\n\t\t\tkparams = {}\n\t\t\t# A filter used to exclude specific types of users\n\t\t\tclient.add_param(kparams, 'filter', filter);\n\t\t\t# A limit for the number of records to display on a page\n\t\t\tclient.add_param(kparams, 'pager', pager);\n\t\t\tclient.queue_service_action_call('user', 'list', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend",
"def list_users(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'ListUsers'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :marker\n\t\t\targs[:query]['Marker'] = optional[:marker]\n\t\tend\n\t\tif optional.key? :max_items\n\t\t\targs[:query]['MaxItems'] = optional[:max_items]\n\t\tend\n\t\tself.run(args)\n\tend",
"def get_users\n users = []\n `/usr/sbin/jamf listUsers`.scan(/<name>(.*?)\\<\\/name>/) { users << $1 }\n users\nend",
"def all_users()\n User.all\n end",
"def getUsers\n return @Users \n end",
"def users\n @users_by_href.values\n end",
"def index\n\t\t@users = User.all\n\tend",
"def index\n\t\t@users = User.all\n\tend",
"def index\n\t\t@users = User.all\n\tend",
"def index\n\t\t@users = User.all\n\tend",
"def index\n\t\t@users = User.all\n\tend",
"def index\n\t\t@users = User.all\n\tend",
"def list_users\n \t#p params[:search]\n \tif params[:search].nil?\n \t\t@users= User.all\n \telse\n \t\t@users= User.search_users(params)#this function from model\n \tend\n end",
"def list_users(query = {})\n aws_service_client.list_users(query)\n end",
"def list\n\t\t\t# Author\n\t\t\tauthorize! :manage, User\n\n\t\t\t# Get params\n\t\t\tpage \t\t\t= \t(params[:page] || 1).to_i\n\t\t\tper \t\t\t=\t(params[:per] || 24).to_i\n\t\t\tsearch_params \t=\tparams[:search] || {}\n\t\t\torder_params \t= \tparams[:order] || {}\n\n\t\t\t# Get users\n\t\t\tusers = User.list_search_with_params search_params, order_params\n\n\t\t\t# Render result\n\t\t\trespond_to do |f|\n\t\t\t\tf.html {\n\t\t\t\t\trender 'list',\n\t\t\t\t\t\tlayout: 'layout_back',\n\t\t\t\t\t\tlocals: {\n\t\t\t\t\t\t\tusers: \tusers,\n\t\t\t\t\t\t\tpage: \tpage,\n\t\t\t\t\t\t\tper: \tper\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tf.json {\n\t\t\t\t\tusers_in_page = users.page page, per\n\n\t\t\t\t\t# Check if empty\n\t\t\t\t\tif users_in_page.count == 0\n\t\t\t\t\t\trender json: {\n\t\t\t\t\t\t\tstatus: 1\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\trender json: {\n\t\t\t\t\t\t\tstatus: 0,\n\t\t\t\t\t\t\tresult: {\n\t\t\t\t\t\t\t\tlist: render_to_string(\n\t\t\t\t\t\t\t\t\tpartial: 'list',\n\t\t\t\t\t\t\t\t\tformats: :html,\n\t\t\t\t\t\t\t\t\tlocals: {\n\t\t\t\t\t\t\t\t\t\tusers: users_in_page\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tpaginator: render_to_string(\n\t\t\t\t\t\t\t\t\tpartial: '/shared/pagination',\n\t\t\t\t\t\t\t\t\tformats: :html,\n\t\t\t\t\t\t\t\t\tlocals: {\n\t\t\t\t\t\t\t\t\t\ttotal: \tusers.count,\n\t\t\t\t\t\t\t\t\t\tper: \tper,\n\t\t\t\t\t\t\t\t\t\tpage: \tpage\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\tend\n\t\tend",
"def index\n \t@users = UsersService.UserListAll(params[:page])\n end",
"def list\n # ask the repo for a list of all the users\n users = @repo.all\n # pass that list to the view to display\n @view.list_users(users)\n end",
"def query_users(options={}) path = \"/api/v2/users\"\n get(path, options, AvaTax::VERSION) end",
"def index\n @users = User.find_all_with_authorization(current_user)\n end"
] |
[
"0.8715094",
"0.8551452",
"0.84233564",
"0.83502555",
"0.8327375",
"0.83068377",
"0.82944286",
"0.8275011",
"0.8265321",
"0.8231169",
"0.8195651",
"0.81913435",
"0.8181365",
"0.8154818",
"0.81418914",
"0.8085132",
"0.80827063",
"0.80827063",
"0.807182",
"0.807182",
"0.80677325",
"0.7998",
"0.7931424",
"0.7924434",
"0.7900961",
"0.7866378",
"0.78533113",
"0.78511906",
"0.78267163",
"0.7820664",
"0.7776695",
"0.7733092",
"0.77326053",
"0.77298266",
"0.7710443",
"0.7708418",
"0.7696537",
"0.76608104",
"0.7641496",
"0.7630696",
"0.75976807",
"0.75934386",
"0.75864446",
"0.75502014",
"0.7550144",
"0.7538011",
"0.75284356",
"0.75104743",
"0.7496274",
"0.74960136",
"0.74949706",
"0.749416",
"0.7488458",
"0.7468867",
"0.7448503",
"0.7445327",
"0.74430305",
"0.74293816",
"0.74116856",
"0.74023736",
"0.7399721",
"0.7378632",
"0.73760647",
"0.7352029",
"0.73447984",
"0.7338848",
"0.73386866",
"0.7338159",
"0.7338159",
"0.73284715",
"0.732512",
"0.73120946",
"0.73091125",
"0.7306469",
"0.73047847",
"0.7301719",
"0.72969496",
"0.7295098",
"0.72926956",
"0.7292555",
"0.7281779",
"0.72738576",
"0.726614",
"0.72658026",
"0.7262583",
"0.72622615",
"0.72615594",
"0.726116",
"0.7250342",
"0.7250342",
"0.7250342",
"0.7250342",
"0.7250342",
"0.7250342",
"0.72469777",
"0.72256607",
"0.72174007",
"0.7212102",
"0.72023326",
"0.72009623",
"0.7199136"
] |
0.0
|
-1
|
directories and files from /home/account_name/www/project_name folder (using ex. FileZilla) but it left some folders with symlinks, such as: www ` project_name | current > /home/account_name/www/project_name/releases/20131014083207 ` releases | 20131014081055 | | log > /home/account_name/www/project_name/shared/log | | public | | ` system > /home/account_name/www/project_name/shared/system | ` tmp | ` pids > /home/account_name/www/project_name/shared/pids ` 20131014083207 | log > /home/account_name/www/project_name/shared/log | public | ` system > /home/account_name/www/project_name/shared/system ` tmp ` pids > /home/account_name/www/project_name/shared/pids Before run change change project_name and account_name variables below. Than connect to your alwaysdata account with ssh, copy this file wherever you want and run: ruby r './ad_cleanup.rb' e 'cleanup'
|
def cleanup
# ----------------------------------------------
account_name = 'your account name' # <-- change this!
project_name = 'your project name' # <-- change this!
# ----------------------------------------------
project_dir = "/home/#{account_name}/www"
Dir.chdir(project_dir)
Dir.entries(project_name).select do |entry1|
dir1 = File.join(project_name,entry1) #dir2 = "#{project_name}/#{entry1}"
if is_directory?(dir1)
Dir.entries(dir1).select do |entry2|
dir2 = File.join(dir1,entry2) #dir2 = "#{project_name}/#{entry1}/#{entry2}"
if is_directory?(dir2)
Dir.entries(dir2).select do |entry3|
dir3 = File.join(dir2,entry3) #dir3 = "#{project_name}/#{entry1}/#{entry2}/#{entry3}"
if is_directory?(dir3)
Dir.entries(dir3).select do |entry4|
delete_file(File.join(dir3,entry4))
end
end
delete_file(dir3)
delete_dir(dir3)
end
end
delete_file(dir2)
delete_dir(dir2)
end
end
delete_file(dir1)
delete_dir(dir1)
end
delete_dir(project_name)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def tidy_up\n return if DEBUG\n\n puts heading(\"Tidying up PWD\")\n\n FileUtils.remove(Dir[\"#{FileUtils.pwd}/bugsnag-*.tgz\"])\nend",
"def remove_dead_symlinks\n base_paths.each do |path|\n command = \"find #{path} -xtype l -delete\"\n Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command)\n end\n end",
"def clean()\n rels = releases()\n rels.pop()\n\n unless rels.empty?\n rm = ['rm', '-rf'].concat(rels.map {|r| release_dir(r)})\n rm << release_dir('skip-*')\n cmd.ssh(rm)\n end\n end",
"def cleanup_dirs\n @cleanup_dirs ||= ['.']\n end",
"def cleanUpWorkingFiles()\n system(\"rm -f #{@tripFile} #{routeFile} #{routeAltFile}\") ;\n end",
"def cleanup\n\tsh 'del /F /Q .\\_site\\*'\n\t# sh 'rm -rf ./_site'\nend",
"def cleanup_release\n if ssh.directory_exists?(release_path)\n ssh.run(\"rm -rf #{release_path}\")\n end\n end",
"def cleanup\n if Dir.exists?(WORKFOLDER)\n FileUtils.remove_dir(WORKFOLDER)\n print_status(\"Workspace \\\"#{WORKFOLDER}\\\" deleted.\")\n end\nend",
"def clean_deploy\n FileUtils.rm_rf(Dir.glob('*'), secure: true)\n end",
"def cleanup_app_caches(app_name, instance_name)\n Dir.chdir RailsPwnerer::Config[app_name, instance_name][:app_path] do\n if File.exist?('Gemfile')\n Kernel.system 'bundle exec rake assets:clean RAILS_ENV=production'\n else\n Kernel.system 'rake assets:clean RAILS_ENV=production'\n end\n end\n end",
"def delete_nsec3_files()\n w = Dir.new(@working)\n w.each {|f|\n if ((f.index(\"audit\")) && (f.index(\"#{Process.pid}\")))\n begin\n File.delete(@working + File::SEPARATOR + f.untaint)\n rescue Exception => e\n print \"Can't delete temporary auditor file #{f}, error : #{e}\\n\"\n end\n end\n }\n end",
"def cleanup_cached_images()\n\n # swap_dir = \"../public/swap\" # use when running locally from /lib/b2_bucket.rb\n swap_dir = \"./public/swap\" # use when running via app.rb\n swap_contents = \"#{swap_dir}/*\"\n gitkeep = \"#{swap_dir}/.gitkeep\"\n\n if File.directory?(swap_dir)\n FileUtils.rm_rf(Dir.glob(swap_contents)) # delete contents of /public/swap \n file = File.new(gitkeep, 'w') # recreate .gitkeep file\n file.close if file\n else\n puts \"Directory does not exist!\"\n end\n\nend",
"def clean!\n stop\n FileUtils.remove_entry(download_path) if File.exists? download_path\n FileUtils.remove_entry(tmp_save_dir, true) if File.exists? tmp_save_dir\n FileUtils.remove_entry(instance_dir, true) if File.exists? instance_dir\n FileUtils.remove_entry(md5sum_path) if File.exists? md5sum_path\n FileUtils.remove_entry(version_file) if File.exists? version_file\n end",
"def clean!\n stop\n FileUtils.remove_entry(download_path) if File.exists? download_path\n FileUtils.remove_entry(tmp_save_dir, true) if File.exists? tmp_save_dir\n FileUtils.remove_entry(instance_dir, true) if File.exists? instance_dir\n FileUtils.remove_entry(md5sum_path) if File.exists? md5sum_path\n FileUtils.remove_entry(version_file) if File.exists? version_file\n end",
"def removestaticfiles()\n\n\t# Make a hash of files so it's easy to add to in the future. \n\t# The key is what will be printed out\n\t# the value is the path upwards of the release's wp/ directory\n\tfiles = {}\n\tfiles[\"readme.html\"] = 'readme.html'\n\tfiles[\"license.txt\"] = 'license.txt'\n\tfiles[\"install.php\"] = 'wp-admin/install.php'\n\n\t# Announce what we're doing\n\tputs \"\\n\" + '[ ' + yellow( 'RUNNING' ) + \" ] Remove static files\"\n\n\t# loop over the files hash and remove the file, saying what we're going\n\t# use print so we can add to the same line\n\tfiles.each do |text, path|\n\t\tprint \"\\n\" + \"............ removing \" + \"#{text}\"\n\t\texecute \"cd #{release_path} && cd wp && rm #{path}\"\n\t\tprint \" .. \" + green( \"\\u2713\" )\n\tend\n\n\tputs \"\\n\" + '[ ' + green( 'SUCCESS' ) + ' ] Static files removed'\n\nend",
"def delete_directories account\n # Use FileUtils\n fu = FileUtils\n # If we're just running as a simulation\n if $simulate\n # Use ::DryRun, that just echoes the commands, instead of the normal FileUtils\n fu = FileUtils::DryRun # ::DryRun / ::NoWrite\n end\n \n # Tell the user\n puts \"> Tar bort kontot från filsystemet\".green\n\n # Build the paths\n mail_dir = BASE_PATH_MAIL + account['mail']\n home_dir = BASE_PATH_HOME + account['home']\n\n # Remove the directories\n fu.rm_r mail_dir\n fu.rm_r home_dir\nend",
"def cleanTmp\n ts_str = \"/tmp/d\" + Date.today.strftime(\"%Y%m%d\") + \"-*\"\n Gitchefsync.logger.info \"clean up of #{ts_str}\"\n FS.cmdNoError \"sudo rm -fr #{ts_str}\"\n end",
"def clean_download_dir\n dir('~/Downloads/*').each do |path|\n trash path if File.mtime(path) < TWO_WEEKS_AGO\n end\n end",
"def erase_old_data()\n Djinn.log_run(\"rm -rf /tmp/h*\")\n Djinn.log_run(\"rm -f ~/.appscale_cookies\")\n Djinn.log_run(\"rm -f #{APPSCALE_HOME}/.appscale/status-*\")\n Djinn.log_run(\"rm -f #{APPSCALE_HOME}/.appscale/database_info\")\n\n Nginx.clear_sites_enabled\n HAProxy.clear_sites_enabled\n Djinn.log_run(\"echo '' > /root/.ssh/known_hosts\") # empty it out but leave the file there\n CronHelper.clear_crontab\n end",
"def preserve_folder(aReleaseFolder,aSharedFolder)\t\n\t\taReleaseFolder = File.join(release_path,aReleaseFolder)\n\t\taSharedFolder = File.join(shared_path,aSharedFolder)\n\t\trelease_exists = file_exists?(aReleaseFolder)\n\t\tshared_exists = file_exists?(aSharedFolder)\n\t\tif shared_exists\n\t\t\trun \"rm -rf #{aReleaseFolder}\" if release_exists\n\t\telse\n\t\t\trun \"mv #{aReleaseFolder} #{aSharedFolder}\" if release_exists\n\t\tend\n\t\tensure_link(\"#{aSharedFolder}\",\"#{aReleaseFolder}\",nil,\"#{user}:#{apache_user}\")\n\tend",
"def clean_up\n Dir.foreach(Dir.pwd) do |f|\n if !f.start_with?('tmp_') then next\n elsif File.directory?(f) then FileUtils.rm_rf(f)\n else FileUtils.rm(f)\n end\n end\nend",
"def cleanup\n cleanup_unpack_path\n cleanup_download_path\n end",
"def remove_moved_files\n scan_for_merges.each do |file|\n if File.amp_lexist?(@repo.working_join(file))\n UI.debug(\"removing #{file}\")\n File.unlink(@repo.working_join(file))\n end\n end\n end",
"def cleanUp\n if @keepForDays == 0\n return\n end\n Dir.chdir(@folder) \n Dir.foreach(\".\") do |entry|\n next if entry == \".\" or entry == \"..\"\n currentFile = File.stat(entry)\n x = currentFile.atime\n if Time.now - x > 60 * 60 * 24 * @keepForDays \n $LOG.info(\"#{@name} : #{entry} reached its lifespan\")\n File.delete(entry)\n end\n end\n end",
"def clean\n needs_cleaning = File.exist?(project_dir)\n if needs_cleaning\n log.info(log_key) { \"Cleaning project directory `#{project_dir}'\" }\n FileUtils.rm_rf(project_dir)\n end\n create_required_directories\n deploy\n needs_cleaning\n end",
"def clean_debris \n objdirs = File.join(\"**/\", \"obj\")\n userfiles = File.join(\"**/\", \"*.vcxproj.user\")\n\n delete_list = FileList.new(objdirs, userfiles)\n delete_list.each do |file|\n puts \"Removing #{file}\"\n FileUtils.rm_rf(\"#{file}\")\n end\nend",
"def clean_debris \n objdirs = File.join(\"**/\", \"obj\")\n userfiles = File.join(\"**/\", \"*.vcxproj.user\")\n\n delete_list = FileList.new(objdirs, userfiles)\n delete_list.each do |file|\n puts \"Removing #{file}\"\n FileUtils.rm_rf(\"#{file}\")\n end\nend",
"def delete_script_files\n validate_before_delete_script_files!\n FileUtils.rm_rf root_dir if Dir.exists? root_dir\n FileUtils.rm symlink_file if File.symlink? symlink_file\n display.print \"Playwright script '#{script_name}' destroyed!\"\n end",
"def clean\n project.run 'rm -rf /var/cache/apk/*'\n end",
"def cleanup\n case SubutaiConfig.provider\n when :hyper_v\n SubutaiDisk.hyperv_remove_disk\n end\n\n # cleanup virtual disks\n disks = SubutaiConfig.get(:_DISK_PATHES)\n unless disks.nil?\n disks.keys.each do |key|\n if File.exist?(disks[key])\n begin\n File.delete(disks[key])\n puts \"==> default: Deleted file: #{disks[key]}\"\n rescue Errno::EACCES\n puts \"==> default: (Permission denied) Failed delete file: #{disks[key]}\"\n end\n end\n end\n end\n\n # cleanup generated files\n if File.exist?(SubutaiConfig::GENERATED_FILE)\n begin\n File.delete SubutaiConfig::GENERATED_FILE\n puts \"==> default: Deleted file: #{SubutaiConfig::GENERATED_FILE}\"\n rescue Errno::EACCES\n puts \"==> default: (Permission denied) Failed delete file: #{SubutaiConfig::GENERATED_FILE}\"\n end\n end\n end",
"def clean_staging\n staging_config_file = '_config.staging.yml'\n File.delete staging_config_file if File.exists? staging_config_file\nend",
"def cleanup\n tmpdir = File.join(OBS_BUILD_DIR,OBS_LOCAL_TMP)\n if File.exists?(tmpdir)\n FileUtils.rm_rf(tmpdir)\n end\n end",
"def cleanup!\n FileUtils.rm_rf(obsolete_files)\n FileUtils.rm_rf(metadata_file) unless @site.incremental?\n end",
"def tmp\n announcing \"Removing temporary files from #{$chrootname}\" do\n if File.exists?(\"#{$chrootdir}\") then\n FileUtils.rm_rf(Dir.glob(\"#{$chrootdir}/tmp/*\"), :verbose => $verbose)\n FileUtils.rm_rf(Dir.glob(\"#{$chrootdir}/var/tmp/*\"), :verbose => $verbose)\n FileUtils.rm_rf(Dir.glob(\"#{$chrootdir}/usr/portage/distfiles/*\"), :verbose => $verbose)\n FileUtils.rm_rf(\"#{$chrootdir}/scripts/\", :verbose => $verbose)\n end\n end\n end",
"def clean\n #rm_r(srcdir)\n rm_r(blddir)\n #rm_r(libdir)\n end",
"def cleanDownloads()\n dir(\"#{DOWNLOADS_DIR}/*\").each do |path|\n if path != PREV_DOWNLOADS_DIR\n # colourFile(path)\n moveOldDownload(path)\n end\n end\n end",
"def clean!\n stop\n remove_instance_dir!\n FileUtils.remove_entry(config.download_path) if File.exists?(config.download_path)\n FileUtils.remove_entry(config.tmp_save_dir, true) if File.exists? config.tmp_save_dir\n md5.clean!\n FileUtils.remove_entry(config.version_file) if File.exists? config.version_file\n end",
"def after_destroy\n super\n\n # Try our best to remove the directory. If it fails there is little\n # else that we could do to resolve the situation -- we already tried to\n # delete it once...\n self.tmpdir and FileUtils.remove_entry_secure(self.tmpdir, true)\n\n # Remove repo directory.\n if self.iso_url\n # Some files in archives are write-only. Change this property so the\n # delete succeeds.\n remove_directory(iso_location)\n end\n end",
"def remove_unwanted_files!\n system(\"cd ../#{self.underscored_name} && rm public/index.html public/images/rails.png\")\n system(\"cd ../#{self.underscored_name} && mv config/database.yml config/database.yml.example\")\n end",
"def preclean_project\n # Clean-up non-useful files (if any)\n clean_msg = `make clean 2>&1`\n @log_file.puts \"\\nNettoyage du répertoire :\\n\\n#{clean_msg}\"\n \n # I want to be sure...\n FileUtils::rm_f Dir.glob(\"*.o\")\n FileUtils::rm_f Dir.glob(\"*~\")\n end",
"def cleanup_cached_images()\n\n # swap_dir = \"../public/swap\" # use when running locally from /lib/s3_bucket.rb\n swap_dir = \"./public/swap\" # use when running via app.rb\n swap_contents = \"#{swap_dir}/*\"\n gitkeep = \"#{swap_dir}/.gitkeep\"\n\n if File.directory?(swap_dir)\n FileUtils.rm_rf(Dir.glob(swap_contents)) # delete contents of /public/swap \n file = File.new(gitkeep, 'w') # recreate .gitkeep file\n file.close if file\n else\n puts \"sightings directory does not exist!\"\n end\n\nend",
"def clean_environment\n `rm -rf /tmp/#{@upload_id}` # all sliced pages of the source file\n end",
"def clean_dir\n File.join clean_dir_parent, name\n end",
"def cleanup(prefix)\n print_header \"Cleaning up ...\"\n Constants::SOFTWARE.each do |sw|\n cmd \"rm #{prefix}/#{sw}.tar.gz; rm -rf #{prefix}/#{sw}\" if File.exist? \"#{prefix}/#{sw}.tar.gz\"\n end\n end",
"def cleanup\n FileUtils.rm(autoinst_path, force: true)\n FileUtils.rm(definition_path, force: true)\n FileUtils.rm(libvirt_definition_path, force: true)\n if provider == :libvirt\n # Due a bug in vagrant-libvirt the images will not cleanuped correctly\n # in the /var/lib/libvirt directory. This has to be done manually\n # (including DB update)\n system \"sudo virsh vol-delete #{IMAGE_BOX_NAME} default\"\n end\n end",
"def clean_tab(dir_source)\n\t#creer nouveau repertoire dans un niveau antérieur au répertoire source\n\tDir.chdir(dir_source)\n\tDir.chdir(\"../\")\n\tdir_dest_name = \"modif_DVS_#{Time.now.strftime('%Y-%m-%d_%H-%M-%S')}\"\n\t\n\tDir.mkdir dir_dest_name\n\tdir_dest_name_absolute = \"#{Dir.pwd}/#{dir_dest_name}\"\n\tputs dir_dest_name_absolute.to_s\n\t\n\t#copier les fichiers originaux DVS dans nouveau repertoire daté\n\tFileUtils.cp_r \"#{dir_source}/.\", \"#{dir_dest_name}\"\n\n=begin\n\t#copie des .TAB\n\tDir.glob(\"*{TAB}*\").each do |file_name|\n\t\tFileUtils.cp(\"#{file_name}\", \"../#{dir_dest_name}/#{file_name}\")\n\tend\n=end\n\t\n\t#positionner le programme dans le nouveau repertoire\n\tDir.chdir(\"#{dir_dest_name}\")\n\tputs \"#{Dir.pwd}\"\n\n\ttemp_file_name = \"temp.txt\" #fichier temp\n\t\n\t#modification de chaque fichier .TAB ou .tab\n\tDir.glob(\"*.{tab,TAB}*\").each do |file_name|\n\t\t# donner les droit d'écriture sur les fichiers .tab\n\t\tFile.chmod(0777, file_name)\n\t\t#vider le fichier temp\n\t\tFile.open(temp_file_name, 'w') {|file| file.truncate(0) }\n\t\t#supprimer les en-tete DVS (Ansaldo, version DVS, nom projet) et lignes du type \"|___|___|_____|\"\n\t\ttext = File.read(file_name)\n\t\ttext = text.gsub(Regexp.new(@@REGEX1), \"\")\n\t\ttext = text.gsub(Regexp.new(@@REGEX2), \"\")\n\t\ttext = text.gsub(Regexp.new(@@REGEX3), \"\")\n\t\ttext = text.gsub(Regexp.new(@@REGEX4), \"\")\n\t\ttext = text.gsub(Regexp.new(@@REGEX5), \"\")\n\t\t\n\t\tFile.open(temp_file_name, \"w\") {|file| file.puts text }\n \n\t\t#supprimer lignes vides et en-tete sauf le premier en-tête (TABLEAU 03.03: ...)\t\t\n\t\ttext_tab = IO.readlines(temp_file_name) #copie le text dans un tableau\n\t\tFile.open(file_name, 'w') {|file| file.truncate(0) } #supprimer le contenu du fichier de destination (DVSxxx.tab)\n\t\t\n\t\tfound_first = false\n\t\ti=0\n\t\twhile (text_tab[i])\n\t\t\tif ((text_tab[i].index(/^.+TABLEAU /)) && (found_first == true))\n\t\t\t\t#supprime 2 lignes avant l'entete et 5 lignes apres\n\t\t\t\tfor ligne in -(@@DELETE_NB_LIGNE_BEFORE)..(@@DELETE_NB_LIGNE_AFTER)\n\t\t\t\t\ttext_tab[i+ligne] = \"\"\n\t\t\t\tend\n\t\t\tend\n\t\t\tif ((text_tab[i].index(/^.+TABLEAU /)) && (found_first == false))\n\t\t\t\tfound_first = true\n\t\t\tend\n\t\t\ti=i+1\n\t\tend\n\t\tfile = File.open(file_name, \"a\")\n\t\ti=0\n\t\twhile (text_tab[i])\n\t\t\tfile.puts text_tab[i] unless ((text_tab[i].chomp.empty?) || \n\t\t\t(text_tab[i].codepoints.to_a[0].eql?(12)))\n\t\t\ti = i+1\n\t\tend\n\t\tfile.close\n\tend\n\tFile.delete(temp_file_name)\n\treturn dir_dest_name_absolute\nend",
"def remove_empty_directories\n base_paths.each do |path|\n command = <<-CMD\n for directory in $(find #{path} -type d); do\n if [ ! -d $directory ]; then\n echo \"Can't find directory $directory, it was probably already deleted, skipping . . .\"\n continue\n fi\n files=$(find $directory -type f)\n if [ -z \"$files\" ]; then\n echo \"No files in directory $directory, deleting . . .\"\n sudo rm -rf $directory\n fi\n done\n CMD\n Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command)\n end\n end",
"def cleanup\n cleanup_accounts\n end",
"def cleanup\n if ::File.exist?(chef_backup_dir) # rubocop:disable Style/GuardClause\n converge_by(\"removing #{chef_backup_dir}\") do\n FileUtils.rm_rf chef_backup_dir\n end\n end\nend",
"def clean_files\n ck_valid\n File.unlink(pid_file) if File.exists?(pid_file)\n File.unlink(prof_file) if File.exists?(prof_file)\n File.unlink(socket_file) if File.exists?(socket_file)\n end",
"def cleanup\n sh 'rm -rf _site'\n compass('clean')\nend",
"def cleanup_files(resource)\n remove_public_dir(resource) # where the local manifest file is stored\n remove_s3_data_files(resource)\n rescue StandardError => e\n msg = \"An unexpected error occurred when cleaning up files for resource #{resource.id}: \"\n msg << e.full_message\n logger.warn(msg)\n end",
"def clean_installation\n clean_paths.each { |path| FileUtils.rm_rf(path) }\n end",
"def clean\n FileUtils.remove_dir(@log_dir, true)\n end",
"def clean_up\n FileUtils.rm_rf @temp_root\n end",
"def cleanup\n _send_command(\"hosts -d\")\n _send_command(\"services -d\")\n _send_command(\"creds -d\")\n end",
"def cleanIntermediateFiles()\n puts \"Deleting intermediate files\"\n deleteTempFilesCmd = \"rm *.sam *.sai\"\n `#{deleteTempFilesCmd}`\n\n # Be careful here, delete only _sorted.bam\n puts \"Deleting intermediate BAM file\"\n deleteTempBAMFileCmd = \"rm *_sorted.bam\"\n `#{deleteTempBAMFileCmd}`\n\n makeDirCmd = \"mkdir casava_fastq\"\n `#{makeDirCmd}`\n moveCmd = \"mv *.fastq.gz ./casava_fastq\"\n `#{moveCmd}`\n end",
"def cleanIntermediateFiles()\n puts \"Deleting intermediate files\"\n deleteTempFilesCmd = \"rm *.sam *.sai\"\n `#{deleteTempFilesCmd}`\n\n # Be careful here, delete only _sorted.bam\n puts \"Deleting intermediate BAM file\"\n deleteTempBAMFileCmd = \"rm *_sorted.bam\"\n `#{deleteTempBAMFileCmd}`\n\n makeDirCmd = \"mkdir casava_fastq\"\n `#{makeDirCmd}`\n moveCmd = \"mv *.fastq.gz ./casava_fastq\"\n `#{moveCmd}`\n end",
"def keep_dirs; end",
"def cleanup(build_dir)\n build_dir = Pathname(build_dir)\n tmp_build_dir = Pathname('.temp-build')\n\n # copy over files we need to keep\n if File.directory?(build_dir)\n build_dir.glob(\"**/all-product-headers.yaml\").each do |file|\n intermediate = Pathname(file).relative_path_from(build_dir).dirname\n destination_dir = tmp_build_dir + intermediate\n\n FileUtils.mkdir_p(destination_dir)\n FileUtils.mv(file, destination_dir)\n end\n\n build_dir.rmtree if build_dir.directory?\n FileUtils.mv(tmp_build_dir, build_dir)\n end\nend",
"def cleanup_state\n delete_if_exists(state_file_path)\n delete_if_exists(chef_file_path)\n delete_if_exists(past_scripts_path)\n delete_if_exists(log_path)\n end",
"def clearDistributionDirectory(projectDir)\n distDir = projectDir.to_s + '/dist'\n FileUtils.rm_rf(distDir)\n FileUtils.mkdir_p(distDir)\nend",
"def destroy_file\n start_ssh do |ssh|\n ssh.exec!(\"rm #{e full_filename}\")\n dir = File.dirname(full_filename)\n ssh.exec!(\"find #{e dir} -maxdepth 0 -empty -exec rm -r {} \\\\;\")\n dir = File.dirname(dir)\n ssh.exec!(\"find #{e dir} -maxdepth 0 -empty -exec rm -r {} \\\\;\")\n end\n end",
"def clean_directory\n Dir.foreach(@server_dir) do |file|\n fn = File.join(@server_dir, file)\n File.delete(fn) if fn[-1] != '.'\n end\n end",
"def remove_temp_files\n @task.shell.mute do\n @task.remove_dir ::File.join(@project.package_path, @package_name)\n @task.remove_file ::File.join(@project.package_path, \"#{@package_name}.tmp\")\n end\n end",
"def unlink_site\n FileUtils.rm_rf(self.absolute_path) if File.exists?(self.absolute_path)\n end",
"def clean_app()\n wd = FileUtils.pwd()\n FileUtils.rm_f( [\n '/app/assets/*',\n '/app/components/*',\n '/app/controllers/*',\n '/app/helpers/*',\n '/app/models/*',\n '/app/views/*'\n ].collect!{|e| Dir.glob(wd + e)}.flatten.compact )\n end",
"def restore_local_hosts(project_name)\n `sudo cp #{local_hosts_path}/hosts_before_#{project_name} #{local_hosts_path}/hosts`\n `sudo rm #{local_hosts_path}/hosts_before_#{project_name}`\n end",
"def clean_up\n FileUtils.rm_rf \"#{@path}\" unless create_in_current_directory?\n FileUtils.rm_rf \"#{@cache}\"\n end",
"def clean_up\n execute(\"rm -rf #{namespace_dir}\")\n end",
"def remove_local_copy\n Dir.chdir(self.study.data_store_path)\n if File.exists?(self.download_location)\n File.delete(self.download_location)\n subdir = self.remote_location.blank? ? self.id : self.remote_location.split('/').first\n if Dir.exist?(subdir) && Dir.entries(subdir).delete_if {|e| e.start_with?('.')}.empty?\n Dir.rmdir(subdir)\n end\n end\n end",
"def remove_hiera_template\n Bebox::PROVISION_STEP_NAMES.each {|step| FileUtils.cd(self.project_root) { FileUtils.rm_rf \"puppet/steps/#{step}/hiera/data/#{self.name}.yaml\" } }\n end",
"def cleanup\n\t\tcleanup_ssh\n\n\tend",
"def purge\n\n FileUtils.remove_dir(@basepath)\n end",
"def cleanup\n FileUtils.rm(@out_filename)\n\n # XXX: could be rm-rf, but be safe for now. Might have\n # problems if app creates files in $PWD\n FileUtils.rmdir(@opts[:tmpdir])\n end",
"def clean\n Dir.foreach(@wd) do |file|\n next if file.start_with?('.') or (file == \"config\")\n filename = File.join(@wd, file)\n FileUtils.remove_file(filename) if File.file?(filename)\n end\n end",
"def cleanup_publish_dir(path)\n FileUtils.rm_rf(path, secure: true)\n end",
"def list_of_app_deployed_files(root_dir, name_to_cut)\n fscd = FileScanDir.new\n fscd.is_silent = true\n fscd.add_extension_filter(['.pdb','.ipdb','.iobj'])\n fscd.scan_dir(root_dir)\n res_names = []\n #each file need to be specified like without keyword File:\n # File \"app\\\\src\\\\cuperativa_gui.rb\"\n old_rel_dir_path = nil\n fscd.result_list.each do |file_src|\n name = file_src.gsub(name_to_cut, \"\")\n rel_dir_path = File.dirname(name) # note: not work with \\ intead of / on the path\n \n name.gsub!('/', \"\\\\\")\n puts str_path_file = \"#{name}\"\n if rel_dir_path != old_rel_dir_path\n puts \"Path changed to: #{rel_dir_path}\"\n adptrel_dir_path = \"\\\\#{rel_dir_path.gsub('/', \"\\\\\")}\" # need: \\app\\src\\network\n res_names << { :filename => str_path_file, :out_path => adptrel_dir_path, \n :delete_path => old_rel_dir_path }\n old_rel_dir_path = rel_dir_path\n else\n res_names << { :filename => str_path_file }\n end\n end\n p res_names.last[:delete_path] = old_rel_dir_path\n return res_names\n end",
"def prepare_workspace\n # create the local backup directory if it doesn't exist\n puts \"Checking workspace...\" if options[:verbose]\n unless File.directory?(backup_directory)\n Dir.mkdir(backup_directory)\n end\n unless File.directory?(temp_directory)\n Dir.mkdir(temp_directory)\n end\n Dir.chdir(backup_directory)\n # check local count against existing backups and delete if needed\n puts \"Checking and clearing archives...\" if options[:verbose]\n backup_files = Dir.glob('*').sort_by{ |f| File.ctime(f) }\n if (backup_files.count > (local_count * total_databases))\n number_to_remove = backup_files.count - (local_count * total_databases)\n backup_files.slice(0, number_to_remove).each { |f| File.delete(f) }\n end\n end",
"def clean_paths\n FileUtils.rm_rf(tmp_path)\n FileUtils.mkdir_p(tmp_path)\n end",
"def clean\n FileUtils.rm_rf(\"#{ROOT_DATA_FOLDER}/.\", secure: true)\n unless File.directory?(ROOT_DATA_FOLDER)\n FileUtils.mkdir_p(ROOT_DATA_FOLDER)\n end\n end",
"def delete_root\n Dir.chdir(root) do\n Dir.entries('.').each do |entry|\n next if entry == '.' || entry == '..'\n next if entry == FILES_DIR && task.options.copy_files_with_symlink\n\n begin\n FileUtils.remove_entry_secure(entry)\n rescue\n if task.options.copy_files_with_symlink\n print_title('Cannot automatically empty ' + root + '. Please manually empty this directory (except for ' + root + '/' + FILES_DIR + ') and then hit any key to continue...')\n else\n print_title('Cannot automatically empty ' + root + '. Please manually empty this directory and then hit any key to continue...')\n end\n STDIN.getch\n break\n end\n end\n end\n\n logger.info(\"#{root} content was deleted\")\n end",
"def remove_version_info name\n add \"find . -maxdepth 1 -name '#{name}*' -a -type d | xargs -I xxx mv xxx #{name}\", check_file(name)\n end",
"def cleanup_files\n FileUtils.rm_rf(File.join(Rails.root, \"tmp\"))\n end",
"def clean_test_case\n if File.exists?(@local_file_download_destination)\n File.delete(@local_file_download_destination)\n end\n end",
"def clear_data\n data_dir = TaliaCore::CONFIG['data_directory_location']\n iip_dir = TaliaCore::CONFIG['iip_root_directory_location']\n FileUtils.rm_rf(data_dir) if(File.exist?(data_dir))\n FileUtils.rm_rf(iip_dir) if(File.exist?(iip_dir))\n end",
"def fix_resources_file_paths\n Project.all.each do |p|\n if p.uuid.nil?\n p.create_uuid\n p.save!\n end\n\n p.resources.each do |r|\n if !r.file_path.nil?\n source = Rails.root.join('app/assets/images', r.file_path)\n dest = Rails.root.join('public/assets/images', r.project.uuid.downcase.parameterize(\"_\"), r.file_path)\n #debugger\n FileUtils.mkdir_p(Rails.root.join('public/assets/images', r.project.uuid.downcase.parameterize(\"_\")))\n FileUtils.mv(source, dest, :force => true) if File.exist?(source)\n r.file_path = File.basename(r.file_path)\n r.save!\n end\n\n end\n end\n \nend",
"def remove_solution_files\n remove_folder_files(SOLUTION_PATH)\n end",
"def cleanup\n winrm.run_cmd( \"del #{base64_file_name} /F /Q\" )\n winrm.run_cmd( \"del #{command_file_name} /F /Q\" )\n end",
"def clean_up\n @files.each {|file| FileUtils.remove(file.path)}\n end",
"def reset_signup_folder\n FileUtils.rm_rf('./tmp/signup')\nend",
"def clean_up_packages!(path, user = 'user')\n send(\"execute_as_#{user}\", \"cd #{path}; rm -rf gitpusshuten-packages\")\n end",
"def delete_tmp_dir(new_file)\n # versions hash is inicialized after storing all versions. We want to delete folder after all versions are restored\n # make sure we don't delete other things accidentally by checking the name pattern\n if versions.length > 0 && @cache_id_was.present? && @cache_id_was =~ /\\A[\\d]{8}\\-[\\d]{4}\\-[\\d]+\\-[\\d]{4}\\z/\n FileUtils.rm_rf(File.join(Rails.root.to_s,Refinery::PhotoGallery.photo_gallery_dir_relative_to_root, cache_dir, @cache_id_was))\n end\n end",
"def clean_wiki_folders\n puts \"Trying to clean the wiki\"\n if File.exist?(g('wiki_dest'))\n #puts \"Removing Folder \"+g('wiki_dest')\n removeFolder(\"\") \n end\n #puts \"Creating Folder \"+g('wiki_dest')\n FileUtils.mkdir(g('wiki_dest'))\nend",
"def delete_all_projects\n FileUtils.rm_rf(Dir.glob(\"#{DIR_PROJECTS}/*\"))\nend",
"def delete_staged_archives\n archive_paths.each do |archive_path|\n command = \"sudo rm -rf #{File.join(archive_path, '*')}\"\n Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command)\n end\n end",
"def clean_dir_root\n File.join(root_dir, \"test\", \"tmp\", \"cleanreps\")\n end",
"def cleanup\n @agent_file_history.each { |af| FileUtils.rm_f(af) }\n @key_file_history.each { |kf| FileUtils.rm_f(kf) }\n end",
"def rollback_platform_files(job)\n context = build_context(job)\n scope = job[\"args\"].first\n nodes_ids = job[\"args\"].second\n project = UserFile.publication_project!(context.user, scope)\n nodes_dxids = UserFile.where(id: nodes_ids).pluck(:dxid)\n persisted_dxids =\n UserFile.where(dxid: nodes_dxids, scope: scope, project: project).pluck(:dxid)\n\n (nodes_dxids - persisted_dxids).each_slice(1000) do |dxids|\n context.api.project_remove_objects(project, dxids, force: true)\n end\n end",
"def cleanup_after(files, verbose=true)\n begin\n @smb.connect(\"\\\\\\\\#{@target}\\\\#{@smbshare}\")\n files.each do |file|\n begin\n if smb_file_exist?(file.sub('c:\\\\\\\\', '').sub('c:\\\\', '').sub('C:', '').sub('c:', '').gsub('\\\\\\\\', '\\\\'))\n smb_file_rm(file.sub('c:\\\\\\\\', '').sub('c:\\\\', '').sub('C:', '').sub('c:', '').gsub('\\\\\\\\', '\\\\'))\n end\n rescue Rex::Proto::SMB::Exceptions::ErrorCode => cleanuperror\n puts \"[\".light_red + \"*\".white + \"]\".light_red + \" Unable to cleanup #{file}. Error: #{cleanuperror}\" if verbose\n end\n end\n left = files.collect{ |f| smb_file_exist?(f.sub('C:', '')) }\n if left.any?\n puts \"[\".light_red + \"*\".white + \"]\".light_red + \" Unable to cleanup. Maybe you'll need to manually remove #{left.join(\", \")} from the target....\".white if verbose\n else\n puts \"[\".light_green + \"*\".white + \"]\".light_green + \" Cleanup was successful!\" if verbose\n end\n @smb.disconnect(\"\\\\\\\\#{@target}\\\\#{@smbshare}\")\n rescue Rex::Proto::SMB::Exceptions::ErrorCode => cleanuperror\n puts \"[\".light_red + \"*\".white + \"]\".light_red + \" Unable to cleanup. Maybe you'll need to manually remove #{left.join(\", \")} from the target....\".white if verbose\n end\nend"
] |
[
"0.61604303",
"0.609182",
"0.5838239",
"0.572081",
"0.56477356",
"0.5638157",
"0.56050116",
"0.5603893",
"0.55922616",
"0.5583106",
"0.5523004",
"0.552116",
"0.5510005",
"0.5510005",
"0.5507161",
"0.5504293",
"0.54923385",
"0.54508877",
"0.5426518",
"0.54211396",
"0.5417211",
"0.54087186",
"0.5405336",
"0.5402306",
"0.53982246",
"0.53980565",
"0.53980565",
"0.53935933",
"0.5383056",
"0.537216",
"0.5365801",
"0.5354787",
"0.5346324",
"0.53431654",
"0.5333296",
"0.53327286",
"0.53137046",
"0.5267066",
"0.52558535",
"0.5243847",
"0.522551",
"0.5220065",
"0.52174455",
"0.52167255",
"0.521375",
"0.5213001",
"0.5211864",
"0.52110326",
"0.52026576",
"0.51933086",
"0.5178913",
"0.51759917",
"0.5163139",
"0.5162667",
"0.5156651",
"0.5155601",
"0.51312894",
"0.51312894",
"0.5127785",
"0.51260227",
"0.5124111",
"0.51156306",
"0.51145625",
"0.51123846",
"0.5108344",
"0.50992584",
"0.50974613",
"0.5087567",
"0.50845563",
"0.507244",
"0.5068444",
"0.50673157",
"0.5063566",
"0.5062409",
"0.50568575",
"0.50462675",
"0.5037902",
"0.50346226",
"0.5030174",
"0.5017039",
"0.5011241",
"0.4999532",
"0.49916917",
"0.49902222",
"0.49841088",
"0.4983494",
"0.4982521",
"0.4980819",
"0.49744573",
"0.4965694",
"0.49617308",
"0.49576804",
"0.49550173",
"0.49507692",
"0.49503055",
"0.4948133",
"0.49479014",
"0.49439687",
"0.4933759",
"0.4930717"
] |
0.7290133
|
0
|
Create an erased flash.
|
def createflashimage
flashdata = "\xff" * FLASHSIZE
Flashimage.write(flashdata)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def flash_keeper\n flash.keep\n end",
"def discard_flash\n flash.discard\n end",
"def flash_destroyed_message\n flash_message_builder(:destroy, flash_status_type, 'destroyed')\n end",
"def keep_flash\n @keep_flash = true\n end",
"def scaffold_flash\n {}\n end",
"def clear_flash\n flash.clear\n end",
"def flash\n {}\n end",
"def clear_flash\n flash.discard \n end",
"def flash=(_arg0); end",
"def sweep\n @flash = @next.dup\n @next.clear\n self\n end",
"def flash\n ActionDispatch::Flash::FlashHash.new\n end",
"def flash_me_naked\n flash.clear\n render :text => \"wow!\"\n end",
"def clear_soft_messages\n \n if flash[:notice_hold]\n flash[:notice] = flash[:notice_hold]\n flash[:notice_hold] = nil\n elsif !flash[:notice_hold]\n flash[:notice] = nil \n end\n \n if flash[:error_hold]\n flash[:error] = flash[:error_hold]\n flash[:error_hold] = nil\n elsif !flash[:error_hold]\n flash[:error] = nil \n end\n \n if flash[:action_hold]\n flash[:action] = flash[:action_hold]\n flash[:action_hold] = nil\n elsif !flash[:action_hold]\n flash[:action] = nil \n end\n \n end",
"def render_flash\n return if state.flash_at.elapsed_time > 10 # return if more than 10 frames have passed since flash.\n # Transparency gradually changes (or eases) during the 10 frames of flash.\n outputs.primitives << [grid.rect, 255, 255, 255, 255 * state.flash_at.ease(10, :flip)].solid\n end",
"def flash; end",
"def flash; end",
"def destroy\n @flashlight.destroy\n respond_to do |format|\n format.html { redirect_to flashlights_url }\n format.json { head :no_content }\n end\n end",
"def flash\n session[:flash] = Hashie::Mash.new if session[:flash].nil?\n session[:flash]\n end",
"def sweep # :nodoc:\n @discard.each { |k| @flashes.delete k }\n @discard.replace @flashes.keys\n end",
"def cleanup\n return unless game_path?\n\n flash.flag!\n Wars.save(session)\n end",
"def flash\n @messages.values.each {|v| v.delete_if {|m| m.options[:flash]}}\n @by_id.delete_if {|k, v| v.first.options[:flash]}\n end",
"def flash\n raise NotImplementedError\n end",
"def flash(evt = nil)\n @notice = evt[:notice] rescue ''\n @alert = evt[:alert] rescue ''\n render :text => update(\"##{dom_id}_flash\"), :layout => 'flash_effect.js.erb',\n :locals => {:flashid => \"#{dom_id}_flash\"}\n end",
"def store_flash(res)\n serialized_flash = @later.to_json\n res.cookies << WEBrick::Cookie.new(\"_rails_lite_flash\" , serialized_flash)\n end",
"def check_flash\n @flash = session[:flash] if session[:flash]\n session[:flash] = nil\n end",
"def flash(type, header, message)\n session[\"notice\"] ||= []\n session[\"notice\"] << {\n :type => type,\n :header => header,\n :message => message\n }\nend",
"def flash\n execute_only(:flash)\n end",
"def hide_flash\n update_page do |page|\n page[:flash].hide\n end\n end",
"def clear\n # FIXME we're just before a release and I can't find a proper way to reproduce\n # this bug that I've found via a browser.\n #\n # It may happen that `#flash` is nil, and those two methods will fail\n unless flash.nil?\n expire_stale!\n remove!\n end\n end",
"def show_flash(key)\n if session[key]\n flash = session[key]\n session[key] = false\n flash\n end\n end",
"def flash\n @flash ||= Flash.new(req)\n end",
"def clear_all_flash\n flash[:notice] = flash[:alert] = flash[:error] = nil\n end",
"def rjs_flash(page)\n page.replace \"flash\", :partial => \"common/flash\", :locals => {:flash => flash}\n flash.discard\n end",
"def show_flash\n html = ''\n [ :alert, :notice, :info, :warning, :error ].each do |f|\n options = { :id => \"flash-#{f}\", :class => \"flash-#{f}\" }\n options.merge!( :style => 'display:none' ) if flash[f].nil?\n html << content_tag( 'div', options ) { flash[f] || '' }\n end\n html.html_safe\n end",
"def show_flash\n html = ''\n [ :alert, :notice, :info, :warning, :error ].each do |f|\n options = { :id => \"flash-#{f}\", :class => \"flash-#{f}\" }\n options.merge!( :style => 'display:none' ) if flash[f].nil?\n html << content_tag( 'div', options ) { flash[f] || '' }\n end\n html.html_safe\n end",
"def store_flash(res)\n cookie = WEBrick::Cookie.new('_rails_lite_app_flash', flash.to_json)\n cookie.path = '/'\n res.cookies << cookie\n end",
"def store_flash(res)\n cookie = @flash.to_json\n res.set_cookie('_rails_lite_app_flash', cookie)\n end",
"def show_flash(key)\n\tif session[key]\n\t flash = session[key]\n\t session[key] = false\n\t flash\n\tend\n end",
"def store_flash(res)\n chips_ahoy = WEBrick::Cookie.new('_rails_lite_flash', @slow_poke.to_json)\n res.cookies << chips_ahoy\n end",
"def destroy\n @flash_card = FlashCard.find(params[:id])\n @flash_card.destroy\n\n respond_to do |format|\n format.html { redirect_to(flash_cards_url) }\n format.json { render :json => [] }\n format.xml { head :ok }\n end\n end",
"def flasher\n\t\ts = ''\n\t\tflash.each do |key, msg|\n\t\t\tunless msg.blank?\n\t\t\t\ts << content_tag( :p, msg.html_safe, :class => \"flash #{key}\" )\n#\t\t\t\ts << content_tag( :p, msg.html_safe, :id => key, :class => 'flash' )\n\t\t\t\ts << \"\\n\"\n\t\t\tend\n\t\tend\n\t\ts << \"<noscript><p id='noscript' class='flash'>\\n\"\n\t\ts << \"Javascript is required for this site to be fully functional.\\n\"\n\t\ts << \"</p></noscript>\\n\"\n\t\ts.html_safe\n\tend",
"def reset_flash_message\n [:blue_notice, :lightgrey_notice, :success, :danger, :warning, :info,\n :light, :dark].each do |x|\n flash[x] = nil\n end\n end",
"def flash_created_message\n flash_message_builder(:create, flash_status_type, 'created')\n end",
"def destroy\n @flashcard = Flashcard.find(params[:id])\n @flashcard.destroy\n\n respond_to do |format|\n format.html { redirect_to flashcards_url }\n format.json { head :ok }\n end\n end",
"def store_flash(res)\n res.cookies << WEBrick::Cookie.new('_rails_lite_app_flash', @persist.to_json)\n end",
"def destroy\n @flaw.destroy\n respond_to do |format|\n format.html { redirect_to flaws_url, notice: 'Flaw was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def hubssolib_standard_flash_tag(key)\n value = flash[key] if defined?(flash)\n\n if (value)\n flash.delete(key)\n return \"<h2 align=\\\"left\\\" class=\\\"#{key}\\\">#{value}</h2><p />\"\n else\n return ''\n end\n end",
"def destroy\n @swf = Swf.find(params[:id])\n @swf.destroy\n\n respond_to do |format|\n format.html { redirect_to(swfs_url) }\n format.xml { head :ok }\n end\n end",
"def store_flash(res)\n res.cookies << WEBrick::Cookie.new('_rails_lite_app_flash', @flash_hash.to_json)\n end",
"def flash text, type = 'success', title = false\n session[:flashes] = [] unless session[:flashes]\n session[:flashes] << {\n type: type,\n text: text,\n title: title\n }\n end",
"def insert_flash(page, position, element, type, options = {}, delay = \"5\")\n page.insert_html(position, element, render_flash(type, options))\n page.delay(delay) do\n page.remove(\"flash_#{type.to_s}#{\"_#{options[:id]}\" unless options[:id].blank?}\")\n end\n end",
"def destroy\n puts(\"Tacos are indestructible\")\n end",
"def build_flash\n result = \"\"\n flash.each do |type, message|\n type = case type\n when :alert then :error\n when :notice then :success\n else :error\n end\n result << \"<div class='alert alert-#{type} fade in out' id='flash'><a href='#' class='close' data-dismiss='alert'>x</a>#{message}</div>\"\n end\n\n return result\n end",
"def show_flash(key)\n\t\tif session[key]\n\t\t\tflash = session[key]\n\t\t\tsession[key] = false\n\t\t\tflash\n\t\tend\n\tend",
"def set_flash(action)\n set_normal_flash(action)\n set_flash_now(action)\n end",
"def store_flash(res)\n res.set_cookie(\"_rails_lite_app_flash\", {\n path: \"/\",\n value: @flash.to_json\n })\n end",
"def store_flash(res)\n res.set_cookie('_rails_lite_app_flash', {path: '/', value: @new_cookie.to_json})\n end",
"def store_flash(res)\n cookie = WEBrick::Cookie.new(\"_rails_lite_flash\", @stuff.to_json)\n cookie.path = \"/\"\n res.cookies << cookie\n end",
"def flash_notice\n if flash[:notice]\n message = flash[:notice]\n flash.clear\n flash[:success] = message\n end\n end",
"def is_flashing_format?\n false\n end",
"def is_flashing_format?; end",
"def is_flashing_format?; end",
"def create\n \n @flashcard = Flashcard.new(params[:flashcard])\n @deck = Deck.find(params[:deck_id]) \n @flashcard.deck = @deck\n respond_to do |format|\n if @flashcard.save\n format.html { redirect_to @flashcard, notice: 'Flashcard was successfully created.' }\n format.json { render json: @flashcard, status: :created, location: @flashcard }\n else\n format.html { render action: \"new\" }\n format.json { render json: @flashcard.errors, status: :unprocessable_entity }\n end\n end\n end",
"def flash\n (JSON.parse(Base64.decode64(page.response_headers['Test-Bot-Flash'])) rescue {})\n end",
"def flash_notice(options = Hash.new)\n return \"\"\n end",
"def new\n @flashcard = Flashcard.new\n end",
"def expire_stale!\n flash.each do |request_id, _|\n flash.delete(request_id) if @request_id != request_id\n end\n end",
"def flash(color, duration)\n\n end",
"def flash\n\t\t{:notice => \"Hello There\"}\n\tend",
"def set_normal_flash(action)\n if f = options_for(action).flash\n flash[:notice] = f.is_a?(Proc) ? instance_eval(&f) : options_for(action).flash\n end\n end",
"def set_flash_failure(msg)\n session[:flash] = [false, msg]\n end",
"def instant_flash\n render partial: 'shared/flash_messages'\n end",
"def create\n @swf = Swf.new(params[:swf])\n\n respond_to do |format|\n if @swf.save\n format.html { redirect_to(@swf, :notice => 'Swf was successfully created.') }\n format.xml { render :xml => @swf, :status => :created, :location => @swf }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @swf.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def start_flash(color, duration)\n @flash_color = color.clone\n @flash_duration = duration\n end",
"def header_flash\n if [\"text/javascript\", \"application/javascript\", \"application/x-javascript\"].include? response.content_type\n response.headers[\"flash-messages\"] = flash.to_json\n flash.each do |key, value|\n flash.delete key\n end\n end\n end",
"def rails_flash\n scope.env[ActionDispatch::Flash::KEY] ||= ActionDispatch::Flash::FlashHash.from_session_value(session[\"flash\"])\n end",
"def map_flash_to_gon\n generate_standard_gon\n if flash[:notice]\n gon.flash[:type] = :notice\n gon.flash[:message] = flash[:notice]\n elsif flash[:alert]\n gon.flash[:type] = :alert\n gon.flash[:message] = flash[:alert]\n end\n end",
"def create\n @flash_card = FlashCard.new(params[:flash_card])\n\n respond_to do |format|\n if @flash_card.save\n format.html { redirect_to(@flash_card, :notice => 'Flash card was successfully created.') }\n format.json { render :json => @flash_card, :status => :created, :location => @flash_card }\n format.xml { render :xml => @flash_card, :status => :created, :location => @flash_card }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @flash_card.errors, :status => :unprocessable_entity }\n format.xml { render :xml => @flash_card.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def hide_flash(key)\n discard_header = response.headers['X-Message-Discard']\n if discard_header.nil?\n response.headers['X-Message-Discard'] = key.to_s\n else\n response.headers['X-Message-Discard'] = \"#{key};#{discard_header}\"\n end\n end",
"def destroy\n fail ESP::NotImplementedError\n end",
"def destroy\n fail ESP::NotImplementedError\n end",
"def destroy\n fail ESP::NotImplementedError\n end",
"def destroy\n fail ESP::NotImplementedError\n end",
"def destroy\n fail ESP::NotImplementedError\n end",
"def destroy\n fail ESP::NotImplementedError\n end",
"def destroy\n fail ESP::NotImplementedError\n end",
"def destroy\n fail ESP::NotImplementedError\n end",
"def flash_messages\n return unless messages = flash.keys.select{|k| flash_keys.include?(k)}\n formatted_messages = messages.map do |type|\n content_tag :div, :id => type, :class => type.to_s do\n msg = flash[type]\n flash.delete(type)\n image_tag(\"#{type}.png\") + \"  \" + msg\n end\n end\n '<div id=\"flashes\">' + formatted_messages.join + '</div>'\n end",
"def destroy\r\n sprint_id = @sprint.id\r\n @sprint.destroy\r\n render :update do |p|\r\n p[\"sprint_frame_cont_#{sprint_id}\"].visual_effect :blind_up, :duration => 1\r\n end\r\n end",
"def destroy\r\n sprint_id = @sprint.id\r\n @sprint.destroy\r\n render :update do |p|\r\n p[\"sprint_frame_cont_#{sprint_id}\"].visual_effect :blind_up, :duration => 1\r\n end\r\n end",
"def start_flash(color, duration)\n @flash_color = color.clone\n @flash_duration = duration\n end",
"def now\n @flash\n end",
"def test_flash_me_naked\n process :flash_me_naked\n assert !@response.has_flash?\n assert !@response.has_flash_with_contents?\n end",
"def replace_flash(page, flash_type, options = {})\n flash_id = \"flash_#{flash_type}\"\n if page.select(\"#\"+flash_id).count > 0\n page.replace id, :partial => \"layouts/flash\"\n end\n end",
"def flash(color, duration); end",
"def render_flash(type, options = {})\n defaults = { :id => \"\", :class => \"\", :style => \"\" }\n options = defaults.merge(options)\n unless flash[type].nil?\n %Q(<h3 id=\"flash_#{type}#{\"_#{options[:id]}\" unless options[:id].empty?}\" \n class=\"flash_#{type}#{\" #{options[:class]}\" unless options[:class].empty?}\" \n style=\"#{options[:style]}\">#{flash[type]}</h3>)\n else\n \"\"\n end\n end",
"def cleanup\n @log.debug \"Deleting #{@out_file}.flv\"\n if File.exists?(\"#{@out_file}.flv\")\n File.delete(\"#{@out_file}.flv\")\n end\n end",
"def check_for_removal\n if @value && @unused && @unused[\"unused\"]\n @res.cookies << create_cookie(\"unused\", false, 'flash_unused')\n elsif @value\n @value = nil\n @res.cookies << create_cookie(\"unused\", nil, 'flash_unused')\n @res.cookies << create_cookie(\"message\", nil)\n end\n end",
"def destroy\n @flash_card_set ||= FlashCardSet.find params[:id]\n\n if @flash_card_set.destroy\n head 204\n else\n render json: { resource: \"flashCardSet\", errors: errors_hash_for(FlashCardSet, \"could not be destroyed\") }, status: 500\n end\n end",
"def flash\n Current.session.flash\n end"
] |
[
"0.63379157",
"0.6034925",
"0.6015594",
"0.5983541",
"0.5918129",
"0.59143656",
"0.58458066",
"0.57976186",
"0.5707702",
"0.56664616",
"0.56011134",
"0.5503426",
"0.54939735",
"0.54881525",
"0.544252",
"0.544252",
"0.5435931",
"0.5394532",
"0.5394523",
"0.5362896",
"0.53485554",
"0.5324639",
"0.5319151",
"0.5305372",
"0.5268742",
"0.52622914",
"0.52579886",
"0.5256282",
"0.5221732",
"0.52171516",
"0.52122813",
"0.5209788",
"0.5194942",
"0.5182383",
"0.5182383",
"0.51759475",
"0.5172317",
"0.5165178",
"0.51610374",
"0.5153176",
"0.5147096",
"0.5111828",
"0.5102553",
"0.5098045",
"0.5094754",
"0.5086871",
"0.5083118",
"0.5054881",
"0.50275064",
"0.50210243",
"0.5017965",
"0.5012708",
"0.50095963",
"0.5004567",
"0.50023425",
"0.49991098",
"0.49981123",
"0.49949706",
"0.49723193",
"0.49698174",
"0.49652416",
"0.49652416",
"0.4960365",
"0.4948184",
"0.49439815",
"0.49376604",
"0.49220935",
"0.4916619",
"0.49133053",
"0.4912669",
"0.49074656",
"0.49060825",
"0.49035758",
"0.48967287",
"0.48921046",
"0.48867163",
"0.48805788",
"0.4879817",
"0.48543307",
"0.48436844",
"0.48436844",
"0.48436844",
"0.48436844",
"0.48436844",
"0.48436844",
"0.48436844",
"0.48436844",
"0.48405537",
"0.48380306",
"0.48380306",
"0.48255342",
"0.48254707",
"0.48210344",
"0.4817905",
"0.48078075",
"0.48020422",
"0.47982585",
"0.47969496",
"0.47918612",
"0.47912315"
] |
0.62776345
|
1
|
Split flash image in partitions.
|
def splitflashimage
flashdata = Flashimage.read
size = flashdata.size
puts("Flash image size: #{size / MiB} MiB = #{size} B.")
raise('Flash size is unexpected.') if (size != FLASHSIZE)
baseaddress = PARTITIONS['boot'][START]
PARTITIONS.each { |label, partition|
first = partition[START] - baseaddress
last = first + partition[SIZE]
filename = "#{File.dirname(FLASHIMAGE)}/#{partition[FILE]}"
Flashimage.write(flashdata[first ... last], filename)
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def mergepartitions\n\tflashdata = \"\\xff\" * FLASHSIZE\n\tbaseaddress = PARTITIONS['boot'][START]\n\tPARTITIONS.each { |label, partition|\n\t\tfirst = partition[START] - baseaddress\n\t\tlast = first + partition[SIZE]\n\t\tfilename = \"#{File.dirname(FLASHIMAGE)}/#{partition[FILE]}\"\n\t\tpartdata = Flashimage.read(filename)\n\t\tsize = partdata.size\n\t\tputs(\"Partition size: #{size / KiB} KiB = #{size} B (#{label}).\")\n\t\traise('Partition size is unexpected.') if (size != partition[SIZE])\n\t\tflashdata[first ... last] = partdata\n\t}\n\tFlashimage.write(flashdata)\nend",
"def changepartition(partition, filename)\n\tbaseaddress = PARTITIONS['boot'][START]\t\n\tsize = partition[SIZE]\n\tpartdata = Flashimage.read(filename)\n\tlength = partdata.size\n\tlast = partition[SIZE]\n\traise('Input file too large.') if length + 12 > last\n\tcrc32 = Zlib.crc32(partdata)\n\tpartdata[length ... last - 12] = \"\\xff\" * (last - length - 12)\n\tpartdata[last - 12 ... last] = [length, 0x12345678, crc32].pack('V3')\n\tfilename = \"#{File.dirname(FLASHIMAGE)}/#{partition[FILE]}\"\n\tFlashimage.write(partdata, filename)\nend",
"def split_tile_set_into_tiles\n number_of_tiles = @tile_set[0].columns/32\n\n number_of_tiles.times do |i|\n image = @tile_set[0].crop((i*32), 0, 32, 32)\n image.write(\"media/tmp/tile#{i}.png\")\n end\n end",
"def loadpart(partname, filename)\n\tflashimage = Flashimage.new\n\tfirmware = Flashimage.read(filename)\n\tsize = firmware.size\n\toffset_signature = size - 10\n\tsignature = firmware[offset_signature .. -1]\n\tputs(\"signature: #{signature.inspect}\")\n\tlength, magic, crc32, offset = getblock(partname, firmware, offset_signature)\n\tpartition = Partition.new(partname)\n\tpartition.update(firmware[offset ... offset + length])\n\tflashimage.update(partition)\n\tflashimage.write\nend",
"def subdivide\n smallerFaces = Array.new\n\n @faces.each { |t| smallerFaces.concat t.subdivide }\n\n @faces = smallerFaces\n end",
"def split_into_parts(*sizes); end",
"def index\n @image_to_parts = ImageToPart.all\n end",
"def split_partitions\n partition_names = @list.map { |bin| bin.partition_names }.flatten\n partition_names.select { |name| partition_names.index(name) != partition_names.rindex(name) }.uniq\n end",
"def splitProgramme()\n @media_operation = :split\n end",
"def create_partitions\n info(\"Creating disk with #{PARTITION_TABLE_TYPE} parition table\")\n execute!(\"parted -s #{@dev} mklabel #{PARTITION_TABLE_TYPE}\")\n\n start_size = FIRST_PARTITION_OFFSET\n end_size = FIRST_PARTITION_OFFSET\n\n unspec_part = nil\n\n # Create the partitions\n @partition_layout.each_with_index do |part, index|\n # Deal with any \"open ended\" partitions last\n if not part.size_mb.is_a?(Integer)\n unspec_part = part\n next\n end\n\n start_size = end_size\n end_size += part.size_mb\n\n info(\"Creating partition #{part.label} (#{part.fs}, #{part.size_mb}MiB)\")\n execute!(\"parted #{@dev} mkpart #{part.label} #{part.fs} #{start_size}MiB #{end_size}MiB\")\n\n (part.flags || {}).each_pair { |k, v|\n info(\"Setting partition flag #{k} to #{v}\")\n execute!(\"parted #{@dev} set #{index + 1} #{k} #{v}\")\n }\n\n label_path = \"/dev/disk/by-partlabel/#{part.label}\"\n self.wait_for_device(label_path)\n\n if not part.fs\n warn(\"No filesystem specified for #{part.label}. Skipping FS\")\n else\n create_filesystem(part.fs, label_path, part.label)\n end\n\n if part.lvm\n notice(\"Setting up LVM on #{part.label}\")\n setup_lvm_on_partition(part)\n end\n end\n\n # Deal with any \"open ended\" partitions (that have an unspecified size_mb)\n if unspec_part\n part = unspec_part\n info(\"Creating partition #{part.label} (#{part.fs}, 100% remaining)\")\n execute!(\"parted #{@dev} mkpart #{part.label} #{part.fs} #{end_size}MiB 100%\")\n\n (part.flags || {}).each_pair { |k, v|\n info(\"Setting partition flag #{k} to #{v}\")\n execute!(\"parted #{@dev} set #{@partition_layout.length} #{k} #{v}\")\n }\n\n label_path = \"/dev/disk/by-partlabel/#{part.label}\"\n self.wait_for_device(label_path)\n create_filesystem(part.fs, label_path, part.label) if part.fs\n\n if part.lvm\n notice(\"Setting up LVM on #{part.label}\")\n setup_lvm_on_partition(part)\n end\n end\n\n nil\n end",
"def partition(data)\n result = []\n i = 0\n while i < data.count\n block_partitions = data[i].split('|')\n result[i] = Block.new(\n block_partitions[0].to_i,\n block_partitions[1],\n block_partitions[2],\n block_partitions[3],\n block_partitions[4]\n )\n i += 1\n end\n result\n end",
"def partition_list()\nend",
"def partitions( partition_count, &proc )\n Enumerable.partition_sizes( self.size, partition_count ) do |partition|\n partitioned_collection = []\n consumed_so_far = 0\n partition.each do |partition_size|\n partitioned_collection << self[ consumed_so_far, partition_size ]\n consumed_so_far += partition_size\n end\n yield partitioned_collection\n end\n end",
"def partition_device\n Souffle::Log.info \"#{@node.log_prefix} Partitioning the device...\"\n provider.partition(@node)\n end",
"def split(name, options = nil, format = nil, width = nil, height = nil, from = nil, to = nil, dest_folder = nil, password = nil, folder = nil, storage = nil, fonts_folder = nil)\n data, _status_code, _headers = split_with_http_info(name, options, format, width, height, from, to, dest_folder, password, folder, storage, fonts_folder)\n data\n end",
"def bootloader_partitions\n raise RuntimeError, \"Not implemented in base class\"\n end",
"def create_partition(size = nil, type = Partition.PartitionType[:TYPE_PRIMARY])\n DiskUtils.create_partition self, size[:start_block], size[:end_block]\n partitions = Device.find(self).partitions\n return partitions.last\n end",
"def list_swap_partitions_with_type_and_size # nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\" && $6==\"82\") print $1\":\"$5\":\"$6;else {if ($5==\"82\") print $1\":\"$4\":\"$5}}' | sed s/+//g`.chomp.split\nend",
"def split!\n return unless model.chunk_size.is_a?(Integer)\n\n if File.size(model.file) > bytes_representation_of(model.chunk_size)\n Logger.message \"#{ self.class } started splitting the packaged archive in to chunks of #{ model.chunk_size } megabytes.\"\n run(\"#{ utility(:split) } -b #{ model.chunk_size }m '#{ model.file }' '#{ model.file + SUFFIX_SEPARATOR }'\")\n Backup::Model.chunk_suffixes = chunk_suffixes\n end\n end",
"def partitions\n [6, 3, 0].map { |n| model.id / 10**n % 1000 }\n end",
"def create_partition device, partition_type = 'primary', start_unit, end_unit\n command = 'parted'\n params = \"#{device.path} -s -a optimal unit MB mkpart #{partition_type} ext3 #{start_unit} -- #{end_unit}\"\n parted = CommandsExecutor.new command, params\n parted.execute\n raise \"Command execution error: #{parted.stderr.read}\" if not parted.success?\n probe_kernal device\n end",
"def list_partitions #by nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{print $1}'`.chomp.split\nend",
"def get_1st_partition(device)\n # Resolves the real device name (ex. /dev/sdg)\n Chef::Log.info(\"Getting 1st partition for device: #{device}\")\n fs_check = Mixlib::ShellOut.new(\"lsblk -ln -o Name #{device}|awk 'NR==2'\")\n fs_check.run_command\n partition = \"/dev/\" + fs_check.stdout.strip\n Chef::Log.info(\"1st partition for device: #{device} is: #{partition}\")\n partition\nend",
"def make_partition_list(withall, flavor)\n part_list = []\n Builtins.foreach(RootPart.rootPartitions) do |partition, i|\n # see https://bugzilla.novell.com/attachment.cgi?id=96783&action=view\n\n # see bugzilla #288201\n # architecture needs to be valid when updating, not booting\n arch_is_valid = flavor == :boot ?\n true :\n Ops.get_boolean(i, :arch_valid, false)\n if withall || Ops.get_boolean(i, :valid, false) && arch_is_valid\n # `ext2, `jfs, ...\n part_fs = Ops.get_symbol(i, :fs)\n part_fs_name = Builtins.tostring(part_fs)\n if part_fs_name != nil &&\n Builtins.regexpmatch(part_fs_name, \"^`(.*)$\")\n part_fs_name = Builtins.regexpsub(part_fs_name, \"^`(.*)$\", \"\\\\1\")\n end\n\n system = Ops.get_string(i, :name, \"error\")\n # unknown system\n if system == \"unknown\"\n if part_fs != nil\n if CanBeLinuxRootFS(part_fs)\n # Table item (unknown system)\n system = _(\"Unknown Linux\")\n else\n # Table item (unknown system)\n system = _(\"Unknown or Non-Linux\")\n end\n else\n # Table item (unknown system [neither openSUSE 11.1 nor SLES 14 nor ...])\n system = _(\"Unknown\") if system == \"unknown\"\n end\n end\n\n arch = Ops.get_string(i, :arch, \"error\")\n # Table item (unknown architecture)\n arch = _(\"Unknown\") if arch == \"unknown\"\n\n # fist, use the name of file system (with short name for Linux)\n # then the file system short name\n # then \"Unknown\"\n fs = \"\"\n\n # is a linux fs, can be a root fs, has a fs name\n if part_fs != nil && Ops.get(i, :fstype) != nil &&\n CanBeLinuxRootFS(part_fs) &&\n part_fs_name != nil\n fs = Builtins.sformat(\n _(\"%1 (%2)\"),\n Ops.get_string(i, :fstype, \"\"),\n part_fs_name\n )\n else\n fs = Ops.get_string(i, :fstype, Ops.get_string(i, :fs, \"\"))\n end\n # Table item (unknown file system)\n fs = _(\"Unknown\") if fs == \"\"\n\n label = Ops.get_string(i, :label, \"\")\n\n part_list = Builtins.add(\n part_list,\n Item(Id(partition), system, partition, arch, fs, label)\n )\n end\n end\n deep_copy(part_list)\n end",
"def split_on(parts)\n\n raise ArgumentError.new(\"Parts should be Integer greater than 0.\") unless parts.is_a? Integer and parts > 0\n raise ArgumentError.new(\"Subnet has #{size} elements only.\") if parts > size\n\n if size % parts == 0\n part_size = size / parts\n else\n part_size = size / (parts - 1)\n if size % part_size == 0 and part_size > 1\n part_size -= 1\n end\n end\n\n subnets = []\n iter = first\n\n parts.times do |i|\n iter_next = iter + (part_size - 1)\n\n # last part should be smaller\n iter_next = last if iter_next > last or i + 1 == parts\n\n subnets << Subnet.new(iter, iter_next)\n iter = iter_next + 1\n end\n\n subnets\n end",
"def go\n\nlines = 3 # cut it at line 3\n\nbasename = 'file_to_split.txt'\nextname = \"part\"\n\npart = 1\nline = 0\n\nfline = 0\nfor i in ifp = open(basename)\n fline = fline + 1\nend\nifp.close\n\nparts = fline / lines + 1\n\nfor i in ifp = open(basename)\n if line == 0\n ofp = open(sprintf(\"%s.%s%02d\", basename, extname, part), \"w\")\n printf(ofp, \"%s part%02d/%02d\\n\", basename, part, parts)\n ofp.write(\"BEGIN--cut here--cut here\\n\")\n end\n ofp.write(i)\n line = line + 1\n if line >= lines and !ifp.eof?\n ofp.write(\"END--cut here--cut here\\n\")\n ofp.close\n part = part + 1\n line = 0\n end\nend\nofp.write(\"END--cut here--cut here\\n\")\nofp.close\n\nifp.close\n\nend",
"def test_0260_partition\n @@log.debug \"test_0260_partition starts\" if @@log.debug?\n assert_respond_to(@list, :partition, \"test_0260_partition_respond\")\n # Basic partition\n ta = @list.partition {|obj| obj.ndata >= 3 }\n assert_equal(2, ta.size,\"test_0260_partition_basic_01\")\n # First array: block evaluated to true\n assert_equal([@aen, @bsb], ta[0], \"test_0260_partition_basic_02\")\n # Second array: block evaluated to false\n assert_equal([@cab, @dad], ta[1], \"test_0260_partition_basic_03\")\n # Check Enumerator or Enumerable::Enumerator return, no block given\n # This form not documented by the 1.8 Pickaxe.\n new_list = @list.partition\nif RUBY_VERSION >= \"1.9\"\n result = new_list.is_a? Enumerator\n assert(result, \"test_0260_partition_enumcheck\")\nelse\n # Note: the author's version of the 1.8 Pickaxe documents this\n # as an Array, however does not document this form of code at all.\n # YMMV.\n result = new_list.is_a? Enumerable::Enumerator\n assert(result, \"test_0260_partition_enumenumcheck\")\nend\n\n @@log.debug \"test_0260_partition ends\" if @@log.debug?\n end",
"def get_partition_info\n # remove leading slash so it matches the packages.DU path\n remove_slash = true\n\n if !Stage.initial\n # read /proc/mounts as a list of maps\n # $[\"file\":\"/boot\", \"freq\":0, \"mntops\":\"rw\", \"passno\":0, \"spec\":\"/dev/sda1\", \"vfstype\":\"ext2\"]\n mounts = Convert.convert(\n SCR.Read(path(\".proc.mounts\")),\n :from => \"any\",\n :to => \"list <map <string, any>>\"\n )\n Builtins.y2milestone(\"mounts %1\", mounts)\n\n partitions = []\n Builtins.foreach(mounts) do |mpoint|\n name = Ops.get_string(mpoint, \"file\", \"\")\n if Builtins.substring(name, 0, 1) == \"/\" &&\n Builtins.substring(name, 0, 5) != \"/dev/\" && # filter out /dev/pts etc.\n Ops.get_string(mpoint, \"vfstype\", \"\") != \"rootfs\" # filter out duplicate \"/\" entry\n capacity = Pkg.TargetCapacity(name)\n if capacity != 0 # dont look at pseudo-devices (proc, shmfs, ...)\n used = Pkg.TargetUsed(name)\n partitions = Builtins.add(\n partitions,\n {\n \"name\" => name,\n \"free\" => Ops.subtract(capacity, used),\n \"used\" => used\n }\n )\n end\n end\n end\n Pkg.TargetInitDU(partitions)\n Builtins.y2milestone(\"get_partition_info: %1\", partitions)\n return deep_copy(partitions)\n end # !Stage::initial ()\n\n # remove the previous failures\n @failed_mounts = []\n\n # installation stage - Storage:: is definitely present\n # call Storage::GetTargetMap()\n targets = Convert.convert(\n WFM.call(\"wrapper_storage\", [\"GetTargetMap\"]),\n :from => \"any\",\n :to => \"map <string, map>\"\n )\n\n if targets == nil\n Builtins.y2error(\"Target map is nil, Storage:: is probably missing\")\n end\n\n if Mode.test\n targets = Convert.convert(\n SCR.Read(path(\".target.yast2\"), \"test_target_map.ycp\"),\n :from => \"any\",\n :to => \"map <string, map>\"\n )\n end\n\n target_partitions = []\n min_spare = 20 * 1024 * 1024 # minimum free space ( 20 MB )\n\n Builtins.foreach(targets) do |disk, diskinfo|\n part_info = Ops.get_list(diskinfo, \"partitions\", [])\n Builtins.foreach(part_info) do |part|\n Builtins.y2milestone(\"Adding partition: %1\", part)\n used_fs = Ops.get_symbol(part, \"used_fs\", :unknown)\n # ignore VFAT and NTFS partitions (bnc#)\n if used_fs == :vfat || used_fs == :ntfs\n Builtins.y2warning(\n \"Ignoring partition %1 with %2 filesystem\",\n Ops.get_string(part, \"device\", \"\"),\n used_fs\n )\n else\n free_size = 0\n\n if Ops.get(part, \"mount\") != nil &&\n Builtins.substring(Ops.get_string(part, \"mount\", \"\"), 0, 1) == \"/\"\n if Ops.get(part, \"create\") == true ||\n Ops.get(part, \"delete\") == false ||\n Ops.get(part, \"create\") == nil &&\n Ops.get(part, \"delete\") == nil\n Builtins.y2debug(\n \"get_partition_info: adding partition: %1\",\n part\n )\n\n # get free_size on partition in kBytes\n free_size = Ops.multiply(\n Ops.get_integer(part, \"size_k\", 0),\n 1024\n )\n free_size = Ops.subtract(free_size, min_spare)\n\n # free_size smaller than min_spare, fix negative value\n if Ops.less_than(free_size, 0)\n Builtins.y2milestone(\"Fixing free size: %1 to 0\", free_size)\n free_size = 0\n end\n\n used = 0\n if !(Ops.get_boolean(part, \"create\", false) ||\n Ops.get_boolean(part, \"format\", false))\n tmpdir = Convert.to_string(SCR.Read(path(\".target.tmpdir\")))\n tmpdir = Ops.add(tmpdir, \"/diskspace_mount\")\n SCR.Execute(\n path(\".target.bash\"),\n Builtins.sformat(\"test -d %1 || mkdir -p %1\", tmpdir)\n )\n\n # mount in read-only mode (safer)\n mount_options = [\"ro\"]\n\n # add \"nolock\" if it's a NFS share (bnc#433893)\n if used_fs == :nfs\n Builtins.y2milestone(\"Mounting NFS with 'nolock' option\")\n mount_options = Builtins.add(mount_options, \"nolock\")\n end\n\n # join the options\n mount_options_str = Builtins.mergestring(mount_options, \",\")\n\n mount_command = Builtins.sformat(\n \"/bin/mount -o %1 %2 %3\",\n mount_options_str,\n Ops.get_string(part, \"device\", \"\"),\n tmpdir\n )\n\n Builtins.y2milestone(\n \"Executing mount command: %1\",\n mount_command\n )\n\n result = Convert.to_integer(\n SCR.Execute(path(\".target.bash\"), mount_command)\n )\n Builtins.y2milestone(\"Mount result: %1\", result)\n\n if result == 0\n partition = Convert.convert(\n SCR.Read(path(\".run.df\")),\n :from => \"any\",\n :to => \"list <map <string, string>>\"\n )\n Builtins.foreach(partition) do |p|\n if Ops.get_string(p, \"name\", \"\") == tmpdir\n Builtins.y2internal(\"P: %1\", p)\n free_size = Ops.multiply(\n Builtins.tointeger(Ops.get_string(p, \"free\", \"0\")),\n 1024\n )\n used = Ops.multiply(\n Builtins.tointeger(Ops.get_string(p, \"used\", \"0\")),\n 1024\n )\n end\n end\n SCR.Execute(\n path(\".target.bash\"),\n Builtins.sformat(\"/bin/umount %1\", tmpdir)\n )\n else\n Builtins.y2error(\n \"Mount failed, ignoring partition %1\",\n Ops.get_string(part, \"device\", \"\")\n )\n @failed_mounts = Builtins.add(@failed_mounts, part)\n\n next\n end\n else\n # for formatted partitions estimate free system size\n # compute fs overhead\n used = EstimateFsOverhead(part)\n\n if Ops.greater_than(used, 0)\n Builtins.y2milestone(\n \"Partition %1: assuming fs overhead: %2kB\",\n Ops.get_string(part, \"device\", \"\"),\n Ops.divide(used, 1024)\n )\n end\n\n # journal size\n js = 0\n\n if ExtFs(used_fs)\n js = ExtJournalSize(part)\n reserved = ReservedSpace(part)\n\n if Ops.greater_than(reserved, 0)\n used = Ops.add(used, reserved)\n end\n elsif used_fs == :xfs\n js = XfsJournalSize(part)\n elsif used_fs == :reiser\n js = ReiserJournalSize(part)\n elsif used_fs == :jfs\n js = JfsJournalSize(part)\n else\n Builtins.y2warning(\n \"Unknown journal size for filesystem: %1\",\n used_fs\n )\n end\n\n if Ops.greater_than(js, 0)\n Builtins.y2milestone(\n \"Partition %1: assuming journal size: %2kB\",\n Ops.get_string(part, \"device\", \"\"),\n Ops.divide(js, 1024)\n )\n used = Ops.add(used, js)\n end\n\n # decrease free size\n free_size = Ops.subtract(free_size, used)\n\n # check for underflow\n if Ops.less_than(free_size, 0)\n Builtins.y2milestone(\"Fixing free size: %1 to 0\", free_size)\n free_size = 0\n end\n end\n\n # convert into kB for TargetInitDU\n free_size = Ops.divide(free_size, 1024)\n used = Ops.divide(used, 1024)\n\n Builtins.y2milestone(\n \"available partition: mount: %1, free: %2 KB, used: %3 KB\",\n Ops.get_string(part, \"mount\", \"\"),\n free_size,\n used\n )\n if !remove_slash\n target_partitions = Builtins.add(\n target_partitions,\n {\n \"name\" => Ops.get_string(part, \"mount\", \"\"),\n \"used\" => used,\n \"free\" => free_size\n }\n )\n else\n part_name = \"\"\n mount_name = Ops.get_string(part, \"mount\", \"\")\n\n if mount_name != \"/\"\n part_name = Builtins.substring(\n mount_name,\n 1,\n Builtins.size(mount_name)\n )\n else\n part_name = mount_name\n end\n\n target_partitions = Builtins.add(\n target_partitions,\n { \"name\" => part_name, \"used\" => used, \"free\" => free_size }\n )\n end\n end\n end\n end\n end # foreach (`part)\n end # foreach (`disk)\n\n # add estimated size occupied by non-package files\n target_partitions = EstimateTargetUsage(target_partitions)\n\n Builtins.y2milestone(\"get_partition_info: part %1\", target_partitions)\n Pkg.TargetInitDU(target_partitions)\n\n deep_copy(target_partitions)\n end",
"def create\n begin\n # Set the partition (/dev/sdb1), device (/dev/sdb) and alignment (optimal,minimal,none etc.) variables\n partition= resource[:name]\n device=partition[0,(partition.length-1)]\n alignment= resource[:alignment]\n\n # Now we can create the partition\n partitions = parted('-a', resource[:alignment],'--script',device,'mklabel',resource[:part_label],'mkpart', resource[:part_type],resource[:fs_type],resource[:p_begin],resource[:p_end])\n rescue Puppet::ExecutionFailure => e\n false\n end\n end",
"def matrix_partitioner(mat)\n n = mat.size-1\n n_half = mat.size/2\n\n m11 = (0..n_half-1).map { |x| mat[x][0..n_half-1] }\n m12 = (0..n_half-1).map { |x| mat[x][n_half..n] }\n\n m21 = (n_half..n).map { |x| mat[x][0..n_half-1] }\n m22 = (n_half..n).map { |x| mat[x][n_half..n] }\n [m11, m12, m21, m22]\nend",
"def partition(&block) # :nodoc:\n resolve\n result = @items.partition(&block)\n [\n self.class.new.import(result[0]),\n self.class.new.import(result[1]),\n ]\n end",
"def list_partitions_with_size_and_type # by nelsongs. => list: partition size type\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\") print $1\":\"$5\":\"$6;else print $1\":\"$4\":\"$5}' | sed s/+//g`.split\nend",
"def SetFormatPartitions(fstabpart)\n fstabpart = deep_copy(fstabpart)\n # All storage devices\n target_map = Storage.GetTargetMap\n\n # all activated\n tmp = Builtins.filter(RootPart.GetActivated) do |e|\n Ops.get_string(e, :type, \"\") == \"mount\" ||\n Ops.get_string(e, :type, \"\") == \"swap\"\n end\n\n Builtins.foreach(tmp) do |e|\n mntpt = Ops.get_string(e, :type, \"\") == \"swap\" ?\n \"swap\" :\n Ops.get_string(e, :mntpt, \"\")\n part = Ops.get_string(e, :device, \"\")\n p = {}\n Builtins.foreach(fstabpart) do |pp|\n # mountpoint matches\n if Ops.get_string(pp, \"mount\", \"\") == mntpt\n p = deep_copy(pp)\n raise Break\n end\n end\n mount_options = \"\"\n Builtins.foreach(Storage.ReadFstab(Installation.destdir)) do |entry|\n if Ops.get_string(entry, \"file\", \"\") == mntpt\n mount_options = Ops.get_string(entry, \"mntops\", \"\")\n raise Break\n end\n end\n target_map = Storage.SetPartitionData(target_map, part, \"mount\", mntpt)\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"format\",\n Ops.get_boolean(p, \"format\", false)\n )\n target_map = Storage.SetPartitionData(target_map, part, \"delete\", false)\n target_map = Storage.SetPartitionData(target_map, part, \"create\", false)\n if Builtins.haskey(p, \"filesystem\")\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"filesystem\",\n Ops.get_symbol(p, \"filesystem\", :ext4)\n )\n end\n if Ops.greater_than(Builtins.size(mount_options), 0) &&\n !Builtins.haskey(p, \"fstopt\")\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"fstopt\",\n mount_options\n )\n end\n if Builtins.haskey(p, \"fstopt\")\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"fstopt\",\n Ops.get_string(p, \"fstopt\", \"\")\n )\n end\n if Builtins.haskey(p, \"mountby\")\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"mountby\",\n Ops.get_symbol(p, \"mountby\", :device)\n )\n end\n end\n\n Storage.SetTargetMap(target_map)\n true\n end",
"def partition\n return enum_for(:partition) if not block_given?\n a,b = super\n [self.class.new(a), self.class.new(b)].freeze\n end",
"def partition_used(partition)\n # Return magic number if in test_mode to prevent syscall\n return '128' if @test_mode\n b = ' ' * 128\n syscall(137, partition, b)\n a = b.unpack('QQQQQ')\n [a[2] * blocks_per_kilobyte, a[4] * blocks_per_kilobyte]\n end",
"def list_swap_partitions_with_size # nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\" && $6==\"82\") print $1\":\"$5;else {if ($5==\"82\") print $1\":\"$4}}' | sed s/+//g`.chomp.split\nend",
"def prepare_image_apria\n images = []\n if @sitecode == \"00Q49\" # site code for DAP\n single_page_images = convert_multipage_to_singlepage\n single_page_images.each_with_index do |image_file, index|\n new_file_name = rename_image_for_dap(image_file, index)\n File.rename(image_file, new_file_name)\n @image_folder = Dir.glob(\"#{@location}/**/#{config['IMAGE']['image_folder']}*\", File::FNM_CASEFOLD)\n image = ImagesForJob.new :image => File.open(\"#{new_file_name}\",\"rb\")\n image.image_file_name = File.basename(new_file_name)\n image.is_splitted_image = true\n image = update_image image\n images << image\n end\n else\n image = ImagesForJob.new\n parse_values(\"IMAGE\", image)\n image_path = @image_folder.detect{|image_string| image_string.downcase == \"#{@image_path}/#{image.image_file_name}\".downcase}\n image.image = File.open(image_path, \"rb\")\n image_file_name = image.image_file_name.strip.split(\"\\\\\").last unless image.image_file_name.blank?\n path = Dir.glob(\"#{@location}/**/#{image_file_name}\").first\n count = %x[identify \"#{path}\"].split(image_file_name).length-1\n new_image_name = File.basename(\"#{path}\")\n if count>1\n dir_location = File.dirname(\"#{path}\")\n ext_name = File.extname(\"#{path}\")\n new_image_base_name = new_image_name.chomp(\"#{ext_name}\")\n if ((not ext_name.empty?) and (ext_name.casecmp(\".pdf\") == 0) ) then\n system \"pdftk '#{path}' burst output '#{dir_location}/#{new_image_base_name}_%d#{ext_name}'\"\n for image_count in 1..count\n image = ImagesForJob.new(:image_file_name=>\"#{new_image_base_name}_#{image_count}#{ext_name}\",:is_splitted_image=>true)\n image = update_image image\n images << image\n end\n else\n InputBatch.split_image(count,path, dir_location, new_image_base_name)\n single_images = Dir.glob(\"#{@location}/**/*\").select{|file| InputBatch.get_single_image(file, new_image_base_name)}.sort\n single_images.each_with_index do |single_image, index|\n new_image_name = \"#{dir_location}/#{new_image_base_name}_#{index}#{ext_name}\"\n File.rename(single_image, new_image_name)\n image = ImagesForJob.create(:image => File.open(new_image_name), :image_number => @img_count, :is_splitted_image=>true)\n @img_count += 1\n images << image\n end\n end\n else\n image = ImagesForJob.new(:image_file_name=>\"#{new_image_name}\")\n image = update_image image\n images << image\n end\n end\n return images\n end",
"def create_partition_to_fill_disk(disk)\n # @disk.create_partition('primary', '100%')\n disk.create_partition_table # LinuxAdmin::Disk.create_partition has this already...\n AwesomeSpawn.run!(\"parted -s #{disk.path} mkpart primary 0% 100%\")\n\n # FIXME: Refetch the disk after creating the partition\n disk = LinuxAdmin::Disk.local.find { |d| d.path == disk.path }\n disk.partitions.first\n end",
"def set_image_to_part\n @image_to_part = ImageToPart.find(params[:id])\n end",
"def GetPartitionList\n deep_copy(@partition_info)\n end",
"def matrix_partitioner(mat)\n n = mat.size-1\n n_half = mat.size/2\n\n m11 = (0..n_half-1).map { |x| mat[x][0..n_half-1] }\n m12 = (0..n_half-1).map { |x| mat[x][n_half..n] }\n\n m21 = (n_half..n).map { |x| mat[x][0..n_half-1] }\n m22 = (n_half..n).map { |x| mat[x][n_half..n] }\n [m11, m12, m21, m22]\n end",
"def lvm_partition(dev)\n part = %x{sfdisk -l /dev/nbd0 2>/dev/null | grep 8e | cut -d ' ' -f 1}.strip\n part.empty? ? raise(\"Failed to locate LVM partition\") : part\nend",
"def split\n sw = (w / 2.0).round\n sh = (h / 2.0).round\n return Rect.new(x, y, sw, sh),\n Rect.new(x + sw, y, sw, sh),\n Rect.new(x, y + sh, sw, sh),\n Rect.new(x + sw, y + sh, sw, sh)\n end",
"def partition(arr, n)\n\nend",
"def split_array(arr, parts)\n ret = []\n arr.each_slice((arr.size / parts.to_f).ceil) { |part| ret << part } unless arr.empty?\n ret\n end",
"def partition_devices(device_list, attempt = 0, max_attempts = 3)\n return false if attempt >= max_attempts\n\n puts case attempt\n when 0 then \"Partioning devices ...\" \n else \"Retrying device partitioning (attempt #{attempt + 1}) ...\" \n end\n\n device_list.each do |device|\n puts \" * #{device}\"\n `echo 0|sfdisk #{device}`\n end\n\n puts \"Sleeping 10 seconds to reload partition tables ...\"\n sleep 10\n\n # Verify all volumes were properly partitioned\n missing_devices = []\n device_list.each do |device|\n missing_devices << device unless File.exists?(\"#{device}1\")\n end\n\n # Retry partitioning for failed volumes\n response = true\n if missing_devices.size > 0\n response = partition_devices(missing_devices, attempt + 1, max_attempts)\n end\n response\n end",
"def partition( header, &block )\n data.partition( header, &block ).map { |d| dup.load( d ) }\n end",
"def split\n # Determine the new max_id for the old page.\n max_id = @min_id + (@max_id - @min_id) / 2\n # Create a new page that stores the upper half of the ID range. Remove\n # all IDs from this page that now belong into the new page and transfer\n # them.\n new_page_record = IDListPageRecord.new(@page_file, max_id + 1, @max_id,\n page.delete(max_id))\n # Adjust the max_id of the current page.\n @max_id = max_id\n\n new_page_record\n end",
"def split_deck\n main_deck = create_deck\n # randomize\n @player1_deck, @player2_deck = main_deck.each_slice(main_deck.length / 2).to_a\n end",
"def split(how_many = self.count/2)\n Deck.new(@cards.shift(how_many))\n end",
"def prepare_strip\r\n @strip = []\r\n for i in 0...@totalFrames\r\n bitmap = Bitmap.new(@width,@height)\r\n bitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmaps[i],Rect.new(0,0,@width,@height))\r\n @strip.push(bitmap)\r\n end\r\n end",
"def split_pdfs!(list, density=300, format=:jpg)\n\n #Process each of the command-line arguments;\n #potentially transforming them into lists of split files.\n list.map! { |pdf| split_pdf(pdf, density, format) }\n\n #Flatten the list of files.\n list.flatten!\n\nend",
"def GetPartitionLst(tg, device)\n tg = deep_copy(tg)\n ret = []\n tmp = GetDiskPartitionTg(device, tg)\n Builtins.y2milestone(\"GetPartitionLst tmp:%1\", tmp)\n Builtins.foreach(tmp) do |m|\n disk = Ops.get_string(m, \"disk\", \"\")\n if Builtins.search(device, \"/dev/evms\") == 0 &&\n !Builtins.haskey(tg, disk)\n disk = \"/dev/evms\"\n end\n Builtins.y2debug(\"GetPartitionLst device=%1 disk=%2\", device, disk)\n part = Builtins.filter(Ops.get_list(tg, [disk, \"partitions\"], [])) do |p|\n Ops.get_string(p, \"device\", \"\") == device\n end\n part = Builtins.filter(part) { |p| !Ops.get_boolean(p, \"delete\", false) }\n if Builtins.size(part) == 0 && Ops.is_integer?(Ops.get(m, \"nr\", 0))\n part = Builtins.filter(Ops.get_list(tg, [disk, \"partitions\"], [])) do |p|\n Ops.get_integer(p, \"nr\", -1) == Ops.get_integer(m, \"nr\", 0)\n end\n part = Builtins.filter(part) do |p|\n !Ops.get_boolean(p, \"delete\", false)\n end\n end\n if Builtins.size(part) == 0\n part = Builtins.filter(Ops.get_list(tg, [disk, \"partitions\"], [])) do |p|\n Ops.get_string(p, \"name\", \"\") == Ops.get_string(m, \"nr\", \"\")\n end\n part = Builtins.filter(part) do |p|\n !Ops.get_boolean(p, \"delete\", false)\n end\n end\n pa = Ops.get(part, 0, {})\n if Builtins.size(pa) == 0 &&\n Builtins.search(device, \"/dev/mapper/\") == 0\n part = Builtins.filter(\n Ops.get_list(tg, [\"/dev/mapper\", \"partitions\"], [])\n ) { |p| Ops.get_string(p, \"device\", \"\") == device }\n pa = Ops.get(part, 0, {})\n end\n if Builtins.size(pa) == 0 &&\n Builtins.search(device, \"/dev/mapper/\") == 0\n part = Builtins.filter(\n Ops.get_list(tg, [\"/dev/loop\", \"partitions\"], [])\n ) { |p| Ops.get_string(p, \"device\", \"\") == device }\n pa = Ops.get(part, 0, {})\n end\n ret = Builtins.add(ret, pa) if Ops.greater_than(Builtins.size(pa), 0)\n end\n Builtins.y2debug(\"GetPartitionLst ret=%1\", ret)\n deep_copy(ret)\n end",
"def split!\n Backup::Splitter.new(self).split!\n end",
"def split_array(arr, parts)\n ret = [];\n arr.each_slice((arr.size / parts.to_f).ceil) { |part| ret << part } unless arr.empty?\n ret\n end",
"def partition(&block) # :nodoc:\n resolve\n result = @items.partition(&block)\n [\n PropertyGroup::PathList.new.import(result[0]),\n PropertyGroup::PathList.new.import(result[1]),\n ]\n end",
"def tmux_split(along:, percent: 50)\n flag =\n case along.to_sym\n when :| ; \"-h\"\n when :- ; \"-v\"\n end\n cmd = %q( split-window %s -p %d ) % [ flag, percent ]\n\n tmux_run cmd\nend",
"def partition_for!(key)\n if leader_available?\n # Use the configured partitioner\n partition_id = partitioner.call(key, available_partitions.count, partitions.count)\n partition!(partition_id)\n else\n error_code.raise\n end\n end",
"def show_parts(device)\n action_parts(device, '-s -av')\n end",
"def extract_first_page_images\n #######\n # Docsplit.extract_images(document.file.file, :size => %w{200x 700x 1000x}, :format => :jpg, :pages => %w{1}, output: output_path)\n Docsplit.extract_images(file.path, :size => %w{200x 700x 1000x}, :format => :jpg, :pages => %w{1}, output: \"public/#{self.docsplit_dir}\" )\n \n # def store_path(for_file=filename)\n # # File.join([store_dir, full_filename(for_file)].compact)\n # \"#{self.model.class.to_s.underscore}\" + \"/\" + \"#{mounted_as}\" + \"/\" + \"#{self.model.user.uuid.to_s}\" + \"/\" + \"#{self.model.slug}\" + \"/\" + \"#{(version_name || :original).to_s}\" + \"_\" + \"#{self.file.basename}\" + \".jpg\"\n # end\n # if Rails.env.production?\n # document.store!(new_file=\"#{output_path}/200x/#{document.model.file_name.chomp(document.model.document.file.extension)[0..-2]}_1.jpg}\")\n # document.store!(new_file=\"#{output_path}/700x/#{document.model.file_name.chomp(document.model.document.file.extension)[0..-2]}_1.jpg}\")\n # document.store!(new_file=\"#{output_path}/1000x/#{document.model.file_name.chomp(document.model.document.file.extension)[0..-2]}_1.jpg}\")\n # end\n # Docsplit.extract_images(document.file.file, :size => %w{200x 700x 1000x}, :format => :jpg, :pages => %w{1}, output: \"/tmp/uploads/docsplit/#{model.class.to_s.underscore}/#{model.slug}\")\n\n\n # ::Docsplit.extract_images(self.pdf, :size => %w{200x 700x 1000x}, :format => :jpg, :pages => %w{1}, output: output_path)\n # if Rails.env.production?\n # # Rename file folders. \n # FileUtils.mv local_output_path + \"160x\", s3_output_path + \"160x\"\n # FileUtils.mv local_output_path + \"700x\", s3_output_path + \"700x\"\n # FileUtils.mv local_output_path + \"1000x\", s3_output_path + \"1000x\"\n # end\n \n true\n # self\n end",
"def list_nix_partitions # nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\" && $6==\"83\") print $1;else {if ($5==\"83\") print $1}}'`.chomp.split\nend",
"def list_nix_partitions_with_size_and_type # nelsongs\n\t`fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\" && ($6==\"83\" || $6==\"82\")) print $1\":\"$5\":\"$6;else {if ($5==\"83\" || $5==\"82\") print $1\":\"$4\":\"$5}}' | sed s/+//g`.split\nend",
"def loadfw(filename)\n\tflashimage = Flashimage.new\n\tfirmware = Flashimage.read(filename)\n\tsize = firmware.size\n\toffset_signature = size - 10\n\tsignature = firmware[offset_signature .. -1]\n\tputs(\"signature: #{signature.inspect}\")\n\tlength, magic, crc32, offset_code = getblock('code', firmware, offset_signature)\n\tcode = Partition.new('code')\n\tcode.update(firmware[offset_code ... offset_code + length])\n\tputs code.size\n\tlength, magic, crc32, offset_web = getblock('web', firmware, offset_code)\n\tweb = Partition.new('web')\n\tputs web.size\n\tweb.update(firmware[offset_web ... offset_web + length])\n\tflashimage.update(code)\n\tflashimage.update(web)\n\tflashimage.write\nend",
"def partitionize(array)\r\n p = Array.new\r\n\r\n array.each_with_index do |x, i|\r\n if i == 0 || x.exercise_id != array[i-1].exercise_id\r\n p << Array.new\r\n end\r\n p.last << x\r\n end\r\n p\r\n end",
"def FSCKPartition(partition)\n if !Mode.test\n detected_fs = Storage.DetectFs(partition)\n if detected_fs == :ext2\n # label, %1 is partition\n out = Builtins.sformat(_(\"Checking partition %1\"), partition)\n UI.OpenDialog(Opt(:decorated), Label(out))\n\n Builtins.y2milestone(\"command: /sbin/e2fsck -y %1\", partition)\n SCR.Execute(\n path(\".target.bash\"),\n Ops.add(\"/sbin/e2fsck -y \", partition)\n )\n\n UI.CloseDialog\n end\n end\n\n nil\n end",
"def AddMountPointsForWinParts(partitions, primary, max_prim, foreign_nr)\n partitions = deep_copy(partitions)\n return if !Arch.i386 && !Arch.ia64 && !Arch.x86_64\n\n foreign_ids = \"CDEFGHIJKLMNOPQRSTUVW\"\n\n Builtins.foreach(partitions) do |partition|\n new_partition = deep_copy(partition)\n fsid = Ops.get_integer(partition, \"fsid\", Partitions.fsid_native)\n partnum = 0\n if Builtins.haskey(partition, \"nr\") &&\n Ops.is_integer?(Ops.get(partition, \"nr\", 0))\n partnum = Ops.get_integer(partition, \"nr\", 0)\n end\n if !Builtins.haskey(partition, \"mount\") &&\n !Ops.get_boolean(partition, \"delete\", false) &&\n Ops.less_or_equal(partnum, max_prim) == primary &&\n Ops.less_than(foreign_nr.value, 24) &&\n Partitions.IsDosWinNtPartition(fsid) &&\n !Arch.ia64 &&\n !IsEfiPartition(partition) &&\n Ops.greater_or_equal(\n Ops.get_integer(partition, \"size_k\", 0),\n 1024 * 1024\n ) &&\n Builtins.contains(\n [:vfat, :ntfs],\n Ops.get_symbol(partition, \"used_fs\", :none)\n )\n Ops.set(\n new_partition,\n \"fstopt\",\n FileSystems.DefaultFstabOptions(partition)\n )\n if Builtins.contains(Partitions.fsid_dostypes, fsid)\n Ops.set(\n new_partition,\n \"mount\",\n Ops.add(\n \"/dos/\",\n Builtins.substring(foreign_ids, foreign_nr.value, 1)\n )\n )\n foreign_nr.value = Ops.add(foreign_nr.value, 1)\n else\n Ops.set(\n new_partition,\n \"mount\",\n Ops.add(\n \"/windows/\",\n Builtins.substring(foreign_ids, foreign_nr.value, 1)\n )\n )\n foreign_nr.value = Ops.add(foreign_nr.value, 1)\n end\n ChangeVolumeProperties(new_partition)\n Builtins.y2milestone(\"win part %1\", new_partition)\n end\n end\n\n nil\n end",
"def divide\n # target\n target_color_list_string = target_color_list\n export(EXPORT_TARGET_FILE_PATH, target_color_list_string)\n display target_color_list_string\n\n # pixels\n pixels_color_list.each_with_index do |pixels_color_str, index|\n path = DIVIDED_PATH + 'elements' + index.to_s + TEXT_FILE_SUFFIX\n export(path, pixels_color_str)\n display pixels_color_str\n end\n end",
"def prepare_image\n images = []\n image = ImagesForJob.new\n parse_values(\"IMAGE\", image)\n images,@initial_image_name = InputBatch.convert_multipage_to_singlepage(image,@location,@img_count)\n return images\n end",
"def compute_parts(source, default_part_size)\n size = File.size(source)\n offset, part_number, parts = 0, 1, []\n while offset < size\n parts << {\n part_number: part_number,\n body: FilePart.new(source: source, offset: offset, size: part_size(size, default_part_size, offset))\n }\n\n part_number += 1\n offset += default_part_size\n end\n parts\n end",
"def crop!(crop_partitions, crop_sites_per_partition)\n @list = Hash[@list.first(crop_partitions)]\n @list = Hash[@list.map do |partition_name, partition|\n [partition_name, partition.crop(crop_sites_per_partition - Random.rand(0..2))]\n end]\n end",
"def cut_white_space_edges\n x1_array = Array.new\n x2_array = Array.new\n y1_array = Array.new\n y2_array = Array.new\n \n @groups.each do |g|\n x1_array << g.x_pos\n x2_array << g.x_pos + g.width\n y1_array << g.y_pos\n y2_array << g.y_pos + g.height\n end\n \n if @vertical\n #Normal position of the image (up)\n if values_bits[Constants::V_Image_position]< 4.5 \n @height = y2_array.max + @upper_margin\n #Alternative position(down)\n else \n new_height = @height - (y1_array.min-@upper_margin)\n \n @groups.each do |g|\n g.y_pos -= (@height - new_height)\n end\n @main_image.y_pos -= (@height - new_height)\n \n @height = new_height\n end\n else\n #Normal position of the image (left)\n if values_bits[Constants::V_Image_position]< 4.5\n @width = x2_array.max + @sides_margin\n #Alternative position of the image (right)\n else \n new_width = @width - (x1_array.min-@sides_margin)\n \n @groups.each do |g|\n g.x_pos -= (@width - new_width)\n end\n @main_image.x_pos -= (@width - new_width)\n \n @width = new_width\n end\n end\n end",
"def partition_types_ext\n ptr1 = MemoryPointer::new( :size_t, 1)\n error = OpenCL.clGetDeviceInfo(self, PARTITION_TYPES_EXT, 0, nil, ptr1)\n error_check(error)\n ptr2 = MemoryPointer::new( ptr1.read_size_t )\n error = OpenCL.clGetDeviceInfo(self, PARTITION_TYPES_EXT, ptr1.read_size_t, ptr2, nil)\n error_check(error)\n arr = ptr2.get_array_of_cl_device_partition_property_ext(0, ptr1.read_size_t/ OpenCL.find_type(:cl_device_partition_property_ext).size)\n arr.reject! { |e| e == 0 }\n return arr.collect { |e| PartitionEXT::new(e.to_i) }\n end",
"def split(position)\n end",
"def split(position)\n end",
"def split_movie(file_path)\n OSX.require_framework(\"QTKit\")\n splitted_files = Array.new\n movie, error = OSX::QTMovie.movieWithFile_error(file_path) # Load in the original movie\n if(error != nil || movie == nil) # Check if we can load the movie\n $stderr.puts \"Could not open #{file_path}, #{error.localizedDescription}\"\n exit(-1)\n end\n \n # a QTTime structure has a timeValue and timeScale we need\n # to dived the timeValue by the timeScale to get the time\n # in seconds. If we devide that by 60 we get the time in\n # minutes\n time_scale = movie.duration.timeScale\n total_time = (movie.duration.timeValue / time_scale) / 60\n \n # If the total time is below 10 minutes we don't have to\n # split the movie\n if(total_time < 10)\n splitted_files.push(file_path)\n return splitted_files\n end\n \n # If the totol time is above 10 minutes we have to calculate\n # how many parts we need to make. No part can be over 10 minutes.\n parts = total_time.to_i / 10\n \n if(total_time.modulo(10) != 0)\n parts = parts + 1\n end\n \n # Parts are always 10 minutes long (or shorter)\n part_duration = OSX::QTMakeTime(600 * time_scale, time_scale)\n temp_dir = Dir.tmpdir()\n attributes = OSX::NSDictionary.dictionaryWithObjectsAndKeys(OSX::NSNumber.numberWithBool(true), \"QTMovieFlatten\", nil)\n movies = Array.new\n \n # For every part we extract the time selection out of the original movie\n # and write it out to a new, temporary file. We store the paths to the\n # temporary files\n parts.times do |i|\n begin_time = OSX::QTMakeTime(i * 600 * time_scale, time_scale)\n range = OSX::QTMakeTimeRange(begin_time, part_duration)\n movie_part, error = movie.movieWithTimeRange_error(range)\n \n if(error != nil || movie_part == nil)\n $stderr.puts \"Could not generate subclip, #{error.localizedDescription}\"\n exit(-1)\n end\n \n # Writing out the temporary file and storing the path in the movies array\n temp_file_path = temp_dir + \"/\" + File.basename(file_path, File.extname(file_path)) + \"-\" + i.to_s + \".mov\"\n movie_part.writeToFile_withAttributes(temp_file_path, attributes)\n movies.push(temp_file_path)\n end\n return movies \n end",
"def discoverDosExtPartitions(priBaseLBA, ptBaseLBA, pNum)\n ra = []\n seek(ptBaseLBA * @blockSize, IO::SEEK_SET)\n mbr = read(MBR_SIZE)\n\n #\n # Create and add disk object for secondary file system partition.\n # NOTE: the start of the partition is relative to ptBaseLBA.\n #\n pte = DOS_PT_START\n ptEntry = DOS_PARTITION_ENTRY.decode(mbr[pte, PTE_LEN])\n ra << MiqPartition.new(self, ptEntry[:ptype], ptEntry[:startLBA] + ptBaseLBA, ptEntry[:partSize], pNum) if ptEntry[:ptype] != 0\n\n #\n # Follow the chain to the next secondary extended partition.\n # NOTE: the start of the partition is relative to priBaseLBA.\n #\n pte += PTE_LEN\n ptEntry = DOS_PARTITION_ENTRY.decode(mbr[pte, PTE_LEN])\n ra.concat(discoverDosExtPartitions(priBaseLBA, ptEntry[:startLBA] + priBaseLBA, pNum + 1)) if ptEntry[:startLBA] != 0\n\n ra\n end",
"def save_splited_part(zip_file, partial_zip_file_name, zip_file_size, szip_file_index, segment_size, segment_count); end",
"def image_to_part_params\n params.require(:image_to_part).permit(:image_id, :part_id)\n end",
"def partitioned_id\n if respond_to?(:attachment_options) and\n attachment_options[:partition] == false \n [ ]\n elsif attachment_options[:uuid_primary_key]\n # Primary key is a 128-bit UUID in hex format.\n # Split it into 2 components.\n path_id = attachment_path_id.to_s\n component1 = path_id[0..15] || \"-\"\n component2 = path_id[16..-1] || \"-\"\n [component1, component2]\n else\n path_id = attachment_path_id\n if path_id.is_a?(Integer)\n # Primary key is an integer. Split it after padding it with 0.\n (\"%08d\" % path_id).scan(/..../)\n else\n # Primary key is a String. Hash it and split it into 4 components.\n hash = Digest::SHA512.hexdigest(path_id.to_s)\n [hash[0..31], hash[32..63], hash[64..95], hash[96..127]]\n end\n end\n end",
"def parts_on?(device)\n partitions = lsblk(device)\n return true if partitions[0]['type'] == 'part'\n\n false\n end",
"def parts; end",
"def parts; end",
"def parts; end",
"def lvm_volume_group(partition)\n %x{pvs --noheadings --separator ' ' #{partition} 2>/dev/null| sed -e 's/^\\s*//' | cut -d ' ' -f 2}.strip\nend",
"def split(next_cards)\n hand = @hands[@current_hand]\n hand_cards = hand.cards # Get the two cards of the hand\n 2.times do |index| # One split results in creation of two hands\n new_hand = Hand.new([hand_cards[index]], hand.bet) # Create new hands with one card each of the original hand cards\n new_card = next_cards[index] # Obtain a new card from the shoe\n new_hand.cards.push(new_card) # Add this card to the newly created hand\n @hands.insert(@current_hand + 1, new_hand) # The newly created hands are pushed to the immediate right of the hand\n end\n place_bet(hand.bet) # Double the original bet\n @hands.delete_at(@current_hand) # Remove the hand that was split\n end",
"def partitions(key, partitions)\n master = fnv_hash(key) % partitions.size\n selected = [master]\n nodes = [partitions[master]]\n current = (master + 1) % partitions.size\n\n # Walk clockwise around the ring of partitions, starting from the master partition.\n # The next few unique nodes in ring order are the replicas.\n while current != master && selected.size < @replicas\n if !nodes.include? partitions[current]\n nodes << partitions[current]\n selected << current\n end\n current = (current + 1) % partitions.size\n end\n\n selected\n end",
"def split_page(width=200)\n scan(/.{1,#{width}}/m)\n end",
"def partition(id)\n partitions.detect {|partition| partition.id == id}\n end",
"def process_images(pat, sp_name)\n sp = ServicePack.find_or_create_by_name(sp_name)\n images = ImagePath.find(:all, :conditions => \"path like '#{pat}'\")\n length = images.length\n images.each_with_index do |image, index|\n # puts \"processing image #{index} of #{length}\"\n image.package.filesets.each do |fileset|\n ServicePackFilesetMap.find_or_create_by_service_pack_id_and_fileset_id(sp.id, fileset.id)\n end\n end\nend",
"def make_parts(iterator, internal_sorter)\n slice = START_SLICE_SIZE\n\n parts = []\n part = []\n\n loop do\n begin\n # Enumerator does not have slice method\n slice.times { part << iterator.next }\n rescue StopIteration\n break\n end\n\n # Carefully memory_limit is variable\n if memory_usage > memory_limit\n # Sort current part with origin key_function\n internal_sorter.sort(part)\n # Tempfile for current part\n # will be destroyed on #destroy_temp_folder\n file = Tempfile.new(\"part\", @dir)\n serializer.dump(part, file)\n # Peek is at the end of file\n file.seek(0)\n parts << serializer.load(file)\n\n # Some memory will be released but not immediately\n # need some new memory for start\n part.clear\n add_memory!\n else\n slice = [slice*2, MAX_SLICE_SIZE].min\n end\n end\n\n # Last part which is not in the file\n if part.any?\n internal_sorter.sort(part)\n parts << part.each\n end\n\n parts\n end",
"def split_into_parts\n number = integer.to_i\n\n @parts = [\n number / 10**8,\n (number / 10**4) % 10**4,\n number % 10**4\n ]\n end",
"def list_size_swap_partitions # nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\" && $6==\"82\") print $5;else {if ($5==\"82\") print $4}}' | sed s/+//g`.chomp\nend",
"def find_limits(free_part_infos, size)\n start_part = nil\n end_part = nil\n minimal_header = 2048\n free_part_infos.each do |p|\n size_part = p['start'].to_i < minimal_header ? p['size'].to_i - minimal_header : p['size'].to_i\n next if size_part < size.to_i\n start_part = p['start'].to_i < minimal_header ? minimal_header : p['start']\n end_part = start_part.to_i + size.to_i - 1\n break\n end\n raise 'not enough free space to create the partition' if start_part.nil? || end_part.nil?\n [start_part, end_part]\n end",
"def GetPartitionInfo\n partition = []\n\n if Stage.cont\n partition = EvaluateFreeSpace(0) # free spare already checked during first part of installation\n elsif Mode.update\n partition = EvaluateFreeSpace(15) # 15% free spare for update/upgrade\n elsif Mode.normal\n partition = EvaluateFreeSpace(5) # 5% free spare for post installation # Stage::initial ()\n else\n partition = get_partition_info\n end\n Builtins.y2milestone(\n \"INIT done, SpaceCalculation - partitions: %1\",\n partition\n )\n\n @info_called = true\n @partition_info = deep_copy(partition) # store partition_info\n\n deep_copy(partition)\n end",
"def delete_file_parts\n #TODO implementation\n end",
"def partition(tracks)\n track_count = tracks.size\n track_numbers = (0...track_count).to_a\n half = track_count / 2.0\n half_rounded = half.round\n range_one = 0...(half_rounded.pred)\n range_two = (half_rounded.pred)...(track_count.pred)\n [tracks.slice(range_one), tracks.slice(range_two)].reject(&:nil?)\n end",
"def split\n [self[0,self.length/2], self[self.length/2,self.length]]\nend",
"def partitions(**opts)\n\t\t\t\topts[:disk]||=@computer.dig(:sysinit, :disk)\n\t\t\t\topts[:mountpoint]||=@computer.dig(:sysinit, :mountpoint)\n\t\t\t\t@partitions=partitions_helper(@partitions||Marshal.load(Marshal.dump(@computer.dig(:sysinit,:partitions))), **opts)\n\t\t\t\t@partitions = yield @partitions, **opts if block_given?\n\t\t\t\t@partitions\n\t\t\tend",
"def CheckPartition(partition)\n partition = deep_copy(partition)\n freshman = {\n :valid => false,\n :name => \"unknown\",\n :arch => \"unknown\",\n :label => Ops.get_string(partition, \"label\", \"\"),\n :fs => Ops.get_symbol(partition, \"detected_fs\", :unknown),\n :fstype => Ops.get_string(partition, \"fstype\", \"unknown\")\n }\n\n p_dev = Ops.get_string(partition, \"device\", \"error\")\n p_fsid = Ops.get_integer(partition, \"fsid\", 0)\n p_type = Ops.get_symbol(partition, \"type\", :primary)\n p_detect_fs = Ops.get_symbol(partition, \"detected_fs\", :unknown)\n\n # possible root FS\n if Builtins.contains(FileSystems.possible_root_fs, p_detect_fs)\n mt_map = {\n :ext2 => \"ext2\",\n :ext3 => \"ext3\",\n :ext4 => \"ext4\",\n :btrfs => \"btrfs\",\n :reiser => \"reiserfs\",\n :xfs => \"xfs\",\n :jfs => \"jfs\"\n }\n mount_type = Ops.get(mt_map, p_detect_fs, \"\")\n\n error_message = nil\n if !(\n error_message_ref = arg_ref(error_message);\n _RunFSCKonJFS_result = RunFSCKonJFS(\n mount_type,\n p_dev,\n error_message_ref\n );\n error_message = error_message_ref.value;\n _RunFSCKonJFS_result\n )\n Ops.set(freshman, :valid, false)\n return deep_copy(freshman)\n end\n\n # mustn't be empty and must be modular\n if mount_type != \"\" && !Builtins.contains(@non_modular_fs, mount_type)\n SCR.Execute(path(\".target.modprobe\"), mount_type, \"\")\n end\n # mount (read-only) partition to Installation::destdir\n Storage.RemoveDmMapsTo(p_dev)\n if Convert.to_boolean(\n SCR.Execute(\n path(\".target.mount\"),\n [p_dev, Installation.destdir, Installation.mountlog],\n \"-o ro\"\n )\n )\n # Is this a root partition, does /etc/fstab exists?\n if Ops.greater_than(\n SCR.Read(\n path(\".target.size\"),\n Ops.add(Installation.destdir, \"/etc/fstab\")\n ),\n 0\n )\n Builtins.y2milestone(\"found fstab on %1\", partition)\n\n fstab = []\n crtab = []\n\n fstab_ref = arg_ref(fstab)\n crtab_ref = arg_ref(crtab)\n read_fstab_and_cryptotab(fstab_ref, crtab_ref, p_dev)\n fstab = fstab_ref.value\n crtab = crtab_ref.value\n Update.GetProductName\n\n fstab = Builtins.filter(fstab) do |p|\n Ops.get_string(p, \"file\", \"\") == \"/\"\n end\n\n if Builtins.size(Ops.get_string(fstab, [0, \"spec\"], \"\")) == 0\n Builtins.y2warning(\"Cannot find / entry in fstab %1\", fstab)\n end\n\n Ops.set(\n freshman,\n :valid,\n Ops.greater_than(\n Builtins.size(Ops.get_string(fstab, [0, \"spec\"], \"\")),\n 0\n ) &&\n Storage.DeviceMatchFstab(\n p_dev,\n Ops.get_string(\n # bugzilla #304269\n # DeviceMatchFstab expects _old_ not _translated_ device\n fstab,\n [0, \"spec_old\"],\n Ops.get_string(fstab, [0, \"spec\"], \"\")\n )\n )\n )\n\n # Why this doesn't match?\n # Possible reasons:\n # - /var not mounted so hwinfo cannot translate device names\n if Ops.get_boolean(freshman, :valid, false) != true\n Builtins.y2warning(\n \"Device does not match fstab: '%1' vs. '%2'\",\n p_dev,\n Ops.get_string(fstab, [0, \"spec\"], \"\")\n )\n end\n if Mode.autoinst\n # we dont care about the other checks in autoinstallation\n SCR.Execute(path(\".target.umount\"), Installation.destdir)\n return deep_copy(freshman)\n end\n\n # Get installed release name\n release = OSRelease.ReleaseInformation(Installation.destdir)\n Builtins.y2debug(\"release: %1\", release)\n if release == \"?\"\n # label for an unknown installed system\n release = _(\"Unknown\")\n end\n Ops.set(freshman, :name, release)\n\n # Right architecture?\n Ops.set(\n freshman,\n :arch,\n GetArchOfELF(Ops.add(Installation.destdir, \"/bin/bash\"))\n )\n instsys_arch = GetArchOfELF(\"/bin/bash\")\n\n # `arch_valid, see bugzilla #288201\n # installed /bin/bash and the one from inst-sys are matching\n if Ops.get_string(freshman, :arch, \"unknown\") == instsys_arch\n Builtins.y2milestone(\"Architecture (%1) is valid\", instsys_arch)\n Ops.set(freshman, :arch_valid, true) \n\n # both are PPC, bugzilla #249791\n elsif Builtins.contains(\n [\"ppc\", \"ppc64\"],\n Ops.get_string(freshman, :arch, \"unknown\")\n ) &&\n Builtins.contains([\"ppc\", \"ppc64\"], instsys_arch)\n Builtins.y2milestone(\n \"Architecture for partition %1 is %2, upgrading %3\",\n p_dev,\n Ops.get_string(freshman, :arch, \"unknown\"),\n instsys_arch\n )\n Ops.set(freshman, :arch_valid, true) \n\n # Architecture is not matching\n else\n Builtins.y2milestone(\n \"Architecture for partition %1 is %2, upgrading %3\",\n p_dev,\n Ops.get_string(freshman, :arch, \"unknown\"),\n instsys_arch\n )\n Ops.set(freshman, :arch_valid, false)\n end\n\n # If architecture is not matching, the whole partition is considered to be wrong\n if Ops.get_boolean(freshman, :arch_valid, false) != true\n Builtins.y2milestone(\n \"Architecture is not valid -> the whole partition is not valid\"\n )\n Ops.set(freshman, :valid, false)\n end\n\n if IncompleteInstallationDetected(Installation.destdir)\n Builtins.y2milestone(\n \"Incomplete installation detected, partition is not valid\"\n )\n Ops.set(freshman, :valid, false)\n end\n\n Builtins.y2milestone(\n \"Partition is valid: %1, arch is valid: %2\",\n Ops.get_boolean(freshman, :valid, false),\n Ops.get_boolean(freshman, :arch_valid, false)\n )\n end\n\n # unmount partition\n SCR.Execute(path(\".target.umount\"), Installation.destdir)\n end\n end\n\n Builtins.y2milestone(\"%1 %2\", partition, freshman)\n\n deep_copy(freshman)\n end",
"def gen_partition_script(number_of_volumes, mount_point_prefix, resize_root_vol = false)\n resize_root = resize_root_vol ? 0 : 1\n template = <<-END.gsub(/^ {6}/, '')\n #!/bin/bash\n RESIZE_ROOT=<%= resize_root %>\n if [ $RESIZE_ROOT -eq 0 ]; then\n echo \"Resizing the root partition\"\n resize2fs /dev/`cat /proc/partitions | awk '/xvd*/ {print $4}' | head -n1`\n fi\n NUM_OF_VOLS=<%= number_of_volumes %>\n if [ $NUM_OF_VOLS -ne 0 ]; then\n DEVICES=`cat /proc/partitions | awk '/xvd*/ {print $4}' | tail -n<%= number_of_volumes %>`\n echo \"Formatting and mounting initiated\"\n count=1\n for dev in $DEVICES; do\n echo \"Formatting and mounting $dev\"\n fdisk -u /dev/$dev << EOF\n n\n p\n 1\n\n\n w\n EOF\n mkfs.ext4 /dev/${dev}1\n data_dir=$((count++))\n mkdir -p <%= mount_point_prefix %>/${data_dir}\n mount /dev/${dev}1 <%= mount_point_prefix %>${data_dir}\n done\n fi\n END\n ERB.new(template).result(binding)\n end"
] |
[
"0.690342",
"0.59546083",
"0.57812333",
"0.57254237",
"0.57205456",
"0.5712888",
"0.56876594",
"0.5683673",
"0.5644677",
"0.56099576",
"0.55600005",
"0.54711246",
"0.54664296",
"0.54483944",
"0.5411717",
"0.5397295",
"0.5254826",
"0.5215175",
"0.5200493",
"0.5196441",
"0.517246",
"0.5170019",
"0.515361",
"0.51358235",
"0.5117855",
"0.5116235",
"0.5065151",
"0.5063816",
"0.50624704",
"0.5050977",
"0.50505215",
"0.50486755",
"0.50368834",
"0.50355774",
"0.5032687",
"0.5027838",
"0.50239307",
"0.50172806",
"0.4990237",
"0.4978183",
"0.49634585",
"0.4935835",
"0.49341545",
"0.4924032",
"0.4909357",
"0.49019882",
"0.49005267",
"0.48945135",
"0.48930547",
"0.48897937",
"0.4866524",
"0.48628554",
"0.48606712",
"0.4856841",
"0.48501942",
"0.48415887",
"0.48283273",
"0.4824686",
"0.48245788",
"0.48208514",
"0.48204106",
"0.4807459",
"0.48044986",
"0.47872877",
"0.47795677",
"0.47794673",
"0.47787732",
"0.47735012",
"0.47717136",
"0.47699296",
"0.47633144",
"0.47521934",
"0.47518808",
"0.47518808",
"0.474725",
"0.47367612",
"0.47363",
"0.47357315",
"0.47354963",
"0.47315693",
"0.47285715",
"0.47285715",
"0.47285715",
"0.47140178",
"0.47068036",
"0.47031662",
"0.4699637",
"0.46907657",
"0.46861398",
"0.46831903",
"0.46697226",
"0.4667477",
"0.46591914",
"0.46552715",
"0.46546477",
"0.46493706",
"0.46484563",
"0.46475837",
"0.46444342",
"0.46382013"
] |
0.8141284
|
0
|
Make flash image from partitions.
|
def mergepartitions
flashdata = "\xff" * FLASHSIZE
baseaddress = PARTITIONS['boot'][START]
PARTITIONS.each { |label, partition|
first = partition[START] - baseaddress
last = first + partition[SIZE]
filename = "#{File.dirname(FLASHIMAGE)}/#{partition[FILE]}"
partdata = Flashimage.read(filename)
size = partdata.size
puts("Partition size: #{size / KiB} KiB = #{size} B (#{label}).")
raise('Partition size is unexpected.') if (size != partition[SIZE])
flashdata[first ... last] = partdata
}
Flashimage.write(flashdata)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def splitflashimage\n\tflashdata = Flashimage.read\n\tsize = flashdata.size\n\tputs(\"Flash image size: #{size / MiB} MiB = #{size} B.\")\n\traise('Flash size is unexpected.') if (size != FLASHSIZE)\n\tbaseaddress = PARTITIONS['boot'][START]\n\tPARTITIONS.each { |label, partition|\n\t\tfirst = partition[START] - baseaddress\n\t\tlast = first + partition[SIZE]\n\t\tfilename = \"#{File.dirname(FLASHIMAGE)}/#{partition[FILE]}\"\n\t\tFlashimage.write(flashdata[first ... last], filename)\n\t}\nend",
"def changepartition(partition, filename)\n\tbaseaddress = PARTITIONS['boot'][START]\t\n\tsize = partition[SIZE]\n\tpartdata = Flashimage.read(filename)\n\tlength = partdata.size\n\tlast = partition[SIZE]\n\traise('Input file too large.') if length + 12 > last\n\tcrc32 = Zlib.crc32(partdata)\n\tpartdata[length ... last - 12] = \"\\xff\" * (last - length - 12)\n\tpartdata[last - 12 ... last] = [length, 0x12345678, crc32].pack('V3')\n\tfilename = \"#{File.dirname(FLASHIMAGE)}/#{partition[FILE]}\"\n\tFlashimage.write(partdata, filename)\nend",
"def loadpart(partname, filename)\n\tflashimage = Flashimage.new\n\tfirmware = Flashimage.read(filename)\n\tsize = firmware.size\n\toffset_signature = size - 10\n\tsignature = firmware[offset_signature .. -1]\n\tputs(\"signature: #{signature.inspect}\")\n\tlength, magic, crc32, offset = getblock(partname, firmware, offset_signature)\n\tpartition = Partition.new(partname)\n\tpartition.update(firmware[offset ... offset + length])\n\tflashimage.update(partition)\n\tflashimage.write\nend",
"def createflashimage\n\tflashdata = \"\\xff\" * FLASHSIZE\n\tFlashimage.write(flashdata)\nend",
"def create_partitions\n info(\"Creating disk with #{PARTITION_TABLE_TYPE} parition table\")\n execute!(\"parted -s #{@dev} mklabel #{PARTITION_TABLE_TYPE}\")\n\n start_size = FIRST_PARTITION_OFFSET\n end_size = FIRST_PARTITION_OFFSET\n\n unspec_part = nil\n\n # Create the partitions\n @partition_layout.each_with_index do |part, index|\n # Deal with any \"open ended\" partitions last\n if not part.size_mb.is_a?(Integer)\n unspec_part = part\n next\n end\n\n start_size = end_size\n end_size += part.size_mb\n\n info(\"Creating partition #{part.label} (#{part.fs}, #{part.size_mb}MiB)\")\n execute!(\"parted #{@dev} mkpart #{part.label} #{part.fs} #{start_size}MiB #{end_size}MiB\")\n\n (part.flags || {}).each_pair { |k, v|\n info(\"Setting partition flag #{k} to #{v}\")\n execute!(\"parted #{@dev} set #{index + 1} #{k} #{v}\")\n }\n\n label_path = \"/dev/disk/by-partlabel/#{part.label}\"\n self.wait_for_device(label_path)\n\n if not part.fs\n warn(\"No filesystem specified for #{part.label}. Skipping FS\")\n else\n create_filesystem(part.fs, label_path, part.label)\n end\n\n if part.lvm\n notice(\"Setting up LVM on #{part.label}\")\n setup_lvm_on_partition(part)\n end\n end\n\n # Deal with any \"open ended\" partitions (that have an unspecified size_mb)\n if unspec_part\n part = unspec_part\n info(\"Creating partition #{part.label} (#{part.fs}, 100% remaining)\")\n execute!(\"parted #{@dev} mkpart #{part.label} #{part.fs} #{end_size}MiB 100%\")\n\n (part.flags || {}).each_pair { |k, v|\n info(\"Setting partition flag #{k} to #{v}\")\n execute!(\"parted #{@dev} set #{@partition_layout.length} #{k} #{v}\")\n }\n\n label_path = \"/dev/disk/by-partlabel/#{part.label}\"\n self.wait_for_device(label_path)\n create_filesystem(part.fs, label_path, part.label) if part.fs\n\n if part.lvm\n notice(\"Setting up LVM on #{part.label}\")\n setup_lvm_on_partition(part)\n end\n end\n\n nil\n end",
"def create_partition device, partition_type = 'primary', start_unit, end_unit\n command = 'parted'\n params = \"#{device.path} -s -a optimal unit MB mkpart #{partition_type} ext3 #{start_unit} -- #{end_unit}\"\n parted = CommandsExecutor.new command, params\n parted.execute\n raise \"Command execution error: #{parted.stderr.read}\" if not parted.success?\n probe_kernal device\n end",
"def SetFormatPartitions(fstabpart)\n fstabpart = deep_copy(fstabpart)\n # All storage devices\n target_map = Storage.GetTargetMap\n\n # all activated\n tmp = Builtins.filter(RootPart.GetActivated) do |e|\n Ops.get_string(e, :type, \"\") == \"mount\" ||\n Ops.get_string(e, :type, \"\") == \"swap\"\n end\n\n Builtins.foreach(tmp) do |e|\n mntpt = Ops.get_string(e, :type, \"\") == \"swap\" ?\n \"swap\" :\n Ops.get_string(e, :mntpt, \"\")\n part = Ops.get_string(e, :device, \"\")\n p = {}\n Builtins.foreach(fstabpart) do |pp|\n # mountpoint matches\n if Ops.get_string(pp, \"mount\", \"\") == mntpt\n p = deep_copy(pp)\n raise Break\n end\n end\n mount_options = \"\"\n Builtins.foreach(Storage.ReadFstab(Installation.destdir)) do |entry|\n if Ops.get_string(entry, \"file\", \"\") == mntpt\n mount_options = Ops.get_string(entry, \"mntops\", \"\")\n raise Break\n end\n end\n target_map = Storage.SetPartitionData(target_map, part, \"mount\", mntpt)\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"format\",\n Ops.get_boolean(p, \"format\", false)\n )\n target_map = Storage.SetPartitionData(target_map, part, \"delete\", false)\n target_map = Storage.SetPartitionData(target_map, part, \"create\", false)\n if Builtins.haskey(p, \"filesystem\")\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"filesystem\",\n Ops.get_symbol(p, \"filesystem\", :ext4)\n )\n end\n if Ops.greater_than(Builtins.size(mount_options), 0) &&\n !Builtins.haskey(p, \"fstopt\")\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"fstopt\",\n mount_options\n )\n end\n if Builtins.haskey(p, \"fstopt\")\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"fstopt\",\n Ops.get_string(p, \"fstopt\", \"\")\n )\n end\n if Builtins.haskey(p, \"mountby\")\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"mountby\",\n Ops.get_symbol(p, \"mountby\", :device)\n )\n end\n end\n\n Storage.SetTargetMap(target_map)\n true\n end",
"def create\n begin\n # Set the partition (/dev/sdb1), device (/dev/sdb) and alignment (optimal,minimal,none etc.) variables\n partition= resource[:name]\n device=partition[0,(partition.length-1)]\n alignment= resource[:alignment]\n\n # Now we can create the partition\n partitions = parted('-a', resource[:alignment],'--script',device,'mklabel',resource[:part_label],'mkpart', resource[:part_type],resource[:fs_type],resource[:p_begin],resource[:p_end])\n rescue Puppet::ExecutionFailure => e\n false\n end\n end",
"def build_ftk_disk_items(coll_pid, disk_image_files_dir, computer_media_photos_dir)\n assembler = FtkDiskImageItemAssembler.new(:collection_pid => coll_pid, :disk_image_files_dir => disk_image_files_dir, :computer_media_photos_dir => computer_media_photos_dir)\n assembler.process\nend",
"def loadfw(filename)\n\tflashimage = Flashimage.new\n\tfirmware = Flashimage.read(filename)\n\tsize = firmware.size\n\toffset_signature = size - 10\n\tsignature = firmware[offset_signature .. -1]\n\tputs(\"signature: #{signature.inspect}\")\n\tlength, magic, crc32, offset_code = getblock('code', firmware, offset_signature)\n\tcode = Partition.new('code')\n\tcode.update(firmware[offset_code ... offset_code + length])\n\tputs code.size\n\tlength, magic, crc32, offset_web = getblock('web', firmware, offset_code)\n\tweb = Partition.new('web')\n\tputs web.size\n\tweb.update(firmware[offset_web ... offset_web + length])\n\tflashimage.update(code)\n\tflashimage.update(web)\n\tflashimage.write\nend",
"def create_partition_to_fill_disk(disk)\n # @disk.create_partition('primary', '100%')\n disk.create_partition_table # LinuxAdmin::Disk.create_partition has this already...\n AwesomeSpawn.run!(\"parted -s #{disk.path} mkpart primary 0% 100%\")\n\n # FIXME: Refetch the disk after creating the partition\n disk = LinuxAdmin::Disk.local.find { |d| d.path == disk.path }\n disk.partitions.first\n end",
"def set_image_to_part\n @image_to_part = ImageToPart.find(params[:id])\n end",
"def create_ewf_image(drive_path ,image_output_location)\n ## Make E01 image\n @colour.notify \"Creating E01 image with path #{image_output_location}.E01\"\n @colour.notify 'This may take a while:'\n @colour.notify \"E01 image #{image_output_location}.E01 created\" if system \"ftkimager '#{drive_path}' '#{image_output_location}' --e01\"\nend",
"def clipart\n output = get_working_image(@session_id)\n unless File.exist?(output)\n FileUtils.cp(\"#{Rails.root}/public/#{params[:src]}\", output)\n img = Image.read(output).first\n img = img.scale(params[:rs].to_f) unless params[:rs].blank?\n img = img.level_colors(params[:b] || \"\", params[:w] || \"\", true) if params[:b] || params[:w]\n img.background_color = \"none\"\n img.rotate!(params[:r].to_f) unless params[:r].blank?\n\n #For embroidery\n if params[:emb] == 'true'\n img = img.ordered_dither\n end\n #FLIP/FLOP/Transpose/Transverse\n if params[:ff] == 'flip'\n img.flip!\n elsif params[:ff] == 'flop'\n img.flop!\n elsif params[:ff] == 'transpose'\n img.transpose!\n elsif params[:ff] == 'transverse'\n img.transverse!\n end\n #Extracts a channel\n if params[:ec] == 'R'\n img = img.channel(Magick::RedChannel)\n elsif params[:ec] == 'G'\n img = img.channel(Magick::GreenChannel)\n elsif params[:ec] == 'B'\n img = img.channel(Magick::BlueChannel)\n end\n\n #Applies a special effect to the image - QuantumRange\n img = img.sepiatone(Magick::QuantumRange * params[:qr].to_f) unless params[:qr].blank?\n\n #Vignette (Shape Edge)\n if params[:vig] == 'true'\n img = img.vignette\n end\n\n #Wet Floor\n if params[:wf]\n img = img.wet_floor\n end\n img.write(output)\n end\n img = Image.read(output).first\n send_data img.to_blob, :disposition => 'inline', :type => 'image/png'\n end",
"def make\n Paperclip.log(\"*********** Label Thumbnail Processor...\")\n dst = Tempfile.new([@basename, @format].compact.join(\".\"))\n dst.binmode\n\n # first create the name text image\n nameImg = createText(name, \"72\", \"\")\n\n # next create the description text image\n descImg = createText(description, \"36\", \"800x\")\n\n # next create the blend text image\n blendImg = createText(blend, \"72\", \"\")\n\n # now composite name text onto comp\n comp = compositeFiles(nameImg, @file, \"820x100!+40+40\")\n\n # now composite blend text onto comp\n comp2 = compositeFiles(blendImg, comp, \"810x50!+50+1050\")\n\n #now composite the description onto the dst\n dst = compositeFiles(descImg, comp2, \"820x300+50+865\")\n\n if generate_tin_image\n dst = compositeFiles(dst, tin_path, \"332x436!+234+139\")\n dst = compositeFiles(tin_fade_path, dst, \"800x800!+0+0\")\n end\n \n dst\n end",
"def index\n @image_to_parts = ImageToPart.all\n end",
"def convert_frames\n MiniMagick.configure do |config|\n config.validate_on_create = false\n end\n\n Dir[\"#{templates_path}/**/*.psd\"].each do |psd|\n resulting_path = psd.gsub('.psd', '.png')\n next if File.exist?(resulting_path)\n\n UI.important \"Converting PSD file '#{psd}'\"\n image = MiniMagick::Image.open(psd)\n\n if psd =~ /iPhone-SE/\n UI.success \"Removing white background 🚫 ⬜️\"\n\n # The iPhone-SE screenshots from April 2016 have\n # 3 layers, a background, a product, and the 'put your image here' layer\n # imagemagick seems to add an additional layer with no label which this the\n # composite of all three. We want to remove the background and composite layer\n good_layers = image.layers.reject do |layer|\n label = layer.details['Properties']['label']\n label.to_s.length == 0 || label =~ /White B/i\n end\n product_layer = good_layers.shift\n\n good_layers.each do |layer|\n product_layer.layers << layer\n end\n\n image = product_layer\n end\n\n if image\n image.format 'png'\n image.trim\n\n image.write(resulting_path)\n else\n UI.error \"Could not parse PSD file at path '#{psd}'\"\n end\n end\n end",
"def reboot\n img = ['blue_flower', 'red_flower', 'white_flower', 'pink_flower'].sample\n @image = Gosu::Image.new window, 'images/flowers/' + img +'.png', true\n @drawing = true\n end",
"def make\n Paperclip.log(\"*********** Product is custom! Compositing...\")\n nameImg = createText(productName, \"36\", \"\")\n\n # next create the description text image\n descImg = createText(productDescription, \"18\", \"400x\")\n\n # next create the blend text image\n blendImg = createText(productBlend, \"36\", \"\")\n\n # now composite name text onto template\n dst = compositeFiles(nameImg, label_image_remote_url.blank? ? label_template_path : file , \"410x50!+20+20\")\n\n # now composite blend text onto comp\n dst = compositeFiles(blendImg, dst, \"405x25!+25+525\")\n\n # now composite the description onto the dst\n dst = compositeFiles(descImg, dst, \"400x93!+25+433\")\n\n # now composite the image onto the label\n if label_image_remote_url.blank?\n dst = compositeFiles(file, dst, \"411x314!+21+86\")\n end\n\n if generate_tin_image\n dst = compositeFiles(dst, tin_path, \"249x327!+176+104\")\n dst = compositeFiles(tin_fade_path, dst, \"600x600!+0+0\")\n end\n\n dst\n end",
"def take\n check\n `adb pull /dev/graphics/fb0 fb0`\n `dd bs=1920 count=800 if=fb0 of=fb0b`\n `ffmpeg -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -s 480x800 -i fb0 -f image2 -vcodec png #{@destination_folder}/#{@prefix}#{@no}.png`\n `rm fb0b`\n end",
"def create_dd_image(drive_path, image_output_location)\n ## Make DD image\n @colour.notify \"Creating dd image with path #{image_output_location}.raw\"\n @colour.notify 'This may take a while:'\n @colour.notify \"Raw image #{image_output_location}.raw created\" if system \"aBoxManage clonemedium disk '#{drive_path}' '#{image_output_location}.raw' --format RAW\"\nend",
"def prepare_image_apria\n images = []\n if @sitecode == \"00Q49\" # site code for DAP\n single_page_images = convert_multipage_to_singlepage\n single_page_images.each_with_index do |image_file, index|\n new_file_name = rename_image_for_dap(image_file, index)\n File.rename(image_file, new_file_name)\n @image_folder = Dir.glob(\"#{@location}/**/#{config['IMAGE']['image_folder']}*\", File::FNM_CASEFOLD)\n image = ImagesForJob.new :image => File.open(\"#{new_file_name}\",\"rb\")\n image.image_file_name = File.basename(new_file_name)\n image.is_splitted_image = true\n image = update_image image\n images << image\n end\n else\n image = ImagesForJob.new\n parse_values(\"IMAGE\", image)\n image_path = @image_folder.detect{|image_string| image_string.downcase == \"#{@image_path}/#{image.image_file_name}\".downcase}\n image.image = File.open(image_path, \"rb\")\n image_file_name = image.image_file_name.strip.split(\"\\\\\").last unless image.image_file_name.blank?\n path = Dir.glob(\"#{@location}/**/#{image_file_name}\").first\n count = %x[identify \"#{path}\"].split(image_file_name).length-1\n new_image_name = File.basename(\"#{path}\")\n if count>1\n dir_location = File.dirname(\"#{path}\")\n ext_name = File.extname(\"#{path}\")\n new_image_base_name = new_image_name.chomp(\"#{ext_name}\")\n if ((not ext_name.empty?) and (ext_name.casecmp(\".pdf\") == 0) ) then\n system \"pdftk '#{path}' burst output '#{dir_location}/#{new_image_base_name}_%d#{ext_name}'\"\n for image_count in 1..count\n image = ImagesForJob.new(:image_file_name=>\"#{new_image_base_name}_#{image_count}#{ext_name}\",:is_splitted_image=>true)\n image = update_image image\n images << image\n end\n else\n InputBatch.split_image(count,path, dir_location, new_image_base_name)\n single_images = Dir.glob(\"#{@location}/**/*\").select{|file| InputBatch.get_single_image(file, new_image_base_name)}.sort\n single_images.each_with_index do |single_image, index|\n new_image_name = \"#{dir_location}/#{new_image_base_name}_#{index}#{ext_name}\"\n File.rename(single_image, new_image_name)\n image = ImagesForJob.create(:image => File.open(new_image_name), :image_number => @img_count, :is_splitted_image=>true)\n @img_count += 1\n images << image\n end\n end\n else\n image = ImagesForJob.new(:image_file_name=>\"#{new_image_name}\")\n image = update_image image\n images << image\n end\n end\n return images\n end",
"def AddMountPointsForWinParts(partitions, primary, max_prim, foreign_nr)\n partitions = deep_copy(partitions)\n return if !Arch.i386 && !Arch.ia64 && !Arch.x86_64\n\n foreign_ids = \"CDEFGHIJKLMNOPQRSTUVW\"\n\n Builtins.foreach(partitions) do |partition|\n new_partition = deep_copy(partition)\n fsid = Ops.get_integer(partition, \"fsid\", Partitions.fsid_native)\n partnum = 0\n if Builtins.haskey(partition, \"nr\") &&\n Ops.is_integer?(Ops.get(partition, \"nr\", 0))\n partnum = Ops.get_integer(partition, \"nr\", 0)\n end\n if !Builtins.haskey(partition, \"mount\") &&\n !Ops.get_boolean(partition, \"delete\", false) &&\n Ops.less_or_equal(partnum, max_prim) == primary &&\n Ops.less_than(foreign_nr.value, 24) &&\n Partitions.IsDosWinNtPartition(fsid) &&\n !Arch.ia64 &&\n !IsEfiPartition(partition) &&\n Ops.greater_or_equal(\n Ops.get_integer(partition, \"size_k\", 0),\n 1024 * 1024\n ) &&\n Builtins.contains(\n [:vfat, :ntfs],\n Ops.get_symbol(partition, \"used_fs\", :none)\n )\n Ops.set(\n new_partition,\n \"fstopt\",\n FileSystems.DefaultFstabOptions(partition)\n )\n if Builtins.contains(Partitions.fsid_dostypes, fsid)\n Ops.set(\n new_partition,\n \"mount\",\n Ops.add(\n \"/dos/\",\n Builtins.substring(foreign_ids, foreign_nr.value, 1)\n )\n )\n foreign_nr.value = Ops.add(foreign_nr.value, 1)\n else\n Ops.set(\n new_partition,\n \"mount\",\n Ops.add(\n \"/windows/\",\n Builtins.substring(foreign_ids, foreign_nr.value, 1)\n )\n )\n foreign_nr.value = Ops.add(foreign_nr.value, 1)\n end\n ChangeVolumeProperties(new_partition)\n Builtins.y2milestone(\"win part %1\", new_partition)\n end\n end\n\n nil\n end",
"def make_partition_list(withall, flavor)\n part_list = []\n Builtins.foreach(RootPart.rootPartitions) do |partition, i|\n # see https://bugzilla.novell.com/attachment.cgi?id=96783&action=view\n\n # see bugzilla #288201\n # architecture needs to be valid when updating, not booting\n arch_is_valid = flavor == :boot ?\n true :\n Ops.get_boolean(i, :arch_valid, false)\n if withall || Ops.get_boolean(i, :valid, false) && arch_is_valid\n # `ext2, `jfs, ...\n part_fs = Ops.get_symbol(i, :fs)\n part_fs_name = Builtins.tostring(part_fs)\n if part_fs_name != nil &&\n Builtins.regexpmatch(part_fs_name, \"^`(.*)$\")\n part_fs_name = Builtins.regexpsub(part_fs_name, \"^`(.*)$\", \"\\\\1\")\n end\n\n system = Ops.get_string(i, :name, \"error\")\n # unknown system\n if system == \"unknown\"\n if part_fs != nil\n if CanBeLinuxRootFS(part_fs)\n # Table item (unknown system)\n system = _(\"Unknown Linux\")\n else\n # Table item (unknown system)\n system = _(\"Unknown or Non-Linux\")\n end\n else\n # Table item (unknown system [neither openSUSE 11.1 nor SLES 14 nor ...])\n system = _(\"Unknown\") if system == \"unknown\"\n end\n end\n\n arch = Ops.get_string(i, :arch, \"error\")\n # Table item (unknown architecture)\n arch = _(\"Unknown\") if arch == \"unknown\"\n\n # fist, use the name of file system (with short name for Linux)\n # then the file system short name\n # then \"Unknown\"\n fs = \"\"\n\n # is a linux fs, can be a root fs, has a fs name\n if part_fs != nil && Ops.get(i, :fstype) != nil &&\n CanBeLinuxRootFS(part_fs) &&\n part_fs_name != nil\n fs = Builtins.sformat(\n _(\"%1 (%2)\"),\n Ops.get_string(i, :fstype, \"\"),\n part_fs_name\n )\n else\n fs = Ops.get_string(i, :fstype, Ops.get_string(i, :fs, \"\"))\n end\n # Table item (unknown file system)\n fs = _(\"Unknown\") if fs == \"\"\n\n label = Ops.get_string(i, :label, \"\")\n\n part_list = Builtins.add(\n part_list,\n Item(Id(partition), system, partition, arch, fs, label)\n )\n end\n end\n deep_copy(part_list)\n end",
"def generate_wallpaper\n if self.order.uncommon_order?\n begin\n rand_id = rand(999999).to_s\n image = MiniMagick::Image.from_file(\"#{Rails.root}/public/assets/printable/#{printable_file_name}-1.jpg\")\n image.gravity('Center')\n image.rotate(90)\n image.resize('400x600^')\n image.crop('320x480+40+120')\n image.write(\"#{Rails.root}/tmp/#{rand_id}.jpg\")\n File.open(\"#{Rails.root}/tmp/#{rand_id}.jpg\", 'rb') { |image| self.wallpaper = image }\n File.delete(\"#{Rails.root}/tmp/#{rand_id}.jpg\")\n self.save\n rescue Exception => e\n UncommonHoptoad::notify(\"Error generating wallpaper for #{id}\",\"Error: #{e.message}\", \"Failed to generate wallpaper for order_item #{self.id}\")\n end\n end\n end",
"def get_partition_info\n # remove leading slash so it matches the packages.DU path\n remove_slash = true\n\n if !Stage.initial\n # read /proc/mounts as a list of maps\n # $[\"file\":\"/boot\", \"freq\":0, \"mntops\":\"rw\", \"passno\":0, \"spec\":\"/dev/sda1\", \"vfstype\":\"ext2\"]\n mounts = Convert.convert(\n SCR.Read(path(\".proc.mounts\")),\n :from => \"any\",\n :to => \"list <map <string, any>>\"\n )\n Builtins.y2milestone(\"mounts %1\", mounts)\n\n partitions = []\n Builtins.foreach(mounts) do |mpoint|\n name = Ops.get_string(mpoint, \"file\", \"\")\n if Builtins.substring(name, 0, 1) == \"/\" &&\n Builtins.substring(name, 0, 5) != \"/dev/\" && # filter out /dev/pts etc.\n Ops.get_string(mpoint, \"vfstype\", \"\") != \"rootfs\" # filter out duplicate \"/\" entry\n capacity = Pkg.TargetCapacity(name)\n if capacity != 0 # dont look at pseudo-devices (proc, shmfs, ...)\n used = Pkg.TargetUsed(name)\n partitions = Builtins.add(\n partitions,\n {\n \"name\" => name,\n \"free\" => Ops.subtract(capacity, used),\n \"used\" => used\n }\n )\n end\n end\n end\n Pkg.TargetInitDU(partitions)\n Builtins.y2milestone(\"get_partition_info: %1\", partitions)\n return deep_copy(partitions)\n end # !Stage::initial ()\n\n # remove the previous failures\n @failed_mounts = []\n\n # installation stage - Storage:: is definitely present\n # call Storage::GetTargetMap()\n targets = Convert.convert(\n WFM.call(\"wrapper_storage\", [\"GetTargetMap\"]),\n :from => \"any\",\n :to => \"map <string, map>\"\n )\n\n if targets == nil\n Builtins.y2error(\"Target map is nil, Storage:: is probably missing\")\n end\n\n if Mode.test\n targets = Convert.convert(\n SCR.Read(path(\".target.yast2\"), \"test_target_map.ycp\"),\n :from => \"any\",\n :to => \"map <string, map>\"\n )\n end\n\n target_partitions = []\n min_spare = 20 * 1024 * 1024 # minimum free space ( 20 MB )\n\n Builtins.foreach(targets) do |disk, diskinfo|\n part_info = Ops.get_list(diskinfo, \"partitions\", [])\n Builtins.foreach(part_info) do |part|\n Builtins.y2milestone(\"Adding partition: %1\", part)\n used_fs = Ops.get_symbol(part, \"used_fs\", :unknown)\n # ignore VFAT and NTFS partitions (bnc#)\n if used_fs == :vfat || used_fs == :ntfs\n Builtins.y2warning(\n \"Ignoring partition %1 with %2 filesystem\",\n Ops.get_string(part, \"device\", \"\"),\n used_fs\n )\n else\n free_size = 0\n\n if Ops.get(part, \"mount\") != nil &&\n Builtins.substring(Ops.get_string(part, \"mount\", \"\"), 0, 1) == \"/\"\n if Ops.get(part, \"create\") == true ||\n Ops.get(part, \"delete\") == false ||\n Ops.get(part, \"create\") == nil &&\n Ops.get(part, \"delete\") == nil\n Builtins.y2debug(\n \"get_partition_info: adding partition: %1\",\n part\n )\n\n # get free_size on partition in kBytes\n free_size = Ops.multiply(\n Ops.get_integer(part, \"size_k\", 0),\n 1024\n )\n free_size = Ops.subtract(free_size, min_spare)\n\n # free_size smaller than min_spare, fix negative value\n if Ops.less_than(free_size, 0)\n Builtins.y2milestone(\"Fixing free size: %1 to 0\", free_size)\n free_size = 0\n end\n\n used = 0\n if !(Ops.get_boolean(part, \"create\", false) ||\n Ops.get_boolean(part, \"format\", false))\n tmpdir = Convert.to_string(SCR.Read(path(\".target.tmpdir\")))\n tmpdir = Ops.add(tmpdir, \"/diskspace_mount\")\n SCR.Execute(\n path(\".target.bash\"),\n Builtins.sformat(\"test -d %1 || mkdir -p %1\", tmpdir)\n )\n\n # mount in read-only mode (safer)\n mount_options = [\"ro\"]\n\n # add \"nolock\" if it's a NFS share (bnc#433893)\n if used_fs == :nfs\n Builtins.y2milestone(\"Mounting NFS with 'nolock' option\")\n mount_options = Builtins.add(mount_options, \"nolock\")\n end\n\n # join the options\n mount_options_str = Builtins.mergestring(mount_options, \",\")\n\n mount_command = Builtins.sformat(\n \"/bin/mount -o %1 %2 %3\",\n mount_options_str,\n Ops.get_string(part, \"device\", \"\"),\n tmpdir\n )\n\n Builtins.y2milestone(\n \"Executing mount command: %1\",\n mount_command\n )\n\n result = Convert.to_integer(\n SCR.Execute(path(\".target.bash\"), mount_command)\n )\n Builtins.y2milestone(\"Mount result: %1\", result)\n\n if result == 0\n partition = Convert.convert(\n SCR.Read(path(\".run.df\")),\n :from => \"any\",\n :to => \"list <map <string, string>>\"\n )\n Builtins.foreach(partition) do |p|\n if Ops.get_string(p, \"name\", \"\") == tmpdir\n Builtins.y2internal(\"P: %1\", p)\n free_size = Ops.multiply(\n Builtins.tointeger(Ops.get_string(p, \"free\", \"0\")),\n 1024\n )\n used = Ops.multiply(\n Builtins.tointeger(Ops.get_string(p, \"used\", \"0\")),\n 1024\n )\n end\n end\n SCR.Execute(\n path(\".target.bash\"),\n Builtins.sformat(\"/bin/umount %1\", tmpdir)\n )\n else\n Builtins.y2error(\n \"Mount failed, ignoring partition %1\",\n Ops.get_string(part, \"device\", \"\")\n )\n @failed_mounts = Builtins.add(@failed_mounts, part)\n\n next\n end\n else\n # for formatted partitions estimate free system size\n # compute fs overhead\n used = EstimateFsOverhead(part)\n\n if Ops.greater_than(used, 0)\n Builtins.y2milestone(\n \"Partition %1: assuming fs overhead: %2kB\",\n Ops.get_string(part, \"device\", \"\"),\n Ops.divide(used, 1024)\n )\n end\n\n # journal size\n js = 0\n\n if ExtFs(used_fs)\n js = ExtJournalSize(part)\n reserved = ReservedSpace(part)\n\n if Ops.greater_than(reserved, 0)\n used = Ops.add(used, reserved)\n end\n elsif used_fs == :xfs\n js = XfsJournalSize(part)\n elsif used_fs == :reiser\n js = ReiserJournalSize(part)\n elsif used_fs == :jfs\n js = JfsJournalSize(part)\n else\n Builtins.y2warning(\n \"Unknown journal size for filesystem: %1\",\n used_fs\n )\n end\n\n if Ops.greater_than(js, 0)\n Builtins.y2milestone(\n \"Partition %1: assuming journal size: %2kB\",\n Ops.get_string(part, \"device\", \"\"),\n Ops.divide(js, 1024)\n )\n used = Ops.add(used, js)\n end\n\n # decrease free size\n free_size = Ops.subtract(free_size, used)\n\n # check for underflow\n if Ops.less_than(free_size, 0)\n Builtins.y2milestone(\"Fixing free size: %1 to 0\", free_size)\n free_size = 0\n end\n end\n\n # convert into kB for TargetInitDU\n free_size = Ops.divide(free_size, 1024)\n used = Ops.divide(used, 1024)\n\n Builtins.y2milestone(\n \"available partition: mount: %1, free: %2 KB, used: %3 KB\",\n Ops.get_string(part, \"mount\", \"\"),\n free_size,\n used\n )\n if !remove_slash\n target_partitions = Builtins.add(\n target_partitions,\n {\n \"name\" => Ops.get_string(part, \"mount\", \"\"),\n \"used\" => used,\n \"free\" => free_size\n }\n )\n else\n part_name = \"\"\n mount_name = Ops.get_string(part, \"mount\", \"\")\n\n if mount_name != \"/\"\n part_name = Builtins.substring(\n mount_name,\n 1,\n Builtins.size(mount_name)\n )\n else\n part_name = mount_name\n end\n\n target_partitions = Builtins.add(\n target_partitions,\n { \"name\" => part_name, \"used\" => used, \"free\" => free_size }\n )\n end\n end\n end\n end\n end # foreach (`part)\n end # foreach (`disk)\n\n # add estimated size occupied by non-package files\n target_partitions = EstimateTargetUsage(target_partitions)\n\n Builtins.y2milestone(\"get_partition_info: part %1\", target_partitions)\n Pkg.TargetInitDU(target_partitions)\n\n deep_copy(target_partitions)\n end",
"def gen_partition_script(number_of_volumes, mount_point_prefix, resize_root_vol = false)\n resize_root = resize_root_vol ? 0 : 1\n template = <<-END.gsub(/^ {6}/, '')\n #!/bin/bash\n RESIZE_ROOT=<%= resize_root %>\n if [ $RESIZE_ROOT -eq 0 ]; then\n echo \"Resizing the root partition\"\n resize2fs /dev/`cat /proc/partitions | awk '/xvd*/ {print $4}' | head -n1`\n fi\n NUM_OF_VOLS=<%= number_of_volumes %>\n if [ $NUM_OF_VOLS -ne 0 ]; then\n DEVICES=`cat /proc/partitions | awk '/xvd*/ {print $4}' | tail -n<%= number_of_volumes %>`\n echo \"Formatting and mounting initiated\"\n count=1\n for dev in $DEVICES; do\n echo \"Formatting and mounting $dev\"\n fdisk -u /dev/$dev << EOF\n n\n p\n 1\n\n\n w\n EOF\n mkfs.ext4 /dev/${dev}1\n data_dir=$((count++))\n mkdir -p <%= mount_point_prefix %>/${data_dir}\n mount /dev/${dev}1 <%= mount_point_prefix %>${data_dir}\n done\n fi\n END\n ERB.new(template).result(binding)\n end",
"def bootloader_partitions\n raise RuntimeError, \"Not implemented in base class\"\n end",
"def make_forensic_image(options)\n drive_path = %x(VBoxManage list hdds | grep '#{options[:project_dir].split('/').last}').sub(/\\ALocation:\\s*/, '').sub(/\\n/, '')\n # drive_path = %x(VBoxManage list hdds | grep '#{options[:project_dir].split('/').last}').sub(/\\ALocation:\\s*|\\n\\Z/, '')\n drive_name = drive_path.split('/').last\n\n options[:image_output_location] = \"#{options[:project_dir]}/#{drive_name}\".sub(/.vmdk|.vdi/, '') unless options.has_key? :image_output_location\n\n unless options.has_key? :no_vm_shutdown\n ## Ensure all vms are shutdown\n system \"cd '#{options[:project_dir]}' && vagrant halt\"\n\n if options.has_key? :create_raw_image\n create_dd_image(drive_path, options[:image_output_location])\n end\n\n if options.has_key? :create_ewf_image\n create_ewf_image(drive_path, options[:image_output_location])\n end\n\n if options.has_key? :delete_vm_after_image_creation\n delete_virtualbox_vm(options[:vm_name])\n end\n else\n @colour.error 'Cannot create forensic image as --no-vm-shutdown option is set to true'\n end\n\n return options\nend",
"def generate_wd_images rname=nil\n return {} unless rname\n \n start_time = Time.now\n \n @selected_room_name = rname\n @room_name = @selected_room_name.gsub('#', '_')\n # rinfo \"Starting Image generation : %s\"%(@selected_room_name)\n\n #Pre Operation things\n exception_raised = false\n #-----------Get previous stuffs--------------------------\n curr_active_layer = Sketchup.active_model.active_layer\n edge_render_option = Sketchup.active_model.rendering_options[\"EdgeColorMode\"]\n active_camera = Sketchup.active_model.active_view.camera\n cam_perspective = Sketchup.active_model.active_view.camera.perspective?\n unit_display = Sketchup.active_model.options[\"UnitsOptions\"][\"SuppressUnitsDisplay\"]\n\n Sketchup.active_model.options[\"UnitsOptions\"][\"SuppressUnitsDisplay\"]=true\n Sketchup.active_model.active_view.camera.perspective=false\n Sketchup.active_model.rendering_options[\"EdgeColorMode\"] = 0\n \n begin\n # puts \"--------------------------hide\"\n Sketchup::active_model::start_operation \"RIO Image Generation\"\n DP::hide_all_entities\n\n view_details_h = get_floor_view_comps\n \n view_details_h[\"top_view\"] = {:top_room_image => get_top_room_image}\n rescue Exception => e\n # rerror \"Exception raised during image generation\"\n raise e\n Sketchup.active_model.abort_operation\n exception_raised = true\n ensure\n DP::unhide_all_entities\n\n Sketchup.active_model.rendering_options[\"EdgeColorMode\"] = edge_render_option\n Sketchup.active_model.options[\"UnitsOptions\"][\"SuppressUnitsDisplay\"]=unit_display\n Sketchup.active_model.active_view.camera=active_camera\n Sketchup.active_model.active_view.camera.perspective=cam_perspective\n Sketchup.active_model.active_view.zoom_extents\n Sketchup.active_model.commit_operation\n end\n\n end_time = Time.now\n # puts \"Time taken : #{end_time - start_time}\"\n result = exception_raised ? {} : view_details_h\n end",
"def show_parts(device)\n action_parts(device, '-s -av')\n end",
"def create_frame_and_thumbnail\n if (File.extname(self.image_sequence) == \".mha\")\n file_path = Rails.root.join(dir_path, self.image_sequence)\n result = system(Rails.root.join('scripts','mha_to_png','bin',\"MhaToPng #{file_path} 1\").to_s)\n base_name = File.basename(file_path, \".mha\")\n image = MiniMagick::Image.open(\"#{dir_path}/#{base_name}_frame.png\")\n image.resize \"200x200\"\n image.format \"png\"\n image.write \"#{dir_path}/#{base_name}_thumbnail.png\"\n File.chmod(0644, \"#{dir_path}/#{base_name}_thumbnail.png\")\n self.thumbnail = \"#{base_name}_thumbnail.png\"\n self.frame = \"#{base_name}_frame.png\"\n end\n end",
"def setup_lvm_on_partition(part)\n return unless part.lvm\n\n pvol = \"/dev/disk/by-partlabel/#{part.label}\"\n execute!(\"pvcreate -y #{pvol}\")\n execute!(\"vgcreate -y #{part.lvm.vg_name} #{pvol}\")\n\n # any \"open ended\" volumes (no size specified), we deal with last\n unspec_vol = nil\n\n notice(\"Creating LVM partitions\")\n part.lvm.volumes.each do |vol|\n if not vol.size_mb.is_a?(Integer)\n unspec_vol = vol\n next\n end\n\n info(\"Creating #{vol.label} volume\")\n execute!(\"lvcreate -y --name #{vol.label} --size #{vol.size_mb}MiB #{part.lvm.vg_name}\")\n next if not vol.fs\n\n create_filesystem(vol.fs, \"/dev/#{part.lvm.vg_name}/#{vol.label}\", vol.label)\n end\n\n if unspec_vol\n vol = unspec_vol\n info(\"Creating #{vol.label} volume\")\n execute!(\"lvcreate -y --name #{vol.label} -l 100%FREE #{part.lvm.vg_name}\")\n if vol.fs\n create_filesystem(vol.fs, \"/dev/#{part.lvm.vg_name}/#{vol.label}\", vol.label)\n end\n end\n end",
"def copy_js_sparc_boot_images(options)\n boot_list=[]\n options['tftpdir']=\"/tftpboot\"\n boot_list.push(\"sun4u\")\n if options['version'] == \"10\"\n boot_list.push(\"sun4v\")\n end\n boot_list.each do |boot_arch|\n boot_file = options['repodir']+\"/Solaris_\"+options['version']+\"/Tools/Boot/platform/\"+boot_arch+\"/inetboot\"\n tftp_file = options['tftpdir']+\"/\"+boot_arch+\".inetboot.sol_\"+options['version']+\"_\"+options['update']\n if not File.exist?(boot_file)\n message = \"Information:\\tCopying boot image \"+boot_file+\" to \"+tftp_file\n command = \"cp #{boot_file} #{tftp_file}\"\n execute_command(options,message,command)\n end\n end\n return\nend",
"def create_image_from_screenshot\n type = @desktop_image.split(/\\./).last\n `screencapture -t#{type} -x #@desktop_image`\n end",
"def copy_js_sparc_boot_images(repo_version_dir,os_version,os_update)\n boot_list=[]\n tftp_dir=\"/tftpboot\"\n boot_list.push(\"sun4u\")\n if os_version == \"10\"\n boot_list.push(\"sun4v\")\n end\n boot_list.each do |boot_arch|\n boot_file = repo_version_dir+\"/Solaris_\"+os_version+\"/Tools/Boot/platform/\"+boot_arch+\"/inetboot\"\n tftp_file = tftp_dir+\"/\"+boot_arch+\".inetboot.sol_\"+os_version+\"_\"+os_update\n if !File.exist?(boot_file)\n message = \"Copying:\\tBoot image \"+boot_file+\" to \"+tftp_file\n command = \"cp #{boot_file} #{tftp_file}\"\n execute_command(message,command)\n end\n end\n return\nend",
"def resizePngs\n destination=\"./Convert/\"\n search_for=[\"*.png\"]\n \n @files=readDirectoryFiles(destination,search_for)\n @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)\n @viewport.z=999999\n \n @bar=Sprite.new(@viewport)\n @bar.bitmap=Bitmap.new(Graphics.width,34)\n pbSetSystemFont(@bar.bitmap)\n \n for i in 0...@files.length\n @files[i]=@files[i].gsub(/.png/) {\"\"}\n end\n \n return false if !Kernel.pbConfirmMessage(_INTL(\"There is a total of #{@files.length} PNG(s) available for conversion. Would you like to begin the process?\"))\n for i in 0...@files.length\n file=@files[i]\n \n width=((i*1.000)/@files.length)*Graphics.width\n @bar.bitmap.clear\n @bar.bitmap.fill_rect(0,0,Graphics.width,34,Color.new(255,255,255))\n @bar.bitmap.fill_rect(0,0,Graphics.width,32,Color.new(0,0,0))\n @bar.bitmap.fill_rect(0,0,width,32,Color.new(25*4,90*2,25*4))\n text=[[\"#{i}/#{@files.length}\",Graphics.width/2,2,2,Color.new(255,255,255),nil]]\n pbDrawTextPositions(@bar.bitmap,text)\n \n next if RTP.exists?(\"#{destination}New/#{file}.png\")\n \n sprite=pbBitmap(\"#{destination}#{file}.png\")\n width=sprite.width\n height=sprite.height\n \n bitmap=Bitmap.new(width/2,height/2)\n bitmap.stretch_blt(Rect.new(0,0,width/2,height/2),sprite,Rect.new(0,0,width,height))\n bitmap.saveToPng(\"#{destination}New/#{file}.png\")\n sprite.dispose\n pbWait(1)\n RPG::Cache.clear\n end\n @bar.dispose\n @viewport.dispose\n Kernel.pbMessage(_INTL(\"Done!\"))\nend",
"def test03()\n sourceMovie = File.join($directory, \"images/604_sd_clip.mov\") # 576x360\n width = 576\n height = 360\n movieLength = 300.0 # seconds.\n borderWidth = 32\n bitmapWidth = (3.0 * width.to_f * 0.5 + (3+1) * borderWidth).to_i\n bitmapHeight = (4.0 * height.to_f * 0.5 + (4+1) * borderWidth).to_i\n bitmapSize = MIShapes.make_size(bitmapWidth, bitmapHeight)\n baseFileName = \"coversheet\"\n begin\n # 1. Create the list of commands object, ready to have commands added to it.\n theCommands = SmigCommands.new\n theCommands.saveresultstype = :lastcommandresult\n\n # 2. Create movie importer and assign to list of commands.\n # Basically after the first block of commands is run, the movie importer\n # is closed automatically in the cleanup commands.\n movieImporterName = SecureRandom.uuid\n movieObject = theCommands.make_createmovieimporter(sourceMovie,\n name: movieImporterName)\n \n # 3. Create the process movie frames command and configure.\n imageIdentifier = SecureRandom.uuid\n\n processFramesCommand = ProcessFramesCommand.new(movieObject)\n processFramesCommand.create_localcontext = false\n processFramesCommand.imageidentifier = imageIdentifier\n\n track_id = MovieTrackIdentifier.make_movietrackid_from_mediatype(\n mediatype: :vide, trackindex: 0)\n \n processFramesCommand.videotracks = [ track_id ]\n\n # 4. Make a pre-process command list.\n preProcessCommands = []\n \n # 5. Make a create a bitmap context command.\n bitmapName = SecureRandom.uuid\n createBitmapCommand = CommandModule.make_createbitmapcontext(\n name: bitmapName, size: bitmapSize)\n\n bitmapObject = SmigIDHash.make_objectid(objecttype: :bitmapcontext,\n objectname: bitmapName)\n\n # 6. Add the create bitmap context object command to the pre-process list.\n preProcessCommands.push(createBitmapCommand.commandhash)\n\n # 7. Make a create exporter object command and add it to the pre-process list\n exporterName = SecureRandom.uuid\n createExporterCommand = CommandModule.make_createexporter(\n \"~/placeholder.jpg\", export_type: 'public.jpeg', name: exporterName)\n preProcessCommands.push(createExporterCommand.commandhash)\n exporterObject = SmigIDHash.make_objectid(objecttype: :imageexporter,\n objectname: exporterName)\n\n # 8. Assign the pre-process commands to the process movie frames command.\n processFramesCommand.preprocesscommands = preProcessCommands\n \n # 9. Add a close bitmap object command to cleanup commands.\n processFramesCommand.add_tocleanupcommands_closeobject(bitmapObject)\n \n # 10. Add a close exporter object command to cleanup commands.\n processFramesCommand.add_tocleanupcommands_closeobject(exporterObject)\n\n # 11. Add a remove image from collection command to cleanup commands.\n processFramesCommand.add_tocleanupcommands_removeimage(imageIdentifier)\n\n # 12. Prepare and start looping for creating process frame instrutions.\n numFrames = 24\n framesPerPage = 12 # 3 x 4\n frameDuration = movieLength / (numFrames - 1)\n pageNumber = 0\n x = 0\n y = 0\n halfWidth = width / 2\n halfHeight = height / 2\n drawnFrameSize = MIShapes.make_size(halfWidth, halfHeight)\n textBoxSize = MIShapes.make_size(halfWidth, borderWidth * 3 / 4)\n filesToCompare = []\n numFrames.times do |i|\n # 13. Create a ProcessMovieFrameInstruction object\n frameInstructions = ProcessMovieFrameInstructions.new\n \n # 14. Calculate the frame time and assign it.\n time = i.to_f * frameDuration\n frameTime = MovieTime.make_movietime_fromseconds(time)\n frameInstructions.frametime = frameTime\n \n # 15. Determine the frame number on the page & destination rectangle.\n frameNumber = i % framesPerPage\n x = frameNumber % 3\n y = 3 - (frameNumber / 3)\n xloc = x * halfWidth + (x + 1) * borderWidth\n yloc = y * halfHeight + (y + 1) * borderWidth\n origin = MIShapes.make_point(xloc, yloc)\n drawnFrameRect = MIShapes.make_rectangle(size: drawnFrameSize,\n origin: origin)\n \n # 16. Create the draw image element to draw the frame onto the bitmap.\n drawImageElement = MIDrawImageElement.new()\n drawImageElement.destinationrectangle = drawnFrameRect\n drawImageElement.set_imagecollection_imagesource(identifier: imageIdentifier)\n \n # 17. Create the draw image command and add it to the frame instructions.\n drawImageCommand = CommandModule.make_drawelement(bitmapObject,\n drawinstructions: drawImageElement, createimage: false)\n frameInstructions.add_command(drawImageCommand)\n \n # 18. Prepare drawing the text with the time.\n timeString = \"Frame time: %.3f secs\" % time\n drawStringElement = MIDrawBasicStringElement.new()\n drawStringElement.stringtext = timeString\n drawStringElement.userinterfacefont = \"kCTFontUIFontLabel\"\n drawStringElement.textalignment = \"kCTTextAlignmentCenter\"\n drawStringElement.fillcolor = MIColor.make_rgbacolor(0.0, 0.0, 0.0)\n boxOrigin = MIShapes.make_point(xloc, yloc - borderWidth)\n boundingBox = MIShapes.make_rectangle(size: textBoxSize, origin: boxOrigin)\n drawStringElement.boundingbox = boundingBox\n drawTextCommand = CommandModule.make_drawelement(bitmapObject,\n drawinstructions: drawStringElement, createimage: false)\n frameInstructions.add_command(drawTextCommand)\n\n # 19. If this was the last frame to be drawn then export the page.\n if (frameNumber == framesPerPage - 1) || i == numFrames - 1\n addImageCommand = CommandModule.make_addimage(exporterObject, bitmapObject)\n frameInstructions.add_command(addImageCommand)\n pageNum = (i / 12).to_s.rjust(3, '0')\n fileName = baseFileName + pageNum + \".jpg\"\n filesToCompare.push(fileName)\n# filePath = File.join($compareImageDir, fileName)\n filePath = File.join(Dir.tmpdir(), fileName)\n setExportPathCommand = CommandModule.make_set_objectproperty(\n exporterObject,\n propertykey: :file,\n propertyvalue: filePath)\n frameInstructions.add_command(setExportPathCommand)\n exportCommand = CommandModule.make_export(exporterObject)\n frameInstructions.add_command(exportCommand)\n # 20. Now redraw the bitmap context with a white rectangle.\n redrawBitmapElement = MIDrawElement.new(:fillrectangle)\n redrawBitmapElement.fillcolor = MIColor.make_rgbacolor(1.0, 1.0, 1.0)\n redrawBitmapElement.rectangle = MIShapes.make_rectangle(size: bitmapSize)\n redrawCommand = CommandModule.make_drawelement(bitmapObject,\n drawinstructions: redrawBitmapElement)\n frameInstructions.add_command(redrawCommand)\n end\n # 21. Set the frame processing intructions to the process frames command.\n processFramesCommand.add_processinstruction(frameInstructions)\n end\n \n # 22. Add the process frames command to the list of commands.\n theCommands.add_command(processFramesCommand)\n Smig.perform_commands(theCommands)\n\n filesToCompare.each do |fileName|\n origFile = File.join($compareImageDir, fileName)\n tempFile = File.join(Dir.tmpdir(), fileName)\n# tempFile = File.join($compareImageDir, fileName)\n compareResult = AreImageFilesSame(origFile, tempFile, 0)\n FileUtils.rm_f(tempFile)\n # FileUtils.mv(tempFile, origFile)\n unless compareResult\n # 2. Report if different.\n raise \"Different image files: \" + origFile + \" and \" + tempFile\n end\n end\n\n rescue RuntimeError => e\n $errorcode = Smig.exitvalue\n unless $errorcode.zero?\n puts \"Exit string: \" + Smig.exitstring\n puts \" Exit status: \" + $errorcode.to_s\n end\n puts e.message\n puts e.backtrace.to_s\n end\nend",
"def test01()\n imageFile = $directory + \"/images/DSCN0724.JPG\"\n baseImageName = \"croppedpaddedimage.jpg\"\n begin\n # Create the object that will contain the list of the commands\n theCommands = CommandModule::SmigCommands.new\n \n # Set the output of the command to \"lastcommandresult\" which means when the\n # list of commands is run, only the result of the last command to be run\n # is returned. If the command list is set up to stop on failure then we\n # get the result of the failed command.\n theCommands.saveresultstype = :lastcommandresult\n\n # Create the image importer object. First generate its name, \n importerName = SecureRandom.uuid\n # then create the importer with the path to the file and the name\n\n createImporterCommand = CommandModule.make_createimporter(imageFile,\n name: importerName)\n\n # Create the image importer object id so we can refer to it later on.\n imageImporterObject = SmigIDHash.make_objectid(objecttype: :imageimporter,\n objectname: importerName)\n theCommands.add_command(createImporterCommand)\n\n # The cleanup commands are run after completion of the main command list.\n # They run whether the main command list ran without error or not.\n # They return no information, all commands in the cleanup command list are\n # run no matter whether an earlier command in the clean up list failed or\n # or not.\n theCommands.add_tocleanupcommands_closeobject(imageImporterObject)\n\n # Create the bitmap context object. First generate its name.\n bitmapContextName = SecureRandom.uuid\n\n # Use spotlight to find out the dimensions of the original image so\n # we can create the appropriate sized bitmap context.\n imageDimensions = SpotlightCommand.get_imagedimensions(imageFile)\n createBitmapContextCommand = CommandModule.make_createbitmapcontext(\n size: imageDimensions,\n# width: imageDimensions[0],\n# height: imageDimensions[1],\n preset: \"AlphaPreMulFirstRGB8bpcInt\",\n name: bitmapContextName)\n \n # Create the bitmap context object id so we can refer it later on.\n bitmapContextObject = SmigIDHash.make_objectid(objecttype: :bitmapcontext,\n objectname: bitmapContextName)\n\n # Now add the create importer and bitmap context commands to command list\n theCommands.add_command(createBitmapContextCommand)\n theCommands.add_tocleanupcommands_closeobject(bitmapContextObject)\n\n # Start preparing the drawing element action.\n theSize = MIShapes.make_size(imageDimensions[:width] * 0.5,\n imageDimensions[:height] * 0.5)\n theOrigin = MIShapes.make_point(imageDimensions[:width] * 0.25,\n imageDimensions[:height] * 0.25)\n sourceRect = MIShapes.make_rectangle(size: theSize, origin: theOrigin)\n destRect = sourceRect\n drawImageElement = MIDrawImageElement.new()\n drawImageElement.set_imagefile_imagesource(source_object: imageImporterObject,\n imageindex: 0)\n drawImageElement.sourcerectangle = sourceRect\n drawImageElement.destinationrectangle = destRect\n \n # With the draw element put together, now create the draw element command\n drawCommand = CommandModule.make_drawelement(bitmapContextObject,\n drawinstructions: drawImageElement)\n\n # Now add the draw element command to the list of commands.\n theCommands.add_command(drawCommand)\n \n # Setup the create image exporter command with a path to export the file\n # to, within the users temporary directory.\n tempFile = File.join(Dir.tmpdir(), baseImageName)\n imageExporterName = SecureRandom.uuid\n \n # Create the image exporter object command.\n createExporterCommand = CommandModule.make_createexporter(tempFile,\n export_type: \"public.jpeg\",\n name: imageExporterName)\n\n # Create the image exporter object id so we can refer it later on.\n exporterObject = SmigIDHash.make_objectid(objecttype: :imageexporter,\n objectname: imageExporterName)\n\n # Add the create image exporter object command to the list of commands.\n theCommands.add_command(createExporterCommand)\n \n # Now create the add image to image exporter object command.\n addImageToExporterCommand = CommandModule.make_addimage(\n exporterObject, bitmapContextObject)\n \n # Add the addimage to exporter object command to the list of commands.\n theCommands.add_command(addImageToExporterCommand)\n \n # Create the export image file command and add it to the list of commands.\n exportImageToFileCommand = CommandModule.make_export(exporterObject)\n theCommands.add_command(exportImageToFileCommand)\n\n theCommands.add_tocleanupcommands_closeobject(exporterObject)\n\n # Everything is set up, now perform the commands.\n commandsHash = theCommands.commandshash\n $teststring = commandsHash.to_json\n theResult = Smig.perform_commands(commandsHash)\n \n # We've generated a new image file, now compare it against one we made\n # earlier.\n origFile = File.join($compareImageDir, baseImageName)\n unless AreImageFilesSame(origFile, tempFile)\n raise \"Different image files: \" + origFile + \" and \" + tempFile\n end\n rescue RuntimeError => e\n $errorcode = Smig.exitvalue\n unless $errorcode.zero?\n puts \"Exit string: \" + Smig.exitstring\n puts $teststring + \" Exit status: \" + $errorcode.to_s\n end\n puts e.message\n puts e.backtrace.to_s\n# exit 240\n ensure\n unless tempFile.nil?\n FileUtils.rm_f(tempFile)\n # Open3.capture2(\"open\", origFile)\n # Open3.capture2(\"open\", tempFile)\n end\n end\nend",
"def create\n @image_to_part = ImageToPart.new(image_to_part_params)\n\n respond_to do |format|\n if @image_to_part.save\n format.html { redirect_to @image_to_part, notice: 'Image to part was successfully created.' }\n format.json { render action: 'show', status: :created, location: @image_to_part }\n else\n format.html { render action: 'new' }\n format.json { render json: @image_to_part.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_thumbnails()\n # {{{\n begin\n @@logger.log('IMAGE UP | Importing image')\n image_renderer = @@image_renderer.new(@media_asset)\n \n id = @media_asset.media_asset_id\n ext = @media_asset.extension.dup.downcase\n path = Aurita.project_path(:public, :assets, \"asset_#{id}.#{ext}\")\n \n @@logger.log(\"IMAGE UP | Path is #{path}\")\n # Every image needs a jpeg base image (esp. needed for PDF): \n STDERR.puts \"Importing #{path} using #{image_renderer.class.inspect}\"\n image_renderer.import(path)\n image_renderer.create_image_variants(@@variants)\n\n if ext == 'pdf' then\n image_renderer.create_pdf_preview()\n elsif @media_asset.is_video? then\n dest = Aurita.project_path(:public, :assets, \"asset_#{id}.jpg\")\n # File.open(source, 'w')\n # system \"ffmpeg -i #{path} -ar 22050 -ab 32 -acodec mp3\n # -s 480x360 -vcodec flv -r 25 -qscale 8 -f flv -y #{ dest }\"\n system(\"ffmpeg -i '#{path}' -ss 00:00:10 -vframes 1 -f image2 -vcodec mjpeg '#{dest}'\")\n ext = 'jpg'\n end\n rescue ::Exception => e\n STDERR.puts('Error when trying to create image versions: ' << e.message)\n e.backtrace.each { |m| \n STDERR.puts(m)\n }\n end\n end",
"def image_to_part_params\n params.require(:image_to_part).permit(:image_id, :part_id)\n end",
"def full_format fstype, label = nil\n DebugLogger.info \"class = #{self.class.name}, method = #{__method__}\"\n delete_all_partitions unless partitions.blank?\n DebugLogger.info \"|#{self.class.name}|>|#{__method__}|:Creating partition #{self.kname}\"\n DiskUtils.create_partition self, 1, -1\n DebugLogger.info \"|#{self.class.name}|>|#{__method__}|:Find partition #{@kname}\"\n self.reload\n new_partition = self.partitions.last # Assuming new partition to be at the last index\n DebugLogger.info \"|#{self.class.name}|>|#{__method__}|:Formating #{@kname} to #{fstype}\"\n new_partition.format fstype and reload\n end",
"def create_image_from_DATA\n puts \"Creating file at \" + @desktop_image\n image_data = DATA.read\n new_file = File.new(@desktop_image,\"w+\")\n new_file.write(image_data)\n end",
"def build_reduced_land_mass_image(x, y, zoom, accuracy_pixels, overwrite = false)\n land_mass_tile_path = LandMassTile.tile_path(x, y, zoom, accuracy_pixels)\n \n # exit if file already exists\n return false if (!overwrite && File.exists?(land_mass_tile_path))\n \n begin\n # build up square of 4 children tiles\n child_tiles = (0..1).map { |this_x| (0..1).map { |this_y| OpenStruct.new(:x => this_x+x*2, :offset_x => this_x, :y => this_y+y*2, :offset_y => this_y, :zoom => zoom+1) } }.flatten(1)\n \n reduce_tiles = child_tiles.select do |tile| \n tile.accuracy_pixels = accuracy_pixels \n tile.path = LandMassTile.tile_path(tile.x, tile.y, tile.zoom, tile.accuracy_pixels)\n tile.exists = File.exists?(tile.path)\n tile.img = Magick::Image.read(tile.path).first if tile.exists\n tile.exists # remove image if tile does not exist\n end\n \n stitch_tiles = child_tiles.select do |tile| \n tile.accuracy_pixels = accuracy_pixels * 2\n tile.path = LandMassTile.tile_path(tile.x, tile.y, tile.zoom, tile.accuracy_pixels)\n tile.exists = File.exists?(tile.path)\n tile.img = Magick::Image.read(tile.path).first if tile.exists\n tile.exists # remove image if tile does not exist\n end unless reduce_tiles.length == 4\n \n if (reduce_tiles.length == 4)\n # We are building a land mass tile from children with the same number of pixels in the tile\n # which means we need to \"squeeze\" 4 tiles into 1\n new_tile = Magick::Image.new(AppConfig.gmap_tile_size / accuracy_pixels * 2, AppConfig.gmap_tile_size / accuracy_pixels * 2) do\n self.background_color = \"transparent\"\n end\n \n child_tile_size = new_tile.columns / 2\n reduce_tiles.each do |tile|\n raise \"Tile#{tile.path} is incorrectly #{tile.img.columns} wide / high\" if ( (tile.img.columns != child_tile_size) || (tile.img.rows != child_tile_size) ) \n pixels = tile.img.export_pixels(0, 0, tile.img.columns, tile.img.rows, \"RGBA\")\n new_tile.import_pixels(tile.offset_x * child_tile_size, tile.offset_y * child_tile_size, tile.img.columns, tile.img.rows, \"RGBA\", pixels)\n end\n \n # now resize down to single tile size\n reduced_tile = new_tile.resize(AppConfig.gmap_tile_size / accuracy_pixels, AppConfig.gmap_tile_size / accuracy_pixels)\n \n reduced_tile.write land_mass_tile_path\n elsif (stitch_tiles.length == 4)\n # We are building a land mass tile from children with a lower accuracy level i.e. we need to \n # build up this tile by stitching 4 children tiles together\n \n new_tile = Magick::Image.new(AppConfig.gmap_tile_size / accuracy_pixels, AppConfig.gmap_tile_size / accuracy_pixels) do\n self.background_color = \"transparent\"\n end\n \n child_tile_size = new_tile.columns / 2\n stitch_tiles.each do |tile|\n raise \"Tile#{tile.path} is incorrectly #{tile.img.columns} wide / high\" if ( (tile.img.columns != child_tile_size) || (tile.img.rows != child_tile_size) ) \n pixels = tile.img.export_pixels(0, 0, tile.img.columns, tile.img.rows, \"RGBA\")\n new_tile.import_pixels(tile.offset_x * child_tile_size, tile.offset_y * child_tile_size, tile.img.columns, tile.img.rows, \"RGBA\", pixels)\n end\n \n new_tile.write land_mass_tile_path\n else\n reduce_tiles_info = reduce_tiles.map{|c| \"#{c.x}:#{c.y} zm #{c.zoom}\" }.join(',')\n stitch_tiles_info = stitch_tiles.map{|c| \"#{c.x}:#{c.y} zm #{c.zoom}\" }.join(',')\n SLogger.warn(\"Could not reduce land mass image for position as not all children tiles exist. Tile #{x}:#{y} (zoom #{zoom}). Reduce tiles: #{reduce_tiles_info}. Stitch tiles: #{stitch_tiles_info}\")\n false\n end\n \n rescue Exception => e\n SLogger.warn(\"Could not save reduced land mass image for position #{x}:#{y} (zoom #{zoom}). Error '#{e.message}'\")\n false\n end\n end",
"def setup\n size 200, 200\n @a = load_image 'construct.jpg'\n @b = load_image 'wash.jpg'\n @offset = 0.0\nend",
"def CheckPartition(partition)\n partition = deep_copy(partition)\n freshman = {\n :valid => false,\n :name => \"unknown\",\n :arch => \"unknown\",\n :label => Ops.get_string(partition, \"label\", \"\"),\n :fs => Ops.get_symbol(partition, \"detected_fs\", :unknown),\n :fstype => Ops.get_string(partition, \"fstype\", \"unknown\")\n }\n\n p_dev = Ops.get_string(partition, \"device\", \"error\")\n p_fsid = Ops.get_integer(partition, \"fsid\", 0)\n p_type = Ops.get_symbol(partition, \"type\", :primary)\n p_detect_fs = Ops.get_symbol(partition, \"detected_fs\", :unknown)\n\n # possible root FS\n if Builtins.contains(FileSystems.possible_root_fs, p_detect_fs)\n mt_map = {\n :ext2 => \"ext2\",\n :ext3 => \"ext3\",\n :ext4 => \"ext4\",\n :btrfs => \"btrfs\",\n :reiser => \"reiserfs\",\n :xfs => \"xfs\",\n :jfs => \"jfs\"\n }\n mount_type = Ops.get(mt_map, p_detect_fs, \"\")\n\n error_message = nil\n if !(\n error_message_ref = arg_ref(error_message);\n _RunFSCKonJFS_result = RunFSCKonJFS(\n mount_type,\n p_dev,\n error_message_ref\n );\n error_message = error_message_ref.value;\n _RunFSCKonJFS_result\n )\n Ops.set(freshman, :valid, false)\n return deep_copy(freshman)\n end\n\n # mustn't be empty and must be modular\n if mount_type != \"\" && !Builtins.contains(@non_modular_fs, mount_type)\n SCR.Execute(path(\".target.modprobe\"), mount_type, \"\")\n end\n # mount (read-only) partition to Installation::destdir\n Storage.RemoveDmMapsTo(p_dev)\n if Convert.to_boolean(\n SCR.Execute(\n path(\".target.mount\"),\n [p_dev, Installation.destdir, Installation.mountlog],\n \"-o ro\"\n )\n )\n # Is this a root partition, does /etc/fstab exists?\n if Ops.greater_than(\n SCR.Read(\n path(\".target.size\"),\n Ops.add(Installation.destdir, \"/etc/fstab\")\n ),\n 0\n )\n Builtins.y2milestone(\"found fstab on %1\", partition)\n\n fstab = []\n crtab = []\n\n fstab_ref = arg_ref(fstab)\n crtab_ref = arg_ref(crtab)\n read_fstab_and_cryptotab(fstab_ref, crtab_ref, p_dev)\n fstab = fstab_ref.value\n crtab = crtab_ref.value\n Update.GetProductName\n\n fstab = Builtins.filter(fstab) do |p|\n Ops.get_string(p, \"file\", \"\") == \"/\"\n end\n\n if Builtins.size(Ops.get_string(fstab, [0, \"spec\"], \"\")) == 0\n Builtins.y2warning(\"Cannot find / entry in fstab %1\", fstab)\n end\n\n Ops.set(\n freshman,\n :valid,\n Ops.greater_than(\n Builtins.size(Ops.get_string(fstab, [0, \"spec\"], \"\")),\n 0\n ) &&\n Storage.DeviceMatchFstab(\n p_dev,\n Ops.get_string(\n # bugzilla #304269\n # DeviceMatchFstab expects _old_ not _translated_ device\n fstab,\n [0, \"spec_old\"],\n Ops.get_string(fstab, [0, \"spec\"], \"\")\n )\n )\n )\n\n # Why this doesn't match?\n # Possible reasons:\n # - /var not mounted so hwinfo cannot translate device names\n if Ops.get_boolean(freshman, :valid, false) != true\n Builtins.y2warning(\n \"Device does not match fstab: '%1' vs. '%2'\",\n p_dev,\n Ops.get_string(fstab, [0, \"spec\"], \"\")\n )\n end\n if Mode.autoinst\n # we dont care about the other checks in autoinstallation\n SCR.Execute(path(\".target.umount\"), Installation.destdir)\n return deep_copy(freshman)\n end\n\n # Get installed release name\n release = OSRelease.ReleaseInformation(Installation.destdir)\n Builtins.y2debug(\"release: %1\", release)\n if release == \"?\"\n # label for an unknown installed system\n release = _(\"Unknown\")\n end\n Ops.set(freshman, :name, release)\n\n # Right architecture?\n Ops.set(\n freshman,\n :arch,\n GetArchOfELF(Ops.add(Installation.destdir, \"/bin/bash\"))\n )\n instsys_arch = GetArchOfELF(\"/bin/bash\")\n\n # `arch_valid, see bugzilla #288201\n # installed /bin/bash and the one from inst-sys are matching\n if Ops.get_string(freshman, :arch, \"unknown\") == instsys_arch\n Builtins.y2milestone(\"Architecture (%1) is valid\", instsys_arch)\n Ops.set(freshman, :arch_valid, true) \n\n # both are PPC, bugzilla #249791\n elsif Builtins.contains(\n [\"ppc\", \"ppc64\"],\n Ops.get_string(freshman, :arch, \"unknown\")\n ) &&\n Builtins.contains([\"ppc\", \"ppc64\"], instsys_arch)\n Builtins.y2milestone(\n \"Architecture for partition %1 is %2, upgrading %3\",\n p_dev,\n Ops.get_string(freshman, :arch, \"unknown\"),\n instsys_arch\n )\n Ops.set(freshman, :arch_valid, true) \n\n # Architecture is not matching\n else\n Builtins.y2milestone(\n \"Architecture for partition %1 is %2, upgrading %3\",\n p_dev,\n Ops.get_string(freshman, :arch, \"unknown\"),\n instsys_arch\n )\n Ops.set(freshman, :arch_valid, false)\n end\n\n # If architecture is not matching, the whole partition is considered to be wrong\n if Ops.get_boolean(freshman, :arch_valid, false) != true\n Builtins.y2milestone(\n \"Architecture is not valid -> the whole partition is not valid\"\n )\n Ops.set(freshman, :valid, false)\n end\n\n if IncompleteInstallationDetected(Installation.destdir)\n Builtins.y2milestone(\n \"Incomplete installation detected, partition is not valid\"\n )\n Ops.set(freshman, :valid, false)\n end\n\n Builtins.y2milestone(\n \"Partition is valid: %1, arch is valid: %2\",\n Ops.get_boolean(freshman, :valid, false),\n Ops.get_boolean(freshman, :arch_valid, false)\n )\n end\n\n # unmount partition\n SCR.Execute(path(\".target.umount\"), Installation.destdir)\n end\n end\n\n Builtins.y2milestone(\"%1 %2\", partition, freshman)\n\n deep_copy(freshman)\n end",
"def create_background_image\n split_tile_set_into_tiles\n create_image_list\n\n montage_cmd = \"montage #{@image_list.join(' ')} \"\n montage_cmd += \"-tile #{@maps[:background][0].size}x \"\n montage_cmd += \"-geometry 32x32+0+0 media/grid_one/full_map_image.png\"\n\n system(\"#{montage_cmd}\")\n\n @background_image = Gosu::Image.new(@window,\n 'media/grid_one/full_map_image.png',\n false)\n\n FileUtils.rm_r Dir.glob('media/tmp/*')\n end",
"def create_thumbnail(image)\n thumb = ( image.gsub /^#{@dirname}/, \"#{@thumbs}\" ) + @thumbext\n system(\"convert #{image} -thumbnail '#{@size}>' -#{@action} '#{@size}' -background white -quality 60 -gravity center -extent #{@size} #{thumb}\")\n end",
"def MountPartitions(root_device_current)\n Builtins.y2milestone(\"mount partitions: %1\", root_device_current)\n\n return true if @did_try_mount_partitions\n\n @did_try_mount_partitions = true\n\n success = true\n\n # popup message, %1 will be replace with the name of the logfile\n message = Builtins.sformat(\n _(\n \"Partitions could not be mounted.\\n\" +\n \"\\n\" +\n \"Check the log file %1.\"\n ),\n Ops.add(Directory.logdir, \"/y2log\")\n )\n Builtins.y2milestone(\"selected partition: %1\", root_device_current)\n\n ret_bool = true\n\n fstab = []\n crtab = []\n\n # Mount selected root partition to Installation::destdir\n ret_bool = nil == FsckAndMount(\"/\", root_device_current, \"\") if !Mode.test\n\n if ret_bool\n # read the keyboard settings now, so that it used when\n # typing passwords for encrypted partitions\n # Calling a script because otherwise this module would depend on yast2-country\n if Stage.initial\n WFM.call(\n \"rootpart_check_keyboard\",\n [{ \"destdir\" => Installation.destdir }]\n )\n end\n\n fstab_ref = arg_ref(fstab)\n crtab_ref = arg_ref(crtab)\n read_fstab_and_cryptotab(fstab_ref, crtab_ref, root_device_current)\n fstab = fstab_ref.value\n crtab = crtab_ref.value\n Storage.ChangeDmNamesFromCrypttab(\n Ops.add(Installation.destdir, \"/etc/crypttab\")\n )\n Update.GetProductName\n\n if FstabUsesKernelDeviceNameForHarddisks(fstab)\n Builtins.y2warning(\n \"fstab on %1 uses kernel device name for hard disks\",\n root_device_current\n )\n warning = Builtins.sformat(\n _(\n \"Some partitions in the system on %1 are mounted by kernel-device name. This is\\n\" +\n \"not reliable for the update since kernel-device names are unfortunately not\\n\" +\n \"persistent. It is strongly recommended to start the old system and change the\\n\" +\n \"mount-by method to any other method for all partitions.\"\n ),\n root_device_current\n )\n if Mode.autoupgrade\n Popup.TimedWarning(warning, 10)\n else\n Popup.Warning(warning)\n end\n end\n\n if Builtins.size(fstab) == 0\n Builtins.y2error(\"no or empty fstab found!\")\n # error message\n message = _(\"No fstab found.\")\n success = false\n else\n tmp_msg = MountVarIfRequired(fstab, root_device_current, true)\n if tmp_msg != nil\n Builtins.y2error(\"failed to mount /var!\")\n message = tmp_msg\n success = false\n else\n tmp = \"\"\n\n if !(\n tmp_ref = arg_ref(tmp);\n check_root_device_result = check_root_device(\n root_device_current,\n fstab,\n tmp_ref\n );\n tmp = tmp_ref.value;\n check_root_device_result\n )\n Builtins.y2error(\"fstab has wrong root device!\")\n # message part 1\n message = Ops.add(\n Ops.add(\n _(\n \"The root partition in /etc/fstab has an invalid root device.\\n\"\n ),\n # message part 2\n Builtins.sformat(\n _(\"It is currently mounted as %1 but listed as %2.\\n\"),\n root_device_current,\n tmp\n )\n ),\n @sdb\n )\n success = false\n else\n Builtins.y2milestone(\"cryptotab %1\", crtab)\n\n fstab_ref = arg_ref(fstab)\n PrepareCryptoTab(crtab, fstab_ref)\n fstab = fstab_ref.value\n\n Builtins.y2milestone(\"fstab %1\", fstab)\n\n if !(\n message_ref = arg_ref(message);\n _MountFSTab_result = MountFSTab(fstab, message_ref);\n message = message_ref.value;\n _MountFSTab_result\n )\n success = false\n end\n end\n end\n end\n else\n Builtins.y2error(\n \"Could not mount root '%1' to '%2'\",\n root_device_current,\n Installation.destdir\n )\n success = false\n end\n\n Builtins.y2milestone(\n \"MountPartition (%1) = %2\",\n root_device_current,\n success\n )\n Builtins.y2milestone(\"activated %1\", @activated)\n\n if !success\n Popup.Message(message)\n\n # some mount failed, unmount all mounted fs\n UnmountPartitions(false)\n @did_try_mount_partitions = true\n else\n # enter the mount points of the newly mounted partitions\n # in the target map of the storage module\n AddToTargetMap()\n end\n\n success\n end",
"def CreatePartition(disk, device, ptype, id, start, len, mby)\n Builtins.y2milestone(\n \"CreatePartition disk:%1 device:%2 ptype:%3 id:%4 start:%5 len:%6 mby:%7\",\n disk,\n device,\n ptype,\n id,\n start,\n len,\n mby\n )\n pt = fromSymbol(@conv_ptype, ptype)\n Builtins.y2milestone(\"CreatePartition type:%1 pt:%2\", ptype, pt)\n ret, cdev = @sint.createPartition(disk, pt, start, len)\n cdev = \"\" if ret<0\n if device != cdev\n Builtins.y2error(\"CreatePartition device:%1 cdev:%2\", device, cdev)\n end\n Builtins.y2error(\"CreatePartition ret %1\", ret) if ret<0\n ret = @sint.changePartitionId(device, id)\n Builtins.y2error(\"CreatePartition ret %1\", ret) if ret<0\n tmp = fromSymbol(@conv_mountby, mby)\n @sint.changeMountBy(device, tmp)\n Builtins.y2milestone(\"CreatePartition sint ret:%1\", ret)\n UpdateTargetMap()\n ret == 0\n end",
"def show_image\n temp_floor_tile = Image.new('tiles\\tile_floor_1.png')\n hex_width = temp_floor_tile.width - 6\n hex_height = temp_floor_tile.width - 4\n temp_floor_tile.remove\n @hexArray.each_with_index do | line, x |\n bottom_y = hex_height * 11\n y_start = bottom_y - (11 - line.size) * (hex_height / 2)\n line.each_with_index do | hex, y |\n cur_x = x * hex_width\n cur_y = y_start - y * hex_height\n\n case hex.type\n when Hex::FLOOR_TYPE\n Image.new('tiles\\tile_floor_1.png', x:cur_x, y:cur_y)\n when Hex::LAVA_TYPE\n Image.new('tiles\\tile_liquid_1.png', x:cur_x, y:cur_y)\n when Hex::EXIT_TYPE\n Image.new('tiles\\tile_base.png', x:cur_x, y:cur_y)\n Image.new('tiles\\dung_ladderdown.png', x:cur_x, y:cur_y)\n else\n Image.new('tiles\\tile_base.png', x:cur_x, y:cur_y)\n end\n if hex.contained_object != nil && hex.contained_object.type == MovingObject::PLAYER_TYPE\n Image.new('tiles\\player.png', x:cur_x, y:cur_y)\n end\n end\n end\n end",
"def generate_thumb(tmp_file_path)\n %x(convert #{tmp_file_path}.pdf[0-#{@num_thumb_pages}] -thumbnail x640 #{tmp_file_path}.png)\n stripped_file_names = (0...@num_thumb_pages).to_a.map { |i| \"#{tmp_file_path}-#{i}.png\" }.join(\" \")\n output_path = \"#{tmp_file_path}_merged.jpg\"\n %x(montage #{stripped_file_names} -mode concatenate -quality 80 -tile x1 #{output_path})\n\n output_path\n end",
"def design2image\n\n bkgImg = Image.read(\"#{Rails.root}/public/#{params[:bkg]}\").first\n\n sideTop = 36\n sideLeft = 95\n sideWidth = 216\n sideHeight = 353\n\n side = params[:side]\n if side == 'SLEEVE'\n sideWidth = 162\n sideHeight = 250\n end\n #ART Processing\n arts = params[:art];\n art_tops = params[:art_top];\n art_lefts = params[:art_left];\n \n \n #Image.new(columns, rows) ~ (width, height)\n containSide = Magick::Image.new(sideWidth, sideHeight) do\n self.background_color = 'none'\n end\n\n i=0\n if arts\n clipArt = Image.read(\"#{Rails.root}/public/#{arts[0]}\").first\n clipArtTop = art_tops[i].to_i if art_tops[i]\n clipArtLeft = art_lefts[i].to_i if art_lefts[i]\n containSide = containSide.composite(clipArt, clipArtLeft, clipArtTop, OverCompositeOp)\n end\n\n #TEXT Processing\n texts = params[:text];\n text_tops = params[:text_top];\n text_lefts = params[:text_left];\n\n\n if texts\n textArtTop = text_tops[i].to_i if text_tops[i]\n textArtLeft = text_lefts[i].to_i if text_lefts[i]\n gc = Magick::Draw.new\n textArt = Magick::Image.new(300, 200) do\n self.background_color = 'none'\n end\n gc.annotate(textArt, 0, 0, 0, 0, texts[i]) do\n self.gravity = Magick::NorthWestGravity\n self.pointsize = 22\n self.font_family = \"Times\"\n self.fill = '#0000A9'\n self.stroke = \"none\"\n end\n end\n\n containSide.composite!(textArt, textArtLeft || 0, textArtTop || 0, OverCompositeOp) if textArt\n \n bkgImg.composite!(containSide, sideLeft, sideTop, OverCompositeOp)\n bkgImg.scale!(0.5)\n\n send_data bkgImg.to_blob, :disposition => 'inline', :type => 'image/png'\n\n# output = get_working_image(@session_id)\n# unless File.exist?(output)\n# FileUtils.cp(\"#{RAILS_ROOT}/public/images/#{params[:textart]}.png\", output)\n# img = Image.read(output).first\n# img = img.scale(params[:rs].to_f) unless params[:rs].blank?\n# img = img.level_colors(params[:b] || \"\", params[:w] || \"\", true) if params[:b] || params[:w]\n# img.background_color = \"none\"\n# img = img.rotate(params[:r].to_f) unless params[:r].blank?\n# img.write(output)\n# end\n# img = Image.read(output).first\n# send_data img.to_blob, :disposition => 'inline', :type => 'image/png'\n\n end",
"def generate( type, *args )\n puts \"==> generate >#{type}< - with #{args.size} part(s) #{args.inspect}\"\n\n character = @chars[ type ]\n\n img = nil ## (by default) auto-derive width x height dimension from first image\n\n character.each_with_index do |(part_key, part),i|\n num = args[i]\n\n ## todo/check - double check if part required set to false - why? why not?\n next if num == 0 ## note: skip part if index is 0!!!\n\n attributes = if part.is_a?( Hash )\n part[:attributes]\n else ## assume array - \"inline\" compact attribute format\n part\n end\n\n attribute = attributes[ num-1 ] ## note: num starts counting at 1 (sub 1 for zero-based array index)\n raise ArgumentError, \"no >#{part_key}< part found for index #{num}; sorry\" if attribute.nil?\n\n print \"#{i} #{part_key} => #{num}\"\n print \" - #{attribute[:name]}\" if attribute.is_a?( Hash ) && attribute.has_key?( :name )\n print \"\\n\"\n\n\n img_part = if attribute.is_a?( Integer ) ## assume filename with num (as .png)\n path = \"#{@rootdir}/#{type}/#{part_key}/#{part_key}#{num}.png\"\n img_part = Image.read( path )\n elsif attribute.is_a?( Hash )\n if attribute.has_key?( :design )\n path = \"#{@rootdir}/#{attribute[:design]}.txt\"\n txt = File.open( path, 'r:utf-8') {|f| f.read }\n img_part = Image.parse( txt, colors: attribute[:colors] )\n else ## assume for now has key :path\n path = \"#{@rootdir}/#{attribute[:path]}.png\"\n img_part = Image.read( path )\n end\n else\n puts \"!! ERROR:\"\n pp part\n raise ArgumentError, \"unknown part data type; expected Integer|Hash\"\n end\n ## note: if (very) first part - auto-create empty image with size/dimensions from part\n img = Image.new( img_part.width, img_part.height ) if i==0\n img.compose!( img_part )\n end\n\n img\nend",
"def create_advanced\n image_service = ImageGeneratingService.new(self, 'Advanced.jpg', 'image/jpeg', 69)\n output_path = image_service.generate\n original_size_mb = File.size(output_path).to_f / 2**20\n if original_size_mb > 1.0\n image_service.generate_resized(1200)\n end\n end",
"def create_partition(size = nil, type = Partition.PartitionType[:TYPE_PRIMARY])\n DiskUtils.create_partition self, size[:start_block], size[:end_block]\n partitions = Device.find(self).partitions\n return partitions.last\n end",
"def copy_generated_images(parent)\n img = parent.find_inspire_image\n mobile = parent.image_for img, 'mobile_inspire'\n desktop = parent.image_for img, 'desktop_inspire'\n thumbnails = parent.image_for '', 'thumbnails'\n\n FileUtils.cp(mobile, \"#{data_path}/inspire/mobile\")\n FileUtils.cp(desktop, \"#{data_path}/inspire/desktop\")\n FileUtils.cp_r(\"#{thumbnails}/.\", \"#{data_path}/thumbnails\")\n end",
"def set_board\n\t\t(1..@disks).each do |disk|\n\t\t\t@pegs[0].unshift disk\n\t\tend\n\tend",
"def on_demand(width, height)\n dims = \"#{width}x#{height}\"\n\n public_path = self.public_path(dims)\n output_path = self.output_path(dims)\n\n if File.exists?(output_path)\n logger.info \"[iphoto library] Thumbnail hit at #{public_path}\"\n else\n FileUtils.mkdir_p(File.dirname(output_path))\n\n unless defined? MiniMagick\n logger.debug \"[iphoto library] Requiring MiniMagick\"\n require 'mini_magick'\n end\n\n image = MiniMagick::Image.from_file(image_path(true))\n image.resize dims\n image.write(output_path)\n FileUtils.chmod 0755, output_path\n\n logger.info \"[iphoto library] Created thumbnail at #{output_path}\"\n end\n\n public_path\n end",
"def create_iscsi_disks(vbox)\n unless controller_exists(ISCSI_NAME, 'SATA Controller')\n vbox.customize ['storagectl', :id,\n '--name', 'SATA Controller',\n '--add', 'sata']\n end\n\n (1..10).each do |i|\n id = i.to_s.rjust(2, '0')\n disk = \"./tmp/disk#{i}.vdi\"\n\n unless File.exist?(disk)\n vbox.customize ['createmedium', 'disk',\n '--filename', disk,\n '--size', '100',\n '--format', 'VDI',\n '--variant', 'fixed']\n end\n\n vbox.customize [\n 'storageattach', :id,\n '--storagectl', 'SATA Controller',\n '--port', i,\n '--type', 'hdd',\n '--medium', disk\n ]\n vbox.customize [\n 'setextradata', :id,\n \"VBoxInternal/Devices/ahci/0/Config/Port#{i}/SerialNumber\",\n \"081118FC1221NCJ6G8#{id}\"\n ]\n end\nend",
"def make\n src = @file\n dst = Tempfile.new([@basename, @format].compact.join(\".\"))\n dst.binmode\n\n command = <<-end_command\n #{ Paperclip.path_for_command('convert') }\n \"#{ File.expand_path(src.path) }\"\n #{ transformation_command }\n \"#{ File.expand_path(dst.path) }\"\n end_command\n success = system(command.gsub(/\\s+/, \" \"))\n\n if success && $?.exitstatus != 0 && @whiny_thumbnails\n raise PaperclipError, \"There was an error processing this thumbnail\"\n end\n\n dst\n end",
"def setup_disk(path)\n dev = ::File.readlink(path)\n full_path = ::File.absolute_path(dev, ::File.dirname(path))\n\n fs_type = get_fs_type(full_path)\n if fs_type.nil?\n Mixlib::ShellOut.new(\"mkfs.ext4 #{full_path}\").run_command\n fs_type = 'ext4'\n end\n\n fs_type\nend",
"def setup_disk(path)\n dev = ::File.readlink(path)\n full_path = ::File.absolute_path(dev, ::File.dirname(path))\n\n fs_type = get_fs_type(full_path)\n if fs_type.nil?\n Mixlib::ShellOut.new(\"mkfs.ext4 #{full_path}\").run_command\n fs_type = 'ext4'\n end\n\n fs_type\nend",
"def create_custom_part(src_image)\n raise \"no src_image to make custom part #{self.inspect}\" if src_image.nil?\n @custom_part = part_layout.draw_custom_part(part_image, src_image)\n dump('assembled', @custom_part) if Rails.env.development?\n image.store_image!(@custom_part)\n end",
"def partition_device\n Souffle::Log.info \"#{@node.log_prefix} Partitioning the device...\"\n provider.partition(@node)\n end",
"def main()\n img = ImageList.new($input)\n convert = ImageList.new\n page = Magick::Rectangle.new(0,0,0,0)\n $total_ops = (img.rows * img.columns).to_f\n\n for i in 0..img.rows\n for j in 0..img.columns\n pixel = generate_hex_pixel(rgb_to_hex(img.pixel_color(j,i)))\n convert << pixel\n page.x = j * pixel.columns\n page.y = i * pixel.rows\n pixel.page = page\n progress()\n end\n end\n\n puts 'Writing image, this could take a while...'\n convert.mosaic.write($output)\nend",
"def create_mini_fat\n v_mf = []\n @storages.select{ |s| s.type == Storage::TYPES[:stream] && s.size < MINI_CUTOFF}.each do |stream|\n allocate_stream(v_mf, stream, 64)\n end\n v_mf.concat Array.new(128 - v_mf.size, -1)\n v_mf.pack 'l*'\n end",
"def make\n src = @file\n dst = Tempfile.new(@basename)\n dst.binmode\n\n command = <<-end_command\n #{transformation_command}\n \"#{File.expand_path(src.path)}[0]\"\n \"#{File.expand_path(dst.path)}\"\n end_command\n\n begin\n success = Paperclip.run('composite', command.gsub(/\\s+/, ' '))\n rescue PaperclipCommandLineError\n raise PaperclipError, \"There was an error processing the watermark for #{@basename}\" if @whiny\n end\n\n dst\n end",
"def image_creation(image_name)\n image_path = Rails.root.join('public', 'images', image_name).to_s\n uploader = Dragonfly[:images]\n uploaded_image = uploader.fetch_file(image_path)\n image = Image.create image: uploaded_image\n\n rescue Error => e\n print \"Error creating image: \" + e\nend",
"def createThumbnail(blob, contenttype, device )\n\n\n thumb_path = \"public/thumbnails/#{device.id}/\"\n \n thumb_name = blob.blob_hash.to_s+\".png\"\n\n if contenttype == \"image/jpeg\" or contenttype == \"image/png\" or contenttype == \"image/gif\"\n data = getBlobById(blob.blob_hash)\n createIcon(data, thumb_name, thumb_path)\n blob.update_attribute(:thumbnail_name, thumb_name)\n return thumb_name\n \n elsif contenttype == \"video/x-msvideo\" or contenttype == \"video/msvideo\"\n format = blob.devfile.name.split(\".\").last\n if format == 'avi'\n vR_default_thumbnail_file = \"vR_avi.png\"\n elsif format == 'mov'\n vR_default_thumbnail_file = \"vR_mov.png\"\n end\n \n elsif contenttype == \"application/mswordapplication/x-mswordapplication/x-wordapplication/wordtext/plain\"\n vR_default_thumbnail_file = \"vR_doc.png\"\n elsif contenttype == \"application/x-ruby\"\n vR_default_thumbnail_file = \"vR_ruby.png\"\n elsif contenttype == \"text/plain\"\n vR_default_thumbnail_file = \"vR_txt.png\"\n else\n puts \"Unknown Filetype: #{contenttype.to_s}\".background(:red)\n vR_default_thumbnail_file = \"vR_unknown.png\"\n end\n \n # create dir if it does not exist\n if not (File.exists?(thumb_path) && File.directory?(thumb_path))\n FileUtils.mkdir_p(thumb_path)\n end\n \n # Copy default thumbnail to file\n from = \"public/thumbnails/vR_default_thumbnails/\" + vR_default_thumbnail_file\n to = thumb_path+thumb_name\n # ftools (ruby 1.8.7)\n #File.copy(from, to )\n \n # fileutils (ruby 1.9.2)\n FileUtils.cp(from, to )\n \n \n blob.update_attribute(:thumbnail_name, thumb_name)\n return thumb_name\n end",
"def partitions(**opts)\n\t\t\t\topts[:disk]||=@computer.dig(:sysinit, :disk)\n\t\t\t\topts[:mountpoint]||=@computer.dig(:sysinit, :mountpoint)\n\t\t\t\t@partitions=partitions_helper(@partitions||Marshal.load(Marshal.dump(@computer.dig(:sysinit,:partitions))), **opts)\n\t\t\t\t@partitions = yield @partitions, **opts if block_given?\n\t\t\t\t@partitions\n\t\t\tend",
"def create_from_disk(*filenames); end",
"def main\n ImageManip::inspect_image(@image_path)\n dimensions = ImageManip::get_dimensions(@image_path)\n sharp_pixels = get_accidental_pixels(@sharp_path)\n flat_pixels = get_accidental_pixels(@flat_path)\n edits = Hash.new\n edits[:lower_left] = [dimensions[0] / 2, dimensions[1] / 2]\n edits[:rgb_array] = sharp_pixels\n ImageManip::draw_2D_object(@image_path, './new_staff.gif', edits)\n edits[:lower_left] = [dimensions[0] / 3, dimensions[1] / 3]\n edits[:rgb_array] = flat_pixels\n ImageManip::draw_2D_object('./new_staff.gif', './new_staff.gif', edits)\n end",
"def crop!(crop_partitions, crop_sites_per_partition)\n @list = Hash[@list.first(crop_partitions)]\n @list = Hash[@list.map do |partition_name, partition|\n [partition_name, partition.crop(crop_sites_per_partition - Random.rand(0..2))]\n end]\n end",
"def prepare_strip\r\n @strip = []\r\n for i in 0...@totalFrames\r\n bitmap = Bitmap.new(@width,@height)\r\n bitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmaps[i],Rect.new(0,0,@width,@height))\r\n @strip.push(bitmap)\r\n end\r\n end",
"def configure_bootloader\n grub_part = first_grub_cfg_partition()\n\n # mount grub partition at some temp location, and operate on it\n Dir.mktmpdir do |mountdir|\n begin\n grub_part = File.join('/dev/disk/by-label', grub_part.label)\n execute!(\"mount #{grub_part} #{mountdir}\")\n\n grub_dir = File.join(mountdir, 'boot', 'grub')\n execute!(\"mkdir -p #{grub_dir}\")\n\n # Write out grub.cfg\n info(\"creating grub.cfg\")\n Tempfile.open('grub.conf') do |f|\n f.puts(grub_cfg_contents)\n f.sync; f.fsync # flush ruby buffers, then os buffers\n execute!(\"cp #{f.path} #{File.join(grub_dir, \"grub.cfg\")}\")\n end\n ensure\n # Always unmount it\n execute!(\"umount #{mountdir}\")\n end\n end\n end",
"def create_images\n imgNames = Hash[\n \tFile.join(Dir.home, 'Desktop/image1.png') => 0,\n \tFile.join(Dir.home, 'Desktop/image2.png') => 1,\n \tFile.join(Dir.home, 'Desktop/image3.png') => 2,\n \tFile.join(Dir.home, 'Desktop/image4.png') => 3,\n \tFile.join(Dir.home, 'Desktop/image5.png') => 4,\n \tFile.join(Dir.home, 'Desktop/image6.png') => 0,\n \tFile.join(Dir.home, 'Desktop/image7.png') => 1,\n \tFile.join(Dir.home, 'Desktop/image8.png') => 2,\n \tFile.join(Dir.home, 'Desktop/image9.png') => 3,\n \tFile.join(Dir.home, 'Desktop/image10.png') => 4 ]\n \t\n i = 0\n imgNames.each_key do |imgN|\n open(imgN, 'wb', 0666) do |file|\n puts \"Loading...\"\n file << open(@imageArray[i%5]).read\n end\n i += 1\n end\n end",
"def list_swap_partitions_with_type_and_size # nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\" && $6==\"82\") print $1\":\"$5\":\"$6;else {if ($5==\"82\") print $1\":\"$4\":\"$5}}' | sed s/+//g`.chomp.split\nend",
"def create\n @artpiece = Artpiece.new(params[:artpiece])\n @artist = Artist.find(params[:artpiece][:artist_id])\n @artist.artpieces << @artpiece\n\n if @artpiece.save\n @image_name = \"#{sprintf(\"%03d\", @artpiece.id)}.jpg\"\n @directory = \"public/images/artcat/pieces\"\n # create the file path\n @path = File.join(@directory, @image_name)\n # write the file\n File.open(@path, \"wb\") { |f| f.write(params[:picture].read) }\n redirect_to(@artist, :notice => 'Artpiece was successfully created.')\n end\n end",
"def generate_png\n command = \"python #{Rails.root}/lib/webkit2png --transparent -F -o #{id} -D #{Rails.root}/tmp #{url} \"\n system command\n return \"#{Rails.root}/tmp/#{id}-full.png\"\n end",
"def make_thumbnails\n return true unless defined?(IMAGEMAGICK_CONVERT) && is_local?\n system(\"#{IMAGEMAGICK_CONVERT} -resize #{THUMBNAIL_SIZE} #{filename} #{filename('s')}\")\n true\n end",
"def vsc_create(drive)\n puts \"[\".light_blue + \"*\".white + \"]\".light_blue + \" Creating New Volume Shady Copy from #{drive}\".white\n cmd=\"vssadmin create shadow /for=#{drive}:\"\n begin\n text = \"#{@tmp}\\\\#{Rex::Text.rand_text_alpha(16)}.txt\"\n bat = \"#{@tmp}\\\\#{Rex::Text.rand_text_alpha(16)}.bat\"\n cmdexec = \"%COMSPEC% /C echo #{cmd} ^> #{text} > #{bat} & %COMSPEC% /C start %COMSPEC% /C #{bat}\"\n# cmdexec = \"%COMSPEC% /C #{cmd} > #{text}\"\n smb_psexec(cmdexec, false)\n puts \"[\".light_blue + \"*\".white + \"]\".light_blue + \" taking short 30 second nap to ensure it has enough time....\".white\n sleep(30) # Need to provide sufficient time for this process to complete or your S.O.L.\n output = get_output(text, false)\n files = [ text, bat ]\n cleanup_after(files, false)\n if output =~ /Successfully created shadow copy/i\n if output =~ /Shadow Copy ID: (.+)/i\n id=$1.chomp\n end\n if output =~ /Shadow Copy Volume Name: (.+)/i\n path=$1.chomp\n end\n if not id.nil? and not path.nil?\n puts \"[\".light_green + \"*\".white + \"]\".light_green + \" New Volume Shady Copy ID: #{id}\".white\n puts \"[\".light_green + \"*\".white + \"]\".light_green + \" New Volume Shady Copy Location: #{path}\".white\n return id, path\n else\n return nil, nil\n end\n else\n puts \"[\".light_red + \"*\".white + \"]\".light_red + \" Error creating Volume Shadow Copy!\".white\n puts \"[\".light_red + \"*\".white + \"]\".light_red + \" Make sure you have enough privileges and that this is a Domain Controller.....\".white\n return nil, nil\n end\n rescue Rex::Proto::SMB::Exceptions::InvalidCommand => e\n puts \"[\".light_red + \"*\".white + \"]\".light_red + \" Error creating Volume Shadow Copy!\".white\n puts \"[\".light_red + \"*\".white + \"]\".light_red + \" Make sure you have enough privileges and that this is a Domain Controller.....\".white\n return nil, nil\n end\nend",
"def dump_show_img\n FileUtils.rm_rf(Dir.glob(\"#{project.image_for('', 'show_image_desk')}/*\"))\n FileUtils.rm_rf(Dir.glob(\"#{project.image_for('', 'show_image_mob')}/*\"))\n FileUtils.rm_rf(Dir.glob(\"#{project.image_for('', 'show')}/*\"))\n end",
"def generate_thumbnail path, img\n img = img.resize_to_fit 200,200\n img.write path\n end",
"def makesheet(edir, emote, framedir)\n fdelays = []\n Dir.chdir(framedir)\n frames = Dir.glob(\"*_frame*png\").sort\n Dir.glob(emote + \"*txt\").sort.each do |file|\n delay = File.read(file).chomp\n fdelays << delay\n end\n if(fdelays.uniq.length != 1)\n frames << frames[0]\n end\n img = ImageList.new(framedir + \"/\" + frames[0])\n ex, ey = img.columns, img.rows\n img = ImageList.new\n frames.each do |frame|\n img.push(Image.read(framedir + \"/\" + frame).first)\n end\n begin\n img.append(false).write(edir + \"/\" + emote + \"-sheet.png\")\n rescue Exception\n puts \"Could not write: \" + edir + \"/\" + emote + \"-sheet.png\"\n end\n system(\"optipng -quiet \" + edir + \"/\" + emote + \"-sheet.png > \" + $bitbucket)\n return ex, ey\nend",
"def split_tile_set_into_tiles\n number_of_tiles = @tile_set[0].columns/32\n\n number_of_tiles.times do |i|\n image = @tile_set[0].crop((i*32), 0, 32, 32)\n image.write(\"media/tmp/tile#{i}.png\")\n end\n end",
"def load_create_scaled_img(scale_lbl, lbl)\r\n unless @cards_scaled_info[scale_lbl]\r\n @log.error \"Scaled information not set, unable to load card\"\r\n return\r\n end\r\n card_width = @cards_scaled_info[scale_lbl][:w]\r\n card_height = @cards_scaled_info[scale_lbl][:h]\r\n \r\n name = get_cardfname_of(lbl)\r\n @log.debug \"Load image of card #{lbl}, filename #{name}\"\r\n card_fname = File.join(@foldercards_fullpath, name)\r\n img = FXPNGIcon.new(getApp, nil,\r\n IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)\r\n FXFileStream.open(card_fname, FXStreamLoad) { |stream| img.loadPixels(stream) }\r\n img.scale(card_width, card_height, 1 )\r\n \r\n img.create\r\n return img\r\n end",
"def partition_devices(device_list, attempt = 0, max_attempts = 3)\n return false if attempt >= max_attempts\n\n puts case attempt\n when 0 then \"Partioning devices ...\" \n else \"Retrying device partitioning (attempt #{attempt + 1}) ...\" \n end\n\n device_list.each do |device|\n puts \" * #{device}\"\n `echo 0|sfdisk #{device}`\n end\n\n puts \"Sleeping 10 seconds to reload partition tables ...\"\n sleep 10\n\n # Verify all volumes were properly partitioned\n missing_devices = []\n device_list.each do |device|\n missing_devices << device unless File.exists?(\"#{device}1\")\n end\n\n # Retry partitioning for failed volumes\n response = true\n if missing_devices.size > 0\n response = partition_devices(missing_devices, attempt + 1, max_attempts)\n end\n response\n end",
"def portrait(size)\n unless File.exists? \"#{RAILS_ROOT}/public/system/characters/#{self.id}_#{size.to_i}.jpg\"\n begin\n File.open(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_256.jpg\",\"wb\") do |f|\n Net::HTTP.start(\"image.eveonline.com\") do |http|\n resp = http.get(\"/Character/#{self.id}_256.jpg\")\n f << resp.body\n end\n end\n # Now use MiniMagick to bake some 16/32 images from the larger source\n \n image = MiniMagick::Image.from_file(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_256.jpg\")\n image.resize \"16x16\"\n image.write(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_16.jpg\")\n \n image = MiniMagick::Image.from_file(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_256.jpg\")\n image.resize \"32x32\"\n image.write(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_32.jpg\")\n \n image = MiniMagick::Image.from_file(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_256.jpg\")\n image.resize \"64x64\"\n image.write(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_64.jpg\")\n rescue\n return \"/images/logo_not_found_#{size}.jpg\"\n end\n end\n return \"/system/characters/#{self.id}_#{size.to_i}.jpg\"\n end",
"def allocate(session, template)\n write_task('rvpe.image.allocate', session) do\n image_def = ResourceFile::Parser.load_yaml(template)\n t = Transfer.find_by_name(image_def[ResourceFile::Image::TRANSFER])[0]\n # check fields\n err_msg_suffix = ' in Image file.'\n # check name\n _name = image_def[ResourceFile::Image::NAME]\n unless _name\n t.cleanup\n raise 'Specify ' + ResourceFile::Image::NAME + err_msg_suffix\n end\n unless Image.find_by_name(_name, session, -2).empty?\n t.cleanup\n raise \"Image[#{_name}] already exists. Use another name.\"\n end\n # check type\n _type = image_def[ResourceFile::Image::TYPE]\n _type = 'OS' unless _type\n # check attributes\n if image_def[ResourceFile::Image::PUBLIC] &&\n image_def[ResourceFile::Image::PERSISTENT]\n t.cleanup\n raise \"An image can't be public and persistent at the same time.\"\n end\n _public = image_def[ResourceFile::Image::PUBLIC]\n if _public\n _public = 'YES' # yaml automatically converted 'YES' to true\n else\n _public = 'NO'\n end\n _persistent = image_def[ResourceFile::Image::PERSISTENT]\n if _persistent\n _persistent = 'YES' # yaml automatically converted 'YES' to true\n else\n _persistent = 'NO'\n end\n # check bus\n _bus = image_def[ResourceFile::Image::IO_BUS]\n _bus = 'virtio' unless _bus\n case _bus.downcase\n when 'virtio'\n _dev_prefix = 'vd'\n when 'ide'\n _dev_prefix = 'hd'\n else\n _dev_prefix = 'sd'\n end\n # check nic model\n _nic_model = image_def[ResourceFile::Image::NIC_MODEL]\n _nic_model = 'virtio' unless _nic_model\n # check image file\n begin\n image_sanity_check(t.path)\n rescue => e\n t.cleanup\n raise e\n end\n\n one_template = <<EOT\nNAME = \"#{_name}\"\nDESCRIPTION = \"#{image_def[ResourceFile::Image::DESCRIPTION]}\"\nTYPE = \"#{_type}\"\nPUBLIC = \"#{_public}\"\nPERSISTENT = \"#{_persistent}\"\nBUS = \"#{_bus}\"\nDEV_PREFIX = \"#{_dev_prefix}\"\nNIC_MODEL = \"#{_nic_model}\"\nPATH = \"#{image_def[ResourceFile::Image::PATH]}\"\nEOT\n rc = call_one_xmlrpc('one.image.allocate', session, one_template)\n\n if rc[0]\n # move OS image to the image storage directory\n rc2 = call_one_xmlrpc('one.image.info', session, rc[1])\n unless rc2[0]\n t.cleanup\n raise rc2[1]\n end\n doc = REXML::Document.new(rc2[1])\n FileUtils.mv(t.path, doc.get_text('IMAGE/SOURCE').value)\n end\n t.cleanup\n rc\n end\n end",
"def create\n\n # Run the \"file\" command in the shell to determine file type\n # Note: Using file.read(4) was not reliable\n user_file_type = `file #{params[:files][0].tempfile.path}`\n \n # Verify the file is a JPEG or TIFF\n # Note: This protects against a spoofed content-type header\n # and also does not rely on file type extension\n if ![\"JPEG\", \"JPG\", \"TIF\", \"TIFF\"].any?{|valid_file_type| user_file_type.include?valid_file_type}\n raise Exception, \"Invalid file type\"\n end\n \n \n #filename the user gave the file\n # Sanitize the filename - upload security - Code from Rails security guide\n params[:files][0].original_filename.strip.tap do |name|\n # NOTE: File.basename doesn't work right with Windows paths on Unix\n # get only the filename, not the whole path\n name.sub! /\\A.*(\\\\|\\/)/, ''\n # Finally, replace all non alphanumeric, underscore\n # or periods with underscore\n name.gsub! /[^\\w\\.\\-]/, '_'\n end\n \n error = false\n titleSet_display = current_user.user_key + \" \" + params[:files][0].original_filename\n \n #Create ClamAV instance for virus scanning\n clam = ClamAV.instance\n \n #Load ClamAV definitions\n clam.loaddb\n \n #Scan file (will return fixnum if ok, string with virus name if not ok)\n if params[:files][0].is_a? Tempfile\n logger.debug(\"TEMPFILE: #{params[:files][0].tempfile.path}\")\n scan_result = clam.scanfile(params[:files][0].tempfile.path)\n else\n logger.debug(\"FILE: #{params[:files][0].path}\")\n scan_result = clam.scanfile(params[:files][0].path)\n end\n \n if (scan_result.is_a? Fixnum)\n # create the Multiresimage\n \n edit_users_array = DIL_CONFIG['admin_staff'] | Array.new([current_user.user_key])\n \n @image = Multiresimage.new(:pid=>mint_pid(\"dil-local\"))\n logger.debug(\"FILES:#{params[:files]}\")\n @image.attach_file(params[:files])\n @image.apply_depositor_metadata(current_user.user_key)\n @image.edit_users = edit_users_array\n @image.titleSet_display = titleSet_display\n @image.save!\n \n @work = Vrawork.new(:pid=>mint_pid(\"dil-local\"))\n \n @image.add_relationship(:is_image_of, \"info:fedora/\" + @work.pid)\n @work.apply_depositor_metadata(current_user.user_key)\n @work.edit_users = edit_users_array\n @work.datastreams[\"properties\"].delete\n @work.add_relationship(:has_image, \"info:fedora/\" + @image.pid)\n \n #update the Vrawork's VRA xml\n #note: the xml_template creates the VRA xml for a VRA image. Update the vra:image tags to vra:work\n @work.update_vra_work_tag\n \n @work.titleSet_display_work = titleSet_display\n \n #update the refid field in the vra xml\n @image.update_ref_id(@image.pid)\n @work.update_ref_id(@work.pid)\n \n #update the relation set in the vra xml for the image and work\n @image.update_relation_set(@work.pid)\n @work.update_relation_set(@image.pid)\n \n @work.save!\n \n \n @image.save!\n \n #add image to Uploads collection\n personal_collection = current_user.get_uploads_collection\n DILCollection.add_image_to_personal_collection(personal_collection, DIL_CONFIG['dil_uploads_collection'], @image, current_user.user_key)\n \n UploadFile.create(:user=>current_user, :pid=>@image.pid)\n \n else\n error = true\n logger.error(\"VIRUS_DETECTED: #{scan_result} : #{params[:files][0].tempfile.path}\")\n \n #delete file from file system\n File.delete params[:files][0].tempfile.path\n end\n \n respond_to do |format|\n if !error\n format.json { \n render :json => [@image.to_jq_upload].to_json\t\t\t\n }\n #custom error message, responds to AJAX call \n else\n format.json { \n render :json => \"[{\\\"error\\\":\\\"VIRUS DETECTED\\\"}]\"\n }\n end\n end\n \n end",
"def test05()\n imageFile = $directory + \"/images/DSCN0733.JPG\"\n baseImageName = \"rotatedimage_a05.jpg\"\n begin\n # Create the object that will contain the list of commands.\n theCommands = CommandModule::SmigCommands.new\n theCommands.saveresultstype = :lastcommandresult\n\n # Create the name for the importer object.\n importerName = SecureRandom.uuid\n \n createImporterCommand = CommandModule.make_createimporter(imageFile,\n name: importerName)\n theCommands.add_command(createImporterCommand)\n\n # Create the image importer object id so we can refer to it later on.\n imageImporterObject = SmigIDHash.make_objectid(objecttype: :imageimporter,\n objectname: importerName)\n\n # Get the dimensions of the image at image index 0 in the image file.\n # So we can calculate how big the bitmap context can be.\n imageDimensions = SpotlightCommand.get_imagedimensions(imageFile)\n\n # Create the bitmap context object command but first make the name\n bitmapContextName = SecureRandom.uuid\n createBitmapContextCommand = CommandModule.make_createbitmapcontext(\n width: imageDimensions[:width],\n height: imageDimensions[:height],\n name: bitmapContextName)\n\n # Add the create bitmap context to the list of commands\n theCommands.add_command(createBitmapContextCommand)\n\n # Create the bitmapcontext object id so we can refer to it later on.\n bitmapContextObject = SmigIDHash.make_objectid(objecttype: :bitmapcontext,\n objectname: bitmapContextName)\n\n # Prepare for the draw element action.\n # The draw element action will draw a rotated image into the bitmapcontext\n width = imageDimensions[:width] * 0.5\n height = imageDimensions[:height] * 0.5\n x = width * 0.5\n y = height * 0.5\n theSize = MIShapes.make_size(width, height)\n theOrigin = MIShapes.make_point(x, y)\n sourceRect = MIShapes.make_rectangle(size: theSize, origin: theOrigin)\n destRect = sourceRect\n drawImageElement = MIDrawImageElement.new()\n drawImageElement.set_imagefile_imagesource(source_object: imageImporterObject,\n imageindex: 0)\n drawImageElement.destinationrectangle = destRect\n drawImageElement.contextalpha = 0.5\n contextTransform = MITransformations.make_contexttransformation()\n MITransformations.add_translatetransform(contextTransform,\n { :x => width, :y => height })\n MITransformations.add_rotatetransform(contextTransform, Math::PI / 4.0)\n MITransformations.add_translatetransform(contextTransform,\n { :x => -width, :y => -height })\n drawImageElement.contexttransformations = contextTransform\n\n # Create the drawelement command.\n drawCommand = CommandModule.make_drawelement(bitmapContextObject,\n drawinstructions: drawImageElement)\n\n # Add the draw element command to the list of commands.\n theCommands.add_command(drawCommand)\n\n # Prepare for creating the image exporter object command\n tempFile = File.join(Dir.tmpdir(), baseImageName)\n # tempFile = File.join($compareImageDir, baseImageName)\n imageExporterName = SecureRandom.uuid\n \n # Make the image file export object command.\n createExporterCommand = CommandModule.make_createexporter(tempFile,\n export_type: \"public.jpeg\",\n name: imageExporterName)\n exporterObject = SmigIDHash.make_objectid(objecttype: :imageexporter,\n objectname: imageExporterName)\n theCommands.add_command(createExporterCommand)\n \n # Make the add an image to the exporter object command.\n addImageToExporterCommand = CommandModule.make_addimage(\n exporterObject, bitmapContextObject)\n theCommands.add_command(addImageToExporterCommand)\n \n # Make the do export command\n exportImageToFileCommand = CommandModule.make_export(exporterObject)\n theCommands.add_command(exportImageToFileCommand)\n\n # Add close object commands to the cleanup command list.\n theCommands.add_tocleanupcommands_closeobject(imageImporterObject)\n theCommands.add_tocleanupcommands_closeobject(bitmapContextObject)\n theCommands.add_tocleanupcommands_closeobject(exporterObject)\n\n # now actually carry out the commands.\n commandsHash = theCommands.commandshash\n $teststring = commandsHash.to_json\n theResult = Smig.perform_commands(commandsHash)\n origFile = File.join($compareImageDir, baseImageName)\n unless AreImageFilesSame(origFile, tempFile)\n raise \"Different image files: \" + origFile + \" and \" + tempFile\n end\n rescue RuntimeError => e\n $errorcode = Smig.exitvalue\n unless $errorcode.zero?\n puts \"Exit string: \" + Smig.exitstring\n puts $teststring + \" Exit status: \" + $errorcode.to_s\n end\n puts e.message\n puts e.backtrace.to_s\n# exit 240\n ensure\n unless tempFile.nil?\n FileUtils.rm_f(tempFile)\n # Open3.capture2(\"open\", tempFile)\n # Open3.capture2(\"open\", origFile)\n end\n end\nend",
"def test04()\n imageFile = $directory + \"/images/DSCN0733.JPG\"\n baseImageName = \"rotatedimage2.jpg\"\n begin\n theCommands = CommandModule::SmigCommands.new\n theCommands.saveresultstype = :lastcommandresult\n importerName = SecureRandom.uuid\n createImporterCommand = CommandModule.make_createimporter(imageFile,\n name: importerName)\n imageImporterObject = SmigIDHash.make_objectid(objecttype: :imageimporter,\n objectname: importerName)\n theCommands.add_command(createImporterCommand)\n theCommands.add_tocleanupcommands_closeobject(imageImporterObject)\n imageDimensions = SpotlightCommand.get_imagedimensions(imageFile)\n windowContextName = SecureRandom.uuid\n createWindowContextCommand = CommandModule.make_createwindowcontext(\n width: imageDimensions[:width],\n height: imageDimensions[:height],\n name: windowContextName)\n windowContextObject = SmigIDHash.make_objectid(\n objecttype: :nsgraphicscontext,\n objectname: windowContextName)\n theCommands.add_command(createWindowContextCommand)\n theCommands.add_tocleanupcommands_closeobject(windowContextObject)\n\n # Need to initialize the window to having a white background.\n windowRect = MIShapes.make_rectangle(size: imageDimensions,\n origin: { :x => 0, :y => 0 } )\n whiteColor = MIColor.make_rgbacolor(1.0, 1.0, 1.0)\n drawBackgroundElement = MIDrawElement.new(:fillrectangle)\n drawBackgroundElement.rectangle = windowRect\n drawBackgroundElement.fillcolor = whiteColor\n \n theSize = MIShapes.make_size(imageDimensions[:width] * 0.5,\n imageDimensions[:height] * 0.5)\n theOrigin = MIShapes.make_point(imageDimensions[:width] * 0.25,\n imageDimensions[:height] * 0.25)\n sourceRect = MIShapes.make_rectangle(size: theSize, origin: theOrigin)\n destRect = sourceRect\n drawImageElement = MIDrawImageElement.new()\n drawImageElement.set_imagefile_imagesource(source_object: imageImporterObject,\n imageindex: 0)\n drawImageElement.destinationrectangle = destRect\n affineTransform = MITransformations.make_affinetransform(\n m11: 0.707, m12: 0.707, m21: -0.707,\n m22: 0.707, tX: 373.74, tY: -221.29)\n drawImageElement.affinetransform = affineTransform\n drawElements = MIDrawElement.new(:arrayofelements)\n drawElements.add_drawelement_toarrayofelements(drawBackgroundElement)\n drawElements.add_drawelement_toarrayofelements(drawImageElement)\n # With the draw element put together, now create the draw element command\n drawCommand = CommandModule.make_drawelement(windowContextObject,\n drawinstructions: drawElements)\n theCommands.add_command(drawCommand)\n tempFile = File.join(Dir.tmpdir(), baseImageName)\n imageExporterName = SecureRandom.uuid\n createExporterCommand = CommandModule.make_createexporter(tempFile,\n export_type: \"public.jpeg\",\n name: imageExporterName)\n exporterObject = SmigIDHash.make_objectid(objecttype: :imageexporter,\n objectname: imageExporterName)\n theCommands.add_command(createExporterCommand)\n theCommands.add_tocleanupcommands_closeobject(exporterObject)\n addImageToExporterCommand = CommandModule.make_addimage(\n exporterObject, windowContextObject)\n theCommands.add_command(addImageToExporterCommand)\n exportImageToFileCommand = CommandModule.make_export(exporterObject)\n theCommands.add_command(exportImageToFileCommand)\n commandsHash = theCommands.commandshash\n $teststring = commandsHash.to_json\n theResult = Smig.perform_commands(commandsHash)\n puts \"The result is: \" + theResult unless theResult.length.zero?\n\n origFile = File.join($compareImageDir, baseImageName)\n unless AreImageFilesSame(origFile, tempFile, 0)\n raise \"Different image files: \" + origFile + \" and \" + tempFile\n end\n rescue RuntimeError => e\n $errorcode = Smig.exitvalue\n unless $errorcode.zero?\n puts \"Exit string: \" + Smig.exitstring\n puts $teststring + \" Exit status: \" + $errorcode.to_s\n end\n puts e.message\n puts e.backtrace.to_s\n# exit 240\n ensure\n FileUtils.rm_f(tempFile) unless tempFile.nil?\n # Open3.capture2(\"open\", tempFile)\n # Open3.capture2(\"open\", origFile)\n end\nend",
"def initialize(image_path, playout_path,\n outfile: nil,\n dev: nil,\n use_system_grub_tools: false)\n\n @tempfile = nil\n\n raise ArgumentError, \"Missing image file\" unless File.exists?(image_path)\n\n @image_tarball_path = image_path\n\n raise ArgumentError, \"Missing layout file\" unless File.exists?(playout_path)\n\n parts = JSON.parse(File.read(playout_path))\n\n raise ArgumentError, \"Partition not an Array\" unless parts.kind_of?(Array)\n\n @partition_layout = (bootloader_partitions + parts).map { |p| DeepStruct.new(p) }\n\n self.validate_partition_layout()\n\n if outfile\n @outfile = outfile\n end\n\n if dev\n @dev = dev\n self.validate_disk_size\n end\n\n if dev.nil? and outfile.nil?\n raise ArgumentError, \"No output file OR device specified!\"\n end\n\n @use_systemwide_grub_tools = use_system_grub_tools\n end",
"def get_1st_partition(device)\n # Resolves the real device name (ex. /dev/sdg)\n Chef::Log.info(\"Getting 1st partition for device: #{device}\")\n fs_check = Mixlib::ShellOut.new(\"lsblk -ln -o Name #{device}|awk 'NR==2'\")\n fs_check.run_command\n partition = \"/dev/\" + fs_check.stdout.strip\n Chef::Log.info(\"1st partition for device: #{device} is: #{partition}\")\n partition\nend",
"def deactivate_partitions\n # First deactive lvm vgs that may have been setup during\n lvm_parts = @partition_layout.select { |p| p.lvm != nil }\n lvm_parts.each { |p|\n p.lvm.volumes.each { |v|\n execute!(\"lvchange -an #{p.lvm.vg_name}/#{v.label}\")\n }\n execute!(\"vgchange -an #{p.lvm.vg_name}\")\n # Running vgexport seems to be problematic (it reimports LVs!)\n # execute!(\"vgexport #{p.lvm.vg_name}\")\n # Run this if you want to be *sure* all LVs have been removed\n # execute!(\"dmsetup -v remove /dev/#{p.lvm.vg_name}/* || true\")\n }\n\n # Then deal with removal of normal partitions from the loopback device\n # else we leak /dev/loopNp{1,2,3}\n sleep(2) # avoid race\n execute!(\"sync\")\n # Print some debugging info (in case the following call to partx fails)\n # execute!(\"dmsetup info || true\")\n execute!(\"partx -d -v #{@dev}\")\n end",
"def test02()\n imageFile = $directory + \"/images/DSCN0733.JPG\"\n baseImageName = \"rotatedimage.jpg\"\n begin\n # Create the object that will contain the list of commands.\n theCommands = CommandModule::SmigCommands.new\n theCommands.saveresultstype = :lastcommandresult\n\n # Create the name for the importer object.\n importerName = SecureRandom.uuid\n \n createImporterCommand = CommandModule.make_createimporter(imageFile,\n name: importerName)\n theCommands.add_command(createImporterCommand)\n\n # Create the image importer object id so we can refer to it later on.\n imageImporterObject = SmigIDHash.make_objectid(objecttype: :imageimporter,\n objectname: importerName)\n\n # Get the dimensions of the image at image index 0 in the image file.\n # So we can calculate how big the bitmap context can be.\n imageDimensions = SpotlightCommand.get_imagedimensions(imageFile)\n\n # Create the bitmap context object command but first make the name\n bitmapContextName = SecureRandom.uuid\n createBitmapContextCommand = CommandModule.make_createbitmapcontext(\n width: imageDimensions[:width],\n height: imageDimensions[:height],\n name: bitmapContextName)\n\n # Add the create bitmap context to the list of commands\n theCommands.add_command(createBitmapContextCommand)\n\n # Create the bitmapcontext object id so we can refer to it later on.\n bitmapContextObject = SmigIDHash.make_objectid(objecttype: :bitmapcontext,\n objectname: bitmapContextName)\n\n # Prepare for the draw element action.\n # The draw element action will draw a rotated image into the bitmapcontext\n width = imageDimensions[:width] * 0.5\n height = imageDimensions[:height] * 0.5\n x = width * 0.5\n y = height * 0.5\n theSize = MIShapes.make_size(width, height)\n theOrigin = MIShapes.make_point(x, y)\n sourceRect = MIShapes.make_rectangle(size: theSize, origin: theOrigin)\n destRect = sourceRect\n drawImageElement = MIDrawImageElement.new()\n drawImageElement.set_imagefile_imagesource(source_object: imageImporterObject,\n imageindex: 0)\n drawImageElement.destinationrectangle = destRect\n contextTransform = MITransformations.make_contexttransformation()\n MITransformations.add_translatetransform(contextTransform,\n { :x => width, :y => height })\n MITransformations.add_rotatetransform(contextTransform, Math::PI / 4.0)\n MITransformations.add_translatetransform(contextTransform,\n { :x => -width, :y => -height })\n drawImageElement.contexttransformations = contextTransform\n\n # Create the drawelement command.\n drawCommand = CommandModule.make_drawelement(bitmapContextObject,\n drawinstructions: drawImageElement)\n\n # Add the draw element command to the list of commands.\n theCommands.add_command(drawCommand)\n\n # Prepare for creating the image exporter object command\n tempFile = File.join(Dir.tmpdir(), baseImageName)\n imageExporterName = SecureRandom.uuid\n \n # Make the image file export object command.\n createExporterCommand = CommandModule.make_createexporter(tempFile,\n export_type: \"public.jpeg\",\n name: imageExporterName)\n exporterObject = SmigIDHash.make_objectid(objecttype: :imageexporter,\n objectname: imageExporterName)\n theCommands.add_command(createExporterCommand)\n \n # Make the add an image to the exporter object command.\n addImageToExporterCommand = CommandModule.make_addimage(\n exporterObject, bitmapContextObject)\n theCommands.add_command(addImageToExporterCommand)\n \n # Make the do export command\n exportImageToFileCommand = CommandModule.make_export(exporterObject)\n theCommands.add_command(exportImageToFileCommand)\n\n # Add close object commands to the cleanup command list.\n theCommands.add_tocleanupcommands_closeobject(imageImporterObject)\n theCommands.add_tocleanupcommands_closeobject(bitmapContextObject)\n theCommands.add_tocleanupcommands_closeobject(exporterObject)\n\n # now actually carry out the commands.\n commandsHash = theCommands.commandshash\n $teststring = commandsHash.to_json\n theResult = Smig.perform_commands(commandsHash)\n origFile = File.join($compareImageDir, baseImageName)\n unless AreImageFilesSame(origFile, tempFile)\n raise \"Different image files: \" + origFile + \" and \" + tempFile\n end\n rescue RuntimeError => e\n $errorcode = Smig.exitvalue\n unless $errorcode.zero?\n puts \"Exit string: \" + Smig.exitstring\n puts $teststring + \" Exit status: \" + $errorcode.to_s\n end\n puts e.message\n puts e.backtrace.to_s\n# exit 240\n ensure\n unless tempFile.nil?\n FileUtils.rm_f(tempFile)\n # Open3.capture2(\"open\", origFile)\n # Open3.capture2(\"open\", tempFile)\n end\n end\nend",
"def test02()\n sourceImage = File.join($directory, \"images/test002image.jpg\")\n begin \n # Create the list of commands object, ready to have commands added to it.\n theCommands = SmigCommands.new\n theCommands.saveresultstype = :lastcommandresult\n\n # 1. Create image importer\n importerName = SecureRandom.uuid\n imageImporterObject = theCommands.make_createimporter(sourceImage,\n name: importerName, addtocleanup: false)\n\n # 2. Create bitmap context.\n imageSize = MIShapes.make_size(336, 600)\n destRect = MIShapes.make_rectangle(size: imageSize)\n bitmapObject = theCommands.make_createbitmapcontext(size: imageSize)\n \n # 3. Draw the image in the image collection to the window context.\n drawImageElement = MIDrawImageElement.new()\n drawImageElement.set_imagefile_imagesource(source_object: imageImporterObject)\n drawImageElement.destinationrectangle = destRect\n drawElementCommand = CommandModule.make_drawelement(bitmapObject,\n drawinstructions: drawImageElement, createimage: false)\n theCommands.add_command(drawElementCommand)\n\n # 4. Assign to the image collection an image generated from the bitmap context\n imageId = SecureRandom.uuid\n assignBitmapImageCommand = CommandModule.make_assignimage_tocollection(\n bitmapObject, identifier: imageId)\n theCommands.add_command(assignBitmapImageCommand)\n\n # 5. Create window context.\n winRect = MIShapes.make_rectangle(origin: { x: 100, y: 50 },\n size: imageSize)\n windowObject = theCommands.make_createwindowcontext(rect: winRect,\n addtocleanup: false)\n \n # 6. Draw the image in the image collection to the window context.\n drawImageElement = MIDrawImageElement.new()\n drawImageElement.set_imagecollection_imagesource(identifier: imageId)\n drawImageElement.destinationrectangle = destRect\n \n drawElementCommand = CommandModule.make_drawelement(\n windowObject, drawinstructions: drawImageElement, createimage: false)\n theCommands.add_command(drawElementCommand)\n # 7 will happen here in the cleanup commands.\n Smig.perform_commands(theCommands)\n \n # 8. Attempt to draw the image from collection again to window context.\n # The first lot of commands to be run have run. I've split up the performing\n # of commands so that we get to see the content actually drawn to the window.\n theCommands = SmigCommands.new\n theCommands.saveresultstype = :lastcommandresult\n\n theCommands.add_command(drawElementCommand)\n \n # 9. Remove the image from the image collection\n removeCommand = CommandModule.make_removeimage_fromcollection(imageId)\n theCommands.add_command(removeCommand)\n Smig.perform_commands(theCommands)\n \n # 10. Now attempt to draw the image again and catch the error.\n begin\n Smig.perform_command(drawElementCommand)\n puts \"We shouldn't get here as perform command should have an exception\"\n puts \"File: #{$filename}, Line: #{__LINE__}\"\n rescue\n end\n\n # 11. Assign to the image colection an image generated from the image importer.\n theCommands = SmigCommands.new\n theCommands.saveresultstype = :lastcommandresult\n imageId2 = SecureRandom.uuid\n assignImageCommand = CommandModule.make_assignimage_fromimporter_tocollection(\n imageImporterObject, imageindex: 0, identifier: imageId2)\n theCommands.add_command(assignImageCommand)\n\n # 12. Draw the new image in the image collection to the window object\n drawImageElement = MIDrawImageElement.new()\n drawImageElement.set_imagecollection_imagesource(identifier: imageId2)\n drawImageElement.destinationrectangle = destRect\n \n drawElementCommand = CommandModule.make_drawelement(\n windowObject, drawinstructions: drawImageElement, createimage: false)\n theCommands.add_command(drawElementCommand)\n Smig.perform_commands(theCommands)\n \n # 13. Close the image importer after creating a new command list.\n theCommands = SmigCommands.new\n theCommands.saveresultstype = :lastcommandresult\n closeCommand = CommandModule.make_close(imageImporterObject)\n theCommands.add_command(closeCommand)\n \n # 14. Draw the image in the image collection to window object again.\n theCommands.add_command(drawElementCommand)\n \n # 15. Remove the image from the image collection.\n removeCommand = CommandModule.make_removeimage_fromcollection(imageId2)\n theCommands.add_command(removeCommand)\n \n Smig.perform_commands(theCommands)\n\n # 16. Attempt to draw the removed image again, and catch failure.\n begin\n Smig.perform_command(drawElementCommand)\n puts \"We shouldn't get here as perform command should have an exception\"\n puts \"File: #{$filename}, Line: #{__LINE__}\"\n rescue\n end\n\n # 17. Assign an image from the window context to the image collection.\n imageId3 = SecureRandom.uuid\n assignCommand = CommandModule.make_assignimage_tocollection(windowObject,\n identifier: imageId3)\n theCommands = SmigCommands.new\n theCommands.saveresultstype = :lastcommandresult\n theCommands.add_command(assignCommand)\n \n # 18. Now close the window context.\n theCommands.add_command(CommandModule.make_close(windowObject))\n \n # 19. Now remove the image from the image collection.\n removeCommand = CommandModule.make_removeimage_fromcollection(imageId2)\n theCommands.add_command(removeCommand)\n Smig.perform_commands(theCommands)\n\n rescue RuntimeError => e\n $errorcode = Smig.exitvalue\n unless $errorcode.zero?\n puts \"Exit string: \" + Smig.exitstring\n puts \" Exit status: \" + $errorcode.to_s\n end\n puts e.message\n puts e.backtrace.to_s\n end\nend",
"def upload_thumb\n path = \"#{Rails.root}/tmp/#{id}_#{Process.pid}.png\"\n `convert #{@file.tempfile.path}[0] -scale 128x128 #{path}`\n\n if File.exists? path\n file_s3_obj_thumb.write(file: path, content_type: 'image/png')\n File.delete(path)\n end\n end"
] |
[
"0.68787396",
"0.65255797",
"0.641545",
"0.62146753",
"0.5831584",
"0.57129085",
"0.5710913",
"0.5696141",
"0.5632923",
"0.5624845",
"0.55377704",
"0.5428235",
"0.54141676",
"0.5406065",
"0.53421277",
"0.5280142",
"0.5260895",
"0.52310866",
"0.5201961",
"0.5164563",
"0.51001763",
"0.5088386",
"0.5087289",
"0.50722605",
"0.50323004",
"0.50314665",
"0.5020111",
"0.5004354",
"0.5003514",
"0.49938354",
"0.49908072",
"0.49840596",
"0.4976633",
"0.49726883",
"0.49642342",
"0.4960144",
"0.49573588",
"0.49519858",
"0.49388045",
"0.49332857",
"0.49308792",
"0.49126104",
"0.49030036",
"0.48981905",
"0.48975044",
"0.48955956",
"0.4859364",
"0.48578128",
"0.48513633",
"0.4831708",
"0.4827593",
"0.47939646",
"0.47768483",
"0.477606",
"0.47626933",
"0.47604012",
"0.4759602",
"0.474249",
"0.47367734",
"0.47310898",
"0.47294927",
"0.4724256",
"0.47230753",
"0.47230753",
"0.47170472",
"0.46954393",
"0.4668897",
"0.46680936",
"0.46677604",
"0.4661315",
"0.46603158",
"0.46582133",
"0.46538523",
"0.4651735",
"0.4638203",
"0.46158782",
"0.4614703",
"0.4612819",
"0.4612755",
"0.46085793",
"0.46077463",
"0.46071285",
"0.4601503",
"0.4597993",
"0.45912325",
"0.45862564",
"0.4584899",
"0.45822528",
"0.45787567",
"0.45766082",
"0.45726198",
"0.45707166",
"0.4565651",
"0.4561305",
"0.45586064",
"0.45585936",
"0.4557744",
"0.45542985",
"0.4553308",
"0.4538274"
] |
0.68463033
|
1
|
Change partition (configuration, web or code).
|
def changepartition(partition, filename)
baseaddress = PARTITIONS['boot'][START]
size = partition[SIZE]
partdata = Flashimage.read(filename)
length = partdata.size
last = partition[SIZE]
raise('Input file too large.') if length + 12 > last
crc32 = Zlib.crc32(partdata)
partdata[length ... last - 12] = "\xff" * (last - length - 12)
partdata[last - 12 ... last] = [length, 0x12345678, crc32].pack('V3')
filename = "#{File.dirname(FLASHIMAGE)}/#{partition[FILE]}"
Flashimage.write(partdata, filename)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_partition\n @partition = Partition.find(params[:id])\n end",
"def setPartitionType(settings)\n settings = deep_copy(settings)\n tm = Storage.GetTargetMap\n settings = Builtins.maplist(settings) do |d|\n if Ops.get_symbol(d, \"type\", :x) == :CT_DISK\n mp = Ops.get_integer(\n tm,\n [Ops.get_string(d, \"device\", \"xxx\"), \"max_primary\"],\n 0\n )\n if Ops.greater_than(mp, 0)\n Ops.set(\n d,\n \"partitions\",\n Builtins.maplist(Ops.get_list(d, \"partitions\", [])) do |pe|\n if Builtins.haskey(pe, \"partition_nr\") &&\n !Builtins.haskey(pe, \"partition_type\") &&\n Ops.less_or_equal(\n Ops.get_integer(pe, \"partition_nr\", -1),\n mp\n )\n Ops.set(pe, \"partition_type\", \"primary\")\n end\n deep_copy(pe)\n end\n )\n end\n end\n deep_copy(d)\n end\n Builtins.y2milestone(\"after setPartitionType = %1\", settings)\n deep_copy(settings)\n end",
"def partition_device\n Souffle::Log.info \"#{@node.log_prefix} Partitioning the device...\"\n provider.partition(@node)\n end",
"def set_partition_usage(host, partition, usage)\n self.client.set(\"gh.storage.server.usage.percent.#{host}.#{partition}\", usage.to_s)\n end",
"def SetFormatPartitions(fstabpart)\n fstabpart = deep_copy(fstabpart)\n # All storage devices\n target_map = Storage.GetTargetMap\n\n # all activated\n tmp = Builtins.filter(RootPart.GetActivated) do |e|\n Ops.get_string(e, :type, \"\") == \"mount\" ||\n Ops.get_string(e, :type, \"\") == \"swap\"\n end\n\n Builtins.foreach(tmp) do |e|\n mntpt = Ops.get_string(e, :type, \"\") == \"swap\" ?\n \"swap\" :\n Ops.get_string(e, :mntpt, \"\")\n part = Ops.get_string(e, :device, \"\")\n p = {}\n Builtins.foreach(fstabpart) do |pp|\n # mountpoint matches\n if Ops.get_string(pp, \"mount\", \"\") == mntpt\n p = deep_copy(pp)\n raise Break\n end\n end\n mount_options = \"\"\n Builtins.foreach(Storage.ReadFstab(Installation.destdir)) do |entry|\n if Ops.get_string(entry, \"file\", \"\") == mntpt\n mount_options = Ops.get_string(entry, \"mntops\", \"\")\n raise Break\n end\n end\n target_map = Storage.SetPartitionData(target_map, part, \"mount\", mntpt)\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"format\",\n Ops.get_boolean(p, \"format\", false)\n )\n target_map = Storage.SetPartitionData(target_map, part, \"delete\", false)\n target_map = Storage.SetPartitionData(target_map, part, \"create\", false)\n if Builtins.haskey(p, \"filesystem\")\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"filesystem\",\n Ops.get_symbol(p, \"filesystem\", :ext4)\n )\n end\n if Ops.greater_than(Builtins.size(mount_options), 0) &&\n !Builtins.haskey(p, \"fstopt\")\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"fstopt\",\n mount_options\n )\n end\n if Builtins.haskey(p, \"fstopt\")\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"fstopt\",\n Ops.get_string(p, \"fstopt\", \"\")\n )\n end\n if Builtins.haskey(p, \"mountby\")\n target_map = Storage.SetPartitionData(\n target_map,\n part,\n \"mountby\",\n Ops.get_symbol(p, \"mountby\", :device)\n )\n end\n end\n\n Storage.SetTargetMap(target_map)\n true\n end",
"def FSCKPartition(partition)\n if !Mode.test\n detected_fs = Storage.DetectFs(partition)\n if detected_fs == :ext2\n # label, %1 is partition\n out = Builtins.sformat(_(\"Checking partition %1\"), partition)\n UI.OpenDialog(Opt(:decorated), Label(out))\n\n Builtins.y2milestone(\"command: /sbin/e2fsck -y %1\", partition)\n SCR.Execute(\n path(\".target.bash\"),\n Ops.add(\"/sbin/e2fsck -y \", partition)\n )\n\n UI.CloseDialog\n end\n end\n\n nil\n end",
"def ResizePartition(device, disk, new_cyls)\n Builtins.y2milestone(\n \"ResizePartition device:%1 disk:%2 new_cyls:%3\",\n device,\n disk,\n new_cyls\n )\n ret = @sint.resizePartition(device, new_cyls)\n if ret<0\n Builtins.y2error(\"ResizePartition sint ret:%1\", ret)\n end\n UpdateTargetMapDisk(disk)\n ret == 0\n end",
"def create_partition_to_fill_disk(disk)\n # @disk.create_partition('primary', '100%')\n disk.create_partition_table # LinuxAdmin::Disk.create_partition has this already...\n AwesomeSpawn.run!(\"parted -s #{disk.path} mkpart primary 0% 100%\")\n\n # FIXME: Refetch the disk after creating the partition\n disk = LinuxAdmin::Disk.local.find { |d| d.path == disk.path }\n disk.partitions.first\n end",
"def add_partition_to_node( tp, node )\n\n @nodes_lists_replicas[node][tp] = ''\n @partitions_lists[tp]['replicas'] ||= {}\n @partitions_lists[tp]['replicas'][node] = ''\n end",
"def SetPartitionFormat(device, format, fs)\n Builtins.y2milestone(\n \"SetPartitionFormat device:%1 format:%2 fs:%3\",\n device,\n format,\n fs\n )\n tmp = fromSymbol(FileSystems.conv_fs, fs)\n Builtins.y2milestone(\"SetPartitionFormat fs:%1\", tmp)\n ret = @sint.changeFormatVolume(device, format, tmp)\n if ret<0\n Builtins.y2error(\"SetPartitionFormat sint ret:%1\", ret)\n end\n UpdateTargetMapDev(device)\n ret == 0\n end",
"def create_partition device, partition_type = 'primary', start_unit, end_unit\n command = 'parted'\n params = \"#{device.path} -s -a optimal unit MB mkpart #{partition_type} ext3 #{start_unit} -- #{end_unit}\"\n parted = CommandsExecutor.new command, params\n parted.execute\n raise \"Command execution error: #{parted.stderr.read}\" if not parted.success?\n probe_kernal device\n end",
"def CreatePartition(disk, device, ptype, id, start, len, mby)\n Builtins.y2milestone(\n \"CreatePartition disk:%1 device:%2 ptype:%3 id:%4 start:%5 len:%6 mby:%7\",\n disk,\n device,\n ptype,\n id,\n start,\n len,\n mby\n )\n pt = fromSymbol(@conv_ptype, ptype)\n Builtins.y2milestone(\"CreatePartition type:%1 pt:%2\", ptype, pt)\n ret, cdev = @sint.createPartition(disk, pt, start, len)\n cdev = \"\" if ret<0\n if device != cdev\n Builtins.y2error(\"CreatePartition device:%1 cdev:%2\", device, cdev)\n end\n Builtins.y2error(\"CreatePartition ret %1\", ret) if ret<0\n ret = @sint.changePartitionId(device, id)\n Builtins.y2error(\"CreatePartition ret %1\", ret) if ret<0\n tmp = fromSymbol(@conv_mountby, mby)\n @sint.changeMountBy(device, tmp)\n Builtins.y2milestone(\"CreatePartition sint ret:%1\", ret)\n UpdateTargetMap()\n ret == 0\n end",
"def update!(**args)\n @partition_key = args[:partition_key] if args.key?(:partition_key)\n end",
"def SetPartitionMount(device, mp)\n Builtins.y2milestone(\"SetPartitionMount device:%1 mp:%2\", device, mp)\n ret = @sint.changeMountPoint(device, mp)\n if ret<0\n Builtins.y2error(\"SetPartitionMount sint ret:%1\", ret)\n end\n UpdateTargetMapDev(device)\n ret == 0\n end",
"def partition!(id)\n partition(id) || ErrorCode[:unknown_topic_or_partition].raise\n end",
"def partition_list()\nend",
"def set_variation_storage_type\n cid = VirtualMonkey::Toolbox::determine_cloud_id(s_one)\n if cid == 232\n @storage_type = \"ros\"\n else\n pick = rand(100000) % 2\n if pick == 1\n @storage_type = \"ros\"\n else\n @storage_type = \"volume\"\n end\n end\n \n @storage_type = ENV['STORAGE_TYPE'] if ENV['STORAGE_TYPE']\n puts \"STORAGE_TYPE: #{@storage_type}\"\n @deployment.nickname += \"-STORAGE_TYPE_#{@storage_type}\"\n @deployment.save\n \n obj_behavior(@deployment, :set_input, \"db_mysql/backup/storage_type\", \"text:#{@storage_type}\")\n end",
"def partition_params\n params.require(:partition).permit(:name, :body, :chapter_id)\n end",
"def create_partitions\n info(\"Creating disk with #{PARTITION_TABLE_TYPE} parition table\")\n execute!(\"parted -s #{@dev} mklabel #{PARTITION_TABLE_TYPE}\")\n\n start_size = FIRST_PARTITION_OFFSET\n end_size = FIRST_PARTITION_OFFSET\n\n unspec_part = nil\n\n # Create the partitions\n @partition_layout.each_with_index do |part, index|\n # Deal with any \"open ended\" partitions last\n if not part.size_mb.is_a?(Integer)\n unspec_part = part\n next\n end\n\n start_size = end_size\n end_size += part.size_mb\n\n info(\"Creating partition #{part.label} (#{part.fs}, #{part.size_mb}MiB)\")\n execute!(\"parted #{@dev} mkpart #{part.label} #{part.fs} #{start_size}MiB #{end_size}MiB\")\n\n (part.flags || {}).each_pair { |k, v|\n info(\"Setting partition flag #{k} to #{v}\")\n execute!(\"parted #{@dev} set #{index + 1} #{k} #{v}\")\n }\n\n label_path = \"/dev/disk/by-partlabel/#{part.label}\"\n self.wait_for_device(label_path)\n\n if not part.fs\n warn(\"No filesystem specified for #{part.label}. Skipping FS\")\n else\n create_filesystem(part.fs, label_path, part.label)\n end\n\n if part.lvm\n notice(\"Setting up LVM on #{part.label}\")\n setup_lvm_on_partition(part)\n end\n end\n\n # Deal with any \"open ended\" partitions (that have an unspecified size_mb)\n if unspec_part\n part = unspec_part\n info(\"Creating partition #{part.label} (#{part.fs}, 100% remaining)\")\n execute!(\"parted #{@dev} mkpart #{part.label} #{part.fs} #{end_size}MiB 100%\")\n\n (part.flags || {}).each_pair { |k, v|\n info(\"Setting partition flag #{k} to #{v}\")\n execute!(\"parted #{@dev} set #{@partition_layout.length} #{k} #{v}\")\n }\n\n label_path = \"/dev/disk/by-partlabel/#{part.label}\"\n self.wait_for_device(label_path)\n create_filesystem(part.fs, label_path, part.label) if part.fs\n\n if part.lvm\n notice(\"Setting up LVM on #{part.label}\")\n setup_lvm_on_partition(part)\n end\n end\n\n nil\n end",
"def configure_disks(vb, server, hostname, name)\n vminfo = vm_info(name)\n disks = server['disks'] || {}\n unless vminfo =~ /Storage Controller Name \\(1\\): *SATA Controller/\n # puts \"Attaching SATA Controller\"\n vb.customize [\n 'storagectl', :id,\n '--name', 'SATA Controller',\n '--add', 'sata',\n '--portcount', disks.size\n ]\n # else\n # puts 'SATA Controller already attached'\n end\n\n disks.each_with_index do |disk, i|\n disk_name = disk.first\n disk_size = disk.last['size']\n disk_uuid = disk.last['uuid']\n real_uuid = \"00000000-0000-0000-0000-#{disk_uuid.rjust(12,'0')}\"\n if server['cluster']\n disk_filename = File.join(VAGRANT_ROOT, \"#{disk_name}_#{server['cluster']}.vdi\")\n else\n disk_filename = File.join(VAGRANT_ROOT, \"#{disk_name}.vdi\")\n end\n\n if File.file?(disk_filename)\n # puts \"Disk #{disk_filename} already created\"\n disk_hash = `VBoxManage showmediuminfo \"#{disk_filename}\"`.scan(/(.*): *(.*)/).to_h\n current_uuid = disk_hash['UUID']\n else\n # puts \"Creating disk #{disk_filename}\"\n current_uuid = '0'\n if server['cluster']\n vb.customize [\n 'createhd',\n '--filename', disk_filename,\n '--size', disk_size.to_s,\n '--variant', 'Fixed'\n ]\n vb.customize [\n 'modifyhd', disk_filename,\n '--type', 'shareable'\n ]\n else\n vb.customize [\n 'createhd',\n '--filename', disk_filename,\n '--size', disk_size.to_s,\n '--variant', 'Standard'\n ]\n end\n end\n\n # Conditional for adding disk_uuid\n if server['cluster'] && current_uuid == real_uuid\n # puts \"Attaching shareable disk #{disk_filename}\"\n vb.customize [\n 'storageattach', :id,\n '--storagectl', 'SATA Controller',\n '--port', (i + 1).to_s,\n '--device', 0,\n '--type', 'hdd',\n '--medium', disk_filename,\n '--mtype', 'shareable'\n ]\n elsif server['cluster']\n # puts \"Attaching shareable disk #{disk_filename}, adding UUID #{real_uuid}\"\n vb.customize [\n 'storageattach', :id,\n '--storagectl', 'SATA Controller',\n '--port', (i + 1).to_s,\n '--device', 0,\n '--type', 'hdd',\n '--medium', disk_filename,\n '--mtype', 'shareable',\n '--setuuid', real_uuid\n ]\n elsif current_uuid == real_uuid\n # puts \"Attaching normal disk #{disk_filename}\"\n vb.customize [\n 'storageattach', :id,\n '--storagectl', 'SATA Controller',\n '--port', (i + 1).to_s,\n '--device', 0,\n '--type', 'hdd',\n '--medium', disk_filename\n ]\n else\n # puts \"Attaching normal disk #{disk_filename}, adding UUID #{real_uuid}\"\n vb.customize [\n 'storageattach', :id,\n '--storagectl', 'SATA Controller',\n '--port', (i + 1).to_s,\n '--device', 0,\n '--type', 'hdd',\n '--medium', disk_filename,\n '--setuuid', real_uuid\n ]\n end\n end\nend",
"def create\n begin\n # Set the partition (/dev/sdb1), device (/dev/sdb) and alignment (optimal,minimal,none etc.) variables\n partition= resource[:name]\n device=partition[0,(partition.length-1)]\n alignment= resource[:alignment]\n\n # Now we can create the partition\n partitions = parted('-a', resource[:alignment],'--script',device,'mklabel',resource[:part_label],'mkpart', resource[:part_type],resource[:fs_type],resource[:p_begin],resource[:p_end])\n rescue Puppet::ExecutionFailure => e\n false\n end\n end",
"def set_partition(arg)\n if arg =~ /-/\n args = arg.split('-')\n arg1 = args[0]\n arg2 = args[1]\n else\n arg1 = arg\n arg2 = ''\n end\n\n partition = ''\n if arg1 == 'short' or arg1 == 's'\n partition = '-p tsl-short'\n elsif arg1 == 'med' or arg1 == 'm'\n partition = '-p tsl-medium'\n elsif arg1 == 'long' or arg1 == 'l'\n partition = '-p tsl-long'\n else\n warn \"incorrect queue. use either short or med or long queue\"\n exit\n end\n\n time = ''\n unless arg2 == ''\n number = /^(\\d+)\\w/.match(arg2)[1].to_i\n format = /^\\d+(\\w)/.match(arg2)[1].to_s\n if format == 'm' or format == 'mins'\n time = \"-t 00:#{number}:00\"\n elsif format == 'h' or format == 'hrs'\n time = \"-t #{number}:00:00\"\n elsif format == 'd' or format == 'days'\n time = \"-t #{number}-00:00:00\"\n else\n time = ''\n end\n end\n [partition, time]\nend",
"def set(partition, field, value)\n partition = deep_copy(partition)\n value = deep_copy(value)\n AutoinstCommon.set(@fields, partition, field, value)\n end",
"def addPartition(ptStr)\n @mOdpsTable.addPartition(ptStr)\n end",
"def UnchangePartitionId(device)\n Builtins.y2milestone(\"UnchangePartitionId device:%1\", device)\n ret = @sint.forgetChangePartitionId(device)\n if ret<0\n Builtins.y2error(\"UnchangePartitionId sint ret:%1\", ret)\n end\n UpdateTargetMapDev(device)\n ret == 0\n end",
"def set_part\n @part = Part.find(params[:id])\n # authorize(@part)\n end",
"def update!(**args)\n @partition_count = args[:partition_count] if args.key?(:partition_count)\n end",
"def CheckPartition(partition)\n partition = deep_copy(partition)\n freshman = {\n :valid => false,\n :name => \"unknown\",\n :arch => \"unknown\",\n :label => Ops.get_string(partition, \"label\", \"\"),\n :fs => Ops.get_symbol(partition, \"detected_fs\", :unknown),\n :fstype => Ops.get_string(partition, \"fstype\", \"unknown\")\n }\n\n p_dev = Ops.get_string(partition, \"device\", \"error\")\n p_fsid = Ops.get_integer(partition, \"fsid\", 0)\n p_type = Ops.get_symbol(partition, \"type\", :primary)\n p_detect_fs = Ops.get_symbol(partition, \"detected_fs\", :unknown)\n\n # possible root FS\n if Builtins.contains(FileSystems.possible_root_fs, p_detect_fs)\n mt_map = {\n :ext2 => \"ext2\",\n :ext3 => \"ext3\",\n :ext4 => \"ext4\",\n :btrfs => \"btrfs\",\n :reiser => \"reiserfs\",\n :xfs => \"xfs\",\n :jfs => \"jfs\"\n }\n mount_type = Ops.get(mt_map, p_detect_fs, \"\")\n\n error_message = nil\n if !(\n error_message_ref = arg_ref(error_message);\n _RunFSCKonJFS_result = RunFSCKonJFS(\n mount_type,\n p_dev,\n error_message_ref\n );\n error_message = error_message_ref.value;\n _RunFSCKonJFS_result\n )\n Ops.set(freshman, :valid, false)\n return deep_copy(freshman)\n end\n\n # mustn't be empty and must be modular\n if mount_type != \"\" && !Builtins.contains(@non_modular_fs, mount_type)\n SCR.Execute(path(\".target.modprobe\"), mount_type, \"\")\n end\n # mount (read-only) partition to Installation::destdir\n Storage.RemoveDmMapsTo(p_dev)\n if Convert.to_boolean(\n SCR.Execute(\n path(\".target.mount\"),\n [p_dev, Installation.destdir, Installation.mountlog],\n \"-o ro\"\n )\n )\n # Is this a root partition, does /etc/fstab exists?\n if Ops.greater_than(\n SCR.Read(\n path(\".target.size\"),\n Ops.add(Installation.destdir, \"/etc/fstab\")\n ),\n 0\n )\n Builtins.y2milestone(\"found fstab on %1\", partition)\n\n fstab = []\n crtab = []\n\n fstab_ref = arg_ref(fstab)\n crtab_ref = arg_ref(crtab)\n read_fstab_and_cryptotab(fstab_ref, crtab_ref, p_dev)\n fstab = fstab_ref.value\n crtab = crtab_ref.value\n Update.GetProductName\n\n fstab = Builtins.filter(fstab) do |p|\n Ops.get_string(p, \"file\", \"\") == \"/\"\n end\n\n if Builtins.size(Ops.get_string(fstab, [0, \"spec\"], \"\")) == 0\n Builtins.y2warning(\"Cannot find / entry in fstab %1\", fstab)\n end\n\n Ops.set(\n freshman,\n :valid,\n Ops.greater_than(\n Builtins.size(Ops.get_string(fstab, [0, \"spec\"], \"\")),\n 0\n ) &&\n Storage.DeviceMatchFstab(\n p_dev,\n Ops.get_string(\n # bugzilla #304269\n # DeviceMatchFstab expects _old_ not _translated_ device\n fstab,\n [0, \"spec_old\"],\n Ops.get_string(fstab, [0, \"spec\"], \"\")\n )\n )\n )\n\n # Why this doesn't match?\n # Possible reasons:\n # - /var not mounted so hwinfo cannot translate device names\n if Ops.get_boolean(freshman, :valid, false) != true\n Builtins.y2warning(\n \"Device does not match fstab: '%1' vs. '%2'\",\n p_dev,\n Ops.get_string(fstab, [0, \"spec\"], \"\")\n )\n end\n if Mode.autoinst\n # we dont care about the other checks in autoinstallation\n SCR.Execute(path(\".target.umount\"), Installation.destdir)\n return deep_copy(freshman)\n end\n\n # Get installed release name\n release = OSRelease.ReleaseInformation(Installation.destdir)\n Builtins.y2debug(\"release: %1\", release)\n if release == \"?\"\n # label for an unknown installed system\n release = _(\"Unknown\")\n end\n Ops.set(freshman, :name, release)\n\n # Right architecture?\n Ops.set(\n freshman,\n :arch,\n GetArchOfELF(Ops.add(Installation.destdir, \"/bin/bash\"))\n )\n instsys_arch = GetArchOfELF(\"/bin/bash\")\n\n # `arch_valid, see bugzilla #288201\n # installed /bin/bash and the one from inst-sys are matching\n if Ops.get_string(freshman, :arch, \"unknown\") == instsys_arch\n Builtins.y2milestone(\"Architecture (%1) is valid\", instsys_arch)\n Ops.set(freshman, :arch_valid, true) \n\n # both are PPC, bugzilla #249791\n elsif Builtins.contains(\n [\"ppc\", \"ppc64\"],\n Ops.get_string(freshman, :arch, \"unknown\")\n ) &&\n Builtins.contains([\"ppc\", \"ppc64\"], instsys_arch)\n Builtins.y2milestone(\n \"Architecture for partition %1 is %2, upgrading %3\",\n p_dev,\n Ops.get_string(freshman, :arch, \"unknown\"),\n instsys_arch\n )\n Ops.set(freshman, :arch_valid, true) \n\n # Architecture is not matching\n else\n Builtins.y2milestone(\n \"Architecture for partition %1 is %2, upgrading %3\",\n p_dev,\n Ops.get_string(freshman, :arch, \"unknown\"),\n instsys_arch\n )\n Ops.set(freshman, :arch_valid, false)\n end\n\n # If architecture is not matching, the whole partition is considered to be wrong\n if Ops.get_boolean(freshman, :arch_valid, false) != true\n Builtins.y2milestone(\n \"Architecture is not valid -> the whole partition is not valid\"\n )\n Ops.set(freshman, :valid, false)\n end\n\n if IncompleteInstallationDetected(Installation.destdir)\n Builtins.y2milestone(\n \"Incomplete installation detected, partition is not valid\"\n )\n Ops.set(freshman, :valid, false)\n end\n\n Builtins.y2milestone(\n \"Partition is valid: %1, arch is valid: %2\",\n Ops.get_boolean(freshman, :valid, false),\n Ops.get_boolean(freshman, :arch_valid, false)\n )\n end\n\n # unmount partition\n SCR.Execute(path(\".target.umount\"), Installation.destdir)\n end\n end\n\n Builtins.y2milestone(\"%1 %2\", partition, freshman)\n\n deep_copy(freshman)\n end",
"def addPartition(ptStr)\n pts_array = ptStr.split(',')\n sqlstr = \"ALTER TABLE \" + @mProjectName + \".\" + @mTableName\n sqlstr = sqlstr + \" ADD IF NOT EXISTS\" + \" PARTITION (\"\n pts_array.each { |pt|\n ptkv = pt.split('=')\n if ptkv.size != 2\n raise \"invalid partition spec\" + pt\n end\n sqlstr += ptkv[0] + '=' + \"'\" + ptkv[1] + \"'\" + ','\n }\n sqlstr = sqlstr[0..-2] + \");\"\n taskName = \"SQLAddPartitionTask\"\n runSQL(taskName, sqlstr)\n end",
"def create_partition(size = nil, type = Partition.PartitionType[:TYPE_PRIMARY])\n DiskUtils.create_partition self, size[:start_block], size[:end_block]\n partitions = Device.find(self).partitions\n return partitions.last\n end",
"def set_part\n @part = Part.find(params[:id])\n end",
"def partition_used(partition)\n # Return magic number if in test_mode to prevent syscall\n return '128' if @test_mode\n b = ' ' * 128\n syscall(137, partition, b)\n a = b.unpack('QQQQQ')\n [a[2] * blocks_per_kilobyte, a[4] * blocks_per_kilobyte]\n end",
"def destroy\n begin\n # We need to set some variables, but we NEED the partition number to delete the partition\n partition= resource[:name]\n device=partition[0,(partition.length-1)]\n partition_nr=partition.slice(partition.length - 1)\n parted('--script',device,'rm',partition_nr)\n rescue Puppet::ExecutionFailure => e\n false\n end\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_Part(value)\n set_input(\"Part\", value)\n end",
"def set_part\n @part = Part.find(params[:id])\n end",
"def partition_type\n raise Error, \"Unable to determine partition type, multiple different partitioning methods called\" if [@from || @to, @list, @modulus || @remainder, @default].compact.length > 1\n\n if @from || @to\n raise Error, \"must call both from and to when creating a partition of a table if calling either\" unless @from && @to\n :range\n elsif @in\n :list\n elsif @modulus || @remainder\n raise Error, \"must call both modulus and remainder when creating a partition of a table if calling either\" unless @modulus && @remainder\n :hash\n elsif @default\n :default\n else\n raise Error, \"unable to determine partition type, no partitioning methods called\"\n end\n end",
"def partition(partition_key)\n state_depth_must_be(States::RELATION)\n if @current_relation.partitions.include?(partition_key)\n raise \"duplicate partition key #{partition_key}\"\n end\n @current_relation.partitions << partition_key\n end",
"def on_partitions_assigned(_, partitions)\n @assigned_partitions = partitions.to_h.transform_values { |part| part.map(&:partition) }\n @changed = true\n end",
"def change_process_execution( prop, value)\n cmd = <<-END\nobj = AdminConfig.list(\"ProcessExecution\", AdminConfig.getid(\"/Node:#{resource[:nodename]}/Server:#{resource[:name]}/\"))\nAdminConfig.modify( obj, '[[#{prop} \"#{value}\"]]')\n END\n cmd\n end",
"def SwappingPartitions\n SCR.UnmountAgent(path(\".proc.swaps\"))\n swaps = Convert.convert(\n SCR.Read(path(\".proc.swaps\")),\n :from => \"any\",\n :to => \"list <map>\"\n )\n if swaps == nil\n Builtins.y2error(\"SCR::Read(.proc.swaps) returned nil\")\n Builtins.y2milestone(\n \"/proc/swaps is %1\",\n SCR.Execute(path(\".target.bash_output\"), \"cat /proc/swaps\")\n )\n swaps = []\n end\n swaps = Builtins.filter(swaps) do |e|\n Ops.get_string(e, \"type\", \"\") == \"partition\"\n end\n ret = Builtins.maplist(swaps) do |e|\n Partitions.TranslateMapperName(Ops.get_string(e, \"file\", \"\"))\n end\n Builtins.y2milestone(\"SwappingPartitions %1\", ret)\n deep_copy(ret)\n end",
"def move_random_partition(node, histogram)\n #pick a random partition\n partition = node[:partitions].sample \n raise \"failed to find partition\" unless partition\n move_partition_to_most_utilised_node_with_space_for_it(node, partition, histogram)\n end",
"def region4resize(settings)\n settings = deep_copy(settings)\n # the storage lib requires the region to be set\n # we transform the size to the region here\n tm = Storage.GetTargetMap\n settings = Builtins.maplist(settings) do |d|\n if Ops.get_symbol(d, \"type\", :x) == :CT_DISK\n realDisk = Ops.get(tm, Ops.get_string(d, \"device\", \"\"), {})\n Ops.set(\n d,\n \"partitions\",\n Builtins.maplist(Ops.get_list(d, \"partitions\", [])) do |pe|\n if Ops.get_boolean(pe, \"resize\", false)\n currentCyl = Ops.get_integer(\n realDisk,\n [\n \"partitions\",\n Ops.subtract(Ops.get_integer(pe, \"partition_nr\", 1), 1),\n \"region\",\n 1\n ],\n 0\n )\n Ops.set(\n pe,\n \"region\",\n Ops.get_list(\n realDisk,\n [\n \"partitions\",\n Ops.subtract(Ops.get_integer(pe, \"partition_nr\", 1), 1),\n \"region\"\n ],\n []\n )\n )\n if Builtins.issubstring(Ops.get_string(pe, \"size\", \"\"), \"%\")\n percentage = Builtins.deletechars(\n Ops.get_string(pe, \"size\", \"\"),\n \"%\"\n )\n newCyl = Ops.divide(\n Ops.multiply(currentCyl, Builtins.tointeger(percentage)),\n 100\n )\n Ops.set(pe, [\"region\", 1], newCyl)\n else\n new_size = humanStringToByte(\n Ops.get_string(pe, \"size\", \"0\"),\n true\n )\n newCyl = Ops.divide(\n new_size,\n Ops.get_integer(realDisk, \"cyl_size\", 1)\n )\n Ops.set(pe, [\"region\", 1], newCyl)\n end\n Builtins.y2milestone(\n \"resize partition nr %1 of %2 to region: %3\",\n Ops.get_integer(pe, \"partition_nr\", 1),\n Ops.get_string(d, \"device\", \"\"),\n Ops.get_list(pe, \"region\", [])\n )\n end\n deep_copy(pe)\n end\n )\n end\n deep_copy(d)\n end\n Builtins.y2milestone(\"after region4resize = %1\", settings)\n deep_copy(settings)\n end",
"def changeworkspacename\n retrievehome\n end",
"def part_install=(part)\n require \"nitro/part/#{part.underscore}\"\n print \"Installing '#{part}' part, press a key to confim..\"\n STDIN.getc\n eval %{#{part}Part.install(\"#{File.expand_path('.')}\")}\n exit\n end",
"def list_swap_partitions_with_type_and_size # nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\" && $6==\"82\") print $1\":\"$5\":\"$6;else {if ($5==\"82\") print $1\":\"$4\":\"$5}}' | sed s/+//g`.chomp.split\nend",
"def add!(partition, dirty = false)\n if @list[partition.name].nil?\n @list[partition.name] = partition\n else\n @list[partition.name].merge!(partition, simulate = false, dirty)\n end\n self\n end",
"def set_part\n @part = Part.find(params[:id])\n end",
"def set_devices(storage_config)\n storage_config = deep_copy(storage_config)\n Builtins.y2milestone(\"entering set_devices with %1\", storage_config)\n first_set = false\n failed = false\n auto_targetmap = Builtins.listmap(storage_config) do |drive|\n device = \"\"\n Builtins.y2milestone(\"Working on drive: %1\", drive)\n # FIXME: Check if physical drives > 1\n if Ops.get_string(drive, \"device\", \"\") == \"ask\"\n dev = DiskSelectionDialog()\n if dev != nil\n first_set = true\n device = dev\n end\n\n next { device => drive }\n end\n if !first_set &&\n (Ops.get_string(drive, \"device\", \"\") == \"\" ||\n Ops.get_string(drive, \"device\", \"\") == \"ask\")\n device = Storage.GetPartDisk\n Builtins.y2milestone(\"device: %1\", device)\n first_set = true\n next { device => drive }\n elsif Ops.get_string(drive, \"device\", \"\") != \"\"\n dev = Ops.get_string(drive, \"device\", \"\")\n if dev == \"\"\n dev = \"error\"\n Builtins.y2error(\"Missing device name in partitioning plan\")\n failed = true\n end\n\n next { dev => drive }\n end\n end\n\n return nil if failed\n\n auto_targetmap = Builtins.mapmap(auto_targetmap) do |device, d|\n # Convert from Old Style\n if Builtins.haskey(d, \"use\")\n Builtins.y2milestone(\n \"converting from \\\"use\\\" to new style: %1\",\n device\n )\n if Ops.get_string(d, \"use\", \"\") == \"free\"\n Ops.set(d, \"prefer_remove\", false)\n elsif Ops.get_string(d, \"use\", \"\") == \"all\"\n Ops.set(d, \"prefer_remove\", true)\n elsif Ops.get_string(d, \"use\", \"\") == \"linux\"\n Ops.set(d, \"keep_partition_num\", GetNoneLinuxPartitions(device))\n Ops.set(d, \"prefer_remove\", true)\n else\n uselist = Builtins.filter(\n Builtins.splitstring(Ops.get_string(d, \"use\", \"\"), \",\")\n ) { |s| s != \"\" }\n Builtins.y2milestone(\"uselist: %1\", uselist)\n keeplist = []\n all = GetAllPartitions(device)\n Builtins.y2milestone(\"all list: %1\", all)\n Builtins.foreach(all) do |i|\n if !Builtins.contains(uselist, Builtins.sformat(\"%1\", i))\n keeplist = Builtins.add(keeplist, i)\n end\n end\n Builtins.y2milestone(\"keeplist: %1\", keeplist)\n Ops.set(d, \"keep_partition_num\", keeplist)\n\n if Ops.greater_than(Builtins.size(keeplist), 0)\n Ops.set(d, \"prefer_remove\", true)\n end\n end\n else\n Ops.set(d, \"use\", \"all\")\n end\n # see if <usepart> is used and add the partitions to <keep_partition_num>\n Builtins.foreach(Ops.get_list(d, \"partitions\", [])) do |p|\n if Ops.get_integer(p, \"usepart\", -1) != -1\n Ops.set(\n d,\n \"keep_partition_num\",\n Builtins.add(\n Ops.get_list(d, \"keep_partition_num\", []),\n Ops.get_integer(p, \"usepart\", -1)\n )\n )\n end\n end\n Ops.set(\n d,\n \"keep_partition_num\",\n Builtins.toset(Ops.get_list(d, \"keep_partition_num\", []))\n )\n { device => d }\n end\n\n Builtins.y2milestone(\n \"processed autoyast partition plan: %1\",\n auto_targetmap\n )\n deep_copy(auto_targetmap)\n end",
"def change_boot_order\n return unless provider == :libvirt\n system \"sudo virsh destroy #{IMAGE_NAME}\" # shutdown\n system \"sudo virsh dumpxml #{IMAGE_NAME} >#{libvirt_definition_path}\"\n system \"sed -i.bak s/dev=\\\\'cdrom\\\\'/dev=\\\\'cdrom_save\\\\'/g #{libvirt_definition_path}\"\n system \"sed -i.bak s/dev=\\\\'hd\\\\'/dev=\\\\'cdrom\\\\'/g #{libvirt_definition_path}\"\n system \"sed -i.bak s/dev=\\\\'cdrom_save\\\\'/dev=\\\\'hd\\\\'/g #{libvirt_definition_path}\"\n system \"sudo virsh define #{libvirt_definition_path}\"\n end",
"def deleteAllDevPartitions(disk, installation)\n disk = deep_copy(disk)\n go_on = true\n del_dev = Ops.get_string(disk, \"device\", \"\")\n Builtins.y2milestone(\n \"deleteAllDevPartitions disk:%1\",\n Builtins.remove(disk, \"partitions\")\n )\n\n #///////////////////////////////////////////////////////////////\n # check mount points if not installation\n\n if !installation\n mounts = Storage.mountedPartitionsOnDisk(del_dev)\n if Builtins.size(mounts) != 0\n #///////////////////////////////////////////////////////\n # mount points found\n\n mounted_parts = \"\"\n Builtins.foreach(mounts) do |mount|\n # %1 is replaced by device name, %1 by directory e.g /dev/hdd1 on /opt\n mounted_parts = Ops.add(\n Ops.add(\n mounted_parts,\n Builtins.sformat(\n \"%1 on %2\",\n Ops.get_string(mount, \"device\", \"\"),\n Ops.get_string(mount, \"mount\", \"\")\n )\n ),\n \"\\n\"\n )\n end\n\n # popup text, %1 is replaced by device name\n message = Builtins.sformat(\n _(\n \"The selected device contains partitions that are currently mounted:\\n\" +\n \"%1\\n\" +\n \"We *strongly* recommended to unmount these partitions before deleting the partition table.\\n\" +\n \"Choose Cancel unless you know exactly what you are doing.\\n\"\n ),\n mounted_parts\n )\n\n go_on = false if !Popup.ContinueCancel(message)\n end\n end\n\n if go_on\n partitions = Ops.get_list(disk, \"partitions\", [])\n\n used = check_devices_used(partitions, false)\n\n go_on = used == :UB_NONE\n\n if used == :UB_LVM\n # popup text, Do not translate LVM.\n Popup.Message(\n _(\n \"\\n\" +\n \"The selected device contains at least one LVM partition\\n\" +\n \"assigned to a volume group. Remove all\\n\" +\n \"partitions from their respective volume groups\\n\" +\n \"before deleting the device.\\n\"\n )\n )\n elsif used == :UB_MD\n # popup text, Do not translate RAID.\n Popup.Message(\n _(\n \"\\n\" +\n \"The selected device contains at least one partition\\n\" +\n \"that is part of a RAID system. Unassign the\\n\" +\n \"partitions from their respective RAID systems before\\n\" +\n \"deleting the device.\\n\"\n )\n )\n elsif used != :UB_NONE\n # popup text\n Popup.Message(\n _(\n \"\\n\" +\n \"The selected device contains at least one partition\\n\" +\n \"that is used by another volume. Delete the volume using it\\n\" +\n \"before deleting the device.\\n\"\n )\n )\n end\n\n if go_on && Ops.get_symbol(disk, \"type\", :CT_UNKNONW) != :CT_DMRAID\n #///////////////////////////////////////////////\n # delete all partitions of disk\n # logical partitions get removed when extended is deleted\n dp = Builtins.filter(partitions) do |part|\n Ops.less_or_equal(\n Ops.get_integer(part, \"nr\", 0),\n Ops.get_integer(disk, \"max_primary\", 4)\n )\n end\n Builtins.y2milestone(\"deleteAllDevPartitions dp:%1\", dp)\n dp = Builtins.sort(dp) do |a, b|\n Ops.greater_than(\n Ops.get_integer(a, \"nr\", 0),\n Ops.get_integer(b, \"nr\", 0)\n )\n end\n Builtins.y2milestone(\"deleteAllDevPartitions dp:%1\", dp)\n Builtins.foreach(dp) do |part|\n go_on = go_on &&\n Storage.DeleteDevice(Ops.get_string(part, \"device\", \"\"))\n end\n end\n end\n Builtins.y2milestone(\"deleteAllDevPartitions ret:%1\", go_on)\n go_on\n end",
"def AddMountPointsForWinParts(partitions, primary, max_prim, foreign_nr)\n partitions = deep_copy(partitions)\n return if !Arch.i386 && !Arch.ia64 && !Arch.x86_64\n\n foreign_ids = \"CDEFGHIJKLMNOPQRSTUVW\"\n\n Builtins.foreach(partitions) do |partition|\n new_partition = deep_copy(partition)\n fsid = Ops.get_integer(partition, \"fsid\", Partitions.fsid_native)\n partnum = 0\n if Builtins.haskey(partition, \"nr\") &&\n Ops.is_integer?(Ops.get(partition, \"nr\", 0))\n partnum = Ops.get_integer(partition, \"nr\", 0)\n end\n if !Builtins.haskey(partition, \"mount\") &&\n !Ops.get_boolean(partition, \"delete\", false) &&\n Ops.less_or_equal(partnum, max_prim) == primary &&\n Ops.less_than(foreign_nr.value, 24) &&\n Partitions.IsDosWinNtPartition(fsid) &&\n !Arch.ia64 &&\n !IsEfiPartition(partition) &&\n Ops.greater_or_equal(\n Ops.get_integer(partition, \"size_k\", 0),\n 1024 * 1024\n ) &&\n Builtins.contains(\n [:vfat, :ntfs],\n Ops.get_symbol(partition, \"used_fs\", :none)\n )\n Ops.set(\n new_partition,\n \"fstopt\",\n FileSystems.DefaultFstabOptions(partition)\n )\n if Builtins.contains(Partitions.fsid_dostypes, fsid)\n Ops.set(\n new_partition,\n \"mount\",\n Ops.add(\n \"/dos/\",\n Builtins.substring(foreign_ids, foreign_nr.value, 1)\n )\n )\n foreign_nr.value = Ops.add(foreign_nr.value, 1)\n else\n Ops.set(\n new_partition,\n \"mount\",\n Ops.add(\n \"/windows/\",\n Builtins.substring(foreign_ids, foreign_nr.value, 1)\n )\n )\n foreign_nr.value = Ops.add(foreign_nr.value, 1)\n end\n ChangeVolumeProperties(new_partition)\n Builtins.y2milestone(\"win part %1\", new_partition)\n end\n end\n\n nil\n end",
"def apply_storage_policy(policy)\n profile_spec = Resources::VM.create_profile_spec(policy)\n disks = [system_disk, ephemeral_disk]\n device_specs = disks.map {|disk| Resources::VM.create_edit_device_spec(disk)}\n device_specs.each do |d|\n d.profile = [profile_spec]\n end\n vmconfig = VimSdk::Vim::Vm::ConfigSpec.new\n vmconfig.device_change = device_specs\n vmconfig.vm_profile = profile_spec\n @client.reconfig_vm(@mob, vmconfig)\n end",
"def get_1st_partition(device)\n # Resolves the real device name (ex. /dev/sdg)\n Chef::Log.info(\"Getting 1st partition for device: #{device}\")\n fs_check = Mixlib::ShellOut.new(\"lsblk -ln -o Name #{device}|awk 'NR==2'\")\n fs_check.run_command\n partition = \"/dev/\" + fs_check.stdout.strip\n Chef::Log.info(\"1st partition for device: #{device} is: #{partition}\")\n partition\nend",
"def set_vbox_vm_boot_priority(client_name)\n message = \"Setting:\\tBoot priority for \"+client_name+\" to disk then network\"\n command = \"VBoxManage modifyvm #{client_name} --boot1 disk --boot2 net\"\n execute_command(message,command)\n return\nend",
"def change_vbox_vm_cpu(client_name,client_cpus)\n message = \"Setting:\\tVirtualBox VM \"+client_name+\" CPUs to \"+client_cpus\n command = \"VBoxManage modifyvm #{client_name} --cpus #{client_cpus}\"\n execute_command(message,command)\n return\nend",
"def plug_drive(name, type)\n raise \"disk '#{name}' already plugged\" if disk_plugged?(name)\n\n removable_usb = nil\n case type\n when 'removable usb', 'usb'\n type = 'usb'\n removable_usb = 'on'\n when 'non-removable usb'\n type = 'usb'\n removable_usb = 'off'\n end\n # Get the next free /dev/sdX on guest\n letter = 'a'\n dev = 'sd' + letter\n while list_disk_devs.include?(dev)\n letter = (letter[0].ord + 1).chr\n dev = 'sd' + letter\n end\n assert letter <= 'z'\n\n xml = REXML::Document.new(File.read(\"#{@xml_path}/disk.xml\"))\n xml.elements['disk/source'].attributes['file'] = @storage.disk_path(name)\n xml.elements['disk/driver'].attributes['type'] = @storage.disk_format(name)\n xml.elements['disk/target'].attributes['dev'] = dev\n xml.elements['disk/target'].attributes['bus'] = type\n if removable_usb\n xml.elements['disk/target'].attributes['removable'] = removable_usb\n end\n\n plug_device(xml)\n end",
"def editStage(nostage, name, desc)\n find(:xpath, \"//*[@id='config-array-#{nostage.to_i-1}-com.spigit.idea.IdeaConfig.lifecycleStages']\").set name\n find(:xpath, \"//*[@id='config-array-#{nostage.to_i-1}-com.spigit.idea.IdeaConfig.lifecycleStageDescriptions']\").set desc\n sleep 3\n end",
"def partition(id)\n partitions.detect {|partition| partition.id == id}\n end",
"def kernel=(value)\n raise ArgumentError, 'correct kernel path must be specified!' unless File.exists?(value) \n cobbler('distro', 'edit', '--name=' + @resource[:name], '--kernel=' + value)\n @property_hash[:kernel]=(value)\n end",
"def partitions\n [6, 3, 0].map { |n| model.id / 10**n % 1000 }\n end",
"def set(key,value)\n @disk.set(key,value)\n end",
"def GetPartitionList\n deep_copy(@partition_info)\n end",
"def full_format fstype, label = nil\n DebugLogger.info \"class = #{self.class.name}, method = #{__method__}\"\n delete_all_partitions unless partitions.blank?\n DebugLogger.info \"|#{self.class.name}|>|#{__method__}|:Creating partition #{self.kname}\"\n DiskUtils.create_partition self, 1, -1\n DebugLogger.info \"|#{self.class.name}|>|#{__method__}|:Find partition #{@kname}\"\n self.reload\n new_partition = self.partitions.last # Assuming new partition to be at the last index\n DebugLogger.info \"|#{self.class.name}|>|#{__method__}|:Formating #{@kname} to #{fstype}\"\n new_partition.format fstype and reload\n end",
"def MountPartition(mount_point, device, mount_type)\n if mount_type == \"\"\n # e.g. -> \"reiserfs\"\n mount_type = FileSystems.GetMountString(Storage.DetectFs(device), \"\")\n end\n\n # #223878, do not call modprobe with empty mount_type\n if mount_type == \"\"\n Builtins.y2warning(\"Unknown filesystem, skipping modprobe...\") \n # #211916, sysfs, proc are not modular\n elsif !Builtins.contains(@non_modular_fs, mount_type)\n # #167976, was broken with \"-t \", modprobe before adding it\n Builtins.y2milestone(\"Calling 'modprobe %1'\", mount_type)\n SCR.Execute(path(\".target.modprobe\"), mount_type, \"\")\n else\n Builtins.y2milestone(\n \"FS type %1 is not modular, skipping modprobe...\",\n mount_type\n )\n end\n\n error_message = nil\n if !(\n error_message_ref = arg_ref(error_message);\n _RunFSCKonJFS_result = RunFSCKonJFS(\n mount_type,\n device,\n error_message_ref\n );\n error_message = error_message_ref.value;\n _RunFSCKonJFS_result\n )\n return error_message\n end\n\n mount_type = Ops.add(\"-t \", mount_type) if mount_type != \"\"\n\n ret = Convert.to_boolean(\n SCR.Execute(\n path(\".target.mount\"),\n [\n device,\n Ops.add(Installation.destdir, mount_point),\n Installation.mountlog\n ],\n mount_type\n )\n )\n if ret\n return nil\n else\n return Convert.to_string(\n SCR.Read(path(\".target.string\"), Installation.mountlog)\n )\n end\n end",
"def set_maintenance_part\n @maintenance_part = MaintenancePart.find(params[:id])\n end",
"def partition_for!(key)\n if leader_available?\n # Use the configured partitioner\n partition_id = partitioner.call(key, available_partitions.count, partitions.count)\n partition!(partition_id)\n else\n error_code.raise\n end\n end",
"def change_device_state(host, device, state)\n raise MogileFS::ReadOnlyError if readonly?\n ! @backend.set_state(:host => host, :device => device, :state => state).nil?\n end",
"def setup_lvm_on_partition(part)\n return unless part.lvm\n\n pvol = \"/dev/disk/by-partlabel/#{part.label}\"\n execute!(\"pvcreate -y #{pvol}\")\n execute!(\"vgcreate -y #{part.lvm.vg_name} #{pvol}\")\n\n # any \"open ended\" volumes (no size specified), we deal with last\n unspec_vol = nil\n\n notice(\"Creating LVM partitions\")\n part.lvm.volumes.each do |vol|\n if not vol.size_mb.is_a?(Integer)\n unspec_vol = vol\n next\n end\n\n info(\"Creating #{vol.label} volume\")\n execute!(\"lvcreate -y --name #{vol.label} --size #{vol.size_mb}MiB #{part.lvm.vg_name}\")\n next if not vol.fs\n\n create_filesystem(vol.fs, \"/dev/#{part.lvm.vg_name}/#{vol.label}\", vol.label)\n end\n\n if unspec_vol\n vol = unspec_vol\n info(\"Creating #{vol.label} volume\")\n execute!(\"lvcreate -y --name #{vol.label} -l 100%FREE #{part.lvm.vg_name}\")\n if vol.fs\n create_filesystem(vol.fs, \"/dev/#{part.lvm.vg_name}/#{vol.label}\", vol.label)\n end\n end\n end",
"def ResizeVolume(device, disk, new_size_k)\n Builtins.y2milestone(\n \"ResizeVolume device:%1 disk:%2 new_size_k:%3\",\n device,\n disk,\n new_size_k\n )\n ret = @sint.resizeVolume(device, new_size_k)\n Builtins.y2error(\"ResizeVolume sint ret:%1\", ret) if ret<0\n UpdateTargetMapDisk(disk)\n ret == 0\n end",
"def []=(index, part)\n parts[index] = part\n end",
"def RootPartitionDialog(flavor)\n # FIXME: Most of the code in this function is obsolete\n\n partition_list = make_partition_list(\n RootPart.showAllPartitions,\n flavor == :boot_popup ? :boot : :update\n )\n\n title = \"\"\n label = \"\"\n help_text = \"\"\n\n if flavor == :boot_popup\n # label for selection of root partition (for boot)\n label = _(\"Partition or System to Boot:\")\n\n # help text for root partition dialog (for boot)\n help_text = _(\n \"<p>\\n\" +\n \"Select the partition or system to boot.\\n\" +\n \"</p>\\n\"\n )\n else\n # label for selection of root partition (for update)\n label = _(\"Partition or System to Update:\")\n\n # help text for root partition dialog (for update)\n help_text = _(\n \"<p>\\n\" +\n \"Select the partition or system to update.\\n\" +\n \"</p>\\n\"\n )\n\n if flavor == :update_dialog || flavor == :update_dialog_proposal\n # headline for dialog \"Select for update\"\n title = _(\"Select for Update\")\n end\n end\n\n # help text for root partition dialog (general part)\n help_text = Ops.add(\n help_text,\n _(\n \"<p>\\n\" +\n \"<b>Show All Partitions</b> expands the list to a\\n\" +\n \"general overview of your system's partitions.\\n\" +\n \"</p>\\n\"\n )\n )\n\n contents = HBox(\n VBox(\n VSpacing(1),\n Left(Label(label)),\n MinSize(\n 70,\n 14,\n Table(\n Id(:partition),\n Opt(:hstretch),\n Header(\n # table header\n _(\"System\"),\n # table header item\n _(\"Partition\"),\n # table header item\n _(\"Architecture\"),\n # table header item\n _(\"File System\"),\n # table header item\n _(\"Label\")\n ),\n partition_list\n )\n ),\n Left(\n CheckBox(\n Id(:showall),\n Opt(:notify),\n # check box\n _(\"&Show All Partitions\"),\n false\n )\n ),\n VSpacing(1)\n )\n )\n\n # bnc #429080\n # finishing the target before selecting a new system to load\n Pkg.TargetFinish if flavor == :update_dialog\n\n if flavor == :update_dialog\n Wizard.SetContents(title, contents, help_text, true, true)\n Wizard.EnableAbortButton if Mode.autoupgrade\n elsif flavor == :update_dialog_proposal\n Wizard.CreateDialog\n Wizard.SetContentsButtons(\n title,\n contents,\n help_text,\n Label.BackButton,\n Label.OKButton\n )\n else\n buttons = PushButton(Id(:next), Opt(:default), Label.OKButton)\n\n if flavor == :boot_popup\n buttons = HBox(\n HStretch(),\n # pushbutton to (rightaway) boot the system selected above\n HWeight(1, PushButton(Id(:next), Opt(:default), _(\"&Boot\"))),\n HSpacing(1),\n HWeight(1, PushButton(Id(:cancel), Label.CancelButton)),\n HStretch()\n )\n end\n\n full = MinHeight(\n 16,\n HBox(\n HSquash(MinWidth(26, RichText(Opt(:vstretch), help_text))),\n HSpacing(2),\n VBox(MinHeight(15, contents), buttons),\n HSpacing(2)\n )\n )\n\n UI.OpenDialog(full)\n end\n\n\n if Ops.greater_than(Builtins.size(RootPart.selectedRootPartition), 0)\n UI.ChangeWidget(\n Id(:partition),\n :CurrentItem,\n RootPart.selectedRootPartition\n )\n end\n\n UI.ChangeWidget(Id(:showall), :Value, RootPart.showAllPartitions)\n\n\n ret = nil\n\n while true\n if flavor == :update_dialog || flavor == :update_dialog_proposal\n ret = Wizard.UserInput\n else\n ret = UI.UserInput\n end\n\n ret = :abort if ret == :cancel\n break if ret == :abort && Popup.ConfirmAbort(:painless)\n\n if ret == :showall\n tmp = Convert.to_string(UI.QueryWidget(Id(:partition), :CurrentItem))\n partition_list = make_partition_list(\n Convert.to_boolean(UI.QueryWidget(Id(:showall), :Value)),\n flavor == :boot_popup ? :boot : :update\n )\n UI.ChangeWidget(Id(:partition), :Items, partition_list)\n UI.ChangeWidget(Id(:partition), :CurrentItem, tmp) if tmp != nil\n next\n end\n if (flavor == :update_dialog || flavor == :update_popup ||\n flavor == :update_dialog_proposal) &&\n ret == :next\n selected = Convert.to_string(\n UI.QueryWidget(Id(:partition), :CurrentItem)\n )\n freshman = Ops.get(RootPart.rootPartitions, selected, {})\n cont = true\n Builtins.y2milestone(\n \"Selected root partition: %1 %2\",\n selected,\n freshman\n )\n if Ops.get_string(freshman, :name, \"unknown\") == \"unknown\"\n cont = Popup.ContinueCancel(\n # continue-cancel popup\n _(\n \"No installed system that can be upgraded with this product was found\\non the selected partition.\"\n )\n )\n elsif !DoArchitecturesMatch(\n Ops.get_string(freshman, :arch, \"\"),\n RootPart.GetDistroArch\n )\n cont = Popup.ContinueCancel(\n # continue-cancel popup\n _(\n \"The architecture of the system installed in the selected partition\\nis different from the one of this product.\\n\"\n )\n )\n end\n ret = nil if !cont\n end\n if ret == :next\n RootPart.selectedRootPartition = Convert.to_string(\n UI.QueryWidget(Id(:partition), :CurrentItem)\n )\n RootPart.showAllPartitions = Convert.to_boolean(\n UI.QueryWidget(Id(:showall), :Value)\n )\n\n if flavor == :update_dialog\n RootPart.targetOk = RootPart.mount_target\n\n # Not mounted correctly\n if !RootPart.targetOk\n # error report\n Report.Error(_(\"Failed to mount target system\"))\n UmountMountedPartition()\n next \n\n # Correctly mounted but incomplete installation found\n elsif RootPart.IncompleteInstallationDetected(Installation.destdir)\n if Popup.AnyQuestion(\n Label.WarningMsg,\n # pop-up question\n _(\n \"A possibly incomplete installation has been detected on the selected partition.\\nAre sure you want to use it anyway?\"\n ),\n # button label\n _(\"&Yes, Use It\"),\n Label.CancelButton,\n :focus_no\n )\n Builtins.y2milestone(\n \"User wants to update possibly incomplete system\"\n )\n else\n Builtins.y2milestone(\n \"User decided not to update incomplete system\"\n )\n UmountMountedPartition()\n next\n end\n end\n end\n break\n end\n break if ret == :cancel || ret == :back || ret == :next\n end\n\n if flavor != :update_dialog\n UI.CloseDialog\n elsif Mode.autoupgrade\n Wizard.DisableAbortButton\n end\n\n # New partition has been mounted\n if flavor == :update_dialog && ret == :next\n # Target load failed, #466803\n if Pkg.TargetInitialize(Installation.destdir) != true\n Builtins.y2error(\"Pkg::TargetInitialize failed\")\n if Popup.AnyQuestion(\n Label.ErrorMsg,\n _(\n \"Initializing the system for upgrade has failed for unknown reason.\\n\" +\n \"It is highly recommended not to continue the upgrade process.\\n\" +\n \"\\n\" +\n \"Are you sure you want to continue?\"\n ),\n _(\"&Yes, Continue\"),\n Label.CancelButton,\n :focus_no\n )\n ret = :back\n else\n Builtins.y2warning(\n \"User decided to continue despite the error above (Pkg::TargetInit() failed)\"\n )\n end\n end\n\n # not aborted\n if ret != :back\n # Target load failed, #466803\n if Pkg.TargetLoad != true\n Builtins.y2error(\"Pkg::TargetLoad failed\")\n if Popup.AnyQuestion(\n Label.ErrorMsg,\n _(\n \"Initializing the system for upgrade has failed for unknown reason.\\n\" +\n \"It is highly recommended not to continue the upgrade process.\\n\" +\n \"\\n\" +\n \"Are you sure you want to continue?\"\n ),\n _(\"&Yes, Continue\"),\n Label.CancelButton,\n :focus_no\n )\n ret = :back\n else\n Builtins.y2warning(\n \"User decided to continue despite the error above (Pkg::TargetLoad() failed)\"\n )\n end\n end\n end\n end\n\n Convert.to_symbol(ret)\n end",
"def bootloader_partitions\n raise RuntimeError, \"Not implemented in base class\"\n end",
"def update!(**args)\n @name = args[:name] if args.key?(:name)\n @partition_config = args[:partition_config] if args.key?(:partition_config)\n @retention_config = args[:retention_config] if args.key?(:retention_config)\n end"
] |
[
"0.68011206",
"0.6676938",
"0.618568",
"0.60967946",
"0.60418004",
"0.5999213",
"0.59895533",
"0.58191353",
"0.57497066",
"0.56553215",
"0.5624845",
"0.55776787",
"0.5513125",
"0.5506415",
"0.54891264",
"0.5467075",
"0.545486",
"0.5430396",
"0.5425995",
"0.54255795",
"0.5394777",
"0.53944385",
"0.5387032",
"0.5341195",
"0.5322421",
"0.53046405",
"0.5299636",
"0.5290671",
"0.5280212",
"0.5259894",
"0.52535427",
"0.524434",
"0.5242258",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.5236622",
"0.52337253",
"0.52318966",
"0.5198139",
"0.51501507",
"0.51432407",
"0.5121438",
"0.50986326",
"0.50946045",
"0.50861853",
"0.50854146",
"0.50820065",
"0.5069574",
"0.50578594",
"0.5045713",
"0.503017",
"0.50270605",
"0.5026086",
"0.5013271",
"0.501009",
"0.5005762",
"0.4982953",
"0.49775806",
"0.49449512",
"0.49277747",
"0.49261716",
"0.4924939",
"0.49166116",
"0.48983222",
"0.48945928",
"0.4889486",
"0.48842332",
"0.48749334",
"0.48748976",
"0.4861957",
"0.48579898",
"0.4852331",
"0.4847996",
"0.48437402",
"0.48408866"
] |
0.6723628
|
1
|
Load partition file (code, web or configuration).
|
def loadpart(partname, filename)
flashimage = Flashimage.new
firmware = Flashimage.read(filename)
size = firmware.size
offset_signature = size - 10
signature = firmware[offset_signature .. -1]
puts("signature: #{signature.inspect}")
length, magic, crc32, offset = getblock(partname, firmware, offset_signature)
partition = Partition.new(partname)
partition.update(firmware[offset ... offset + length])
flashimage.update(partition)
flashimage.write
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def load(file_path); end",
"def load(file_path); end",
"def load(path); end",
"def load_path; end",
"def set_partition\n @partition = Partition.find(params[:id])\n end",
"def load_path=(load_path); end",
"def load\n @yaml_parts, @ruby_parts = lookup_parts\n @data.clear\n self.yaml_parts_in_loading_order.each do |yaml_part|\n yaml_data = YAML.load_file(yaml_part)\n part_sections = File.basename(yaml_part, '.yml').split('.')\n part_sections.delete_at 0 # delete the 'en' at the beginning\n if part_sections.empty?\n @data.merge! yaml_data\n else\n begin\n target_section = @data[*part_sections]\n raise EntryNotFound unless target_section.respond_to? :merge!\n target_section.merge! yaml_data\n rescue EntryNotFound\n @data[*part_sections] = yaml_data\n end\n end\n end\n \n @ruby_parts.each do |ruby_part|\n Kernel.load ruby_part\n end\n end",
"def changepartition(partition, filename)\n\tbaseaddress = PARTITIONS['boot'][START]\t\n\tsize = partition[SIZE]\n\tpartdata = Flashimage.read(filename)\n\tlength = partdata.size\n\tlast = partition[SIZE]\n\traise('Input file too large.') if length + 12 > last\n\tcrc32 = Zlib.crc32(partdata)\n\tpartdata[length ... last - 12] = \"\\xff\" * (last - length - 12)\n\tpartdata[last - 12 ... last] = [length, 0x12345678, crc32].pack('V3')\n\tfilename = \"#{File.dirname(FLASHIMAGE)}/#{partition[FILE]}\"\n\tFlashimage.write(partdata, filename)\nend",
"def load\n initialize(File.info(uuid).entity)\n end",
"def load\r\n\t\tload_file\r\n\t\tconfigure\r\n\tend",
"def load_file(path)\n send_cmd(\"load #{path}\")\n end",
"def create\n begin\n # Set the partition (/dev/sdb1), device (/dev/sdb) and alignment (optimal,minimal,none etc.) variables\n partition= resource[:name]\n device=partition[0,(partition.length-1)]\n alignment= resource[:alignment]\n\n # Now we can create the partition\n partitions = parted('-a', resource[:alignment],'--script',device,'mklabel',resource[:part_label],'mkpart', resource[:part_type],resource[:fs_type],resource[:p_begin],resource[:p_end])\n rescue Puppet::ExecutionFailure => e\n false\n end\n end",
"def load_file(filename); end",
"def load_file(filename); end",
"def load_file(file_path, status)\n\t\tmodel = Sketchup.active_model\n\t\tSketchup.status_text = 'Importing Seene... (about 1 minute on max quality)'\n\t\t\tstatus = model.start_operation('Import Seene', true)\n\t\t\tbegin\n\t\t\t\tresult = load_file_internal(file_path, status)\n\t\t\trescue Exception => e\n\t\t\t UI.messagebox \"Import failed: \" + e.to_s # + \"\\n\" + e.backtrace\n\t\t\t raise #to display the problem in ruby console as well (should be open)\n\t\t\tend\n\n\t\t\tmodel.commit_operation\n\t\tSketchup.status_text = ''\n\t\treturn result\n end",
"def load_file(file)\n kernel_load(file)\n end",
"def load\r\n return unless File.exist?(STORAGE)\r\n\r\n props = YAML.load(File.read(STORAGE))\r\n props.each{|k, v| instance_variable_set(\"@#{k}\", v) }\r\n end",
"def load_state\n begin\n if File.file?(\"#{$statefile}\") && File.readable?(\"#{$statefile}\") \n @current_state = File.read(\"#{$statefile}\").strip.split(':')\n end\n rescue\n error('Invalid Resume Point')\n exit 1\n end\n end",
"def load_runcom(rcpath)\n\n return if @loaded == true\n\n rc = YAML.load(rcpath)\n if rc.nil?\n @mountpoint = \"/ramdev\"\n @diskname = \"ramdev\"\n @paths = []\n\n for pathset in rc[\"ramdisk\"][\"paths\"] do\n @paths.push([Dir.pwd, \"#{@mountpoint}\"])\n end\n else\n @mountpoint = rc[\"ramdisk\"][\"mountpoint\"]\n @diskname = rc[\"ramdisk\"][\"name\"]\n @paths = []\n # TODO: Get size of paths and create default ramdisk size (x2)\n for pathset in rc[\"ramdisk\"][\"paths\"] do\n @paths.push([pathset[\"source\"], \"#{@mountpoint}/#{pathset['destination']}\"])\n end\n\n @loaded = true\n\n end\n puts \"ramdev_sync configured for: #{@mountpoint}\"\n end",
"def read_platform_from_file(path:)\n path.basename.to_s.split('.').first\n end",
"def init(file)\n\t\tbegin\n\t\t\tload file\n\t\trescue => e\n\t\t\traise Disbatch::FailedLoadPluginError, file\n\t\tend\n\tend",
"def load; end",
"def load; end",
"def load; end",
"def load_storage\n YAML.load_file(file_path) || {}\n end",
"def load_from_filesystem(options)\n return if options[:skip_metadata]\n\n # Load localised data\n ignore_validation = options[:ignore_language_directory_validation]\n Loader.language_folders(options[:metadata_path], ignore_validation).each do |lang_folder|\n language = File.basename(lang_folder)\n (LOCALISED_VERSION_VALUES + LOCALISED_APP_VALUES).each do |key|\n path = File.join(lang_folder, \"#{key}.txt\")\n next unless File.exist?(path)\n\n UI.message(\"Loading '#{path}'...\")\n options[key] ||= {}\n options[key][language] ||= File.read(path)\n end\n end\n\n # Load non localised data\n (NON_LOCALISED_VERSION_VALUES + NON_LOCALISED_APP_VALUES).each do |key|\n path = File.join(options[:metadata_path], \"#{key}.txt\")\n next unless File.exist?(path)\n\n UI.message(\"Loading '#{path}'...\")\n options[key] ||= File.read(path)\n end\n\n # Load trade representative contact information\n options[:trade_representative_contact_information] ||= {}\n TRADE_REPRESENTATIVE_CONTACT_INFORMATION_VALUES.values.each do |option_name|\n path = File.join(options[:metadata_path], TRADE_REPRESENTATIVE_CONTACT_INFORMATION_DIR, \"#{option_name}.txt\")\n next unless File.exist?(path)\n next if options[:trade_representative_contact_information][option_name].to_s.length > 0\n\n UI.message(\"Loading '#{path}'...\")\n options[:trade_representative_contact_information][option_name] ||= File.read(path)\n end\n\n # Load review information\n options[:app_review_information] ||= {}\n REVIEW_INFORMATION_VALUES.values.each do |option_name|\n path = File.join(options[:metadata_path], REVIEW_INFORMATION_DIR, \"#{option_name}.txt\")\n next unless File.exist?(path)\n next if options[:app_review_information][option_name].to_s.length > 0\n\n UI.message(\"Loading '#{path}'...\")\n options[:app_review_information][option_name] ||= File.read(path)\n end\n end",
"def load_page page_name\n file = page_file page_name\n\n File.open file, 'rb' do |io|\n obj = Marshal.load io.read\n obj.store = self\n obj\n end\n rescue Errno::ENOENT => e\n error = MissingFileError.new(self, file, page_name)\n error.set_backtrace e.backtrace\n raise error\n end",
"def load(from_disk = false)\n if id = read_head_id\n @head = get(id)\n @root = @head.tree\n end\n\n load_from_disk if from_disk\n end",
"def load_org_example name\n File.open(\"spec/data/org-file-#{name}.org\").read\nend",
"def load( dirname )\n\t\t\t@filename= File.join( dirname, \"ticket.yaml\" )\n\t\t\t@idstring = File.basename( dirname )[0..7]\n\t\t\tif File.file?( @filename )\n\t\t\t\t@data = YAML.load_file( @filename ) \n\t\t\tend \n\t\t\tloadComments\n\t\t\tloadAttachments\n\t\tend",
"def load_character account, filename\n end",
"def load_path\n # TODO: Could this be used to load app dir and blueprint.yml?\n # If not remove it\n owner.before_load_path(rootpath, self) if owner.respond_to?(:before_load_path)\n create_assets\n validate_if_segment\n create_components\n end",
"def load_file(file); end",
"def partition_lookup\n return @partition_lookup unless @partition_lookup.nil?\n io = _root._io\n _pos = io.pos\n io.seek(_root.sector_size)\n @_raw_partition_lookup = io.read_bytes(sector_size)\n _io__raw_partition_lookup = Kaitai::Struct::Stream.new(@_raw_partition_lookup)\n @partition_lookup = PartitionEntry.new(_io__raw_partition_lookup, self, @_root)\n io.seek(_pos)\n @partition_lookup\n end",
"def load_specification(file_name); end",
"def create_partition device, partition_type = 'primary', start_unit, end_unit\n command = 'parted'\n params = \"#{device.path} -s -a optimal unit MB mkpart #{partition_type} ext3 #{start_unit} -- #{end_unit}\"\n parted = CommandsExecutor.new command, params\n parted.execute\n raise \"Command execution error: #{parted.stderr.read}\" if not parted.success?\n probe_kernal device\n end",
"def load_launcher_data launcher_data_file=\"bin/LAUNCHER_TYPE\"\n launcher_data = nil\n\n begin\n File.open launcher_data_file do |f|\n launcher_data = YAML.load(f.read)\n end\n rescue Errno::ENOENT\n end\n\n return launcher_data\nend",
"def get_partition_info\n # remove leading slash so it matches the packages.DU path\n remove_slash = true\n\n if !Stage.initial\n # read /proc/mounts as a list of maps\n # $[\"file\":\"/boot\", \"freq\":0, \"mntops\":\"rw\", \"passno\":0, \"spec\":\"/dev/sda1\", \"vfstype\":\"ext2\"]\n mounts = Convert.convert(\n SCR.Read(path(\".proc.mounts\")),\n :from => \"any\",\n :to => \"list <map <string, any>>\"\n )\n Builtins.y2milestone(\"mounts %1\", mounts)\n\n partitions = []\n Builtins.foreach(mounts) do |mpoint|\n name = Ops.get_string(mpoint, \"file\", \"\")\n if Builtins.substring(name, 0, 1) == \"/\" &&\n Builtins.substring(name, 0, 5) != \"/dev/\" && # filter out /dev/pts etc.\n Ops.get_string(mpoint, \"vfstype\", \"\") != \"rootfs\" # filter out duplicate \"/\" entry\n capacity = Pkg.TargetCapacity(name)\n if capacity != 0 # dont look at pseudo-devices (proc, shmfs, ...)\n used = Pkg.TargetUsed(name)\n partitions = Builtins.add(\n partitions,\n {\n \"name\" => name,\n \"free\" => Ops.subtract(capacity, used),\n \"used\" => used\n }\n )\n end\n end\n end\n Pkg.TargetInitDU(partitions)\n Builtins.y2milestone(\"get_partition_info: %1\", partitions)\n return deep_copy(partitions)\n end # !Stage::initial ()\n\n # remove the previous failures\n @failed_mounts = []\n\n # installation stage - Storage:: is definitely present\n # call Storage::GetTargetMap()\n targets = Convert.convert(\n WFM.call(\"wrapper_storage\", [\"GetTargetMap\"]),\n :from => \"any\",\n :to => \"map <string, map>\"\n )\n\n if targets == nil\n Builtins.y2error(\"Target map is nil, Storage:: is probably missing\")\n end\n\n if Mode.test\n targets = Convert.convert(\n SCR.Read(path(\".target.yast2\"), \"test_target_map.ycp\"),\n :from => \"any\",\n :to => \"map <string, map>\"\n )\n end\n\n target_partitions = []\n min_spare = 20 * 1024 * 1024 # minimum free space ( 20 MB )\n\n Builtins.foreach(targets) do |disk, diskinfo|\n part_info = Ops.get_list(diskinfo, \"partitions\", [])\n Builtins.foreach(part_info) do |part|\n Builtins.y2milestone(\"Adding partition: %1\", part)\n used_fs = Ops.get_symbol(part, \"used_fs\", :unknown)\n # ignore VFAT and NTFS partitions (bnc#)\n if used_fs == :vfat || used_fs == :ntfs\n Builtins.y2warning(\n \"Ignoring partition %1 with %2 filesystem\",\n Ops.get_string(part, \"device\", \"\"),\n used_fs\n )\n else\n free_size = 0\n\n if Ops.get(part, \"mount\") != nil &&\n Builtins.substring(Ops.get_string(part, \"mount\", \"\"), 0, 1) == \"/\"\n if Ops.get(part, \"create\") == true ||\n Ops.get(part, \"delete\") == false ||\n Ops.get(part, \"create\") == nil &&\n Ops.get(part, \"delete\") == nil\n Builtins.y2debug(\n \"get_partition_info: adding partition: %1\",\n part\n )\n\n # get free_size on partition in kBytes\n free_size = Ops.multiply(\n Ops.get_integer(part, \"size_k\", 0),\n 1024\n )\n free_size = Ops.subtract(free_size, min_spare)\n\n # free_size smaller than min_spare, fix negative value\n if Ops.less_than(free_size, 0)\n Builtins.y2milestone(\"Fixing free size: %1 to 0\", free_size)\n free_size = 0\n end\n\n used = 0\n if !(Ops.get_boolean(part, \"create\", false) ||\n Ops.get_boolean(part, \"format\", false))\n tmpdir = Convert.to_string(SCR.Read(path(\".target.tmpdir\")))\n tmpdir = Ops.add(tmpdir, \"/diskspace_mount\")\n SCR.Execute(\n path(\".target.bash\"),\n Builtins.sformat(\"test -d %1 || mkdir -p %1\", tmpdir)\n )\n\n # mount in read-only mode (safer)\n mount_options = [\"ro\"]\n\n # add \"nolock\" if it's a NFS share (bnc#433893)\n if used_fs == :nfs\n Builtins.y2milestone(\"Mounting NFS with 'nolock' option\")\n mount_options = Builtins.add(mount_options, \"nolock\")\n end\n\n # join the options\n mount_options_str = Builtins.mergestring(mount_options, \",\")\n\n mount_command = Builtins.sformat(\n \"/bin/mount -o %1 %2 %3\",\n mount_options_str,\n Ops.get_string(part, \"device\", \"\"),\n tmpdir\n )\n\n Builtins.y2milestone(\n \"Executing mount command: %1\",\n mount_command\n )\n\n result = Convert.to_integer(\n SCR.Execute(path(\".target.bash\"), mount_command)\n )\n Builtins.y2milestone(\"Mount result: %1\", result)\n\n if result == 0\n partition = Convert.convert(\n SCR.Read(path(\".run.df\")),\n :from => \"any\",\n :to => \"list <map <string, string>>\"\n )\n Builtins.foreach(partition) do |p|\n if Ops.get_string(p, \"name\", \"\") == tmpdir\n Builtins.y2internal(\"P: %1\", p)\n free_size = Ops.multiply(\n Builtins.tointeger(Ops.get_string(p, \"free\", \"0\")),\n 1024\n )\n used = Ops.multiply(\n Builtins.tointeger(Ops.get_string(p, \"used\", \"0\")),\n 1024\n )\n end\n end\n SCR.Execute(\n path(\".target.bash\"),\n Builtins.sformat(\"/bin/umount %1\", tmpdir)\n )\n else\n Builtins.y2error(\n \"Mount failed, ignoring partition %1\",\n Ops.get_string(part, \"device\", \"\")\n )\n @failed_mounts = Builtins.add(@failed_mounts, part)\n\n next\n end\n else\n # for formatted partitions estimate free system size\n # compute fs overhead\n used = EstimateFsOverhead(part)\n\n if Ops.greater_than(used, 0)\n Builtins.y2milestone(\n \"Partition %1: assuming fs overhead: %2kB\",\n Ops.get_string(part, \"device\", \"\"),\n Ops.divide(used, 1024)\n )\n end\n\n # journal size\n js = 0\n\n if ExtFs(used_fs)\n js = ExtJournalSize(part)\n reserved = ReservedSpace(part)\n\n if Ops.greater_than(reserved, 0)\n used = Ops.add(used, reserved)\n end\n elsif used_fs == :xfs\n js = XfsJournalSize(part)\n elsif used_fs == :reiser\n js = ReiserJournalSize(part)\n elsif used_fs == :jfs\n js = JfsJournalSize(part)\n else\n Builtins.y2warning(\n \"Unknown journal size for filesystem: %1\",\n used_fs\n )\n end\n\n if Ops.greater_than(js, 0)\n Builtins.y2milestone(\n \"Partition %1: assuming journal size: %2kB\",\n Ops.get_string(part, \"device\", \"\"),\n Ops.divide(js, 1024)\n )\n used = Ops.add(used, js)\n end\n\n # decrease free size\n free_size = Ops.subtract(free_size, used)\n\n # check for underflow\n if Ops.less_than(free_size, 0)\n Builtins.y2milestone(\"Fixing free size: %1 to 0\", free_size)\n free_size = 0\n end\n end\n\n # convert into kB for TargetInitDU\n free_size = Ops.divide(free_size, 1024)\n used = Ops.divide(used, 1024)\n\n Builtins.y2milestone(\n \"available partition: mount: %1, free: %2 KB, used: %3 KB\",\n Ops.get_string(part, \"mount\", \"\"),\n free_size,\n used\n )\n if !remove_slash\n target_partitions = Builtins.add(\n target_partitions,\n {\n \"name\" => Ops.get_string(part, \"mount\", \"\"),\n \"used\" => used,\n \"free\" => free_size\n }\n )\n else\n part_name = \"\"\n mount_name = Ops.get_string(part, \"mount\", \"\")\n\n if mount_name != \"/\"\n part_name = Builtins.substring(\n mount_name,\n 1,\n Builtins.size(mount_name)\n )\n else\n part_name = mount_name\n end\n\n target_partitions = Builtins.add(\n target_partitions,\n { \"name\" => part_name, \"used\" => used, \"free\" => free_size }\n )\n end\n end\n end\n end\n end # foreach (`part)\n end # foreach (`disk)\n\n # add estimated size occupied by non-package files\n target_partitions = EstimateTargetUsage(target_partitions)\n\n Builtins.y2milestone(\"get_partition_info: part %1\", target_partitions)\n Pkg.TargetInitDU(target_partitions)\n\n deep_copy(target_partitions)\n end",
"def load(name); end",
"def load\r\n \r\n end",
"def load_and_run!\n File.open(@pathfile, \"w\") { |f| f.write(@pathfile_contents) }\n Pathological.add_paths!(@load_path)\n end",
"def load_master\n @master_preferences[@master_label] = @master_path\n @master_preferences\n end",
"def load\n end",
"def load_file(filename)\n File.read File.join(\"plugins\",name,filename)\n end",
"def load_contentful_structure_file\n file_exists? ? load_existing_contentful_structure_file : create_empty_contentful_structure_file\n end",
"def load_process(model, the_process)\n Lorj.debug(1, \"Loading Process '%s'\", the_process)\n\n if the_process.include?('/')\n file = File.expand_path(the_process)\n else\n file = processfile_from_default(model, the_process)\n end\n\n return PrcLib.warning(\"Process file definition '%s' is missing. \",\n file) unless File.exist?(file)\n\n load_processfile(model, file, classname_from_file(file))\n end",
"def _process_local_to_load(index, my_process, a_process)\n my_process[:process_path] = a_process[:process_path]\n\n if a_process[:process_name].nil?\n my_process[:process_name] = File.basename(a_process[:process_path])\n else\n my_process[:process_name] = a_process[:process_name]\n end\n\n if a_process[:controller_path]\n my_process[:controller_path] = a_process[:controller_path]\n else\n my_process[:controller_name] = a_process[:controller_name]\n end\n\n defaults_file = a_process[:defaults]\n if defaults_file.nil?\n path = a_process[:process_path]\n path['.rb'] = ''\n defaults_file = File.join(path, 'defaults.yaml')\n end\n\n _process_load_data(config, index,\n a_process[:process_name], defaults_file,\n PRC::SectionConfig)\n\n data_file = a_process[:data]\n if defaults_file.nil?\n path = a_process[:process_path]\n path['.rb'] = ''\n data_file = File.join(path, 'data.yaml')\n end\n\n _process_load_data(Lorj.data, index,\n a_process[:process_name], data_file)\n\n # TODO: Implement Object definition as a config layer.\n # _process_load_definition(definition, index, a_process[:process_name],\n # a_process[:definition])\n\n my_process\n end",
"def load_storage\n path = Pathname.new(\"#{ENV['HOME']}/.hush/storage.yml\")\n path.file? ? YAML.load_file(path) : {}\n\n if path.file? && y = YAML.load_file(path)\n y\n else\n {}\n end\n end",
"def create_partitions\n info(\"Creating disk with #{PARTITION_TABLE_TYPE} parition table\")\n execute!(\"parted -s #{@dev} mklabel #{PARTITION_TABLE_TYPE}\")\n\n start_size = FIRST_PARTITION_OFFSET\n end_size = FIRST_PARTITION_OFFSET\n\n unspec_part = nil\n\n # Create the partitions\n @partition_layout.each_with_index do |part, index|\n # Deal with any \"open ended\" partitions last\n if not part.size_mb.is_a?(Integer)\n unspec_part = part\n next\n end\n\n start_size = end_size\n end_size += part.size_mb\n\n info(\"Creating partition #{part.label} (#{part.fs}, #{part.size_mb}MiB)\")\n execute!(\"parted #{@dev} mkpart #{part.label} #{part.fs} #{start_size}MiB #{end_size}MiB\")\n\n (part.flags || {}).each_pair { |k, v|\n info(\"Setting partition flag #{k} to #{v}\")\n execute!(\"parted #{@dev} set #{index + 1} #{k} #{v}\")\n }\n\n label_path = \"/dev/disk/by-partlabel/#{part.label}\"\n self.wait_for_device(label_path)\n\n if not part.fs\n warn(\"No filesystem specified for #{part.label}. Skipping FS\")\n else\n create_filesystem(part.fs, label_path, part.label)\n end\n\n if part.lvm\n notice(\"Setting up LVM on #{part.label}\")\n setup_lvm_on_partition(part)\n end\n end\n\n # Deal with any \"open ended\" partitions (that have an unspecified size_mb)\n if unspec_part\n part = unspec_part\n info(\"Creating partition #{part.label} (#{part.fs}, 100% remaining)\")\n execute!(\"parted #{@dev} mkpart #{part.label} #{part.fs} #{end_size}MiB 100%\")\n\n (part.flags || {}).each_pair { |k, v|\n info(\"Setting partition flag #{k} to #{v}\")\n execute!(\"parted #{@dev} set #{@partition_layout.length} #{k} #{v}\")\n }\n\n label_path = \"/dev/disk/by-partlabel/#{part.label}\"\n self.wait_for_device(label_path)\n create_filesystem(part.fs, label_path, part.label) if part.fs\n\n if part.lvm\n notice(\"Setting up LVM on #{part.label}\")\n setup_lvm_on_partition(part)\n end\n end\n\n nil\n end",
"def load_path\n data[:load_path].nil? ? \"\" : data[:load_path]\n end",
"def bootloader_partitions\n raise RuntimeError, \"Not implemented in base class\"\n end",
"def load(file); end",
"def load()\n\n checkFileExists()\n loadConfigs()\n checkConfigs() \n end",
"def load\n end",
"def load\n end",
"def load_spp\n spp = nil\n if @new_resource.spp_name\n spp = load_resource(:FirmwareDriver, @new_resource.spp_name)\n elsif @new_resource.spp_file\n spp = load_firmware(@new_resource.spp_file)\n else\n raise \"InvalidProperties: The property 'spp_name' or 'spp_file' must be specified.\"\n end\n @item['baselineUri'] = spp['uri']\n end",
"def load(filename)\n\t\tend",
"def load(filename)\n end",
"def load_master\n @master = load_config_file Constants::Filepath::MASTER\n end",
"def load_file(path, name)\n data_file = PStore.new(path)\n data = nil\n data_file.transaction do\n data = data_file[name]\n end\n if data == nil\n data = Array.new\n end\n data\nend",
"def load(file)\r\n if file.starts_with? '.'\r\n bootstrap_path = File.dirname(self.context().config.bootstrap_file)\r\n file = File.join(bootstrap_path, File.basename(file))\r\n end\r\n source_code = load_script_resource(file) # does *safe* IO\r\n load_service(file, source_code)\r\n end",
"def loadConfig(configFile)\n #For Shoes compatability change to a known directory\n Dir.chdir(ENV['HOME'])\n config = {}\n #do this to set parameters that might be missing from the yaml file\n config[:raw_conf_folder_loc] = \"1\"\n config[:drv_conf_folder_loc] = \"2\"\n if File.exist?(configFile)\n config.update(open(configFile) {|f| YAML.load(f) })\n end\n return config\nend",
"def load_file(path)\n load(path)\n end",
"def load_from_filesystem(options)\n return if options[:skip_metadata]\n\n # Load localised data\n ignore_validation = options[:ignore_language_directory_validation]\n Loader.language_folders(options[:metadata_path], ignore_validation).each do |lang_folder|\n language = File.basename(lang_folder)\n (LOCALISED_VERSION_VALUES.keys + LOCALISED_APP_VALUES.keys).each do |key|\n path = File.join(lang_folder, \"#{key}.txt\")\n next unless File.exist?(path)\n\n UI.message(\"Loading '#{path}'...\")\n options[key] ||= {}\n options[key][language] ||= File.read(path)\n end\n end\n\n # Load non localised data\n (NON_LOCALISED_VERSION_VALUES.keys + NON_LOCALISED_APP_VALUES.keys).each do |key|\n path = File.join(options[:metadata_path], \"#{key}.txt\")\n next unless File.exist?(path)\n\n UI.message(\"Loading '#{path}'...\")\n options[key] ||= File.read(path)\n end\n\n # Load review information\n # This is used to find the file path for both new and legacy review information filenames\n resolve_review_info_path = lambda do |option_name|\n path = File.join(options[:metadata_path], REVIEW_INFORMATION_DIR, \"#{option_name}.txt\")\n return nil unless File.exist?(path)\n return nil if options[:app_review_information][option_name].to_s.length > 0\n\n UI.message(\"Loading '#{path}'...\")\n return path\n end\n\n # First try and load review information from legacy filenames\n options[:app_review_information] ||= {}\n REVIEW_INFORMATION_VALUES_LEGACY.each do |legacy_option_name, option_name|\n path = resolve_review_info_path.call(legacy_option_name)\n next if path.nil?\n options[:app_review_information][option_name] ||= File.read(path)\n\n UI.deprecated(\"Review rating option '#{legacy_option_name}' from iTunesConnect has been deprecated. Please replace with '#{option_name}'\")\n end\n\n # Then load review information from new App Store Connect filenames\n REVIEW_INFORMATION_VALUES.keys.each do |option_name|\n path = resolve_review_info_path.call(option_name)\n next if path.nil?\n options[:app_review_information][option_name] ||= File.read(path)\n end\n end",
"def FSCKPartition(partition)\n if !Mode.test\n detected_fs = Storage.DetectFs(partition)\n if detected_fs == :ext2\n # label, %1 is partition\n out = Builtins.sformat(_(\"Checking partition %1\"), partition)\n UI.OpenDialog(Opt(:decorated), Label(out))\n\n Builtins.y2milestone(\"command: /sbin/e2fsck -y %1\", partition)\n SCR.Execute(\n path(\".target.bash\"),\n Ops.add(\"/sbin/e2fsck -y \", partition)\n )\n\n UI.CloseDialog\n end\n end\n\n nil\n end",
"def load_active_from_disk\n workdir = Pathname.new(@workdir)\n if workdir.exist?\n workdir.find do |path|\n # symlinks indicate an active version of a resource\n next unless File.symlink?(path)\n\n target = File.readlink(path)\n # the version will be the parent directory\n version = target.split('/')[-2]\n @active[path.relative_path_from(workdir).to_s] = version\n end\n end\n end",
"def loadfw(filename)\n\tflashimage = Flashimage.new\n\tfirmware = Flashimage.read(filename)\n\tsize = firmware.size\n\toffset_signature = size - 10\n\tsignature = firmware[offset_signature .. -1]\n\tputs(\"signature: #{signature.inspect}\")\n\tlength, magic, crc32, offset_code = getblock('code', firmware, offset_signature)\n\tcode = Partition.new('code')\n\tcode.update(firmware[offset_code ... offset_code + length])\n\tputs code.size\n\tlength, magic, crc32, offset_web = getblock('web', firmware, offset_code)\n\tweb = Partition.new('web')\n\tputs web.size\n\tweb.update(firmware[offset_web ... offset_web + length])\n\tflashimage.update(code)\n\tflashimage.update(web)\n\tflashimage.write\nend",
"def initialize(partition_data)\n @partition_data = partition_data\n end",
"def load_from_file filename\n fnm = File.exist?(filename) ? filename : File.join(@wd,filename)\n load_configuration(fnm)\n end",
"def partition_path path, web = nil\n if (result = (cache = web ? @_partition_path_web : @_partition_path_sys)[path])\n return result\n end\n\n posix_path = posixify path\n\n if web\n # ex. /sample/path\n if web_root? posix_path\n root = SLASH\n # ex. ./sample/path\n elsif posix_path.start_with? DOT_SLASH\n root = DOT_SLASH\n # else ex. sample/path\n end\n elsif root? posix_path\n # ex. //sample/path\n if unc? posix_path\n root = DOUBLE_SLASH\n # ex. /sample/path\n elsif posix_path.start_with? SLASH\n root = SLASH\n # ex. C:/sample/path (or file:///sample/path in browser environment)\n else\n root = posix_path.slice 0, (posix_path.index SLASH) + 1\n end\n # ex. ./sample/path\n elsif posix_path.start_with? DOT_SLASH\n root = DOT_SLASH\n # else ex. sample/path\n end\n\n path_segments = (root ? (posix_path.slice root.length, posix_path.length) : posix_path).split SLASH\n # strip out all dot entries\n path_segments.delete DOT\n cache[path] = [path_segments, root]\n end",
"def create_partition(size = nil, type = Partition.PartitionType[:TYPE_PRIMARY])\n DiskUtils.create_partition self, size[:start_block], size[:end_block]\n partitions = Device.find(self).partitions\n return partitions.last\n end",
"def load_file(file)\n return if @loaded.include? file\n\n # We have to specify Kernel.load, because we have a load method.\n begin\n # Store the file path so we don't try to reload it\n @loaded << file\n Kernel.load(file)\n rescue ScriptError => detail\n # Don't store the path if the file can't be loaded\n # in case it's loadable later on.\n @loaded.delete(file)\n Facter.warn \"Error loading fact #{file} #{detail}\"\n end\n end",
"def create_partition_to_fill_disk(disk)\n # @disk.create_partition('primary', '100%')\n disk.create_partition_table # LinuxAdmin::Disk.create_partition has this already...\n AwesomeSpawn.run!(\"parted -s #{disk.path} mkpart primary 0% 100%\")\n\n # FIXME: Refetch the disk after creating the partition\n disk = LinuxAdmin::Disk.local.find { |d| d.path == disk.path }\n disk.partitions.first\n end",
"def lvm_partition(dev)\n part = %x{sfdisk -l /dev/nbd0 2>/dev/null | grep 8e | cut -d ' ' -f 1}.strip\n part.empty? ? raise(\"Failed to locate LVM partition\") : part\nend",
"def load(name)\n Kernel.load name\nend",
"def initialize\n @path = File.join(File.expand_path('.'), FILE_NAME)\n unless File.exist?(@path)\n @path = (ENV['ASPELLBEE_CONFIG_PATH'] || File.join(File.expand_path('~'), FILE_NAME))\n end\n @data = load_config_file\n end",
"def import_file(path)\n return Kernel.load(path)\nend",
"def load\n @filename = File.expand_path(file_name('feeds.yml'))\n end",
"def restore_from_disk\n log(\"Loading Data in...\")\n\n if File.directory?('buckets') then\n entries = Dir.entries(\"buckets\").collect do |f| f unless f.match(\"bucket\").nil? end.compact\n\n entries.each do |e|\n File.open(\"buckets/\" + e) do |f|\n @contents = Marshal.load(f)\n end\n\n buckets[\"#{e.gsub(\".bucket\", \"\")}\"] = @contents\n\n end\n\n end\n\n end",
"def part\n \"#{path.chomp('.part')}.part\"\n end",
"def load\n end",
"def load\n end",
"def load\n end",
"def CheckPartition(partition)\n partition = deep_copy(partition)\n freshman = {\n :valid => false,\n :name => \"unknown\",\n :arch => \"unknown\",\n :label => Ops.get_string(partition, \"label\", \"\"),\n :fs => Ops.get_symbol(partition, \"detected_fs\", :unknown),\n :fstype => Ops.get_string(partition, \"fstype\", \"unknown\")\n }\n\n p_dev = Ops.get_string(partition, \"device\", \"error\")\n p_fsid = Ops.get_integer(partition, \"fsid\", 0)\n p_type = Ops.get_symbol(partition, \"type\", :primary)\n p_detect_fs = Ops.get_symbol(partition, \"detected_fs\", :unknown)\n\n # possible root FS\n if Builtins.contains(FileSystems.possible_root_fs, p_detect_fs)\n mt_map = {\n :ext2 => \"ext2\",\n :ext3 => \"ext3\",\n :ext4 => \"ext4\",\n :btrfs => \"btrfs\",\n :reiser => \"reiserfs\",\n :xfs => \"xfs\",\n :jfs => \"jfs\"\n }\n mount_type = Ops.get(mt_map, p_detect_fs, \"\")\n\n error_message = nil\n if !(\n error_message_ref = arg_ref(error_message);\n _RunFSCKonJFS_result = RunFSCKonJFS(\n mount_type,\n p_dev,\n error_message_ref\n );\n error_message = error_message_ref.value;\n _RunFSCKonJFS_result\n )\n Ops.set(freshman, :valid, false)\n return deep_copy(freshman)\n end\n\n # mustn't be empty and must be modular\n if mount_type != \"\" && !Builtins.contains(@non_modular_fs, mount_type)\n SCR.Execute(path(\".target.modprobe\"), mount_type, \"\")\n end\n # mount (read-only) partition to Installation::destdir\n Storage.RemoveDmMapsTo(p_dev)\n if Convert.to_boolean(\n SCR.Execute(\n path(\".target.mount\"),\n [p_dev, Installation.destdir, Installation.mountlog],\n \"-o ro\"\n )\n )\n # Is this a root partition, does /etc/fstab exists?\n if Ops.greater_than(\n SCR.Read(\n path(\".target.size\"),\n Ops.add(Installation.destdir, \"/etc/fstab\")\n ),\n 0\n )\n Builtins.y2milestone(\"found fstab on %1\", partition)\n\n fstab = []\n crtab = []\n\n fstab_ref = arg_ref(fstab)\n crtab_ref = arg_ref(crtab)\n read_fstab_and_cryptotab(fstab_ref, crtab_ref, p_dev)\n fstab = fstab_ref.value\n crtab = crtab_ref.value\n Update.GetProductName\n\n fstab = Builtins.filter(fstab) do |p|\n Ops.get_string(p, \"file\", \"\") == \"/\"\n end\n\n if Builtins.size(Ops.get_string(fstab, [0, \"spec\"], \"\")) == 0\n Builtins.y2warning(\"Cannot find / entry in fstab %1\", fstab)\n end\n\n Ops.set(\n freshman,\n :valid,\n Ops.greater_than(\n Builtins.size(Ops.get_string(fstab, [0, \"spec\"], \"\")),\n 0\n ) &&\n Storage.DeviceMatchFstab(\n p_dev,\n Ops.get_string(\n # bugzilla #304269\n # DeviceMatchFstab expects _old_ not _translated_ device\n fstab,\n [0, \"spec_old\"],\n Ops.get_string(fstab, [0, \"spec\"], \"\")\n )\n )\n )\n\n # Why this doesn't match?\n # Possible reasons:\n # - /var not mounted so hwinfo cannot translate device names\n if Ops.get_boolean(freshman, :valid, false) != true\n Builtins.y2warning(\n \"Device does not match fstab: '%1' vs. '%2'\",\n p_dev,\n Ops.get_string(fstab, [0, \"spec\"], \"\")\n )\n end\n if Mode.autoinst\n # we dont care about the other checks in autoinstallation\n SCR.Execute(path(\".target.umount\"), Installation.destdir)\n return deep_copy(freshman)\n end\n\n # Get installed release name\n release = OSRelease.ReleaseInformation(Installation.destdir)\n Builtins.y2debug(\"release: %1\", release)\n if release == \"?\"\n # label for an unknown installed system\n release = _(\"Unknown\")\n end\n Ops.set(freshman, :name, release)\n\n # Right architecture?\n Ops.set(\n freshman,\n :arch,\n GetArchOfELF(Ops.add(Installation.destdir, \"/bin/bash\"))\n )\n instsys_arch = GetArchOfELF(\"/bin/bash\")\n\n # `arch_valid, see bugzilla #288201\n # installed /bin/bash and the one from inst-sys are matching\n if Ops.get_string(freshman, :arch, \"unknown\") == instsys_arch\n Builtins.y2milestone(\"Architecture (%1) is valid\", instsys_arch)\n Ops.set(freshman, :arch_valid, true) \n\n # both are PPC, bugzilla #249791\n elsif Builtins.contains(\n [\"ppc\", \"ppc64\"],\n Ops.get_string(freshman, :arch, \"unknown\")\n ) &&\n Builtins.contains([\"ppc\", \"ppc64\"], instsys_arch)\n Builtins.y2milestone(\n \"Architecture for partition %1 is %2, upgrading %3\",\n p_dev,\n Ops.get_string(freshman, :arch, \"unknown\"),\n instsys_arch\n )\n Ops.set(freshman, :arch_valid, true) \n\n # Architecture is not matching\n else\n Builtins.y2milestone(\n \"Architecture for partition %1 is %2, upgrading %3\",\n p_dev,\n Ops.get_string(freshman, :arch, \"unknown\"),\n instsys_arch\n )\n Ops.set(freshman, :arch_valid, false)\n end\n\n # If architecture is not matching, the whole partition is considered to be wrong\n if Ops.get_boolean(freshman, :arch_valid, false) != true\n Builtins.y2milestone(\n \"Architecture is not valid -> the whole partition is not valid\"\n )\n Ops.set(freshman, :valid, false)\n end\n\n if IncompleteInstallationDetected(Installation.destdir)\n Builtins.y2milestone(\n \"Incomplete installation detected, partition is not valid\"\n )\n Ops.set(freshman, :valid, false)\n end\n\n Builtins.y2milestone(\n \"Partition is valid: %1, arch is valid: %2\",\n Ops.get_boolean(freshman, :valid, false),\n Ops.get_boolean(freshman, :arch_valid, false)\n )\n end\n\n # unmount partition\n SCR.Execute(path(\".target.umount\"), Installation.destdir)\n end\n end\n\n Builtins.y2milestone(\"%1 %2\", partition, freshman)\n\n deep_copy(freshman)\n end",
"def load_n n\n load id_to_full_filename n\n end",
"def mergepartitions\n\tflashdata = \"\\xff\" * FLASHSIZE\n\tbaseaddress = PARTITIONS['boot'][START]\n\tPARTITIONS.each { |label, partition|\n\t\tfirst = partition[START] - baseaddress\n\t\tlast = first + partition[SIZE]\n\t\tfilename = \"#{File.dirname(FLASHIMAGE)}/#{partition[FILE]}\"\n\t\tpartdata = Flashimage.read(filename)\n\t\tsize = partdata.size\n\t\tputs(\"Partition size: #{size / KiB} KiB = #{size} B (#{label}).\")\n\t\traise('Partition size is unexpected.') if (size != partition[SIZE])\n\t\tflashdata[first ... last] = partdata\n\t}\n\tFlashimage.write(flashdata)\nend",
"def load\n\t\tsource = self.depfile.read\n\t\tself.instance_eval( source, self.depfile.to_s, 1 )\n\tend",
"def load!; end",
"def _load(path)\n path = Pathname.new(path)\n @loader.load(path)\n end",
"def path_boot\n case node['platform']\n when \"exherbo\", \"ubuntu\", \"arch\"\n return \"/etc/modules-load.d/#{new_resource.name}.conf\"\n when \"debian\", \"ubuntu\"\n return \"/etc/modules\"\n end\nend",
"def load_setup\n setupFile = @properties[\"config/setup_file\"]\n return unless (setupFile and File.exist?(setupFile))\n file = File.new(setupFile)\n setup = file.read\n file.close\n instance_eval(setup)\n end",
"def initialize file_separator = nil, working_dir = nil\n @file_separator = file_separator || ::File::ALT_SEPARATOR || ::File::SEPARATOR\n @working_dir = working_dir ? ((root? working_dir) ? (posixify working_dir) : (::File.expand_path working_dir)) : ::Dir.pwd\n @_partition_path_sys = {}\n @_partition_path_web = {}\n end",
"def loadBootHive(_filter = nil)\n loadHive(\"BCD\", nil, \"/boot\")\n end",
"def part_install=(part)\n require \"nitro/part/#{part.underscore}\"\n print \"Installing '#{part}' part, press a key to confim..\"\n STDIN.getc\n eval %{#{part}Part.install(\"#{File.expand_path('.')}\")}\n exit\n end",
"def read_data(file)\n if ENV['RACK_ENV'] == 'test'\n local = File.expand_path(\"../test/data/#{file}\", __FILE__)\n else\n local = File.expand_path(\"../data/#{file}\", __FILE__)\n\n if USE_GOOGLE_DRIVE\n remote = google_session.file_by_title(file.to_s)\n remote.download_to_file(local)\n end\n end\n\n YAML.load_file(local)\nend",
"def initialize(image_path, playout_path,\n outfile: nil,\n dev: nil,\n use_system_grub_tools: false)\n\n @tempfile = nil\n\n raise ArgumentError, \"Missing image file\" unless File.exists?(image_path)\n\n @image_tarball_path = image_path\n\n raise ArgumentError, \"Missing layout file\" unless File.exists?(playout_path)\n\n parts = JSON.parse(File.read(playout_path))\n\n raise ArgumentError, \"Partition not an Array\" unless parts.kind_of?(Array)\n\n @partition_layout = (bootloader_partitions + parts).map { |p| DeepStruct.new(p) }\n\n self.validate_partition_layout()\n\n if outfile\n @outfile = outfile\n end\n\n if dev\n @dev = dev\n self.validate_disk_size\n end\n\n if dev.nil? and outfile.nil?\n raise ArgumentError, \"No output file OR device specified!\"\n end\n\n @use_systemwide_grub_tools = use_system_grub_tools\n end",
"def config_read\n f = File.expand_path(CONFIG_FILE)\n if File.readable? f\n load f\n # maybe we should check for these existing else crash will happen.\n #$bookmarks.push(*bookmarks) if bookmarks\n log \"loaded #{CONFIG_FILE} \"\n end\nend",
"def loadDataFromDisk\n begin\n data = NSKeyedUnarchiver.unarchiveObjectWithFile(pathForDataFile)\n print \"(Init) Loaded user data from disk: #{data.inspect}\\n\"\n rescue\n print \"(Init) Corrupt data store! Unarchiving failed! #{$!}\\n\"\n end\n self.user = ApplicationData.new(data)\n end",
"def load_disk_config\n return nil unless File.exists?(@config_file)\n\n config_array = []\n\n File.readlines(@config_file).each do |line|\n next if line =~ /^#.*$/\n config_array.push(line.to_s.strip)\n end\n\n Puppet.debug \"Loaded file: #{@config_file}\"\n return config_array\n end",
"def load_local\n files = lookup(CONFIG_FILE)\n file = files.find{ |f| File.file?(f) }\n new(*file)\n\n #if file\n # paths = [file]\n #else\n # dir = lookup(CONFIG_DIR).find{ |f| File.directory?(f) }\n # paths = dir ? Dir.glob(File.join(dir, '**/*')) : []\n #end\n #files = paths.select{ |path| File.file?(path) }\n end"
] |
[
"0.56779397",
"0.56779397",
"0.56776893",
"0.5607713",
"0.552809",
"0.5422654",
"0.5393423",
"0.53713644",
"0.53360283",
"0.53193",
"0.53123003",
"0.5309336",
"0.5309114",
"0.5309114",
"0.52840716",
"0.5271817",
"0.5270335",
"0.5269269",
"0.52681625",
"0.52555305",
"0.52335936",
"0.52158797",
"0.52158797",
"0.52158797",
"0.5213801",
"0.52044255",
"0.52020925",
"0.51912653",
"0.5187401",
"0.51865995",
"0.517685",
"0.51733124",
"0.5166573",
"0.5155811",
"0.5146988",
"0.5128502",
"0.5125368",
"0.51230925",
"0.51148623",
"0.50909203",
"0.5087126",
"0.5076545",
"0.50757533",
"0.5067704",
"0.505128",
"0.5048528",
"0.5040934",
"0.5040598",
"0.5039842",
"0.50308686",
"0.50233066",
"0.50093794",
"0.50050753",
"0.50024945",
"0.50024945",
"0.49984854",
"0.49914473",
"0.49900848",
"0.4989893",
"0.498494",
"0.498465",
"0.49846375",
"0.49817705",
"0.4980191",
"0.4976853",
"0.4967019",
"0.49620318",
"0.49469745",
"0.49468192",
"0.4937687",
"0.49328786",
"0.49289382",
"0.4928887",
"0.49203092",
"0.49170887",
"0.49138355",
"0.49064505",
"0.49054685",
"0.48967978",
"0.48875684",
"0.4886478",
"0.4886478",
"0.4886478",
"0.48859933",
"0.48748732",
"0.48748392",
"0.4874071",
"0.4871919",
"0.48716673",
"0.4856062",
"0.48551953",
"0.48535994",
"0.48506653",
"0.48447123",
"0.48300132",
"0.48169073",
"0.4813947",
"0.48077422",
"0.48048747",
"0.4804542"
] |
0.6331081
|
0
|
Load firmware file (code and web).
|
def loadfw(filename)
flashimage = Flashimage.new
firmware = Flashimage.read(filename)
size = firmware.size
offset_signature = size - 10
signature = firmware[offset_signature .. -1]
puts("signature: #{signature.inspect}")
length, magic, crc32, offset_code = getblock('code', firmware, offset_signature)
code = Partition.new('code')
code.update(firmware[offset_code ... offset_code + length])
puts code.size
length, magic, crc32, offset_web = getblock('web', firmware, offset_code)
web = Partition.new('web')
puts web.size
web.update(firmware[offset_web ... offset_web + length])
flashimage.update(code)
flashimage.update(web)
flashimage.write
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_firmware\n ensure_client && ensure_uri\n response = @client.rest_get(@data['uri'] + '/firmware')\n @client.response_handler(response)\n end",
"def load_file(path)\n load_string(File.binread(path))\n end",
"def loadpart(partname, filename)\n\tflashimage = Flashimage.new\n\tfirmware = Flashimage.read(filename)\n\tsize = firmware.size\n\toffset_signature = size - 10\n\tsignature = firmware[offset_signature .. -1]\n\tputs(\"signature: #{signature.inspect}\")\n\tlength, magic, crc32, offset = getblock(partname, firmware, offset_signature)\n\tpartition = Partition.new(partname)\n\tpartition.update(firmware[offset ... offset + length])\n\tflashimage.update(partition)\n\tflashimage.write\nend",
"def load(file_path); end",
"def load(file_path); end",
"def bootcode\n\t\t\t# /vl/bc.jsp?v=0.0.0.10&m=00:19:db:9e:92:91&l=00:00:00:00:00:00&p=00:00:00:00:00:00&h=4\n\t\t\t#\n\t\t\t# Firmware version, e.g.0.0.0.10\n\t\t\t@version = params[:v]\n\n\t\t\t# MAC address\n\t\t\t@serial = params[:m]\n\n\t\t\t# Hardware model 4 == V2 model\n\t\t\t@hardware = params[:h]\n\n\n\t\t\tsend_file Rails.public_path+'/'+'bc-nominal-segabor.bin',\n\t\t\t\t:type => 'application/octet-stream'\n\t\tend",
"def pre_soft_load(mod); end",
"def load_file(path)\n send_cmd(\"load #{path}\")\n end",
"def set_firmware\n @firmware = Firmware.find(params[:id])\n end",
"def pre_hard_load(mod); end",
"def load program_binary\n ram[code_start, program_binary.length] = program_binary\n self\n end",
"def load(path); end",
"def file=(path)\n return unless File.exist?(path)\n\n @path = path\n File.open(path, 'rb:UTF-8') do |f|\n @code = f.read\n end\n\n # Check if the input is an SE Linux policy package file (which also use\n # the .pp extension), which all have the first 4 bytes 0xf97cff8f.\n @code = '' if @code[0..3].unpack('V').first == 0xf97cff8f\n end",
"def load_rb(filename); end",
"def read filepath\n\t\t\tbin = File.binread(filepath).unpack(\"C*\")\n\t\t\telf_ident = bin[0, ELF_IDENT_SIZE]\n\n\t\t\t# check magic number\n\t\t\tunless is_elf? elf_ident\n\t\t\t\tthrow \"This is not ELF Format File\"\n\t\t\tend\n\n\t\t\t# Check ELF class\n\t\t\tval = elf_ident[ELF_IDENT_OFFSET_CLASS].ord\n\t\t\tcase val\n\t\t\twhen ELF_CLASS_ELF32\n\t\t\t\t@elf_class = ELF_CLASS_ELF32\n\n\t\t\t\t# set Address and Offset size for ELF32\n\t\t\t\t@address_size = ELF_SIZE_ADDR_32\n\t\t\t\t@offset_size = ELF_SIZE_OFFSET_32\n\t\t\twhen ELF_CLASS_ELF64\n\t\t\t\t@elf_class = ELF_CLASS_ELF64\n\n\t\t\t\t# set Address and Offset size for ELF64\n\t\t\t\t@address_size = ELF_SIZE_ADDR_64\n\t\t\t\t@offset_size = ELF_SIZE_OFFSET_64\n\t\t\telse\n\t\t\t\tthrow \"Invalid ELF Class:#{val}\"\n\t\t\tend\n\n\t\t\t# Check Endian\n\t\t\tval = elf_ident[ELF_IDENT_OFFSET_ENDIAN].ord\n\t\t\tcase val\n\t\t\twhen ELF_LITTLE_ENDIAN, ELF_BIG_ENDIAN\n\t\t\t\t@elf_endian = val\n\t\t\telse\n\t\t\t\tthrow \"Invalid ELF Endian:#{val}\"\n\t\t\tend\n\n\t\t\t# Check ELF Format Version\n\t\t\tval = elf_ident[ELF_IDENT_OFFSET_FORMAT_VERSION].ord\n\t\t\tunless val == 1\n\t\t\t\tthrow \"Unsuppoted ELF Format Version:#{val}\"\n\t\t\tend\n\t\t\t@elf_version = val\n\n\t\t\t# Check OS ABI\n\t\t\tval = elf_ident[ELF_IDENT_OFFSET_OS_ABI].ord\n\t\t\tcase val\n\t\t\twhen OS_ABI_UNIX, OS_ABI_LINUX\n\t\t\t\t@os_abi = val\n\t\t\telse\n\t\t\t\tthrow \"Unsuppoted OS ABI Format:#{val}\"\n\t\t\tend\n\n\t\t\t# Check OS ABI Version\n\t\t\t@os_abi_version = elf_ident[ELF_IDENT_OFFSET_OS_ABI_VERSION]\n\n\t\t\t@bin = bin\n\t\t\t@ident = elf_ident\n\n\t\t\tis_little = @elf_endian == ELF_LITTLE_ENDIAN\n\t\t\tcase @elf_class\n\t\t\twhen ELF_CLASS_ELF32\n\t\t\t\t@elf_type = @bin[ELF32_OFFSET_TYPE, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\t\t@elf_machine = @bin[ELF32_OFFSET_MACHINE, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\t\t@elf_version = @bin[ELF32_OFFSET_VERSION, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\t\t@elf_entry = @bin[ELF32_OFFSET_ENTRY, ELF_SIZE_ADDR_32].to_i(is_little)\n\t\t\t\t@elf_program_h_offset = @bin[ELF32_OFFSET_PROGRAM_HEADER, ELF_SIZE_OFFSET_32].to_i(is_little)\n\t\t\t\t@elf_section_h_offset = @bin[ELF32_OFFSET_SECTION_HEADER, ELF_SIZE_OFFSET_32].to_i(is_little)\n\t\t\t\t@elf_flags = @bin[ELF32_OFFSET_FLAGS, ELF_SIZE_WORD].to_i(is_little)\n\t\t\t\t@elf_h_size \t\t= @bin[ELF32_OFFSET_ELF_HEADER_SIZE, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\t\t@elf_program_h_size = @bin[ELF32_OFFSET_PROGRAM_HEADER_SIZE, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\t\t@elf_program_h_num = @bin[ELF32_OFFSET_PROGRAM_HEADER_NUM, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\t\t@elf_section_h_size = @bin[ELF32_OFFSET_SECTION_HEADER_SIZE, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\t\t@elf_section_h_num = @bin[ELF32_OFFSET_SECTION_HEADER_NUM, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\t\t@elf_section_name_idx = @bin[ELF32_OFFSET_SECTION_NAME_IDX, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\twhen ELF_CLASS_ELF64\n\t\t\t\t@elf_type = @bin[ELF64_OFFSET_TYPE, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\t\t@elf_machine = @bin[ELF64_OFFSET_MACHINE, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\t\t@elf_version = @bin[ELF64_OFFSET_VERSION, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\t\t@elf_entry = @bin[ELF64_OFFSET_ENTRY, ELF_SIZE_ADDR_64].to_i(is_little)\n\t\t\t\t@elf_program_h_offset = @bin[ELF64_OFFSET_PROGRAM_HEADER, ELF_SIZE_OFFSET_64].to_i(is_little)\n\t\t\t\t@elf_section_h_offset = @bin[ELF64_OFFSET_SECTION_HEADER, ELF_SIZE_OFFSET_64].to_i(is_little)\n\t\t\t\t@elf_flags = @bin[ELF64_OFFSET_FLAGS, ELF_SIZE_WORD].to_i(is_little)\n\t\t\t\t@elf_h_size \t\t= @bin[ELF64_OFFSET_ELF_HEADER_SIZE, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\t\t@elf_program_h_size = @bin[ELF64_OFFSET_PROGRAM_HEADER_SIZE, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\t\t@elf_program_h_num = @bin[ELF64_OFFSET_PROGRAM_HEADER_NUM, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\t\t@elf_section_h_size = @bin[ELF64_OFFSET_SECTION_HEADER_SIZE, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\t\t@elf_section_h_num = @bin[ELF64_OFFSET_SECTION_HEADER_NUM, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\t\t@elf_section_name_idx = @bin[ELF64_OFFSET_SECTION_NAME_IDX, ELF_SIZE_HALF_WORD].to_i(is_little)\n\t\t\telse\n\t\t\t\tthrow \"Invalid ELF Class #{@elf_class}\"\n\t\t\tend\n\n\t\t\t# create section name - section index map.\n\t\t\tinitialize_section_h_map\n\n\t\t\t# DEBUG\n\t\t\t#show_elf_header\n\n\t\t\tget_program_header\n\t\tend",
"def post_soft_load(mod); end",
"def wifi_firmware(fetch: true)\n @wifi_firmware ||= begin\n send_message!(Protocol::Device::GetWifiFirmware.new,\n wait_for: Protocol::Device::StateWifiFirmware) do |payload|\n Firmware.new(payload)\n end if fetch\n end\n end",
"def load_file\n data = ''\n #@file = Pathname.new(Gem.loaded_specs['wmap'].full_gem_path).join('data', 'domains')\n @file = Rails.root.join('shared','data','domains')\n file = File.open(@file, 'r')\n file.each_line { |line| data += line }\n file.close\n render plain: data\n end",
"def load_file(filename); end",
"def load_file(filename); end",
"def load; end",
"def load; end",
"def load; end",
"def load_file(file_path)\n\t\t\tcode = File.open(file_path) { |f| f.read }\n\t\t\trun(code)\n\t\tend",
"def load_file(file); end",
"def load\n @checksum ||= ::File.exists?(checksum_file) ? ::File.read(checksum_file) : ''\n Chef::Log.debug(\"Loaded checksum for SMF #{self.name}: #{@checksum}\")\nend",
"def load(filename)\n end",
"def load_file(file)\n kernel_load(file)\n end",
"def load(file); end",
"def load(str=nil)\r\n case language\r\n when :boolexp\r\n self.src = str\r\n log.info \"Load of BoolExp program - #{name}\"\r\n true\r\n when :fart\r\n File.open(\"farts/#{name}.fart\") {|f|\r\n self.src = f.read\r\n }\r\n log.info \"Load of FART program - #{name}\"\r\n true\r\n else\r\n false\r\n end\r\n end",
"def post_hard_load(mod); end",
"def load_file(file_path)\n\t\t\tcode = File.open(file_path) { |f| f.read }\n\t\t\t@interpreter.run(code)\n\t\tend",
"def load_compiled_file(path, version)\n Ruby.primitive :compiledfile_load\n\n raise InvalidRBC, path\n end",
"def load(filename)\n\t\tend",
"def update_firmware(attributes = {})\n patch('replace', '/firmware', attributes)\n end",
"def load_bin filename\n hibyte = 0 # Upper, actual byte, under read head.\n lobyte = 0 # Lower byte of the word.\n word = 0 # Readed word.\n origin = 0 # Origin, memory pointer (0o OOOO)\n field = 0 # Actual field in form (0o F0000)\n checksum = 0\n\n File.open filename do |f|\n\n # Tape must begin with LEADER marks (0b 1000 000). We must\n # skip all these, and read first byte before entering the main\n # reading loop.\n hibyte = 0200\n hibyte = f.readchar while hibyte == 0200\n\n # In 'endless' loop we interpret data on the paper tape.\n while true\n\n # We look into the byte and decide what is on the tape now.\n case hibyte >> 6\n\n when 0b00 # DATA, next byte contains lower 6 bits of the word.\n lobyte = f.readchar\n word = (hibyte << 6) | lobyte\n sum = lobyte + hibyte\n # Read the next byte because we need to know if it's\n # TRAILER or not.\n hibyte = f.readchar\n if hibyte != 0200 then\n @content[field | origin] = word\n origin = (origin +1) & 07777 # Advance origin by one.\n checksum += sum\n end\n next\n\n when 0b01 # ORIGIN, next byte contains lower 6 bits of origin.\n lobyte = f.readchar\n origin = ((hibyte & 0o77) << 6) | lobyte\n checksum += hibyte + lobyte\n\n when 0b10 # TRAILER marks the end of tape.\n # Last word written to memory is checksum. We must check\n # it and remove from memory.\n checksum &= 07777\n if checksum != word then\n puts \"BIN loader checksum error: computer=%0.4o, on tape=%0.4o\" % [checksum, word]\n exit\n end\n break\n\n when 0b11 # FIELD SETTING byte contains the filed number.\n field = (hibyte & 070) << 9\n end\n\n hibyte = f.readchar # Read the next byte.\n end\n end\n\n end",
"def load(name); end",
"def load!; end",
"def set_firmware_driver(firmware)\n self['firmwareBaselineUri'] = firmware['uri'] if firmware['uri'] || firmware.retrieve!\n raise \"Resource #{firmware['customBaselineName']} could not be found!\" unless firmware['uri']\n end",
"def load\n return unless @file_path && File.exist?(@file_path)\n File.open(@file_path, 'rb') do |file|\n return Marshal.load(file)\n end\n end",
"def load_from(source)\n if ( source[0..4] == 'http:' || source[0..5] == 'https:' )\n load_url(source)\n else\n load_file(source)\n end\n end",
"def load_source\n load source\n end",
"def load_source!\n @source = load_file_contents\n end",
"def load\n end",
"def load_data_utf8(filename)\n unless PSDK_CONFIG.release? && filename.start_with?('Data/')\n File.open(filename) do |f|\n return Marshal.load(f, proc { |o| o.class == String ? o.force_encoding(Encoding::UTF_8) : o })\n end\n end\n return load_data(filename, true)\nend",
"def load\r\n \r\n end",
"def load\r\n\t\tload_file\r\n\t\tconfigure\r\n\tend",
"def load\n end",
"def load\n end",
"def load!(file)\n bytes = file.split(/\\W+/).map { |code| code.to_i }\n code_start = 4\n code_end = bytes[0] + code_start # header is 4 ints long\n global_size = bytes[1]\n str_size = bytes[2]\n\n @code = bytes[code_start...code_end]\n @data[global_size, str_size] = bytes[code_end, str_size]\n\n return @code\n end",
"def load\n\t\tsource = self.depfile.read\n\t\tself.instance_eval( source, self.depfile.to_s, 1 )\n\tend",
"def load_from(path)\n Halcyon::Config::File.load(path)\n end",
"def load_file(path)\n load(path)\n end",
"def load_path=(load_path); end",
"def load(file)\r\n if file.starts_with? '.'\r\n bootstrap_path = File.dirname(self.context().config.bootstrap_file)\r\n file = File.join(bootstrap_path, File.basename(file))\r\n end\r\n source_code = load_script_resource(file) # does *safe* IO\r\n load_service(file, source_code)\r\n end",
"def load_path; end",
"def load_wurfl(wurflfilepath)\n fallbacks = {}\n doc = XML::Document.file(wurflfilepath)\n doc.find(\"///devices/device\").each do |element| \n wurfl_id = element.attributes[\"id\"] \n h = @handsets[wurfl_id] ||= Wurfl::Handset.new(wurfl_id, element.attributes[\"user_agent\"], nil, element.attributes[\"actual_device_root\"])\n fall_back_id = element.attributes[\"fall_back\"]\n fallbacks[wurfl_id] = fall_back_id unless fall_back_id == \"root\"\n \n element.find(\"group/capability\").each do |capability|\n h[capability.attributes[\"name\"]] = capability.attributes[\"value\"]\n end\n end\n\n fallbacks.each {|k,v| @handsets[k].fallback = @handsets[v]}\n \n @handsets\n end",
"def gp_install_load(file_aid, sd_aid = nil, data_hash = [], params = {},\n token = [])\n ber_params = []\n \n data = [file_aid.length, file_aid, sd_aid.length, sd_aid,\n Asn1Ber.encode_length(data_hash.length), data_hash,\n Asn1Ber.encode_length(ber_params.length), ber_params,\n Asn1Ber.encode_length(token.length), token].flatten\n response = iso_apdu! :cla => 0x80, :ins => 0xE6, :p1 => 0x02, :p2 => 0x00,\n :data => data\n response == [0x00]\n end",
"def get_program_file_data(program_file)\n File.open(program_file,'rb'){|f| f.read}\nend",
"def load\n instance_eval File.read(@path).tap(&Gem::UNTAINT), @path, 1\n\n self\n end",
"def load_dataE(filename)\r\n Log.ger.debug('Read '+filename)\r\n File.open(filename, \"rb\") { |f|\r\n obj = Marshal.load(f)\r\n }\r\nend",
"def load file='GOL.sav'\n self.state=File.open(file,'r') do |f|\n Marshal.load(f)\n end\n end",
"def load_and_run!\n File.open(@pathfile, \"w\") { |f| f.write(@pathfile_contents) }\n Pathological.add_paths!(@load_path)\n end",
"def load_rom(rom_filename)\n rom_file = File.new(rom_filename, \"r\")\n memcnt = @instruction_ptr\n while (opcode = rom_file.read(2))\n opcode_bytes = opcode.bytes.to_a\n @memory[memcnt] = opcode_bytes[0]\n @memory[memcnt+1] = opcode_bytes[1]\n memcnt += 2\n end\n end",
"def get_firmware_files\n response = request(:get, \"/devmgr/v2/firmware/cfw-files/\")\n status(response, 200, 'Failed to get uploaded firmware file list')\n JSON.parse(response.body)\n end",
"def read_embedded_file(path)\n str = nil\n $LOAD_PATH.each do |loc|\n next if load_path_invalid?(loc)\n serf_name = get_serf_name(loc, path)\n str = self.read(serf_name)\n return str.to_s if str\n end\n false\n end",
"def load\n initialize(File.info(uuid).entity)\n end",
"def load!(file = T.unsafe(nil)); end",
"def load_character account, filename\n end",
"def load_specification(file_name); end",
"def load_or_run(path)\n result = nil\n if File.exist?(path)\n File.open(path, 'rb') { |f| result = Marshal.load(f) }\n else\n result = yield\n File.open(path, 'wb') { |f| Marshal.dump(result, f) }\n end\n result\nend",
"def l(filename)\n load \"#{filename}.rb\"\nend",
"def firmware_name\n \"Little Wire\"\n end",
"def initialize(asm_filename)\n @lines = File.readlines(asm_filename)\n @hack_file = File.open(hack_filename(asm_filename), \"w\")\n @symbol_table = SymbolTable.new()\n @rom_location = 0\n end",
"def load!(file=nil)\n return if @loaded\n\n file ||= latest_binary_file\n\n unless file && File.readable?(file)\n if ENV['SWISSMATCH_DATA']\n raise LoadError.new(\"File #{file.inspect} not found or not readable (used SWISSMATCH_DATA, data_directory=#{@data_directory}) - see https://github.com/apeiros/swissmatch-location#installation\", nil)\n else\n raise LoadError.new(\"File #{file.inspect} not found or not readable (used ~/.swissmatch, data_directory=#{@data_directory}) - see https://github.com/apeiros/swissmatch-location#installation\", nil)\n end\n end\n\n data = File.read(file, encoding: Encoding::BINARY)\n date, random_code, zip1_count, zip2_count, com1_count, com2_count, district_count = *data[0,18].unpack(\"NNn*\")\n int1_size, int2_size, int4_size, text_size = *data[18,16].unpack(\"N*\")\n\n offset = 34\n int1_cols = data[offset, int1_size].unpack(\"C*\")\n int2_cols = data[offset+=int1_size, int2_size].unpack(\"n*\")\n int4_cols = data[offset+=int2_size, int4_size].unpack(\"N*\")\n text_cols = data[offset+=int4_size, text_size].force_encoding(Encoding::UTF_8).split(\"\\x1f\")\n\n offset = 0\n zip1_type = int1_cols[offset, zip1_count]\n zip1_addon = int1_cols[offset += zip1_count, zip1_count]\n zip1_language = int1_cols[offset += zip1_count, zip1_count]\n zip1_language_alternative = int1_cols[offset += zip1_count, zip1_count]\n zip2_region = int1_cols[offset += zip1_count, zip2_count]\n zip2_type = int1_cols[offset += zip2_count, zip2_count]\n zip2_lang = int1_cols[offset += zip2_count, zip2_count]\n com2_PLZZ = int1_cols[offset += zip2_count, com2_count]\n\n offset = 0\n zip1_onrp = int2_cols[offset, zip1_count]\n zip1_code = int2_cols[offset += zip1_count, zip1_count]\n zip1_delivery_by = int2_cols[offset += zip1_count, zip1_count]\n zip1_largest_community_number = int2_cols[offset += zip1_count, zip1_count]\n zip2_onrp = int2_cols[offset += zip1_count, zip2_count]\n com1_bfsnr = int2_cols[offset += zip2_count, com1_count]\n com1_agglomeration = int2_cols[offset += com1_count, com1_count]\n com2_GDENR = int2_cols[offset += com1_count, com2_count]\n com2_PLZ4 = int2_cols[offset += com2_count, com2_count]\n district_GDEBZNR = int2_cols[offset += com2_count, district_count]\n\n zip1_valid_from = int4_cols\n\n offset = 0\n zip1_name_short = text_cols[offset, zip1_count]\n zip1_name = text_cols[offset += zip1_count, zip1_count]\n zip1_canton = text_cols[offset += zip1_count, zip1_count]\n zip2_short = text_cols[offset += zip1_count, zip2_count]\n zip2_name = text_cols[offset += zip2_count, zip2_count]\n com1_name = text_cols[offset += zip2_count, com1_count]\n com1_canton = text_cols[offset += com1_count, com1_count]\n district_GDEKT = text_cols[offset += com1_count, district_count]\n district_GDEBZNA = text_cols[offset += district_count, district_count]\n\n zip1 = [\n zip1_onrp, zip1_type, zip1_canton, zip1_code, zip1_addon,\n zip1_delivery_by, zip1_language, zip1_language_alternative,\n zip1_name_short, zip1_name, zip1_largest_community_number,\n zip1_valid_from\n ].transpose\n zip2 = [zip2_onrp, zip2_region, zip2_type, zip2_lang, zip2_short, zip2_name].transpose\n com1 = [com1_bfsnr, com1_name, com1_canton, com1_agglomeration].transpose\n com2 = [com2_PLZ4, com2_PLZZ, com2_GDENR].transpose\n district = [district_GDEKT, district_GDEBZNR, district_GDEBZNA].transpose\n\n @date = Date.jd(date)\n @random_code = random_code\n @cantons = AllCantons\n @districts = load_districts(district)\n @communities = load_communities(com1)\n @zip_codes = load_zipcodes(zip1, zip2, com2)\n\n self\n end",
"def loadFile(filename)\n\t\t\tdescname = filename.basename.sub_ext(\"\").to_s + \"Desc\"\n\t\t\tif(!@loaded.include?(descname))\n\t\t\t\t@loaded << descname\n\n\t\t\t\tfilename = filename.to_s\n\t\t\t\tlast = $mec_mgr\n\n\t\t\t\t$mec_mgr = self\n\t\t\t\trequire(filename)\n\t\t\t\t$mec_mgr = last\n\t\t\t\t\n\t\t\t\tdesc = begin\n\t\t\t\t\tMakeRbExt.const_get(descname)\n\t\t\t\trescue NameError\n\t\t\t\t\traise(\"File `#{filename}' should contain a ruby module `#{descname}', but doesn't\")\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tdesc.register(@settings)\n\t\t\tend\n\t\tend",
"def load\n if File.exist?(@path) && !self.loaded?\n @source = File.read(@path)\n context = Context.new(self)\n eval @source, context.binding, @path.to_s, 1\n @loaded = true\n end \n end",
"def loadfile _file_url, _append\n send_cmd(\"loadfile #{_file_url} #{_append}\")\n end",
"def reload; @data = File.read @path end",
"def testget_leveled_file_contentNonRubyFile\n assert_raise(LoadError) do\n RCodeLeveler.get_leveled_file_content('RequiredFiles/NonRubyFile.so')\n end\n end",
"def load(file_name, default_env = T.unsafe(nil)); end",
"def load(fname)\n # search for configuration file\n unless File.exist?(fname)\n fname = File.exist?(File.expand_path(fname)) ?\n File.expand_path(fname) :\n File.join(PATH[\"config\"], fname)\n end\n \n # parsing document by REXML lib\n doc = REXML::Document.new File.new(fname)\n \n # get configuration node\n config = doc.root\n \n # initialize array of instances of ModelConfig\n marr = Array.new\n\n # load texture library\n # --------------------\n # get material handle of SketchUp\n mts = Sketchup.active_model.materials\n # load materials with specific texture\n config.elements.each(\"texture\") do |t|\n tname = t.attributes[\"name\"].downcase\n # add new material if not exist\n unless mts[tname]\n # add a new material\n mt = mts.add(tname)\n # search for texture file\n tfile = File.exist?(t.text) ? t.text : File.expand_path(t.text)\n tfile = File.join(PATH[\"texture\"], t.text) unless File.exist?(tfile)\n # assigne texture file to it\n mt.texture = tfile\n # show information\n puts \"Loaded Texture : #{tname}\"\n end\n end\n \n # load surface library\n # --------------------\n config.elements.each(\"surflib\") do |sl|\n slname = sl.attributes[\"name\"].downcase\n # add new surface to surface library if not exist before\n unless @@surflib[slname]\n # add new surface\n @@surflib[slname] = SurfConfig.new(sl)\n # print information\n puts \"Loaded Surface : #{slname} [Surface Library]\"\n end\n end\n\n # generate ModelConfig instance for each model node\n config.elements.each(\"model\") {|m| marr << ModelConfig.new(m)}\n \n # return the array of model configuration\n return marr\n end",
"def load_from_file_cache(file)\n puts \"loading stuff from #{file}\"\n File.open(file, 'r') do |input|\n Marshal.load(input.read)\n end\n end",
"def file\n #load_file\n @file ||= load_file\n end",
"def load_library\n\t\t#wget some url\n\tend",
"def read_binary(path)\n if exist? path\n File.binread(expand path)\n else\n nil\n end\n end",
"def load_file\n raise NotImplementedError, \"loading Ruby source files is not implemented\"\n end",
"def load_game\n print_saves\n begin\n read_save\n rescue IOError, SystemCallError\n puts 'File not found'\n load_game\n end\n end",
"def load\n end",
"def load\n end",
"def load\n end",
"def file path\n STDERR.puts \"file called with: #{path}\"\n puts \"Loading file: #{path}\"\n begin\n load path\n rescue => e\n puts e.inspect\n puts e.backtrace.join(\"\\n\\tfrom \")\n end\n end",
"def load(file)\n path = expand_path(file)\n runtime.run(path) if path\n end",
"def do_load_file(path)\n @btn_play.enable\n\t@btn_pause.enable\n\t@btn_stop.enable\n unless @mc.load(path)\n Wx::message_box(\"Unable to load file\", \"ERROR\",\n Wx::ICON_ERROR|Wx::OK)\n else\n \n end\n end",
"def bits_full_local_path_dl\n \"#{bits_full_local_path}.dl\"\n end",
"def loadBootHive(_filter = nil)\n loadHive(\"BCD\", nil, \"/boot\")\n end",
"def pbGetFileString(file)\n file = canonicalize(file)\n if !(safeExists?(\"./Game.rgssad\") || safeExists?(\"./Game.rgss2a\"))\n return nil if !safeExists?(file)\n begin\n File.open(file,\"rb\") { |f| return f.read } # read all data\n rescue Errno::ENOENT, Errno::EINVAL, Errno::EACCES\n return nil\n end\n end\n Marshal.neverload = true\n str = nil\n begin\n str = load_data(file)\n rescue Errno::ENOENT, Errno::EINVAL, Errno::EACCES, RGSSError\n str = nil\n ensure\n Marshal.neverload = false\n end\n return str\nend",
"def load_launcher_data launcher_data_file=\"bin/LAUNCHER_TYPE\"\n launcher_data = nil\n\n begin\n File.open launcher_data_file do |f|\n launcher_data = YAML.load(f.read)\n end\n rescue Errno::ENOENT\n end\n\n return launcher_data\nend",
"def pbGetFileString(file)\n file=canonicalize(file)\n if !(safeExists?(\"./Game.rgssad\") || safeExists?(\"./Game.rgss2a\"))\n return nil if !safeExists?(file)\n begin\n File.open(file,\"rb\"){|f|\n return f.read # read all data\n }\n rescue Errno::ENOENT, Errno::EINVAL, Errno::EACCES\n return nil\n end\n end\n Marshal.neverload=true\n str=nil\n begin\n str=load_data(file)\n rescue Errno::ENOENT, Errno::EINVAL, Errno::EACCES, RGSSError\n str=nil\n ensure\n Marshal.neverload=false\n end\n return str\nend",
"def get_loaded_model(model_path, file); end"
] |
[
"0.63007134",
"0.6011472",
"0.5928067",
"0.5909968",
"0.5909968",
"0.58938366",
"0.5889059",
"0.5864592",
"0.5854285",
"0.5824867",
"0.5769541",
"0.5741391",
"0.57156634",
"0.56640905",
"0.56462",
"0.5618558",
"0.5609447",
"0.56001127",
"0.55932903",
"0.55932903",
"0.55531216",
"0.55531216",
"0.55531216",
"0.55209154",
"0.5513724",
"0.55131376",
"0.548863",
"0.54878265",
"0.5480537",
"0.5478505",
"0.54709214",
"0.5464918",
"0.5464548",
"0.5451477",
"0.5414982",
"0.5405409",
"0.53910345",
"0.5385307",
"0.53839844",
"0.537977",
"0.5378314",
"0.5378138",
"0.5377003",
"0.53739107",
"0.5370436",
"0.5352905",
"0.5350246",
"0.5334548",
"0.5334548",
"0.53330445",
"0.5312441",
"0.5308554",
"0.5305668",
"0.5297509",
"0.5289312",
"0.5277602",
"0.52773714",
"0.52771854",
"0.5263487",
"0.5259236",
"0.5232286",
"0.52273875",
"0.5226978",
"0.5226243",
"0.52002347",
"0.51946956",
"0.51922977",
"0.5190843",
"0.51714444",
"0.5158538",
"0.51516676",
"0.51428366",
"0.5142016",
"0.5139553",
"0.5130727",
"0.5129303",
"0.5120341",
"0.51133066",
"0.51109",
"0.51090133",
"0.5103386",
"0.50982046",
"0.50976515",
"0.50964063",
"0.5085045",
"0.50847423",
"0.5075893",
"0.5074467",
"0.5072003",
"0.5072003",
"0.5072003",
"0.5067573",
"0.506558",
"0.5057632",
"0.5046319",
"0.5030421",
"0.50299674",
"0.5024007",
"0.5015399",
"0.5006207"
] |
0.72785926
|
0
|
GET /boots/1 GET /boots/1.json
|
def show
@boot = Boot.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @boot }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @boot = Boot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @boot }\n end\n end",
"def index\n info = Aws.get_recipes_from_db\n render :json => info\n end",
"def show\n @boot = Boot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @boot }\n end\n end",
"def index\n @testboots = Testboot.all\n end",
"def create\n @boot = Boot.new(params[:boot])\n puts \"=================================================================\"\n puts params[:boot]\n p @boot.bootlargeimage_file_name\n puts \"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\"\n\n \n respond_to do |format|\n if @boot.save\n flash[:success] = \"Boot was successfully created\"\n format.html { redirect_to boots_path, notice: 'Boot was successfully created.' }\n format.json { render json: boots_path, status: :created, location: @boot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @boot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n response = Aws.list_recipe(params[:id])\n render :json => response\n end",
"def index\n @recipes = Recipe.all\n render json: @recipes\n end",
"def get_brandings\n request :get, \"/v3/brandings.json\"\n end",
"def update\n @boot = Boot.find(params[:id])\n\n respond_to do |format|\n if @boot.update_attributes(params[:boot])\n flash[:success] = \"Updated successfully \"\n format.html { redirect_to boots_path, notice: 'Boot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @boot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @boot = Boot.new(params[:boot])\n\n respond_to do |format|\n if @boot.save\n flash[:notice] = 'Boot was successfully created.'\n format.html { redirect_to(@boot) }\n format.xml { render :xml => @boot, :status => :created, :location => @boot }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @boot.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @super_bowl_picks = SuperBowlPick.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @super_bowl_picks }\n end\n end",
"def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end",
"def show\n @baton = Baton.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @baton }\n end\n end",
"def index\n @bemaps = Bemap.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bemaps }\n end\n end",
"def show\n @bloom = Bloom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bloom }\n end\n end",
"def index\n @machines = Machine.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @machines }\n end\n end",
"def index\n @recipes = Recipe.all\n respond_to do |format|\n format.html {}\n format.json { render json: @recipes }\n end\n end",
"def index\n @recipes = Recipe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipes }\n end\n end",
"def show\n\n recipe = Recipe.find(params[:id])\n render :json => recipe.to_json\n\n end",
"def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend",
"def show\n @beacon = Beacon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @beacon }\n end\n end",
"def index\n @macs = Mac.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @macs }\n end\n end",
"def show\n @climb = Climb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @climb }\n end\n end",
"def destroy\n @boot = Boot.find(params[:id])\n @boot.destroy\n\n respond_to do |format|\n format.html { redirect_to(boots_url) }\n format.xml { head :ok }\n end\n end",
"def set_testboot\n @testboot = Testboot.find(params[:id])\n end",
"def show\n @rainbow = Rainbow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rainbow }\n end\n end",
"def show\n @scratcher = Scratcher.find(params[:id])\n\n render json: @scratcher\n end",
"def show\n @broad = Broad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @broad }\n end\n end",
"def index\n @applications = Application.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @applications }\n end\n end",
"def new\n @boot = Boot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @boot }\n end\n end",
"def show\n @boat = Boat.find(params[:id])\n\n render json: @boat\n end",
"def show\n @fabric = Fabric.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fabric }\n end\n end",
"def show\n @supermarket = Supermarket.find(params[:id])\n respond_to do |format|\n format.json { render json: @supermarket, status: :ok } \n end \n end",
"def show\n @logstash = Logstash.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @logstash }\n end\n end",
"def index\n @apps = @client.apps\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @apps }\n end\n end",
"def index\n @requests = Request.all\n\n render json: @requests\n end",
"def index\r\n @machines = Machine.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @machines }\r\n end\r\n end",
"def show\n @scrobble = Scrobble.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @scrobble }\n end\n end",
"def index\n @applications = Application.all\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render json: @applications }\n end\n end",
"def index\n render json: Recipe.all\n end",
"def show(id) \n response = request(:get, \"/recipes/#{id}.json\")\n response.first[1]\n end",
"def show\n recipe = Recipe.find(params[:id])\n # recipes = Recipe.find_by(params[:id])\n # render json: recipe\n render json: recipe\n end",
"def getbatteries\n puts params\n buildid = params[\"buildingid\"]\n\n batteries = Battery.where(:building_id => buildid)\n\n puts batteries.inspect\n puts \"#################################################\"\n \n respond_to do |format|\n format.json { render json: batteries }\n end\n end",
"def index\n @down_sizes = DownSize.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @down_sizes }\n end\n end",
"def show\n @bike = Bike.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bike }\n end\n end",
"def create\n @testboot = Testboot.new(testboot_params)\n\n respond_to do |format|\n if @testboot.save\n format.html { redirect_to @testboot, notice: 'Testboot was successfully created.' }\n format.json { render :show, status: :created, location: @testboot }\n else\n format.html { render :new }\n format.json { render json: @testboot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @beer = BreweryDB.beer(params[:id]) \n render json: @beer\n end",
"def boot?(ip = nil)\n path = \"/boot\"\n path << \"/#{ip}\" if ip\n perform_get path\n end",
"def destroy\n @boot = Boot.find(params[:id])\n @boot.destroy\n\n\n respond_to do |format|\n flash[:success] = \"Deleted successfully \"\n format.html { redirect_to boots_url }\n format.json { head :no_content }\n end\n end",
"def index\n weathers = Weather.all\n render json: weathers, status: 200\n end",
"def show\n @kb = Kb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @kb }\n end\n end",
"def index\n @supermarkets = Supermarket.all\n respond_to do |format|\n format.json { render json: @supermarkets, status: :ok } \n end \n end",
"def show\n @bundlesticker = Bundlesticker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bundlesticker }\n end\n end",
"def show\n @machine = Machine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @machine }\n end\n end",
"def show\n @machine = Machine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @machine }\n end\n end",
"def show\n @machine = Machine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @machine }\n end\n end",
"def show\n @machine = Machine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @machine }\n end\n end",
"def show\n render json: Server.where(name: params[:name]).first\n end",
"def show\n @apk_bin = ApkBin.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @apk_bin }\n end\n end",
"def show\n render \"api/v1/bounties/show\"\n end",
"def show\n @book_shelf = BookShelf.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book_shelf }\n end\n end",
"def show\n @sleep = Sleep.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sleep }\n end\n end",
"def ipxe_boot_url\n vars = {}\n (1..@nic_max).each do |index|\n net_id = \"net#{index - 1}\"\n vars[net_id] = \"${#{net_id}/mac:hexhyp}\"\n end\n [\"dhcp_mac\", \"serial\", \"asset\", \"uuid\"].each { |k| vars[k] = \"${#{k}}\" }\n q = vars.map { |k,v| \"#{k}=#{v}\" }.join(\"&\")\n url \"/svc/boot?#{q}\"\n end",
"def index\n @scrobbles = Scrobble.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @scrobbles }\n end\n end",
"def show\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def index\n @instances = Instance.all\n render json: @instances\n end",
"def show\n @bootcamp = Bootcamp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bootcamp }\n end\n end",
"def index\n @app = App.new\n @apps = App.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @apps }\n end\n end",
"def boot(options={})\n Jets::Booter.boot!(options)\n end",
"def index\n @brags = Brag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brags }\n end\n end",
"def show\n @microplst = Microplst.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @microplst }\n end\n end",
"def show\n @application = Application.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @application }\n end\n end",
"def show\n @application = Application.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @application }\n end\n end",
"def show\n @chef_mapping = ChefMapping.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chef_mapping }\n end\n end",
"def show\n add_breadcrumb @recipe.name, @recipe\n respond_to do |format|\n format.html\n format.json { render json: @recipe }\n end\n end",
"def index\n @instances = Instance.all\n render :json => @instances\n end",
"def index\n @banks = Bank.all\n render json: @banks\n end",
"def show\n @app = App.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @app }\n end\n end",
"def show\n @app = App.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @app }\n end\n end",
"def show\n @app = App.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @app }\n end\n end",
"def index\n @devices = Device.all\n render json: @devices\n end",
"def show\n @ami = Ami.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ami }\n end\n end",
"def show\n @rubygem = Rubygem.find(params[:id])\n\n render json: @rubygem\n end",
"def show\n respond_to do |format|\n format.html {}\n format.json { render json: @recipe }\n end\n end",
"def index # testing purposes only\n applications = Application.includes(:user).all\n\n render json: applications\n end",
"def index\n @used_bikes = UsedBike.all\n\n render json: @used_bikes, each_serializer: Web::V1::UsedBikeSerializer\n end",
"def show\n params.require(%i[id])\n render json: Beverage.find_by!(id: params[:id])\n end",
"def index\n @cargo_manifests = CargoManifest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cargo_manifests }\n end\n end",
"def update\n @boot = Boot.find(params[:id])\n\n respond_to do |format|\n if @boot.update_attributes(params[:boot])\n flash[:notice] = 'Boot was successfully updated.'\n format.html { redirect_to(@boot) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @boot.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def list\n \n recipes = Recipe.all\n render :json => recipes.to_json\n\n end",
"def show\n @berth = Berth.find(params[:id])\n @dock = Dock.find(params[:dock_id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @berth }\n end\n end",
"def index\n # sleep 3 # simulate a slow connection\n render json: Secret.all.reverse\n end",
"def show\n @application = Application.find(params[:id])\n\n respond_to do |format|\n format.html # show.haml\n format.json { render json: @application }\n end\n end",
"def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end",
"def show\n bike = Bike.find(params[:id]);\n render json: {status: 'SUCCESS', message:'Loaded bike', data:bike}, status: :ok\n end",
"def index\n @manifestations = Manifestation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @manifestations }\n end\n end",
"def show\n @butterfly = Butterfly.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @butterfly }\n end\n end",
"def get_skus()\n\tputs \"Getting skus\"\n\tresponse = request_get(\"/api/sku\")\n\tputs response.body\nend",
"def index\n @beverages = Beverage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @beverages }\n end\n end",
"def index\n @reserve_stat_has_manifestations = ReserveStatHasManifestation.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @reserve_stat_has_manifestations }\n end\n end"
] |
[
"0.66913277",
"0.62402487",
"0.61105716",
"0.59769744",
"0.591952",
"0.5876535",
"0.5660398",
"0.5596117",
"0.55550104",
"0.55473495",
"0.55455303",
"0.5509982",
"0.5491295",
"0.5486162",
"0.5483385",
"0.54735804",
"0.5445544",
"0.5432645",
"0.5427404",
"0.54243594",
"0.541055",
"0.5397136",
"0.5391156",
"0.5370808",
"0.53707755",
"0.53696406",
"0.53633976",
"0.5362474",
"0.53568447",
"0.5356788",
"0.53536415",
"0.5352508",
"0.5351278",
"0.53463423",
"0.5331242",
"0.5327407",
"0.5325234",
"0.5325103",
"0.5320009",
"0.53193474",
"0.52943707",
"0.52877975",
"0.5284814",
"0.5279364",
"0.5270408",
"0.52690053",
"0.5266618",
"0.5258702",
"0.52584106",
"0.5257937",
"0.5220777",
"0.5220287",
"0.52196276",
"0.5214729",
"0.5214729",
"0.5214729",
"0.5214729",
"0.52062863",
"0.5205591",
"0.52041054",
"0.5203137",
"0.5200949",
"0.5183578",
"0.51809824",
"0.51785696",
"0.5177867",
"0.5177276",
"0.5172129",
"0.5165189",
"0.5164832",
"0.51608115",
"0.51576036",
"0.51576036",
"0.515586",
"0.51527244",
"0.5151917",
"0.51479286",
"0.51432115",
"0.51432115",
"0.51432115",
"0.51430076",
"0.5142346",
"0.5140902",
"0.5137562",
"0.5136764",
"0.5134783",
"0.5132264",
"0.5130148",
"0.5129695",
"0.5127413",
"0.5127285",
"0.5125984",
"0.51256794",
"0.51227736",
"0.5120966",
"0.51107436",
"0.51105565",
"0.5107312",
"0.5104083",
"0.5103545"
] |
0.75800765
|
0
|
GET /boots/new GET /boots/new.json
|
def new
@boot = Boot.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @boot }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @boot = Boot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @boot }\n end\n end",
"def new\n @newapp = Newapp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newapp }\n end\n end",
"def create\n @boot = Boot.new(params[:boot])\n\n respond_to do |format|\n if @boot.save\n flash[:notice] = 'Boot was successfully created.'\n format.html { redirect_to(@boot) }\n format.xml { render :xml => @boot, :status => :created, :location => @boot }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @boot.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @baton = Baton.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @baton }\n end\n end",
"def new\n @monkey = Monkey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @monkey }\n end\n end",
"def new\n @stalking = Stalking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stalking }\n end\n end",
"def create\n @testboot = Testboot.new(testboot_params)\n\n respond_to do |format|\n if @testboot.save\n format.html { redirect_to @testboot, notice: 'Testboot was successfully created.' }\n format.json { render :show, status: :created, location: @testboot }\n else\n format.html { render :new }\n format.json { render json: @testboot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end",
"def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end",
"def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end",
"def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end",
"def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end",
"def new\n @serving = Serving.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serving }\n end\n end",
"def new\n @app = App.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @app }\n end\n end",
"def new\n @app = App.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @app }\n end\n end",
"def new\n @app = App.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @app }\n end\n end",
"def new\n @app = App.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @app }\n end\n end",
"def new\n @flavor = Flavor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @flavor }\n end\n end",
"def create\n @boot = Boot.new(params[:boot])\n puts \"=================================================================\"\n puts params[:boot]\n p @boot.bootlargeimage_file_name\n puts \"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\"\n\n \n respond_to do |format|\n if @boot.save\n flash[:success] = \"Boot was successfully created\"\n format.html { redirect_to boots_path, notice: 'Boot was successfully created.' }\n format.json { render json: boots_path, status: :created, location: @boot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @boot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @machine = Machine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @machine }\n end\n end",
"def new\n @ninja = Ninja.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ninja }\n end\n end",
"def new\n @seed = Seed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seed }\n end\n end",
"def new\n @broad = Broad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @broad }\n end\n end",
"def new\n @lost = Lost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost }\n end\n end",
"def new\n @bloom = Bloom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bloom }\n end\n end",
"def new\n @climb = Climb.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @climb }\n end\n end",
"def new\n @application = Application.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @application }\n end\n end",
"def new\n @application = Application.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @application }\n end\n end",
"def new\n @application = Application.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @application }\n end\n end",
"def new\n @pickup = Pickup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pickup }\n end\n end",
"def new\n @machine = Machine.new\n\n respond_to do |format|\n format.html # new.html.erb\n #format.json { render json: @machine }\n end\n end",
"def new\n @potluck = Potluck.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @potluck }\n end\n end",
"def new\n @fabric = Fabric.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fabric }\n end\n end",
"def new\n @stuff = Stuff.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @stuff }\n end\n end",
"def new\r\n @machine = Machine.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @machine }\r\n end\r\n end",
"def new\n @boat = Boat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json {render json: @boat}\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request }\n end\n end",
"def new\n @beacon = Beacon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beacon }\n end\n end",
"def new\n @pot = Pot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pot }\n end\n end",
"def new\n @entry = Entry.new\n\n render json: @entry\n end",
"def new\n @cloud = Cloud.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @cloud }\n end\n end",
"def new\n @brand = Brand.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @brand }\n end\n end",
"def show\n @boot = Boot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @boot }\n end\n end",
"def new\n @distro = Distro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @distro }\n end\n end",
"def new\n @distro = Distro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @distro }\n end\n end",
"def new\n @startup = Startup.new\n\n # respond_to do |format|\n # format.html # new.html.erb\n # format.json { render json: @startup }\n # end\n end",
"def new\n @web_app = WebApp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @web_app }\n end\n end",
"def new\n @rainbow = Rainbow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rainbow }\n end\n end",
"def new\n @take = Take.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @take }\n end\n end",
"def new\n @version = Version.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @version }\n end\n end",
"def new\n @thing = Thing.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @thing }\n end\n end",
"def new\n @get = Get.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @get }\n end\n end",
"def new\n @kb = Kb.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @kb }\n end\n end",
"def new\n @beat = Beat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beat }\n end\n end",
"def new\n \n #timestamp={{FellAsleepAt}}&total_sleep={{TotalTimeSleptInSeconds}}&deep={{TimeInDeepSleepSeconds}}&light={{TimeInLightSleepSeconds}}&awake={{TimeAwakeSeconds}}\n \n json_hash = Hash.new\n \n @sleep = json_hash\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sleep }\n end\n end",
"def new\n @patch = Patch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patch }\n end\n end",
"def new\n @taker = Taker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @taker }\n end\n end",
"def new\n @breadcrumb = 'create'\n @bank = Bank.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bank }\n end\n end",
"def new\n @bagtype = Bagtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bagtype }\n end\n end",
"def new\n @sleep = Sleep.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @sleep }\n end\n end",
"def new\n @cat = Cat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cat }\n end\n end",
"def new\n @cat = Cat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cat }\n end\n end",
"def new\n @go_slim = GoSlim.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @go_slim }\n end\n end",
"def new\n @pushup = Pushup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pushup }\n end\n end",
"def new\n # @recipe = Recipe.new\n #\n new! do |format|\n # format.html # new.html.erb\n # format.json { render json: @recipe }\n end\n end",
"def new\n @lift = Lift.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lift }\n end\n end",
"def new\n @chef_mapping = ChefMapping.new\n @source = []\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @chef_mapping }\n end\n end",
"def new\n @meteor = Meteor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meteor }\n end\n end",
"def new\n @cookbook = Cookbook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cookbook }\n end\n end",
"def new\r\n @brand = Brand.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @brand }\r\n end\r\n end",
"def new\n @glass = Glass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @glass }\n end\n end",
"def new\n @bid = Bid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bid }\n end\n end",
"def new\n @bid = Bid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bid }\n end\n end",
"def new\n @bootcamp = Bootcamp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bootcamp }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @beverage = Beverage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beverage }\n end\n end",
"def new\n @borrow_request = BorrowRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrow_request }\n end\n end",
"def new\n @monit = Monit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @monit }\n end\n end",
"def new\n @cake = Cake.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cake }\n end\n end",
"def new\n @borrow = Borrow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrow }\n end\n end",
"def new\n @slab = Slab.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @slab }\n end\n end",
"def new\n @goat = Goat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goat }\n end\n end",
"def new\n @thing = Thing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @thing }\n end\n end",
"def new\n @bundle = Bundle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bundle }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @secret_record }\n end\n end",
"def new\n @deployment = Deployment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @deployment }\n end\n end",
"def new\n @update = Update.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @update }\n end\n end",
"def new\n @click = Click.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @click }\n end\n end",
"def new\n @scrobble = Scrobble.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @scrobble }\n end\n end"
] |
[
"0.7068447",
"0.6764454",
"0.6749742",
"0.6606039",
"0.6537489",
"0.64620835",
"0.64563084",
"0.64284384",
"0.64284384",
"0.64284384",
"0.64284384",
"0.64284384",
"0.636379",
"0.63579077",
"0.63579077",
"0.63579077",
"0.63579077",
"0.63535166",
"0.63530594",
"0.6350001",
"0.6344698",
"0.6341443",
"0.633781",
"0.63302535",
"0.63123685",
"0.6303932",
"0.6301526",
"0.6301526",
"0.6301526",
"0.6270941",
"0.62608033",
"0.62600887",
"0.62585825",
"0.62551296",
"0.62519187",
"0.624417",
"0.6237158",
"0.6237158",
"0.6237158",
"0.6237158",
"0.6237158",
"0.62368596",
"0.62259865",
"0.62256175",
"0.62219846",
"0.62063795",
"0.6190295",
"0.6184945",
"0.6184945",
"0.6183873",
"0.6181954",
"0.61793536",
"0.6178399",
"0.61714154",
"0.6166851",
"0.6164606",
"0.6161461",
"0.61614233",
"0.61584777",
"0.61569566",
"0.61472446",
"0.6145737",
"0.61447066",
"0.61431384",
"0.61362845",
"0.61362845",
"0.6128401",
"0.6126337",
"0.612092",
"0.61178964",
"0.6109144",
"0.6108758",
"0.6105771",
"0.6103679",
"0.61026347",
"0.6101823",
"0.6101823",
"0.60916704",
"0.6089014",
"0.6089014",
"0.6089014",
"0.6089014",
"0.6089014",
"0.6089014",
"0.6089014",
"0.6089014",
"0.60874414",
"0.6086248",
"0.60853",
"0.60841495",
"0.60840464",
"0.60836214",
"0.60791445",
"0.6078273",
"0.60754126",
"0.6073091",
"0.60724753",
"0.6072384",
"0.6070254",
"0.6068274"
] |
0.81628734
|
0
|
POST /boots POST /boots.json
|
def create
@boot = Boot.new(params[:boot])
puts "================================================================="
puts params[:boot]
p @boot.bootlargeimage_file_name
puts "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"
respond_to do |format|
if @boot.save
flash[:success] = "Boot was successfully created"
format.html { redirect_to boots_path, notice: 'Boot was successfully created.' }
format.json { render json: boots_path, status: :created, location: @boot }
else
format.html { render action: "new" }
format.json { render json: @boot.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @testboot = Testboot.new(testboot_params)\n\n respond_to do |format|\n if @testboot.save\n format.html { redirect_to @testboot, notice: 'Testboot was successfully created.' }\n format.json { render :show, status: :created, location: @testboot }\n else\n format.html { render :new }\n format.json { render json: @testboot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @boot = Boot.new(params[:boot])\n\n respond_to do |format|\n if @boot.save\n flash[:notice] = 'Boot was successfully created.'\n format.html { redirect_to(@boot) }\n format.xml { render :xml => @boot, :status => :created, :location => @boot }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @boot.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def testboot_params\n params.require(:testboot).permit(:name)\n end",
"def new\n @boot = Boot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @boot }\n end\n end",
"def boot(options={})\n Jets::Booter.boot!(options)\n end",
"def boot\n if self.stopped?\n self.status = \"booting\"\n # delayed_job, 5.times sleep 10 sec, print to /scenarios/#{1}\n debug \"Booting scenario...\"\n\n \n # Boot Clouds\n self.clouds.each { |cloud| cloud.boot }\n \n # Final Setup\n self.final_setup\n self.status = \"booted\"\n self.save!\n end\n end",
"def show\n @boot = Boot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @boot }\n end\n end",
"def index\n @testboots = Testboot.all\n end",
"def update\n @boot = Boot.find(params[:id])\n\n respond_to do |format|\n if @boot.update_attributes(params[:boot])\n flash[:success] = \"Updated successfully \"\n format.html { redirect_to boots_path, notice: 'Boot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @boot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_testboot\n @testboot = Testboot.find(params[:id])\n end",
"def boot\n runcmd 'boot'\n end",
"def boot(vid)\n perform_request(action: 'vserver-boot', vserverid: vid)\n end",
"def boot(opts)\n opts[:flavor] ||= 'standard.xsmall'\n opts[:image] ||= /Ubuntu Precise/\n opts[:sec_groups] ||= ['default']\n opts[:key_name] ||= 'default'\n opts[:region] ||= 'az-2.region-a.geo-1'\n\n raise 'no name provided' if !opts[:name] or opts[:name].empty?\n\n cleanup opts[:name]\n private_key = new_key opts[:name]\n write_key(private_key, File.expand_path('~/.ssh/hpcloud-keys/' + opts[:region] + '/'))\n\n server = @os.create_server(\n :imageRef => image_id(opts[:image]),\n :flavorRef => flavor_id(opts[:flavor]),\n :key_name => private_key[:name],\n :security_groups => opts[:sec_groups],\n :name => opts[:name])\n\n wait(300) do\n server = @os.server(server.id)\n raise 'error booting vm' if server.status == 'ERROR'\n server.status == 'ACTIVE'\n end\n sleep 60\n\n {\n :ip => public_ip(server),\n :user => 'ubuntu',\n :key => private_key[:private_key]\n }\n end",
"def bootstrap!\n @bootstrapped = false\n bootstrap\n end",
"def create\n ::Velum::Salt.call(\n action: \"cmd.run\",\n targets: \"admin\",\n arg: \"systemctl reboot\"\n )\n\n render json: { status: Minion.statuses[:rebooting] }\n end",
"def init_boot\n RightScale::Sender.instance.initialize_offline_queue\n payload = {:agent_identity => @agent_identity,\n :right_link_version => ::RightLink.version,\n :r_s_version => ::RightScale::AgentConfig.protocol_version,\n :resource_uid => ::RightScale::InstanceState.resource_uid}\n req = RightScale::RetryableRequest.new('/booter/declare', payload, :retry_on_error => true)\n req.callback do |res|\n begin\n RightScale::Sender.instance.start_offline_queue\n init_fetch_tags\n rescue Exception => e\n RightScale::Log.error(\"Failed handling /booter/declare response\", e, :trace)\n end\n end\n req.errback do |res|\n RightScale::Log.error(\"Failed making /booter/declare (#{res.inspect}\")\n end\n req.run\n true\n end",
"def bootstrap\n return if File.exist?(json_file)\n FileUtils.touch json_file\n File.open(json_file, 'w') {|f| f.write(to_json) }\n save\n end",
"def update\n respond_to do |format|\n if @testboot.update(testboot_params)\n format.html { redirect_to @testboot, notice: 'Testboot was successfully updated.' }\n format.json { render :show, status: :ok, location: @testboot }\n else\n format.html { render :edit }\n format.json { render json: @testboot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def boot\n req = RightScale::RetryableRequest.new('/booter/get_repositories', { :agent_identity => @agent_identity })\n\n req.callback do |res|\n @audit = RightScale::AuditProxy.new(res.audit_id)\n if RightScale::FeatureConfigManager.feature_enabled?('package_repositories_freeze') && !RightScale::Platform.windows? && !RightScale::Platform.darwin?\n reps = res.repositories\n audit_content = \"Using the following software repositories:\\n\"\n reps.each { |rep| audit_content += \" - #{rep.to_s}\\n\" }\n @audit.create_new_section('Configuring software repositories')\n @audit.append_info(audit_content)\n configure_repositories(reps)\n @audit.update_status('Software repositories configured')\n end\n @audit.create_new_section('Preparing boot bundle')\n prepare_boot_bundle do |prep_res|\n if prep_res.success?\n @audit.update_status('Boot bundle ready')\n run_boot_bundle(prep_res.content) do |boot_res|\n if boot_res.success?\n # want to go operational only if no immediate shutdown request.\n # immediate shutdown requires we stay in the current (booting)\n # state pending full reboot/restart of instance so that we don't\n # bounce between operational and booting in a multi-reboot case.\n # if shutdown is deferred, then go operational before shutdown.\n shutdown_request = RightScale::ShutdownRequest.instance\n if shutdown_request.immediately?\n # process the shutdown request immediately since the\n # operational bundles queue will not start in this case.\n errback = lambda { strand(\"Failed to #{shutdown_request} while running boot sequence\") }\n shutdown_request.process(errback, @audit)\n else\n # any deferred shutdown request was submitted to the\n # operational bundles queue and will execute later.\n RightScale::InstanceState.value = 'operational'\n end\n else\n strand('Failed to run boot sequence', boot_res)\n end\n end\n else\n strand('Failed to prepare boot bundle', prep_res)\n end\n end\n end\n\n req.errback do|res|\n strand('Failed to retrieve software repositories', res)\n end\n\n req.run\n true\n end",
"def boot\n # Raise an exception if the limit of vms is reachable\n raise Exceptions::NextDeployException.new(\"Vms limit is reachable\") if Vm.count > Rails.application.config.limit_vm\n\n osapi = Apiexternal::Osapi.new\n\n begin\n self.name = vm_name\n self.technos = project.technos if technos.size == 0\n self.status = 0\n generate_hiera\n user_data = generate_userdata\n sshname = user.sshkeys.first ? user.sshkeys.first.shortname : ''\n self.nova_id = osapi.boot_vm(name, systemimage.glance_id, sshname, vmsize.title, user_data)\n save\n generate_authorizedkeys\n rescue Exceptions::NextDeployException => me\n self.status = 1\n save\n me.log_e\n end\n\n # Wait that vm is well running\n sleep(15)\n init_extra_attr\n # if foatingip is not yet setted by openstack, sleep 15s more\n if @floating_ip.nil?\n sleep(15)\n init_extra_attr\n end\n\n generate_host_all\n end",
"def boot?(ip = nil)\n path = \"/boot\"\n path << \"/#{ip}\" if ip\n perform_get path\n end",
"def bootstrap\n return if File.exist?(json_file) and !File.zero?(json_file)\n FileUtils.touch json_file\n File.open(json_file, 'w') {|f| f.write(to_json) }\n save\n end",
"def destroy\n @boot = Boot.find(params[:id])\n @boot.destroy\n\n respond_to do |format|\n format.html { redirect_to(boots_url) }\n format.xml { head :ok }\n end\n end",
"def bootup\n Merb.trap(\"TERM\") { shutdown }\n\n Merb.logger.warn! \"Running bootloaders...\" if Merb::Config[:verbose]\n BootLoader.run\n Merb.logger.warn! \"Starting Rack adapter...\" if Merb::Config[:verbose]\n Merb.adapter.start(Merb::Config.to_hash)\n end",
"def destroy\n @boot = Boot.find(params[:id])\n @boot.destroy\n\n\n respond_to do |format|\n flash[:success] = \"Deleted successfully \"\n format.html { redirect_to boots_url }\n format.json { head :no_content }\n end\n end",
"def boot params={}\n Server.node = Server.start! params\n Server.semaphore = Mutex.new\n Server.workers = []; true\n end",
"def update\n @boot = Boot.find(params[:id])\n\n respond_to do |format|\n if @boot.update_attributes(params[:boot])\n flash[:notice] = 'Boot was successfully updated.'\n format.html { redirect_to(@boot) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @boot.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def prepare_boot_bundle(&cb)\n payload = {:agent_identity => @agent_identity, :audit_id => @audit.audit_id}\n req = RightScale::RetryableRequest.new('/booter/get_boot_bundle', payload)\n\n req.callback do |bundle|\n if bundle.executables.any? { |e| !e.ready }\n @audit.create_new_section(\"Waiting for missing inputs\")\n retrieve_missing_inputs(bundle) { cb.call(success_result(bundle)) }\n else\n yield success_result(bundle)\n end\n end\n\n req.errback do |res|\n yield error_result(RightScale::Log.format('Failed to retrieve boot scripts', res))\n end\n\n req.run\n end",
"def create\n @latstraps1 = Latstraps1.new(latstraps1_params)\n\n respond_to do |format|\n if @latstraps1.save\n format.html { redirect_to @latstraps1, notice: 'Latstraps1 was successfully created.' }\n format.json { render :show, status: :created, location: @latstraps1 }\n else\n format.html { render :new }\n format.json { render json: @latstraps1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # {\"vcpus\": 1, \"disk\": 1, \"name\": \"test\", \"rxtx_factor\": 1, \"OS-FLV-EXT-DATA:ephemeral\": 1, \"ram\": 512, \"id\": 6, \"swap\": 1}}'\n @flavor = compute.create_flavor(\"rxtx_factor\"=>1,\"OS-FLV-EXT-DATA:ephemeral\"=>params[:ephemeral],:vcpus=>params[:vcpus],:disk=>params[:disk],:name=>params[:name],:ram=>params[:ram],:id=>params[:id],:swap=>params[:swap])\n\n respond_to do |format|\n format.html { redirect_to flavors_path, :notice => 'Flavor was successfully created.' }\n format.json { render :json => @flavor, :status => :created, :location => @flavor }\n end\n end",
"def create\n \n #timestamp={{FellAsleepAt}}&total_sleep={{TotalTimeSleptInSeconds}}&deep={{TimeInDeepSleepSeconds}}&light={{TimeInLightSleepSeconds}}&awake={{TimeAwakeSeconds}}\n \n json_hash = Hash.new\n \n description = params[:description]\n \n timestamp = params[:timestamp]\n total_sleep_seconds = params[:total_sleep]\n deep_sleep_seconds = params[:deep]\n light_sleep_seconds = params[:light]\n awake_seconds = params[:awake]\n \n if timestamp.nil? || total_sleep_seconds.nil?\n \n puts 'timestamp is nil or total_sleep_seconds is nil :('\n \n else\n \n total_sleep = total_sleep_seconds / 60.0\n deep = deep_sleep_seconds / 60.0\n light = light_sleep_seconds / 60.0\n awake = awake_seconds / 60.0\n \n post_to_twitter = false\n post_to_facebook = false\n \n # FellAsleepAt is formatted: August 23, 2013 at 11:01PM\n # Convert to Runkeeper's preferred format: Sat, 1 Jan 2011 00:00:00\n timestamp_datetime = DateTime.parse(timestamp)\n formatted_timestamp = timestamp_datetime.strftime(\"%a, %d %b %Y %H:%M:%S\")\n \n json_hash['timestamp'] = formatted_timestamp\n json_hash['total_sleep'] = deep\n json_hash['deep'] = deep\n json_hash['light'] = light\n json_hash['awake'] = awake\n json_hash['post_to_twitter'] = post_to_twitter\n json_hash['post_to_facebook'] = post_to_facebook\n \n url = 'https://api.runkeeper.com/sleep'\n \n uri = URI.parse(url)\n \n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n request = Net::HTTP::Post.new(uri.request_uri)\n request[\"Authorization\"] = \"Bearer \" + RUNKEEPER_ACCESS_TOKEN\n request[\"Content-Type\"] = \"application/vnd.com.runkeeper.NewSleep+json\"\n request.body = json_hash.to_json\n \n response = http.request(request)\n \n puts response.body\n \n end\n \n @sleep = json_hash\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sleep }\n end\n \n end",
"def bootstrap_server\n bootstrap_config\n\n bootstrap_init\n bootstrap_run\n bootstrap_cleanup\n rescue Hazetug::Exception => e\n ui.error(e.message); 1\n ensure \n knife and knife.ui.stdout.close\n end",
"def new\n @boot = Boot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @boot }\n end\n end",
"def postBoot(instance_id = nil)\n if !instance_id.nil?\n @cloud_id = instance_id\n end\n node, config, deploydata = describe(cloud_id: @cloud_id)\n instance = cloud_desc\n raise MuError, \"Couldn't find instance #{@mu_name} (#{@cloud_id})\" if !instance\n @cloud_id = instance.instance_id\n return false if !MU::MommaCat.lock(instance.instance_id+\"-orchestrate\", true)\n return false if !MU::MommaCat.lock(instance.instance_id+\"-groom\", true)\n\n MU::MommaCat.createStandardTags(instance.instance_id, region: @config['region'], credentials: @config['credentials'])\n MU::MommaCat.createTag(instance.instance_id, \"Name\", node, region: @config['region'], credentials: @config['credentials'])\n\n if @config['optional_tags']\n MU::MommaCat.listOptionalTags.each { |key, value|\n MU::MommaCat.createTag(instance.instance_id, key, value, region: @config['region'], credentials: @config['credentials'])\n }\n end\n\n if !@config['tags'].nil?\n @config['tags'].each { |tag|\n MU::MommaCat.createTag(instance.instance_id, tag['key'], tag['value'], region: @config['region'], credentials: @config['credentials'])\n }\n end\n MU.log \"Tagged #{node} (#{instance.instance_id}) with MU-ID=#{MU.deploy_id}\", MU::DEBUG\n\n # Make double sure we don't lose a cached mu_windows_name value.\n if windows? or !@config['active_directory'].nil?\n if @mu_windows_name.nil?\n @mu_windows_name = deploydata['mu_windows_name']\n end\n end\n\n retries = -1\n max_retries = 30\n begin\n if instance.nil? or instance.state.name != \"running\"\n retries = retries + 1\n if !instance.nil? and instance.state.name == \"terminated\"\n raise MuError, \"#{@cloud_id} appears to have been terminated mid-bootstrap!\"\n end\n if retries % 3 == 0\n MU.log \"Waiting for EC2 instance #{node} (#{@cloud_id}) to be ready...\", MU::NOTICE\n end\n sleep 40\n # Get a fresh AWS descriptor\n instance = MU::Cloud::Server.find(cloud_id: @cloud_id, region: @config['region'], credentials: @config['credentials']).values.first\n if instance and instance.state.name == \"terminated\"\n raise MuError, \"EC2 instance #{node} (#{@cloud_id}) terminating during bootstrap!\"\n end\n end\n rescue Aws::EC2::Errors::ServiceError => e\n if retries < max_retries\n MU.log \"Got #{e.inspect} during initial instance creation of #{@cloud_id}, retrying...\", MU::NOTICE, details: instance\n retries = retries + 1\n retry\n else\n raise MuError, \"Too many retries creating #{node} (#{e.inspect})\"\n end\n end while instance.nil? or (instance.state.name != \"running\" and retries < max_retries)\n\n punchAdminNAT\n\n\n # If we came up via AutoScale, the Alarm module won't have had our\n # instance ID to associate us with itself. So invoke that here.\n # XXX might be possible to do this with regular alarm resources and\n # dependencies now\n if !@config['basis'].nil? and @config[\"alarms\"] and !@config[\"alarms\"].empty?\n @config[\"alarms\"].each { |alarm|\n alarm_obj = MU::MommaCat.findStray(\n \"AWS\",\n \"alarms\",\n region: @config[\"region\"],\n deploy_id: @deploy.deploy_id,\n name: alarm['name']\n ).first\n alarm[\"dimensions\"] = [{:name => \"InstanceId\", :value => @cloud_id}]\n\n if alarm[\"enable_notifications\"]\n topic_arn = MU::Cloud::AWS::Notification.createTopic(alarm[\"notification_group\"], region: @config[\"region\"], credentials: @config['credentials'])\n MU::Cloud::AWS::Notification.subscribe(arn: topic_arn, protocol: alarm[\"notification_type\"], endpoint: alarm[\"notification_endpoint\"], region: @config[\"region\"], credentials: @config[\"credentials\"])\n alarm[\"alarm_actions\"] = [topic_arn]\n alarm[\"ok_actions\"] = [topic_arn]\n end\n\n alarm_name = alarm_obj ? alarm_obj.cloud_id : \"#{node}-#{alarm['name']}\".upcase\n\n MU::Cloud::AWS::Alarm.setAlarm(\n name: alarm_name,\n ok_actions: alarm[\"ok_actions\"],\n alarm_actions: alarm[\"alarm_actions\"],\n insufficient_data_actions: alarm[\"no_data_actions\"],\n metric_name: alarm[\"metric_name\"],\n namespace: alarm[\"namespace\"],\n statistic: alarm[\"statistic\"],\n dimensions: alarm[\"dimensions\"],\n period: alarm[\"period\"],\n unit: alarm[\"unit\"],\n evaluation_periods: alarm[\"evaluation_periods\"],\n threshold: alarm[\"threshold\"],\n comparison_operator: alarm[\"comparison_operator\"],\n region: @config[\"region\"],\n credentials: @config['credentials']\n )\n }\n end\n\n # We have issues sometimes where our dns_records are pointing at the wrong node name and IP address.\n # Make sure that doesn't happen. Happens with server pools only\n if @config['dns_records'] && !@config['dns_records'].empty?\n @config['dns_records'].each { |dnsrec|\n if dnsrec.has_key?(\"name\")\n if dnsrec['name'].start_with?(MU.deploy_id.downcase) && !dnsrec['name'].start_with?(node.downcase)\n MU.log \"DNS records for #{node} seem to be wrong, deleting from current config\", MU::WARN, details: dnsrec\n dnsrec.delete('name')\n dnsrec.delete('target')\n end\n end\n }\n end\n\n # Unless we're planning on associating a different IP later, set up a\n # DNS entry for this thing and let it sync in the background. We'll come\n # back to it later.\n if @config['static_ip'].nil? && !@named\n MU::MommaCat.nameKitten(self)\n @named = true\n end\n\n if !@config['src_dst_check'] and !@config[\"vpc\"].nil?\n MU.log \"Disabling source_dest_check #{node} (making it NAT-worthy)\"\n MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).modify_instance_attribute(\n instance_id: @cloud_id,\n source_dest_check: {:value => false}\n )\n end\n\n # Set console termination protection. Autoscale nodes won't set this\n # by default.\n MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).modify_instance_attribute(\n instance_id: @cloud_id,\n disable_api_termination: {:value => true}\n )\n\n has_elastic_ip = false\n if !instance.public_ip_address.nil?\n begin\n resp = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).describe_addresses(public_ips: [instance.public_ip_address])\n if resp.addresses.size > 0 and resp.addresses.first.instance_id == @cloud_id\n has_elastic_ip = true\n end\n rescue Aws::EC2::Errors::InvalidAddressNotFound => e\n # XXX this is ok to ignore, it means the public IP isn't Elastic\n end\n end\n\n win_admin_password = nil\n ec2config_password = nil\n sshd_password = nil\n if windows?\n ssh_keydir = \"#{Etc.getpwuid(Process.uid).dir}/.ssh\"\n ssh_key_name = @deploy.ssh_key_name\n\n if @config['use_cloud_provider_windows_password']\n win_admin_password = getWindowsAdminPassword\n elsif @config['windows_auth_vault'] && !@config['windows_auth_vault'].empty?\n if @config[\"windows_auth_vault\"].has_key?(\"password_field\")\n win_admin_password = @groomer.getSecret(\n vault: @config['windows_auth_vault']['vault'],\n item: @config['windows_auth_vault']['item'],\n field: @config[\"windows_auth_vault\"][\"password_field\"]\n )\n else\n win_admin_password = getWindowsAdminPassword\n end\n\n if @config[\"windows_auth_vault\"].has_key?(\"ec2config_password_field\")\n ec2config_password = @groomer.getSecret(\n vault: @config['windows_auth_vault']['vault'],\n item: @config['windows_auth_vault']['item'],\n field: @config[\"windows_auth_vault\"][\"ec2config_password_field\"]\n )\n end\n\n if @config[\"windows_auth_vault\"].has_key?(\"sshd_password_field\")\n sshd_password = @groomer.getSecret(\n vault: @config['windows_auth_vault']['vault'],\n item: @config['windows_auth_vault']['item'],\n field: @config[\"windows_auth_vault\"][\"sshd_password_field\"]\n )\n end\n end\n\n win_admin_password = MU.generateWindowsPassword if win_admin_password.nil?\n ec2config_password = MU.generateWindowsPassword if ec2config_password.nil?\n sshd_password = MU.generateWindowsPassword if sshd_password.nil?\n\n # We're creating the vault here so when we run\n # MU::Cloud::Server.initialSSHTasks and we need to set the Windows\n # Admin password we can grab it from said vault.\n creds = {\n \"username\" => @config['windows_admin_username'],\n \"password\" => win_admin_password,\n \"ec2config_username\" => \"ec2config\",\n \"ec2config_password\" => ec2config_password,\n \"sshd_username\" => \"sshd_service\",\n \"sshd_password\" => sshd_password\n }\n @groomer.saveSecret(vault: @mu_name, item: \"windows_credentials\", data: creds, permissions: \"name:#{@mu_name}\")\n end\n\n subnet = nil\n if !@vpc.nil? and @config.has_key?(\"vpc\") and !instance.subnet_id.nil?\n subnet = @vpc.getSubnet(\n cloud_id: instance.subnet_id\n )\n if subnet.nil?\n raise MuError, \"Got null subnet id out of #{@config['vpc']} when asking for #{instance.subnet_id}\"\n end\n end\n\n if !subnet.nil?\n if !subnet.private? or (!@config['static_ip'].nil? and !@config['static_ip']['assign_ip'].nil?)\n if !@config['static_ip'].nil?\n if !@config['static_ip']['ip'].nil?\n public_ip = MU::Cloud::AWS::Server.associateElasticIp(instance.instance_id, classic: false, ip: @config['static_ip']['ip'])\n elsif !has_elastic_ip\n public_ip = MU::Cloud::AWS::Server.associateElasticIp(instance.instance_id)\n end\n end\n end\n\n nat_ssh_key, nat_ssh_user, nat_ssh_host, canonical_ip, ssh_user, ssh_key_name = getSSHConfig\n if subnet.private? and !nat_ssh_host and !MU::Cloud::AWS::VPC.haveRouteToInstance?(cloud_desc, region: @config['region'], credentials: @config['credentials'])\n raise MuError, \"#{node} is in a private subnet (#{subnet}), but has no NAT host configured, and I have no other route to it\"\n end\n\n # If we've asked for additional subnets (and this @config is not a\n # member of a Server Pool, which has different semantics), create\n # extra interfaces to accomodate.\n if !@config['vpc']['subnets'].nil? and @config['basis'].nil?\n device_index = 1\n @vpc.subnets { |subnet|\n subnet_id = subnet.cloud_id\n MU.log \"Adding network interface on subnet #{subnet_id} for #{node}\"\n iface = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).create_network_interface(subnet_id: subnet_id).network_interface\n MU::MommaCat.createStandardTags(iface.network_interface_id, region: @config['region'], credentials: @config['credentials'])\n MU::MommaCat.createTag(iface.network_interface_id, \"Name\", node+\"-ETH\"+device_index.to_s, region: @config['region'], credentials: @config['credentials'])\n\n if @config['optional_tags']\n MU::MommaCat.listOptionalTags.each { |key, value|\n MU::MommaCat.createTag(iface.network_interface_id, key, value, region: @config['region'], credentials: @config['credentials'])\n }\n end\n\n if !@config['tags'].nil?\n @config['tags'].each { |tag|\n MU::MommaCat.createTag(iface.network_interface_id, tag['key'], tag['value'], region: @config['region'], credentials: @config['credentials'])\n }\n end\n\n MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).attach_network_interface(\n network_interface_id: iface.network_interface_id,\n instance_id: instance.instance_id,\n device_index: device_index\n )\n device_index = device_index + 1\n }\n end\n elsif !@config['static_ip'].nil?\n if !@config['static_ip']['ip'].nil?\n public_ip = MU::Cloud::AWS::Server.associateElasticIp(instance.instance_id, classic: true, ip: @config['static_ip']['ip'])\n elsif !has_elastic_ip\n public_ip = MU::Cloud::AWS::Server.associateElasticIp(instance.instance_id, classic: true)\n end\n end\n\n\n if !@config['image_then_destroy']\n notify\n end\n\n MU.log \"EC2 instance #{node} has id #{instance.instance_id}\", MU::DEBUG\n\n @config[\"private_dns_name\"] = instance.private_dns_name\n @config[\"public_dns_name\"] = instance.public_dns_name\n @config[\"private_ip_address\"] = instance.private_ip_address\n @config[\"public_ip_address\"] = instance.public_ip_address\n\n ext_mappings = MU.structToHash(instance.block_device_mappings)\n\n # Root disk on standard CentOS AMI\n # tagVolumes(instance.instance_id, \"/dev/sda\", \"Name\", \"ROOT-\"+MU.deploy_id+\"-\"+@config[\"name\"].upcase)\n # Root disk on standard Ubuntu AMI\n # tagVolumes(instance.instance_id, \"/dev/sda1\", \"Name\", \"ROOT-\"+MU.deploy_id+\"-\"+@config[\"name\"].upcase)\n\n # Generic deploy ID tag\n # tagVolumes(instance.instance_id)\n\n # Tag volumes with all our standard tags.\n # Maybe replace tagVolumes with this? There is one more place tagVolumes is called from\n volumes = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).describe_volumes(filters: [name: \"attachment.instance-id\", values: [instance.instance_id]])\n volumes.each { |vol|\n vol.volumes.each { |volume|\n volume.attachments.each { |attachment|\n MU::MommaCat.listStandardTags.each_pair { |key, value|\n MU::MommaCat.createTag(attachment.volume_id, key, value, region: @config['region'], credentials: @config['credentials'])\n\n if attachment.device == \"/dev/sda\" or attachment.device == \"/dev/sda1\"\n MU::MommaCat.createTag(attachment.volume_id, \"Name\", \"ROOT-#{MU.deploy_id}-#{@config[\"name\"].upcase}\", region: @config['region'], credentials: @config['credentials'])\n else\n MU::MommaCat.createTag(attachment.volume_id, \"Name\", \"#{MU.deploy_id}-#{@config[\"name\"].upcase}-#{attachment.device.upcase}\", region: @config['region'], credentials: @config['credentials'])\n end\n }\n\n if @config['optional_tags']\n MU::MommaCat.listOptionalTags.each { |key, value|\n MU::MommaCat.createTag(attachment.volume_id, key, value, region: @config['region'], credentials: @config['credentials'])\n }\n end\n\n if @config['tags']\n @config['tags'].each { |tag|\n MU::MommaCat.createTag(attachment.volume_id, tag['key'], tag['value'], region: @config['region'], credentials: @config['credentials'])\n }\n end\n }\n }\n }\n\n canonical_name = instance.public_dns_name\n canonical_name = instance.private_dns_name if !canonical_name or nat_ssh_host != nil\n @config['canonical_name'] = canonical_name\n\n if !@config['add_private_ips'].nil?\n instance.network_interfaces.each { |int|\n if int.private_ip_address == instance.private_ip_address and int.private_ip_addresses.size < (@config['add_private_ips'] + 1)\n MU.log \"Adding #{@config['add_private_ips']} extra private IP addresses to #{instance.instance_id}\"\n MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).assign_private_ip_addresses(\n network_interface_id: int.network_interface_id,\n secondary_private_ip_address_count: @config['add_private_ips'],\n allow_reassignment: false\n )\n end\n }\n notify\n end\n\n begin\n if @config['groom'].nil? or @config['groom']\n if windows?\n # kick off certificate generation early; WinRM will need it\n cert, key = @deploy.nodeSSLCerts(self)\n if @config.has_key?(\"basis\")\n @deploy.nodeSSLCerts(self, true)\n end\n if !@groomer.haveBootstrapped?\n session = getWinRMSession(50, 60, reboot_on_problems: true)\n initialWinRMTasks(session)\n begin\n session.close\n rescue Exception\n # this is allowed to fail- we're probably rebooting anyway\n end\n else # for an existing Windows node: WinRM, then SSH if it fails\n begin\n session = getWinRMSession(1, 60)\n rescue Exception # yeah, yeah\n session = getSSHSession(1, 60)\n # XXX maybe loop at least once if this also fails?\n end\n end\n else\n session = getSSHSession(40, 30)\n initialSSHTasks(session)\n end\n end\n rescue BootstrapTempFail\n sleep 45\n retry\n ensure\n session.close if !session.nil? and !windows?\n end\n\n if @config[\"existing_deploys\"] && !@config[\"existing_deploys\"].empty?\n @config[\"existing_deploys\"].each { |ext_deploy|\n if ext_deploy[\"cloud_id\"]\n found = MU::MommaCat.findStray(\n @config['cloud'],\n ext_deploy[\"cloud_type\"],\n cloud_id: ext_deploy[\"cloud_id\"],\n region: @config['region'],\n dummy_ok: false\n ).first\n\n MU.log \"Couldn't find existing resource #{ext_deploy[\"cloud_id\"]}, #{ext_deploy[\"cloud_type\"]}\", MU::ERR if found.nil?\n @deploy.notify(ext_deploy[\"cloud_type\"], found.config[\"name\"], found.deploydata, mu_name: found.mu_name, triggering_node: @mu_name)\n elsif ext_deploy[\"mu_name\"] && ext_deploy[\"deploy_id\"]\n MU.log \"#{ext_deploy[\"mu_name\"]} / #{ext_deploy[\"deploy_id\"]}\"\n found = MU::MommaCat.findStray(\n @config['cloud'],\n ext_deploy[\"cloud_type\"],\n deploy_id: ext_deploy[\"deploy_id\"],\n mu_name: ext_deploy[\"mu_name\"],\n region: @config['region'],\n dummy_ok: false\n ).first\n\n MU.log \"Couldn't find existing resource #{ext_deploy[\"mu_name\"]}/#{ext_deploy[\"deploy_id\"]}, #{ext_deploy[\"cloud_type\"]}\", MU::ERR if found.nil?\n @deploy.notify(ext_deploy[\"cloud_type\"], found.config[\"name\"], found.deploydata, mu_name: ext_deploy[\"mu_name\"], triggering_node: @mu_name)\n else\n MU.log \"Trying to find existing deploy, but either the cloud_id is not valid or no mu_name and deploy_id where provided\", MU::ERR\n end\n }\n end\n\n # See if this node already exists in our config management. If it does,\n # we're done.\n if @groomer.haveBootstrapped?\n MU.log \"Node #{node} has already been bootstrapped, skipping groomer setup.\", MU::NOTICE\n if @config['groom'].nil? or @config['groom']\n @groomer.saveDeployData\n end\n MU::MommaCat.unlock(instance.instance_id+\"-orchestrate\")\n MU::MommaCat.unlock(instance.instance_id+\"-groom\")\n return true\n end\n\n begin\n @groomer.bootstrap if @config['groom'].nil? or @config['groom']\n rescue MU::Groomer::RunError\n MU::MommaCat.unlock(instance.instance_id+\"-groom\")\n MU::MommaCat.unlock(instance.instance_id+\"-orchestrate\")\n return false\n end\n\n # Make sure we got our name written everywhere applicable\n if !@named\n MU::MommaCat.nameKitten(self)\n @named = true\n end\n\n MU::MommaCat.unlock(instance.instance_id+\"-groom\")\n MU::MommaCat.unlock(instance.instance_id+\"-orchestrate\")\n return true\n end",
"def create\n @bike_rack = BikeRack.new(bike_rack_params)\n\n respond_to do |format|\n if @bike_rack.save\n flash[:success] = 'Bike rack was successfully created.'\n format.html { redirect_to @bike_rack }\n format.json { render :show, status: :created, location: @bike_rack }\n else\n flash[:danger] = 'There was a problem with creating Bike rack.'\n format.html { render :new }\n format.json { render json: @bike_rack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def boot\n Souffle::Log.info \"#{@node.log_prefix} Booting node...\"\n provider.boot(@node)\n end",
"def ipxe_boot_url\n vars = {}\n (1..@nic_max).each do |index|\n net_id = \"net#{index - 1}\"\n vars[net_id] = \"${#{net_id}/mac:hexhyp}\"\n end\n [\"dhcp_mac\", \"serial\", \"asset\", \"uuid\"].each { |k| vars[k] = \"${#{k}}\" }\n q = vars.map { |k,v| \"#{k}=#{v}\" }.join(\"&\")\n url \"/svc/boot?#{q}\"\n end",
"def bootstrap\n commit_stage\n process_service_queue\n\n try_console\n end",
"def create\n @shutdown_request = ShutdownRequest.new(shutdown_request_params)\n @shutdown_request.state == \"waiting\" ? flash[:info] = \"shutdowning #{@shutdown_request.vm_host}.\" : flash[:info] = nil\n\n respond_to do |format|\n if @shutdown_request.save\n @shutdown_request.update(state: \"waiting\", started_at: Time.now)\n ShutdownVmWorker.perform_async(@shutdown_request.id)\n format.html { redirect_to @shutdown_request, notice: 'Shutdown request was successfully created.' }\n format.json { render action: 'show', status: :created, location: @shutdown_request }\n else\n format.html { render action: 'new' }\n format.json { render json: @shutdown_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def on_boot!\n (@on_boot || []).each {|b| b.call}\n end",
"def boot_sp_pair\n @endorsement_certificate = @s.endorsement_certificate\n puf_syndrome = @s.puf_syndrome\n encrypted_nonce, nonce_hmac =\n @p.boot_logic.boot_start puf_syndrome, @endorsement_certificate\n root_hash, state_hmac, endorsement_key = @s.boot encrypted_nonce, nonce_hmac\n @p.boot_logic.boot_finish root_hash, state_hmac, endorsement_key\n end",
"def bootstrap_for_node(server, bootstrap_ip)\n bootstrap = Chef::Knife::Bootstrap.new\n Chef::Log.debug(\"Bootstrap name_args = [ #{bootstrap_ip} ]\")\n bootstrap.name_args = [ bootstrap_ip ]\n\n Chef::Log.debug(\"Bootstrap run_list = #{config[:run_list]}\")\n bootstrap.config[:run_list] = config[:run_list]\n\n Chef::Log.debug(\"Bootstrap ssh_user = #{config[:ssh_user]}\")\n bootstrap.config[:ssh_user] = config[:ssh_user]\n\n Chef::Log.debug(\"Bootstrap chef_node_name = #{config[:chef_node_name]}\")\n bootstrap.config[:chef_node_name] = config[:chef_node_name] || server.id\n\n Chef::Log.debug(\"Bootstrap prerelease = #{config[:prerelease]}\")\n bootstrap.config[:prerelease] = config[:prerelease]\n\n Chef::Log.debug(\"Bootstrap distro = #{config[:distro]}\")\n bootstrap.config[:distro] = config[:distro]\n\n if config[:ssh_user] == 'root'\n bootstrap.config[:use_sudo] = false\n else\n bootstrap.config[:use_sudo] = true\n end\n\n Chef::Log.debug(\"Bootstrap use_sudo = #{bootstrap.config[:use_sudo]}\")\n\n bootstrap.config[:environment] = config[:environment]\n Chef::Log.debug(\"Bootstrap environment = #{bootstrap.config[:environment]}\")\n\n bootstrap.config[:no_host_key_verify] = config[:no_host_key_verify]\n Chef::Log.debug(\"Bootstrap no_host_key_verify = #{bootstrap.config[:no_host_key_verify]}\")\n\n bootstrap.config[:identity_file] = config[:identity_file]\n Chef::Log.debug(\"Bootstrap identity_file = #{bootstrap.config[:identity_file]}\")\n\n bootstrap.config[:ssh_gateway] = determine_ssh_gateway(bootstrap_ip)\n Chef::Log.debug(\"Bootstrap ssh_gateway= #{bootstrap.config[:ssh_gateway]}\")\n\n bootstrap.config[:first_boot_attributes] = config[:json_attributes]\n Chef::Log.debug(\"Bootstrap json_attributes = #{bootstrap.config[:json_attributes]}\")\n\n bootstrap\n end",
"def postBoot(instance_id = nil)\n @cloud_id ||= instance_id\n _node, _config, deploydata = describe(cloud_id: @cloud_id)\n\n raise MuError, \"Couldn't find instance #{@mu_name} (#{@cloud_id})\" if !cloud_desc\n return false if !MU::MommaCat.lock(@cloud_id+\"-orchestrate\", true)\n return false if !MU::MommaCat.lock(@cloud_id+\"-groom\", true)\n\n getIAMProfile\n\n finish = Proc.new { |status|\n MU::MommaCat.unlock(@cloud_id+\"-orchestrate\")\n MU::MommaCat.unlock(@cloud_id+\"-groom\")\n return status\n }\n\n MU::Cloud::AWS.createStandardTags(\n @cloud_id,\n region: @region,\n credentials: @credentials,\n optional: @config['optional_tags'],\n nametag: @mu_name,\n othertags: @config['tags']\n )\n\n # Make double sure we don't lose a cached mu_windows_name value.\n if (windows? or !@config['active_directory'].nil?)\n @mu_windows_name ||= deploydata['mu_windows_name']\n end\n\n loop_if = Proc.new {\n !cloud_desc(use_cache: false) or cloud_desc.state.name != \"running\"\n }\n MU.retrier([Aws::EC2::Errors::ServiceError], max: 30, wait: 40, loop_if: loop_if) { |retries, _wait|\n if cloud_desc and cloud_desc.state.name == \"terminated\"\n logs = if !@config['basis'].nil?\n pool = @deploy.findLitterMate(type: \"server_pools\", name: @config[\"name\"])\n if pool\n MU::Cloud::AWS.autoscale(region: @region, credentials: @credentials).describe_scaling_activities(auto_scaling_group_name: pool.cloud_id).activities\n else\n nil\n end\n end\n raise MuError.new, \"#{@cloud_id} appears to have been terminated mid-bootstrap!\", details: logs\n end\n if retries % 3 == 0\n MU.log \"Waiting for EC2 instance #{@mu_name} (#{@cloud_id}) to be ready...\", MU::NOTICE\n end\n }\n\n allowBastionAccess\n\n setAlarms\n\n # Unless we're planning on associating a different IP later, set up a\n # DNS entry for this thing and let it sync in the background. We'll come\n # back to it later.\n if @config['static_ip'].nil? and !@named\n MU::MommaCat.nameKitten(self)\n @named = true\n end\n\n if !@config['src_dst_check'] and !@config[\"vpc\"].nil?\n MU.log \"Disabling source_dest_check #{@mu_name} (making it NAT-worthy)\"\n MU::Cloud::AWS.ec2(region: @region, credentials: @credentials).modify_instance_attribute(\n instance_id: @cloud_id,\n source_dest_check: { value: false }\n )\n end\n\n # Set console termination protection. Autoscale nodes won't set this\n # by default.\n MU::Cloud::AWS.ec2(region: @region, credentials: @credentials).modify_instance_attribute(\n instance_id: @cloud_id,\n disable_api_termination: { value: true}\n )\n\n tagVolumes\n configureNetworking\n saveCredentials\n\n if !@config['image_then_destroy']\n notify\n end\n\n finish.call(false) if !bootstrapGroomer\n\n # Make sure we got our name written everywhere applicable\n if !@named\n MU::MommaCat.nameKitten(self)\n @named = true\n end\n\n finish.call(true)\n end",
"def create_entry(payload_array, scaffold)\n api_url = \"#{@device_address}/admin/scaffolds/#{scaffold}/create.json?api_key=#{@device_api_key}\"\n api_connection = Excon.new(api_url, persistent: true)\n\n payload_array.map do |payload|\n Thread.new do\n api_connection.post(\n body: JSON[record: payload],\n headers: { 'Content-Type' => 'application/json' },\n persistent: true\n )\n end\n end.each(&:join)\n end",
"def create\n @power_rack = PowerRack.new(power_rack_params)\n\n respond_to do |format|\n if @power_rack.save\n format.html { redirect_to @power_rack, notice: \"Power rack was successfully created.\" }\n format.json { render :show, status: :created, location: @power_rack }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @power_rack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_ebs_backup(options = {})\n params = options.merge( { :commit => \"explicit\", :api_version => 1.0 } )\n STDERR.puts \"Performing RightScale API call to create a new snapshot\"\n json=nil\n SystemTimer.timeout_after(@api_snap_timeout) do\n body = RestClient.post @api_url+\"/create_ebs_backup.js\", params\n json = body.nil? ? nil: JSON.load(body)\n STDERR.puts \"CREATED_SNAPS: #{json}\"\n end\n json \n rescue Exception => e\n display_exception(e, \"create_ebs_backup(#{options.inspect})\")\n end",
"def change_bootorder(vid, bootorder)\n perform_request(:action => 'vserver-bootorder', :vserverid => vid, :bootorder => bootorder.to_s)\n end",
"def bootcode\n\t\t\t# /vl/bc.jsp?v=0.0.0.10&m=00:19:db:9e:92:91&l=00:00:00:00:00:00&p=00:00:00:00:00:00&h=4\n\t\t\t#\n\t\t\t# Firmware version, e.g.0.0.0.10\n\t\t\t@version = params[:v]\n\n\t\t\t# MAC address\n\t\t\t@serial = params[:m]\n\n\t\t\t# Hardware model 4 == V2 model\n\t\t\t@hardware = params[:h]\n\n\n\t\t\tsend_file Rails.public_path+'/'+'bc-nominal-segabor.bin',\n\t\t\t\t:type => 'application/octet-stream'\n\t\tend",
"def boot_mode\n data[:boot_mode]\n end",
"def create\n @startup = current_user.startups.build(startup_params)\n\n respond_to do |format|\n if @startup.save\n format.html { redirect_to startups_url, notice: 'listing was successfully created.' }\n format.json { render :index, status: :created, location: @startup }\n else\n format.html { render :new }\n format.json { render json: @startup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @scratcher = Scratcher.new(permitted_params)\n\n if @scratcher.save\n render json: @scratcher, status: :created, location: @scratcher\n else\n render json: @scratcher.errors, status: :unprocessable_entity\n end\n end",
"def create\n @baton = Baton.new(params[:baton])\n\n respond_to do |format|\n if @baton.save\n format.html { redirect_to @baton, notice: 'Baton was successfully created.' }\n format.json { render json: @baton, status: :created, location: @baton }\n else\n format.html { render action: \"new\" }\n format.json { render json: @baton.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n info = Aws.get_recipes_from_db\n render :json => info\n end",
"def create_stages(api_id, env, stage_variables)\r\n deployment_description = 'Deployment of service to ' + env\r\n deployment = @client.create_deployment(\r\n rest_api_id: api_id, stage_name: env, cache_cluster_enabled: false, description: deployment_description,\r\n variables: stage_variables\r\n ).data\r\n puts deployment\r\n end",
"def change_bootorder(vid, bootorder)\n perform_request(action: 'vserver-bootorder', vserverid: vid, bootorder: bootorder.to_s)\n end",
"def seed_banks\n\tdata = ActiveSupport::JSON.decode(File.read('db/seeds/banks.json'))\n\tdata.each do |d|\n\t\tBank.create!(d)\n\tend\nend",
"def destroy\n @testboot.destroy\n respond_to do |format|\n format.html { redirect_to testboots_url, notice: 'Testboot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def bootstrap\n if Minion.where(role: nil).count > 1\n Minion.assign_roles(roles: [:master], default_role: :minion)\n Pharos::Salt.orchestrate\n else\n flash[:alert] = \"Not enough Workers to bootstrap. Please start at least one worker.\"\n end\n\n redirect_to nodes_path\n end",
"def create\n @stalking = Stalking.new(app_params)\n @stalking.user_id = current_user.id\n\n respond_to do |format|\n if @stalking.save\n format.html { redirect_to @stalking, flash: { success: 'Stalking was successfully created.' } }\n format.json { render json: @stalking, status: :created, location: @stalking }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stalking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def latstraps1_params\n params.require(:latstraps1).permit(:exercise, :reps, :sets)\n end",
"def postBoot(instance_id = nil)\n if !instance_id.nil?\n @cloud_id = instance_id\n end\n\n node, _config, deploydata = describe(cloud_id: @cloud_id)\n instance = cloud_desc\n raise MuError, \"Couldn't find instance of #{@mu_name} (#{@cloud_id})\" if !instance\n return false if !MU::MommaCat.lock(@cloud_id+\"-orchestrate\", true)\n return false if !MU::MommaCat.lock(@cloud_id+\"-groom\", true)\n\n# MU::Cloud::AWS.createStandardTags(@cloud_id, region: @config['region'])\n# MU::Cloud::AWS.createTag(@cloud_id, \"Name\", node, region: @config['region'])\n#\n# if @config['optional_tags']\n# MU::MommaCat.listOptionalTags.each { |key, value|\n# MU::Cloud::AWS.createTag(@cloud_id, key, value, region: @config['region'])\n# }\n# end\n#\n# if !@config['tags'].nil?\n# @config['tags'].each { |tag|\n# MU::Cloud::AWS.createTag(@cloud_id, tag['key'], tag['value'], region: @config['region'])\n# }\n# end\n# MU.log \"Tagged #{node} (#{@cloud_id}) with MU-ID=#{MU.deploy_id}\", MU::DEBUG\n#\n # Make double sure we don't lose a cached mu_windows_name value.\n if windows? or !@config['active_directory'].nil?\n if @mu_windows_name.nil?\n @mu_windows_name = deploydata['mu_windows_name']\n end\n end\n\n# punchAdminNAT\n#\n#\n# # If we came up via AutoScale, the Alarm module won't have had our\n# # instance ID to associate us with itself. So invoke that here.\n# if !@config['basis'].nil? and @config[\"alarms\"] and !@config[\"alarms\"].empty?\n# @config[\"alarms\"].each { |alarm|\n# alarm_obj = MU::MommaCat.findStray(\n# \"AWS\",\n# \"alarms\",\n# region: @config[\"region\"],\n# deploy_id: @deploy.deploy_id,\n# name: alarm['name']\n# ).first\n# alarm[\"dimensions\"] = [{:name => \"InstanceId\", :value => @cloud_id}]\n#\n# if alarm[\"enable_notifications\"]\n# topic_arn = MU::Cloud::AWS::Notification.createTopic(alarm[\"notification_group\"], region: @config[\"region\"])\n# MU::Cloud::AWS::Notification.subscribe(arn: topic_arn, protocol: alarm[\"notification_type\"], endpoint: alarm[\"notification_endpoint\"], region: @config[\"region\"])\n# alarm[\"alarm_actions\"] = [topic_arn]\n# alarm[\"ok_actions\"] = [topic_arn]\n# end\n#\n# alarm_name = alarm_obj ? alarm_obj.cloud_id : \"#{node}-#{alarm['name']}\".upcase\n#\n# MU::Cloud::AWS::Alarm.setAlarm(\n# name: alarm_name,\n# ok_actions: alarm[\"ok_actions\"],\n# alarm_actions: alarm[\"alarm_actions\"],\n# insufficient_data_actions: alarm[\"no_data_actions\"],\n# metric_name: alarm[\"metric_name\"],\n# namespace: alarm[\"namespace\"],\n# statistic: alarm[\"statistic\"],\n# dimensions: alarm[\"dimensions\"],\n# period: alarm[\"period\"],\n# unit: alarm[\"unit\"],\n# evaluation_periods: alarm[\"evaluation_periods\"],\n# threshold: alarm[\"threshold\"],\n# comparison_operator: alarm[\"comparison_operator\"],\n# region: @config[\"region\"]\n# )\n# }\n# end\n#\n# # We have issues sometimes where our dns_records are pointing at the wrong node name and IP address.\n# # Make sure that doesn't happen. Happens with server pools only\n# if @config['dns_records'] && !@config['dns_records'].empty?\n# @config['dns_records'].each { |dnsrec|\n# if dnsrec.has_key?(\"name\")\n# if dnsrec['name'].start_with?(MU.deploy_id.downcase) && !dnsrec['name'].start_with?(node.downcase)\n# MU.log \"DNS records for #{node} seem to be wrong, deleting from current config\", MU::WARN, details: dnsrec\n# dnsrec.delete('name')\n# dnsrec.delete('target')\n# end\n# end\n# }\n# end\n\n # Unless we're planning on associating a different IP later, set up a\n # DNS entry for this thing and let it sync in the background. We'll\n # come back to it later.\n if @config['static_ip'].nil? && !@named\n MU::MommaCat.nameKitten(self)\n @named = true\n end\n\n _nat_ssh_key, _nat_ssh_user, nat_ssh_host, _canonical_ip, _ssh_user, _ssh_key_name = getSSHConfig\n if !nat_ssh_host and !MU::Cloud.resourceClass(\"Google\", \"VPC\").haveRouteToInstance?(cloud_desc, credentials: @config['credentials'])\n# XXX check if canonical_ip is in the private ranges\n# raise MuError, \"#{node} has no NAT host configured, and I have no other route to it\"\n end\n\n # See if this node already exists in our config management. If it does,\n # we're done.\n if @groomer.haveBootstrapped?\n MU.log \"Node #{node} has already been bootstrapped, skipping groomer setup.\", MU::NOTICE\n @groomer.saveDeployData\n MU::MommaCat.unlock(@cloud_id+\"-orchestrate\")\n MU::MommaCat.unlock(@cloud_id+\"-groom\")\n return true\n end\n\n @groomer.bootstrap\n\n # Make sure we got our name written everywhere applicable\n if !@named\n MU::MommaCat.nameKitten(self)\n @named = true\n end\n\n MU::MommaCat.unlock(@cloud_id+\"-groom\")\n MU::MommaCat.unlock(@cloud_id+\"-orchestrate\")\n return true\n end",
"def splash()\n\t\t@request.add('/')\n\t\t@request.add('/var/widgets.json?callback=define')\n\t\t@request.add('/system/me?_charset_=utf-8')\n\t\t@request.add('/tags/directory.tagged.json?_charset_=utf-8&_=1342651726188')\n\t\t@request.add('/var/search/activity/all.json?items=12&_charset_=utf-8&_=1342651726197')\n\t\t@request.add('/var/search/public/random-content.json?page=0&items=10&tag=&type=c&_charset_=utf-8&_=1342651726201')\n\t\t@request.add('/var/templates/worlds.2.json?_charset_=utf-8')\n end",
"def create(bin_params)\n @rest.post('save', bin_params)\n end",
"def create\n\t\tboat = Boat.new(boat_params)\n \tif boat.save\n \t\trender json: boat, status: 201\n \tend\n\tend",
"def seed\n get(path: 'wallet/seed')\n end",
"def bootstrapped?\n # @bootstrapped ||= !run('if [ -f /var/poolparty/bootstrapped ]; then echo \"YES\"; fi').match(/YES/).nil?\n @bootstrapped ||= !run('if [ -f /var/poolparty/bootstrapped ]; then echo \"YES\"; fi').chomp.empty? || false\n end",
"def create\n @bunch = Bunch.new(bunch_params)\n\n respond_to do |format|\n if @bunch.save\n format.html { redirect_to @bunch, notice: 'Bunch was successfully created.' }\n format.json { render :show, status: :created, location: @bunch }\n else\n format.html { render :new }\n format.json { render json: @bunch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def bunch_params\n params.require(:bunch).permit(:name)\n end",
"def create\n megam_rest.post_marketplaceapp(to_hash)\n end",
"def create\n megam_rest.post_marketplaceapp(to_hash)\n end",
"def boot\n Rucola::Plugin.before_boot\n do_boot\n Rucola::Plugin.after_boot\n end",
"def create\n @salt = Salt.new(salt_params)\n\n respond_to do |format|\n if @salt.save\n format.html { redirect_to @salt, notice: 'Salt was successfully created.' }\n format.json { render action: 'show', status: :created, location: @salt }\n else\n format.html { render action: 'new' }\n format.json { render json: @salt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n if params[:name].present?\n @json = Punk::API.beers_name!(params[:name])\n elsif params[:abv_gt].present?\n @json = Punk::API.beers_abv_gt!(params[:abv_gt])\n elsif params[:abv_lt].present?\n @json = Punk::API.beers_abv_lt!(params[:abv_lt])\n else\n @json = Punk::API.all_beers!(params)\n end\n\n render json: {\n beers: @json\n }\n create(@json)\n end",
"def bootstrapped?\n # When we have a bootstrap waiter, we haven't bootstrapped because it is\n # set to nil upon bootstrap completion.\n return !@bootstrap.nil?\n end",
"def create\n\t\turi = URI.parse(Counter::Application.config.simplyurl)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\n\t\trequest = Net::HTTP::Post.new('/offsets.json')\n\t\tputs params\n\t\tputs params.slice(*['custids','acctids','itemids'])\n\t\t\n\t\t# ok, this join stuff is bogus - it encodes properly, but the other side only sees the last element and loses the array type - it's just string\n\t\t# this way, i 'split' it at the other side to recover my array\n\t\t# it should work without the join/split crap, but it doesn't\n\t\trequest.set_form_data({:custids => ( params['custids'] || []).join(','), :acctids => ( params['acctids'] || []).join(','), :itemids => ( params['itemids'] || []).join(','), :amount => params['amount'], :type => params['type']})\n\t\t\n\t\tputs request.body\n\t\t\n\t\tresponse = http.request(request)\n\t\tputs response.body\n\n respond_to do |format|\n format.html { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n format.json { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n end\n end",
"def create\n @bloom = Bloom.new(params[:bloom])\n\n respond_to do |format|\n if @bloom.save\n format.html { redirect_to @bloom, notice: 'Bloom was successfully created.' }\n format.json { render json: @bloom, status: :created, location: @bloom }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bloom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_servers\n # use \"rsc\" tool to get detailed deployment + server view from api 1.6, not supported by right_api_client\n old_deployment = JSON.parse(`rsc -a #{@options[:src]} cm16 show /api/deployments/#{@options[:deployment]} view=full`)\n\n old_deployment['servers'].each do |server|\n @api.account_id = @options[:src]\n name = server['next_instance']['name']\n\n puts \"Creating server: #{name} ...\\n\"\n\n cloud = find_cloud(server['next_instance']['links']['cloud']['href'], name)\n @api.account_id = @options[:src]\n\n ssh_key = choose_ssh_key(cloud)\n @api.account_id = @options[:src]\n\n instance_type = choose_instance_type(cloud)\n old_st_url = server['next_instance']['server_template']['href']\n new_st_url = @server_templates[old_st_url]['new_st_url']\n \n mci = choose_mci(new_st_url)\n @api.account_id = @options[:src]\n\n subnets = choose_subnets(cloud)\n @api.account_id = @options[:src]\n\n security_groups = choose_security_groups(cloud)\n @api.account_id = @options[:src]\n\n inputs_hash = format_inputs(@api.resource(server['next_instance']['href']).show.inputs)\n\n # Create server\n params = {}\n params[:server] = {}\n params[:server][:name] = name\n params[:server][:deployment_href] = @new_deployment\n params[:server][:instance] = {}\n params[:server][:instance][:cloud_href] = cloud\n params[:server][:instance][:server_template_href] = new_st_url\n params[:server][:instance][:ssh_key_href] = ssh_key if ssh_key\n params[:server][:instance][:instance_type_href] = instance_type\n params[:server][:instance][:multi_cloud_image_href] = mci\n params[:server][:instance][:subnet_hrefs] = subnets if subnets\n params[:server][:instance][:security_group_hrefs] = security_groups\n params[:server][:instance][:inputs] = inputs_hash\n @api.account_id = @options[:dst]\n @api.servers.create(params)\n end\nend",
"def create_recipe_request(version, auth_headers, data = {})\n post \"/api/recipes\", params: data, headers: {'Content-Type' => \"application/json\", 'Accept' => \"application/vnd.ink.#{version}\" }.merge(auth_headers)\nend",
"def index\n @recipes = Recipe.all\n render json: @recipes\n end",
"def medieval_composers\n response = RestClient.get 'https://api.openopus.org/composer/list/epoch/Medieval.json'\n json = JSON.parse response\n puts json\n\n if !json.nil?\n json[\"composers\"].map do |composer|\n Composer.create(name: \"#{composer[\"complete_name\"]}\", birth: \"#{composer[\"birth\"]}\", death: \"#{composer[\"death\"]}\", portrait: \"#{composer[\"portrait\"]}\", period_id: 1)\n end\n else\n puts \"Error seeding composers\"\n end\nend",
"def bootstrap\n self.class.loadChefLib\n stashHostSSLCertSecret\n splunkVaultInit\n if !@config['cleaned_chef']\n begin\n leave_ours = @config['scrub_groomer'] ? false : true\n preClean(leave_ours)\n rescue RuntimeError => e\n MU.log e.inspect, MU::ERR\n sleep 10\n retry\n end\n @config['cleaned_chef'] = true\n end\n\n _nat_ssh_key, _nat_ssh_user, _nat_ssh_host, canonical_addr, ssh_user, ssh_key_name = @server.getSSHConfig\n\n MU.log \"Bootstrapping #{@server.mu_name} (#{canonical_addr}) with knife\"\n\n run_list = [\"recipe[mu-tools::newclient]\"]\n run_list << \"mu-tools::gcloud\" if @server.cloud == \"Google\" or @server.config['cloud'] == \"Google\"\n\n json_attribs = {}\n if !@config['application_attributes'].nil?\n json_attribs['application_attributes'] = @config['application_attributes']\n json_attribs['skipinitialupdates'] = @config['skipinitialupdates']\n end\n\n# XXX this seems to break Knife Bootstrap\n# vault_access = if !@config['vault_access'].nil?\n# @config['vault_access']\n# else\n# []\n# end\n\n @server.windows? ? max_retries = 25 : max_retries = 10\n @server.windows? ? timeout = 1800 : timeout = 300\n retries = 0\n begin\n load MU.myRoot+'/modules/mu/monkey_patches/chef_knife_ssh.rb'\n if !@server.windows?\n kb = ::Chef::Knife::Bootstrap.new([canonical_addr])\n kb.config[:use_sudo] = true\n kb.name_args = \"#{canonical_addr}\"\n kb.config[:distro] = 'chef-full'\n kb.config[:ssh_user] = ssh_user\n kb.config[:ssh_verify_host_key] = :accept_new\n kb.config[:forward_agent] = ssh_user\n kb.config[:identity_file] = \"#{Etc.getpwuid(Process.uid).dir}/.ssh/#{ssh_key_name}\"\n kb.config[:ssh_identity_file] = \"#{Etc.getpwuid(Process.uid).dir}/.ssh/#{ssh_key_name}\"\n else\n kb = ::Chef::Knife::BootstrapWindowsWinrm.new([@server.mu_name])\n kb.name_args = [@server.mu_name]\n kb.config[:manual] = true\n kb.config[:winrm_transport] = :ssl\n kb.config[:winrm_port] = 5986\n kb.config[:session_timeout] = timeout\n kb.config[:operation_timeout] = timeout\n# kb.config[:bootstrap_curl_options] = \"\"\n if retries % 2 == 0\n kb.config[:host] = canonical_addr\n kb.config[:winrm_authentication_protocol] = :basic\n kb.config[:winrm_user] = @server.config['windows_admin_username']\n kb.config[:winrm_password] = @server.getWindowsAdminPassword\n else\n kb.config[:host] = @server.mu_name\n kb.config[:winrm_authentication_protocol] = :cert\n kb.config[:winrm_client_cert] = \"#{MU.mySSLDir}/#{@server.mu_name}-winrm.crt\"\n kb.config[:winrm_client_key] = \"#{MU.mySSLDir}/#{@server.mu_name}-winrm.key\"\n end\n# kb.config[:ca_trust_file] = \"#{MU.mySSLDir}/Mu_CA.pem\"\n # XXX ca_trust_file doesn't work for some reason, so we have to set the below for now\n kb.config[:winrm_ssl_verify_mode] = :verify_none\n kb.config[:msi_url] = \"https://www.chef.io/chef/download?p=windows&pv=2012&m=x86_64&v=#{MU.chefVersion}\"\n end\n\n # XXX this seems to break Knife Bootstrap\n # if vault_access.size > 0\n # v = {}\n # vault_access.each { |vault|\n # v[vault['vault']] = [] if v[vault['vault']].nil?\n # v[vault['vault']] << vault['item']\n # }\n # kb.config[:bootstrap_vault_json] = JSON.generate(v)\n # end\n\n kb.config[:json_attribs] = JSON.generate(json_attribs) if json_attribs.size > 1\n kb.config[:run_list] = run_list\n kb.config[:chef_node_name] = @server.mu_name\n kb.config[:bootstrap_product] = \"chef\"\n kb.config[:bootstrap_version] = MU.chefVersion\n kb.config[:channel] = \"stable\"\n # XXX key off of MU verbosity level\n kb.config[:log_level] = :debug\n # kb.config[:ssh_gateway] = \"#{nat_ssh_user}@#{nat_ssh_host}\" if !nat_ssh_host.nil? # Breaking bootsrap\n\n MU.log \"Knife Bootstrap settings for #{@server.mu_name} (#{canonical_addr}), timeout set to #{timeout.to_s}\", MU::NOTICE, details: kb.config\n if @server.windows? and @server.windowsRebootPending?\n raise MU::Cloud::BootstrapTempFail, \"#{@server.mu_name} has a pending reboot\"\n end\n Timeout::timeout(timeout) {\n MU::Cloud.handleNetSSHExceptions\n kb.run\n }\n # throws Net::HTTPServerException if we haven't really bootstrapped\n ::Chef::Node.load(@server.mu_name)\n rescue SystemExit, Timeout::Error, MU::Cloud::BootstrapTempFail, Net::HTTPServerException, HTTPClient::ConnectTimeoutError, WinRM::WinRMError, Net::SSH::AuthenticationFailed, Net::SSH::Disconnect, Net::SSH::ConnectionTimeout, Net::SSH::Proxy::ConnectError, Net::SSH::Exception, Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::EPIPE, SocketError, IOError => e\n if retries < max_retries\n retries += 1\n # Bad Chef installs are possible culprits of bootstrap failures, so\n # try scrubbing them when that happens.\n # On Windows, even a fresh install comes up screwy disturbingly\n # often, so we let it start over from scratch if needed. Except for\n # the first attempt, which usually fails due to WinRM funk.\n if !e.is_a?(MU::Cloud::BootstrapTempFail) and\n !(e.is_a?(WinRM::WinRMError) and @config['forced_preclean']) and\n !@config['forced_preclean']\n begin\n preClean(false) # it's ok for this to fail\n rescue StandardError => e\n end\n MU::Groomer::Chef.purge(@server.mu_name, nodeonly: true)\n @config['forced_preclean'] = true\n @server.reboot if @server.windows? # *sigh*\n end\n MU.log \"#{@server.mu_name}: Knife Bootstrap failed #{e.inspect}, retrying in #{(10*retries).to_s}s (#{retries} of #{max_retries})\", MU::WARN, details: e.backtrace\n sleep 10*retries\n retry\n else\n raise MuError, \"#{@server.mu_name}: Knife Bootstrap failed too many times with #{e.inspect}\"\n end\n rescue StandardError => e\nMU.log e.inspect, MU::ERR, details: e.backtrace\nsleep 10*retries\nretry\n end\n\n\n # Now that we're done, remove one-shot bootstrap recipes from the\n # node's final run list\n [\"mu-tools::newclient\"].each { |recipe|\n begin\n ::Chef::Knife.run(['node', 'run_list', 'remove', @server.mu_name, \"recipe[#{recipe}]\"], {})\n rescue SystemExit => e\n MU.log \"#{@server.mu_name}: Run list removal of recipe[#{recipe}] failed with #{e.inspect}\", MU::WARN\n end\n }\n knifeAddToRunList(\"role[mu-node]\")\n knifeAddToRunList(\"recipe[mu-tools::selinux]\")\n\n grantSecretAccess(@server.mu_name, \"windows_credentials\") if @server.windows?\n grantSecretAccess(@server.mu_name, \"ssl_cert\")\n\n saveChefMetadata\n knifeAddToRunList(\"recipe[mu-tools::updates]\") if !@config['skipinitialupdates']\n # Making sure all Windows nodes get the mu-tools::windows-client recipe\n if @server.windows?\n knifeAddToRunList(\"recipe[mu-tools::windows-client]\")\n run(purpose: \"Base Windows configuration\", update_runlist: false, max_retries: 20)\n elsif !@config['skipinitialupdates']\n run(purpose: \"Base configuration\", update_runlist: false, max_retries: 20)\n end\n ::Chef::Knife.run(['node', 'run_list', 'remove', @server.mu_name, \"recipe[mu-tools::updates]\"], {}) if !@config['skipinitialupdates']\n ::Chef::Knife.run(['node', 'run_list', 'remove', @server.mu_name, \"recipe[mu-tools::selinux]\"], {})\n\n # This will deal with Active Directory integration.\n if !@config['active_directory'].nil?\n if @config['active_directory']['domain_operation'] == \"join\"\n knifeAddToRunList(\"recipe[mu-activedirectory::domain-node]\")\n run(purpose: \"Join Active Directory\", update_runlist: false, max_retries: max_retries)\n elsif @config['active_directory']['domain_operation'] == \"create\"\n knifeAddToRunList(\"recipe[mu-activedirectory::domain]\")\n run(purpose: \"Create Active Directory Domain\", update_runlist: false, max_retries: 15)\n elsif @config['active_directory']['domain_operation'] == \"add_controller\"\n knifeAddToRunList(\"recipe[mu-activedirectory::domain-controller]\")\n run(purpose: \"Add Domain Controller to Active Directory\", update_runlist: false, max_retries: 15)\n end\n end\n\n if !@config['run_list'].nil?\n knifeAddToRunList(multiple: @config['run_list'])\n end\n\n saveDeployData\n end",
"def backup_wallet\n client.make_request('/backup-wallet', 'post', params: {})\n end",
"def bootstrap(ssh_url)\n server = Chaos::Server.new ssh_url\n\n display_ \"Bootstrapping #{server}...\", :topic\n server.bootstrap\n\n display_ \"Update the system...\", :topic\n server.system_update true\n\n display_ \"Configure services using Chef...\", :topic\n server.register_server_roles options[:roles]\n server.run_chef true\n\n user = ENV['USER']\n display_ \"Register git user '#{user}'...\", :topic\n server.register_git_user user\n\n display_ \"Done.\", :topic\n display_ \"Default passwords set for admin users by chef is their user names.\"\n display_ \"Connect to the server to change it ('ssh #{server}') before doing anything else.\"\n end",
"def create_instances\n min_count = max_count = @bs.number_of_nodes\n puts \"\\nCreating #{max_count} on-demand instance(s)\"\n options = {\n 'ClientToken' => generate_token,\n 'KeyName' => Chef::Config[:knife][:aws_ssh_key_id],\n 'InstanceType' => @bs.flavor,\n 'SubnetId' => @bs[:novpc] ? nil : @bs.subnet_id,\n 'Placement.AvailabilityZone' => @bs.mixins.az.data,\n 'SecurityGroupId' => @bs.mixins.sg.data\n }\n options['EbsOptimized'] = !! @bs[:ebs_optimized]\n\n ## REVIEW\n if ami.root_device_type == \"ebs\"\n ami_map = ami.block_device_mapping.first\n block_device_mapping = {\n 'DeviceName' => ami_map['deviceName'],\n 'Ebs.VolumeSize' => ami_map['volumeSize'].to_s,\n 'Ebs.DeleteOnTermination' => ami_map['deleteOnTermination']\n }\n options['BlockDeviceMapping'] = [block_device_mapping]\n end\n\n ## Optionally only include mapped devices\n ## This way we get all of the ephemeral drives, some unmapped however\n if @bs.mixins.volume.data[:ephemeral_available]\n ephmap = @bs.mixins.volume.data.ephemeral_available.each_with_index.map do |d,i|\n {\n 'VirtualName' => \"ephemeral#{i}\",\n 'DeviceName' => d\n }\n end\n options['BlockDeviceMapping'].concat( ephmap )\n end\n\n if (max_count == 1) and @bs[:private_ip_address]\n options['PrivateIpAddress'] = @bs.private_ip_address\n puts \"Assigning IP ADDRESS : #{options['PrivateIpAddress']}\"\n end\n\n if Chef::Config[:knife][:aws_user_data]\n begin\n options['UserData']= File.read(Chef::Config[:knife][:aws_user_data])\n rescue\n ui.warn(\"Cannot read #{Chef::Config[:knife][:aws_user_data]}:\"\\\n \" #{$!.inspect}. Ignoring option.\")\n end\n end\n\n # -----------------------------------------------------------------\n tries = 5\n print_table(options, 'Launch Config')\n begin\n puts \"\\nSending request...\"\n response = connection.run_instances(@bs.image, min_count,\n max_count, options)\n ui.msg(response.inspect)\n rescue Exception => e\n ui.warn(\"#{e.message}\\nException creating instances\")\n if (tries -= 1) <= 0\n ui.warn(\"\\n\\nMax tries reached. Exiting.\\n\\n\")\n exit 1\n else\n ui.msg(\"Trying again.\\n\")\n retry\n end\n end\n # now we have our servers\n instances = response.body['instancesSet']\n # select only instances that have instanceId key and collect those ids\n # into an array\n @bs[:instance_ids] =\n instances.select {|i| i.has_key?('instanceId')}.collect do |i|\n i['instanceId']\n end\n\n puts \"\\nNumber of instances started: #{@bs.instance_ids.size}\\n\"\n sleep 10\n puts \"Getting servers..\"\n # collect an array of servers retrieved based on the instance ids we\n # obtained above\n @bs[:servers] = @bs.instance_ids.collect do |id|\n begin\n server = connection.servers.get(id)\n rescue Exception => e\n sleep 7\n retry\n end\n raise Ec2Error.new(\"server #{id} was nil\") if server.nil?\n server\n end\n end",
"def boot\n return self if booted?\n\n prepare\n\n container.finalize!\n slices.each(&:boot)\n\n @booted = true\n\n self\n end",
"def create\n response = get_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers/\"+params[:containerID].to_s+\"/deploy.json\"), (sesh :current_token))\n json_respond response.body\n end",
"def create\n @firmware = Firmware.new(firmware_params)\n\n respond_to do |format|\n if @firmware.save\n format.json { render json: {\n status: \"ok\"\n },\n status: :ok\n }\n else\n format.html { render :new }\n format.json { render json: @firmware.errors, status: :unprocessable_entity }\n end\n end\n end",
"def boot_aws_inception_vm\n say \"\" # glowing whitespace\n\n unless settings[\"inception\"][\"ip_address\"]\n say \"Provisioning IP address for inception VM...\"\n settings[\"inception\"][\"ip_address\"] = acquire_ip_address\n save_settings!\n end\n\n unless settings[\"inception\"] && settings[\"inception\"][\"server_id\"]\n username = \"ubuntu\"\n size = \"m1.small\"\n ip_address = settings[\"inception\"][\"ip_address\"]\n key_name = settings[\"inception\"][\"key_pair\"][\"name\"]\n say \"Provisioning #{size} for inception VM...\"\n inception_vm_attributes = {\n :groups => [settings[\"inception\"][\"security_group\"]],\n :key_name => key_name,\n :private_key_path => inception_vm_private_key_path,\n :flavor_id => size,\n :bits => 64,\n :username => \"ubuntu\",\n :public_ip_address => ip_address\n }\n if vpc?\n raise \"must create subnet before creating VPC inception VM\" unless settings[\"subnet\"] && settings[\"subnet\"][\"id\"]\n inception_vm_attributes[:subnet_id] = settings[\"subnet\"][\"id\"]\n inception_vm_attributes[:private_ip_address] = \"10.0.0.5\"\n end\n server = provider.bootstrap(inception_vm_attributes)\n unless server\n error \"Something mysteriously cloudy happened and fog could not provision a VM. Please check your limits.\"\n end\n\n settings[\"inception\"].delete(\"create_new\")\n settings[\"inception\"][\"server_id\"] = server.id\n settings[\"inception\"][\"username\"] = username\n save_settings!\n end\n\n server ||= fog_compute.servers.get(settings[\"inception\"][\"server_id\"])\n\n unless settings[\"inception\"][\"disk_size\"]\n disk_size = DEFAULT_INCEPTION_VOLUME_SIZE # Gb\n device = \"/dev/sdi\"\n provision_and_mount_volume(server, disk_size, device)\n\n settings[\"inception\"][\"disk_size\"] = disk_size\n settings[\"inception\"][\"disk_device\"] = device\n save_settings!\n end\n\n # settings[\"inception\"][\"host\"] is used externally to determine\n # if an inception VM has been assigned already; so we leave it\n # until last in this method to set this setting.\n # This way we can always rerun the CLI and rerun this method\n # and idempotently get an inception VM\n unless settings[\"inception\"][\"host\"]\n settings[\"inception\"][\"host\"] = server.dns_name\n save_settings!\n end\n\n confirm \"Inception VM has been created\"\n display_inception_ssh_access\n end",
"def seed_params\n params.require(:seed).permit(:seedId, :name, :state, :growth, :drought, :soil, :salt)\n end",
"def create\n @kb = Kb.new(params[:kb])\n\n respond_to do |format|\n if @kb.save\n format.html { redirect_to @kb, :notice => 'Kb was successfully created.' }\n format.json { render :json => @kb, :status => :created, :location => @kb }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @kb.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def backupAllVolumes(profile,region,daystokeep,name,json,tags)\n parsed = JSON.parse(json)\n parsed[\"Volumes\"].each do |volume|\n backupVolume(profile,region,volume[\"VolumeId\"],daystokeep,name,tags)\n end\nend",
"def create_branding(params)\n request :post, \"/v3/brandings.json\", params\n end",
"def bootstrap_post\n # only create if no other netwroks\n if Network.where(:name=>Network::ADMIN_NET).count == 0\n deployment = Deployment.system\n Network.transaction do\n # admin network\n net = Network.create :name=>Network::ADMIN_NET, :description=>I18n.t('support.bootstrap.admin_net'), :deployment_id=>deployment.id, :conduit=>Network::DEFAULTCONDUIT, :v6prefix => Network::V6AUTO\n NetworkRange.create :name=>'admin', :network_id=>net.id, :first=>\"192.168.124.10/24\", :last=>\"192.168.124.11/24\"\n NetworkRange.create :name=>'dhcp', :network_id=>net.id, :first=>\"192.168.124.21/24\", :last=>\"192.168.124.80/24\"\n NetworkRange.create :name=>'host', :network_id=>net.id, :first=>\"192.168.124.81/24\", :last=>\"192.168.124.254/24\"\n # bmc network\n bmc = Network.create :name=>Network::BMC_NET, :description=>I18n.t('support.bootstrap.bmc_net'), :deployment_id=>deployment.id, :conduit=>Network::BMCCONDUIT, :v6prefix => Network::V6AUTO\n NetworkRange.create :name=>'admin', :network_id=>bmc.id, :first=>\"192.168.128.10/24\", :last=>\"192.168.128.20/24\"\n NetworkRange.create :name=>'host', :network_id=>bmc.id, :first=>\"192.168.128.21/24\", :last=>\"192.168.128.254/24\"\n\n end\n end\n end",
"def create\n megam_rest.post_appdefn(to_hash)\n end",
"def create\n @baker = Baker.new(baker_params)\n\n respond_to do |format|\n if @baker.save\n format.html { redirect_to @baker, notice: 'Baker was successfully created.' }\n format.json { render :show, status: :created, location: @baker }\n else\n format.html { render :new }\n format.json { render json: @baker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @brave_burst = BraveBurst.new(brave_burst_params)\n\n respond_to do |format|\n if @brave_burst.save\n format.html { redirect_to @brave_burst, notice: 'Brave burst was successfully created.' }\n format.json { render action: 'show', status: :created, location: @brave_burst }\n else\n format.html { render action: 'new' }\n format.json { render json: @brave_burst.errors, status: :unprocessable_entity }\n end\n end\n end",
"def boot_openstack_inception_vm\n say \"\" # glowing whitespace\n\n unless settings[\"inception\"] && settings[\"inception\"][\"server_id\"]\n username = \"ubuntu\"\n say \"Provisioning server for inception VM...\"\n settings[\"inception\"] ||= {}\n\n # Select OpenStack flavor\n if settings[\"inception\"][\"flavor_id\"]\n inception_flavor = fog_compute.flavors.find { |f| f.id == settings[\"inception\"][\"flavor_id\"] }\n settings[\"inception\"][\"flavor_id\"] = nil if inception_flavor.nil?\n end\n unless settings[\"inception\"][\"flavor_id\"]\n say \"\"\n hl.choose do |menu|\n menu.prompt = \"Choose OpenStack flavor: \"\n fog_compute.flavors.each do |flavor|\n menu.choice(flavor.name) do\n inception_flavor = flavor\n settings[\"inception\"][\"flavor_id\"] = inception_flavor.id\n save_settings!\n end\n end\n end\n end\n say \"\"\n confirm \"Using flavor #{inception_flavor.name} for Inception VM\"\n\n # Select OpenStack image\n if settings[\"inception\"][\"image_id\"]\n inception_image = fog_compute.images.find { |i| i.id == settings[\"inception\"][\"image_id\"] }\n settings[\"inception\"][\"image_id\"] = nil if inception_image.nil?\n end\n unless settings[\"inception\"][\"image_id\"]\n say \"\"\n hl.choose do |menu|\n menu.prompt = \"Choose OpenStack image (Ubuntu): \"\n fog_compute.images.each do |image|\n menu.choice(image.name) do\n inception_image = image\n settings[\"inception\"][\"image_id\"] = inception_image.id\n save_settings!\n end\n end\n end\n end\n say \"\"\n confirm \"Using image #{inception_image.name} for Inception VM\"\n\n key_name = settings[\"inception\"][\"key_pair\"][\"name\"]\n\n # Boot OpenStack server\n server = fog_compute.servers.create(\n :name => \"Inception VM\",\n :key_name => key_name,\n :private_key_path => inception_vm_private_key_path,\n :flavor_ref => inception_flavor.id,\n :image_ref => inception_image.id,\n :security_groups => [settings[\"inception\"][\"security_group\"]],\n :username => username\n )\n server.wait_for { ready? }\n unless server\n error \"Something mysteriously cloudy happened and fog could not provision a VM. Please check your limits.\"\n end\n\n settings[\"inception\"].delete(\"create_new\")\n settings[\"inception\"][\"server_id\"] = server.id\n settings[\"inception\"][\"username\"] = username\n save_settings!\n end\n\n server ||= fog_compute.servers.get(settings[\"inception\"][\"server_id\"])\n\n unless settings[\"inception\"][\"ip_address\"]\n say \"Provisioning IP address for inception VM...\"\n ip_address = acquire_ip_address\n associate_ip_address_with_server(ip_address, server)\n\n settings[\"inception\"][\"ip_address\"] = ip_address\n save_settings!\n end\n\n # TODO: Hack\n unless server.public_ip_address\n server.addresses[\"public\"] = [settings[\"inception\"][\"ip_address\"]]\n end\n unless server.private_key_path\n server.private_key_path = inception_vm_private_key_path\n end\n server.username = settings[\"inception\"][\"username\"]\n Fog.wait_for(60) { server.sshable? }\n\n unless settings[\"inception\"][\"disk_size\"]\n disk_size = prompt_for_disk_space(\"Inception VM\", DEFAULT_INCEPTION_VOLUME_SIZE)\n device = \"/dev/vdc\"\n provision_and_mount_volume(server, disk_size, device)\n\n settings[\"inception\"][\"disk_size\"] = disk_size\n settings[\"inception\"][\"disk_device\"] = device\n save_settings!\n end\n\n # settings[\"inception\"][\"host\"] is used externally to determine\n # if an inception VM has been assigned already; so we leave it\n # until last in this method to set this setting.\n # This way we can always rerun the CLI and rerun this method\n # and idempotently get an inception VM\n unless settings[\"inception\"][\"host\"]\n settings[\"inception\"][\"host\"] = settings[\"inception\"][\"ip_address\"]\n save_settings!\n end\n\n confirm \"Inception VM has been created\"\n display_inception_ssh_access\n end",
"def run_bootstrap\n dockercfg_location = args[0]\n cloudsql_credentials_location = args[1]\n\n if dockercfg_location.nil? || dockercfg_location == ''\n puts 'Please specify the dockercfg json key location as first param.'\n exit(1)\n end\n\n if cloudsql_credentials_location.nil? || cloudsql_credentials_location == ''\n puts 'Please specify the cloudsql_credentials_location json key location as second param.'\n exit(1)\n end\n\n # puts `kubectl create secret generic gcr-secret --namespace default --from-file=.dockercfg=#{dockercfg_location}`\n puts `kubectl create secret docker-registry gcr-secret --docker-username=_json_key --docker-password=\"$(cat #{dockercfg_location})\" --docker-server=https://gcr.io --docker-email=doesnotmatter@example.com`\n puts `kubectl create secret generic cloudsql-credentials --namespace default --from-file=credentials.json=#{cloudsql_credentials_location}`\n end",
"def post_app_generate(application_id, type, opts={})\n # \n # default_options = {\n # \"name\" => \"\",\n # \"author\" => \"\",\n # \"description\" => \"\",\n # \"guid\" => \"\",\n # \"datasets\" => \"\",\n # \"env\" => \"prod\",\n # \"image_url\" => \"http://appresource.s3.amazonaws.com/apiappimages/missing_icard.jpg\",\n # \"runtime\" => \"\"\n # }\n # options = default_options.merge(opts)\n return post_response(\"app/#{application_id}/generate/#{type}\", opts,:json)\n end",
"def create\n @boat = Boat.new(boat_params)\n\n if @boat.save\n render json: @boat, status: :created, location: @boat\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n end"
] |
[
"0.6742345",
"0.6466418",
"0.6065044",
"0.6004548",
"0.5919822",
"0.56240284",
"0.56207764",
"0.5488821",
"0.5426072",
"0.54159385",
"0.5402109",
"0.538391",
"0.53199",
"0.525922",
"0.5255671",
"0.52223134",
"0.51395017",
"0.5122044",
"0.5095216",
"0.50821424",
"0.50764984",
"0.50649893",
"0.50571126",
"0.49967775",
"0.49853587",
"0.49798533",
"0.49476492",
"0.49189815",
"0.48175928",
"0.48122162",
"0.47811764",
"0.47762367",
"0.47759616",
"0.47697476",
"0.47634324",
"0.47487405",
"0.473367",
"0.47165576",
"0.47099963",
"0.46758768",
"0.4671201",
"0.46361437",
"0.46117994",
"0.46031225",
"0.4598472",
"0.45957077",
"0.45904103",
"0.45894286",
"0.45854107",
"0.4574913",
"0.4565732",
"0.45641837",
"0.45412925",
"0.45284268",
"0.45271638",
"0.45257872",
"0.45237288",
"0.45223635",
"0.45173252",
"0.45003763",
"0.44912374",
"0.44745934",
"0.4458554",
"0.44551933",
"0.4448957",
"0.4432711",
"0.4431398",
"0.44284844",
"0.44191337",
"0.44191337",
"0.4412359",
"0.4407034",
"0.4405473",
"0.44018054",
"0.43991566",
"0.4389636",
"0.43843368",
"0.4379969",
"0.43796632",
"0.4379493",
"0.43740857",
"0.43723062",
"0.43640292",
"0.4362127",
"0.4361899",
"0.43604013",
"0.43587443",
"0.43583345",
"0.43566653",
"0.435578",
"0.4352046",
"0.43493122",
"0.43430153",
"0.43410063",
"0.43333802",
"0.4332301",
"0.43289092",
"0.43269312",
"0.43255898",
"0.431615"
] |
0.6190524
|
2
|
PUT /boots/1 PUT /boots/1.json
|
def update
@boot = Boot.find(params[:id])
respond_to do |format|
if @boot.update_attributes(params[:boot])
flash[:success] = "Updated successfully "
format.html { redirect_to boots_path, notice: 'Boot was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @boot.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @boot = Boot.find(params[:id])\n\n respond_to do |format|\n if @boot.update_attributes(params[:boot])\n flash[:notice] = 'Boot was successfully updated.'\n format.html { redirect_to(@boot) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @boot.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @testboot.update(testboot_params)\n format.html { redirect_to @testboot, notice: 'Testboot was successfully updated.' }\n format.json { render :show, status: :ok, location: @testboot }\n else\n format.html { render :edit }\n format.json { render json: @testboot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_testboot\n @testboot = Testboot.find(params[:id])\n end",
"def show\n @boot = Boot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @boot }\n end\n end",
"def destroy\n @boot = Boot.find(params[:id])\n @boot.destroy\n\n respond_to do |format|\n format.html { redirect_to(boots_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @boot = Boot.find(params[:id])\n @boot.destroy\n\n\n respond_to do |format|\n flash[:success] = \"Deleted successfully \"\n format.html { redirect_to boots_url }\n format.json { head :no_content }\n end\n end",
"def create\n @boot = Boot.new(params[:boot])\n puts \"=================================================================\"\n puts params[:boot]\n p @boot.bootlargeimage_file_name\n puts \"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\"\n\n \n respond_to do |format|\n if @boot.save\n flash[:success] = \"Boot was successfully created\"\n format.html { redirect_to boots_path, notice: 'Boot was successfully created.' }\n format.json { render json: boots_path, status: :created, location: @boot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @boot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @boot = Boot.new(params[:boot])\n\n respond_to do |format|\n if @boot.save\n flash[:notice] = 'Boot was successfully created.'\n format.html { redirect_to(@boot) }\n format.xml { render :xml => @boot, :status => :created, :location => @boot }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @boot.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @latstraps1.update(latstraps1_params)\n format.html { redirect_to \"/latstraps1s\"}\n format.json { render :show, status: :ok, location: @latstraps1 }\n else\n format.html { render :edit }\n format.json { render json: @latstraps1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_app data={}\n put '/app', data\n end",
"def create\n @testboot = Testboot.new(testboot_params)\n\n respond_to do |format|\n if @testboot.save\n format.html { redirect_to @testboot, notice: 'Testboot was successfully created.' }\n format.json { render :show, status: :created, location: @testboot }\n else\n format.html { render :new }\n format.json { render json: @testboot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @boot = Boot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @boot }\n end\n end",
"def update\n @supermarket = Supermarket.find(params[:id]) \n respond_to do |format|\n if @supermarket.update(supermarket_params)\n format.json { render json: @supermarket, status: :ok }\n end\n end\n end",
"def update(name, attributes)\n\t\tput(\"/apps/#{name}\", :app => attributes)\n\tend",
"def update(name, attributes)\n\t\tput(\"/apps/#{name}\", :app => attributes)\n\tend",
"def update\n request_body_Data= '{ \"widget\":\n {\n \"name\" : \"'+params[:name]+'\",\n \"description\" : \"'+params[:description]+'\"\n }}'\n response = RestClient::Request.new({\n method: :put,\n url: ENV['API_URL'] + '/widgets/' + params[:id],\n payload: request_body_Data,\n headers: { Authorization: session[:access_token], content_type: 'application/json'}\n }).execute do |response, request, result|\n case response.code\n when 400\n [ :error, JSON.parse(response) ]\n when 200\n [ :success, JSON.parse(response) ]\n json=JSON.parse(response)\n @widget= Widget.new do |widget|\n widget.id=json[\"data\"][\"widget\"][\"id\"]\n widget.name=json[\"data\"][\"widget\"][\"name\"]\n widget.description=json[\"data\"][\"widget\"][\"description\"]\n widget.kind=json[\"data\"][\"widget\"][\"kind\"]\n widget.userid=json[\"data\"][\"widget\"][\"user\"][\"id\"]\n widget.username=json[\"data\"][\"widget\"][\"user\"][\"name\"]\n widget.owner=json[\"data\"][\"widget\"][\"owner\"]\n end\n else\n fail \"Invalid response #{response.to_str} received.\"\n end\n end\n respond_to do |format|\n if @widget\n format.html { redirect_to @widget, notice: 'Widget was successfully updated.' }\n format.json { render :show, status: :ok, location: @widget }\n else\n format.html { render :edit }\n format.json { render json: @widget.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @startup.update(startup_params)\n format.html { redirect_to startups_url, notice: 'listing was successfully updated.' }\n format.json { render :index, status: :ok, location: @startup }\n else\n format.html { render :edit }\n format.json { render json: @startup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @boot_disk_size_gb = args[:boot_disk_size_gb] if args.key?(:boot_disk_size_gb)\n @boot_disk_type = args[:boot_disk_type] if args.key?(:boot_disk_type)\n end",
"def update\n @serving = Serving.find(params[:id])\n\n respond_to do |format|\n if @serving.update_attributes(params[:serving])\n format.html { redirect_to @serving, notice: 'Serving was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @serving.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def update(name, attributes)\n put(\"/apps/#{name}\", :app => attributes).to_s\n end",
"def update\n @scrobble = Scrobble.find(params[:id])\n\n respond_to do |format|\n if @scrobble.update_attributes(params[:scrobble])\n format.html { redirect_to @scrobble, notice: 'Scrobble was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @scrobble.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stalking = Stalking.find(params[:id])\n @stalking.user_id = current_user.id\n\n respond_to do |format|\n if @stalking.update_attributes(app_params)\n format.html { redirect_to @stalking, flash: { success: 'Stalking was successfully updated.' } }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stalking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n recipe.update(recipe_params)\n render json: recipe\n end",
"def update\n @shelf = Shelf.find(params[:id])\n\n respond_to do |format|\n if @shelf.update_attributes(params[:shelf])\n flash[:notice] = 'Shelf was successfully updated.'\n format.html { redirect_to(@shelf) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @shelf.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def testboot_params\n params.require(:testboot).permit(:name)\n end",
"def boot(vid)\n perform_request(action: 'vserver-boot', vserverid: vid)\n end",
"def update\n @data = @recipe.update(params[:id], recipe_params)\n render json: @data\n end",
"def update\n @climb = Climb.find(params[:id])\n\n respond_to do |format|\n if @climb.update_attributes(params[:climb])\n format.html { redirect_to @climb, notice: 'Climb was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @climb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def change_bootorder(vid, bootorder)\n perform_request(:action => 'vserver-bootorder', :vserverid => vid, :bootorder => bootorder.to_s)\n end",
"def update\n @go_slim = GoSlim.find(params[:id])\n\n respond_to do |format|\n if @go_slim.update_attributes(params[:go_slim])\n format.html { redirect_to @go_slim, notice: 'Go slim was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @go_slim.errors, status: :unprocessable_entity }\n end\n end\n end",
"def boot(options={})\n Jets::Booter.boot!(options)\n end",
"def change_bootorder(vid, bootorder)\n perform_request(action: 'vserver-bootorder', vserverid: vid, bootorder: bootorder.to_s)\n end",
"def update\n @bloom = Bloom.find(params[:id])\n\n respond_to do |format|\n if @bloom.update_attributes(params[:bloom])\n format.html { redirect_to @bloom, notice: 'Bloom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bloom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @fabric = Fabric.find(params[:id])\n\n respond_to do |format|\n if @fabric.update_attributes(params[:fabric])\n format.html { redirect_to @fabric, notice: 'Fabric was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fabric.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n params[:book_shelf]['user'] = User.where(:id => params[:book_shelf]['user']).first\n params[:book_shelf]['book'] = Book.where(:id => params[:book_shelf]['book']).first\n @book_shelf = BookShelf.find(params[:id])\n respond_to do |format|\n if @book_shelf.update_attributes(params[:book_shelf])\n format.html { redirect_to @book_shelf, notice: 'Book shelf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book_shelf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @kb = Kb.find(params[:id])\n\n respond_to do |format|\n if @kb.update_attributes(params[:kb])\n format.html { redirect_to @kb, :notice => 'Kb was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @kb.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n id = params[:id]\n @physical_rack = PhysicalRack.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @physical_rack.attributes = params[:physical_rack]\n @physical_rack.audits << Audit.new(source: 'controller', action: 'update', admin_user: current_user)\n respond_to do |format|\n if @physical_rack.save\n format.html { redirect_to @physical_rack, notice: 'Physical rack was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @physical_rack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @broad = Broad.find(params[:id])\n\n respond_to do |format|\n if @broad.update_attributes(params[:broad])\n format.html { redirect_to @broad, notice: 'Broad was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @broad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @rainbow = Rainbow.find(params[:id])\n\n respond_to do |format|\n if @rainbow.update_attributes(params[:rainbow])\n format.html { redirect_to @rainbow, notice: 'Rainbow was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rainbow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @slab = Slab.find(params[:id])\n\n respond_to do |format|\n if @slab.update_attributes(params[:slab])\n format.html { redirect_to @slab, :notice => 'Slab was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @slab.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @shelf.update(shelf_params)\n format.html { redirect_to house_shelves_path(params[:house_id]), notice: 'Shelf was successfully created.' } \n format.json { render :show, status: :ok, location: @shelf }\n else\n format.html { render :edit }\n format.json { render json: @shelf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def boot\n if self.stopped?\n self.status = \"booting\"\n # delayed_job, 5.times sleep 10 sec, print to /scenarios/#{1}\n debug \"Booting scenario...\"\n\n \n # Boot Clouds\n self.clouds.each { |cloud| cloud.boot }\n \n # Final Setup\n self.final_setup\n self.status = \"booted\"\n self.save!\n end\n end",
"def update\n rid = params['id']\n name = params['name']\n description = params['description']\n instructions = params['instructions']\n cook_time = params['cook_time']\n quantity = params['quantity']\n serving_size = params['serving_size']\n uid = params['user_id']\n aws_params = Hash.new\n aws_params[:custom_fields] = {\n 'recipe_id' => rid,\n 'name' => name,\n 'description' => description,\n 'instructions' => instructions,\n 'cook_time' => cook_time,\n 'quantity' => quantity,\n 'serving_size' => serving_size,\n 'user_id' => uid\n }\n if Aws.update_recipe(aws_params)\n msg = {:notice => \"Recipe updated!\"}\n render :json => msg\n else\n msg = {:notice => \"Error while save to DynamoDB!\"}\n render :json => msg\n end\n end",
"def update\n @flavor = Flavor.find(params[:id])\n\n respond_to do |format|\n if @flavor.update_attributes(params[:flavor])\n format.html { redirect_to @flavor, :notice => 'Flavor was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @flavor.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @box = Box.find(params[:id])\n\n respond_to do |format|\n if @box.update_attributes(params[:box])\n format.html { redirect_to @box, notice: 'Box was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @box.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n put :update\n end",
"def update\n respond_to do |format|\n if @bike_rack.update(bike_rack_params)\n flash[:success] = 'Bike rack was successfully updated.'\n format.html { redirect_to @bike_rack }\n format.json { render :show, status: :ok, location: @bike_rack }\n else\n flash[:danger] = 'There was a problem editing Bike rack.'\n format.html { render :edit }\n format.json { render json: @bike_rack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @scaffold = Scaffold.find(params[:id])\n\n respond_to do |format|\n if @scaffold.update_attributes(params[:scaffold])\n format.html { redirect_to @scaffold, notice: 'Scaffold was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @scaffold.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n sneaker = find_sneaker\n # update! exceptions will be handled by the rescue_from ActiveRecord::RecordInvalid code\n sneaker.update(sneaker_params)\n render json: sneaker\n end",
"def update\n @microplst = Microplst.find(params[:id])\n\n respond_to do |format|\n if @microplst.update_attributes(params[:microplst])\n format.html { redirect_to @microplst, notice: 'Microplst was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @microplst.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @swatch.update(swatch_params)\n format.html { redirect_to @swatch, notice: 'Swatch was successfully updated.' }\n format.json { render :show, status: :ok, location: @swatch }\n else\n format.html { render :edit }\n format.json { render json: @swatch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @salt.update(salt_params)\n format.html { redirect_to @salt, notice: 'Salt was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @salt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stage = Stage.find(params[:id])\n\n if @stage.update_attributes(params[:stage])\n head :no_content\n else\n format.json { render json: @stage.errors, status: :unprocessable_entity }\n end\n end",
"def update\n begin\n recipe = Recipe.find(params[:id])\n\n if recipe.update_attributes(recipe_params)\n render json: { status: 'SUCCESS', message: 'Recipe updated!', data: recipe }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Error updating recipe', data: recipe.errors }, status: :unprocessable_entity\n end\n rescue\n render json: { status: 'ERROR', message: 'Error finding recipe', data: {} }, status: :not_found\n end\n end",
"def update\n respond_to do |format|\n if @climb.update(climb_params)\n format.html { redirect_to @climb, notice: 'Climb was successfully updated.' }\n format.json { render :show, status: :ok, location: @climb }\n else\n format.html { render :edit }\n format.json { render json: @climb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n @logstash = Logstash.find(params[:id])\n\n respond_to do |format|\n if @logstash.update_attributes(params[:logstash])\n format.html { redirect_to @logstash, notice: 'Logstash was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @logstash.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bow.update(bow_params)\n format.html { redirect_to @bow, notice: 'Bow was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @shoot = Shoot.find(params[:id])\n\n respond_to do |format|\n if @shoot.update_attributes(params[:shoot])\n format.html { redirect_to @shoot, notice: 'Shoot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shoot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bunny.update(bunny_params)\n format.html { redirect_to @bunny, notice: 'Bunny was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bunny.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n keystone.update_tenant({:id=>params[:id],:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n format.html { redirect_to tenants_path, :notice => 'Tenant was successfully updated.' }\n format.json { head :ok }\n end\n end",
"def update\n respond_to do |format|\n if @kota_stone.update(kota_stone_params)\n format.html { redirect_to kota_stones_url, notice: 'Kota stone was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kota_stone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @microposst = Microposst.find(params[:id])\n\n respond_to do |format|\n if @microposst.update_attributes(params[:microposst])\n format.html { redirect_to @microposst, notice: 'Microposst was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @microposst.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @super_bowl_pick = SuperBowlPick.find(params[:id])\n\n respond_to do |format|\n if @super_bowl_pick.update_attributes(params[:super_bowl_pick])\n format.html { redirect_to @super_bowl_pick, notice: 'Super bowl pick was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @super_bowl_pick.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @taker = Taker.find(params[:id])\n\n respond_to do |format|\n if @taker.update_attributes(params[:taker])\n format.html { redirect_to @taker, notice: 'Taker was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @taker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n @shard = Shard.find(params[:id])\n\n respond_to do |format|\n if @shard.update_attributes(params[:shard])\n format.html { redirect_to @shard, notice: 'Shard was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shard.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bundlesticker = Bundlesticker.find(params[:id])\n\n respond_to do |format|\n if @bundlesticker.update_attributes(params[:bundlesticker])\n format.html { redirect_to @bundlesticker, notice: 'Bundlesticker was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bundlesticker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @serving.update(serving_params)\n format.html { redirect_to @serving, notice: 'Serving was successfully updated.' }\n format.json { render :show, status: :ok, location: @serving }\n else\n format.html { render :edit }\n format.json { render json: @serving.errors, status: :unprocessable_entity }\n end\n end\n end",
"def vagrant_json_update(image_name, version_entry)\n # Load the vagrant JSON file\n json_file = File.new(\"#{Packer::OUTPUT_DIR}/#{image_name}.json\", 'w+')\n json_str = json_file.read\n \n # Load the JSON data\n begin\n json_data = JSON.load json_str\n rescue JSON::ParserError\n json_data = {\n \"name\" => image_name,\n \"versions\" => []\n }\n end\n\n # This will make sure there are no duplicate\n # entries for each box version specified in the\n # JSON file\n json_data['versions'].each_index do |i|\n box_version = json_data['versions'][i]\n if box_version['version'] == version_entry['version']\n json_data['versions'][i].delete\n break\n end\n end\n\n # Insert the new version entry\n json_data['versions'].push version_entry\n \n # Write the thing\n json_file.puts JSON.dump json_data\nend",
"def update\n @bowl = Bowl.find(params[:id])\n \n # set bowl modify time\n @bowl.modified = Time.now\n \n respond_to do |format|\n if @bowl.update_attributes(params[:bowl])\n \n Rails.logger.info \"Updating Bowl Contents\"\n \n # remove all contents for this bowl and add new\n @bowl.contents.delete_all(\"bowl_id=\" + @bowl.id)\n \n params.keys.each do |param|\n if param.start_with?(\"input_\") and (params[param] != \"\") \n @bowl.contents.create(:bowl_id => @bowl.id, :dryfruit_id => param[6, 2], :quantity => params[param]) \n end\n end\n\n format.html { redirect_to bowls_path, :notice => 'Bowl was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bowl.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_firmware(attributes = {})\n patch('replace', '/firmware', attributes)\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n respond_to do |format|\n if @rack_installation.update(rack_installation_params)\n format.html { redirect_to @rack_installation, notice: 'Rack installation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rack_installation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @beacon = Beacon.find(params[:id])\n\n respond_to do |format|\n if @beacon.update_attributes(params[:beacon])\n format.html { redirect_to @beacon, notice: 'Beacon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @beacon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @animal.update(animal_params)\n respond_with(@shelter)\n end",
"def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def boot(opts)\n opts[:flavor] ||= 'standard.xsmall'\n opts[:image] ||= /Ubuntu Precise/\n opts[:sec_groups] ||= ['default']\n opts[:key_name] ||= 'default'\n opts[:region] ||= 'az-2.region-a.geo-1'\n\n raise 'no name provided' if !opts[:name] or opts[:name].empty?\n\n cleanup opts[:name]\n private_key = new_key opts[:name]\n write_key(private_key, File.expand_path('~/.ssh/hpcloud-keys/' + opts[:region] + '/'))\n\n server = @os.create_server(\n :imageRef => image_id(opts[:image]),\n :flavorRef => flavor_id(opts[:flavor]),\n :key_name => private_key[:name],\n :security_groups => opts[:sec_groups],\n :name => opts[:name])\n\n wait(300) do\n server = @os.server(server.id)\n raise 'error booting vm' if server.status == 'ERROR'\n server.status == 'ACTIVE'\n end\n sleep 60\n\n {\n :ip => public_ip(server),\n :user => 'ubuntu',\n :key => private_key[:private_key]\n }\n end",
"def update\n @bundle = Bundle.find(params[:id])\n\n respond_to do |format|\n if @bundle.update_attributes(params[:bundle])\n format.html { redirect_to @bundle, notice: 'Bundle was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bundle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n ingredient.update(ingredient_params)\n render json: ingredient\n end",
"def update\n @spkj_bsb=SpkjBsb.find(params[:id])\n @spkj_bsb.update_attributes(params[:spkj_bsb])\n\n respond_to do |format|\n format.html { redirect_to(\"/spkj_bsbs\") }\n format.json { render json: @spkj_bsb }\n end\n end",
"def update\n if @secret.update_attributes(secret_params)\n head :no_content\n else\n render json: @secret.errors, status: :unprocessable_entity\n end\n end",
"def update\n @shelter = Shelter.find(params[:id])\n\n if @shelter.update(shelter_params)\n head :no_content\n else\n render json: @shelter.errors, status: :unprocessable_entity\n end\n end",
"def update\n @sugar_bag = SugarBag.find(params[:id])\n\n respond_to do |format|\n if @sugar_bag.update_attributes(params[:sugar_bag])\n format.html { redirect_to @sugar_bag, notice: 'Sugar bag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sugar_bag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @power_rack.update(power_rack_params)\n format.html { redirect_to @power_rack, notice: \"Power rack was successfully updated.\" }\n format.json { render :show, status: :ok, location: @power_rack }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @power_rack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @default_skaffold_version = args[:default_skaffold_version] if args.key?(:default_skaffold_version)\n @name = args[:name] if args.key?(:name)\n @supported_versions = args[:supported_versions] if args.key?(:supported_versions)\n end",
"def create\n ::Velum::Salt.call(\n action: \"cmd.run\",\n targets: \"admin\",\n arg: \"systemctl reboot\"\n )\n\n render json: { status: Minion.statuses[:rebooting] }\n end",
"def update\n respond_to do |format|\n if @mbracket.update(mbracket_params)\n format.html { redirect_to @mbracket, notice: 'Mbracket was successfully updated.' }\n format.json { render :show, status: :ok, location: @mbracket }\n else\n format.html { render :edit }\n format.json { render json: @mbracket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bucket.update(bucket_params)\n format.html { redirect_to buckets_path, notice: 'Bucket was successfully updated.' }\n format.json { render :show, status: :ok, location: @pin }\n else\n format.html { render :edit, status: :unprocessable_entity}\n format.json { render json: @bucket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n mountain = Mountain.find params[:id]\n mountain.update mountain_params\n redirect_to (mountains_path)\n end",
"def update\n respond_to do |format|\n if @shrink.update(shrink_params)\n format.html { redirect_to @shrink, notice: 'Shrink was successfully updated.' }\n format.json { render :show, status: :ok, location: @shrink }\n else\n format.html { render :edit }\n format.json { render json: @shrink.errors, status: :unprocessable_entity }\n end\n end\n end",
"def boot\n runcmd 'boot'\n end",
"def update\n @boxtype = Boxtype.find(params[:id])\n\n respond_to do |format|\n if @boxtype.update_attributes(params[:boxtype])\n format.html { redirect_to @boxtype, notice: 'Boxtype was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @boxtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stone = Stone.find(params[:id])\n\n respond_to do |format|\n if @stone.update_attributes(params[:stone])\n format.html { redirect_to @stone, notice: 'Stone was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @crossbow.update(crossbow_params)\n format.html { redirect_to @crossbow, notice: 'Crossbow was successfully updated.' }\n format.json { render :show, status: :ok, location: @crossbow }\n else\n format.html { render :edit }\n format.json { render json: @crossbow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ninja = Ninja.find(params[:id])\n\n respond_to do |format|\n if @ninja.update_attributes(params[:ninja])\n format.html { redirect_to @ninja, notice: 'Ninja was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ninja.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cake_flavor.update(cake_flavor_params)\n format.html { redirect_to @cake_flavor, notice: 'Cake flavor was successfully updated.' }\n format.json { render :show, status: :ok, location: @cake_flavor }\n else\n format.html { render :edit }\n format.json { render json: @cake_flavor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ami = Ami.find(params[:id])\n\n respond_to do |format|\n if @ami.update_attributes(params[:ami])\n format.html { redirect_to @ami, notice: 'Ami was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ami.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6424908",
"0.61105126",
"0.5636898",
"0.56145096",
"0.5521343",
"0.5443643",
"0.5434995",
"0.5411755",
"0.5400058",
"0.53812206",
"0.5359651",
"0.5345468",
"0.53138494",
"0.52571774",
"0.52571774",
"0.52345127",
"0.52269644",
"0.5200251",
"0.51425636",
"0.51385486",
"0.5112287",
"0.51122123",
"0.5111704",
"0.5097622",
"0.50837237",
"0.50697106",
"0.50673676",
"0.5061889",
"0.5041092",
"0.5039859",
"0.50325704",
"0.50314665",
"0.5029795",
"0.50120884",
"0.50082546",
"0.4969352",
"0.49642825",
"0.4962471",
"0.4958735",
"0.4955488",
"0.49498492",
"0.49351683",
"0.4934301",
"0.49338317",
"0.49329",
"0.49304074",
"0.49286532",
"0.49273726",
"0.49265617",
"0.49249205",
"0.49197876",
"0.4912453",
"0.489961",
"0.48981133",
"0.48929036",
"0.4886819",
"0.48858362",
"0.48778242",
"0.48777118",
"0.4874083",
"0.48737243",
"0.48689634",
"0.4859938",
"0.48556748",
"0.48533794",
"0.48511106",
"0.48455703",
"0.4837029",
"0.48287764",
"0.4824241",
"0.48172808",
"0.48148432",
"0.48128754",
"0.48115674",
"0.48015592",
"0.47972965",
"0.4792994",
"0.4790282",
"0.47825328",
"0.4774825",
"0.47738016",
"0.47724563",
"0.47723657",
"0.476901",
"0.47679928",
"0.47665024",
"0.4762986",
"0.47628835",
"0.47624084",
"0.47576615",
"0.47546595",
"0.47470596",
"0.47467613",
"0.47458985",
"0.4745364",
"0.4744723",
"0.4741889",
"0.4736331",
"0.47356483",
"0.473397"
] |
0.6826857
|
0
|
DELETE /boots/1 DELETE /boots/1.json
|
def destroy
@boot = Boot.find(params[:id])
@boot.destroy
respond_to do |format|
flash[:success] = "Deleted successfully "
format.html { redirect_to boots_url }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @boot = Boot.find(params[:id])\n @boot.destroy\n\n respond_to do |format|\n format.html { redirect_to(boots_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @testboot.destroy\n respond_to do |format|\n format.html { redirect_to testboots_url, notice: 'Testboot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def destroy\n @beacon = Beacon.find(params[:id])\n @beacon.destroy\n\n respond_to do |format|\n format.html { redirect_to beacons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @latstraps1.destroy\n respond_to do |format|\n format.html { redirect_to latstraps1s_url, notice: 'Latstraps1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @baton = Baton.find(params[:id])\n @baton.destroy\n\n respond_to do |format|\n format.html { redirect_to batons_url }\n format.json { head :no_content }\n end\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def destroy\n id = params[:id]\n @physical_rack = PhysicalRack.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @physical_rack.destroy\n\n respond_to do |format|\n format.html { redirect_to physical_racks_url }\n format.json { head :ok }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy(name)\n\t\tdelete(\"/apps/#{name}\")\n\tend",
"def destroy(name)\n\t\tdelete(\"/apps/#{name}\")\n\tend",
"def destroy\n compute.delete_flavor(params[:id])\n \n\n respond_to do |format|\n format.html { redirect_to flavors_path }\n format.json { head :ok }\n end\n end",
"def destroy\n @startup = Startup.find(params[:id])\n @startup.destroy\n\n respond_to do |format|\n format.html { redirect_to startups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @logstash = Logstash.find(params[:id])\n @logstash.destroy\n\n respond_to do |format|\n format.html { redirect_to logstashes_url }\n format.json { head :no_content }\n end\n end",
"def delete\n request(:delete)\n end",
"def destroy\n chef_rest_v1.delete(\"clients/#{@name}\")\n end",
"def destroy(name)\n delete(\"/apps/#{name}\").to_s\n end",
"def destroy\n @bacterium.destroy\n respond_to do |format|\n format.html { redirect_to bacteria_url, notice: 'Bacterium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @database = Database.find(params[:id])\n path = @database.path\n delete = %x[rm -R #{path}]\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stash = Stash.find(params[:id])\n @stash.destroy\n\n respond_to do |format|\n format.html { redirect_to stashes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shutdown_request.destroy\n respond_to do |format|\n format.html { redirect_to shutdown_requests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bits_1.destroy\n respond_to do |format|\n format.html { redirect_to bits_1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @loadbalancer = Loadbalancer.find(params[:id])\n checkaccountobject(\"loadbalancers\",@loadbalancer)\n @loadbalancer.send_delete\n\n respond_to do |format|\n format.html { redirect_to loadbalancers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @fabric = Fabric.find(params[:id])\n @fabric.destroy\n\n respond_to do |format|\n format.html { redirect_to fabrics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.delete( name )\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @startup.destroy\n respond_to do |format|\n format.html { redirect_to startups_url, notice: 'startup was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rackitem = Rackitem.find(params[:id])\n @rackitem.destroy\n\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Rackitem removed' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kb = Kb.find(params[:id])\n @kb.destroy\n\n respond_to do |format|\n format.html { redirect_to kbs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @client.delete(@name)\n end",
"def destroy\n @scrobble = Scrobble.find(params[:id])\n @scrobble.destroy\n\n respond_to do |format|\n format.html { redirect_to scrobbles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lob.destroy\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kota_stone.destroy\n respond_to do |format|\n format.html { redirect_to kota_stones_url }\n format.json { head :no_content }\n end\n end",
"def delete\n api(\"Delete\")\n end",
"def deleteFlatpack( flatpack_id)\n params = Hash.new\n params['flatpack_id'] = flatpack_id\n return doCurl(\"delete\",\"/flatpack\",params)\n end",
"def destroy\n @broad = Broad.find(params[:id])\n @broad.destroy\n\n respond_to do |format|\n format.html { redirect_to broads_url }\n format.json { head :no_content }\n end\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n rid = params['id']\n if Aws.delete_recipe(rid) && Aws.delete_all_ingredients(rid)\n msg = {:notice => \"Recipe deleted!\"}\n render :json => msg\n else\n msg = {:notice => \"Error while deleting from DynamoDB!\"}\n render :json => msg\n end\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def destroy\n @bg_setup = BgSetup.find(params[:id])\n @bg_setup.destroy\n\n respond_to do |format|\n format.html { redirect_to bg_setups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shelf.destroy\n\n respond_to do |format|\n format.html { redirect_to shelves_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @climb = Climb.find(params[:id])\n @climb.destroy\n\n respond_to do |format|\n format.html { redirect_to climbs_url }\n format.json { head :no_content }\n end\n end",
"def cmd_delete argv\n setup argv\n e = @hash['element']\n response = @api.delete(e)\n msg response\n return response\n end",
"def destroy\n @bloom = Bloom.find(params[:id])\n @bloom.destroy\n\n respond_to do |format|\n format.html { redirect_to blooms_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @go_slim = GoSlim.find(params[:id])\n @go_slim.destroy\n\n respond_to do |format|\n format.html { redirect_to go_slims_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n return if @name.nil?\n delete_rest \"extra/#{@name}\"\n end",
"def destroy\n @data = @recipe.delete(params[:id])\n render json: @data\n end",
"def destroy\n @client.app_destroy(params[:id])\n\n respond_to do |format|\n format.html { redirect_to apps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crossbow.destroy\n respond_to do |format|\n format.html { redirect_to crossbows_url, notice: 'Crossbow was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @monkey = Monkey.find(params[:id])\n @monkey.destroy\n\n respond_to do |format|\n format.html { redirect_to monkeys_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shelf.destroy\n respond_to do |format|\n format.html { redirect_to shelves_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @singleb.destroy\n respond_to do |format|\n format.html { redirect_to singlebs_url, notice: 'Singleb was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def destroy\n bin_url = @request.bin.url\n\n @request.destroy\n respond_to do |format|\n format.html do\n redirect_to \"/bins/#{bin_url}\",\n notice: 'Request was successfully destroyed.'\n end\n format.json { head :no_content }\n end\n end",
"def delete\n api_client.delete(url)\n end",
"def destroy\n @bow.destroy\n respond_to do |format|\n format.html { redirect_to bows_url }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n @version = Version.find(params[:id])\n @versionconfig = @version.version_configurations.destroy_all\n @version.destroy\n\n respond_to do |format|\n format.html { redirect_to [@application, @version] }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bones_segment.destroy\n respond_to do |format|\n format.html { redirect_to bones_segments_url, notice: 'Bones segment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lun_disk = LunDisk.find(params[:id])\n @lun_disk.destroy\n\n respond_to do |format|\n format.html { redirect_to lun_disks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apk_bin = ApkBin.find(params[:id])\n @apk_bin.destroy\n\n respond_to do |format|\n format.html { redirect_to apk_bins_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @scaffold = Scaffold.find(params[:id])\n @scaffold.destroy\n\n respond_to do |format|\n format.html { redirect_to scaffolds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @supermarket = Supermarket.find(params[:id]) \n @supermarket.destroy\n respond_to do |format|\n format.json { render json: @supermarket, status: :ok }\n end\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def delete endpoint\n do_request :delete, endpoint\n end",
"def destroy\n @baz8.destroy\n respond_to do |format|\n format.html { redirect_to baz8s_url, notice: \"Baz8 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bread.destroy\n respond_to do |format|\n format.html { redirect_to breads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @backup.destroy\n respond_to do |format|\n format.html { redirect_to backups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vdisk = Vdisk.find(params[:id])\n @vdisk.destroy\n\n respond_to do |format|\n format.html { redirect_to vdisks_url }\n format.json { head :no_content }\n end\n end",
"def delete!\n request! :delete\n end",
"def destroy\n @server1 = Server1.find(params[:id])\n @server1.destroy\n\n respond_to do |format|\n format.html { redirect_to server1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @storage = @client.storages.find(params[:id])\n @storage.destroy\n\n respond_to do |format|\n format.html { redirect_to client_url(@client) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bootcamp = Bootcamp.find(params[:id])\n @bootcamp.destroy\n\n respond_to do |format|\n format.html { redirect_to bootcamps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n begin\n recipe = Recipe.find(params[:id])\n\n recipe.destroy\n render json: { status: 'SUCCESS', message: 'Recipe deleted!', data: recipe }, status: :ok\n rescue\n render json: { status: 'ERROR', message: 'Error finding recipe', data: {} }, status: :not_found\n end\n end",
"def destroy\n @baz1.destroy\n respond_to do |format|\n format.html { redirect_to baz1s_url, notice: \"Baz1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rack_installation.destroy\n respond_to do |format|\n format.html { redirect_to rack_installations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stone = Stone.find(params[:id])\n @stone.destroy\n\n respond_to do |format|\n format.html { redirect_to stones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @scaffold.destroy\n respond_to do |format|\n format.html { redirect_to scaffolds_url, notice: 'Scaffold was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @bdatabase = Bdatabase.find(params[:id])\n @bdatabase.destroy\n\n respond_to do |format|\n format.html { redirect_to bdatabases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @basis = Base.find(params[:id])\n @basis.destroy\n\n respond_to do |format|\n format.html { redirect_to bases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end",
"def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end",
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n # @recipe = Recipe.find(params[:id])\n # @recipe.destroy\n #\n destroy! do |format|\n # format.html { redirect_to recipes_url }\n # format.json { head :ok }\n end\n end",
"def destroy\n @climb.destroy\n respond_to do |format|\n format.html { redirect_to climbs_url, notice: 'Climb was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @basin = Basin.find(params[:id])\n @basin.destroy\n\n respond_to do |format|\n format.html { redirect_to basins_url }\n format.json { head :no_content }\n end\n end",
"def destroy(params = {})\n client.delete(\"#{endpoint(params)}/#{attributes[:id]}\")\n end",
"def destroy\n @cake = Cake.find(params[:id])\n @cake.destroy\n\n respond_to do |format|\n format.html { redirect_to cakes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cake_flavor.destroy\n respond_to do |format|\n format.html { redirect_to cake_flavors_url, notice: 'Cake flavor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] |
[
"0.74450946",
"0.69838065",
"0.6720092",
"0.65074015",
"0.6457982",
"0.64458597",
"0.64412314",
"0.64234084",
"0.6423225",
"0.6412931",
"0.6346784",
"0.6346784",
"0.6346784",
"0.6346784",
"0.63379455",
"0.6324339",
"0.63220555",
"0.630647",
"0.630647",
"0.62963164",
"0.6296077",
"0.62806976",
"0.624784",
"0.62164",
"0.6210077",
"0.6206493",
"0.62008595",
"0.61991423",
"0.6189128",
"0.61879814",
"0.6184267",
"0.61727256",
"0.61627465",
"0.6158123",
"0.61563504",
"0.6152189",
"0.613715",
"0.61368424",
"0.61264914",
"0.61243165",
"0.6123043",
"0.61225957",
"0.61185807",
"0.611836",
"0.6113691",
"0.61075944",
"0.6098786",
"0.6098786",
"0.6095148",
"0.60949874",
"0.60939986",
"0.6091223",
"0.6087868",
"0.6085995",
"0.60825723",
"0.6076657",
"0.6072762",
"0.6072727",
"0.6068116",
"0.60622907",
"0.6061757",
"0.60614294",
"0.60554457",
"0.60552025",
"0.60521954",
"0.60519254",
"0.6045098",
"0.6042867",
"0.6038186",
"0.6030094",
"0.6029507",
"0.6026705",
"0.60264033",
"0.6025726",
"0.6019465",
"0.6017749",
"0.6012737",
"0.60126704",
"0.601228",
"0.60100895",
"0.59887576",
"0.59875506",
"0.59875053",
"0.5979703",
"0.5979692",
"0.5979175",
"0.5975525",
"0.5970152",
"0.5964602",
"0.5964321",
"0.5963956",
"0.5960294",
"0.5957825",
"0.5956985",
"0.5956984",
"0.5956771",
"0.59522474",
"0.5951455",
"0.5949818",
"0.5947985"
] |
0.7643134
|
0
|
GET /daw_promos GET /daw_promos.json
|
def index
@daw_promos = DawPromo.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @promocion = Promocion.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @promocion }\n end\n end",
"def index\n @daw_matricula_promos = DawMatriculaPromo.all\n end",
"def show\n @pdevice = Pdevice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pdevice }\n end\n end",
"def show\n @promo = Promo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @promo }\n end\n end",
"def get\n\t\t\t result = Status.find_by(windmillid: params[:windmillid]) \n \t\t\trender json: [result.as_json(only: [:status,:power,:gen,:frequency,:rotor,:wind,:pitch])]\n\tend",
"def show\n @promotion_demotion = PromotionDemotion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @promotion_demotion }\n end\n end",
"def show\n @promos = Promos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @promos }\n end\n end",
"def show\n @gymnasium = Gymnasium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gymnasium }\n end\n end",
"def show\n @material_apoyo = MaterialApoyo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material_apoyo }\n end\n end",
"def show\n @rpm = Rpm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rpm }\n end\n end",
"def show\n @promotion = Promotion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @promotion }\n end\n end",
"def taken_promos\n respond_to do |format|\n @promos = Promo.get_taken_promos_for_user current_user\n format.html { render \"promos/content\" }\n end\n end",
"def lastest_promos\n last_time_milliseconds = params[:last_promos_retrieval].to_f\n if (last_time_milliseconds != 0)\n last_time = Time.at(last_time_milliseconds/1000)\n @promos = Promo.where(\"validez >= ? AND updated_at >= ?\", Time.zone.now, last_time).order(\"validez ASC\")\n else\n @promos = Promo.where(\"validez >= ? AND version >= 0\", Time.zone.now).order(\"validez ASC\")\n end\n #Rails.logger.info request.env['PATH_INFO']\n render json: @promos\n end",
"def show\n render json: @prossumer\n end",
"def show\n if @power_supply.nil?\n head :not_found\n else\n render json: @power_supply.properties\n end\n end",
"def show\n @paint_manufacturer = PaintManufacturer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paint_manufacturer }\n end\n end",
"def show\n @pro_wmall_product = Wmall::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pro_wmall_product }\n end\n end",
"def show\n @voprosy = Voprosy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @voprosy }\n end\n end",
"def show\n @remedio = Remedio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @remedio }\n end\n end",
"def show\n @powiadomienie = Powiadomienie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @powiadomienie }\n end\n end",
"def show\n render json: @vdm\n end",
"def index\n @promotions = Promotion.where(active: true)\n @all_promotions = Promotion.all\n respond_to do |format|\n format.html \n format.json { render json: @all_promotions }\n end\n end",
"def show\n @medio = Medio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @medio }\n end\n end",
"def show\n @promotersbind = Promotersbind.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @promotersbind }\n end\n end",
"def movie_data\n response = RestClient.get(\"critics.api.mks.io/movie-genres\")\n JSON.parse(response)\nend",
"def show\n render json: @promotion\n end",
"def show\n render json: @promotion\n end",
"def show\n @medio_pago = MedioPago.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medio_pago }\n end\n end",
"def show\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @premio }\n end\n end",
"def show\n @prod = Prod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @prod }\n end\n end",
"def show\n @precious_metal = PreciousMetal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @precious_metal }\n end\n end",
"def show\n @promotion = Promotion.find(params[:id], :include => [:promotion_factors, :factor_conditions, :factor_results] )\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @promotion }\n format.json { \n\t \trender :json => mapping_to_hash(@promotion, Promotion.json_mapping_table)\n\t }\n end\n end",
"def get_episode_data\n data_hash = get_episode_info(params['imdb_id'])\n\n render :json => data_hash\n end",
"def index\n @power_supplies = PowerSupply.all.to_a\n render(json: @power_supplies.map do |power_supply|\n setup_power_supply_properties power_supply\n power_supply.properties\n end)\n end",
"def show\n @moresmallarmorinfo = Moresmallarmorinfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moresmallarmorinfo }\n end\n end",
"def index\n @promos = Promo.search(params[:search])\n @promos.each do |promo|\n promo[:brand_name] = promo.brand.name\n promo.image_url = promo.image\n end\n respond_with(@promos)\n end",
"def index\n @devices = Device.all\n render json: @devices\n end",
"def index\n if params[:product_id]\n @promotions = Product.find(params[:product_id]).promotions\n else\n @promotions = Promotion.all\n end\n\n render json: @promotions\n end",
"def index\n hardware = Hardware.all\n render json: hardware.to_json(:except => [:id])\n end",
"def index\n @vdms = Vdm.all\n\n render json: @vdms\n end",
"def show\n @dns_device_assoc = DnsDeviceAssoc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dns_device_assoc }\n end\n end",
"def show\n render json: @carbon_monoxide\n end",
"def show\n json_response(@device)\n end",
"def show\n @prod = Prod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @prod }\n end\n end",
"def show\n @wager = Wager.find(params[:id])\n\n render json: @wager\n end",
"def show\n eps = EpV2.select(\"id,title,prelink\").where(\"show_id = #{params[:id]}\")\n .order(\"id DESC\").paginate(:page => params[:page], :per_page => 20)\n\n render :json => eps.to_json\n end",
"def show\n @osoba = Osoba.find(params[:id])\n\n render json: @osoba\n end",
"def index\n @powiadomienia = Powiadomienie.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @powiadomienia }\n end\n end",
"def show\n @produto = Produto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @produto }\n end\n end",
"def show\n @round_robin_promo = RoundRobinPromo.find(params[:id])\n \n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @round_robin_promo }\n end\n end",
"def show\n render json: @printer.map_to_custom_printer\n end",
"def show\n @medida = Medida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medida }\n end\n end",
"def index\n @denuncia = Denuncium.all\n\n render json: @denuncia\n end",
"def show\n @home_promotion = Home::Promotion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @home_promotion }\n end\n end",
"def show\n @promocao = Promocao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @promocao }\n end\n end",
"def show\n @derpu = Derpu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @derpu }\n end\n end",
"def getmill\n\tformid = Windmill.where(windformid: params[:id])\n\tif formid.present?\n render json: formid.as_json(only:[:no])\n\telse\n\t\trender json: {massage: 'Windform not found'}\n\tend\nend",
"def show\n @memory = Memory.find(params[:id])\n \n Spira.add_repository! :hardware, RDF::Mongo::Repository.new\n @memory_rdf = SPARQL.execute(\"SELECT * WHERE { <#{MemoryRdf.for(@memory.item).subject.to_s}> ?p ?o }\", MemoryRdf.repository)\n \n @recommendations = Semantics::Recommendations.new.for_memory(@memory)\n\n @computer = Semantics::Recommendations.new.build_computer(@memory)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @memory }\n end\n end",
"def index\n @carbon_monoxides = CarbonMonoxide.all\n render json: @carbon_monoxides\n end",
"def show\n @propuesta = Propuesta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @propuesta }\n end\n end",
"def show\n @unidade_medida = UnidadeMedida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unidade_medida }\n end\n end",
"def index\n @post_prod_dpts = PostProdDpt.all\n\n render json: @post_prod_dpts\n end",
"def show\n @propose = Propose.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @propose }\n end\n end",
"def show\n @os_release = OsRelease.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @os_release }\n end\n end",
"def show\n @medicamento = Medicamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medicamento }\n end\n end",
"def show\n @hardware = Hardware.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @hardware }\n end\n end",
"def show\n render json: @processo\n end",
"def show\n @mac = Mac.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mac }\n end\n end",
"def show\n @promotion_type = PromotionType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @promotion_type }\n end\n end",
"def index\n @dinos = Dino.where(query_params)\n render json: @dinos\n end",
"def show\n render json: @post_prod_dpt\n end",
"def show\n @mugshot = Mugshot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mugshot }\n end\n end",
"def index\n @movers = Mover.all\n\n render json: @movers\n end",
"def create\n megam_rest.post_promos(to_hash) #WONT BE USED AS OF NOW\n end",
"def index\n @prospecto_meta_mediano_plazos = ProspectoMetaMedianoPlazo.all\n end",
"def index\n @dns_device_assocs = DnsDeviceAssoc.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dns_device_assocs }\n end\n end",
"def show\n @unidade_metrica = UnidadeMetrica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unidade_metrica }\n end\n end",
"def show\n @monnaie = Monnaie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @monnaie }\n end\n end",
"def show\n @estate_agent = EstateAgent.find(params[:id])\n @properties = Property.where(\"estate_agent_id = ?\", @estate_agent.id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @properties }\n end\n end",
"def show\n if @cmm.nil?\n head :not_found\n else\n render json: @cmm.properties\n end\n end",
"def show\n @microposr = Microposr.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @microposr }\n end\n end",
"def property_details\n details = VendorApi.new(params[:udprn].to_i, nil, params[:vendor_id].to_i).property_details\n render json: details, status: 200\n end",
"def show\n @turbo_memoid = TurboMemoid.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @turbo_memoid }\n end\n end",
"def index\n @unidade_medidas = UnidadeMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @unidade_medidas }\n end\n end",
"def index\n @processos = Processo.all\n\n render json: @processos\n end",
"def show\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end",
"def show\n @magnetic_finger_print = MagneticFingerPrint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @magnetic_finger_print }\n end\n end",
"def show\n render json: @gpsd\n end",
"def show\n @materia = Materia.find(params[:id])\n\n render json: @materia\n end",
"def show\n @printing_screen = PrintingScreen.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @printing_screen }\n end\n end",
"def index\n if params[:printer_type].present?\n @printers = Printer.where(printer_type: params[:printer_type])\n else\n @printers = Printer.all\n end\n\n render json: @printers\n end",
"def show\n @outdoor = Outdoor.find(params[:id])\n @json = Outdoor.find(params[:id]).to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @outdoor }\n end\n end",
"def show\n @produccion = Produccion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @produccion }\n end\n end",
"def show\n @produccion = Produccion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @produccion }\n end\n end",
"def show\n @productonegocio = Productonegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @productonegocio }\n end\n end",
"def show\n @medusa_premis_representation_object = MedusaPremis::RepresentationObject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medusa_premis_representation_object }\n end\n end",
"def index\n @demots = Demot.where(active: true).page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @demots }\n end\n end",
"def show\n @mapeamento = Mapeamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mapeamento }\n end\n end",
"def show\n @profesore = Profesore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @profesore }\n end\n end",
"def show\n @preguntum = Preguntum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @preguntum }\n end\n end"
] |
[
"0.6421152",
"0.62996143",
"0.6150884",
"0.6138804",
"0.6123474",
"0.6080514",
"0.60380435",
"0.59345794",
"0.5912635",
"0.5878894",
"0.5827744",
"0.5813213",
"0.58032966",
"0.5799405",
"0.57931346",
"0.57843083",
"0.57540596",
"0.57470965",
"0.57324034",
"0.57320577",
"0.57131785",
"0.5701721",
"0.56984884",
"0.56960297",
"0.56897783",
"0.5679516",
"0.5679516",
"0.56612635",
"0.5638416",
"0.56365305",
"0.56351876",
"0.5634287",
"0.56325984",
"0.5625211",
"0.5624218",
"0.56152046",
"0.56115866",
"0.56068856",
"0.5606738",
"0.55890065",
"0.5585882",
"0.55808705",
"0.55796343",
"0.55766076",
"0.55750644",
"0.5574613",
"0.5569426",
"0.5560643",
"0.55499095",
"0.55416495",
"0.55403394",
"0.5538735",
"0.55385506",
"0.55380934",
"0.55348676",
"0.5531167",
"0.5525584",
"0.5514641",
"0.5514108",
"0.5503835",
"0.5498082",
"0.5497671",
"0.5489021",
"0.5484938",
"0.54841936",
"0.54838926",
"0.54776406",
"0.5473078",
"0.54641205",
"0.5461993",
"0.54571337",
"0.54558283",
"0.54538137",
"0.544921",
"0.5445217",
"0.54330254",
"0.5429588",
"0.5429427",
"0.54284525",
"0.54220855",
"0.54188734",
"0.5418259",
"0.5417699",
"0.54133373",
"0.54124194",
"0.54110694",
"0.54094964",
"0.5400158",
"0.5397068",
"0.5394867",
"0.5387405",
"0.53872776",
"0.5385998",
"0.5385998",
"0.53852427",
"0.5383183",
"0.53829926",
"0.5381858",
"0.53789526",
"0.5374006"
] |
0.67679787
|
0
|
GET /daw_promos/1 GET /daw_promos/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @promocion = Promocion.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @promocion }\n end\n end",
"def index\n @daw_promos = DawPromo.all\n end",
"def show\n @pdevice = Pdevice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pdevice }\n end\n end",
"def get\n\t\t\t result = Status.find_by(windmillid: params[:windmillid]) \n \t\t\trender json: [result.as_json(only: [:status,:power,:gen,:frequency,:rotor,:wind,:pitch])]\n\tend",
"def show\n @promo = Promo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @promo }\n end\n end",
"def show\n @rpm = Rpm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rpm }\n end\n end",
"def show\n @promotion_demotion = PromotionDemotion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @promotion_demotion }\n end\n end",
"def show\n @gymnasium = Gymnasium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gymnasium }\n end\n end",
"def index\n @daw_matricula_promos = DawMatriculaPromo.all\n end",
"def show\n @promos = Promos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @promos }\n end\n end",
"def show\n @voprosy = Voprosy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @voprosy }\n end\n end",
"def lastest_promos\n last_time_milliseconds = params[:last_promos_retrieval].to_f\n if (last_time_milliseconds != 0)\n last_time = Time.at(last_time_milliseconds/1000)\n @promos = Promo.where(\"validez >= ? AND updated_at >= ?\", Time.zone.now, last_time).order(\"validez ASC\")\n else\n @promos = Promo.where(\"validez >= ? AND version >= 0\", Time.zone.now).order(\"validez ASC\")\n end\n #Rails.logger.info request.env['PATH_INFO']\n render json: @promos\n end",
"def show\n @promotion = Promotion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @promotion }\n end\n end",
"def show\n @material_apoyo = MaterialApoyo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material_apoyo }\n end\n end",
"def show\n @paint_manufacturer = PaintManufacturer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paint_manufacturer }\n end\n end",
"def show\n @remedio = Remedio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @remedio }\n end\n end",
"def show\n @precious_metal = PreciousMetal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @precious_metal }\n end\n end",
"def show\n @medio = Medio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @medio }\n end\n end",
"def show\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @premio }\n end\n end",
"def show\n if @power_supply.nil?\n head :not_found\n else\n render json: @power_supply.properties\n end\n end",
"def show\n @hardware = Hardware.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @hardware }\n end\n end",
"def show\n @powiadomienie = Powiadomienie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @powiadomienie }\n end\n end",
"def show\n @mac = Mac.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mac }\n end\n end",
"def show\n @prod = Prod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @prod }\n end\n end",
"def index\n hardware = Hardware.all\n render json: hardware.to_json(:except => [:id])\n end",
"def show\n @pro_wmall_product = Wmall::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pro_wmall_product }\n end\n end",
"def show\n @medio_pago = MedioPago.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medio_pago }\n end\n end",
"def show\n @promotersbind = Promotersbind.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @promotersbind }\n end\n end",
"def show\n @microposr = Microposr.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @microposr }\n end\n end",
"def show\n @dns_device_assoc = DnsDeviceAssoc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dns_device_assoc }\n end\n end",
"def show\n render json: @prossumer\n end",
"def show\n @os_release = OsRelease.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @os_release }\n end\n end",
"def show\n render json: @vdm\n end",
"def show\n @prod = Prod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @prod }\n end\n end",
"def show\n @memory = Memory.find(params[:id])\n \n Spira.add_repository! :hardware, RDF::Mongo::Repository.new\n @memory_rdf = SPARQL.execute(\"SELECT * WHERE { <#{MemoryRdf.for(@memory.item).subject.to_s}> ?p ?o }\", MemoryRdf.repository)\n \n @recommendations = Semantics::Recommendations.new.for_memory(@memory)\n\n @computer = Semantics::Recommendations.new.build_computer(@memory)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @memory }\n end\n end",
"def show\n @moresmallarmorinfo = Moresmallarmorinfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moresmallarmorinfo }\n end\n end",
"def show\n json_response(@device)\n end",
"def show\n @osoba = Osoba.find(params[:id])\n\n render json: @osoba\n end",
"def show\n @produto = Produto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @produto }\n end\n end",
"def movie_data\n response = RestClient.get(\"critics.api.mks.io/movie-genres\")\n JSON.parse(response)\nend",
"def index\n @devices = Device.all\n render json: @devices\n end",
"def show\n @round_robin_promo = RoundRobinPromo.find(params[:id])\n \n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @round_robin_promo }\n end\n end",
"def show\n @preguntum = Preguntum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @preguntum }\n end\n end",
"def show\n @derpu = Derpu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @derpu }\n end\n end",
"def show\n @promotion_type = PromotionType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @promotion_type }\n end\n end",
"def show\n @unidade_metrica = UnidadeMetrica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unidade_metrica }\n end\n end",
"def show\n @magnetic_finger_print = MagneticFingerPrint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @magnetic_finger_print }\n end\n end",
"def show\n @home_promotion = Home::Promotion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @home_promotion }\n end\n end",
"def show\n @wager = Wager.find(params[:id])\n\n render json: @wager\n end",
"def show\n @repuestum = Repuestum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repuestum }\n end\n end",
"def show\n @device = Device.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @device }\n end\n end",
"def show\n @device = Device.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @device }\n end\n end",
"def show\n @device = Device.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @device }\n end\n end",
"def show\n @microposst = Microposst.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @microposst }\n end\n end",
"def show\n @promotion = Promotion.find(params[:id], :include => [:promotion_factors, :factor_conditions, :factor_results] )\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @promotion }\n format.json { \n\t \trender :json => mapping_to_hash(@promotion, Promotion.json_mapping_table)\n\t }\n end\n end",
"def show\n @monnaie = Monnaie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @monnaie }\n end\n end",
"def show\n @metum = Metum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @metum }\n end\n end",
"def getmill\n\tformid = Windmill.where(windformid: params[:id])\n\tif formid.present?\n render json: formid.as_json(only:[:no])\n\telse\n\t\trender json: {massage: 'Windform not found'}\n\tend\nend",
"def show\n @medicamento = Medicamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medicamento }\n end\n end",
"def show\n eps = EpV2.select(\"id,title,prelink\").where(\"show_id = #{params[:id]}\")\n .order(\"id DESC\").paginate(:page => params[:page], :per_page => 20)\n\n render :json => eps.to_json\n end",
"def show\n render json: @carbon_monoxide\n end",
"def show\n render json: @promotion\n end",
"def show\n render json: @promotion\n end",
"def index\n @promotions = Promotion.where(active: true)\n @all_promotions = Promotion.all\n respond_to do |format|\n format.html \n format.json { render json: @all_promotions }\n end\n end",
"def show\n @medida = Medida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medida }\n end\n end",
"def show\n render json: @processo\n end",
"def get_episode_data\n data_hash = get_episode_info(params['imdb_id'])\n\n render :json => data_hash\n end",
"def show\n @turbo_memoid = TurboMemoid.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @turbo_memoid }\n end\n end",
"def show\n @monit = Monit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @monit }\n end\n end",
"def show\n @productonegocio = Productonegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @productonegocio }\n end\n end",
"def show\n @unidade_medida = UnidadeMedida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unidade_medida }\n end\n end",
"def show\n @memory = Memory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @memory }\n end\n end",
"def show\n @promocao = Promocao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @promocao }\n end\n end",
"def show\n @mugshot = Mugshot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mugshot }\n end\n end",
"def show\n @hot_water_demand = HotWaterDemand.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hot_water_demand }\n end\n end",
"def show\n @distro = Distro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @distro }\n end\n end",
"def show\n @distro = Distro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @distro }\n end\n end",
"def index\n @vdms = Vdm.all\n\n render json: @vdms\n end",
"def show\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end",
"def show\n @pologeno = Pologeno.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pologeno }\n end\n end",
"def taken_promos\n respond_to do |format|\n @promos = Promo.get_taken_promos_for_user current_user\n format.html { render \"promos/content\" }\n end\n end",
"def show\n @odontologo = Odontologo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @odontologo }\n end\n end",
"def show\n @printing_screen = PrintingScreen.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @printing_screen }\n end\n end",
"def show\n @propuesta = Propuesta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @propuesta }\n end\n end",
"def index\n @powiadomienia = Powiadomienie.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @powiadomienia }\n end\n end",
"def show\n @metric = Metric.find(params[:id])\n\n render json: @metric\n end",
"def show\n @propose = Propose.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @propose }\n end\n end",
"def show\n @powerchip = Powerchip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @powerchip }\n end\n end",
"def index\n if params[:product_id]\n @promotions = Product.find(params[:product_id]).promotions\n else\n @promotions = Promotion.all\n end\n\n render json: @promotions\n end",
"def show\n @denuncium = Denuncium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @denuncium }\n end\n end",
"def show\n @diagnoz = Diagnoz.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @diagnoz }\n end\n end",
"def show\n @pto = Pto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pto }\n end\n end",
"def index\n @carbon_monoxides = CarbonMonoxide.all\n render json: @carbon_monoxides\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dbh_measurement }\n end\n end",
"def show\n @pinit = Pinit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pinit }\n end\n end",
"def index\n @power_supplies = PowerSupply.all.to_a\n render(json: @power_supplies.map do |power_supply|\n setup_power_supply_properties power_supply\n power_supply.properties\n end)\n end",
"def show\r\n @imobiliaria = Imobiliaria.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.json { render json: @imobiliaria }\r\n end\r\n end",
"def show\n @produccion = Produccion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @produccion }\n end\n end",
"def show\n @produccion = Produccion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @produccion }\n end\n end",
"def show\n @monel = Monel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @monel }\n end\n end",
"def show\n @observacao_vocacionada = ObservacaoVocacionada.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observacao_vocacionada }\n end\n end"
] |
[
"0.6606121",
"0.6514304",
"0.640169",
"0.6317443",
"0.6274082",
"0.61593235",
"0.6122043",
"0.6120167",
"0.61056894",
"0.609848",
"0.6025202",
"0.6003655",
"0.59652865",
"0.5956525",
"0.5950266",
"0.59340936",
"0.5903782",
"0.58972895",
"0.58915377",
"0.5888215",
"0.58862895",
"0.5857947",
"0.5833558",
"0.5828729",
"0.5826016",
"0.5807511",
"0.5802462",
"0.57925475",
"0.5788651",
"0.5787187",
"0.57770795",
"0.57685065",
"0.5767829",
"0.57642543",
"0.57634103",
"0.57601446",
"0.5729459",
"0.5728505",
"0.5726209",
"0.5719365",
"0.57131284",
"0.570868",
"0.57065934",
"0.5704815",
"0.5704296",
"0.5683606",
"0.5680304",
"0.56748927",
"0.56703925",
"0.5665699",
"0.5665196",
"0.5665196",
"0.5665196",
"0.5657342",
"0.5653897",
"0.56535435",
"0.5651498",
"0.56455076",
"0.56431293",
"0.56406844",
"0.5636117",
"0.56359243",
"0.56359243",
"0.5632872",
"0.5624085",
"0.56234145",
"0.5616505",
"0.5615832",
"0.5615088",
"0.56148785",
"0.5610445",
"0.5604331",
"0.56043255",
"0.55969125",
"0.559136",
"0.5590517",
"0.5590517",
"0.5589426",
"0.5583744",
"0.55807966",
"0.55795187",
"0.5578697",
"0.55773365",
"0.5575482",
"0.5568274",
"0.5567493",
"0.5566452",
"0.5563986",
"0.5557976",
"0.5555678",
"0.5555246",
"0.5548095",
"0.55453944",
"0.5544044",
"0.554073",
"0.5536983",
"0.55365664",
"0.5536438",
"0.5536438",
"0.55364287",
"0.5535197"
] |
0.0
|
-1
|
POST /daw_promos POST /daw_promos.json
|
def create
@daw_promo = DawPromo.new(daw_promo_params)
respond_to do |format|
if @daw_promo.save
format.html { redirect_to @daw_promo, notice: 'Daw promo was successfully created.' }
format.json { render :show, status: :created, location: @daw_promo }
else
format.html { render :new }
format.json { render json: @daw_promo.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n megam_rest.post_promos(to_hash) #WONT BE USED AS OF NOW\n end",
"def create\n @daw_matricula_promo = DawMatriculaPromo.new(daw_matricula_promo_params)\n\n respond_to do |format|\n if @daw_matricula_promo.save\n format.html { redirect_to @daw_matricula_promo, notice: 'Daw matricula promo was successfully created.' }\n format.json { render :show, status: :created, location: @daw_matricula_promo }\n else\n format.html { render :new }\n format.json { render json: @daw_matricula_promo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @promocion = Promocion.new(params[:promocion])\n\n respond_to do |format|\n if @promocion.save\n format.html { redirect_to @promocion, :notice => 'Promocion was successfully created.' }\n format.json { render json: @promocion, status: :created, location: @promocion }\n else\n format.html { render :action => \"new\" }\n format.json { render json: @promocion.errors }\n end\n end\n end",
"def create\n @promos = Promos.new(params[:promos])\n\n respond_to do |format|\n if @promos.save\n flash[:notice] = 'Promos was successfully created.'\n format.html { redirect_to(@promos) }\n format.xml { render :xml => @promos, :status => :created, :location => @promos }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @promos.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @promocion = Promocion.new(promocion_params)\n\n respond_to do |format|\n if @promocion.save\n format.html { redirect_to @promocion, notice: 'Promocion ha sido creado.' }\n format.json { render :show, status: :created, location: @promocion }\n else\n format.html { render :new }\n format.json { render json: @promocion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @promotion = Promotion.new(promotion_params)\n\n if @promotion.save\n render json: @promotion, status: :created, location: @promotion\n else\n render json: @promotion.errors, status: :unprocessable_entity\n end\n end",
"def create\n @promo = Promo.new(params[:promo])\n\n respond_to do |format|\n if @promo.save\n format.html { redirect_to @promo, notice: 'Promo was successfully created.' }\n format.json { render json: @promo, status: :created, location: @promo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @promo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def daw_matricula_promo_params\n params.require(:daw_matricula_promo).permit(:daw_promo_id)\n end",
"def create\n @power_order = PowerOrder.new(power_order_params)\n @power_order.save\n render json: @power_order\n end",
"def create\n @propuestum = Propuestum.new(propuestum_params)\n\n respond_to do |format|\n if @propuestum.save\n format.html { redirect_to @propuestum, notice: 'Propuestum was successfully created.' }\n format.json { render :show, status: :created, location: @propuestum }\n else\n format.html { render :new }\n format.json { render json: @propuestum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def daw_promo_params\n params.require(:daw_promo).permit(:pro_nombre, :pro_porcentaje, :pro_fechaini, :pro_fechafin, :pro_tipopromocion, :pro_estado, :daw_alianza_id)\n end",
"def create\n megam_rest.post_appdefn(to_hash)\n end",
"def create\n @promo = Promo.new(params[:promo])\n brand = @promo.brand\n @promo.stores = brand.stores\n respond_to do |format|\n if @promo.save\n format.html { redirect_to @promo, notice: 'Promo was successfully created.' }\n format.json { render json: @promo, status: :created, location: @promo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @promo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @wod = Wod.new(wod_params)\n\n if @wod.save\n render json: @wod, status: :created\n else\n render json: @wod.errors, status: :unprocessable_entity\n end\n end",
"def index\n @daw_promos = DawPromo.all\n end",
"def prospecto_meta_mediano_plazo_params\n params.require(:prospecto_meta_mediano_plazo).permit(:prospecto_id, :meta_mediana, :estatus)\n end",
"def create\n @admin_promo = Admin::Promo.new(admin_promo_params)\n\n respond_to do |format|\n if @admin_promo.save\n format.html { redirect_to session['previous_url'] || admin_promos_path, notice: 'Promozioni è stato creato con successo.' }\n format.json { render :show, status: :created, location: @admin_promo }\n else\n format.html { render :new }\n format.json { render json: @admin_promo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gymnasium = Gymnasium.new(params[:gymnasium])\n\n respond_to do |format|\n if @gymnasium.save\n format.html { redirect_to @gymnasium, notice: 'Gymnasium was successfully created.' }\n format.json { render json: @gymnasium, status: :created, location: @gymnasium }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gymnasium.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @promocao = Promocao.new(params[:promocao])\n\n respond_to do |format|\n if @promocao.save\n format.html { redirect_to(@promocao, :notice => 'Promocção criada com sucesso!') }\n format.xml { render :xml => @promocao, :status => :created, :location => @promocao }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @promocao.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @promotion_demotion = PromotionDemotion.new(params[:promotion_demotion])\n\n respond_to do |format|\n if @promotion_demotion.save\n format.html { redirect_to :back, notice: 'Promotion demotion was successfully created.' }\n format.json { render json: @promotion_demotion, status: :created, location: @promotion_demotion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @promotion_demotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @promotion = Promotion.new(params[:promotion])\n\n respond_to do |format|\n if @promotion.save\n format.html { redirect_to @promotion, notice: 'Promotion was successfully created.' }\n format.json { render json: @promotion, status: :created, location: @promotion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @proposta = Propostum.new(propostum_params)\n\n respond_to do |format|\n if @proposta.save\n format.html { redirect_to @proposta, notice: 'Propostum was successfully created.' }\n format.json { render :show, status: :created, location: @proposta }\n else\n format.html { render :new }\n format.json { render json: @proposta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @promotion = Promotion.new(promotion_params)\n authorize @promotion\n if @promotion.save\n render json: {promotion: @promotion, status: :created }\n else\n render json: {errors: @promotion.errors, status: :unprocessable_entity }, status: :unprocessable_entity\n end\n end",
"def create\n @demob = Demob.new(demob_params)\n\n respond_to do |format|\n if @demob.save\n format.html { redirect_to demob_url(@demob), notice: \"Demob was successfully created.\" }\n format.json { render :show, status: :created, location: @demob }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @demob.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @promotion = Promotion.new(promotion_params)\n\n respond_to do |format|\n if @promotion.save\n format.html { redirect_to @promotion, notice: 'Promotion was successfully created.' }\n format.json { render :show, status: :created, location: @promotion }\n else\n format.html { render :new }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @promotion = Promotion.new(promotion_params)\n\n respond_to do |format|\n if @promotion.save\n format.html { redirect_to @promotion, notice: 'Promotion was successfully created.' }\n format.json { render :show, status: :created, location: @promotion }\n else\n format.html { render :new }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @carbon_monoxide = CarbonMonoxide.new(carbon_monoxide_params)\n\n if @carbon_monoxide.save\n render json: @carbon_monoxide, status: :created, location: @carbon_monoxide\n else\n render json: @carbon_monoxide.errors, status: :unprocessable_entity\n end\n \n end",
"def create\r\n @promotion = Promotion.new(params[:promotion])\r\n\r\n respond_to do |format|\r\n if @promotion.save\r\n format.html { redirect_to @promotion, notice: 'Promotion was successfully created.' }\r\n format.json { render json: @promotion, status: :created, location: @promotion }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n\n\n\n @promotion = Promotion.new(promotion_params)\n respond_to do |format|\n if @promotion.save\n format.html { redirect_to adminpromotions_path, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @adminpromotion }\n else\n format.html { render :new }\n format.json { render json: @adminpromotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @medio = Medio.new(params[:medio])\n\n respond_to do |format|\n if @medio.save\n format.html { redirect_to @medio, :notice => 'Medio was successfully created.' }\n format.json { render :json => @medio, :status => :created, :location => @medio }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @medio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @dino = Dino.new(dino_params)\n\n if @dino.save\n render json: @dino, status: :created, location: @dino\n else\n render json: @dino.errors, status: :unprocessable_entity\n end\n end",
"def create\r\n @registro_medicion = Api::RegistroMedicion.new(registro_medicion_params)\r\n @registro_medicion.microcontrolador = Api::Microcontrolador.find_or_create_by(nivel: params[:nivel], area: params[:area])\r\n #TODO Mande que tipo de variable ambiental es\r\n\r\n @registro_medicion.variable_ambiental = Api::VariableAmbiental.where(tipo: params[:tipo]).first\r\n\r\n if @registro_medicion.save && Api::RegistroMedicionesHelper.verify(@registro_medicion, params[:promedio])\r\n render json: @registro_medicion.to_json, status: :ok\r\n else\r\n render :json => { :mssg => 'Hubo un error creando el registro medicion.' }, status: :unprocessable_entity\r\n end\r\n end",
"def create\n @prospecto_meta_mediano_plazo = ProspectoMetaMedianoPlazo.new(prospecto_meta_mediano_plazo_params)\n\n respond_to do |format|\n if @prospecto_meta_mediano_plazo.save\n format.html { redirect_to @prospecto_meta_mediano_plazo, notice: 'Prospecto meta mediano plazo was successfully created.' }\n format.json { render :show, status: :created, location: @prospecto_meta_mediano_plazo }\n else\n format.html { render :new }\n format.json { render json: @prospecto_meta_mediano_plazo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @profesor = Profesor.new(profesor_params)\n\n if @profesor.save\n render json: @profesor, status: :created, location: @profesor\n else\n render json: @profesor.errors, status: :unprocessable_entity\n end\n end",
"def create\n @powiadomienie = Powiadomienie.new(params[:powiadomienie])\n\n respond_to do |format|\n if @powiadomienie.save\n format.html { redirect_to @powiadomienie, notice: 'Powiadomienie was successfully created.' }\n format.json { render json: @powiadomienie, status: :created, location: @powiadomienie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @powiadomienie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n megam_rest.post_appreq(to_hash)\n end",
"def create\n @pockemon = Pockemon.new(pockemon_params)\n\n respond_to do |format|\n if @pockemon.save\n format.html { redirect_to @pockemon, notice: 'Pockemon was successfully created.' }\n format.json { render :show, status: :created, location: @pockemon }\n else\n format.html { render :new }\n format.json { render json: @pockemon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post_prod_dpt = PostProdDpt.new(post_prod_dpt_params)\n\n if @post_prod_dpt.save\n render json: @post_prod_dpt, status: :created, location: @post_prod_dpt\n else\n render json: @post_prod_dpt.errors, status: :unprocessable_entity\n end\n end",
"def create\n @premio = Premio.new(params[:premio])\n\n respond_to do |format|\n if @premio.save\n format.html { redirect_to @premio, :notice => 'Premio was successfully created.' }\n format.json { render :json => @premio, :status => :created, :location => @premio }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n # {\"vcpus\": 1, \"disk\": 1, \"name\": \"test\", \"rxtx_factor\": 1, \"OS-FLV-EXT-DATA:ephemeral\": 1, \"ram\": 512, \"id\": 6, \"swap\": 1}}'\n @flavor = compute.create_flavor(\"rxtx_factor\"=>1,\"OS-FLV-EXT-DATA:ephemeral\"=>params[:ephemeral],:vcpus=>params[:vcpus],:disk=>params[:disk],:name=>params[:name],:ram=>params[:ram],:id=>params[:id],:swap=>params[:swap])\n\n respond_to do |format|\n format.html { redirect_to flavors_path, :notice => 'Flavor was successfully created.' }\n format.json { render :json => @flavor, :status => :created, :location => @flavor }\n end\n end",
"def create\n product_name = competitor_params[:title]\n honestbee_datas = get_honestbee_data (product_name)\n predict_catalog = get_predict_catalog ( product_name )\n save_data_in_postgres (predict_catalog)\n render :json => honestbee_datas\n end",
"def create\n @device = Device.create!(device_params)\n json_response(@device, :created)\n end",
"def create\n @precious_metal = PreciousMetal.new(params[:precious_metal])\n\n respond_to do |format|\n if @precious_metal.save\n format.html { redirect_to @precious_metal, :notice => 'Precious metal was successfully created.' }\n format.json { render :json => @precious_metal, :status => :created, :location => @precious_metal }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @precious_metal.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @device.browsers.create!(browser_params)\n json_response(@device, :created)\n end",
"def set_daw_promo\n @daw_promo = DawPromo.find(params[:id])\n end",
"def new\n @pdevice = Pdevice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pdevice }\n end\n end",
"def create\n @produto = Produto.create(produto_params)\n respond_with @produto\n end",
"def create\n @promotion = Promotion.new(promotion_params)\n\n respond_to do |format|\n if @promotion.save\n format.html {redirect_to @promotion, notice: 'Promotion was successfully created.'}\n format.json {render :show, status: :created, location: @promotion}\n else\n format.html {render :new}\n format.json {render json: @promotion.errors, status: :unprocessable_entity}\n end\n end\n end",
"def create\n @plasmid_probe = PlasmidProbe.new(plasmid_probe_params)\n\n respond_to do |format|\n if @plasmid_probe.save\n format.html { redirect_to @plasmid_probe, notice: 'Plasmid probe was successfully created.' }\n format.json { render action: 'show', status: :created, location: @plasmid_probe }\n else\n format.html { render action: 'new' }\n format.json { render json: @plasmid_probe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @prestamo = Prestamo.new(prestamo_params)\n\n respond_to do |format|\n if @prestamo.save\n format.html { redirect_to @prestamo, notice: \"Prestamo was successfully created.\" }\n format.json { render :show, status: :created, location: @prestamo }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @prestamo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(resource, params)\n case resource\n when \"pedidos\", \"place_order\", \"new_order\" then url = \"/pedidos\"\n when \"envios\", \"shipping\" then url = \"/envios\"\n else url = \"/#{resource}\"\n end\n\n post_request(url, params)\n end",
"def create\n @ware_house = WareHouse.new(ware_house_params)\n\n respond_to do |format|\n if @ware_house.save\n format.html { redirect_to @ware_house, notice: 'Ware house was successfully created.' }\n format.json { render :show, status: :created, location: @ware_house }\n else\n format.html { render :new }\n format.json { render json: @ware_house.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @premio_manual = PremioManual.new(premio_manual_params)\n\n respond_to do |format|\n if @premio_manual.save\n format.html { redirect_to @premio_manual, notice: 'Se ha creado correctamente.' }\n format.json { render :show, status: :created, location: @premio_manual }\n else\n format.html { render :new }\n format.json { render json: @premio_manual.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @promotion = Promotion.new(promotion_params)\n check_unlimited\n @promotion.advertiser = current_advertiser\n \n respond_to do |format|\n if @promotion.save\n format.html { redirect_to @promotion, notice: 'Promotion was successfully created.' }\n format.json { render :show, status: :created, location: @promotion }\n else\n format.html { render :new }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @wombat = Wombat.new(wombat_params)\n\n respond_to do |format|\n if @wombat.save\n format.html { redirect_to @wombat, notice: 'Wombat was successfully created.' }\n format.json { render :show, status: :created, location: @wombat }\n else\n format.html { render :new }\n format.json { render json: @wombat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @medio_pago = MedioPago.new({ :medio_pago => params[:medio_pago], :odontologo_id => params[:odontologo_id] })\n #@medio_pago = MedioPago.new(params[:medio_pago])\n\n respond_to do |format|\n if @medio_pago.save\n format.html { redirect_to @medio_pago, notice: 'Medio pago was successfully created.' }\n format.json { render json: @medio_pago, status: :created, location: @medio_pago }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medio_pago.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @property = Property.new(params[:property])\n\n respond_to do |format|\n if @property.save\n users = User.all\n users.each { |u|\n options = {\n :registration_id => u.registration_id,\n :message => \"New property added to Property Market!\",\n :id => @property.id,\n :name => @property.name,\n :ptype => @property.ptype,\n :collapse_key => @property.id.to_s\n }\n puts options.inspect\n response = SpeedyC2DM::API.send_notification(options)\n puts response.inspect\n }\n \n\n \n format.html { redirect_to @property, notice: 'Property was successfully created.' }\n format.json { render json: @property, status: :created, location: @property }\n else\n format.html { render action: \"new\" }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @firmware = Firmware.new(firmware_params)\n\n respond_to do |format|\n if @firmware.save\n format.json { render json: {\n status: \"ok\"\n },\n status: :ok\n }\n else\n format.html { render :new }\n format.json { render json: @firmware.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @premio = Premio.new(params[:premio])\n\n respond_to do |format|\n if @premio.save\n format.html { redirect_to @premio, notice: 'Premio was successfully created.' }\n format.json { render json: @premio, status: :created, location: @premio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @premio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @prospecto = Prospecto.new(prospecto_params)\n\n respond_to do |format|\n if @prospecto.save\n format.html { redirect_to @prospecto, notice: 'Prospecto was successfully created.' }\n format.json { render :show, status: :created, location: @prospecto }\n else\n format.html { render :new }\n format.json { render json: @prospecto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # @printer = Printer.new(printer_params)\n @printer = Printer.build_from_custom_printer(printer_params)\n\n # see if printer already exists\n @existing_printers = Printer.where(printer_type: @printer.printer_type,\n url: @printer.url)\n if @existing_printers.length > 0\n return_data = {error_message: \"Printer already exists\", return_code: 400}\n render json: return_data, :status => return_data[:return_code] and return\n end\n \n # validate the printer data\n adapter = @printer.get_adapter\n return_data = adapter.validate_connection(@printer)\n\n # bail out and return error\n if 200 != return_data[:return_code]\n render json: return_data, :status => return_data[:return_code] and return\n end\n\n if @printer.save\n adapter.loadProductData(@printer)\n render json: @printer.map_to_custom_printer, status: :created\n else\n render json: @printer.errors, status: :unprocessable_entity\n end\n end",
"def create\n @prospecto_marca = ProspectoMarca.new(prospecto_marca_params)\n\n respond_to do |format|\n if @prospecto_marca.save\n format.html { redirect_to @prospecto_marca, notice: 'Prospecto marca was successfully created.' }\n format.json { render :show, status: :created, location: @prospecto_marca }\n else\n format.html { render :new }\n format.json { render json: @prospecto_marca.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @vdm = Vdm.new(vdm_params)\n\n if @vdm.save\n render json: @vdm, status: :created, location: @vdm\n else\n render json: @vdm.errors, status: :unprocessable_entity\n end\n end",
"def index\n @daw_matricula_promos = DawMatriculaPromo.all\n end",
"def create\n @padrao = Padrao.new(padrao_params)\n\n respond_to do |format|\n if @padrao.save\n format.html { redirect_to @padrao, notice: 'Padrao was successfully created.' }\n format.json { render action: 'show', status: :created, location: @padrao }\n else\n format.html { render action: 'new' }\n format.json { render json: @padrao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @printer = Printer.new(printer_params)\n\n respond_to do |format|\n if @printer.save\n format.html { redirect_to root_path }\n format.json { render :show, status: :created, location: @printer }\n else\n format.html { render :new }\n format.json { render json: @printer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @osoba = Osoba.new(params[:osoba])\n\n if @osoba.save\n render json: @osoba, status: :created, location: @osoba\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end",
"def create\n @paint_manufacturer = PaintManufacturer.new(params[:paint_manufacturer])\n\n respond_to do |format|\n if @paint_manufacturer.save\n format.html { redirect_to @paint_manufacturer, notice: 'Paint manufacturer was successfully created.' }\n format.json { render json: @paint_manufacturer, status: :created, location: @paint_manufacturer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @paint_manufacturer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n @empresa = Empresa.find(params[:empresa_id]) \n @producto = @empresa.productos.find(params[:producto_id])\n @preparar_mate = @producto.preparar_mates.build(preparar_mate_params)\n respond_to do |format|\n if @preparar_mate.save\n format.html { redirect_to empresa_producto_preparar_mates_path, notice: 'Preparar mate was successfully created.' }\n format.json { render :show, status: :created, location: @preparar_mate }\n else\n format.html { render :new }\n format.json { render json: @preparar_mate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \t@dpm = Dpm.new(dpm_params)\n \t#todo @user = User.find_by(current_user[:id])\n \t#@user.dpms << @dpm\n \t\n respond_to do |format|\n if @dpm.save\n format.html { render '/dpms/step1', notice: 'Dpm was successfully created.' }\n format.json { render action: 'show', status: :created, location: @dpm }\n else\n format.html { render action: 'new' }\n format.json { render json: @dpm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @voprosy = Voprosy.new(params[:voprosy])\n\n respond_to do |format|\n if @voprosy.save\n format.html { redirect_to @voprosy, notice: 'Voprosy was successfully created.' }\n format.json { render json: @voprosy, status: :created, location: @voprosy }\n else\n format.html { render action: \"new\" }\n format.json { render json: @voprosy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dis_generic_monograph = DisGenericMonograph.new(dis_generic_monograph_params)\n\n respond_to do |format|\n if @dis_generic_monograph.save\n format.html { redirect_to @dis_generic_monograph, notice: 'Dis generic monograph was successfully created.' }\n format.json { render :show, status: :created, location: @dis_generic_monograph }\n else\n format.html { render :new }\n format.json { render json: @dis_generic_monograph.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @remedio = Remedio.new(params[:remedio])\n\n respond_to do |format|\n if @remedio.save\n format.html { redirect_to @remedio, notice: 'Remedio was successfully created.' }\n format.json { render json: @remedio, status: :created, location: @remedio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @remedio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @physio = Physio.new(physio_params)\n\n respond_to do |format|\n if @physio.save\n format.html { redirect_to @physio, notice: 'Physio was successfully created.' }\n format.json { render :show, status: :created, location: @physio }\n else\n format.html { render :new }\n format.json { render json: @physio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @device = Device.first\n if @device == nil\n @device = Device.new(device_params)\n @device.save!\n end\n render json: {\"device\": @device}, status: :created\n end",
"def create\n @moresmallarmorinfo = Moresmallarmorinfo.new(params[:moresmallarmorinfo])\n\n respond_to do |format|\n if @moresmallarmorinfo.save\n format.html { redirect_to @moresmallarmorinfo, notice: 'Moresmallarmorinfo was successfully created.' }\n format.json { render json: @moresmallarmorinfo, status: :created, location: @moresmallarmorinfo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @moresmallarmorinfo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pharma = Pharma.new(pharma_params)\n\n respond_to do |format|\n if @pharma.save\n format.html { redirect_to @pharma, notice: 'Pharma was successfully created.' }\n format.json { render :show, status: :created, location: @pharma }\n else\n format.html { render :new }\n format.json { render json: @pharma.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pupil_measurement = PupilMeasurement.new(pupil_measurement_params)\n\n respond_to do |format|\n if @pupil_measurement.save\n format.html { redirect_to @pupil_measurement, notice: \"Pupil measurement was successfully created.\" }\n format.json { render :show, status: :created, location: @pupil_measurement }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @pupil_measurement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @product_ware_house = ProductWareHouse.new(product_ware_house_params)\r\n respond_to do |format|\r\n if @product_ware_house.save\r\n \r\n format.html { redirect_to @product_ware_house, notice: 'Ware house was successfully created.' }\r\n format.json { render :show, status: :created, location: @product_ware_house }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @product_ware_house.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @propiedad = Pmc::Propiedad.new(propiedad_params)\n\n respond_to do |format|\n if @propiedad.save\n format.html { redirect_to @propiedad, notice: 'La propiedad se creo correctamente.' }\n format.json { render :show, status: :created, location: @propiedad }\n else\n format.html { render :new }\n format.json { render json: @propiedad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @storepromotion = Storepromotion.new(storepromotion_params)\n\n respond_to do |format|\n if @storepromotion.save\n format.html { redirect_to @storepromotion, notice: 'Storepromotion was successfully created.' }\n format.json { render :show, status: :created, location: @storepromotion }\n else\n format.html { render :new }\n format.json { render json: @storepromotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @monitorium = Monitorium.new(monitorium_params)\n @monitorium.capacidadeatual = @monitorium.capacidade\n\n respond_to do |format|\n if @monitorium.save\n format.html { redirect_to @monitorium, notice: 'Monitoria criada com sucesso.' }\n format.json { render :show, status: :created, location: @monitorium }\n else\n format.html { render :new }\n format.json { render json: @monitorium.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dia_evento = DiaEvento.new(dia_evento_params)\n\n if @dia_evento.save\n render json: @dia_evento, status: :created, location: @dia_evento\n else\n render json: @dia_evento.errors, status: :unprocessable_entity\n end\n end",
"def create\n @turbo_memoid = TurboMemoid.new(params[:turbo_memoid])\n\n respond_to do |format|\n if @turbo_memoid.save\n format.html { redirect_to @turbo_memoid, notice: 'Turbo memoid was successfully created.' }\n format.json { render json: @turbo_memoid, status: :created, location: @turbo_memoid }\n else\n format.html { render action: \"new\" }\n format.json { render json: @turbo_memoid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n apartment = Apartment.create(apartment_params)\n render json: apartment\n end",
"def create\n @dns_device_assoc = DnsDeviceAssoc.new(params[:dns_device_assoc])\n\n respond_to do |format|\n if @dns_device_assoc.save\n format.html { redirect_to @dns_device_assoc, notice: 'Dns device assoc was successfully created.' }\n format.json { render json: @dns_device_assoc, status: :created, location: @dns_device_assoc }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dns_device_assoc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @wager = Wager.new(params[:wager])\n\n if @wager.save\n render json: @wager, status: :created, location: @wager\n else\n render json: @wager.errors, status: :unprocessable_entity\n end\n end",
"def create\n @processo = Processo.new(processo_params)\n\n if @processo.save\n render json: @processo, status: :created, location: @processo\n else\n render json: @processo.errors, status: :unprocessable_entity\n end\n end",
"def processed_promos\n respond_to do |format|\n @taken_promos = TakenPromo.get_taken_promos_for_user current_user\n format.html { }\n end\n end",
"def suscriber_wm\n\t\turi = URI(\"http://staging.benchprep.com/api/v1/test/fixtures.json\")\t\n\n\t\tres = Net::HTTP.post_form(uri, 'email' => 'integration-tester+1@benchprep.com&enrollments_persona=subscriber&devices_persona=web_and_mobile')\n\t\t# write this output to a file\n\t\toutput = File.open( \"spec/fixtures/sp_wm_persona.json\",'w' ){|f| \n\t\t\tf.flock(File::LOCK_EX)\n\t\t\tf.write(res.body)\n\t\t}\n\n\t\t# Now parse this string as json\n\t\tjson = File.read('spec/fixtures/sp_wm_persona.json')\n\t\templs = JSON.parse(json)\n\n\t\treturn empls #pretty printed output\n\tend",
"def create\n @notify_observer = NotifyObserver.new(params[:notify_observer])\n @notify_observer.save\n @properties = params[:notify_observer_properties]\n \n for property in @properties\n @notify_observer.notify_observer_properties.create(:name => property)\n end if @properties\n \n respond_to do |format|\n if @notify_observer.save\n format.html { redirect_to @notify_observer, :notice => 'Notify observer was successfully created.' }\n format.json { render :json => @notify_observer, :status => created, :location => @notify_observer }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @notify_observer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_daw_matricula_promo\n @daw_matricula_promo = DawMatriculaPromo.find(params[:id])\n end",
"def create\n @prod_alma = ProdAlma.new(prod_alma_params)\n\n respond_to do |format|\n if @prod_alma.save\n format.html { redirect_to @prod_alma, notice: 'Prod alma was successfully created.' }\n format.json { render :show, status: :created, location: @prod_alma }\n else\n format.html { render :new }\n format.json { render json: @prod_alma.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pautum = Pautum.new(pautum_params)\n\n respond_to do |format|\n if @pautum.save\n format.html { redirect_to @pautum, notice: 'Pautum was successfully created.' }\n format.json { render :show, status: :created, location: @pautum }\n else\n format.html { render :new }\n format.json { render json: @pautum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @terminal_device = TerminalDevice.new(terminal_device_params)\n\n respond_to do |format|\n if @terminal_device.save\n format.html { redirect_to @terminal_device, notice: 'Terminal device was successfully created.' }\n format.json { render :show, status: :created, location: @terminal_device }\n else\n format.html { render :new }\n format.json { render json: @terminal_device.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @prd_m = PrdM.new(prd_m_params)\n\n respond_to do |format|\n if @prd_m.save\n format.html { redirect_to @prd_m, notice: 'Prd m was successfully created.' }\n format.json { render :show, status: :created, location: @prd_m }\n else\n format.html { render :new }\n format.json { render json: @prd_m.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_promocion\n @promocion = Promocion.find(params[:id])\n end",
"def medicaldevice_params\n params.require(:medicaldevice).permit(:pmak_number, :applicant, :street1, :street2, :city, :state, :zip, :generic_name, :trade_name, :product_code, :advisory_committee, :description,:image)\n end",
"def device_params\n params.require(:device).permit(:tele, :pawprint, :name, :email, :secret_key )\n end",
"def create\n @estadopro = Estadopro.new(estadopro_params)\n\n respond_to do |format|\n if @estadopro.save\n format.html { redirect_to @estadopro, notice: 'Estadopro was successfully created.' }\n format.json { render :show, status: :created, location: @estadopro }\n else\n format.html { render :new }\n format.json { render json: @estadopro.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.7214397",
"0.6106348",
"0.5992868",
"0.5981123",
"0.5788211",
"0.57550657",
"0.5698611",
"0.5653004",
"0.5481892",
"0.5480644",
"0.5477",
"0.54521966",
"0.54376364",
"0.5414071",
"0.5412733",
"0.540968",
"0.5398997",
"0.53984874",
"0.53982407",
"0.53896254",
"0.5343505",
"0.53333855",
"0.531403",
"0.53111404",
"0.5309042",
"0.5309042",
"0.53057206",
"0.52724165",
"0.5258064",
"0.52480584",
"0.5208844",
"0.5203681",
"0.5203423",
"0.5200128",
"0.5174404",
"0.51738507",
"0.51680475",
"0.5155299",
"0.5150155",
"0.5142083",
"0.5141969",
"0.5129679",
"0.51259184",
"0.51208156",
"0.5109617",
"0.5109408",
"0.51084137",
"0.50970286",
"0.50909823",
"0.5087424",
"0.50810176",
"0.5074845",
"0.5065009",
"0.50649905",
"0.50613433",
"0.50602686",
"0.5059863",
"0.5059021",
"0.50588",
"0.50566334",
"0.5054367",
"0.5053628",
"0.5049466",
"0.5042486",
"0.50411737",
"0.5038525",
"0.503685",
"0.50336385",
"0.50305706",
"0.5019762",
"0.5019308",
"0.5018045",
"0.5015306",
"0.5002374",
"0.49996334",
"0.49963295",
"0.49957183",
"0.49946967",
"0.49945286",
"0.49944854",
"0.49885157",
"0.49879596",
"0.49859348",
"0.49856067",
"0.4985131",
"0.4984896",
"0.49790862",
"0.49749917",
"0.49736995",
"0.4962977",
"0.49628487",
"0.49570107",
"0.49537763",
"0.49468625",
"0.49459937",
"0.4939743",
"0.49339655",
"0.49315438",
"0.49297592",
"0.4928828"
] |
0.6368797
|
1
|
PATCH/PUT /daw_promos/1 PATCH/PUT /daw_promos/1.json
|
def update
respond_to do |format|
if @daw_promo.update(daw_promo_params)
format.html { redirect_to @daw_promo, notice: 'Daw promo was successfully updated.' }
format.json { render :show, status: :ok, location: @daw_promo }
else
format.html { render :edit }
format.json { render json: @daw_promo.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @promos = Promos.find(params[:id])\n\n respond_to do |format|\n if @promos.update_attributes(params[:promos])\n flash[:notice] = 'Promos was successfully updated.'\n format.html { redirect_to(@promos) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @promos.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n respond_to do |format|\n if @promocion.update(promocion_params)\n format.html { redirect_to @promocion, notice: 'Promocion ha sido actualizado.' }\n format.json { render :show, status: :ok, location: @promocion }\n else\n format.html { render :edit }\n format.json { render json: @promocion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @promo = Promo.find(params[:id])\n\n respond_to do |format|\n if @promo.update_attributes(params[:promo])\n format.html { redirect_to @promo, notice: 'Promo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @promo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n @voprosy = Voprosy.find(params[:id])\n\n respond_to do |format|\n if @voprosy.update_attributes(params[:voprosy])\n format.html { redirect_to @voprosy, notice: 'Voprosy was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @voprosy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to @premio, :notice => 'Premio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to @premio, notice: 'Premio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @premio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @promocion = Promocion.find(params[:id])\n logger.debug \"-------------------------------------------------------\"\n logger.debug params[:promocion][:formadepago_ids]\n logger.debug \"-------------------------------------------------------\"\n if (params[:promocion][:comercializable_ids] == nil)\n params[:promocion][:comercializable_ids] = []\n end\n\n if (params[:promocion][:formadepago_ids] == nil)\n params[:promocion][:formadepago_ids] = []\n end\n\n respond_to do |format|\n if @promocion.update_attributes(params[:promocion])\n format.html { redirect_to @promocion, :notice => 'Promocion was successfully updated.' }\n format.json { render json: @promocion}\n else\n format.html { render :action => \"edit\" }\n format.json { render json: @promocion.errors }\n end\n end\n end",
"def update\n @promotion = Promotion.find(params[:id])\n\n if @promotion.update(promotion_params)\n head :no_content\n else\n render json: @promotion.errors, status: :unprocessable_entity\n end\n end",
"def update\n @promocao = Promocao.find(params[:id])\n\n respond_to do |format|\n if @promocao.update_attributes(params[:promocao])\n format.html { redirect_to(@promocao, :notice => 'Promoção aletrada com sucesso!') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @promocao.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n new_properties = params[:d]\n profile = Profile[params[:id]]\n profile.update_with(new_properties)\n\n respond_with(profile) do |format|\n format.json { render json: profile.stripped }\n end\n end",
"def update\n respond_to do |format|\n if @prospecto.update(prospecto_params)\n format.html { redirect_to @prospecto, notice: 'Prospecto was successfully updated.' }\n format.json { render :show, status: :ok, location: @prospecto }\n else\n format.html { render :edit }\n format.json { render json: @prospecto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @daw_matricula_promo.update(daw_matricula_promo_params)\n format.html { redirect_to @daw_matricula_promo, notice: 'Daw matricula promo was successfully updated.' }\n format.json { render :show, status: :ok, location: @daw_matricula_promo }\n else\n format.html { render :edit }\n format.json { render json: @daw_matricula_promo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @plasmid_probe.update(plasmid_probe_params)\n format.html { redirect_to @plasmid_probe, notice: 'Plasmid probe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @plasmid_probe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n put :update\n end",
"def update\n @rpm = Rpm.find(params[:id])\n @rpm.save\n respond_to do |format|\n if @rpm.update_attributes(params[:rpm])\n format.html { redirect_to imprimir_rpm_path(@rpm) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rpm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @precious_metal = PreciousMetal.find(params[:id])\n\n respond_to do |format|\n if @precious_metal.update_attributes(params[:precious_metal])\n format.html { redirect_to @precious_metal, :notice => 'Precious metal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @precious_metal.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @power_order.update(power_order_params)\n render json: @power_order\n end",
"def update\n respond_to do |format|\n if @cephalopod.update(cephalopod_params)\n format.html { redirect_to @cephalopod, notice: 'Cephalopod was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cephalopod.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @empresa = Empresa.find(params[:empresa_id]) \n @producto = @empresa.productos.find(params[:producto_id])\n @preparar_mate = @producto.preparar_mates.find(params[:id])\n respond_to do |format|\n if @preparar_mate.update(preparar_mate_params)\n format.html { redirect_to empresa_producto_preparar_mates_path, notice: 'Preparar mate was successfully updated.' }\n format.json { render :show, status: :ok, location: @preparar_mate }\n else\n format.html { render :edit }\n format.json { render json: @preparar_mate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n concat_phone_numbers params[:guest]\n @tablet_guest = Tablet::Guest.find(params[:id])\n\n respond_to do |format|\n if @tablet_guest.update_attributes(params[:guest])\n format.json { render :json => @tablet_guest }\n else\n format.json { render :json => @tablet_guest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @propuestum.update(propuestum_params)\n format.html { redirect_to @propuestum, notice: 'Propuestum was successfully updated.' }\n format.json { render :show, status: :ok, location: @propuestum }\n else\n format.html { render :edit }\n format.json { render json: @propuestum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @promotion_demotion = PromotionDemotion.find(params[:id])\n\n respond_to do |format|\n if @promotion_demotion.update_attributes(params[:promotion_demotion])\n format.html { redirect_to @promotion_demotion.rid, notice: 'Promotion demotion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @promotion_demotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @prospecto.update(prospecto_params)\n format.html { redirect_to @prospecto, notice: 'Prospecto actualizado' }\n format.json { render :show, status: :ok, location: @prospecto }\n else\n format.html { render :edit }\n format.json { render json: @prospecto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rm_update path, data, msg\n\n re = rm_request path, data, 'PUT'\n puts re.body\n chk (re.code!='200'), msg + \"\\n#{re.code} #{re.msg}\\n\\n\"\n return true\n\nend",
"def update\n @osoba = Osoba.find(params[:id])\n\n if @osoba.update(params[:osoba])\n head :no_content\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end",
"def update\n @material_apoyo = MaterialApoyo.find(params[:id])\n\n respond_to do |format|\n if @material_apoyo.update_attributes(params[:material_apoyo])\n format.html { redirect_to @material_apoyo, notice: 'Material apoyo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @material_apoyo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @instrument_patch.update(instrument_patch_params)\n format.html { redirect_to @instrument_patch, notice: 'Instrument patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @instrument_patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @promotion = Promotion.find(params[:id])\n\n respond_to do |format|\n if @promotion.update_attributes(params[:promotion])\n format.html { redirect_to @promotion, notice: 'Promotion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @produto.update(produto_params)\n respond_with @produto\n end",
"def update\n respond_to do |format|\n if @manifesto_promise.update(manifesto_promise_params)\n format.html { redirect_to @manifesto_promise, notice: 'Manifesto promise was successfully updated.' }\n format.json { render :show, status: :ok, location: @manifesto_promise }\n else\n format.html { render :edit }\n format.json { render json: @manifesto_promise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @prueba_json.update(prueba_json_params)\n format.html { redirect_to @prueba_json, notice: 'Prueba json was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @prueba_json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @promotion = Promotion.find(params[:id])\n\n respond_to do |format|\n if @promotion.update_attributes(params[:promotion])\n format.html { redirect_to @promotion, notice: 'Promotion was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @gommi.update(gommi_params)\n format.html { redirect_to @gommi, notice: 'Gommi was successfully updated.' }\n format.json { render :show, status: :ok, location: @gommi }\n else\n format.html { render :edit }\n format.json { render json: @gommi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @prospect.update(prospect_params)\n format.html { redirect_to @prospect, notice: 'Prospect was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @prospect.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @round_robin_promo = RoundRobinPromo.find(params[:id])\n\n respond_to do |format|\n if @round_robin_promo.update_attributes(params[:round_robin_promo])\n format.html { redirect_to @round_robin_promo, notice: 'Round robin promo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @round_robin_promo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @repuestum = Repuestum.find(params[:id])\n\n respond_to do |format|\n if @repuestum.update_attributes(params[:repuestum])\n format.html { redirect_to @repuestum, notice: 'Repuestum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @repuestum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @platoon.update(platoon_params)\n format.html { redirect_to @platoon, notice: 'Platoon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @platoon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @plato = Plato.find(params[:id])\n\n if @plato.update(plato_params)\n head :no_content\n else\n render json: @plato.errors, status: :unprocessable_entity\n end\n end",
"def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end",
"def pro_farm_update\n respond_to do |format|\n activo = params[:pro_far][:activo_produc]\n farmacia_id = session[:farmacia_id]\n id = params[:id]\n ProFar.where(producto_id: id, farmacium_id:farmacia_id).update_all(activo_produc: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end",
"def update\n respond_to do |format|\n if @objeto.update(objeto_params)\n format.html { redirect_to @objeto, notice: 'Objeto was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @objeto.update(objeto_params)\n format.html { redirect_to @objeto, notice: 'Objeto was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def pupdate\n @event = Event.find(params[:id])\n respond_to do |format|\n if @event.update_attributes(JSON.parse(params[:event]))\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content}\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @device.update(device_params)\n format.json { head :no_content }\n else\n format.json { render json: {errors: @device.errors}, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pdevice = Pdevice.find(params[:id])\n\n respond_to do |format|\n if @pdevice.update_attributes(params[:pdevice])\n format.html { redirect_to @pdevice, notice: 'Pdevice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pdevice.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @kota_stone.update(kota_stone_params)\n format.html { redirect_to kota_stones_url, notice: 'Kota stone was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kota_stone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipoapreensao.update(tipoapreensao_params)\n format.html { redirect_to @tipoapreensao, notice: 'Tipoapreensao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipoapreensao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update_attr\n #sanity checks \n @persona = current_persona\n @mediaset = @persona.mediasets.find(params[:id])\n \n respond_to do |format|\n @mediaset.update_attributes( params[:mediaset] )\n format.json{ respond_with_bip(@mediaset) }\n end\n end",
"def update\n respond_to do |format|\n if @apoio.update(apoio_params)\n format.html { redirect_to @apoio, notice: 'Apoio was successfully updated.' }\n format.json { render :show, status: :ok, location: @apoio }\n else\n format.html { render :edit }\n format.json { render json: @apoio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pockemon.update(pockemon_params)\n format.html { redirect_to @pockemon, notice: 'Pockemon was successfully updated.' }\n format.json { render :show, status: :ok, location: @pockemon }\n else\n format.html { render :edit }\n format.json { render json: @pockemon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n @promotion = Promotion.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @promotion.update_attributes(params[:promotion])\r\n format.html { redirect_to @promotion, notice: 'Promotion was successfully updated.' }\r\n format.json { head :ok }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n @processo = Processo.find(params[:id])\n\n if @processo.update(processo_params)\n head :no_content\n else\n render json: @processo.errors, status: :unprocessable_entity\n end\n end",
"def update_firmware(attributes = {})\n patch('replace', '/firmware', attributes)\n end",
"def update\n respond_to do |format|\n if @demanda.update(demanda_params)\n format.html { redirect_to @demanda, notice: 'Demanda was successfully updated.' }\n format.json { render :show, status: :ok, location: @demanda }\n else\n format.html { render :edit }\n format.json { render json: @demanda.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n puts \"update\"\n\tputs params\n\tputs \"controllo target\"\n\tputs params[:opera][:target]\n\tnew_opera_params = opera_params\n\tnew_opera_params.delete(\"target\")\n\tif params[:opera][:target] != nil \n\t if params[:opera][:target].length > 3\n\t puts \"modifico\"\n\t target_id = params[:opera][:target].split('-')[0].to_s\n\t target_type = params[:opera][:target].split('-')[1].to_s\n\t \n\t new_opera_params.merge({\"target_id\" => target_id})\n\t\tnew_opera_params.merge({\"target_type\" => target_type})\n\t\t\n\t\tputs new_opera_params\n\t end\n\tend\n\tputs new_opera_params\n respond_to do |format|\n if @opera.update(new_opera_params)\n format.html { redirect_to @opera, notice: 'Opera was successfully updated.' }\n format.json { render :show, status: :ok, location: @opera }\n else\n format.html { render :edit }\n format.json { render json: @opera.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @kodomo.update(kodomo_params)\n format.html { redirect_to @kodomo, notice: 'Kodomo was successfully updated.' }\n format.json { render :show, status: :ok, location: @kodomo }\n else\n format.html { render :edit }\n format.json { render json: @kodomo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n @profesor = Profesor.find(params[:id])\n\n if @profesor.update(profesor_params)\n head :no_content\n else\n render json: @profesor.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @premio_manual.update(premio_manual_params)\n format.html { redirect_to @premio_manual, notice: 'El premio de actualizo correctamente.' }\n format.json { render :show, status: :ok, location: @premio_manual }\n else\n format.html { render :edit }\n format.json { render json: @premio_manual.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @dpm.update(dpm_params) \n format.html { render '/dpms/step1', notice: 'Dpm was successfully updated.' }\n format.json { head :no_content } \n else\n format.html { render action: 'edit' }\n format.json { render json: @dpm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @device.update(device_params)\n head :no_content\n end",
"def update\n @spoofer = Spoofer.find(params[:id])\n\n respond_to do |format|\n if @spoofer.update_attributes(params[:spoofer])\n format.html { redirect_to @spoofer, notice: 'Spoofer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spoofer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @prospecto_telefono.update(prospecto_telefono_params)\n format.html { redirect_to @prospecto_telefono, notice: 'Prospecto telefono was successfully updated.' }\n format.json { render :show, status: :ok, location: @prospecto_telefono }\n else\n format.html { render :edit }\n format.json { render json: @prospecto_telefono.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @moose = Moose.find(params[:id])\n\n respond_to do |format|\n if @moose.update_attributes(params[:moose])\n format.html { redirect_to @moose, notice: 'Moose was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @moose.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @padrao.update(padrao_params)\n format.html { redirect_to @padrao, notice: 'Padrao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @padrao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @power_rack.update(power_rack_params)\n format.html { redirect_to @power_rack, notice: \"Power rack was successfully updated.\" }\n format.json { render :show, status: :ok, location: @power_rack }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @power_rack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def update_from_mobile\n\t\tif !params[:id].nil?\n\t\t\t@protege = Protege.find(params[:id])\n\t\t\tif @protege.update_attributes(protege_mobile)\n\t\t\t\trender json: {status: \"success\"}\n\t\t\telse\n\t\t\t\trender json: {status: \"failure\"}\n\t\t\tend\n\t\telse\n\t\t\trender json: {status: \"failure\"}\n\t\tend\n\n\tend",
"def update\n respond_to do |format|\n if @promotion.update(promotion_params)\n format.html { redirect_to @promotion, notice: 'Promotion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @protein_complex = ProteinComplex.find(params[:id])\n\n respond_to do |format|\n if @protein_complex.update_attributes(params[:protein_complex])\n format.html { redirect_to @protein_complex, notice: 'Protein complex was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @protein_complex.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @dis_generic_monograph.update(dis_generic_monograph_params)\n format.html { redirect_to @dis_generic_monograph, notice: 'Dis generic monograph was successfully updated.' }\n format.json { render :show, status: :ok, location: @dis_generic_monograph }\n else\n format.html { render :edit }\n format.json { render json: @dis_generic_monograph.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @kumo.update(kumo_params)\n format.html { redirect_to kumos_path, notice: 'Kumo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kumo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @magnetic_finger_print = MagneticFingerPrint.find(params[:id])\n\n respond_to do |format|\n if @magnetic_finger_print.update_attributes(params[:magnetic_finger_print])\n format.html { redirect_to @magnetic_finger_print, notice: 'Magnetic finger print was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @magnetic_finger_print.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to(@product, :notice => 'Product was successfully updated.') }\n format.xml { head :ok }\n format.json { head :ok }\n\n # RhoConnect server\n server = \"http://127.0.0.1:9292\"\n login = \"rhoadmin\"\n password = \"\"\n\n # Login to the RhoConnect server\n res = RestClient.post(\"#{server}/login\", { :login => login, :password => password }.to_json, :content_type => :json)\n\n # Get the token from the login response\n token = RestClient.post(\"#{server}/api/get_api_token\", '', { :cookies => res.cookies })\n\n # Send a ping message, which triggers a ping on the device\n ping_params = {\n :api_token => token,\n :user_id => [\"bhanu\"], # user_id that this message is for\n :sources => [\"Product\"], # sources we want to sync when this message is received\n :vibrate => \"2\",\n :message => \"#{params[:product][:name]} has been updated\",\n :sound => ''\n }\n\n RestClient.post(\"#{server}/api/ping\", ping_params.to_json, :content_type => :json)\n\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @microposr = Microposr.find(params[:id])\n\n respond_to do |format|\n if @microposr.update_attributes(params[:microposr])\n format.html { redirect_to @microposr, notice: 'Microposr was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @microposr.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @propose = Propose.find(params[:id])\n\n respond_to do |format|\n if @propose.update_attributes(params[:propose])\n format.html { redirect_to @propose, notice: 'Propuesta actualizada' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @propose.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @makrana_marble.update(makrana_marble_params)\n format.html { redirect_to @makrana_marble, notice: 'Marble product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @makrana_marble.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @homeroom.update(homeroom_params)\n format.html { redirect_to @homeroom, notice: 'Homeroom was successfully updated.' }\n format.json { render :show, status: :ok, location: @homeroom }\n else\n format.html { render :edit }\n format.json { render json: @homeroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n dream = Dream.find params[:id]\n dream.update dream_params\n render json: {dream: dream}\n end",
"def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to(@premio, :notice => 'Premio was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @microposst = Microposst.find(params[:id])\n\n respond_to do |format|\n if @microposst.update_attributes(params[:microposst])\n format.html { redirect_to @microposst, notice: 'Microposst was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @microposst.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @observ.update(observ_params)\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @observ.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @printer = Printer.find(params[:id])\n @printer.update_from_custom_printer!(printer_params)\n\n if @printer.save\n render json: @printer.map_to_custom_printer\n else\n render json: @printer.errors, status: :unprocessable_entity\n end\n end",
"def update(data = :object || :json)\n end",
"def update\n @ventas_presupuesto = Ventas::Presupuesto.find(params[:id])\n\n respond_to do |format|\n if @ventas_presupuesto.update_attributes(params[:ventas_presupuesto])\n format.html { redirect_to @ventas_presupuesto, notice: 'Presupuesto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ventas_presupuesto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n end",
"def update\n @getoff_info = GetoffInfo.find(params[:id])\n\n respond_to do |format|\n if @getoff_info.update_attributes(params[:getoff_info])\n format.html { redirect_to @getoff_info, :notice => 'Getoff info was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @getoff_info.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @wod.update(wod_params)\n render json: @wod\n else\n render json: @wod.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @prospecto_marca.update(prospecto_marca_params)\n format.html { redirect_to @prospecto_marca, notice: 'Prospecto marca was successfully updated.' }\n format.json { render :show, status: :ok, location: @prospecto_marca }\n else\n format.html { render :edit }\n format.json { render json: @prospecto_marca.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @persona = Persona.find(params[:id])\n \n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.json { head :ok }\n else\n format.json { render :json => @persona.errors,\n :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6426635",
"0.6289894",
"0.6176794",
"0.6118892",
"0.6061302",
"0.60556245",
"0.60500866",
"0.6033528",
"0.5984155",
"0.59552926",
"0.5940345",
"0.5928201",
"0.59210974",
"0.59179556",
"0.59135354",
"0.5909171",
"0.5852612",
"0.5831549",
"0.5829486",
"0.5825716",
"0.5823297",
"0.58068645",
"0.5799864",
"0.5798434",
"0.5792782",
"0.57897484",
"0.57867086",
"0.57834786",
"0.5780678",
"0.5776877",
"0.57759714",
"0.5774759",
"0.5762133",
"0.5757627",
"0.5756085",
"0.5755117",
"0.5754552",
"0.5751499",
"0.57474345",
"0.57468307",
"0.57455766",
"0.57385045",
"0.57360476",
"0.57343674",
"0.5731931",
"0.572521",
"0.5721287",
"0.5721287",
"0.5720212",
"0.57200277",
"0.5717446",
"0.57148373",
"0.5710434",
"0.5709469",
"0.5707401",
"0.5706127",
"0.5703565",
"0.5703238",
"0.57006454",
"0.5695136",
"0.5690781",
"0.56823397",
"0.5680468",
"0.567719",
"0.56684804",
"0.56663996",
"0.56632847",
"0.56608665",
"0.5660089",
"0.5658929",
"0.56553257",
"0.5653925",
"0.56531286",
"0.5651751",
"0.5650043",
"0.5650043",
"0.56469035",
"0.5644793",
"0.5642425",
"0.56415254",
"0.5641415",
"0.5639279",
"0.5637461",
"0.563308",
"0.5632816",
"0.56294686",
"0.5626625",
"0.5625805",
"0.5619776",
"0.5619349",
"0.5619237",
"0.5618059",
"0.5611705",
"0.56101316",
"0.56078106",
"0.56077504",
"0.5605046",
"0.5603033",
"0.56005687",
"0.5600046"
] |
0.58440816
|
17
|
DELETE /daw_promos/1 DELETE /daw_promos/1.json
|
def destroy
@daw_promo.destroy
respond_to do |format|
format.html { redirect_to daw_promos_url, notice: 'Daw promo was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @promos = Promos.find(params[:id])\n @promos.destroy\n\n respond_to do |format|\n format.html { redirect_to(promos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @promo = Promo.find(params[:id])\n @promo.destroy\n\n respond_to do |format|\n format.html { redirect_to promos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @promo = Promo.find(params[:id])\n @promo.destroy\n\n respond_to do |format|\n format.html { redirect_to promos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @daw_matricula_promo.destroy\n respond_to do |format|\n format.html { redirect_to daw_matricula_promos_url, notice: 'Daw matricula promo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @promocion = Promocion.find(params[:id])\n @promocion.destroy\n\n respond_to do |format|\n format.html { redirect_to promocions_url }\n #format.json { head :ok }\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @retroaspecto = Retroaspecto.find(params[:id])\n @retroaspecto.destroy\n\n respond_to do |format|\n format.html { redirect_to retroaspectos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def delete_data\n response = WebPay.client.delete([path, 'data'].join('/'))\n response['deleted']\n end",
"def destroy\n @diagnoz = Diagnoz.find(params[:id])\n @diagnoz.destroy\n\n respond_to do |format|\n format.html { redirect_to diagnozs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dpm.destroy\n respond_to do |format|\n format.html { redirect_to dpms_url }\n format.json { head :no_content }\n end\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @gymnasium = Gymnasium.find(params[:id])\n @gymnasium.destroy\n\n respond_to do |format|\n format.html { redirect_to gymnasia_url }\n format.json { head :no_content }\n end\n end",
"def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n @kota_stone.destroy\n respond_to do |format|\n format.html { redirect_to kota_stones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dns_device_assoc = DnsDeviceAssoc.find(params[:id])\n @dns_device_assoc.destroy\n\n respond_to do |format|\n format.html { redirect_to dns_device_assocs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unidade_metrica = UnidadeMetrica.find(params[:id])\n @unidade_metrica.destroy\n\n respond_to do |format|\n format.html { redirect_to unidade_metricas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cephalopod.destroy\n respond_to do |format|\n format.html { redirect_to cephalopods_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @promocion.destroy\n respond_to do |format|\n format.html { redirect_to promocions_url, notice: 'Promocion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end",
"def destroy\n @promotion = Promotion.find(params[:id])\n @promotion.destroy\n\n respond_to do |format|\n format.html { redirect_to promotions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @mydevice = Mydevice.find(params[:id])\n @mydevice.destroy\n\n respond_to do |format|\n format.html { redirect_to mydevices_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @promotion = Promotion.find(params[:id])\n @promotion.destroy\n\n respond_to do |format|\n format.html { redirect_to promotions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pdevice = Pdevice.find(params[:id])\n @pdevice.destroy\n\n respond_to do |format|\n format.html { redirect_to pdevices_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @device.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @round_robin_promo = RoundRobinPromo.find(params[:id])\n @round_robin_promo.destroy\n\n respond_to do |format|\n format.html { redirect_to round_robin_promos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @remedio = Remedio.find(params[:id])\n @remedio.destroy\n\n respond_to do |format|\n format.html { redirect_to remedios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prueba_json.destroy\n respond_to do |format|\n format.html { redirect_to prueba_jsons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @repuestum = Repuestum.find(params[:id])\n @repuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to repuesta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @plasmid_probe.destroy\n respond_to do |format|\n format.html { redirect_to plasmid_probes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nodo.destroy\n respond_to do |format|\n format.html { redirect_to nodos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datoscontacto = Datoscontacto.find(params[:id])\n @datoscontacto.destroy\n\n respond_to do |format|\n format.html { redirect_to datoscontactos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @htc.destroy\n respond_to do |format|\n format.html { redirect_to htcs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @promotion = Promotion.find(params[:id])\r\n @promotion.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to promotions_url }\r\n format.json { head :ok }\r\n end\r\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @promotion_demotion = PromotionDemotion.find(params[:id])\n @promotion_demotion.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end",
"def destroy\n @premio = Premio.find(params[:id])\n @premio.destroy\n\n respond_to do |format|\n format.html { redirect_to premios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @premio = Premio.find(params[:id])\n @premio.destroy\n\n respond_to do |format|\n format.html { redirect_to premios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mob.destroy\n respond_to do |format|\n format.html { redirect_to mobs_url }\n format.json { head :no_content }\n end\n end",
"def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end",
"def destroy\n @ministerios = Ministerios.find(params[:id])\n @ministerios.destroy\n\n respond_to do |format|\n format.html { redirect_to(ministerios_url) }\n format.xml { head :ok }\n end\n end",
"def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end",
"def destroy\n @demob.destroy\n\n respond_to do |format|\n format.html { redirect_to demobs_url, notice: \"Demob was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@promotion = Promotion.find(params[:id])\n @promotion.destroy\n respond_to do |format|\n format.html { redirect_to promotions_url, notice: 'Promotion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @odontologia1 = Odontologia1.find(params[:id])\n @odontologia1.destroy\n\n respond_to do |format|\n format.html { redirect_to odontologia1s_url }\n format.json { head :no_content }\n end\n end",
"def delete_and_give_me_a_json(additional_path, params = nil)\n if self.service_base_path != nil\n if params == nil\n params = Hash.new\n end\n params[:api_key] = self.access_token\n message = self.http_client.delete \"#{self.base_url}#{self.service_base_path}/#{additional_path}.json\", params\n trata_erro(message.content)\n end\n end",
"def destroy\n @apuesta_detail = ApuestaDetail.find(params[:id])\n @apuesta_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to apuesta_details_url }\n format.json { head :no_content }\n end\n end",
"def cmd_delete argv\n setup argv\n e = @hash['element']\n response = @api.delete(e)\n msg response\n return response\n end",
"def destroy\n @serv = Serv.find(params[:id])\n if @serv.mngbl\n #Remueve el MR a través de una llamada al webservice del núcleo\n http = Net::HTTP.new(\"192.168.119.163\",9999)\n post_params = {'ip' => @serv.conn.ip, 'port' => @serv.conn.port}\n request = Net::HTTP::Delete.new(\"/mbs/#{@serv.domain}/#{@serv.name}\")\n request.set_form_data(post_params)\n begin\n response = http.request(request)\n rescue Errno::ECONNREFUSED\n end\n end\n @serv.destroy\n\n respond_to do |format|\n format.html { redirect_to servs_url, notice: t('servs.delete.notice') }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n request(:delete, path)\n end",
"def destroy\n @pharmaceutical_master.destroy\n respond_to do |format|\n format.html { redirect_to pharmaceutical_masters_url, notice: DELETE_NOTICE }\n format.json { head :no_content }\n end\n end",
"def delete\n api(\"Delete\")\n end",
"def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end",
"def destroy\r\n @sivic_ministerio.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_ministerios_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @mou.destroy\n respond_to do |format|\n format.html { redirect_to mous_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prod_cli.destroy\n respond_to do |format|\n format.html { redirect_to prod_clis_url, notice: 'produto excluido com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def destroy\n @dbh_measurement.destroy\n respond_to do |format|\n format.html { redirect_to dbh_measurements_url }\n format.json { head :no_content }\n end\n end",
"def delete(path, params = {})\n post(path, params.merge(\"_method\" => \"delete\"))\n end",
"def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end",
"def destroy\n @aquarium = Aquarium.find(params[:id])\n @aquarium.destroy\n\n respond_to do |format|\n format.html { redirect_to aquaria_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ministerio = Ministerio.find(params[:id])\n @ministerio.destroy\n\n respond_to do |format|\n format.html { redirect_to ministerios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n onevnet('delete', resource[:name])\n @property_hash.clear\n end",
"def delete(path, params)\n parse_response @client[path].delete(:params => params)\n end",
"def destroy\n @turbo_memoid = TurboMemoid.find(params[:id])\n @turbo_memoid.destroy\n\n respond_to do |format|\n format.html { redirect_to turbo_memoids_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @demot = Demot.find(params[:id])\n @demot.destroy\n\n respond_to do |format|\n format.html { redirect_to demots_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @voprosy = Voprosy.find(params[:id])\n @voprosy.destroy\n\n respond_to do |format|\n format.html { redirect_to voprosies_url }\n format.json { head :ok }\n end\n end",
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @database = Database.find(params[:id])\n path = @database.path\n delete = %x[rm -R #{path}]\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kumo.destroy\n respond_to do |format|\n format.html { redirect_to kumos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gastronomium.destroy\n respond_to do |format|\n format.html { redirect_to gastronomia_url, notice: 'Gastronomium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trein_consul_comercial.destroy\n respond_to do |format|\n format.html { redirect_to trein_consul_comercials_url }\n format.json { head :no_content }\n end\n end",
"def delete(payload = {})\n request! do\n options = {payload: to_payload(payload)}\n api(options)[url.path].delete(API_HEADERS)\n end\n end",
"def destroy\n #@phone.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @mostsmalltrapinfo = Mostsmalltrapinfo.find(params[:id])\n @mostsmalltrapinfo.destroy\n\n respond_to do |format|\n format.html { redirect_to mostsmalltrapinfos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @moresmallarmorinfo = Moresmallarmorinfo.find(params[:id])\n @moresmallarmorinfo.destroy\n\n respond_to do |format|\n format.html { redirect_to moresmallarmorinfos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dis_generic_monograph.destroy\n respond_to do |format|\n format.html { redirect_to dis_generic_monographs_url, notice: 'Dis generic monograph was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @consensu = Consensu.find(params[:id])\n @consensu.destroy\n\n respond_to do |format|\n format.html { redirect_to consensus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @moresmalltrial = Moresmalltrial.find(params[:id])\n @moresmalltrial.destroy\n\n respond_to do |format|\n format.html { redirect_to moresmalltrials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bg_measurement.destroy\n respond_to do |format|\n format.html { redirect_to bg_measurements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bg_measurement.destroy\n respond_to do |format|\n format.html { redirect_to bg_measurements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @powiadomienie = Powiadomienie.find(params[:id])\n @powiadomienie.destroy\n\n respond_to do |format|\n format.html { redirect_to powiadomienia_url }\n format.json { head :no_content }\n end\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def destroy\n @momsg = Momsg.find(params[:id])\n @momsg.destroy\n\n respond_to do |format|\n format.html { redirect_to momsgs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n @agronomiaquimica.destroy\n\n respond_to do |format|\n format.html { redirect_to agronomiaquimicas_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.68476886",
"0.6831857",
"0.6782474",
"0.6763007",
"0.6687799",
"0.6687799",
"0.6661607",
"0.66362584",
"0.6619438",
"0.65782565",
"0.6578152",
"0.65766793",
"0.65715885",
"0.65598637",
"0.6545403",
"0.65070486",
"0.6481814",
"0.6478965",
"0.6478949",
"0.6478642",
"0.64782375",
"0.64782375",
"0.64782375",
"0.64782375",
"0.6466133",
"0.64656717",
"0.6462791",
"0.64609575",
"0.64580697",
"0.64507484",
"0.64429426",
"0.6428848",
"0.64245456",
"0.6424479",
"0.64232713",
"0.64200926",
"0.6412445",
"0.640664",
"0.64018565",
"0.63966006",
"0.63935065",
"0.63863397",
"0.6376492",
"0.63727576",
"0.6371182",
"0.6370961",
"0.6366072",
"0.63647074",
"0.63647074",
"0.63623506",
"0.6343585",
"0.6343313",
"0.63399565",
"0.6319811",
"0.6317989",
"0.6317438",
"0.6316952",
"0.6315796",
"0.6307794",
"0.6307408",
"0.6306412",
"0.6300022",
"0.6299479",
"0.6294528",
"0.62934893",
"0.62925744",
"0.6289756",
"0.6287582",
"0.6284183",
"0.6284183",
"0.6283232",
"0.62832296",
"0.6281204",
"0.6278795",
"0.6276883",
"0.6276224",
"0.6276021",
"0.6274571",
"0.6272818",
"0.6271853",
"0.62689066",
"0.6268271",
"0.62677866",
"0.6260423",
"0.62596697",
"0.6256907",
"0.62563735",
"0.62525576",
"0.625211",
"0.6251831",
"0.6248202",
"0.62478125",
"0.624673",
"0.624666",
"0.6246474",
"0.6246474",
"0.6245352",
"0.6242705",
"0.6241546",
"0.62413085"
] |
0.66795
|
6
|
Use callbacks to share common setup or constraints between actions.
|
def set_daw_promo
@daw_promo = DawPromo.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_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"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.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def daw_promo_params
params.require(:daw_promo).permit(:pro_nombre, :pro_porcentaje, :pro_fechaini, :pro_fechafin, :pro_tipopromocion, :pro_estado, :daw_alianza_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 end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"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.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
VIEW_ID = "222861936" initialize
|
def initialize()
@view_id = VIEW_ID
@analytics = Google::Apis::AnalyticsreportingV4
auth
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def define_view\n \t#puts \"#{controller_name}.define_view:begin view=#{@myparams[:view_id]}\"\n \t# views: liste des vues possibles est utilisee dans la view ruby show\n\t\t@views = View.all\n\t\t# view_id: id de la vue selectionnee est utilisee dans la view ruby show\n\t\t#@myparams[:view_id] = @views.first.id if @myparams[:view_id].nil?\n\t\tif @myparams[:view_id].nil?\n\t\t\tif logged_in?\n\t\t\t@myparams[:view_id] = current_user.get_default_view.id\n\t\t\tend\n\t\tend\n\t\t#puts \"#{controller_name}.define_view:end view=#{@myparams[:view_id]}\"\n\tend",
"def set_view\n @view = View.find(params[:id])\n end",
"def set_yourview\n @yourview = Yourview.find(params[:id])\n end",
"def getViewLink(request)\r\n viewid = request.getParameter(\"viewid\")\r\n if !viewid.nil? \r\n newviewid = KeywordProcessor.filterAlphaNumeric(viewid)\r\n end\r\n return nil if newviewid.nil?\r\n # Use alpha-numeric viewid\r\n newviewid\r\n end",
"def initialize(view)\n @view = view\n end",
"def rendered_views=(_arg0); end",
"def _view; end",
"def initialize(view)\n @view = view\n end",
"def cd_id_table\n view_name = cd_id_table_tn\n if @cd_id_table_tn_exists.nil?\n @cd_id_table_tn_exists=true\n if !$db.table_exists?(view_name)\n $db.run(\"CREATE VIEW #{view_name} AS SELECT DISTINCT(r.canonical_document_id) FROM records r INNER JOIN records_searches br ON r.id=br.record_id INNER JOIN searches b ON br.search_id=b.id WHERE b.systematic_review_id=#{self[:id]} AND b.valid=1\n\n UNION\n\n SELECT DISTINCT r.canonical_document_id FROM searches b INNER JOIN records_searches br ON b.id=br.search_id INNER JOIN records_references rr ON br.record_id=rr.record_id INNER JOIN bib_references r ON rr.reference_id=r.id WHERE b.systematic_review_id=#{self[:id]} and r.canonical_document_id IS NOT NULL and b.valid=1 GROUP BY r.canonical_document_id\")\n end\n end\n $db[view_name.to_sym]\n end",
"def add_view_code\n return '' if (data = @record.send(@yaml['name'])).blank?\n\n table, form_name = @yaml['view'].split(/\\ |\\,/).delete_if { |e| e.blank? }\n url = @parent.url_for(controller: 'cmsedit', id: data, action: :edit, table: table, form_name: form_name, readonly: true, window_close: 1 )\n icon = @parent.mi_icon('eye-o md-18')\n %(<span class=\"dc-window-open\" data-url=\"#{url}\"> #{icon}</span>)\nend",
"def initialize(view)\n @view = view\n end",
"def view(ddoc,view,*opts)\n q = \"#{database}/_design/#{ddoc}/_view/#{view}\"\n q << build_query_string(opts.first,\"view\") if opts && opts.any? && opts.first.is_a?(Hash)\n\n @conn.query({url_path: q, method: :get})\n end",
"def getViewLink(request)\r\n viewid = request.getParameter(\"viewid\") \r\n if !viewid.nil? \r\n newviewid = KeywordProcessor.filterAlphaNumeric(viewid)\r\n end\r\n return nil if newviewid.nil?\r\n link = @daohelperlink.readLinkListing(newviewid.to_i())\r\n cur_session = request.getSession(false)\r\n cur_session = BotListSessionManager::safeCreateSession(request) if cur_session.nil?\r\n if !cur_session.nil?\r\n cur_session.setAttribute(BotListSessionManager::CURRENT_LINK_VIEW, link)\r\n end \r\n return link\r\n end",
"def set_viewthread\n @viewthread = Viewthread.find(params[:id])\n end",
"def view; end",
"def loc_view\n \n end",
"def initialize(params = {})\n @main_view = params[:main_view]\n end",
"def set_postgresql_view_person\n @postgresql_view_person = PostgresqlViewPerson.find(params[:id])\n end",
"def getViewObject(ixNet, viewName)\r\n views = @ixNet.getList('/statistics', 'view')\r\n viewObj = ''\r\n editedViewName = '::ixNet::OBJ-/statistics/view:\\\"' + viewName + '\\\"'\r\n for view in views\r\n if editedViewName == view then\r\n viewObj = view\r\n break\r\n end\r\n end\r\n return viewObj\r\nend",
"def app_id=(_arg0); end",
"def app_id=(_arg0); end",
"def set_lake_view\n @lake_view = LakeView.find(params[:id])\n end",
"def set_view_statistic\n @view_statistic = ViewStatistic.find(params[:id])\n end",
"def finviz_view_type\n 411\n end",
"def doctorView \n end",
"def view_flow=(_arg0); end",
"def view()\n @view\n end",
"def initialize(view, current_user)\n @view = view\n @current_user = current_user\n @collection_id = params[:collection_id].to_i #sanitize\n\n @documents_all = Document.where(:collection_id => @collection_id).order(\"#{sort_column} #{sort_direction}\")\n end",
"def view\n end",
"def get_views\n connect_db.fetch(\"SELECT RDB$RELATION_NAME, RDB$VIEW_SOURCE FROM RDB$RELATIONS WHERE RDB$VIEW_BLR IS NOT NULL AND (RDB$SYSTEM_FLAG IS NULL OR RDB$SYSTEM_FLAG = 0)\")\n end",
"def request_id=(_arg0); end",
"def single_customer_view_details\n @id = params[:id]\n end",
"def after_view_setup\n end",
"def view\n ads = Ad.find(params[:id])\n views = AdsView.new\n views.ad_id = ads.id\n views.ipaddress = request.remote_ip\n views.hostname = request.host\n views.save\n \n Ad.increment_counter(:total_views, ads.id)\n redirect_to ads.redirect_to\n end",
"def initialize(view)\n @view = view\n @dt_params = DtParams.new view.params\n @column_key_options = ColumnKeyOptions.new columns, global_search_columns, predefined_ranges\n @preferences = Preferences.new preferences_holder, preferences_field, self.class.name\n\n # if @dt_params.dt_columns.size != @column_key_options.size\n # raise Error, \"dt_columns size of columns is #{@dt_params.dt_columns.size} \\\n # but column_key_options size is #{@column_key_options.size}\"\n # end\n end",
"def get_view_for_viewid(view_id)\n http = create_http\n request = create_request(\"/rest/greenhopper/1.0/rapidviews/list\")\n response = http.request(request)\n views = JSON.parse(response.body)['views']\n views.each do |view|\n if view['id'] == view_id\n return view\n end\n end\nend",
"def get_view_for_viewid(view_id)\n http = create_http\n request = create_request(\"/rest/greenhopper/1.0/rapidviews/list\")\n response = http.request(request)\n views = JSON.parse(response.body)['views']\n views.each do |view|\n if view['id'] == view_id\n return view\n end\n end\nend",
"def create\n @view = View.new(params[:view])\n @view.owner_id = @application_user.id\n\n respond_to do |format|\n if @view.save\n flash[:notice] = 'View was successfully created.'\n format.html { redirect_to(@view) }\n format.xml { render :xml => @view, :status => :created, :location => @view }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @view.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def setviewer \n #the view script.\n \n view = params[:value] \n #Gets the first resource in the set and sets the new view for it.\n resource = session[:application].get(params[:setid]).resources[0] \n #it will add a triple in the repository where the subject will be the resource uri, the predicate\n #will be explorator:view and the object will be the view script. \n resource.explorator::view=view \n \n #render nothing\n render :text => ''\n end",
"def begin_view_index(objects_locale_key)\n begin_view(t(objects_locale_key))\n #begin_view(t(:List),\" \",t(objects_locale_key))\n end",
"def set_view_count\n pa = params[:view_count]\n @view_count = params[:id].to_i.zero? ? ViewCount.where(user_id: pa[:user_id], post_id: pa[:post_id]).take : ViewCount.find(params[:id])\n end",
"def view_value\n {type: type, id: id}\n end",
"def view_props\n {}\n end",
"def create_view(db) \n begin\n db.get('_design/todos')\n rescue RestClient::ResourceNotFound => nfe\n db.save_doc({\n \"_id\" => \"_design/todos\",\n :views => {\n :allTodos => {\n :reduce => \"_count\",\n :map => \"function(doc){if(doc.title && doc.completed != null){emit(doc.order,{title: doc.title,completed: doc.completed})}}\"\n }\n }\n })\n end\nend",
"def rp_id; end",
"def content_id; end",
"def start_new_toy\n @main_view.setup_for_new\n @id = rand(2**60).to_s\n end",
"def materialized_view_definition(matview_name, name = nil) raise \"Internal Error: Connection adapter didn't override abstract function\"; end",
"def navigation_id=(_arg0); end",
"def id_number; end",
"def create\n @view = View.new(params[:view])\n @view.ministry = @ministry\n\n respond_to do |format|\n if @view.save\n # Make this view the current view\n session[:view_id] = @view.id\n flash[:notice] = 'View was successfully created.'\n format.html { redirect_to edit_view_url(@view) }\n format.xml { head :created, :location => view_url(@view) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @view.errors.to_xml }\n end\n end\n end",
"def view_ad(ad_id)\n \tmodify_adstat(ad_id, \"views\")\n end",
"def request_id=(_); end",
"def init_pairing_view_variables\n otp_confirm_view_variables\n end",
"def begin_view_new(object_locale_key)\n begin_view(t(:Create),\" \",t(object_locale_key))\n end",
"def master_view\n\t\toption = @view.initial_view\n\t\tselect(option)\n\tend",
"def set_pageview\n @pageview = Pageview.find(params[:id])\n end",
"def view\n @_view\n end",
"def view=(item)\n frm.select(:id=>\"view\").select(item)\n end",
"def id; 1; end",
"def view=(list_item)\n frm.select(:id=>\"view\").set(list_item)\n end",
"def app_id; end",
"def app_id; end",
"def add_view(id)\n\n\t\tif Pview.where(:project_id => id, :ip => request.remote_ip).all.size == 0\n\t\t\tview = Pview.new\n\t\t\tview.project_id = id\n\t\t\tview.ip = request.remote_ip\n\t\t\tview.save\n\t\tend\n\tend",
"def sview\n ActiveSupport::StringInquirer.new(@params[:sview]) unless @params[:sview].nil?\n end",
"def ListView_SetView(hwnd, iView) send_listview_message(hwnd, :SETVIEW, wparam: iView) end",
"def to_param\n view_number.to_s\n end",
"def set_reeview\n @reeview = Reeview.find(params[:id])\n end",
"def get_view_for_viewid(view_id)\n\tp view_id\n\thttp = create_http\n\trequest = create_request(\"/rest/greenhopper/1.0/rapidviews/list\")\n\tresponse = http.request(request)\n\tviews = JSON.parse(response.body)['views']\n\tviews.each do |view|\n\t\tp view\n\t\tif view['id'] == view_id\n\t\t\treturn view\n\t\tend\n\tend\nend",
"def client_id=(_arg0); end",
"def set_viewpoint\n @viewpoint = Viewpoint.find(params[:id])\n end",
"def id=(_arg0); end",
"def id=(_arg0); end",
"def id=(_arg0); end",
"def record_view\n self.views += 1\n save\n end",
"def set_view_publication\n @view_publication = ViewPublication.find(params[:id])\n end",
"def set_common_view_name\n @view_name = \"message_view\"\n @params = params\n end",
"def demo \n @id_ = 1\nend",
"def create_view(db)\n begin\n db.get('_design/todos')\n rescue RestClient::ResourceNotFound => nfe\n db.save_doc({\n \"_id\" => \"_design/todos\",\n :views => {\n :allTodos => {\n :reduce => \"_count\",\n :map => \"function(doc){if(doc.name != null){emit(doc.order,{name: doc.name})}}\"\n }\n }\n })\n end\n end",
"def materialized_views(name = nil) raise \"Internal Error: Connection adapter didn't override abstract function\"; [] end",
"def set_viewing\n @viewing = Viewing.find(params[:id])\n end",
"def show \n @videoshop = Videoshop.find(params[:id])\n id = @videoshop.id\n x = @videoshop.views\n vw = Videoshop.update(id, :views => x+1)\n vw.save\n end",
"def set_view_name\n\n if !(session[:generic_view_name].nil?)\n\n @view_name = session[:generic_view_name]\n\n else\n\n error_log(\"session[:generic_view_name] was nil\",2)\n\n end\n\n end",
"def cool_view_count\n view_count\n end",
"def id; 1; end",
"def GetView id\n\n APICall(path: \"views/#{id}.json\")\n\n end",
"def view_flow; end",
"def request_id; end",
"def client_id; end",
"def ListView_GetView(hwnd) send_listview_message(hwnd, :GETVIEW) end",
"def id\n __id\n end",
"def view_select_statement(view, name=nil)\n row = execute(\"SELECT VIEW_DEFINITION FROM SYSIBM.VIEWS WHERE TABLE_NAME = '#{view}'\", name).each do |row|\n return row[0]\n end\n raise \"No view called #{view} found\"\n end",
"def views\n self[:views] ||= Gnash.new\n end",
"def ar_view\n view = nil\n\n if params[:view]\n view = self.class.ar_views[params[:view].to_sym] ||\n self.class.ar_model.interfaces[:rest].views[params[:view].to_sym]\n end\n\n view ||= self.class.ar_views[action_name.to_sym] ||\n self.class.ar_model.interfaces[:rest].views[action_name.to_sym] ||\n View.new(:anonymous)\n view\n end",
"def references_bw_canonical\n view_name = references_bw_canonical_tn\n if @references_bw_canonical_tn_exists.nil?\n @references_bw_canonical_tn_exists=true\n if !$db.table_exists?(view_name)\n $db.run(\"CREATE VIEW #{view_name} AS SELECT r.canonical_document_id as cd_start, ref.canonical_document_id as cd_end FROM records r INNER JOIN records_searches br ON r.id=br.record_id INNER JOIN searches b ON br.search_id=b.id INNER JOIN records_references rr ON rr.record_id=r.id INNER JOIN bib_references ref ON ref.id=rr.reference_id WHERE systematic_review_id='#{self[:id]}' AND ref.canonical_document_id IS NOT NULL AND b.valid=1 GROUP BY cd_start, cd_end\")\n end\n end\n $db[view_name.to_sym]\n end",
"def store_page_view #:nodoc:\n return if @page_view == 0\n data = ['C8081100C808000000000040000000000900000000'].pack(\"H*\")\n append(data)\n end",
"def create_view(id,doc)\n resp = get_design_doc(id)\n ddoc = set_views(resp,doc)\n\n create_design_doc(id,ddoc)\n end",
"def initialize(view_context)\n @view_context = view_context\n super\n end",
"def set_view(view)\n add_actions \"SetView(#{view})\"\n end",
"def local_rid=(_arg0); end"
] |
[
"0.6556202",
"0.65433985",
"0.6481879",
"0.6463633",
"0.6451928",
"0.6407291",
"0.6404822",
"0.63247037",
"0.625735",
"0.6242812",
"0.6194703",
"0.59661794",
"0.5916904",
"0.5903193",
"0.58999515",
"0.5825491",
"0.5814987",
"0.58099526",
"0.5806841",
"0.5806045",
"0.5806045",
"0.5787931",
"0.5761238",
"0.57587916",
"0.5721695",
"0.57191867",
"0.5711336",
"0.57011384",
"0.5683523",
"0.56825346",
"0.56716746",
"0.5656286",
"0.5650081",
"0.56463385",
"0.5641082",
"0.5633693",
"0.5633693",
"0.5628843",
"0.5628591",
"0.5626493",
"0.56253797",
"0.56164813",
"0.5590653",
"0.5584715",
"0.5575577",
"0.55751795",
"0.55745673",
"0.55731225",
"0.5560558",
"0.5552748",
"0.5551065",
"0.5545684",
"0.55423653",
"0.55381924",
"0.553761",
"0.55309844",
"0.55293214",
"0.55281264",
"0.5522124",
"0.5511614",
"0.5511002",
"0.5510954",
"0.5510954",
"0.5507589",
"0.5506248",
"0.5505002",
"0.5503362",
"0.5502279",
"0.5491352",
"0.54894036",
"0.5486428",
"0.5485133",
"0.5485133",
"0.5485133",
"0.54824066",
"0.54796",
"0.5477628",
"0.5475175",
"0.54744273",
"0.5472526",
"0.5465768",
"0.5463277",
"0.5450975",
"0.5445336",
"0.5442405",
"0.54346657",
"0.5414348",
"0.5399323",
"0.538943",
"0.5385473",
"0.53848296",
"0.5384101",
"0.5378649",
"0.53768873",
"0.5373398",
"0.53677005",
"0.53652614",
"0.5360836",
"0.53607684",
"0.53585684"
] |
0.55849445
|
43
|
total data by selected period
|
def get_total_ga_info(startdate, enddate, hostname)
puts 'totla data'
set_total_by_date = Array.new
formatted_startdate = DateTime.parse(startdate)
formatted_enddate = DateTime.parse(enddate)
# index 0 -> total data, index 1 -> data by date or hour
current_arr = set_api_by_date(startdate, enddate, hostname)
current_data = current_arr[0]
current_linechart_data = current_arr[1]
# get compare dates
if startdate == enddate then
compare_startdate = (formatted_startdate - 1.day).strftime("%Y-%m-%d")
compare_enddate = (formatted_enddate - 1.day).strftime("%Y-%m-%d")
else
diff = (formatted_enddate - formatted_startdate).to_i + 1
compare_startdate = (formatted_startdate - diff.days).strftime("%Y-%m-%d")
compare_enddate = (formatted_enddate - diff.days).strftime("%Y-%m-%d")
end
# index 0 -> total data, index 1 -> data by date or hour
compare_arr = set_api_by_date(compare_startdate, compare_enddate, hostname)
compare_data = compare_arr[0]
compare_linechart_data = compare_arr[1]
set_total_by_date.push(current_data)
set_total_by_date.push(compare_data)
set_total_by_date.push(current_linechart_data)
set_total_by_date.push(compare_linechart_data)
return set_total_by_date
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def total_payments_data(period_data = 'this_month')\n res = payments.completed\n range, daily_report = period_data.to_s.report_period_to_range\n data = [[period_data.to_s.report_period_to_title, I18n.t('number.currency.format.unit')]]\n range.each{|d| data << [d.strftime(daily_report ? '%d' : '%Y-%m'), res.where(payment_at: d.beginning_of_day..(daily_report ? d.end_of_day : d.end_of_month.end_of_day)).count(:id)] }\n data\n end",
"def total(options = {})\n extra = {}\n response = total_by_time_period(options)\n extra = { error: response[:error] } if response[:error].present?\n { query: options[:query], total: response[:results].map { |item| item[:count] }.reduce(:+), calls: response[:calls] }.merge!(extra)\n end",
"def real_total_in_period(center_id, start, stop)\n\t\tstop_date = stop.blank? && \"Now()\" || \"'#{stop.to_s(:db)}'\"\n\t\tquery = []\n\t\tquery << \"select center_id, survey_id, count(id) as used from survey_answers \"\n\t\tquery << \"where done = 1 and center_id = #{center_id.to_i} \"\n\t\tquery << \"and created_at between '#{start.to_s(:db)}' and #{stop_date} \"\n\t\t# query << \"and created_at between '2013-12-10' and '2015-09-03 20:48:55' \"\n\t\tquery << \"group by center_id, survey_id\"\n\n\t\tcount = ActiveRecord::Base.connection.execute(query.join).each(:as => :hash).inject(PeriodCount.new) do |p,j| \n\t\t\tkey = j['survey_id']\n\t\t\tp.start = start\n\t\t\tp.stop = stop\n\t\t\tp.center_id = center_id.to_i\n\t\t\tp.per_survey ||= {} #j['used']\n \t\tp.per_survey[key] ||= []\n \t\tp.per_survey[key] = j['used']\n \t\t\tp\n \tend\n\tend",
"def sum_income(period)\n if period.is_a?(Range)\n income = items.sum(:value, :conditions=>[\"date >= ? and date <= ? and value > 0\", period.first, period.last])\n else\n income = items.sum(:value, :conditions=>[\"date = ? and value > 0\", period])\n end\n return income || 0\n end",
"def fees(period = (Time.now.beginning_of_month - 1).beginning_of_month .. (Time.now.beginning_of_month - 1).end_of_month)\n subscription_payments.all(:conditions => { :created_at => period }).collect(&:affiliate_amount).sum \n end",
"def sum_regular(regular_items, end_date, options={})\n\t #end_date = @today + @days_ahead\n\t\tsum_out = regular_items.inject(0) do |sum, (account, item)|\t\n\t\t\titem = [item] unless item.kind_of? Array\n#\t\t\t ep item\n\t\t\tvalue_out = item.inject(0) do |value,info|\n\t\t\t\tfinish = (info[:end] and info[:end] < end_date) ? info[:end] : end_date\n\t\t\t\t#today = (Time.now.to_i / (24.0*3600.0)).round\n\t\t\t\t \n nunits = 0.0\n\t\t\t\tcounter = info[:period][0] == 1 ? 0 : nil\n\t\t\t\tunless counter\n\t\t\t\t\tdate = @today\n\t\t\t\t\tcounter = 0\n\t\t\t\t\tcase info[:period][1]\n\t\t\t\t\twhen :month\n\t\t\t\t\t\twhile date >= (info[:start] or @today)\n\t\t\t\t\t\t\tcounter +=1 if date.mday == (info[:monthday] or 1)\n\t\t\t\t\t\t\tdate -= 1\n\t\t\t\t\t\tend\n\t\t\t\t\twhen :year\n\t\t\t\t\t\twhile date >= (info[:start] or @today) \n\t\t\t\t\t\t\tcounter +=1 if date.yday == (info[:yearday] or 1)\n\t\t\t\t\t\t\tdate -= 1\n\t\t\t\t\t\tend\n\t\t\t\t\twhen :day\n\t\t\t\t\t\twhile date > (info[:start] or @today)\n\t\t\t\t\t\t\tcounter +=1\n\t\t\t\t\t\t\tdate -= 1\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n delta_units = account.kind_of?(Account) && account.projection\n\t\t\t\tdate = @today\n\t\t\t\tcase info[:period][1]\n\t\t\t\twhen :month\n\t\t\t\t\t#p date, info\n\t\t\t\t\twhile date <= finish \n if delta_units \n nunits += 1.0/date.days_in_month\n else\n if date.mday == (info[:monthday] or 1)\n nunits += 1 if counter % info[:period][0] == 0\n counter +=1 \n end\n end\n\t\t\t\t\t\tdate += 1\n\t\t\t\t\tend\n\t\t\t\twhen :year\n\t\t\t\t\twhile date <= finish\n if delta_units\n nunits += 1.0/date.days_in_year\n else\n if date.yday == (info[:yearday] or 1)\n nunits += 1 if counter % info[:period][0] == 0\n counter +=1\n end\n end\n\t\t\t\t\t\tdate += 1\n\t\t\t\t\tend\n\t\t\t\twhen :day\n\t\t\t\t\twhile date <= finish\n\t\t\t\t\t\tnunits += 1 if counter % info[:period][0] == 0\n\t\t\t\t\t\tcounter +=1\n\t\t\t\t\t\tdate += 1\n\t\t\t\t\tend\n\t\t\t\tend\n\n\n\n #ep ['name2234', name, info, @projected_account_factor] if info[:discretionary]\n\n value + nunits * (info[:size]||account.projection*(@projected_account_factor||1.0))\n\n\t\t\tend\n\t\t\tsum + value_out\n\t\t\t#(rcp.excluding? and rcp.excluding.include?(name)) ? sum : sum + value\n\t\tend\n\t\tsum_out\n\tend",
"def stats_from_period(period)\n return self.stats.where(:period => period).count\n end",
"def calorie_sum_by_day\n\n end",
"def count_per_period_all\n \tcount = Center.all.inject({}) do |col,center|\n \t\tcol[center.id] = count_sum_per_period(center.id)\n \t\tcol\n \tend\n end",
"def sum_totals\n @total = Lote.where(:programacion_id => @programacion.first).sum(:precio_t)\n @total = Money.new(\"#{@total}00\", \"USD\").format\n @cantidades = Lote.where(:programacion_id => @programacion.first).sum(:cantidad)\n end",
"def payments_report(period_data = 'last_month')\n res = payments.completed\n range, daily_report = period_data.to_s.report_period_to_range\n data = [[period_data.to_s.report_period_to_title, 'Tithe', 'Pledge', 'Partner', 'Donation', 'Offertory', 'Payment']]\n range.each do |d| \n r = d.beginning_of_day..(daily_report ? d.end_of_day : d.end_of_month.end_of_day)\n data << [d.strftime(daily_report ? '%d' : '%Y-%m'), \n res.where(payment_at: r, goal: 'tithe').sum(:amount).to_f,\n res.where(payment_at: r, goal: 'pledge').sum(:amount).to_f,\n res.where(payment_at: r, goal: 'partner').sum(:amount).to_f,\n res.where(payment_at: r, goal: 'donation').sum(:amount).to_f,\n res.where(payment_at: r, goal: 'offertory').sum(:amount).to_f,\n res.where(payment_at: r, goal: nil).sum(:amount).to_f\n ]\n end\n data\n end",
"def getTotalValueOfAllFundInvestments(ind, date)\r\n\r\n\tend",
"def consumption_total_period\n # @readings = Reading.where(billing_period_id: billing_period_id, subscriber_id: subscriber_ids).where('reading_type_id NOT IN (?)',[1,2,5,6]).group_by(&:reading_1_id)\n readings = subscriber.readings.where(billing_period_id: billing_period_id).where('reading_type_id IN (?)',[ReadingType::NORMAL,ReadingType::OCTAVILLA,ReadingType::RETIRADA,ReadingType::AUTO]).order(:reading_date).group_by(&:reading_1_id)\n total = 0\n ccm = 0\n readings.each do |reading|\n total += reading[1].last.consumption\n end\n if meter.is_master?\n # Billable Master Meter:\n # Consumption to bill must be the substraction between this consumption\n # and the sum of the child meters consumption\n ccm = consumption_child_meters\n total = ccm > total ? 0 : total - ccm\n end\n return total\n end",
"def event_tickets_sold_data(period_data = 'this_month')\n res = event_payments\n range, daily_report = period_data.to_s.report_period_to_range\n data = [[period_data.to_s.report_period_to_title, I18n.t('number.currency.format.unit')]]\n range.each{|d| data << [d.strftime(daily_report ? '%d' : '%Y-%m'), res.where(payment_at: d.beginning_of_day..(daily_report ? d.end_of_day : d.end_of_month.end_of_day)).sum(:amount).to_f] }\n data\n end",
"def calculate_no_of_periods(start_date, end_date, period, options = {})\n { date: all_dates(start_date, end_date, period.to_sym, options).last , count: all_dates(start_date, end_date, period.to_sym, options).count }\n end",
"def fees(period = (Time.now.beginning_of_month - 1).beginning_of_month .. (Time.now.beginning_of_month - 1).end_of_month)\n subscription_payments.where({ :created_at => period }).collect(&:affiliate_amount).sum\n end",
"def print_used_per_period(center_id)\n\t\tquery = []\n\t\tquery << \"select created_on as start, ifnull(paid_on, Now()) as end, survey_id, center_id, sum(used) as used \"\n\t\tquery << \" from periods where center_id = #{center_id} \"\n\t\tquery << \" group by start, end\"\n\t\tperiods_count = ActiveRecord::Base.connection.execute(query.join).each(:as => :hash).inject([]) do |col,j| \n\t\t\tcol << \"#{j['start']} - #{j['end']} \\tsurvey: #{j['survey_id']} \\tc: #{j['center_id']} \\tused: #{j['used']}\"\n \t\t\tcol\n \tend\n \tputs periods_count.join(\"\\n\")\n \tperiods_count\n end",
"def sales_quantity_amount_in_period(start_date, end_date, branch_id)\n if branch_id.present?\n sales = invoice_line_items.select(\"sum(quantity) as invoice_quantity, sum(amount) as invoice_amount\").joins(:invoice)\n .where(:invoices =>{:company_id=> company_id, :deleted => false, :invoice_status_id => [0,2,3,4], :invoice_date => start_date..end_date, :branch_id => branch_id})\n else\n sales = invoice_line_items.select(\"sum(quantity) as invoice_quantity, sum(amount) as invoice_amount\").joins(:invoice)\n .where(:invoices =>{:company_id=> company_id, :deleted => false, :invoice_status_id => [0,2,3,4], :invoice_date => start_date..end_date})\n end \n end",
"def total\n @data['total']\n end",
"def total\n dataset.unlimited.count\n end",
"def income_this_month\n Sale.past_month.sum(:total)\n end",
"def new_total_current_tb(start_date=Time.now, end_date=Time.now, section=nil)\n value = []\n\n start_date = @@start_date.to_date.strftime('%Y-%m-%d 00:00:00')\n end_date = @@end_date.to_date.strftime('%Y-%m-%d 23:59:59')\n\n patients = FlatCohortTable.find_by_sql(\"SELECT ftc.patient_id FROM flat_cohort_table ftc\n LEFT OUTER JOIN flat_table1 ft1 ON ft1.patient_id = ftc.patient_id\n WHERE ftc.date_enrolled >= '#{start_date}'\n AND ftc.date_enrolled <= '#{end_date}'\n AND (ft1.pulmonary_tuberculosis = 'Yes' OR\n ft1.extrapulmonary_tuberculosis = 'Yes' OR\n ft1.who_stages_criteria_present IN ('Extrapulmonary tuberculosis (EPTB)', 'Pulmonary tuberculosis', 'Pulmonary tuberculosis (current)'))\n GROUP BY ftc.patient_id\").collect{|p| p.patient_id}\n\n value = patients unless patients.blank?\n end",
"def purchase_quantity_amount_in_period(start_date, end_date, branch_id)\n if branch_id.present?\n purchases = purchase_line_items.select(\"sum(quantity) as purchase_quantity, sum(amount) as purchase_amount\").joins(:purchase)\n .where(:purchases =>{:company_id=> company_id, :status_id => [0,1,3], :record_date => start_date..end_date, :branch_id => branch_id})\n else\n purchases = purchase_line_items.select(\"sum(quantity) as purchase_quantity, sum(amount) as purchase_amount\").joins(:purchase)\n .where(:purchases =>{:company_id=> company_id, :status_id => [0,1,3], :record_date => start_date..end_date})\n end \n end",
"def total\n sum(:total)\n end",
"def payment_data(period_data = 'this_month')\n res = payments.completed\n range, daily_report = period_data.to_s.report_period_to_range\n data = [[period_data.to_s.report_period_to_title] + UserGroup::PAYMENT_GOALS.values]\n range.each do |d| \n r = [d.beginning_of_day, (daily_report ? d.end_of_day : d.end_of_month.end_of_day)]\n d = [d.strftime(daily_report ? '%d' : '%Y-%m')]\n UserGroup::PAYMENT_GOALS.each{|k, v| d << res.where(payment_at: r[0]..r[1], goal: k).sum(:amount).to_f }\n data << d\n end\n data\n end",
"def period_dataset_for_resource(resource, date_range)\n data = {}\n\n payments = resource.payments.in_range(date_range)\n expenses = resource.expenses.in_range(date_range)\n\n data['Payments'] = payments.sum(:amount)\n @organization.expense_categories.major.each do |ec|\n data[\"#{ec.name} Expenses\"] = expenses.where(expense_category_id: ec.id).sum(:amount)\n end\n\n data['Other Expenses'] = expenses.minor_expenses.sum(:amount)\n data['Profit'] = data['Payments'] - expenses.sum(:amount)\n data\n end",
"def total_on(date)\n total = (items.sum :value, :conditions=>{:date=>date}) || 0\n total += value_unpaid_tasks_on(date)\n end",
"def chart_data\n # date_from = (params[:q].nil? or params[:q][:issue_date_gteq].empty?) ? 30.days.ago.to_date : Date.parse(params[:q][:issue_date_gteq])\n # date_to = (params[:q].nil? or params[:q][:issue_date_lteq].empty?) ? Date.current : Date.parse(params[:q][:issue_date_lteq])\n\n # scope = @search.result\n # scope = scope.tagged_with(params[:tags].split(/\\s*,\\s*/)) if params[:tags].present?\n # scope = scope.select('issue_date, sum(gross_amount) as total').where(active: true).group('issue_date')\n\n # build all keys with 0 values for all\n @date_totals = {}\n\n # (date_from..date_to).each do |day|\n # @date_totals[day.to_formatted_s(:db)] = 0\n # end\n\n # scope.each do |inv|\n # @date_totals[inv.issue_date.to_formatted_s(:db)] = inv.total\n # end\n\n render\n end",
"def total_amount(range = nil)\n return (range == nil ? self.transactions : self.transactions.all(:date => range)).sum(:amount)\n end",
"def new_total_tb_w2yrs(start_date=Time.now, end_date=Time.now, section=nil)\n value = []\n\n start_date = @@start_date.to_date.strftime('%Y-%m-%d 00:00:00')\n end_date = @@end_date.to_date.strftime('%Y-%m-%d 23:59:59')\n\n patients = FlatCohortTable.find_by_sql(\"SELECT ftc.patient_id FROM flat_cohort_table ftc\n LEFT OUTER JOIN flat_table1 ft1 ON ft1.patient_id = ftc.patient_id\n WHERE ftc.date_enrolled >= '#{start_date}'\n AND ftc.date_enrolled <= '#{end_date}'\n AND (ft1.pulmonary_tuberculosis_last_2_years = 'Yes' OR\n ft1.who_stages_criteria_present = 'Tuberculosis (PTB or EPTB) within the last 2 years')\n GROUP BY ftc.patient_id\").collect{|p| p.patient_id}\n\n\n value = patients unless patients.blank?\n end",
"def total_by_time_period(options = {})\n response = options[:response] || {}\n search_options = {}\n search_options[:query] = options[:query] || ''\n search_options[:bucket] = options[:bucket] || 'day'\n search_options[:fromDate] = Gnip.format_date(options[:date_from]) if options[:date_from]\n search_options[:toDate] = Gnip.format_date(options[:date_to]) if options[:date_to]\n search_options[:next] = options[:next_cursor] if options[:next_cursor]\n\n url = [counts_url, search_options.to_query].join('?')\n call_done = 0\n\n begin\n gnip_call = self.class.get(url, basic_auth: @auth)\n\n parsed_response = gnip_call.parsed_response\n parsed_response = (parsed_response || {}).with_indifferent_access\n\n raise gnip_call.response.message unless parsed_response.present?\n\n if parsed_response[:error].present?\n response = { results: [], next: nil, error: parsed_response[:error][:message], code: gnip_call.response.code.to_i, calls: (response[:calls] || 0) + 1 }\n else\n call_done = 1 # we have received a valid response\n parsed_response[:results].each_with_index do |item, i|\n parsed_response[:results][i] = item.merge(timePeriod: DateTime.parse(item[:timePeriod]).to_s)\n end\n response = { results: (response[:results] || []) + parsed_response[:results], next: parsed_response[:next], code: gnip_call.response.code.to_i, calls: (response[:calls] || 0) + 1 }\n end\n rescue StandardError => e\n response = { results: [], next: nil, error: e.message, code: 500, calls: (response[:calls] || 0) + call_done }\n end\n # If the next cursor is not present we fetched all the data\n # It happens that twitter returns the same cursor, in that case we stop\n return response if !parsed_response[:next].to_s.present? || (parsed_response[:next].to_s.present? && parsed_response[:next] == search_options[:next])\n\n total_by_time_period(query: search_options[:query],\n date_from: search_options[:fromDate],\n date_to: search_options[:toDate],\n bucket: search_options[:bucket],\n next_cursor: parsed_response[:next],\n response: response)\n end",
"def bi_total_date(_project, _from, _to, _group)\n if _group.nil?\n budget_items.joins(:budget).where(\"budgets.project_id in (?) AND budgets.approval_date >= ? AND budgets.approval_date <= ?\",_project,_from,_to).select('SUM(budget_items.amount) bi_t')\n else\n budget_items.joins(:budget,:charge_account).where(\"budgets.project_id in (?) AND budgets.approval_date >= ? AND budgets.approval_date <= ? AND charge_accounts.charge_group_id = ?\",_project,_from,_to, _group).select('SUM(budget_items.amount) bi_t')\n end\n end",
"def sum\n\t\tprintf(\"%02i.%i\\n\", @options[:monat], @options[:jahr])\n\t\t@db.execute(\"select summe, gemeinsam from sum_#{@options[:name]} where jahr = #{@options[:jahr]} and monat = #{@options[:monat]} \") do |row|\n\t\t\tprintf(\"(%s) % .2f EUR \\n\", row[1], row[0])\n\t\tend\n\tend",
"def total\n sum = 0\n\n @four_result.each do |result|\n sum += result\n end\n @six_result.each do |result|\n sum += result\n end\n @eight_result.each do |result|\n sum += result\n end\n @ten_result.each do |result|\n sum += result\n end\n @twelve_result.each do |result|\n sum += result\n end\n @twenty_result.each do |result|\n sum += result\n end\n @percentile_result.each do |result|\n sum += result\n end\n\n sum\n end",
"def total; end",
"def total_amount\n t = amount\n t += sub_transactions.sum(:amount) if recurring_period\n t\n end",
"def count_per_period_per_survey(center_id)\n\t\tquery = []\n\t\tquery << \"select created_on as start, ifnull(paid_on, Now()) as end, survey_id, center_id, sum(used) as used \"\n\t\tquery << \" from periods where center_id = #{center_id} \"\n\t\tquery << \" group by start, end\"\n\t\tperiods_count = ActiveRecord::Base.connection.execute(query.join).each(:as => :hash).inject({}) do |col,j| \n\t\t\tkey = j['survey_id']\n\t\t\tkey2 = j['start']\n\t\t\tcol[key] ||= {}\n \t\tcol[key][key2] = { \n \t\t\t:used => j['used'],\n \t\t\t:start => j['start'].to_s(:db),\n \t\t\t:stop => j['end'].to_s(:db),\n \t\t\t:center_id => j['center_id'],\n \t\t\t:survey_id => j['survey_id']\n\t\t\t\t}\n \t\t\tcol\n \tend\n end",
"def total\n number_of_days_rental = end_date - start_date\n daily_rate = car_category.daily_price\n\n number_of_days_rental * daily_rate\n end",
"def calculate_total_in_cents\n total = 0\n self.subscriptions.each do |s|\n if s.duration.to_i == 30\n total += PriceConfig.pricing(30) * 100\n elsif s.duration.to_i == 60\n total += PriceConfig.pricing(60) * 100\n else\n total += PriceConfig.pricing(90) * 100\n end\n end\n total\n end",
"def calculate_period\n return StandardError, 'Already calculated stats for period' if @calculated.include?(:period)\n check_for_dates\n calculate_stats_for(PERIOD, Statistic::VIEW, start_date, end_date)\n calculate_stats_for(PERIOD, Statistic::DOWNLOAD, start_date, end_date)\n calculate_stats_for(PERIOD, Statistic::STREAM, start_date, end_date) if include_streaming\n @calculated << :period\n self\n end",
"def get_grand_total_one_month\n\t$pokitdok_call.each do |drug|\n\t$total_cost << drug['retail']['total_cost_30_day']['amount'].to_f\n\tend\n\t\n\tsum_total_cost = $total_cost.inject(:+)\nend",
"def strategy_stats date_range\n data = []\n current_user.reports.where(exam_date:date_range).each do |report|\n l1 = (report.l1_attended.to_f/(report.l1_total.to_f.nonzero? || 1 ))*100\n l2 = (report.l2_attended.to_f/(report.l2_total.to_f.nonzero? || 1 ))*100\n l3 = (report.l3_attended.to_f/(report.l3_total.to_f.nonzero? || 1 ))*100\n data << (report.l1_attended.to_f/(report.l1_total.to_f.nonzero? || 1 ))*100 + (report.l2_attended.to_f/(report.l2_total.to_f.nonzero? || 1 ))*10 + (report.l3_attended.to_f/(report.l3_total.to_f.nonzero? || 1 ))\n end\n return data\n end",
"def get_customer_payments_value(fecha1,fecha2,id)\n\n facturas = CustomerPayment.where([\" company_id = ? AND fecha1 >= ? and fecha1 <= ? and bank_acount_id = ?\", self.id, \"#{fecha1} 00:00:00\",\"#{fecha2} 23:59:59\" , id]).order(:id)\n ret = 0 \n if facturas \n ret=0 \n for factura in facturas \n ret += factura.total\n end\n end \n return ret \n end",
"def get_customer_payments_value(fecha1,fecha2,id)\n\n facturas = CustomerPayment.where([\" company_id = ? AND fecha1 >= ? and fecha1 <= ? and bank_acount_id = ?\", self.id, \"#{fecha1} 00:00:00\",\"#{fecha2} 23:59:59\" , id]).order(:id)\n ret = 0 \n if facturas \n ret=0 \n for factura in facturas \n ret += factura.total\n end\n end \n return ret \n end",
"def calculate_total_amount\n total_days = (self.end_date - self.start_date).to_i\n self.update_column(:total_amount, total_days * self.room.room_type.price)\n end",
"def days_totals\n totals(:day)\n end",
"def pollen_totals\n totals(:pollen_id)\n end",
"def income_this_week\n Sale.past_week.sum(:total)\n end",
"def get_grand_total_one_month\n\t\t$pokitdok_call.each do |drug|\n\t\t$total_cost << drug['retail']['total_cost_30_day']['amount'].to_f\n\t\tend\n\n\t\tsum_total_cost = $total_cost.inject(:+)\n\tend",
"def wrt_total_sales(purchases, options = {})\n format = options[:format] || 6\n total_sales = 0.0\n purchases.each do |sale|\n total_sales += sale[\"price\"]\n end\n $report_file.puts(\"Total Sales:\" + \"%#{format}s\" % \"$\" + total_sales.to_s)\n total_sales\nend",
"def total(day, project_id)\n sum = 0\n Array.wrap(day[project_id]).each do |story|\n sum += story['estimate'].to_i\n end\n sum\nend",
"def forecast_charged(date_from, date_to)\n result = {total: 0, detail: {}}\n month = date_from.month \n year = date_from.year\n last_month = date_to.month\n last_year = date_to.year\n until (month == last_month && year == last_year) do\n result[:detail].store(\"#{year}-#{month.to_s.rjust(2, '0')}\", 0)\n if month == 12\n month = 1\n year += 1\n else\n month += 1\n end\n end\n data = query_strategy.forecast_charged(date_from, date_to)\n data.each do |item| \n result[:total] += item.total\n result[:detail][item.period] += item.total\n end\n return result\n end",
"def total_deposit\n self.group_loan_memberships.sum(\"deposit\")\n end",
"def revenue_data(kind = '')\n range = case kind.presence || 'this_year'\n when 'this_year'\n Date.today.beginning_of_year..Date.today\n when 'past_year'\n 1.year.ago.beginning_of_year.to_date..1.year.ago.end_of_year.to_date\n when '6_months_ago'\n 5.months.ago.beginning_of_month.to_date..Date.today\n end\n range.select{|d| d.day == 1}.map{|d| [d.strftime('%Y-%m'), mentor_payments.where(payment_at: d.beginning_of_day..d.end_of_month.end_of_day).sum('payments.amount')] }.to_h\n end",
"def period; end",
"def period; end",
"def period; end",
"def total_price\n\t price = listing.price\n\t num_dates = (start_date..end_date).to_a.length\n\t return price * num_dates\n\tend",
"def data\n month = params[:month].blank? ? '0' : params[:month]\n year = params[:year].blank? ? 0 : params[:year].to_i\n staff_id = get_staff_id\n \n title = 'Hourly Payroll'\n yaxis = 'Total Amount (RM)'\n \n months = I18n.t('date.month_names')\n \n o = Array.new(12) { |x| [months[x + 1], 0] }\n b = Array.new(12) { |x| 0 }\n categories = Array.new(12) { |x| months[x + 1][0..2] }\n \n if year != 0\n listyear = [year]\n title = \"Hourly Payroll for #{year}\"\n \n else\n list = PayRate.select('distinct(year)').all\n listyear = list.collect { |x| x.year }\n end\n \n if month != '0'\n listmonth = month.collect { |x| x.to_i }\n \n else\n list = PayRate.select('distinct(month)').all\n listmonth = list.collect { |x| x.month }\n end\n \n listyear.each do |y|\n listmonth.each do |m|\n filters = { :year => y, :month => m, :staff_id => staff_id }\n total_hours = AttendanceHelper.get_total_hours(filters)\n rate = PayRateHelper.get_pay_rate(filters)\n v = total_hours * rate\n o[m - 1][1] = v\n b[m - 1] += v\n end\n end\n \n c = b.collect { |x| x.round(2) }\n \n @data = { :pie => o, :column => { :data => c, \n :categories => categories, \n :yaxis => yaxis }, \n :title => title }\n \n render :json => @data\n end",
"def sales_return_quantity_amount_in_period(start_date, end_date, branch_id)\n if branch_id.present?\n invoice_returns = invoice_return_line_items.\n select(\" sum(quantity * unit_rate) as total_stk_retrn_amount, sum(quantity) as total_stk_retrn_qty\").\n joins(:invoice_return).\n where(:invoice_returns => {:company_id=> self.company_id, :record_date => start_date..end_date, :branch_id => branch_id})\n else\n invoice_returns = invoice_return_line_items.\n select(\" sum(quantity * unit_rate) as total_stk_retrn_amount, sum(quantity) as total_stk_retrn_qty\").\n joins(:invoice_return).\n where(:invoice_returns => {:company_id=> self.company_id, :record_date => start_date..end_date})\n end\n end",
"def calculate_overall_power_for\n t = Time.zone.now\n\n until_today = self.energy_data.where(:year=>t.year, :month=> (1..(t.month)), :day=>(1..t.day-1)).sum(\"power\") # total in Wh\n today = self.energy_data.where(:year=>t.year, :month=>t.month, :day=>t.day, :hour=>(1..t.hour)).sum(\"power\") # total in Wh\n until_today + today\n end",
"def port_total\n @port.each do |x|\n @all_totals += x.total_con\n end\n end",
"def book_quantity(period='enddate', basis, exclude)\n volarray = []\n sales = self.book_sales(period, basis, exclude)\n sales.each do |sale|\n volarray << sale.quantities_by_band.inject(0) { |sum, i| sum + i }\n end\n book_quantity = volarray.inject(0) { |sum, i| sum +i.to_f }\n end",
"def get_product_sold_data start_date=nil, end_date=nil, step=nil\n start_date = (start_date || '2018-01-01').to_datetime.beginning_of_day\n end_date = (end_date || '2018-12-31').to_datetime.end_of_day\n step = (step || 'week').upcase\n\n Lineitem.where(\"created_at >= ? AND created_at <= ?\", start_date, end_date)\n .select(\"sku_id, #{step}(created_at) as period, SUM(quantity) as total\")\n .group('sku_id, period')\n end",
"def total\n @solr_data[:total]\n end",
"def period\n return @period\n end",
"def series_sum()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::SeriesSum::SeriesSumRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def index\n @orders = Order.all\n\n @orders_this_month = Order.where(created_at: Time.now.beginning_of_month..Time.now.end_of_month)\n @sales = []\n @orders_this_month.each do |order| \n @sales.push(order.total)\n end\n @total_sales_this_month = @sales.reduce(:+)\n end",
"def total\n @total\n end",
"def purchase_return_quantity_amount_in_period(start_date, end_date, branch_id)\n if branch_id.present?\n purchase_retrn_qty = purchase_return_line_items.select(\"sum(quantity) as purchase_return_quantity, sum(amount) as purchase_return_amount\").joins(:purchase_return)\n .where(:purchase_returns => {:company_id => company_id, :record_date => start_date..end_date, :branch_id => branch_id})\n else\n purchase_retrn_qty = purchase_return_line_items.select(\"sum(quantity) as purchase_return_quantity, sum(amount) as purchase_return_amount\").joins(:purchase_return)\n .where(:purchase_returns => {:company_id => company_id, :record_date => start_date..end_date, :branch_id => branch_id}) \n end\n end",
"def book_value(period='enddate', basis, exclude)\n salearray = []\n sales = self.book_sales(period, basis, exclude)\n sales.each do |sale|\n salearray << sale.value_by_band.inject(0) { |sum, i| sum + i.to_f unless i.nan? or i.nil? }\n end\n book_value =salearray.inject(0) { |sum, i| sum +i.to_f }\n end",
"def precio_total_compras\n compras.sum(:precio_total)\n #p = 0\n #compras.each do |compra|\n #p += (compra.precio_total || 0)\n #end\n #return p\n end",
"def total(params)\n search(params.merge(limit: 1))['total']\n end",
"def total\n @solr_data[:total]\n end",
"def country_total\n @totals = {}\n (@start_date..@end_date).each do |date|\n key_pattern = params[:country].present? ? \"Country:#{date}:#{params[:country]}*\" : \"Country:#{date}*\"\n keys = REDIS.keys key_pattern\n keys.each do |key|\n value = REDIS.get key\n split_key = key.split ':'\n split_value = value.split ':'\n country = split_key[2]\n currency = split_key[3]\n amount = split_value[0]\n usd_amount = split_value[1]\n total = split_value[2]\n country_name = split_value[3]\n total_key = \"#{country}_#{currency}\"\n @totals[total_key] ||= { currency: currency,\n country_total: 0,\n country_total_usd: 0,\n country_name: country_name,\n total_count: 0,\n arpu: 0 }\n @totals[total_key][:country_total] += amount.to_d.truncate(2).to_money(currency)\n @totals[total_key][:country_total_usd] += usd_amount.to_d.truncate(2).to_money\n @totals[total_key][:total_count] += total.to_i\n @totals[total_key][:arpu] = @totals[total_key][:country_total_usd] / @totals[total_key][:total_count]\n end\n end\n\n @totals = @totals.sort_by { |_key, value| value[:total_count] }.reverse\n @country_total = @totals.map { |_key, total| total[:country_total_usd] }.sum\n @total_count = @totals.map { |_key, value| value[:total_count] }.sum\n\n respond_to do |format|\n format.html do\n end\n format.csv do\n send_data to_csv('country_total', @totals), type: 'text/csv; charset=utf-8; header=present',\n disposition: \"attachment; filename=country_total-#{Time.now.strftime('%Y-%m-%d-%H:%M:%S')}.csv\"\n end\n end\n end",
"def total_points(semester = Semester.current_semester)\n sum = 0\n\n event_mems = Array.new\n self.event_members.each do |em|\n if em.semester == semester\n event_mems << em\n end\n end\n\n if semester == \"all\"\n event_mems = self.event_members\n end\n # Calculate points from events\n event_mems.each do |event_member|\n sum += event_member.event_points.value if event_member.event_points\n end\n\n # Calculate points from tabling\n # TODO only for this semester tabling slots\n self.tabling_slot_members.where(\n status_id: Status.where(name: :attended).first\n ).each do |tsm|\n # only add points if it was from this semester\n if TablingSlot.find(tsm.tabling_slot_id).start_time >= Semester.current_semester.start_date\n sum += TablingSlot::POINTS\n end\n\n # TODO: points for other statuses\n end\n\n return sum\n end",
"def set_total\r\n self.total = self.order_items.collect{ |order_item| order_item.valid? ? (order_item.sub_total) : 0 }.sum.to_d\r\n end",
"def today_feed_volume\n feed_today.sum(:volume)\n end",
"def total(carbon_or_km)\n self.trips.pluck(carbon_or_km).inject{ |sum,x| sum + x }\n end",
"def period\n\t\t\t\t5\n\t\t\tend",
"def total\n total_time = 0.0\n each { |record| total_time += record[:time] }\n total_time\n end",
"def total\n @total\n end",
"def compute_total(type)\n list = capture_amounts(type)\n generate_total(list)\n end",
"def production_stock_received_qty_amt_in_period(start_date, end_date, branch_id)\n if branch_id.present?\n stock_receipt_vouchers = stock_receipt_line_items.select(\"sum(quantity) as received_quantity, sum(unit_rate*quantity) as received_amount\").joins(:stock_receipt_voucher)\n .where(:stock_receipt_vouchers =>{:company_id=> company_id, :voucher_date => start_date..end_date, :branch_id => branch_id})\n else\n stock_receipt_vouchers = stock_receipt_line_items.select(\"sum(quantity) as received_quantity, sum(unit_rate*quantity) as received_amount\").joins(:stock_receipt_voucher)\n .where(:stock_receipt_vouchers =>{:company_id=> company_id, :voucher_date => start_date..end_date}) \n end \n end",
"def index\n period = params[:period]\n if period.present?\n if period == \"day\"\n @attribute_measures = @attribute.attribute_measures.where(\"created_at >= ?\", Date.today.beginning_of_day)\n elsif period == \"week\"\n #@attribute_measures = @attribute.attribute_measures.where(created_at: Date.today.all_week)\n @attribute_measures = @attribute.attribute_measures.find_by_sql(\"SELECT created_at as created_at, ROUND(AVG(value),2) as value FROM attribute_measures WHERE (created_at BETWEEN '#{1.week.ago}' AND '#{Time.now}') GROUP BY date(created_at), hour(created_at)\")\n elsif period == \"month\"\n #@attribute_measures = @attribute.attribute_measures.where(created_at: Date.today.all_month)\n @attribute_measures = @attribute.attribute_measures.find_by_sql(\"SELECT created_at as created_at, ROUND(AVG(value),2) as value FROM attribute_measures WHERE (created_at BETWEEN '#{1.month.ago}' AND '#{Time.now}') GROUP BY date(created_at)\")\n elsif period == \"year\"\n #@attribute_measures = @attribute.attribute_measures.where(:created_at => Date.today.all_year).order(:created_at).group(\"date(created_at)\").average(:value)\n @attribute_measures = @attribute.attribute_measures.find_by_sql(\"SELECT created_at as created_at, ROUND(AVG(value),2) as value FROM attribute_measures WHERE (created_at BETWEEN '#{1.year.ago}' AND '#{Time.now}') GROUP BY date(created_at)\")\n else\n @attribute_measures = @attribute.attribute_measures.all\n end\n else\n @attribute_measures = @attribute.attribute_measures.all\n end\n\n render json: @attribute_measures.to_json(only:[:value,:created_at])\n end",
"def get_services_year_month_value( year,month, value = \"total\")\n \n services = Serviceorder.where([\" company_id = ? AND fecha1 >= ? AND fecha1 <= ?\", self.id,\"#{year}-#{month}-01 00:00:00\", \"#{year}-#{month}-31 23:59:59\"]).order(\"id desc\")\n ret = 0\n \n for service in services\n puts service.code \n\n if(value == \"subtotal\")\n ret += service.subtotal\n elsif(value == \"tax\")\n ret += service.tax\n elsif(value == \"detraccion\")\n ret += service.detraccion\n else \n \n ret += service.total\n end\n end\n \n return ret\n end",
"def get_services_year_month_value( year,month, value = \"total\")\n \n services = Serviceorder.where([\" company_id = ? AND fecha1 >= ? AND fecha1 <= ?\", self.id,\"#{year}-#{month}-01 00:00:00\", \"#{year}-#{month}-31 23:59:59\"]).order(\"id desc\")\n ret = 0\n \n for service in services\n puts service.code \n\n if(value == \"subtotal\")\n ret += service.subtotal\n elsif(value == \"tax\")\n ret += service.tax\n elsif(value == \"detraccion\")\n ret += service.detraccion\n else \n \n ret += service.total\n end\n end\n \n return ret\n end",
"def get_services_year_month_value( year,month, value = \"total\")\n \n services = Serviceorder.where([\" company_id = ? AND fecha1 >= ? AND fecha1 <= ?\", self.id,\"#{year}-#{month}-01 00:00:00\", \"#{year}-#{month}-31 23:59:59\"]).order(\"id desc\")\n ret = 0\n \n for service in services\n puts service.code \n\n if(value == \"subtotal\")\n ret += service.subtotal\n elsif(value == \"tax\")\n ret += service.tax\n elsif(value == \"detraccion\")\n ret += service.detraccion\n else \n \n ret += service.total\n end\n end\n \n return ret\n end",
"def percent_active es, class_name, upto_date = Time.now.month_start\n range = class_months(es, class_name)\n range.count.to_f / month_range(range.first, upto_date).count.to_f * 100.0\nend",
"def mot_m_total(params = { season: Date.current.year })\n if params[:season]\n (mot_m_firsts.select { |x| x.match.season == params[:season] }.length * 3) + (mot_m_seconds.select { |x| x.match.season == params[:season] }.length * 2) + (mot_m_thirds.select { |x| x.match.season == params[:season] }.length * 1)\n else\n (mot_m_firsts.select { |x| x.match_id.in? [params[:match_id]].flatten }.length * 3) + (mot_m_seconds.select { |x| x.match_id.in? [params[:match_id]].flatten }.length * 2) + (mot_m_thirds.select { |x| x.match_id.in? [params[:match_id]].flatten }.length * 1)\n end\n end",
"def attendances_data(period_data = 'this_month')\n res = user_group_attendances\n range, daily_report = period_data.to_s.report_period_to_range\n data = [[period_data.to_s.report_period_to_title, 'System Data', 'Manual Data']]\n range.each{|d|\n r = [d.beginning_of_day,(daily_report ? d.end_of_day : d.end_of_month.end_of_day)]\n data << [d.strftime(daily_report ? '%d' : '%Y-%m'), \n res.where(created_at: r[0]..r[1]).count(:id),\n user_group_manual_values.attendances.where(date: r[0].to_date..r[1].to_date).sum(:value)] \n }\n data\n end",
"def totals\n t=['Totaux']\n # bottoms est un arrau de totaux des différents mois de l'exercice\n bottoms = 1.upto(@period.list_months.size).collect do |i| # i va de 1 à 12 par ex\n lines.sum {|l| l[i]} # l[i] car l[0] est nature.name\n end\n t + bottoms + [bottoms.sum {|i| i}]\n end",
"def totals\n t=['Totaux']\n # bottoms est un arrau de totaux des différents mois de l'exercice\n bottoms = 1.upto(@period.list_months.size).collect do |i| # i va de 1 à 12 par ex\n lines.sum {|l| l[i]} # l[i] car l[0] est nature.name\n end\n t + bottoms + [bottoms.sum {|i| i}]\n end",
"def index\n # @accounts = Account.order(:buyday).all.page(params[:page]).per(5)\n @accounts = Account.all.page(params[:page]).per(5)\n @grouped_months = @accounts.group_by { |r| r.buyday.beginning_of_month}\n\n @month_num = ['1','2','3','4','5','6','7','8','9','10','11','12']\n @month_details = []\n @month_costs = []\n (0..11).each do |i|\n @month_details[i] = Account.where([\"date_part('month',buyday) = ? and date_part('year',buyday) = ?\" , @month_num[i],2015]).order('buyday desc')\n @month_costs[i] = Account.where([\"date_part('month',buyday) = ? and date_part('year',buyday) = ?\" , @month_num[i],2015]).sum(:dollar)\n end\n # @mar = Account.where(['buyday between ? and ?', '2015-03-01', '2015-03-31' ])\n \n end",
"def total_funds\n total = nil\n FundingRound.all.each do |funding|\n funding.startup == self\n total += funding.investment\n end\n end",
"def totals\n @title = 'Sales Totals'\n sql = \"SELECT DISTINCT YEAR(created_on) as year \"\n sql << \"FROM orders \"\n sql << \"ORDER BY year ASC\"\n @year_rows = Order.find_by_sql(sql)\n @years = Hash.new\n # Build a hash containing all orders hashed by year.\n for row in @year_rows\n @years[row.year] = Order.get_totals_for_year(row.year)\n end\n end",
"def running_total\n sum = 0.00\n @items.each { |item| sum += item[\"price\"] }\n return sum\n end",
"def get_total\n\t\t@total = 0\n\t\tresult = @query_result.build_query(\"portfolioitem/feature\",\"c_ExpScopingCP,c_ExpScopingDP,c_ExpScopingPlatform,c_ExpScopingTest,c_ExpScopingPerf,c_ExpScopingDoc\",\"(FormattedID = #{@feature_id})\",\"\")\n\t\tputs \"getting total for #{@feature_id}\"\n\t\tif(result!=nil)\n\t\t\tresult.each do |res| \n\t\t\t\t@total = res[\"c_ExpScopingCP\"].to_i\n\t\t @total += res[\"c_ExpScopingDP\"].to_i\n\t\t @total += res[\"c_ExpScopingPlatform\"].to_i\n\t\t @total += res[\"c_ExpScopingTest\"].to_i\n\t\t @total += res[\"c_ExpScopingPerf\"].to_i\n\t\t @total += res[\"c_ExpScopingDoc\"].to_i\n\t\t\tend\n\t\tend\n\tend",
"def year1total\n @year1total = @year1 + @manage + @corporate\n end",
"def total\n @total ||= (\n tally = 0\n each do |w|\n tally += w.count\n end\n tally\n )\n end"
] |
[
"0.71462023",
"0.69259024",
"0.6843798",
"0.66862667",
"0.66794366",
"0.65194374",
"0.65041906",
"0.6476117",
"0.6457001",
"0.64241815",
"0.6353831",
"0.627408",
"0.6240165",
"0.6239664",
"0.6222121",
"0.6205127",
"0.61658514",
"0.6163508",
"0.6150929",
"0.61325055",
"0.6121343",
"0.611654",
"0.6064762",
"0.6055605",
"0.6026222",
"0.60174036",
"0.600238",
"0.5997008",
"0.59941816",
"0.59923565",
"0.5989619",
"0.59855264",
"0.59658456",
"0.5956857",
"0.59493494",
"0.5947092",
"0.59328467",
"0.5932785",
"0.5924268",
"0.5910998",
"0.58908725",
"0.5887925",
"0.5876504",
"0.5876504",
"0.5875993",
"0.58712095",
"0.5855275",
"0.5849384",
"0.58118254",
"0.58092743",
"0.5803894",
"0.5796778",
"0.5785468",
"0.5783094",
"0.57807267",
"0.57807267",
"0.57807267",
"0.577693",
"0.57665324",
"0.5760023",
"0.5753861",
"0.57527167",
"0.57518876",
"0.5749302",
"0.5749086",
"0.57476175",
"0.5742607",
"0.5737539",
"0.57347393",
"0.5733988",
"0.57264626",
"0.57242346",
"0.57107854",
"0.5708833",
"0.5707674",
"0.5703592",
"0.5701651",
"0.5697526",
"0.569496",
"0.5682554",
"0.5681562",
"0.56805485",
"0.56786525",
"0.56781495",
"0.5672336",
"0.5667384",
"0.5667384",
"0.5667384",
"0.5662142",
"0.5659012",
"0.564337",
"0.5637203",
"0.5637203",
"0.56355256",
"0.5631645",
"0.5630713",
"0.5627446",
"0.5627071",
"0.5612905",
"0.56119984"
] |
0.57223237
|
72
|
total data by dates
|
def set_api_by_date(startdate, enddate, hostname)
# setup date range
date_range = @analytics::DateRange.new(start_date: startdate, end_date: enddate)
# set metircs data. 10 metrices are allowed per one request
metrics = ['ga:pageviews', 'ga:users', 'ga:bounces', 'ga:sessions',
'ga:avgTimeOnPage', 'ga:newUsers', 'ga:goal1ConversionRate', 'ga:goal1Completions'
]
# make new array and put metric type data in the array
metric_type = Array.new
metrics.each do |m|
metric = @analytics::Metric.new
metric.expression = m
metric_type.push(metric)
end
# if startdate == enddate then
# dimension = @analytics::Dimension.new(name: 'ga:hour')
# order_by = @analytics::OrderBy.new(field_name: 'ga:hour', sort_order: 'ASCENDING')
# else
# dimension = @analytics::Dimension.new(name: 'ga:date')
# order_by = @analytics::OrderBy.new(field_name: 'ga:date', sort_order: 'ASCENDING')
# end
# set dimensions, dimension_filters by hostname. if hostname is total, then set only hour or date in dimension
if hostname == 'total'
if startdate == enddate then
dimensions = ['ga:hour']
else
dimensions = ['ga:date']
end
else
if startdate == enddate then
dimensions = ['ga:hour', 'ga:hostname']
else
dimensions = ['ga:date', 'ga:hostname']
end
dimension_filters = @analytics::DimensionFilterClause.new(
filters: [
@analytics::DimensionFilter.new(
dimension_name: 'ga:hostname',
not: false,
operator: "IN_LIST",
expressions: [hostname]
)
]
)
end
dimension_type = Array.new
dimensions.each do |d|
dimension = @analytics::Dimension.new
dimension.name = d
dimension_type.push(dimension)
end
#set order_bys
order_by = @analytics::OrderBy.new(field_name: dimensions[0], sort_order: 'ASCENDING')
# setup request with the data i set up above to google analytics server
request = @analytics::GetReportsRequest.new(
report_requests: [@analytics::ReportRequest.new(
view_id: @view_id,
metrics: metric_type,
dimensions: dimension_type,
dimension_filter_clauses: [dimension_filters],
date_ranges: [date_range],
order_bys: [order_by]
)]
)
# send request and get the result in the response
response = @client.batch_get_reports(request)
# make new array for the total data. it will has datahash and dropdwnhash, datahash is for total data and
# the other is for hourly/daily data. key would be time(00,01,02,...) or date(i.e. 5/20.5/21,...).
set_total_array = Array.new
# this data is mcv and it is from database
total_clicks_count = set_total_article(startdate, enddate)
# getting total data part start
total_data = response.reports.first.data.totals
key_array = metrics
# get rid of 'ga:'
key_array.each_with_index do |k, index|
key_array[index] = k.gsub("ga:","")
end
total_data.each do |t|
datahash = {}
t.values.each_with_index do |v, index|
datahash[key_array[index]] = v
end
datahash['mcv'] = total_clicks_count
set_total_array.push(datahash)
end
# datahash sample -> { "pageviews": "11", "users": "22", "bounces": "33", ... , "mcv": 0 }
# getting total data part end
# getting daily or hourly data part start
dropdwnhash = {}
data_from_google = response.reports.first.data.rows
data_from_google.each do |r|
vhash = {}
# key would be hour or date
key = r.dimensions.first
# vhash is the data such as pageview, users and so on for specific time or date
r.metrics.first.values.each_with_index do |v, index|
vhash[key_array[index]] = v
end
if startdate == enddate
key = key + ":00"
end
dropdwnhash[key.to_sym] = vhash
end
# dropdwnhash sample (hour) -> "00:00": { "pageviews": "534", "users": "478", "bounces": "432", ... }, "01:00": { ... }
# dropdwnhash sample (date) -> "20200608": { "pageviews": "534", "users": "478", "bounces": "432", ... }, "20200609": { ... }
set_total_array.push(dropdwnhash)
# getting daily or hourly data part end
return set_total_array
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def calorie_sum_by_day\n\n end",
"def total_on(date)\n total = (items.sum :value, :conditions=>{:date=>date}) || 0\n total += value_unpaid_tasks_on(date)\n end",
"def chart_data\n # date_from = (params[:q].nil? or params[:q][:issue_date_gteq].empty?) ? 30.days.ago.to_date : Date.parse(params[:q][:issue_date_gteq])\n # date_to = (params[:q].nil? or params[:q][:issue_date_lteq].empty?) ? Date.current : Date.parse(params[:q][:issue_date_lteq])\n\n # scope = @search.result\n # scope = scope.tagged_with(params[:tags].split(/\\s*,\\s*/)) if params[:tags].present?\n # scope = scope.select('issue_date, sum(gross_amount) as total').where(active: true).group('issue_date')\n\n # build all keys with 0 values for all\n @date_totals = {}\n\n # (date_from..date_to).each do |day|\n # @date_totals[day.to_formatted_s(:db)] = 0\n # end\n\n # scope.each do |inv|\n # @date_totals[inv.issue_date.to_formatted_s(:db)] = inv.total\n # end\n\n render\n end",
"def getTotalValueOfAllFundInvestments(ind, date)\r\n\r\n\tend",
"def amount_by_date_cumulative\n amounts_by_date = Installment.amount_by_date(self)\n amounts_by_date.each do |status, dates|\n sum = 0\n amounts_by_date[status].each do |date, amount|\n sum += amount\n amounts_by_date[status][date] = sum\n end\n end\n return amounts_by_date\n end",
"def days_totals\n totals(:day)\n end",
"def totals(key)\n @data.group_by(&key).map do |key, workdays|\n totals = workdays.inject([0, 0]) do |array, workday|\n array[0] += workday.mg_harvested\n array[1] += workday.sugar_harvested\n\n array\n end\n\n Totals.new(key, totals[0], totals[1], workdays.length)\n end\n end",
"def get_total_ga_info(startdate, enddate, hostname)\n\t\tputs 'totla data'\n\t\tset_total_by_date = Array.new\n\n\t\tformatted_startdate = DateTime.parse(startdate)\n\t\tformatted_enddate = DateTime.parse(enddate)\n\t\t\n\n\t\t# index 0 -> total data, index 1 -> data by date or hour\n\t\tcurrent_arr = set_api_by_date(startdate, enddate, hostname)\n\t\tcurrent_data = current_arr[0]\n\t\tcurrent_linechart_data = current_arr[1]\n\t\t\n\t\t# get compare dates\n\t\tif startdate == enddate then\n\t\t\tcompare_startdate = (formatted_startdate - 1.day).strftime(\"%Y-%m-%d\")\n\t\t\tcompare_enddate = (formatted_enddate - 1.day).strftime(\"%Y-%m-%d\")\n\t\telse\n\t\t\tdiff = (formatted_enddate - formatted_startdate).to_i + 1\n\t\t\tcompare_startdate = (formatted_startdate - diff.days).strftime(\"%Y-%m-%d\")\n\t\t\tcompare_enddate = (formatted_enddate - diff.days).strftime(\"%Y-%m-%d\")\n\t\tend\t\n\n\t\t# index 0 -> total data, index 1 -> data by date or hour\n\t\tcompare_arr = set_api_by_date(compare_startdate, compare_enddate, hostname)\n\t\tcompare_data = compare_arr[0]\n\t\tcompare_linechart_data = compare_arr[1]\n\t\t\n\n\t\tset_total_by_date.push(current_data)\n\t\tset_total_by_date.push(compare_data)\n\t\tset_total_by_date.push(current_linechart_data)\n\t\tset_total_by_date.push(compare_linechart_data)\n\n\t\treturn set_total_by_date\n\tend",
"def index\n @quiebres = Quiebre.all\n @array=[]\n @quiebres_totales=0\n @quiebres.each do |q|\n @quiebres_totales+=q.dineroperdido\n end\n # fecha=@quiebres.first.created_at\n # while(fecha<Date.today)\n # num=@quiebres.where(created_at:fecha).count\n # @array << [fecha.to_datetime.to_i*100, num]\n # fecha=fecha+1.day\n # end\n @grafico=Quiebre.group(\"date(created_at)\").count\n @grafico.each do |g|\n @array << [g[0].to_datetime.to_i*1000, g[1]]\n end\n # if !@\n end",
"def daily\n if dates_ok?\n @entries = Entry.where('user_id = ?\n AND \"time\"(date) BETWEEN ? AND ?\n AND CAST(date AS DATE) >= ? and CAST(date AS DATE) <= ?', current_user.id, params[:timeFrom], params[:timeTo], Date.parse(params[:dateFrom]), Date.parse(params[:dateTo])).\n select('CAST(date AS DATE), sum(calories) as calories').group('CAST(date AS DATE)')\n else\n @entries = Entry.where('user_id = ?', current_user.id).\n select('CAST(date AS DATE), sum(calories) as calories').group('CAST(date AS DATE)')\n end\n end",
"def daily_totals(emoji)\n\n @day_zero = self.last_day.where(emoji: emoji).pluck(:created_at).size\n @day_one = self.last_day_plus_one.where(emoji: emoji).pluck(:created_at).size\n @day_two = self.last_day_plus_two.where(emoji: emoji).pluck(:created_at).size\n some_days = [@day_zero, @day_one, @day_two]\n\n end",
"def compute_date_stats tweets\n dates = {}\n tweets.each do |x|\n rec = dates[x.created_at.to_date] ||= 0\n rec+=1\n dates[x.created_at.to_date] = rec\n end\n dates\n end",
"def sum_totals\n @total = Lote.where(:programacion_id => @programacion.first).sum(:precio_t)\n @total = Money.new(\"#{@total}00\", \"USD\").format\n @cantidades = Lote.where(:programacion_id => @programacion.first).sum(:cantidad)\n end",
"def set_total_article(startdate, enddate)\n\t\tstart_date = startdate.to_date.beginning_of_day\n\t end_date = enddate.to_date.end_of_day\n\t\ttotal_clicks_count = Click.where(:created_at => start_date..end_date).count\n\t\treturn total_clicks_count\n\tend",
"def sum\n reservation_dates.inject(0.0) do |sum, elem|\n sum += elem.cost*(1+(elem.hours-8)*1.5/8)\n end\n end",
"def sum_regular(regular_items, end_date, options={})\n\t #end_date = @today + @days_ahead\n\t\tsum_out = regular_items.inject(0) do |sum, (account, item)|\t\n\t\t\titem = [item] unless item.kind_of? Array\n#\t\t\t ep item\n\t\t\tvalue_out = item.inject(0) do |value,info|\n\t\t\t\tfinish = (info[:end] and info[:end] < end_date) ? info[:end] : end_date\n\t\t\t\t#today = (Time.now.to_i / (24.0*3600.0)).round\n\t\t\t\t \n nunits = 0.0\n\t\t\t\tcounter = info[:period][0] == 1 ? 0 : nil\n\t\t\t\tunless counter\n\t\t\t\t\tdate = @today\n\t\t\t\t\tcounter = 0\n\t\t\t\t\tcase info[:period][1]\n\t\t\t\t\twhen :month\n\t\t\t\t\t\twhile date >= (info[:start] or @today)\n\t\t\t\t\t\t\tcounter +=1 if date.mday == (info[:monthday] or 1)\n\t\t\t\t\t\t\tdate -= 1\n\t\t\t\t\t\tend\n\t\t\t\t\twhen :year\n\t\t\t\t\t\twhile date >= (info[:start] or @today) \n\t\t\t\t\t\t\tcounter +=1 if date.yday == (info[:yearday] or 1)\n\t\t\t\t\t\t\tdate -= 1\n\t\t\t\t\t\tend\n\t\t\t\t\twhen :day\n\t\t\t\t\t\twhile date > (info[:start] or @today)\n\t\t\t\t\t\t\tcounter +=1\n\t\t\t\t\t\t\tdate -= 1\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n delta_units = account.kind_of?(Account) && account.projection\n\t\t\t\tdate = @today\n\t\t\t\tcase info[:period][1]\n\t\t\t\twhen :month\n\t\t\t\t\t#p date, info\n\t\t\t\t\twhile date <= finish \n if delta_units \n nunits += 1.0/date.days_in_month\n else\n if date.mday == (info[:monthday] or 1)\n nunits += 1 if counter % info[:period][0] == 0\n counter +=1 \n end\n end\n\t\t\t\t\t\tdate += 1\n\t\t\t\t\tend\n\t\t\t\twhen :year\n\t\t\t\t\twhile date <= finish\n if delta_units\n nunits += 1.0/date.days_in_year\n else\n if date.yday == (info[:yearday] or 1)\n nunits += 1 if counter % info[:period][0] == 0\n counter +=1\n end\n end\n\t\t\t\t\t\tdate += 1\n\t\t\t\t\tend\n\t\t\t\twhen :day\n\t\t\t\t\twhile date <= finish\n\t\t\t\t\t\tnunits += 1 if counter % info[:period][0] == 0\n\t\t\t\t\t\tcounter +=1\n\t\t\t\t\t\tdate += 1\n\t\t\t\t\tend\n\t\t\t\tend\n\n\n\n #ep ['name2234', name, info, @projected_account_factor] if info[:discretionary]\n\n value + nunits * (info[:size]||account.projection*(@projected_account_factor||1.0))\n\n\t\t\tend\n\t\t\tsum + value_out\n\t\t\t#(rcp.excluding? and rcp.excluding.include?(name)) ? sum : sum + value\n\t\tend\n\t\tsum_out\n\tend",
"def total(day, project_id)\n sum = 0\n Array.wrap(day[project_id]).each do |story|\n sum += story['estimate'].to_i\n end\n sum\nend",
"def total\n number_of_days_rental = end_date - start_date\n daily_rate = car_category.daily_price\n\n number_of_days_rental * daily_rate\n end",
"def country_total\n @totals = {}\n (@start_date..@end_date).each do |date|\n key_pattern = params[:country].present? ? \"Country:#{date}:#{params[:country]}*\" : \"Country:#{date}*\"\n keys = REDIS.keys key_pattern\n keys.each do |key|\n value = REDIS.get key\n split_key = key.split ':'\n split_value = value.split ':'\n country = split_key[2]\n currency = split_key[3]\n amount = split_value[0]\n usd_amount = split_value[1]\n total = split_value[2]\n country_name = split_value[3]\n total_key = \"#{country}_#{currency}\"\n @totals[total_key] ||= { currency: currency,\n country_total: 0,\n country_total_usd: 0,\n country_name: country_name,\n total_count: 0,\n arpu: 0 }\n @totals[total_key][:country_total] += amount.to_d.truncate(2).to_money(currency)\n @totals[total_key][:country_total_usd] += usd_amount.to_d.truncate(2).to_money\n @totals[total_key][:total_count] += total.to_i\n @totals[total_key][:arpu] = @totals[total_key][:country_total_usd] / @totals[total_key][:total_count]\n end\n end\n\n @totals = @totals.sort_by { |_key, value| value[:total_count] }.reverse\n @country_total = @totals.map { |_key, total| total[:country_total_usd] }.sum\n @total_count = @totals.map { |_key, value| value[:total_count] }.sum\n\n respond_to do |format|\n format.html do\n end\n format.csv do\n send_data to_csv('country_total', @totals), type: 'text/csv; charset=utf-8; header=present',\n disposition: \"attachment; filename=country_total-#{Time.now.strftime('%Y-%m-%d-%H:%M:%S')}.csv\"\n end\n end\n end",
"def total\n total_time = 0.0\n each { |record| total_time += record[:time] }\n total_time\n end",
"def strategy_stats date_range\n data = []\n current_user.reports.where(exam_date:date_range).each do |report|\n l1 = (report.l1_attended.to_f/(report.l1_total.to_f.nonzero? || 1 ))*100\n l2 = (report.l2_attended.to_f/(report.l2_total.to_f.nonzero? || 1 ))*100\n l3 = (report.l3_attended.to_f/(report.l3_total.to_f.nonzero? || 1 ))*100\n data << (report.l1_attended.to_f/(report.l1_total.to_f.nonzero? || 1 ))*100 + (report.l2_attended.to_f/(report.l2_total.to_f.nonzero? || 1 ))*10 + (report.l3_attended.to_f/(report.l3_total.to_f.nonzero? || 1 ))\n end\n return data\n end",
"def day_total(day = nil)\n day = day.to_time rescue Time.now\n total day.beginning_of_day, day.beginning_of_next_day\n end",
"def total(start_date, stop_date)\n total = 0\n\n @seasons.map do |season|\n (start_date...stop_date).each do |date| #using ... instead of .. because we don't pay on the final day\n total += season.rate unless !season.in_season?(date) #add to total unless the date isn't in season\n end\n end\n total.to_f\n end",
"def total_asset_value_on_date(date)\n assets.includes(:past_pricings).sum { |asset| asset.value_at_date(date) }\n end",
"def compute_sum(projects, date)\n \tmyHash=Hash.new\n \tprojects.each do |project|\n \tsnapshots = project.processed_snapshots\n \tsnapshot = first_previous_analysis(date, snapshots)\n \tlist = get_violations_data(snapshot)\n \t#hash_data = get_violations_data(snapshot)\n \tif !list.empty?\n\t \thash_data = JSON.parse(list)\n\t \thash_data.each do |name, violationsList|\t \t\n\t\t \tif myHash.has_key?(name)\n\t\t\t\t\tmyHash[name]=myHash[name].zip(violationsList).map { |x, y| x + y }\n\t\t\t\telse\t\t\t\t\n\t\t\t\t\tmyHash.merge!(Hash[name => violationsList])\n\t\t\t\tend\n\t\t\tend\n\t\tend\n end\n return myHash\n end",
"def total_day_kwh_usage_on(date)\n raise \"Invalid argument: Please use a date value that is not in the future\" if (date > Time.now.utc.to_date)\n\n cumulative_hourly_kwh_usage = 0.0\n (0..23).each do |i|\n cumulative_hourly_kwh_usage += self.total_hour_kwh_usage_on(date, i)\n #puts cumulative_hourly_kwh_usage.to_s\n end\n cumulative_hourly_kwh_usage\n end",
"def dates_requiring_data\n collected = Dir.glob(File.join(@config[:data_dir], \"*-*-*.{csv,espi}\")).map { |f| File.basename(f).split(\".\")[0] }\n all_days = []\n\n count_of_days = (Date.today - @config[:start_date]).to_i\n\n count_of_days.times do |i|\n all_days << (@config[:start_date] + i).strftime(\"%Y-%m-%d\")\n end\n\n (all_days - collected).map { |d| Date.parse(d) }\n end",
"def total(options = {})\n extra = {}\n response = total_by_time_period(options)\n extra = { error: response[:error] } if response[:error].present?\n { query: options[:query], total: response[:results].map { |item| item[:count] }.reduce(:+), calls: response[:calls] }.merge!(extra)\n end",
"def set_dates(results)\n date_dimension = []\n for result in results\n stored_element = date_dimension.detect { |element| element[:date].to_s == result.send(:date).to_s }\n if stored_element\n stored_element[:value][:pageviews] += result.send(:pageviews).to_i\n stored_element[:value][:unique_pageviews] += result.send(:unique_pageviews).to_i\n else\n date_dimension << {:date => result.send(:date).to_s, :value => {:pageviews => result.send(:pageviews).to_i, :unique_pageviews => result.send(:unique_pageviews).to_i} }\n end\n result.date_dimension = date_dimension\n end\n end",
"def total_invoice_amount(start_date, end_date)\n total = 0\n projects.each do |project|\n total += project.invoices.where(due_on_date: start_date...end_date).map(&:total_amount_inc_vat).sum\n end\n total\n end",
"def statistic\n @daily_amounts = Order\n .joins(:sales)\n .where(:status_id => Status.find_by_name(:closed).id)\n .select(\"date(orders.created_at) as 'date', sum(count) as 'count', sum(count*price) as 'day_sum'\")\n .order(\"date(orders.created_at) desc\")\n .group(\"date(orders.created_at)\")\n\n respond_to do |format|\n format.html # fillhtml.erb\n format.json { render json: @orders }\n end\n end",
"def calculate\n calculate_for_dates(bucket_dates)\n end",
"def index\n @daily_totals = DailyTotal.all\n end",
"def get_total_diners_for_current_time(date_and_time)\n @diners_at_same_start_time = 0\n @bookings_at_same_start_time = []\n\n @bookings_at_same_start_time = Booking.where(\"booking_date_time BETWEEN ? AND ?\", date_and_time,(date_and_time+15.minutes)).where(:status => \"Confirmed\")\n @diners_at_same_start_time = @bookings_at_same_start_time.to_a.sum do |booking_at_same_start_time|\n booking_at_same_start_time.number_of_diners\n end\n return @diners_at_same_start_time\n end",
"def total_payments_data(period_data = 'this_month')\n res = payments.completed\n range, daily_report = period_data.to_s.report_period_to_range\n data = [[period_data.to_s.report_period_to_title, I18n.t('number.currency.format.unit')]]\n range.each{|d| data << [d.strftime(daily_report ? '%d' : '%Y-%m'), res.where(payment_at: d.beginning_of_day..(daily_report ? d.end_of_day : d.end_of_month.end_of_day)).count(:id)] }\n data\n end",
"def dni_total_date(_project, _from, _to, _office)\n if _office.nil?\n delivery_note_items.joins(:delivery_note).where(\"delivery_notes.project_id in (?) AND delivery_notes.delivery_date >= ? AND delivery_notes.delivery_date <= ?\",_project,_from,_to).select('SUM(delivery_note_items.quantity * delivery_note_items.cost) dni_t')\n else\n delivery_note_items.joins(:delivery_note,:project).where(\"delivery_notes.project_id in (?) AND delivery_notes.delivery_date >= ? AND delivery_notes.delivery_date <= ? AND projects.office_id = ?\",_project,_from,_to, _office).select('SUM(delivery_note_items.quantity * delivery_note_items.cost) dni_t')\n end\n end",
"def dni_total_date(_project, _from, _to, _office)\n if _office.nil?\n delivery_note_items.joins(:delivery_note).where(\"delivery_notes.project_id in (?) AND delivery_notes.delivery_date >= ? AND delivery_notes.delivery_date <= ?\",_project,_from,_to).select('SUM(delivery_note_items.quantity * delivery_note_items.cost) dni_t')\n else\n delivery_note_items.joins(:delivery_note,:project).where(\"delivery_notes.project_id in (?) AND delivery_notes.delivery_date >= ? AND delivery_notes.delivery_date <= ? AND projects.office_id = ?\",_project,_from,_to, _office).select('SUM(delivery_note_items.quantity * delivery_note_items.cost) dni_t')\n end\n end",
"def daily_aggregate_data\n data = FbPost.select(\"count(*) AS post_count,sum(likes) as likes, sum(comments) as comments, sum(shares) as shares,sum(replies_to_comment) as replies_to_comment\").\n where(account_id: self.id).to_a.first\n if data\n z = self.graph_api.get_object self.object_name\n options = {:likes=>data.likes, \n :comments=>data.comments,\n :shares=>data.shares,\n :posts => data.post_count,\n :replies_to_comment => data.replies_to_comment\n }\n if z['likes']\n options[:total_likes]=z['likes']\n today_page.total_likes=z['likes']\n end\n if z['talking_about_count']\n options[:total_talking_about] = z['talking_about_count']\n today_page.total_talking_about=z['talking_about_count']\n end\n curr_date = Time.zone.now.middle_of_day\n options[:post_created_time] = curr_date\n if today_page.total_likes && yesterday_page && yesterday_page.total_likes\n today_page.fan_adds_day =today_page.total_likes - yesterday_page.total_likes\n end\n today_page.update_attributes options\n today_fbpage.update_attributes options # for table fbpages\n logger.debug \" daily_aggregate_data for #{curr_date.to_s(:db)}\"\n else\n logger.debug \" daily_aggregate_data NOT RECORDS for \"\n end\n end",
"def day_stats\n days = Array.new(7){0}\n @file.each do |line|\n date = line[:regdate].split(\" \")\n date = Date.strptime(date[0],\"%m/%d/%y\")\n days[date.wday.to_i] += 1\n end\n days.each_with_index{ |counter, days| puts \"#{days}: #{counter}\"}\n\n end",
"def breastfed_quantity_today \n breastfeedings.where(\"created_at >= :start_at AND created_at <= :end_date\", {start_at: Time.now.beginning_of_day, end_date: Time.now}).sum(:quantity) \n end",
"def calls_by_date_data\n response = api_request(:timeseries, {fields: 'total_calls,missed_calls'})\n data = response['data']\n total_calls = data.map { |day| [day[\"date\"], day[\"total_calls\"]] }\n missed_calls = data.map { |day| [day[\"date\"], day[\"missed_calls\"]] }\n\n [\n { name: \"Total Calls\", data: total_calls },\n { name: \"Missed Calls\", data: missed_calls }\n ]\n end",
"def aggregate_data_daily start_date=7.days.ago, end_date=Time.now\n start_date = Time.zone.parse start_date if String === start_date\n end_date = Time.zone.parse end_date if String === end_date\n current_date = start_date.beginning_of_day\n # reload @my_account_pages\n my_account_pages(true)\n my_arr = []\n my_posts = fb_posts.reload.select(\"DATE_FORMAT(post_created_time,'%Y%m%d') AS post_date,likes, comments, shares, replies_to_comment\").\n where(\"post_created_time > '#{current_date}'\").to_a \n while current_date < end_date do\n logger.debug \" aggregate_data_daily for #{current_date.to_s(:db)}\"\n posts= my_posts.select{|po| po.post_date == current_date.strftime('%Y%m%d')}\n \n=begin\n data = FbPost.select(\"count(*) AS post_count,sum(likes) as likes, sum(comments) as comments, sum(shares) as shares,sum(replies_to_comment) as replies_to_comment\").\n where(account_id: self.id).\n where(post_type: 'original').\n where(post_created_time: current_date..current_date.end_of_day).to_a.first\n=end\n rec = my_account_pages.detect{|pa| pa.post_date==current_date.strftime('%Y%m%d')}\n # if posts.size > 0\n options = construct_sum posts\n # p \" AAA #{current_date.strftime('%Y%m%d')} #{options}\"\n rec = my_account_pages.detect{|pa| pa.post_date==current_date.strftime('%Y%m%d')}\n if rec\n rec.update_attributes options\n else\n options[:post_created_time] = current_date.middle_of_day\n options[:account_id] = self.id\n options[:object_name] = self.object_name\n rec = FbPage.create options\n end\n # else\n # logger.debug \" aggregate_data_daily NOT RECORDS for #{start_date.to_s(:db)} .. #{end_date.to_s(:db)}\"\n # end\n current_date += 1.day\n end\n end",
"def stats_by_date from_date, to_date\n events_by_date = campaign_finance_transactions.group(:sub_type)\n .select(:sub_type)\n .group(:transaction_date)\n .select(:transaction_date)\n .sum(:amount)\n\n types = campaign_finance_transactions.select(:sub_type).uniq.pluck(:sub_type)\n\n (from_date..to_date).map{ |date|\n {\n date: date,\n }.merge(\n types.reduce(Hash.new) {|hash, type|\n hash[type.to_sym] = events_by_date[[type, date]]\n hash\n }\n )\n }\n end",
"def bi_total_date(_project, _from, _to, _group)\n if _group.nil?\n budget_items.joins(:budget).where(\"budgets.project_id in (?) AND budgets.approval_date >= ? AND budgets.approval_date <= ?\",_project,_from,_to).select('SUM(budget_items.amount) bi_t')\n else\n budget_items.joins(:budget,:charge_account).where(\"budgets.project_id in (?) AND budgets.approval_date >= ? AND budgets.approval_date <= ? AND charge_accounts.charge_group_id = ?\",_project,_from,_to, _group).select('SUM(budget_items.amount) bi_t')\n end\n end",
"def index\n @orders = Order.all\n\n @orders_this_month = Order.where(created_at: Time.now.beginning_of_month..Time.now.end_of_month)\n @sales = []\n @orders_this_month.each do |order| \n @sales.push(order.total)\n end\n @total_sales_this_month = @sales.reduce(:+)\n end",
"def revenue(date)\n end",
"def group_by_day\n\n\tend",
"def total\n sum = 0\n\n @four_result.each do |result|\n sum += result\n end\n @six_result.each do |result|\n sum += result\n end\n @eight_result.each do |result|\n sum += result\n end\n @ten_result.each do |result|\n sum += result\n end\n @twelve_result.each do |result|\n sum += result\n end\n @twenty_result.each do |result|\n sum += result\n end\n @percentile_result.each do |result|\n sum += result\n end\n\n sum\n end",
"def calc_graph_labels_and_series_data\n # Index as we are going to increment \n # it for every iteration\n index_date = @range[:start_date]\n\n (index_date..@range[:end_date]).each do |idate|\n count = impressions\n .where(created_at: ((idate.at_beginning_of_day)..(idate.end_of_day)))\n .length\n @views.push(count)\n @dates.push(idate)\n index_date = index_date + 1.day\n end\n end",
"def consolidate_week \n \t#grab last 30 days\n t = Time.zone.local(2012,12,10);\n\n \trefEntry = self.energy_data.where(:month => t.month, :day => t.day).last\n \tputs \"REFENTRY\", refEntry.nil?\n refDay = refEntry.day\n puts \"PASTDAY\"\n tmp_refDay = refDay\n \trefMonth = refEntry.month\n \tcount = (0..30).to_a\n \t@dateCount = Array.new\n \t@weekTotals = Array.new\n \tsubCount = 0\n\n #creating date array for weekTotals, assumes each month has 31 days\n \tcount.each do |var|\n \t\tif (tmp_refDay - subCount) > 0\n \t\t\t@dateCount << [tmp_refDay - subCount, refMonth]\n \t\telse\n tmp_refDay = 30\n \t\t\trefMonth = refMonth - 1\n \t\t\tsubCount = 0\n \t\t\t@dateCount << [tmp_refDay - subCount, refMonth]\n \t\tend\n \t\tsubCount = subCount + 1\n \tend\n\n \tarrayCount = 0\n\n \t@dateCount.each do |day, month|\n puts day, \" \", month\n temp_Obj = self.energy_data.where(:day=>day, :month=>month).last\n \t\tif month== t.month && day == t.day\n @weekTotals[arrayCount] = [Time.utc(2012, temp_Obj.month, temp_Obj.day).to_i*1000, self.energy_data.where(:day => day, :month => month, :hour=>(1..t.hour)).sum(\"power\")/1000]\n else\n @weekTotals[arrayCount] = [Time.utc(2012, temp_Obj.month, temp_Obj.day).to_i*1000, self.energy_data.where(\"day=#{day} AND month=#{month}\").sum(\"power\")/1000]\n \t\tend\n arrayCount = arrayCount + 1\n \tend\n\n # return both because @weekTotals must be 0-indexed, @dateCount has actual dates\n \treturn @dateCount, @weekTotals\n end",
"def calculate_total_amount\n total_days = (self.end_date - self.start_date).to_i\n self.update_column(:total_amount, total_days * self.room.room_type.price)\n end",
"def total_price\n\t price = listing.price\n\t num_dates = (start_date..end_date).to_a.length\n\t return price * num_dates\n\tend",
"def sum\n @num1 = params[:bike.days]\n @num2 = params[:bike.price]\n @result = Calculator.total(@num1.to_i, @num2.to_i)\n end",
"def total\n sum(:total)\n end",
"def get_view_and_redemption_count_by_day(deals, start_date, end_date, total)\n overall_deals_array = Array.new\n deals.each do |d|\n num_view_array = Array.new\n num_redeem_array = Array.new\n deal_array = Array.new\n view_start_date = Viewcount.where(:deal_id => d.id).order(created_at: :asc).first\n if view_start_date.blank?\n view_start_date = DateTime.now.in_time_zone(\"Singapore\").beginning_of_day\n else\n view_start_date = view_start_date.created_at.beginning_of_day\n end\n temp = view_start_date\n\n # If start date of deal is after given start date, we will start from deal start date\n if d.start_date > start_date\n redemption_start_date = d.start_date.in_time_zone(\"Singapore\").beginning_of_day\n else\n redemption_start_date = start_date.in_time_zone(\"Singapore\").beginning_of_day\n end\n\n # If end date of deal is before given end date, we will end at deal end date\n if d.expiry_date < end_date\n temp_end_date = d.expiry_date.in_time_zone(\"Singapore\").end_of_day\n else\n temp_end_date = end_date.in_time_zone(\"Singapore\").end_of_day\n end\n\n deal_array << d.title\n deal_array << Time.parse((redemption_start_date).to_s).to_f * 1000\n\n if total\n while view_start_date <= temp_end_date\n num_view_array << Viewcount.where(deal_id: d.id).where(created_at: d.created_at..view_start_date.to_datetime.in_time_zone(\"Singapore\").end_of_day).count\n view_start_date = view_start_date + 1.days\n end\n\n while redemption_start_date <= temp_end_date\n num_redeem_array << Redemption.where(deal_id: d.id).where(created_at: d.created_at..redemption_start_date.to_datetime.in_time_zone(\"Singapore\").end_of_day).count\n redemption_start_date = redemption_start_date + 1.days\n end\n else\n while view_start_date <= temp_end_date\n num_view_array << Viewcount.where(deal_id: d.id).where(created_at: view_start_date.beginning_of_day..view_start_date.to_datetime.in_time_zone(\"Singapore\").end_of_day).count\n view_start_date = view_start_date + 1.days\n end\n\n while redemption_start_date <= temp_end_date\n num_redeem_array << Redemption.where(deal_id: d.id).where(created_at: redemption_start_date.beginning_of_day..redemption_start_date.to_datetime.in_time_zone(\"Singapore\").end_of_day).count\n redemption_start_date = redemption_start_date + 1.days\n end\n end\n deal_array << num_view_array\n deal_array << num_redeem_array\n deal_array << Time.parse((temp).to_s).to_f * 1000\n overall_deals_array << deal_array\n end\n overall_deals_array\n end",
"def total\n @data['total']\n end",
"def get_grand_total_one_month\n\t$pokitdok_call.each do |drug|\n\t$total_cost << drug['retail']['total_cost_30_day']['amount'].to_f\n\tend\n\t\n\tsum_total_cost = $total_cost.inject(:+)\nend",
"def convertDailyToMonthlyData()\n aggregateData(ChartDirector::ArrayMath.new(@timeStamps).selectStartOfMonth())\n end",
"def data_for(date)\n UseLog::Data.find_all_by_date(date).collect do |log|\n [log.category, log.count]\n end\n end",
"def sum attribute, days_ago\n @stats[days_ago] ||= {}\n @stats[days_ago][attribute] ||= @wars[days_ago] ? @wars[days_ago].collect{ |war| war[attribute].to_i }.inject(0, :+) : 0\n end",
"def calc_daily_credit_debit\n credit = Transaction.sum(:amount, :conditions => \"date IS '#{Date.current}' AND sign IS 'c' \") # change this to transactiontype_id 1\n debit = Transaction.sum(:amount, :conditions => \"date IS '#{Date.current}' AND sign IS 'd' \") # change this to transactiontype_id 4 (2 + 5)\n @dailytotal = credit - debit\n return @dailytotal\n end",
"def summarise days = 7, debug = nil\n days = days.to_i\n data = [ ]\n file = self.get_summary_file.gsub 'summary', 'daily'\n daily = self.class.get_json file\n start_date = 0\n d = nil\n last = 0\n prev = 0\n cut_off_date = ( DateTime.now - days ).to_s\n File.open( self.get_log_file, 'r' ).each_line do | line |\n begin\n line = JSON.parse line\n rescue\n line = nil\n end\n if line and line['timestamp'] and ( last != line['message']['usage'] )\n next if ( cut_off_date > line['timestamp'] )\n new_line = []\n d = line['timestamp'][2..3] + line['timestamp'][5..6] + line['timestamp'][8..9] # compact version of date\n ts = Time.parse( line['timestamp'] ).strftime '%s'\n ts = ts.to_i\n ts = ts - start_date\n if start_date == 0\n # start_date = ts # can't get this delta working\n end\n new_line << ts\n smoothedUsage = line['message']['usage'].to_i\n if last != 0 and prev != 0\n smoothedUsage = ( smoothedUsage + last + prev ) / 3 # average of last 3 readings\n end\n new_line << smoothedUsage\n if line['message']['annotation'] and line['message']['annotation']['title'] and line['message']['annotation']['text']\n new_line << line['message']['annotation']['title']\n new_line << line['message']['annotation']['text']\n end\n data << new_line\n if (( ! daily[d] ) or ( line['message']['today'].to_i > daily[d]['today'].to_i ))\n daily[d] = line['message']\n daily[d].delete 'usage'\n end\n prev = last\n last = line['message']['usage'].to_i\n end\n end\n if data and data.first\n if data.first.first != start_date\n data.first[0] += start_date\n end\n end\n summary_file = self.get_summary_file\n File.open( summary_file, 'w' ) do |file|\n file.write( JSON.pretty_generate( data ))\n end\n File.open( summary_file.gsub( 'summary', 'daily' ), 'w' ) do | file |\n file.write daily.to_json.to_s\n end\n File.open( summary_file.gsub( 'summary', 'daily.' + d ), 'w' ) do | file |\n file.write daily.select { |key| key == daily.keys.last }.to_json.to_s\n end\n end",
"def index\n @gios_measurments = GiosMeasurment.all\n @days = @gios_measurments.order(\"calc_date desc\").pluck(:calc_date).uniq.collect { |d| d = d ? d.strftime(\"%Y-%m-%d\") : DateTime.now.strftime(\"%Y-%m-%d\") }.uniq\n @date = params[:date] ? Date.parse(params[:date]) : Date.today\n end",
"def index\n @summaries = Summary.all\n @accounts = Account.all\n\n dailyTotals = DailyTotal.all\n monthlyTotals = MonthlyTotal.all\n\n # Calculating the monthly total by adding daily total values\n monthlyTotals.each { |mt|\n dailyTotals.each { |dt|\n if dt.date.year == mt.year && dt.date.month == mt.month\n mt.total += dt.total\n end\n } # end of inner dailyTotal loop\n } # end of monthlyTotal loop\n\n # For linechart to display monthly total spendings\n @mTotals = Array.new\n monthlyTotals.each { |mt|\n case mt.month\n when 1\n @mTotals.push([\"January\",mt.total.to_f])\n when 2\n @mTotals.push([\"February\",mt.total.to_f])\n when 3\n @mTotals.push([\"March\",mt.total.to_f])\n when 4\n @mTotals.push([\"April\",mt.total.to_f])\n when 5\n @mTotals.push([\"May\",mt.total.to_f])\n when 6\n @mTotals.push([\"June\",mt.total.to_f])\n when 7\n @mTotals.push([\"July\",mt.total.to_f])\n when 8\n @mTotals.push([\"August\",mt.total.to_f])\n when 9\n @mTotals.push([\"September\",mt.total.to_f])\n when 10\n @mTotals.push([\"October\",mt.total.to_f])\n when 11\n @mTotals.push([\"November\",mt.total.to_f])\n when 12\n @mTotals.push([\"December\",mt.total.to_f])\n end\n }\n\n @balanceSummary = Array.new\n @accounts.each { |account|\n @balanceSummary.push ([account.name,account.balance.to_f])\n }\n end",
"def real_total_in_period(center_id, start, stop)\n\t\tstop_date = stop.blank? && \"Now()\" || \"'#{stop.to_s(:db)}'\"\n\t\tquery = []\n\t\tquery << \"select center_id, survey_id, count(id) as used from survey_answers \"\n\t\tquery << \"where done = 1 and center_id = #{center_id.to_i} \"\n\t\tquery << \"and created_at between '#{start.to_s(:db)}' and #{stop_date} \"\n\t\t# query << \"and created_at between '2013-12-10' and '2015-09-03 20:48:55' \"\n\t\tquery << \"group by center_id, survey_id\"\n\n\t\tcount = ActiveRecord::Base.connection.execute(query.join).each(:as => :hash).inject(PeriodCount.new) do |p,j| \n\t\t\tkey = j['survey_id']\n\t\t\tp.start = start\n\t\t\tp.stop = stop\n\t\t\tp.center_id = center_id.to_i\n\t\t\tp.per_survey ||= {} #j['used']\n \t\tp.per_survey[key] ||= []\n \t\tp.per_survey[key] = j['used']\n \t\t\tp\n \tend\n\tend",
"def get_customer_payments_value(fecha1,fecha2,id)\n\n facturas = CustomerPayment.where([\" company_id = ? AND fecha1 >= ? and fecha1 <= ? and bank_acount_id = ?\", self.id, \"#{fecha1} 00:00:00\",\"#{fecha2} 23:59:59\" , id]).order(:id)\n ret = 0 \n if facturas \n ret=0 \n for factura in facturas \n ret += factura.total\n end\n end \n return ret \n end",
"def get_customer_payments_value(fecha1,fecha2,id)\n\n facturas = CustomerPayment.where([\" company_id = ? AND fecha1 >= ? and fecha1 <= ? and bank_acount_id = ?\", self.id, \"#{fecha1} 00:00:00\",\"#{fecha2} 23:59:59\" , id]).order(:id)\n ret = 0 \n if facturas \n ret=0 \n for factura in facturas \n ret += factura.total\n end\n end \n return ret \n end",
"def forecast_charged(date_from, date_to)\n result = {total: 0, detail: {}}\n month = date_from.month \n year = date_from.year\n last_month = date_to.month\n last_year = date_to.year\n until (month == last_month && year == last_year) do\n result[:detail].store(\"#{year}-#{month.to_s.rjust(2, '0')}\", 0)\n if month == 12\n month = 1\n year += 1\n else\n month += 1\n end\n end\n data = query_strategy.forecast_charged(date_from, date_to)\n data.each do |item| \n result[:total] += item.total\n result[:detail][item.period] += item.total\n end\n return result\n end",
"def today_feed_volume\n feed_today.sum(:volume)\n end",
"def report_daily_totals\n report.all(\"[data-testid=\\\"report-daily-total\\\"] li\").map(&:text)\n end",
"def events_per_day\n city = City.find(params[:city_id])\n @events = city.events.month(params[:year], params[:month])\n days = {}\n (1..31).each do |d|\n days[d] = 0\n end\n\n @events.each do |e|\n days[e.start_time.day] += 1\n end\n\n respond_to do |format|\n format.json { render :json => days}\n end\n end",
"def totals\n @title = 'Sales Totals'\n sql = \"SELECT DISTINCT YEAR(created_on) as year \"\n sql << \"FROM orders \"\n sql << \"ORDER BY year ASC\"\n @year_rows = Order.find_by_sql(sql)\n @years = Hash.new\n # Build a hash containing all orders hashed by year.\n for row in @year_rows\n @years[row.year] = Order.get_totals_for_year(row.year)\n end\n end",
"def get_grand_total_one_month\n\t\t$pokitdok_call.each do |drug|\n\t\t$total_cost << drug['retail']['total_cost_30_day']['amount'].to_f\n\t\tend\n\n\t\tsum_total_cost = $total_cost.inject(:+)\n\tend",
"def main_chart total_days, models\n content_tag :div, { id: 'chart_data', style: 'display:none;', 'data-custom-fdate' => total_days } do\n models.each_with_index.map do |model, i|\n filters = relevant_filters model\n content_tag :div, { id: \"serie_#{i+1}\", \"data-custom-label\" => I18n.t(\"activerecord.models.#{model.to_s.underscore.downcase}.other\")} do\n (0..total_days).to_a.collect do |day|\n concat content_tag(:span, daily_count(model, total_days-day, filters), class: day, style: 'display:none;', \"data-custom-date\" => (total_days-day).days.ago.to_i*1000)\n end\n end\n end.join.html_safe\n end.html_safe\n end",
"def total_sum\n rows.collect(&:sum_with_vat).sum\n end",
"def mark_total an_date\n the_count = marks.select{|m| m.mark_date == an_date}.count\n the_count == 0 ? \"\" : the_count \n end",
"def total_month_kwh_usage_until(date)\n raise \"Invalid argument: Please use a date value that is not in the future\" if (date > Time.now.utc.to_date)\n\n cumulative_daily_kwh_usage = 0.0\n (1..date.day).each do |i|\n cumulative_daily_kwh_usage += self.total_day_kwh_usage_on(date - i.day)\n end\n cumulative_daily_kwh_usage\n end",
"def new_total_current_tb(start_date=Time.now, end_date=Time.now, section=nil)\n value = []\n\n start_date = @@start_date.to_date.strftime('%Y-%m-%d 00:00:00')\n end_date = @@end_date.to_date.strftime('%Y-%m-%d 23:59:59')\n\n patients = FlatCohortTable.find_by_sql(\"SELECT ftc.patient_id FROM flat_cohort_table ftc\n LEFT OUTER JOIN flat_table1 ft1 ON ft1.patient_id = ftc.patient_id\n WHERE ftc.date_enrolled >= '#{start_date}'\n AND ftc.date_enrolled <= '#{end_date}'\n AND (ft1.pulmonary_tuberculosis = 'Yes' OR\n ft1.extrapulmonary_tuberculosis = 'Yes' OR\n ft1.who_stages_criteria_present IN ('Extrapulmonary tuberculosis (EPTB)', 'Pulmonary tuberculosis', 'Pulmonary tuberculosis (current)'))\n GROUP BY ftc.patient_id\").collect{|p| p.patient_id}\n\n value = patients unless patients.blank?\n end",
"def total\n count = 0\n self.total_time_exercise_workouts.each do |ex|\n count += ex.duration\n end\n count\n end",
"def event_tickets_sold_data(period_data = 'this_month')\n res = event_payments\n range, daily_report = period_data.to_s.report_period_to_range\n data = [[period_data.to_s.report_period_to_title, I18n.t('number.currency.format.unit')]]\n range.each{|d| data << [d.strftime(daily_report ? '%d' : '%Y-%m'), res.where(payment_at: d.beginning_of_day..(daily_report ? d.end_of_day : d.end_of_month.end_of_day)).sum(:amount).to_f] }\n data\n end",
"def daily_statistics start_on = Date.today, end_on = Date.today, local_time_zone = true\n self.get_statistics('ox.publisherDailyStatistics', start_on, end_on, local_time_zone)\n end",
"def totals\n\t\tis_test = Rails.env == 'test' ? :test : :live\n\t\t@totals = Solr.get_totals(is_test)\n#\t\tresults = [ { :name => 'NINES', :total_docs => 400, :total_archives => 12}, { :name => '18thConnect', :total_docs => 800, :total_archives => 24 } ]\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @totals }\n\t\t\tformat.xml # index.xml.builder\n\t\tend\n\tend",
"def sum\n\t\tprintf(\"%02i.%i\\n\", @options[:monat], @options[:jahr])\n\t\t@db.execute(\"select summe, gemeinsam from sum_#{@options[:name]} where jahr = #{@options[:jahr]} and monat = #{@options[:monat]} \") do |row|\n\t\t\tprintf(\"(%s) % .2f EUR \\n\", row[1], row[0])\n\t\tend\n\tend",
"def chart\n data = case params[:kind]\n when 'number_of_users'\n @title = 'Number of users '\n User.group('DATE_TRUNC(\\'month\\', created_at)').count\n when 'number_of_loves'\n @title = 'Number of Loves'\n ActsAsVotable::Vote.group('DATE_TRUNC(\\'month\\', created_at)').count\n when 'number_of_comments'\n @title = 'Number of comments'\n Comment.unscoped.group('DATE_TRUNC(\\'month\\', created_at)').count\n when 'number_of_shares'\n @title = 'Number of shares'\n Share.group('DATE_TRUNC(\\'month\\', created_at)').count\n when 'monthly_active_users'\n @title = 'Monthly active users'\n votes = ActsAsVotable::Vote.group('DATE_TRUNC(\\'month\\', created_at)').count\n comments = Comment.unscoped.group('DATE_TRUNC(\\'month\\', created_at)').count\n shares = Share.group('DATE_TRUNC(\\'month\\', created_at)').count\n votes\n .merge(comments) { |k, a_value, b_value| a_value + b_value }\n .merge(shares) { |k, a_value, b_value| a_value + b_value }\n when 'joined_last_month'\n @title = 'Joined last month'\n User.group('DATE_TRUNC(\\'day\\', created_at)').where(created_at: Date.today.beginning_of_month..Date.today.end_of_month).count\n else #net_promoter_score\n @title = 'Net promoter score'\n PhoneNumberInvitation.uniq.group('DATE_TRUNC(\\'month\\', created_at)').count(:user_id)\n end\n\n # data manipulation\n @data = []\n prev_key, year = nil, Time.current.year\n data.sort.each do |k ,v|\n k = k.to_date\n if params[:kind] == 'joined_last_month'\n (prev_key.next...k).each{|d| @data << [d.strftime('%d'), 0, \"#{d.to_s(:long)} = 0\"] } if prev_key.present?\n @data << [k.strftime('%d'), v, \"#{k.to_s(:long)} = #{v}\"]\n else\n k = k.beginning_of_month\n (prev_key.next..k.yesterday).select{|d| d.day == 1 }.each{|d| @data << [d.strftime(year == d.year ? '%m' : '%y/%-m'), 0, \"#{d.strftime(\"%B, %Y\")} = 0\"] } if prev_key.present?\n @data << [k.strftime(year == k.year ? '%m' : '%y/%-m'), v, \"#{k.strftime(\"%B, %Y\")} = #{v}\"]\n end\n prev_key = k\n end\n\n render partial: 'chart'\n end",
"def grafico_total_por_fecha(params = {})\n if params[:data]\n data = params[:data]\n else\n fecha = params[:fecha]\n data = ParteDiario.total_por_fecha(fecha)\n end\n ret_tipo = params[:return]\n fecha_ini = data.first[:fecha]\n fecha_fin = data.last[:fecha]\n public = \"/informes/#{fecha_fin.strftime(\"%Y/%m\")}\"\n if fecha_ini == fecha_ini.at_beginning_of_month && fecha_fin == fecha_ini.at_end_of_month\n tit = I18n.l fecha_ini, :format => \"%B de %Y\"\n else\n tit = \"(30 días) hasta el #{I18n.l fecha_fin, :format => \"%d de %B de %Y\"}\"\n end\n\n g = Gruff::Line.new(550)\n g.theme = THEME_REPORT\n g.marker_font_size = 14\n g.title_font_size = 20\n g.x_axis_label = \"día\"\n dias = {}\n data.each_index{|i| dias[i] = data[i][:fecha].strftime(\"%d\")}\n g.labels = dias\n # Grafica de GAS\n if params[:tipo] == 'gas'\n g.title = \"Producción de Gas #{tit}\"\n g.y_axis_label = \"Miles Pies cúbcos\"\n img = \"#{public}/gas-total-hasta-#{fecha_ini.strftime(\"%d-%m-%Y\")}.png\"\n g.data(\"GAS\", data.map{|v| v.try(:entregado_gasoducto).to_f})\n #Grafica de liquidos\n else\n g.title = \"Producción de Líquidos #{tit}\"\n g.y_axis_label = \"Barriles (BBL)\"\n img = \"#{public}/liquidos-total-hasta-#{fecha_ini.strftime(\"%d-%m-%Y\")}.png\"\n g.data(\"Petroleo\", data.map{|v| v.try(:petroleo).to_f})\n g.data(\"Condensado\", data.map{|v| v.try(:condensado).to_f})\n g.data(\"Gasolina\", data.map{|v| v.try(:gasolina).to_f})\n g.data(\"Suma Líqudos\", data.map{|v| v.try(:gasolina).to_f + v.try(:condensado).to_f + v.try(:petroleo).to_f})\n end\n \n makedirs(Rails.public_path + public)\n #g.normalize\n #g.minimum_value = \n case ret_tipo\n when 'i'\n g.write(Rails.public_path + img)\n return \"<img src=\\\"#{img}\\\" alt=\\\"Producción gas\\\" />\"\n when 'b'\n g.to_blob(\"PNG\")\n else\n g.write(Rails.public_path + img)\n return \"<img src=\\\"#{img}\\\" alt=\\\"Producción gas\\\" />\"\n end\n \n end",
"def data_collector collection, factor, duration\n your_data, comparison_data = [], [], []\n uniq_exam_dates = collection.map(&:exam_date).uniq\n if duration == \"12\"\n Date.today.month.times do |count|\n your_temp_data, todays_data = [], []\n collection.where(exam_date:(Time.now-count.month).all_month()).each do |report|\n your_temp_data << report.send(:\"#{factor}\")\n end\n Report.where(exam_date: (Time.now-count.month).all_month(), school_id:current_user.school.id).each do |m|\n todays_data << (m.send(:\"#{factor}\")).round(2) rescue 0\n end\n comparison_data << average(todays_data)\n your_data << average(your_temp_data)\n end\n else\n uniq_exam_dates.each do |date|\n your_temp_data,todays_data = [], []\n collection.where(exam_date:date).each do |report|\n your_temp_data << report.send(:\"#{factor}\")\n end\n Report.where(exam_date:date, school_id:current_user.school.id).each do |m|\n todays_data << (m.send(:\"#{factor}\")).round(2) rescue 0\n end\n comparison_data << average(todays_data)\n your_data << average(your_temp_data)\n end\n end\n your_data.reverse!\n comparison_data.reverse!\n factor == \"accuracy\" ? plot_accuracy(your_data, comparison_data) : plot_time_management(your_data, comparison_data)\n end",
"def suma_valores\n resultados = {}\n self.totales = {}\n self.totales_por_comprobante = {}\n\n # revisa todas las monedas\n EmpCuentab.monedas.each do |moneda, id_moneda|\n resultados[moneda] = {\n valor: 0.0,\n descuento: 0.0,\n desc_general: 0.0,\n subtotal: 0.0,\n iva: 0.0,\n ieps: 0.0,\n total: 0.0,\n }\n \n com_det_compra.where(moneda: moneda).each do |cdc|\n valor = cdc.precio * cdc.cantidad\n desc_cdc = valor * (cdc.descuento / 100)\n subtotal_temp = valor - desc_cdc\n desc_gral = subtotal_temp * (descuento / 100)\n subtotal = valor - desc_cdc - desc_gral\n iva = subtotal * (cdc.iva / 100)\n ieps = subtotal * (cdc.ieps / 100)\n total = subtotal + iva + ieps\n\n resultados[moneda][:valor] += valor\n resultados[moneda][:descuento] += desc_cdc\n resultados[moneda][:desc_general] += desc_gral\n resultados[moneda][:subtotal] += subtotal\n resultados[moneda][:iva] += iva\n resultados[moneda][:ieps] += ieps\n resultados[moneda][:total] += total\n\n # actualiza totales\n totales[moneda] = 0.0 unless totales[moneda]\n totales[moneda] += total\n\n # actualiza totales por comprobante\n comprobante = cdc.comprobante ? cdc.comprobante : \"Sin comprobante\"\n tipo_comp = cdc.tipo_comprobante ? cdc.tipo_comprobante : nil\n # total, moneda, nombre del departamento, id del departamento, comprobante, tipo de comprobante\n totales_por_comprobante[comprobante] = [0.0, nil, nil, nil, nil] unless totales_por_comprobante[comprobante]\n totales_por_comprobante[comprobante][0] += total\n totales_por_comprobante[comprobante][1] = cdc.moneda\n totales_por_comprobante[comprobante][2] = cdc.emp_locacion.nombre\n totales_por_comprobante[comprobante][3] = cdc.emp_locacion.id\n totales_por_comprobante[comprobante][4] = comprobante\n totales_por_comprobante[comprobante][5] = tipo_comp\n end\n end\n\n resultados\n end",
"def cumsum_data\n @data.elements.values.reverse.inject(Array.new(@data.num_values, 0)) { |sum, e| e.values.zip(sum).map{ |v, sum| v.value += sum } }\n end",
"def work_per_month(ary_work)\n nary = ary_work.group_by{ |t| \n t[:date] \n }.transform_values { |tasks|\n tasks.reduce(0) { |sum, t|\n sum + t[:time] \n }\n }.to_a.group_by { |e|\n e[0][0..6]\n }.transform_values { |tasks|\n tasks.reduce(0) { |sum, t|\n sum + t[1] \n } / tasks.length\n }\nend",
"def dates\n end",
"def summrize_stories(from_date, to_date = Date.today)\n stories = current_stories\n story_summaries = Array.new\n (from_date .. to_date).each{|current_date|\n if (current_date <= Date.today) then\n story_summaries << [current_date , aggrigate_story_size_by_date(current_date, stories)].flatten\n else\n story_summaries << [current_date , [nil, nil, nil]]\n end\n }\n story_summaries\n end",
"def add_and_return_array(data)\n # Create new array\n days = []\n # Loop through dates\n (1.week.ago.to_date..Date.today).each do |date|\n # Set datetime to beginning of day\n date = date.midnight\n # Push to hash into array\n days << { m: date, a: data[date] }\n end\n # return days as array\n days\n end",
"def values_by_date(level, date)\n\t\tcase level\n\t\twhen 0\n\t\t\t [personal_average_by_date(date)]\n\t\twhen 1\n\t\t\t [personal_average_by_date(date)] + [local_average_by_date(date)]\n\t\twhen 2\n\t\t\t [personal_average_by_date(date)] + [local_average_by_date(date)] + [global_average_by_date(date)]\n\t\twhen 3\n\t\t\t [personal_average_by_date(date)] + [local_average_by_date(date)] + [global_average_by_date(date)] + [super_average_by_date(date)]\n\t\tend\n\tend",
"def income_this_month\n Sale.past_month.sum(:total)\n end",
"def statistics start_on = Date.today, end_on = Date.today, local_time_zone = true\n daily_statistics start_on, end_on, local_time_zone\n end",
"def index\n #LOS ULTIMOS 12 MESES\n @sales_group_by_month = SalesCoffee.twelve_months_ago.group_by_month(:date_time).order(date_time: :asc ).sum(:price)\n @sales_quantity_twelve_months = SalesCoffee.twelve_months_ago.group_by_month(:date_time).order(date_time: :asc).count\n @sales_average_twelve_months = SalesCoffee.twelve_months_ago.group_by_month(:date_time).order(date_time: :asc).average(:price)\n\n #SEGUN ORIGEN\n @origen_twelve_months = SalesCoffee.twelve_months_ago\n @origen_six_months = SalesCoffee.six_months_ago\n @origen_three_months = SalesCoffee.three_months_ago\n @origen_last_month = SalesCoffee.last_month_ago\n\n #SEGUN MEZCLA\n @blend_name_twelve_months = SalesCoffee.twelve_months_ago\n @blend_name_six_months = SalesCoffee.six_months_ago\n @blend_name_three_months = SalesCoffee.three_months_ago\n @blend_name_last_month = SalesCoffee.last_month_ago\n end",
"def get_ptc_value_date(date, value)\n date_arr = date.split(\"-\")\n year = date_arr[0]\n month = date_arr[1]\n \n invoices = Invoice.where([\"invoices.return = '0' AND company_id = ? AND date_processed >= ? AND date_processed <= ?\", self.id, \"#{year}-#{month}-01 00:00:00\", \"#{year}-#{month}-31 23:59:59\"])\n ret = 0\n \n for invoice in invoices\n products = invoice.get_products\n \n for product in products\n if(value == \"profit\")\n ret += product.profit * product.curr_quantity\n elsif(value == \"tax\")\n ret += product.tax * product.curr_quantity\n elsif(value == \"price\")\n ret += product.price * product.curr_quantity\n elsif(value == \"total\")\n ret += (product.price + product.tax) * product.curr_quantity\n else\n ret += product.cost * product.curr_quantity\n end\n end\n end\n \n return ret\n end",
"def get_ptc_value_date(date, value)\n date_arr = date.split(\"-\")\n year = date_arr[0]\n month = date_arr[1]\n \n invoices = Invoice.where([\"invoices.return = '0' AND company_id = ? AND date_processed >= ? AND date_processed <= ?\", self.id, \"#{year}-#{month}-01 00:00:00\", \"#{year}-#{month}-31 23:59:59\"])\n ret = 0\n \n for invoice in invoices\n products = invoice.get_products\n \n for product in products\n if(value == \"profit\")\n ret += product.profit * product.curr_quantity\n elsif(value == \"tax\")\n ret += product.tax * product.curr_quantity\n elsif(value == \"price\")\n ret += product.price * product.curr_quantity\n elsif(value == \"total\")\n ret += (product.price + product.tax) * product.curr_quantity\n else\n ret += product.cost * product.curr_quantity\n end\n end\n end\n \n return ret\n end",
"def get_ptc_value_date(date, value)\n date_arr = date.split(\"-\")\n year = date_arr[0]\n month = date_arr[1]\n \n invoices = Invoice.where([\"invoices.return = '0' AND company_id = ? AND date_processed >= ? AND date_processed <= ?\", self.id, \"#{year}-#{month}-01 00:00:00\", \"#{year}-#{month}-31 23:59:59\"])\n ret = 0\n \n for invoice in invoices\n products = invoice.get_products\n \n for product in products\n if(value == \"profit\")\n ret += product.profit * product.curr_quantity\n elsif(value == \"tax\")\n ret += product.tax * product.curr_quantity\n elsif(value == \"price\")\n ret += product.price * product.curr_quantity\n elsif(value == \"total\")\n ret += (product.price + product.tax) * product.curr_quantity\n else\n ret += product.cost * product.curr_quantity\n end\n end\n end\n \n return ret\n end",
"def user_count_by_month(type)\n result = Hash.new(0)\n time = type\n title_graph = ''\n x_axsis = ''\n case time\n when 'month'\n users = @users.where(:created_at => Time.now.beginning_of_month..Time.now.end_of_month)\n users.group_by{ |m| m.created_at.beginning_of_day}.each do |key, value|\n aux = key.to_s.split('-')\n result[\"#{aux[2].split(' ')[0]}-#{aux[1]}-#{aux[0]}\"] = value.count\n end\n title_graph = 'Usuarios nuevos durante el ultimo mes'\n x_axsis = 'Días'\n when 'year'\n users = @users.where(:created_at => Time.now.beginning_of_year..Time.now.end_of_year)\n users.group_by{ |m| m.created_at.beginning_of_month }.each do |key, value|\n aux = key.to_s.split('-')\n result[\"#{aux[1]}-#{aux[0]}\"] = value.count\n end\n title_graph = 'Usuarios nuevos durante el ultimo año'\n x_axsis = 'Meses'\n else\n users = @users\n users.group_by{ |m| m.created_at.beginning_of_year}.each do |key, value|\n aux = key.to_s.split('-')\n result[\"#{aux[0]}\"] = value.count\n end\n title_graph = 'Usuarios nuevos durante los años'\n x_axsis = 'Años'\n end\n line_chart result.sort, height: '80%', width: '95%', colors: [\"#FFD586\"],\n library: {\n chart: {\n borderColor: '#aaa', borderWidth: 2, type: 'line',backgroundColor: '#FEFEFA',\n style: {\n fontFamily: 'Helvetica Neue'\n }\n },\n title: {\n text: title_graph,\n style: {\n fontWeight: 'bold', fontSize: '14px'\n }\n },\n yAxis: {\n allowDecimals: false,\n title: {\n text: 'Usuarios'\n }\n },\n xAxis: {\n title: {\n text: x_axsis\n }\n }\n }\n end",
"def get_cumulative_totals\n Function.new do |data|\n data.map(&:flatten)\n .reduce([]){ |array, item| array << [item[0],\n item[2].to_i + (array.length == 0 ? 0 : array.last[1]),\n item[2],\n item[3],\n item[6],\n item[5]] }\n end\n end"
] |
[
"0.74724084",
"0.71565723",
"0.67710024",
"0.6631749",
"0.66201204",
"0.6606829",
"0.648559",
"0.64828455",
"0.6480033",
"0.6460719",
"0.64020985",
"0.63573104",
"0.63203496",
"0.63151824",
"0.62724555",
"0.6268677",
"0.625671",
"0.6251783",
"0.6188261",
"0.6166282",
"0.61639357",
"0.61602074",
"0.61330014",
"0.61100435",
"0.6093273",
"0.60772616",
"0.60729855",
"0.60668695",
"0.6066728",
"0.6055043",
"0.6053099",
"0.6050198",
"0.60277367",
"0.60173076",
"0.60154986",
"0.599482",
"0.599482",
"0.5945591",
"0.59279543",
"0.5927562",
"0.59252715",
"0.5925232",
"0.5915367",
"0.59068453",
"0.58985406",
"0.5895947",
"0.58886325",
"0.5864543",
"0.58589506",
"0.58453864",
"0.58353853",
"0.58329105",
"0.5805294",
"0.5800278",
"0.57988596",
"0.57790756",
"0.57713497",
"0.57585734",
"0.57556194",
"0.57517415",
"0.57305735",
"0.57287747",
"0.5727822",
"0.5726142",
"0.57214016",
"0.5721155",
"0.5721155",
"0.5713651",
"0.5713438",
"0.57125866",
"0.57051724",
"0.56951034",
"0.56944585",
"0.56938815",
"0.56816465",
"0.566985",
"0.5667423",
"0.5657393",
"0.5655388",
"0.56539977",
"0.56538326",
"0.56506425",
"0.564204",
"0.563027",
"0.56267303",
"0.5622748",
"0.56217426",
"0.5621663",
"0.5617407",
"0.5614161",
"0.5613492",
"0.56127983",
"0.56015414",
"0.5598257",
"0.5595897",
"0.5594884",
"0.5594774",
"0.5594774",
"0.5594774",
"0.55852664",
"0.55786425"
] |
0.0
|
-1
|
get mcv date from database
|
def set_total_article(startdate, enddate)
start_date = startdate.to_date.beginning_of_day
end_date = enddate.to_date.end_of_day
total_clicks_count = Click.where(:created_at => start_date..end_date).count
return total_clicks_count
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_date()\n @date\n end",
"def get_date()\n @date\n end",
"def date\n @date\n end",
"def date\n @date\n end",
"def date() self[:date]; end",
"def date\n @date\n end",
"def date\n @date\n end",
"def get_date(sqlite_date)\n sqlite_date.nil? ? nil : sqlite_date[0..9]\n end",
"def date\n Date.civil(year, month, 1)\n end",
"def easy_date; date; end",
"def date; end",
"def date; end",
"def date; end",
"def date; end",
"def date\n get_scm_data if @_date.nil?\n @_date\n end",
"def date\n moment.floor\n end",
"def read_date; end",
"def get_date(row_data)\n values = row_data.to_s.chomp.split(' ')\n month = values.map { |token| MONTHS[token.downcase] }.compact.first\n year = values.find { |token| /\\d{4}/ =~ token }\n date = Date.new(year.to_i, month)\n @latest_date = date if latest_date < date\n date\n end",
"def get_date_actualizacion\n Date.strptime(self.fecha_actualizacion,'%s')\n end",
"def to_date\n find\n end",
"def date\n object.date.strftime('%a %b %e') rescue nil\n end",
"def statement_to_date\n end",
"def statement_to_date\n end",
"def statement_to_date\n end",
"def get_date()\n @time\n end",
"def to_date()\n #This is a stub, used for indexing\n end",
"def date\n result_hash['dte']\n end",
"def gettransactiondate\r\n SVUtils::getdate(@transactiondate, SVUtils::QC_DATE_FORMAT)\r\n end",
"def value\n self.class.get_date(@bits)\n end",
"def get_date\n\t\t@date = Date.today.to_s\n\tend",
"def datum\nt = Time.now\ndate = t.strftime(\"%y%m%d\")\nend",
"def duedate\n @date\n end",
"def create_date\n data.create_date\n end",
"def create_date\n data.create_date\n end",
"def create_date\n data.create_date\n end",
"def ruby_value\n ::Date.parse(@date_time_value.strftime(\"%Y%m%d\"))\n end",
"def web_date\n strftime(MO.web_date_format)\n end",
"def resolve_date(date)\n ModernTimesDatabase::Dates[date]\n end",
"def date\n \"#{self[:day]}_#{self[:month]}_#{self[:year]}\"\n end",
"def dmy_date(date)\n Time.gm(date.year, date.month, date.day)\n end",
"def date \n\t\tI18n.l(moment, format: :date_long)\n\tend",
"def date\n model.created_at.strftime(\"%d-%b-%Y\")\n end",
"def date; raw_changeset.time; end",
"def date \n params['date']\n end",
"def publication_date\n Time.parse self.table[:publication_date]\n end",
"def dob\n @dob\n end",
"def date\n now.to_date\n end",
"def geek_date(date)\n date.strftime(\"%Y-%m-%d\") \n end",
"def date\n dreport.date_format\n end",
"def data_geracao\n Date.current.strftime('%d%m%Y')\n end",
"def data_geracao\n Date.current.strftime('%d%m%Y')\n end",
"def date \n \"date\" \n end",
"def getLogDate()\n return self.getDateStr()\n end",
"def date\n object.date.strftime(\"%m/%d/%Y\")\n end",
"def date\n parse!\n @date\n end",
"def fecha_marca\n fecha_numero_marca[:fecha]\n end",
"def date\n Date.parse(@obj['date'])\n end",
"def date\n @date ||= Date.parse(@attrs[:date]) rescue nil\n end",
"def read_date=(_); end",
"def date\n time_table_date || @date\n end",
"def ris_date\n return @ris_date if defined?(@ris_date)\n\n @ris_date ||= begin\n if start_d = @citable_attributes.date && @citable_attributes.date.parts.first\n self.class.formatted_ris_date(year: start_d.year, month: start_d.month, day: start_d.day)\n end\n end\n end",
"def date\n Date.parse(@data['date'])\n end",
"def date\n\t\treturn Time.at( @date[0] )\n\tend",
"def get_date\n format_date DateTime.new(2011, 1, 1, 17, 9, 59)\n end",
"def date\n return @date if @date\n if matches = class_const(:DATE_RE).match(page)\n @date = matches[1].to_s.strip\n date_processor\n @date\n end\n end",
"def date\n team.date_format\n end",
"def game_date\n Time.parse(\"#{@date.strftime(\"%m/%d/%Y\")}\")\n end",
"def date\n @match_buffer[\"date\"]\n end",
"def last_date_s\r\n last_date = $db.execute(\"SELECT day FROM prices ORDER BY day_i DESC LIMIT 1\")\r\n last_date = last_date[0][0]\r\n return last_date\r\nend",
"def getdate(key, format)\r\n @value = getvalue(key)\r\n return SVUtils::getdate(@value, format)\r\n end",
"def departureDate = (value)",
"def get_date(property, data, uri = nil, single: true)\n get_property(property, data, uri, single: single) { |value, type| DateTime.parse(value) }\n end",
"def start_date\n @raw.first.date\n end",
"def solr_date(date)\n return Time.utc(date.year, date.mon, date.mday).iso8601()\nend",
"def solr_date(date)\n return Time.utc(date.year, date.mon, date.mday).iso8601()\nend",
"def create_date\n @attributes.fetch('create date', nil)\n end",
"def publication_date\n object.publication_date.strftime \"%Y-%m-%d\"\n end",
"def date\n date_parser(self[:date])\n end",
"def date\n date_parser(self[:date])\n end",
"def return_date\n\t\tif(last_line_modified_date && last_modified_date != nil)\n\t\t\tif(last_line_modified_date <= last_modified_date)\n\t\t\t\treturn last_line_modified_date()\n\t\t\telse\n\t\t\t\treturn last_modified_date()\n\t\t\tend\n\t\telse\n\t\t\treturn '2000-01-01'\n\t\tend\n\tend",
"def mday() end",
"def manufacture_date\n bf = data['ManufactureDate']\n day = bf & ((2**5)-1)\n month = (bf & (((2**4)-1) << 5)) >> 5\n year = ((bf & (((2**7)-1) << 9)) >> 9) + 1980\n\n # Ruby 1.8 lacks Time#strptime\n Time.parse Date.new(year, month, day).to_s\n end",
"def date_string_to_readable(db_date)\n\n # Parse string (db date) to DateTime\n date = date_string_to_object(db_date)\n\n # Format it to a more readable string\n string = \"#{date.day}/#{date.month}/#{date.year}\"\n string << \" #{date.hour}:#{date.minute}\"\n\n return string\nend",
"def date\n @date ||= Time.utc(*Gem.source_date_epoch.utc.to_a[3..5].reverse)\n end",
"def matriculate\n \tif !matriculation_date.blank?\n \t\tmatriculation_date.strftime(\"%B %Y\")\n \telse\n \t\t\"Unknown\"\n \tend\n end",
"def getPostDate\r\n\t\t\t\t\treturn @postDate\r\n\t\t\t\tend",
"def getPostDate\r\n\t\t\t\t\treturn @postDate\r\n\t\t\t\tend",
"def issue_date\n issue_date = read_attribute(:issue_date)\n User.current.user_time(issue_date)\n end",
"def fecha_marca(marca)\n case marca.estado\n when \"sm\" then marca.fecha_solicitud\n when \"lp\" then marca.fecha_solicitud\n when \"lr\" then marca.fecha_registro\n when \"sr\" then marca.fecha_solicitud_renovacion\n when \"rc\" then marca.fecha_renovacion\n else\n marca.fecha_solicitud\n end\n end",
"def publication_date(field = nil)\n IsoDay.cast(find_record_items(field).first)&.to_s if field\n end",
"def entered_senedd\n representations.first.log_date\n end",
"def crdt\n @pubmed['CRDT'].strip # in the form 2005/06/10\n end",
"def date_str\n date.strftime(\"%Y%m%d\")\n end",
"def get_date()\n strip = self;\n return strip.created_at.strftime( \"%d%m%y\" );\n end",
"def form_date\n \"#{date.month}/#{date.day}/#{date.year - 2000}\"\n end",
"def httpdate\n utc.httpdate\n end",
"def to_datetime()\n #This is a stub, used for indexing\n end",
"def dob\n @registration.dob.strftime('%B %d, %Y')\n end",
"def last_modified_date()\n\t\tmax_update = @database.execute(\"SELECT MAX(updated) as maxmodified FROM invoices;\")\n\t\tif (DBCHOICE == 'sqlite3') then\n\t\t\treturn max_update[0][0]\n\t\telsif (DBCHOICE == 'mysqltest' || DBCHOICE == 'mysql') then\n\t\t\t# structure is hash of hashes, look for the maxmodified key in 1st record and return\n\t\t\tmax_update.each do |row|\n\t\t\t\treturn row['maxmodified']\n\t\t\tend # max_update.each\n\t\tend\n\tend",
"def as_date\n strftime \"%Y-%m-%d\"\n end",
"def date(date, format)\n RubyMotionQuery::Format.date_formatter(format).stringFromDate(date)\n end"
] |
[
"0.73385954",
"0.73385954",
"0.69346356",
"0.69346356",
"0.6906459",
"0.6832835",
"0.6832835",
"0.6766766",
"0.6744504",
"0.6704357",
"0.66079026",
"0.66079026",
"0.66079026",
"0.66079026",
"0.6513092",
"0.65023994",
"0.6499432",
"0.6477608",
"0.6473672",
"0.6394089",
"0.6385977",
"0.638565",
"0.638565",
"0.638565",
"0.6377148",
"0.63754153",
"0.6373283",
"0.6330155",
"0.6328536",
"0.6321274",
"0.6317261",
"0.6310265",
"0.6301985",
"0.6301985",
"0.6301985",
"0.6292288",
"0.62890494",
"0.6276908",
"0.6269769",
"0.62607974",
"0.626039",
"0.6260321",
"0.6259104",
"0.6253084",
"0.62479305",
"0.6237236",
"0.6216928",
"0.62146956",
"0.619668",
"0.6191542",
"0.6191542",
"0.6163869",
"0.6163072",
"0.6152923",
"0.6152823",
"0.61499226",
"0.61389977",
"0.61345243",
"0.6128789",
"0.6115228",
"0.608265",
"0.6076621",
"0.6045736",
"0.60448885",
"0.6037475",
"0.6030093",
"0.60251075",
"0.59959835",
"0.5979294",
"0.59771734",
"0.5976181",
"0.595731",
"0.59564716",
"0.59553075",
"0.59553075",
"0.59500086",
"0.59483635",
"0.5947512",
"0.5947512",
"0.5940292",
"0.59331024",
"0.5931429",
"0.592779",
"0.5923615",
"0.5921521",
"0.59186983",
"0.59186983",
"0.59128106",
"0.58882284",
"0.5878883",
"0.58777934",
"0.5877582",
"0.587322",
"0.58628774",
"0.5859482",
"0.5858814",
"0.584918",
"0.5845495",
"0.58441466",
"0.584322",
"0.5835311"
] |
0.0
|
-1
|
each article data by selected period
|
def get_data(startdate, enddate)
date_range = @analytics::DateRange.new(start_date: startdate, end_date: enddate)
order_by = @analytics::OrderBy.new(field_name: 'ga:pageviews', sort_order: 'DESCENDING')
# metric = @analytics::Metric.new(expression: 'ga:sessions')
# metric = @analytics::Metric.new(expression: ['ga:sessions', 'ga:uniquePageviews'])
# metric = @analytics::Metric.new
# metric.expression = ['ga:sessions', 'ga:uniquePageviews']
metrics = ['ga:pageviews', 'ga:users', 'ga:bounces', 'ga:sessions',
'ga:avgTimeOnPage', 'ga:newUsers', 'ga:goal1ConversionRate', 'ga:goal1Completions'
]
# metrics = ['ga:totalEvents'
# ]
metric_type = Array.new
metrics.each do |m|
metric = @analytics::Metric.new
metric.expression = m
metric_type.push(metric)
end
dimensions = ['ga:pagePath', 'ga:pageTitle', 'ga:hostname' ]
# dimensions = ['ga:pagePath', 'ga:eventCategory']
dimension_type = Array.new
dimensions.each do |d|
dimension = @analytics::Dimension.new
dimension.name = d
dimension_type.push(dimension)
end
# dimension = @analytics::Dimension.new(name: 'ga:pagePath')
# dimension_filters = @analytics::DimensionFilterClause.new(
# filters: [
# @analytics::DimensionFilter.new(
# dimension_name: 'ga:pagePath',
# operator: "IN_LIST",
# expressions: ['/archives/69839', '/archives/54087', '/archives/68924', '/archives/58437', '/archives/65171', '/archives/64435', '/archives/61533', '/archives/68924',
# '/archives/65086', '/archives/64736', '/archives/55244', '/archives/68211'
# ]
# )
# ]
# )
request = @analytics::GetReportsRequest.new(
report_requests: [@analytics::ReportRequest.new(
view_id: @view_id,
metrics: metric_type,
dimensions: dimension_type,
# dimension_filter_clauses: [dimension_filters],
# dimensions: [dimension],
date_ranges: [date_range],
order_bys: [order_by],
pageSize: 10000
)]
)
response = @client.batch_get_reports(request)
messageHash = {}
# handling error
if !response.reports.first.data.rows then
key = "message"
messageHash[key.to_sym] = "no data"
return messageHash
end
data_from_google = response.reports.first.data.rows
key_array = dimensions + metrics
# get rid of 'ga:'
key_array.each_with_index do |k, index|
key_array[index] = k.gsub("ga:","")
end
key_array.push('id')
key_array.push('clickCount')
set_ga_data_array = Array.new
data_from_google.each_with_index do |r, index|
datahash = {}
i = 0;
# setup dimension part
r.dimensions.each do |d|
datahash[key_array[i]] = d
i += 1
end
# setup metrics part
r.metrics.first.values.each do |m|
datahash[key_array[i]] = m
i += 1
end
# get aticle data from db
articleArr = set_article_data(datahash['hostname'], datahash['pagePath'], startdate, enddate)
# setup id, mcv
articleArr.each do |a|
datahash[key_array[i]] = a
i += 1
end
set_ga_data_array.push(datahash)
#datahash sample -> { "pagePath": "/archives/69839", ... , "goal1Completions": "23", "id": 4, "clickCount": 0 },
end
return set_ga_data_array
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n # @search = Article.search do\n # fulltext params[:search]\n # # with(:published_at).less_than(Time.zone.now)\n # # facet(:publish_month)\n # # with(:publish_month, params[:month]) if params[:month].present?\n # end\n # @articles = @search.results\n\n @articles = Article.all \n @sections = Section.all\n\nend",
"def set_article_data(hostname, uri, startdate, enddate) \n\t\turl = 'https://' + hostname + uri\n\t\tarticle = Article.find_by(article_url: url)\n\t\tstart_date = startdate.to_date.beginning_of_day \n\t\tend_date = enddate.to_date.end_of_day\n\t\t\n\t\tarticleArr = Array.new\n\n\t\tif article\n\t\t\tid = article.id\n\t\t\tclickCount = article.clicks.where(:created_at => start_date..end_date).count\n\t\telse\n\t\t\tid = 0\n\t\t\tclickCount = 0\n\t\tend\n\n\t\tarticleArr = [id, clickCount]\n\n\t\treturn articleArr\n\n\tend",
"def scrape_articles\n age_import=AgeImporter.new(self.start_date,self.end_date)\n age_import.scrape_article\n sun_import=SunImporter.new(self.start_date,self.end_date)\n sun_import.scrape_article\n nyt_import=NytImporter.new(self.start_date,self.end_date)\n nyt_import.scrape_article\n\n\n\n abc_import=AbcImporter.new(self.start_date,self.end_date)\n abc_import.scrape_article\n\n smh_import=SmhImporter.new(self.start_date,self.end_date)\n smh_import.scrape_article\n\n sbs_import=SbsImporter.new(self.start_date,self.end_date)\n sbs_import.scrape_article\n end",
"def article_performance_report(start_date,end_date)\n\n report = OpenStruct.new\n period_articles = self.articles.no_agcon.where(\"pub_date IN (?)\",start_date..end_date)\n\n article_list = []\n\n period_articles.each { |a| article_list << Hash[:title => a.title, :pub_date => a.pub_date, :views => a.period_views(start_date,end_date), :net_revenue => a.period_net_revenue(start_date,end_date)] }\n\n\n report.top_revenue = article_list.sort_by { |a| a[:net_revenue] }.reverse\n report.bottom_revenue = article_list.sort_by { |a| a[:net_revenue] }\n report.top_views = article_list.sort_by { |a| a[:views] }.reverse\n report.bottom_views = article_list.sort_by { |a| a[:views] }\n\n return report\n\n end",
"def index\n period = params[:period]\n if period.present?\n if period == \"day\"\n @attribute_measures = @attribute.attribute_measures.where(\"created_at >= ?\", Date.today.beginning_of_day)\n elsif period == \"week\"\n #@attribute_measures = @attribute.attribute_measures.where(created_at: Date.today.all_week)\n @attribute_measures = @attribute.attribute_measures.find_by_sql(\"SELECT created_at as created_at, ROUND(AVG(value),2) as value FROM attribute_measures WHERE (created_at BETWEEN '#{1.week.ago}' AND '#{Time.now}') GROUP BY date(created_at), hour(created_at)\")\n elsif period == \"month\"\n #@attribute_measures = @attribute.attribute_measures.where(created_at: Date.today.all_month)\n @attribute_measures = @attribute.attribute_measures.find_by_sql(\"SELECT created_at as created_at, ROUND(AVG(value),2) as value FROM attribute_measures WHERE (created_at BETWEEN '#{1.month.ago}' AND '#{Time.now}') GROUP BY date(created_at)\")\n elsif period == \"year\"\n #@attribute_measures = @attribute.attribute_measures.where(:created_at => Date.today.all_year).order(:created_at).group(\"date(created_at)\").average(:value)\n @attribute_measures = @attribute.attribute_measures.find_by_sql(\"SELECT created_at as created_at, ROUND(AVG(value),2) as value FROM attribute_measures WHERE (created_at BETWEEN '#{1.year.ago}' AND '#{Time.now}') GROUP BY date(created_at)\")\n else\n @attribute_measures = @attribute.attribute_measures.all\n end\n else\n @attribute_measures = @attribute.attribute_measures.all\n end\n\n render json: @attribute_measures.to_json(only:[:value,:created_at])\n end",
"def index\n seach_months_article\n if params[:tag]\n @articles = Article.tagged_with(params[:tag]).paginate(page: params[:page], per_page: 5)\n elsif params[:search]\n @articles = Article.search_published(params[:search]).paginate(page: params[:page], per_page: 5)\n else\n @articles = Article.paginate(page: params[:page], per_page: 5).order('created_at DESC')\n end\n #fresh_when(:etag => [@articles, @articles_month], :public => true)\n end",
"def scrape_article\n\n url='http://www.theage.com.au/rssheadlines/political-news/article/rss.xml'\n puts url\n open(url) do |rss|\n\n feed = RSS::Parser.parse(rss)\n\n #For each article gather the relevent information and put it in the article\n feed.items.each do |item|\n\n temp_article=Article.new\n temp_article.author=item.author\n temp_article.title=item.title\n # input was in form of several paragraphs in html format\n # the code splits the paragraphs to arrays so only the relevent\n # text is displayed\n temp_article.summary = item.description.split('</p>')[1]\n temp_article.images=get_http(item.description.split('</p>')[0].split('><')[1])\n\n temp_article.source=AgeImporter.source_name\n temp_article.link=item.link\n temp_article.date=item.pubDate.to_date\n\n\n\n if(temp_article.date <= @end && temp_article.date>=@start && is_unique(temp_article))\n # if article is with the start and end date insert into array and is unique\n\n temp_article.save\n\n\n end\n\n end\n\n\n\n\n end\n end",
"def ind_estud\n #@periodos = Periodo.find(:all)\n end",
"def get_article_data(yesterday, view_id, domain_id, article_key)\n\t\t\n\t\tdate_range = @analytics::DateRange.new(start_date: yesterday, end_date: yesterday)\n\t\torder_by = @analytics::OrderBy.new(field_name: 'ga:pageviews', sort_order: 'DESCENDING')\n\t\tmetric = @analytics::Metric.new(expression: 'ga:pageviews')\n\n\t\tdimensions = ['ga:pageTitle', 'ga:pagePath']\n\t\tdimension_type = Array.new\n\t\tdimensions.each do |d|\n\t\t\tdimension = @analytics::Dimension.new\n\t\t\tdimension.name = d\n\t\t\tdimension_type.push(dimension)\n\t\tend\n\n\t\trequest = @analytics::GetReportsRequest.new(\n \t\t\treport_requests: [@analytics::ReportRequest.new(\n \t\t\tview_id: view_id,\n \t\t\tdimensions: dimension_type,\n \t\t\tmetrics: [metric], \n \t\t\t# dimension_filter_clauses: [dimension_filters],\n \t\t\t# dimensions: [dimension], \n \t\t\tdate_ranges: [date_range],\n \t\t\torder_bys: [order_by],\n \t\t\tpage_size: 100_000\n \t\t\t)]\n\t\t)\n\t\tresponse = @client.batch_get_reports(request)\n\t\tmessageHash = {}\n\n\t\t# handling error \n\t\tif !response.reports.first.data.rows then\n\t\t\treturn\n\t\tend\n\n\n\t\tdata_from_google = response.reports.first.data.rows\n\n\t\t# max_position_array = get_max_position(yesterday, view_id)\n\t\t\n\t\tset_ga_data_array = Array.new\n\n\t\t\n\t\tdata_from_google.each_with_index do |r, index|\n\n\t\t\tdatahash = {}\n\t\t\t\n\t\t\t# domain_id\n\t\t\tdatahash['domain_id'] = domain_id\n\n\t\t\t# dimensions = ['ga:pageTitle', 'ga:pagePath']\n\n\t\t\tdatahash['article_title'] = r.dimensions[0]\n\n\t\t\turls_rm_params = r.dimensions[1].split(/\\?/)[0]\n\n\t\t\tdatahash['article_url'] = urls_rm_params\n\n\t\t\t# total_events = 0\n\t\t\t# max_position = 1\n\t\t\t# mobile_device_info = ''\n\t\t\t# if max_position_array != nil\n\t\t\t# \tmax_arr = max_position_array.select{|max| max['article_url'] == r.dimensions[1]}\n\t\t\t# \tif !max_arr.empty?\n\t\t\t# \t\tmax_arr.each do |a|\n\t\t\t# \t\t\tif a['total_events'] > total_events\n\n\t\t\t# \t\t\t\ttotal_events = a['total_events']\n\t\t\t# \t\t\t\tmobile_device_info = a['mobileDeviceInfo']\n\t\t\t# \t\t\t\tmax_position = a['max_position']\n\n\t\t\t# \t\t\telsif a['total_events'] == total_events && a['mobileDeviceInfo'] == 'Apple iPhone'\n\n\t\t\t# \t\t\t\tif mobile_device_info == 'Apple iPhone' && a['max_position'] > max_position\n\t\t\t# \t\t\t\t\tmax_position = a['max_position']\n\t\t\t# \t\t\t\telsif mobile_device_info != 'Apple iPhone'\n\t\t\t# \t\t\t\t\tmobile_device_info = a['mobileDeviceInfo']\n\t\t\t# \t\t\t\t\tmax_position = a['max_position']\n\t\t\t# \t\t\t\tend\n\n\t\t\t# \t\t\tend\n\t\t\t\t\t\t\t\n\t\t\t# \t\tend\n\t\t\t# \tend\n\n\t\t\t# \tdatahash[article_key[i]] = max_position\n\t\t\t# else \n\t\t\t# \tdatahash[article_key[i]] = 25000\n\t\t\t# end\n\n\t\t\tdatahash['max_position'] = 0\n\n\t\t\tset_ga_data_array.push(datahash)\n\t\tend\n\t\t\n\t\treturn set_ga_data_array\n\tend",
"def period_dataset_for_resource(resource, date_range)\n data = {}\n\n payments = resource.payments.in_range(date_range)\n expenses = resource.expenses.in_range(date_range)\n\n data['Payments'] = payments.sum(:amount)\n @organization.expense_categories.major.each do |ec|\n data[\"#{ec.name} Expenses\"] = expenses.where(expense_category_id: ec.id).sum(:amount)\n end\n\n data['Other Expenses'] = expenses.minor_expenses.sum(:amount)\n data['Profit'] = data['Payments'] - expenses.sum(:amount)\n data\n end",
"def scrape_article\n\n url=\"http://sbs.feedsportal.com/c/34692/f/637303/index.rss\"\n open(url) do |rss|\n feed = RSS::Parser.parse(rss)\n feed.items.each do |item|\n temp_article=Article.new\n temp_article.author=item.author\n temp_article.title=item.title\n\n # input was in form of several paragraphs in html format\n # the code splits the paragraphs to arrays so only the relevent\n # text is displayed\n temp_article.summary=item.description.split('<')[0]\n temp_article.images=get_http(item.description)\n temp_article.source=SbsImporter.source_name\n temp_article.link=item.link\n temp_article.date=item.pubDate.to_date\n\n\n\n\n\n if(temp_article.date <= @end && temp_article.date>=@start && is_unique(temp_article))\n #if article is with the start and end date insert into array and is unique\n\n temp_article.save\n\n\n end\n\n end\n\n\n\n\n end\n end",
"def article_feed\n \tArticle.all\n end",
"def scrape_article\n url=\"http://www.abc.net.au/radionational/feed/3777540/rss.xml\"\n open(url) do |rss|\n feed = RSS::Parser.parse(rss)\n feed.items.each do |item|\n temp_article=Article.new\n temp_article.author=item.author\n temp_article.title=item.title\n temp_article.summary = item.description\n temp_article.images=nil #note no image provided on this RSS field\n temp_article.source=AbcImporter.source_name\n temp_article.link=item.link\n temp_article.date=item.pubDate.to_date\n\n\n\n\n\n if(temp_article.date <= @end && temp_article.date>=@start && is_unique(temp_article))\n #if article is with the start and end date insert into array and is unique\n\n temp_article.save\n\n\n end\n\n end\n\n\n\n\n end\n end",
"def index\n @articles = Article.all\n @article = Article.all\n @article.each do |article|\n article = parsearArticulo(article)\n end\n end",
"def transact_load_column_articles(data)\n resp = {:msg => \"\", :articles => []}\n \n count = (data[\"count\"] || 15).to_i\n load_old_data = (data[\"load_old_data\"] || 0).to_i\n time = (data[\"time\"] || 0).to_i\n column_id = (data[\"column_id\"] || 0) .to_i\n load_rolling_news = (data[\"load_rolling_news\"] || 0).to_i \n raise InvalidInputParamsError if load_rolling_news == 0 and column_id == 0\n \n articles = []\n if load_rolling_news == 1\n if column_id == 0\n articles = Article.rolling\n else\n column = Column.where(:id => column_id).first\n raise InvalidInputParamsError if column.blank?\n articles = column.articles.rolling\n end\n else\n column = Column.where(:id => column_id).first\n raise InvalidInputParamsError if column.blank?\n articles = column.articles\n end\n if load_old_data == 1\n articles = articles.where([\"articles.created_at < ?\", Time.at(time)])\n end\n articles = articles.order(\"articles.id DESC\").includes({:pages => :image}).page(0).per(count)\n \n articles.each do|article|\n content = \"\"\n \n article_hash = {:id => article.id.to_s, :title => article.title, :url => article_url(article), :digest => article.show_digest, :content => content,\n :column_id => column_id.to_s, :is_rolling_news => article.is_rolling_news, :images => [], :created_at => article.created_at.to_i.to_s, :updated_at => article.updated_at.to_i.to_s}\n article.pages.each do|p|\n content += \"<p>\" + p.content + \"</p>\"\n \n if p.p_index == 1 and p.image.present?\n if column_id == 2 # head news\n article_hash[:images] << p.image.article_url(:x_large)\n else # thumbnails\n article_hash[:images] << p.image.article_url(:middle) \n end\n end\n end\n \n article_hash[:content] = resp_article_content(article, content)\n \n resp[:articles] << article_hash\nend\n\nresp\nend",
"def retrieve_data\n # Define the url\n url = 'http://www.abc.net.au/radionational/feed/3771046/rss.xml'\n\n # Open the url and parse the rss feed\n open(url) do |rss|\n # Start parsing\n feed = RSS::Parser.parse(rss, false)\n\n # Iterate each item and scrape information\n feed.items.each do |item|\n # If the title of thie article matches the title of the last saved article,\n # stop scraping to avoid from saving duplicates in database\n break if !@last_title.nil? && @last_title.eql?(item.title.to_s)\n\n # If thie article is already stored then ignore\n next if Article.find_by(title: item.title.to_s)\n\n # Get the author\n regex_author = /<dc:creator>(.*)<\\/dc:creator>/\n regex_author.match(item.to_s)\n author = Regexp.last_match(1)\n\n author = nil if author.eql? ''\n\n # Get categories values\n regex_category = /<category>(.*)<\\/category>/\n\n categories = []\n item.categories.each do |category|\n regex_category.match(category.to_s)\n categories.push(Regexp.last_match(1))\n end\n\n # Make a template dictionary to put @articles\n temp = {\n author: author,\n title: item.title,\n summary: item.description.to_s,\n image: nil,\n date_time: DateTime.parse(item.pubDate.to_s),\n link: item.link,\n categories: categories.join(',')\n }\n\n # Put the object into articles array\n @articles << temp\n end\n end\n end",
"def getAllPeriods()\n aggregateQuery = [\n @dsObj.groupByPeriods(),\n {:$sort => {\"_id.fiscal_year\" => -1, \"_id.fiscal_quarter\" => -1, \"_id.fiscal_month\" => -1, \"_id.fiscal_week\" => -1}}\n ]\n aggregateCursor = @bookingDumpColl.aggregate(aggregateQuery)\n\n yearArray = []; quarterArray = []; monthArray = []; weekArray = [];\n periodsArray = [] \n periodDict = {}\n\n aggregateCursor.each do |doc|\n subDoc = doc[:_id]\n yearArray << subDoc[:fiscal_year]\n quarterArray << subDoc[:fiscal_quarter]\n monthArray << subDoc[:fiscal_month]\n weekArray << subDoc[:fiscal_week]\n periodDict = {\n :periods => {\n :year => subDoc[:fiscal_year],\n :quarter => subDoc[:fiscal_quarter],\n :month => subDoc[:fiscal_month],\n :week => subDoc[:fiscal_week]\n }\n }\n periodsArray << periodDict\n end\n yearArray = yearArray.uniq; yearArray = yearArray.sort\n quarterArray = quarterArray.uniq; quarterArray = quarterArray.sort\n monthArray = monthArray.uniq; monthArray = monthArray.sort\n weekArray = weekArray.uniq; weekArray = weekArray.sort\n\n arrayHash = {\n :yArray => yearArray,\n :qArray => quarterArray,\n :mArray => monthArray,\n :wArray => weekArray,\n :pArray => periodsArray\n }\n return arrayHash\n \n end",
"def get_tab_articles\n case params[:tab_type]\n when Article::Tab::Type::FAVORITES #'favorites'\n @articles = current_user.favorite_articles.paginate(page: params[:page], per_page: Article::PER_PAGE).all if current_user\n when Article::Tab::Type::MY #'my_articles'\n @articles = current_user.articles.publics.paginate(page: params[:page], per_page: Article::PER_PAGE).all if current_user\n when Article::Tab::Type::PRIVATES # 'private_articles'\n @articles = Article.privates(current_user).paginate(page: params[:page], per_page: Article::PER_PAGE).all\n when Article::Tab::Type::ALL # 'all_articles'\n @articles = Article.order_by_last_updated_at_desc.accessibles(current_user).paginate(page: params[:page], per_page: Article::PER_PAGE).all\n when Article::Tab::Type::RECENTLY_FEEDBACKED\n @articles = Article.recently_feedbacked(current_user).paginate(page: params[:page], per_page: Article::PER_PAGE).all\n when Article::Tab::Type::RECENTLY_RECOMMENDED\n @articles = Article.recently_recommended(current_user).paginate(page: params[:page], per_page: Article::PER_PAGE).all\n else # index inial display\n @articles = Article.order_by_last_updated_at_desc.accessibles(current_user).paginate(page: params[:page], per_page: Article::PER_PAGE).all\n end\n end",
"def fetch_articles(published_before: nil, limit_num: 6)\n if published_before\n articles = Article.includes(:outlet).where(outlet_name: following.pluck(:outlet_name))\n .where('articles.published_at < ?', published_before.to_datetime)\n else\n articles = Article.includes(:outlet).where(outlet_name: following.pluck(:outlet_name))\n end\n articles.limit(limit_num)\n end",
"def get_article_list(start = 0, news_type: \"\", from_date: \"\", to_date: \"\", title_keyword: \"\", content_keyword: \"\")\n from_date = from_date.to_s unless from_date.kind_of?(String)\n to_date = to_date.to_s unless to_date.kind_of?(String)\n\n doc = REXML::Document.new(fetch_article_list(start, news_type, from_date, to_date, title_keyword, content_keyword))\n article_ids = REXML::XPath.match(doc, \"//articleCode\").map(&:text)\n disp_titles = REXML::XPath.match(doc, \"//dispTitle\").map { |node| normalize_text(node.text) }\n main_titles = REXML::XPath.match(doc, \"//mainTitle\").map { |node| normalize_text(node.text) }\n sub_titles = REXML::XPath.match(doc, \"//subTitle\").map { |node| normalize_text(node.text) }\n dates = REXML::XPath.match(doc, \"//sendInfo\").map(&:text)\n movie_counts = REXML::XPath.match(doc, \"//fMovieCnt\").map { |node| node.text.to_i }\n music_counts = REXML::XPath.match(doc, \"//fMusicCnt\").map { |node| node.text.to_i }\n photo_counts = REXML::XPath.match(doc, \"//fPhotoCnt\").map { |node| node.text.to_i }\n\n article_ids.zip(\n disp_titles, main_titles, sub_titles, dates,\n movie_counts, music_counts, photo_counts\n ).map do |id, disp, main, sub, date, movie, music, photo|\n date = \"2015-04-02\" if id == \"AR0060168\"\n Article.new(\n id, date: Date.parse(date),\n display_title: disp, main_title: main, sub_title: sub,\n movie_count: movie, music_count: music, photo_count: photo\n )\n end\n end",
"def index\n @articles = Article.all.by_publish_date.by_display_order\n end",
"def index\n @topics = Topic.order(date: :desc)\n @monthly_topics = []\n this_month_topics = []\n month = 0\n year = 0\n count = 0\n @topics.each do |topic|\n unless month == topic.date.month\n unless @topics.first == topic\n @monthly_topics << [[\"#{year}\",\"#{month}\"],count,this_month_topics]\n this_month_topics = []\n end\n month = topic.date.month\n year = topic.date.year\n count = 0\n end\n this_month_topics << topic\n count = count + 1\n if topic == @topics.last\n @monthly_topics << [[\"#{year}\",\"#{month}\"],count,this_month_topics]\n end\n end\n @topics = @topics.paginate(page: params[:page], per_page: 20)\n end",
"def periods( num )\n @ma.fetch_periods( num )\n end",
"def fetch_articles(url)\n req = open(url)\n response_body = req.read\n articles_json = JSON.parse(response_body)\n articles_array = articles_json[\"articles\"]\n last_articles = []\n articles_array.each do |a|\n article = Article.find_by(title:a[\"title\"])\n unless article #check if article is already in the database\n author = a[\"author\"].blank? ? a[\"source\"][\"name\"] : a[\"author\"]\n article = Article.new(title:a[\"title\"],author: author,source:a[\"source\"][\"name\"],url:a[\"url\"],date:a[\"publishedAt\"],content:a[\"content\"] || \"no content available\",image:a[\"urlToImage\"],description:a[\"description\"])\n article.publication_list.add(a[\"source\"][\"id\"])\n # extractor = Phrasie::Extractor.new\n # tagging = extractor.phrases(a[\"content\"],occur:1)\n # tags = tagging.each{|p|p[0]}\n # article.theme_list.add(tags)\n article.save!\n end\n end\nend",
"def fetch_articles\n current_feed = get_rss_feed( self.url )\n current_feed.entries.each do |article|\n unless self.array_of_article_urls.include?(article.url)\n a = Article.new(title: article.title, url: article.url, clicks: 0)\n a.title ||= article.summary\n self.articles.push a \n end\n end\n\tend",
"def aggregate_data_daily start_date=7.days.ago, end_date=Time.now\n start_date = Time.zone.parse start_date if String === start_date\n end_date = Time.zone.parse end_date if String === end_date\n current_date = start_date.beginning_of_day\n # reload @my_account_pages\n my_account_pages(true)\n my_arr = []\n my_posts = fb_posts.reload.select(\"DATE_FORMAT(post_created_time,'%Y%m%d') AS post_date,likes, comments, shares, replies_to_comment\").\n where(\"post_created_time > '#{current_date}'\").to_a \n while current_date < end_date do\n logger.debug \" aggregate_data_daily for #{current_date.to_s(:db)}\"\n posts= my_posts.select{|po| po.post_date == current_date.strftime('%Y%m%d')}\n \n=begin\n data = FbPost.select(\"count(*) AS post_count,sum(likes) as likes, sum(comments) as comments, sum(shares) as shares,sum(replies_to_comment) as replies_to_comment\").\n where(account_id: self.id).\n where(post_type: 'original').\n where(post_created_time: current_date..current_date.end_of_day).to_a.first\n=end\n rec = my_account_pages.detect{|pa| pa.post_date==current_date.strftime('%Y%m%d')}\n # if posts.size > 0\n options = construct_sum posts\n # p \" AAA #{current_date.strftime('%Y%m%d')} #{options}\"\n rec = my_account_pages.detect{|pa| pa.post_date==current_date.strftime('%Y%m%d')}\n if rec\n rec.update_attributes options\n else\n options[:post_created_time] = current_date.middle_of_day\n options[:account_id] = self.id\n options[:object_name] = self.object_name\n rec = FbPage.create options\n end\n # else\n # logger.debug \" aggregate_data_daily NOT RECORDS for #{start_date.to_s(:db)} .. #{end_date.to_s(:db)}\"\n # end\n current_date += 1.day\n end\n end",
"def representatives(period)\n fetch \"eksport/representanter/?StortingsPeriodeId=#{period}\"\n end",
"def drip_articles\n # articles that the user can see based on the duration of their subscription, if any\n sub = subscriptions.first\n @articles = []\n\n if self.access_admin?\n @articles = Article\n .where(drip_content: true).to_a\n elsif sub\n @articles = Article\n .where(drip_content: true)\n .where('reveal_after_days <= ?', sub.subscribed_days).to_a\n end\n @articles.sort! { |a, b| b.reveal_after_days <=> a.reveal_after_days }\n @articles.sort! { |a, b|\n if a.intro?\n -1\n elsif b.intro? == a.intro?\n 0\n else\n 1\n end\n }\n end",
"def article_data\n @article = Article.find(params[:article_id])\n end",
"def multiple_dates_occupation_detail(month, year)\n\n date_from = Date.civil(year, month, 1)\n date_to = Date.civil(year, month, -1)\n result = {}\n\n # Get planned activities\n condition = Conditions::JoinComparison.new('$and',\n [Conditions::Comparison.new(:date,'$gte', date_from),\n Conditions::Comparison.new(:date,'$lte', date_to)\n ])\n planned_activities = condition.build_datamapper(::Yito::Model::Booking::PlannedActivity).all(\n :order => [:date, :time, :activity_code]\n )\n\n # Build the structure\n activities = ::Yito::Model::Booking::Activity.all(#:active => true,\n :occurence => :multiple_dates,\n 'activity_dates.date_from.gte'.to_sym => date_from,\n 'activity_dates.date_from.lte'.to_sym => date_to)\n\n activities.each do |activity|\n\n # Build item prices hash\n item_prices = {}\n if activity.number_of_item_price > 0\n (1..activity.number_of_item_price).each do |item_price|\n item_prices.store(item_price, 0)\n end\n end\n\n # Fill with the activity turns\n activity_detail = {}\n activity.multiple_dates_timetable.each do |turn|\n # Build days hash\n days = {}\n (1..(date_to.day)).each do |day|\n date = Date.civil(year, month, day)\n modified_capacity = planned_activities.select do |item|\n item.date.strftime('%Y-%m-%d') == date.strftime('%Y-%m-%d') and\n item.time == turn and\n item.activity_code == activity.code\n end\n real_capacity = modified_capacity.size > 0 ? modified_capacity.first.capacity : activity.capacity\n\n if activity.start_date?(date)\n days.store(day, {quantity: (item_prices.empty? ? 0 : item_prices.clone),\n pending_confirmation: (item_prices.empty? ? 0 : item_prices.clone),\n capacity: real_capacity,\n planned: true})\n else\n days.store(day, {quantity: '-',\n pending_confirmation: (item_prices.empty? ? 0 : item_prices.clone),\n capacity: real_capacity,\n planned: false})\n end\n end\n activity_detail.store(turn, days)\n end\n\n # Store the item\n result.store(activity.code, {name: activity.name,\n capacity: activity.capacity,\n price_literals: activity.price_definition_detail,\n number_of_item_price: activity.number_of_item_price,\n occupation: activity_detail})\n end\n\n sql =<<-SQL\n select o_i.item_id, o_i.date, o_i.time, o_i.item_price_type, CAST (o_i.status AS UNSIGNED) as status, sum(quantity) as quantity\n from orderds_order_items o_i\n join orderds_orders o on o.id = o_i.order_id\n join bookds_activities a on a.code = o_i.item_id \n where o.status NOT IN (3) and o_i.date >= ? and o_i.date <= ? and \n a.occurence IN (2)\n group by o_i.item_id, o_i.date, o_i.time, o_i.item_price_type, o_i.status\n SQL\n\n # Fill with the orders\n\n orders = repository.adapter.select(sql, date_from, date_to)\n\n orders.each do |order|\n if result[order.item_id] and\n result[order.item_id][:occupation] and\n result[order.item_id][:occupation][order.time] and\n result[order.item_id][:occupation][order.time][order.date.day] and\n result[order.item_id][:occupation][order.time][order.date.day][:quantity][order.item_price_type] and\n result[order.item_id][:occupation][order.time][order.date.day][:pending_confirmation][order.item_price_type]\n result[order.item_id][:occupation][order.time][order.date.day][:pending_confirmation][order.item_price_type] += order.quantity if order.status == 1\n result[order.item_id][:occupation][order.time][order.date.day][:quantity][order.item_price_type] += order.quantity if order.status == 2\n end\n end\n\n return result\n\n end",
"def ind_distr\n @periodos = Periodo.find(:all)\n end",
"def all_articles\n json = self.class.get(\"#{QUERY1 + PARAMETERS_API}\")\n puts \"QUERY IS: #{QUERY1 + PARAMETERS_API}\"\n response = json['response']\n articles = response['results']\n\n articles.each do |article|\n parse_article(article, nil)\n end\n end",
"def retrieve_data\n # Define the url\n url = 'http://www.sbs.com.au/news/rss/news/science-technology.xml'\n\n # Open the url and parse the rss feed\n open(url) do |rss|\n # Start parsing\n feed = RSS::Parser.parse(rss, false)\n\n # Iterate each item and scrape information\n feed.items.each do |item|\n # If the title of thie article matches the title of the last saved article,\n # stop scraping to avoid from saving duplicates in database\n break if !@last_title.nil? && @last_title.eql?(item.title.to_s)\n\n # If thie article is already stored then ignore\n next if Article.find_by(title: item.title.to_s)\n\n # Make a template dictionary to put @articles\n temp = {\n author: nil,\n title: item.title,\n summary: item.description,\n image: nil,\n date_time: DateTime.parse(item.pubDate.to_s),\n link: item.link,\n categories: nil\n }\n\n # Put the object into articles array\n @articles << temp\n end\n end\n end",
"def periods\n @periods ||= @data['properties']['periods'].map { |row|\n ::WeatherSage::Weather::Period.new(@ctx, row)\n }\n end",
"def index\n @institutes = Institute.all.order('name asc')\n @collections = {}\n @institutes.each do |institute|\n @collections[institute.id] = institute.collections.select(&:published?)\n end\n\n @depositing_institutes = @institutes.select { |i| i.depositing == true }\n @other_institutes = @institutes.select { |i| i.depositing.blank? }\n end",
"def index\n #@articles = Article.all\n # @article = Article.friendly.find(params[:id])\n # impressionist(@article)\n @articleOrder = Article.article_order(params[:page])\n # @jasonObject = render json: @articleOrder\n # puts JSON.pretty_generate(@articleOrder)\n if params[:tag]\n @articles = Article.tagged_with(params[:tag])\n else\n @articles = Article.order('created_at DESC').paginate(page: params[:page], :per_page => 4)\n end\n # @articles = Article.order('created_at DESC').paginate(page: params[:page], :per_page => 4)\n # all.page(params[:page]).per(4)\n @articles_corousal = Article.all\n # use scope\n @article_paginate = Article.paginate(page: params[:page], :per_page => 4)\n @widgetArticle = Article.widget_article(params[:page])\n \n end",
"def articles\n Ticket::Article.where(ticket_id: id).order(:created_at, :id)\n end",
"def interactive_info(i)\n info = [];\n (2013..2019).each{|year|\n info << i.interactive_page.lightweight_activity.runs.where(updated_at: Date.new(year)..Date.new(year+1)).count\n }\n info << i.interactive_page.lightweight_activity.runs.where(updated_at: Date.new(2020)..Date.today).count\n\n info << i.interactive_page.lightweight_activity.runs.count\n info << i.id\n info << i.interactive_page.lightweight_activity.id\n info << i.url\n info\nend",
"def period(period_content)\n if period_content[\"startDate\"] && period_content[\"endDate\"]\n return {\"start_date\" => Date.parse(period_content[\"startDate\"][0][\"content\"]), \"end_date\" => Date.parse(period_content[\"endDate\"][0][\"content\"])}\n elsif period_content[\"instant\"]\n return Date.parse(period_content[\"instant\"][0][\"content\"])\n elsif period_content[\"forever\"]\n return Context::PERIOD_FOREVER\n end\n end",
"def show\n @article = Article.find(params[:id])\n @comment_count = @article.comments.size\n seach_months_article\n end",
"def index\n @periods = Period.all\n end",
"def articles=(value)\n @articles = value\n end",
"def index\n @article_events = ArticleEvent.all\n end",
"def feed\n @articles = Article.feed_list(current_user, params[:page])\n end",
"def index\n @adverts = Advert.order(:state, monday_start: :desc)\n @adverts.each { |advert|\n if advert.state == \"published\"\n begin\n advert.planed_dates = Calendar.planed_dates(30, :advert, advert.id)\n rescue Exception => e\n advert.planed_dates = []\n\n end\n else\n advert.planed_dates = []\n end\n }\n end",
"def revenue_report(start_date,end_date)\n report = OpenStruct.new\n\n days_range = [30,(end_date - start_date).to_i].max\n\n articles = self.articles.no_agcon.where(\"pub_date IN (?)\",start_date..end_date)\n articles_and_views = articles.joins(:views).where(\"views.article_age <= ?\",days_range)\n stats = self.site_stats.where(\"month IN (?)\", start_date..end_date)\n\n report.new_articles_count = articles.count\n\n report.gross_revenue = stats.sum(:revenue)\n report.total_content_cost = articles.sum(:total_cost)\n report.average_content_cost = articles.average(:total_cost)\n\n report.net_revenue = report.gross_revenue - report.total_content_cost\n\n report.total_views = stats.sum(:pageviews).to_i\n report.new_content_views = articles_and_views.sum(:pageviews).to_i\n report.old_content_views = report.total_views - report.new_content_views\n\n\n report.gross_revenue_per_view = report.gross_revenue/report.total_views\n report.old_content_revenue = report.gross_revenue_per_view * report.old_content_views\n\n report.new_content_avg_views = report.new_content_views/report.new_articles_count\n\n report.new_content_gross_revenue = report.gross_revenue_per_view * report.new_content_views\n report.new_content_net_revenue = report.new_content_gross_revenue - report.total_content_cost\n\n report.new_content_avg_gross_revenue = report.new_content_gross_revenue/report.new_articles_count\n report.new_content_avg_net_revenue = report.new_content_net_revenue/report.new_articles_count\n\n return report\n\n\n end",
"def show\n @apt = Apt.find(params[:id])\n\n @reservations_by_start_date = @apt.reservations.group_by(&:start_date)\n @reservations_by_due_date = @apt.reservations.group_by(&:due_date)\n # @reservations_by_save_dates = @reservations.group_by(&:save_dates)\n @date = params[:date] ? Date.parse(params[:date]) : Date.today\n\n @day_ranges = :start_date..:due_date\n\n first = @apt.reservations.first.start_date.beginning_of_month.beginning_of_week(:sunday)\n @reservations = @apt.reservations.where(\"start_date > ?\", first)\n\n #@res_ranges = @apt.reservations.day_ranges(params[:start_date],\n # params[:due_date])\n\n @picture = @apt.pictures.build\n @pictures = Picture.scoped(:conditions => [ 'apt_id = ?', @apt.id ] )\n #find(:all, :conditions => [ 'gallery_id = ?', @gallery.id ])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @apt }\n end\n end",
"def show\n @ponto = Ponto.find(params[:id])\n @range_dias = @ponto.data.at_beginning_of_month..@ponto.data.at_end_of_month\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ponto }\n end\n end",
"def fetch_articles\n return unless any_new?\n (how_many? - 1).downto(0) do |index|\n next if added?(index)\n Article.create(title: feed.entries[index].title,\n description: description(index),\n published: feed.entries[index].published,\n link: feed.entries[index].url,\n site_id: id,\n readingtime: reading_time(index))\n end\n end",
"def scrape\n # Define the URL\n url = \"http://content.guardianapis.com/search?api-key=uggudpb34qwz47bxb3rn7e4q&page=1&page-size=100\"\n start_date = @start.strftime(\"%Y-%m-%d\")\n end_date = @end.strftime(\"%Y-%m-%d\")\n url += '&from-date=' + start_date + '&to-date=' + end_date\n \n # Define the HTTP object\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n\n # Get the response \n response = http.get(uri)\n \n # Parse the response body\n forecast = JSON.parse(response.body)\n\n # Start parsing and store information in GuardianArticle object\n forecast['response']['results'].each do |each_article|\n temp = News::GuardianArticle.new( \n author: nil,\n title: each_article[\"webTitle\"],\n summary: nil,\n images: nil,\n source: each_article[\"webUrl\"],\n date: each_article[\"webPublicationDate\"],\n type: each_article[\"type\"],\n sectionID: each_article[\"sectionId\"],\n id: each_article[\"id\"],\n apiUrl: each_article[\"apiUrl\"],\n section_name: each_article[\"sectionName\"]\n )\n \n # put this article into the array of articles\n @articles << temp\n end\n \n # Return the array of articles\n @articles\n\tend",
"def index\n # still_relevent and month are define in the model\n @events = Event.still_relevent\n @event_months = @events.order(esdate: :asc).group_by(&:month)\n @page_by_mouths = @event_months.to_a.paginate(:page => params[:page], :per_page => 3)\n end",
"def index\n @articles = Article.desc_by_date\n end",
"def data_collector collection, factor, duration\n your_data, comparison_data = [], [], []\n uniq_exam_dates = collection.map(&:exam_date).uniq\n if duration == \"12\"\n Date.today.month.times do |count|\n your_temp_data, todays_data = [], []\n collection.where(exam_date:(Time.now-count.month).all_month()).each do |report|\n your_temp_data << report.send(:\"#{factor}\")\n end\n Report.where(exam_date: (Time.now-count.month).all_month(), school_id:current_user.school.id).each do |m|\n todays_data << (m.send(:\"#{factor}\")).round(2) rescue 0\n end\n comparison_data << average(todays_data)\n your_data << average(your_temp_data)\n end\n else\n uniq_exam_dates.each do |date|\n your_temp_data,todays_data = [], []\n collection.where(exam_date:date).each do |report|\n your_temp_data << report.send(:\"#{factor}\")\n end\n Report.where(exam_date:date, school_id:current_user.school.id).each do |m|\n todays_data << (m.send(:\"#{factor}\")).round(2) rescue 0\n end\n comparison_data << average(todays_data)\n your_data << average(your_temp_data)\n end\n end\n your_data.reverse!\n comparison_data.reverse!\n factor == \"accuracy\" ? plot_accuracy(your_data, comparison_data) : plot_time_management(your_data, comparison_data)\n end",
"def fetch_articles\n\t\trequire 'open-uri'\n\t\tnewest_article = Article.limit(1).order(\"date DESC\")\n\t\ttrigger = false\n\t\tarticles = Array.new\n\t\tcache_article = Article.new\n\n\t\tfile = open(URL)\n\t\tcontents = file.readlines\n\t\tcontents.each do |line|\n\t\t\tif trigger\n\t\t\t\t#Date\n\t\t\t\tif line =~ /[1-3]?[0-9]\\.1?[0-9]\\.201[0-9]{1}/\n\t\t\t\t\tcache_article.date = line.slice(/[1-3]?[0-9]\\.1?[0-9]\\.201[0-9]{1}/)\n\t\t\t\t\tif (newest_article[0] != nil && cache_article.date < newest_article[0].date)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\tend\n\t\t\t\t#Title\n\t\t\t\telsif line =~ /<h2>.+<\\/h2>/\n\t\t\t\t\tline.slice!(\"<h2>\")\n\t\t\t\t\tline.slice!(\"<\\/h2>\")\n\t\t\t\t\tcache_article.title = replace_uml line.strip\n\t\t\t\t#Text\n\t\t\t\telsif line =~ /<p[^>]*>/\n\t\t\t\t\tcache_article.text = fetch_text cache_article.url\n\t\t\t\t\tcache_article.text = replace_uml cache_article.text\n\t\t\t\t\timage_url = fetch_image_url cache_article.url\n\t\t\t\t\tcache_article.news_image = URI.parse(image_url) \n\t\t\t\t\tarticle = Article.create(title: cache_article.title, url: cache_article.url, text: cache_article.text, date: cache_article.date, news_image: cache_article.news_image)\n\t\t\t\t\ttrigger = false\n\t\t\t\t#url\n\t\t\t\telsif line =~ /\\/de\\/newsdetail.+.html/\n\t\t\t\t\tcache_article.url = \"http://www.ehco.ch\" + line.slice(/\\/de\\/newsdetail.+.html/)\n\t\t\t\tend\n\t\t\telsif line.include? \"news-element newsarchiv\"\n\t\t\t\ttrigger = true\t\t\t\t\t\n\t\t\tend\n\t\tend\n\tend",
"def book_sales(period='enddate', basis, exclude)\n royalty_period = Period.where([\"currentperiod = ? and client_id = ?\", true, self.client_id])\n if period == 'startdate'\n self.calculate_book_royalties(self, royalty_period.first.enddate, royalty_period.first.startdate, basis, exclude)\n else #if period isn't 'startdate'\n self.calculate_book_royalties(self, royalty_period.first.enddate, \"1900-01-01\", basis, exclude)\n end\n end",
"def articles\n @articles\n end",
"def index\n\t\t@articles = Article.paginate(page: params[:page], per_page: 9).ultimos\n\n\tend",
"def show_all_articles\n\t\tif @articles.size > 0\n \t\t\t@articles.each do |article|\n \t\t\tshow_article_piece(\"\\nArticle Title: #{article[:title]}\\nSection: #{article[:section]}\\nColumn: #{article[:column]}\")\n \t\t\t\tshow_article_piece(\"Published: #{article[:date]}\\nDescription: #{article[:description]}\\nLink: #{article[:url]}\")\n \t\t\tend\n \t\t\tputs \"\\nTotal Articles Available: #{@articles.size}\"\n \t\telse # No articles to display\n \t\t\tputs \"\\nSorry, There are no articles available with the options that were selected.\"\n \t\tend\n \tend",
"def get_publication_dates(params)\n params[:domain] = host_from_url(params[:domain])\n uri = @base_uri+'publication_dates'\n uri.query = \"domain=#{params[:domain]}&production_days=#{params[:production_days]}\"\n result = content_from(uri)\n result['issues'] = result['issues'].map{|date| Date.parse(date)}\n result\n end",
"def timeline(params={:include => [:events, :attractions, :meals, :transportations]})\n dataset = {}\n if params[:include]\n timeline_include_events(dataset) if params[:include].include?(:events)\n timeline_include_attractions(dataset) if params[:include].include?(:attractions)\n timeline_include_transportations(dataset) if params[:include].include?(:transportations)\n timeline_include_meals(dataset) if params[:include].include?(:meals)\n end\n \n dataset.each do |k, v|\n \n end\n \n return dataset\n end",
"def show\n @entries = @slideshow.entries.recent.limit(12)\n\n @active_feeds = @slideshow.feeds.order(title: :asc)\n @available_feeds = Feed.where.not(id: @slideshow.feed_ids).order(title: :asc)\n end",
"def index\n\t @articles = Article.paginate(page: params[:page],per_page:5).publicados.ultimos\n\tend",
"def index\n @periods = Period.all\n @all_scholarships = Array.new\n @periods.each do |p|\n @all_scholarships << {\"sesiune\" => p, \"burse\" => Domain.where(:period_id => p.id)}\n end\n end",
"def displayAll (period)\n \t# We take only days that fall in week of Date.today.cweek\n \t@daysFromWeek = []\n \t@daysFromMonth = []\n \t#@daysFromYear = []\n \t@currentWeek = Date.today.cweek\n \t@currentMonth = Date.today.month\n \t@currentYear = Date.today.year\n \t# iterate over all the days and add days from the current week\n \t# save the time values from these\n \t@days.each { |day|\n \t\tif (period == 'Week' && day.day.cweek == @currentWeek)\n \t\t\t@daysFromWeek.push(day.time)\n \t\tend\n\n \t\tif (period == 'Month' && day.day.month == @currentMonth)\n \t\t\t#@time += \n \t\t\t@daysFromMonth.push(day.time)\n \t\tend\n \t\t# Year is going to be a little trickier\n \t\t# We need to go through all the days and split them \n \t\t# by month. all date.month == 1 will go into a[0]...\n \t\t#if period == 'Year' && day.day.year == @currentYear \n \t}\n\n \tif period == 'Week'\n \t\treturn @daysFromWeek\n \telsif period == 'Month'\n \t\treturn @daysFromMonth\n \tend\n\n end",
"def index\n @article_collections = ArticleCollection.all\n set_article_list\n end",
"def index\n @schedule_entries = ScheduleEntry.all\n current_date = Date.today\n monday = current_date.monday\n dates_this_week = [monday, monday.next, monday.next.next, monday.next.next.next, monday.next.next.next.next]\n @grouped_periods = Period.where(:date => dates_this_week).group_by {|period| period.num}.values\n end",
"def mongo_daily_views\n \tARTICLE_DAILY_VIEWS.find(:article_id => id).projection(:article_id => 0, :_id => 0).first\n end",
"def cur_calendars\n Article.find(:all, :conditions => ['issue_id = ? AND ((priority >= 50 AND priority < 55) OR (priority >= 70 AND priority < 75))', id], :order => 'priority')\n end",
"def fees(period = (Time.now.beginning_of_month - 1).beginning_of_month .. (Time.now.beginning_of_month - 1).end_of_month)\n subscription_payments.all(:conditions => { :created_at => period }).collect(&:affiliate_amount).sum \n end",
"def default_data collection, factor\n your_data, comparison_data, l1_data, l2_data, l3_data = [], [], [], [], []\n average_l1_comp_data, average_l2_comp_data, average_l3_comp_data = [],[],[]\n duration = params[\"duration\"]\n uniq_exam_dates = collection.map(&:exam_date).uniq\n if duration == \"12\"\n Date.today.month.times do |count|\n l1_temp_data, l2_temp_data, l3_temp_data = [], [], []\n collection.where(exam_date:(Time.now-count.month).all_month()).each do |r|\n l1_temp_data << r.send(:\"l1_#{factor}\")\n l2_temp_data << r.send(:\"l2_#{factor}\")\n l3_temp_data << r.send(:\"l3_#{factor}\")\n end\n l1_comp_data, l2_comp_data, l3_comp_data = [], [], [] \n Report.where(exam_date: (Time.now-count.month).all_month(), school_id:current_user.school.id).each do |m|\n l1_comp_data << m.send(:\"l1_#{factor}\")\n l2_comp_data << m.send(:\"l2_#{factor}\")\n l3_comp_data << m.send(:\"l3_#{factor}\")\n end\n l1_data << average(l1_temp_data)\n l1_data.reverse!\n l2_data << average(l2_temp_data)\n l2_data.reverse!\n l3_data << average(l3_temp_data)\n l3_data.reverse!\n average_l1_comp_data << average(l1_comp_data)\n average_l1_comp_data.reverse!\n average_l2_comp_data << average(l2_comp_data)\n average_l2_comp_data.reverse!\n average_l3_comp_data << average(l3_comp_data)\n average_l3_comp_data.reverse!\n end\n else\n uniq_exam_dates.each do |date|\n l1_temp_data, l2_temp_data, l3_temp_data = [], [], []\n collection.where(exam_date:date).each do |r|\n l1_temp_data << r.send(:\"l1_#{factor}\")\n l2_temp_data << r.send(:\"l2_#{factor}\")\n l3_temp_data << r.send(:\"l3_#{factor}\")\n end\n l1_comp_data, l2_comp_data, l3_comp_data = [], [], [] \n Report.where(exam_date: date, school_id:current_user.school.id).each do |m|\n l1_comp_data << m.send(:\"l1_#{factor}\")\n l2_comp_data << m.send(:\"l2_#{factor}\")\n l3_comp_data << m.send(:\"l3_#{factor}\")\n end\n l1_data << average(l1_temp_data)\n l2_data << average(l2_temp_data)\n l3_data << average(l3_temp_data)\n average_l1_comp_data << average(l1_comp_data)\n average_l2_comp_data << average(l2_comp_data)\n average_l3_comp_data << average(l3_comp_data)\n end\n end\n your_data = [l1_data, l2_data, l3_data]\n comparison_data = [average_l1_comp_data, average_l2_comp_data, average_l3_comp_data]\n factor == \"time\" ? plot_timedistribution(your_data, comparison_data) : plot_strategy(your_data, comparison_data)\n end",
"def set_event\n year_ids = params[:date][:year] unless params[:date].nil?\n @events = Event.where(privacy:\"f\").order(\"date_begin DESC\").search(year_ids).page(params[:page]).per(10)\n @categories = Category.all\n @departments = Department.all\n end",
"def index\n if params[:periodo]\n @mes_referencia = params[:periodo].to_date\n else\n @mes_referencia = Date.today\n end\n # FIXME Acrescentado para evitar bugs nos dias > 28\n # Deve ser corrigido pois pode afetar o fluxo de caixa do mês\n @mes_referencia = @mes_referencia.change(day: 1)\n data_corrente = Date.today\n params[:periodo] = l(data_corrente) unless params[:periodo]\n @metas = apply_scopes(Meta).all.order('pontuacao DESC')\n respond_to do |format|\n format.html\n format.csv { export_csv(@metas) }\n end\n # respond_with(@metas)\n end",
"def set_period\n @period = Period.find(params[:id])\n end",
"def set_period\n @period = Period.find(params[:id])\n end",
"def set_period\n @period = Period.find(params[:id])\n end",
"def index\n\t\t# Devuelve los articulos publicados\n\t\t@articles = Article.paginate(page: params[:page],per_page:9).publicados.ultimos\n\tend",
"def generate_ymd_indices\n years = {}\n months = {}\n days = {}\n\n sorted_articles.each do |item|\n time = attribute_to_time(item[:created_at])\n\n years[time.year] ||= []\n years[time.year] << item\n\n months[time.year] ||= {}\n months[time.year][time.month] ||= []\n months[time.year][time.month] << item\n\n days[time.year] ||= {}\n days[time.year][time.month] ||= {}\n days[time.year][time.month][time.day] ||= []\n days[time.year][time.month][time.day] << item\n end\n\n ret = []\n years.each do |year, a_year|\n ret << Nanoc::Item.new(\n '<%= render \\'partials/article_list\\', :articles => @item[:list] %>',\n {\n :title => Date.new(year).strftime(@config[:year]),\n :kind => 'fixed', :extension => 'html', :list => a_year\n },\n Date.new(year).strftime('/%Y/')\n )\n\n months[year].each do |month, a_month|\n ret << Nanoc::Item.new(\n '<%= render \\'partials/article_list\\', :articles => @item[:list] %>',\n {\n :title => Date.new(year, month).strftime(@config[:monthyear]),\n :kind => 'fixed', :extension => 'html', :list => a_month\n },\n Date.new(year, month).strftime('/%Y/%m/')\n )\n\n days[year][month].each do |day, a_day|\n ret << Nanoc::Item.new(\n '<%= render \\'partials/article_list\\', :articles => @item[:list] %>',\n {\n :title => Date.new(year, month, day).strftime(@config[:date]),\n :kind => 'fixed', :extension => 'html', :list => a_day\n },\n Date.new(year, month, day).strftime('/%Y/%m/%d/')\n )\n end\n end\n end\n\n ret\nend",
"def articles\n return @articles\n end",
"def show\n @period_list = [['7 days',7],['14 days',14],['31 days',30],['3 months',90],['6 months',180]]\n\n # get description data\n @transaction_group = TransactionGroup.find(params[:id])\n @transaction_group.transaction_group_items.all\n \n # get the period, default is 7 days\n @period_curr = params[:period].to_i\n @period_curr = 180 if @period_curr.nil? || @period_curr == 0\n\n mgr = GraphTransactionGroup.new\n mgr.getData(@transaction_group, @period_curr)\n @google_url = mgr.write\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @transaction_group }\n end\n end",
"def article_schedule(date_cond)\n # current_user's schedules\n schedule_ids = schedule_ids_during(date_cond, @current_user)\n \n unless @other_user.blank?\n other_schedule_ids = schedule_ids_during(date_cond, @other_user)\n schedule_ids = (schedule_ids.to_set & other_schedule_ids.to_set).to_a\n end\n# return [] if schedule_ids.blank?\n schedule_ids.blank? and return [] \n \n Article.find schedule_ids,\n :select => Article_Schedule_Item,\n :scope => \":self >> thread:ArticleThread\",\n :conditions=> forum_cond,\n :group => \"articles.id\"\n end",
"def latest_by_section\n unless @latest_articles_for_sections\n @latest_articles_for_sections = {}\n for article in latest_articles_for_sections\n if @latest_articles_for_sections[article.section]\n @latest_articles_for_sections[article.section] << article\n else\n @latest_articles_for_sections[article.section] = [article]\n end\n end\n end\n @latest_articles_for_sections\n end",
"def all_movement_by_period(period)\n\t\tmonth,year = period.split(\"/\")\n\t\tperiod = \"#{year}-#{month}\"\n\t\tcash_bank_bank_movements.all(:conditions => [\"SUBSTRING(date,1,7) = '#{period}'\"])\n\tend",
"def set_period\n @period = Period.joins(:budget).where(user: current_user).find(params[:period_id] || params[:id])\n end",
"def articles_data(source)\n articles_url = Api.gnews_path('articles?source=' + source)\n call_gnews_url(articles_url).parse\n end",
"def index\n @valet_data = ValetDatum.all.limit(20)\n @day = params[:day]\n end",
"def select_docs_by(basedate, unit, itype, condition)\n #SQL filter by date & itype\n start_at = period_start_at(basedate, unit).in_time_zone\n end_at = period_end_at(basedate, unit).in_time_zone\n #debugger\n #debug(\"#{start_at} ~ #{end_at}\")\n itypes = (itype == \"all\")? Item.itype_lists : itype.to_a\n cond = [\"basetime >= ? and basetime< ? and itype in (?)\", start_at, end_at, itypes]\n \n #Fetch either from Document or DataDocument\n docs = Item.all(:conditions=>cond).group_by(&:itype)\n result = {}\n docs.each do |itype,docs|\n #info(\"[StatExtractor:select_docs_by(#{start_at.ymdhms} ~ #{end_at.ymdhms}}/#{itype})] total #{docs.size} docs\")\n docs = docs.find_all do |d|\n d.validate_by_condition(condition)\n end#find\n if block_given?\n yield itype, docs\n else\n result[itype] = docs\n end\n end#each(itype)\n result\n end",
"def index\n @teaching_periods = TeachingPeriod.all\n end",
"def download_article_data\n print \"Getting list of articles...\\n\"\n ArticleGetter.new([ARTICLE_SOURCE]).result\n end",
"def period\n return @period\n end",
"def index\n @periodes = {}\n dates = FeuilleGroupe.candidates\n Periode.where(\"debut >= ?\", Date.new(Date.today().year, 1, 1)).each do | p |\n @periodes[p.debut] = p\n end\n \n # Ajouter une periode ou il n'y en a pas encore\n now = Date.today\n dates.each do | date |\n if !@periodes.has_key?(date) && date <= now\n @periodes[date] = Periode.new({debut: date})\n end\n end\n @periodes = @periodes.sort.to_h.values\n end",
"def period_summary\n [\n ['Days of distribution', distribution_collection.days_of_distribution],\n ['Unique households', household_collection.length],\n ['Unique residents', client_collection.length],\n ['Distributions', distribution_collection.length],\n ['New households', household_collection.new(for_date).length],\n ['New residents', household_collection.new_clients(for_date)],\n ['Lbs. of food distributed', distribution_collection.lbs_of_food_distributed]\n ]\n end",
"def index\n @entries = current_user.entries.for_month(@date)\n @budgets = current_user.budgets\n end",
"def paginate_entries_a_year(entity_opts,opts)\n opts[:start_time] = Time.now.last_year\n opts[:end_time] = Time.now\n paginate_entries_within_interval(entity_opts,opts)\n end",
"def feed_for(name)\n find_articles(name) \n articles_to_list\n feed = @page.page_parts.where(name: 'feed').first\n process_with_filter(feed) \n end",
"def scrape\r\n @article_arr = []\r\n\t\turl = 'http://www.theage.com.au/rssheadlines/technology-news/article/rss.xml'\r\n open(url) do |rss|\r\n \tfeed = RSS::Parser.parse(rss, false)\r\n puts \" \"\r\n puts \"*********************************\"\r\n \tputs \"Title: #{feed.channel.title}\"\r\n puts \"--------------------------------\"\r\n feed.items.each do |item|\r\n \t@article_arr << AgeArticle.new(author: \"nil\", title: item.title.to_s.gsub(/,/,''), \r\n summary: (item.description).match(/\\<\\/p\\>[\\w ?,''\"\"]+/).to_s.gsub(/\\<\\/p\\>/,'').gsub(/,/,'').gsub(/\\\"/,''), \r\n images: (item.description).match(/http.+\\.(jpg|png)/), source: item.link, date: item.pubDate.to_s.gsub(/,/,''))\r\n end\r\n end\r\n @articles.concat(@article_arr)\r\n end",
"def get_new_articles\n # Download the RSS feed and save to self.doc\n get_source\n \n # Keep track of which articles are in the feed \n articles = []\n \n article_links = (self.doc/'li.mjItemMain').collect do |mjItem|\n mjItem.at('a.mjLinkItem')\n end\n \n # For each item in the RSS feed \n article_links.each_with_index do |link, index|\n \n # Create or update the article in the db\n articles << Article.factory(\n :category => self.category,\n :description => '',\n :feed => self,\n :url => \"http://online.wsj.com#{link.attributes['href']}\",\n :priority => index\n )\n end\n \n articles\n end",
"def index\n @articles = Article.paginate(page: params[:page], per_page: 10).order('pub_date DESC')\n end",
"def index\n # @accounts = Account.order(:buyday).all.page(params[:page]).per(5)\n @accounts = Account.all.page(params[:page]).per(5)\n @grouped_months = @accounts.group_by { |r| r.buyday.beginning_of_month}\n\n @month_num = ['1','2','3','4','5','6','7','8','9','10','11','12']\n @month_details = []\n @month_costs = []\n (0..11).each do |i|\n @month_details[i] = Account.where([\"date_part('month',buyday) = ? and date_part('year',buyday) = ?\" , @month_num[i],2015]).order('buyday desc')\n @month_costs[i] = Account.where([\"date_part('month',buyday) = ? and date_part('year',buyday) = ?\" , @month_num[i],2015]).sum(:dollar)\n end\n # @mar = Account.where(['buyday between ? and ?', '2015-03-01', '2015-03-31' ])\n \n end",
"def index\n @get_banners ||= Banner.where(published: true)\n @featured_articles ||= Article.limit(3).where(published: true)\n @our_clients ||= TrustCompany.all.order('RANDOM()').limit(15)\n\n @portfolios ||= Portfolio::Portfolio.where(published: true).order('release desc').limit(12)\n\n\n end",
"def index\n @periods = Period.find(:all, :include => { :talks => :users })\n @periods_by_time_and_scene = Hash.new\n for p in @periods\n @periods_by_time_and_scene[p.time_id] ||= Hash.new\n @periods_by_time_and_scene[p.time_id][p.scene_id] = p \n end\n\n @time_ids = @periods.collect { |p| p.time_id }.sort.uniq\n \n @edit = params[:edit] && admin?\n @all_talks = Talk.all_pending_and_approved if @edit\n @all_talks.sort!{|t1,t2|t1.id <=> t2.id}\n\n respond_to do |format|\n format.html {render :layout => 'plain' }# index.html.erb\n format.xml { render :xml => @periods }\n end\n end"
] |
[
"0.6340772",
"0.6268592",
"0.6192167",
"0.6175236",
"0.5997018",
"0.59653",
"0.5928373",
"0.5853675",
"0.58528817",
"0.58490795",
"0.58367676",
"0.5802076",
"0.5752877",
"0.57439256",
"0.57111377",
"0.57017946",
"0.5693628",
"0.56608725",
"0.5642664",
"0.56386214",
"0.5580434",
"0.5580225",
"0.5575473",
"0.5568342",
"0.55438983",
"0.5531408",
"0.5528497",
"0.55031556",
"0.5490659",
"0.5490226",
"0.54735506",
"0.54616684",
"0.54443705",
"0.5425348",
"0.5422242",
"0.5416323",
"0.5416155",
"0.5414208",
"0.5410915",
"0.54065114",
"0.5383213",
"0.5381983",
"0.5378385",
"0.53738403",
"0.5367498",
"0.5360676",
"0.5350257",
"0.53469545",
"0.5346593",
"0.53441316",
"0.5338383",
"0.53341657",
"0.53315747",
"0.5328027",
"0.53269726",
"0.5325483",
"0.5320429",
"0.53204095",
"0.5318434",
"0.5314375",
"0.53122497",
"0.5309043",
"0.53062373",
"0.5303017",
"0.52995896",
"0.5298233",
"0.5297644",
"0.5294373",
"0.52898085",
"0.5285463",
"0.52824724",
"0.5281515",
"0.5279448",
"0.5279448",
"0.5279448",
"0.52774966",
"0.52752644",
"0.5275042",
"0.5271031",
"0.5267276",
"0.52653605",
"0.5260486",
"0.5258202",
"0.52540535",
"0.5253697",
"0.52523834",
"0.52475995",
"0.5247052",
"0.524077",
"0.52359754",
"0.5231034",
"0.5228656",
"0.5228462",
"0.5223685",
"0.52225804",
"0.5220308",
"0.52133965",
"0.520739",
"0.52042705",
"0.52025515"
] |
0.5453094
|
32
|
db data by url
|
def set_article_data(hostname, uri, startdate, enddate)
url = 'https://' + hostname + uri
article = Article.find_by(article_url: url)
start_date = startdate.to_date.beginning_of_day
end_date = enddate.to_date.end_of_day
articleArr = Array.new
if article
id = article.id
clickCount = article.clicks.where(:created_at => start_date..end_date).count
else
id = 0
clickCount = 0
end
articleArr = [id, clickCount]
return articleArr
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def database! url\n parsed = parse url\n cr = Sova.new(parsed[:host])\n cr.database!(parsed[:database])\n end",
"def database! url\n parsed = parse url\n cr = CouchRest.new(parsed[:host])\n cr.database!(parsed[:database])\n end",
"def write_urls_db()\n end",
"def getDBData(urlInput)\n url = URI.parse(urlInput)\n server = Couch::Server.new(url.host, url.port)\n res = server.GET(urlInput)\n puts \"PARSING JSON FILE--------------\"\n json = JSON.parse(res.body)\n return json\n end",
"def save_data(url_list)\n urls = []\n url_list.each do |url|\n begin\n parsed_url = URI.parse(url)\n main_url = parsed_url.scheme + '://' + parsed_url.host + parsed_url.path\n query = URI::decode_www_form(parsed_url.query).to_h rescue nil\n insert_in_table({url: main_url, query: query})\n rescue Exception => e\n puts \"BAD URL = #{e.message}, url = #{url}\"\n end\n end\n puts urls\n end",
"def find(url)\n @database.get(url) rescue nil\n end",
"def parse_database_url(url)\n parsed = URI(url)\n {}.tap do |db|\n # Store this for use later in #set_state, and maybe future use by\n # Django in some magic world where operability happens.\n db[:URL] = url\n db[:ENGINE] = resolve_engine(parsed.scheme)\n # Strip the leading /.\n path = parsed.path ? parsed.path[1..-1] : parsed.path\n # If we are using SQLite, make it an absolute path.\n path = ::File.expand_path(path, self.path) if db[:ENGINE].include?('sqlite')\n db[:NAME] = path if path && !path.empty?\n db[:USER] = parsed.user if parsed.user && !parsed.user.empty?\n db[:PASSWORD] = parsed.password if parsed.password && !parsed.password.empty?\n db[:HOST] = parsed.host if parsed.host && !parsed.host.empty?\n db[:PORT] = parsed.port if parsed.port && !parsed.port.empty?\n end\n end",
"def get_record(param)\n db = Sequel.connect('postgres://username:password@localhost:5432/shorty')\n if param.is_a?(Integer)\n @data = db[:data].limit(param).order(:id.desc).all\n else\n @data = db[:data].filter(:surl => param).first\n end\nend",
"def get_couch_db(url)\n if !url.end_with?('/')\n url = url + '/'\n end\n url = url + 'mydb'\n\n puts 'Using URL: ' + url\n #This will create the DB if it does not exist, however it will fail if you do not have permissions\n CouchRest.database!(url)\n end",
"def db(*args); data(1, args); end",
"def url(url_or_int = 1)\n case url_or_int\n when String\n parsed_url = Wgit::Url.parse(url_or_int)\n append_url(parsed_url)\n when Array\n url_or_int.each { |url| append_url(url) }\n when Integer\n url_or_int.times { @@urls << DatabaseTestData.url }\n else\n raise \"Invalid data type: #{url_or_int.class}\"\n end\n end",
"def get_file_from_url(url)\n return $db.execute(\"SELECT * FROM files WHERE unique_url = ?\", url)[0]\nend",
"def db_info\n @conn.query({url_path: \"#{database}\", method: :get})\n end",
"def database\n @database ||= opts.fetch(:database, parsed_uri.path[1..-1])\n end",
"def shorten_url\n db = Sequel.connect('postgres://username:password@localhost:5432/shorty')\n data = db[:data]\n params[:url] = \"http://\"+params[:url] unless params[:url].match(/^http:\\/\\//)\n if (data.order(:id).last) \n data.insert(:url => params[:url], :surl => data.order(:id).last[:surl].succ)\n else\n data.insert(:url => params[:url], :surl => \"A\")\n end\nend",
"def db_tuna_add(url)\n db = open_create_db\n\n if db\n db.execute(\"INSERT INTO tunaimgur(url, time) VALUES(?,?)\", url, DateTime.now.strftime(\"%b %d, %Y at %l:%M:%S %p (%Z)\").to_s )\n end\n result = db.execute(\"SELECT 1 FROM tunaimgur WHERE url = ?\", url)\n return result[0][0]\n db.close\n end",
"def fetch_urls\n # Crazy crazy URLs to try to find PARSE_PARAMS in Sfx4 db that have a period in\n # them, so they look like they might be URLs. Parse params could be at target service\n # level, or at portfolio level; and could be in local overrides or in global kb. \n # This is crazy crazy SQL to get this, sorry. Talking directly to SFX db isn't\n # a great idea, but best way we've found to get this for now. Might make more\n # sense to try to use the (very very slow) SFX export in the future instead. \n sql = %{\n SELECT \n COALESCE(LCL_SERVICE_LINKING_INFO.PARSE_PARAM,KB_TARGET_SERVICES.PARSE_PARAM) PARSE_PARAM\n FROM\n LCL_TARGET_INVENTORY\n JOIN sfxglb41.KB_TARGET_SERVICES\n ON KB_TARGET_SERVICES.TARGET_ID = LCL_TARGET_INVENTORY.TARGET_ID\n JOIN LCL_SERVICE_INVENTORY \n ON LCL_TARGET_INVENTORY.TARGET_ID = LCL_SERVICE_INVENTORY.TARGET_ID\n LEFT OUTER JOIN LCL_SERVICE_LINKING_INFO\n ON LCL_SERVICE_INVENTORY.TARGET_SERVICE_ID = LCL_SERVICE_LINKING_INFO.TARGET_SERVICE_ID\n WHERE\n ( LCL_SERVICE_LINKING_INFO.PARSE_PARAM like '%.%' OR\n KB_TARGET_SERVICES.PARSE_PARAM like '%.%' )\n AND\n LCL_SERVICE_INVENTORY.ACTIVATION_STATUS='ACTIVE'\n AND\n LCL_TARGET_INVENTORY.ACTIVATION_STATUS = 'ACTIVE'\n\n UNION\n -- object portfolio parse param version\n SELECT\n COALESCE(LCL_OBJECT_PORTFOLIO_LINKING_INFO.PARSE_PARAM, KB_OBJECT_PORTFOLIOS.PARSE_PARAM) PARSE_PARAM\n FROM\n sfxglb41.KB_OBJECT_PORTFOLIOS\n JOIN LCL_SERVICE_INVENTORY\n ON KB_OBJECT_PORTFOLIOS.TARGET_SERVICE_ID = LCL_SERVICE_INVENTORY.TARGET_SERVICE_ID\n JOIN LCL_OBJECT_PORTFOLIO_INVENTORY\n ON KB_OBJECT_PORTFOLIOS.OP_ID = LCL_OBJECT_PORTFOLIO_INVENTORY.OP_ID\n left outer join LCL_OBJECT_PORTFOLIO_LINKING_INFO\n ON KB_OBJECT_PORTFOLIOS.OP_ID = LCL_OBJECT_PORTFOLIO_LINKING_INFO.OP_ID \n WHERE\n ( KB_OBJECT_PORTFOLIOS.PARSE_PARAM like '%.%' OR \n LCL_OBJECT_PORTFOLIO_LINKING_INFO.PARSE_PARAM like '%.%' )\n AND LCL_OBJECT_PORTFOLIO_INVENTORY.ACTIVATION_STATUS = 'ACTIVE' \n AND LCL_SERVICE_INVENTORY.ACTIVATION_STATUS='ACTIVE'\n }\n\n results = connection.select_all(sql)\n urls = []\n results.each do |line|\n param_string = line[\"PARSE_PARAM\"]\n # Try to get things that look sort of like URLs out. Brutal force,\n # sorry. \n url_re = Regexp.new('(https?://\\S+\\.\\S+)(\\s|$)')\n urls.concat( param_string.scan( url_re ).collect {|matches| matches[0]} ) \n end \n urls.uniq!\n return urls\n end",
"def add_db\n mapId = params[:mapId]\n venueName = params[:venueName]\n floor = params[:floor]\n typeMap = params[:typeMap]\n venueFloorMapImageUrl = params[:venueFloorMapImageUrl]\n venueFloorMapUrl = params[:venueFloorMapUrl]\n urlMaster = Urlmaster.create(:mapId => mapId, :venueName => venueName, :floor => floor, :typeMap => typeMap, :venueFloorMapImageUrl => venueFloorMapImageUrl, :venueFloorMapUrl => venueFloorMapUrl)\n if urlMaster\n redirect_to crawler_path\n else\n render :action => :add\n end\n end",
"def get(url); end",
"def data\n @data ||= ManageData.new data: url.to_s, list: @list\n end",
"def fetch_url_data(url)\n open(url).read\n end",
"def fetch_url_data(url)\n open(url).read\n end",
"def get_response url, format\r\n begin\r\n response = Net::HTTP.get_response(URI.parse(url))\r\n if format.to_sym == :json\r\n res = JSON.parse response.body\r\n else\r\n res = response.body\r\n end\r\n rescue Exception => e\r\n res = \"ERROR: There is a problem while fetching data, please check whether OpenTSDB is running or not.\"\r\n end\r\n res\r\n end",
"def db; end",
"def db; end",
"def queryurlTable\n @conn.exec( \"SELECT * FROM urls\" ) do |result|\n result.each do |row|\n yield row if block_given?\n end\n end\n end",
"def db_record\n db or MyBiaDJ::Table(:files)[:path => relative_path, :name => name.to_s]\n end",
"def get_da_urls (doc,comment_url)\n doc.search('table tbody tr').each do |tr|\n # Columns in table\n # Show Number Submitted Details\n tds = tr.search('td')\n\n break if tds[0].inner_text =~ /no records/\n\n h = tds.map{|td| td.inner_html}\n\n puts h\n info_url = 'https://pdonline.toowoombarc.qld.gov.au/Masterview/Modules/ApplicationMaster/' + tds[0].at('a')['href'].strip\n puts info_url\n descParts = h[3].split('<br>')\n record = {\n 'info_url' => info_url,\n 'comment_url' => comment_url,\n 'council_reference' => clean_whitespace(h[1]),\n 'date_received' => Date.strptime(clean_whitespace(h[2]), '%d/%m/%Y').to_s,\n # TODO: Some DAs have multiple addresses, we're just getting the first :(\n 'address' => clean_whitespace(descParts[0]),\n 'description' => clean_whitespace(descParts[1]),\n 'date_scraped' => Date.today.to_s\n }\n\n if (ScraperWiki.select(\"* from data where `council_reference`='#{record['council_reference']}'\").empty? rescue true)\n ScraperWiki.save_sqlite(['council_reference'], record)\n else\n puts \"Skipping already saved record \" + record['council_reference']\n end\n end\nend",
"def print_urls db, tables\n tables.each do |tbl|\n db.execute(\"select word,pdata,pic,usa,uk from #{tbl}\") do |row|\n pdata = xml2urls row[1]\n\n pic = [nil]\n if row[2]\n pic = ['http://www.longmandictionariesusa.com/res/ldoce/images/mobile/fullsize/%s.jpg' % row[2].sub(/\\.[^.]+$/, '').downcase]\n end\n\n usa = [nil]\n if row[3]\n usa = ['http://www.longmandictionariesusa.com/res/ldoce/audio/hwd/ame/' + row[3]]\n end\n\n uk = [nil]\n if row[4]\n uk = ['http://www.longmandictionariesusa.com/res/ldoce/audio/hwd/bre/' + row[4]]\n end\n\n puts \"# #{row[0]}\"\n (pdata + pic + usa + uk).select {|name| name}.each {|name| puts name}\n end\n end\nend",
"def datastore_url\n @datastore_url ||= 'sqlite://db/data.sqlite3'\n end",
"def openDB\n db =Rho::Database.new(Rho::Application.databaseFilePath('local'), \"local\");\n puts \"#{db.to_s}\"\n data = db\n data\n end",
"def get( id )\n resource = begin # this is just in case the developer has already escaped the name\n CouchDB.get( \"#{database.uri}/#{CGI.escape(id)}\" )\n rescue\n CouchDB.get( \"#{database.uri}/#{id}\" ) \n end\n new( resource ) \n end",
"def fetch(name); end",
"def getDB\n @db\n end",
"def database; datastore['DATABASE']; end",
"def url\n end",
"def get_url_data(url)\n Nokogiri::HTML(open(url))\n end",
"def get_data(flag, url)\n\t\t\t\t\t\tdata = \"\"\n\t\t\t\t\t\t\t\tresponse = 0\n\t\t\t\t\t\t\t\t\t\tif flag == false\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tresponse = RestClient.get(url)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdata = JSON.load response\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t\treturn data\nend",
"def database_info(dbname, options = {})\n version = options.fetch(:t, '-')\n get db_url(dbname, version) + \"/\", :Accept => 'application/edn'\n end",
"def databags(api_url)\n @databags = Berkshelf::Source.new(api_url)\n end",
"def fetchfilm parturl, _file=nil\n return nil unless parturl\n table = \"movie\"\n if parturl.index(\"&\")\n #$log.warn \"Cannot handle ampersand in URL. please correct #{parturl}\"\n $stderr.puts \">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\"\n $stderr.puts \"Cannot handle ampersand in URL. please correct #{parturl}\"\n $stderr.puts \"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\"\n return nil\n end\n # remove HOST and keep last part\n if parturl.index OLDHOST\n parturl = parturl[OLDHOST.length..-1]\n end\n if parturl.index HOST\n parturl = parturl[HOST.length..-1]\n end\n if parturl.index(\"http:\") or parturl.index(\"https:\")\n # added this block 2015-12-30 \n $stderr.puts \">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\"\n $stderr.puts \"Don't know how to handle this host : #{parturl}. Pls use #{HOST} if you must.\"\n $stderr.puts \"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\"\n #$log.error \"Don't know how to handle #{parturl}\"\n #exit(1)\n return nil\n end\n #inserting = false\n return nil if parturl.nil? || parturl.strip == \"\"\n parturl = parturl.chomp\n #nid = counter + starting\n nid = nil\n upperurl = parturl.upcase\n key = converturl parturl\n id = $db.get_first_value %Q[select rowid from #{table} where upper(url) = \"#{upperurl}\";]\n # in some cases the data on wiki has changed a lot, so we are forcing a download\n unless $opt_force\n if id.nil?\n id = $db.get_first_value %Q[select url from #{table} where upper(canonical) = \"#{upperurl}\";]\n if id\n $stderr.puts color(\"ERROR: FOUND another url with similar canonical : #{id} skipping ..\",\"red\");\n return nil\n end\n # NOTE 2016-02-28 - this can prevent me from downloading a movie with same name but different\n # year. I should check title + year at point of updating in db. or key + year.\n id = $db.get_first_value \"select rowid from #{table} where key = '#{key}';\"\n if id\n tmp = $db.get_first_value \"select url from #{table} where key = '#{key}';\"\n $stderr.puts color(\"ERROR: FOUND another row with similar KEY #{key}: #{id} #{tmp} , skipping ..\",\"red\");\n #$log.warn \"XXX: FOUND another row with similar KEY #{key}: #{id} #{tmp} , SKIPPING ..\"\n return nil\n end\n else\n $stderr.puts color(\"ERROR: FOUND another row with #{parturl} ... skipping\",\"red\");\n return nil\n end\n end\n id = nid\n url = HOST + parturl.strip\n #\n # BUG: still fails if ampersand in URL regardless of single or double quote\n # TODO maybe we need to try Shellwords.escape since i am able to do it with wget on commandline\n text = %x[wget -q -O - \"#{url}\"] \n # 2015-12-29 - sometimes the URL is wrong, so we get a blank. The file has zero bytes\n # so we should check here\n if text.nil? or text.chomp == \"\"\n $stderr.puts color(\"ERROR: =========== url is wrong or internet down, no data received #{url}. pls check ...\", \"red\")\n #$my_errors << \"no data fetched for #{parturl} pls check/correct.\"\n sleep(60)\n return nil\n end\n # 2016-03-08 - write to a temp folder and only copy to real name if file passes disambiguation check\n tmpfile = _file.sub(\"wiki\", \"tmp\")\n File.open(tmpfile,\"w\") {|f2| f2.write(text) }\n\n _ff = Shellwords.escape(tmpfile)\n type = `file #{_ff}`\n\n # check if its a zip\n # SOMETime it comes in zip format. how do contreol that ?\n # if file says zipped then add gz extension and do a gunzip\n if type.index \"gzip\"\n $stderr.puts color(\" gzip found, expanding\", \"blue\")\n FileUtils.mv tmpfile, \"#{tmpfile}.gz\"\n system \"gunzip #{_ff}.gz\"\n #text = File.readlines(_file).join(\"\\n\")\n end\n\n # 2016-03-08 - check if disambiguation page\n ret = %x[ ./oldprogs/grepdisambiguation.sh \"#{tmpfile}\" ]\n if ret and ret.size > 3\n $stderr.puts color(\" ERROR: This (#{tmpfile} is a disambiguation page, aborting ...\", \"red\" ) \n return nil\n end\n # all okay, move file to real folder\n FileUtils.mv tmpfile, _file\n #\n # TODO 2016-03-06 - 13:09 extract canonical and compare with parturl\n # If different then change html path removing HOST and calling uri_to_filename \n # Then change parturl and write to file so next program can pick up and adjust url, htmlpath and ymlpath.\n # We check after writing since the string could be in zip format.\n # This could fail, we may need to use _ff instead here and in parsedoc\n canonical = %x[ ./oldprogs/grepcanonical.sh -h \"#{_file}\" ]\n\n # 2016-03-08 - read file and check for canonical. if so return error do not update table.\n if canonical && canonical.size > 2\n canonical = canonical.chomp\n if ( (canonical != parturl) && (URI.decode(canonical) != parturl) )\n suggestedurl = URI.decode(canonical);\n # 2016-03-08 - if canon link contains disambiguation or '#' then return error\n if suggestedurl.index(\"disambiguation\") or suggestedurl.index(\"#\")\n $stderr.puts color(\" ERROR: This (#{suggestedurl} is a disambiguation page, aborting ...\", \"red\", \"reverse\") \n return nil\n end\n $stderr.puts color(\" WARNING: canonical does not match url, should change name #{parturl} != #{canonical}...\",\"red\");\n $stderr.puts color(\" WARNING: we should rename file and url to: #{suggestedurl} and change the parturl in file and caller \",\"red\");\n # if this works out, we can change the name of the file. and write new url and html path to a yml file.\n end\n end\n return _file\nend",
"def get_url_data(url)\n Nokogiri::HTML(open(url))\n end",
"def load_data(data_hash)\n super\n @url = data_hash['url']\n end",
"def query; end",
"def select(db); end",
"def select(db); end",
"def url\n end",
"def look_up(url)\n all = RestClient.get(url)\n hash = JSON.parse(all)\nend",
"def parse_url(url)\n expect! url => /^postgres(ql)?s?:\\/\\//\n\n require \"uri\"\n uri = URI.parse(url)\n raise ArgumentError, \"Invalid URL #{url}\" unless uri.hostname && uri.path\n\n config = {\n dbname: uri.path.sub(%r{^/}, \"\"),\n host: uri.hostname\n }\n config[:port] = uri.port if uri.port\n config[:user] = uri.user if uri.user\n config[:password] = uri.password if uri.password\n config[:sslmode] = uri.scheme == \"postgress\" || uri.scheme == \"postgresqls\" ? \"require\" : \"prefer\"\n config\n end",
"def parse_url(url)\n expect! url => /^postgres(ql)?s?:\\/\\//\n\n require \"uri\"\n uri = URI.parse(url)\n raise ArgumentError, \"Invalid URL #{url}\" unless uri.hostname && uri.path\n\n config = {\n dbname: uri.path.sub(%r{^/}, \"\"),\n host: uri.hostname\n }\n config[:port] = uri.port if uri.port\n config[:user] = uri.user if uri.user\n config[:password] = uri.password if uri.password\n config[:sslmode] = uri.scheme == \"postgress\" || uri.scheme == \"postgresqls\" ? \"require\" : \"prefer\"\n config\n end",
"def load_reg_db(url)\r\n begin\r\n url = self.module_patch(url)\r\n index_reg = 0\r\n File.open(\"#{url}\",\"r\") do | reg |\r\n line = reg.gets\r\n key_tag = \"\"\r\n while(false == (line.eql?(nil)))\r\n reg_key = line.split(',')\r\n if index_reg == 0\r\n key_tag = \"#{reg_key[0]}\"\r\n $reg_base[\"#{key_tag}\"] = Hash.new\r\n $reg_attribute[\"#{key_tag}\"] = Hash.new\r\n $reg_properties[\"#{key_tag}\"] = Hash.new\r\n #$reg_base[\"#{key_tag}\"][\"#{reg_key[0]}\"] = Regexp.new(\"#{reg_key[2].gsub(/\\n/,'')}\",Regexp::IGNORECASE)\r\n end\r\n $reg_base[\"#{key_tag}\"][\"#{reg_key[0]}\"] = Regexp.new(\"#{reg_key[2].gsub(/\\n/,'')}\",Regexp::IGNORECASE)\r\n if($reg_base[\"#{key_tag}\"][\"#{reg_key[0]}\"].eql?(nil))\r\n log \"#{reg_key[0]} cannot created regexp\",1\r\n end\r\n $reg_attribute[\"#{key_tag}\"][\"#{reg_key[0]}\"] = \"#{reg_key[1]}\"\r\n if reg_key[3].eql?(nil)\r\n $reg_properties[\"#{key_tag}\"][\"#{reg_key[0]}\"] = \"\"\r\n else\r\n $reg_properties[\"#{key_tag}\"][\"#{reg_key[0]}\"] = \"#{reg_key[3].gsub(/\\n/,'')}\"\r\n end\r\n #puts $reg_base.size\r\n line = reg.gets\r\n index_reg = index_reg + 1\r\n end\r\n end\r\n log(\"loading regexp datebase #{url} success\",1)\r\n rescue\r\n log(\"loading regexp datebase #{url} failed\")\r\n self.show_all\r\n end\r\n \r\n end",
"def website_connection(subdomain)\n\t default_connection.dup.update(:database => (\"db/\" + subdomain + \".sqlite3\"))\n\tend",
"def fetch; end",
"def fetch; end",
"def url\n data['url']\n end",
"def parse url\n begin\n @h_data = {}\n\n scheme, remaining_url = url.split( '://' )\n raise \"invalid scheme\" unless scheme == 'cassandra'\n raise \"invalid url\" if remaining_url.strip.nil? || remaining_url.strip == ''\n\n host_port, keyspace = remaining_url.split( '/' )\n raise \"no keyspace\" if keyspace.nil? || keyspace.strip == ''\n\n host, port = host_port.split( ':' )\n\n port = 9160 if port.nil? || post.strip == ''\n @h_data[:host] = host\n @h_data[:port] = port\n @h_data[:keyspace] = keyspace\n\n true\n rescue\n msg = \"ERROR PARSING CASSANDRA URL #{url}: #{$!}\"\n if defined?( Rails )\n Rails.logger.error msg\n else\n puts msg\n end\n false\n end\n end",
"def test_url_main\n\t\tres = DB.exec(\"SELECT main FROM urls WHERE id=3\")\n\t\tassert_equal 't', res[0]['main']\n\t\tres = DB.exec(\"SELECT main FROM urls WHERE id=5\")\n\t\tassert_nil res[0]['main']\n\t\tDB.exec(\"UPDATE urls SET main=TRUE WHERE id=5\")\n\t\tres = DB.exec(\"SELECT main FROM urls WHERE id=5\")\n\t\tassert_equal 't', res[0]['main']\n\t\tres = DB.exec(\"SELECT main FROM urls WHERE id=3\")\n\t\tassert_equal 'f', res[0]['main']\n\t\tres = DB.exec(\"SELECT main FROM urls WHERE id=6\")\n\t\tassert_nil res[0]['main']\n\t\tres = DB.exec(\"SELECT main FROM urls WHERE id=7\")\n\t\tassert_nil res[0]['main']\n\t\tDB.exec(\"UPDATE urls SET main='t' WHERE id=6\")\n\t\tres = DB.exec(\"SELECT main FROM urls WHERE id=6\")\n\t\tassert_equal 't', res[0]['main']\n\t\tres = DB.exec(\"SELECT main FROM urls WHERE id=7\")\n\t\tassert_equal 'f', res[0]['main']\n\t\tDB.exec(\"INSERT INTO urls (person_id, url, main) VALUES (3, 'salt.biz', 't')\")\n\t\tres = DB.exec(\"SELECT main FROM urls WHERE id=6\")\n\t\tassert_equal 'f', res[0]['main']\n\tend",
"def opendb\n db = Rho::Database.new(Rho::Application.databaseFilePath('local'), 'local')\n render :json => db.to_s\n return db.to_s\n end",
"def create_db name\n \n req = Net::HTTP::Put.new \"/#{name}\"\n ret = @http.request req\n \n puts \"Creating Database #{name} => #{ret.msg} (#{ret.code})\\n\"\n \n end",
"def get_all_data\n init_data\n\n Bot::DB[my_name]\n end",
"def get_all_data\n init_data\n\n Bot::DB[my_name]\n end",
"def run(url, headers, req_type, data = nil, sql = false)\n begin\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n if uri.port.to_s == \"443\"\n http.use_ssl = true\n end\n http.read_timeout = @timeout\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n requester = nil\n parsed_data = data\n\n if !sql \n parsed_data = data.to_json\n end\n\n if req_type == \"post\"\n requester = Net::HTTP::Post.new(uri.request_uri, initheader = headers)\n requester.body = parsed_data\n elsif req_type == \"put\"\n requester = Net::HTTP::Put.new(uri.request_uri, initheader = headers)\n requester.body = parsed_data\n elsif req_type == \"get\"\n requester = Net::HTTP::Get.new(uri.request_uri, initheader = headers)\n elsif req_type == \"delete\"\n requester = Net::HTTP::Delete.new(uri.request_uri, initheader = headers)\n end\n http.request(requester)\n rescue Timeout::Error, Errno::EINVAL,\n Errno::ECONNRESET, EOFError, Net::HTTPBadResponse,\n Net::HTTPHeaderSyntaxError, Net::ProtocolError => e\n raise e\n end\n end",
"def fetch\n end",
"def query_db(sql)\n pp sql\n db = SQLite3::Database.new('database.db')\n db.results_as_hash = true\n data = db.execute(sql)\n db.close\n data\nend",
"def url\n [\"http://\" + @uploader.couch_host + \":\" + @uploader.couch_port, model.database.name , model.id, @path].join(\"/\")\n end",
"def get_db\n db = SQLite3::Database.new 'barbershop.db'\n db.results_as_hash = true\n\n db\nend",
"def get_data(class_name)\n return JSON.parse(File.read(@database_file))[class_name]\n \n # error handling\n rescue Errno::ENOENT\n File.open(@database_file, 'w+')\n File.write(@database_file, [])\n retry\n end",
"def createurlTable\n @conn.exec(\"CREATE TABLE urls (uid serial NOT NULL, loc character varying(255), CONSTRAINT urls_pkey PRIMARY KEY (uid)) WITH (OIDS=FALSE);\");\n end",
"def db\n $db ||= Db.new database: 'results.db'\nend",
"def index\n @urls = Url.all\n\n \n\n end",
"def data\n retrieve_data\n end",
"def enhance_data(arr)\n puts \"Enhancing data\"\n valscount = {}\n\n####\n if (use_store())\n require 'lib/four_store/store'\n store = FourStore::Store.new 'http://dbtune.org/bbc/programmes/sparql/'\n\n\n arr.each do |pid|\n\n q = \"SELECT ?vals WHERE\n{{<http://www.bbc.co.uk/programmes/#{pid}#programme>\n<http://purl.org/ontology/po/masterbrand> ?vals .} UNION\n{<http://www.bbc.co.uk/programmes/#{pid}#programme>\n<http://purl.org/ontology/po/category> ?vals . } UNION \n{<http://www.bbc.co.uk/programmes/#{pid}#programme> \n<http://purl.org/ontology/po/genre> ?vals . } UNION \n{?vals <http://purl.org/ontology/po/episode>\n<http://www.bbc.co.uk/programmes/#{pid}#programme> . }}\"\n\n puts \"Making query for #{pid}\\n#{q}\"\n response = store.select(q)\n\n response.each do |r|\n url = r[\"vals\"]\n if(valscount[url]==nil)\n valscount[url]=1\n else\n count = valscount[url]\n count = count+1\n valscount[url]=count\n end\n end\n sleep 2\n end\n else\n#not store\n arr.each do |pid|\n\n url = \"http://www.bbc.co.uk/programmes/#{pid}.rdf\"\n puts \"pid url is #{url}\"\n #occassionally we get a duff pid\n\n m = ModelFactory.createDefaultModel()\n\n begin \n m.read(url)\n \n q = \"SELECT ?vals WHERE\n{{<http://www.bbc.co.uk/programmes/#{pid}#programme>\n<http://purl.org/ontology/po/masterbrand> ?vals .} UNION\n{<http://www.bbc.co.uk/programmes/#{pid}#programme>\n<http://purl.org/ontology/po/category> ?vals . } UNION \n{<http://www.bbc.co.uk/programmes/#{pid}#programme> \n<http://purl.org/ontology/po/genre> ?vals . } UNION \n{?vals <http://purl.org/ontology/po/episode>\n<http://www.bbc.co.uk/programmes/#{pid}#programme> . }}\"\n puts \"Making query for #{pid}\\n#{q}\"\n\n qexec = QueryExecutionFactory.create(q, m) ;\n response = qexec.execSelect()\n# ResultSetFormatter.out(java.lang.System.out, response)\n response.each do |r|\n url = r.get(\"vals\").to_s\n puts \"got result #{url}\"\n if(valscount[url]==nil)\n valscount[url]=1\n else\n count = valscount[url]\n count = count+1\n valscount[url]=count\n end\n end\n rescue\n puts \"duff url, continuing\"\n end\n sleep 2\n end\n\n end\n pp valscount\n####\n return valscount\n end",
"def insert_link(url, comment)\n open_db { |db|\n db.execute(\"insert into links (url, comment, time) values ('#{url}', '#{comment}', datetime('now', 'localtime'));\") \n }\nend",
"def link_to_database \n \"/connect/#{url_uuid}\"\n end",
"def get_db\n db = SQLite3::Database.new 'BarberShop.db'\n db.results_as_hash = true\n return db\n end",
"def lookup_record(url)\n begin\n Link.where(url: url).first_or_create(\n title: link_params[:title],\n code: Link::GenerateCode.run\n )\n rescue\n nil\n end\n end",
"def retrieve_data\n # Define the url\n url = 'http://www.sbs.com.au/news/rss/news/science-technology.xml'\n\n # Open the url and parse the rss feed\n open(url) do |rss|\n # Start parsing\n feed = RSS::Parser.parse(rss, false)\n\n # Iterate each item and scrape information\n feed.items.each do |item|\n # If the title of thie article matches the title of the last saved article,\n # stop scraping to avoid from saving duplicates in database\n break if !@last_title.nil? && @last_title.eql?(item.title.to_s)\n\n # If thie article is already stored then ignore\n next if Article.find_by(title: item.title.to_s)\n\n # Make a template dictionary to put @articles\n temp = {\n author: nil,\n title: item.title,\n summary: item.description,\n image: nil,\n date_time: DateTime.parse(item.pubDate.to_s),\n link: item.link,\n categories: nil\n }\n\n # Put the object into articles array\n @articles << temp\n end\n end\n end",
"def bind(url); end",
"def database(value)\n update_query(:database => value)\n end",
"def read_db()\n if File.exist?('public/tokens.db')\n db = SQLite3::Database.open './public/tokens.db'\n else\n db = []\n end\nend",
"def db_fetch!( db_file )\n ####db = SQLite3::Database.new( db_file )\n ####db_row = db.execute( db_fetch )\n ####db.close\n ####return db_row\n puts \"SQLite\" \n return nil\n end",
"def site_data; end",
"def data_urls\n # returns\n # @instrument\n # @varnames: a hash keyed on the shortname, containing the long name\n \n if params.key?(:instrument_id) \n if Instrument.exists?(params[:instrument_id])\n inst_id = params[:instrument_id]\n else\n inst_id = Instrument.all.first.id\n end\n else\n inst_id = Instrument.all.first.id\n end\n \n @instrument = Instrument.find(inst_id)\n varshortnames = Var.all.where(\"instrument_id = ?\", inst_id).pluck(:shortname)\n # Create a hash, with shortname => name\n @varnames = {}\n varshortnames.each do |vshort|\n @varnames[vshort] = Var.all.where(\"instrument_id = ? and shortname = ?\", inst_id, vshort).pluck(:name)[0]\n end\n \n end",
"def retrieve_database_meta(modelname, adapter,driver,host,username,password,database,urltemplate)\n \n urltemplate.gsub!(\"{host}\",host)\n urltemplate.gsub!(\"{password}\",password)\n urltemplate.gsub!(\"{username}\",username)\n urltemplate.gsub!(\"{database}\",database)\n mdmtype=MdmDataType.first\n \n curr_connect = ActiveRecord::Base.connection\n if adapter==\"mysql\"\n arconfig = {\n :adapter => adapter,\n :host => host,\n :username => username,\n :password => password,\n :database => database }\n \n config = ActiveRecord::ConnectionAdapters::ConnectionSpecification.new( {\n :adapter => adapter,\n :driver => driver,\n :username => username,\n :password => password,\n :host => host,\n :url => urltemplate,\n :pool => 2\n }, 'mysql_connection')\n \n connection = ActiveRecord::ConnectionAdapters::ConnectionPool.new(config)\n \n else\n # jdbc = JDBCAR.new\n # connection = jdbc.connect(driver,username,password,urltemplate)\n arconfig = {:adapter => 'jdbc',\n :driver => driver,\n :username => username,\n :password => password,\n :url => urltemplate,\n :pool => 2}\n config = ActiveRecord::ConnectionAdapters::ConnectionSpecification.new( {\n :adapter => 'jdbc',\n :driver => driver,\n :username => username,\n :password => password,\n \n :url => urltemplate,\n :pool => 2\n }, 'jdbc_connection')\n \n connection = ActiveRecord::ConnectionAdapters::ConnectionPool.new(config)\n end\n \n primary_k = {}\n newtables={}\n metaconnect = connection.checkout\n metaconnect.tables.each do |table|\n newtables[table] = [] \n primary_k[table] = metaconnect.primary_key(table)\n metaconnect.columns(table.to_s).each do |col|\n newtables[table] << col.name\n print col.name + \", \"\n end\n end\n \n connection.checkin metaconnect\n \n \n mdm_model = MdmModel.find_by_name(modelname) \n mdm_model = MdmModel.new if mdm_model.nil? \n mdm_model.connect_src = serialize_config(adapter,driver,host,username,password,database,urltemplate)\n mdm_model.name = modelname\n newtables.keys.each do |table|\n mdmexist = MdmObject.find_by_name(table)\n mdmexist.destroy if mdmexist\n mdmobject = MdmObject.new\n mdmobject.name=table\n newtables[table].each do |col|\n mdmcolumn = MdmColumn.new\n mdmcolumn.name = col\n mdmcolumn.mdm_data_type = mdmtype\n mdmcolumn.is_primary_key=true if !primary_k[table].nil? && primary_k[table].include?(mdmcolumn.name)\n mdmcolumn.save\n if mdmcolumn.is_primary_key\n pk = MdmPrimaryKey.new\n pk.mdm_column = mdmcolumn\n mdmobject.mdm_primary_keys << pk\n end\n mdmobject.mdm_columns << mdmcolumn\n end\n mdm_model.mdm_objects << mdmobject\n \n end\n \n mdm_model.save\n generate_active_record(mdm_model,arconfig)\n end",
"def uri\n database.uri + '/_design/' + name\n end",
"def url\n @url\n end",
"def all\n setup_file\n \n links_data = File.open('link_db.txt').read\n links = JSON.parse(links_data)\n return links\nend",
"def test_query_runner\n assert( @data_source )\n qrun = QueryRunner.new( @data_source )\n\n url = VisitURL.normalize( \"http://gravitext.com/test\" )\n\n qrun.update( \"TRUNCATE urls;\" )\n\n c = qrun.update( \"INSERT into urls (uhash, url, domain, type ) \" +\n \"VALUES (?,?,?,?);\",\n url.uhash, url.url, url.domain, \"PAGE\" )\n assert_equal( 1, c )\n\n out_domain = nil\n qrun.query( \"SELECT * FROM urls WHERE uhash = ?\", url.uhash ) do |rs|\n while rs.next\n out_domain = rs.get_string( 'domain' )\n end\n end\n assert_equal( url.domain, out_domain )\n\n assert_equal( 1, qrun.update( \"DELETE from urls;\" ) )\n end",
"def select_db(name)\n #This is a stub, used for indexing\n end",
"def save_content(record)\n\n\tid = record[\"id\"]\n\ttitle = record[\"title\"]\n\tdesc = record[\"desc\"]\n\turl = record[\"url\"]\n\tpath = \"\"\n\t\n\tbegin\n\t\tdb = Mysql.real_connect('localhost', 'ashish', 'ashish', 'content')\n#\t puts \"Server version: \" + db.get_server_info\n\t db.query(\"INSERT INTO data_image ( `id`, `title`,`url`,`path`,`desc` ) VALUES (#{id},'#{db.escape_string(title)}','#{db.escape_string(url)}','#{db.escape_string(path)}','#{db.escape_string(desc)}') \")\n\trescue Mysql::Error => e\n\t puts \"Error code: #{e.errno}\"\n\t puts \"Error message: #{e.error}\"\n\t puts \"Error SQLSTATE: #{e.sqlstate}\" if e.respond_to?(\"sqlstate\")\n\tend\t\nend",
"def set_db\n @db = Db.find(params[:id])\n end",
"def initialize(db)\n @db = db\n #initialize the scraper with a database\n end",
"def query\n end",
"def create_db(database)\n @conn.query({url_path: database, method: :put})\n end",
"def get_by_id(id)\n if @data == nil\n url = make_url(:fq => \"id:#{id}\")\n\n begin\n @data = Net::HTTP.get(URI.parse(url))\n rescue Exception => e\n @error = \"Unable to connect to #{url}\"\n end\n end\n \n return @data\n end",
"def fetch_drink_page(name, url, size, milk)\n doc = Hpricot Curl::Easy.http_get(url).body_str\n key = nil\n data = {}\n\n (doc.at('#nutrition')/:td).each do|td|\n value = td.inner_text.gsub(/\\(.*\\)/,'').strip\n if key.nil?\n key = value\n else\n data[CaribouToDB[key]] = value if CaribouToDB.key?(key)\n key = nil\n end\n end\n data[:name] = ((doc.at(\"#content h1\").inner_text) || name).cleanstr\n data[:size] = size\n data[:milk] = milk\n data\nend",
"def addurl(uid, loc)\n @conn.exec_prepared(\"insert_url\", [uid, loc])\n end",
"def addurl(uid, loc)\n @conn.exec_prepared(\"insert_url\", [uid, loc])\n end",
"def index\n\n\t\t@url_data_models = UrlDataModel.all\n\n\tend",
"def get_data\n\t \thydra = Typhoeus::Hydra.hydra\n\n\t \tfirst_url = \"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22#{self.stock_ticker}%22)&format=json%0A%09%09&env=http%3A%2F%2Fdatatables.org%2Falltables.env\"\n\t \tsecond_url = \"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.keystats%20where%20symbol%20in%20(%22#{self.stock_ticker}%22)&format=json%0A%09%09&env=http%3A%2F%2Fdatatables.org%2Falltables.env\"\n\t \tthird_url = \"http://www.quandl.com/api/v1/datasets/DMDRN/#{self.stock_ticker}_ALLFINANCIALRATIOS.csv?auth_token=#{ENV['QUANDL_API_TOKEN']}\"\n\t \tfourth_url = \"http://www.quandl.com/api/v1/datasets/PSYCH/#{self.stock_ticker}_I.json?&auth_token=auth_token=#{ENV['QUANDL_API_TOKEN']}&trim_start=#{Chronic.parse(\"last week\").strftime(\"%F\")}&trim_end=#{Chronic.parse(\"today\").strftime(\"%F\")}&sort_order=desc\"\n\n\t \t(((first_url) =~ URI::DEFAULT_PARSER.regexp[:ABS_URI]) == 0) ? first_request = Typhoeus::Request.new(first_url) : (return false)\n\t \tsecond_request = Typhoeus::Request.new(second_url) \n\t \tthird_request = Typhoeus::Request.new(third_url) \n\t \tfourth_request = Typhoeus::Request.new(fourth_url) \n\n\t \thydra.queue first_request\n\t \thydra.queue second_request\n\t \thydra.queue third_request\n\t \thydra.queue fourth_request\n\t \t\n\t \thydra.run\n\n\t\t\tfirst_request.response.options[:response_code] == 200 ? first_response = first_request.response : (return false )\n\t \tsecond_response = second_request.response\n\t \tthird_response = third_request.response \n\t \tfourth_response = fourth_request.response\n\n\t \t@quotes = JSON.parse(first_response.body) if !first_response.body.nil?\n\n\t \t@key_stats = JSON.parse(second_response.body) \n\n\t \tthird_request.response.options[:response_code] == 200 ? @quandl_data = CSV.parse(third_response.body) : @quandl_data = nil\n\n\t \tfourth_request.response.options[:response_code] == 200 ? @psych_data = JSON.parse(fourth_response.body) : @psych_data = nil\n\n\t \t@tradier = $tradier_client.quote(self.stock_ticker)\n\n\t \tmethod(:assign_yahooQuotes).call\n\t \tmethod(:assign_yahooKeyStats).call\n\t \tmethod(:assign_quandlStockData).call\n\t \tmethod(:assign_quandlPsychData).call\n\t \tmethod(:assign_databaseValues).call\n\t \tmethod(:assign_stockProfile).call\n\t \tmethod(:assign_tradierQuote).call\n\n\t end",
"def set_url\n # @url = Url.find(params[:id])\n end"
] |
[
"0.7081181",
"0.7055872",
"0.6588096",
"0.6471091",
"0.63598365",
"0.6351594",
"0.6200471",
"0.6073722",
"0.60664654",
"0.60117733",
"0.595577",
"0.59473366",
"0.5875172",
"0.5824699",
"0.5812224",
"0.57774645",
"0.57739085",
"0.57111925",
"0.5696198",
"0.56932586",
"0.5673894",
"0.5673894",
"0.5649415",
"0.56181103",
"0.56181103",
"0.56167364",
"0.5549835",
"0.55104476",
"0.5499025",
"0.5496964",
"0.548306",
"0.54551643",
"0.5453403",
"0.54431415",
"0.54377085",
"0.5415545",
"0.54131347",
"0.54052347",
"0.54006225",
"0.5397962",
"0.5388913",
"0.53727347",
"0.5366954",
"0.53652585",
"0.53636914",
"0.53636914",
"0.5355118",
"0.53524554",
"0.5350453",
"0.5350453",
"0.53265613",
"0.53177947",
"0.53144944",
"0.53144944",
"0.53068894",
"0.53038526",
"0.5301992",
"0.5298787",
"0.5292492",
"0.52870476",
"0.52870476",
"0.5280008",
"0.5275139",
"0.5265586",
"0.5258394",
"0.52517474",
"0.5249353",
"0.5248102",
"0.5245538",
"0.52454495",
"0.52442974",
"0.5242512",
"0.52378064",
"0.52369964",
"0.52252036",
"0.52241874",
"0.5210509",
"0.5209858",
"0.5207615",
"0.52041686",
"0.5203592",
"0.5201962",
"0.52011156",
"0.5192558",
"0.5190976",
"0.51834285",
"0.51809794",
"0.51782346",
"0.51712114",
"0.51678777",
"0.5167471",
"0.5167037",
"0.5164881",
"0.51580906",
"0.5157835",
"0.5156453",
"0.5153993",
"0.5153993",
"0.51519537",
"0.51445943",
"0.51352704"
] |
0.0
|
-1
|
method for cron job
|
def get_ga_data(yesterday, view_id, ga_key)
date_range = @analytics::DateRange.new(start_date: yesterday, end_date: yesterday)
order_by = @analytics::OrderBy.new(field_name: 'ga:pageviews', sort_order: 'DESCENDING')
metrics = ['ga:pageviews', 'ga:users', 'ga:newUsers', 'ga:bounces', 'ga:sessions', 'ga:timeOnPage']
metric_type = Array.new
metrics.each do |m|
metric = @analytics::Metric.new
metric.expression = m
metric_type.push(metric)
end
dimensions = ['ga:dateHour', 'ga:pagePath']
dimension_type = Array.new
dimensions.each do |d|
dimension = @analytics::Dimension.new
dimension.name = d
dimension_type.push(dimension)
end
request = @analytics::GetReportsRequest.new(
report_requests: [@analytics::ReportRequest.new(
view_id: view_id,
metrics: metric_type,
dimensions: dimension_type,
# dimension_filter_clauses: [dimension_filters],
date_ranges: [date_range],
order_bys: [order_by],
page_size: 100_000
)]
)
response = @client.batch_get_reports(request)
# handling error
if !response.reports.first.data.rows then
return
end
data_from_google = response.reports.first.data.rows
set_ga_data_array = Array.new
data_from_google.each_with_index do |r, index|
# dimensions = ['ga:dateHour', 'ga:pagePath']
# metrics = ['ga:pageviews', 'ga:users', 'ga:newUsers', 'ga:bounces', 'ga:sessions', 'ga:avgTimeOnPage']
datahash = {}
urls_rm_params = r.dimensions[1].split(/\?/)[0]
article = Article.select(:id).find_by(article_url: urls_rm_params)
next if !article
article_arr = set_ga_data_array.each_with_index.select{|a, index| a['article_id'] == article.id && a['date_hour'] == r.dimensions[0]}
if !article_arr.empty?
article_index = article_arr.first[1]
set_ga_data_array[article_index]
page_view = set_ga_data_array[article_index]['page_view'].to_i
page_view_temp = r.metrics.first.values[0].to_i
set_ga_data_array[article_index]['page_view'] = page_view + page_view_temp
user = set_ga_data_array[article_index]['user'].to_i
user_temp = r.metrics.first.values[1].to_i
set_ga_data_array[article_index]['user'] = user + user_temp
new_user = set_ga_data_array[article_index]['new_user'].to_i
new_user_temp = r.metrics.first.values[2].to_i
set_ga_data_array[article_index]['new_user'] = new_user + new_user_temp
bounce = set_ga_data_array[article_index]['bounce'].to_i
bounce_temp = r.metrics.first.values[3].to_i
set_ga_data_array[article_index]['bounce'] = bounce + bounce_temp
session = set_ga_data_array[article_index]['session'].to_i
session_temp = r.metrics.first.values[4].to_i
set_ga_data_array[article_index]['session'] = session + session_temp
avg_time_on_page = set_ga_data_array[article_index]['avg_time_on_page'].to_i
avg_time_on_page_temp = r.metrics.first.values[5].to_i
set_ga_data_array[article_index]['avg_time_on_page'] = avg_time_on_page + avg_time_on_page_temp
else
datahash['article_id'] = article.id
datahash['date_hour'] = r.dimensions[0]
page_view = r.metrics.first.values[0]
datahash['page_view'] = page_view
user = r.metrics.first.values[1]
datahash['user'] = user
new_user = r.metrics.first.values[2]
datahash['new_user'] = new_user
bounce = r.metrics.first.values[3]
datahash['bounce'] = bounce
session = r.metrics.first.values[4]
datahash['session'] = session
avg_time_on_page = r.metrics.first.values[5]
datahash['avg_time_on_page'] = avg_time_on_page
datahash['created_at'] = Time.zone.now
datahash['updated_at'] = Time.zone.now
set_ga_data_array.push(datahash)
end
end
# avg time on page setup (avt t.o.p in ga doesn't fit to our site so we need to calculate by ourselves)
# avg.time on page = time on page / pageviews
set_ga_data_array.each do |ga|
time_on_page = ga['avg_time_on_page'].to_i
pv = ga['page_view'].to_i
if time_on_page != 0 && pv != 0
begin
ga['avg_time_on_page'] = time_on_page/pv
rescue StandardError => e
puts e
ga['avg_time_on_page'] = 0
end
end
end
return set_ga_data_array
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def cron_tasks\n end",
"def cron_open\n # jo = File.open #still need to write crontab protocol\n end",
"def cron(*args)\n @cron = args\n end",
"def execute_tasks(starttime)\n now=Time.now\n starttime=Time.at(now.to_i-24*60*60) if starttime.nil? \n $stdin.each_line do |line|\n md= /^([^\\t|^\\#].*\\t){5}/.match(line)\n if (md)\n cron = Rufus::Scheduler::CronLine.new(md[0]) \n next_time = cron.next_time(starttime)\n if (next_time.day()==now.day())\n command=line[md[0].length .. line.length-1]\n system(command)\n end\n end\n end\nend",
"def cron_command\n cron_content = master.run_shell('crontab -l').stdout\n collector_line = cron_content.split(\"\\n\").select do |line|\n line =~ %r{splunk_hec_collect_api_events.rb}\n end\n collector_line.join.split[-3..-1].join(' ')\nend",
"def run\n super\n cron_poller.start\n end",
"def apply\n if desired.cron_exists\n action_create\n else\n action_delete\n end\n end",
"def schedule(uri); end",
"def update!(**args)\n @cron = args[:cron] if args.key?(:cron)\n end",
"def cron_dot_d_directory\n end",
"def cron(task_name)\n task = $bot[:tasks][task_name]\n unless task\n say \"Task \\\"#{task_name}\\\" does not exist. Use \\\"twittbot cron list\\\" for a list of available tasks.\"\n return\n end\n\n #check_config\n init_clients\n task[:block].call\n end",
"def execute_cron_job\n lambda do\n |request, jle|\n $db_lock.synchronize {\n jle.run_status = 'Running'\n jle.start_time = Time.now\n jle.save(:validate => false)\n }\n jlh = Hash.new\n jlh[:run_status] = \"Failure\"\n @@thread_count = @@thread_count + 1;\n Thread.current[:name] = \"JOB_THREAD \" + request.to_s + ' ' + @@thread_count.to_s;\n Thread.current[:watchdogged] = false\n begin\n jmd = JobMetadata.job_code(request)[0]\n @job_map[Thread.current] = jmd.max_execution_minutes.to_i.minutes.from_now\n\n jlh[:jmd] = jmd\n jlh[:jle] = jle\n commands = gather_commands(true,request)\n commands = commands[request]\n if (commands.nil? || commands.empty?)\n $logger.error(\"There are no commands for request #{request}. Exiting...\")\n return\n end\n $logger.debug(\"The size of commands is \" << commands.length.to_s)\n #total_result = nil\n commands.each do |command|\n command.chomp!\n $logger.debug(\"command = #{command}\")\n #$stderr.puts(\"executing #{command}\")\n #result = `#{command}` There seems to be a bug in ruby where backticks hang in multi threaded situations\n result = JobEngine.execute_command_to_temp(command)\n #$stderr.puts(\"executed #{command}\")\n result.chomp!\n\n if (jlh[:job_result].nil?)\n jlh[:job_result] = result\n else\n jlh[:job_result] << \"\\n\" << result\n end\n $logger.debug(\"the result is #{result}...\")\n #check to see if the command is in\n end\n # $stderr.puts(\"About to finish the jle\")\n # finish_job_log_entry(Time.now,total_result, jle, nil)\n jlh[:run_status] = \"Completed\"\n # $stderr.puts(\"finished the jle\")\n # email_job_result(total_result,jle,jmd) if jmd.email_result\n # $stderr.puts(\"emailed\") if jmd.email_result\n # $stderr.puts(\"not emailed\") unless jmd.email_result\n\n rescue =>ex\n error = \"An execution thread terminated while executing \" << request\n $logger.error(error)\n $logger.error(ex.to_s)\n jlh[:job_result] = '' if jlh[:job_result].nil?\n jlh[:job_result] << ex.to_s\n ensure\n unless jlh[:run_status].eql?(\"Completed\")\n jlh[:job_result] = '' if jlh[:job_result].nil?\n if (Thread.current[:watchdogged])\n jlh[:job_result] << \"\\nKilled by the job watch dog at \" + Thread.current[:watchdogged_time].to_s + \"!\"\n else\n jlh[:job_result] << \"\\nAn exceptional event occurred!\"\n end\n end\n finish_job_log_entry(jlh)\n end\n end\n end",
"def histcall\n HardWorker.perform_at(24.hours, 1)\n puts \"Cron job: Stocks being added to db\"\n end",
"def cron_schedule\n @cron_schedule ||= Fugit::Cron.parse(cron)\n end",
"def install_crontab\n # create a working crontab file\n # log \"Building crontab\\n\"\n f = File.open(CRONTAB, 'w')\n f.write \"MAIL='keburgett@gmail.com'\\n\"\n # for each sprinkle, write a crontab entry for OPEN and CLOSE times.\n p = Porter.first.localhost_with_port # provides host:port combination\n Sprinkle.all.each do |s|\n [OPEN, CLOSE].each do |action|\n crontab_line = \"#{s.to_crontab(action)} sh #{valve_actuator_path} #{s.valve.to_crontab(action)} #{p} #{s.id}\\n\" \n f.write crontab_line\n # log \"#{crontab_line}\\n\"\n end\n end\n f.close\n system(\"crontab #{CRONTAB}\")\n end",
"def run_job\n end",
"def do_job\r\n# disable recycle invites\r\n# min = Time.now.min\r\n# #recycle invites 1 min per hour\r\n# if min == 0\r\n# ret = ActiveRecord::Base.connection.execute(\"delete from invites where invitee_id is null and created_at < subdate(now(), interval 3 day)\")\r\n# puts \"recycle invites: #{ret}\"\r\n# end\r\n end",
"def pm_counter_cron_main_with_team(team_array)\n \n start_time=Time.now\n\n return if team_array.nil? || team_array.size ==0\n \n\nteam_array.each do |team|\n logger=Logger.new(\"pm_counter_#{team}.log\",shift_age = 7, shift_size = 1048576)\n all_counters=pm_counter_get_defined_counter(logger)\n set_logger_level(logger)\n Bts.where(:team=>team).each do |bts|\n result=pm_counter_analysis_one_bts(all_counters,bts.s1_ip,bts.bts_username,bts.bts_password,logger)\n end\n\n Cron.create(:name=>\"PM counter_#{team}\",:scope=>\"#{team}\",:start=>start_time.to_s,:cost=>Time.now - start_time,:succ=>\"#{0}\",:fail=>\"#{0}\")\n ActiveRecord::Base.connection.close\nend\nend",
"def install_crontab\n # create a working crontab file\n f = File.open(CRONTAB, 'w')\n f.write \"MAIL='keburgett@gmail.com'\\n\"\n # for each sprinkle, write a crontab entry for OPEN and CLOSE times.\n Sprinkle.all.each do |s|\n [AppConstants::OPEN, AppConstants::CLOSE].each do |action|\n crontab_line = \"#{s.to_crontab(action)} sh #{valve_actuator_path} #{s.valve.to_crontab(action)} #{host_with_port}\\n\" \n f.write crontab_line\n # #logger.info crontab_line\n end\n end\n f.close\n system(\"crontab #{CRONTAB}\")\n end",
"def run_cron_on(host, action, user, entry=\"\", &block)\n platform = host['platform']\n if platform.include?('solaris') || platform.include?('aix') then\n case action\n when :list then args = '-l'\n when :remove then args = '-r'\n when :add\n on( host,\n \"echo '#{entry}' > /var/spool/cron/crontabs/#{user}\",\n &block )\n end\n\n else # default for GNU/Linux platforms\n case action\n when :list then args = '-l -u'\n when :remove then args = '-r -u'\n when :add\n on( host,\n \"echo '#{entry}' > /tmp/#{user}.cron && \" +\n \"crontab -u #{user} /tmp/#{user}.cron\",\n &block )\n end\n end\n\n if args\n case action\n when :list, :remove then on(host, \"crontab #{args} #{user}\", &block)\n end\n end\n end",
"def run time=nil\n\n puts \"[cron] run called #{Time.now}\" if @debug\n time = self.time if time.nil?\n self.each { |cron_job|\n ok,details = cron_job.runnable?(time)\n if ok then\n @queue.enq(cron_job)\n if cron_job.once? then\n cron_job[:delete] = true\n end\n end\n }\n self.reject! { |cron_job|\n cron_job[:delete]\n }\n end",
"def run_task\n\t\tif params[:job] == 'xapian'\n\t\t\tsystem(\"rake xapian:update_index RAILS_ENV=#{RAILS_ENV}\")\n\t\tend\n\t\tif params[:job] == 'feeds'\n\t\t\tsystem(\"ruby script/runner -e #{RAILS_ENV} 'FeedSource.update_feed_source'\")\n\t\tend\n\t\tif params[:job] == 'newsletter'\n\t\t\tDelayed::Job.enqueue(NewsletterJob.new)\n\t\tend\n\t\tif params[:job] == 'translations'\n\t\t\tLANGUAGES.each do |l|\n\t\t\t\tcommand_backup = \"mv config/locales/\" + l + \".yml tmp/backup/\" + Time.now.strftime(\"%Y%m%d\") + \"_\" + l + \".yml\"\n\t\t\t\tcommand_get = \"wget \" + TRANSLATION_SITE + \"/translations/\" + PROJECT_NAME + \"/\" + l + \".yaml -O config/locales/\" + l + \".yml\"\n\t\t\t\tsystem(command_backup)\n\t\t\t\tsystem(command_get)\n\t\t\tend\n\t\t\tmessage = \"Translation files Retrieved\"\n\t\tend\n\t\tif params[:job] == 'restart_server'\n\t\t\tsystem \"touch #{RAILS_ROOT}/tmp/restart.txt\" # tells passenger to restart the server\n\t\t\tmessage = \"Server restarted successfully\"\n\t\tend\n\t\t\n\t\tmessage.nil? ? @message = \"#{params[:job].capitalize} Updated Sucessfully \" : @message = message\n\t\t\n\t\trespond_to do |format|\n \t format.js {render :layout => false}\n \tend\n \t\n\t\t# render :update do |page|\n\t\t# page.show 'notice'\n\t\t# page.replace_html 'notice', \n\t\t# end\n end",
"def run_now!\n update_attributes(run_at: nil) if cron_schedule\n end",
"def run_cron_on(host, action, user, entry = \"\", &block)\n block_on host do |host|\n platform = host['platform']\n if platform.include?('solaris') || platform.include?('aix') then\n case action\n when :list then args = '-l'\n when :remove then args = '-r'\n when :add\n on(host,\n \"echo '#{entry}' > /var/spool/cron/crontabs/#{user}\",\n &block)\n end\n\n else # default for GNU/Linux platforms\n case action\n when :list then args = '-l -u'\n when :remove then args = '-r -u'\n when :add\n on(host,\n \"echo '#{entry}' > /tmp/#{user}.cron && \" +\n \"crontab -u #{user} /tmp/#{user}.cron\",\n &block)\n end\n end\n\n if args\n case action\n when :list, :remove then on(host, \"crontab #{args} #{user}\", &block)\n end\n end\n end\n end",
"def cron\n @cron_expression.original_expression\n end",
"def safe_run()\n begin\n self.run()\n rescue Exception=>e\n\te_string = \"hmm, cron method excepted: #{e}\"\n\tprint e_string\n\tself.getSession().say( e_string )\n end\n end",
"def create\n @chore = @dwelling.chores.build(params[:chore])\n @chore.owner = current_user\n @chore.active = true\n\n # Make the actual cron-format string\n cron_cmd = \"/bin/bash -l -c 'cd #{Rails.root} && bundle exec rake chores:activate_chore CHORE_ID=\"\n case @chore.cron_str\n when \"Every M/W/F\"\n @chore.cron_str = \"0 0 * * MON,WED,FRI #{cron_cmd}\"\n when \"Every T/Th\"\n @chore.cron_str = \"0 0 * * TUE,THU #{cron_cmd}\"\n when \"Every Sunday\"\n @chore.cron_str = \"0 0 * * SUN #{cron_cmd}\"\n else\n @chore.cron_str = nil\n end\n\n # if @chore.cron_str\n # puts @chore.cron_str\n # puts (CronEdit::Crontab.Add \"chore_#{params[:id]}\", @chore.cron_str)\n # end\n\n respond_to do |format|\n if @chore.save\n if @chore.cron_str\n puts @chore.cron_str\n puts (CronEdit::Crontab.Add \"chore_#{@chore.id}\", \"#{@chore.cron_str}#{@chore.id}'\")\n end\n format.html { redirect_to @chore, notice: 'Chore was successfully created.' }\n format.json { render json: @chore, status: :created, location: @chore }\n else\n format.html { render :new }\n format.json { render json: @chore.errors, status: :unprocessable_entity }\n end\n end\n end",
"def run_cron_on(host, action, user, entry=\"\", &block)\n platform = host['platform']\n if platform.include?('solaris') || platform.include?('aix') then\n case action\n when :list then args = '-l'\n when :remove then args = '-r'\n when :add\n on(host, \"echo '#{entry}' > /var/spool/cron/crontabs/#{user}\", &block)\n end\n else # default for GNU/Linux platforms\n case action\n when :list then args = '-l -u'\n when :remove then args = '-r -u'\n when :add\n on(host, \"echo '#{entry}' > /tmp/#{user}.cron && crontab -u #{user} /tmp/#{user}.cron\", &block)\n end\n end\n\n if args\n case action\n when :list, :remove then on(host, \"crontab #{args} #{user}\", &block)\n end\n end\n end",
"def run!\n logger.info(\"Running task #{self.class.to_s}\")\n @block.call\n @next_run = cron_parser && cron_parser.next(Time.now)\n end",
"def sudo_add_to_crontab(commands,period)\n add_to_crontab(commands, period, true)\nend",
"def get_crontab_entry\n # Initialize\n newcron = []\n newcron << \"# Chef Name: #{new_resource.name}\"\n newcron << env_var_str unless env_var_str.empty?\n newcron << duration_str + time_out_str + cmd_str\n\n newcron.join(\"\\n\")\n end",
"def cron_timer(minutes_from_now,time_object, script)\n raw_time = time_object + (minutes_from_now.to_i*60)\n cron_string = cron_converter(raw_time)\n end",
"def enable_cron\n require 'rufus/scheduler'\n set :scheduler, Rufus::Scheduler.new\n job = PuppetHerald::PurgeCronJob.new\n # Run every 30 minutes, by default\n cron = ENV['PUPPET_HERALD_PURGE_CRON'] || '*/30 * * * *'\n PuppetHerald.logger.info \"Stating scheduler with: `#{cron}`...\"\n scheduler.cron(cron) { job.run! }\n end",
"def jobs\r\n end",
"def update_mountain_ranges_cron\n begin\n date = Date.today.prev_day.to_s.delete(\"-\").to_i\n update_mountain_ranges(date)\n rescue Exception => e\n puts \"bra_meteo_france indisponible \"\n end\nend",
"def trigger (params)\n\n return if paused?\n\n ldebug { \"trigger() cron : #{@fei.to_debug_s}\" }\n\n #@raw_child.application_context = @application_context\n # done in expool.tlaunch_child()\n\n begin\n\n @counter += 1\n store_itself\n #\n # note : one variant would be to give Time.now.to_f as a sub_id...\n # then no need to store...\n #\n # but it's good to have a counter to keep track of the number of\n # executions\n\n child_fei = get_expression_pool.tlaunch_child(\n self,\n first_expression_child,\n @counter,\n @applied_workitem.dup,\n :register_child => false)\n #\n # register_child is set to false, cron doesn't keep\n # track of its spawned children\n\n rescue\n\n lerror do\n \"trigger() cron caught exception\\n#{OpenWFE::exception_to_s($!)}\"\n end\n end\n end",
"def rocket_job_restart_new_instance\n return unless cron_schedule\n super\n end",
"def rocket_job_restart_new_instance\n return unless cron_schedule\n super\n end",
"def schedule\n Resque.set_schedule(schedule_name, {\n :cron => cron,\n :class => \"Myreplicator::Export\",\n :queue => \"myreplicator_export\",\n :args => id\n })\n end",
"def cron_get(type)\n cmd = \"{\\\"id\\\":13,\\\"method\\\":\\\"cron_get\\\",\\\"params\\\":[#{type}]}\\r\\n\"\n request(cmd)\n end",
"def process_command\n puts \"# #{$0} #{@options.to_s}\" if @options.verbose\n # Get current time in epochs\n time = Time.now\n epochs = time.gmtime.to_i\n # Subtract seconds(obtained from minutes user ip) to go back in accounting file\n epochs = epochs - @seconds.to_i\n # Output file - set to STDOUT if @options.opfile not specified\n if @ofilename \n ofile = File.open(@ofilename, \"w\") \n else\n ofile = STDOUT\n end\n ofile << \"# Failed jobs for user #{@user} since last #{@options.since}\\n\" if @options.verbose\n ofile << \"# SGE Job ID,Job script name,Requested Memory,Used Memory,Requested run-time,Actual walltime\\n\" if @options.verbose\n count_failed_jobs = 0\n File.foreach(@afilename) do |aline| \n # Select lines that match following criteria: \n ## specified-username\n ## && (completed/end-time in last n minutes #{epochs})\n ## && (failed status is non-zero || exit status is non-zero)\n if aline !~ /#/\n aarray = aline.split(\":\")\n wallclock = aarray[10].to_i - aarray[9].to_i\n s_rt = aarray[39].slice(/(s_rt=)([\\d]+)/,2).to_i # get requested s_rt\n h_rt = aarray[39].slice(/(h_rt=)([\\d]+)/,2).to_i # get requested h_rt\n h_vmem = aarray[39].slice(/(h_vmem=)([[:alnum:]]+\\.?[[:alnum:]]+)/,2) # get requested h_vmem\n failure = wallclock.between?(s_rt,h_rt+2) ? \"Reached max. run-time limit #{seconds_to_units(h_rt)}\" : \"Reached max. memory limit #{h_vmem}\"\n if aarray[3]== @user && (aarray[10].to_i>=epochs) && (aarray[11]!='0' || aarray[12]!='0')\n #ofile << \"#{aarray[5]} #{epochs} #{aarray[10]} #{time}\\n\"\n ofile << \"#{aarray[5]},#{aarray[4]},#{h_vmem},#{aarray[42]},#{h_rt},#{wallclock},#{failure}\\n\"\n count_failed_jobs = count_failed_jobs + 1 \n end\n end\n end\n ofile << \"# #{count_failed_jobs} jobs failed for #{@user} in last #{@options.since}\\n\" if @options.verbose\n ofile.close\n # Close output file \n end",
"def rocket_job_restart_new_instance\n return unless cron_schedule\n\n super\n end",
"def execute\n\n end",
"def update_whenever \n begin\n ::Whenever::CommandLine.execute({:update => true, :file => \"#{Rails.root}/config/schedule.rb\"})\n rescue SystemExit # whenever quits after updating cron jobs, we need to stop him\n end\n end",
"def run\n # Your code here, eg: task execute: :environment do\n s = SavedSearchManager.new\n s.process\n \n # use log() for writing to scheduler daemon log\n log(\"Saved searches processed.\")\n ActionMailer::Base.mail(:from => \"mail@treadhunter.com\", \n :to => system_process_completion_email_address(), \n :subject => \"Saved Searches processed.\", \n :body => \"Ran saved search process.\").deliver\n end",
"def execute\n end",
"def mkcron(name, addargs = true)\n cron = nil\n command = \"date > #{tmpdir()}/crontest#{name}\"\n args = nil\n if addargs\n args = {\n :command => command,\n :name => name,\n :user => @me,\n :minute => rand(59),\n :month => \"1\",\n :monthday => \"1\",\n :hour => \"1\"\n }\n else\n args = {:command => command, :name => name}\n end\n assert_nothing_raised {\n cron = @crontype.new(args)\n }\n\n cron\n end",
"def execute; end",
"def execute; end",
"def schedule_info\n\n @cron_line.original\n end",
"def create_cron\n cron_edit = CronEdit.new\n command = cron_edit.add_command create_cron_command, Environment.ruby\n puts \"--> added command to cron\"\n puts \" #{command}\"\n end",
"def add_to_crontab(commands,period,use_sudo=false)\n send_cmd = use_sudo ? :sudo : :run\n tmp_cron=\"/tmp/cron.tmp\"\n self.send(send_cmd, \"rm -f #{tmp_cron} && touch #{tmp_cron}\")\n run \"(#{use_sudo ? 'sudo ' : ''}crontab -l || true) > #{tmp_cron}\"\n cron_lines = [*commands].map{|cmd| \"#{period} #{cmd}\"}\n add_to_file(tmp_cron, cron_lines)\n self.send(send_cmd, \"crontab #{tmp_cron}\")\n sudo \"rm -f #{tmp_cron}\"\nend",
"def execute\n end",
"def execute\n end",
"def auto_manage(cloud_type)\n\n cron_file = \"crontab-#{cloud_type}\"\n path = \"/etc/puppet/modules/#{cloud_type}/files/cron/#{cron_file}\"\n \n if File.exists?(path)\n file = File.open(path, 'r')\n line = file.read().chomp()\n file.close\n \n # Add the 'puppet apply manifest.pp' line to the crontab file\n mcc = MCollectiveCronClient.new(\"cronos\")\n mcc.add_line(CloudCron::CRON_FILE, line)\n mcc.disconnect\n else\n @err.call \"Impossible to find cron file at #{path}\"\n end\n \n end",
"def update!\n scheduling.total_runs = scheduling.total_runs.to_i + qjob.stats['releases']\n scheduling.last_run = Time.now\n end",
"def rocket_job_cron_next_time(time = Time.now)\n RocketJob::Plugins::Rufus::CronLine.new(cron_schedule).next_time(time)\n end",
"def rocket_job_cron_next_time(time = Time.now)\n RocketJob::Plugins::Rufus::CronLine.new(cron_schedule).next_time(time)\n end",
"def queue_job; end",
"def initialize\n klass = self.class\n create_hourly_cronjob(klass.hourly_method) if klass.hourly_method\n create_daily_cronjob(klass.daily_method, klass.daily_trigger_time) if klass.daily_method\n create_weekly_cronjob(klass.weekly_method, klass.weekly_trigger_time) if klass.weekly_method\n end",
"def schedule\n # implemented by subclass\n end",
"def Clockwork\n puts \"testing clockwork!\"\n every(30.seconds, 'Send Messages') {\n rake 'scheduler:send_messages'\n mail(:to => \"swamy@ostryalabs.com\", subject: 'hello')\n }\n \nend",
"def task\n end",
"def schedule_updates\n schedule_update_in(48.hours)\n end",
"def current_cron_jobs\n client.get_cron_jobs(label_selector)\n end",
"def run!\n PeriodicJob.log_error \"Executing job id #{self.id}, #{self.to_s}...\"\n begin\n self.last_run_at = Time.now\n self.next_run_at = nil\n self.save\n command = self.job.gsub(/#JOBID#/, self.id.to_s).gsub(/#RAILS_ROOT#/, Rails.root.to_s)\n puts command\n eval(command)\n self.last_run_result = \"OK\"\n PeriodicJob.log_info \"Job completed successfully\"\n rescue Exception\n err_string = \"'#{self.job}' could not run: #{$!.message}\\n#{$!.backtrace}\"\n PeriodicJob.log_error err_string\n self.last_run_result = err_string.slice(1..500)\n begin\n GeneralMailer.failed_periodic_job(self).deliver\n rescue\n end\n end\n self.save\n\n # ...and persist the next run of this job if one exists\n set_next_job\n end",
"def daily_morning\n logger.info \" daily_morning\"\n run('Newsletter', :send!)\n end",
"def validate_check_cron(check)\n must_be_a_string(check[:cron]) ||\n invalid(check, \"check cron must be a string\")\n begin\n cron_parser = CronParser.new(check[:cron])\n cron_parser.next(Time.now)\n rescue ArgumentError\n invalid(check, \"check cron string must use the cron syntax\")\n end\n end",
"def cron_logs(app_name)\n\t\tget(\"/apps/#{app_name}/cron_logs\")\n\tend",
"def execute()\n\n end",
"def execute()\n\n end",
"def execute\n end",
"def execute\n end",
"def schedule cron\n Resque.set_schedule(\"myreplicator_transporter\", {\n :cron => cron,\n :class => \"Myreplicator::Transporter\",\n :queue => \"myreplicator_transporter\"\n })\n end",
"def execute_continuous_task\n Rake::Task['cron_task:continuous:execute_task'].reenable\n Rake::Task['cron_task:continuous:execute_task'].invoke\n @lock_file_handle.close\n end",
"def calculate_this_month\n site_id = params[:id]\n date_end = DateTime.now\n nrday = date_end.day.to_i\n nrday -= 1\n date_start = DateTime.now-nrday.days\n Delayed::Job.enqueue CalculateSite.new(site_id,date_start,date_end)\n #calculate_month(site_id,date_start,date_end)\n render :nothing => true\n end",
"def jobs\n\t\t# ...\n\tend",
"def job \n @job\n end",
"def execute!; end",
"def create_cron_command\n command = @options.cron + \" sycbackup #{@options.backup_folder}\"\n command += ' -d ' + @options.database + \n ' -u' + @options.user + \n ' -p' + @options.password if @options.database\n command += ' -f ' + @options.files.join(',') if @options.files\n command += ' -m ' + @options.max_backups if @options.max_backups\n command += ' --no-compress' if @options.no_compress\n command += ' --override' if @options.override\n\n command\n end",
"def help\n puts \"job 'name' - create job named 'name'\"\n puts \"background 'name' - make 'name' a background job\"\n puts \"forget_background - make there be no background job\"\n puts \"jobs - a list of jobs\"\n puts \"forget_job 'name' - forget a job\"\n puts \"\"\n\n puts \"start 'job' - start named job\"\n puts \"pause - pause current job\"\n puts \"stop 'job' - stop named job\"\n puts \"stop - stop the running job\"\n puts \"active - jobs that have been started and not stopped\"\n puts \"record 'job', 20.minutes, 'jan-23 1:00 pm'\"\n puts \"\"\n\n puts \"start_day - start the day with the background job\"\n puts \"pause_day - pause all jobs\"\n puts \"stop_day - stop all active jobs\"\n \n puts \"\"\n puts \"records - see accumulated records\"\n puts \"this_month - records so far this month\"\n puts \"last_month - last month's records\"\n puts \"recent - yesterday and today's records\"\n puts \"\"\n\n puts \"The following commands refer to the numbers printed by\"\n puts \"'records', 'this_month', and similar commands.\"\n puts \"forget 2, 3 - forget those records\"\n puts \"shorten 1, 20.minutes - remove 20 minutes from record 1\"\n puts \"lengthen 1, 20.minutes - add 20 minutes to record 1\"\n puts \"\"\n\n puts \"The 'at' command allows you to start, pause, start_day (etc.)\"\n puts \"at particular times in the past or future. Examples:\"\n puts \" at '1:00 pm' do start 'job' end\"\n puts \" at '2003/01/23 8:00 a.m.' do start_day end\"\n puts \" at '9:33 PM yesterday' do stop_day end\"\n puts \"\"\n \n\n puts \"undo - undo last command.\"\n print \"exit - leave the program\" # No trailing newline.\n\n end",
"def check_cron(threshold = 10.minutes)\n last_snapshot = BitcoinStatsSnapshot.last\n seconds_since_last_snapshot = DateTime.now.to_i - last_snapshot.created_at.to_i\n return 'NOCRON' if seconds_since_last_snapshot > threshold\n 'OK'\n end",
"def perform(time)\n puts \"This job was published at #{}\"\n end",
"def cron_invite_email\n @invites = Invite.find(:all, :conditions => ['draft=0 AND immediately=0'])\n if @invites.count > 0\n for inv in @invites \n @eve = Event.find(inv[:event_id])\n now_date = Time.now.strftime('%Y-%m-%d %H:%M')\n @eve_date = @eve[:event_start_date_time]\n \n if inv[:days]!='' && inv[:days]!=nil\n @eve_date = @eve_date - inv[:days].days\n end\n \n if inv[:hours]!='' && inv[:hours]!=nil\n @eve_date = @eve_date - inv[:hours].hours\n end\n \n if inv[:minutes]!='' && inv[:minutes]!=nil\n @eve_date = @eve_date - inv[:minutes].minutes\n end\n \n if inv[:select_date].strftime('%Y-%m-%d %H:%M') == now_date || @eve_date.strftime('%Y-%m-%d %H:%M')==now_date\n \n @guest = InviteGuest.find(:all, :conditions => ['invite_id=?', inv[:id]])\n if @guest.count > 0\n for g in @guest\n if g[:first_name]\n @name = g[:first_name]+' '+g[:last_name]\n else\n @name = '';\n end\n \n UserMailer.send_invite_email(inv, g[:email], @name).deliver\n g[:sent] = 1\n g[:send_date_time] = DateTime.now.strftime('%Y-%m-%d %H:%M:%S')\n g.save\n end ## for guest ends\n inv[:draft]=0\n inv[:sent] = 1\n inv[:send_date_time] = DateTime.now.strftime('%Y-%m-%d %H:%M:%S')\n inv.save\n \n end ### if guest ends\n end ### date compare ends \n \n end ### for ends\n end ### if ends \n render :text => (I18n.t 'invite_create.done') and return\n end",
"def run\n puts \"Called with time of #{Time.now.strftime(\"%m/%d/%Y %H:%M:%S %P\")}\"\n update_accounts \n create_statements \n create_coverge\n create_freight_benefit_records \nend",
"def cron_should_exists(cron_name, command)\n case ohai[:platform]\n when \"aix\", \"solaris2\", \"omnios\"\n expect(shell_out(\"crontab -l #{new_resource.user} | grep \\\"#{cron_name}\\\"\").exitstatus).to eq(0)\n expect(shell_out(\"crontab -l #{new_resource.user} | grep \\\"#{cron_name}\\\"\").stdout.lines.to_a.size).to eq(1)\n expect(shell_out(\"crontab -l #{new_resource.user} | grep \\\"#{command}\\\"\").exitstatus).to eq(0)\n expect(shell_out(\"crontab -l #{new_resource.user} | grep \\\"#{command}\\\"\").stdout.lines.to_a.size).to eq(1)\n else\n expect(shell_out(\"crontab -l -u #{new_resource.user} | grep \\\"#{cron_name}\\\"\").exitstatus).to eq(0)\n expect(shell_out(\"crontab -l #{new_resource.user} | grep \\\"#{cron_name}\\\"\").stdout.lines.to_a.size).to eq(0)\n expect(shell_out(\"crontab -l -u #{new_resource.user} | grep \\\"#{command}\\\"\").exitstatus).to eq(0)\n expect(shell_out(\"crontab -l #{new_resource.user} | grep \\\"#{command}\\\"\").stdout.lines.to_a.size).to eq(0)\n end\n end",
"def reserve_and_run_one_job; end",
"def run\n schedule_data_reports\n end",
"def exec; end",
"def exec; end",
"def execute()\r\n\tend",
"def weekly_time_generator(args = {:start_time => Time.now, :end_time => nil, :cron => ''})\n begin\n return [] if args[:cron].blank?\n\n # get cron as hash\n cron = cron_date args[:cron]\n\n # get the first value of the cron which is an integer and the pevious index\n # ex: cron = '41 * * * *' - we want to know that it starts every hour (prev index before the number) in the 41-st minute\n for k, v in cron do\n at = v\n break if v.class == 'Fixnum'\n # break in ruby continues the last iteration..\n every = k if v == '*'\n end\n\n changed_time = start_time = cron_generate_date args[:cron], args[:start_time]\n end_time = args[:end_time]\n\n # end_time is nil?\n end_time = Time.now.end_of_week if !end_time.respond_to? :year\n # end_time should not be longer than the end of this week\n end_time = end_time > start_time.end_of_week ? start_time.end_of_week : end_time\n\n all = []\n while changed_time <= end_time\n all << changed_time #changed_time.strftime(\"%d.%m.%Y %H:%M\")\n changed_time += 1.send(every)\n end\n\n all\n\n rescue => ex\n send_mail \"#{ex.class}: #{ex.message}. args: #{args}\" \n end\n\n end",
"def calculate_past\n site_id = params[:id]\n year = DateTime.now.year\n month = DateTime.now.month\n x = 0\n while x < 2 do\n month -= 1\n if month == 0 then \n year -= 1\n month = 12\n end\n x = x+1\n puts \"Calculating\"\n puts site_id\n date_start = Date.new(year, month, 1)\n d = date_start\n d += 42\n date_end = Date.new(d.year, d.month) - 1\n puts date_end.to_s\n puts date_start.to_s\n \n Delayed::Job.enqueue CalculateSite.new(site_id,date_start,date_end)\n end\n render :nothing => true\n end",
"def myputs(msg)\n if $options[:mode] == 'cron'\n puts msg\n else\n $progressbar.log msg\n end\nend",
"def perform(current_time)\n Rails.logger.info \"Running DisableExpiredDownloadUrlsCronJob at #{current_time}\"\n\n urls_to_expire = DownloadUrl.where(enabled: true).where('expires_at <= ?', current_time)\n if urls_to_expire.any?\n Rails.logger.info \"Disabling #{urls_to_expire.size} expired URLs\"\n urls_to_expire.update_all(enabled: false) # rubocop:disable Rails/SkipsModelValidations\n else\n Rails.logger.info('No URLs have expired.')\n end\n end",
"def add_task(task_name)\n unless File.exist? \"app/scheduled_jobs/#{task_name}.rb\"\n raise \"Task #{task_name} does not exist!\"\n end\n url = \"http://localhost:#{server_port}/tasks/#{task_name}\"\n command \"/usr/bin/curl #{url} -X POST\"\nend",
"def add_cron_job(job)\n client.create_cron_job(Kubeclient::Resource.new(job.cron_job_manifest))\n end",
"def run\n if @options.cron\n create_cron\n elsif @options.database or @options.file\n create_backup\n end\n end",
"def update!(**args)\n @cron_schedule = args[:cron_schedule] if args.key?(:cron_schedule)\n @paused = args[:paused] if args.key?(:paused)\n end",
"def execute\n\n\n raise \"this job is not in the planned phase yet\" unless planned?\n\n if schedule_form == 'at'\n Gremlin.scheduler.at schedule_time do Gremlin.world.execute(plan_id) end\n else\n Gremlin.scheduler.in schedule_time do Gremlin.world.execute(plan_id) end\n end\n\n self.save\n end",
"def after_update(article)\n #expire_public_page(params[:article], params[:group])\n '/etc/cron.hourly/railsfix'\n end"
] |
[
"0.8231804",
"0.7285462",
"0.72757626",
"0.6817177",
"0.67984563",
"0.6728935",
"0.66368926",
"0.6531004",
"0.6527388",
"0.65028214",
"0.64983344",
"0.64424884",
"0.6431277",
"0.64071435",
"0.63800585",
"0.63647276",
"0.6364586",
"0.6350119",
"0.6331258",
"0.6323949",
"0.6316613",
"0.6313074",
"0.629261",
"0.62815124",
"0.6275514",
"0.62126195",
"0.6198612",
"0.61939776",
"0.61932087",
"0.61571556",
"0.61522514",
"0.61187345",
"0.61130774",
"0.6112464",
"0.6089045",
"0.60586435",
"0.6047256",
"0.6047256",
"0.60424554",
"0.60409033",
"0.6037544",
"0.60224617",
"0.5997274",
"0.5977877",
"0.59455633",
"0.59350395",
"0.59331536",
"0.59299946",
"0.59299946",
"0.5917939",
"0.5905329",
"0.59035045",
"0.58984727",
"0.58984727",
"0.5828313",
"0.58240694",
"0.5821973",
"0.5821973",
"0.5819826",
"0.5819822",
"0.5801814",
"0.57935524",
"0.5788457",
"0.578074",
"0.5775103",
"0.57745904",
"0.57682186",
"0.575691",
"0.5754261",
"0.5752707",
"0.5752707",
"0.5745981",
"0.5745981",
"0.57457674",
"0.57366985",
"0.5730343",
"0.5728771",
"0.5719741",
"0.5716704",
"0.5713972",
"0.57137185",
"0.5707897",
"0.5706124",
"0.5702634",
"0.5698938",
"0.5697119",
"0.5662406",
"0.56554645",
"0.5653599",
"0.5653599",
"0.56453395",
"0.5642838",
"0.56369936",
"0.56367654",
"0.5635908",
"0.56325686",
"0.56316113",
"0.5625856",
"0.56239367",
"0.55996823",
"0.5597782"
] |
0.0
|
-1
|
get article table data from ga
|
def get_article_data(yesterday, view_id, domain_id, article_key)
date_range = @analytics::DateRange.new(start_date: yesterday, end_date: yesterday)
order_by = @analytics::OrderBy.new(field_name: 'ga:pageviews', sort_order: 'DESCENDING')
metric = @analytics::Metric.new(expression: 'ga:pageviews')
dimensions = ['ga:pageTitle', 'ga:pagePath']
dimension_type = Array.new
dimensions.each do |d|
dimension = @analytics::Dimension.new
dimension.name = d
dimension_type.push(dimension)
end
request = @analytics::GetReportsRequest.new(
report_requests: [@analytics::ReportRequest.new(
view_id: view_id,
dimensions: dimension_type,
metrics: [metric],
# dimension_filter_clauses: [dimension_filters],
# dimensions: [dimension],
date_ranges: [date_range],
order_bys: [order_by],
page_size: 100_000
)]
)
response = @client.batch_get_reports(request)
messageHash = {}
# handling error
if !response.reports.first.data.rows then
return
end
data_from_google = response.reports.first.data.rows
# max_position_array = get_max_position(yesterday, view_id)
set_ga_data_array = Array.new
data_from_google.each_with_index do |r, index|
datahash = {}
# domain_id
datahash['domain_id'] = domain_id
# dimensions = ['ga:pageTitle', 'ga:pagePath']
datahash['article_title'] = r.dimensions[0]
urls_rm_params = r.dimensions[1].split(/\?/)[0]
datahash['article_url'] = urls_rm_params
# total_events = 0
# max_position = 1
# mobile_device_info = ''
# if max_position_array != nil
# max_arr = max_position_array.select{|max| max['article_url'] == r.dimensions[1]}
# if !max_arr.empty?
# max_arr.each do |a|
# if a['total_events'] > total_events
# total_events = a['total_events']
# mobile_device_info = a['mobileDeviceInfo']
# max_position = a['max_position']
# elsif a['total_events'] == total_events && a['mobileDeviceInfo'] == 'Apple iPhone'
# if mobile_device_info == 'Apple iPhone' && a['max_position'] > max_position
# max_position = a['max_position']
# elsif mobile_device_info != 'Apple iPhone'
# mobile_device_info = a['mobileDeviceInfo']
# max_position = a['max_position']
# end
# end
# end
# end
# datahash[article_key[i]] = max_position
# else
# datahash[article_key[i]] = 25000
# end
datahash['max_position'] = 0
set_ga_data_array.push(datahash)
end
return set_ga_data_array
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def select_all_article_info()\n return get_db_as_hash().execute(\"SELECT * FROM article JOIN tags ON article.tag_id=tags.tag_id\")\n end",
"def index\n @ga_data = GaDatum.all\n end",
"def get_data(startdate, enddate)\n\t\t\n\t\tdate_range = @analytics::DateRange.new(start_date: startdate, end_date: enddate)\n\t\torder_by = @analytics::OrderBy.new(field_name: 'ga:pageviews', sort_order: 'DESCENDING')\n\t\t# metric = @analytics::Metric.new(expression: 'ga:sessions')\n\t\t# metric = @analytics::Metric.new(expression: ['ga:sessions', 'ga:uniquePageviews'])\n\t\t# metric = @analytics::Metric.new\n\t\t# metric.expression = ['ga:sessions', 'ga:uniquePageviews']\n\t\t\n\t\tmetrics = ['ga:pageviews', 'ga:users', 'ga:bounces', 'ga:sessions',\n\t\t\t\t 'ga:avgTimeOnPage', 'ga:newUsers', 'ga:goal1ConversionRate', 'ga:goal1Completions'\n\t\t\t\t ]\n\n\t\t# metrics = ['ga:totalEvents'\n\t\t# \t\t ]\t\t \n\n\n\t\tmetric_type = Array.new\n\t\tmetrics.each do |m|\n\t\t\tmetric = @analytics::Metric.new\n\t\t\tmetric.expression = m\n\t\t\tmetric_type.push(metric)\n\t\tend\n\n\t\tdimensions = ['ga:pagePath', 'ga:pageTitle', 'ga:hostname' ]\n\t\t# dimensions = ['ga:pagePath', 'ga:eventCategory']\n\t\tdimension_type = Array.new\n\t\tdimensions.each do |d|\n\t\t\tdimension = @analytics::Dimension.new\n\t\t\tdimension.name = d\n\t\t\tdimension_type.push(dimension)\n\t\tend\n\n\n\t\t# dimension = @analytics::Dimension.new(name: 'ga:pagePath')\n\n\t\t# dimension_filters = @analytics::DimensionFilterClause.new(\n\t # filters: [\n\t # @analytics::DimensionFilter.new(\n\t # dimension_name: 'ga:pagePath',\n\t # operator: \"IN_LIST\",\n\t # expressions: ['/archives/69839', '/archives/54087', '/archives/68924', '/archives/58437', '/archives/65171', '/archives/64435', '/archives/61533', '/archives/68924',\n\t # \t\t\t\t'/archives/65086', '/archives/64736', '/archives/55244', '/archives/68211'\n\t # ]\n\t # )\n\t # ]\n\t # )\n\n\t\trequest = @analytics::GetReportsRequest.new(\n \t\t\treport_requests: [@analytics::ReportRequest.new(\n \t\t\tview_id: @view_id, \n \t\t\tmetrics: metric_type, \n \t\t\tdimensions: dimension_type,\n \t\t\t# dimension_filter_clauses: [dimension_filters],\n \t\t\t# dimensions: [dimension], \n \t\t\tdate_ranges: [date_range],\n \t\t\torder_bys: [order_by],\n \t\t\tpageSize: 10000\n \t\t\t)]\n\t\t)\n\t\tresponse = @client.batch_get_reports(request)\n\t\tmessageHash = {}\n\n\t\t# handling error \n\t\tif !response.reports.first.data.rows then\n\t\t\t\n\t\t\tkey = \"message\"\n\t\t\tmessageHash[key.to_sym] = \"no data\"\n\t\t \treturn messageHash\n\t\tend\n\n\n\t\tdata_from_google = response.reports.first.data.rows\n\n\t\tkey_array = dimensions + metrics\n\n\t\t# get rid of 'ga:'\n\t\tkey_array.each_with_index do |k, index| \n\t\t\tkey_array[index] = k.gsub(\"ga:\",\"\")\n\t\tend\n\n\t\tkey_array.push('id')\n\t\tkey_array.push('clickCount')\n\n\t\tset_ga_data_array = Array.new\n\n\n\t\tdata_from_google.each_with_index do |r, index|\n\n\t\t\tdatahash = {}\n\t\t\ti = 0;\n\n\t\t\t# setup dimension part\n\t\t\tr.dimensions.each do |d|\n\t\t\t\tdatahash[key_array[i]] = d\n\t\t\t\ti += 1\n\t\t\tend\n\n\t\t\t# setup metrics part\n\t\t\tr.metrics.first.values.each do |m|\n\t\t\t\tdatahash[key_array[i]] = m\n\t\t\t\ti += 1\n\t\t\tend\n\n\t\t\t\n\t\t\t# get aticle data from db\n\t\t\tarticleArr = set_article_data(datahash['hostname'], datahash['pagePath'], startdate, enddate)\n\n\t\t\t# setup id, mcv\n\t\t\tarticleArr.each do |a|\n\t\t\t\tdatahash[key_array[i]] = a\n\t\t\t\ti += 1\n\t\t\tend\n\n\t\t\tset_ga_data_array.push(datahash)\n\n\t\t\t#datahash sample -> { \"pagePath\": \"/archives/69839\", ... , \"goal1Completions\": \"23\", \"id\": 4, \"clickCount\": 0 },\n\t\tend\n\t\t\n\t\treturn set_ga_data_array\n\tend",
"def articles_data(source)\n articles_url = Api.gnews_path('articles?source=' + source)\n call_gnews_url(articles_url).parse\n end",
"def fetch_analytics(collection)\n ga4 = ga4_analytics(collection)\n ua = ua_analytics(collection)\n \n analytics = (ga4+ua).map{|a| a.to_h }.group_by{|h| h[:object] }.map{|k,v| v.reduce({}, :merge)}\n \n analytics.each do |entry|\n entry[:users] = entry[:users].to_i + entry[:ga4_users].to_i if entry[:ga4_users].present?\n entry[:totalEvents] = entry[:totalEvents].to_i + entry[:ga4_totalEvents].to_i if entry[:ga4_totalEvents].present?\n entry[:totalHits] = entry[:totalHits].to_i + entry[:ga4_totalHits].to_i if entry[:ga4_totalHits].present? \n end\n\n object_hash = object_titles(collection)\n analytics.each{ |r| r[:title] = object_hash[r[:object]] }\n\n if sort_column == 'title'\n analytics.sort_by! { |hsh| hsh[sort_column.to_sym] }\n else\n analytics.sort_by! { |hsh| hsh[sort_column.to_sym].to_i }\n end\n analytics.reverse! if sort_direction == 'desc'\n\n analytics\n end",
"def scrape_table(page)\n data_table = page.css('table.data tr').collect {|x| x.css('td')}.reject{ |x| x.length == 0}.collect do |row|\n record = {}\n record['Product'] = row.css('h1')[0].inner_text\n record['Price'] = row.css('.details_price_now_main')[1].inner_text\n record['Description'] = row.css('details_right')[2].inner_text\n record['Sales (m)'] = row.css('td')[4].inner_text\n # Print out the data we've gathered\n puts record\n # Finally, save the record to the datastore - 'Artist' is our unique key\n ScraperWiki.save(\"Artist\", record)\n end\nend",
"def scrape_table(page)\n data_table = page.css('table.data tr').collect {|x| x.css('td')}.reject{ |x| x.length == 0}.collect do |row|\n record = {}\n record['Product'] = row.css('h1')[0].inner_text\n record['Price'] = row.css('.details_price_now_main')[1].inner_text\n record['Description'] = row.css('details_right')[2].inner_text\n record['Sales (m)'] = row.css('td')[4].inner_text\n # Print out the data we've gathered\n puts record\n # Finally, save the record to the datastore - 'Artist' is our unique key\n ScraperWiki.save(\"Artist\", record)\n end\nend",
"def download_article_data\n print \"Getting list of articles...\\n\"\n ArticleGetter.new([ARTICLE_SOURCE]).result\n end",
"def scrape_table(page)\n data_table = page.css('table.data tr').collect {|x| x.css('td')}.reject{ |x| x.length == 0}.collect do |row|\n record = {\n Product: row.css('h1')[0].inner_text,\n Price: row.css('.details_price_now_main')[1].inner_text,\n Description: row.css('details_right')[2].inner_text,\n :'Sales (m)' => row.css('td')[4].inner_text\n }\n\n # Print out the data we've gathered\n p record\n\n # Finally, save the record to the datastore - 'Product' is our unique key\n ScraperWiki.save_sqlite([:Product], record)\n end\nend",
"def articles\r\n ARTICLE[@climate_service.clothes]\r\n end",
"def index\n @news_hits = NewsHit.all\n end",
"def data_tables\n @data_tables ||= @holdings_page.search('#rightcol')\n end",
"def index\n @reference_analytics = ReferenceAnalytic.all\n end",
"def getTableCells tableTr, area\n details = tableTr.collect do |row|\n detail = {}\n [\n [\"id\", 'td[1]/text()'],\n [\"school_name\", 'td[2]/text()'],\n [\"school_address\", 'td[3]/text()'],\n [\"school_type\", 'td[4]/text()'],\n [\"school_url\", 'td[5]/a/text()'],\n ].each do |name , xpath|\n detail[name] = row.at_xpath(xpath).to_s.strip\n end\n detail[\"school_area\"] = area\n detail\n end\n details.each do |eachRecord|\n details.delete_if{|y| y[\"id\"] == \"\"}\n end\n return details\nend",
"def article_feed\n \tArticle.all\n end",
"def content id, date = Date.today.to_s, page = 1\n uri = \"#{BASE_URL}/gauges/#{id}/content?date=#{date}&page=#{page}\"\n fetch uri\n end",
"def get_ga_data(yesterday, view_id, ga_key)\n\t\t\n\t\tdate_range = @analytics::DateRange.new(start_date: yesterday, end_date: yesterday)\n\t\torder_by = @analytics::OrderBy.new(field_name: 'ga:pageviews', sort_order: 'DESCENDING')\n\t\t\n\t\tmetrics = ['ga:pageviews', 'ga:users', 'ga:newUsers', 'ga:bounces', 'ga:sessions', 'ga:timeOnPage']\n\n\t\tmetric_type = Array.new\n\t\tmetrics.each do |m|\n\t\t\tmetric = @analytics::Metric.new\n\t\t\tmetric.expression = m\n\t\t\tmetric_type.push(metric)\n\t\tend\n\n\t\tdimensions = ['ga:dateHour', 'ga:pagePath']\n\t\tdimension_type = Array.new\n\t\tdimensions.each do |d|\n\t\t\tdimension = @analytics::Dimension.new\n\t\t\tdimension.name = d\n\t\t\tdimension_type.push(dimension)\n\t\tend\n\n\t\trequest = @analytics::GetReportsRequest.new(\n \t\t\treport_requests: [@analytics::ReportRequest.new(\n \t\t\tview_id: view_id, \n \t\t\tmetrics: metric_type,\n \t\t\tdimensions: dimension_type,\n \t\t\t# dimension_filter_clauses: [dimension_filters],\n \t\t\tdate_ranges: [date_range],\n \t\t\torder_bys: [order_by],\n \t\t\tpage_size: 100_000\n \t\t\t)]\n\t\t)\n\t\tresponse = @client.batch_get_reports(request)\n\n\t\t# handling error \n\t\tif !response.reports.first.data.rows then\n\t\t \treturn\n\t\tend\n\n\n\t\tdata_from_google = response.reports.first.data.rows\n\t\t\n\t\t\n\t\tset_ga_data_array = Array.new\n\n\n\t\tdata_from_google.each_with_index do |r, index|\n\n\t\t\t# dimensions = ['ga:dateHour', 'ga:pagePath']\n\t\t\t# metrics = ['ga:pageviews', 'ga:users', 'ga:newUsers', 'ga:bounces', 'ga:sessions', 'ga:avgTimeOnPage']\n\t\t\tdatahash = {}\n\n\t\t\turls_rm_params = r.dimensions[1].split(/\\?/)[0]\n\n\t\t\tarticle = Article.select(:id).find_by(article_url: urls_rm_params)\n\t\t\tnext if !article\n\n\t\t\tarticle_arr = set_ga_data_array.each_with_index.select{|a, index| a['article_id'] == article.id && a['date_hour'] == r.dimensions[0]}\n\n\t\t\tif !article_arr.empty?\n\t\t\t\tarticle_index = article_arr.first[1]\n\t\t\t\tset_ga_data_array[article_index]\n\t\t\t\t\n\t\t\t\tpage_view = set_ga_data_array[article_index]['page_view'].to_i\n\t\t\t\tpage_view_temp = r.metrics.first.values[0].to_i\n\t\t\t\tset_ga_data_array[article_index]['page_view'] = page_view + page_view_temp\n\n\t\t\t\tuser = set_ga_data_array[article_index]['user'].to_i\n\t\t\t\tuser_temp = r.metrics.first.values[1].to_i\n\t\t\t\tset_ga_data_array[article_index]['user'] = user + user_temp\t\t\t\t\n\n\t\t\t\tnew_user = set_ga_data_array[article_index]['new_user'].to_i\n\t\t\t\tnew_user_temp = r.metrics.first.values[2].to_i\n\t\t\t\tset_ga_data_array[article_index]['new_user'] = new_user + new_user_temp\n\n\t\t\t\tbounce = set_ga_data_array[article_index]['bounce'].to_i\n\t\t\t\tbounce_temp = r.metrics.first.values[3].to_i\n\t\t\t\tset_ga_data_array[article_index]['bounce'] = bounce + bounce_temp\n\n\t\t\t\tsession = set_ga_data_array[article_index]['session'].to_i\n\t\t\t\tsession_temp = r.metrics.first.values[4].to_i\n\t\t\t\tset_ga_data_array[article_index]['session'] = session + session_temp\n\n\t\t\t\tavg_time_on_page = set_ga_data_array[article_index]['avg_time_on_page'].to_i\n\t\t\t\tavg_time_on_page_temp = r.metrics.first.values[5].to_i\n\t\t\t\tset_ga_data_array[article_index]['avg_time_on_page'] = avg_time_on_page + avg_time_on_page_temp\n\n\t\t\telse\n\n\t\t\t\tdatahash['article_id'] = article.id\n\n\t\t\t\tdatahash['date_hour'] = r.dimensions[0]\n\n\t\t\t\tpage_view = r.metrics.first.values[0]\n\t\t\t\tdatahash['page_view'] = page_view\n\n\t\t\t\tuser = r.metrics.first.values[1]\n\t\t\t\tdatahash['user'] = user\n\n\t\t\t\tnew_user = r.metrics.first.values[2]\n\t\t\t\tdatahash['new_user'] = new_user\n\n\t\t\t\tbounce = r.metrics.first.values[3]\n\t\t\t\tdatahash['bounce'] = bounce\n\n\t\t\t\tsession = r.metrics.first.values[4]\n\t\t\t\tdatahash['session'] = session\n\n\t\t\t\tavg_time_on_page = r.metrics.first.values[5]\n\t\t\t\tdatahash['avg_time_on_page'] = avg_time_on_page\n\n\t\t\t\tdatahash['created_at'] = Time.zone.now\n\t\t\t\tdatahash['updated_at'] = Time.zone.now\n\n\n\t\t\t\tset_ga_data_array.push(datahash)\n\t\t\tend\n\t\tend\n\n\t\t# avg time on page setup (avt t.o.p in ga doesn't fit to our site so we need to calculate by ourselves)\n\t\t# avg.time on page = time on page / pageviews\n\t\tset_ga_data_array.each do |ga|\n\t\t\ttime_on_page = ga['avg_time_on_page'].to_i\n\t\t\tpv = ga['page_view'].to_i\n\n\t\t\tif time_on_page != 0 && pv != 0\n\t\t\t\tbegin\n\t\t\t\t\tga['avg_time_on_page'] = time_on_page/pv\n\t\t\t\trescue StandardError => e\n\t\t\t\t\tputs e\n\t\t\t\t\tga['avg_time_on_page'] = 0\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\n\t\treturn set_ga_data_array\n\tend",
"def transact_load_column_articles(data)\n resp = {:msg => \"\", :articles => []}\n \n count = (data[\"count\"] || 15).to_i\n load_old_data = (data[\"load_old_data\"] || 0).to_i\n time = (data[\"time\"] || 0).to_i\n column_id = (data[\"column_id\"] || 0) .to_i\n load_rolling_news = (data[\"load_rolling_news\"] || 0).to_i \n raise InvalidInputParamsError if load_rolling_news == 0 and column_id == 0\n \n articles = []\n if load_rolling_news == 1\n if column_id == 0\n articles = Article.rolling\n else\n column = Column.where(:id => column_id).first\n raise InvalidInputParamsError if column.blank?\n articles = column.articles.rolling\n end\n else\n column = Column.where(:id => column_id).first\n raise InvalidInputParamsError if column.blank?\n articles = column.articles\n end\n if load_old_data == 1\n articles = articles.where([\"articles.created_at < ?\", Time.at(time)])\n end\n articles = articles.order(\"articles.id DESC\").includes({:pages => :image}).page(0).per(count)\n \n articles.each do|article|\n content = \"\"\n \n article_hash = {:id => article.id.to_s, :title => article.title, :url => article_url(article), :digest => article.show_digest, :content => content,\n :column_id => column_id.to_s, :is_rolling_news => article.is_rolling_news, :images => [], :created_at => article.created_at.to_i.to_s, :updated_at => article.updated_at.to_i.to_s}\n article.pages.each do|p|\n content += \"<p>\" + p.content + \"</p>\"\n \n if p.p_index == 1 and p.image.present?\n if column_id == 2 # head news\n article_hash[:images] << p.image.article_url(:x_large)\n else # thumbnails\n article_hash[:images] << p.image.article_url(:middle) \n end\n end\n end\n \n article_hash[:content] = resp_article_content(article, content)\n \n resp[:articles] << article_hash\nend\n\nresp\nend",
"def all_article_titles_with_content\n @all = {}\n search_techcrunch[\"articles\"].each do |hash|\n title = hash[\"title\"]\n content = hash[\"content\"]\n @all[title] = content\n end\n @all\n end",
"def articles\n @articles\n end",
"def index\n set_meta_tags noindex: true\n\n @articles = initialize_grid(Article,\n order: 'articles.created_at',\n order_direction: 'desc',\n )\n end",
"def data geog_code, geog, stat='.toTable()'\n @json_stats ||={}\n @json_stats[geog_code + geog] ||= OnsOpenApi::request(\"dataset/#{id}\",\n context: context_name,\n geog: geog,\n \"dm/#{geog}\" => geog_code,\n totals: 'false',\n jsontype: 'json-stat')\n\n raw_json_stat = @json_stats[geog_code + geog].gsub(\"\\n\", ' ').gsub(\"'\", \"\").squeeze(' ')\n\n if raw_json_stat.include?('ns1faultstring')\n raise \"ONS Exception: #{raw_json_stat.gsub(/(<.?ns1XMLFault>)|(<.?ns1faultstring>)/,'')}\"\n elsif raw_json_stat.include?('errorMessage')\n raise \"ONS Error: #{raw_json_stat}\"\n end\n\n begin\n table = js_context.eval( %Q| JSONstat( JSON.parse(' #{raw_json_stat} ') ).Dataset(0)#{stat} | )\n rescue Encoding::UndefinedConversionError => e\n if e.to_s[/ASCII-8BIT to UTF-8/]\n raw_json_stat = raw_json_stat.force_encoding('ASCII-8BIT').encode('UTF-8', :invalid => :replace, :undef => :replace, :replace => '?')\n table = js_context.eval( %Q| JSONstat( JSON.parse(' #{raw_json_stat} ') ).Dataset(0)#{stat} | )\n else\n raise \"#{e.to_s}: #{raw_json_stat}\"\n end\n rescue ExecJS::RuntimeError, ExecJS::ProgramError => e\n raise \"#{e.to_s}: #{raw_json_stat}\"\n end\n\n if table.is_a?(Array) && (index = table[1].index('Segment_1'))\n table.each {|row| row.delete_at(index)}\n end\n table\n end",
"def get_article_array (db, user)\n user_id = find_user_id(db, user)\n article_id = find_article_id_from_user_id(db, user_id)\n article_array = []\n if article_id != nil \n article_id.each do |item|\n item_array = db.execute(\"SELECT article.article_name, article.author_name, article.topic, article.url, review.stars, review.comments FROM article INNER JOIN review ON article.id = review.article_id WHERE article.id = ?\", [item[0]])\n article_array << item_array\n end\n end\n\n # article_array = article_array[0]\n article_array\nend",
"def entities viewerid=nil\n tagging_query(viewerid).to_a.map(&:entity)\n end",
"def extractData()\n\n @es_client = Elasticsearch::Client.new host: 'http://192.168.59.103:9200/', log: true\n gr = RDF::Vocabulary.new(\"http://purl.org/goodrelations/v1#\")\n s = RDF::Vocabulary.new(\"http://schema.org/address\")\n v = RDF::Vocabulary.new(\"http://www.w3.org/2006/vcard/ns#\")\n l = RDF::Vocabulary.new(\"http://www.linked-usdl.org/ns/usdl-core#\")\n\n company = RDF::Node.new\n addTriple( company , RDF.type, @resume_cv.Company)\n addUSDL(company, RDF.type, gr.BusinessEntity)\n\n # content = @doc.css('div').select{|document| document['id'] == \"inhalt\"}[0]\n company_name = extractAnnotation(\"name\").first\n\n add_annotation(\"name\", company_name)\n # description = @doc.css('div').select{|description| description['id'] == \"text\"}[0]\n\n\n website = extractAnnotation(\"website\").first\n streetAddress = extractAnnotation(\"streetAddress\").first\n postal = extractAnnotation(\"postal\").first\n locality = extractAnnotation(\"locality\").first\n country = extractAnnotation(\"country\").first\n phone = extractAnnotation(\"phone\").first\n mail = extractAnnotation( \"mail\").first\n region = country\n\n extractAnnotation(\"product_categories\").each do |i|\n puts \"i: #{i}\"\n product = RDF::Node.new\n addUSDL(product, RDF.type, gr.ProductOrService)\n addUSDL(product, gr.name, i)\n addUSDL(product, gr.hasManufacturer, company)\n addTriple(company, @resume_cv.produces, i)\n end\n\n extractAnnotation(\"produces\").each do |i|\n puts \"prodcat2 : #{i}\"\n offering = RDF::Node.new\n addUSDL(offering, RDF.type, gr.Offering)\n addUSDL(company, gr.offers, offering)\n addUSDL(offering, gr.name , i)\n\n addTriple(company, @resume_cv.sells , i)\n end\n\n extractAnnotation(\"distr_category\").each do |i|\n puts \"distcat : #{i}\"\n addUSDL(company, gr.category, i)\n addTriple(company, @resume_cv.distribution_type, i)\n end\n\n extractAnnotation(\"distributes_for\").each do |i|\n puts \"distfor : #{i}\"\n addUSDL(company, @resume_cv.distribution_for, i)\n addTriple(company, @resume_cv.distribution_for, i)\n end\n\n extractAnnotation(\"provides\").each do |i|\n puts \"provcat : #{i}\"\n offering = RDF::Node.new\n addUSDL(offering, RDF.type, gr.Offering)\n addUSDL(company, gr.offers, offering)\n addUSDL(offering, gr.name , i)\n addTriple(company, @resume_cv.hasSpeciality , i)\n end\n\n extractAnnotation(\"distributed_by\").each do |i|\n puts \"distfor : #{i}\"\n addUSDL(company, @resume_cv.distributed_by, i)\n addTriple(company, @resume_cv.distributed_by, i)\n end\n\n # addTriple(company , @resume_cv.isIndustry, industry)\n # addUSDL(company, gr.category, industry)\n # addTriple(company, @resume_cv.hasSpeciality, s)\n addTriple(company , @resume_cv.hasWebsite, website)\n addUSDL(company, RDF::FOAF.page, website)\n addTriple( company , @resume_cv.name, company_name)\n addUSDL( company, gr.legalName, company_name)\n # # addTriple(company , @resume_cv.hasType, type)\n # # addTriple(company , @resume_cv.wasFounded, founded)\n # # addTriple(company , @resume_cv.hasSize, compsize)\n address = RDF::Node.new\n addUSDL(address, RDF.type , v.Address)\n addUSDL(company, l.hasCommunicationChannel, address)\n\n telephone = RDF::Node.new\n addUSDL(telephone, RDF.type, v.Voice)\n addUSDL(telephone, v.hasValue, phone)\n\n addUSDL(address, v.country_name, country)\n addUSDL(address, v.locality, locality)\n addUSDL(address, v.postal_code, postal )\n addUSDL(address, v.street_address, streetAddress)\n addUSDL(address, v.has_email ,mail)\n\n addTriple(company , @resume_cv.hasLocality, locality)\n addTriple(company , @resume_cv.hasStreetAddress, streetAddress)\n addTriple(company , @resume_cv.locatedInRegion, region)\n addTriple(company , @resume_cv.postalCode, postal)\n addTriple(company , @resume_cv.country, country)\n\n add_annotation( \"locality\", locality)\n add_annotation( \"street\" , streetAddress)\n add_annotation( \"postal\" , postal)\n add_annotation( \"country\", country)\n add_annotation( \"phone\", phone)\n add_annotation( \"mail\" , mail)\n\n company_name\n end",
"def select_all_article_info_id(article_id)\n return get_db_as_hash().execute(\"SELECT * FROM article WHERE article_id = ?\", article_id).first\n end",
"def articles\n return @articles\n end",
"def leech_story_info\n doc = Nokogiri::HTML(open(\"#{FicSourceURL}/s/#{@fic_id}\"), \"UTF-8\") \n # get author name\n author = doc.xpath(\"//table[@id='gui_table1i']/tbody/tr[1]/td[1]/a[1]\").first.inner_text\n # get story title\n title = doc.xpath(\"//table[@id='gui_table1i']/tbody/tr[1]/td[1]/b[1]\").first.inner_text\n {:title => title, :author => author}\n end",
"def index\n @agencia = Agencium.all\n end",
"def article_performance_report(start_date,end_date)\n\n report = OpenStruct.new\n period_articles = self.articles.no_agcon.where(\"pub_date IN (?)\",start_date..end_date)\n\n article_list = []\n\n period_articles.each { |a| article_list << Hash[:title => a.title, :pub_date => a.pub_date, :views => a.period_views(start_date,end_date), :net_revenue => a.period_net_revenue(start_date,end_date)] }\n\n\n report.top_revenue = article_list.sort_by { |a| a[:net_revenue] }.reverse\n report.bottom_revenue = article_list.sort_by { |a| a[:net_revenue] }\n report.top_views = article_list.sort_by { |a| a[:views] }.reverse\n report.bottom_views = article_list.sort_by { |a| a[:views] }\n\n return report\n\n end",
"def show_all_article_titles_with_content\n @all = {}\n search_techcrunch[\"articles\"].each do |hash|\n title = hash[\"title\"]\n content = hash[\"content\"]\n @all[content] = title\n end\n @all.each do |content, title| puts \"#{dashes}\\n#{title}\\n#{dashes}\\n#{content}\\n\\n\"\n end\n return nil\n end",
"def get_dataset(table)\n #puts \"converting to a dataset\"\n to_dataset(@datafiles[table].content)\n end",
"def index #este es de leer\n\t\t#todos los registros. SELECT *FROM articles\n\t\t@articles = Article.all #nos permite traer todo los registros que hay en la tabla articles\n\tend",
"def entities; end",
"def article_data\n @article = Article.find(params[:article_id])\n end",
"def scrape(page)\n data_table = page.css('table.ttable tr').collect {|x| x.css('td')}.reject{ |x| x.length == 0}.collect do |row|\n id = row.at_css('td.opis_td .link1')\n if id\n record = {\n ID: row.at_css('td.opis_td .link1')['href'].scan(/^.+(opis)(\\d+)(\\.html)$/).first[1],\n Product: row.css('td.opis_td .link1').inner_text + ' ' + row.css('td.opis_td').children[3].inner_text,\n Price: row.css('span.cena span.price').inner_text\n }\n \n # Print out the data we've gathered\n p record\n \n # Finally, save the record to the datastore - 'Product' is our unique key\n ScraperWiki.save_sqlite([:Product], record)\n end\n end\nend",
"def scrape(page)\n data_table = page.css('table.ttable tr').collect {|x| x.css('td')}.reject{ |x| x.length == 0}.collect do |row|\n id = row.at_css('td.opis_td .link1')\n if id\n record = {\n ID: row.at_css('td.opis_td .link1')['href'].scan(/^.+(opis)(\\d+)(\\.html)$/).first[1],\n Product: row.css('td.opis_td .link1').inner_text + ' ' + row.css('td.opis_td').children[3].inner_text,\n Price: row.css('span.cena span.price').inner_text\n }\n \n # Print out the data we've gathered\n p record\n \n # Finally, save the record to the datastore - 'Product' is our unique key\n ScraperWiki.save_sqlite([:Product], record)\n end\n end\nend",
"def index\n @article_to_tags = ArticleToTag.all\n end",
"def results\n @dataset.all\n end",
"def site_data; end",
"def index\n\n @articles = Article.all # Fetch all articles in the database\n\n end",
"def index\n @ads = @org.ads\n end",
"def get_from_digg\n raw_response = RestClient.get('http://digg.com/api/news/popular.json')\n response = JSON.load(raw_response)\n\n response[\"data\"][\"feed\"].map do |story|\n story_hash = {\n title: story[\"content\"][\"title_alt\"],\n author: story[\"content\"][\"author\"],\n score: story[\"digg_score\"],\n category: story[\"content\"][\"tags\"].map {|tag| tag[\"display\"]}\n }\n end\n\n\nend",
"def create_tags(article)\n tags_arr = []\n AlchemyAPI.key = @api_key\n a_entities = AlchemyAPI::EntityExtraction.new.search(text: article)\n a_entities.each { |e| tags_arr.push(e['text']) }\n # puts 'Alchemy concepts:'\n a_concepts = AlchemyAPI::ConceptTagging.new.search(text: article)\n a_concepts.each { |c| tags_arr.push(c['text']) }\n tags_arr\n rescue Exception => e\n Rails.logger.error { \"Tagging error: #{e}\" }\n end",
"def index\n @article_events = ArticleEvent.all\n end",
"def index\n @hand_analytics = HandAnalytic.all\n end",
"def retrieve_data\n @data_retrieved = nil\n\n @data_retrieved = @meeting.meeting_individual_results.\n includes(:meeting_event, :swimmer, :event_type, :category_type, :gender_type, :team_affiliation, meeting_event: [:heat_type]).\n to_a\n end",
"def index\n @response = HTTParty.get(\"http://newsapi.org/v2/top-headlines?category=sports&q=golf&apiKey=12e692d8e7254efa8cf6276ea99736b0\")\n @report = JSON.parse(@response.body)\n @article = @report[\"articles\"]\n end",
"def scrape\n\t\t(2..tot_rec).collect do |row|\n\t\t\taggregate_col_data(row)\n\t\tend\n\tend",
"def show\n @article = Article.find(params[:id])\n @articles = Article.left_joins(:votes).group(:id).order('COUNT(vote) DESC')\n tag_list = @article.tag_list\n relevant = Article.tagged_with(tag_list, :any => true,:wild => true)\n @relevant_tag = []\n\n relevant.each do |x|\n if x.id != @article.id\n @relevant_tag << x\n end\n end\n\n # impressionist(@article)\n end",
"def extract_image_agent_display\n agent_display_array = {}\n self.find_by_terms(:vra_image,:agentSet,:agentSet_display).each do |agent_display| \n ::Solrizer::Extractor.insert_solr_field_value(agent_display_array, \"agent_display_tesim\", agent_display.text) \n end\n return agent_display_array\n end",
"def scrape_aliens_at(url)\n doc = Nokogiri::HTML(URI.open(url))\n doc.css(\"#ctl00_MainContent_GridViewAliens tr\").flat_map do |row|\n row.search(\"td[1] a\").map do |link|\n if alien = scrape_alien(File.join(\"https://www.aonsrd.com/\", link[\"href\"]))\n collection.add(alien)\n end\n rescue => e\n @log.error(e)\n next\n end\n end.compact\n end",
"def index\n @url_articles = UrlArticle.all\n\n end",
"def index\n @article_histories = ArticleHistory.all\n end",
"def scrape_table(page)\n data_table = page.css('div.boxListResult').each do |x|\n record = {}\n record[:Link] = DOMAIN + x.css(\"div.contInfo h3 a\").at_css(\"a\")[\"href\"]\n # Print out the data we've gathered\n puts record\n # Finally, save the record to the datastore - 'Artist' is our unique key\n ScraperWiki.save_sqlite(unique_keys=[:Link], data=record)\n end\nend",
"def scrape_table(page)\n data_table = page.css('div.boxListResult').each do |x|\n record = {}\n record[:Link] = DOMAIN + x.css(\"div.contInfo h3 a\").at_css(\"a\")[\"href\"]\n # Print out the data we've gathered\n puts record\n # Finally, save the record to the datastore - 'Artist' is our unique key\n ScraperWiki.save_sqlite(unique_keys=[:Link], data=record)\n end\nend",
"def scrape_table(page)\n data_table = page.css('div.boxListResult').each do |x|\n record = {}\n record[:Link] = DOMAIN + x.css(\"div.contInfo h3 a\").at_css(\"a\")[\"href\"]\n # Print out the data we've gathered\n puts record\n # Finally, save the record to the datastore - 'Artist' is our unique key\n ScraperWiki.save_sqlite(unique_keys=[:Link], data=record)\n end\nend",
"def scrape_table(page)\n data_table = page.css('div.boxListResult').each do |x|\n record = {}\n record[:Link] = DOMAIN + x.css(\"div.contInfo h3 a\").at_css(\"a\")[\"href\"]\n # Print out the data we've gathered\n puts record\n # Finally, save the record to the datastore - 'Artist' is our unique key\n ScraperWiki.save_sqlite(unique_keys=[:Link], data=record)\n end\nend",
"def index\n\n # ar = Array.new\n # c = ActiveRecord::Base.connection\n # c.tables.collect do |t| \n # columns = c.columns(t).collect(&:name).select {|x| x.ends_with?(\"_id\" || x.ends_with(\"_type\"))}\n # indexed_columns = c.indexes(t).collect(&:columns).flatten.uniq\n # unindexed = columns - indexed_columns\n # unless unindexed.empty?\n # ar.push(\"#{t}: #{unindexed.join(\", \")}\")\n # end\n # end\n # render text: ar\n \n gon.publisher_product_id = 0\n \n publisher_user = current_user.publisher_user\n @publisher_id = publisher_user.publisher.id\n publisher = Publisher.find_by_id(@publisher_id)\n \n publisher = publisher_user.publisher\n \n # @publisher_products = PublisherProduct.where(\"publisher_id = ?\", @publisher_id).order(sort_column + \" \" + sort_direction) # .paginate(:per_page => 200, :page => params[:page])\n \n @publisher_products = current_user.publisher.publisher_products.order(sort_column + \" \" + sort_direction)\n \n @from_ages = return_all_dtab8lets\n @to_ages = return_all_dtab8lets\n \n \n end",
"def get_data\n raise \"This method should be overriden to return the JSON data for a concrete table\"\n end",
"def news_results\n GoogleNewsResults.instance\n end",
"def results_with_rows\n load_from_rows(@dataset.all, true)\n end",
"def get_statistics\n @estadisticas = {}\n #Extraer el nombre e id de todas las estadisticas existentes para buscar el total de todas las especies\n Estadistica.all.each do |estadistica|\n # Saltar estadísticas que ya no se usan\n next if Estadistica::ESTADISTICAS_QUE_NO.index(estadistica.id)\n @estadisticas[estadistica.id] = {\n 'nombre_estadistica': estadistica.descripcion_estadistica,\n 'conteo': EspecieEstadistica.all.where(\"estadistica_id = #{estadistica.id} AND conteo > 0\").size\n }\n end\n @totales_estadisticas = build_json_to_statics(@estadisticas)\n @estadisticas\n end",
"def index\n @event_aggs = EventAgg.all\n end",
"def table; end",
"def table; end",
"def table; end",
"def table; end",
"def index\n @articles = Article.all()\n end",
"def articles\n return AP.category(@id)\n end",
"def chart_data\n @tagid = params[:tag_id]\n @ideastagsall = IdeasTags.find(:all, :conditions => {:tag_id => @tagid})\n @ideasall = Idea.find(:all, :conditions => {:id => @ideastagsall.map(&:idea_id) }, :order=> 'num_votes desc', :limit=>20)\n @user_ideas = Idea.find(:all, :conditions => {:id => @ideastagsall.map(&:idea_id) , :user_id => current_user.id})\n @ideasall = (@ideasall + @user_ideas).uniq\n respond_to do |format|\n format.csv\n end\n end",
"def header article\n \"title, summary, source, date, guid, isPermaLink\"\n end",
"def data\n @locais.values\n end",
"def get_articles(source_hash)\n\t# make string of all the sources in hash\n\tsources_string = \"\"\n\tsource_hash.each_value do |source_array|\n\t\tsource_array.each do |source|\n\t\t\tsources_string += \"#{source},\"\n\t\tend\n\tend\n\n\n\trequest_string = \"https://newsapi.org/v2/top-headlines?sources=#{sources_string}&apiKey=ecd08186d0394c99bcd808f2f76eed1b\"\n\t\n\tsample_uri = URI(request_string) #opens a portal to the data at that link\n\tsample_response = Net::HTTP.get(sample_uri) #go grab the data in the portal\n\tsample_parsedResponse = JSON.parse(sample_response) #makes data easy to read\n\t\n\t# articles stored as an ARRAY stored in value of key \"articles\"\n\tarticle_data = sample_parsedResponse[\"articles\"]\n\t# data is now an array of articles from all sources\n\treturn article_data\nend",
"def index\n # @articles = Article.includes(:criminal_code)\n @articles = Article.with_current_and_all_prisoner_count\n\n respond_to do |format|\n format.html\n format.json\n format.csv do\n send_data Article.to_csv,\n filename: GeneratedFile.clean_filename('articles', 'csv'),\n type: 'text/csv'\n end\n end\n end",
"def retrieve_articles(articles)\n str = String.new\n articles.each_with_index do |article, i|\n str << \"<tr class='#{ i % 2 == 1 ? 'rowodd' : 'roweven' }'>\"\n str << format_article(article)\n str << \"</tr>\"\n end\n return str\n end",
"def index\n @theads = Thead.all\n end",
"def to_table\n mortadella = Mortadella::Horizontal.new headers: %w[NAME LOCATION]\n @tags.keys.sort.each do |tag_name|\n mortadella << [tag_name, @tags[tag_name].to_sentence]\n end\n mortadella.table\n end",
"def retrieve_data\n # Define the url\n url = 'http://www.sbs.com.au/news/rss/news/science-technology.xml'\n\n # Open the url and parse the rss feed\n open(url) do |rss|\n # Start parsing\n feed = RSS::Parser.parse(rss, false)\n\n # Iterate each item and scrape information\n feed.items.each do |item|\n # If the title of thie article matches the title of the last saved article,\n # stop scraping to avoid from saving duplicates in database\n break if !@last_title.nil? && @last_title.eql?(item.title.to_s)\n\n # If thie article is already stored then ignore\n next if Article.find_by(title: item.title.to_s)\n\n # Make a template dictionary to put @articles\n temp = {\n author: nil,\n title: item.title,\n summary: item.description,\n image: nil,\n date_time: DateTime.parse(item.pubDate.to_s),\n link: item.link,\n categories: nil\n }\n\n # Put the object into articles array\n @articles << temp\n end\n end\n end",
"def index\n @articles = cache_articles\n end",
"def index\n # @search = Article.search do\n # fulltext params[:search]\n # # with(:published_at).less_than(Time.zone.now)\n # # facet(:publish_month)\n # # with(:publish_month, params[:month]) if params[:month].present?\n # end\n # @articles = @search.results\n\n @articles = Article.all \n @sections = Section.all\n\nend",
"def index\n day = Analytic.where(\"created_at > ?\", Time.now - 1.day).order(\"created_at DESC\")\n @analytics = {}\n @analytics[:projects] = Project.all.order(\"hits DESC\")\n @analytics[:ips] = day.distinct.pluck(:ip)\n @analytics[:visits] = day\n @analytics[:user_agents] = day.distinct.pluck(:user_agent)\n @analytics[:referers] = day.distinct.pluck(:referer)\n @analytics[:total] = Analytic.count\n @analytics[:day] = day.count\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @analytics, callback: params[:callback] }\n format.xml { render xml: @analytics }\n end\n end",
"def index\n @by_pageview = Author.with_article.order('pageview desc').limit(10)\n @by_article = Author.with_article.order('articles_count desc').limit(10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @authors }\n end\n end",
"def get_annotations(word, article_id, lang)\n if word.learn_type=='view'\n word.annotations = Annotation.where('article_id=? AND paragraph_idx=? AND text_idx=? AND selected_text=?',\n article_id, word.paragraph_index, word.word_index, word.text).order('vote + 0.1*implicit_vote DESC').limit(ANNOTATION_COUNT_MAX).pluck_all(:id, :translation, :vote, :implicit_vote)\n if !word.annotations.nil?\n word.annotations.each do |annotation|\n annotation['pronunciation'] = Utilities::AnnotationUtil.get_pronunciation_by_word(annotation['translation'], lang)\n annotation['audio_urls'] = Utilities::LearningUtil.get_audio_urls(annotation['pronunciation'], lang)\n annotation['more_url'] = Utilities::LearningUtil.get_more_url(annotation['translation'], lang)\n annotation['weighted_vote'] = Utilities::LearningUtil.get_weighted_vote(annotation['vote'], annotation['implicit_vote'], 'human')\n end\n end\n end\n end",
"def index\n @featureds = Featured.all\n end",
"def get_from_digg\n route = 'http://digg.com/api/news/popular.json'\n raw_response = RestClient.get route\n response = JSON.load raw_response\n response[\"data\"][\"feed\"].map do |story|\n categories = []\n story[\"content\"][\"tags\"].map do |tags|\n categories.push(tags[\"display\"]) # Push the 'tags' for each Digg article to an array.\n end\n category_string = categories.join(\", \") # Make a string for each story's category array for Digg.\n story_hash = {\n title: story[\"content\"][\"title\"],\n score: story[\"digg_score\"],\n category: category_string, # There are multiple categories so you're going to have to use .join to get all the different categories to be part of the array.\n author: story[\"content\"][\"author\"]\n }\n end\nend",
"def retrieve_data\n # Define the url\n url = 'http://www.abc.net.au/radionational/feed/3771046/rss.xml'\n\n # Open the url and parse the rss feed\n open(url) do |rss|\n # Start parsing\n feed = RSS::Parser.parse(rss, false)\n\n # Iterate each item and scrape information\n feed.items.each do |item|\n # If the title of thie article matches the title of the last saved article,\n # stop scraping to avoid from saving duplicates in database\n break if !@last_title.nil? && @last_title.eql?(item.title.to_s)\n\n # If thie article is already stored then ignore\n next if Article.find_by(title: item.title.to_s)\n\n # Get the author\n regex_author = /<dc:creator>(.*)<\\/dc:creator>/\n regex_author.match(item.to_s)\n author = Regexp.last_match(1)\n\n author = nil if author.eql? ''\n\n # Get categories values\n regex_category = /<category>(.*)<\\/category>/\n\n categories = []\n item.categories.each do |category|\n regex_category.match(category.to_s)\n categories.push(Regexp.last_match(1))\n end\n\n # Make a template dictionary to put @articles\n temp = {\n author: author,\n title: item.title,\n summary: item.description.to_s,\n image: nil,\n date_time: DateTime.parse(item.pubDate.to_s),\n link: item.link,\n categories: categories.join(',')\n }\n\n # Put the object into articles array\n @articles << temp\n end\n end\n end",
"def table_data\n @building_groups.reduce([]) do |table, bg|\n table << energy_row(bg)\n end\n end",
"def get_sighting_records(db)\r\n\r\n sighting_records = db.query(\"select * from sighting_details order by id\")\r\n\r\n return sighting_records.to_a\r\n\r\nend",
"def download_raw_data\n sql = \"select \"\n if self.has_regions?\n sql << \"`region`,\"\n end\n sql << \" `district_id`,\"\n if self.has_district_names?\n sql << \"`district_name`,\"\n end\n if self.is_local_majoritarian?\n sql << \"`major_district_id`, \"\n end\n\n sql << \"`precinct_id`,\n `num_possible_voters`,\n `num_special_voters`,\n `num_at_12`,\n `num_at_17`,\n `num_votes`,\n `num_ballots`,\n `num_invalid_votes`,\n `num_valid_votes`,\n `logic_check_fail`,\n `logic_check_difference`,\n `more_ballots_than_votes_flag`,\n `more_ballots_than_votes`,\n `more_votes_than_ballots_flag`,\n `more_votes_than_ballots`,\n `supplemental_documents_flag`,\n `supplemental_document_count`,\n `amendment_flag`,\n `explanatory_note_flag`,\n `is_annulled`, \"\n\n parties = Party.hash_for_analysis(self.id, true)\n if parties.present?\n party_sql = []\n parties.each do |party|\n party_sql << \"`#{party[:id]} - #{party[:name]}`\"\n end\n end\n sql << party_sql.join(', ')\n sql << \" from `#{@@analysis_db}`.`#{self.analysis_table_name} - raw`\n order by district_id, precinct_id \"\n results = @@client.exec_query(sql)\n\n if results.present?\n csv_data = CSV.generate(col_sep: ',', force_quotes: true) do |csv|\n # add header\n csv << results.columns\n\n # data\n # - each row is a hash so just need to get values\n results.each do |row|\n csv << row.values\n end\n end\n end\n\n return csv_data\n end",
"def fetch_articles(url)\n req = open(url)\n response_body = req.read\n articles_json = JSON.parse(response_body)\n articles_array = articles_json[\"articles\"]\n last_articles = []\n articles_array.each do |a|\n article = Article.find_by(title:a[\"title\"])\n unless article #check if article is already in the database\n author = a[\"author\"].blank? ? a[\"source\"][\"name\"] : a[\"author\"]\n article = Article.new(title:a[\"title\"],author: author,source:a[\"source\"][\"name\"],url:a[\"url\"],date:a[\"publishedAt\"],content:a[\"content\"] || \"no content available\",image:a[\"urlToImage\"],description:a[\"description\"])\n article.publication_list.add(a[\"source\"][\"id\"])\n # extractor = Phrasie::Extractor.new\n # tagging = extractor.phrases(a[\"content\"],occur:1)\n # tags = tagging.each{|p|p[0]}\n # article.theme_list.add(tags)\n article.save!\n end\n end\nend",
"def index\n @g_anewbies = GAnewbie.all\n end",
"def index\n @geo_data = GeoDatum.all\n end",
"def index\n my_tenant_id = (current_user.role == 'admin' ? current_user.tenant_id : nil)\n @all_stats = Stats.new\n @seven_day_stats = Stats.new(tenant_id: my_tenant_id, since: (Time.new - 7.days))\n @resources = build_table_query\n # If no records were found and a search parameter was specified, requery with\n # a ful text search to find partial word matches\n @resources = build_table_query(true) if @resources.empty? && params[:q].present? && params[:q].length > 4\n @publications = InternalDatum.where(data_type: 'publicationName').order(:value).pluck(:value).uniq\n respond_to do |format|\n format.html\n format.csv\n end\n end",
"def set_article_data(hostname, uri, startdate, enddate) \n\t\turl = 'https://' + hostname + uri\n\t\tarticle = Article.find_by(article_url: url)\n\t\tstart_date = startdate.to_date.beginning_of_day \n\t\tend_date = enddate.to_date.end_of_day\n\t\t\n\t\tarticleArr = Array.new\n\n\t\tif article\n\t\t\tid = article.id\n\t\t\tclickCount = article.clicks.where(:created_at => start_date..end_date).count\n\t\telse\n\t\t\tid = 0\n\t\t\tclickCount = 0\n\t\tend\n\n\t\tarticleArr = [id, clickCount]\n\n\t\treturn articleArr\n\n\tend",
"def agency_content\n content = {}\n if active_agency.site_texts\n active_agency.site_texts.each do |site_text|\n content.merge!(site_text.name.to_sym => site_text.value)\n end\n end\n return content\n end",
"def get_data()\n db = read_db() # open database for querying\n db.results_as_hash = true # format query results as a hash so columns available as keys\n all_records = db.execute('select * from tokens')\n return all_records # get hash of arrays\nend",
"def parse_table(doc)\n rows = doc.css('table#listUsersTable tbody tr')\n data = rows.map do |row|\n id, name, details = row.search('td')\n url = details.search('a').first['href']\n {id: id.content, name: name.content, registry_url: BASE_URL + url}\n end\nend",
"def parse_table(doc)\n rows = doc.css('table#listUsersTable tbody tr')\n data = rows.map do |row|\n id, name, details = row.search('td')\n url = details.search('a').first['href']\n {id: id.content, name: name.content, registry_url: BASE_URL + url}\n end\nend",
"def data_tables\n @data_tables ||= @profile_page.search('table#yfncsumtab').to_s.gsub(\"\\n\",'')\n end"
] |
[
"0.6470874",
"0.6367738",
"0.63142264",
"0.6152746",
"0.5951434",
"0.56811464",
"0.56811464",
"0.5666134",
"0.5623902",
"0.5609545",
"0.55517805",
"0.5516633",
"0.54986185",
"0.54972523",
"0.54873294",
"0.5440363",
"0.54317963",
"0.54102975",
"0.54008114",
"0.5400532",
"0.53904945",
"0.53804433",
"0.5378644",
"0.5334232",
"0.531749",
"0.53137",
"0.5312057",
"0.5303439",
"0.5302245",
"0.53013915",
"0.52779156",
"0.52578425",
"0.5254548",
"0.52432275",
"0.5241315",
"0.5225146",
"0.5225146",
"0.5216323",
"0.52157277",
"0.5213863",
"0.521137",
"0.5205224",
"0.5201961",
"0.51978934",
"0.51969755",
"0.51882565",
"0.5188008",
"0.518378",
"0.51808816",
"0.5179901",
"0.517987",
"0.5174624",
"0.51677644",
"0.5166606",
"0.5166049",
"0.5166049",
"0.5166049",
"0.5166049",
"0.51624924",
"0.5157544",
"0.5155782",
"0.5150162",
"0.51472336",
"0.51430905",
"0.5141095",
"0.5141095",
"0.5141095",
"0.5141095",
"0.51386136",
"0.51231045",
"0.5118931",
"0.51152533",
"0.5114087",
"0.51069975",
"0.51031464",
"0.50977725",
"0.50911623",
"0.5088273",
"0.50868076",
"0.50864744",
"0.5084434",
"0.5076384",
"0.50718343",
"0.50714254",
"0.5070258",
"0.50701",
"0.50700545",
"0.50657755",
"0.50630754",
"0.50626516",
"0.5061751",
"0.506096",
"0.50570285",
"0.5056361",
"0.5049284",
"0.5043726",
"0.50426626",
"0.5042365",
"0.5042365",
"0.5038919"
] |
0.6058423
|
4
|
customize rack app for testing, if block is given, reverts to default rack app after testing is done
|
def set_app!(options = {})
old_app = self.app
self.app = Rack::Builder.app do
use Rack::Session::Cookie, secret: 'ultra_strong_secret'
use OmniAuth::Strategies::Zendesk, options
run lambda{|env| [404, {'env' => env}, ["HELLO!"]]}
end
if block_given?
yield
self.app = old_app
end
self.app
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def mock_app(base=Sinatra::Base, &block)\n @app = Sinatra.new(base, &block)\n end",
"def mock_app(base=Sinatra::Base, &block)\n @app = Sinatra.new(base, &block)\n end",
"def mock_app(base=Sinatra::Base, &block)\n @app = Sinatra.new(base, &block)\n end",
"def mock_app(base=Sinatra::Base, &block)\n @app = Sinatra.new(base, &block)\n end",
"def mock_app(base=Padrino::Application, &block)\n @app = Sinatra.new(base, &block)\n end",
"def mock_app(base=Padrino::Application, &block)\n @app = Sinatra.new(base, &block)\n end",
"def mock_app(base=Padrino::Application, &block)\n @app = Sinatra.new(base, &block)\n end",
"def mock_app(base=Padrino::Application, &block)\n @app = Sinatra.new(base, &block)\n end",
"def mock_app(&block)\n path = default_views_path\n @app = Renee::Core.new(&block).setup {\n views_path path\n }\n end",
"def app_or_dsl_block\n @app_to_run || Rack::Builder.new(&@dsl_block)\n end",
"def set_app!(tent_options = {})\n old_app = self.app\n self.app = Rack::Builder.app do\n use OmniAuth::Strategies::Tent, tent_options\n run lambda{|env| [404, {'env' => env}, [\"HELLO!\"]]}\n end\n if block_given?\n yield\n self.app = old_app\n end\n self.app\n end",
"def setup_rack(app = nil)\n app ||= block if block_given?\n Rack::Builder.new do\n use SessionApp\n use Warden::Manager\n run app\n end\nend",
"def rackup(app); return @@rack.call(app); end",
"def run_default_server(app, port, &block)\n begin\n require 'rack/handler/thin'\n Thin::Logging.silent = true\n Rack::Handler::Thin.run(app, :Port => port, &block)\n rescue LoadError\n require 'rack/handler/webrick'\n Rack::Handler::WEBrick.run(app, :Port => port, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0), &block)\n end\n end",
"def rack_app_route_block(block)\n block\n end",
"def rack_app_route_block(block)\n block\n end",
"def configure_apps(&block)\n return unless block_given?\n global_configurations << block\n end",
"def build(app, &block)\n app ||= block\n raise \"MiddlewareStack#build requires an app\" unless app\n Skylight::Core::Probes::Middleware::Probe.add_instrumentation(app, default_name: \"Rack App\", category: \"rack.app\")\n build_without_sk(app)\n end",
"def make_app(&blk)\n handler = Class.new(TestApp)\n handler.class_eval(&blk)\n handler\nend",
"def rack_standard(env)\n @req = Rack::Request.new(env)\n # puts \"here in standard rack handler\"\n @res = Rack::Response.new\n @res.write(\"Hey from a standard rack app\")\n @res.finish\n end",
"def route(&block)\n @route_block = block\n build_rack_app\n end",
"def mock_app(options)\n builder = Rack::Builder.new\n builder.use Rack::YandexMetrika, options\n builder.run controller\n @app = builder.to_app\n end",
"def rack_app\n return unless router\n\n @rack_app ||= router.to_rack_app\n end",
"def run_app(app, env)\n setup_rack(app).call(env)\nend",
"def rack_app\n opts = { host: @host.host,\n scheme: @host.scheme,\n force_ssl: @host.scheme == 'https' }\n\n Lotus::Router.new(opts).tap do |router|\n router.get(INDEX_PATH, to: Coach::Handler.new(Routes::Index))\n router.get(GC_CALLBACK_PATH, to: build_gc_callback_handler)\n router.post(SLACK_MESSAGES_PATH, to: build_slack_messages_handler)\n router.get(ADD_CUSTOMER_PATH, to: build_add_customer_handler)\n router.get(ADD_CUSTOMER_SUCCESS_PATH, to: build_add_customer_success_handler)\n router.post(GC_WEBHOOKS_PATH, to: build_gc_webhooks_handler)\n end\n end",
"def guess_app\n app = if ::File.exists?(::File.join(::File.dirname(@options[:wdir]), \"config/environment.rb\"))\n require 'config/environment'\n Rack::Builder.new do\n use Rails::Rack::Static\n run ActionController::Dispatcher.new\n end\n else\n raise Exception, \"No rackup file nore rails environement file found. Please supply one of them\"\n end\n end",
"def app\n @rack_app ||= Rack::Builder.parse_file('config.ru').first\nend",
"def app\n @rack_app || fail(\"Missing @rack_app\")\n end",
"def rack_app\n ctx = @context\n proc do |env|\n request_ctx = ctx.child\n request_ctx.templates = {}\n\n # If there are trailing slashes in path, don't dispatch\n if match = env['PATH_INFO'].match(/^(.+)(?<!\\$)\\/$/)\n\n # Remove trailing slash in the path and redirect\n loc = match[1]\n loc << \"?#{env['QUERY_STRING']}\" unless env['QUERY_STRING'].empty?\n [301, {'Location' => loc, 'Content-Type' => 'text/html; charset=utf-8'}, []]\n\n else\n\n # Dispatch controller chain for the current path\n request_ctx.env = env\n result = ::Tanuki::ControllerBehavior.dispatch(request_ctx, ctx.i18n ? ::Tanuki::I18n : ctx.root_page,\n Rack::Utils.unescape(env['PATH_INFO']).force_encoding('UTF-8'))\n\n # Handle dispatch result\n case result[:type]\n when :redirect then\n [302, {'Location' => result[:location], 'Content-Type' => 'text/html; charset=utf-8'}, []]\n when :page then\n [200, {'Content-Type' => 'text/html; charset=utf-8'}, build_body(result[:controller], request_ctx)]\n else\n [404, {'Content-Type' => 'text/html; charset=utf-8'}, build_body(result[:controller], request_ctx)]\n end\n\n end # if\n\n end\n end",
"def rack(name, *parents, &block)\n\t\t\t\tenvironment = merge(name, :rack, *parents, &block)\n\t\t\t\t\n\t\t\t\tenvironment[:root] = @root\n\t\t\t\tenvironment[:authority] = name\n\t\t\t\t\n\t\t\t\t@configuration.add(environment.flatten)\n\t\t\tend",
"def app\n # Load the application defined in config.ru\n Rack::Builder.parse_file(\"config.ru\").first\nend",
"def use(*args, &block)\n @middleware << [args, block].freeze\n build_rack_app\n end",
"def app\n # Load the application defined in config.ru\n Rack::Builder.parse_file('config.ru').first\nend",
"def app\n # Load the application defined in config.ru\n Rack::Builder.parse_file('config.ru').first\nend",
"def app\n # Load the application defined in config.ru\n Rack::Builder.parse_file('config.ru').first\nend",
"def app\n eval \"Rack::Builder.new {( \" + File.read(File.dirname(__FILE__) + '/../config.ru') + \"\\n )}\"\nend",
"def rack_standard(env)\n [200, {\"Content-Type\" => \"text/plain\"}, [\"Hey from a standard rack app\"]]\n # Just another way to do the above, can get more request info, ...\n # @req = Rack::Request.new(env)\n # @res = Rack::Response.new\n # @res.write(\"Hey from a standard rack app\")\n # @res.finish\n end",
"def erb_app(view, options = {})\n options = {:layout => '<%= yield %>', :url => '/tests' }.merge(options)\n get options[:url], :view => view, :layout => options[:layout], :engine => :erb \n end",
"def rack_builder; end",
"def app\n # Load the application defined in config.ru\n Rack::Builder.parse_file('config.ru').first\n end",
"def app\n @app ||= Rack::Builder.parse_file(File.join(OpenRecipeApp.root,\"config.ru\"))[0]\n end",
"def build_rack_app\n super if @build_app\n end",
"def rackup(path); end",
"def app\n\t\tSinatra::Application #where computer is finding all the tests?\n\tend",
"def app # def app is something that Rack::Test is looking for\n TaskManager\n end",
"def run\n check_args\n Application::InstanceMethods.instance_method(:sandbox).bind(@app).call.\n instance_eval(&@block)\n end",
"def app\n Sinatra::Application # It is must and tell rspec that test it running is for sinatra\nend",
"def to_app\n Rack::Builder.new do\n Scrapple.middleware_stack.middleware.each do |ware|\n use ware[0], *ware[1], &ware[2]\n end\n\n run Scrapple.middleware_stack.endpoint\n end \n end",
"def initialize rack_app=nil, options={}\n if Hash === rack_app\n options = rack_app\n @rack_app = nil\n else\n @rack_app = rack_app\n end\n\n @options = {\n :config_dir => self.class.config_dir,\n :public_dir => self.class.public_dir,\n :assets_dir => self.class.assets_dir,\n :asset_paths => self.class.asset_paths,\n :layouts_dir => self.class.layouts_dir,\n :views_dir => self.class.views_dir,\n :config => self.class.config\n }.merge(self.class.options).merge(options)\n\n @options[:config] = self.class.make_config(@options) if\n @options[:environment] != @options[:config].environment ||\n @options[:config_dir] != @options[:config].dir ||\n @options[:config_reload] != @options[:config].ttl\n\n @override_options = options if autoreload\n\n validate_all_controllers!\n\n @app = self\n @stack = build_app Rack::Builder.new\n\n setup_asset_pipeline\n end",
"def app\n path = File.expand_path('../config.ru', File.dirname(__FILE__))\n @app ||= Rack::Builder.parse_file(path).first\n end",
"def respond_with(status=200, headers={}, body=['Hello World'], &bk)\n @app = FakeApp.new(status, headers, body, bk)\n end",
"def base_rack_app_callable(new_api=true)\n if new_api\n lambda{|env| new(env)._roda_handle_main_route}\n else\n block = @rack_app_route_block\n lambda{|env| new(env).call(&block)}\n end\n end",
"def initialize(options = {}, &blk)\n options ||= {}\n options[:type] = :application\n init(options, &blk)\n end",
"def run\n configure_middleware(rack_builder = Rack::Builder.new)\n rack_builder.run(rack_app)\n\n # Choose and start a Rack handler\n @context.running_server = available_server\n @context.running_server.run rack_builder.to_app, :Host => @context.host, :Port => @context.port do |server|\n [:INT, :TERM].each {|sig| trap(sig) { (server.respond_to? :stop!) ? server.stop! : server.stop } }\n puts \"A#{'n' if @environment =~ /\\A[aeiou]/} #{@environment} Tanuki appears! Press Ctrl-C to set it free.\",\n \"You used #{@context.running_server.name.gsub(/.*::/, '')} at #{@context.host}:#{@context.port}.\"\n end\n end",
"def as_rack_app\n #routes = Rack::Mount::RouteSet.new_without_optimizations do |set|\n routes = Rack::Mount::RouteSet.new do |set|\n @set = set\n self.add_routes\n add_route %r{^.*$}, :action => \"render_static\"\n end\n return routes\n end",
"def start( configuration = {}, &block )\n this = self\n debug = !!configuration.fetch(:debug, true)\n root = configuration.fetch(:root, \"/\" )\n type = configuration.fetch(:type, debug ? \"webrick\" : \"fcgi\")\n port = configuration.fetch(:port, debug ? 8989 : nil )\n host = configuration.fetch(:host, debug ? \"localhost\" : nil )\n \n desc = Rack::Builder.new do\n use Rack::CommonLogger\n use Rack::ContentLength\n if debug then\n use Rack::ShowExceptions\n end\n \n instance_eval(&block) if block\n\n map root do\n run this\n end\n end\n \n Rack::Server.start(:app => desc.to_app, :server => type, :Port => port, :Host => host)\n end",
"def setup\n @requester = Rack::MockRequest.new(SampleApp)\n end",
"def default(app)\n @default_app = app\n end",
"def use(*args, &block)\n @middleware.insert(@position, [args, block])\n @app.send(:build_rack_app)\n @position += 1\n nil\n end",
"def driver\n start_app_if_needed\n @driver\n end",
"def respond_with(status=200, headers={}, body=['Hello World'], &bk)\n @app = FakeApp.new(status, headers, body, bk)\n end",
"def start_app\nend",
"def stack\n # map your apps here...\n map \"/hello\" do\n run HelloWorld.new\n end\n\n map \"/lobster\" do\n require 'rack/lobster'\n use Rack::ShowExceptions\n use Rack::Auth::Basic, \"Lobster 2.0\" do |username, password|\n 'secret' == password\n end\n run Rack::Lobster.new \n end\n\nend",
"def with_primary_app_server(&block)\n with_env('HOSTS',primary_app_server.to_s) { yield }\n end",
"def default_configuration!\n # Overwriting Sinatra defaults\n set :app_file, caller_files.first || $0 # Assume app file is first caller\n set :environment, Padrino.env\n set :raise_errors, true if development?\n set :logging, false # !test?\n set :sessions, true\n set :public, Proc.new { Padrino.root('public', self.uri_root) }\n # Padrino specific\n set :uri_root, \"/\"\n set :reload, development?\n set :app_name, self.to_s.underscore.to_sym\n set :default_builder, 'StandardFormBuilder'\n set :flash, defined?(Rack::Flash)\n set :authentication, false\n # Padrino locale\n set :locale_path, Proc.new { Dir[File.join(self.root, \"/locale/**/*.{rb,yml}\")] }\n set :auto_locale, false\n # Plugin specific\n set :padrino_mailer, defined?(Padrino::Mailer)\n set :padrino_helpers, defined?(Padrino::Helpers)\n end",
"def application(label = nil, &block)\n new_application = Hsquare::Application.new(label: label)\n\n @default_application ||= new_application\n applications.push(new_application) unless applications.include?(new_application)\n\n yield new_application\n end",
"def app\n @app || make_app\nend",
"def inside_dummy_app\n Bundler.with_clean_env do\n FileUtils.cd(dummy_app_path) do\n yield\n end\n end\n end",
"def run_for_all(&block)\n the_app = node[:zz][:app_name]\n the_role = node[:zz][:deploy_role]\n rails_env = node[:zz][:group_config][:rails_env]\n block.call(the_app.to_sym, the_role.to_sym, rails_env.to_sym)\n end",
"def configure(&block)\n site.configure &block\n end",
"def with_app(params={}, &block)\n params.merge!('name' => Heroku::QC::Autoscale.app) unless params.key?(\"name\")\n heroku = Heroku::Scaler.client\n \n begin\n data = heroku.post_app(params).body\n @name = data['name']\n ready = false\n until ready\n ready = heroku.request(:method => :put, :path => \"/apps/#{@name}/status\").status == 201\n end\n yield(data)\n ensure\n heroku.delete_app(@name) rescue nil\n end\nend",
"def boot!\n adjust_load_path\n adjust_gem_path\n ENV['RACK_ENV'] = rack_env\n change_working_directory\n export_global_settings\n load_settings_from_init_rb\n set_relative_url_root\n run_boot_hooks\n self\n end",
"def run(comp = nil)\n if comp.nil?\n container = s2app.create\n if container.component_def?(Seasar::Rack::CGI::Page)\n app = container.get(Seasar::Rack::CGI::Page)\n else\n app = Seasar::Rack::CGI::Page.new\n end\n elsif comp.is_a?(Class) || comp.is_a?(Symbol) || comp.is_a?(String)\n app = s2app.create.get(comp)\n else\n app = comp\n end\n if block_given?\n app = yield(app)\n elsif Seasar::Rack::CGI::Page.rack?\n app = Seasar::Rack::CGI::Page.rackup(app)\n end\n begin\n ::Rack::Handler::CGI.run(app)\n rescue => e\n if Seasar::Rack::CGI::Page.fatal?\n Seasar::Rack::CGI::Page.fatal.call(e, app)\n else\n s2logger.fatal(self) {\"#{e.message} #{e.backtrace}\"}\n end\n end\n\n begin\n container.destroy if container\n rescue => e\n s2logger.error(self) {\"destroy of s2container failed. #{e.message} #{e.backtrace}\"}\n end\n end",
"def initialize(default_app = nil, &block)\n @use, @map, @run = [], nil, default_app\n instance_eval(&block) if block_given?\n end",
"def configures(*envs, &b)\n return if @app.reloading?\n yield self if envs.empty? || envs.include?(@app.options[:env])\n end",
"def app; @app; end",
"def use *args, &block\n @app_builder.use(*args, &block)\n end",
"def setup_server\n ENV[\"RAILS_ENV\"] = \"test\"\n require \"rails\"\n fork do\n exec \"cd test/rails#{Rails::VERSION::MAJOR}_dummy && COVERBAND_TEST=test bundle exec rackup config.ru -p 9999 --pid /tmp/testrack.pid\"\n end\n end",
"def start_server\n if ENV['RACK_ENV'] == 'production'\n run APP\n else\n Rack::Server.start(\n app: APP,\n Port: $PORT\n )\n end\nend",
"def handle(app)\n app\n end",
"def stack(options = {}, &block)\n @stack ||= if block_given?\n Faraday::RackBuilder.new(&block)\n else\n Faraday::RackBuilder.new(&default_middleware(options))\n end\n end",
"def configure(&block); end",
"def configure(&block); end",
"def app\n @app ||= Rack::Cascade.new([self, Rack::File.new(path)])\n end",
"def initialize(&block)\n raise ArgumentError, \"block required\" unless block\n @actions, @with, @layouts, @views, @helpers = [], [], {}, {}, self\n @app = method(:_call)\n @root = File.dirname(eval(\"__FILE__\", block.binding))\n instance_eval(&block)\n end",
"def addApplication(uri, block)\n return s(:iter, \n s(:call, \n s(:lvar, :node), \n :addApplication, \n s(:arglist, s(:str, uri))), \n s(:lasgn, :app), block)\n end",
"def run_app_tests\n end",
"def call(env)\n env['crossbeams.appname'] = @appname\n env['crossbeams.banner'] = @template if @template\n @app.call(env)\n end",
"def app_configured?; end",
"def haml_app(view, options = {}) \n options = {:layout => '= yield ', :url => '/tests' }.merge(options)\n get options[:url], :view => view, :layout => options[:layout], :engine => :haml \n end",
"def test? ; @app.options[:env] == :test ; end",
"def run\n reconfigure\n setup_application\n run_application\n end",
"def build_rack_app\n app = base_rack_app_callable(use_new_dispatch_api?)\n\n @middleware.reverse_each do |args, bl|\n mid, *args = args\n app = mid.new(app, *args, &bl)\n app.freeze if opts[:freeze_middleware]\n end\n\n @app = app\n end",
"def run opts = {}\n boot!\n\n handler = opts.delete(:server)\n (handler && Rack::Handler.const_defined?(handler)) || (handler = HTTP__DEFAULT_SERVER)\n\n port = opts.delete(:port)\n opts[:Port] ||= port || HTTP__DEFAULT_PORT\n\n host = opts.delete(:host) || opts.delete(:bind)\n opts[:Host] = host if host\n\n $stderr.puts \"\\n--- Starting Espresso for %s on %s port backed by %s server ---\\n\\n\" % [\n environment, opts[:Port], handler\n ]\n Rack::Handler.const_get(handler).run app, opts do |server|\n %w[INT TERM].each do |sig|\n Signal.trap(sig) do\n $stderr.puts \"\\n--- Stopping Espresso... ---\\n\\n\"\n server.respond_to?(:stop!) ? server.stop! : server.stop\n end\n end\n server.threaded = opts[:threaded] if server.respond_to? :threaded=\n yield server if block_given?\n end\n end",
"def start app, &block\n # run available process types\n app[\"ps\"].each do |type,ps|\n ps[\"scale\"].times do |index|\n host = GV::Valley::Runner.random_service \n app[\"ps\"][type][\"containers\"] << host.start(app[\"name\"], type, index, &block)\n end\n end\n end",
"def setup\n Sinatra::Base.set :environment, :test\n end",
"def app\n @app || configure_middleware!\n end",
"def override_application_system_test\n return unless config.dig(\"test_suite\") == \"minitest\"\n template \"templates/application_system_test.tt\", \"test/application_system_test_case.rb\", force: true\n end",
"def configure &block\n\t\tinstance_eval &block\n\tend",
"def call!(env)\n before_call(env)\n\n begin\n response = @app.call(env)\n rescue Exception => ex # rubocop:disable Lint/RescueException\n notify_airbrake(ex)\n raise ex\n end\n\n exception = framework_exception(env)\n notify_airbrake(exception) if exception\n\n response\n ensure\n # Clear routes for the next request.\n RequestStore.clear\n end"
] |
[
"0.7283195",
"0.7268397",
"0.7268397",
"0.7268397",
"0.70114857",
"0.70114857",
"0.70114857",
"0.70114857",
"0.6834816",
"0.6798196",
"0.6750964",
"0.66858554",
"0.65658593",
"0.6479456",
"0.6439406",
"0.6439406",
"0.6385005",
"0.6344517",
"0.63343036",
"0.623196",
"0.62249243",
"0.6182238",
"0.61772186",
"0.6140645",
"0.61349064",
"0.6074194",
"0.6053839",
"0.59848344",
"0.597081",
"0.59693325",
"0.5966734",
"0.5962118",
"0.59601927",
"0.59601927",
"0.5951559",
"0.59384435",
"0.590931",
"0.5843002",
"0.5834004",
"0.5792237",
"0.57778007",
"0.5776614",
"0.57570064",
"0.57527566",
"0.5732661",
"0.56880903",
"0.5677642",
"0.56773746",
"0.56714284",
"0.5641981",
"0.562943",
"0.56266046",
"0.56183904",
"0.56099117",
"0.55821353",
"0.557475",
"0.55709285",
"0.556864",
"0.5546212",
"0.5539723",
"0.55291575",
"0.55196476",
"0.550315",
"0.54794556",
"0.54790026",
"0.5456507",
"0.54434836",
"0.54432553",
"0.5441647",
"0.5436296",
"0.54284203",
"0.540193",
"0.53860784",
"0.5380821",
"0.5369074",
"0.5359309",
"0.53562635",
"0.5343007",
"0.53330845",
"0.53280556",
"0.5320659",
"0.5312339",
"0.5312339",
"0.5305814",
"0.5303988",
"0.53016",
"0.5290805",
"0.52880615",
"0.5283225",
"0.5279922",
"0.527864",
"0.52697265",
"0.5263676",
"0.5263001",
"0.52526885",
"0.5246239",
"0.5242253",
"0.5240013",
"0.5235911",
"0.5203408"
] |
0.6906908
|
8
|
Check the home page after login has some links
|
def test_links_exist
login_as_valid_user
puts "****"+session[:login].to_s
assert_tag :tag => "a",
:parent => { :tag => "li"},
:descendant => {
:child => /Project Management/ }
logout
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def check_logged_in_home\n if current_user != nil\n redirect_to user_path(current_user)\n end\n end",
"def home_check\n if logged_in? && @current_user.admin?\n puts @current_user\n redirect_to account_url(@current_user.id)\n return\n elsif logged_in?\n redirect_to cases_path\n else\n redirect_to page_path(\"home\")\n return\n end\n end",
"def check_authentication\n unless logged_in?\n flash[:warning] = \"You must be logged in to view the requested page.\"\n request.env[\"HTTP_REFERER\"] ? (redirect_to :back) : (redirect_to :action => \"index\", :controller => \"site\")\n return false\n end\n end",
"def check_for_login\n #if not, back home with you!\n redirect_to root_path unless @current_user.present?\n end",
"def home\n redirect_to signin_path() and return if ( @current_user.nil? )\n end",
"def home_page\n if current_user.guest?\n user_signup_url\n elsif current_user.administrator?\n admin_films_path\n elsif current_user.judge?\n judging_categories_path\n else\n obejct_url current_user\n end\n end",
"def check_redirect_if_user_login\n \t\tif signed_in?\n \t\t\tflash[:alert] = \"You are already login.\"\n \t\t\tredirect_to homes_path and return \n \t\tend\n \tend",
"def redirect_to_homepage?\n false\n end",
"def redirect_to_homepage?\n @page.homepage?\n end",
"def redirect_to_homepage?\n false\n end",
"def index\r\n # State machine stuff\r\n current_user.came_home\r\n eval current_user.redirect, binding()\r\n return\r\n end",
"def home\n if user_signed_in?\n current_user.update_attribute(:login_status, true) if current_user # update login status for logged in user\n if !current_user.is_super_admin? && current_user.sign_in_count == 1 && current_user.created_by != 0 #User records which are created by super admin or dept admin has to change the password while they are logged in first time\n redirect_to :controller => \"registrations\", :action => \"privacy_setting\"\n else\n redirect_to :controller => \"dashboard\", :action => \"index\"\n end\n else\n redirect_to new_user_session_path\n end\n end",
"def is_current_page_home?\n puts \"url_home\"\n puts request.url\n if request.url == \"http://127.0.0.1:3000/\" #home url\n @home = true\n end\n end",
"def check_login\n redirect_to root_url, alert: \"You must login to view this page.\" if current_user.nil?\n end",
"def check_login!\n u = check_and_get_user\n redirect to('/signin.html') unless u\n u\n end",
"def loginpage\n end",
"def check_logged_in?\n if !logged_in?\n redirect_to root_path\n end\n end",
"def login_checkpoint\n redirect to '/' if !logged_in?\n end",
"def require_login\n if request.fullpath == \"/about\"\n #Let everybody (even not logged in users) see the about page\n else\n unless current_user\n redirect_to root_url\n end\n end\n end",
"def verify_logged_in\n redirect_to root_path unless logged_in?\n end",
"def index\n redirect_to(:action => 'login') unless logged_in? \n end",
"def home\n if user_signed_in?\n\n if current_user.connection_valid?\n @favorites = current_user.favorites\n @queries = current_user.queries\n @keytech_username = current_user.keytech_username\n # Load Dashboard async in javascript\n render 'home'\n else\n render 'invalid_login'\n end\n else\n\n # User is not signed in in platform\n render 'landing_page'\n end\n end",
"def home\r\n\r\n redirect_to(@current_user.home_page)\r\n end",
"def logged_in?\n !!link_to_account_detail_page\n end",
"def check_login\n unless is_logged_in?\n # all cool\n redirect_to new_session_path\n end\n end",
"def verify_landing_page\n @higgs.page_title_present?('Puppet Enterprise Installer')\n @higgs.link_present?('email the CEO.')\n @higgs.select_link(\"Let's get started\")\n @higgs.page_title_present?('Puppet Enterprise Installer - Choose your deployment')\n end",
"def url_home\n\tvisit url_visit\n end",
"def check_login\n if !session[:user_name]\n redirect_to sign_in_path\n end\n end",
"def clean_home_url\n redirect_to(home_page) and return if request.path == '/'\n end",
"def login_page\n end",
"def index\n redirect_to(:action => 'login') #unless logged_in? || User.count > 0\n end",
"def home_link\n if logged_in? \n\t\t\ttext = \"my home\"\n\t\t\tlink = user_path(current_user) \n\t\telse\n\t\t\ttext = \"home\"\n\t\t\tlink = root_path\n\t\tend\n\t\tlink_to_unless_current \"<span>\" + text + \"</span>\", link\n end",
"def on_page_portal?\n return (controller.controller_name == \"home\" and controller.action_name == \"portal\") \n end",
"def links_present\n resend_email_link.visible?\n change_email_link.visible?\n back_to_login_page_link.visible?\n end",
"def check_logged_in\n unless current_user\n redirect_to '/login'\n end\n end",
"def check_login\n user = current_user\n if user.nil?\n if params[:controller] != \"login\"\n session[:previous_url] = request.fullpath\n redirect_to \"/login\"\n return\n end\n else\n if params[:controller] != \"firstlogin\" &&\n params[:controller] != \"login\"\n if user.is_deleted? || !user.is_firstlogged?\n redirect_to \"/login\"\n return\n end\n end\n end\n end",
"def home\n if !view_context.signed_in?\n redirect_to '/'\n end\n end",
"def check_login\n head :forbidden unless self.current_user\n end",
"def redirected_to_login?\n @agent.page.body.match \"#{@piggybank.url_base}/cas/login.php\"\n end",
"def check_existing_home_page\n\t\tif self.home_page?\n\t\t\t@old_home = Page.get_home_page\n\t\t\tunless @old_home.nil? || @old_home == self\n\t\t\t\t@old_home.home_page = false\n\t\t\t\t@old_home.save\n\t\t\tend\n\t\tend\n\t\t\n\tend",
"def requires_login\n unless user_logged_in?\n return redirect_to login_index_path, notice: \"You must login to view that page.\"\n end\n end",
"def check_unlogin\n return unless curr_user\n redirect_to articles_path\n end",
"def check_session\n if session[:user_id].nil?\n session[:return_to] = request.request_uri\n flash[:messgae] = \"Please sign-in or sign-up to access any of these pages.\"\n redirect_to :controller => 'user', :action => 'index'\n return\n end\n end",
"def home_page?\n current_route?('')\n end",
"def home_page?\n controller_name == 'pages' && %w(home location_name).detect {|x| action_name == x} ? true : false\n end",
"def is_home?\n current_page?('/')\n end",
"def authenticate!\n\t #when we solve the require relative problem write the line: unless session[:user_id] && User.where(id: session[:user_id])\n\n\t\tif session[:user_id] && User.where(id: session[:user_id]).exists? #if the user id saved in session does not belong to any user, also direct to general homepage\n\t\t\ttrue\n\t\telse\n\t\t\tsession[:original_request] = request.path_info\n\t\t\tfalse\n\t\tend\nend",
"def index\n if session[:user_id] != nil \n redirect_to '/home'\n end\n end",
"def index\n if session[:user_id] != nil \n redirect_to '/home'\n end\n end",
"def home\n if current_user\n redirect_to '/dashboard'\n else\n render 'home'\n end\n end",
"def check_login_status\n # If user hasn't logged in\n unless logged_in?\n # Show reminder message\n flash[:info] = \"Log in to continue.\"\n\n # Redirect user to login page\n redirect_to login_url\n end\n end",
"def check_redirect(proj)\n visit opening_path(proj)\n assert_text 'You must be logged in to view job openings.'\n assert page.has_css?('title', text: full_title('User Login'), visible: false)\n assert page.has_css?('h1', text: 'User Login')\n end",
"def check_login\n unless logged_in?\n access_denied\n end\n end",
"def check_login\n if !check_authentication\n redirect_to controller: \"account\", action: \"login\"\n end\n end",
"def visit_home_page\n return if already_on_site?\n close_popups\n driver.visit(BASE_URL)\n end",
"def check_signin\n if session[:login_name] == nil\n \tredirect_to sessions_url, notice: 'Sign in, please'\n end\n end",
"def check_signin\n if session[:login_name] == nil\n \tredirect_to sessions_url, notice: 'Sign in, please'\n end\n end",
"def check_signin\n if session[:login_name] == nil\n \tredirect_to sessions_url, notice: 'Sign in, please'\n end\n end",
"def already_logged_in\n\t\t\t#current user is not nil\n\t\t\tif !current_user.nil?\n\t\t\t\tredirect_to root_url\n\t\t\tend\n\t\tend",
"def home\n authenticate!\n end",
"def check_if_logged_in\n redirect_to(new_user_path) if @current_user.nil?\n end",
"def check_if_logged_in\n redirect_to(new_user_path) if @current_user.nil?\n end",
"def user_login\n unless logged_in?\n navigated_location #stores the location that was navigated before login\n flash[:alert]= \"You Must Be Log In Order To Access that Portion of the Site\" \n redirect_to login_path\n end\n end",
"def check_if_already_logged_in\n redirect_to(user_url(current_user)) if logged_in?\n end",
"def redirect_home_if_not_logged_in\n unless logged_in?\n session[:error] = \"You must be signed in to do that.\"\n redirect \"/\"\n end\nend",
"def home\n if !current_user\n redirect_to :new_user_session\n else\n redirect_to '/post/new'\n end\n end",
"def home\n if logged_in?\n redirect_to user_path(current_user) # Redirect to user show page if logged in\n else\n render layout: 'welcome' # Render home view with welcome layout\n end\n end",
"def require_login\n redirect R(:login) unless logged_in?\n end",
"def logged_in?\n page.has_selector? \"a\", text: \"Cerrar sesión\"\nend",
"def pre_shibboleth_login\n url = URI.parse(\"http://academic.sar-data.ccsr.ac.uk/nesstar/?\" + SHIB_LOGIN_URL + \"/session/shibboleth\")\n res = Net::HTTP.get url\n doc = Nokogiri::HTML(res)\n links = doc.css('a').map { |link| link['href'] }\n shib_links = links.reject{|entry| entry.rindex('shibboleth') == nil}\n shib_link = shib_links[0]\n redirect_to shib_link\n end",
"def index\n if logged_in?\n redirect_to :controller => 'account', :action => 'mypage'\n else\n if User.count > 0\n redirect_to :controller => 'account', :action => 'signup'\n else\n redirect_to :controller => 'recommend', :action => 'question'\n end\n end\n end",
"def require_login\n redirect_to login_path if !user_logged?\n end",
"def index\n redirect_to disabled_path\n # unless logged_in?\n # redirect_to tour_path\n # else\n # @current_item = \"my_hsa\"\n # end\n end",
"def check_login_info\n # @signed_up = false\n # something\n # @signed_up = true\n \n # get \"/user_sign_in/\"\n if (User.find_by_name \"#{params[:un]}\")\n redirect_to(\"/user/:#{params[:un]}\")\n else\n redirect_to(\"/sign_up/\")\n end \n end",
"def login_incomplete_user\n\t\tincomplete_user = IncompleteUser.find_by(email: params[:homepage][:email].downcase)\n\t\tif incomplete_user && incomplete_user.authenticate(params[:homepage][:password])\n\t\t\tgo_to_complete_registration(incomplete_user)\n\t\t\ttrue\n\t\telsif incomplete_user # incorrect password\n\t\t\tflash.now[:danger] = ERROR_MESSAGE\n\t\t\trender 'index'\n\t\t\ttrue\n\t\tend\n\tend",
"def login_required\n if logged_in?\n return true\n else\n redirect_to(:controller => '/user', :action => 'index')\n return false\n end\n end",
"def check_authentication\n redirect_to root_path, notice: \"You don't have access permission for this page!\" unless current_user.has_role?(:admin)\n end",
"def require_login\n redirect_to root_path unless logged_in?\n end",
"def require_login\n redirect_to root_path unless logged_in?\n end",
"def index\n redirect_to(:action => 'signup') unless logged_in? || User.count > 0\n end",
"def index\n redirect_to(:action => 'signup') unless logged_in? || User.count > 0\n end",
"def index\n redirect_to(:action => 'signup') unless logged_in? || User.count > 0\n end",
"def index\n redirect_to(:action => 'signup') unless logged_in? or User.count > 0\n end",
"def index\n redirect_to(:action => 'signup') unless logged_in? or User.count > 0\n end",
"def test_home\n @current_test_name = \"Arch - Testing Home Page\"\n each_driver do\n each_view_redirects do\n common_elements?\n end\n end\n end",
"def landing_page\n if current_user\n redirect_to actions_path(current_user[:id])\n end\n end",
"def index\n #@page = Page.find_by_slug('home') || Page.first(:conditions => {:root => true})\n #render '/pages/show'\n if cookies[:first_time_visit]\n redirect_to courses_path\n return\n else\n cookies[:first_time_visit] = {:value => Time.now.to_s, :expires => 1.year.from_now }\n redirect_to '/landing'\n end\n end",
"def index\n # Insert ruby code...\n redirect_to home_path if current_user\n end",
"def require_login\n if !current_user\n redirect_to \"/\"\n end\n end",
"def Usuario_noLogueado\n redirect_to(root_url) unless logged_in?\n end",
"def require_login\n end",
"def authorize_page\n if (params[:id] == 'dashboard' or params[:id] == 'welcome') and current_user.nil?\n session[:next] = request.fullpath\n puts session[:next]\n redirect_to new_user_session_path, alert: _(\"You have to log in to continue.\")\n end\n end",
"def login_required\n if !logged_in?\n redirect \"/login?#{env[\"REQUEST_PATH\"]}\"\n end\n end",
"def user_logged_in_sin_hogar\n\n\t\t redirect_to new_direccion_path if logged_in? && !tiene_hogar?\n\n \tend",
"def home\n redirect_path = Redirect.find_by_uri request\n if redirect_path\n redirect_to redirect_path\n else\n @hotels = Hotel.limit(10)\n @comments = Comment.latest.limit(5)\n end\n end",
"def must_login\n redirect_to login_path unless logged_in?\n end",
"def home_page?\n active_page? 'info' => ['index']\n end",
"def login_required\n \t\t redirect_to(root_url, notice: 'You have to be signed in to do that! Top right ~') unless current_user\n \tend",
"def in\n @var = Users.find_users\n @salout = \"Wrong username or password\"\n if cookies[ :user_id ] != nil\n redirect_to :action => \"index\" ,:controller => \"homepage\"\n else\n @var.each do |v|\n if ( v.username == params[ :username ] )\n if( v.encrypted_password == params[ :password ])\n cookies[ :user_id ] = v.id\n cookies[ :username ] = v.username\n #this if condition redirect the user after logging in to the right home page.\n #if the user is an admin redirects to admin homepage otherwise redirects to normal homepage.\n #Author: Rehab A.Elshahawy\n if(v.admin == true)\n redirect_to :action => \"index\" ,:controller => \"admin\"\n else\n redirect_to :action => \"index\" ,:controller => \"homepage\"\n return\n end\n end\n end\n end\n end\nend",
"def redirect_to_home\n redirect_to session[:superadmin_mode] ? ubiquo.superadmin_home_path : ubiquo.home_path\n end",
"def must_be_logged_in\n redirect_to root_path unless logged_in?\n end"
] |
[
"0.7586777",
"0.73427194",
"0.6974875",
"0.6941298",
"0.6922606",
"0.691566",
"0.6886396",
"0.6836467",
"0.68243676",
"0.67823046",
"0.67764926",
"0.67730474",
"0.6751303",
"0.67338896",
"0.672224",
"0.66629237",
"0.66353726",
"0.6634183",
"0.66152614",
"0.6595828",
"0.65701145",
"0.65158474",
"0.65038323",
"0.6503718",
"0.6499747",
"0.64896923",
"0.64881426",
"0.6468184",
"0.6466366",
"0.6463822",
"0.64630747",
"0.64564383",
"0.6449584",
"0.6444364",
"0.64296925",
"0.6429084",
"0.6424193",
"0.64153314",
"0.64042246",
"0.6394709",
"0.63909477",
"0.63878673",
"0.6378703",
"0.637361",
"0.63458186",
"0.6333414",
"0.6333151",
"0.63249373",
"0.63249373",
"0.63211685",
"0.63185143",
"0.63125455",
"0.6296158",
"0.6294705",
"0.6294605",
"0.6293578",
"0.6293578",
"0.6293578",
"0.628578",
"0.62813246",
"0.62808853",
"0.62808853",
"0.627572",
"0.62679416",
"0.626792",
"0.62488675",
"0.62332946",
"0.62331533",
"0.62309074",
"0.6230885",
"0.6229751",
"0.62282526",
"0.6226711",
"0.6225911",
"0.62193453",
"0.62132776",
"0.6208189",
"0.6203574",
"0.6203574",
"0.6200354",
"0.6200354",
"0.6200354",
"0.6189521",
"0.6189521",
"0.6188661",
"0.61823976",
"0.6181874",
"0.61816335",
"0.61796325",
"0.6177429",
"0.6171533",
"0.6171088",
"0.6168569",
"0.6168405",
"0.6167999",
"0.6166094",
"0.6164259",
"0.6160482",
"0.6158609",
"0.6156093",
"0.6152808"
] |
0.0
|
-1
|
MODIFIED: Sam Wolfe 4/10/2018 Added ability to hide/show profile elements based on request number
|
def band
@posts_applied = Response.where(band_id: current_band.id).map{|response| response.post}
@posts_applied = @posts_applied.first(3);
@posts_not_applied = Post.find Post.all.map{|p| p.id} - @posts_applied.map{|post| post.id}
@posts_not_applied = @posts_not_applied.first(3);
@business_requests = BusinessRequest.where(band_id: current_band.id)
@requests = @business_requests.count - @business_requests.count(:band_decision)
if@requests > 0
@has_requests = true;
else
@has_requests = false;
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n \n @user = logged_in_user \n @questions = logged_in_user.user_attribute_details \n @change_list = ContentManager.calculate_change_list(@user) \n @campaigns_to_show = 5\n @owned_campaigns = logged_in_user.owned_campaigns.not_deleted\n @is_org_user = @user.has_role? \"OrganizationUser\"\n @orgs = OrganizationUser.find_all_by_user_id(@user.id).map(&:organization) if @is_org_user\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @profile }\n end\n end",
"def show\n @flag = @profile.country_code + \" flag\" unless @profile.country_code.nil?\n\n if @profile.user_id == current_user.id\n @title = \"My Profile Card\"\n else\n @title = \"#{@profile.nickname}'s Profile Card\"\n end\n end",
"def profile_displayed\n profile = @wait.until{\n element = @browser.find_element :id, 'profile-ico'\n element if element.displayed?\n }\n return profile\n end",
"def show\n @user = User.find(params[:id])\n can_edit_hash = Permissions.currentLoggedInOrHasMorePermissions(@current_user,@user)\n @can_edit = can_edit_hash[:has_permission]\n\n #max needs\n @can_see_pref= Permissions.is_at_least_manager(@current_user)\n\n profile_attrs = [:first_name,:last_name, :email,:phone_number]\n @first_name = @user.first_name\n @last_name = @user.last_name\n @email = @user.email\n @phone_number = @user.phone_number\n @role = @user.role\n end",
"def small_profile\n\t\t# determine which user's profile page\n \t@user = User.find_by_login(params[:username])\n\t\t# get all comments for this user\n\t @comments = @user.user_comments\n\t\t# get all user_items by this user\n\t @user_items = current_user.user_items\n\t\trespond_to do |format|\n\t\t\tformat.html\n format.js { render_to_facebox }\n end\n\tend",
"def forFriendfunctions\n @status = false\n self.hide\n showElements\n end",
"def show\n\n @user = User.find(params[:id])\n @is_an_interest = !Visible.where(hidden_user: params[:id], user_of_interest: @user).nil?\n\n if @user.event_id.present?\n @event = Location.find(Event.find(@user.event_id).location_id).name\n end\n\n # used to show a person link to editing his profile\n @is_user = false\n if @user.id == session[:user_id]\n @is_user = true\n end\n\n @is_female = false\n if @user.gender.eql? \"F\"\n @is_female = true\n end\n\n if @user.visible || @is_user || @is_an_interest\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n else\n redirect_to root_url, notice: \"Nice Try\"\n end\n end",
"def profile\n\t\t# determine which user's profile page\n\t\t@user = User.find_by_login(params[:username])\n\t\t# retrieve all bids by this user\n\t @bids = Bid.find_all_by_bidder_id(@user.id, :group => 'item_id')\n\t\t# get all comments for this user\n\t @comments = @user.user_comments\n\t\t# get all user_items by this user\n\t @user_items = @user.posted_items\n\n\t\t# code for facebox\n\t respond_to do |format|\n\t\t\tformat.html\n format.js { render_to_facebox }\n end\n\tend",
"def show\n @use = User.find(@profile.my_id)\n if @profile.user_id then\n @target = User.find(@profile.user_id)\n end\n if ((@use.id == 1) && (@use.id == @profile.my_id) && (!@profile.user_id)) then\n do_it\n end\n end",
"def show \n when_fragment_expired \"profile_#{@profile.id}/profile_flickr_pics_and_video#{@profile.id}\",\n :expire => EXPIRE_TIME_IN_MIN.minutes.from_now do\n unless @profile.youtube_username.blank?\n begin\n client = YouTubeG::Client.new\n @video = client.videos_by(:user => @profile.youtube_username).videos.first\n rescue Exception, OpenURI::HTTPError\n end\n end\n begin\n @flickr = @profile.flickr_username.blank? ? [] : flickr_images(flickr.people.findByUsername(@profile.flickr_username), {}, FLICKR_IMGAES_ON_PROFILE)\n rescue Exception, OpenURI::HTTPError\n @flickr = []\n end\n end\n if @profile.can_see_field(\"marker\", @p)\n @profiles = @profile.all_friends.select{|f|f.can_see_field('marker',@p)}\n end\n @comments = @profile.comments.paginate(:page => params[:page], :per_page => @per_page)\n @feed_items = @profile.find_feed_items\n respond_to do |wants|\n wants.html \n wants.rss {render :layout => false}\n end\n end",
"def index\n\n\t\t@user=current_user\n\n\t\t# We need to tell the view what to do with the profile\n\t\t# If a profile exists then display some profile information\n\t\t# If a profile doesn't exist then display a message saying to click the edit button to add a new profile\n\n\t\t# Does a valid profile exist on the user?\n\t\t@valid_profile = Profile.exists?(user_id: @user.id)\n\n\t\t# Valid profile exists\n\t\tif @valid_profile\n\n\t\t\t@user_profile = Profile.find_by(user_id: @user.id)\n\n\t\telse\n\n\t\t\t# No valid profile exists\n\t\t\t# The user can either create a new profile or request an existing one\n\t\t\t#@user_profile_requests = @user.profile_requests\n\n\t\t\t# if !current_user.profile_requests.approved(false).empty? %>\n\n\t\t\t# Create a list of user profile requests that are not set yet\n\t\t\t@user_profile_requests_not_set = @user.profile_requests.status_not_set\n\n\t\t\tif @user_profile_requests_not_set.blank?\n\n\t\t\t\t@available_profiles_collection = Profile.where(user_id: nil).order(:lastname)\n\n\t\t\tend\n\n\t\t\t# Create a list of user profile requests that are denied\n\t\t\t@user_profile_requests_denied = @user.profile_requests.status_denied\n\n\t\tend\n\n\n\n\n\tend",
"def show_profile\n if GeneralInfo.exists?(:userKey => params[:id])\n @general_info = GeneralInfo.find_by(userKey: params[:id])\n @general_info_attributes = GeneralInfo.attribute_names\n @general_info_values = @general_info.attribute_values\n \n case @general_info.specific_profile_id\n when 1\n @profile_type = \"Designer\"\n if SpecificDesigner.exists?(:user_key => params[:id])\n @specific_designer = SpecificDesigner.find_by(user_key: params[:id])\n @profile_info = @specific_designer.attribute_values\n else\n #stuff\n end\n when 2\n @profile_type = \"Model\"\n if SpecificModel.exists?(:user_key => params[:id])\n @specific_model = SpecificModel.find_by(user_key: params[:id])\n @profile_info = @specific_model.attribute_values\n else\n #stuff\n end\n when 3\n @profile_type = \"Photographer\"\n if SpecificPhotographer.exists?(:user_key => params[:id])\n @specific_photographer = SpecificPhotographer.find_by(user_key: params[:id])\n @profile_info = @specific_photographer.attribute_values\n else\n #stuff\n end\n else\n puts \"Unknown profile type! Profile type given: \" + @general_info.specific_profile_id\n @profile_type = \"Error\"\n end\n else\n #SHOULD DISPLAY BLANK STUFF!!!!\n @general_info = GeneralInfo.new\n @general_info_values = Hash.new\n end\n end",
"def xml_query_profile(xml) \n if current_user \n profile_name = (xml.root.get_elements('AccessProfile').first || empty).text \n profile_name = 'public' unless profile_name \n @profile = current_user.profiles.find_by_title(profile_name) \n return render(:text => \"<Response>bad profile</Response>\") unless @profile \n \n properties = @profile.properties.map{|p| p.property_type.title }.join(',') \n return render(:text => \"<Response>#{properties}</Response>\") \n end \n render(:text => \"<Response>Internal Error</Response>\") \n end",
"def show\n session[:current_tab] = \"Profile\"\n session[:current_sub_tab] = \"\"\n\n if params[:hcard]\n hcard\n return\n end\n \n @user_spaces = @user.stages\n if @user.profile.new_record? && current_user == @user\n flash[:notice]= 'You must create your profile first'\n redirect_to new_user_profile_path(@user)\n elsif current_user != @user && @user.profile.new_record?\n flash[:notice]= \"Action Not Allowed\"\n redirect_to root_path() \n else\n @thumbnail = Logotype.find(:first, :conditions => {:parent_id => @user.profile.logotype, :thumbnail => 'photo'}) \n respond_to do |format|\n format.html \n format.xml { render :xml => @profile }\n format.vcf { vcard }\n format.atom\n end\n end\n end",
"def show\n @profiles_all = current_user.profiles.order('lastname ASC')\n if current_user.business\n @business = current_user.business.name\n end\n @profile = current_user.profiles.find(params[:id])\n @profile_tickets = Ticket.where(:user => @user).order('date_opened DESC')\n .paginate(page: params[:page])\n @profile_assets = Asset.where(:owner => @user).order('serial ASC')\n .paginate(page: params[:page])\n end",
"def show\n #@profile = Profile.find(params[:profile_id])\n @user = current_user\n @request = Request.find(params[:id])\n #enable comments\n @commentable = @request\n @comments = @commentable.comments\n @comment = Comment.new\n end",
"def show\n @request = Request.find(params[:request_id])\n case params[:id]\n when 'features'\n @new_feature = @request.features.new\n @features = @request.features.load\n @features.reverse!\n when 'select_recipient'\n @experts = User.where(role: :expert).load\n when 'select_what_kind_of_software'\n @software_groups = RequestGroup.all\n when 'upload_images'\n #@image = @request.images.new\n when 'image_preview'\n @images = [@request.images]\n else\n end\n render_wizard\n end",
"def show_cidprofile_publiconly\n @profile = Profile.find_by_cid(params[:cid])\n puts 'found profile by cid=' + params[:cid]\n\n # Crude: copy the (hardcoded) public attributes from profile object\n # NB this ideally needs a deep copy/clone to also cover info from associated models\n profile_atts = @profile.clone_attributes\n profile_atts_public = {}\n ['cid','firstname','lastname', 'middleinitials'].each do |key|\n profile_atts_public[key] = profile_atts[key]\n end\n \n puts 'Showing public-only profile info:'\n pp profile_atts_public\n pp @profile\n respond_to do |format|\n format.html do\n params[id] = @profile.id\n #forward 'show'\n #redirect_to profile_path(@profile)}\n render \"show_public\"\n end\n format.xml { render :xml => profile_atts_public }\n format.json { render :json => profile_atts_public }\n end\n \n end",
"def profile_show_page?\n controller_name == \"profiles\"\n end",
"def profile_show_page?\n controller_name == \"profiles\"\n end",
"def show\n @profiles = @evaluation.profiles\n filters, @filter_label = session_filters\n # @counts = Rails.cache.read(\"counts:#{@evaluation.id}\")\n # @controls = Rails.cache.read(\"controls:#{@evaluation.id}\")\n # unless @counts\n # @counts, @controls = @evaluation.status_counts(filters)\n # Rails.cache.write \"counts:#{@evaluation.id}\", @counts\n # Rails.cache.write \"controls:#{@evaluation.id}\", @controls\n # end\n @nist_hash = Constants::NIST_800_53\n respond_to do |format|\n format.html { render :show }\n format.json { render :show }\n format.ckl { render :show, layout: false }\n format.csv { render :show, layout: false }\n end\n end",
"def index\n if @profile == current_profile\n @filters = @profile.filters\n else\n @filters = @profile.filters.opt_in\n end\n end",
"def show\n if Profile.find(params[:id].to_i).public_profile == 1 || params[:id].to_i == current_user.profile.id\n @profile = Profile.find(params[:id])\n @session_id = params[:id].to_i\n else\n redirect_to '/'\n end\n end",
"def show\n #@profile = Profile.find(params[:id])\n \n @codes = Code.find(:all, :conditions => {:user_id => session[:user_id]}) # Get ALL codes, even private, since this is user's private code view\n\n @listing = 10\n if !session[:user_id].nil? then\n @activeProfile = Profile.find session[:user_id]\n @listing = @activeProfile.listing \n end\n \n @numPages = (@codes.length / @listing.to_f).ceil\n # @codes = @codes[(params[:page].to_i-1)*@listing, @listing]\n \n @categories = Category.all\n @languages = ProgramLanguage.all\n\n #respond_to do |format|\n # format.html # new.html.erb\n # format.xml { render :xml => @codes }\n #nd\n \n @profile = Profile.find(:first, :conditions => {:user_id => session[:user_id]} )\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @profile } \n end\n end",
"def is_visible?\n is_public? && ProfileStatus::VISIBLE.include?(profile_status)\n end",
"def show\n unless params[:id].blank?\n @user = User.find_by_id(params[:id])\n else\n if logged_in?\n @user = current_user\n else\n require_login and return\n end\n end\n \n if @user.blank?\n flash[:error] = \"User not found\"\n redirect_to root_path and return\n end\n\n @own_profile = (logged_in? && (@user.id == current_user.id))\n\n @page_title = @own_profile ? \"My profile\" : \"View profile\"\n\n @memberships = @user.liga_users.approved.map(&:league)\n end",
"def display_requested?(key)\n @display_requests ||= (session[:display_requests] ||= Set.new).dup\n session[:display_requests].delete(key)\n # allow simple dev by passing the key in a query string\n @display_requests.member?(key) || params[key]\n end",
"def show\n #@persona = Persona.find(params[:id])\n @persona = Persona.find(:all, :conditions => {:screen_name => params[:id] }).first\n @storage_usage = @persona.storage_usage\n @storage_size = @persona.current_storage_size\n\n @following = Persona.find(:all, :conditions => { \n :id => @persona.followers.where(:tracked_object_type => 'persona').pluck(:tracked_object_id)\n }, :limit => 30)\n @followers = Persona.find(Follower.where(:tracked_object_id => @persona.id, \n :tracked_object_type => 'persona').pluck(:persona_id))\n\n if persona_signed_in? && @persona == current_persona && !@persona.premium? then\n @bandwidth = current_persona.photos.where{ \n created_at.gt Date.today.at_beginning_of_month }.map{ |p| p.avatar.size \n }.sum \n @exceed_bandwidth = @bandwidth > 300*1024*1024 \n end\n\n\t\tjs :params => { :screen_name => @persona.screen_name }\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @persona }\n end\n end",
"def test_00070_add_feild_as_show_feild\n first_name = @c.users[user_for_test].name.split(' ')[0]\n # set first name feild as not show\n @admin_profile_page.navigate_in\n @admin_profile_page.custom_profile_feild \"First Name\", {0 => false }\n # admin can't see first name feild\n @profile_page.goto_profile\n url = @browser.url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert !(@profile_page.profile_page_author_name_betaon.text.include? first_name)\n # user2 can't see first name feild\n @login_page.about_login(\"regular_user2\", \"logged\")\n @browser.goto url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert !(@profile_page.profile_page_author_name_betaon.text.include? first_name)\n\n # set first name feild as show\n @login_page.about_login(\"network_admin\",\"logged\")\n @admin_profile_page.navigate_in\n @admin_profile_page.custom_profile_feild \"First Name\", {0 => true, 2 => false }\n # admin can't see first name feild]\n @browser.goto url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert (@profile_page.profile_page_author_name_betaon.text.include? first_name)\n # user2 can't see first name feild\n @login_page.about_login(\"regular_user2\", \"logged\")\n @browser.goto url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert (!@profile_page.profile_page_author_name_betaon.text.include? first_name)\n\n # set first name feild as public\n @login_page.about_login(\"network_admin\",\"logged\")\n @admin_profile_page.navigate_in\n @admin_profile_page.custom_profile_feild \"First Name\", {0 => true, 2 => true }\n # admin can see first name feild\n @browser.goto url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert (@profile_page.profile_page_author_name_betaon.text.include? first_name)\n # user2 can see first name feild\n @browser.goto url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert (@profile_page.profile_page_author_name_betaon.text.include? first_name)\n ensure\n # set first name feild as public\n @login_page.about_login(\"network_admin\",\"logged\")\n @admin_profile_page.navigate_in\n @admin_profile_page.custom_profile_feild \"First Name\", {2 => true }\n end",
"def show\n @profile = current_user.profile\n\n # ToDo: error message if no profile is found for user\n\n puts 'Got profile='\n pp @profile\n \n\n puts 'got other_names='\n pp @profile.other_names\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @profile }\n format.json { render :json => @profile }\n end\n \n end",
"def show_cidprofile_full\n puts 'got signed request from an OAuth consumer:'\n pp current_token\n pp current_client_application\n \n @profile = Profile.find_by_cid(params[:cid])\n puts 'found profile by cid=' + params[:cid]\n \n puts 'Showing all profile info:'\n pp @profile\n respond_to do |format|\n format.xml { render :xml => @profile }\n format.json { render :json => @profile }\n end \n \n end",
"def show\n @member = Member.find(params[:id], :include=>:profiles)\n\n @user_profiles = @member.profiles.map{|p|{p.network_id=>p.url}}\n @pro_networks = Network.with_urls(@user_profiles, :pro)\n @perso_networks = Network.with_urls(@user_profiles, :perso)\n\n end",
"def request_display(*keys)\n @display_requests ||= (session[:display_requests] || Set.new)\n session[:display_requests] = @display_requests = @display_requests | keys\n end",
"def show\n @user = User.find(params[:id])\n @owned_methods = @user.owned_methods.limit(12)\n @owned_discussions = @user.owned_discussions.limit(12)\n @owned_collections = @user.owned_collections\n\n @private_collections = @owned_collections.where(is_private: true)\n @public_collections = @owned_collections.where(is_private: false)\n\n @private_collections = @private_collections.paginate(page: params[:private_page], :per_page => 10)\n @public_collections = @public_collections.paginate(page: params[:public_page], :per_page => 10)\n if user_signed_in?\n @is_current_user = @user.id == current_user.id\n else \n @is_current_user = false\n end\n store_location\n render layout: \"custom\"\n end",
"def show\n redirect_to edit_profile_url if @profile.nil?\n\n @no_trade_owned_products = @profile.user.listings.where(category_id: 'products', status: 'owned', item_type: 'no-trade')\n @no_trade_owned_skills = @profile.user.listings.where(category_id: 'skills', status: 'owned', item_type: 'no-trade')\n @trade_owned_products_or_skills = @profile.user.listings.where(category_id: ['skills', 'products'], status: 'owned', item_type: 'trade')\n @trade_wanted_skills = @profile.user.listings.where(category_id: 'skills', status: 'wanted')\n @trade_wanted_products = @profile.user.listings.where(category_id: 'products', status: 'wanted')\n\n end",
"def show\n @security_user = SecurityUser.find(params[:id])\n @current_title_text = @security_user.is_profile_mine(current_user.id,'My Profile Status','Profile Status of {first_name} {last_name}')\n\n respond_to do |format|\n format.html # show.html.erb\n format.js\n format.json { render json: @security_user }\n end\n end",
"def viewable_for (profile)\n self.by_membership_id(profile.id)\n end",
"def manage_profile\n begin\n @has_link_access = true\n if @actor.is_fan? # in case of fan profile login\n @user = @actor\n @additional_info = current_user.additional_info\n get_user_associated_objects\n render :template =>\"/fan/manage_profile\" and return\n elsif @actor.is_artist? # in case of artist profile login\n @user = current_user\n @artist = @actor\n @artist_user = ArtistUser.for_user_and_artist(current_user, @artist).first || ArtistUser.new\n get_artist_objects_for_right_column(@artist)\n render :template =>\"/artist/edit\" and return\n elsif @actor.is_venue? # in case of venue profile login\n @user = current_user\n @venue = @actor\n @venue_user = VenueUser.for_user_and_venue(current_user, @venue).first || VenueUser.new\n get_venue_objects_for_right_column(@venue)\n render :template =>\"/venue/edit\" and return\n end\n rescue =>exp\n logger.error \"Error in User#ManageProfile :=> #{exp.message}\"\n render :nothing => true and return\n end\n respond_to do |format|\n format.js\n format.html\n end\n end",
"def show\n impressionist(@profile)\n @profile = Profile.friendly.find(params[:id])\n\n @profile_urbanterms = @profile.urbanterms.order(\"created_at DESC\") #important! to enable profiles urbanterms on profile\n \n\n end",
"def show?\n user.rank > UNIT_RANK || user.unit_id == @division.id\n end",
"def show\r\n\r\n @user_attributes = params[:user] ? params[:user][params[:id]].clone : {}\r\n @user_attributes.merge!(:id => params[:id]) if @user_attributes\r\n @user_attributes.delete(:active) if @user_attributes && restrict_active_for_show_5\r\n @user_attributes.delete(:password) if @user_attributes && restrict_password_for_show_5\r\n @user_attributes.delete(:hashed_password) if @user_attributes && restrict_hashed_password_for_show_5\r\n @user_attributes.delete(:salt) if @user_attributes && restrict_salt_for_show_5\r\n @user_attributes.delete(:last_login) if @user_attributes && restrict_last_login_for_show_5\r\n @user_attributes.delete(:last_session_id) if @user_attributes && restrict_last_session_id_for_show_5\r\n @user_attributes.delete(:user_accesses) if @user_attributes && restrict_user_accesses_for_show_5\r\n @user_attributes.delete(:accesses) if @user_attributes && restrict_accesses_for_show_5\r\n @user_attributes.delete(:profiles) if @user_attributes && restrict_profiles_for_show_5\r\n @user = User.load_from_params(@user_attributes)\r\n if @user.nil?\r\n flash[:warning] ||= []\r\n flash[:warning] << _(\"Warning: %{obj} with ID %{id} does not exist!\") % {:obj => 'user', :id => params[:id]}\r\n redirect_to(:action => :index)\r\n return\r\n end\r\n\r\n respond_to do |format|\r\n format.html {\r\n render :layout => !request.xhr? }\r\n format.pdf {\r\n render :layout => false }\r\n format.xml {\r\n render :xml => @user.to_xml }\r\n format.json {\r\n render :json => @user.to_json }\r\n end\r\n end",
"def show\n @last_pages = []\n\n elements = Impression.where(user_id: current_user._id).order_by([:created_at, :desc])\n elements.each do |element|\n break if @last_pages.size >= 10\n checking = element.impressionable_type.constantize.find(element.impressionable_id) rescue @last_pages.last\n unless checking == @last_pages.last\n @last_pages << checking\n end\n end\n\n @my_activities = PublicActivity::Activity.where(owner_id: current_user.id).order_by(created_at: :desc).page(params[:page]).per(20)\n @comments = PublicActivity::Activity.where(:recipient_id.in => current_user.all_resources_ids).order_by(created_at: :desc).page(params[:page]).per(20)\n end",
"def show\n @years = @user.active_years(\"Show\")\n\n respond_to do |format|\n format.html # show.html.erb\n\n if @user.public_profile? then\n format.xml { render :xml => @user, :only => [:home_college, :gender,\n :id, :about, :majors, :other_activities, :andrewid, :minors,\n :birthday, :last_name, :first_name, :phone, :graduation_year, :smc,\n :email] }\n end\n end\n end",
"def showRequests\n \t\t# Ensure user is logged in to view this page\n\t\tif(session.has_key?(\"logged_in\"))\n\t\t\n\t\t\t# If the user is not logged in redirect to homepage\n\t\t\tif(session['logged_in'] != 1) \n\t\t\t\tredirect_to url_for(:controller => :home, :action => :showHome)\n\t\t\tend\n\n\t\t\t# Get user id.\n\t\t\t@userID = session['user_id']\n\n\n\t\t\t# ids of people requesting collaboration.\n\t\t\t@co_ids = Collaboration.where(second_id:@userID)\n\n\t\t\t@num = @co_ids.count\n\n\t\t\t# Arrays to store ids other requesters.\n\t\t\t@requester_ids = Array.new(@num)\n\t\t\t@names = Array.new(@num)\n\t\t\t@messages = Array.new(@num)\n\n\t\t\tfor i in 0..@num-1\n\t\t\t\t@requester_ids[i] = @co_ids[i].first_id\n\t\t\t\t@messages[i] = Collaboration.find_by(first_id:@requester_ids[i], second_id:@userID).message\n\t\t\t\t@names[i] = User.find(@co_ids[i].first_id).username\n\t\t\tend\n\n\t\telse\n\t\t\tredirect_to url_for(:controller => :home, :action => :showHome)\n\t\tend\n\tend",
"def show?\n user.rank > UNIT_RANK || user.unit_id == @department.id\n end",
"def click_on_profile_by_name(name = get_random_profile_name)\n click(css: \"h4>a[class='freelancer-tile-name'][title='#{name}']\")\n Log.step \"Clicked on random profile, profile selected: '#{name}'\"\n end",
"def test_p1_00010_profilepage_profile_option\n if !@profilepage.profile_activity.present?\n @profilepage.goto_profile\n end\n if @profilepage.profile_pic_modal.present?\n @profilepage.profile_pic_cancel_button.click\n @browser.wait_until($t) { !@profilepage.profile_pic_modal.present? }\n end\n \t@profilepage.check_profile_in_user_dropdown\n \tassert @profilepage.profile_link.present? \n @profilepage.newline\n end",
"def profile\n \n end",
"def fetch_profile_data\n puts \"Step 10: Extracting freelancer profile data\"\n freelance_profile_page = FreelancerProfilePage.new\n data = freelance_profile_page.get_profile_header\n data2 = data.find_element(css: \".overlay-container\")\n title = data2.find_element(css: \"h3\").text\n description = data2.find_elements(css: \"o-profile-overview\").first.text\n skills = freelance_profile_page.get_profile_skills.collect{|t| t.text}\n\n @profile_data = {\n title: title,\n description: description,\n skills: skills\n }\n puts \"Profile data extracted successfully\"\n end",
"def show\n @user = User.find(params[:id])\n\n if @user.state != 'active' or @user.login == 'admin'\n return redirect_to users_path\n end\n \n @page_ancestors = [{:name=>'Community', :url=> users_path}]\n @bc_title = 'User Profile'\n \n respond_to do |format|\n format.html # show.html.erb\n format.iphone\n format.xml { render :xml => @user }\n end\n end",
"def show\n redirect_to '/unauthorized' if current_user.blocked_by? User.find(params[:user_id])\n @user = User.find(params[:user_id])\n @dm_profile = @user.dm_profile\n unless @dm_profile.nil?\n @similar_profiles = User.recommender(@dm_profile, \"dm\")\n @similar_profiles = recommend_set(@similar_profiles, @user) & User.location(current_user, \"1\")\n else\n @similar_profiles = nil\n end\n if !@dm_profile\n redirect_to new_user_dm_profiles_path(@user, tutorial: params[:tutorial])\n else\n render 'show'\n end\n end",
"def user_profile_settings_label\n $tracer.trace(__method__)\n return ToolTag.new(div.id(\"/ProfileTabs_TabSet/\") ,__method__)\n end",
"def profile\n\n end",
"def profile\n @user = @current_user\n\n render :show\n\n end",
"def show\n\n if @user.id == current_user.id\n add_breadcrumb \"My Profile\"\n else\n add_breadcrumb @user.name\n end\n\n # get the @prev_record_path and @next_record_path view vars\n get_next_and_prev_object_keys(@user, INDEX_KEY_LIST_VAR)\n @prev_record_path = @prev_record_key.nil? ? \"#\" : user_path(@prev_record_key)\n @next_record_path = @next_record_key.nil? ? \"#\" : user_path(@next_record_key)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @user }\n end\n end",
"def index\n @profiles = Profile.all\n @user = current_user\n if current_user.profile\n @profile = current_user.profile\n @explores = @profile.explore_categories.uniq\n @guides = @profile.guide_categories.uniq\n @projects = @profile.projects.includes(:categories).sort_by_created_desc\n @explore_ratings = @profile.explore_ratings.includes(:category).sort_by_created_desc.group_by(&:category)\n @guide_ratings = @profile.guide_ratings.includes(:category).sort_by_created_desc.group_by(&:category)\n @new_profile = false\n\n else\n @new_profile = true\n @profile = Profile.new\n @explores = []\n @guides = []\n end\n @filterrific = initialize_filterrific(\n Category,\n params[:filterrific]\n ) or return\n @categories = @filterrific.find.page(params[:page])\n respond_to do |format|\n format.html\n format.js\n end\n @list = current_user.profile.explore_categories.pluck(:id).uniq\n @listg = current_user.profile.guide_categories.pluck(:id).uniq\n\n @category = Category.all\n end",
"def xml_profile_list(xml) \n if current_user \n profiles = current_user.profiles.map{|p| p.title}.join(',') \n return render(:text => \"<Response>#{profiles}</Response>\") \n end \n render :text => '<Response>Internal Error</Response>' \n end",
"def display_resource(user)\n user.restricted? ? 'Hidden' : user.name\n end",
"def show\n @not_current = params[:not_current]\n\n respond_to do |format|\n format.html {render :partial => \"admin/profiles/show\"}\n #format.js \n end\n end",
"def show\n redirect_to root_path if current_user.blocked_by? User.find(params[:user_id])\n @user = User.find(params[:user_id])\n @player_profile = @user.player_profile\n unless @player_profile.nil?\n @similar_profiles = User.recommender(@player_profile, \"player\")\n @similar_profiles = recommend_set(@similar_profiles, @user) & User.location(current_user, \"0\")\n else\n @similar_profiles = nil\n end\n end",
"def memberrequests\n @group = Group.find(session[:group_id])\n @membership = Membership.find_by(user_id: session[:user_id], group_id: session[:group_id])\n @requests = Request.where(requestor_id: @membership).order('requesting_at DESC')\n authorize @requests, :index?\n respond_to do |format|\n format.js\n format.html\n end\n end",
"def show\n @profiles = @grab.profiles\n end",
"def profile\n self.profilelink.click\n end",
"def show\n @user = if params[:user_id]\n User.find(params[:user_id])\n else\n current_user\n end\n\n @profile = @user.profile\n authorize! :show, @profile\n\n @progress_remaining = @profile.profile_progress\n @progress = Profile::PROFILE_STEPS - @progress_remaining\n @progress_percent = ((@progress/Profile::PROFILE_STEPS.to_f) * 100).round(0)\n\n #here is code for creating a \"view\" event in the Views table\n unless current_user.id == @user.id\n @view = View.new\n @view.profile_id = @profile.user_id\n @view.viewer_id = current_user.id\n @view.save\n end\n #end of code relating to the view\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @profile }\n end\n end",
"def show_profile?\n if controller.controller_name == 'hackers'\n true\n else\n false\n end\n end",
"def edit\n @help = PageContent.find_by_name(\"profile-help\") # \"What to include in profile\" Content\n @presenter = find_presenter\n @presenter_profile = @presenter.presenter_profile\n if @presenter_profile.nil?\n redirect_to new_presenter_profile_path(@presenter)\n end\n #displays current profile information for editing \n if !@presenter_profile.bio_edit.nil?\n if @presenter_profile.approved? && @presenter_profile.bio_edit.empty?\n @presenter_profile.bio_edit = @presenter_profile.bio\n end\n else\n if @presenter_profile.approved?\n @presenter_profile.bio_edit = @presenter_profile.bio\n end\n end\n end",
"def show\n\t\t# Initializing the Inivitation form from profile page\n\tend",
"def show\n @user = User.find_from_param(params[:id], :include => :avatar)\n\n respond_to do |format|\n format.html do\n current_user_page = current_user == @user\n\n if request.xhr?\n # Request partials\n #\n partial = params[:partial]\n unless current_user_page && @@ajax_partials.include?(partial)\n render :nothing => true, :status => :bad_request and return\n end\n\n render :partial => \"users/#{partial}\"\n else\n # Request page\n #\n @user.profile_viewed_by(tracked_user) unless current_user_page\n \n @songs = @user.songs.public.paginate(:page => 1, :per_page => 10)\n\n if current_user_page\n @private_songs = @user.songs.private.paginate(:page => 1, :per_page => 10)\n @tracks = @user.tracks.stuffable.paginate(:page => 1, :per_page => 10)\n else\n @tracks = @user.tracks.public.paginate(:page => 1, :per_page => 10)\n end\n\n @instrument_categories = InstrumentCategory.by_name.with_instruments\n @gears = @user.gears\n \n @answers = @user.answers.paginate(:page => 1, :per_page => 6)\n \n @mbands = @user.mbands\n \n @new_membership = MbandMembership.new\n \n @has_abuse = @user.abuses.exists? ['user_id = ?', current_user.id] if logged_in?\n end\n end\n\n format.xml { render :partial => 'multitrack/user' }\n end\n\n rescue ActiveRecord::RecordNotFound\n flash[:error] = 'User not found..'\n redirect_to '/'\n end",
"def profilerDisplayControl()\n controlPanel = \"$map_table.>.hal_access.>.profileControl\"\n\n # Check if already displayed\n inwin=cwGetRootWatches\n if (!(inwin.include?(controlPanel)))\n # Add to watch\n cwAddWatch(eval(controlPanel.gsub(/\\.>/,\".derefAt(4)\")))\n end\n\n # Refresh\n cwRefreshWatches\nend",
"def pull_profiles\n @user = current_user\n @accessible_artists = @user.artists.includes(:artist_musics, :songs)\n @accessible_venues = @user.venues\n get_fan_objects_for_right_column(@user)\n respond_to do |format|\n format.js\n format.html\n end\n end",
"def show\n @web_profile = WebProfile.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.js do\n replace_content(dom_id(@web_profile), :partial => 'web_profile')\n end\n end\n end",
"def show_list\n @breadcrumbs = []\n bc_name = _(\"Requests\")\n @request_tab = params[:typ] if params[:typ] # set this to be used to identify which Requests subtab was clicked\n @layout = layout_from_tab_name(@request_tab)\n\n drop_breadcrumb(:name => bc_name, :url => \"/miq_request/show_list?typ=#{@request_tab}\")\n @lastaction = \"show_list\"\n @gtl_url = \"/show_list\"\n\n if params[:ppsetting] # User selected new per page value\n @items_per_page = params[:ppsetting].to_i # Set the new per page value\n @settings.store_path(:perpage, PERPAGE_TYPES['list'], @items_per_page) # Set the per page setting for this gtl type\n end\n @sortcol = session[:request_sortcol].nil? ? 0 : session[:request_sortcol].to_i\n @sortdir = session[:request_sortdir].nil? ? \"ASC\" : session[:request_sortdir]\n @no_checkboxes = true # Don't show checkboxes, read_only\n kls = @layout == \"miq_request_ae\" ? AutomationRequest : MiqRequest\n @view, @pages = get_view(kls, :named_scope => prov_scope(user_options(params)))\n\n @current_page = @pages[:current] unless @pages.nil? # save the current page number\n session[:request_sortcol] = @sortcol\n session[:request_sortdir] = @sortdir\n\n {:view => @view, :pages => @pages}\n end",
"def profile\n end",
"def profile\n end",
"def profile\n end",
"def profile\n end",
"def profile\n end",
"def profile\n end",
"def view_profile_of_page(page_name)\n self.link(:class=>/lhnavigation_page_title_value/, :text=>page_name).fire_event(\"onmouseover\")\n wait_for_ajax #.wait_until { self.link(:class=>/lhnavigation_page_title_value/, :text=>page_name).parent.div(:class=>\"lhnavigation_selected_submenu_image\").visible? }\n self.div(:class=>\"lhnavigation_selected_submenu_image\").hover\n self.execute_script(\"$('#lhnavigation_submenu').css({left:'328px', top:'349px', display: 'block'})\")\n wait_for_ajax #.wait_until { self.link(:id=>\"lhavigation_submenu_edittitle\").visible? }\n self.link(:id=>\"lhnavigation_submenu_profile\").click\n wait_for_ajax #.button(:title=>\"Show debug info\").wait_until_present\n self.window(:title=>\"rSmart | Content Profile\").use\n ContentDetailsPage.new self\n end",
"def show\n @toil_requests = User.find(params[:id]).toil_request\n @leave_requests = User.find(params[:id]).leave_request\n end",
"def index\n\t\t@user = set_user\n\n\t\tif @user.privacy.eql?(\"private\") && user_signed_in?(false)\n\t\t\trender \"forbidden_profile\"\n\t\telsif user_signed_in? && current_user.eql?(@user)\n\t\t\trender \"index\"\n\t\telsif @user.privacy.eql?(\"private\") && user_signed_in? && current_user.following?(@user).nil?\n\t\t\t@follow_or_unfollow = current_user.get_relationship_label(@user)\n\t\t\trender \"forbidden_profile\"\n\t\telse\n\t\t\t@follow_or_unfollow = current_user.get_relationship_label(@user) if user_signed_in?\n\t\t\trender \"index\"\n\t\tend\n\tend",
"def show\n @requests = Request.where(pet_id: params[:id]).all\n users_id = Array.new(@requests.size) \n @requests.each do |req|\n users_id.push([req.interented_id])\n end\n @interested = User.find(users_id)\n end",
"def show\n @user = User.find(params[:id])\n if @user.slug != params[:id]\n redirect_to(@user, :status => :moved_permanently)\n return\n end\n\n @pageTitle = @user.display_name\n @metaDescription = @user.description.blank? ? @user.display_name : @user.description\n @homepage = @user.home_page\n @homepage = \"http://\" + @homepage unless @homepage.nil? || @homepage.downcase.starts_with?(\"http://\")\n unless read_fragment(:part => \"photos_#{@user.id}\")\n @photos = @user.photos_by_time.limit(Photo.per_page)\n @has_photos = @photos.length != 0\n @appears_in_other_photos = false\n end\n unless read_fragment(:part => \"trip_reports_#{@user.id}\")\n @trip_reports_by_sub_region = @user.trip_reports_by_sub_region\n @trip_reports_by_year = @user.trip_reports_by_year\n @trip_year_groups = @trip_reports_by_year.keys.in_groups(1)\n @trip_year_groups = @trip_reports_by_year.keys.in_groups(2) if @trip_reports_by_year.length >= 6 \n @trip_year_groups = @trip_reports_by_year.keys.in_groups(3) if @trip_reports_by_year.length >= 11 \n @has_trip_reports = @user.trip_reports.length != 0\n end\n unless read_fragment(:part => \"albums_#{@user.id}\")\n @albums = @user.albums.where('deleted=false').includes(:user)\n @has_albums = @albums.length != 0\n @album_groups = @albums.in_groups_of(1)\n @appears_in_other_albums = false\n end\n @show_edit_link = can_edit?\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def show\n \t@person = Person.find(params[:id])\n \t@is_admin = false\n \tactive_person = Person.find(session[:user_id])\n \troles = active_person.roles.collect {|role| role.name}\n if roles == [\"DirectCareProvider\"] && session[:user_id] != params[:id]\n flash[:notice] = \"You can only access your own profile.\"\n @person = active_person\n elsif roles.member?(\"Supervisor\") || roles.member?(\"Administrator\")\n \t@is_admin = true\n end\n end",
"def show\n @profile = Profile.find(params[:id])\n #NOTE: Due to a mysql bug, we can't put parentheses around the clauses joined by the union.\n @friends=User.includes(:profile).where([\"id IN (SELECT invitee_id FROM friends WHERE confirmed = 1 AND inviter_id = ? \" +\n \" UNION SELECT inviter_id FROM friends WHERE confirmed = 1 AND invitee_id = ?)\",\n @profile.user_id, @profile.user_id]).paginate(:page => params[:page]).order('name')\n @my_friends=User.where([\"id IN (SELECT invitee_id FROM friends WHERE confirmed = 1 AND inviter_id = ?) \" +\n \" OR id IN (SELECT inviter_id FROM friends WHERE confirmed = 1 AND invitee_id = ?)\",\n session[:user_id], session[:user_id]])\n @my_friend_invites=User.where([\"id IN (SELECT invitee_id FROM friends WHERE confirmed = 0 AND inviter_id = ?) \" +\n \" OR id IN (SELECT inviter_id FROM friends WHERE confirmed = 0 AND invitee_id = ?)\",\n session[:user_id], session[:user_id]])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @profile }\n end\n end",
"def show\n @user = User.find(params[:id])\n\t@cuser = current_user\n\t@visible = Relationship.where(\"accessed_id = ? AND accessor_id = ? AND accepted = ?\", @user.id, @cuser.id, true).first || Relationship.where(\"accessed_id = ? AND accessor_id = ? AND accepted = ?\", @cuser.id, @user.id, true).first || (@cuser.id == @user.id)\n\t@title = \"#{@user.first_name} #{@user.last_name}\"\n\tif (@user.relationships.find_by_accessed_id(@cuser).nil?)\n\t\t@rel = @cuser.relationships.find_by_accessed_id(@user)\n\telse\n\t\t@rel = @user.relationships.find_by_accessed_id(@cuser)\n\tend\n\t\t\n end",
"def set_ProfileID(value)\n set_input(\"ProfileID\", value)\n end",
"def profile\n @reviews = current_user.reviews\n @tag = Tag.new\n @new_event = Event.new\n @friends = current_user.friends\n @new_review = Review.new\n @user = current_user\n respond_to do |format|\n format.html\n format.js { render layout: false }\n end\n end",
"def show\n user_profile = UserProfile.new(current_user: current_user)\n\n valid_rn = params[:resource_name]\n if valid_rn.present?\n resource_info = user_profile.resource_info(valid_rn)\n resource = user_profile.current_user_resource_instance(resource_info: resource_info)\n if resource\n resource.current_user = current_user\n # resource_info[:resource_item_name]\n render json: { resource.resource_item_name => resource }\n else\n base_route_segments = resource_info[:base_route_segments]\n unless resource_info[:model].no_master_association\n use_temp_master = \"/masters/#{Master::TemporaryMasterIds.first}\"\n end\n new_path = \"#{use_temp_master}/#{base_route_segments}/new\"\n redirect_to new_path\n end\n\n elsif request.format == :html\n @panels = user_profile.current_user_resource_infos\n render :show\n else\n render json: { user_profile: user_profile.current_user_resource_instances }\n end\n end",
"def if_condition\n \n @profile = Profile.find(params[:id])\n\n if @profile.state_id\n @show_state = State.find(@profile.state_id).name\n else\n @show_state = 'n/a'\n end\n \n if @profile.city\n @show_city = @profile.city\n else\n @show_city = 'n/a'\n end\n \n end",
"def index\n @kid_profile = Profile.find(params[:profile_id])\n @parent_profile = current_user.parent_profile\n @organization = Organization.find(params[:org_id])\n end",
"def show\n @profile = self.current_member.profile\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @profile.to_xml }\n end\n end",
"def test_00020_profilepage_profile_page\n @profile_page.goto_profile\n @browser.wait_until { @profile_page.profile_activity_item.present? }\n\n assert_all_keys({\n :profile_page => @profile_page.profile_page.present?,\n :profile_username_match => @c.users[user_for_test].name == @profile_page.user_name,\n :work_info => @profile_page.profile_workinfo_line.present?,\n :profile_img => @profile_page.profile_img.present?,\n :profile_edit_button => @profile_page.profile_edit_button.present?,\n :profile_activity_item => @profile_page.profile_activity_item.present?,\n :topnav_home => @profile_page.topnav_home.present?,\n :topnav_topic => @profile_page.topnav_topic.present?,\n :topnav_product => @profile_page.topnav_product.present?,\n :topnav_about => @profile_page.topnav_about.present?,\n :topnav_search => @profile_page.topnav_search.present?,\n :topnav_logo => @profile_page.topnav_logo.present?,\n # :browser_title => (@browser.title == \"#{@c.users[user_for_test].name}'s Profile\"),\n })\n \n #TODO\n @profile_page.profile_avatar_img.when_present.hover\n @profile_page.profile_avatar_camera.when_present\n assert @profile_page.profile_avatar_camera.present?\n # comment below assert since it is invisible when no bio\n # assert @profile_page.profile_bioinfo_line.present? \n end",
"def index\n @users = policy_scope(User)\n .includes(:avatar, :main, :rank)\n .order(created_at: :desc)\n .page(params[:page])\n\n @users = @users.where(hidden: false) unless params[:hidden]\n\n authorize @users\n end",
"def for(requesting_user, for_profile)\n requesting_user.id.eql?(for_profile.user_id) ? self.owned_by(for_profile) : self.viewable_for(for_profile)\n end",
"def personal_page?\n return false unless current_user\n return true if params[:owner_id].to_i == current_user.id\n return true if @user && current_user == @user\n return true if @quest && current_user.owns?(@quest)\n return true if @offer && current_user.owns?(@offer)\n \n false\n end",
"def show_private_tab\n current_user && (current_user.admin? || # if current_user is an admin\n current_user.premium? || # current_user is a premium\n current_user.wiki_collaborations.any?) # current_user has any private wiki collaborations\n end",
"def show\n # show all the accepted infractions created by this player\n @player_infractions = @player.infractions.accepted\n # but hide the anonymous infractions when seeing by any person other than the creator\n unless @player.user == current_user\n @player_infractions = @player_infractions.where.not(anonymous: true)\n end\n\n # also show all the information regarding this player being a witness\n @witnesses = @player.witnesses\n @pending_witnesses = @witnesses.select { |witness| pending?(witness) }\n @accepted_witnesses = @witnesses.select { |witness| accepted?(witness) }\n @rejected_witnesses = @witnesses.select { |witness| rejected?(witness) }\n\n if params['tooltip'].nil?\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @player }\n end\n else # show ajax tooltip\n render :partial => 'shared/tooltip', :locals => {\n :image => @player.avatar.url(:thumb), :simple_data => {\n 'Player name' => @player.full_name, 'Team' => @player.team.to_s\n }, :collection => nil\n }\n end\n end",
"def display_personal_info_and_disclaimer\n display_personal_information()\n display_disclaimer()\n end",
"def hide_uoc_info_form\n wait_for_element_and_click form_show_hide_button('Use of Collections Information')\n end",
"def public_profile\n if params['form_profile']\n CsApi::Member.update(current_access_token, @current_user.username, params['form_profile'])\n Resque.enqueue(UpdateBadgeVillePlayer, current_access_token, @current_user.username, 'name,first_name,last_name,profile_pic,badgeville_id') unless ENV['BADGEVILLE_ENABLED'].eql?('false')\n flash.now[:notice] = 'Your profile information has been updated.'\n # get the updated account\n get_account \n end\n @page_title = 'Public Profile'\n end"
] |
[
"0.59980124",
"0.58354694",
"0.5797862",
"0.57949615",
"0.5775649",
"0.570969",
"0.56919116",
"0.5663435",
"0.5656469",
"0.56062245",
"0.55806166",
"0.5534865",
"0.5499659",
"0.5442959",
"0.54041946",
"0.53907263",
"0.538885",
"0.5383257",
"0.53717613",
"0.5371131",
"0.5367791",
"0.5360519",
"0.53422475",
"0.5324512",
"0.53233945",
"0.531891",
"0.53152215",
"0.52994466",
"0.5288328",
"0.52857774",
"0.5257787",
"0.5253387",
"0.5247396",
"0.523964",
"0.522378",
"0.52133954",
"0.5210907",
"0.52052003",
"0.52038395",
"0.5194954",
"0.5191086",
"0.51853883",
"0.517493",
"0.515988",
"0.5149858",
"0.5148991",
"0.5141919",
"0.5140518",
"0.51398",
"0.5133627",
"0.512634",
"0.51254874",
"0.51232505",
"0.51209235",
"0.5116848",
"0.51156974",
"0.51152426",
"0.5114459",
"0.5114286",
"0.5111251",
"0.5105038",
"0.51005137",
"0.5100182",
"0.50974464",
"0.50952286",
"0.5094835",
"0.50933456",
"0.50889647",
"0.5086918",
"0.5083197",
"0.5081648",
"0.50815576",
"0.5081533",
"0.5081533",
"0.5081533",
"0.5081533",
"0.5081533",
"0.5081533",
"0.508001",
"0.5073557",
"0.5069569",
"0.5065072",
"0.5064505",
"0.5060217",
"0.50575185",
"0.50571257",
"0.505695",
"0.5056548",
"0.5056247",
"0.50552845",
"0.5053639",
"0.50488967",
"0.50455904",
"0.5043303",
"0.5040865",
"0.50406545",
"0.50387156",
"0.5030895",
"0.50222623",
"0.5022256",
"0.50206614"
] |
0.0
|
-1
|
Use callbacks to share common setup or constraints between actions.
|
def set_item_data_property_ledger
@item_data_property_ledger = ItemDataPropertyLedger.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_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"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.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Only allow a trusted parameter "white list" through.
|
def item_data_property_ledger_params
params.require(:item_data_property_ledger).permit(:item_id, :data_property_id, :data)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
"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 filtered_parameters; end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def valid_params?; end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def filter_parameters; end",
"def filter_parameters; end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def check_params; true; end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def list_params\n params.permit(:name)\n end",
"def check_params\n true\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def additional_permitted_params\n []\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def allow_params_authentication!; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end",
"def quote_params\n params.permit!\n end",
"def list_params\n params.permit(:list_name)\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def all_params; end",
"def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end",
"def source_params\n params.require(:source).permit(all_allowed_params)\n end",
"def user_params\n end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end",
"def permitted_params\n @wfd_edit_parameters\n end",
"def user_params\r\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def params_permit\n params.permit(:id)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def filter_params\n params.permit(*resource_filter_permitted_params)\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end",
"def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def argument_params\n params.require(:argument).permit(:name)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def parameters\n nil\n end",
"def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end",
"def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end",
"def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end"
] |
[
"0.7120904",
"0.70538116",
"0.69469863",
"0.6901261",
"0.67348766",
"0.6717708",
"0.66874576",
"0.6676195",
"0.66601187",
"0.65563625",
"0.6525127",
"0.64565873",
"0.64494514",
"0.644928",
"0.64452374",
"0.6433947",
"0.6412815",
"0.6412815",
"0.6391939",
"0.63792473",
"0.63792473",
"0.63738",
"0.6360176",
"0.6354222",
"0.6284756",
"0.6277987",
"0.6245304",
"0.62259704",
"0.62243503",
"0.6223834",
"0.62104595",
"0.62081766",
"0.61759263",
"0.61721593",
"0.6168236",
"0.61587787",
"0.6143901",
"0.6135065",
"0.61204714",
"0.61065775",
"0.60983306",
"0.6073666",
"0.6051939",
"0.6040974",
"0.6036216",
"0.60291374",
"0.6020614",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.6017416",
"0.60161096",
"0.6006702",
"0.6002367",
"0.600212",
"0.5996321",
"0.59943277",
"0.59942585",
"0.59858114",
"0.5982845",
"0.59766084",
"0.5973769",
"0.5968758",
"0.59653395",
"0.5964966",
"0.5964966",
"0.5957481",
"0.59511584",
"0.5951042",
"0.5948871",
"0.59427315",
"0.5930573",
"0.5930121",
"0.5926885",
"0.5923959",
"0.59182686",
"0.5916637",
"0.5913613",
"0.5912174",
"0.5906678",
"0.59059656",
"0.5904252",
"0.5901623",
"0.58983696",
"0.58962476",
"0.589576",
"0.5893608"
] |
0.0
|
-1
|
Work with Rails 4 strong parameters
|
def registration_params
begin
p = params.require(:user)
rescue
return false
end
p.permit(:username, :email, :password, :password_confirmation)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def person_params\n params.require(:person).permit!\n end",
"def other_skill_params\n params.require(:other_skill).permit(OtherSkill.safe_attributes)\n end",
"def some_thing_params\n params.require(:some_thing).permit(:val)\n end",
"def player_strong_params\n params.require(:player_strong).permit(:presence, :project_strong_id, :name, :surname, :photopath, :group_type_id, :city, :country, :old, :weight, :height, :description)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def content_form_params\n params.require(form_param_key).permit!\n end",
"def strong_parameters\n\t\t\tattrs = self.attribute_names - [\"created_at\", \"updated_at\", \"id\"]\n\t\t\tattrs.push(:_color) if colored? # add the color attribute to the permitted attributes if the object is colorable\n\t\t\tif is_encrypted? # add the color attribute to the permitted attributes if the object is colorable\n\t\t\t\tattrs.push(:_inki_password) \n\t\t\t\tattrs.push(:_inki_password_confirmation) \n\t\t\tend\n\t\t\tattrs.collect do |a|\n\t\t\t\ta.to_sym\n\t\t\tend\n\t\tend",
"def person_params\n params.require(:person).permit(:name)\n end",
"def good_params\n params.permit(:title)\n end",
"def quote_params\n params.permit!\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def task_params\n params.require(:task).permit(Task.safe_attributes)\n end",
"def task_params\n params.require(:task).permit(Task.safe_attributes)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def student_params(*args) #is the helper method \n\n\t\tparams.require(:student).permit(*args)\n\t\t#uses .require and .permit methods as stronger params to prevent hacks through inspect element right click edit html \n\t\t#require restricts, permit allows, and *args is for the custom arguments\n\tend",
"def tipo_comunicacao_params\n #params.require(:tipo_comunicacao).permit(:analise_privacidade_attributes, :rede_social, :analise_privacidades_id, :tipo_comunicacao, :observacao)\n params.require(:tipo_comunicacao).permit!\n end",
"def permit_attributes\n params.require(resource_as_param_key).permit(*permitted_attributes)\n end",
"def params_permit\n params.permit(:id)\n end",
"def custom_form_params\n params.require(:custom_form).permit!\n end",
"def journal_params\n params.require(:journal).permit(Journal.safe_attributes)\n end",
"def song_params(*args)\n params.require(:song).permit(*args)\nend",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def form_params\n params.permit(Document.allowable_params)\n end",
"def <%= singular_name %>_params\n params.require(:<%= singular_name %>).permit(<%= attributes_allowed %>)\n end",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def valid_params?; end",
"def person_params\n params.require(:person).permit(:name, :occupation, :quote, :special_ability)\n end",
"def person_params\n params.require(:person).permit(:name, :age)\n end",
"def attr_params\n params[:attr].permit(:name, :type, :value, :foreign_key, :ordinal, :group, :visible, :editable, :required, :input)\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def strong_params\n params.require(:applicant).permit(\n :first_name,\n :last_name,\n :email,\n :resume,\n :website_url,\n :linkedin_url,\n :phone_number\n )\n end",
"def model_params\n\t\tparams.require(:competitor).permit(\n \t\t:first_name,\n \t\t:last_name,\n \t\t:address_line_1,\n \t\t:address_line_2,\n \t\t:city,\n \t\t:state,\n \t\t:zip,\n \t\t:grade,\n \t\t:email,\n :school_id,\n :team_id\n \t\t\t)\n\tend",
"def research_question_params\n res = params.require(:research_question).permit(:name, :description, :private, :model_ids => [])\n res[:user] = current_user\n res\n end",
"def person_params\n params.require(:person).permit(:name, :height)\n end",
"def personal_params\n params.require(:amount)\n params.permit(:amount)\n end",
"def song_params\n #Returns a sanitized hash of the params with nothing extra\n #requiring the song model and permitting only these fields\n params.required(:song).permit(:title,:artist_name, :artwork)\n end",
"def education_params\n params.require(:education).permit(Education.safe_attributes)\n end",
"def user_params\n params.require(:user).permit!\n end",
"def user_params\n params.require(:user).permit!\n end",
"def user_params\n params.require(:user).permit!\n end",
"def surgical_params\n params.require(:surgical).permit(Surgical.safe_attributes)\n end",
"def transaction_params\n params.require(:transaction).permit!\n end",
"def contact_params\n params.require(:contact).permit(Contact.safe_attributes)\n end",
"def concessionary_params\n params.require(:concessionary).permit(:name, :telephone)\n end",
"def awesome_stuff_params\n params.require(:awesome_stuff).permit(:name)\n end",
"def backend_user_params\n params.permit!\n end",
"def article_params\n params.require(:article).permit(:title, :text) \n end",
"def document_params\n params.require(:document).permit(Document.safe_attributes)\n end",
"def document_params\n params.require(:document).permit(Document.safe_attributes)\n end",
"def need_params\n params.require(:need).permit(Need.safe_attributes)\n end",
"def person_params\n params.require(:person).permit(:name)\n end",
"def blog_params\n# params[:blog]\n\t\tparams.require(:blog).permit!\n end",
"def engagement_params\n #params.require(:branch).permit(:name, :active, :user_id)\n\n raw_parameters = { :name => \"#{params[:name]}\", :active => \"#{params[:active]}\", :user_id => \"#{params[:user_id]}\", :description => \"#{params[:description]}\" }\n parameters = ActionController::Parameters.new(raw_parameters)\n parameters.permit(:name, :active, :description, :user_id)\n \n end",
"def post_params\n permit_params\n end",
"def expected_permitted_parameter_names; end",
"def key_params\n params.require(:key).permit(:name, :value)\n end",
"def blog_legal_params\n params.require(:blog_legal).permit(:titulo, :texto)\n end",
"def staff_params\n params.require(:person).permit! # allow mass params for now\n end",
"def resource_params\n deserialized_params.permit!\n end",
"def model_params\n if Rails.version < '4.0'\n params[model_identifier]\n else\n params.require(model_identifier).permit(permitted_attrs)\n end\n end",
"def slate_params\n # params.fetch(:slate, {}).permit(:name, :election_cycle)\n\n # alternate ejemplo\n # params.require(:slate).permit(:name, :election_cycle)\n\n params.require(:slate).permit!\n\n\n end",
"def post_params(*args)\n\t\t# strong params ...\n\t\t# can simply call post_params in the update and create method\n\t\tparams.require(:post).permit(*args)\n\tend",
"def person_params\n params.require(:person).permit(:gender, :height, :weight)\n end",
"def hr_person_params\n params.require(:hr_person).permit!\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def post_params\n params.require(:post).permit!\n end",
"def form_params\n params.require(:funding_request).permit(FundingRequest.allowable_params)\n end",
"def user_params\n #byebug\n params.require(:user).permit(:name, :phone, :workgroup, :timezone)\n end",
"def transportation_params\n params.require(:transportation).permit(Transportation.safe_attributes)\n end",
"def form_params\n # Remove role and privilege ids as these are managed by the app not by\n # the active record associations\n params[:user].delete :role_ids\n params[:user].delete :privilege_ids\n params.require(:user).permit(user_allowable_params)\n end",
"def person_params\n params.require(:person).permit(:name, :cpf, :birthdate, :email, :phone, :address, :cep, :city, :uf, :user_id)\n end",
"def interesting_thing_params\n params.require(:interesting_thing).permit(:name, :student_id)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n params.require(:person).permit(:name, :gender)\n end",
"def safe_params\n safe_attributes = %i[name key]\n params.require(:role).permit(safe_attributes)\n end",
"def model_params\r\n params.require(:model).permit(:code, :title, :gender_id, :category_id, :price, :priority, :note)\r\n end",
"def post_params\n # allow attributes that I trust, ignore any scary malicious unsation evil data\n\n params.require(:post).permit(:title, :body, :is_published, :is_featured)\n end",
"def case_support_params\n params.require(:case_support).permit(CaseSupport.safe_attributes)\n end",
"def case_support_params\n params.require(:case_support).permit(CaseSupport.safe_attributes)\n end",
"def user_params\n # params.permit(:content, :color, taggings_attributes: [:id, :tag])\n params.permit(:id)\n end",
"def user_params #este metodo SE PUEDE LLAMAR COMO QUIERAS, pero es necesario para que al crear un objeto se autorice su creacion (porque si no nos podrían meter codigo malicioso)\n\t\tparams.require(:user).permit(:name, :email, :password)\n\tend",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def model_params\n params.require(:model).permit(:code, :name, :brand_id, :manufacture_id, :body_type_id, :note)\n end",
"def student_params\n params.require(:student).permit!\n end",
"def treino_params\n #params.require(:aluno).permit(:idacademia, :nome, :nascimento, :sexo, :observacao)\n params.require(:treino).permit!\n end",
"def transaction_params\n params.require(:transaction).permit!\n end",
"def foo_params\n params.require(:foo).permit(:text, :user_id)\n end",
"def aluno_params\n #params.require(:aluno).permit(:idacademia, :nome, :nascimento, :sexo, :observacao)\n params.require(:aluno).permit!\n end",
"def goal_params\n params.require(:goal).permit(Goal.safe_attributes)\n end",
"def user_params\n params.require(:user).permit!\n end",
"def user_params\n params.require(:user).permit!\n end",
"def capsule_params #strong params\n params.require(:capsule).permit(:name) # param requires a key of capsule and within that key permit a key of name \n #permit a key of name\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end"
] |
[
"0.709536",
"0.70448744",
"0.70181274",
"0.6857846",
"0.68065673",
"0.6789449",
"0.67739236",
"0.6763506",
"0.67374355",
"0.6731862",
"0.6729607",
"0.6702324",
"0.66590965",
"0.6643814",
"0.66240853",
"0.6606347",
"0.6606347",
"0.6601395",
"0.66004115",
"0.6598087",
"0.6592997",
"0.65914446",
"0.6588627",
"0.6587025",
"0.6582485",
"0.6581187",
"0.65732265",
"0.65686095",
"0.65664107",
"0.65656054",
"0.65641505",
"0.65579176",
"0.6548643",
"0.6545357",
"0.653861",
"0.6533029",
"0.65291876",
"0.6525403",
"0.65213525",
"0.6517233",
"0.6515714",
"0.65143496",
"0.65042126",
"0.6495745",
"0.6494895",
"0.6494895",
"0.6494895",
"0.64922184",
"0.64904255",
"0.64879894",
"0.64866793",
"0.6482026",
"0.64790946",
"0.64701575",
"0.64700776",
"0.64700776",
"0.64682794",
"0.6466902",
"0.6466316",
"0.6465388",
"0.6454436",
"0.64532864",
"0.6450971",
"0.6447082",
"0.6446757",
"0.64462066",
"0.64452964",
"0.64422315",
"0.643604",
"0.64344317",
"0.6429563",
"0.6422004",
"0.64208823",
"0.6414396",
"0.6410845",
"0.64092726",
"0.64030975",
"0.6396427",
"0.63955927",
"0.6392435",
"0.63885486",
"0.63851064",
"0.63833994",
"0.6381274",
"0.6380926",
"0.6380926",
"0.63771564",
"0.63756806",
"0.6369538",
"0.6367872",
"0.6366404",
"0.6366375",
"0.63660103",
"0.6365639",
"0.63648105",
"0.6364185",
"0.63638836",
"0.6361984",
"0.6361984",
"0.6361731",
"0.6360478"
] |
0.0
|
-1
|
Work with Rails 4 strong parameters
|
def login_params
begin
p = params.require(:login)
rescue
return false
end
p.permit(:username, :password)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def person_params\n params.require(:person).permit!\n end",
"def other_skill_params\n params.require(:other_skill).permit(OtherSkill.safe_attributes)\n end",
"def some_thing_params\n params.require(:some_thing).permit(:val)\n end",
"def player_strong_params\n params.require(:player_strong).permit(:presence, :project_strong_id, :name, :surname, :photopath, :group_type_id, :city, :country, :old, :weight, :height, :description)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def content_form_params\n params.require(form_param_key).permit!\n end",
"def strong_parameters\n\t\t\tattrs = self.attribute_names - [\"created_at\", \"updated_at\", \"id\"]\n\t\t\tattrs.push(:_color) if colored? # add the color attribute to the permitted attributes if the object is colorable\n\t\t\tif is_encrypted? # add the color attribute to the permitted attributes if the object is colorable\n\t\t\t\tattrs.push(:_inki_password) \n\t\t\t\tattrs.push(:_inki_password_confirmation) \n\t\t\tend\n\t\t\tattrs.collect do |a|\n\t\t\t\ta.to_sym\n\t\t\tend\n\t\tend",
"def person_params\n params.require(:person).permit(:name)\n end",
"def good_params\n params.permit(:title)\n end",
"def quote_params\n params.permit!\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def task_params\n params.require(:task).permit(Task.safe_attributes)\n end",
"def task_params\n params.require(:task).permit(Task.safe_attributes)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def student_params(*args) #is the helper method \n\n\t\tparams.require(:student).permit(*args)\n\t\t#uses .require and .permit methods as stronger params to prevent hacks through inspect element right click edit html \n\t\t#require restricts, permit allows, and *args is for the custom arguments\n\tend",
"def tipo_comunicacao_params\n #params.require(:tipo_comunicacao).permit(:analise_privacidade_attributes, :rede_social, :analise_privacidades_id, :tipo_comunicacao, :observacao)\n params.require(:tipo_comunicacao).permit!\n end",
"def permit_attributes\n params.require(resource_as_param_key).permit(*permitted_attributes)\n end",
"def params_permit\n params.permit(:id)\n end",
"def custom_form_params\n params.require(:custom_form).permit!\n end",
"def journal_params\n params.require(:journal).permit(Journal.safe_attributes)\n end",
"def song_params(*args)\n params.require(:song).permit(*args)\nend",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def form_params\n params.permit(Document.allowable_params)\n end",
"def <%= singular_name %>_params\n params.require(:<%= singular_name %>).permit(<%= attributes_allowed %>)\n end",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def valid_params?; end",
"def person_params\n params.require(:person).permit(:name, :occupation, :quote, :special_ability)\n end",
"def person_params\n params.require(:person).permit(:name, :age)\n end",
"def attr_params\n params[:attr].permit(:name, :type, :value, :foreign_key, :ordinal, :group, :visible, :editable, :required, :input)\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def strong_params\n params.require(:applicant).permit(\n :first_name,\n :last_name,\n :email,\n :resume,\n :website_url,\n :linkedin_url,\n :phone_number\n )\n end",
"def model_params\n\t\tparams.require(:competitor).permit(\n \t\t:first_name,\n \t\t:last_name,\n \t\t:address_line_1,\n \t\t:address_line_2,\n \t\t:city,\n \t\t:state,\n \t\t:zip,\n \t\t:grade,\n \t\t:email,\n :school_id,\n :team_id\n \t\t\t)\n\tend",
"def research_question_params\n res = params.require(:research_question).permit(:name, :description, :private, :model_ids => [])\n res[:user] = current_user\n res\n end",
"def person_params\n params.require(:person).permit(:name, :height)\n end",
"def personal_params\n params.require(:amount)\n params.permit(:amount)\n end",
"def song_params\n #Returns a sanitized hash of the params with nothing extra\n #requiring the song model and permitting only these fields\n params.required(:song).permit(:title,:artist_name, :artwork)\n end",
"def education_params\n params.require(:education).permit(Education.safe_attributes)\n end",
"def user_params\n params.require(:user).permit!\n end",
"def user_params\n params.require(:user).permit!\n end",
"def user_params\n params.require(:user).permit!\n end",
"def surgical_params\n params.require(:surgical).permit(Surgical.safe_attributes)\n end",
"def transaction_params\n params.require(:transaction).permit!\n end",
"def contact_params\n params.require(:contact).permit(Contact.safe_attributes)\n end",
"def concessionary_params\n params.require(:concessionary).permit(:name, :telephone)\n end",
"def awesome_stuff_params\n params.require(:awesome_stuff).permit(:name)\n end",
"def backend_user_params\n params.permit!\n end",
"def document_params\n params.require(:document).permit(Document.safe_attributes)\n end",
"def document_params\n params.require(:document).permit(Document.safe_attributes)\n end",
"def article_params\n params.require(:article).permit(:title, :text) \n end",
"def need_params\n params.require(:need).permit(Need.safe_attributes)\n end",
"def person_params\n params.require(:person).permit(:name)\n end",
"def blog_params\n# params[:blog]\n\t\tparams.require(:blog).permit!\n end",
"def engagement_params\n #params.require(:branch).permit(:name, :active, :user_id)\n\n raw_parameters = { :name => \"#{params[:name]}\", :active => \"#{params[:active]}\", :user_id => \"#{params[:user_id]}\", :description => \"#{params[:description]}\" }\n parameters = ActionController::Parameters.new(raw_parameters)\n parameters.permit(:name, :active, :description, :user_id)\n \n end",
"def post_params\n permit_params\n end",
"def expected_permitted_parameter_names; end",
"def key_params\n params.require(:key).permit(:name, :value)\n end",
"def blog_legal_params\n params.require(:blog_legal).permit(:titulo, :texto)\n end",
"def staff_params\n params.require(:person).permit! # allow mass params for now\n end",
"def resource_params\n deserialized_params.permit!\n end",
"def model_params\n if Rails.version < '4.0'\n params[model_identifier]\n else\n params.require(model_identifier).permit(permitted_attrs)\n end\n end",
"def slate_params\n # params.fetch(:slate, {}).permit(:name, :election_cycle)\n\n # alternate ejemplo\n # params.require(:slate).permit(:name, :election_cycle)\n\n params.require(:slate).permit!\n\n\n end",
"def post_params(*args)\n\t\t# strong params ...\n\t\t# can simply call post_params in the update and create method\n\t\tparams.require(:post).permit(*args)\n\tend",
"def person_params\n params.require(:person).permit(:gender, :height, :weight)\n end",
"def hr_person_params\n params.require(:hr_person).permit!\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def post_params\n params.require(:post).permit!\n end",
"def form_params\n params.require(:funding_request).permit(FundingRequest.allowable_params)\n end",
"def user_params\n #byebug\n params.require(:user).permit(:name, :phone, :workgroup, :timezone)\n end",
"def transportation_params\n params.require(:transportation).permit(Transportation.safe_attributes)\n end",
"def form_params\n # Remove role and privilege ids as these are managed by the app not by\n # the active record associations\n params[:user].delete :role_ids\n params[:user].delete :privilege_ids\n params.require(:user).permit(user_allowable_params)\n end",
"def person_params\n params.require(:person).permit(:name, :cpf, :birthdate, :email, :phone, :address, :cep, :city, :uf, :user_id)\n end",
"def interesting_thing_params\n params.require(:interesting_thing).permit(:name, :student_id)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n params.require(:person).permit(:name, :gender)\n end",
"def safe_params\n safe_attributes = %i[name key]\n params.require(:role).permit(safe_attributes)\n end",
"def model_params\r\n params.require(:model).permit(:code, :title, :gender_id, :category_id, :price, :priority, :note)\r\n end",
"def post_params\n # allow attributes that I trust, ignore any scary malicious unsation evil data\n\n params.require(:post).permit(:title, :body, :is_published, :is_featured)\n end",
"def case_support_params\n params.require(:case_support).permit(CaseSupport.safe_attributes)\n end",
"def case_support_params\n params.require(:case_support).permit(CaseSupport.safe_attributes)\n end",
"def user_params\n # params.permit(:content, :color, taggings_attributes: [:id, :tag])\n params.permit(:id)\n end",
"def user_params #este metodo SE PUEDE LLAMAR COMO QUIERAS, pero es necesario para que al crear un objeto se autorice su creacion (porque si no nos podrían meter codigo malicioso)\n\t\tparams.require(:user).permit(:name, :email, :password)\n\tend",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def model_params\n params.require(:model).permit(:code, :name, :brand_id, :manufacture_id, :body_type_id, :note)\n end",
"def student_params\n params.require(:student).permit!\n end",
"def treino_params\n #params.require(:aluno).permit(:idacademia, :nome, :nascimento, :sexo, :observacao)\n params.require(:treino).permit!\n end",
"def transaction_params\n params.require(:transaction).permit!\n end",
"def foo_params\n params.require(:foo).permit(:text, :user_id)\n end",
"def aluno_params\n #params.require(:aluno).permit(:idacademia, :nome, :nascimento, :sexo, :observacao)\n params.require(:aluno).permit!\n end",
"def goal_params\n params.require(:goal).permit(Goal.safe_attributes)\n end",
"def user_params\n params.require(:user).permit!\n end",
"def user_params\n params.require(:user).permit!\n end",
"def capsule_params #strong params\n params.require(:capsule).permit(:name) # param requires a key of capsule and within that key permit a key of name \n #permit a key of name\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end"
] |
[
"0.70956105",
"0.7045022",
"0.7018351",
"0.68581796",
"0.68067217",
"0.6789715",
"0.67742157",
"0.6763879",
"0.67376703",
"0.6732135",
"0.67298895",
"0.6702509",
"0.66594124",
"0.66441065",
"0.662438",
"0.6606626",
"0.6606626",
"0.660173",
"0.6600566",
"0.6598159",
"0.65933806",
"0.6591529",
"0.6589036",
"0.6587289",
"0.6582801",
"0.65812826",
"0.65735096",
"0.6569046",
"0.6566598",
"0.6565864",
"0.65645206",
"0.65581036",
"0.6548756",
"0.6545542",
"0.653882",
"0.65332866",
"0.6529478",
"0.65256727",
"0.6521621",
"0.65175086",
"0.65159416",
"0.6514654",
"0.6504535",
"0.64960027",
"0.6495048",
"0.6495048",
"0.6495048",
"0.64925414",
"0.64907944",
"0.6488032",
"0.6486895",
"0.6482326",
"0.64792377",
"0.64704216",
"0.64704216",
"0.6470335",
"0.6468597",
"0.64670885",
"0.64665645",
"0.6465627",
"0.64545673",
"0.64534277",
"0.645131",
"0.64472646",
"0.6446887",
"0.64463925",
"0.64456666",
"0.6442497",
"0.64362353",
"0.6434547",
"0.6429744",
"0.64221734",
"0.64210963",
"0.64146686",
"0.6411007",
"0.6409314",
"0.64032435",
"0.63965327",
"0.6395876",
"0.6392665",
"0.63886666",
"0.63853836",
"0.6383715",
"0.6381525",
"0.6381114",
"0.6381114",
"0.6377308",
"0.637586",
"0.63697916",
"0.636793",
"0.63668126",
"0.6366671",
"0.63661474",
"0.6366004",
"0.63649637",
"0.6364155",
"0.6364015",
"0.63621414",
"0.63621414",
"0.63619393",
"0.63606405"
] |
0.0
|
-1
|
Given a hash with numeric values, return the key for the smallest value
|
def key_for_min_value(name_hash)
current = 0
lowest = 0
lowest_key = nil
name_hash.collect do |key, value|
current = value
if current < lowest || lowest == 0
lowest = current
lowest_key = key
end
end
lowest_key
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |k, v|\n if v < lowest_value\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n smallest_value = nil\n smallest_key = nil\n hash.each do |name, num|\n if smallest_value == nil || num < smallest_value\n smallest_value = num\n smallest_key = name\n end\n end\n smallest_key\nend",
"def key_for_min_value(hash)\n min_val = Float::INFINITY\n min_key = nil\n hash.each do |key, value|\n if value < min_val\n min_val = value\n min_key = key\n end\n end\n min_key\nend",
"def key_for_min_value(hash)\n \n min_val = Float::INFINITY\n min_key = nil\n hash.each do |k, v|\n if min_val > v\n min_val = v\n min_key = k\n end\n end\n return min_key\nend",
"def key_for_min_value(hash)\n smallest_key = nil\n tiny_value = nil\n hash.each do |key, value|\n if tiny_value == nil || value < tiny_value\n tiny_value = value\n smallest_key = key\n end\n end\n smallest_key\nend",
"def key_for_min_value(hash)\n smallest = nil\n key = nil\n hash.collect do |name, val|\n if smallest == nil || val < smallest\n smallest = val\n key = name\n end\n end\n key\nend",
"def key_for_min_value(hash)\n int_hash = hash.select { |key, val| val.class == Fixnum }\n smallest = int_hash[int_hash.keys.sample]\n # debugger\n int_hash.each do |key, val|\n if val < smallest\n smallest = val \n end\n end\n int_hash.key(smallest)\nend",
"def key_for_min_value(hash)\r\n smallest_key = nil\r\n tiniest_value = nil\r\n hash.each do |key, value|\r\n if tiniest_value == nil || value < tiniest_value\r\n tiniest_value = value\r\n smallest_key = key\r\n end\r\n end\r\n smallest_key\r\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = 0\n\n\n hash.each do |key,value|\n if lowest_value == 0 || value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n min = nil\n hash.each_pair do |key, value|\n min ||= value\n min = value if value < min\n end\n hash.key(min)\nend",
"def key_for_min_value(hash)\n smallest = nil\n hash.each do |key, value|\n if smallest == nil\n smallest = key\n end\n if hash[key] < hash[smallest]\n smallest = key\n end\n end\n smallest\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil\n hash.each do |k, v|\n if lowest_value == nil || v < lowest_value\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil\n hash.each do |k, v|\n if lowest_value == nil || v < lowest_value\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n smallest_key = nil\n tiniest_value = nil\n hash.each do |key, value|\n if tiniest_value == nil || value < tiniest_value\n \n # this way, the smallest value in the hash so far always overwrites the existing tiniest value\n \n tiniest_value = value\n smallest_key = key\n end\n end\n smallest_key\nend",
"def key_for_min_value(hash)\n hash_key = nil\n hash_value = nil\n hash.each do |key, value|\n if hash_value == nil || value < hash_value\n hash_value = value\n hash_key = key\n end\n end\n hash_key\nend",
"def key_for_min_value(hash)\n min_key = nil\n hash.each do |key, value|\n if min_key.nil?\n min_key = key\n elsif value < hash[min_key]\n min_key = key\n else\n next\n end\n end\n min_key\nend",
"def key_for_min_value(hash)\n min_key = nil\n hash.each do |key, value|\n if min_key.nil?\n min_key = key\n elsif value < hash[min_key]\n min_key = key\n else\n next\n end\n end\n min_key\nend",
"def key_for_min_value(hash)\n min = 99999999\n min_key = nil\n hash.select do |key, value|\n if value < min\n min = value\n min_key = key\n end\n end\n min_key\nend",
"def key_for_min_value(hash)\n if hash.empty?\n return nil\n end\n ans = [hash.first[0],hash.first[1]]\n hash.each do |k,v|\n if v < ans[1]\n ans[1] = v\n ans[0] = k\n end\n end\n return ans[0]\nend",
"def key_for_min_value(hash)\n key = nil\n lowest_value = nil\n hash.each do |name, value|\n if lowest_value == nil || value < lowest_value\n lowest_value = value\n key = name\n end\nend\nkey\nend",
"def key_for_min_value(hash)\n hash_key = nil\n hash_value = nil\n hash.each do |a, b|\n if hash_value == nil || b < hash_value\n hash_value = b\n hash_key = a\n end\n end\n hash_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil \n hash.each do |key, value|\n if lowest_value == nil || value < lowest_value \n lowest_value = value \n lowest_key = key \n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n lowestnum = 1000\n name_hash.each_value do |hashvalue|\n if hashvalue < lowestnum\n lowestnum = hashvalue\n end\n end\n name_hash.index(lowestnum)\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_number = nil\n name_hash.each do |name, number|\n if lowest_number == nil || number < lowest_number\n lowest_number = number\n lowest_key = name\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil\n hash.each do |k,v|\n # first iteration\n ## this creates a starting point for comparison\n if lowest_value == nil || lowest_value > v\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n low = Float::INFINITY\n name_hash.each do |k,v|\n if v < low\n low = v\n end\n end\n name_hash.key(low)\nend",
"def key_for_min_value(hash)\n small_key = nil\n small_value = nil\n \n hash.each do |key, value|\n if small_value == nil || value < small_value\n small_value = value\n small_key = key\n end\nend\nsmall_key\nend",
"def key_for_min_value(hash)\n low_min = 1000\n min_key = nil\n hash.each do |key, value|\n if(low_min > value)\n low_min = value\n min_key = key\n end\nend\n min_key\nend",
"def key_for_min_value(name_hash)\n lowest = nil\n key = nil\n if name_hash.length == 0\n return \n end\n \n name_hash.each do |name, number|\n if lowest == nil\n lowest = number\n end\n if key == nil\n key = name\n end\n if number < lowest\n lowest = number\n key = name\n end\n end\n key\nend",
"def key_for_min_value(hash)\n least_value = nil \n least_key = nil\n hash.each do |a, b|\n if least_value == nil || b < least_value\n least_value = b\n least_key = a\n end\n end\n least_key\nend",
"def key_for_min_value(name_hash)\n\tif name_hash == {}\n\t\tnil\n\tend\n\n\tsmallest_key = nil\n\tsmallest_value = nil\n\tname_hash.each do |key, value|\n\t\tif !smallest_value || value < smallest_value\n\t\t\tsmallest_key = key\n\t\t\tsmallest_value = value\n\t\tend\n\tend\n\tsmallest_key\nend",
"def key_for_min_value(hash)\n i = 0\n lowest1 = :key\n lowest = 0\n if hash.empty? == true \n return nil\n end\n hash.each do |name, value|\n if i == 0\n lowest1 = name\n lowest = value\n i =+ 1\n end\n if value < lowest\n lowest1 = name\n lowest = value\n end\n if hash.empty? == true \n lowest1 = nil\n end\n end\n lowest1\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n name_hash.each do |name, amount|\n if amount < lowest_value\n lowest_value = amount\n lowest_key = name\n end\n end\n lowest_key\n end",
"def key_for_min_value(hash)\n lo_key = nil \n lo_value = nil \n hash.each do |k,v| \n if lo_key == nil || v < lo_value\n lo_key = k \n lo_value = v \n end \n end \n lo_key\n end",
"def key_for_min_value(hash)\n\n lowest_key = nil \n lowest_value = nil \n \n hash.each do |key,value|\n if lowest_value == nil || lowest_value > value\n\n lowest_key = key\n lowest_value = value \n end \n \n end \n lowest_key\nend",
"def key_for_min_value(name_hash)\n small_num = Float::INFINITY\n smallest_key = \"\"\n if name_hash.length == 0\n return nil\n end\n name_hash.each do |key, value|\n if value < small_num\n small_num = value\n smallest_key = key\n end\n end\nsmallest_key\nend",
"def key_for_min_value(hash)\n value_only_array = []\n hash.each_pair do |key, value|\n value_only_array << value\n end\n value_only_array.sort!\n hash.key(value_only_array[0])\nend",
"def key_for_min_value(hash)\n return nil if hash.empty?\n arr = hash.collect {|key, value| value}.sort\n hash.each {|key, value| return key if value == arr[0]}\nend",
"def key_for_min_value(hash)\n array = []\n hash.each do |key, value|\n array << value\n end\n array.sort!\n hash.key(array[0])\nend",
"def key_for_min_value(name_hash)\n lowest_key=nil\n lowest_value=Float::INFINITY\n name_hash.each{|key, value| \n if value<lowest_value\n lowest_value=value\n lowest_key=key\n end\n }\n lowest_key\nend",
"def key_for_min_value(name_hash)\n empty_hash = nil\n lowest_value = 10000000000000000000000\n name_hash.collect do |name, value|\n if value < lowest_value\n lowest_value = value\n empty_hash = name\n end\n end\n empty_hash\nend",
"def key_for_min_value(name_hash)\n lowest = \"\"\n lowest = nil if name_hash.empty?\n high_num = 100000000000000000\n name_hash.each do | key, value |\n lowest = key if value < high_num\n high_num = value if value < high_num\n end\n lowest\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_value = nil\n name_hash.each do |name, num|\n if lowest_key == nil || num < lowest_value\n lowest_key = name\n lowest_value = num\n elsif name_hash == nil\n nil\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n num = nil\n name_hash.collect do |key, value|\n if value < num\n num = value\n end\n end \n name_hash.key(num)\nend",
"def key_for_min_value(name_hash)\n smallest_val = 0\n smallest_key = nil\n name_hash.each do|key, val|\n if smallest_val == 0 || val < smallest_val\n smallest_val = val\n smallest_key = key\n end\n end\n smallest_key\n\nend",
"def key_for_min_value(name_hash)\n smallest_hash_key = nil\n name_hash.each do |key, val|\n if smallest_hash_key == nil\n smallest_hash_key = key\n next\n elsif val < name_hash[smallest_hash_key]\n smallest_hash_key = key\n end\n end\n smallest_hash_key\nend",
"def key_for_min_value(hash)\n if hash.count < 2\n return hash[0]\n else \n num = 42\n hash.each do |key, value|\n if value <= num\n num = value\n end\n end\n hash.invert[num] \n end\nend",
"def key_for_min_value(name_hash)\n return nil if name_hash.empty?\n lowest_number = name_hash.first[1];\n key_value = \"\"\n name_hash.each do |key, value|\n if value <= lowest_number\n lowest_number = value\n key_value = key\n end\n end\n key_value\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n lowestvalue = 1000\n name_hash.each do |name, value|\n if value < lowestvalue\n lowest_key = name\n lowestvalue = value\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n small_value = 10000000000\n small_key = nil\n name_hash.each do |k,v|\n if v < small_value\n small_value = v\n small_key = k\n end\n end\n small_key\nend",
"def key_for_min_value(name_hash)\n low_key = nil\n low_value = nil\n name_hash.each do |k, v|\n if low_value == nil || v < low_value\n low_value = v\n low_key = k\n end\n end\n low_key\n end",
"def key_for_min_value(hash)\n lowest_value = nil\n lowest_key = nil\n\n hash.each do |key, value|\n if lowest_value == nil # tell me if this makes sense\n lowest_value = value\n lowest_key = key\n elsif lowest_value > value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key #you want to return the key for min\nend",
"def key_for_min_value(hash)\n \n if hash.empty?\n return nil\n end\n min_value=500\n min_key=:symbol\n \n hash.each do |key, value|\n if value<min_value\n min_value=value\n min_key=key\n end\n end\n return min_key\nend",
"def key_for_min_value(name_hash)\n lowestKey = nil\n lowestValue = Float::INFINITY\n name_hash.each do |k, v|\n if v < lowestValue\n lowestValue = v\n lowestKey = k\n end\n end\n lowestKey\n\nend",
"def key_for_min_value(name_hash)\n smallest_val = 0\n smallest_key = 0\n comp = nil\n name_hash.each do |key,val|\n comp = val\n if smallest_key == 0\n smallest_key = key\n smallest_val = val\n end \n if comp < smallest_val\n smallest_val = comp\n smallest_key = key\n end\n end\n if smallest_key == 0 \n return nil \n else\n return smallest_key\n end\nend",
"def key_for_min_value(name_hash)\n lowest_key=nil\n lowest_val=0\n name_hash.collect do |key,value|\n if value<lowest_val or lowest_val==0\n lowest_key=key\n lowest_val=value\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n smallest = nil\n this_num = 0\n previous_num = 1000000\n name_hash.collect { |item, qty|\n this_num = qty\n if this_num < previous_num\n smallest = item\n previous_num = this_num\n end\n }\n smallest\nend",
"def key_for_min_value(name_hash)\n rkey = nil\n rvalue = 10000000000000000\n name_hash.each do |key, value|\n if value < rvalue\n rkey = key\n rvalue = value\n end\n end\n rkey\nend",
"def key_for_min_value(name_hash)\n\tsmallest_value = nil\n\tassociated_key = nil \n\tname_hash.collect do |key, value|\n\t\tif smallest_value == nil || value < smallest_value\n\t\t\tsmallest_value = value \n\t\t\tassociated_key = key\n\t \tend\n\tend\n\tassociated_key\nend",
"def key_for_min_value(hash)\n # binding.pry\n lowest_key = nil\n lowest_value = 0\n # binding.pry\n hash.each do |key, value|\n if lowest_key == nil || value < lowest_value\n # binding.pry\n lowest_value = value\n lowest_key = key\n # binding.pry\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n hash.key(hash.values.min)\nend",
"def key_for_min_value(hash)\n hash.key(hash.values.min)\nend",
"def key_for_min_value(name_hash)\n smallest_value = 100\n name_hash.each do |key, value| \n if value < smallest_value\n smallest_value = value \n end \n end\n name_hash.key(smallest_value)\nend",
"def key_for_min_value(name_hash)\n lowest=\"\"\n lowest=nil if name_hash.empty?\n tracker=100000000\n name_hash.each do |key,value|\n lowest=key if value<tracker\n tracker=value if value<tracker\n # if value<tracker\n end\n lowest\nend",
"def key_for_min_value(name_hash)\n if name_hash.length == 0 \n nil\n else\n smallest_num = nil\n smallest_num_key = nil\n name_hash.collect do |key, value|\n if smallest_num == nil\n smallest_num = value\n smallest_num_key = key\n elsif smallest_num > value\n smallest_num = value\n smallest_num_key = key\n end\n end\n smallest_num_key\n end\n\nend",
"def key_for_min_value(name_hash)\n low_key = nil\n low_value = nil\n name_hash.each do |n, s|\n if low_value == nil\n low_value = s\n low_key = n\n elsif low_value > s\n low_value = s\n low_key = n\n end\n end\n low_key\nend",
"def key_for_min_value(name_hash)\n return nil if name_hash == nil || name_hash == {}\n number_array = name_hash.collect do |name, number|\n number\n end\n number_array.sort!\n name_hash.key(number_array[0])\nend",
"def key_for_min_value(name_hash)\n lowestId = nil\n lowestNum = 0\n name_hash.each{ |id, val|\n if lowestNum == 0 \n lowestNum = val\n end\n if val <= lowestNum\n lowestNum = val\n lowestId = id\n end\n }\n return lowestId\nend",
"def key_for_min_value(name_hash)\n lowest_v = nil\n lowest_k = nil\n name_hash.each do |name, value|\n if lowest_v == nil\n lowest_v = value\n lowest_k = name\n elsif value < lowest_v\n lowest_v = value\n lowest_k = name\n end\n end\n lowest_k\n end",
"def key_for_min_value(name_hash)\n smallest_key = nil\n smallest_value = nil\n name_hash.each do |j, r|\n if smallest_value == nil || r < smallest_value\n smallest_value = r\n smallest_key = j\n end\n end\n smallest_key\nend",
"def key_for_min_value(name_hash)\nlowest = 1000000\n low_key = nil\n name_hash.each {|key, value|\n if value < lowest\n lowest = value\n low_key = key\n end\n }\n low_key\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n name_hash.each_key do |key|\n if lowest_key == nil\n lowest_key = key\n elsif name_hash[key] < name_hash[lowest_key]\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n\n if name_hash.empty?\n return nil\n end\n lowest = Float::INFINITY\n name_hash.each_pair do |k, v|\n if v < lowest\n lowest = v\n end\n end\n name_hash.each_pair do |k, v|\n if v == lowest\n return k\n end\n end\nend",
"def key_for_min_value(name_hash)\n output = 0\n smallest = nil\n name_hash.map do |key, value|\n if value < output || output == 0\n output = value\n smallest = key\n end\n end\n\n smallest\nend",
"def key_for_min_value(my_hash)\n #what is my value?\n lowest_value = 500\n lowest_key = nil\n\n my_hash.collect do |key, value|\n # what is my value?\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n lowest_num = 1000000000\n lowest_num_key = \" \"\n if name_hash == {}\n return nil\n else\n name_hash.each do |name, num|\n if num < lowest_num\n lowest_num = num\n lowest_num_key = name\n end\n end\n return lowest_num_key\n end\nend",
"def key_for_min_value(name_hash)\n nums = name_hash.collect do |item, num|\n num\n end\n nums.sort!\n nums[0]\n \n min_key = nil\n name_hash.map do |item, num|\n if num == nums[0]\n min_key = item\n end\n end\n min_key\nend",
"def key_for_min_value(name_hash)\n vals = name_hash.collect { |key, value| value }\n keys = name_hash.collect { |key, value| key }\n low = vals[0]\n lowkey = keys[0]\n if name_hash.empty?\n nil\n else\n name_hash.collect do |key, value|\n if value < low\n low = value\n lowkey = key\n end\n end\n lowkey\n end\nend",
"def key_for_min_value(name_hash)\n value1 = 0\n lowestKey = nil\n name_hash.each do |key, value|\n if(value1 == 0)\n value1 = value\n lowestKey = key\n end\n if(value1 > value)\n value1 = value\n lowestKey = key\n elsif (value1 < value)\n lowestKey = lowestKey\n value1 = value1\n end\n end\n return lowestKey\nend",
"def key_for_min_value(hash)\n return nil if hash.empty?\n arr = hash.collect { |k, v| v }.sort\n hash.each { |k, v| return k if v == arr[0] }\nend",
"def key_for_min_value(name_hash)\n # saves the smaller value in memo, and takes the first elem of memo at the end (the key)\n smallest = name_hash.inject do|memo, (k, v)|\n memo = v < memo[1] ? [k,v] : memo\n end\n #handle the empty hash case...\n smallest ? smallest[0] : nil\nend",
"def key_for_min_value(name_hash)\n key = \"\"\n low_value = nil\n if name_hash.empty? == true\n return nil\n end\n name_hash.each do |name, number|\n if low_value == nil || number < low_value\n low_value = number\n key = name\n end\n end\n key\nend",
"def key_for_min_value(name_hash)\n answer = nil\n smallest = nil\n name_hash.each {|key, value|\n if smallest.nil?\n smallest = value\n end\n if value <= smallest\n smallest = value\n answer = key\n end\n }\n answer\nend",
"def smallest_key(q, hash)\n\t\ttemp = {}\n\t\tq.each do |v|\n\t\t\ttemp[v] = hash[v]\n\t\tend\n\t\treturn temp.key(temp.each_value.min)\n\tend",
"def key_for_min_value(name_hash)\n lowest_value = 0\n lowest_key = \"\"\n if name_hash.empty? == true\n nil\n else\n name_hash.each_with_index do |(key, value), i|\n if i == 0\n lowest_value = value\n lowest_key = key\n elsif value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\n end\nend",
"def key_for_min_value(name_hash)\n low=10000000000000000000\n return_key=nil\n name_hash.each do |key, value|\n if value<low\n low=value\n return_key=key\n end\n end\n return_key\nend",
"def key_for_min_value(hash)\n if hash.length == 0\n return nil\n else\n smallest = 1000\n printme = \"\"\n hash.each do |thing, number|\n if number < smallest\n smallest = number\n printme = thing\n end\n end\n printme\n end\nend",
"def key_for_min_value(name_hash)\n \n lowest_key = nil\n lowest_value = nil\n name_hash.each do |name_key, name_value|\n if lowest_value == nil || name_value < lowest_value\n lowest_value = name_value\n lowest_key = name_key\n end\n end\n lowest_key\n \n end",
"def key_for_min_value(name_hash)\n the_key = nil \n the_value = 1/0.0\n # Infinity...can also be expressed as FLOAT::Infinity\n name_hash.each do |id, num|\n if num <= the_value\n the_value = num\n the_key = id\n end\n end\n the_key\nend",
"def key_for_min_value(hash)\n array = []\n hash.each {|key,value| \n if array.empty? || value < array[1] \n array[0] = key \n array[1] = value \n end }\n if !array.empty? \n array.first \n else \n nil \n end\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n name_hash.each do |k,v|\n if v < lowest_value\n lowest_value = v\n lowest_key = k\n end \nend\nlowest_key\nend",
"def key_for_min_value(name_hash)\n return nil if name_hash == {}\n smallest_key = name_hash.first[0]\n smallest_val = name_hash.first[1]\n\n name_hash.each do |pair|\n if pair[1] < smallest_val\n smallest_key = pair[0]\n end\n end\n smallest_key\nend",
"def key_for_min_value(name_hash)\n key_of_smallest_value = \"\"\n smallest_value = 99999\n name_hash.each do |key, value|\n if smallest_value > value\n smallest_value = value\n key_of_smallest_value = key\n end\n end\n if name_hash.size == 0\n key_of_smallest_value = nil\n end\n key_of_smallest_value\nend",
"def key_for_min_value(name_hash)\n smallest_value = Float::INFINITY\n key_for_smallest_val = nil\n name_hash.each do |key, value|\n if smallest_value > value\n smallest_value = value\n key_for_smallest_val = key\n end \n end \n key_for_smallest_val\nend",
"def key_for_min_value(name_hash)\n minKey = nil\n minVal = 2 ** (64 - 2) - 1\n name_hash.each {|key, value|\n if value < minVal\n minVal = value\n minKey = key\n end}\n minKey\nend",
"def key_for_min_value(name_hash)\n if name_hash == {}\n return nil\n end\n lowest_number = nil\n name_hash.collect do |name, value|\n if lowest_number == nil\n lowest_number = value\n elsif lowest_number > value\n lowest_number = value\n end\n end\n \n name_hash.each do |name, value|\n if lowest_number == value\n return name\n end\n end\nend",
"def key_for_min_value(hash)\n min_value = hash.values.min\n keys = hash.collect do |key, num|\n \tkey if num == min_value\n end\n keys\nend",
"def key_for_min_value(name_hash)\n lowest_value = nil\n key_value = nil\n name_hash.collect do |name, number|\n if lowest_value == nil || number < lowest_value\n lowest_value = number\n key_value = name\n end\n end\n key_value\nend",
"def key_for_min_value(name_hash)\n smallest_value = 1/0.0\n key_of_smallest_value = nil\n name_hash.each do |key, value|\n if smallest_value > value\n key_of_smallest_value = key\n smallest_value = value\n end\n end\n return key_of_smallest_value\nend"
] |
[
"0.8821222",
"0.8777674",
"0.87769854",
"0.8745862",
"0.8689437",
"0.86553806",
"0.865241",
"0.86165065",
"0.8587693",
"0.8572328",
"0.85674095",
"0.8550907",
"0.8529734",
"0.8529734",
"0.85182345",
"0.84936565",
"0.8475531",
"0.8475531",
"0.8466132",
"0.8449126",
"0.84490585",
"0.84359556",
"0.84328413",
"0.8430745",
"0.8428166",
"0.84090126",
"0.8388222",
"0.83684903",
"0.83568215",
"0.83524764",
"0.8345625",
"0.8343887",
"0.8328773",
"0.83284044",
"0.83269894",
"0.83253354",
"0.83201903",
"0.83164364",
"0.8312503",
"0.8312319",
"0.8304851",
"0.83014053",
"0.83008987",
"0.82917446",
"0.8288315",
"0.82870966",
"0.8274123",
"0.82674986",
"0.8267187",
"0.8250538",
"0.82443976",
"0.82439804",
"0.8243696",
"0.82416916",
"0.8240566",
"0.823854",
"0.82375354",
"0.82283455",
"0.82274485",
"0.82205135",
"0.82190055",
"0.82136935",
"0.82136935",
"0.82102376",
"0.82101446",
"0.82060164",
"0.8200657",
"0.81985617",
"0.81966525",
"0.81958514",
"0.81932545",
"0.81874573",
"0.8186549",
"0.8185174",
"0.8183619",
"0.8183068",
"0.8182941",
"0.8179895",
"0.8173536",
"0.81732464",
"0.8172825",
"0.81721044",
"0.8171692",
"0.81681263",
"0.8165602",
"0.81609225",
"0.8160289",
"0.81587887",
"0.815757",
"0.8154019",
"0.81534094",
"0.8152752",
"0.81524456",
"0.8151455",
"0.81511825",
"0.8151019",
"0.8146792",
"0.814368",
"0.8142542",
"0.81412685"
] |
0.82527804
|
49
|
Will include all attribute from API document
|
def searches
wrapping!(
search(
root_uri,
data_raw.to_s.gsub('=>', ':')
)
)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def include_attrs\n @include_attrs\n end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def api_attributes\n {\n :id => id.to_s,\n :type => self.class.name.underscore.downcase,\n :photo => photo,\n :chapter => chapter.api_attributes,\n :caption => caption,\n }\n end",
"def api_attributes(ref = nil)\n {\n :id => id.to_s,\n :type => self.class.name.underscore.downcase,\n :speaker => speaker.api_attributes,\n :chapter => ref != 'chapters' ? chapter.api_attributes : '',\n }\n end",
"def attributes\n scraper.attributes.keys + uri_response_attributes + [:feed]\n end",
"def attributes\n end",
"def attributes\n end",
"def api_attributes\n {\n :id => id.to_s,\n :type => self.class.name.downcase,\n :name => name,\n :title => title,\n :about => about,\n :portrait => portrait,\n :sort => sort,\n }\n end",
"def get_attribs_all( )\n url = \"#{self.url}/cid?auth=#{self.authtoken}\"\n status, response = rest_get( url )\n return status, response['results'] if ok?( status ) && response['results']\n return status, ''\n end",
"def api_attributes\n {\n :id => id.to_s,\n :type => self.class.name.downcase,\n :name => name,\n :description => description,\n :sponsorship_level => sponsorship_level.api_attributes,\n :logo => logo,\n }\n end",
"def api_attributes\n {\n :id => id.to_s,\n :type => self.class.name.downcase,\n :name => name,\n :description => description,\n :sponsorship_level => sponsorship_level.api_attributes,\n :logo => logo,\n }\n end",
"def attributes\n data.require(:attributes)\n end",
"def api_attributes\n {\n :id => id.to_s,\n :type => self.class.name.underscore.downcase,\n :name => name,\n :description => description,\n :partner => partner.present? ? partner.api_attributes : \"\",\n :day => day.present? ? day.api_attributes : \"\",\n :venue => venue.present? ? venue.api_attributes : \"\",\n :event_type => event_brand.present? ? event_brand.api_attributes : \"\",\n :banner => banner.url,\n :lab_host => lab_host.url,\n :start_time => start_time,\n :end_time => end_time,\n }\n end",
"def attributes\n data[:attributes]\n end",
"def api_attributes\n {\n :id => id.to_s,\n :type => self.class.name.underscore.downcase,\n :name => name,\n :title => title,\n :bio => bio,\n :twitter_screen_name => twitter_screen_name,\n :permalink => permalink,\n :photo => portrait.url\n }\n end",
"def attribute(opts)\n raise ArgumentError unless opts.is_a?(Hash)\n # extract the documentation part and add it where it belongs\n new_attribute = Attribute.new(opts)\n @attributes << new_attribute\n # document the attribute if description available\n # we might want to have a placeholder message when a response attribute isn't defined\n if opts.has_key?(:doc)\n @doc.attribute(new_attribute.name, opts[:doc])\n end\n @attributes\n end",
"def api_attributes\n {\n :id => id.to_s,\n :type => self.class.name.underscore.downcase,\n :name => name,\n :sort => sort,\n }\n end",
"def attributes\n @attributes ||= {}\n @attributes\n end",
"def set_attributes\n attributes :all\n end",
"def api_attributes\n {\n :id => id.to_s,\n :type => self.class.name.underscore.downcase,\n :name => name,\n }\n end",
"def attributes\n @attributes ||= []\n @attributes\n end",
"def annotations_with_attribute(attrib, include_values = false)\n return [] if attrib.blank?\n\n obj_type = self.class.base_class.name\n\n options = {\n joins: :annotation_attribute,\n conditions: { annotatable_type: obj_type,\n annotatable_id: id,\n annotation_attributes: { name: attrib.strip.downcase } },\n order: 'updated_at DESC'\n }\n\n options[:include] = [:value] if include_values\n\n fetch_annotations(options)\n end",
"def attributes\n ATTRIBUTES.each_with_object({}) do |name, buffer|\n buffer[name] = public_send(name)\n end\n end",
"def attr_list\n\t\ta_list \n\tend",
"def fetch_custom_attributes\n endpoint = \"/api/#{@version}/custom-attributes/\"\n make_get_request(endpoint)\n end",
"def to_rest\n return attributes\n end",
"def to_rest\n return attributes\n end",
"def attributes\n @attributes ||= descriptors_fields.select{|field| field.scope == ATTRIBUTE_FIELDS }\n end",
"def attributes\n @build['attributes']\n end",
"def attributes\n @attributes ||= get_field_by_type(ATTRIBUTE_FIELDS)\n end",
"def include_attributes\n @include_attributes\n end",
"def attributes\n @attributes\n end",
"def accept_all_attributes\n accept_attributes Object\n end",
"def build_complex_attributes(document)\n document.identifier = identifier\n document.description = description\n document.access_rights = geo_concern.solr_document.visibility\n end",
"def attributes\n @attributes ||= []\n end",
"def attributes\n @attrs\n end",
"def attributes\r\n hash = super\r\n hash.delete('author')\r\n hash.delete('images')\r\n hash[\"document_type\"] = document_type\r\n hash[\"section_name\"] = section_name\r\n hash\r\n end",
"def attributes(*args)\n args.each do |attr|\n attribute(attr)\n end\n end",
"def attributes\n ATTRIBUTES\n end",
"def parse_attributes! #:nodoc:\n self.attributes = (attributes || []).map do |attr|\n Barbecue::Generators::GeneratedAttribute.parse(attr)\n end\n end",
"def attributes\n platform.attributes.rmerge(suite.attributes)\n end",
"def attributes\n attrs = super\n if attrs['user'] && attrs['user']['id']\n attrs.merge!('user_id' => attrs['user']['id'])\n attrs.delete 'user'\n end\n attrs\n end",
"def attributes\n @list.map(&:attributes)\n end",
"def attributes(*args)\n args.each { |attr| attribute(attr) }\n end",
"def all_attributes\n the_attrs = Hash[accessors.collect {|v| [v, send(v.to_s)] if respond_to? \"#{v}\".to_sym}]\n (respond_to?(:attributes) && attributes.merge(the_attrs)) || the_attrs\n end",
"def attributes\n Hash[attribute_pairs].\n merge(media_attributes)\n end",
"def attributes\n @_attributes\n end",
"def attributes\n @attributes\n end",
"def attributes\n @attributes\n end",
"def attributes\n @attributes\n end",
"def api_attributes\n {\n :id => id.to_s,\n :type => self.class.name.underscore.downcase,\n :user => user.api_attributes,\n :member_type => member_type.api_attributes,\n :first_name => first_name,\n :last_name => last_name,\n }\n end",
"def attributes\n @attributes\n end",
"def attributes\n @json_attributes.reject{|k,v| !schema.fields.include?(k)}\n end",
"def attribute_list\n [:id, :version, :uid, :user, :timestamp, :lon, :lat, :changeset]\n end",
"def attrs\n @attrs\n end",
"def model_attrs(except: [])\n attrs = %i(\n name starts_at duration budget fb_ad_account_id interests location\n age_min age_max\n )\n attrs << :publication_id unless [except].flatten.include?(:publication_id)\n attributes.slice(*attrs)\n end",
"def attrs_authoritative\n @authority = :attributes\n self\n end",
"def attributes\n attrs = sort_members(@context.attributes).find_all{|a| @options.show_all || a.visibility == :public || a.visibility == :protected}\n attrs.collect{|a| {:name=>a.name, :visibility=>a.visibility, :rw=>a.rw, :description=>markup(a.comment, true)}}\n end",
"def attributes\n @attributes = @attributes || {}\n end",
"def all_attrs\n key_attrs.merge(other_attrs)\n end",
"def add_doc_specific_attributes(filepath, is_src, attributes); end",
"def api_attributes\n record.class.column_names.map(&:to_sym)\n end",
"def attributes\n @attributes ||= yaml_front_matter.with_indifferent_access\n end",
"def get_attributes\n\t\t\t@@attributes\n\t\tend",
"def attributes; @attributes ||= []; end",
"def attrs\n @attrs\n end",
"def api_response\n attrs.merge(@tag_ids_by_type).merge(\n {\n ingredients: @ingredients.reduce({}) { |h, i| h.merge(i.api_response) },\n priorities: @priority_tag_hash_array,\n ratings: @rating_tag_hash_array.select { |h| h[:tag_name].include? 'star' },\n comments: @comment_tag_hash_array\n }\n )\n end",
"def iiif_manifest_attributes\n super.merge imported_attributes\n end",
"def iiif_manifest_attributes\n super.merge imported_attributes\n end",
"def values(xml)\n self.class::ATTRS.each do |attribute|\n value = instance_variable_get(\"@#{attribute}\") || ''\n xml[:v20].public_send(attribute, value)\n end\n end",
"def attributes\n self.class.fields.inject({}) do |attribute_hash, field|\n attribute_hash[field] = send(field)\n attribute_hash\n end\n end",
"def attributes\n @_attributes\n end",
"def attributes\n @attributes ||= Set.new\n end",
"def attribs\n\t\t@attributes\n\tend",
"def attribute_list(el); end",
"def serialize_for_api(keys: attribute_definitions.keys)\n serialize(keys: keys, enforce_read_only: true)\n end",
"def __attrs(attrs_hash={})\n @_undies_io.current.attrs(attrs_hash)\n end",
"def document_data_attributes(document)\n attr = {}\n\n # To add this to the div.document.result: data-foo=\"bar\"\n # do this:\n # attr['foo'] = 'bar'\n\n attr['onsite'] = 'true' if document.has_onsite_holdings?\n attr['offsite'] = 'true' if document.has_offsite_holdings?\n \n # NEXT-1635 - mark search-results docs with Hathi access status\n if (APP_CONFIG['hathi_search_results_links'])\n attr['hathi_access'] = document['hathi_access_s'] if document['hathi_access_s']\n end\n\n attr\n end",
"def attributes\n []\n end",
"def attributes\n @metadata\n end",
"def index\n @attributes = Attribute.all\n end",
"def testable_response_attributes(response)\n testable_response(response)['data']['attributes']\n end",
"def attributes\n @attributes = {\n \"placa\" => placa,\n \"UF\" => UF\n }\n end",
"def data_attributes\n end",
"def jsonapi_received_attributes\n\t\t\t\t\tbegin\n\t\t\t\t\t\tparams.require(\n\t\t\t\t\t\t\t:data\n\t\t\t\t\t\t).require(\n\t\t\t\t\t\t\t:attributes\n\t\t\t\t\t\t).permit(\n\t\t\t\t\t\t\t*jsonapi_model_class.attribute_names\n\t\t\t\t\t\t).reject do |key, value|\n\t\t\t\t\t\t\t# ignore automatically generated attributes\n\t\t\t\t\t\t\t%w(\n\t\t\t\t\t\t\t\tid \n\t\t\t\t\t\t\t\tcreated_at created_on \n\t\t\t\t\t\t\t\tupdated_at updated_on\n\t\t\t\t\t\t\t).include?(\n\t\t\t\t\t\t\t\tkey.to_s\n\t\t\t\t\t\t\t) or \n\n\t\t\t\t\t\t\t# ignore reference attributes\n\t\t\t\t\t\t\tkey.to_s =~ /_id$/\n\t\t\t\t\t\tend\n\t\t\t\t\trescue ActionController::ParameterMissing => e\n\t\t\t\t\t\tnil\n\t\t\t\t\tend\n\t\t\t\tend",
"def exposed_attributes\n [ :id, :curriculum_core_id, :subject_id, :curriculum_grade_id, :curriculum_area_id,\n :standard, :description1, :description2]\n end",
"def attributes\n self._attributes.inject({}) do |hash, attr|\n hash[attr.to_s] = send(attr)\n hash\n end\n end",
"def attributes\n @attributes ||= {}\n end",
"def attributes\n @attributes ||= {}\n end",
"def attributes\n @attributes ||= {}\n end",
"def attributes\n @attributes ||= @internal_struct[:attributes]\n end"
] |
[
"0.6565531",
"0.6327796",
"0.6327796",
"0.6327796",
"0.6327796",
"0.6327796",
"0.6327796",
"0.6327796",
"0.6327796",
"0.6327796",
"0.6327796",
"0.6327796",
"0.63206816",
"0.6318168",
"0.6298896",
"0.62770164",
"0.61958444",
"0.6189441",
"0.61867046",
"0.6173783",
"0.6173783",
"0.61429274",
"0.613101",
"0.60876876",
"0.60843563",
"0.6044884",
"0.6022206",
"0.6012422",
"0.6007319",
"0.5999071",
"0.59979284",
"0.5989187",
"0.59635276",
"0.59439665",
"0.5941538",
"0.5940851",
"0.5937133",
"0.59348834",
"0.59340215",
"0.59176695",
"0.59155226",
"0.5911962",
"0.5910775",
"0.5899744",
"0.5894413",
"0.58879143",
"0.5868551",
"0.5860636",
"0.58524173",
"0.5849003",
"0.584347",
"0.5830071",
"0.5829223",
"0.58215404",
"0.5816007",
"0.58141446",
"0.58122003",
"0.579856",
"0.579856",
"0.579856",
"0.5796176",
"0.5783257",
"0.5782614",
"0.57714707",
"0.57685375",
"0.5756947",
"0.57507235",
"0.5730506",
"0.57238674",
"0.5716914",
"0.5716432",
"0.5714557",
"0.5707776",
"0.5707123",
"0.5704622",
"0.56974816",
"0.5695335",
"0.56843865",
"0.56843865",
"0.5683701",
"0.5677318",
"0.5673887",
"0.5673255",
"0.5671495",
"0.5670766",
"0.56699675",
"0.5669747",
"0.56690675",
"0.56580335",
"0.564921",
"0.56411135",
"0.564033",
"0.5635847",
"0.56347245",
"0.5632768",
"0.56317544",
"0.56290734",
"0.56270844",
"0.56270844",
"0.56270844",
"0.5624838"
] |
0.0
|
-1
|
Post request raw datas
|
def field_ids
@conditions['field_ids'] || cbobject.basis_fields
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def post_data; end",
"def raw_post; end",
"def post_data\n @request[\"postData\"]\n end",
"def raw_post_request raw_params\n json_body = raw_params.to_json\n Rubix.logger.log(Logger::DEBUG, \"SEND: #{json_body}\") if Rubix.logger\n Net::HTTP::Post.new(uri.path).tap do |req|\n req['Content-Type'] = 'application/json-rpc'\n req.body = json_body\n end\n end",
"def post_data=(_arg0); end",
"def raw_post\n env['RAW_POST_DATA']\n end",
"def post data\n commit data\n end",
"def post(data)\n uri = URI(@host)\n res = Net::HTTP.post_form(uri, {shell: data})\n # puts res.body\nend",
"def post endpoint, data\n do_request :post, endpoint, data\n end",
"def post_request(object)\n end",
"def post(data = {})\n call data, method: :post\n end",
"def body\r\nif raw_post = @env['RAW_POST_DATA']\r\nraw_post.force_encoding(Encoding::BINARY)\r\nStringIO.new(raw_post)\r\nelse\r\n@env['rack.input']\r\nend\r\nend",
"def POST; end",
"def raw_post\r\nunless @env.include? 'RAW_POST_DATA'\r\nraw_post_body = body\r\n@env['RAW_POST_DATA'] = raw_post_body.read(@env['CONTENT_LENGTH'].to_i)\r\nraw_post_body.rewind if raw_post_body.respond_to?(:rewind)\r\nend\r\n@env['RAW_POST_DATA']\r\nend",
"def post_data(body)\r\n raise ConfigError, 'no json_records' if body.empty?\r\n # Create REST request header\r\n header = get_header(body.bytesize)\r\n # Post REST request \r\n response = RestClient.post(@uri, body, header)\r\n\r\n return response\r\n end",
"def raw_post(path, body, options = {})\n # Allow format override\n format = options.delete(:format) || @format\n # Clear cache\n expire_matching \"#{raw_path(path)}.*\"\n # Create POST request\n post = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", \n :verbose => DEBUG,\n :method => \"post\",\n :body => body,\n :headers => { :'Content-type' => options[:content_type] || content_type(format) }\n )\n\n # Send request\n do_request(post, format)\n end",
"def post(request)\n do_request(request) { |client| client.http_post request.body }\n end",
"def transmit_data\n body = {body: {datum:{data_type:\"float\", value: rand, virtual_entity_id: 1}}}\n self.class.post(API+'/data', body)\n end",
"def post(data = \"\")\n submit :Post, data\n end",
"def post(request)\n if request.params.is_a?(Hash)\n @connection.post request.path, request.params\n else\n @connection.post request.path do |req|\n req.body = request.params\n end\n end\n end",
"def post(attrs = nil)\n attrs ||= attributes\n execute_request do\n faraday_connection.post { |req| req.body = adapter.serialize(attrs) }\n end\n end",
"def form_data= data\n @headers['Content-Type'] = \"application/x-www-form-urlencoded\"\n @body = self.class.build_query data\n end",
"def upload_raw(data)\n data.rstrip!\n response = do_post data\n if response.status == 200\n data = JSON.parse(response.body)\n data['key']\n else\n fail_with \"failure uploading: #{response.body}\"\n end\n rescue JSON::ParserError => e\n fail_with \"failure parsing response: #{e.message}\"\n rescue Errno::ECONNREFUSED => e\n fail_with \"failure connecting: #{e.message}\"\n end",
"def post(*args)\n Request.post(*args)\n end",
"def do_post_request(data)\n\t\tresponse = Net::HTTP.post_form(URI(@url),data)\n if response.message == \"OK\"\n\t\t\tresult = {}\n\t\t\tresponse.body.split('&').each do |res|\n\t\t\t\tif res != ''\n\t\t\t\t\ttemp = res.split('=')\n\t\t\t\t\tif temp.size > 1\n\t\t\t\t\t\tresult[temp[0]] = temp[1]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n else\n result = \"Error in the HTTP request\"\n end\n return result\n\tend",
"def post payload, path = \"\" \n make_request(path, \"post\", payload)\n end",
"def api_gateway_post(path, params)\n api_gateway_body_fwd = params.to_json\n rack_input = StringIO.new(api_gateway_body_fwd)\n\n post path, real_params = {}, {\"rack.input\" => rack_input}\nend",
"def post(path, data = {})\n request 'POST', path, body: data.to_json\n end",
"def post\n request_object.post_query\n end",
"def api_gateway_post(path, params)\n api_gateway_body_fwd = params.to_json\n rack_input = StringIO.new(api_gateway_body_fwd)\n\n post path, real_params = {}, 'rack.input' => rack_input\nend",
"def post operation, data={}\n body = case data\n when String\n body = data\n else\n Yajl::Encoder.encode(data)\n end\n\n request = new_request operation, body\n request.sign sts\n hydra.queue request\n hydra.run\n response = request.response\n puts response.inspect if @debug\n\n if response.code == 200\n Yajl::Parser.parse response.body\n else\n raise_error response\n end\n end",
"def post\n Rentlinx.client.post(self)\n end",
"def post(attrs = nil)\n attrs ||= attributes\n\n execute_request('POST') do |uri, headers|\n HTTP.http_client.post(\n uri,\n body: adapter.serialize(attrs),\n header: headers.merge(CONTENT_TYPE_HEADERS)\n )\n end\n end",
"def process_put_and_post_requests(request, data)\n content_type = request['Content-Type'] ||= 'application/x-www-form-urlencoded'\n case content_type\n when 'application/x-www-form-urlencoded'; request.form_data = data\n when 'application/json'; request.body = (data.is_a?(Hash) or data.is_a?(Array)) ? JSON.generate(data) : data\n else\n #data = data.to_s unless request.body.is_a?(String)\n request.body = data\n end\n process_request(request)\n end",
"def create(data, &block)\n request :post, '', data, &block\n end",
"def create(data, &block)\n request :post, '', data, &block\n end",
"def post()\n return @http.request(@req)\n end",
"def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end",
"def post\n resource.post(request, response)\n end",
"def api_post(action, data, binary_key = nil)\n api_request(action, data, 'POST', binary_key)\n end",
"def postSignal( entity_id, country, gen_id, signal_type, data_type, inactive_reason, inactive_description, feedback)\n params = Hash.new\n params['entity_id'] = entity_id\n params['country'] = country\n params['gen_id'] = gen_id\n params['signal_type'] = signal_type\n params['data_type'] = data_type\n params['inactive_reason'] = inactive_reason\n params['inactive_description'] = inactive_description\n params['feedback'] = feedback\n return doCurl(\"post\",\"/signal\",params)\n end",
"def post_data(data, api_key)\n mutation = Mutations::CREATE_EVENT\n Client.query(mutation, api_key, {\n \"sessionId\": data[:session_id],\n \"eventInput\": {\n \"input\": data\n }\n })\n end",
"def post(*args)\n request(:post, *args)\n end",
"def request_data; end",
"def post(path, *data, &block)\n map(path, R3::POST, *data, &block)\n end",
"def post; end",
"def post(path, data={})\n request(:post, path, data)\n end",
"def rest_post\n ##define the url path\n url =\"/post\"\n ##This is headers definition.\n headers = [\n ['Cached-Control', \"no-cache\" ],\n [\"Content-Type\", \"application/x-www-form-urlencoded; charset=UTF-8\"]\n ]\n input_body = {\"test_key\" =>\"test_value\"}\n\n begin\n #------------------------\n #Send Post Request\n #------------------------\n request, response = send_post(url, input_body.to_json, headers)\n\n if response.code.to_i == 200\n actual_value =JSON.parse(response.body)\n ## return the value need to be validated\n actual_value = actual_value['form']\n return actual_value.to_json\n else\n return false\n end\n rescue Exception => ex\n @log.error \"#### Response code is: #{response.code} #####\"\n @log.error ex.message\n puts \"#### Response code is: #{response.code} #####\"\n puts ex.message\n return false\n end\n end",
"def post(path, data, headers = {})\n request(:post, path, data, headers).body\n end",
"def request_post_data(request_hash)\r\n \"#{hash2cgiString(request_hash)}&#{hash2cgiString(@cre)}&#{hash2cgiString(@ci)}\"\r\n end",
"def post(*args)\n request :post, *args\n end",
"def post(path, form_data=nil)\n parse_json do |parser|\n @http_client.post(path, form_data) {|chunk| parser << chunk }\n end\n end",
"def submit(verb, data)\n start do |connection|\n request = http verb\n request.body = data\n connection.request request\n end\n end",
"def post(path, data = {})\n # Allow format override\n format = data.delete(:format) || @format\n # Clear cache\n expire_matching \"#{raw_path(path)}.*\"\n # Extract return unit params\n query_params = {}\n query_params[:returnUnit] = data.delete(:returnUnit) if data[:returnUnit]\n query_params[:returnPerUnit] = data.delete(:returnPerUnit) if data[:returnPerUnit]\n # Create POST request\n post_params = {\n :verbose => DEBUG,\n :method => \"post\",\n :body => form_encode(data)\n }\n post_params[:params] = query_params unless query_params.empty?\n post = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", post_params)\n # Send request\n do_request(post, format) \n end",
"def content(c)\n @request.env[\"RAW_POST_DATA\"] = c.to_s\n end",
"def post(path, data, params = {}, request_options = {})\n request(:post, path, data, params)\n end",
"def make_post_request url, body, headers = []\n make_request url, method: ::Rack::POST, body: body, headers: headers\n end",
"def transmit(path, data)\n http_post (host + path),\n {'Content-Type' => 'application/json'},\n [data.to_json]\n end",
"def post_data(action, parameters = {})\n post = {}\n post[:action] = action\n post[:usepost] = 1\n post[:acctid] = @options[:test] ? 'TEST0' : @options[:login]\n post[:merchantpin] = @options[:password] if @options[:password] && !@options[:test]\n\n request = post.merge(parameters).map {|key,value| \"#{key}=#{CGI.escape(value.to_s)}\"}.join(\"&\")\n request\n end",
"def http_post(uri, data)\n RestClient.post uri, data\n end",
"def post\r\n end",
"def post(payload)\n post_like payload, Net::HTTP::Post.new(@uri.path)\n end",
"def set_up_post_request(uri, data, headers, binary_key = nil)\n if !binary_key.nil?\n binary_data = data[binary_key]\n\n if binary_data.is_a?(StringIO)\n data[binary_key] = UploadIO.new(\n binary_data, \"text/plain\", \"local.path\"\n )\n else\n data[binary_key] = UploadIO.new(\n File.open(binary_data), \"text/plain\"\n )\n end\n\n req = Net::HTTP::Post::Multipart.new(uri.path, data)\n else\n req = Net::HTTP::Post.new(uri.path, headers)\n req.body = data.to_json\n end\n req\n end",
"def postEntityBulkJson( data)\n params = Hash.new\n params['data'] = data\n return doCurl(\"post\",\"/entity/bulk/json\",params)\n end",
"def content_post\n\t\t\t# POST requests seem to bomb out when they're deflated\n\t\t\t# and they probably don't need to be compressed anyway\n\t\t\t@request_params[\"SAMLRequest\"] = Base64.encode64(@request).gsub(/\\n/, \"\")\n\t\t\t\n\t\t\t#Logging.debug \"SAMLRequest=#{@request_params[\"SAMLRequest\"]}\"\n\t\t\t# kind of a cheesy method of building an HTML, form since we can't rely on Rails too much,\n\t\t\t# and REXML doesn't work well with quote characters\n\t\t\tstr = \"<html><body onLoad=\\\"document.getElementById('form').submit();\\\">\\n\"\n\t\t\tstr += \"<form id='form' name='form' method='POST' action=\\\"#{@URL}\\\">\\n\"\n\t\t\t# we could change this in the future to associate a temp auth session ID\n\t\t\tstr += \"<input name='RelayState' value='ruby-saml' type='hidden' />\\n\"\n\t\t\t@request_params.each_pair do |key, value|\n\t\t\t\tstr += \"<input name=\\\"#{key}\\\" value=\\\"#{value}\\\" type='hidden' />\\n\"\n\t\t\t\t#str += \"<input name=\\\"#{key}\\\" value=\\\"#{CGI.escape(value)}\\\" type='hidden' />\\n\"\n\t\t\tend\n\t\t\tstr += \"</form></body></html>\\n\"\n\t\t\t\n\t\t\tLogging.debug \"Created form:\\n#{str}\"\n\t\t\treturn str\n\t\tend",
"def api_post(action, data)\n api_request(action, data, 'POST')\n end",
"def post_http(args)\n\t\t return(Net::HTTP.post_form @uri, args)\t\t\t\n \tend",
"def exec_post(req, data, exit_on_fail = false)\n response_hash = exec_api_call('POST', req, data, exit_on_fail)\n response_hash[:response]\n end",
"def send_post(resource, data)\n\n url = URI.parse(primavera_path(resource))\n req = Net::HTTP::Post.new(url.to_s, initheader = {'Content-Type' => 'application/json'})\n req.body = data\n\n puts 'Sending POST request to ' + url.to_s\n\n send_request(url, req)\n end",
"def api_post_request(url_prefix, raw_response = false, data=nil)\n to_post = URI.escape(url_prefix)\n request = Net::HTTP::Post.new(to_post)\n @logger.info \"POST #{to_post}\"\n exec_request(request, raw_response, data)\n end",
"def get_post_body(name, params)\n { 'method' => name, 'params' => params, 'id' => 'jsonrpc' }\n end",
"def post(request)\n _request(request) { |client, options| client.post options }\n end",
"def create\n seth_server_rest.post_rest(\"data\", self)\n self\n end",
"def postToolsUpload( filedata)\n params = Hash.new\n params['filedata'] = filedata\n return doCurl(\"post\",\"/tools/upload\",params)\n end",
"def post(params = nil)\n request.method = :post\n execute(params)\n end",
"def post(post_data, path)\n response = self.class.post(path, options(post_data, true))\n response.response.body\n end",
"def convert()\n @helper.post(@fields, @files, @raw_data)\n end",
"def convertRawData(data)\n @raw_data['file'] = data\n @helper.post(@fields, @files, @raw_data)\n end",
"def convertRawData(data)\n @raw_data['file'] = data\n @helper.post(@fields, @files, @raw_data)\n end",
"def convertRawData(data)\n @raw_data['file'] = data\n @helper.post(@fields, @files, @raw_data)\n end",
"def convertRawData(data)\n @raw_data['file'] = data\n @helper.post(@fields, @files, @raw_data)\n end",
"def post_data(params)\n {\n gateway_username: options[:login],\n gateway_password: options[:password],\n payload: encrypt(params.to_json)\n }.to_json\n end",
"def post(path, **args); end",
"def post(data)\n jss = self.get_structure() # For referencing purposes\n\n input = self.query_to_hash(data)\n bad_request = false\n resp = nil\n jss.each do |key, value|\n # Check if we have it on the query too\n unless input.has_key? key\n resp = MIDB::Interface::Server.json_error(400, \"Bad Request - Not enough data for a new resource\")\n @engine.http_status = 400\n bad_request = true\n end\n end\n input.each do |key, value|\n # Check if we have it on the structure too\n unless jss.has_key? key\n resp = MIDB::Interface::Server.json_error(400, \"Bad Request - Wrong argument #{key}\")\n @engine.http_status = 400\n bad_request = true\n end\n end\n \n\n # Insert the values if we have a good request\n unless bad_request\n fields = Hash.new\n inserts = Hash.new\n main_table = self.get_structure.values[0].split('/')[0]\n input.each do |key, value|\n struct = jss[key]\n table = struct.split(\"/\")[0]\n inserts[table] ||= []\n fields[table] ||= []\n inserts[table].push \"\\\"\" + value + \"\\\"\"\n fields[table].push struct.split(\"/\")[1]\n if struct.split(\"/\").length > 2\n match = struct.split(\"/\")[2]\n matching_field = match.split(\"->\")[0]\n row_field = match.split(\"->\")[1]\n fields[table].push matching_field\n if @engine.config[\"dbengine\"] == :mysql\n inserts[table].push \"(SELECT #{row_field} FROM #{main_table} WHERE id=(SELECT LAST_INSERT_ID()))\"\n else\n inserts[table].push \"(SELECT #{row_field} FROM #{main_table} WHERE id=(last_insert_rowid()))\"\n end\n end\n end\n queries = [] \n inserts.each do |table, values|\n queries.push \"INSERT INTO #{table}(#{fields[table].join(',')}) VALUES (#{inserts[table].join(',')});\"\n end\n # Connect to the database\n dbe = MIDB::API::Dbengine.new(@engine.config, @db)\n dblink = dbe.connect()\n results = []\n rid = nil\n # Find the ID to return in the response (only for the first query)\n queries.each do |q|\n results.push dbe.query(dblink, q)\n if @engine.config[\"dbengine\"] == :mysql\n rid ||= dbe.extract(dbe.query(dblink, \"SELECT id FROM #{main_table} WHERE id=(SELECT LAST_INSERT_ID());\"), \"id\")\n else\n rid ||= dbe.extract(dbe.query(dblink, \"SELECT id FROM #{main_table} WHERE id=(last_insert_rowid());\"), \"id\")\n end\n end\n @engine.http_status = \"201 Created\"\n resp = {status: \"201 created\", id: rid}\n end\n return resp\n end",
"def postUser( email, user_id, first_name, last_name, active, trust, creation_date, user_type, social_network, social_network_id, reseller_admin_masheryid, group_id, admin_upgrader)\n params = Hash.new\n params['email'] = email\n params['user_id'] = user_id\n params['first_name'] = first_name\n params['last_name'] = last_name\n params['active'] = active\n params['trust'] = trust\n params['creation_date'] = creation_date\n params['user_type'] = user_type\n params['social_network'] = social_network\n params['social_network_id'] = social_network_id\n params['reseller_admin_masheryid'] = reseller_admin_masheryid\n params['group_id'] = group_id\n params['admin_upgrader'] = admin_upgrader\n return doCurl(\"post\",\"/user\",params)\n end",
"def post(path, data=nil)\n request(:post, path, data)\n end",
"def content_post\n # POST requests seem to bomb out when they're deflated\n # and they probably don't need to be compressed anyway\n @request_params[\"SAMLRequest\"] = Base64.encode64(@request).gsub(/\\n/, \"\")\n \n #Logging.debug \"SAMLRequest=#{@request_params[\"SAMLRequest\"]}\"\n # kind of a cheesy method of building an HTML, form since we can't rely on Rails too much,\n # and REXML doesn't work well with quote characters\n str = \"<html><body onLoad=\\\"document.getElementById('form').submit();\\\">\\n\"\n str += \"<form id='form' name='form' method='POST' action=\\\"#{@URL}\\\">\\n\"\n # we could change this in the future to associate a temp auth session ID\n str += \"<input name='RelayState' value='ruby-saml' type='hidden' />\\n\"\n @request_params.each_pair do |key, value|\n str += \"<input name=\\\"#{key}\\\" value=\\\"#{value}\\\" type='hidden' />\\n\"\n #str += \"<input name=\\\"#{key}\\\" value=\\\"#{CGI.escape(value)}\\\" type='hidden' />\\n\"\n end\n str += \"</form></body></html>\\n\"\n \n #Logging.debug \"Created form:\\n#{str}\"\n return str\n end",
"def create(input)\n @response = self.request(Net::HTTP::Post.new(\n \"/stikkits.atom?raw_text=#{CGI.escape(input)}\"\n ))\n #-- TODO: This should be processed and useful output presented\n #++\n puts @response.body\n end",
"def send\n post_params = {}\n self.parameters.each { |key, value|\n if value.is_a? Array\n i = 0\n value.each { |value_value|\n post_params[key.to_s + '[' + i.to_s + ']'] = value_value.to_s\n i += 1\n }\n elsif value.is_a? Hash\n value.each { |value_key, value_value|\n post_params[key.to_s + '[' + value_key.to_s + ']'] = value_value.to_s\n }\n else\n post_params[key.to_s] = value.to_s\n end\n }\n\n url = URI.parse(@@API_URL)\n http_request = Net::HTTP::Post.new(url.path)\n http_request.form_data = post_params\n http_request.basic_auth url.user, url.password if url.user\n\n response = Spree::PAYONE::Proxy::Response.new\n connection = Net::HTTP.new(url.host, url.port)\n load_ca_file connection\n connection.use_ssl = true\n connection.start { |http|\n http_response = http.request(http_request)\n response.response_body= http_response.body\n }\n\n response\n end",
"def xhr_post *args, params_or_action\n Presto::Browser.new(@controller, env, 'POST', true).body *args, params_or_action\n end",
"def send_raw_request raw_params\n @request_id += 1\n begin\n raw_response = server.request(raw_post_request(raw_params))\n rescue NoMethodError, SocketError => e\n raise RequestError.new(\"Could not connect to Zabbix server at #{host_with_port}\")\n end\n raw_response\n end",
"def post(action, params = T.unsafe(nil), header = T.unsafe(nil), query = T.unsafe(nil)); end",
"def post(request)\n request.method = :post\n request.call\n end",
"def post!\n request! :post\n end",
"def api_post(path, data = {})\n api_request(:post, path, :data => data)\n end",
"def post_params(method, params)\n p = params ? params.clone : {}\n p.delete :post\n sign_params(method, p)\n \n # since we're using Net::HTTP.post_form to do the call,\n # CGI escape is already done for us, so, no escape here\n # p.keys.each { |k| p[k] = CGI.escape(p[k].to_s) } \n p\n end",
"def body\n if raw_post = @env['RAW_POST_DATA']\n raw_post.force_encoding(Encoding::BINARY) if raw_post.respond_to?(:force_encoding)\n StringIO.new(raw_post)\n else\n @env['rack.input']\n end\n end",
"def post_json(path, body)\n uri = build_uri(path)\n #puts \"🤖 POST #{path}\"\n #puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n #puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n #puts result[:result]\n result\nend",
"def post!\n self.https.request self.http_request # Net::HTTPResponse object\n end",
"def post query=nil, content_type='application/x-www-form-urlencoded'\n\t\treq = Net::HTTP::Post.new(@uri.path)\n\n\t\treq.body= make_query query if query\n\t\treq.content_type=content_type if query\n\t\treq.content_length=query ? req.body.length : 0\n\n\t\tdo_http req\n\tend",
"def post(path, data = {}, params = {})\n body = data.to_json\n path = File.join(@prefix, path)\n\n response = @conn.post(path, body) do |req|\n req.params = params\n req.headers['Content-Type'] = 'application/json'\n end\n\n JSON.parse response.body\n end"
] |
[
"0.7524728",
"0.7046655",
"0.7007513",
"0.7005208",
"0.69985884",
"0.6963396",
"0.67141587",
"0.66797686",
"0.65774536",
"0.65544075",
"0.65361583",
"0.65251786",
"0.6415895",
"0.6394937",
"0.6367588",
"0.6343628",
"0.631943",
"0.6306414",
"0.62750965",
"0.6268481",
"0.6247295",
"0.624089",
"0.6224288",
"0.6211943",
"0.6189082",
"0.6171918",
"0.61665297",
"0.6156897",
"0.6144389",
"0.61436784",
"0.6139669",
"0.6127473",
"0.61258256",
"0.6114165",
"0.6097368",
"0.6097368",
"0.60874814",
"0.6085681",
"0.6075454",
"0.6061392",
"0.60554063",
"0.60439336",
"0.602037",
"0.6009163",
"0.6007071",
"0.59977096",
"0.59898245",
"0.598793",
"0.5985722",
"0.5984868",
"0.5982803",
"0.5978511",
"0.595121",
"0.595032",
"0.59452933",
"0.59378904",
"0.5936868",
"0.5927966",
"0.59180903",
"0.59125197",
"0.5909581",
"0.59056467",
"0.5894468",
"0.5893751",
"0.58712834",
"0.5867999",
"0.5867821",
"0.5865034",
"0.58599055",
"0.5822464",
"0.58209",
"0.582052",
"0.5819556",
"0.58184665",
"0.5816803",
"0.58118665",
"0.5811317",
"0.5810286",
"0.5810286",
"0.5810286",
"0.5810286",
"0.5801137",
"0.57965374",
"0.579545",
"0.5793164",
"0.57849324",
"0.5778471",
"0.57738984",
"0.5769122",
"0.57663745",
"0.5762544",
"0.57430744",
"0.5728286",
"0.5727979",
"0.5726402",
"0.5722953",
"0.57213897",
"0.57204175",
"0.5714068",
"0.5713528",
"0.57089776"
] |
0.0
|
-1
|
Set an attribute in the servlet context.
|
def []=(key, val)
setAttribute(key.to_s, val)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_attribute(id, attr)\n\t\t\t@current_context.set_attribute(id, attr)\n\t\tend",
"def set_attribute(name, value); end",
"def set_attr(attr, value)\n ret = LibSeccomp.seccomp_attr_set(context, attr, value)\n raise SystemCallError.new(\"seccomp_attr_set(context, #{attr.inspect}, #{value}) failed\", -ret) if ret < 0\n end",
"def set attribute, value\n attributes[attribute] = value\n end",
"def set_attribute(name, value)\n @attributes[name] = value\n end",
"def setAttrib(name,value)\n\t\t@attributes[name] = value\n\tend",
"def set_attribute(key_, value_)\n attribute(key_, value_, :set)\n end",
"def set_attribute(attribute, value)\n if MojeID.is_attribute_available?(attribute)\n fetch_request.set_values(attribute, value)\n bundle_to_request\n end\n end",
"def set_global_attribute(id, attr)\n\t\t\t@project.global_context.set_attribute(id, attr)\n\t\tend",
"def set(attribute, value)\n @attributes[attribute.to_s] = value\n nil\n end",
"def set_attribute\n @attribute = Attribute.find(params[:id])\n end",
"def set_attribute\n @attribute = Attribute.find(params[:id])\n end",
"def set_attr\n @attr = Attr.find(params[:id])\n end",
"def set_attr\n @attr = Attr.find(params[:id])\n end",
"def attribute=(attribute_name, value)\n write_attribute(attribute_name, value)\n end",
"def attribute=(attribute_name, value)\n write_attribute(attribute_name, value)\n end",
"def setAttribute(attributeName)\n @attributeName = attributeName\n end",
"def set_attribute(attribute,value,index=0)\n index = normalize_index(index)\n# puts \"<br>SETTING ATTRIBUTE #{attribute}[#{index}]=#{value} [caller: #{trace}]\"\n @attributes[index] ||= {}\n @attributes[index][normalize_attribute(attribute)] = value\n end",
"def []=(attr, value)\n @attrs[attr] = value\n end",
"def []=(attr_name, value)\n write_attribute(attr_name, value)\n end",
"def []=(attr_name, value)\n write_attribute(attr_name, value)\n end",
"def []=(attr_name, value)\n write_attribute(attr_name, value)\n end",
"def []=(attr_name, value)\n write_attribute(attr_name, value)\n end",
"def set_attribute(a,b)\n write_attribute(a,b)\n end",
"def []=(attr_name, value)\n write_attribute(attr_name, value)\n end",
"def attribute_set(name, value)\n @dirty[name] = true\n @attributes[:current][name] = value\n end",
"def set_attr(name, value)\n each_value {|x| x[name] = value }\n end",
"def []= (attr_name, value) \n write_attribute(attr_name, value)\n end",
"def []= attribute, value\n `#@native.setAttribute(#{attribute}, #{value})`\n end",
"def []=(name, value) \n @server.setAttribute @object_name, javax.management.Attribute.new(name.to_s, value)\n end",
"def attribute=(name, val)\n write_attribute(name, val)\n end",
"def set_attribute(id, attribute, value)\n\t\to = getObject(id)\n\t\tif (o != nil && o.respond_to?(:[]))\n\t\t\to[attribute] = value\n\t\telse\n\t\t\tputs \"Could not find object with id = #{id}\"\n\t\tend\n\tend",
"def set_attribute_for element, attr, value\n AXUIElementSetAttributeValue(element, attr, value)\n end",
"def []=(attr_name, value)\n @attributes[attr_name.to_s] = value\n end",
"def attribute=(name, value)\n @attributes ||= {}\n @attributes[name] = value\n end",
"def []=(attr_name, value)\n @attributes.write_from_user(attr_name.to_s, value)\n end",
"def []=(attribute, value)\n self.send(\"#{attribute}=\", value)\n end",
"def set_attribute(dict_name, key, value)\n end",
"def assign(attribute, value)\n @attributes[attribute.to_sym] = value\n end",
"def []=(attr_name, value)\n if self.attribute_names.include?(attr_name.to_s)\n write_attribute(attr_name, value)\n else\n set_custom_attribute(attr_name, value)\n end\n end",
"def attr attribute_name,value = nil\n string=\"$('##{@id}').attr('#{attribute_name}','#{value}')\"\n @app.dom_on_sockets.execute string\n end",
"def []=(attr, value)\n if Roomorama::Property::ATTRIBUTES.include?(attr)\n setter = [attr, \"=\"].join\n public_send(setter, value)\n end\n end",
"def []=(attr_name, value)\n writer_method = \"#{attr_name}=\"\n send(writer_method, value) if respond_to?(writer_method)\n end",
"def set_attribute(dict_name, key, value)\n end",
"def set_attribute(dict_name, key, value)\n end",
"def set(option, value)\n @context.send \"#{option}=\".to_sym, value\n end",
"def set_attr(key, value)\n value = format_value(value)\n key = format_key(key)\n send(\"#{key}=\", value)\n rescue\n unless defined?(Rails).nil?\n $lxca_log.info(\n 'XClarityClient::Endpoints::BuildableResourceMixin',\n \"UNEXISTING ATTRIBUTES FOR #{self.class}: #{key}\"\n )\n end\n end",
"def []=(key,value)\n @attributes[key] = value\n end",
"def []=(name, value)\n @attr[name] = value\n end",
"def set_attribute(attribute_key, attribute_value)\n @attr_mutex.synchronize { @user_attributes[attribute_key] = attribute_value }\n end",
"def set_attribute(attribute_key, attribute_value)\n @attr_mutex.synchronize { @user_attributes[attribute_key] = attribute_value }\n end",
"def set_single_attribute(attribute_name, attribute_value, opts = {})\n Operation::Service.set_attribute(\n :attribute_name => attribute_name,\n :attribute_value => attribute_value,\n :encrypt => opts[:encrypt],\n :service_instance => self.service_instance,\n :service_instance_dir => self.service_instance_dir\n )\n end",
"def []=(attribute,value)\n `c$Element.prototype.m$set_property.call(#{@element},attribute,value)`\n end",
"def write_attribute(key, value)\n @attributes[key] = value\n end",
"def add_attribute(id, *attr)\n\t\t\t@current_context.add_attribute(id, *attr)\n\t\tend",
"def write_attribute(attribute, value)\n @object.send(:write_attribute, attribute, value)\n end",
"def []=(attribute, value)\n attributes[attribute] = to_field(value)\n end",
"def configure_attr(attr, default_value = nil)\n v = instance_variable_get(\"@#{attr}\".to_sym)\n v = default_value if v.nil?\n instance_variable_set(\"@#{attr}\".to_sym, eval_attr(v))\n end",
"def set_user_attribute\n @user_attribute = UserAttribute.find(params[:id])\n end",
"def []=(key, value)\n attributes[key] = value\n end",
"def attribute_set(name, value)\n properties[name].set(self, value)\n end",
"def []=(attribute, value)\n attribute = attribute.to_s.gsub(/[^a-zA-Z0-9_\\-]/, '').gsub('_', '-')\n # FIXME => Attributes per class\n unless POSSIBLE_ATTRIBUTES.include? attribute\n # FIXME: Log, don't print\n puts \"Warning! Attribute #{attribute} not recognized\"\n @canvas << js_method('attr', {attribute => value})\n return nil\n end\n @canvas << js_method('attr', {attribute => value})\n return self\n end",
"def setattribute_raw(path, name, value)\n Puppet.debug \"#{name.inspect} setting to #{value.inspect} for path: #{path}\"\n cmd = if value.nil?\n \"#{path}:undefine-attribute(name=\\\"#{name}\\\")\"\n else\n \"#{path}:write-attribute(name=\\\"#{name}\\\", value=#{value})\"\n end\n cmd = \"/profile=#{@resource[:profile]}#{cmd}\" if runasdomain?\n state = execute cmd\n Puppet.debug(\"Setting attribute response: #{state.output}\")\n raise \"Cannot set #{name} for #{path}: #{state.output}\" unless state.success?\n @property_hash[name] = value\n end",
"def set_tag_attr (tag_path, attr_name, attr_value)\n\n $test_logger.log(\"Set XML tag attribute #{tag_path}, #{attr_name}, #{attr_value}\")\n\n raise \"XML doc not loaded\" if @xml_ilv_node == nil\n\n #Get target tag\n target_tag = @xml_ilv_node.root.elements[tag_path]\n\n #Raise exception if no tag is found\n raise \"XML path '#{tag_path}' not found!\" if !target_tag\n\n attr_obj = target_tag.add_attribute(attr_name, attr_value)\n\n #Notify changes to load other formats like RAW and HEX\n notify_change(InputChannel::XML)\n end",
"def attribute_setter(attribute_name)\n \"set#{attribute_name.to_s.camelcase(:upper)}\"\n end",
"def []=(name, value)\n `#{@el}.setAttribute(#{name},#{value})`\n end",
"def set_attribute(opts = {})\n data, _status_code, _headers = set_attribute_with_http_info(opts)\n return data\n end",
"def set_attribute(locator, attribute, value)\n execute_script(%(\n var element = arguments[0];\n var attribute = arguments[1];\n var value = arguments[2];\n element.setAttribute(attribute, value);\n ), find_element(locator), attribute, value)\n end",
"def update_attribute(attribute, attribute_type, value)\n\t\tresults = submit_cmd('update app attribute',:db, \"-env #{self.belongs_to.env} \\\n -app_instance #{self.name} -attribute #{attribute} -attribute_type #{attribute_type} \\\n -new_value #{value}\")\n\t \n\t if ( results.to_s =~ /failure/i || results.to_s =~ /error/i)\n\t \traise \"update attribute failed\" \n\t else\n\t \tself.attributes[attribute.intern] = value\n\t end\n\tend",
"def set_shmrequestattribute\n @shmrequestattribute = Shmrequestattribute.find(params[:id])\n end",
"def assign_attribute(name, value)\n self.send(\"#{name}=\", value) if has_attribute?(name)\n end",
"def []=(attr, value)\n self.send(\"#{attr}=\", value)\n end",
"def []=(attr, value)\n self.send(\"#{attr}=\", value)\n end",
"def set_property(attribute, value)\n `var el=this.__native__,attr=attribute.__value__,bool=c$Element.__boolean_attributes__[attr],key=c$Element.__boolean_attributes__[attr]||bool`\n `key ? el[key]=bool?$T(value):value : el.setAttribute(attr,''+value)`\n return self\n end",
"def instance_set(attribute, value)\n setter = :\"#{self.name}_#{attribute}=\"\n self.instance.send(setter, value) if instance.respond_to?(setter)\n end",
"def set_attribute(name, value)\n if name == 'scrollTop'\n `#{@element}.scrollTop=#{value}`\n else\n `#{@element}.setAttribute(#{name}, #{value})`\n end\n end",
"def []=(key, value)\n attributes[key] = value\n end",
"def []=(key, value)\n attributes[key] = value\n end",
"def set_c_attribute\n @c_attribute = CAttribute.find(params[:id])\n end",
"def []= (attr, val)\n sanity_check\n @handle[attr] = val\n end",
"def []=(name, value)\n @attributes[name] = value\n end",
"def set_attribute_value(attrib_name, attrib_value=nil)\n return set_attribute_values(attrib_name) if attrib_name.is_a? Hash \n touch(attrib_name)\n @attribute_values_flat[attrib_name.to_sym] = attrib_value\n end",
"def write_set_attribute(attribute_name, value)\n column_type = ((column_definition = self.class.columns_hash[attribute_name.to_s]) and column_definition.type)\n value = value.to_s(10) if column_type == :string\n write_attribute(attribute_name, value)\n end",
"def update(attribute, value)\n instance_variable_set(\"@#{attribute}\", value)\n end",
"def set_attribute_value(node_id:, name:, value:)\n {\n method: \"DOM.setAttributeValue\",\n params: { nodeId: node_id, name: name, value: value }.compact\n }\n end",
"def update_tag_attribute(content, tag_name, attr_name, init_val); end",
"def on_attribute(attribute)\n @attribute = attribute\n self\n end",
"def attr(name, value)\n self[name] = value\n return self\n end",
"def set attrib, value\n if attrib.is_a? String and attrib.include? \".\"\n syms = attrib.split(\".\")\n first = syms[0]\n rest = syms[1..-1].join(\".\")\n self.send(first).set(rest, value)\n else\n self.send(\"#{attrib}=\".to_sym, value)\n end\n end",
"def set_attribute(ents, handle, name, value)\n ents.each { |e|\n e.set_attribute(handle, name, value)\n }\n end",
"def _assign_attribute(k, v)\n attributes[k] = v\n super\n end",
"def set_attribute(rule, attribute, value)\n begin\n rule.send(\"#{attribute}=\".to_sym, value)\n rescue NoMethodError\n raise AtomMarshallingError.new(\"Attribute #{attribute} unsupported in Atom #{rule_type_name(rule)}.\")\n end\n end",
"def set_attribute(x)\n if attr_name = attribute(x)\n if collection?(x)\n send(attr_name) << yield\n else\n send(\"#{attr_name}=\", yield)\n end\n end\n end",
"def []= field, value\n @attributes[field] = value\n end",
"def set attr, to: value\n unless writable_attr? attr\n raise NoMethodError, \"#{attr} is read-only for #{inspect}\"\n end\n real_attr = attribute_for attr\n value = value.to_axvalue\n set real_attr, to: value, for: @ref\n value\n end",
"def set_attribute_value(attribute, value)\n\n # This product needs to have an id in order to set\n # attribute values on it.\n save! if new_record?\n\n if attribute.atype == ProductAttribute::Atype_String\n str_val = value\n int_val = nil\n elsif attribute.atype == ProductAttribute::Atype_Currency\n str_val = nil\n int_val = MoneyUtils.parse(value)\n else\n # It is possible that the admin did not fill in a value for\n # a text field, so we get an empty string for \"value\". We\n # could implement a default value for the attribute (probably\n # stored in the attribute itself, but for now just store 0.)\n str_val = nil\n if value.blank?\n int_val = 0\n else\n int_val = Integer(value)\n end\n end\n write_attr_val(attribute.id, str_val, int_val)\n\n end",
"def []=(attr, value)\n raise \"argument to [] must be a Symbol or a String.\" unless attr.is_a?(Symbol) or attr.is_a?(String)\n @attributes = { } if !instance_variable_defined?(:@attributes) or @attributes.nil?\n @attributes[attr] = value.to_s\n end",
"def myname=(myname)\n @context[:myname] = myname\n end"
] |
[
"0.7841657",
"0.7423242",
"0.71422565",
"0.7134273",
"0.69706947",
"0.690911",
"0.6894438",
"0.6843054",
"0.6803996",
"0.6761267",
"0.67404664",
"0.67404664",
"0.6673457",
"0.6673457",
"0.6627738",
"0.6627738",
"0.6580242",
"0.657689",
"0.65652084",
"0.653342",
"0.6531859",
"0.6531859",
"0.6531859",
"0.65093255",
"0.6508277",
"0.6504404",
"0.64928526",
"0.6466345",
"0.6450091",
"0.64491546",
"0.63987005",
"0.6360403",
"0.63405246",
"0.6335778",
"0.63083225",
"0.6308299",
"0.6293076",
"0.6291115",
"0.62871253",
"0.62743884",
"0.62642",
"0.6259422",
"0.6249221",
"0.6241343",
"0.6241343",
"0.62027663",
"0.61939096",
"0.61884344",
"0.6177042",
"0.6172401",
"0.6172401",
"0.6169454",
"0.6148321",
"0.6137682",
"0.6126008",
"0.60972655",
"0.6090762",
"0.60835254",
"0.6068922",
"0.60568",
"0.60461324",
"0.604526",
"0.6034076",
"0.6033385",
"0.60321146",
"0.6009373",
"0.5989227",
"0.5977112",
"0.59721506",
"0.5970118",
"0.596874",
"0.5968248",
"0.5968248",
"0.59638715",
"0.5959351",
"0.59373116",
"0.5931026",
"0.5931026",
"0.5923581",
"0.59226686",
"0.59221387",
"0.59034467",
"0.5894648",
"0.58839345",
"0.58833784",
"0.58771104",
"0.58682173",
"0.5864062",
"0.5863361",
"0.5859758",
"0.58572435",
"0.58569294",
"0.585332",
"0.5849996",
"0.58147",
"0.5814176",
"0.57983536",
"0.57668966"
] |
0.6298588
|
36
|
Remove an attribute for the given key.
|
def delete(key)
removeAttribute(key.to_s)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_attribute(key); end",
"def delete_attr!(key)\n copy_on_write if @attrs.shared\n key = key.intern \n old_attrs = @attrs\n @attrs = AttrArray.new\n @attrs_hash = {}\n old_attrs.each do |a|\n put_attr(a) if a.key_symbol != key\n end\n end",
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def remove_attr(name); end",
"def remove_attr(name); end",
"def remove(key)\n Lib.remove @path, @no_follow, key.to_s\n end",
"def remove_property(key)\n end",
"def delete(key)\n attribute = key.to_sym\n details.delete(attribute)\n messages.delete(attribute)\n end",
"def attr_clean!(key)\n @dirty_attribute_keys ||= []\n @dirty_attribute_keys.delete_if {|k| k == key.to_sym }\n end",
"def - (name) remove_attribute name end",
"def remove_attribute(name)\n attr = attributes[name].remove if key? name\n clear_xpath_context if Nokogiri.jruby?\n attr\n end",
"def delete_attribute(attr_name)\n debug(\"Model#delete_attribute(#{attr_name.inspect})\")\n set_attribute(attr_name, nil)\n end",
"def remove_attribute(to_remove)\n index = 0\n if not to_remove.kind_of? Fixnum\n index = find_index_of_attribute(to_remove)\n else\n index = to_remove\n end\n # binding.pry\n\n if not index.nil?\n @attributes.delete_at index\n @data.each do |d|\n d.delete to_remove\n end\n end\n self\n end",
"def remove_attribute(attr)\n C.LLVMRemoveFunctionAttr(self, attr)\n end",
"def kwattr_remove(attribute_name, keywords); end",
"def del_attribute(opts = {})\n data, _status_code, _headers = del_attribute_with_http_info(opts)\n return data\n end",
"def remove(key); end",
"def remove_attr name\n each do |el|\n next unless el.respond_to? :remove_attribute\n el.remove_attribute(name)\n end\n self \n end",
"def delete(attribute)\n `c$Element.prototype.m$remove_property.call(#{@element},attribute)`\n end",
"def remove_attribute(node_id:, name:)\n {\n method: \"DOM.removeAttribute\",\n params: { nodeId: node_id, name: name }.compact\n }\n end",
"def delete(attribute); end",
"def del(key)\n @meta.delete(key.to_sym) if key\n end",
"def remove(key)\n a_hash[key] = nil\n end",
"def remove(key)\n\n end",
"def remove_key(key)\n\t\tdelete(\"/user/keys/#{escape(key)}\")\n\tend",
"def remove_key(key)\n\t\tdelete(\"/user/keys/#{escape(key)}\")\n\tend",
"def remove_attribute(name)\n `#{@element}.removeAttribute(#{name})`\n end",
"def erase(attr)\n erased << attr.to_s\n end",
"def remove_attribute(name)\n `#@native.removeAttribute(name)`\n end",
"def removeAttribute(name)\n ret = getAttributeNode(name)\n removeAttributeNode(ret) if ret\n end",
"def remove_key(key)\n deprecate # 07/31/2012\n delete(\"/user/keys/#{escape(key)}\").to_s\n end",
"def delete_key(key)\n end",
"def remove( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && HTMapHelper.remove_map( self, key )\n end",
"def delete_with_key(key)\n real_key = @original_properties.keys.find { |k| k.to_s == key.to_s }\n @original_properties.delete(real_key)\n end",
"def removeAttribute(name)\n `#{@el}.removeAttribute(#{name})`\n end",
"def delete_custom_attribute(product_id, attribute_name)\n response, status = BeyondApi::Request.delete(@session, \"/products/#{product_id}/attributes/#{attribute_name}\")\n\n handle_response(response, status, respond_with_true: true)\n end",
"def delete_user_custom_attribute(key, user_id)\n delete(\"/users/#{user_id}/custom_attributes/#{key}\")\n end",
"def delete(key)\n @hash.delete(key.to_s)\n end",
"def removed(attribute_name)\n changed(attribute_name)\n end",
"def removed(attribute_name)\n changed(attribute_name)\n end",
"def remove(key)\n\n if include?(key)\n self[key].delete(key)\n @count -= 1\n end\n\n end",
"def delete(key)\n @ivar.each_with_index do |ele, i|\n if ele[0] == key\n @ivar.delete_at(i)\n end\n end\n end",
"def remove_attribute(locator, attribute)\n execute_script(%(\n var element = arguments[0];\n var attributeName = arguments[1];\n if (element.hasAttribute(attributeName)) {\n element.removeAttribute(attributeName);\n }\n ), find_element(locator), attribute)\n end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def unset(key)\n update(key) { |option| @data.delete(option.name) }\n end",
"def delete(key)\n key = alternate_key(key) unless has_key?(key)\n super\n end",
"def delete(attr)\n attr = attr.intern\n if @parameters.has_key?(attr)\n @parameters.delete(attr)\n else\n raise Puppet::DevError.new(\"Undefined attribute '#{attr}' in #{self}\")\n end\n end",
"def delete_attribute(*args)\n end",
"def unset_value(key)\n database.delete(key)\n removed_keys << key\n end",
"def remove(key)\n row = key >> 10\n column = @a[row].index{|(i,v)| i == key}\n if column\n @a[row].delete_at(column)\n end\n end",
"def clear_attribute( attribute )\n send(\"#{attribute}=\", nil)\n end",
"def reset(attribute)\n @attributes.delete attribute.to_sym\n end",
"def attr_dirty!(key)\n @dirty_attribute_keys ||= []\n @dirty_attribute_keys << key.to_sym\n @dirty_attribute_keys.uniq!\n end",
"def delete(key)\n @data.delete(key)\n @key_size.delete(key)\n end",
"def delete_kapp_attribute_definition(kapp_slug, name, headers=default_headers)\n @logger.info(\"Deleting the \\\"#{name}\\\" Kapp attribute definition from the \\\"#{kapp_slug}\\\" kapp.\")\n delete(\"#{@api_url}/kapps/#{kapp_slug}/kappAttributeDefinitions/#{encode(name)}\", headers)\n end",
"def remove(key)\n @store.delete_if { |i| i[:key] == build_key(key) }\n end",
"def delete attrib\n if attrib.is_a? String and attrib.include? \".\"\n syms = attrib.split(\".\")\n first = syms[0]\n rest = syms[1..-1].join(\".\")\n self.send(first).delete(rest)\n else\n self.delete_field(attrib)\n end\n end",
"def delete(key)\n @hash.delete key\n @key_hash.delete key\n end",
"def del_attribute_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi.del_attribute ...\"\n end\n # resource path\n local_var_path = \"/{uuid}/attribute/{key}\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse2004')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#del_attribute\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def remove_property(attribute)\n `var el=this.__native__,attr=attribute.__value__,bool=c$Element.__boolean_attributes__[attr],key=c$Element.__boolean_attributes__[attr]||bool`\n `key ? el[key]=bool?false:'' : el.removeAttribute(attr)`\n return self\n end",
"def delete(key)\n\n end",
"def delete(key)\n @relation.delete(key)\n end",
"def destroy\n self.class.remove(key)\n end",
"def destroy\n self.class.remove(key)\n end",
"def remove_key(key)\n delete(\"/users/ssh_keys/#{escape(key)}\").to_s\n end",
"def del(key)\n @first.del(key)\n end",
"def remove(key)\n File.unlink cache_path(key)\n rescue Errno::ENOENT\n end",
"def remove(key, options = {})\n fetch({:method => :delete, :key => key, :body_to_params => true, :body => options}).parsed_response\n end",
"def delete( key )\n context.delete(key.to_s)\n end",
"def del(key)\n response = db.delete_item(@table_name, {'HashKeyElement' => {'S' => key}})\n true\n end",
"def unset(key)\n run { conf.unset(key, config_params) }\n end",
"def delete(key)\n unimplemented\n end",
"def remove(key)\n with_client do |client|\n client.del(build_key(key))\n end\n end",
"def delete key\n write_data_entry key, nil, true\n @keydict[key] = nil\n\n sync\n end",
"def unset key\n storage.delete key\n end",
"def delete_user_attribute(email_address, attribute)\n found_user = read_user(email_address)\n if found_user\n dn = get_DN(found_user[:cn])\n Net::LDAP.open(@ldap_conf) do |ldap|\n ldap.delete_attribute(dn, ENTITY_ATTR_MAPPING[attribute])\n end\n end\n end",
"def delete(key)\n value = self[key]\n\n @memcached.delete key\n\n value\n end",
"def read_attribute(key)\n if type = namespace.attribute_type(key)\n key = type.names.first\n else\n key = Ldaptic.encode(key)\n end\n @attributes[key] ||= ((@original_attributes || {}).fetch(key, [])).dup\n Ldaptic::AttributeSet.new(self, key, @attributes[key])\n end",
"def kwattr_remove(attribute_name, keywords)\n if keywords.nil?\n remove_attribute(attribute_name)\n return self\n end\n\n keywords = keywordify(keywords)\n current_kws = kwattr_values(attribute_name)\n new_kws = current_kws - keywords\n if new_kws.empty?\n remove_attribute(attribute_name)\n else\n set_attribute(attribute_name, new_kws.join(\" \"))\n end\n self\n end",
"def delete(attribute)\n `c$Element.prototype.m$remove_style.call(#{@element},attribute)`\n end",
"def delete key\n rv = self[key]\n self.removeField key\n return rv\n end",
"def delete key\n @internal_hash[key].clear\n end",
"def remove(key)\n @map.delete(key)\n end",
"def remove(*key)\n @cache.delete(key)\n end",
"def delete_option(key, meta_key = \"_default\")\n values = cama_options(meta_key)\n key = key.to_sym\n values.delete(key) if values.has_key?(key)\n set_meta(meta_key, values)\n end",
"def delete(key)\n super(convert_key(key))\n end",
"def delete(key)\n return self unless @hash.key?(key)\n\n h = Hash[@hash]\n h.delete(key)\n self.class.create(h)\n end",
"def unregister(key)\n @data.update { |h| h.dup.tap { |j| j.delete(key) } }\n self\n end",
"def delete(attribute)\n attribute = (\"@\"+attribute).to_sym if attribute.to_s !~ /^@/\n instance_variable_set(attribute.to_sym, nil)\n end",
"def delete(key)\n @succ.delete key\n end",
"def delete(key)\n super(convert_key(key))\n end"
] |
[
"0.85295427",
"0.8046233",
"0.7494352",
"0.7494352",
"0.7494352",
"0.7494352",
"0.7170832",
"0.7170832",
"0.7168768",
"0.71535647",
"0.71510696",
"0.708984",
"0.70307964",
"0.7027887",
"0.6876078",
"0.685754",
"0.68046373",
"0.6751213",
"0.6698729",
"0.6678779",
"0.667554",
"0.6673347",
"0.66536385",
"0.6639876",
"0.66372836",
"0.660744",
"0.65945923",
"0.65502363",
"0.65502363",
"0.6539565",
"0.646932",
"0.644373",
"0.64318115",
"0.6429775",
"0.64276886",
"0.6424365",
"0.64131063",
"0.6369642",
"0.63555163",
"0.6353127",
"0.6352665",
"0.62795115",
"0.62795115",
"0.6248401",
"0.62308705",
"0.6227252",
"0.6218646",
"0.6218646",
"0.6218646",
"0.6218646",
"0.6218646",
"0.6190472",
"0.6182144",
"0.6178433",
"0.617767",
"0.6172363",
"0.61405104",
"0.61342657",
"0.61286247",
"0.6123182",
"0.61169994",
"0.61092025",
"0.6106665",
"0.61017317",
"0.60899764",
"0.608059",
"0.6066888",
"0.60657406",
"0.60475606",
"0.60428256",
"0.60428256",
"0.6041822",
"0.6034309",
"0.6033359",
"0.60092515",
"0.60024774",
"0.5999377",
"0.59893835",
"0.59839207",
"0.5978541",
"0.5953174",
"0.594602",
"0.59324723",
"0.59312326",
"0.5929392",
"0.5922807",
"0.5917765",
"0.59118766",
"0.59076864",
"0.58735764",
"0.5859652",
"0.58500594",
"0.58474284",
"0.58465093",
"0.58461004",
"0.58230656",
"0.5822933",
"0.58200717"
] |
0.83570427
|
3
|
Retrieve all the attribute names (keys). like Hashkeys
|
def keys
getAttributeNames.to_a
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def keys\n attributes.keys\n end",
"def keys\n @attributes.keys\n end",
"def attribute_names\n names = []\n @attributes.each {|values| names << values.keys if values}\n names.flatten.uniq\n end",
"def keys\n attribute_nodes.map(&:node_name)\n end",
"def attribute_keys\n return [] unless self[:attributes]\n self[:attributes].keys\n end",
"def attribute_names\n @name_to_definition.keys\n end",
"def keys\n Keys[to_attr_list]\n end",
"def attributes\n @attrs.keys\n end",
"def attribute_names\n @attributes.keys.sort\n end",
"def attribute_names\n attributes.keys.sort\n end",
"def attribute_names\n attributes.keys.sort\n end",
"def attribute_names\n @attribute_names ||= attributes.keys\n end",
"def attribute_names\n @attributes.keys.sort\n end",
"def attribute_keys\n self.class.attribute_keys\n end",
"def attribute_names\n @attributes.map(&:name)\n end",
"def attribute_names\n @attribute_names ||= attribute_definitions.keys.collect {|a|a.to_s}\n end",
"def attribute_names\n @attribute_names ||= attribute_definitions.keys.map(&:to_s)\n end",
"def attribute_names\n self.class.attributes.map { |a| a[:name] }\n end",
"def attr_keys\n\t\treturn attr_keys_in @current_node\n\tend",
"def get_array_of_symbolic_keys\n # getting array of keys (in symbol form)\n all_fields = self.attributes.keys.map do |key|\n key.to_sym;\n end\n return all_fields\n end",
"def keys(model)\n model.attributes.keys\n end",
"def keys(tf = true)\n attributes(tf).keys\n end",
"def attribute_names\r\n translated_attribute_names.map(&:to_s) + @attributes.keys.sort\r\n end",
"def attribute_names\n Array.new\n end",
"def attribute_names\n @attribute_names ||= if !abstract_class?\n attribute_types.keys\n else\n []\n end\n end",
"def field_names\n attribute_names.map(&:to_sym)\n end",
"def attribute_names(normalize=false)\n ensure_apply_object_class\n names = @attr_methods.keys\n if normalize\n names.collect do |name|\n to_real_attribute_name(name)\n end.uniq\n else\n names\n end\n end",
"def attribute_titles\n attribute_names.map {|f| f.to_s.capitalize.sub(/$/, \":\").gsub(/_/, \" \") }\n end",
"def attributes\n @data.keys\n end",
"def attributes\n self.attribute_keys.inject({}) do |hash, key|\n hash[key] = self.__send__(key) if self.__send__(key)\n hash\n end\n end",
"def keys\n [ name ]\n end",
"def keys(name)\n key_schema(name).each_with_object({}) do |s, h|\n h[s.key_type.downcase.to_sym] = s.attribute_name\n end\n end",
"def attributes\n ATTRIBUTE_NAMES\n end",
"def attribute_names\n raise NotImplementedError\n end",
"def list_attributes\n if @attributes.empty?\n fetch_configuration()\n end\n return @attributes.keys\n end",
"def members\n attributes.keys\n end",
"def field_names\n @field_names ||= attribute_names.map(&:to_sym)\n end",
"def attribute_names\n self.class.attribute_names\n end",
"def keys\n fields.map { |f| f.name }\n end",
"def names\n iterator = @form_fields.keySet.iterator\n set = []\n set << iterator.next.toString.to_sym while iterator.hasNext\n set\n end",
"def collect_attribute_labels(original_data)\n original_data.keys\nend",
"def attr_keys_in(node)\n\t\treturn is_valid(node) ? node.keys : nil\n\tend",
"def attributes\n self._attributes.inject({}) do |hash, attr|\n hash[attr.to_s] = send(attr)\n hash\n end\n end",
"def keys\n values.map(&:to_sym)\n end",
"def keys\n\n self.to_h.keys\n end",
"def keys\n map(&:key)\n end",
"def keys\n @data.keys.sort.collect { |k| k.to_sym }\n end",
"def list_keys\n @keys.keys\n end",
"def keys\n list = []\n each_key{|key| list << key}\n list\n end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def attributes_get\n h = {}\n self.class.attributes.each do |a|\n h[a] = attribute_get(a)\n end\n h\n end",
"def attributes_get\n h = {}\n self.class.attributes.each do |a|\n h[a] = attribute_get(a)\n end\n h\n end",
"def attr\n @attr.map{|k,v| \"#{k}=\\\"#{h v}\\\"\"}.sort.join(' ')\n end",
"def attribute_names\n relvar_def.attribute_names\n end",
"def list_keys\n @keydict.keys\n end",
"def list_keys()\n # TODO\n end",
"def as_names\n __getobj__.map { |i| i.name }\n end",
"def names\n all.map { |item| item.name_sym }\n end",
"def keys\n @hash.keys\n end",
"def keys\n @hash.keys\n end",
"def keys\n @hash.keys\n end",
"def attributes\n Hash.new.tap do |atts|\n _accessors.each do |accessor|\n att = accessor[0..-2].to_sym\n atts[att] = send(att)\n end\n end\n end",
"def keys\n @hash.keys\n end",
"def keys\n @hash.keys\n end",
"def key_attributes\n [\n first_and_middle_names,\n family_name,\n date_of_birth,\n place_of_birth,\n parent_first_and_middle_names,\n parent_family_name,\n other_parent_first_and_middle_names,\n other_parent_family_name\n ]\n end",
"def keys\n struct.keys\n end",
"def attr_strings\n @attr_strings\n end",
"def fields\r\n @hash.keys\r\n end",
"def derived_attribute_names\n Module.nesting.first.public_instance_methods - [:derived_attribute_names]\n end",
"def attributes\n self.class.attribute_names.map do |name|\n [name.to_s, self.send(name)]\n end.to_h\n end",
"def attributes *attr_names\n @attribute_names ||= Set.new\n\n attr_names.each { |attr_name| @attribute_names << attr_name.intern }\n end",
"def keys(*) end",
"def attributes\n self\n .class\n .attribute_names\n .map { |attr| [attr, send(attr)] }\n .reject { |_, value| value.nil? }\n .map do |attr, value|\n [attr, value.respond_to?(:attributes) ? value.attributes : value]\n end\n .to_h\n end",
"def attributes\n @attributes = Hash[attrs.map { |a| [a.to_sym, send(\"#{a}\")] }]\n end",
"def attributes\n # Note: the values returned here are ignored by\n # ActiveModel::Serializers#serializable_hash; just the keys are\n # used to again call those getter methods... But we do want to\n # check the values so we can leave 'nil' out of the hash.\n attribute_keys.inject(\n ActiveSupport::HashWithIndifferentAccess.new) do |result, key|\n value = send(key)\n result[key] = value unless value == nil\n result\n end\n end",
"def keys\n map { |line| line.key }\n end",
"def keys\n end",
"def keys\n end",
"def keys\n end",
"def keys\n end",
"def keys\n keys = []\n each_pair {|k,v| keys << k}\n keys\n end",
"def keys\n @children.map(&:title)\n end",
"def keys\n @key\n end",
"def keys\n @data.keys\n end",
"def keys\n @data.keys\n end"
] |
[
"0.83720696",
"0.83720696",
"0.83720696",
"0.83720696",
"0.83421046",
"0.83070236",
"0.8240137",
"0.82318974",
"0.8211159",
"0.81253296",
"0.80687785",
"0.8066238",
"0.7990659",
"0.79830986",
"0.79690486",
"0.79690486",
"0.7962223",
"0.79262525",
"0.79241925",
"0.7881712",
"0.778492",
"0.7677684",
"0.76750803",
"0.766754",
"0.7657624",
"0.7604993",
"0.7600134",
"0.75415236",
"0.7510867",
"0.7479878",
"0.7464051",
"0.7452485",
"0.7446589",
"0.739432",
"0.7367228",
"0.73648965",
"0.7362643",
"0.7246267",
"0.71644795",
"0.7153589",
"0.7120301",
"0.7120298",
"0.7115178",
"0.7115075",
"0.70526916",
"0.70429486",
"0.7031355",
"0.6991603",
"0.6987397",
"0.6984405",
"0.6972479",
"0.694716",
"0.6925479",
"0.6910588",
"0.68940187",
"0.68940187",
"0.68940187",
"0.68940187",
"0.68940187",
"0.68940187",
"0.68940187",
"0.68940187",
"0.68940187",
"0.68927515",
"0.68927515",
"0.68880785",
"0.6834243",
"0.68326086",
"0.6809002",
"0.6803844",
"0.6779739",
"0.67637646",
"0.67637646",
"0.67637646",
"0.674875",
"0.67403996",
"0.67403996",
"0.6739739",
"0.67363733",
"0.67330116",
"0.67286366",
"0.67035043",
"0.6702402",
"0.66897714",
"0.6683978",
"0.6670623",
"0.66624314",
"0.66452247",
"0.6639712",
"0.6630377",
"0.6620282",
"0.6620282",
"0.6620282",
"0.66132814",
"0.6607861",
"0.66019255",
"0.659863",
"0.659863"
] |
0.8470216
|
0
|
Iterate over every attribute name/value pair from the context. like Hasheach
|
def each
getAttributeNames.each { |name| yield(name, getAttribute(name)) }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def each_attribute(&block)\n attributes.each(&block)\n end",
"def each_attribute(&block)\n\t\t @@attributes.each &block\n\t\tend",
"def each_attribute # :yields: key\n @attrs.each_key { |k| yield(k) }\n end",
"def each_attribute(&block)\n attributes.each_attribute(&block)\n end",
"def each # :yields: key, value\n @attrs.each { |k, v| yield(k, v) }\n end",
"def each(&block)\n attributes.each_value(&block)\n end",
"def each_attribute_pair(&block)\n @attributes.each_pair do |name, value|\n block.call(name, value)\n end\n end",
"def attributes\n if iterator?\n @attr.each do |key, value|\n yield(value)\n end if @attr\n else\n @attr\n end\n end",
"def each(&block)\n attributes.each(&block)\n end",
"def each(&block)\n attributes.each(&block)\n end",
"def each\n attribute_nodes.each { |node|\n yield [node.node_name, node.value]\n }\n end",
"def each_value # :yields: value\n @attrs.each_value { |v| yield(v) }\n end",
"def attributs()\n if block_given?\n rados_getxattrs.each { |key,value| \n yield key,value\n }\n else\n return rados_getxattrs\n end\n \n end",
"def each(&block)\n\t\t\tvalues = {}\n\t\t\teach_attribute do |attr|\n\t\t\t\tvalue = self.fetch(attr)\n\t\t\t\tif not value.nil?\n\t\t\t\t\tvalues[attr] = value\n\t\t\t\tend\n\t\t\tend\n\t\t values.each &block\n\t\tend",
"def attributes(*args)\n args.each do |attr|\n attribute(attr)\n end\n end",
"def each_attr_in(items)\n items.each do |item|\n if item.is_a?(Hash)\n each_attr_in(item[:items]) if item[:items].is_a?(Array)\n yield(item) if item[:name]\n end\n end\n end",
"def attributes(*args)\n args.each { |attr| attribute(attr) }\n end",
"def each_attribute(&blk)\n to_enum(:_each_attribute).sort_by{|attr| attr.name}.each(&blk)\n end",
"def with_attributes(attributes_hash)\n attributes_hash = attributes.merge(attributes_hash)\n Context.with_value(CURRENT_ATTRIBUTES_HASH, attributes_hash) { |c, h| yield h, c }\n end",
"def attributes\n @context[:attributes]\n end",
"def attributes\n instance_variables.each do |var|\n child = instance_variable_get var\n name = var.to_s[1..-1]\n yield child, name\n end\n end",
"def attributes(*attrs, **args)\n attrs.each { |attr| attribute(attr, **args) }\n end",
"def attributes(attrs)\n\t\t\tattrs.each do |k,v|\n\t\t\t\tsetter = \"#{k}=\".to_sym\n\t\t\t\tself.send(setter, v)\n\t\t\tend\n\t\t\t\n\t\t\tyield self if block_given?\n\t\t\t\n\t\t\treturn self\n\t\tend",
"def each(opts={})\n options = {\n :index => :any\n }.update(opts)\n index = options[:index]\n attribs = normalize_attribute_list options[:attributes]\n if index == :any\n @attributes.each_with_index do |values,idx|\n values.clone.each { |attribute,value| next if attribs && !attribs.include?(attribute); yield attribute,value,idx } if values\n end\n else\n index = normalize_index(index)\n values = @attributes[index]\n values.clone.each { |attribute,value| next if attribs && !attribs.include?(attribute); yield attribute,value,index } if values\n end \n end",
"def attribute_values(attributes)\n attributes.map { |attribute| self.send(attribute) }\n end",
"def kwattr_values(attribute_name); end",
"def attributes\n @attributes = Hash[attrs.map { |a| [a.to_sym, send(\"#{a}\")] }]\n end",
"def attributes(*attrs)\n\n self._attributes = _attributes.dup\n\n attrs.each do |attr|\n if Hash === attr\n attr.each {|attr_real, key| attribute attr_real, :key => key }\n else\n attribute attr\n end\n end\n end",
"def attributes(*attrs)\n attrs.each { |attr_name| @_attributes[attr_name.to_sym] = attr_name.to_sym }\n end",
"def attributes(*args, &block)\n if current_object.nil?\n raise(ArgumentError, \"You cannot use #attributes when inferred object is not present.\")\n end\n\n args.each do |arg|\n if arg.is_a?(Hash)\n merge_result!(arg.keys.first, current_object.send(arg.values.first))\n else\n merge_result!(arg, current_object.send(arg))\n end\n end\n nil\n end",
"def each()\n fields.each do |name|\n yield(name, instance_variable_get(\"@#{name}\".intern))\n end\n end",
"def attributes\n @ldap_entry.attribute_names.each_with_object({}) do |key, hsh|\n hsh[key] = get_value(key)\n end\n end",
"def enumerate_attrs\n @node_attrs.keys.each_with_object({}) { |node, h|\n h[node] = enumerate_attrs_by_node(node)\n }\n end",
"def helper_attr(*attrs)\n attrs.flatten.each { |attr| helper_method(attr, \"#{attr}=\") }\n end",
"def helper_attr(*attrs)\n attrs.flatten.each { |attr| helper_method(attr, \"#{attr}=\") }\n end",
"def attributes(context = nil)\n context ||= Context.current\n context.value(CURRENT_ATTRIBUTES_HASH) || {}\n end",
"def attributes\n _fast_attributes\n\n rescue NameError\n\n method = \"def _fast_attributes\\n\"\n method << \" @_attributes ||=\\n\"\n method << \" begin\\n\"\n method << \" h = {}\\n\"\n\n self.class.attributes.each do |name|\n method << \" h[:\\\"#{name}\\\"] = send(:\\\"#{name}\\\") if include_#{name}?\\n\"\n end\n\n method << \" h\\n\"\n method << \" end\\n\"\n method << \"end\"\n\n self.class.class_eval method\n\n _fast_attributes\n end",
"def enumerate_attrs\n @node_attrs.keys.each_with_object({}) do |node, h|\n h[node] = enumerate_attrs_by_node(node)\n end\n end",
"def define_attributes\n @attributes = {}\n @attribute_map = {}\n yield # to the user defined block for further instruction\n @keys = @attributes.keys.freeze\n @attribute_map.freeze\n @attributes.freeze\n end",
"def hit_on_attributes attrhash, site\n return unless results.present? && site\n attrhash.each do |label, value_or_set|\n if value_or_set.is_a? Hash\n (value_or_set = value_or_set.values).map { |value|\n hit_on_attribute label, value, site\n }\n else\n hit_on_attribute label, value_or_set, site\n end\n end\n end",
"def current_attributes\n attributes.each_key.each_with_object({}) do |key, h|\n h[key] = public_send(key)\n end\n end",
"def attribute_values\n self.class.attributes.map{ |attr| self.send(attr) }\n end",
"def each\n messages.each_key do |attribute|\n self[attribute].each { |hint| yield attribute, hint }\n end\n end",
"def values(xml)\n self.class::ATTRS.each do |attribute|\n value = instance_variable_get(\"@#{attribute}\") || ''\n xml[:v20].public_send(attribute, value)\n end\n end",
"def helper_attr(*attrs)\n attrs.flatten.each { |attr| helper_method(attr, \"#{attr}=\") }\n end",
"def attribute_list(el); end",
"def attributes\n [@attribute,@value].inject(Hash.new([])) do |memo,c|\n case c \n when Sower::Relation::Statement, Sower::Relation::Attribute, Sower::Relation::Value::Base\n memo.merge!(c.attributes){|k,v,n| v | n}\n end\n memo\n end\n end",
"def each_property\n IO.readlines(path).each do |l|\n begin\n stripped = l.strip.encode(\"UTF-8\")\n if stripped.match(/^\\-\\-\\s+sem\\.attribute\\./)\n stripped.sub!(/^\\-\\-\\s+sem\\.attribute\\./, '')\n name, value = stripped.split(/\\=/, 2).map(&:strip)\n yield name, value\n end\n rescue Encoding::InvalidByteSequenceError\n # Ignore - attributes must be in ascii\n end\n end\n rescue Encoding::InvalidByteSequenceError\n # Ignore - file must be in ascii in order to parse attributes\n end",
"def each(opts={}, &block)\n attribute_definitions.map{|name, attribute| attribute.to_rdf(self, opts)}.each(&block)\n end",
"def sf_attributes(*attrs)\n attrs.each do |attr|\n sf_attribute attr\n end\n end",
"def method_missing(method, *args, &block)\n @attributes.send(method, *args, &block)\n end",
"def attributes\n # ...\n # debugger\n # f = method_missing(name)\n @attributes ||= {}\n # attributes = Hash.new {|h,k| h[k] = []}\n # @attributes = @colm.map {|colm| attributes[colm]}\n # unless instance_variables(false).include?(f)\n # # print f\n # end\n\n # @attribute ={}\n end",
"def get_attributes\n\t\t\t@@attributes\n\t\tend",
"def attributes_get\n h = {}\n self.class.attributes.each do |a|\n h[a] = attribute_get(a)\n end\n h\n end",
"def attributes_get\n h = {}\n self.class.attributes.each do |a|\n h[a] = attribute_get(a)\n end\n h\n end",
"def collect(*args) # :nodoc:\n args.inject({}) do |buffer, attr_name|\n value = send(attr_name)\n buffer[attr_name] = value if value\n buffer\n end\n end",
"def each\n @params.keys.each { |key| yield key, self[key] }\n end",
"def attributes\n @attrs.keys\n end",
"def attributes\n ATTRIBUTES.each_with_object({}) do |name, buffer|\n buffer[name] = public_send(name)\n end\n end",
"def attributes\n {}.tap do |attributes|\n attribute_names.each do |key|\n attributes[key] = send(key)\n end\n end\n end",
"def attributes\n attributes = {}\n self.instance_variables.each do |i| \n meth = i.gsub(\"@\",\"\")\n attributes[meth.to_sym] = self.send meth\n end\n attributes\n end",
"def values(tf = true)\n attributes(tf).map{ |k, a| @this.send(k)}\n end",
"def update_attributes(atts)\n atts.each { |att, val| send(:\"#{att}=\", val) }\n end",
"def attributes\n attrs = Hash.new\n attribute_list.each do |attribute|\n value = self.send(attribute)\n attrs[attribute] = value unless value.nil?\n end\n attrs\n end",
"def attributes\n self._attributes.inject({}) do |hash, attr|\n hash[attr.to_s] = send(attr)\n hash\n end\n end",
"def attributes\n self.attribute_keys.inject({}) do |hash, key|\n hash[key] = self.__send__(key) if self.__send__(key)\n hash\n end\n end",
"def parse_attributes! #:nodoc:\n self.attributes = (attributes || []).map do |key_value|\n name, type = key_value.split(':')\n Rails::Generators::GeneratedAttribute.new(name, type)\n end\n end",
"def attribute(*args)\n if args.first.is_a?(Hash)\n args.first.each_pair { |k,v| self.attribute(k, :as => v) }\n else # array of attributes\n options = args.extract_options!\n @_options[:attributes] ||= {}\n args.each { |name| @_options[:attributes][name] = options[:as] || name }\n end\n end",
"def values\n @attrs.values\n end",
"def allprop(xml = nil)\n @liveprops.each do |key, v|\n if v.allprop?\n begin\n value = self[key, xml]\n yield(key, value) if block_given?\n rescue NotFoundError, UnauthorizedError, ForbiddenError\n end\n end\n end\n end",
"def attributes(*attrs)\n if attrs.size > 0\n attrs.each{|attr| attribute attr}\n end\n @attributes ||= []\n end",
"def method_missing(method, *args, &block)\n @attributes.send(method, *args, &block)\n end",
"def attributes(*attrs)\n @attributes = attrs\n attr_reader(*attrs)\n end",
"def add_student_attributes(attributes_hash)\n attributes_hash.each do |attr, value| #from the hash get each attribute and value\n self.send(\"#{attr}=\", value) #send the studen tthe new attribute/value key pair\n end #end the each-do\n self #call self\n end",
"def attributes\n hash = HashWithIndifferentAccess.new\n\n self.class.attribute_names.each_with_object(hash) do |name, attrs|\n attrs[name] = read_attribute(name)\n end\n end",
"def local_each(attrs)\n timevec[index_range].each_with_index { |time, i| yield hash_at(i, attrs).merge({ :time => time}) }\n end",
"def define_attributes\n @info.attributes.each do |attr|\n rname = underscore(attr.name)\n self.class.__send__(:define_method, rname) { self[attr.name] } if attr.readable?\n self.class.__send__(:define_method, rname + \"=\") {|v| self[attr.name] = v } if attr.writable?\n end\n end",
"def process_attrasgn exp\n process_call exp\n end",
"def process_attrasgn exp\n process_call exp\n end",
"def method_missing(method_name, *args, &block)\n attributes.send(method_name.to_s, *args, &block)\n end",
"def all_attributes\n the_attrs = Hash[accessors.collect {|v| [v, send(v.to_s)] if respond_to? \"#{v}\".to_sym}]\n (respond_to?(:attributes) && attributes.merge(the_attrs)) || the_attrs\n end",
"def attributes\n @cache[:attributes]\n end",
"def attributes\n load_attributes! unless attributes_loaded?\n @attributes.values\n end",
"def data_attributes(*attrs)\n attrs.map(&:to_s).each do |attr|\n define_method attr do\n @data ||= {}\n @data[attr.to_sym]\n end\n\n define_method \"#{attr}=\" do |arg|\n @data ||= {}\n @data[attr.to_sym] = arg\n end\n end\n end",
"def list_attributes\n if @attributes.empty?\n fetch_configuration()\n end\n return @attributes.keys\n end",
"def attribs\n\t\t@attributes\n\tend",
"def attribute_values\n attributes.values\n end",
"def attributes\n @attr_statements ||= begin\n result = {}\n\n stmt_element = REXML::XPath.first(document, \"/p:Response/a:Assertion/a:AttributeStatement\", { \"p\" => PROTOCOL, \"a\" => ASSERTION })\n stmt_element.elements.each do |attr_element|\n name = attr_element.attributes[\"Name\"]\n value = attr_element.elements.first.text\n\n result[name] = value\n end\n\n result.keys.each do |key|\n result[key.intern] = result[key]\n end\n\n result\n end\n end",
"def attributes= attributes = {}\n return if attributes.nil?\n attributes.each_pair { |k, v|\n # Parse the nested attributed to instantiate the right model, is applicable\n value = FlightStats::Resource.from_parsed_json(v, k)\n send(\"#{underscore_with_caching(k)}=\", value) rescue nil\n }\n end",
"def add_attrs\n yield self\n end",
"def attributes\n ATTRIBUTES.inject({}) do |hash, attribute|\n hash[attribute] = self.send(attribute)\n hash\n end\n end",
"def attributes\n ATTRIBUTES.inject({}) do |hash, attribute|\n hash[attribute] = self.send(attribute)\n hash\n end\n end",
"def context\n attributes.fetch(:context)\n end",
"def method_missing(method, *args, &block)\n attributes.public_send(method, *args, &block)\n end",
"def attribute_value\n @attributes.each { | id, value | return value }\n end",
"def parse_attributes! #:nodoc:\n self.attributes = (attributes || []).map do |attr|\n Barbecue::Generators::GeneratedAttribute.parse(attr)\n end\n end",
"def lively_attributes(*args)\n self._active_attributes += args.collect(&:to_s)\n end",
"def initialize(atts)\n atts.each do |key, val|\n accessor = \"#{key}=\"\n\n if respond_to?(accessor)\n send(accessor, val)\n end\n end\n end"
] |
[
"0.77277815",
"0.7718536",
"0.76774967",
"0.75490063",
"0.75388104",
"0.750261",
"0.7461197",
"0.7363203",
"0.7356307",
"0.7356307",
"0.72969013",
"0.7191803",
"0.71763533",
"0.70837915",
"0.6812762",
"0.673729",
"0.67111945",
"0.668203",
"0.661299",
"0.65600127",
"0.6490451",
"0.6420477",
"0.634916",
"0.6315204",
"0.6296237",
"0.62513644",
"0.6222836",
"0.6213517",
"0.61962515",
"0.6190727",
"0.6175984",
"0.61716354",
"0.6153964",
"0.61339974",
"0.61339974",
"0.61248845",
"0.6115958",
"0.61049926",
"0.6094738",
"0.60770655",
"0.60622144",
"0.60466766",
"0.6036135",
"0.602773",
"0.60240835",
"0.6018018",
"0.60142285",
"0.6011864",
"0.5999317",
"0.59726167",
"0.5954212",
"0.5949694",
"0.5946046",
"0.5939816",
"0.5939816",
"0.5936891",
"0.59228706",
"0.5906036",
"0.59041977",
"0.58918846",
"0.5884153",
"0.5875832",
"0.5862939",
"0.58606225",
"0.5856952",
"0.5855035",
"0.5847308",
"0.5843627",
"0.5842671",
"0.5835633",
"0.58335924",
"0.58311725",
"0.5827756",
"0.5817946",
"0.58087915",
"0.5803006",
"0.5795556",
"0.579411",
"0.579411",
"0.57909983",
"0.5783003",
"0.5774991",
"0.5773587",
"0.57698256",
"0.5758858",
"0.57562697",
"0.5749605",
"0.5742196",
"0.5740344",
"0.5738823",
"0.5737388",
"0.5737388",
"0.5732712",
"0.57275635",
"0.57226336",
"0.5719173",
"0.56941485",
"0.56916994"
] |
0.77591556
|
2
|
Set an attribute in the servlet request.
|
def []=(key, val)
setAttribute(key.to_s, val)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_attribute(name, value); end",
"def set_attribute(attribute, value)\n if MojeID.is_attribute_available?(attribute)\n fetch_request.set_values(attribute, value)\n bundle_to_request\n end\n end",
"def setAttribute(attributeName)\n @attributeName = attributeName\n end",
"def set attribute, value\n attributes[attribute] = value\n end",
"def setAttrib(name,value)\n\t\t@attributes[name] = value\n\tend",
"def set_attribute(id, attr)\n\t\t\t@current_context.set_attribute(id, attr)\n\t\tend",
"def set_attribute(key_, value_)\n attribute(key_, value_, :set)\n end",
"def set_attribute(name, value)\n @attributes[name] = value\n end",
"def set_attr\n @attr = Attr.find(params[:id])\n end",
"def set_attr\n @attr = Attr.find(params[:id])\n end",
"def set_attribute\n @attribute = Attribute.find(params[:id])\n end",
"def set_attribute\n @attribute = Attribute.find(params[:id])\n end",
"def set(attribute, value)\n @attributes[attribute.to_s] = value\n nil\n end",
"def set_shmrequestattribute\n @shmrequestattribute = Shmrequestattribute.find(params[:id])\n end",
"def []=(attr, value)\n @attrs[attr] = value\n end",
"def set_attr(attr, value)\n ret = LibSeccomp.seccomp_attr_set(context, attr, value)\n raise SystemCallError.new(\"seccomp_attr_set(context, #{attr.inspect}, #{value}) failed\", -ret) if ret < 0\n end",
"def []= attribute, value\n `#@native.setAttribute(#{attribute}, #{value})`\n end",
"def set_attr(name, value)\n each_value {|x| x[name] = value }\n end",
"def set_attribute(a,b)\n write_attribute(a,b)\n end",
"def attribute_set(name, value)\n @dirty[name] = true\n @attributes[:current][name] = value\n end",
"def []=(attr_name, value)\n @attributes.write_from_user(attr_name.to_s, value)\n end",
"def attribute=(attribute_name, value)\n write_attribute(attribute_name, value)\n end",
"def attribute=(attribute_name, value)\n write_attribute(attribute_name, value)\n end",
"def set_attr(key, value)\n value = format_value(value)\n key = format_key(key)\n send(\"#{key}=\", value)\n rescue\n unless defined?(Rails).nil?\n $lxca_log.info(\n 'XClarityClient::Endpoints::BuildableResourceMixin',\n \"UNEXISTING ATTRIBUTES FOR #{self.class}: #{key}\"\n )\n end\n end",
"def set_attribute(dict_name, key, value)\n end",
"def []=(attr_name, value)\n @attributes[attr_name.to_s] = value\n end",
"def []= (attr_name, value) \n write_attribute(attr_name, value)\n end",
"def []=(attr_name, value)\n write_attribute(attr_name, value)\n end",
"def []=(attr_name, value)\n write_attribute(attr_name, value)\n end",
"def []=(attr_name, value)\n write_attribute(attr_name, value)\n end",
"def []=(attr_name, value)\n write_attribute(attr_name, value)\n end",
"def set_request_data(key, value)\n self.request_data[key] = value\n end",
"def set_attribute(attribute,value,index=0)\n index = normalize_index(index)\n# puts \"<br>SETTING ATTRIBUTE #{attribute}[#{index}]=#{value} [caller: #{trace}]\"\n @attributes[index] ||= {}\n @attributes[index][normalize_attribute(attribute)] = value\n end",
"def []=(attr_name, value)\n write_attribute(attr_name, value)\n end",
"def set_attribute(dict_name, key, value)\n end",
"def set_attribute(dict_name, key, value)\n end",
"def []=(attr_name, value)\n writer_method = \"#{attr_name}=\"\n send(writer_method, value) if respond_to?(writer_method)\n end",
"def []=(name, value) \n @server.setAttribute @object_name, javax.management.Attribute.new(name.to_s, value)\n end",
"def attribute=(name, value)\n @attributes ||= {}\n @attributes[name] = value\n end",
"def attr attribute_name,value = nil\n string=\"$('##{@id}').attr('#{attribute_name}','#{value}')\"\n @app.dom_on_sockets.execute string\n end",
"def request=(request); @request = request end",
"def []= field, value\n @attributes[field] = value\n end",
"def []=(attribute, value)\n attributes[attribute] = to_field(value)\n end",
"def attribute=(name, val)\n write_attribute(name, val)\n end",
"def []=(name, value)\n @attr[name] = value\n end",
"def []=(attribute, value)\n self.send(\"#{attribute}=\", value)\n end",
"def attribute_setter(attribute_name)\n \"set#{attribute_name.to_s.camelcase(:upper)}\"\n end",
"def []=(key,value)\n @attributes[key] = value\n end",
"def assign(attribute, value)\n @attributes[attribute.to_sym] = value\n end",
"def set_attribute(id, attribute, value)\n\t\to = getObject(id)\n\t\tif (o != nil && o.respond_to?(:[]))\n\t\t\to[attribute] = value\n\t\telse\n\t\t\tputs \"Could not find object with id = #{id}\"\n\t\tend\n\tend",
"def []=(attr_name, value)\n if self.attribute_names.include?(attr_name.to_s)\n write_attribute(attr_name, value)\n else\n set_custom_attribute(attr_name, value)\n end\n end",
"def set_attribute_for element, attr, value\n AXUIElementSetAttributeValue(element, attr, value)\n end",
"def set_attribute(rule, attribute, value)\n begin\n rule.send(\"#{attribute}=\".to_sym, value)\n rescue NoMethodError\n raise AtomMarshallingError.new(\"Attribute #{attribute} unsupported in Atom #{rule_type_name(rule)}.\")\n end\n end",
"def set_attribute(attribute_key, attribute_value)\n @attr_mutex.synchronize { @user_attributes[attribute_key] = attribute_value }\n end",
"def set_attribute(attribute_key, attribute_value)\n @attr_mutex.synchronize { @user_attributes[attribute_key] = attribute_value }\n end",
"def set_attribute\n raise Error::CustomError.error(422, :ATT_01, \"attribute\") unless Number.is_integer?(params[:attribute_id])\n begin\n @attribute = Attribute.find(params[:attribute_id]) \n rescue ActiveRecord::RecordNotFound\n raise Error::CustomError.error(404, :ATT_02, \"attribute\")\n rescue\n raise Error::CustomError.error(500, :ISE, \"attribute\")\n end\n end",
"def set_single_attribute(attribute_name, attribute_value, opts = {})\n Operation::Service.set_attribute(\n :attribute_name => attribute_name,\n :attribute_value => attribute_value,\n :encrypt => opts[:encrypt],\n :service_instance => self.service_instance,\n :service_instance_dir => self.service_instance_dir\n )\n end",
"def set_user_attribute\n @user_attribute = UserAttribute.find(params[:id])\n end",
"def []=(attr, value)\n if Roomorama::Property::ATTRIBUTES.include?(attr)\n setter = [attr, \"=\"].join\n public_send(setter, value)\n end\n end",
"def []=(name, value)\n @attributes[name] = value\n end",
"def set_attribute(locator, attribute, value)\n execute_script(%(\n var element = arguments[0];\n var attribute = arguments[1];\n var value = arguments[2];\n element.setAttribute(attribute, value);\n ), find_element(locator), attribute, value)\n end",
"def []=(attr, value)\n self.send(\"#{attr}=\", value)\n end",
"def []=(attr, value)\n self.send(\"#{attr}=\", value)\n end",
"def []=(attribute, value)\n attribute = attribute.to_s.gsub(/[^a-zA-Z0-9_\\-]/, '').gsub('_', '-')\n # FIXME => Attributes per class\n unless POSSIBLE_ATTRIBUTES.include? attribute\n # FIXME: Log, don't print\n puts \"Warning! Attribute #{attribute} not recognized\"\n @canvas << js_method('attr', {attribute => value})\n return nil\n end\n @canvas << js_method('attr', {attribute => value})\n return self\n end",
"def setattribute_raw(path, name, value)\n Puppet.debug \"#{name.inspect} setting to #{value.inspect} for path: #{path}\"\n cmd = if value.nil?\n \"#{path}:undefine-attribute(name=\\\"#{name}\\\")\"\n else\n \"#{path}:write-attribute(name=\\\"#{name}\\\", value=#{value})\"\n end\n cmd = \"/profile=#{@resource[:profile]}#{cmd}\" if runasdomain?\n state = execute cmd\n Puppet.debug(\"Setting attribute response: #{state.output}\")\n raise \"Cannot set #{name} for #{path}: #{state.output}\" unless state.success?\n @property_hash[name] = value\n end",
"def []= (attr, val)\n sanity_check\n @handle[attr] = val\n end",
"def set_global_attribute(id, attr)\n\t\t\t@project.global_context.set_attribute(id, attr)\n\t\tend",
"def []=(key, value)\n attributes[key] = value\n end",
"def set_attribute(opts = {})\n data, _status_code, _headers = set_attribute_with_http_info(opts)\n return data\n end",
"def set_attribute(name, value)\n if name == 'scrollTop'\n `#{@element}.scrollTop=#{value}`\n else\n `#{@element}.setAttribute(#{name}, #{value})`\n end\n end",
"def assign_attribute(name, value)\n self.send(\"#{name}=\", value) if has_attribute?(name)\n end",
"def op_set(attrname = nil)\n attrname ||= pop\n attrvalue = pop\n receiver = peek\n if receiver.respond_to?(:[]=)\n receiver[attrname] = attrvalue\n elsif receiver.respond_to?(:\"#{attrname}=\")\n receiver.send(:\"#{attrname}=\", attrvalue)\n else\n raise Error, \"Unable to set #{attrname} on #{receiver.inspect}\"\n end\n end",
"def set_request(request)\n ATTRIBUTE_MAP.each do |request_name, attribute_name| \n unless request_name == :region && address_type == :billing # special case\n # this is ugly, but it saves us from subclassing just to change field names in a predictable way...\n request.set_param(\"#{address_type.to_s}_#{request_name}\".to_sym, self.send(attribute_name))\n end\n end\n end",
"def on_attribute(attribute)\n @attribute = attribute\n self\n end",
"def request=(request)\n @@request = request\n end",
"def []=(name, value)\n `return self.removeAttr(name)` if value.nil?\n `self.attr(name, value)`\n end",
"def set_tag_attr (tag_path, attr_name, attr_value)\n\n $test_logger.log(\"Set XML tag attribute #{tag_path}, #{attr_name}, #{attr_value}\")\n\n raise \"XML doc not loaded\" if @xml_ilv_node == nil\n\n #Get target tag\n target_tag = @xml_ilv_node.root.elements[tag_path]\n\n #Raise exception if no tag is found\n raise \"XML path '#{tag_path}' not found!\" if !target_tag\n\n attr_obj = target_tag.add_attribute(attr_name, attr_value)\n\n #Notify changes to load other formats like RAW and HEX\n notify_change(InputChannel::XML)\n end",
"def set_attr\n @inspection = Inspection.find(params[:inspection_id]) if params[:inspection_id]!=nil\n @attr = Attr.find(params[:id]) if params[:id]!=nil\n end",
"def []=(name, value)\n `#{@el}.setAttribute(#{name},#{value})`\n end",
"def []=(attribute,value)\n `c$Element.prototype.m$set_property.call(#{@element},attribute,value)`\n end",
"def set_property(attribute, value)\n `var el=this.__native__,attr=attribute.__value__,bool=c$Element.__boolean_attributes__[attr],key=c$Element.__boolean_attributes__[attr]||bool`\n `key ? el[key]=bool?$T(value):value : el.setAttribute(attr,''+value)`\n return self\n end",
"def _assign_attribute(k, v)\n attributes[k] = v\n super\n end",
"def set_attribute_value(node_id:, name:, value:)\n {\n method: \"DOM.setAttributeValue\",\n params: { nodeId: node_id, name: name, value: value }.compact\n }\n end",
"def update_attribute(attr_name, attr_value)\n update_attributes(attr_name => attr_value)\n end",
"def []=(attribute, value)\n form_data.merge!(Adyen::Util.flatten(attribute => value))\n value\n end",
"def []=(key, value)\n attributes[key] = value\n end",
"def []=(key, value)\n attributes[key] = value\n end",
"def []=(attr, value)\n raise \"argument to [] must be a Symbol or a String.\" unless attr.is_a?(Symbol) or attr.is_a?(String)\n @attributes = { } if !instance_variable_defined?(:@attributes) or @attributes.nil?\n @attributes[attr] = value.to_s\n end",
"def put_on_a_hat\n\n # set all instance variables we have in the sinatra request object\n self.instance_variables.each { |v| @sinatra.instance_variable_set(v, self.instance_variable_get(v)) }\n\n end",
"def write_attribute(key, value)\n @attributes[key] = value\n end",
"def set_attribute_value(attrib_name, attrib_value=nil)\n return set_attribute_values(attrib_name) if attrib_name.is_a? Hash \n touch(attrib_name)\n @attribute_values_flat[attrib_name.to_sym] = attrib_value\n end",
"def attr(name, value)\n self[name] = value\n return self\n end",
"def update_tag_attribute(content, tag_name, attr_name, init_val); end",
"def set_attraction\n @attraction = Attraction.find(params[:id])\n end",
"def attribute=(_arg0); end",
"def attribute=(_arg0); end",
"def set attrib, value\n if attrib.is_a? String and attrib.include? \".\"\n syms = attrib.split(\".\")\n first = syms[0]\n rest = syms[1..-1].join(\".\")\n self.send(first).set(rest, value)\n else\n self.send(\"#{attrib}=\".to_sym, value)\n end\n end",
"def update(attribute, value)\n instance_variable_set(\"@#{attribute}\", value)\n end"
] |
[
"0.7239456",
"0.68424404",
"0.68416333",
"0.6782506",
"0.6678777",
"0.6677796",
"0.6625543",
"0.66216785",
"0.65993536",
"0.65993536",
"0.65319693",
"0.65319693",
"0.6499317",
"0.6443476",
"0.64036244",
"0.63552034",
"0.6302561",
"0.627635",
"0.62237495",
"0.62061423",
"0.6198648",
"0.6168451",
"0.6168451",
"0.6164891",
"0.61641616",
"0.61626667",
"0.61581665",
"0.6153095",
"0.6151804",
"0.6151804",
"0.6151804",
"0.6145137",
"0.61304665",
"0.6127962",
"0.6125262",
"0.6125262",
"0.6112083",
"0.6082847",
"0.60693926",
"0.6067833",
"0.604927",
"0.6030411",
"0.60225827",
"0.6015305",
"0.60006076",
"0.59402454",
"0.5934378",
"0.5931994",
"0.59298664",
"0.5919977",
"0.591412",
"0.5907035",
"0.5876905",
"0.58744854",
"0.58744854",
"0.5862599",
"0.58562946",
"0.5852408",
"0.5850763",
"0.57995415",
"0.57961017",
"0.5785567",
"0.5785567",
"0.57816124",
"0.5758964",
"0.57339424",
"0.5724111",
"0.5716792",
"0.571534",
"0.56922007",
"0.5690956",
"0.5670254",
"0.5667903",
"0.56666887",
"0.56652385",
"0.5662037",
"0.565457",
"0.56495595",
"0.5643482",
"0.5643225",
"0.5636424",
"0.5634394",
"0.5632785",
"0.56267864",
"0.5626511",
"0.5625995",
"0.5625995",
"0.5625262",
"0.562057",
"0.5609718",
"0.55953646",
"0.5594387",
"0.558901",
"0.5588299",
"0.5571644",
"0.5571644",
"0.5567462",
"0.55659455"
] |
0.6058898
|
42
|
Remove an attribute for the given key.
|
def delete(key)
removeAttribute(key.to_s)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_attribute(key); end",
"def delete_attr!(key)\n copy_on_write if @attrs.shared\n key = key.intern \n old_attrs = @attrs\n @attrs = AttrArray.new\n @attrs_hash = {}\n old_attrs.each do |a|\n put_attr(a) if a.key_symbol != key\n end\n end",
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def remove_attr(name); end",
"def remove_attr(name); end",
"def remove(key)\n Lib.remove @path, @no_follow, key.to_s\n end",
"def remove_property(key)\n end",
"def delete(key)\n attribute = key.to_sym\n details.delete(attribute)\n messages.delete(attribute)\n end",
"def attr_clean!(key)\n @dirty_attribute_keys ||= []\n @dirty_attribute_keys.delete_if {|k| k == key.to_sym }\n end",
"def - (name) remove_attribute name end",
"def remove_attribute(name)\n attr = attributes[name].remove if key? name\n clear_xpath_context if Nokogiri.jruby?\n attr\n end",
"def delete_attribute(attr_name)\n debug(\"Model#delete_attribute(#{attr_name.inspect})\")\n set_attribute(attr_name, nil)\n end",
"def remove_attribute(to_remove)\n index = 0\n if not to_remove.kind_of? Fixnum\n index = find_index_of_attribute(to_remove)\n else\n index = to_remove\n end\n # binding.pry\n\n if not index.nil?\n @attributes.delete_at index\n @data.each do |d|\n d.delete to_remove\n end\n end\n self\n end",
"def remove_attribute(attr)\n C.LLVMRemoveFunctionAttr(self, attr)\n end",
"def kwattr_remove(attribute_name, keywords); end",
"def del_attribute(opts = {})\n data, _status_code, _headers = del_attribute_with_http_info(opts)\n return data\n end",
"def remove(key); end",
"def remove_attr name\n each do |el|\n next unless el.respond_to? :remove_attribute\n el.remove_attribute(name)\n end\n self \n end",
"def delete(attribute)\n `c$Element.prototype.m$remove_property.call(#{@element},attribute)`\n end",
"def remove_attribute(node_id:, name:)\n {\n method: \"DOM.removeAttribute\",\n params: { nodeId: node_id, name: name }.compact\n }\n end",
"def delete(attribute); end",
"def del(key)\n @meta.delete(key.to_sym) if key\n end",
"def remove(key)\n a_hash[key] = nil\n end",
"def remove(key)\n\n end",
"def remove_key(key)\n\t\tdelete(\"/user/keys/#{escape(key)}\")\n\tend",
"def remove_key(key)\n\t\tdelete(\"/user/keys/#{escape(key)}\")\n\tend",
"def remove_attribute(name)\n `#{@element}.removeAttribute(#{name})`\n end",
"def erase(attr)\n erased << attr.to_s\n end",
"def remove_attribute(name)\n `#@native.removeAttribute(name)`\n end",
"def removeAttribute(name)\n ret = getAttributeNode(name)\n removeAttributeNode(ret) if ret\n end",
"def remove_key(key)\n deprecate # 07/31/2012\n delete(\"/user/keys/#{escape(key)}\").to_s\n end",
"def delete_key(key)\n end",
"def remove( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && HTMapHelper.remove_map( self, key )\n end",
"def delete_with_key(key)\n real_key = @original_properties.keys.find { |k| k.to_s == key.to_s }\n @original_properties.delete(real_key)\n end",
"def removeAttribute(name)\n `#{@el}.removeAttribute(#{name})`\n end",
"def delete_custom_attribute(product_id, attribute_name)\n response, status = BeyondApi::Request.delete(@session, \"/products/#{product_id}/attributes/#{attribute_name}\")\n\n handle_response(response, status, respond_with_true: true)\n end",
"def delete_user_custom_attribute(key, user_id)\n delete(\"/users/#{user_id}/custom_attributes/#{key}\")\n end",
"def delete(key)\n @hash.delete(key.to_s)\n end",
"def removed(attribute_name)\n changed(attribute_name)\n end",
"def removed(attribute_name)\n changed(attribute_name)\n end",
"def remove(key)\n\n if include?(key)\n self[key].delete(key)\n @count -= 1\n end\n\n end",
"def delete(key)\n @ivar.each_with_index do |ele, i|\n if ele[0] == key\n @ivar.delete_at(i)\n end\n end\n end",
"def remove_attribute(locator, attribute)\n execute_script(%(\n var element = arguments[0];\n var attributeName = arguments[1];\n if (element.hasAttribute(attributeName)) {\n element.removeAttribute(attributeName);\n }\n ), find_element(locator), attribute)\n end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def unset(key)\n update(key) { |option| @data.delete(option.name) }\n end",
"def delete(key)\n key = alternate_key(key) unless has_key?(key)\n super\n end",
"def delete(attr)\n attr = attr.intern\n if @parameters.has_key?(attr)\n @parameters.delete(attr)\n else\n raise Puppet::DevError.new(\"Undefined attribute '#{attr}' in #{self}\")\n end\n end",
"def delete_attribute(*args)\n end",
"def unset_value(key)\n database.delete(key)\n removed_keys << key\n end",
"def remove(key)\n row = key >> 10\n column = @a[row].index{|(i,v)| i == key}\n if column\n @a[row].delete_at(column)\n end\n end",
"def clear_attribute( attribute )\n send(\"#{attribute}=\", nil)\n end",
"def reset(attribute)\n @attributes.delete attribute.to_sym\n end",
"def attr_dirty!(key)\n @dirty_attribute_keys ||= []\n @dirty_attribute_keys << key.to_sym\n @dirty_attribute_keys.uniq!\n end",
"def delete(key)\n @data.delete(key)\n @key_size.delete(key)\n end",
"def delete_kapp_attribute_definition(kapp_slug, name, headers=default_headers)\n @logger.info(\"Deleting the \\\"#{name}\\\" Kapp attribute definition from the \\\"#{kapp_slug}\\\" kapp.\")\n delete(\"#{@api_url}/kapps/#{kapp_slug}/kappAttributeDefinitions/#{encode(name)}\", headers)\n end",
"def remove(key)\n @store.delete_if { |i| i[:key] == build_key(key) }\n end",
"def delete attrib\n if attrib.is_a? String and attrib.include? \".\"\n syms = attrib.split(\".\")\n first = syms[0]\n rest = syms[1..-1].join(\".\")\n self.send(first).delete(rest)\n else\n self.delete_field(attrib)\n end\n end",
"def delete(key)\n @hash.delete key\n @key_hash.delete key\n end",
"def del_attribute_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi.del_attribute ...\"\n end\n # resource path\n local_var_path = \"/{uuid}/attribute/{key}\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse2004')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#del_attribute\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def remove_property(attribute)\n `var el=this.__native__,attr=attribute.__value__,bool=c$Element.__boolean_attributes__[attr],key=c$Element.__boolean_attributes__[attr]||bool`\n `key ? el[key]=bool?false:'' : el.removeAttribute(attr)`\n return self\n end",
"def delete(key)\n\n end",
"def delete(key)\n @relation.delete(key)\n end",
"def destroy\n self.class.remove(key)\n end",
"def destroy\n self.class.remove(key)\n end",
"def remove_key(key)\n delete(\"/users/ssh_keys/#{escape(key)}\").to_s\n end",
"def del(key)\n @first.del(key)\n end",
"def remove(key)\n File.unlink cache_path(key)\n rescue Errno::ENOENT\n end",
"def remove(key, options = {})\n fetch({:method => :delete, :key => key, :body_to_params => true, :body => options}).parsed_response\n end",
"def delete( key )\n context.delete(key.to_s)\n end",
"def del(key)\n response = db.delete_item(@table_name, {'HashKeyElement' => {'S' => key}})\n true\n end",
"def unset(key)\n run { conf.unset(key, config_params) }\n end",
"def delete(key)\n unimplemented\n end",
"def remove(key)\n with_client do |client|\n client.del(build_key(key))\n end\n end",
"def delete key\n write_data_entry key, nil, true\n @keydict[key] = nil\n\n sync\n end",
"def unset key\n storage.delete key\n end",
"def delete_user_attribute(email_address, attribute)\n found_user = read_user(email_address)\n if found_user\n dn = get_DN(found_user[:cn])\n Net::LDAP.open(@ldap_conf) do |ldap|\n ldap.delete_attribute(dn, ENTITY_ATTR_MAPPING[attribute])\n end\n end\n end",
"def delete(key)\n value = self[key]\n\n @memcached.delete key\n\n value\n end",
"def read_attribute(key)\n if type = namespace.attribute_type(key)\n key = type.names.first\n else\n key = Ldaptic.encode(key)\n end\n @attributes[key] ||= ((@original_attributes || {}).fetch(key, [])).dup\n Ldaptic::AttributeSet.new(self, key, @attributes[key])\n end",
"def kwattr_remove(attribute_name, keywords)\n if keywords.nil?\n remove_attribute(attribute_name)\n return self\n end\n\n keywords = keywordify(keywords)\n current_kws = kwattr_values(attribute_name)\n new_kws = current_kws - keywords\n if new_kws.empty?\n remove_attribute(attribute_name)\n else\n set_attribute(attribute_name, new_kws.join(\" \"))\n end\n self\n end",
"def delete(attribute)\n `c$Element.prototype.m$remove_style.call(#{@element},attribute)`\n end",
"def delete key\n rv = self[key]\n self.removeField key\n return rv\n end",
"def delete key\n @internal_hash[key].clear\n end",
"def remove(key)\n @map.delete(key)\n end",
"def remove(*key)\n @cache.delete(key)\n end",
"def delete_option(key, meta_key = \"_default\")\n values = cama_options(meta_key)\n key = key.to_sym\n values.delete(key) if values.has_key?(key)\n set_meta(meta_key, values)\n end",
"def delete(key)\n super(convert_key(key))\n end",
"def delete(key)\n return self unless @hash.key?(key)\n\n h = Hash[@hash]\n h.delete(key)\n self.class.create(h)\n end",
"def unregister(key)\n @data.update { |h| h.dup.tap { |j| j.delete(key) } }\n self\n end",
"def delete(attribute)\n attribute = (\"@\"+attribute).to_sym if attribute.to_s !~ /^@/\n instance_variable_set(attribute.to_sym, nil)\n end",
"def delete(key)\n @succ.delete key\n end",
"def delete(key)\n super(convert_key(key))\n end"
] |
[
"0.85295427",
"0.8046233",
"0.7494352",
"0.7494352",
"0.7494352",
"0.7494352",
"0.7170832",
"0.7170832",
"0.7168768",
"0.71535647",
"0.71510696",
"0.708984",
"0.70307964",
"0.7027887",
"0.6876078",
"0.685754",
"0.68046373",
"0.6751213",
"0.6698729",
"0.6678779",
"0.667554",
"0.6673347",
"0.66536385",
"0.6639876",
"0.66372836",
"0.660744",
"0.65945923",
"0.65502363",
"0.65502363",
"0.6539565",
"0.646932",
"0.644373",
"0.64318115",
"0.6429775",
"0.64276886",
"0.6424365",
"0.64131063",
"0.6369642",
"0.63555163",
"0.6353127",
"0.6352665",
"0.62795115",
"0.62795115",
"0.6248401",
"0.62308705",
"0.6227252",
"0.6218646",
"0.6218646",
"0.6218646",
"0.6218646",
"0.6218646",
"0.6190472",
"0.6182144",
"0.6178433",
"0.617767",
"0.6172363",
"0.61405104",
"0.61342657",
"0.61286247",
"0.6123182",
"0.61169994",
"0.61092025",
"0.6106665",
"0.61017317",
"0.60899764",
"0.608059",
"0.6066888",
"0.60657406",
"0.60475606",
"0.60428256",
"0.60428256",
"0.6041822",
"0.6034309",
"0.6033359",
"0.60092515",
"0.60024774",
"0.5999377",
"0.59893835",
"0.59839207",
"0.5978541",
"0.5953174",
"0.594602",
"0.59324723",
"0.59312326",
"0.5929392",
"0.5922807",
"0.5917765",
"0.59118766",
"0.59076864",
"0.58735764",
"0.5859652",
"0.58500594",
"0.58474284",
"0.58465093",
"0.58461004",
"0.58230656",
"0.5822933",
"0.58200717"
] |
0.83570427
|
1
|
Retrieve all the attribute names (keys) from the servlet request. like Hashkeys
|
def keys
getAttributeNames.to_a
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def attributes\n @attrs.keys\n end",
"def keys\n attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_keys\n return [] unless self[:attributes]\n self[:attributes].keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def keys\n @attributes.keys\n end",
"def attribute_names\n names = []\n @attributes.each {|values| names << values.keys if values}\n names.flatten.uniq\n end",
"def keys\n Keys[to_attr_list]\n end",
"def keys\n attribute_nodes.map(&:node_name)\n end",
"def attribute_names\n @attribute_names ||= attributes.keys\n end",
"def keys\n @params.keys\n end",
"def attribute_names\n @name_to_definition.keys\n end",
"def attr_keys\n\t\treturn attr_keys_in @current_node\n\tend",
"def attribute_names\n attributes.keys.sort\n end",
"def attribute_names\n attributes.keys.sort\n end",
"def attribute_names\n @attributes.keys.sort\n end",
"def attribute_names\n @attributes.map(&:name)\n end",
"def attribute_names\n @attributes.keys.sort\n end",
"def attributes\n self.attribute_keys.inject({}) do |hash, key|\n hash[key] = self.__send__(key) if self.__send__(key)\n hash\n end\n end",
"def attributes\n ATTRIBUTE_NAMES\n end",
"def attribute_keys\n self.class.attribute_keys\n end",
"def get_array_of_symbolic_keys\n # getting array of keys (in symbol form)\n all_fields = self.attributes.keys.map do |key|\n key.to_sym;\n end\n return all_fields\n end",
"def list_attributes\n if @attributes.empty?\n fetch_configuration()\n end\n return @attributes.keys\n end",
"def attributes\n @data.keys\n end",
"def keys(tf = true)\n attributes(tf).keys\n end",
"def attribute_names\n @attribute_names ||= attribute_definitions.keys.collect {|a|a.to_s}\n end",
"def attribute_names\n self.class.attributes.map { |a| a[:name] }\n end",
"def keys(model)\n model.attributes.keys\n end",
"def attributes\n self._attributes.inject({}) do |hash, attr|\n hash[attr.to_s] = send(attr)\n hash\n end\n end",
"def attribute_names\n @attribute_names ||= attribute_definitions.keys.map(&:to_s)\n end",
"def attr_keys_in(node)\n\t\treturn is_valid(node) ? node.keys : nil\n\tend",
"def attributes\n Hash[instance_variables.map{|attrib| [attrib.to_s[1..attrib.to_s.size], nil]}]\n end",
"def attributes_get\n h = {}\n self.class.attributes.each do |a|\n h[a] = attribute_get(a)\n end\n h\n end",
"def attributes_get\n h = {}\n self.class.attributes.each do |a|\n h[a] = attribute_get(a)\n end\n h\n end",
"def request_keys\n [:created_at, :user_agent, :browser_name, :browser_version, :referrer, :remote_ip]\n end",
"def names\n iterator = @form_fields.keySet.iterator\n set = []\n set << iterator.next.toString.to_sym while iterator.hasNext\n set\n end",
"def attribute_titles\n attribute_names.map {|f| f.to_s.capitalize.sub(/$/, \":\").gsub(/_/, \" \") }\n end",
"def attributes\n @attributes = Hash[attrs.map { |a| [a.to_sym, send(\"#{a}\")] }]\n end",
"def field_names\n attribute_names.map(&:to_sym)\n end",
"def attribute_names(normalize=false)\n ensure_apply_object_class\n names = @attr_methods.keys\n if normalize\n names.collect do |name|\n to_real_attribute_name(name)\n end.uniq\n else\n names\n end\n end",
"def user_keys\n all_keys = params[:user].keys\n all_keys.collect do |key|\n next if key == \"addresses_attributes\"\n key\n end\n end",
"def get_params()\n return self.params.keys\n end",
"def attr\n @attr.map{|k,v| \"#{k}=\\\"#{h v}\\\"\"}.sort.join(' ')\n end",
"def keys\n fields.map { |f| f.name }\n end",
"def recipe_keys\n all_keys = params[:recipe].keys\n all_keys.collect do |key|\n next if key == \"ingredients_attributes\"\n key\n end\n end",
"def attribute_names\n Array.new\n end",
"def field_names\n @field_names ||= attribute_names.map(&:to_sym)\n end",
"def keys\n [ name ]\n end",
"def address_keys\n address_attr = params[:user][\"addresses_attributes\"].values\n address_attr[0].keys\n end",
"def attribute_names\n @attribute_names ||= if !abstract_class?\n attribute_types.keys\n else\n []\n end\n end",
"def key_attrs\n @key_attrs ||= {}\n end",
"def attributes\n Hash.new.tap do |atts|\n _accessors.each do |accessor|\n att = accessor[0..-2].to_sym\n atts[att] = send(att)\n end\n end\n end",
"def request_keys\n [:created_at, :user_agent, :referrer, :remote_ip]\n end",
"def attribute_names\r\n translated_attribute_names.map(&:to_s) + @attributes.keys.sort\r\n end",
"def attributes *attr_names\n @attribute_names ||= Set.new\n\n attr_names.each { |attr_name| @attribute_names << attr_name.intern }\n end",
"def pnames\n @params.keys\n end",
"def params\n @symbolised_params ||= @rack_request.params.inject({}) { |p, (k,v)| p[k.to_sym] = v; p }\n end",
"def attributes\n self.class.attribute_names.map do |name|\n [name.to_s, self.send(name)]\n end.to_h\n end",
"def keys(name)\n key_schema(name).each_with_object({}) do |s, h|\n h[s.key_type.downcase.to_sym] = s.attribute_name\n end\n end",
"def attributes\n ATTRIBUTES.inject({}) do |hash, attribute|\n hash[attribute] = self.send(attribute)\n hash\n end\n end",
"def attributes\n ATTRIBUTES.inject({}) do |hash, attribute|\n hash[attribute] = self.send(attribute)\n hash\n end\n end",
"def attributes\n restricted = defined?(self.class::NON_ATTRIBUTE_PARAMS) ? self.class::NON_ATTRIBUTE_PARAMS : []\n (self.class::PARAM_DEFAULTS.keys - restricted).index_with { |attr| send(attr) }.with_indifferent_access\n end",
"def attributes\n @content.keys\n end",
"def attributes\n {}.tap do |attributes|\n attribute_names.each do |key|\n attributes[key] = send(key)\n end\n end\n end",
"def attributes\n # Note: the values returned here are ignored by\n # ActiveModel::Serializers#serializable_hash; just the keys are\n # used to again call those getter methods... But we do want to\n # check the values so we can leave 'nil' out of the hash.\n attribute_keys.inject(\n ActiveSupport::HashWithIndifferentAccess.new) do |result, key|\n value = send(key)\n result[key] = value unless value == nil\n result\n end\n end",
"def attributes\n attrs = Hash.new\n attribute_list.each do |attribute|\n value = self.send(attribute)\n attrs[attribute] = value unless value.nil?\n end\n attrs\n end",
"def safe_attrs\n controller.request.get? ? {} : call(:attrs)\n end",
"def precomputed_header_keys_for_rack\n @precomputed_header_keys_for_rack ||= begin\n @headers.attributes.keys.each_with_object(Hash.new) do |key,hash|\n name = key.to_s\n name = \"HTTP_#{name.gsub('-','_').upcase}\" unless ( name == \"CONTENT_TYPE\" || name == \"CONTENT_LENGTH\" )\n hash[name] = key\n end\n end\n end",
"def attributes_of(node)\n\t\tmap = Hash.new\n\t\t\n\t\tif !is_valid node then\n\t\t\treturn map\n\t\tend\n\t\t\n\t\tvarKeys = attr_keys_in node\n\t\tif !varKeys.nil? then\n\t\t\tvarKeys.each do |key|\n\t\t\t\tmap[key] = node[key]\n\t\t\tend\n\t\tend\n\t\treturn map\n\tend",
"def attributes\n @attributes ||= attribute_names.inject({}) do |hash, name|\n attribute_values = saml.xpath(\"//saml:Attribute[@Name='#{name}']/saml:AttributeValue/text()\")\n hash[name] = attribute_values.length > 1 ? attribute_values.collect(&:to_s) : attribute_values.to_s\n hash\n end\n end",
"def members\n attributes.keys\n end",
"def attributes\n self\n .class\n .attribute_names\n .map { |attr| [attr, send(attr)] }\n .reject { |_, value| value.nil? }\n .map do |attr, value|\n [attr, value.respond_to?(:attributes) ? value.attributes : value]\n end\n .to_h\n end",
"def keys\n [:name, :username, :email, ]\n end",
"def attributes(*attrs)\n attrs.each { |attr_name| @_attributes[attr_name.to_sym] = attr_name.to_sym }\n end",
"def kwattr_values(attribute_name); end",
"def keys(*args)\n @params.keys(*args)\n end",
"def keys(*args)\n @params.keys(*args)\n end",
"def symbol_attributes\n attributes.map {|k, v| [k.to_sym, v]}.to_h\n end",
"def attributes\n @attr_statements ||= begin\n result = {}\n\n stmt_element = REXML::XPath.first(document, \"/p:Response/a:Assertion/a:AttributeStatement\", { \"p\" => PROTOCOL, \"a\" => ASSERTION })\n stmt_element.elements.each do |attr_element|\n name = attr_element.attributes[\"Name\"]\n value = attr_element.elements.first.text\n\n result[name] = value\n end\n\n result.keys.each do |key|\n result[key.intern] = result[key]\n end\n\n result\n end\n end",
"def permitted_keys\n @permitted_keys ||= properties.map(&:to_sym)\n end",
"def attribute_hash\n instance_vars = self.send(:instance_variables)\n values = {}\n instance_vars.each do |var|\n values[(var.to_s.delete('@')).to_sym] = self.instance_variable_get(var)\n end\n values\n end",
"def attributes\n hash = HashWithIndifferentAccess.new\n\n self.class.attribute_names.each_with_object(hash) do |name, attrs|\n attrs[name] = read_attribute(name)\n end\n end",
"def attributes\n self.class.attribute_names.map do |attr|\n type = self.class.attribute_types[attr.to_s]\n value = public_send(attr)\n [attr, type ? type.serialize(value) : value]\n end.to_h\n end",
"def attributes\n attributes = {}\n self.instance_variables.each do |i| \n meth = i.gsub(\"@\",\"\")\n attributes[meth.to_sym] = self.send meth\n end\n attributes\n end",
"def attribute_names\n self.class.attribute_names\n end",
"def attributes\n attrs = filter_partials(self.class._attributes.dup)\n filter(attrs).each_with_object({}) do |attr, hash|\n hash[camelize_value(attr)] = send(attr)\n end\n end",
"def attribute_names\n relvar_def.attribute_names\n end",
"def attributes(hash)\n hash.keys.inject(\"\") { |attrs, key| attrs + %{#{key}=\"#{hash[key]}\" } }\n end",
"def hash\n @attrs\n end",
"def fields\r\n @hash.keys\r\n end",
"def attributes\n @attr_statements ||= begin\n result = {}\n\n stmt_element = REXML::XPath.first(document, \"/p:Response/a:Assertion/a:AttributeStatement\", { \"p\" => PROTOCOL, \"a\" => ASSERTION })\n return {} if stmt_element.nil?\n\n stmt_element.elements.each do |attr_element|\n name = attr_element.attributes[\"Name\"]\n value = attr_element.elements.first.text\n\n result[name] = value\n end\n\n result.keys.each do |key|\n result[key.intern] = result[key]\n end\n\n result\n end\n end",
"def attributes\n super.map { |k, v| [ k.to_s.camelize(:lower).to_sym, v ] }.to_h\n end",
"def validated_attribute_names(params); end",
"def permitted_keys\n self.class.instance_variable_get(:@permitted_keys) || []\n end",
"def attributes\n ATTRIBUTES.each_with_object({}) do |name, buffer|\n buffer[name] = public_send(name)\n end\n end"
] |
[
"0.7356165",
"0.7324754",
"0.72731984",
"0.72731984",
"0.72731984",
"0.72731984",
"0.7173571",
"0.7165584",
"0.71301204",
"0.71086454",
"0.7095123",
"0.70937",
"0.6940586",
"0.69400525",
"0.6928852",
"0.68425727",
"0.6841071",
"0.6841071",
"0.68225986",
"0.6796084",
"0.6776723",
"0.6761532",
"0.6756268",
"0.67496544",
"0.67297435",
"0.665287",
"0.664684",
"0.6598217",
"0.6586145",
"0.6563992",
"0.6560391",
"0.6538073",
"0.6517048",
"0.6507323",
"0.6493121",
"0.6485142",
"0.6485142",
"0.6484059",
"0.64512247",
"0.6447347",
"0.6395318",
"0.6382674",
"0.63704664",
"0.6338557",
"0.6332377",
"0.6321466",
"0.6312306",
"0.6258866",
"0.6258786",
"0.62399817",
"0.6226185",
"0.6220017",
"0.6215806",
"0.6206381",
"0.6196915",
"0.619034",
"0.6187048",
"0.6186522",
"0.6174452",
"0.61743003",
"0.617171",
"0.61710364",
"0.6162479",
"0.6162479",
"0.61352015",
"0.61268425",
"0.6119812",
"0.611644",
"0.6112849",
"0.610123",
"0.6090809",
"0.6081523",
"0.6074389",
"0.6057749",
"0.6055296",
"0.6028368",
"0.6019434",
"0.60187167",
"0.60176563",
"0.60176563",
"0.6003682",
"0.60036564",
"0.6002181",
"0.5988201",
"0.59780025",
"0.59681934",
"0.5967459",
"0.59583926",
"0.59552723",
"0.5951302",
"0.5943613",
"0.5939245",
"0.59285635",
"0.59196895",
"0.59142077",
"0.5913039",
"0.59110785",
"0.5902975"
] |
0.77442914
|
2
|
Iterate over every attribute name/value pair from the servlet request. like Hasheach
|
def each
getAttributeNames.each { |name| yield(name, getAttribute(name)) }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def each_attribute # :yields: key\n @attrs.each_key { |k| yield(k) }\n end",
"def each_attribute(&block)\n\t\t @@attributes.each &block\n\t\tend",
"def each # :yields: key, value\n @attrs.each { |k, v| yield(k, v) }\n end",
"def each_attribute(&block)\n attributes.each(&block)\n end",
"def attributes\n if iterator?\n @attr.each do |key, value|\n yield(value)\n end if @attr\n else\n @attr\n end\n end",
"def each_attribute(&block)\n attributes.each_attribute(&block)\n end",
"def each\n attribute_nodes.each { |node|\n yield [node.node_name, node.value]\n }\n end",
"def each_attribute_pair(&block)\n @attributes.each_pair do |name, value|\n block.call(name, value)\n end\n end",
"def each(&block)\n\t\t\tvalues = {}\n\t\t\teach_attribute do |attr|\n\t\t\t\tvalue = self.fetch(attr)\n\t\t\t\tif not value.nil?\n\t\t\t\t\tvalues[attr] = value\n\t\t\t\tend\n\t\t\tend\n\t\t values.each &block\n\t\tend",
"def each(&block)\n attributes.each_value(&block)\n end",
"def attributes(*attrs)\n attrs.each { |attr_name| @_attributes[attr_name.to_sym] = attr_name.to_sym }\n end",
"def attributes(*args)\n args.each do |attr|\n attribute(attr)\n end\n end",
"def attributs()\n if block_given?\n rados_getxattrs.each { |key,value| \n yield key,value\n }\n else\n return rados_getxattrs\n end\n \n end",
"def each(&block)\n attributes.each(&block)\n end",
"def each(&block)\n attributes.each(&block)\n end",
"def each_value # :yields: value\n @attrs.each_value { |v| yield(v) }\n end",
"def attributes(*args)\n args.each { |attr| attribute(attr) }\n end",
"def attributes\n attrs = Hash.new\n attribute_list.each do |attribute|\n value = self.send(attribute)\n attrs[attribute] = value unless value.nil?\n end\n attrs\n end",
"def attributes\n @attributes = Hash[attrs.map { |a| [a.to_sym, send(\"#{a}\")] }]\n end",
"def kwattr_values(attribute_name); end",
"def attributes(*attrs)\n if attrs.size > 0\n attrs.each{|attr| attribute attr}\n end\n @attributes ||= []\n end",
"def attributes(*attrs, **args)\n attrs.each { |attr| attribute(attr, **args) }\n end",
"def attributes(*attrs)\n\n self._attributes = _attributes.dup\n\n attrs.each do |attr|\n if Hash === attr\n attr.each {|attr_real, key| attribute attr_real, :key => key }\n else\n attribute attr\n end\n end\n end",
"def attributes\n @ldap_entry.attribute_names.each_with_object({}) do |key, hsh|\n hsh[key] = get_value(key)\n end\n end",
"def parse_attrlist\n tok = readbyte\n list = []\n currentname = nil\n currentvalue = \"\"\n while tok != END_T\n if tok == SWITCH_PAGE\n @attr_codepage = readbyte\n elsif tok == STR_I\n currentvalue += readntstring\n elsif tok == STR_T\n currentvalue += @stringtable[parse_mbint]\n elsif tok == ENTITY\n currentvalue << readmbstr\n elsif tok == OPAQUE\n currentvalue << readstring # TODO: What should we do for opaque in an attribute?\n elsif tok == EXT_0\n currentvalue << \"&wbxml_#{@attr_codepage.to_s 16}_ext0;\"\n elsif tok == EXT_1\n currentvalue << \"&wbxml_#{@attr_codepage.to_s 16}_ext1;\"\n elsif tok == EXT_2\n currentvalue << \"&wbxml_#{@attr_codepage.to_s 16}_ext2;\"\n # TODO: Deal with extension tokens that have a string payload\n elsif tok == LITERAL\n if currentname\n list << [currentname, currentvalue]\n end\n currentname = @stringtable[parse_mbint]\n currentvalue = \"\"\n elsif tok < 128 # ATTRSTART\n if currentname\n list << [currentname, currentvalue]\n end\n currentname, currentvalue = get_attr_start(tok)\n elsif tok > 128 # ATTRVALUE\n currentvalue += get_attr_value(tok)\n end\n tok = readbyte\n end\n if currentname\n list << [currentname, currentvale]\n end\n list\n end",
"def attributes *attr_names\n @attribute_names ||= Set.new\n\n attr_names.each { |attr_name| @attribute_names << attr_name.intern }\n end",
"def attribute_values(attributes)\n attributes.map { |attribute| self.send(attribute) }\n end",
"def each_attribute(&blk)\n to_enum(:_each_attribute).sort_by{|attr| attr.name}.each(&blk)\n end",
"def safe_attrs\n controller.request.get? ? {} : call(:attrs)\n end",
"def attributes=(attrs)\n attrs.each_pair do |attr, value|\n if respond_to?(\"#{attr}=\")\n public_send(\"#{attr}=\", value)\n else\n attributes[attr.to_s] = value\n end\n end\n end",
"def attributes\n @attr_statements ||= begin\n result = {}\n\n stmt_element = REXML::XPath.first(document, \"/p:Response/a:Assertion/a:AttributeStatement\", { \"p\" => PROTOCOL, \"a\" => ASSERTION })\n stmt_element.elements.each do |attr_element|\n name = attr_element.attributes[\"Name\"]\n value = attr_element.elements.first.text\n\n result[name] = value\n end\n\n result.keys.each do |key|\n result[key.intern] = result[key]\n end\n\n result\n end\n end",
"def attributes\n @attrs.keys\n end",
"def attributes\n restricted = defined?(self.class::NON_ATTRIBUTE_PARAMS) ? self.class::NON_ATTRIBUTE_PARAMS : []\n (self.class::PARAM_DEFAULTS.keys - restricted).index_with { |attr| send(attr) }.with_indifferent_access\n end",
"def enumerate_attrs\n @node_attrs.keys.each_with_object({}) { |node, h|\n h[node] = enumerate_attrs_by_node(node)\n }\n end",
"def attributes_get\n h = {}\n self.class.attributes.each do |a|\n h[a] = attribute_get(a)\n end\n h\n end",
"def attributes_get\n h = {}\n self.class.attributes.each do |a|\n h[a] = attribute_get(a)\n end\n h\n end",
"def attribute_and_parameter_values\n attribute_value_pairs = attributes.inject({}) do |h, attr| \n # Attributes may be not synced with db so updating them with attr.update_attribute_value!\n h.merge(attr.display_name => attr.update_attribute_value!)\n end\n params.merge(attribute_value_pairs)\n end",
"def each\n @params.keys.each { |key| yield key, self[key] }\n end",
"def attributes(attrs)\n\t\t\tattrs.each do |k,v|\n\t\t\t\tsetter = \"#{k}=\".to_sym\n\t\t\t\tself.send(setter, v)\n\t\t\tend\n\t\t\t\n\t\t\tyield self if block_given?\n\t\t\t\n\t\t\treturn self\n\t\tend",
"def enumerate_attrs\n @node_attrs.keys.each_with_object({}) do |node, h|\n h[node] = enumerate_attrs_by_node(node)\n end\n end",
"def attributes_for_params\n attributes.collect{ |key, value| \"#{key}:'#{CGI.escape value}'\" }.join(\", \")\n end",
"def helper_attr(*attrs)\n attrs.flatten.each { |attr| helper_method(attr, \"#{attr}=\") }\n end",
"def helper_attr(*attrs)\n attrs.flatten.each { |attr| helper_method(attr, \"#{attr}=\") }\n end",
"def attribute_list(el); end",
"def hit_on_attributes attrhash, site\n return unless results.present? && site\n attrhash.each do |label, value_or_set|\n if value_or_set.is_a? Hash\n (value_or_set = value_or_set.values).map { |value|\n hit_on_attribute label, value, site\n }\n else\n hit_on_attribute label, value_or_set, site\n end\n end\n end",
"def attributes\n @attr_statements ||= begin\n result = {}\n\n stmt_element = REXML::XPath.first(document, \"/p:Response/a:Assertion/a:AttributeStatement\", { \"p\" => PROTOCOL, \"a\" => ASSERTION })\n return {} if stmt_element.nil?\n\n stmt_element.elements.each do |attr_element|\n name = attr_element.attributes[\"Name\"]\n value = attr_element.elements.first.text\n\n result[name] = value\n end\n\n result.keys.each do |key|\n result[key.intern] = result[key]\n end\n\n result\n end\n end",
"def all_attributes\n the_attrs = Hash[accessors.collect {|v| [v, send(v.to_s)] if respond_to? \"#{v}\".to_sym}]\n (respond_to?(:attributes) && attributes.merge(the_attrs)) || the_attrs\n end",
"def attributes\n @attributes ||= attribute_names.inject({}) do |hash, name|\n attribute_values = saml.xpath(\"//saml:Attribute[@Name='#{name}']/saml:AttributeValue/text()\")\n hash[name] = attribute_values.length > 1 ? attribute_values.collect(&:to_s) : attribute_values.to_s\n hash\n end\n end",
"def attributes\n # ...\n # debugger\n # f = method_missing(name)\n @attributes ||= {}\n # attributes = Hash.new {|h,k| h[k] = []}\n # @attributes = @colm.map {|colm| attributes[colm]}\n # unless instance_variables(false).include?(f)\n # # print f\n # end\n\n # @attribute ={}\n end",
"def attributes\n hash = HashWithIndifferentAccess.new\n\n self.class.attribute_names.each_with_object(hash) do |name, attrs|\n attrs[name] = read_attribute(name)\n end\n end",
"def sf_attributes(*attrs)\n attrs.each do |attr|\n sf_attribute attr\n end\n end",
"def attributes\n self._attributes.inject({}) do |hash, attr|\n hash[attr.to_s] = send(attr)\n hash\n end\n end",
"def link_attributes(tag)\n Hash[$1.scan(/(\\w+)=\"([^\"]*)\"/)] if tag =~ link_regex\n end",
"def helper_attr(*attrs)\n attrs.flatten.each { |attr| helper_method(attr, \"#{attr}=\") }\n end",
"def attributes\n ATTRIBUTES.each_with_object({}) do |name, buffer|\n buffer[name] = public_send(name)\n end\n end",
"def attribute_values\n self.class.attributes.map{ |attr| self.send(attr) }\n end",
"def attr\n @attr.map{|k,v| \"#{k}=\\\"#{h v}\\\"\"}.sort.join(' ')\n end",
"def attributes=(params)\n params.each_pair do |k, v|\n setter = \"#{k}=\".to_sym\n public_send(setter, v)\n end\n end",
"def each_attr_in(items)\n items.each do |item|\n if item.is_a?(Hash)\n each_attr_in(item[:items]) if item[:items].is_a?(Array)\n yield(item) if item[:name]\n end\n end\n end",
"def each_property\n IO.readlines(path).each do |l|\n begin\n stripped = l.strip.encode(\"UTF-8\")\n if stripped.match(/^\\-\\-\\s+sem\\.attribute\\./)\n stripped.sub!(/^\\-\\-\\s+sem\\.attribute\\./, '')\n name, value = stripped.split(/\\=/, 2).map(&:strip)\n yield name, value\n end\n rescue Encoding::InvalidByteSequenceError\n # Ignore - attributes must be in ascii\n end\n end\n rescue Encoding::InvalidByteSequenceError\n # Ignore - file must be in ascii in order to parse attributes\n end",
"def attributes\n Hash[instance_variables.map{|attrib| [attrib.to_s[1..attrib.to_s.size], nil]}]\n end",
"def list_attributes\n if @attributes.empty?\n fetch_configuration()\n end\n return @attributes.keys\n end",
"def attributes\n self.attribute_keys.inject({}) do |hash, key|\n hash[key] = self.__send__(key) if self.__send__(key)\n hash\n end\n end",
"def data_attributes(*attrs)\n attrs.map(&:to_s).each do |attr|\n define_method attr do\n @data ||= {}\n @data[attr.to_sym]\n end\n\n define_method \"#{attr}=\" do |arg|\n @data ||= {}\n @data[attr.to_sym] = arg\n end\n end\n end",
"def values\n @attrs.values\n end",
"def parse_attributes!\n self.attributes = (attributes || []).map do |key_value|\n name, type, index, default = key_value.split(/:/)\n opts = {}\n if default\n opts[:default] = default\n end\n if index\n index_type, constraint = index.split(/,/)\n if constraint == 'not_null'\n opts[:null] = false\n end\n end\n create_attribute(name, type, index_type, opts)\n end\n end",
"def attributes(*attrs)\n @attributes = attrs\n attr_reader(*attrs)\n end",
"def process_attributes(params, attributes)\n # Get the id of the section corresponding to :section_name\n unless params[:section_name].blank?\n section = Section.find_by_name(params[:section_name])\n unless section.blank?\n attributes[:section_id] = section.id\n end\n end\n\n parameters = [:last_name, :first_name, :type, :grace_credits, :email, :id_number, :hidden]\n parameters.each do |key|\n unless params[key].blank?\n attributes[key] = params[key]\n end\n end\n\n attributes\n end",
"def attributes(requested_attrs = nil, reload = false)\n @attributes = nil if reload\n @attributes ||= self.class._attributes_data.each_with_object({}) do |(key, attr), hash|\n next if attr.excluded?(self)\n next unless requested_attrs.nil? || requested_attrs.include?(key)\n hash[key] = attr.value(self)\n end\n end",
"def attrs(*names)\n names.each { |name| attr(name) }\n end",
"def attributes\n @params\n end",
"def attribs\n\t\t@attributes\n\tend",
"def attributes\n _fast_attributes\n\n rescue NameError\n\n method = \"def _fast_attributes\\n\"\n method << \" @_attributes ||=\\n\"\n method << \" begin\\n\"\n method << \" h = {}\\n\"\n\n self.class.attributes.each do |name|\n method << \" h[:\\\"#{name}\\\"] = send(:\\\"#{name}\\\") if include_#{name}?\\n\"\n end\n\n method << \" h\\n\"\n method << \" end\\n\"\n method << \"end\"\n\n self.class.class_eval method\n\n _fast_attributes\n end",
"def define_attributes\n @info.attributes.each do |attr|\n rname = underscore(attr.name)\n self.class.__send__(:define_method, rname) { self[attr.name] } if attr.readable?\n self.class.__send__(:define_method, rname + \"=\") {|v| self[attr.name] = v } if attr.writable?\n end\n end",
"def attributes\n instance_variables.each do |var|\n child = instance_variable_get var\n name = var.to_s[1..-1]\n yield child, name\n end\n end",
"def attributes(requested_attrs = nil, reload = false)\n @attributes = nil if reload\n @attributes ||= self.class._attributes_data.each_with_object({}) do |(key, attr), hash|\n next if attr.excluded?(self)\n next unless requested_attrs.nil? || requested_attrs.include?(key)\n hash[key] = attr.value(self)\n end\n end",
"def attributes\n attributes = {}\n self.instance_variables.each do |i| \n meth = i.gsub(\"@\",\"\")\n attributes[meth.to_sym] = self.send meth\n end\n attributes\n end",
"def attributes(attributes)\n @attributes = attributes.to_a.map do |k, v|\n { :name => k,\n :type => v,\n :length => Tem::Abi.send(:\"#{v}_length\") \n }\n end\n end",
"def update_attributes(atts)\n atts.each { |att, val| send(:\"#{att}=\", val) }\n end",
"def _search_attributes\n _attrs.hmap do |name, settings|\n opts = settings[:options]\n next unless opts[:net_miner_search_path]\n [name, opts[:net_miner_search_path]]\n end\n end",
"def parse_attributes! #:nodoc:\n self.attributes = (attributes || []).map do |key_value|\n name, type = key_value.split(':')\n Rails::Generators::GeneratedAttribute.new(name, type)\n end\n end",
"def parse_attributes(attribute_string)\n keywords = %w{with using and given}\n parsed_attributes = {}\n found_attributes = []\n while attribute_string.slice(/(#{keywords.join('|')})\\s+\\w*\\s+\\w*/)\n found_attributes << attribute_string.slice!(/(#{keywords.join('|')})\\s+\\w*\\s+\\w*/)\n end\n found_attributes.each {|fa| parsed_attributes[fa.slice(/\\s\\w*/).strip.to_sym] = fa.slice(/\\w*\\z/)}\n return parsed_attributes\nend",
"def get_attributes\n\t\t\t@@attributes\n\t\tend",
"def attributes\n Hash.new.tap do |atts|\n _attributes.instance_variables.each do |ivar|\n # todo: figure out why it's setting @constructor and @toString\n next if ivar == :@constructor || ivar == :@toString || ivar == :@_attributes || ivar == :@_data || ivar == :@_forms\n\n att = ivar[1..-1].to_sym\n atts[att] = _attributes.send(att)\n\n if form_name = _form[att.to_s.to_sym]\n atts[att] = wedge(form_name, atts[att].respond_to?(:attributes)? atts[att].attributes : atts[att]).attributes\n end\n end\n end\n end",
"def attributes\n ATTRIBUTES.inject({}) do |hash, attribute|\n hash[attribute] = self.send(attribute)\n hash\n end\n end",
"def attributes\n ATTRIBUTES.inject({}) do |hash, attribute|\n hash[attribute] = self.send(attribute)\n hash\n end\n end",
"def process_attributes(rest_of_line)\n @tag_attributes = []\n while rest_of_line != \"\" do\n # If '=' doesn't exist, empty attribute string and break from loop\n if rest_of_line.index('=') == nil\n break\n elsif rest_of_line.index('=') != nil and rest_of_line.index('<') != nil and rest_of_line.index('<') < rest_of_line.index('=')\n break\n end\n \n first_equals_index = rest_of_line.index '='\n embedded_attribute = false\n \n if rest_of_line[first_equals_index+1..first_equals_index+2] == '{{'\n embedded_attribute = true\n close_index = rest_of_line.index '}}'\n if close_index == nil\n raise CompilerException, \"Unmatched '{{' found in line #{@line_number}\"\n end\n elsif rest_of_line[first_equals_index+1..first_equals_index+2] == '<%'\n embedded_attribute = true\n close_index = rest_of_line.index '%>'\n if close_index == nil\n raise CompilerException, \"Unmatched '<%' found in line #{@line_number}\"\n end\n end\n \n if embedded_attribute\n current_attribute = rest_of_line[0..close_index+1]\n if rest_of_line.length == close_index + 2\n rest_of_line = \"\"\n else\n rest_of_line = rest_of_line[close_index+2..-1]\n end\n \n elsif rest_of_line.length == first_equals_index\n current_attribute = rest_of_line.strip\n rest_of_line = \"\"\n \n elsif rest_of_line[first_equals_index + 1..-1].index('=') == nil\n open_inner_text_index = rest_of_line.index('<')\n if open_inner_text_index != nil\n current_attribute = rest_of_line[0..open_inner_text_index-1].strip\n rest_of_line = rest_of_line[open_inner_text_index..-1]\n else\n current_attribute = rest_of_line * 1\n rest_of_line = \"\"\n end\n \n else\n second_equals_index = rest_of_line[first_equals_index + 1..-1].index '='\n reversed_letters_between_equals = rest_of_line[first_equals_index+1..first_equals_index + 1 + second_equals_index - 1].split(\"\").reverse\n \n whitespace_index = nil\n i = 0\n for char in reversed_letters_between_equals do\n if \" \\t\".index(char) != nil\n whitespace_index = first_equals_index + 1 + second_equals_index - i\n break\n end\n i += 1\n end\n \n if whitespace_index == nil\n # TODO: Do some error reporting here\n break\n end\n \n current_attribute = rest_of_line[0..whitespace_index-1].strip\n rest_of_line = rest_of_line[whitespace_index..-1]\n end\n \n if current_attribute != nil\n equals_index = current_attribute.index '='\n @tag_attributes << ' ' + current_attribute[0..equals_index-1] + '=\"' + current_attribute[equals_index+1..-1] + '\"'\n end\n end\n \n rest_of_line.strip\n end",
"def attributes\n scraper.attributes.keys + uri_response_attributes + [:feed]\n end",
"def create_attr_hash\n data = {}\n self.instance_variables.each do |attr|\n value = self.instance_variable_get(attr)\n key = attr.to_s.sub(%r{^\\@}, '').sub(%r{\\@}, '')\n if @attr_list.include?(key)\n data[key] = value\n end\n end\n\n data\n end",
"def attributes\n {}.tap do |attributes|\n attribute_names.each do |key|\n attributes[key] = send(key)\n end\n end\n end",
"def collectible_attribute_list_params\n params.fetch(:collectible_attribute_list, {})\n end",
"def method_missing(method_name, *args)\n method_match, attribute_name, equal_sign = method_name.to_s.match(/\\A([^=]+)(=)?\\Z/).to_a\n if attribute_name && self.class.valid_attributes.include?(attribute_name.to_sym)\n if equal_sign \n attributes[attribute_name.to_sym] = args.first\n else\n attributes[attribute_name.to_sym]\n end\n else\n super\n end\n end",
"def values(xml)\n self.class::ATTRS.each do |attribute|\n value = instance_variable_get(\"@#{attribute}\") || ''\n xml[:v20].public_send(attribute, value)\n end\n end",
"def scan_attrs(node, attr_rules)\n attrs = [ ]\n\n attr_rules.each do |rule|\n attr = {\n :want => nil\n }\n\n rule.each_pair do |key,val|\n # \"want\" is a reserved word used to specify desired values.\n if (key.downcase == 'want')\n attr[:want] = val\n else\n attr[:title] = key\n attr[:value] = SiteScan::HTML.get_value(node, val)\n end\n end\n\n attrs.push(attr)\n end\n\n return attrs\n end",
"def attributes\n load_attributes! unless attributes_loaded?\n @attributes.values\n end",
"def attributes\n ATTRIBUTE_NAMES\n end",
"def attributes\n @attributes ||= get_field_by_type(ATTRIBUTE_FIELDS)\n end",
"def accept_attributes attribs={}\n attribs.slice(*self.class.tracked_attributes).each do |attrib, value|\n setter = :\"accept_#{attrib}\"\n respond_to?(setter) ? self.send(setter, value) : accept_attribute(attrib, value)\n end\n end"
] |
[
"0.6871169",
"0.6616208",
"0.6598819",
"0.6588127",
"0.64660853",
"0.6449042",
"0.6395681",
"0.6395101",
"0.6347066",
"0.6317744",
"0.6188348",
"0.6186114",
"0.61479557",
"0.6146135",
"0.6146135",
"0.61373293",
"0.61347294",
"0.61000615",
"0.6099919",
"0.6072865",
"0.6058385",
"0.6047685",
"0.596142",
"0.59598356",
"0.59102154",
"0.59098077",
"0.59018475",
"0.5897117",
"0.5872499",
"0.5862257",
"0.5856734",
"0.58527625",
"0.58517003",
"0.5845113",
"0.5829944",
"0.5829944",
"0.5829829",
"0.57962215",
"0.5783819",
"0.5774149",
"0.5761266",
"0.5756231",
"0.5756231",
"0.57543665",
"0.57461303",
"0.57357985",
"0.5731298",
"0.5718317",
"0.5714916",
"0.5708132",
"0.57062334",
"0.570156",
"0.56921065",
"0.5683472",
"0.5679347",
"0.5672766",
"0.5671502",
"0.5661861",
"0.5659404",
"0.5653037",
"0.56455415",
"0.56447005",
"0.56390315",
"0.5637521",
"0.56209165",
"0.5615122",
"0.56117034",
"0.56056017",
"0.5601187",
"0.55929536",
"0.55870163",
"0.55808425",
"0.5579283",
"0.5575184",
"0.5567547",
"0.5567059",
"0.5565632",
"0.55420184",
"0.55281407",
"0.5526768",
"0.5523839",
"0.55208856",
"0.5507412",
"0.55045855",
"0.5502896",
"0.5502896",
"0.55027765",
"0.549967",
"0.5491559",
"0.54856557",
"0.54838014",
"0.5479213",
"0.54745585",
"0.54712045",
"0.54612345",
"0.54575866",
"0.54540664",
"0.54491675"
] |
0.69973594
|
0
|
Set an attribute in the session.
|
def []=(key, val)
setAttribute(key.to_s, val)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set attribute, value\n attributes[attribute] = value\n end",
"def set_attribute(name, value); end",
"def set(attribute, value)\n @attributes[attribute.to_s] = value\n nil\n end",
"def set_attribute(key_, value_)\n attribute(key_, value_, :set)\n end",
"def set_attribute(name, value)\n @attributes[name] = value\n end",
"def session_set(name,value)\n session[name] = value\n end",
"def add_session_attribute(key, value)\n @session_attributes[key.to_sym] = value\n end",
"def set_attribute(id, attr)\n\t\t\t@current_context.set_attribute(id, attr)\n\t\tend",
"def []=(key, value)\r\n session[key] = value\r\n end",
"def []= attribute, value\n `#@native.setAttribute(#{attribute}, #{value})`\n end",
"def attribute=(attribute_name, value)\n write_attribute(attribute_name, value)\n end",
"def attribute=(attribute_name, value)\n write_attribute(attribute_name, value)\n end",
"def assign(attribute, value)\n @attributes[attribute.to_sym] = value\n end",
"def set_attribute\n @attribute = Attribute.find(params[:id])\n end",
"def set_attribute\n @attribute = Attribute.find(params[:id])\n end",
"def []= (attr_name, value) \n write_attribute(attr_name, value)\n end",
"def []=(attr_name, value)\n @attributes.write_from_user(attr_name.to_s, value)\n end",
"def setAttrib(name,value)\n\t\t@attributes[name] = value\n\tend",
"def set_attribute(attribute, value)\n if MojeID.is_attribute_available?(attribute)\n fetch_request.set_values(attribute, value)\n bundle_to_request\n end\n end",
"def set_attribute(attribute,value,index=0)\n index = normalize_index(index)\n# puts \"<br>SETTING ATTRIBUTE #{attribute}[#{index}]=#{value} [caller: #{trace}]\"\n @attributes[index] ||= {}\n @attributes[index][normalize_attribute(attribute)] = value\n end",
"def set_attribute(id, attribute, value)\n\t\to = getObject(id)\n\t\tif (o != nil && o.respond_to?(:[]))\n\t\t\to[attribute] = value\n\t\telse\n\t\t\tputs \"Could not find object with id = #{id}\"\n\t\tend\n\tend",
"def set_attribute(attribute_key, attribute_value)\n @attr_mutex.synchronize { @user_attributes[attribute_key] = attribute_value }\n end",
"def set_attribute(attribute_key, attribute_value)\n @attr_mutex.synchronize { @user_attributes[attribute_key] = attribute_value }\n end",
"def []=(attribute, value)\n self.send(\"#{attribute}=\", value)\n end",
"def []=(attr_name, value)\n write_attribute(attr_name, value)\n end",
"def []=(attr_name, value)\n write_attribute(attr_name, value)\n end",
"def []=(attr_name, value)\n write_attribute(attr_name, value)\n end",
"def []=(attr_name, value)\n write_attribute(attr_name, value)\n end",
"def []=(attr_name, value)\n write_attribute(attr_name, value)\n end",
"def []=(attr_name, value)\n @attributes[attr_name.to_s] = value\n end",
"def []=(key,value)\n @attributes[key] = value\n end",
"def []=(attr, value)\n @attrs[attr] = value\n end",
"def set_attr(name, value)\n each_value {|x| x[name] = value }\n end",
"def []=(attr_name, value)\n writer_method = \"#{attr_name}=\"\n send(writer_method, value) if respond_to?(writer_method)\n end",
"def set_attr(attr, value)\n ret = LibSeccomp.seccomp_attr_set(context, attr, value)\n raise SystemCallError.new(\"seccomp_attr_set(context, #{attr.inspect}, #{value}) failed\", -ret) if ret < 0\n end",
"def set(session_variable, value)\n current_session[session_variable] = value\n end",
"def setAttribute(attributeName)\n @attributeName = attributeName\n end",
"def []=(attr, value)\n if Roomorama::Property::ATTRIBUTES.include?(attr)\n setter = [attr, \"=\"].join\n public_send(setter, value)\n end\n end",
"def session_token_set_attribute!(token, track = false)\n @session_token = token.to_s\n end",
"def set_attribute(a,b)\n write_attribute(a,b)\n end",
"def []=(key, value)\n attributes[key] = value\n end",
"def []=(attr, value)\n self.send(\"#{attr}=\", value)\n end",
"def []=(attr, value)\n self.send(\"#{attr}=\", value)\n end",
"def attribute_set(name, value)\n @dirty[name] = true\n @attributes[:current][name] = value\n end",
"def save_to(session)\n attributes.each do |key, value|\n session[key] = value\n end\n self\n end",
"def set_attr\n @attr = Attr.find(params[:id])\n end",
"def set_attr\n @attr = Attr.find(params[:id])\n end",
"def set_attribute(dict_name, key, value)\n end",
"def []=(attribute,value)\n `c$Element.prototype.m$set_property.call(#{@element},attribute,value)`\n end",
"def set_attribute(dict_name, key, value)\n end",
"def set_attribute(dict_name, key, value)\n end",
"def set_property(attribute, value)\n `var el=this.__native__,attr=attribute.__value__,bool=c$Element.__boolean_attributes__[attr],key=c$Element.__boolean_attributes__[attr]||bool`\n `key ? el[key]=bool?$T(value):value : el.setAttribute(attr,''+value)`\n return self\n end",
"def []=(attribute, value)\n attributes[attribute] = to_field(value)\n end",
"def attribute=(name, val)\n write_attribute(name, val)\n end",
"def attribute=(name, value)\n @attributes ||= {}\n @attributes[name] = value\n end",
"def update_session(data)\n update_attribute('data', data) \n end",
"def value=(val)\n session.set(@name, val)\n end",
"def write_attribute(key, value)\n @attributes[key] = value\n end",
"def []=(key, value)\n attributes[key] = value\n end",
"def []=(key, value)\n attributes[key] = value\n end",
"def instance_set(attribute, value)\n setter = :\"#{self.name}_#{attribute}=\"\n self.instance.send(setter, value) if instance.respond_to?(setter)\n end",
"def write_attribute(attribute, value)\n @object.send(:write_attribute, attribute, value)\n end",
"def []=(attr_name, value)\n if self.attribute_names.include?(attr_name.to_s)\n write_attribute(attr_name, value)\n else\n set_custom_attribute(attr_name, value)\n end\n end",
"def []=(name, value)\n @attributes[name] = value\n end",
"def set_shmrequestattribute\n @shmrequestattribute = Shmrequestattribute.find(params[:id])\n end",
"def update(attribute, value)\n instance_variable_set(\"@#{attribute}\", value)\n end",
"def set_attribute(rule, attribute, value)\n begin\n rule.send(\"#{attribute}=\".to_sym, value)\n rescue NoMethodError\n raise AtomMarshallingError.new(\"Attribute #{attribute} unsupported in Atom #{rule_type_name(rule)}.\")\n end\n end",
"def set_attribute_for element, attr, value\n AXUIElementSetAttributeValue(element, attr, value)\n end",
"def []=(attr, value)\n raise \"argument to [] must be a Symbol or a String.\" unless attr.is_a?(Symbol) or attr.is_a?(String)\n @attributes = { } if !instance_variable_defined?(:@attributes) or @attributes.nil?\n @attributes[attr] = value.to_s\n end",
"def set_session(env, sid, session, options)\n raise '#set_session not implemented.'\n end",
"def set_user_attribute\n @user_attribute = UserAttribute.find(params[:id])\n end",
"def []=(key, value)\n self.attributes[key.to_sym] = value\n save\n value\n end",
"def write_set_attribute(attribute_name, value)\n column_type = ((column_definition = self.class.columns_hash[attribute_name.to_s]) and column_definition.type)\n value = value.to_s(10) if column_type == :string\n write_attribute(attribute_name, value)\n end",
"def []=(name, value)\n @attr[name] = value\n end",
"def assign_attribute(name, value)\n self.send(\"#{name}=\", value) if has_attribute?(name)\n end",
"def []=(key, value)\n sess_hash[key.to_sym] = value\n end",
"def attribute_set(name, value)\n properties[name].set(self, value)\n end",
"def set_session_key(key) \n if self.new_record?\n @session_key=key\n else\n ActiveRecord::Base.session_keys[session_key_id]=key\n end\n decrypt_attributes if self.class.include? Encrypted #if respond_to?(:decrypt_attributes)\n \n end",
"def []= field, value\n @attributes[field] = value\n end",
"def set_single_attribute(attribute_name, attribute_value, opts = {})\n Operation::Service.set_attribute(\n :attribute_name => attribute_name,\n :attribute_value => attribute_value,\n :encrypt => opts[:encrypt],\n :service_instance => self.service_instance,\n :service_instance_dir => self.service_instance_dir\n )\n end",
"def op_set(attrname = nil)\n attrname ||= pop\n attrvalue = pop\n receiver = peek\n if receiver.respond_to?(:[]=)\n receiver[attrname] = attrvalue\n elsif receiver.respond_to?(:\"#{attrname}=\")\n receiver.send(:\"#{attrname}=\", attrvalue)\n else\n raise Error, \"Unable to set #{attrname} on #{receiver.inspect}\"\n end\n end",
"def set_session_key(key) \n @session_key=key\n self.decrypt_attributes if self.class.include? Encrypted\n end",
"def set_attribute(locator, attribute, value)\n execute_script(%(\n var element = arguments[0];\n var attribute = arguments[1];\n var value = arguments[2];\n element.setAttribute(attribute, value);\n ), find_element(locator), attribute, value)\n end",
"def set_attribute(ents, handle, name, value)\n ents.each { |e|\n e.set_attribute(handle, name, value)\n }\n end",
"def update_attribute!(attribute, value)\n send(\"#{attribute}=\", value)\n self.save!\n end",
"def []= (attr, val)\n sanity_check\n @handle[attr] = val\n end",
"def setattribute_raw(path, name, value)\n Puppet.debug \"#{name.inspect} setting to #{value.inspect} for path: #{path}\"\n cmd = if value.nil?\n \"#{path}:undefine-attribute(name=\\\"#{name}\\\")\"\n else\n \"#{path}:write-attribute(name=\\\"#{name}\\\", value=#{value})\"\n end\n cmd = \"/profile=#{@resource[:profile]}#{cmd}\" if runasdomain?\n state = execute cmd\n Puppet.debug(\"Setting attribute response: #{state.output}\")\n raise \"Cannot set #{name} for #{path}: #{state.output}\" unless state.success?\n @property_hash[name] = value\n end",
"def []=(key, value)\n fail_if_value_exculudes_attribute\n @attributes[key] = value\n end",
"def set_active_data(key, value)\n @active_data ||= {}\n @active_data[key] = value\n session[key] = value\n end",
"def set_attr(key, value)\n value = format_value(value)\n key = format_key(key)\n send(\"#{key}=\", value)\n rescue\n unless defined?(Rails).nil?\n $lxca_log.info(\n 'XClarityClient::Endpoints::BuildableResourceMixin',\n \"UNEXISTING ATTRIBUTES FOR #{self.class}: #{key}\"\n )\n end\n end",
"def []=(name, value, options = {})\n attributes.set(name, value, options)\n end",
"def update\n java_session = @java_request.getSession(true)\n hash = @session_data.dup\n hash.delete_if do |k,v|\n if String === k\n case v\n when String, Numeric, true, false, nil\n java_session.setAttribute k, v\n true\n else\n if v.respond_to?(:java_object)\n java_session.setAttribute k, v\n true\n else\n false\n end\n end\n end\n end\n unless hash.empty?\n marshalled_string = Marshal.dump(hash)\n marshalled_bytes = marshalled_string.to_java_bytes\n java_session.setAttribute(RAILS_SESSION_KEY, marshalled_bytes)\n end\n end",
"def set_attribute(opts = {})\n data, _status_code, _headers = set_attribute_with_http_info(opts)\n return data\n end",
"def []=(attr_name, attr_value)\n value[attr_name.to_s] = attr_value\n end",
"def []=(attr_name, attr_value)\n value[attr_name.to_s] = attr_value\n end",
"def update_attribute(attribute, value)\n send(\"#{attribute}=\", value)\n self.save\n end",
"def set_session(env, sid)\n raise '#set_session needs to be implemented.'\n end",
"def []=(attribute, value)\n raise ArgumentError unless self.class.keys.include? attribute\n # coerce value according to its attribute's type before being set.\n self.instance_variable_set(\"@#{attribute}\", coerce(value, attribute))\n end"
] |
[
"0.7424007",
"0.7346795",
"0.72452635",
"0.7098992",
"0.70484173",
"0.6964161",
"0.69447935",
"0.6932773",
"0.6844347",
"0.6842768",
"0.6799717",
"0.6799717",
"0.6761823",
"0.67564094",
"0.67564094",
"0.67532665",
"0.6718862",
"0.6680971",
"0.66648626",
"0.66628784",
"0.66533536",
"0.66481274",
"0.66481274",
"0.6637787",
"0.6626428",
"0.6624562",
"0.6624562",
"0.6624562",
"0.65854096",
"0.65524566",
"0.65457577",
"0.65150654",
"0.6508358",
"0.6486571",
"0.64851546",
"0.6475602",
"0.6448216",
"0.6425907",
"0.6410983",
"0.64071167",
"0.6400554",
"0.63994014",
"0.63994014",
"0.6395566",
"0.6379308",
"0.6379188",
"0.6379188",
"0.6375336",
"0.6373724",
"0.6355435",
"0.6355435",
"0.6330396",
"0.6325547",
"0.632268",
"0.6317055",
"0.6294096",
"0.62895876",
"0.62882245",
"0.6275067",
"0.6275067",
"0.6253726",
"0.6253044",
"0.6231033",
"0.6230548",
"0.62112767",
"0.6209879",
"0.62060815",
"0.6204506",
"0.6203808",
"0.61912745",
"0.61887395",
"0.6188334",
"0.6185347",
"0.61738837",
"0.6167786",
"0.6136284",
"0.6132421",
"0.6127926",
"0.61151886",
"0.6111076",
"0.61058784",
"0.61028224",
"0.6094524",
"0.60837054",
"0.60785097",
"0.60781723",
"0.60667074",
"0.6051682",
"0.6046736",
"0.60309315",
"0.6029586",
"0.5998378",
"0.5996998",
"0.5996266",
"0.5996266",
"0.59958065",
"0.5993611",
"0.59933203"
] |
0.63322526
|
52
|
Remove an attribute for the given key.
|
def delete(key)
removeAttribute(key.to_s)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_attribute(key); end",
"def delete_attr!(key)\n copy_on_write if @attrs.shared\n key = key.intern \n old_attrs = @attrs\n @attrs = AttrArray.new\n @attrs_hash = {}\n old_attrs.each do |a|\n put_attr(a) if a.key_symbol != key\n end\n end",
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def remove_attr(name); end",
"def remove_attr(name); end",
"def remove(key)\n Lib.remove @path, @no_follow, key.to_s\n end",
"def remove_property(key)\n end",
"def delete(key)\n attribute = key.to_sym\n details.delete(attribute)\n messages.delete(attribute)\n end",
"def attr_clean!(key)\n @dirty_attribute_keys ||= []\n @dirty_attribute_keys.delete_if {|k| k == key.to_sym }\n end",
"def - (name) remove_attribute name end",
"def remove_attribute(name)\n attr = attributes[name].remove if key? name\n clear_xpath_context if Nokogiri.jruby?\n attr\n end",
"def delete_attribute(attr_name)\n debug(\"Model#delete_attribute(#{attr_name.inspect})\")\n set_attribute(attr_name, nil)\n end",
"def remove_attribute(to_remove)\n index = 0\n if not to_remove.kind_of? Fixnum\n index = find_index_of_attribute(to_remove)\n else\n index = to_remove\n end\n # binding.pry\n\n if not index.nil?\n @attributes.delete_at index\n @data.each do |d|\n d.delete to_remove\n end\n end\n self\n end",
"def remove_attribute(attr)\n C.LLVMRemoveFunctionAttr(self, attr)\n end",
"def kwattr_remove(attribute_name, keywords); end",
"def del_attribute(opts = {})\n data, _status_code, _headers = del_attribute_with_http_info(opts)\n return data\n end",
"def remove(key); end",
"def remove_attr name\n each do |el|\n next unless el.respond_to? :remove_attribute\n el.remove_attribute(name)\n end\n self \n end",
"def delete(attribute)\n `c$Element.prototype.m$remove_property.call(#{@element},attribute)`\n end",
"def remove_attribute(node_id:, name:)\n {\n method: \"DOM.removeAttribute\",\n params: { nodeId: node_id, name: name }.compact\n }\n end",
"def delete(attribute); end",
"def del(key)\n @meta.delete(key.to_sym) if key\n end",
"def remove(key)\n a_hash[key] = nil\n end",
"def remove(key)\n\n end",
"def remove_key(key)\n\t\tdelete(\"/user/keys/#{escape(key)}\")\n\tend",
"def remove_key(key)\n\t\tdelete(\"/user/keys/#{escape(key)}\")\n\tend",
"def remove_attribute(name)\n `#{@element}.removeAttribute(#{name})`\n end",
"def erase(attr)\n erased << attr.to_s\n end",
"def remove_attribute(name)\n `#@native.removeAttribute(name)`\n end",
"def removeAttribute(name)\n ret = getAttributeNode(name)\n removeAttributeNode(ret) if ret\n end",
"def remove_key(key)\n deprecate # 07/31/2012\n delete(\"/user/keys/#{escape(key)}\").to_s\n end",
"def delete_key(key)\n end",
"def remove( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && HTMapHelper.remove_map( self, key )\n end",
"def delete_with_key(key)\n real_key = @original_properties.keys.find { |k| k.to_s == key.to_s }\n @original_properties.delete(real_key)\n end",
"def removeAttribute(name)\n `#{@el}.removeAttribute(#{name})`\n end",
"def delete_custom_attribute(product_id, attribute_name)\n response, status = BeyondApi::Request.delete(@session, \"/products/#{product_id}/attributes/#{attribute_name}\")\n\n handle_response(response, status, respond_with_true: true)\n end",
"def delete_user_custom_attribute(key, user_id)\n delete(\"/users/#{user_id}/custom_attributes/#{key}\")\n end",
"def delete(key)\n @hash.delete(key.to_s)\n end",
"def removed(attribute_name)\n changed(attribute_name)\n end",
"def removed(attribute_name)\n changed(attribute_name)\n end",
"def remove(key)\n\n if include?(key)\n self[key].delete(key)\n @count -= 1\n end\n\n end",
"def delete(key)\n @ivar.each_with_index do |ele, i|\n if ele[0] == key\n @ivar.delete_at(i)\n end\n end\n end",
"def remove_attribute(locator, attribute)\n execute_script(%(\n var element = arguments[0];\n var attributeName = arguments[1];\n if (element.hasAttribute(attributeName)) {\n element.removeAttribute(attributeName);\n }\n ), find_element(locator), attribute)\n end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def unset(key)\n update(key) { |option| @data.delete(option.name) }\n end",
"def delete(key)\n key = alternate_key(key) unless has_key?(key)\n super\n end",
"def delete(attr)\n attr = attr.intern\n if @parameters.has_key?(attr)\n @parameters.delete(attr)\n else\n raise Puppet::DevError.new(\"Undefined attribute '#{attr}' in #{self}\")\n end\n end",
"def delete_attribute(*args)\n end",
"def unset_value(key)\n database.delete(key)\n removed_keys << key\n end",
"def remove(key)\n row = key >> 10\n column = @a[row].index{|(i,v)| i == key}\n if column\n @a[row].delete_at(column)\n end\n end",
"def clear_attribute( attribute )\n send(\"#{attribute}=\", nil)\n end",
"def reset(attribute)\n @attributes.delete attribute.to_sym\n end",
"def attr_dirty!(key)\n @dirty_attribute_keys ||= []\n @dirty_attribute_keys << key.to_sym\n @dirty_attribute_keys.uniq!\n end",
"def delete(key)\n @data.delete(key)\n @key_size.delete(key)\n end",
"def delete_kapp_attribute_definition(kapp_slug, name, headers=default_headers)\n @logger.info(\"Deleting the \\\"#{name}\\\" Kapp attribute definition from the \\\"#{kapp_slug}\\\" kapp.\")\n delete(\"#{@api_url}/kapps/#{kapp_slug}/kappAttributeDefinitions/#{encode(name)}\", headers)\n end",
"def remove(key)\n @store.delete_if { |i| i[:key] == build_key(key) }\n end",
"def delete attrib\n if attrib.is_a? String and attrib.include? \".\"\n syms = attrib.split(\".\")\n first = syms[0]\n rest = syms[1..-1].join(\".\")\n self.send(first).delete(rest)\n else\n self.delete_field(attrib)\n end\n end",
"def delete(key)\n @hash.delete key\n @key_hash.delete key\n end",
"def del_attribute_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi.del_attribute ...\"\n end\n # resource path\n local_var_path = \"/{uuid}/attribute/{key}\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse2004')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#del_attribute\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def remove_property(attribute)\n `var el=this.__native__,attr=attribute.__value__,bool=c$Element.__boolean_attributes__[attr],key=c$Element.__boolean_attributes__[attr]||bool`\n `key ? el[key]=bool?false:'' : el.removeAttribute(attr)`\n return self\n end",
"def delete(key)\n\n end",
"def delete(key)\n @relation.delete(key)\n end",
"def destroy\n self.class.remove(key)\n end",
"def destroy\n self.class.remove(key)\n end",
"def remove_key(key)\n delete(\"/users/ssh_keys/#{escape(key)}\").to_s\n end",
"def del(key)\n @first.del(key)\n end",
"def remove(key)\n File.unlink cache_path(key)\n rescue Errno::ENOENT\n end",
"def remove(key, options = {})\n fetch({:method => :delete, :key => key, :body_to_params => true, :body => options}).parsed_response\n end",
"def delete( key )\n context.delete(key.to_s)\n end",
"def del(key)\n response = db.delete_item(@table_name, {'HashKeyElement' => {'S' => key}})\n true\n end",
"def unset(key)\n run { conf.unset(key, config_params) }\n end",
"def delete(key)\n unimplemented\n end",
"def remove(key)\n with_client do |client|\n client.del(build_key(key))\n end\n end",
"def delete key\n write_data_entry key, nil, true\n @keydict[key] = nil\n\n sync\n end",
"def unset key\n storage.delete key\n end",
"def delete_user_attribute(email_address, attribute)\n found_user = read_user(email_address)\n if found_user\n dn = get_DN(found_user[:cn])\n Net::LDAP.open(@ldap_conf) do |ldap|\n ldap.delete_attribute(dn, ENTITY_ATTR_MAPPING[attribute])\n end\n end\n end",
"def delete(key)\n value = self[key]\n\n @memcached.delete key\n\n value\n end",
"def read_attribute(key)\n if type = namespace.attribute_type(key)\n key = type.names.first\n else\n key = Ldaptic.encode(key)\n end\n @attributes[key] ||= ((@original_attributes || {}).fetch(key, [])).dup\n Ldaptic::AttributeSet.new(self, key, @attributes[key])\n end",
"def kwattr_remove(attribute_name, keywords)\n if keywords.nil?\n remove_attribute(attribute_name)\n return self\n end\n\n keywords = keywordify(keywords)\n current_kws = kwattr_values(attribute_name)\n new_kws = current_kws - keywords\n if new_kws.empty?\n remove_attribute(attribute_name)\n else\n set_attribute(attribute_name, new_kws.join(\" \"))\n end\n self\n end",
"def delete(attribute)\n `c$Element.prototype.m$remove_style.call(#{@element},attribute)`\n end",
"def delete key\n rv = self[key]\n self.removeField key\n return rv\n end",
"def delete key\n @internal_hash[key].clear\n end",
"def remove(key)\n @map.delete(key)\n end",
"def remove(*key)\n @cache.delete(key)\n end",
"def delete_option(key, meta_key = \"_default\")\n values = cama_options(meta_key)\n key = key.to_sym\n values.delete(key) if values.has_key?(key)\n set_meta(meta_key, values)\n end",
"def delete(key)\n super(convert_key(key))\n end",
"def delete(key)\n return self unless @hash.key?(key)\n\n h = Hash[@hash]\n h.delete(key)\n self.class.create(h)\n end",
"def unregister(key)\n @data.update { |h| h.dup.tap { |j| j.delete(key) } }\n self\n end",
"def delete(attribute)\n attribute = (\"@\"+attribute).to_sym if attribute.to_s !~ /^@/\n instance_variable_set(attribute.to_sym, nil)\n end",
"def delete(key)\n @succ.delete key\n end",
"def delete(key)\n super(convert_key(key))\n end"
] |
[
"0.85295427",
"0.8046233",
"0.7494352",
"0.7494352",
"0.7494352",
"0.7494352",
"0.7170832",
"0.7170832",
"0.7168768",
"0.71535647",
"0.71510696",
"0.708984",
"0.70307964",
"0.7027887",
"0.6876078",
"0.685754",
"0.68046373",
"0.6751213",
"0.6698729",
"0.6678779",
"0.667554",
"0.6673347",
"0.66536385",
"0.6639876",
"0.66372836",
"0.660744",
"0.65945923",
"0.65502363",
"0.65502363",
"0.6539565",
"0.646932",
"0.644373",
"0.64318115",
"0.6429775",
"0.64276886",
"0.6424365",
"0.64131063",
"0.6369642",
"0.63555163",
"0.6353127",
"0.6352665",
"0.62795115",
"0.62795115",
"0.6248401",
"0.62308705",
"0.6227252",
"0.6218646",
"0.6218646",
"0.6218646",
"0.6218646",
"0.6218646",
"0.6190472",
"0.6182144",
"0.6178433",
"0.617767",
"0.6172363",
"0.61405104",
"0.61342657",
"0.61286247",
"0.6123182",
"0.61169994",
"0.61092025",
"0.6106665",
"0.61017317",
"0.60899764",
"0.608059",
"0.6066888",
"0.60657406",
"0.60475606",
"0.60428256",
"0.60428256",
"0.6041822",
"0.6034309",
"0.6033359",
"0.60092515",
"0.60024774",
"0.5999377",
"0.59893835",
"0.59839207",
"0.5978541",
"0.5953174",
"0.594602",
"0.59324723",
"0.59312326",
"0.5929392",
"0.5922807",
"0.5917765",
"0.59118766",
"0.59076864",
"0.58735764",
"0.5859652",
"0.58500594",
"0.58474284",
"0.58465093",
"0.58461004",
"0.58230656",
"0.5822933",
"0.58200717"
] |
0.83570427
|
2
|
Retrieve all the attribute names (keys) from the session. like Hashkeys
|
def keys
getAttributeNames.to_a
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def keys\n attributes.keys\n end",
"def keys\n @attributes.keys\n end",
"def attributes\n @attrs.keys\n end",
"def keys\n Keys[to_attr_list]\n end",
"def attribute_keys\n return [] unless self[:attributes]\n self[:attributes].keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_keys\n self.class.attribute_keys\n end",
"def keys\n attribute_nodes.map(&:node_name)\n end",
"def attribute_names\n names = []\n @attributes.each {|values| names << values.keys if values}\n names.flatten.uniq\n end",
"def attr_keys\n\t\treturn attr_keys_in @current_node\n\tend",
"def list_attributes\n if @attributes.empty?\n fetch_configuration()\n end\n return @attributes.keys\n end",
"def attributes\n @data.keys\n end",
"def attribute_names\n @attribute_names ||= attributes.keys\n end",
"def keys(model)\n model.attributes.keys\n end",
"def get_array_of_symbolic_keys\n # getting array of keys (in symbol form)\n all_fields = self.attributes.keys.map do |key|\n key.to_sym;\n end\n return all_fields\n end",
"def keys(tf = true)\n attributes(tf).keys\n end",
"def members\n attributes.keys\n end",
"def attributes\n self.attribute_keys.inject({}) do |hash, key|\n hash[key] = self.__send__(key) if self.__send__(key)\n hash\n end\n end",
"def attribute_names\n attributes.keys.sort\n end",
"def attribute_names\n attributes.keys.sort\n end",
"def attribute_names\n @attributes.keys.sort\n end",
"def attribute_names\n @name_to_definition.keys\n end",
"def keys\n [ name ]\n end",
"def attribute_names\n @attributes.map(&:name)\n end",
"def attribute_names\n @attributes.keys.sort\n end",
"def attribute_names\n self.class.attributes.map { |a| a[:name] }\n end",
"def list_keys\n @keys.keys\n end",
"def attributes\n ATTRIBUTE_NAMES\n end",
"def list_keys\n @keydict.keys\n end",
"def keys\n @params.keys\n end",
"def sessions\n @sessions.each_key.to_a\n end",
"def keys\n\n self.to_h.keys\n end",
"def keys\n DoesKeyValue::State.instance.keys[self.to_s]\n end",
"def attributes\n Hash[instance_variables.map{|attrib| [attrib.to_s[1..attrib.to_s.size], nil]}]\n end",
"def attributes\n self._attributes.inject({}) do |hash, attr|\n hash[attr.to_s] = send(attr)\n hash\n end\n end",
"def list_keys()\n # TODO\n end",
"def attribute_names\n self.class.attribute_names\n end",
"def attribute_names\n Array.new\n end",
"def keys\n list = []\n each_key{|key| list << key}\n list\n end",
"def keys\n values.map(&:to_sym)\n end",
"def attribute_names\n @attribute_names ||= attribute_definitions.keys.collect {|a|a.to_s}\n end",
"def attribute_names\n @attribute_names ||= attribute_definitions.keys.map(&:to_s)\n end",
"def keys\n @key\n end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys\n @hash.keys\n end",
"def keys\n @hash.keys\n end",
"def keys\n @hash.keys\n end",
"def attributes\n self.class.attribute_names.map do |name|\n [name.to_s, self.send(name)]\n end.to_h\n end",
"def attribute_names\n @attribute_names ||= if !abstract_class?\n attribute_types.keys\n else\n []\n end\n end",
"def field_names\n attribute_names.map(&:to_sym)\n end",
"def attributes_get\n h = {}\n self.class.attributes.each do |a|\n h[a] = attribute_get(a)\n end\n h\n end",
"def attributes_get\n h = {}\n self.class.attributes.each do |a|\n h[a] = attribute_get(a)\n end\n h\n end",
"def keys\n @hash.keys\n end",
"def keys\n @hash.keys\n end",
"def keys\n [:name, :username, :email, ]\n end",
"def keys\n @data.keys.sort.collect { |k| k.to_sym }\n end",
"def keys\n deprecate # 07/31/2012\n doc = xml get('/user/keys').to_s\n doc.elements.to_a('//keys/key').map do |key|\n key.elements['contents'].text\n end\n end",
"def keys\n @data.keys\n end",
"def keys\n @data.keys\n end",
"def fields\r\n @hash.keys\r\n end",
"def get_keys()\n\t\t\treturn @config.keys\n\t\tend",
"def keys\n end",
"def keys\n end",
"def keys\n end",
"def keys\n end",
"def keys\n struct.keys\n end",
"def attr_keys_in(node)\n\t\treturn is_valid(node) ? node.keys : nil\n\tend",
"def keys\n return []\n end",
"def attributes\n @attributes ||= attribute_names.inject({}) do |hash, name|\n attribute_values = saml.xpath(\"//saml:Attribute[@Name='#{name}']/saml:AttributeValue/text()\")\n hash[name] = attribute_values.length > 1 ? attribute_values.collect(&:to_s) : attribute_values.to_s\n hash\n end\n end",
"def symbol_attributes\n attributes.map {|k, v| [k.to_sym, v]}.to_h\n end",
"def attributes\n instance_variables.map{ |iv| iv.sub('@','') }\n end",
"def attributes\n attributes = {}\n self.instance_variables.each do |i| \n meth = i.gsub(\"@\",\"\")\n attributes[meth.to_sym] = self.send meth\n end\n attributes\n end",
"def attribute_hash\n instance_vars = self.send(:instance_variables)\n values = {}\n instance_vars.each do |var|\n values[(var.to_s.delete('@')).to_sym] = self.instance_variable_get(var)\n end\n values\n end",
"def keys\n map(&:key)\n end",
"def attributes\n self\n .class\n .attribute_names\n .map { |attr| [attr, send(attr)] }\n .reject { |_, value| value.nil? }\n .map do |attr, value|\n [attr, value.respond_to?(:attributes) ? value.attributes : value]\n end\n .to_h\n end",
"def keys\n end",
"def attributes\n @attributes = Hash[attrs.map { |a| [a.to_sym, send(\"#{a}\")] }]\n end",
"def keys\n fields.map { |f| f.name }\n end",
"def hkeys\r\n self.class.hkeys\r\n end",
"def names\n iterator = @form_fields.keySet.iterator\n set = []\n set << iterator.next.toString.to_sym while iterator.hasNext\n set\n end",
"def attributes\n {}.tap do |attributes|\n attribute_names.each do |key|\n attributes[key] = send(key)\n end\n end\n end",
"def keys\n return [], []\n end",
"def attributes\n self.class.attribute_names.map do |attr|\n type = self.class.attribute_types[attr.to_s]\n value = public_send(attr)\n [attr, type ? type.serialize(value) : value]\n end.to_h\n end",
"def accessors\n @tracked_attrs.keys ||= []\n end",
"def attribute_titles\n attribute_names.map {|f| f.to_s.capitalize.sub(/$/, \":\").gsub(/_/, \" \") }\n end",
"def attributes\n Hash.new.tap do |atts|\n _accessors.each do |accessor|\n att = accessor[0..-2].to_sym\n atts[att] = send(att)\n end\n end\n end"
] |
[
"0.77650887",
"0.7575111",
"0.75099236",
"0.74804366",
"0.7431779",
"0.74076426",
"0.74076426",
"0.74076426",
"0.74076426",
"0.7357327",
"0.7351607",
"0.71687037",
"0.7148262",
"0.7088859",
"0.706278",
"0.7058341",
"0.7055983",
"0.7030187",
"0.7005255",
"0.6972871",
"0.6935397",
"0.68897605",
"0.6878699",
"0.6878699",
"0.6862596",
"0.685218",
"0.6835652",
"0.68185693",
"0.6810887",
"0.67948514",
"0.6736333",
"0.6715352",
"0.6704644",
"0.6672853",
"0.6631609",
"0.6588421",
"0.65795445",
"0.6573868",
"0.6549686",
"0.65380085",
"0.6537244",
"0.6532358",
"0.6507465",
"0.6504033",
"0.6502607",
"0.6478071",
"0.6465477",
"0.6458317",
"0.6458317",
"0.6458317",
"0.6458317",
"0.6458317",
"0.6458317",
"0.6458317",
"0.6458317",
"0.6458317",
"0.6434952",
"0.6434952",
"0.6434952",
"0.6428469",
"0.6408042",
"0.6389619",
"0.6387866",
"0.6387866",
"0.63743615",
"0.63743615",
"0.6364842",
"0.6343641",
"0.6342483",
"0.6338116",
"0.6338116",
"0.6336187",
"0.63280374",
"0.63270926",
"0.63270926",
"0.63270926",
"0.6318263",
"0.63138527",
"0.630179",
"0.6281846",
"0.6276308",
"0.6269524",
"0.62651104",
"0.6252799",
"0.6218581",
"0.62135357",
"0.6212067",
"0.62106436",
"0.62051034",
"0.6204677",
"0.620103",
"0.62004924",
"0.6198613",
"0.6197871",
"0.61951035",
"0.61854804",
"0.61772823",
"0.617621"
] |
0.8037139
|
1
|
Iterate over every attribute name/value pair from the session. like Hasheach
|
def each
getAttributeNames.each { |name| yield(name, getAttribute(name)) }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def each_attribute # :yields: key\n @attrs.each_key { |k| yield(k) }\n end",
"def each # :yields: key, value\n @attrs.each { |k, v| yield(k, v) }\n end",
"def attributes\n if iterator?\n @attr.each do |key, value|\n yield(value)\n end if @attr\n else\n @attr\n end\n end",
"def each_attribute(&block)\n\t\t @@attributes.each &block\n\t\tend",
"def each(&block)\n\t\t\tvalues = {}\n\t\t\teach_attribute do |attr|\n\t\t\t\tvalue = self.fetch(attr)\n\t\t\t\tif not value.nil?\n\t\t\t\t\tvalues[attr] = value\n\t\t\t\tend\n\t\t\tend\n\t\t values.each &block\n\t\tend",
"def each(&block)\n attributes.each_value(&block)\n end",
"def each_attribute(&block)\n attributes.each(&block)\n end",
"def kwattr_values(attribute_name); end",
"def each\n attribute_nodes.each { |node|\n yield [node.node_name, node.value]\n }\n end",
"def each_value # :yields: value\n @attrs.each_value { |v| yield(v) }\n end",
"def attributes\n @attributes = Hash[attrs.map { |a| [a.to_sym, send(\"#{a}\")] }]\n end",
"def each_attribute(&block)\n attributes.each_attribute(&block)\n end",
"def each(&block)\n attributes.each(&block)\n end",
"def each(&block)\n attributes.each(&block)\n end",
"def attributes\n attributes = {}\n self.instance_variables.each do |i| \n meth = i.gsub(\"@\",\"\")\n attributes[meth.to_sym] = self.send meth\n end\n attributes\n end",
"def each_attribute_pair(&block)\n @attributes.each_pair do |name, value|\n block.call(name, value)\n end\n end",
"def attributes\n @attrs.keys\n end",
"def attributes\n @attr_statements ||= begin\n result = {}\n\n stmt_element = REXML::XPath.first(document, \"/p:Response/a:Assertion/a:AttributeStatement\", { \"p\" => PROTOCOL, \"a\" => ASSERTION })\n stmt_element.elements.each do |attr_element|\n name = attr_element.attributes[\"Name\"]\n value = attr_element.elements.first.text\n\n result[name] = value\n end\n\n result.keys.each do |key|\n result[key.intern] = result[key]\n end\n\n result\n end\n end",
"def attribute_values(attributes)\n attributes.map { |attribute| self.send(attribute) }\n end",
"def list_attributes\n if @attributes.empty?\n fetch_configuration()\n end\n return @attributes.keys\n end",
"def login_attributes\n attrs = {}\n\n attr_pairs = [\n {\"userName\" => @user_name},\n {\"suspended\" => @suspended},\n {\"ipWhitelisted\" => @ip_whitelisted},\n {\"admin\" => @admin},\n {\"changePasswordAtNextLogin\" => @change_password_at_next_login},\n {\"agreedToTerms\" => @agreed_to_terms},\n {'password' => @password},\n {'hashFunctionName' => @hash_function_name},\n ]\n\n attr_pairs.each do |pair|\n key = pair.keys.first\n attrs.merge!(pair) unless pair[key].nil?\n end\n\n attrs\n end",
"def attributes\n # ...\n # debugger\n # f = method_missing(name)\n @attributes ||= {}\n # attributes = Hash.new {|h,k| h[k] = []}\n # @attributes = @colm.map {|colm| attributes[colm]}\n # unless instance_variables(false).include?(f)\n # # print f\n # end\n\n # @attribute ={}\n end",
"def attributes\n @ldap_entry.attribute_names.each_with_object({}) do |key, hsh|\n hsh[key] = get_value(key)\n end\n end",
"def attributes\n @attributes ||= attribute_names.inject({}) do |hash, name|\n attribute_values = saml.xpath(\"//saml:Attribute[@Name='#{name}']/saml:AttributeValue/text()\")\n hash[name] = attribute_values.length > 1 ? attribute_values.collect(&:to_s) : attribute_values.to_s\n hash\n end\n end",
"def attributes\n attrs = Hash.new\n attribute_list.each do |attribute|\n value = self.send(attribute)\n attrs[attribute] = value unless value.nil?\n end\n attrs\n end",
"def attributes\n @attr_statements ||= begin\n result = {}\n\n stmt_element = REXML::XPath.first(document, \"/p:Response/a:Assertion/a:AttributeStatement\", { \"p\" => PROTOCOL, \"a\" => ASSERTION })\n return {} if stmt_element.nil?\n\n stmt_element.elements.each do |attr_element|\n name = attr_element.attributes[\"Name\"]\n value = attr_element.elements.first.text\n\n result[name] = value\n end\n\n result.keys.each do |key|\n result[key.intern] = result[key]\n end\n\n result\n end\n end",
"def attributes\n self.attribute_keys.inject({}) do |hash, key|\n hash[key] = self.__send__(key) if self.__send__(key)\n hash\n end\n end",
"def attribute_values\n self.class.attributes.map{ |attr| self.send(attr) }\n end",
"def tweak_session_attrs_saml\n return unless valid_saml_session?\n saml_profile_attr_map.each do |d, s|\n tweak_session_attr_saml(d, s)\n end\n end",
"def attributs()\n if block_given?\n rados_getxattrs.each { |key,value| \n yield key,value\n }\n else\n return rados_getxattrs\n end\n \n end",
"def attributes\n instance_values.with_indifferent_access.slice(*USER_ATTRIBUTES)\n end",
"def attributes\n self._attributes.inject({}) do |hash, attr|\n hash[attr.to_s] = send(attr)\n hash\n end\n end",
"def attributes\n hash = HashWithIndifferentAccess.new\n\n self.class.attribute_names.each_with_object(hash) do |name, attrs|\n attrs[name] = read_attribute(name)\n end\n end",
"def attributes\n Hash[instance_variables.map{|attrib| [attrib.to_s[1..attrib.to_s.size], nil]}]\n end",
"def attributes\n @cache[:attributes]\n end",
"def enumerate_attrs\n @node_attrs.keys.each_with_object({}) { |node, h|\n h[node] = enumerate_attrs_by_node(node)\n }\n end",
"def attribute_hash\n instance_vars = self.send(:instance_variables)\n values = {}\n instance_vars.each do |var|\n values[(var.to_s.delete('@')).to_sym] = self.instance_variable_get(var)\n end\n values\n end",
"def attributes_get\n h = {}\n self.class.attributes.each do |a|\n h[a] = attribute_get(a)\n end\n h\n end",
"def attributes_get\n h = {}\n self.class.attributes.each do |a|\n h[a] = attribute_get(a)\n end\n h\n end",
"def enumerate_attrs\n @node_attrs.keys.each_with_object({}) do |node, h|\n h[node] = enumerate_attrs_by_node(node)\n end\n end",
"def attributes\n ATTRIBUTES.each_with_object({}) do |name, buffer|\n buffer[name] = public_send(name)\n end\n end",
"def attributes(*attrs)\n attrs.each { |attr_name| @_attributes[attr_name.to_sym] = attr_name.to_sym }\n end",
"def attributes(*attrs)\n\n self._attributes = _attributes.dup\n\n attrs.each do |attr|\n if Hash === attr\n attr.each {|attr_real, key| attribute attr_real, :key => key }\n else\n attribute attr\n end\n end\n end",
"def attributes\n load_attributes! unless attributes_loaded?\n @attributes.values\n end",
"def attribute_values\n attributes.values\n end",
"def attribute_list(el); end",
"def current_attributes\n attributes.each_key.each_with_object({}) do |key, h|\n h[key] = public_send(key)\n end\n end",
"def keys\n getAttributeNames.to_a\n end",
"def keys\n getAttributeNames.to_a\n end",
"def keys\n getAttributeNames.to_a\n end",
"def save_to(session)\n attributes.each do |key, value|\n session[key] = value\n end\n self\n end",
"def values\n @attrs.values\n end",
"def get_attributes\n h = {}\n if @reader.has_attributes?\n if @reader.move_to_first_attribute == 1\n h[@reader.name] = @reader.value\n while @reader.move_to_next_attribute == 1\n h[@reader.name] = @reader.value\n end\n end\n @reader.move_to_element # reset main pointer in libxml\n end\n # p h\n h\n end",
"def attributes\n {}.tap do |attributes|\n attribute_names.each do |key|\n attributes[key] = send(key)\n end\n end\n end",
"def save_to_session(session,key)\n session[key] ||= {}\n ClaimFilter.columns.each do |c|\n session[key][c.name.to_sym] = self.read_attribute(c.name)\n end\n nil\n end",
"def each_attr_in(items)\n items.each do |item|\n if item.is_a?(Hash)\n each_attr_in(item[:items]) if item[:items].is_a?(Array)\n yield(item) if item[:name]\n end\n end\n end",
"def attributes\n [@attribute,@value].inject(Hash.new([])) do |memo,c|\n case c \n when Sower::Relation::Statement, Sower::Relation::Attribute, Sower::Relation::Value::Base\n memo.merge!(c.attributes){|k,v,n| v | n}\n end\n memo\n end\n end",
"def attr_values\n values = self.instance_variables.collect do |key|\n [key, self.instance_variable_get(key)]\n end\n return Hash[values]\n end",
"def attributes\n _fast_attributes\n\n rescue NameError\n\n method = \"def _fast_attributes\\n\"\n method << \" @_attributes ||=\\n\"\n method << \" begin\\n\"\n method << \" h = {}\\n\"\n\n self.class.attributes.each do |name|\n method << \" h[:\\\"#{name}\\\"] = send(:\\\"#{name}\\\") if include_#{name}?\\n\"\n end\n\n method << \" h\\n\"\n method << \" end\\n\"\n method << \"end\"\n\n self.class.class_eval method\n\n _fast_attributes\n end",
"def attributes\n @attributes ||= {}\n @attributes\n end",
"def attributes\n instance_variables.each do |var|\n child = instance_variable_get var\n name = var.to_s[1..-1]\n yield child, name\n end\n end",
"def attributes(attrs)\n\t\t\tattrs.each do |k,v|\n\t\t\t\tsetter = \"#{k}=\".to_sym\n\t\t\t\tself.send(setter, v)\n\t\t\tend\n\t\t\t\n\t\t\tyield self if block_given?\n\t\t\t\n\t\t\treturn self\n\t\tend",
"def attribute_values\n @attribute_values ||= {}\n end",
"def attributes\n data[:attributes]\n end",
"def each_attribute(&blk)\n to_enum(:_each_attribute).sort_by{|attr| attr.name}.each(&blk)\n end",
"def attributes(*args)\n args.each do |attr|\n attribute(attr)\n end\n end",
"def get_attributes\n\t\t\t@@attributes\n\t\tend",
"def find_attributes(name)\n\t\t\tr=[]\n\t\t\tp=self\n\t\t\twhile(p)\n\t\t\t\tif(p.respond_to?(name))\n\t\t\t\t\tv=p.send(name)\n\t\t\t\t\tr << v if(v)\n\t\t\t\tend\n\t\t\t\tbreak if(!p.respond_to?(\"container\"))\n\t\t\t\tp=p.container\n\t\t\tend\n\t\t\tr\n\t\tend",
"def attributes\n instance_variables.map{ |iv| iv.sub('@','') }\n end",
"def parse_attrlist\n tok = readbyte\n list = []\n currentname = nil\n currentvalue = \"\"\n while tok != END_T\n if tok == SWITCH_PAGE\n @attr_codepage = readbyte\n elsif tok == STR_I\n currentvalue += readntstring\n elsif tok == STR_T\n currentvalue += @stringtable[parse_mbint]\n elsif tok == ENTITY\n currentvalue << readmbstr\n elsif tok == OPAQUE\n currentvalue << readstring # TODO: What should we do for opaque in an attribute?\n elsif tok == EXT_0\n currentvalue << \"&wbxml_#{@attr_codepage.to_s 16}_ext0;\"\n elsif tok == EXT_1\n currentvalue << \"&wbxml_#{@attr_codepage.to_s 16}_ext1;\"\n elsif tok == EXT_2\n currentvalue << \"&wbxml_#{@attr_codepage.to_s 16}_ext2;\"\n # TODO: Deal with extension tokens that have a string payload\n elsif tok == LITERAL\n if currentname\n list << [currentname, currentvalue]\n end\n currentname = @stringtable[parse_mbint]\n currentvalue = \"\"\n elsif tok < 128 # ATTRSTART\n if currentname\n list << [currentname, currentvalue]\n end\n currentname, currentvalue = get_attr_start(tok)\n elsif tok > 128 # ATTRVALUE\n currentvalue += get_attr_value(tok)\n end\n tok = readbyte\n end\n if currentname\n list << [currentname, currentvale]\n end\n list\n end",
"def attributes\n scraper.attributes.keys + uri_response_attributes + [:feed]\n end",
"def attribs\n\t\t@attributes\n\tend",
"def attributes\n self.class._attributes.dup.each_with_object({}) do |name, hash|\n hash[name] = send(name)\n end\n end",
"def attributes\n @_attributes ||= Hash.new.with_indifferent_access\n end",
"def deserialize_attributes\n # STDERR.puts \"deserialize_attributes()\"\n # STDERR.puts @@custom_attributes.inspect\n # STDERR.puts \"SECRETS: #{self[:secrets]}\"\n name = self.class.name.to_s.to_sym\n if @@custom_attributes[name].respond_to? 'each_key'\n # STDERR.puts \"Responds to each_key\"\n @@custom_attributes[name].each_key do |sym|\n # STDERR.puts \"deserialize[#{name}](#{sym}) = #{self[:secrets][sym.to_s]}\"\n self.send(sym.to_s+'=', self[:secrets][sym.to_s])\n end\n end\n end",
"def attributes\n @data.keys\n end",
"def attributes\n Hash[instance_variables.map { |name| [name, instance_variable_get(name)] }]\n end",
"def attributes\n ATTRIBUTES.inject({}) do |hash, attribute|\n hash[attribute] = self.send(attribute)\n hash\n end\n end",
"def attributes\n ATTRIBUTES.inject({}) do |hash, attribute|\n hash[attribute] = self.send(attribute)\n hash\n end\n end",
"def tweak_session_attrs\n tweak_session_attrs_saml\n end",
"def attribute_values \n columns = self.class.columns\n columns.map { |col| self.send(col) } #=> ex. [:id, :name, :owner_id]\n end",
"def list_attributes\n list = \"Age: #{@age} Earth years old\\nSize: #{@size}\\nVisitor Count: #{@visitor_count}\\nInhabitants: #{@inhabitants}\\n\"\n return list\n end",
"def attributes=(hash)\n hash.each do |key, value|\n send(\"#{key}=\", value)\n end\n end",
"def allprop(xml = nil)\n @liveprops.each do |key, v|\n if v.allprop?\n begin\n value = self[key, xml]\n yield(key, value) if block_given?\n rescue NotFoundError, UnauthorizedError, ForbiddenError\n end\n end\n end\n end",
"def attributes=(attrs)\n attrs.each_pair do |attr, value|\n if respond_to?(\"#{attr}=\")\n public_send(\"#{attr}=\", value)\n else\n attributes[attr.to_s] = value\n end\n end\n end",
"def attributes\n @attributes\n end",
"def attributes\n instance_values\n end",
"def printallattrs(msg)\n msg.reply \"Listing available attributes:\"\n Physattr.each { |p| msg.reply p unless p.is_hidden? }\n msg.reply \"Done!\"\n end",
"def attributes\n @attributes ||= begin\n attrs = {}\n self.class.key_attrs.values.each { |a| attrs[a.name] = a.initial_value }\n self.class.other_attrs.values.each { |a| attrs[a.name] = a.initial_value }\n attrs\n end\n end",
"def attributes\n attrs = {}\n instance_variables.each { |instance_variable|\n # Convert the instariable to a string, removing the @ (instance notation), and convert back to a symbol\n attrs[instance_variable.to_s[1..-1].to_sym] = instance_variable_get(instance_variable)\n }\n attrs\n end",
"def attributes\n Hash.new.tap do |atts|\n _accessors.each do |accessor|\n att = accessor[0..-2].to_sym\n atts[att] = send(att)\n end\n end\n end",
"def create_attr_hash\n data = {}\n self.instance_variables.each do |attr|\n value = self.instance_variable_get(attr)\n key = attr.to_s.sub(%r{^\\@}, '').sub(%r{\\@}, '')\n if @attr_list.include?(key)\n data[key] = value\n end\n end\n\n data\n end",
"def attributes\n @attrs\n end",
"def attributes\n # Note: the values returned here are ignored by\n # ActiveModel::Serializers#serializable_hash; just the keys are\n # used to again call those getter methods... But we do want to\n # check the values so we can leave 'nil' out of the hash.\n attribute_keys.inject(\n ActiveSupport::HashWithIndifferentAccess.new) do |result, key|\n value = send(key)\n result[key] = value unless value == nil\n result\n end\n end",
"def link_attributes\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 17 )\n hash = nil\n attribute26 = nil\n # - - - - @init action - - - -\n hash = Hashie::Mash.new\n\n begin\n # at line 112:8: ( ';' ( WS )? attribute )*\n # at line 112:8: ( ';' ( WS )? attribute )*\n while true # decision 27\n alt_27 = 2\n look_27_0 = @input.peek(1)\n\n if (look_27_0 == T__11)\n look_27_1 = @input.peek(2)\n\n if (look_27_1.between?(WS, LOALPHA))\n alt_27 = 1\n\n end\n\n end\n case alt_27\n when 1\n # at line 112:9: ';' ( WS )? attribute\n match(T__11, TOKENS_FOLLOWING_T__11_IN_link_attributes_708)\n # at line 112:13: ( WS )?\n alt_26 = 2\n look_26_0 = @input.peek(1)\n\n if (look_26_0 == WS)\n alt_26 = 1\n end\n case alt_26\n when 1\n # at line 112:13: WS\n match(WS, TOKENS_FOLLOWING_WS_IN_link_attributes_710)\n\n end\n @state.following.push(TOKENS_FOLLOWING_attribute_IN_link_attributes_713)\n attribute26 = attribute\n @state.following.pop\n # --> action\n hash.merge!(attribute26)\n # <-- action\n\n else\n break # out of loop for decision 27\n end\n end # loop for decision 27\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 17 )\n\n end\n\n return hash\n end",
"def attributes\n @@attributes\n end",
"def hash\n @attrs\n end",
"def hit_on_attributes attrhash, site\n return unless results.present? && site\n attrhash.each do |label, value_or_set|\n if value_or_set.is_a? Hash\n (value_or_set = value_or_set.values).map { |value|\n hit_on_attribute label, value, site\n }\n else\n hit_on_attribute label, value_or_set, site\n end\n end\n end"
] |
[
"0.6623814",
"0.6488496",
"0.6451143",
"0.640535",
"0.6334656",
"0.6282344",
"0.62392306",
"0.6152692",
"0.6128836",
"0.60732865",
"0.60620636",
"0.60481846",
"0.6032993",
"0.6032993",
"0.60315186",
"0.60060924",
"0.5999632",
"0.59871143",
"0.59691674",
"0.5969161",
"0.5967325",
"0.5960134",
"0.59406334",
"0.5936624",
"0.59225625",
"0.5909294",
"0.5897998",
"0.58834076",
"0.58780617",
"0.5875386",
"0.586638",
"0.58489513",
"0.5839377",
"0.58357555",
"0.58169776",
"0.5808367",
"0.58071524",
"0.57994556",
"0.57994556",
"0.5796003",
"0.57773644",
"0.57731533",
"0.57710147",
"0.57694656",
"0.5769154",
"0.57683706",
"0.5765598",
"0.5746094",
"0.5746094",
"0.5746094",
"0.5713717",
"0.5710468",
"0.57072",
"0.5701743",
"0.56687796",
"0.5654326",
"0.5650955",
"0.562269",
"0.5618033",
"0.5605816",
"0.5603686",
"0.55925876",
"0.55908585",
"0.5577168",
"0.5572314",
"0.55684966",
"0.5568038",
"0.5562565",
"0.5561813",
"0.55568326",
"0.5545387",
"0.55407935",
"0.553581",
"0.551633",
"0.5508198",
"0.55039907",
"0.5499249",
"0.5496759",
"0.5496759",
"0.5494907",
"0.5494748",
"0.5494571",
"0.5489695",
"0.5484503",
"0.54830974",
"0.5480657",
"0.54798996",
"0.5478925",
"0.5475957",
"0.54753464",
"0.5474679",
"0.54605585",
"0.5457929",
"0.5449193",
"0.5446957",
"0.5446069",
"0.5438248",
"0.5438084"
] |
0.67497075
|
1
|
Question3: Write at least one more function of your own design, and run it 10 different ways.
|
def sum_of(a,b)
return a + b
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def bad_smell_by_nfunctions\n end",
"def three_to_twenty\n\nend",
"def calls; end",
"def calls; end",
"def how_it_works\r\n end",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def problem_14\nend",
"def perform\n multiples_3_and_5()\nend",
"def koan_3\nend",
"def call1\n call2\n call3\nend",
"def making_functions(monkey, dogs)\n puts \"I think monkeys eat #{monkey}.\"\n puts \"I think dogs eat #{dogs}.\"\nend",
"def do_twice(what1, what2, what3)\n 2.times do\n what1.call\n what2.call\n what3.call\n end\nend",
"def problem_8\nend",
"def do_stuff more_actions=[], num_actions=5\n actions = []\n num_actions.times do\n actions.push ((['move', 'eat', 'nap'] + more_actions).sample)\n end\n actions.each do |action|\n m = method action\n m.call\n end\n puts \"#{@name} is done doing stuff!\"\n end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def fizzbuzz\n (1..100).each do |num|\n puts fizz_buzz(num)\n end\nend",
"def learn\n\n language = do_you_want_to_learn(\"human languages\")\n\n if language == \"1\"\n learn_human_languages\n end\n\n math = do_you_want_to_learn(\"math\")\n\n math = get_data\n\n if math == \"1\"\n learn_math\n end\n\n it = do_you_want_to_learn(\"it\")\n\n it = get_data\n\n if it == \"1\"\n learn_it\n end\nend",
"def firstMethod()\n p \"hey this is first method ok\"\n p \"here i show how can create method in ruby\"\n p \" know time end \"\nend",
"def do_something(swim, bike, run)\nend",
"def the_interview\n (1..100).each{ |n| puts n % 15 == 0 ? \"fizzbuzz\" : n % 3 == 0 ? \"fizz\" : n % 5 == 0 ? \"buzz\" : n }\n (0..99).reverse_each{|n| puts \"I have #{n} bottles.\"}\nend",
"def fizz_buzz(number)\n if can_be_divided_by_three_and_five(number)\n return \"FizzBuzz\" #ends method early to avoid getting the following two responses\n end\n if can_be_divided_by_three(number)\n return \"Fizz\"\n end\n if can_be_divided_by_five(number)\n return \"Buzz\"\n end\nend",
"def p15\n\t\nend",
"def say_hello_world_five_times\n puts \"Hello World!\"\n puts \"Hello World!\"\n puts \"Hello World!\"\n puts \"Hello World!\"\n puts \"Hello World!\"\nend",
"def functions\n\n end",
"def runs; end",
"def demo3\n end",
"def travelAroundTheWorld(a, b, c)\n #\n # Write your code here.\n #\n\nend",
"def solution1(input)\n return \"Not implemented!\"\nend",
"def stest_method_1(test); end",
"def run_tests()\n check_solution(1, [1, 4, 10, 13, 15], true)\n check_solution(2, [1, 4, 10, 10, 13, 15], true)\n check_solution(3, [1, 2, 5, 3, 4 ], false)\nend",
"def run_tests()\n check_solution(1, [1, 4, 10, 13, 15], true)\n check_solution(2, [1, 4, 10, 10, 13, 15], true)\n check_solution(3, [1, 2, 5, 3, 4 ], false)\nend",
"def run_tests()\n check_solution(1, [1, 3, 5, 4], [5])\n check_solution(2, [4, 2, 3, 6, 10], [4, 10])\n check_solution(3, [4, 2, 11, 6, 10], [4, 11, 10])\nend",
"def main\n#main method\nfunction_a\n# function_b\nend",
"def main\n#main method\nfunction_a\n# function_b\nend",
"def run_tests()\n check_solution(1,\"aaabbc\", \"3a2bc\")\n check_solution(2, \"xxyyyyzz\", \"2x4y2z\")\n check_solution(3, \"qqqqq\", \"5q\")\n check_solution(4, \"mississippi\", \"mi2si2si2pi\")\nend",
"def run_tests()\n check_solution(1,\"aaabbc\", \"3a2bc\")\n check_solution(2, \"xxyyyyzz\", \"2x4y2z\")\n check_solution(3, \"qqqqq\", \"5q\")\n check_solution(4, \"mississippi\", \"mi2si2si2pi\")\nend",
"def run_tests()\n check_solution(1,\"aaabbc\", \"3a2bc\")\n check_solution(2, \"xxyyyyzz\", \"2x4y2z\")\n check_solution(3, \"qqqqq\", \"5q\")\n check_solution(4, \"mississippi\", \"mi2si2si2pi\")\nend",
"def function(action1, action2, action3)\n puts \"To '#{action1}', '#{action2}', or '#{action3}' a function all mean the same thing.\"\nend",
"def using_times \n 7.times do \n puts \"Wingardium Leviosa\"\n end\nend",
"def prescription_1\n\tputs \"*** Prescription 1 ***\"\n\tputs \"Use the TDD process to create and adjust your code's design in small, incremental steps.\\n\\n\"\nend",
"def procasaurus( p1, p2, p3 )\n\tputs p1.call\n\tputs p2.call\n\tputs p3.call\nend",
"def fizzbuzz\nend",
"def using_times\n 7.times do\n puts \"Wingardium Leviosa\"\n end\nend",
"def get_famous\n begin\n move_to_san_francisco && make_friends\n do_interesting_things\n rescue TotalFailError\n whats_the_worst_that_can_happen\n end\nend",
"def fizz_buzz number \nend",
"def three_and_5(number)\r\n \r\nend",
"def koan_4\nend",
"def run_tests\n check_solution(1, [6, 29, 18, 2, 72, 19, 18, 10, 37], 18, 2)\n check_solution(2, [6, 29, 18, 2, 72, 19, 18, 10, 37], 9, -1)\nend",
"def introduce_myself\n puts \"I am handsome\"\n puts \"I am talented\"\n puts \"I am brilliant\"\nend",
"def call() end",
"def mi_funcion(parametro)\n parametro.times do\n puts \"Ruby es raramente elegante.\"\n end\nend",
"def fizz_buzz number\nend",
"def fizz_buzz number\nend",
"def say_hello_ten_times #method signature\n phrase = \"Hello World\"\n puts phrase\n puts phrase\n puts phrase\n puts phrase\n puts phrase\n puts phrase\n puts phrase\n puts phrase\n puts phrase\n puts phrase\n end",
"def introduce_myself\n puts 'am handsome'\n puts 'i am talented'\n puts 'i am brilliant'\nend",
"def run_tests\n check_solution(1, (100..200).to_a, 135, 35)\n check_solution(2, [13, 19, 24, 29, 32, 37, 43], 35, -1)\nend",
"def a_method_fixed(a,b)\n puts \"I got #{a}\"\n puts \"I got #{b}\"\n puts \"I got #{a+b}\"\n a + b\nend",
"def tutorial\n puts\n rules\n deck = Visualized.new\n examples deck.base_deck\n bad_examples deck.base_deck\nend",
"def phase_one\n 8.times do\n @borneo.immunity_challenge.tribal_council()\n puts\n end\nend",
"def operations; end",
"def operations; end",
"def test_costo_cafe\n print validate(177.56, costo_cafe(100.0,7))\n print validate(1537.30, costo_cafe(1000.0,5)) \n print validate(363.0, costo_cafe(300.0,2)) \nend",
"def introduce_myself\n puts \"I am a world ruler\"\n puts \"I am filty rich\"\n puts \"I own a library\"\nend",
"def always_three_method(number)\n\t(((number+5)*2 -4)/2 - number)\nend",
"def what_to_do(count)\n puts \"What do you want to do?\"\n sleep 0.5\n puts \"Type help for available commands!\"\n answer = gets.chomp.downcase\n if answer.include? \"help\"\n help(count, answer)\n end\n if answer.include? \"scrape\" and count == 0\n scrape_potatoes(count)\n elsif answer.include? \"cut\" and count == 1\n cut_potatoes(count)\n elsif answer.include? \"add\" and count == 2 and answer.include? \"potatoes\"\n add_potatoes_to_pan(count)\n elsif answer.include? \"stir\" and count == 3\n stir(count)\n elsif answer.include? \"break\" and count == 4\n break_eggs(count)\n elsif answer.include? \"salt\" and count > 4\n add_salt(count)\n elsif answer.include? \"pepper\" and count > 4\n add_pepper(count)\n elsif answer.include? \"exit\"\n exit\n elsif answer.include? \"serve\" and count > 4\n serve_dish\n else\n puts \"Thats not the right order! Try again\"\n sleep 2\n try_again(count)\n end\nend",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def test_cases; end",
"def fizzbuzz (i)\n if i % 3 == 0 && i % 5 == 0\n return \"FizzBuzz\"\nend\n if i % 3 == 0 \n return \"Fizz\"\nend\n if i % 5 == 0 \n return \"Buzz\"\nend \nend",
"def find_people_around_football_pitch_around_jindigeling\n find_shops\nend",
"def cheese_and_crackers(cheese_count, boxes_of_crackers)\n# provides string to run with cheese_count\n puts \"You have #{cheese_count} cheeses!\"\n# provides string to run with boxes_of_crackers\n puts \"You have #{boxes_of_crackers} boxes of crackers!\"\n# provides string to run\n puts \"Man that's enough for a party!\"\n# provides string to run\n puts \"Get a blanket.\\n\"\n# ends the method\nend",
"def post_squares\n\ttumblr()\n\ttweet()\nend",
"def fizzbuzz(fiz_3)\n if fiz_3 % 3 == 0 && fiz_3 % 5 == 0 \n return \"FizzBuzz\"\n end \n \n if fiz_3 % 3 == 0 \n return \"Fizz\"\n end\n \n if fiz_3 % 5 == 0 \n return \"Buzz\"\n end\nend",
"def fizzbuzz(num_1, num_2, range)\n # creates an action that will be carried out when the method is called\n (1..range).each do |i|\n # creates the first conditional to the action above\n if i % num_1 === 0 && i % num_2 === 0\n # notes the action to carry out if the above is true\n puts 'fizzbuzz'\n # creates an alternate conditional route for the action above\n elsif i % num_1 === 0\n # notes the action to carry out if the above conditional is true\n puts 'fizz'\n # creates yet another conidtional route - if both of the above are false - this will be evaluated.\n elsif i % num_2 === 0\n # notes the action to carry out if the above conditional is true\n puts 'buzz'\n # creates the final condition - encompasses all other options if the all 3 of the above are false\n else\n # notes the action to carry out if we've moved to the 'else' realm with the first 3 conditions\n puts i\n # ends the function within the method\n end\n #ends the method within a method of .each\n end\n# ends the method\nend",
"def number_in_a_can(number = 10)\n number.times { |n| puts \"The number is #{n}\" }\nend",
"def yet_another_func\r\n 18\r\n end",
"def introduceMyself\n puts \"I am handsome\"\n puts \"I am talented\"\n puts \"I am brilliant\"\nend",
"def greet(n)\n n.times do |x|\n puts \"Hello: #{x}\"\n end\nend",
"def call(*) end",
"def call(*) end",
"def program; end",
"def do_something(study,work,clean)\n puts study\n puts work\n puts clean\nend",
"def sale_hotdogs(n)\n #your code here\n n < 5? 100 * n : n < 10? 95*n : 90*n\nend",
"def solution4(input)\n end",
"def basic_methods \n\n\t#ask the user their name\n\tputs \"What is your name?\"\n\n\t#create a variable to get the name then use the chomp method to remove the enter \n \tname = gets.chomp\n\n \t#let the user know how nice their name is \n \tputs \"What a lovely name \" + name\n\n \t#ask the user how old they are \n\tputs \"How old are you?\"\n\n\t#create a variable to old the users age and use the gets method to get the string of data and convert it into a integer to be calculated like so\n\tage = gets.to_i\n\n\t#calculate how old the user will be in 10 years \n \tputs \"You are \" + age.to_s\n \tputs \"That\\'s a good age\"\n \tputs \"Do you realize that in ten years you will be \" \n \ttenyears = age + 10 \n \ttenyears.to_i\n \tputs \"#{tenyears}\"\n\n \t#ask the user some more questions about themselves\n \tputs \"#{name} what do you do for a living?\"\n \tliving = gets.chomp\n\n \tputs \"What made you decide to #{living}\"\n\n \tdecide = gets.chomp\n \tputs \"That\\'s interesting!\"\n \tputs \"Good luck on all your endevours!\"\n \tputs \"GOD BLESS YOU #{name}\"\n\t\n\t#you have to let Ruby know to end the method before you can call the method. \n\tend",
"def step_two()\r\nend",
"def a_good_method\n 1 + 1\nend",
"def greeting(proc_1, proc_2, proc_3)\n puts proc_1.call('good morning')\n puts proc_2.call('hello')\n puts proc_3.call('good evening')\nend",
"def add_three(n)\n n + 3\nend"
] |
[
"0.63595676",
"0.62267905",
"0.62042725",
"0.62042725",
"0.618429",
"0.6077839",
"0.6077839",
"0.6077839",
"0.6006674",
"0.5958124",
"0.59420806",
"0.592435",
"0.59094024",
"0.5899994",
"0.58799595",
"0.58733886",
"0.5867641",
"0.5867641",
"0.5867641",
"0.5867641",
"0.5867641",
"0.5846504",
"0.581479",
"0.58141106",
"0.58124983",
"0.5806337",
"0.5804441",
"0.58033353",
"0.57841885",
"0.5781024",
"0.5778499",
"0.57725114",
"0.5762911",
"0.57623017",
"0.575953",
"0.5759527",
"0.5759527",
"0.57522964",
"0.57290715",
"0.57290715",
"0.5715402",
"0.5715402",
"0.5715402",
"0.5687173",
"0.5684198",
"0.5670702",
"0.56564975",
"0.56541437",
"0.56424737",
"0.5635733",
"0.56295156",
"0.5624739",
"0.56138664",
"0.5601978",
"0.5596256",
"0.5569219",
"0.556471",
"0.5563049",
"0.5563049",
"0.55628276",
"0.55599195",
"0.5548944",
"0.5545654",
"0.55380785",
"0.5526679",
"0.5525169",
"0.5525169",
"0.5518043",
"0.55108273",
"0.55072033",
"0.5502749",
"0.55018145",
"0.55018145",
"0.55018145",
"0.55018145",
"0.55018145",
"0.55018145",
"0.55018145",
"0.55018145",
"0.5501766",
"0.54873097",
"0.5476144",
"0.5472134",
"0.5466326",
"0.5465488",
"0.5465103",
"0.54637986",
"0.54637235",
"0.54616785",
"0.5459926",
"0.5457337",
"0.5457337",
"0.5450451",
"0.54491675",
"0.5447345",
"0.5445487",
"0.54414403",
"0.5433598",
"0.54306614",
"0.5426373",
"0.54244834"
] |
0.0
|
-1
|
codewars kata: deodorant evaporator
|
def evaporator(content, evap_per_day, threshold)
days = 0
threshold_amount = threshold.fdiv(100) * content
until content < threshold_amount do
content -= evap_per_day.fdiv(100) * content
days += 1
end
days
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def silly_adjective; end",
"def celebration; end",
"def anchored; end",
"def villian; end",
"def terpene; end",
"def superweening_adorningly(counterstand_pyrenomycetales)\n end",
"def demon; end",
"def emotional_adjective; end",
"def gounod; end",
"def suivre; end",
"def herald; end",
"def bye; end",
"def surge; end",
"def doors; end",
"def delelte\n\n end",
"def elv_kicklee\n atk > dfe\n end",
"def virgilism_dentality(checkrowed, generatrix)\n unflickeringly_draftiness_goer()\n retrust(clavation_uneclipsed)\n thumby(afterknowledge, disproval)\n end",
"def invention; end",
"def king_richard_iii; end",
"def dv; end",
"def jack_handey; end",
"def nonstriker_perimartium(pronunciation_crotched)\n end",
"def ygg_attacker() ; return nil ; end",
"def kex; end",
"def diarchic()\n menald_apinae(preadvance, herpetotomy)\n puppy_becrown_thusgate(nonrepresentative_cometographical, gadolinite, curably_nondeliberate)\n unorbital?(hedgy_intervarietal, omenology)\n end",
"def eplore\n end",
"def electromechanical; end",
"def dh; end",
"def ravel; end",
"def sub_e\n end",
"def hiddens; end",
"def deter\n \n end",
"def sharp; accidental; end",
"def soft_ace\n # softy method refactor for when an ace is played\nend",
"def celebrity; end",
"def celebrity; end",
"def vowel_killer\n\"Rubber Soul\".delete \"u\"\n\"Rbber Soul\".delete \"o\"\n\"Rbber Sul\".delete \"u\"\n\"Rbber Sl\".delete \"e\"\nend",
"def droid; end",
"def feruchemist; end",
"def things_to_diff(exp, act); end",
"def diff(exp, act); end",
"def sub_d\n end",
"def sk! ; k! ; s! ; end",
"def isolated; end",
"def isolated; end",
"def offences_by; end",
"def verdi; end",
"def trd; end",
"def dish; end",
"def both_changed(name)\n part_1_vowels = next_vowel(name)\n part_2_consonants = next_consonant(part_1_vowels)\n return part_2_consonants #gives it back to caller\nend",
"def diff2; end",
"def buzzword; end",
"def buzzword; end",
"def heroine; end",
"def upc_e; end",
"def deco_call; end",
"def mitch_hedberg; end",
"def eye; end",
"def yoda; end",
"def malts; end",
"def hiss; end",
"def romeo_and_juliet; end",
"def phase; end",
"def tongue_twister; end",
"def dy() 0 end",
"def corrector; end",
"def corrector; end",
"def corrector; end",
"def corrector; end",
"def difficultly(qoph_ridding, fadedness_santalaceae)\n biopsychologist_hamidian_tachardiinae()\n inigo()\n huddock_konde(phrenitic, mistake, condurango_cymoscope)\n end",
"def xor_e\n end",
"def bizet; end",
"def strain; end",
"def kids_musical; end",
"def yyerrok; end",
"def yyerrok; end",
"def daa\n end",
"def p15\n\t\nend",
"def schubert; end",
"def leeway; end",
"def leeway; end",
"def enchantment; end",
"def berlioz; end",
"def y; end",
"def y; end",
"def y; end",
"def revert_code()\n\t\t\n\tend",
"def sweep; end",
"def diff1; end",
"def berg; end",
"def slop!; end",
"def slop!; end",
"def food_and_drink; end",
"def potion; end",
"def deco_pos; end",
"def faint; end",
"def faint; end",
"def forkless(interspinous_interdevour, cladodontid_michel)\n end",
"def alt; end",
"def dec_e\n end",
"def odds_and_evens(string, return_odds)\nstring = string.split('')\ndevolver = []\n counter = 0\n\tif return_odds == true\n\t\tstring.each do |x|\n\t\t\tif counter % 2 != 0\n\t\t\t\tdevolver.push(x)\n\t\t\tend\n\t\t\tcounter= counter + 1\n\t\tend\t\n\telse\n\t\tstring.each do |x|\t\t\t\n\t\t\tif counter % 2 == 0\n\t\t\t\tdevolver.push(x)\n\t\t\tend\n\t\t\tcounter= counter + 1\n\t\tend\t\n\tend\nreturn devolver.join\nend"
] |
[
"0.6394914",
"0.63324815",
"0.6163264",
"0.6136077",
"0.60891545",
"0.60746104",
"0.60338175",
"0.6016724",
"0.5994889",
"0.59768456",
"0.5797448",
"0.5791851",
"0.57638204",
"0.5760907",
"0.57375765",
"0.5713643",
"0.56810826",
"0.56661266",
"0.56586915",
"0.5634365",
"0.55827117",
"0.5580983",
"0.5565905",
"0.5548772",
"0.5519296",
"0.5510944",
"0.5494073",
"0.5486054",
"0.5480322",
"0.54702455",
"0.5464441",
"0.5435689",
"0.54221624",
"0.5411886",
"0.5395012",
"0.5395012",
"0.5368196",
"0.5365775",
"0.5350416",
"0.5348832",
"0.5345009",
"0.53408194",
"0.5319533",
"0.53169715",
"0.53169715",
"0.5314768",
"0.53020406",
"0.52988017",
"0.5293716",
"0.5283742",
"0.52813184",
"0.52811193",
"0.52811193",
"0.5266539",
"0.5261278",
"0.52499694",
"0.52343005",
"0.52260214",
"0.5225673",
"0.5215717",
"0.5211319",
"0.5207136",
"0.519948",
"0.5195864",
"0.51950955",
"0.5188813",
"0.5188813",
"0.5188813",
"0.5188813",
"0.5167472",
"0.5167086",
"0.51668763",
"0.5166792",
"0.51573855",
"0.51489574",
"0.51489574",
"0.5138639",
"0.5117087",
"0.5109989",
"0.5109073",
"0.5109073",
"0.51068074",
"0.5103714",
"0.510027",
"0.510027",
"0.510027",
"0.50964296",
"0.5091251",
"0.5089847",
"0.508805",
"0.50880134",
"0.50880134",
"0.50859183",
"0.507996",
"0.5073181",
"0.5072702",
"0.5072702",
"0.5067786",
"0.5067237",
"0.5065842",
"0.5062713"
] |
0.0
|
-1
|
codewars kata: operations with sets
|
def process_2arrays(array_1, array_2)
shared = array_1 & array_2
shared_count = shared.count
array_1_unshared = array_1 - shared
array_2_unshared = array_2 - shared
count_1 = array_1_unshared.count
count_2 = array_2_unshared.count
unshared = array_1_unshared + array_2_unshared
unshared_count = unshared.count
[].push(shared_count, unshared_count, count_1, count_2)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sets\n end",
"def apply_harvesting_set_membership(sets)\n\t\t#We delete previous set memberships and move to new set\n old_sets = harvesting_set_membership.dup\n old_sets.each { |s| self.remove_relationship(:is_member_of_collection, s) }\n sets.delete_if { |s| s == \"\"}.each { |s| self.add_relationship :is_member_of_collection, s }\n\tend",
"def apply_harvesting_set_membership(sets)\n\t\t#We delete previous set memberships and move to new set\n old_sets = harvesting_set_membership.dup\n old_sets.each { |s| self.remove_relationship(:is_member_of_collection, s) }\n sets.delete_if { |s| s == \"\"}.each { |s| self.add_relationship :is_member_of_collection, s }\n\tend",
"def rset; end",
"def valid_sets; end",
"def each_set\n \n end",
"def apply_set_membership(sets)\n\t\t#We delete previous set memberships and move to new set\n old_sets = set_membership.dup\n old_sets.each { |s| self.remove_relationship(:is_member_of, s) unless HULL_QUEUES.has_key?(s) }\n sets.delete_if { |s| s == \"\"}.each { |s| self.add_relationship :is_member_of, s }\n\tend",
"def hint(workingSet)\n setFound = false\n for i in workingSet\n for j in workingSet\n for k in workingSet\n if(!(i == k || j == k || i == k))\n setFound = VerifySet?(i,j,k)\n if(setFound)\n return i\n break\n end\n end\n end\n end\n end\n if(setFound == false)\n return nil\n end\nend",
"def better_sum1(arr, target) # this one is going to return true or false\n pairs = Set.new\n\n arr.each do |ele|\n if pairs.include?(ele)\n return true\n else\n pairs << target - ele\n end\n end\n false\nend",
"def make_union\n #prompts for name of first set\n puts \"Enter name of first set:\"\n set1name = gets\n #locates first set\n set1 = find_set(set1name.chomp)\n if set1 == nil\n #if it is not found, it ends the method\n return 0\n end\n #prompts for the name of the second set\n puts \"Enter name of second set:\"\n set2name = gets\n #locates the second set\n set2 = find_set(set2name.chomp)\n if set2 == nil\n #if it is not found, it ends the method\n return 0\n end\n\n #asks the user to name the new set\n puts \"Enter name for union set:\"\n newsetname = gets\n #for loop iterates through all existing sets in $current_sets\n i=0\n for i in 0..($current_sets.length-1)\n if $current_sets[i].setname == newsetname.chomp\n # if any set has the same name as the specified set name, it ends the method\n puts \"There is already a set with that name!\"\n return 0\n \n end\n end\n #calls unionset from the first set entered, and passes the second set entered as a parameter\n unionset = set1.union(set2, newsetname.chomp)\n #adds the new set to the list of current sets\n $current_sets.push(unionset)\n puts \"Union set created!\"\nend",
"def make_intersection\n #asks for the name of first set\n puts \"Enter name of first set:\"\n set1name = gets\n #locates the desired set\n set1 = find_set(set1name.chomp)\n if set1 == nil\n #if not found, ends the method\n return 0\n end\n #asks for the name of the second set\n puts \"Enter name of second set:\"\n set2name = gets\n #locates the desired set\n set2 = find_set(set2name.chomp)\n if set2 == nil\n #if not found, ends the method\n return 0\n end\n #asks for the name of the new set\n puts \"Enter name for intersection set:\"\n newsetname = gets\n #for loop to iterate through list of current sets\n i=0\n for i in 0..($current_sets.length-1)\n #if a set with the same name is found, it ends the method\n if $current_sets[i].setname == newsetname.chomp\n puts \"There is already a set with that name!\"\n return 0\n \n end\n end\n\n #calls the intersection method from the first set and passes the second set as a parameter\n interset = set1.intersection(set2, newsetname.chomp)\n #adds new intersection set to list of current sets\n $current_sets.push(interset)\n puts \"Intersection set created!\"\nend",
"def partition_set(s, universe)\n all_disjoint(s) \n s.union.size.must == universe.entries.length\n end",
"def better_sum?(arr, target)\n pair_set = Set.new\n\n arr.each do |ele|\n if pair_set.include?(ele)\n return true\n else\n pair_set << target - ele\n end\n end\n\n false\n\nend",
"def union(setone,settwo) \n #Find the number of elements , make root of the Tree with fewer nodes point to root of the tree with large node\n first=find(setone)\n second=find(settwo)\n\n if first.instance_of?(String) || second.instance_of?(String) then\n puts 'One of the Input is not a valid set'\n return\n end\n \n if first[1]>=second[1] then\n @store[settwo]=setone #settwo has more elements\n @store[first[0]]=second[1]+first[1]\n else\n @store[setone]=settwo\n @store[first[0]]=first[1]+second[1]\n end\n end",
"def union(other_set)\n new_set = @set\n # Create an array with elements that are members of either set\n other_set.set.each do |element|\n new_set.push(element)\n end\n Set.new(new_set)\n end",
"def print_all_combinations(selected_set, left_over_set)\ndebug(\"first #{selected_set} - left over #{left_over_set}\")\n left_over_set.each do |left_over|\n save(selected_set + [left_over])\n end\nend",
"def complemento(op)\n array_clases.to_set - op # ese - es el mensaje (sustraccion) entre 2 Set\n end",
"def get_sets\n result = []\n (0..(TAILLE_TAPIS + TAILLE_EXT*self.etendu - 3)).each do |a|\n ((a + 1)..(TAILLE_TAPIS + TAILLE_EXT*self.etendu - 2)).each do |b|\n ((b + 1)..(TAILLE_TAPIS + TAILLE_EXT*self.etendu - 1)).each do |c|\n if (is_a_set?([self.talon[self.tapis[a]], self.talon[self.tapis[b]], self.talon[self.tapis[c]]]))[0]\n result << [a, b, c]\n end\n end\n end\n end\n result\n end",
"def points_possible_on_set(set,args)\n c = {}\n [true,false].each { |online|\n [true,false].each { |extra_credit|\n c[[online,extra_credit]] = 0\n set.each { |stream_group|\n stream_group.each { |flag_group|\n flags,probs = flag_group\n is_online = (flags.has_key?(\"o\"))\n is_extra_credit = (flags.has_key?(\"*\")) || flags_contain_letter_in_string(flags,args['ec_if'])\n excluded = flags_contain_letter_in_string(flags,args['exclude_if'])\n if is_online==online && is_extra_credit==extra_credit && !excluded then\n probs.each { |g| # g is individualization group\n c[[online,extra_credit]] += 1 unless $has_solution[[g[0][0],g[0][1]]]\n }\n end\n }\n } # end loop over stream groups\n }\n }\n return c\nend",
"def change_set_fn\n -> f, g, prev, this {\n f.(Set.new(this) - Set.new(prev))\n g.(Set.new(prev) - Set.new(this))\n }.curry\n end",
"def check_special_sum(set)\n\n sums = Array.new\n # initialize the sums array with the set elements\n #set.each { |i| verify_no_sums(sums, i) }\n \n max = 2**set.size-1\n (1..max).each do |i|\n subset = generate_subset(set, i) \n puts \"subset: \" + subset.join(' ')\n sum = subset.inject(0) { |sum,j| sum += j }\n unless verify_no_sum(sums, sum)\n return false\n end\n end\n return true\nend",
"def set(values); end",
"def find_duplicates_set_approach(array)\n duplicates = []\n set = Set.new(array)\n \n set\n \nend",
"def naive(set)\n solutions = []\n indexes = (0..set.size-1).to_a\n\n Backtracker.generate do\n candidates { |a| indexes - a }\n solution? { |a| a.size == set.size }\n found_solution do |a| \n solution = a.map { |i| set[i] } \n solutions << solution unless solutions.include? solution\n end\n end\n\n return solutions\nend",
"def closure item_set\n\t\tresult = item_set\n\t\ttemp = nil\n\t\t#continue adding to closure set until it doesn't change\n\t\tuntil temp == result\n\t\t\t#create deep copy of temp\n\t\t\ttemp = Marshal.load(Marshal.dump(result))\n\t\t\ttemp.keys.each do |lhs|\n\t\t\t\ttemp[lhs].each do |rhs|\n\t\t\t\t\tif rhs.index(@marker)\n\t\t\t\t\t\tnext_val = rhs[rhs.index(@marker)+1]\n\t\t\t\t\t\tif non_terminals.include?(next_val)\n\t\t\t\t\t\t\t@production_rules[next_val].each do |rhs|\n\t\t\t\t\t\t\t\t#create temporary rhs so we don't modify the production rules with unshift\n\t\t\t\t\t\t\t\tt_rhs = rhs.clone\n\t\t\t\t\t\t\t\tt_rhs = t_rhs.unshift(@marker)\n\t\t\t\t\t\t\t\tif result[next_val]\n\t\t\t\t\t\t\t\t\tdup = false\n\t\t\t\t\t\t\t\t\tresult[next_val].each do |r|\n\t\t\t\t\t\t\t\t\t\tif r.eql?(t_rhs)\n\t\t\t\t\t\t\t\t\t\t\tdup = true\n\t\t\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\tif !dup\n\t\t\t\t\t\t\t\t\t\tresult[next_val].push(t_rhs)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tresult[next_val] = [t_rhs]\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\treturn result\n\tend",
"def subarray_bitwise_o_rs(a)\n result_set = Set.new()\n a.size.times do |i|\n (1..a.size-i).each do |length|\n subarray = a[i, length]\n #puts subarray.inspect\n result = subarray.reduce(0) do |bor, elem|\n bor | elem\n end\n #puts result\n result_set << result\n end\n end\n result_set.size\nend",
"def multipleSet(n)\n return (n..99).step(n).to_a.to_set\nend",
"def supplementaryCase records #generate the supplementary set for selected records \n num=@records.recordsArr[0].valuesArr.length\n \n recordset = Records.new\n tagset = []\n # add the @records and selected records (just the inputparameter 'records' into the recordset ) \n for i in 0...@records.recordsArr.length do #add the @records to recordset and set tagset=1\n recordset.recordsArr << @records.recordsArr[i]\n tagset << 1\n end\n for j in 0...records.recordsArr.length do #add the records to recordset and set tagset=0\n recordset.recordsArr << records.recordsArr[j]\n tagset << 0\n end\n\n sum = @parameters.paramsArr.length*(@parameters.paramsArr.length-1)/2\n print 'sum='\n puts sum\n\n\n\n for i in 0...recordset.recordsArr.length do\n isexist=0\n for h in 0...@parameters.paramsArr.length do\n for k in h+1 ...@parameters.paramsArr.length do\n for j in i+1 ...recordset.recordsArr.length do\n if recordset.recordsArr[i].valuesArr[h]== recordset.recordsArr[j].valuesArr[h] and recordset.recordsArr[i].valuesArr[k] == recordset.recordsArr[j].valuesArr[k]\n isexist+=1 \n end\n end\n end\n end\n if isexist >=sum\n tagset[i]=0\n end \n end\n result = Records.new\n for m in 0...tagset.length do\n if tagset[m]==1\n result.recordsArr << recordset.recordsArr[m]\n end\n end\n return result\n end",
"def get_power_set_1(set)\n\t(0..set.length).map {|i| set.combination(i).to_a}.flatten(1)\nend",
"def getSet( s, x=1 )\n return [] if (x2 = x**2) > s\n return [[x]] if x2 == s\n getSet( s-x2, x+1 ).each { |a| a.unshift x }.concat getSet( s, x+1 )\nend",
"def assosi(minsupp = 2)\n # create 1-frequent-set\n c1 = Product.all.permutation(1).to_a\n l1 = c1.reject { |fi| trans_containing(fi) < minsupp}\n # find k-frequent-set, first elem is nil because k = 2\n l = [nil, l1]\n k = 2\n c = []\n while not(l[k-1].empty?)\n # find candidates\n b = l[k-1].flatten.to_set.to_a\n c = b.reduce([]) do |accu, extension|\n accu + l[k-1].reduce([]) do |accu2, canidate|\n if not(canidate.include?(extension)) then\n accu2 << (canidate + [extension])\n else\n accu2\n end\n end\n end\n # remove dubs\n c = c.collect {|e| e.to_set }.to_set.collect {|e| e.to_a }.to_a\n # select minsupps\n l[k] = c.reject { |canidate| trans_containing(canidate) < minsupp }\n k = k + 1\n end\n #first elem is nil; last elem is an empty list\n l.shift; l.pop\n low_fatten(l)\n end",
"def fivesSet(s)\n return (s.find_all {|i| i%5 == 0}).to_set\nend",
"def set_intersection set1, set2 \n\tresult \t\t\t= [];\n\tsec_index = 0 \n\tfirst_index = 0\n\n\twhile sec_index < set2.size && first_index < set1.size do \n\t\tif set1[first_index].to_i > set2[sec_index].to_i\n\t\t\tsec_index += 1\n\t\telsif set1[first_index].to_i == set2[sec_index].to_i\n\t\t\tresult << set1[first_index]\n\t\t\tfirst_index += 1\n\t\telsif set1[first_index].to_i < set2[sec_index].to_i\n\t\t\tfirst_index += 1\n\t\tend\n\tend\n\treturn result\nend",
"def valid_sudoku(table)\n # seen_set = Set.new()\n # for i in \nend",
"def MakeSet(dset, x)\n unless dset[x] \n # add x to the disjoint-set tree\n dset[x] = {parent: x, size:1}\n end\nend",
"def intersection(set1, set2)\r\n\t# set1 and set2 are arrays\r\n\t# return the intersection\r\nend",
"def mset(*args); end",
"def set\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 53 )\n\n\n return_value = SetReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __K_SET284__ = nil\n __LLAIZQ285__ = nil\n __K_VALUE286__ = nil\n __LLADER287__ = nil\n\n\n tree_for_K_SET284 = nil\n tree_for_LLAIZQ285 = nil\n tree_for_K_VALUE286 = nil\n tree_for_LLADER287 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 243:3: K_SET LLAIZQ K_VALUE LLADER\n __K_SET284__ = match( K_SET, TOKENS_FOLLOWING_K_SET_IN_set_1202 )\n if @state.backtracking == 0\n tree_for_K_SET284 = @adaptor.create_with_payload( __K_SET284__ )\n @adaptor.add_child( root_0, tree_for_K_SET284 )\n\n end\n\n __LLAIZQ285__ = match( LLAIZQ, TOKENS_FOLLOWING_LLAIZQ_IN_set_1204 )\n if @state.backtracking == 0\n tree_for_LLAIZQ285 = @adaptor.create_with_payload( __LLAIZQ285__ )\n @adaptor.add_child( root_0, tree_for_LLAIZQ285 )\n\n end\n\n __K_VALUE286__ = match( K_VALUE, TOKENS_FOLLOWING_K_VALUE_IN_set_1206 )\n if @state.backtracking == 0\n tree_for_K_VALUE286 = @adaptor.create_with_payload( __K_VALUE286__ )\n @adaptor.add_child( root_0, tree_for_K_VALUE286 )\n\n end\n\n __LLADER287__ = match( LLADER, TOKENS_FOLLOWING_LLADER_IN_set_1208 )\n if @state.backtracking == 0\n tree_for_LLADER287 = @adaptor.create_with_payload( __LLADER287__ )\n @adaptor.add_child( root_0, tree_for_LLADER287 )\n\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 53 )\n\n\n end\n\n return return_value\n end",
"def each(&block)\n to_set.each(&block)\n end",
"def intersection(other_set)\n new_set = []\n # Fill our empty array with elements that are members of both sets\n other_set.set.each do |element|\n new_set.push(element) if @set.include?(element)\n end\n Set.new(new_set)\n end",
"def findPairs(set)\n 0.upto(@size-1) do |n|\n (n+1).upto(@size-1) do |m|\n if (set[n].possible.size == 2 && set[n].possible ==\nset[m].possible)\n eliminateExcept(set, [m,n], set[n].possible)\n end\n end\n end\n end",
"def make_set(x,y,z)\n return [x,y,z]\n end",
"def problem_106\n a = [1,2,3,4]\n a = [1,2,3,4,5,6,7]\n a = [1,2,3,4,5,6,7,8,9,10,11,12] \n \n num = 0\n seen = {}\n # Don't do length of 1, they are ordered\n # Because they are size ordered, and 2 smalls are bigger than a large\n 2.upto(a.length/2) do |n|\n puts \"n = #{n}\"\n a.combination(n) do |set_a|\n b = a - set_a\n break if b.length < n\n b.combination(n) do |set_b|\n key = [set_a,set_b].sort\n next if seen[key]\n seen[key] = true\n index = 0\n state = 0\n 0.upto(set_a.length-1) do |i|\n break unless set_b[i] && set_a[i]\n if set_a[i] < set_b[i]\n state -= 1\n else\n state += 1\n end\n end\n\n# print \"#{set_a.inspect} #{set_b.inspect} #{state}\"\n if state.abs <= (set_a.length - 2) ||\n (state < 0 && set_a.last > set_b.last) ||\n (state > 0 && set_a.first < set_b.first)\n# puts \" good\"\n num += 1\n else\n# puts \"\"\n end\n end\n end\n end\n num\nend",
"def unique(integers)\n integers.to_set.to_a\nend",
"def atomic_array_add_to_sets\n @atomic_array_add_to_sets ||= {}\n end",
"def to_set\n require 'set' unless defined?(::Set)\n each.to_set\n end",
"def question_two\n set = SetOfStacks.new(5)\n set.push(3)\n set.push(2)\n set.push(5)\n set.push(1)\n set.push(7)\n set.push(4)\n set.push(2)\n set.push(8)\n set.push(2)\n set.push(1)\n set.push(3)\n set.push(5)\n set.pop\n set.pop_at(1)\n set\nend",
"def make_cartesian\n #asks for name of the first set\n puts \"Enter name of first set:\"\n set1name = gets\n #locates the desired set\n set1 = find_set(set1name.chomp)\n if set1 == nil\n #if not found, ends the method\n return 0\n end\n #asks for name of second set\n puts \"Enter name of second set:\"\n set2name = gets\n #locates desired set\n set2 = find_set(set2name.chomp)\n if set2 == nil\n #if not ends the method\n return 0\n end\n\n #asks the user to name the new set\n puts \"Enter name for cartesian set:\"\n newsetname = gets\n #for loop iterates through current sets \n i=0\n for i in 0..($current_sets.length-1)\n if $current_sets[i].setname == newsetname.chomp\n #if a set already has that name it ends the method\n puts \"There is already a set with that name!\"\n return 0\n \n end\n end\n\n #creates new set by instantiating the cartesian method from the first set, and passing the other set as a parameter\n cartset = set1.cartesian(set2, newsetname.chomp)\n #adds new set to the list of current sets\n $current_sets.push(cartset)\n puts \"Cartesian Product set created!\"\nend",
"def items_for_set(set, opts={})\n opts.merge!(default_options)\n\n suggestions = Hash.new(0.0)\n\n set.each do |item|\n related = similar_related_to(item, opts)\n related.each { |rel| suggestions[rel[0]] += rel[1] unless\n set.include? rel[0] }\n end\n\n suggestions = suggestions.map { |label, score| [label, score / set.length] }\n suggestions.sort_by { |sug| sug[1] }.reverse\n end",
"def add_each_to_set(adds)\n view.update_many(\"$addToSet\" => collect_each_operations(adds))\n end",
"def match_maker(criteria, *sets)\n #go through each of the sets, in bulk of two\n score = []\n i = 0\n\n while i < sets.length do\n score << false if criteria == true and !!sets[i] == !!sets[i+1]\n score << true if criteria == false and !!sets[i] == !!sets[i+1]\n score << true if criteria == true and !!sets[i] != !!sets[i+1]\n score << false if criteria == false and !!sets[i]!= !!sets[i+1]\n i += 2\n end\n return score\nend",
"def test_boolean_sets\n Sets.rcreate(@alice, :name => 'and')\n Sets.rcreate(@alice, :name => 'or')\n @alice.items[0].add_tag '|'\n @alice.items[1].add_tag '&'\n @alice.items(\n \"sets.name\" => 'and',\n \"rating\" => ['>=', 4],\n :order_by => [[:rating, :desc]]\n )\n end",
"def powerset(arr)\n arr.inject([Set.new].to_set) do |powerset, el|\n new_powerset = Set.new\n powerset.each do |subset|\n new_powerset << subset\n new_powerset << subset + [el]\n end\n new_powerset\n end\n end",
"def find_set(set_name)\n #for loop loops through each element of $current_sets\n i=0\n for i in 0..($current_sets.length-1)\n #checks if the name of the set at i is the same as the desired set\n if $current_sets[i].setname == set_name\n #returns the set if it is found\n return $current_sets[i]\n end\n end\n #otherwise puts that the set is not found\n puts \"Set not found!\"\n return nil\n\nend",
"def getASAry(set)\n ary = Array.new\n set.each{|k,v|\n if v then ary.push(k.to_i) end\n }\n ary.sort!\nend",
"def get_primer_set(ops, handle)\n # primers - need to find the collection if the Primer is a sub-item\n primers = ops.map do |op|\n if op.input(handle).object_type.name == SUB_ITEM\n Item.find(op.input(handle).item.get(\"collection\"))\n else\n op.input(handle).item\n end\n end\n\n primers.uniq\n end",
"def add_all(set)\n raise NotImplementedError\n end",
"def test_find_words_multiple\n words = ['apple','candy','bat']\n dict = Set['apple','bat','candy','cat']\n assert_equal Set[\"apple\",\"candy\"], @grapher.find_words(words, dict)\n end",
"def codepoints(*features)\n features = setify(*features)\n @sets[features] || (raise FeatureError, \"No such set #{features.inspect}\")\n end",
"def set; end",
"def set; end",
"def process_valueset\n puts \"Processing #{@valueset_model.url}\"\n include_set = Set.new\n @valueset_model.compose.include.each do |include|\n # Cumulative of each include\n include_set.merge(get_code_sets(include))\n end\n @valueset_model.compose.exclude.each do |exclude|\n # Remove excluded codes\n include_set.subtract(get_code_sets(exclude))\n end\n @valueset = include_set\n end",
"def subsets(set)\n return [[]] if set == []\n \n res= [[]]\n \n 0.upto set.length-1 do |i|\n subsets(set[(i+1)..-1]).each do |subsubset|\n res << [set[i]] + subsubset\n end\n end\n \n res\nend",
"def difference(other_set)\n new_set = @set\n # Delete elements from our array that are in the other set\n other_set.set.each do |element|\n new_set.delete(element)\n end\n Set.new(new_set)\n end",
"def setByApplyingConditionsToSet(set)\n if @predicate\n if set.is_a?(NSOrderedSet)\n # TODO not the most efficient way of doing this when there are also sort descriptors\n filtered = set.array.filteredArrayUsingPredicate(@predicate)\n set = NSOrderedSet.orderedSetWithArray(filtered)\n else\n set = set.filteredSetUsingPredicate(@predicate)\n end\n end\n\n unless @sortDescriptors.empty?\n set = set.set if set.is_a?(NSOrderedSet)\n sorted = set.sortedArrayUsingDescriptors(@sortDescriptors)\n set = NSOrderedSet.orderedSetWithArray(sorted)\n end\n\n set\n end",
"def getset(key); end",
"def union(anotha_one)\n new_set = MySet.new\n for i in 0...secret_size\n new_set.add(@da_set.get(i)) unless @da_set.get(i) == nil\n end\n\n for i in 0...anotha_one.secret_size\n # anotha_one.element_at_index(i) == nil ? nil : new_set.contains?(anotha_one.element_at_index(i)) ? nil : new_set.add(anotha_one.element_at_index(i))\n\n unless anotha_one.element_at_index(i) == nil\n new_set.add(anotha_one.element_at_index(i)) unless new_set.contains?(anotha_one.element_at_index(i))\n end\n end\n\n return new_set\n end",
"def symmetric_difference(set1, set2)\n symarray=[]\n for object in set1\n if set2.include?(object)\n\n else\n symarray.push(object)\n end\n end\n \n for object in set2\n if set1.include?(object)\n \n else\n symarray.push(object)\n end\n end\n\n return symarray\n\t# set1 and set2 are arrays\n\t# return the symmetric difference\nend",
"def <=>(set)\n return unless set.is_a?(Set)\n\n case size <=> set.size\n when -1 then -1 if proper_subset?(set)\n when +1 then +1 if proper_superset?(set)\n else 0 if self.==(set)\n end\n end",
"def set(sets)\n view.update_many(\"$set\" => collect_operations(sets))\n end",
"def subsets(array)\n\nend",
"def subsets(array)\n\nend",
"def subsets(array)\n\nend",
"def answer(input_nums)\n [2,3].each do |set_size|\n all_combinations = input_nums.combination(set_size)\n\n target_set = all_combinations.to_a.find do |x|\n x.sum == 2020\n end\n\n puts \"Answer for set size #{set_size} is #{target_set.reduce(:*)}\"\n end\nend",
"def permutation (array)\n# yields permutation set WITH duplicates\nend",
"def total_set\n self.inject(0) { |a, bucket| a += bucket.zero? ? 0 : 1; a }\n end",
"def normalize(set)\n set.map { |n| n - set.min }\n end",
"def pairs(k, arr)\n ha = {}\n pairs = Set.new\n count = 0\n arr.to_set.each do |element|\n ha[element] = 1\n end\n arr.to_set.each do |element|\n sum = (k + element)\n if ha.key? sum\n count += 1\n end\n end\n count\nend",
"def next_items_in_set(set)\n set.items.select{|item| item.rule.name == @rule.productions[@dot]}\n end",
"def valid?(set); end",
"def subsets_with_dup(nums)\n result = []\n nums.sort!\n subsets_helper(nums, [], result, 0, {})\n result\nend",
"def union(other)\n set = MyHashSet.new\n (to_a + other.to_a).uniq.each { |el| set.insert(el) }\n set\n end",
"def intersection3(arr1, arr2)\n intersection = []\n set_1 = arr1.to_set\n arr2.each do |el|\n intersection << el if set_1[el]\n end\n\n intersection\nend",
"def _get_keywords_set_int_v_1_55()\n \n result = []\n \n genre_int = Genre.find(:all, :conditions => {:code => 'int'})[0]\n \n categories = Category.find(:all, :conditions => {:genre_id => genre_int.id})\n \n #debug\n if categories != nil\n \n write_log(\n @log_path,\n \"categories.size => #{categories.size}\", \n # __FILE__,\n __FILE__.split(\"/\")[-1],\n __LINE__.to_s)\n\n else\n write_log(\n @log_path,\n \"categories => nil\", \n # __FILE__,\n __FILE__.split(\"/\")[-1],\n __LINE__.to_s) \n end\n \n if categories != nil and categories.size > 0\n \n kws1 = KeyWordSet.new\n kws1.category = 'China'\n kws1.keywords = '中国 日中'\n \n kws2 = KeyWordSet.new\n kws2.category = 'Europe'\n # kws2.keywords = '米国 アメリカ'\n kws2.keywords = '欧州 イギリス ドイツ フランス ロシア'\n \n result.push(kws1)\n result.push(kws2)\n \n else\n \n kws1 = KeyWordSet.new\n kws1.category = 'China'\n kws1.keywords = '中国 日中'\n \n kws2 = KeyWordSet.new\n kws2.category = 'US'\n # kws2.keywords = '米国 アメリカ'\n kws2.keywords = '米国 アメリカ オバマ 米選挙'\n \n result.push(kws1)\n result.push(kws2)\n \n end\n \n \n return result\n \n end",
"def subsets(set)\n return [[]] if set.empty?\n smaller_set = set.take(set.count-1)\n smaller_subsets = subsets(smaller_set)\n bigger_subsets = []\n smaller_subsets.each do |smaller_subset|\n bigger_subsets << smaller_subset + [set.last]\n end\n\n smaller_subsets + bigger_subsets\nend",
"def difference_of_sets(set1, set2)\n i = 0\n j = 0\n result = Array.new\n # Iterate through the list, not adding elements to the result if they are also found in the second list\n while i < set1.length && j < set2.length\n test = compare_movies(set1[i], set2[j])\n if test == 0\n i += 1\n j += 1\n elsif test == -1\n result << set1[i]\n i += 1\n else\n j += 1\n end\n end\n while i < set1.length\n result << set1[i]\n i += 1\n end\n # Return the result\n result\nend",
"def reduce(set)\n set.map { |n| Scale::Degree.reduce(n) }\n end",
"def convert(y)\n y.chars.to_a.to_set\nend",
"def does_set_exist!\n\t\ttrue_set = []\n\t\twhile true_set.length == 0 do\n\t\t\tpossibleCombination = @board.combination(3).to_a\n\t\t\tpossibleCombination.each do |setOf3| \n\t\t\t\tif Board.actual_set?(setOf3)\n\t\t\t\t\ttrue_set = setOf3\n\t\t\t\t\tbreak\n\t\t\t\tend \n\t\t\tend\n\t\t\tif true_set.length == 0\n\t\t\t\tadd_cards\n\t\t\tend\n\t\tend\n\t\treturn true_set\n\tend",
"def reduce_solution_set(secret_code)\n clue = Clues.new(guess: @guess, code: secret_code).keys\n @solution_set = @solution_set.map do |num|\n Clues.new(guess: num.digits.reverse, code: @guess).keys == clue ? num : nil\n end\n # remove the nil values just added\n @solution_set = @solution_set.compact\n end",
"def exercise_method\n\n # => All jobs\n @old = Job.all\n @jobs=Set.new\n @jobs=@old\n @result=Set.new\n # => let remove the singles, independent one\n @jobs.each do |f| \n if f.predecessor_id.nil? && f.successor_id.nil?\n if @result.add?(f).nil?\n return 'Error 1'\n end\n @jobs.delete(f)\n end\n if f.predecessor_id==f.id || f.successor_id==f.id\n raise \"#{f.inspect}\"\n \n return 'Error 0'\n end\n end\n\n # => following successors\n @jobs.each do |f|\n if f.predecessor_id.nil? \n loop do\n if @result.empty?\n @result.add(f)\n elsif @result.add?(f).nil?\n return 'Error 2'\n end\n @jobs.delete(f)\n if !f.successor_id.nil?\n f = Job.find(f.successor_id)\n else\n f=nil\n end\n break if !f \n end\n end\n end\n \n if @jobs.any?\n return 'Error 3'\n end\n return @result\n end",
"def &(other)\n (to_set - other.to_set).inject(clone) do |copy, e|\n copy.delete e\n copy\n end\n end",
"def sum_of_cubes(a, b)\n set = (a..b) {|num| num**3}\n \nend",
"def merge_sets(set1, set2)\n merged_set = Array.new\n last_movie_added = Movie.new\n while set1.length > 0 && set2.length > 0\n test = compare_movies set1[0], set2[0]\n if test == -1\n if (compare_movies set1[0], last_movie_added) != 0\n merged_set << set1[0]\n end\n set1.delete_at 0\n elsif test == 1\n if (compare_movies set2[0], last_movie_added) != 0\n merged_set << set2[0]\n end\n set2.delete_at 0\n else\n if (compare_movies set1[0], last_movie_added) != 0\n merged_set << set1[0]\n end\n set1.delete_at 0\n set2.delete_at 0\n end\n end\n if set1.length > 0\n while set1.length > 0\n merged_set << set1[0]\n set1.delete_at 0\n end\n elsif set2.length > 0\n while set2.length > 0\n merged_set << set2[0]\n set2.delete_at 0\n end\n end\n merged_set\nend",
"def two_sum(arr) #o(ns)\n set = Set.new\n arr.each{|el| set << el}\n arr.select{|el| set.include?(-1 * el)}\nend",
"def codes_in_code_set(code_set)\n matching = {}\n codes.keys.each do |code_system|\n matching_codes = []\n matching[code_system] = matching_codes\n all_codes_in_system = code_set.find_all {|set| set['set'] == code_system}\n all_codes_in_system.each do |codes_in_system|\n matching_codes.concat codes_in_system['values'] & codes[code_system]\n end\n end\n matching\n end",
"def combine_lists set\n # get all possible sets of the given values\n combinations = set.flatten.combination(set.size)\n # reject any that contain more than one value from a given list\n combinations.reject do |combination|\n min_size = combination.size - 1\n set.any? do |list|\n (combination - list).size < min_size\n end\n end\n end",
"def matching_sets(path, type); end",
"def produce_set(project)\n set = Set.new\n puts \"Context method:\" if @verbose\n \n points_map = points_map(project)\n \n # look into points map\n points_map.each(@threshold).each do |pair,value|\n f = pair.first\n s = pair.second\n id_i = NodeId.from_node(f)\n id_j = NodeId.from_node(s)\n set << CrossLanguageRelation.new([id_i,id_j])\n end\n\n puts \"Context method, set produced: #{set.count} elements\" if @verbose\n set\n end",
"def produce_set(project)\n set = Set.new\n puts \"Tversky method:\" if @verbose\n block = Proc.new do |ni,nj|\n context_ni = context(ni).values & project.shared_ids\n context_nj = context(nj).values & project.shared_ids \n j = tversky_coefficient(context_ni,context_nj)\n if j>=@threshold\n id_i = NodeId.from_node(ni)\n id_j = NodeId.from_node(nj)\n puts \" * '#{id_i.file}':#{id_i.index} -> '#{id_j.file}':#{id_j.index}\" if @verbose\n set << CrossLanguageRelation.new([id_i,id_j])\n end\n end \n project.iter_over_shared_ids_instances {|ni,nj| block.call(ni,nj) } \n puts \"Tversky method, set produced: #{set.count} elements\" if @verbose\n set\n end",
"def test_find_words_valid\n words = ['apple','bat','cat']\n dict = Set['apple','bat','cat']\n assert_equal Set[\"apple\"], @grapher.find_words(words, dict)\n end"
] |
[
"0.7116957",
"0.6758597",
"0.6758597",
"0.6477536",
"0.64008814",
"0.6383874",
"0.6361601",
"0.63207406",
"0.6299085",
"0.62765026",
"0.6194148",
"0.6178563",
"0.61028564",
"0.60945547",
"0.60883653",
"0.60755897",
"0.6050743",
"0.5999694",
"0.5980863",
"0.59770066",
"0.59396297",
"0.5938774",
"0.5924277",
"0.5921576",
"0.5917746",
"0.591769",
"0.59167445",
"0.5910978",
"0.5904714",
"0.5896107",
"0.5894945",
"0.58734804",
"0.58543783",
"0.5831373",
"0.58307666",
"0.582966",
"0.5812487",
"0.57791615",
"0.5769472",
"0.5760491",
"0.5747861",
"0.57465035",
"0.57448816",
"0.5743422",
"0.5742824",
"0.57373863",
"0.57326317",
"0.572462",
"0.5724482",
"0.5724299",
"0.57174194",
"0.5716022",
"0.5709079",
"0.5703534",
"0.5693394",
"0.569017",
"0.5690117",
"0.568542",
"0.5674042",
"0.56709564",
"0.56709564",
"0.56609267",
"0.5654627",
"0.5652651",
"0.5650459",
"0.56501436",
"0.5645875",
"0.5642629",
"0.5641932",
"0.56413764",
"0.5637048",
"0.5637048",
"0.5637048",
"0.5633583",
"0.5631371",
"0.5629539",
"0.5627829",
"0.562315",
"0.56200546",
"0.56194025",
"0.5616198",
"0.5613773",
"0.56104606",
"0.56030715",
"0.560281",
"0.5599983",
"0.5591305",
"0.55887467",
"0.5586276",
"0.558349",
"0.5577432",
"0.5574898",
"0.55698806",
"0.55653137",
"0.5563764",
"0.5560864",
"0.5559258",
"0.55537575",
"0.55454284",
"0.5534115",
"0.55231184"
] |
0.0
|
-1
|
codewars kata: next version
|
def nextVersion(version)
return version.to_i.next.to_s if !version.include? '.'
top, bottom = version.split('.', 2)
bottom = bottom.split('.').join
new_bottom = bottom.to_i.next.to_s
if new_bottom.length > bottom.length
top = top.to_i.next
new_bottom = new_bottom.chars.drop(1).join
end
[top, new_bottom.chars.join('.')].join '.'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def king_richard_iii; end",
"def jack_handey; end",
"def solution4(input)\n end",
"def anchored; end",
"def koan_4\nend",
"def p15\n\t\nend",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def villian; end",
"def koan_3\nend",
"def strain; end",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def romeo_and_juliet; end",
"def alg; end",
"def superweening_adorningly(counterstand_pyrenomycetales)\n end",
"def suivre; end",
"def challenge; end",
"def probers; end",
"def silly_adjective; end",
"def slop!; end",
"def slop!; end",
"def scientist; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def succ!() end",
"def verdi; end",
"def terpene; end",
"def mambo_no_5; end",
"def bizet; end",
"def buzzword; end",
"def buzzword; end",
"def schumann; end",
"def bellini; end",
"def tongue_twister; end",
"def intensifier; end",
"def succ(source); end",
"def schubert; end",
"def solution1(input)\n return \"Not implemented!\"\nend",
"def kcode() end",
"def how_it_works\r\n end",
"def problem_8\nend",
"def code_point; end",
"def stylish_chef\n best_hairstyle = \"Guy Fieri\"\n return \"Martha Stewart\"\n \"Guy Fieri\"\nend",
"def branch; end",
"def hook_solution?(a); end",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def herald; end",
"def k8805_a()\n return 'B'\nend",
"def stderrs; end",
"def make; end",
"def succ() end",
"def succ() end",
"def succ() end",
"def next() end",
"def next() end",
"def berlioz; end",
"def ibu; end",
"def problem_14\nend",
"def phase; end",
"def\n \nend\n\n\n# 6. sentence_maker refactored solution",
"def appraisals; end",
"def appraisals; end",
"def formation; end",
"def token!\n # at line 1:8: ( T__80 | T__81 | T__82 | EOL | LPAR | RPAR | LLAIZQ | LLADER | COMA | PUNTO | CORDER | CORIZQ | DELIM | ASIGNACION | DOUBLEDOT | COMILLA | OP_REL | OP_ARI | OP_LOG | K_ACCIONARCHIVO | K_ACCIONARREGLO | K_PACKAGE | K_CLASS | K_END | K_DEF | K_VAR | K_REQUIRE | K_IMPLEMENTS | K_EXTENDS | K_IMPRIMIR | K_CONVERSION | K_ASIGNACION | K_RETORNO | K_ACCIONSYS | K_INTERFACE | K_IF | K_TIMES | K_DO | K_EACH | K_ELSE | K_INVOKE | K_NEW | TIPO | K_REFERENCIA | K_INSPECCIONAR | K_MATEMATICA | K_NUM | K_RESIZE | K_ORDENAR | ModoOrd | K_BUSQUEDA | K_TIPOBUSQUEDA | K_WHERE | K_SPLIT | K_BEGIN | K_DIR | K_UNION | K_VISIBILIDAD | K_MODIFICADOR | K_ARRAY | K_PROPIEDAD | K_GET | K_SET | K_VALUE | K_INITIALIZE | K_FUNC | K_VOID | HexLiteral | DecimalLiteral | OctalLiteral | WS | LINE_COMMENT | Identificador )\n alt_28 = 73\n alt_28 = @dfa28.predict( @input )\n case alt_28\n when 1\n # at line 1:10: T__80\n t__80!\n\n\n when 2\n # at line 1:16: T__81\n t__81!\n\n\n when 3\n # at line 1:22: T__82\n t__82!\n\n\n when 4\n # at line 1:28: EOL\n eol!\n\n\n when 5\n # at line 1:32: LPAR\n lpar!\n\n\n when 6\n # at line 1:37: RPAR\n rpar!\n\n\n when 7\n # at line 1:42: LLAIZQ\n llaizq!\n\n\n when 8\n # at line 1:49: LLADER\n llader!\n\n\n when 9\n # at line 1:56: COMA\n coma!\n\n\n when 10\n # at line 1:61: PUNTO\n punto!\n\n\n when 11\n # at line 1:67: CORDER\n corder!\n\n\n when 12\n # at line 1:74: CORIZQ\n corizq!\n\n\n when 13\n # at line 1:81: DELIM\n delim!\n\n\n when 14\n # at line 1:87: ASIGNACION\n asignacion!\n\n\n when 15\n # at line 1:98: DOUBLEDOT\n doubledot!\n\n\n when 16\n # at line 1:108: COMILLA\n comilla!\n\n\n when 17\n # at line 1:116: OP_REL\n op_rel!\n\n\n when 18\n # at line 1:123: OP_ARI\n op_ari!\n\n\n when 19\n # at line 1:130: OP_LOG\n op_log!\n\n\n when 20\n # at line 1:137: K_ACCIONARCHIVO\n k_accionarchivo!\n\n\n when 21\n # at line 1:153: K_ACCIONARREGLO\n k_accionarreglo!\n\n\n when 22\n # at line 1:169: K_PACKAGE\n k_package!\n\n\n when 23\n # at line 1:179: K_CLASS\n k_class!\n\n\n when 24\n # at line 1:187: K_END\n k_end!\n\n\n when 25\n # at line 1:193: K_DEF\n k_def!\n\n\n when 26\n # at line 1:199: K_VAR\n k_var!\n\n\n when 27\n # at line 1:205: K_REQUIRE\n k_require!\n\n\n when 28\n # at line 1:215: K_IMPLEMENTS\n k_implements!\n\n\n when 29\n # at line 1:228: K_EXTENDS\n k_extends!\n\n\n when 30\n # at line 1:238: K_IMPRIMIR\n k_imprimir!\n\n\n when 31\n # at line 1:249: K_CONVERSION\n k_conversion!\n\n\n when 32\n # at line 1:262: K_ASIGNACION\n k_asignacion!\n\n\n when 33\n # at line 1:275: K_RETORNO\n k_retorno!\n\n\n when 34\n # at line 1:285: K_ACCIONSYS\n k_accionsys!\n\n\n when 35\n # at line 1:297: K_INTERFACE\n k_interface!\n\n\n when 36\n # at line 1:309: K_IF\n k_if!\n\n\n when 37\n # at line 1:314: K_TIMES\n k_times!\n\n\n when 38\n # at line 1:322: K_DO\n k_do!\n\n\n when 39\n # at line 1:327: K_EACH\n k_each!\n\n\n when 40\n # at line 1:334: K_ELSE\n k_else!\n\n\n when 41\n # at line 1:341: K_INVOKE\n k_invoke!\n\n\n when 42\n # at line 1:350: K_NEW\n k_new!\n\n\n when 43\n # at line 1:356: TIPO\n tipo!\n\n\n when 44\n # at line 1:361: K_REFERENCIA\n k_referencia!\n\n\n when 45\n # at line 1:374: K_INSPECCIONAR\n k_inspeccionar!\n\n\n when 46\n # at line 1:389: K_MATEMATICA\n k_matematica!\n\n\n when 47\n # at line 1:402: K_NUM\n k_num!\n\n\n when 48\n # at line 1:408: K_RESIZE\n k_resize!\n\n\n when 49\n # at line 1:417: K_ORDENAR\n k_ordenar!\n\n\n when 50\n # at line 1:427: ModoOrd\n modo_ord!\n\n\n when 51\n # at line 1:435: K_BUSQUEDA\n k_busqueda!\n\n\n when 52\n # at line 1:446: K_TIPOBUSQUEDA\n k_tipobusqueda!\n\n\n when 53\n # at line 1:461: K_WHERE\n k_where!\n\n\n when 54\n # at line 1:469: K_SPLIT\n k_split!\n\n\n when 55\n # at line 1:477: K_BEGIN\n k_begin!\n\n\n when 56\n # at line 1:485: K_DIR\n k_dir!\n\n\n when 57\n # at line 1:491: K_UNION\n k_union!\n\n\n when 58\n # at line 1:499: K_VISIBILIDAD\n k_visibilidad!\n\n\n when 59\n # at line 1:513: K_MODIFICADOR\n k_modificador!\n\n\n when 60\n # at line 1:527: K_ARRAY\n k_array!\n\n\n when 61\n # at line 1:535: K_PROPIEDAD\n k_propiedad!\n\n\n when 62\n # at line 1:547: K_GET\n k_get!\n\n\n when 63\n # at line 1:553: K_SET\n k_set!\n\n\n when 64\n # at line 1:559: K_VALUE\n k_value!\n\n\n when 65\n # at line 1:567: K_INITIALIZE\n k_initialize!\n\n\n when 66\n # at line 1:580: K_FUNC\n k_func!\n\n\n when 67\n # at line 1:587: K_VOID\n k_void!\n\n\n when 68\n # at line 1:594: HexLiteral\n hex_literal!\n\n\n when 69\n # at line 1:605: DecimalLiteral\n decimal_literal!\n\n\n when 70\n # at line 1:620: OctalLiteral\n octal_literal!\n\n\n when 71\n # at line 1:633: WS\n ws!\n\n\n when 72\n # at line 1:636: LINE_COMMENT\n line_comment!\n\n\n when 73\n # at line 1:649: Identificador\n identificador!\n\n\n end\n end",
"def op; end",
"def codes; end",
"def generate_comprehensive\n\n end",
"def gounod; end",
"def next!() end",
"def pass; end",
"def pass; end",
"def passes; end",
"def passes; end",
"def main; end",
"def token!\n # at line 1:8: ( T__30 | T__31 | T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | T__41 | T__42 | T__43 | T__44 | T__45 | T__46 | T__47 | T__48 | T__49 | T__50 | T__51 | T__52 | T__53 | T__54 | INTEGER | FLOAT | BOOLEAN | STRING | CHAR | INIT | OPEN | CLOSE | TYPE_INT | TYPE_FLOAT | TYPE_STRING | TYPE_BOOL | TYPE_VOID | ENTITY | COMPONENT | SYSTEM | ENUM | IF | ELSE | RETURN | WHILE | IDENT | WS | COMMENT | MULTILINE_COMMENT | NL )\n alt_9 = 51\n alt_9 = @dfa9.predict( @input )\n case alt_9\n when 1\n # at line 1:10: T__30\n t__30!\n\n\n when 2\n # at line 1:16: T__31\n t__31!\n\n\n when 3\n # at line 1:22: T__32\n t__32!\n\n\n when 4\n # at line 1:28: T__33\n t__33!\n\n\n when 5\n # at line 1:34: T__34\n t__34!\n\n\n when 6\n # at line 1:40: T__35\n t__35!\n\n\n when 7\n # at line 1:46: T__36\n t__36!\n\n\n when 8\n # at line 1:52: T__37\n t__37!\n\n\n when 9\n # at line 1:58: T__38\n t__38!\n\n\n when 10\n # at line 1:64: T__39\n t__39!\n\n\n when 11\n # at line 1:70: T__40\n t__40!\n\n\n when 12\n # at line 1:76: T__41\n t__41!\n\n\n when 13\n # at line 1:82: T__42\n t__42!\n\n\n when 14\n # at line 1:88: T__43\n t__43!\n\n\n when 15\n # at line 1:94: T__44\n t__44!\n\n\n when 16\n # at line 1:100: T__45\n t__45!\n\n\n when 17\n # at line 1:106: T__46\n t__46!\n\n\n when 18\n # at line 1:112: T__47\n t__47!\n\n\n when 19\n # at line 1:118: T__48\n t__48!\n\n\n when 20\n # at line 1:124: T__49\n t__49!\n\n\n when 21\n # at line 1:130: T__50\n t__50!\n\n\n when 22\n # at line 1:136: T__51\n t__51!\n\n\n when 23\n # at line 1:142: T__52\n t__52!\n\n\n when 24\n # at line 1:148: T__53\n t__53!\n\n\n when 25\n # at line 1:154: T__54\n t__54!\n\n\n when 26\n # at line 1:160: INTEGER\n integer!\n\n\n when 27\n # at line 1:168: FLOAT\n float!\n\n\n when 28\n # at line 1:174: BOOLEAN\n boolean!\n\n\n when 29\n # at line 1:182: STRING\n string!\n\n\n when 30\n # at line 1:189: CHAR\n char!\n\n\n when 31\n # at line 1:194: INIT\n init!\n\n\n when 32\n # at line 1:199: OPEN\n open!\n\n\n when 33\n # at line 1:204: CLOSE\n close!\n\n\n when 34\n # at line 1:210: TYPE_INT\n type_int!\n\n\n when 35\n # at line 1:219: TYPE_FLOAT\n type_float!\n\n\n when 36\n # at line 1:230: TYPE_STRING\n type_string!\n\n\n when 37\n # at line 1:242: TYPE_BOOL\n type_bool!\n\n\n when 38\n # at line 1:252: TYPE_VOID\n type_void!\n\n\n when 39\n # at line 1:262: ENTITY\n entity!\n\n\n when 40\n # at line 1:269: COMPONENT\n component!\n\n\n when 41\n # at line 1:279: SYSTEM\n system!\n\n\n when 42\n # at line 1:286: ENUM\n enum!\n\n\n when 43\n # at line 1:291: IF\n if!\n\n\n when 44\n # at line 1:294: ELSE\n else!\n\n\n when 45\n # at line 1:299: RETURN\n return!\n\n\n when 46\n # at line 1:306: WHILE\n while!\n\n\n when 47\n # at line 1:312: IDENT\n ident!\n\n\n when 48\n # at line 1:318: WS\n ws!\n\n\n when 49\n # at line 1:321: COMMENT\n comment!\n\n\n when 50\n # at line 1:329: MULTILINE_COMMENT\n multiline_comment!\n\n\n when 51\n # at line 1:347: NL\n nl!\n\n\n end\n end",
"def cases()\n \n end",
"def code_point=(_); end",
"def bunny(n)\n # raise NotImplementedError, \"Method not implemented\"\n return 0 if n == 0\n return 2 + bunny(n - 1)\n\nend",
"def generate_checkincode\n sai_words = %w(sisters chapter formal music business sigma alpha iota)\n sai_words[rand(sai_words.length)]+(rand(89)+10).to_s()\n end",
"def spice; end",
"def rossini; end",
"def who_we_are\r\n end",
"def kids_musical; end",
"def method_731(base); end",
"def operations; end",
"def operations; end",
"def leeway; end",
"def leeway; end"
] |
[
"0.6714021",
"0.6444321",
"0.6353518",
"0.62171453",
"0.6216865",
"0.6173083",
"0.61607474",
"0.61607474",
"0.61607474",
"0.61607474",
"0.61607474",
"0.61607474",
"0.61607474",
"0.61536807",
"0.609242",
"0.60637873",
"0.6030874",
"0.6030874",
"0.6030874",
"0.6030874",
"0.60240954",
"0.5995047",
"0.5947318",
"0.59017503",
"0.5857462",
"0.5850517",
"0.5849243",
"0.5841735",
"0.5841735",
"0.58357495",
"0.58212095",
"0.58212095",
"0.58212095",
"0.58212095",
"0.58212095",
"0.58187246",
"0.58155596",
"0.5807699",
"0.577371",
"0.57572174",
"0.57519823",
"0.57519823",
"0.574218",
"0.5728144",
"0.57274747",
"0.5715657",
"0.57093877",
"0.5708485",
"0.570306",
"0.5693647",
"0.5691694",
"0.56776476",
"0.5664132",
"0.5654459",
"0.5643196",
"0.5641958",
"0.5622348",
"0.5622348",
"0.5622348",
"0.5602787",
"0.55956376",
"0.5588455",
"0.55845606",
"0.55789226",
"0.55789226",
"0.55789226",
"0.5573617",
"0.5573617",
"0.55248606",
"0.55217326",
"0.55139726",
"0.5508826",
"0.5504334",
"0.55036205",
"0.55036205",
"0.5502537",
"0.5492005",
"0.54821044",
"0.5481893",
"0.54815274",
"0.54801154",
"0.54772455",
"0.54681516",
"0.54681516",
"0.5466803",
"0.5466803",
"0.5453684",
"0.5445655",
"0.5442128",
"0.54410625",
"0.5437267",
"0.5431101",
"0.5430689",
"0.5428818",
"0.54205215",
"0.54101",
"0.54076713",
"0.5400403",
"0.5400403",
"0.5390003",
"0.5390003"
] |
0.0
|
-1
|
codewars kata: averages of numbers
|
def averages(array)
return [] if !array.is_a? Array
averages_array = []
array.each_index do |index|
unless array[index + 1].nil?
sum = (array[index] + array[index + 1])
sum % 2 == 0 ? averages_array << sum / 2 : averages_array << sum / 2.0
end
end
averages_array
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def average numbers\n ave = numbers.reduce 0 do |total, number|\n sum = (total + number)\n end\n ave / numbers.length.to_f\nend",
"def average(numbers)\n sum = numbers.reduce { |sum, number| sum + number }\n sum / numbers.count\nend",
"def average(numbers)\n sum = numbers.reduce { |sum, number| sum + number }\n sum / numbers.count\nend",
"def average(numbers)\n sum = numbers.reduce { |sum, number| sum + number }\n sum / numbers.count\nend",
"def average(numbers)\n sum = numbers.reduce { |sum, number| sum + number }\n sum / numbers.count\nend",
"def average(numbers)\n sum = numbers.reduce { |sum, number| sum + number }\n sum / numbers.count\nend",
"def average_of_ratings(numbers)\n\t\tsum = numbers.reduce(:+)\n\t\tavg = sum.to_f / numbers.length\n\tend",
"def average numbers\n total = 0\n for i in numbers do\n total+=i\n num_of_nums = numbers.length\n average1 = total.to_f/num_of_nums.to_f\nend\n return average1\nend",
"def average(numbers)\n sum = numbers.reduce(:+)\n sum / numbers.count\nend",
"def average(nums)\n sum = 0\n # nums.each {|num| sum += num}\n sum = nums.reduce(:+)\n sum.to_f / nums.count\nend",
"def average numbers\n\tsum = numbers.reduce do |total, number|\n\t\ttotal + number\n\tend\n\taverage = sum.to_f / numbers.length\nend",
"def avg(*numbers)\n sum = numbers.inject(0) { |sum, x| sum += x }\n count = numbers.count\n return sum / count\nend",
"def average()\n if(@countN > 0) then\n return @sum / @countN ;\n else\n return 0.0 ;\n end\n end",
"def average numbers\n avg = numbers.reduce 0 do |total, num|\n total + num\n end\n return avg / numbers.length.to_f\nend",
"def average numbers\n\tnumbers.reduce(:+).to_f / numbers.length\n\t# total / numbers.length\nend",
"def average numbers\n average = numbers.reduce 0 do |total, numbers|\n sum = (total + numbers)\n end\n average / numbers.length.to_f\n\nend",
"def mean(numbers) \r\n sum = numbers.inject(:+)\r\n \r\n return sum / numbers.length\r\nend",
"def average\n return nil if empty?\n sum = n = 0\n if block_given?\n each { |x| n += 1; sum += (yield x) }\n else\n each { |x| n += 1; sum += x }\n end\n sum.to_f / n\n end",
"def average numbers\n sum = numbers.reduce 0.0 do |total, number| #im using 0.0 to go directly into floats\n total + number\n end\n sum / numbers.length\nend",
"def average(numbers)\n total = numbers.reduce do |sum, number|\n sum + number\n end\n \n total / numbers.count\nend",
"def average numbers\n\nend",
"def average(numbers)\n sum = numbers.reduce(:+)\n average = sum / numbers.count.to_f\n average.round(2)\nend",
"def average(num01, num02, num03)\r\n return (num01 + num02 + num03) / 3\r\nend",
"def average(num_array)\n sum = 0\n num_array.each { |num| sum += num }\n sum / num_array.length\nend",
"def average numbers\n\tb=[]\n\t\tsum = numbers.reduce [] do |total, number| \n\t\ttotal+number\n\t\tend \n\t\tb.push(sum/numbers.length)\n\t\treturn b\n\nend",
"def average numbers\n average = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n average.inject{ |sum, el| sum + el }.to_f / average.size\nend",
"def average numbers\n sum = 0.0\n num_length = (numbers.length).to_f\n numbers.each do |number|\n sum+=number\n end\n sum_float = sum.to_f\n return sum_float / num_length\nend",
"def mean\n sum = 0\n @test.each do |value|\n sum += value[2] - value[3]\n end\n\n sum/@test.length.to_f\n end",
"def average(numbers)\n numbers.inject { |sum, element| sum + element }.to_f / numbers.size\nend",
"def average(numbers)\n sum = numbers.inject {|sum, n| sum + n}\n sum / numbers.size\nend",
"def findAverage arr\n sum = 0\n for ocenka in arr do\n sum = sum + ocenka \n \n end\n average = sum / arr.length\n return average\nend",
"def average\n @array.inject(0.0) {|total, n| total + n} / @array.size\n end",
"def get_avg(num_1, num_2)\n (num_1 + num_2) / 2\n end",
"def average numbers\n numbers.reduce(0,:+)/ numbers.length.to_f\nend",
"def average\n check_numeric_array!\n a = numerify\n a.sum / length.to_f\n end",
"def average(num, num2, num3)\n return (num + num2 + num3)/3\nend",
"def average(array)\n sum = 0\n array.each { |n| sum += n }\n average = sum / array.count\nend",
"def get_avg(num_1, num_2)\n (num_1 + num_2) / 2\nend",
"def average(array)\n sum = 0\n array.each do |int|\n sum += int\n end\n sum / array.length\nend",
"def average(num1, num2)\n (num1 + num2) / 2.0\nend",
"def average(numbers)\n sum = 0.0\n numbers.each { |number| sum += number.to_f }\n (sum / numbers.size).round(2)\nend",
"def mean(numbers)\n numbers.inject(:+) / numbers.length\nend",
"def avg(sample)\n sample.inject{ |sum, trial| sum + trial }.to_f / sample.size \nend",
"def average(array)\n total = 0\n array.each do |number|\n total += number\n end\n total / array.length\nend",
"def find_avg(vals)\n sum = 0\n vals.each { |n| sum += n }\n (sum / vals.length).round(2)\nend",
"def average(array)\n total = 0\n array.each do |number|\n total = total + number\n end\n total / array.size\nend",
"def calc_mean(ary)\n if !ary.is_a?(Array)\n 0\n elsif ary.empty?\n 0\n else\n # Your code goes here \n\n #add the numbers \n #divide by the amount of numbers in array\n temp = 0\n ary.each do |index|\n temp = temp + index\n\n end\n\n mean = temp / ary.size\n\n return mean\n end\nend",
"def average(num1, num2)\n return (num1+num2) / 2.0\nend",
"def average(input_array)\n n = input_array.length\n sum = 0 \n\n input_array.each do |num|\n sum = sum + num\n end\n average_of_array = sum.to_f / n\nend",
"def average(numbers)\n numbers.inject(&:+) / numbers.size.to_f # denominator here doesn't need to also be a float. appears that ruby will do a float operation as long as one of the numbers is a float\nend",
"def average(array)\n total = 0\n array.each { |num| total += num }\n total / array.length\nend",
"def average_rating\n ratings.inject(0.0) {|sum, num| sum +=num} / ratings.length\n end",
"def mean(array)\n\ttotal = 0\n\tarray.each do |x|\n\t\ttotal = total + x\n\tend\n\tmean = total.to_f / array.count\n\tputs mean\nend",
"def avg(input_array)\n n = input_array.size \n sum = 0 \n n.times{|x|\n sum = sum + input_array[x]\n }\n return ((sum/n).to_f)\n end",
"def average(array)\n total = 0\n array.each do |num|\n total += num\n end\n total.to_f / array.size\nend",
"def average(input_array)\n sum = 0\n \n input_array.each {|num| sum += num}\n \n average = sum.to_f/input_array.length\nend",
"def mean array\n length = array.length\n sum = 0 \n array.each do |x|\n sum += x\n end\n sum / length\nend",
"def average(arr)\n total = 0\n arr.select do |num|\n total += num\n end\n average = total / arr.length\nend",
"def average(array)\n result = array.inject(:+)\n result / array.count\nend",
"def average arr\n sum = 0\n arr.each {|i| sum += i}\n average = sum/(arr.size) \nend",
"def average\n value = frequency.inject(:+) \n\n value / frequency.length.to_f\n end",
"def mean(arr)\n return 0 if arr.empty?\n sum = 0\n\n arr.each do |num|\n sum = sum + num\n end\n \n sum / arr.count\nend",
"def mean(array)\n total = 0\n array.each { |i| total+= i.to_f }\n total / array.count\n puts total\nend",
"def average(array)\n sum = 0\n array.each { |x| sum += x }\n (sum / array.count).to_f\nend",
"def average(array)\n sum = 0\n array.each { |value| sum += value }\n sum / array.length\nend",
"def mean(numbers)\n Float(numbers.inject(:+)) / numbers.length\nend",
"def avg(list)\n total = 0\n\n list.each do |n|\n total += n\n end\n return total / list.size.to_f\nend",
"def array_average arr\n arr_sum = 0.0\n\n arr.each do |num|\n arr_sum += num\n end\n\n arr_avg = arr_sum / arr.size\nend",
"def mean\n variance =0\n count = 0.0\n @data.each do |line|\n true_rating = line[2]\n guess_rating = line[3]\n count = count + 1\n variance = (true_rating.to_i - guess_rating.to_i).abs + variance\n end\n return (variance/count.to_f)\n end",
"def mean(nums)\n sum = nums.reduce { |x, y| x.to_f + y.to_f}\n sum / nums.length.to_f\nend",
"def average\n\t\tif self.length > 0\n\t\t\t#\tsum defined in activesupport/lib/active_support/core_ext/enumerable.rb\n\t\t\tself.digitize.sum.to_f / self.length\n\t\telse\n\t\t\tnil\n\t\tend\n\tend",
"def average(arr)\ncounting_variable = 0\narr.each {|element| counting_variable += element }\ncounting_variable / arr.length\nend",
"def average(anArray)\n avg = 0\n sum = sum(anArray)\n if (anArray.length > 0) then\n avg = sum / anArray.length\n else\n return 0\n end\nend",
"def mean(ary)\n\tsum=0.0\n\tary.each {|item| sum+=item}\n\tsum/ary.count\nend",
"def average(arr)\n int = 0\n arr.each { |num| int += num }\n int / arr.length.to_f\nend",
"def average (anArray)\n if (anArray.length <= 0)\n return 0.0;\n else\n return sum(anArray) / anArray.length;\n end\nend",
"def average(array)\n array.inject(:+).to_f / array.size\nend",
"def average(arr)\n arr.inject(:+) / arr.length\nend",
"def average_of_array(array)\n\tn = [10, 15, 25]\n\taverage = n.inject(0.0) { | total, num | total + num } / n.count\n\taverage.round\nend",
"def Avg(user)\n sodanhgia = 0\n ru = 0\n $input.first.count.times do |i|\n if $input[user][i] != 0\n sodanhgia+= 1\n ru += $input[user][i]\n end\n end\n ru /= sodanhgia\n return ru\nend",
"def average(array)\n array.inject(&:+) / array.length\n end",
"def avg(list)\n total = 0\n list.each do |n|\n total += n\n end\n return total / list.size.to_f\nend",
"def average(integers)\n sum = integers.reduce(:+)\n sum / integers.size\nend",
"def average(arr)\n output = 0\n i = 0\n while i < arr.length\n output += arr[i].to_i\n i += 1\n end\n output = output/arr.length\n return output.to_f\nend",
"def average(array)\n \n sum = 0\n array.each do |element|\n sum = sum + element\n end\n puts \"The sum is #{sum}\"\n puts \"The array size is #{array.size}\"\n puts \"The average is #{(sum / array.size)}\"\n return (sum / array.size)\nend",
"def average_of_three(num1, num2, num3)\n sum = num1 + num2 + num3\n avg = sum / 3.0\n return avg\nend",
"def mean(*numbers)\n sum = numbers.inject(:+)\n \n return sum / numbers.length\nend",
"def avg(prevs)\n avg = prevs.reduce(:+) / prevs.size\n avg.round(3)\nend",
"def find_average \n result = array.sum(0.0)/array.size\n return result\n end",
"def average(arr)\n output = 0\n i = 0\n while i < arr.length\n output += arr[i]\n i += 1\n end\n output = output.to_f/arr.length\n return output\nend",
"def mean\n sum / count.to_f\n end",
"def average(number1, number2, number3)\n return (number1 + number2 + number3)/3\nend",
"def average(array)\n result = array.inject { |sum, n| sum + n }\n result / array.size\nend",
"def calcAverage(n1, n2)\n return (n1 + n2) / 2.0\nend",
"def average(num_arr)\n (num_arr.sum/num_arr.length).to_f\nend",
"def mean(list_of_numbers)\n # Let's re-use the work we did above in the sum method\n calc_mean = sum(list_of_numbers)/(list_of_numbers.length)\n return calc_mean\n end",
"def average(array)\n i = 0\n sum = 0\n while i < array.length\n sum += array[i].to_int\n i += 1\n end\n return (sum.to_f / array.length.to_f)\nend",
"def mean\n @mean ||= x.inject(:+) / n\n end",
"def avg\n array = []\n# this DO-loop will put all the star ratings into an array\n @reviews.each do |count|\n array.push(count.star.to_i)\n end\n# this line will calculate the actual average of all the star ratings\n outavg = array.inject(0.0) { |sum, el| sum + el } / array.size\n end",
"def calcAverage(num1, num2)\n (num1 + num2) / 2.0 # 'return' keyword is optional\nend"
] |
[
"0.76195127",
"0.75833255",
"0.75833255",
"0.75833255",
"0.75833255",
"0.75833255",
"0.7582135",
"0.7578446",
"0.75643134",
"0.75389767",
"0.7529635",
"0.75248945",
"0.75080657",
"0.7497693",
"0.74847496",
"0.7480164",
"0.7474084",
"0.74145824",
"0.741104",
"0.7360753",
"0.73578274",
"0.7352858",
"0.7338022",
"0.73201114",
"0.7308581",
"0.7291587",
"0.7283322",
"0.7274028",
"0.7255112",
"0.72469956",
"0.72451615",
"0.7241849",
"0.7240221",
"0.7228",
"0.72271866",
"0.7218581",
"0.72184646",
"0.72175336",
"0.7208166",
"0.72059363",
"0.7194857",
"0.71925247",
"0.7192265",
"0.7185859",
"0.7182432",
"0.7158047",
"0.7147767",
"0.714081",
"0.7121828",
"0.7119147",
"0.71185523",
"0.7110156",
"0.7099645",
"0.7088669",
"0.70844555",
"0.7080618",
"0.7079507",
"0.7077846",
"0.70767057",
"0.7071311",
"0.70616466",
"0.7059263",
"0.7025222",
"0.70226127",
"0.701556",
"0.70114845",
"0.7004889",
"0.69932735",
"0.6992503",
"0.69906104",
"0.6983478",
"0.6969173",
"0.6968874",
"0.6964411",
"0.6963941",
"0.69633484",
"0.69544256",
"0.6954326",
"0.69526803",
"0.69499063",
"0.6947775",
"0.6942346",
"0.69396824",
"0.69393957",
"0.6927366",
"0.6921215",
"0.69106746",
"0.6908823",
"0.6889444",
"0.6888194",
"0.6883143",
"0.6882492",
"0.6878783",
"0.68734944",
"0.6872113",
"0.68718356",
"0.687013",
"0.6865157",
"0.68566",
"0.6841175"
] |
0.6961258
|
76
|
codewars kata: shortest word
|
def find_short(string)
string.split.map(&:length).sort.first
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def shortest(word1, word2)\n \n end",
"def shortest_word(words)\n words.inject { |memo, word| memo.length < word.length ? memo : word}\nend",
"def shortest_first(array_of_words)\n # TODO\nend",
"def shortest_string(list_of_words)\n if list_of_words.empty? == true\n return nil\n end\n word = 1\n list_of_words.each do |x|\n if x.length <= word.to_s.length\n word = x\n end\n end\n p word\nend",
"def shortest_string(list_of_words)\n # Your code goes here!\n shortest = list_of_words[0]\n\n list_of_words.each { |word| \n if word.length < shortest.length\n shortest = word\n end\n }\n\n return shortest\nend",
"def shortest_string(list_of_words)\n shortest = list_of_words[0]\n\n list_of_words.each do |word|\n if word.length < shortest.length\n shortest = word\n end\nend\n\nreturn shortest\nend",
"def shortest_string(list_of_words)\n if list_of_words.empty? \n return nil\n end\n \n short=list_of_words[0]\n list_of_words.each { |str| \n if str.length < short.length\n short=str\n end \n }\n return short\nend",
"def shortest_string(list_of_words)\n # Your code goes here!\n if list_of_words.empty?\n return nil\n end\n shortest_word = list_of_words[0]\n for word in list_of_words\n if word.length < shortest_word.length\n shortest_word = word\n end\n end\n return shortest_word\n\nend",
"def shortest_string(list_of_words)\n list_of_words.min_by(&:length)\nend",
"def shortest_string(list_of_words)\n list_of_words.min_by(&:length)\nend",
"def shortest_string(list_of_words)\n shortest = list_of_words[0]\n list_of_words.each do |i|\n \tif shortest.length <= i.length\n \t\tshortest = shortest\n \telse\n \t\tshortest = i\n \tend\n end\n p shortest\nend",
"def shortest_word_in_array(array)\n array.min_by{|word|word.length}\nend",
"def shortest_string(list_of_words)\n if list_of_words == []\n \treturn nil\n else\n \tcounter = 0\n \tshortest_word = ''\n \tshorest_word_length = list_of_words[0].length\n \twhile counter < list_of_words.length\n \t\tif shorest_word_length >= list_of_words[counter].length\n \t\t\tshortest_word = list_of_words[counter]\n \t\tend\n \tcounter += 1\n \tend\n end\n return shortest_word\nend",
"def shortest_string(list_of_words)\n if list_of_words.length == 0\n nil\n else\n index = 0\n shortest_word = list_of_words[0]\n while index < list_of_words.length do\n if list_of_words[index].length <= shortest_word.length\n shortest_word = list_of_words[index]\n end\n index+=1\n end\n shortest_word\n end\n end",
"def shortest_string(list_of_words)\n # Your code goes here!\n return list_of_words[0].to_s if list_of_words.length == 1\n smallest_word(list_of_words)\n# until_loop(list_of_words)\n# for_loop(list_of_words)\n# smallest = list_of_words[0]\n# list_of_words.each do |word|\n# smallest = word if word.length < smallest.length\n# end\n# return smallest\nend",
"def shortest_string(list_of_words)\n shortest = list_of_words[0]\n for word in 1...list_of_words.length\n if shortest.length > list_of_words[word].length then\n shortest = list_of_words[word]\n end\n end\n return shortest\nend",
"def shortest_string(list_of_words)\n\n for x in 0..list_of_words.length - 1\n if x == 0\n currentSmallest = list_of_words[x]\n else\n if list_of_words[x].length < currentSmallest.length\n currentSmallest = list_of_words[x]\n end\n end\n end\n\n return currentSmallest\nend",
"def shortest_string(list_of_words)\n \n array = []\n\n list_of_words.each {|value|\n \tarray << value.length\n }\n\n if array.empty?\n \tnil\n else\n return list_of_words[array.index(array.min)]\n end\n\nend",
"def find_short(s)\n # your code here\n the_1st_array = s.split(\" \")\n this_counts = []\n i = 0\n while i < the_1st_array.count\n this_counts.push(the_1st_array[i].length)\n i+=1\n end\n l = this_counts.min\n return l # l: length of the shortest word\nend",
"def shortest_string(list_of_words)\n if list_of_words.empty?\n return nil\n else\n shortest_length = list_of_words.first.length\n shortest_word = ''\n list_of_words.each do |word|\n if word.length <= shortest_length\n shortest_length = word.length\n shortest_word = word\n else\n shortest_word = shortest_word\n end\n end\n return shortest_word\n end\nend",
"def shortest_string(list_of_words)\n list_of_words.min {|x,y| x.size <=> y.size}\nend",
"def shortest_string(list_of_words)\n\treturn list_of_words.min_by {|x| x.length }\nend",
"def shortest_string(list_of_words)\n # Your code goes here!\n list_of_words.sort! { |a , b| a.length <=> b.length }\n\t\treturn list_of_words[0]\nend",
"def find_short(s)\n l = s.split(\" \").min_by { |x| x.length}.length\n return l #l: length of the shortest word\nend",
"def shortest_string(list_of_words)\n list_of_words = list_of_words.sort_by {|x| x.length}\n short_string = list_of_words[0]\n return short_string\nend",
"def shortest_string(list_of_words)\n list_of_words.min { |a, b| a.size <=> b.size }\nend",
"def shortest_string(list_of_words)\n\tif list_of_words.length == 0\n\t\treturn nil\n\tend\n\ti = list_of_words[0]\n\tj = 1\n\twhile j <= list_of_words.length - 1 do\n\t\tif i.length > list_of_words[j].length\n\t\t\ti = list_of_words[j]\n\t\tend\n\t\tj = j + 1\n\tend\n\treturn i\nend",
"def shortest_string(list_of_words)\n if list_of_words.empty?\n return nil\n else\n shortest = list_of_words[0]\n list_of_words.each.to_s do |x|\n if list_of_words.length < shortest\n shortest = x\n end\n end\n end\n return shortest\nend",
"def shortest_string(list_of_words)\n length_of_words = {}\n list_of_words.each do |word|\n word_length = word.length\n length_of_words[word] = word_length\n end\n answer = length_of_words.min_by{|k,v| v}\n if answer == nil\n return nil\n else\n answer.first\n end\nend",
"def shortest_string(list_of_words)\n return nil if no_string?(list_of_words)\n return list_of_words[0] if one_string?(list_of_words)\n \telse\n \t\tfirst_word = list_of_words[0]\n \t\tx = 1\n \t\twhile x < list_of_words.length\n \t\t\tif first_word.length > list_of_words[x].length\n \t\t\t\tfirst_word = list_of_words[x]\n \t\t\tend\n \t\t\tx += 1\n \t\tend\n \t\treturn first_word\nend",
"def shortest_string(list_of_words)\n\tif list_of_words == []\n\t\treturn nil\n\telsif list_of_words == [\" \"]\n\t\treturn \" \"\n\telse\n\t\tstring_length = []\n\t\tlist_of_words.each do |string|\n\t\t\t string_length.push string.length\n\t\tend\n\t\tlist_of_words.each do |string|\n\t\t\tif string_length.min == string.length\n\t\t\t\treturn string\n\t\t\tend\n\t\tend\n\n\tend\n\nend",
"def shortest_string(list_of_words)\n\tif list_of_words==[]\n\t\treturn nil\n\telse\n\t\tshort_string=list_of_words[0]\n \t\tlist_of_words.each do |x|\n \t\t\tif x.length < short_string.length\n \t\t\t\tshort_string = x\n\t\t\tend\t\t\n\t\tend\n \t\treturn short_string\n \tend\nend",
"def shortest_string(list_of_words)\n\n return nil if list_of_words.length == 0\n return \" \" if list_of_words.length == 1 && list_of_words[0] == \" \"\n return list_of_words[0] if list_of_words.length == 1\n\n test_word = list_of_words.pop\n not_it = []\n solution = []\n list_of_words.each do |word|\n if word.length < test_word.length\n not_it << test_word\n test_word = word\n else\n not_it << word\n end\n end\n\n solution.push test_word\n return solution[0]\n\n #------SOLUTION WITH sort_by METHOD:\n\n # new_list = list_of_words.sort_by {|x| x.length}\n # return new_list[0]\n\nend",
"def shortest_word_in_array(array)\n array.min{ | x, y | x.length <=> y.length }\nend",
"def shortest_string(list_of_words)\n # Your code goes here!\n return nil if list_of_words.empty?\n\n shortest = list_of_words[0]\n i = 1\n while(i < list_of_words.length)\n \tshortest = list_of_words[i] if list_of_words[i].size < shortest.size\n \ti += 1\n end\n return shortest\nend",
"def shortest_string(list_of_words)\n shortest = list_of_words[0]\n array_number = 1\n while array_number < list_of_words.length\n \tif list_of_words[array_number].length < shortest.length\n \t\tshortest = list_of_words[array_number]\n \tend\n \tarray_number += 1\n end\n return shortest\nend",
"def shortest_string(list_of_words)\n if list_of_words.length == 0\n \treturn nil\n end\n shortest_str = list_of_words[0]\n list_of_words.each do |str| \n \tif str.size < shortest_str.size\n \t\tshortest_str = str\n \tend\n end\n shortest_str\nend",
"def shortest_string(list_of_words)\n \n short_string = list_of_words[0]\n \n i = 0\n while i < list_of_words.length\n current_item = list_of_words[i]\n if current_item.length < short_string.length\n short_string = current_item\n end\n i = i + 1\n\n end\n short_string\nend",
"def shortest_string(list_of_words)\n\tif list_of_words.empty?\n\t\treturn nil\n\telse p list_of_words.sort_by {|x| x.length}.shift\n\tend\nend",
"def shortest_string(list_of_words)\n\treturn list_of_words.min{|a,b| a.size <=> b.size}\nend",
"def shortest_string(list_of_words)\n if list_of_words == []\n return nil\n end\n i = 0\n array_length = array_size(list_of_words)\n smallest_index = 0\n for i in 0..array_length - 1\n if string_length(list_of_words[smallest_index]) > string_length(list_of_words[i])\n smallest_index = i\n end\n end\n return list_of_words[smallest_index]\nend",
"def shortest_string(list_of_words)\n # PSEUDOCODE\n # return nil if list has no strings in it\n # I'm assuming the .length method is okay here, otherwise this problem would be a lot more tedious\n # Initialize initial shortest word as first word in array\n # Initialize initial shortest length as length of that word\n # FOR each word\n # IF word length is smaller than minimum\n # Set shortest word as that word\n # Set shortest length as word's length\n # Return minimum\n\n\n# INITIAL SOLUTION\n# return nil if list_of_words == []\n#\n# shortest = list_of_words[0]\n# min_length = shortest.length\n# list_of_words.each { |word|\n#\n# if word.length < min_length\n# shortest = word\n# min_length = word.length\n# end\n# }\n# return shortest\n\n #BUILT-IN SOLUTION\n\n return list_of_words.min { |a, b| a.length <=> b.length }\n\n\nend",
"def find_short(s)\n return s.split(\" \").map { |word| word.length }.min\nend",
"def shortest_string(list_of_words)\n\n#If presented with an array of mixed objects, maybe not all strings\n# strings = []\n# list_of_words.each do |i|\n# if i.is_a? String\n# strings.push(i)\n# end\n# end\n\n\n\n if list_of_words.length ==0\n return nil\n else\n i=0\n shorty = list_of_words[0]\n while i<list_of_words.length do\n if list_of_words[i].length <= shorty.length\n shorty = list_of_words[i]\n end\n i += 1\n end\n return shorty\n end\nend",
"def shortest_string(list_of_words)\n\tif list_of_words.length == 0\n\t\treturn nil\n\tend\n\tlist_of_words.sort_by! {|i| i.length}\n\treturn list_of_words[0]\nend",
"def shortest_string(list_of_words)\r\n\tif list_of_words[0].nil?\r\n\t\treturn nil\r\n\telse\r\n\t\tstring_length = Hash.new\r\n\t\tsorted = Hash.new\r\n\t\tlist_of_words.each do |words|\r\n\t\t\tstring_length[words] = words.length\r\n\t\tend\r\n\t\tsorted = string_length.sort_by{|x, y| y}\r\n\t\treturn sorted.first.first\r\n\tend\r\nend",
"def smallest_word(array)\n smallest = array[0]\n array.each do |word|\n smallest = word if word.length < smallest.length\n end\n return smallest\nend",
"def shortest(word1, word2)\n ans = @M\n for i in @d[word1]\n for j in @d[word2]\n ans = [ans, (i-j).abs].min\n end\n end\n return ans\n end",
"def shortest_word_in_array(array)\n # check each element of array\n # if the shortest, update the shortest word\n shortest_word = array[0]\n array.each {|word|\n shortest_word = word if shortest_word.size>word.size\n }\n shortest_word\nend",
"def find_short(s)\n return s.split(' ').min_by{|word| word.length}.length\nend",
"def find_shortest_words(str)\n words = str.downcase.split(/[^a-z0-9]/)\n words = words.sort_by {|word| word.size}\n shortest = []\n\n words = words.select {|word| word.size > 0}\n\n size = words[0].size\n words.each do |word|\n break if word.size > size\n shortest << word\n end\n shortest.sort\nend",
"def shortest_word_in_array(array)\n array.min_by(&:length)\n # array.min_by { |x| x.length }\nend",
"def shortest_string(list_of_words)\n\tshortest_string.each {|x1| x1.length}\n\t\tshortest_string.each {|x2| x2.length.to_i} #iterrates over each string in array, counts the string's length \n\t\tif shortest_string|x1.length| > shortest_string|x2.length| #compares the 2 pulled string lenghts\n\t\t\tshortest_string|x1| , shortest_string|x2| = shortest_string|x2| > shortest_string|x1| #keeps putting the smallest one to the front\n\t\tend\n\t\treturn shortest_string[0] #returns the first stirng in the array which should be the smallest one\nend\n\n# was getting some errors I could not resolve in order to get this to run. ",
"def for_fs_sake(string)\n words = string.split\n min_f_distance = nil\n min_f_word = \"\"\n\n words.each do |word|\n current_f_distance = find_f_distance(word)\n if current_f_distance && (min_f_distance.nil? || current_f_distance < min_f_distance)\n min_f_distance = current_f_distance\n min_f_word = word\n end\n end\n\n min_f_word\nend",
"def shortest_word_in_array(array)\n\tn = %w(here is a bunch of words of different lengths)\n\tsorted = n.sort_by! { | word | word.length }\n\tsorted.first\nend",
"def for_cs_sake(string)\n words = string.delete(\"!.,?;:\").split(\" \")\n words = words.select { |word| word.include?(\"c\") }\n c_distances = []\n words.each do |word|\n c_distances << find_c_distance(word)\n end\n c_distances\n lowest_c_distance = c_distances.min\n p words.select { |word| find_c_distance(word) == lowest_c_distance }[0]\nend",
"def shortest_string(list_of_words)\n\tmethod = 1\n\tcase method\n\twhen 1\n\t\tlist_of_words.min_by {|x| x.size} #The easy way\n\twhen 2\n\t\tshortest = list_of_words[0]\n \t\tlist_of_words.each do |element|\n \t\t\tshortest = element if element.size < shortest.size\n \t\tend\n \t\treturn shortest\n \twhen 3\n \t\tshortest = list_of_words[0]\n \t\tfor element in list_of_words\n \t\t\tshortest = element if element.size < shortest.size\n \t\tend\n \t\treturn shortest\n \tend\nend",
"def get_the_shortest_word(str)\n str.split(\" \").sort! {|s, l| s.length <=> l.length}[0]\nend",
"def shortest(word1, word2)\n word1_indices = @hash[word1]\n word2_indices = @hash[word2]\n\n dis = @size\n i, j = 0, 0\n while word1_indices[i] && word2_indices[j]\n dis = [dis, (word1_indices[i] - word2_indices[j]).abs].min\n if word1_indices[i] < word2_indices[j]\n i += 1\n else\n j += 1\n end\n end\n\n return dis\n end",
"def for_cs_sake(string)\n return '' unless string.include? 'c'\n\n remove_punctuation(string)\n c_words = string.split.select { |word| word.downcase.include? 'c' }\n c_words.min_by { |word| c_distance(word) }\nend",
"def find_short(s)\n s.split(' ').map{|e|e.length}.min\nend",
"def for_cs_sake(string)\n c_words = Hash.new(0)\n string = remove_punctuation(string)\n string.split(' ').each do |word|\n c_words[word] = c_distance(word) if word.include?('c')\n end\n p c_words\n c_words.min_by { |v| v }.first\nend",
"def start_of_word(a)\n return a.chars.first.join\nend",
"def common_prefix(words)\n smallest_string= words.min_by{|word| word.size}\n\n result = \"\"\n\n smallest_string.chars.each_with_index do |current_char, current_index|\n if words.all?{|word| word[current_index] == current_char}\n result << current_char\n else\n return result\n end\n end\n result\nend",
"def longest_prefix(strings)\n return \"\" if strings.empty?\n prefix = \"\"\n smallest_word = strings.min_by { |word| word.length } # start with smallest word\n for i in 0..smallest_word.length-1\n if strings.all? { |word| word[i] == smallest_word[i] } # if the index matches the same index of the other words\n prefix += smallest_word[i] # then append the index value to the prefix\n else\n break # otherwise index is not in all words, so stop\n end\n end\n return prefix\nend",
"def for_cs_sake(string)\n string = string.gsub(/[[:punct:]]/, '')\n string = string.split\n string = string.reject { |word| c_distance(word) == nil }\n string.sort_by { |word| c_distance(word) }[0]\n\n #too long\n # closest = \"\"\n # split_string = string.split\n # c_distance = 0\n #\n # (0...split_string.length).each do |idx|\n # next if c_distance(split_string[idx]) == nil\n # if c_distance(split_string[idx]) > c_distance\n # c_distance = c_distance(split_string[idx])\n # closest = split_string[idx]\n # end\n # end\n # closest\nend",
"def least_frequent_word(str)\n words = str.split\n frequency = words.length\n min_word = \"\"\n\n words.each_with_index do |word, idx|\n if words.count(word) < frequency\n frequency = words.count(word)\n min_word = words[idx]\n end\n end\n min_word\nend",
"def best_next_word(set, goal)\n set.to_a[0]\n end",
"def start_of_word(a, b)\n return a.chars.first(b).join\nend",
"def first_wa(array)\n\n array.each do |word|\n temp = word.to_s\n return temp if temp.start_with?(\"wa\")\n end\n\nend",
"def find_short(sentence)\n word_array = sentence.split\n\n word_array.sort! do |word_a, word_b|\n word_a.length <=> word_b.length\n end\n\n return word_array.first.length\nend",
"def solution(a)\n shortest = a.min_by &:length\n maxlen = shortest.length\n maxlen.downto(0) do |len|\n 0.upto(maxlen - len) do |start|\n substr = shortest[start,len]\n return substr if a.all?{|str| str.include? substr }\n end\n end\nend",
"def short\n # this are short words\n assert PorterStemmer::Porter2.short?(\"bed\")\n assert PorterStemmer::Porter2.short?(\"shed\")\n assert PorterStemmer::Porter2.short?(\"shred\")\n\n # this are not short words\n assert !PorterStemmer::Porter2.short?(\"bead\")\n assert !PorterStemmer::Porter2.short?(\"embed\")\n assert !PorterStemmer::Porter2.short?(\"beds\")\n end",
"def common_prefix(words)\n longest = ''\n\n shortest_word = words.min\n (0...shortest_word.length).each do |stop_index|\n sequence = shortest_word[0..stop_index]\n\n match = words.all? do |word|\n word[0..stop_index] == sequence\n end\n\n longest = sequence if match\n end\n\n longest\nend",
"def start_of_word; end",
"def find_short(s)\n # input is string\n # convert string to array\n converted = s.split(\" \") # gives us an array of words\n # order elements of array by length\n sorted_by_length = converted.sort_by {|x| x.length}\n # returns an array of words sorted by length\n # return the first element in array\n return sorted_by_length[0].length\n \nend",
"def find_short(s)\n # s.split.map(&:size).min\n s.split\n .map(&:size)\n .min\nend",
"def shortest_string(list)\n\tshortest = list.first\n\tlist.each do |current_str|\n\t\tif current_str.length < shortest.length\n\t\t\tshortest = current_str\n\t\tend\n\tend\n\n\tshortest\nend",
"def shortest(letters)\n x = 0\n y = 0\n longitud =[]\n delevery =letters.sort_by{|i|i.length}#sort_by ordena de menor a mayor\n delevery.each do |f| #sacar los valores ordenador del array\n if delevery[0].length == letters[x].length #toma el primer valor que es el menor y compara con los demas si tiene la misma longitud\n longitud[y] = letters[x] #se mete el resultado en el array vacio \n y += 1 #posiciona en el array el valor que resulta de la comparacion\n end\n x += 1 #guarda e incrementa en el array que va encontrando en el array o,1,2,3,...\n end\n\n longitud\nend",
"def first_wa(array)\n output = \"\"\n array.each do |word|\n if word[0..1].to_s == \"wa\"\n output = word\n break\n end\n end\n output\nend",
"def shortest\n '-shortest'\n end",
"def first_word(a)\n\t\ta = a.split[0]\n\tend",
"def find_short(s)\n ar = (s.split).map { |k| k.size }.sort\n p ar[0]\n end",
"def for_cs_sake(string)\n string.delete!(\",.;:!?\")\n c_word=string.split.select{|word|word.include?('c')}\n return nil if c_word.empty?\n c_word.sort_by{|word|c_distance(word)}[0]\nend",
"def first_word (a)\n\t return a.split[0]\nend",
"def rule1(str = @word)\n newstr = str.chars\n newstr.each_index do |index|\n if newstr[index-1].eql?newstr[index+1]\n newstr[index]=newstr[index-1] unless newstr[index].eql?(\" \") || newstr[index-1].eql?(\" \") || newstr[index+1].eql?(\" \")\n end\n end\n newstr.join('').to_s.squeeze(\" \")\n end",
"def minimum_set_of_words(input)\n return [] if input.nil? || input.size == 0\n return input if input.size == 1\n\n w = input[-1] # take last word, that has just been added\n ww = input[0..-2] # take the words without last.\n\n w_letter_set = letter_set_from_words(w)\n ww_letter_set = letter_set_from_words(ww)\n\n if w_letter_set <= ww_letter_set\n\n minimum_set_of_words(ww)\n\n elsif (w_letter_set & ww_letter_set < w_letter_set) && (w_letter_set & ww_letter_set).size >= 1\n\n temp = minimum_set_of_words(ww)\n without_words_not_contributing_to_letter_set(temp, w)\n temp + [w]\n\n else\n\n minimum_set_of_words(ww) + [w]\n\n end\nend",
"def get_the_shortest_word(str)\n words = str.split()\n return words.max\nend",
"def first_word(words)\n\twords.split(\" \")[0]\nend",
"def shortest a, b\n left = -1\n last = b.chars.map { |c| [c, -1] }.to_h\n bcount = 0\n min_length = a.length + 1\n min_left = min_right = -1\n a.chars.each_with_index do |c, right|\n if not last.has_key? c\n left = right\n bcount = 0\n else\n bcount += 1 if last[c] <= left\n last[c] = right\n while last[a[left + 1]] != left + 1\n left += 1\n end\n length = right - left\n if bcount == b.length and length < min_length\n min_length = length\n min_left = left\n min_right = right\n end\n end\n end\n if min_length < a.length + 1\n return a[(min_left + 1)..min_right]\n else\n return ''\n end\nend",
"def shortest_string(list)\n # This is your job. :)\n shortest_so_far = list.first\n list.each do |item|\n if item.length < shortest_so_far.length\n shortest_so_far = item\n end\n end\n return shortest_so_far\nend",
"def for_cs_sake(string)\n if !string.include?('c')\n return ''\n end\n string.delete!('!')\n string.delete!('?')\n string.delete!(',')\n string.delete!('.')\n word_arr = string.split\n new_arr = word_arr.sort_by {|word| c_distance(word)}\n return new_arr[0]\nend",
"def longest_prefix(strings)\n words = strings.length\n min_characters = (strings.min_by{|string|string.length}).length\n prefix = \"\"\n\n min_characters.times do |j|\n letter = strings[0][j]\n\n words.times do |i|\n return prefix if strings[i][j] != letter\n end\n\n prefix += letter\n end\n\n return prefix\nend",
"def start_of_word word, length\n word.chars.take(length).join\nend",
"def shortest_string(list)\n shortest_so_far = list.first\n list.each do |item|\n if shortest_so_far.length > item.length\n shortest_so_far = item\n end\n end\n shortest_so_far\nend",
"def find_short(string)\n string.split.map(&:length).min\nend",
"def break_ties(tied_words)\n puts \"This is our array of just words: #{tied_words}\"\n all_tens = tied_words.select{|word| word.length == 10}\n\n winning_word = \"\"\n if all_tens.size >= 1 \n winning_word = all_tens[0]\n else\n all_smallest = tied_words.min_by{|word| word.length}\n if all_smallest.class == Array \n winning_word = all_smallest[0]\n else\n winning_word = all_smallest\n end\n end\n return winning_word\nend",
"def LongestWord(sen)\n arr = sen.split(\" \")\n arr.sort! { |a, b| b.length <=> a.length }\n arr[0]\n\nend",
"def smallest_string(strings)\n smallest = strings[0]\n strings.each do |string|\n if string.length < smallest.length\n smallest = string\n end\n end\n smallest\nend",
"def canonical(word)\n word.split(\"\").sort.join\nend",
"def for_cs_sake(string)\n remove_punctuation(string)\n c_words = string.split.select { |word| word.downcase.include?(\"c\") }\n return \"\" if c_words.empty?\n c_words.sort_by { |word| c_distance(word) }.first\nend"
] |
[
"0.8314696",
"0.80332565",
"0.77733916",
"0.76788294",
"0.76128864",
"0.7594599",
"0.7564295",
"0.7530207",
"0.74949026",
"0.74949026",
"0.7450016",
"0.7436052",
"0.74038327",
"0.73993284",
"0.7394312",
"0.73942447",
"0.73930174",
"0.73926634",
"0.73741066",
"0.7366519",
"0.7358797",
"0.73577493",
"0.733321",
"0.7331405",
"0.73073786",
"0.7305406",
"0.729173",
"0.72912437",
"0.7288994",
"0.726372",
"0.7245311",
"0.7232948",
"0.7201625",
"0.7201469",
"0.71979856",
"0.71950424",
"0.7194688",
"0.71944964",
"0.7193198",
"0.71683574",
"0.7166832",
"0.71629065",
"0.71472335",
"0.7140013",
"0.70944786",
"0.7056552",
"0.7043136",
"0.7031221",
"0.7030426",
"0.7028787",
"0.70281017",
"0.7024536",
"0.6980378",
"0.69687325",
"0.6933625",
"0.6927794",
"0.69020975",
"0.6885311",
"0.6854009",
"0.6826437",
"0.68160015",
"0.6815495",
"0.6755639",
"0.67359483",
"0.6667481",
"0.66123",
"0.66010183",
"0.6579782",
"0.65727246",
"0.6567789",
"0.65401584",
"0.6499479",
"0.64607394",
"0.64535344",
"0.6453032",
"0.6430844",
"0.64217836",
"0.64189845",
"0.63938165",
"0.63896984",
"0.63798034",
"0.6374586",
"0.6349983",
"0.6336105",
"0.63331187",
"0.63123924",
"0.6311178",
"0.62947446",
"0.6292645",
"0.6277687",
"0.6277447",
"0.6272436",
"0.6263323",
"0.6260048",
"0.62505245",
"0.62492365",
"0.6239969",
"0.62274885",
"0.6211801",
"0.62028855",
"0.61914945"
] |
0.0
|
-1
|
codewars kata: histogram h1
|
def histogram(results)
array = []
results.each_with_index do |rolls, index|
if rolls > 0
array.unshift("#{index + 1}|#{"#" * rolls} #{rolls}\n")
else
array.unshift("#{index + 1}|#{"#" * rolls}\n")
end
end
array.join
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def histogram\n if @histogram.nil?\n @histogram = Hash[*BINS.map{ |elt| [elt, 0] }.flatten]\n authors.each do |name, num_commits|\n bottom = 0\n BINS.each do |top|\n if num_commits >= bottom and num_commits < top\n @histogram[bottom] += 1\n end\n bottom = top\n end\n end\n end\n @histogram\nend",
"def histogram(params = {})\n params[:name] ||= File.join(@pictureName.gsub(\".png\", \"Histogram.html\"))\n bins = Hash.new(0)\n \n (0...@picture.height).each do |j|\n (0...@picture.width).each do |i|\n r = ChunkyPNG::Color.r(@picture[i,j])\n g = ChunkyPNG::Color.g(@picture[i,j])\n b = ChunkyPNG::Color.b(@picture[i,j])\n \n op = 0.241 * r**2 + 0.691 * g**2 + 0.68 * b**2\n val = Math.sqrt(op).round\n val /= 13\n \n bins[val] += 1\n end\n end\n \n bins = Hash[ bins.map { |k,v| [k * 13, v] }.sort ]\n graph(bins, params[:name])\n end",
"def histogram(*args, &block)\n reduce(Hash.new(0)) do |hist, h|\n if block_given?\n v = yield(h)\n else\n v = h[args.first]\n end\n hist[v] += 1\n hist\n end\n end",
"def histogram(arr,ch)\n temp_arr=[]\n arr.each do |c|\n c.times {print ch} \n print \"\\n\"\n end\t \n temp_arr\nend",
"def histo_counts\n @histo_counts ||= calculate_histo_counts\n end",
"def hist\n return [] unless @histogram_buckets\n max = @histogram_buckets.max.to_f\n @histogram_buckets[0..-2].map { | count | { count: count, score: max > 0 ? count / max : 0 } }\n end",
"def histogram grid, n = 50000\n marginal(n).to_h grid\n end",
"def calculate_histo_counts\n counts = []\n xx = x.dup\n histo_ranges.each do |i|\n counts << xx.size - xx.delete_if { |j| j > i[1] }.size\n end\n counts\n end",
"def calc_histogram(arr, list=nil)\n\t\t\n\t\thisto = []\n\t\tif list.nil?\n\t\t\tarr[0].clusters.each_key do |clust|\n\t\t\t\tgene_class = sum_cluster(arr, clust)\n\t\t\t\tnext unless gene_class > 0\n\t\t\t\tif histo[gene_class].nil? \n\t\t\t\t\thisto[gene_class] = 1\n\t\t\t\telse\n\t\t\t\t\thisto[gene_class] += 1\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tnew_array = []\n\t\t\tarr.each do |strain|\n\t\t\t\tif list.include? strain.name\n\t\t\t\t\tnew_array.push(strain)\n\t\t\t\t\tnew_array[0].clusters.each_key do |clust|\n\t\t\t\t\t\tgene_class = sum_cluster(new_array, clust)\n\t\t\t\t\t\tif histo[gene_class].nil? \n\t\t\t\t\t\t\thisto[gene_class] = 1\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\thisto[gene_class] += 1\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\thisto.shift\n\t\thisto\n\tend",
"def histogram(htype, data_column)\n print_csv_results\n if data_column == 2\n var = \"ddays\"\n unit = 1\n elsif data_column == 3\n var = \"sum_dose\"\n if @config[\"dose_unit\"] == \"mSv\"\n unit = 1\n else\n unit = 1000\n end\n end\n # min_value -- where binning starts; max_value -- where binning ends\n min_value = @data.min_by{|key, values| values[var]}[1][var] / unit\n max_value = @data.max_by{|key, values| values[var]}[1][var] / unit\n FileUtils.mkdir_p(%w(gnuplot plots))\n erb(\"templates/histogram.gp.erb\", \"gnuplot/#{htype}.gp\", {:config => @config, :column => data_column, :htype => htype, :min => min_value, :max => max_value})\n system(\"#{@config[\"path_gnuplot\"] || \"gnuplot\"} gnuplot/#{htype}.gp\")\n puts \"Draw a #{htype}.#{@config[\"output_format\"] || \"png\"} in plots!\"\n FileUtils.rm_rf(%w(gnuplot data))\n end",
"def histogram(a_string)\n an_array = Array.new(a_string.length)\n ls_compact_string = a_string.delete(' ')\n an_array = ls_compact_string.downcase\n str_hash = Hash.new(0)\n for idx in 0..an_array.length\n item = an_array[idx]\n str_hash[item] += 1\n end\n return str_hash\nend",
"def define_histogram(name, opts = {}, &block)\n define_metric(:histogram, name, opts, &block)\n end",
"def histogram freq_group, title\n upper = freq_group.map(&:first).max\n values = spread(freq_group,(0..upper),0).map(&:second)\n chart [title], values\nend",
"def histogram(fg = 'white', bg = 'black')\n red = Array.new(HISTOGRAM_COLS, 0)\n green = Array.new(HISTOGRAM_COLS, 0)\n blue = Array.new(HISTOGRAM_COLS, 0)\n alpha = Array.new(HISTOGRAM_COLS, 0)\n int = Array.new(HISTOGRAM_COLS, 0)\n\n rows.times do |row|\n pixels = get_pixels(0, row, columns, 1)\n pixels.each do |pixel|\n red[pixel.red & MAX_QUANTUM] += 1\n green[pixel.green & MAX_QUANTUM] += 1\n blue[pixel.blue & MAX_QUANTUM] += 1\n\n # Only count opacity channel if some pixels are not opaque.\n alpha[pixel.opacity & MAX_QUANTUM] += 1 unless opaque?\n v = pixel_intensity(pixel)\n int[v] += 1\n end\n end\n\n # Scale to chart size. When computing the scale, add some \"air\" between\n # the max frequency and the top of the histogram. This makes a prettier chart.\n # The RGBA and intensity histograms are all drawn to the same scale.\n\n max = [red.max, green.max, blue.max, alpha.max, int.max].max\n scale = HISTOGRAM_ROWS / (max * AIR_FACTOR)\n\n charts = ImageList.new\n\n # Add the thumbnail.\n thumb = copy\n thumb['Label'] = File.basename(filename)\n charts << thumb\n\n # Compute the channel and intensity histograms.\n channel_hists = channel_histograms(red, green, blue, int, scale, fg, bg)\n\n # Add the red, green, and blue histograms to the list\n charts << channel_hists.shift\n charts << channel_hists.shift\n charts << channel_hists.shift\n\n # Add Alpha channel or image stats\n charts << if !opaque?\n alpha_hist(alpha, scale, fg, bg)\n else\n info_text(fg, bg)\n end\n\n # Add the RGB histogram\n charts << channel_hists.shift\n\n # Add the intensity histogram.\n charts << intensity_hist(channel_hists.shift)\n\n # Add the color frequency histogram.\n charts << color_hist(fg, bg)\n\n # Make a montage.\n histogram = charts.montage do |options|\n options.background_color = bg\n options.stroke = 'transparent'\n options.fill = fg\n options.border_width = 1\n options.tile = '4x2'\n options.geometry = \"#{HISTOGRAM_COLS}x#{HISTOGRAM_ROWS}+10+10\"\n end\n\n histogram\n end",
"def histogram(lookback)\n histo = Hash.new\n key = [@@start_token] * lookback\n get_text.each do |char|\n ((histo[key.clone] ||= { })[char] ||= 0)\n histo[key.clone][char] += 1\n key.push(char).shift\n end\n histo\n end",
"def getHistogram(sort)\n\n\tif sort == nil\n\t\treturn\n\tend\n\n\thistoGram = {}\n\tvalues = {}\n\ti = 0\n\tj = 1\n\n\twhile j <= sort.length\n\t\tif sort[i] == sort[j]\n\t\t\tj+=1\n\t\telse\n\t\t\tif j - i > 1\n\t\t\t\t#more than 1 character in string\n\t\t\t\tvalues = {sort[i] => (j-i)}\n\t\t\t\thistoGram.merge!(values)\n\t\t\tend\n\t\t\ti = j\n\t\t\tj = i + 1\n\t\tend\n\tend\n\n\thistoGram = histoGram.to_h\n\n\treturn histoGram\n\nend",
"def create_Qreads_hist_data(qualities)\r\n hist = [0] * 50\r\n qualities.each do |qual|\r\n qual.each_char do |phred|\r\n q = convert_phred33_to_q(phred)\r\n hist[q] += 1\r\n end\r\n end\r\n return hist\r\nend",
"def histograms\n metrics(Histogram)\n end",
"def calcRandHistogram2(rand, lowerBound, upperBound, nSections=100, nRuns=10000)\n bRand = boundedRand(rand, lowerBound, upperBound)\n sectionWidth = (upperBound - lowerBound) / nSections\n\n result = Array.new(nSections) {|i| [lowerBound + i*sectionWidth, 0]}\n\n nRuns.times { |i|\n r = bRand.call\n result[(r-lowerBound)/sectionWidth][1] += 1\n }\n\n result\nend",
"def extract_histogram\n Riiif::File.new(\"#{Settings.IMAGE_PATH}/#{file_name}\")\n .extract(\n Riiif::Transformation.new(\n nil, nil, nil, nil,\n # Only provide :format for this Struct\n '-define histogram:unique-colors=true -format %c'\\\n ' histogram:info'\n )\n )\n end",
"def hash_to_hist(hhash)\n hhash.map{ |k,v| [k, v.size] }.to_h.sort_by{|k,v| v}.reverse.to_h\n end",
"def histogramer(str)\r\n arr = str.split(//)\r\n storage = {}\r\n for x in arr\r\n if(x != \" \")\r\n storage[x]==nil ? storage[x]=\"*\": storage[x]+=\"*\"\r\n end\r\n end\r\n return storage\r\nend",
"def mkhist(fname, hist)\n\ttext = nil\n\tif fname =~ /\\.txt$/ || fname =~ /\\.tex/\n\t\ttext = `cat \\\"#{fname}\\\" | #{$lex}`\n\telsif fname =~ /\\.pdf$/\n\t\ttext = `pdftotext -q \\\"#{fname}\\\" - | #{$lex}`\n\telsif fname =~ /\\.doc$/ || fname =~ /\\.docx$/\n\t\ttext = `textutil -stdout -convert txt \\\"#{fname}\\\" | #{$lex}`\n\tend\n\treturn if text == nil\n\n\twcount = 0\n\ttext.each_line{ |l|\n\t\tbegin\n\t\t\ttkn = l.split\n\t\t\tif tkn.length >= 3 && tkn[2] != \"<unknown>\"\n\t\t\t\tpart = nil\n\t\t\t\tpart = \"V\" if tkn[1] =~ /^VB/ #verb\n\t\t\t\tpart = \"Ad\" if tkn[1] =~ /^JJ/ # adjective\n\t\t\t\tpart = \"Adv\" if tkn[1] =~ /^RB/ # adverb\n\t\t\t\tpart = \"N\" if tkn[1] =~ /^NN/ # noun\n\t\t\t\tpart = \"C\" if tkn[1] =~ /^CC/ || tkn[1] =~ /^IN/ # conjunction/preposition\n\t\t\t\tif part\n\t\t\t\t\tword = tkn[2] # verb base form\n\t\t\t\t\thist[part][word] = 0 if hist[part][word] == nil\n\t\t\t\t\thist[part][word] += 1\n\t\t\t\t\twcount += 1\n\t\t\t\tend\n\t\t\tend\n\t\trescue\n\t\tend\n\t}\n\n\t$stderr.print \"#{wcount} word(s) are extracted\\n\\n\"\n\treturn wcount\nend",
"def prepare_fasta_hhviz_histograms_etc\n # Reformat query into fasta format ('full' alignment, i.e. 100 maximally diverse sequences, to limit amount of data to transfer)\n @commands << \"#{HH}/hhfilter -i #{@basename}.a3m -o #{@local_dir}/#{job.jobid}.reduced.a3m -diff 100\"\n @commands << \"#{HH}/reformat.pl a3m fas #{@local_dir}/#{job.jobid}.reduced.a3m #{@basename}.fas -d 160\" # max. 160 chars in description \n \n # Reformat query into fasta format (reduced alignment) (Careful: would need 32-bit version to execute on web server!!)\n @commands << \"#{HH}/hhfilter -i #{@basename}.a3m -o #{@local_dir}/#{job.jobid}.reduced.a3m -diff 50\"\n @commands << \"#{HH}/reformat.pl -r a3m fas #{@local_dir}/#{job.jobid}.reduced.a3m #{@basename}.reduced.fas\"\n @commands << \"rm #{@local_dir}/#{job.jobid}.reduced.a3m\"\n \n # Generate graphical display of hits\n @commands << \"#{HH}/hhviz.pl #{job.jobid} #{job.job_dir} #{job.url_for_job_dir} &> /dev/null\"\n \n # Generate profile histograms\n @commands << \"#{HH}/profile_logos.pl #{job.jobid} #{job.job_dir} #{job.url_for_job_dir} 1>> #{job.statuslog_path} 2>> #{job.statuslog_path}\"\n end",
"def serializable_hash \n results.each.inject(empty_bins) do |histogram, result|\n histogram[result] = histogram[result] ? histogram[result] + 1 : 1; histogram\n end\n end",
"def get_histogram(url)\n\t\tbegin \n\t\t\tmax_colors = settings.max_colors\n\t\t\timage = Magick::ImageList.new \n\t\t\th = {}\n\n\t\t\turi = URI.parse(url)\n\n\t\t\turi.open { |f|\n\t\t\t\timage.from_blob(f.read)\n\n\t\t\t\ttotal_pixels = image.columns * image.rows\n\t\t\t\thist = image.quantize(256, Magick::RGBColorspace).color_histogram\n\t\t\t\thist = Hash[hist.sort_by { |k,v| -v }[0..max_colors - 1]]\n\n\t\t\t\tpixels = hist.each {|pixel, value|\n\t\t\t\t\th[pixel.to_color(Magick::AllCompliance, false, 8, true)] = (value/total_pixels.to_f * 100).round(2)\n\t\t\t\t}\n\t\t\t}\t\t\n\t\t\treturn h\n\t\trescue\n\t\t\traise \n\t\tend\n\tend",
"def promedio(h)\n suma = h.values.inject(0) {|sum, x| sum + x}\n p suma\n suma / h.count.to_f\nend",
"def calcRandHistogram(rand, lowerBound, upperBound, nSections=100, nRuns=10000)\n bRand = boundedRand(rand, lowerBound, upperBound)\n sectionWidth = (upperBound - lowerBound) / nSections\n\n xs = (0...nSections).collect {|i| lowerBound + i*sectionWidth}\n ys = [0]*nSections\n\n nRuns.times { |i|\n r = bRand.call\n ys[(r-lowerBound)/sectionWidth] += 1\n }\n\n [xs,ys]\nend",
"def time_histogram(time_bin,object_array)\n binned = Hash.new(0)\n p = Proc.new { |date|\n case time_bin\n when :day_of_month then date.strftime(\"%d\")\n when :day_of_week then date.strftime(\"%A\")\n when :time_of_day then date.strftime(\"%H\")\n else \n nil\n end\n }\n \n object_array.each { |v| \n date = yield v\n if date and bin = p.call(date) \n binned[bin] += 1\n end\n } \n binned\n end",
"def to_s(columns=nil)\n\n #default to an 80 column terminal, don't support < 80 for now\n if nil == columns\n columns = 80\n else\n raise ArgumentError if columns < 80\n end\n\n #Find the largest bucket and create an array of the rows we intend to print\n disp_buckets = Array.new\n max_count = 0\n total = 0\n @buckets.each_with_index do |count, idx|\n next if 0 == count\n max_count = [max_count, count].max\n disp_buckets << [idx, to_bucket(idx), count]\n total += count\n end\n\n #XXX: Better to print just header --> footer\n return \"Empty histogram\" if 0 == disp_buckets.length\n\n #Figure out how wide the value and count columns need to be based on their\n #largest respective numbers\n value_str = \"value\"\n count_str = \"count\"\n total_str = \"Total\"\n value_width = [disp_buckets.last[1].to_s.length, value_str.length].max\n value_width = [value_width, total_str.length].max\n count_width = [total.to_s.length, count_str.length].max\n max_bar_width = columns - (value_width + \" |\".length + \"| \".length + count_width)\n\n #Determine the value of a '@'\n weight = [max_count.to_f/max_bar_width.to_f, 1.0].max\n\n #format the header\n histogram = sprintf(\"%#{value_width}s |\", value_str)\n max_bar_width.times { histogram << \"-\"}\n histogram << sprintf(\"| %#{count_width}s\\n\", count_str)\n\n # We denote empty buckets with a '~'\n def skip_row(value_width)\n sprintf(\"%#{value_width}s ~\\n\", \" \")\n end\n\n #Loop through each bucket to be displayed and output the correct number\n prev_index = disp_buckets[0][0] - 1\n\n disp_buckets.each do |x|\n #Denote skipped empty buckets with a ~\n histogram << skip_row(value_width) unless prev_index == x[0] - 1\n prev_index = x[0]\n\n #Add the value\n row = sprintf(\"%#{value_width}d |\", x[1])\n\n #Add the bar\n bar_size = (x[2]/weight).to_i\n bar_size.times { row += \"@\"}\n (max_bar_width - bar_size).times { row += \" \" }\n\n #Add the count\n row << sprintf(\"| %#{count_width}d\\n\", x[2])\n\n #Append the finished row onto the histogram\n histogram << row\n end\n\n #End the table\n histogram << skip_row(value_width) if disp_buckets.last[0] != bucket_count-1\n histogram << sprintf(\"%#{value_width}s\", \"Total\")\n histogram << \" |\"\n max_bar_width.times {histogram << \"-\"}\n histogram << \"| \"\n histogram << sprintf(\"%#{count_width}d\\n\", total)\n end",
"def histo_mids\n @histo_mids ||= histo_ranges.map { |x| (x[0] + x[1]) / 2 }\n end",
"def h(n)\n font_sizes.percentile ((HEADING_DEPTH-1)-n) * HEADING_STEP\n end",
"def h(num)\n font_sizes.percentile(((HEADING_DEPTH - 1) - num) * HEADING_STEP)\n end",
"def alpha_hist(freqs, scale, fg, bg)\n histogram = Image.new(HISTOGRAM_COLS, HISTOGRAM_ROWS) do |options|\n options.background_color = bg\n options.border_color = fg\n end\n\n gc = Draw.new\n gc.affine(1, 0, 0, -scale, 0, HISTOGRAM_ROWS)\n gc.fill('white')\n\n HISTOGRAM_COLS.times do |x|\n gc.point(x, freqs[x])\n end\n\n gc.draw(histogram)\n histogram['Label'] = 'Alpha'\n\n histogram\n end",
"def get_histogram(features)\n return [] if features.empty?\n results = []\n #lower limit\n left = features.first.start - (features.first.start % 10)\n #upper limit\n right = features.last.end + (features.last.end % 10)\n #number of arrays\n start = left\n while start <= right\n results << [start, 0, 0]\n start += 10\n end\n features.each do |f|\n window = f.start - (f.start % 10)\n start_index = nil\n if window == left\n start_index = 0\n else\n start_index = (window - left) / 10\n end\n end_index = start_index + (((f.end - f.start) - ((f.end - f.start) % 10)) / 10)\n for index in start_index .. end_index\n break if index > results.length\n if f.strand.match(/\\+/)\n results[index][1] += 1\n else\n results[index][2] += 1\n end\n end\n end\n return results\n\n end",
"def histogram(query, field, interval=nil)\n raise \"The class #{self.class.name} must implement the 'histogram' method.\"\n end",
"def color_hist(fg, bg)\n img = number_colors > 256 ? quantize(256) : self\n\n begin\n hist = img.color_histogram\n rescue NotImplementedError\n warn 'The color_histogram method is not supported by this version '\\\n 'of ImageMagick/GraphicsMagick'\n else\n pixels = hist.keys.sort_by { |pixel| hist[pixel] }\n scale = HISTOGRAM_ROWS / (hist.values.max * AIR_FACTOR)\n\n histogram = Image.new(HISTOGRAM_COLS, HISTOGRAM_ROWS) do |options|\n options.background_color = bg\n options.border_color = fg\n end\n\n x = 0\n pixels.each do |pixel|\n column = Array.new(HISTOGRAM_ROWS).fill { Pixel.new }\n HISTOGRAM_ROWS.times do |y|\n column[y] = pixel if y >= HISTOGRAM_ROWS - (hist[pixel] * scale)\n end\n histogram.store_pixels(x, 0, 1, HISTOGRAM_ROWS, column)\n x = x.succ\n end\n\n histogram['Label'] = 'Color Frequency'\n return histogram\n end\n end",
"def initialize(low=nil, high=nil, width=nil)\n @count = 0\n @sum = 0.0\n @sum2 = 0.0\n @outliers_low = 0\n @outliers_high = 0\n\n # If the user asks we maintain a linear histogram where\n # values in the range [low, high) are bucketed in multiples\n # of width\n if (nil != low && nil != high && nil != width)\n\n #Validate linear specification\n if high <= low\n\traise ArgumentError, \"High bucket must be > Low bucket\"\n end\n\n if high - low < width\n raise ArgumentError, \"Histogram width must be <= histogram range\"\n end\n\n if 0 != (high - low).modulo(width)\n\traise ArgumentError, \"Histogram range (high - low) must be a multiple of width\"\n end\n\n @low = low\n @high = high\n @width = width\n else\n @low = 1\n @width = nil\n @high = to_bucket(@@LOG_BUCKETS - 1)\n end\n\n #Initialize all buckets to 0\n @buckets = Array.new(bucket_count, 0)\n end",
"def histogram(textString)\n\tfrequencies = Hash.new(0)\t\t# parameter defines the default value \n\twords = textString.split(\" \")\t\t\t# split string up into array of words\n\n\t# for each word, add it to hash, increasing frequency count (whose default was 0)\n\twords.each { |w| frequencies[w] += 1 } \n\tfrequencies = frequencies.sort_by {|a, b| b }\t# sort by hash values\n\tfrequencies.reverse!\t\t\t\t\t\t\t# make highest values first\n\n\tfrequencies.each { |word, frequency| puts word + \" \" + frequency.to_s }\nend",
"def ri_histogram(az, platform, size, options={})\n options[:az] = az\n options[:platform] = platform\n options[:size] = size\n\n request = get '/1/reporting/histogram', options\n Hashie::Mash.new request\n end",
"def initialize(url) #pass in the url...cnn\n @url = url #saving the url in n instance variable \n #this is how you create a default value for a hash\n @histogram = Hash.new(0) #taking histogram and creating a hash but setting default values at 0. we're going to be couting words so default should be zero\n\n parse #parse is a method (def below)\n\n #this is how you sort a hash!!!!\n words.each{|w| @histogram[w.downcase] +=1 } #creating the histogram \"for each word..grab each word one at a time- take the histogram and make all the words lowercase. +=1 means add words/couting for all the words that are the same. so we'll have all the words and all the counts\"\n @histogram = @histogram.sort_by {|key, value| value}.reverse #take the histogram and sort it by value. does this in ascending order. .reverse puts it in descending order\n end",
"def calculate_histo_ranges\n rng = [[effective_range[1], effective_range[1] - histo_bin_size]]\n while rng[rng.size - 1][1] > effective_range[0]\n rng << [rng[rng.size - 1][1], rng[rng.size - 1][1] - histo_bin_size]\n end\n rng\n end",
"def Occurrence_count(arr)\n\th1={}\n\tarr.each do |element|\n\t\th1[\"#{element}\"].nil? ? h1[\"#{element}\"]=1 : h1[\"#{element}\"]+=1\n\tend\n\th1.each do |key,value|\n\t\tputs \"\tOccurrence of #{ key } in the array is #{value} times \"\n\tend\t\nend",
"def get_histogram(name:, delta: nil)\n {\n method: \"Browser.getHistogram\",\n params: { name: name, delta: delta }.compact\n }\n end",
"def register_histogram( name )\n @metrics.histogram( name )\n end",
"def biodiversity_index(specimens)\n hsh = Hash.new(0)\n\n specimens.each { |ani| hsh[ani] += 1 }\n\n number_of_species = hsh.length\n smallest_population_size = hsh.min.last\n largest_population_size = hsh.max.last\n\n (number_of_species ** 2) * (smallest_population_size / largest_population_size)\n\nend",
"def hbarchart(*args)\n HBar.new(self, *args)\n end",
"def fetch_histogram(name, opts = {}, &block)\n fetch_metric(:histogram, name, opts, &block)\n end",
"def entropy(list)\n entropy = 0.0\n histogram = list.to_hist\n length = list.length.to_f\n \n histogram.keys.each do |key|\n p1 = histogram[key].to_f / length\n p2 = Math.log(p1) / Math.log(2)\n entropy -= ( p1 * p2 )\n end\n entropy\nend",
"def histo_bin_size\n @opts[:histo_bin_size] ||= effective_range_size / 50.0\n end",
"def graph(hash, name)\n Haml::Engine.new(File.read(\"../templates/hist.haml\")).def_method(hash, :render, :title)\n begin\n hist = File.open(\"#{name}\", 'w')\n hist.write(hash.render(:title => name))\n rescue IOError => e\n puts e\n end\n end",
"def urlhist(path)\n\t\tu = Hash.new(0)\n\t\tcnt = 0\n\t\tf=File.open(path)\n\t\tf.readlines.each do |line|\n\t\t\tpart = line.split(' ')\n\t\t\turl = part[6]\n\t\t\tu[url] = u[url] + 1\n\t\t\tcnt +=1\t\n\t\tend\n\t\tu.sort.each do |k, v|\n\t\t\tprint \"The frequency of #{k} | \"\n\t\t\twhile v > 0\n\t\t\t\tprint \"#\"\n\t\t\t\tv-=1\n\t\t\tend\n\t\tputs \"\\n\"\n\t\tend\n\t\t\n\tend",
"def count_letters(input_string)\n letter = input_string.scan /\\w/\n freq = Hash.new(0)\n\n # this will create a histogram count for each letter\n letter.each do |letter|\n freq[letter] += 1\n end\n\n\n\n # output letter and count\n freq.each do |letter, count|\n puts letter + \" \" + count.to_s\n end\n\nend",
"def alloc_uniform(n_bins, p1=nil,p2=nil)\n if p1.is_a? Array\n min,max=p1\n else\n min,max=p1,p2\n end\n range=max - min\n step=range / n_bins.to_f\n range=(n_bins+1).times.map {|i| min + (step*i)}\n Histogram.new(range)\n end",
"def index\n @weekly_histograms = WeeklyHistogram.all\n end",
"def savehist(hist, name) \n\thist_sort = {}\n\thist.each {|part, h|\n\t\thist_sort[part] = h.to_a.sort{ |a, b| b[1]<=>a[1]}\n\t\tFile.open(\"#{name}#{part}.txt\", \"w\") {|f| \n\t\t\thist_sort[part].each {|word, occurrence|\n\t\t\t\tf.print \"#{word} #{occurrence}\\n\"\n\t\t\t}\n\t\t}\n\t}\n\treturn hist_sort\nend",
"def repeats\n @total_letters - @hist.size\n end",
"def extract_and_parse_histogram\n self.histogram = HistogramExtractor.new(file_name)\n .extract_and_parse_histogram\n save\n end",
"def make_hash_with_count(passage)\n array_from_excerpt = strip_text(passage)#input from first question\n names_and_counts = Hash.new 0 #initializes at 0\n array_from_excerpt.each do |word|\n names_and_counts[word] += 1#for all subs. occurences, add 1\n end\n names_and_counts # must have the last line return the array!\nend",
"def histogram(buckets)\n\n # -----------------------------------------------------------------------\n # Integer\n #\n if buckets.is_a?(Integer)\n\n # Validation\n if buckets < 1\n raise ArgumentError, \"Bucket count must be >= 1, #{buckets} inserted.\"\n end\n\n # Filter invalid values\n # Nil and NaN\n func = 'lambda{|x|\n if x.nil? || (x.is_a?(Float) && x.nan?)\n false\n else\n true\n end\n }'\n filtered = self.filter(func)\n\n # Compute the minimum and the maximum\n func = 'lambda{|memo, item|\n [memo[0] < item[0] ? memo[0] : item[0],\n memo[1] > item[1] ? memo[1] : item[1]]\n }'\n min, max = filtered.map('lambda{|x| [x, x]}').reduce(func)\n\n # Min, max must be valid numbers\n if (min.is_a?(Float) && !min.finite?) || (max.is_a?(Float) && !max.finite?)\n raise Spark::RDDError, 'Histogram on either an empty RDD or RDD containing +/-infinity or NaN'\n end\n\n # Already finished\n if min == max || buckets == 1\n return [min, max], [filtered.count]\n end\n\n # Custom range\n begin\n span = max - min # increment\n buckets = (0...buckets).map do |x|\n min + (x * span) / buckets.to_f\n end\n buckets << max\n rescue NoMethodError\n raise Spark::RDDError, 'Can not generate buckets with non-number in RDD'\n end\n\n even = true\n\n # -----------------------------------------------------------------------\n # Array\n #\n elsif buckets.is_a?(Array)\n\n if buckets.size < 2\n raise ArgumentError, 'Buckets should have more than one value.'\n end\n\n if buckets.detect{|x| x.nil? || (x.is_a?(Float) && x.nan?)}\n raise ArgumentError, 'Can not have nil or nan numbers in buckets.'\n end\n\n if buckets.detect{|x| buckets.count(x) > 1}\n raise ArgumentError, 'Buckets should not contain duplicated values.'\n end\n\n if buckets.sort != buckets\n raise ArgumentError, 'Buckets must be sorted.'\n end\n\n even = false\n\n # -----------------------------------------------------------------------\n # Other\n #\n else\n raise Spark::RDDError, 'Buckets should be number or array.'\n end\n\n reduce_func = 'lambda{|memo, item|\n memo.size.times do |i|\n memo[i] += item[i]\n end\n memo\n }'\n\n return buckets, new_rdd_from_command(Spark::Command::Histogram, even, buckets).reduce(reduce_func)\n end",
"def plotRandHistogram(hist,out=nil)\n require 'gplot/Gnuplot'\n include Gnuplot\n\n xs,ys = hist\n\n plot = Plot.new(out)\n plot.title(\"random number generator histogram\")\n plot.xlabel(\"domain\")\n plot.ylabel(\"amount\")\n\n plot.draw(ArrayDataSet.new(ys, \"with\"=>\"point 3 3\", \"title\"=>nil, \"xgrid\"=>xs))\nend",
"def hist\n @hist = History.where(:asset_id => @asset)\n render layout: false\n end",
"def calculate(ratings)\n histogram_data = ratings.group(:int_value).count\n 5.times { |i| histogram_data[i+1] = 0 if !histogram_data[i+1] }\n histogram_data.to_a.sort.to_s\n end",
"def bins\n @p.size - 1\n end",
"def reset_all!\n initialize_histograms_hash\n end",
"def setValue(low, high, value)\n # We should error check the information we have.\n @low = if low <= high then low else 0 end\n @high = if low <= high then high else 0 end\n @value = if low <= value && value <= high then value else 0 end\n # Determine the percentage of the given value.\n @percent = if @high == 0 then 0 else 1.0 * @value / @high end\n\n # Determine the size of the histogram bar.\n if @orient == CDK::VERTICAL\n @bar_size = @percent * @field_height\n else\n @bar_size = @percent * @field_width\n end\n\n # We have a number of variables which determine the personality of the\n # histogram. We have to go through each one methodically, and set them\n # correctly. This section does this.\n if @view_type != :NONE\n if @orient == CDK::VERTICAL\n if @stats_pos == CDK::LEFT || @stats_pos == CDK::BOTTOM\n # Set the low label attributes.\n @low_string = @low.to_s\n @lowx = 1\n @lowy = @box_height - @low_string.size - 1\n\n # Set the high label attributes\n @high_string = @high.to_s\n @highx = 1\n @highy = @title_lines + 1\n\n string = ''\n # Set the current value attributes.\n string = if @view_type == :PERCENT\n then \"%3.1f%%\" % [1.0 * @percent * 100]\n elsif @view_type == :FRACTION\n string = \"%d/%d\" % [@value, @high]\n else string = @value.to_s\n end\n @cur_string = string\n @curx = 1\n @cury = (@field_height - string.size) / 2 + @title_lines + 1\n elsif @stats_pos == CDK::CENTER\n # Set the lower label attributes\n @low_string = @low.to_s\n @lowx = @field_width / 2 + 1\n @lowy = @box_height - @low_string.size - 1\n\n # Set the high label attributes\n @high_string = @high.to_s\n @highx = @field_width / 2 + 1\n @highy = @title_lines + 1\n\n # Set the stats label attributes\n string = if @view_type == :PERCENT\n then \"%3.2f%%\" % [1.0 * @percent * 100]\n elsif @view_type == :FRACTIOn\n \"%d/%d\" % [@value, @high]\n else @value.to_s\n end\n\n @cur_string = string\n @curx = @field_width / 2 + 1\n @cury = (@field_height - string.size) / 2 + @title_lines + 1\n elsif @stats_pos == CDK::RIGHT || @stats_pos == CDK::TOP\n # Set the low label attributes.\n @low_string = @low.to_s\n @lowx = @field_width\n @lowy = @box_height - @low_string.size - 1\n\n # Set the high label attributes.\n @high_string = @high.to_s\n @highx = @field_width\n @highy = @title_lines + 1\n\n # Set the stats label attributes.\n string = if @view_type == :PERCENT\n then \"%3.2f%%\" % [1.0 * @percent * 100]\n elsif @view_type == :FRACTION\n \"%d/%d\" % [@value, @high]\n else @value.to_s\n end\n @cur_string = string\n @curx = @field_width\n @cury = (@field_height - string.size) / 2 + @title_lines + 1\n end\n else\n # Alignment is HORIZONTAL\n if @stats_pos == CDK::TOP || @stats_pos == CDK::RIGHT\n # Set the low label attributes.\n @low_string = @low.to_s\n @lowx = 1\n @lowy = @title_lines + 1\n\n # Set the high label attributes.\n @high_string = @high.to_s\n @highx = @box_width - @high_string.size - 1\n @highy = @title_lines + 1\n\n # Set the stats label attributes.\n string = if @view_type == :PERCENT\n then \"%3.1f%%\" % [1.0 * @percent * 100]\n elsif @view_type == :FRACTION\n \"%d/%d\" % [@value, @high]\n else @value.to_s\n end\n @cur_string = string\n @curx = (@field_width - @cur_string.size) / 2 + 1\n @cury = @title_lines + 1\n elsif @stats_pos == CDK::CENTER\n # Set the low label attributes.\n @low_string = @low.to_s\n @lowx = 1\n @lowy = (@field_height / 2) + @title_lines + 1\n\n # Set the high label attributes.\n @high_string = @high.to_s\n @highx = @box_width - @high_string.size - 1\n @highy = @field_height / 2 + @title_lines + 1\n\n # Set the stats label attributes.\n string = if @view_type == :PERCENT\n then \"%3.1f%%\" % [1.0 * @percent * 100]\n elsif @view_type == :FRACTION\n \"%d/%d\" % [@value, @high]\n else @value.to_s\n end\n @cur_string = string\n @curx = (@field_width - @cur_string.size) / 2 + 1\n @cury = @field_height / 2 + @title_lines + 1\n elsif @stats_pos == CDK::BOTTOM || @stats_pos == CDK::LEFT\n # Set the low label attributes.\n @low_string = @low.to_s\n @lowx = 1\n @lowy = @box_height -2 * @border_size\n\n # Set the high label attributes.\n @high_string = @high.to_s\n @highx = @box_width - @high_string.size - 1\n @highy = @box_height - 2 * @border_size\n\n # Set the stats label attributes.\n string = if @view_type == :PERCENT\n then \"%3.1f%%\" % [1.0 * @percent * 100]\n elsif @view_type == :FRACTION\n \"%d/%d\" % [@value, @high]\n else @value.to_s\n end\n @cur_string = string\n @curx = (@field_width - @cur_string.size) / 2 + 1\n @cury = @box_height - 2 * @border_size\n end\n end\n end\n end",
"def header_init(width)\r\n display_arr = Array.new(width)\r\n count = width -1\r\n display_arr.each_with_index do\r\n |x, y|\r\n display_arr[y] = count\r\n count = count - 1\r\n end\r\n return display_arr\r\nend",
"def merge! hist\n self.frequency.reserve(hist.size) # avoid repeated reallocation if growing\n for i in 0...hist.size\n freq = hist.frequency[i] # avoid calling swig for zero frequencies\n self.accumulate(i, freq) if freq > 0\n end\n self\n end",
"def inc_h\n end",
"def calcShannonEnt(dataSet)\n numEntries = dataSet.size\n labelCounts = {}\n dataSet.each_with_index do |inst, pos|\n label = inst[-1]\n labelCounts[label]=labelCounts.fetch(label,0)+1\n end\n shannonEnt = 0.0\n labelCounts.each_pair do |k, v|\n prob=v.to_f/numEntries\n shannonEnt-=prob*Math.log2(prob)\n end\n shannonEnt\n end",
"def hcount\n @hcount += 1\n end",
"def hcount\n @hcount += 1\n end",
"def raw_count(value)\n @bins[value] || 0\n end",
"def biodiversity_index(specimens)\n hash = Hash.new(0)\n specimens.uniq.each do |sp|\n hash[sp] = specimens.count(sp) \n end\n num_species = specimens.uniq.length\n smallest_pop = hash.values.min \n largest_pop = hash.values.max\n num_species**2 * smallest_pop / largest_pop\nend",
"def initialize(sequence, arg = 10)\n @with_counts = false\n if arg.is_a?(Hash)\n bins = arg.fetch(:bins, 10)\n wc = arg[:with_counts] and @with_counts = wc\n else\n bins = arg\n end\n @sequence = sequence\n @bins = bins\n @result = compute\n end",
"def designerPdfViewer(h, word)\n heights = Array.new\n hsh = Hash.new\n (\"a\"..\"z\").each_with_index { |letter, i| hsh[letter] = h[i] }\n word.each_char { |ch| heights << hsh[ch] }\n return heights.max * heights.count\nend",
"def counts_one_line(array)\n array.each_with_object(hello = Hash.new(0)) {|x, counts| counts[x] += 1}\n hello\nend",
"def analyze_data(ary)\n frequency = count_frequency(ary)\n sort_hash(frequency)\nend",
"def frequency\n \n end",
"def empty_bins\n bins.inject({}) { |bins, bin| bins[bin] = 0; bins }\n end",
"def biodiversity_index(specimens)\n number_of_species = specimens.uniq.length\n hsh = Hash.new(0)\n specimens.each do |el|\n hsh[el] += 1\n end\n smallest_population_size = hsh.values.min\n largest_population_size = hsh.values.max\n number_of_species**2 * smallest_population_size / largest_population_size\nend",
"def list_histograms(opts = {})\n data, _status_code, _headers = list_histograms_with_http_info(opts)\n data\n end",
"def show_first_unique()\n # Iterate hash and return where value is equal to 1\n @h1.each do |k,v|\n if v == 1\n return k\n end \n end\n return -1 # Return -1 if no value with count 1.\n end",
"def print_hitnumdist(io, run)\n\n io.puts \"<h3>hit number distributions</h3>\"\n io.puts \"<div style=\\\"text-align: center;\\\">\"\n\n io.puts \"<table>\"\n (1..4).each { |row|\n io.puts \" <tr>\"\n (1..6).each { |col|\n ch = 48 + 6*(row-1) + (col-1)\n io.puts \" <td><a href=\\\"fig/#{run}/lehit#{ch}.gif\\\"><img src=\\\"fig/#{run}/thumb/lehit#{ch}.gif\\\" alt='' /></a></td>\"\n }\n io.puts \" </tr>\" \n }\n io.puts \"</table>\" \n\n io.puts \"<table>\"\n (1..$mod).each { |row|\n io.puts \" <tr>\"\n (1..$pad).each { |col|\n ch = $off + $pad*(row-1) + (col-1)\n io.puts \" <td><a href=\\\"fig/#{run}/tehit#{ch}.gif\\\"><img src=\\\"fig/#{run}/thumb/tehit#{ch}.gif\\\" alt='' /></a></td>\"\n }\n io.puts \" </tr>\" \n }\n io.puts \"</table>\" \n\n io.puts \"</div>\"\n\nend",
"def word_count(file_name, line)\n #file_array = []\n count_words_hash = {}\n line_index = 0\n\n while line_index <= line\n line_text = rio(\"hamlet.txt\").lines[line_index]\n line_array_index0 = line_text[0]\n words_array = line_array_index0.split(\" \")\n\n #puts \"Line array string: #{line_array_index0}\"\n words_array.each do |word|\n #puts \"Line text: #{line_text}, word: #{word}, index: #{line_index}\"\n if !count_words_hash.has_key?(word)\n count_words_hash[word] = 0\n end\n count_words_hash[word] += 1\n end #end array each loop\n line_index += 1\n end #end while loop\n puts \"Final hash: #{count_words_hash}\"\n\n return count_words_hash\n\nend",
"def bin_status\n rows = []\n\n # loop through to find all available bin space\n self.bins.each do |bin|\n rows << [bin.type, \"#{bin.bin_level}%\"]\n end\n # Drawing and styling the table\n table = Terminal::Table.new :rows => rows\n table = Terminal::Table.new :title => ' Your available bin space '.light_white.on_light_red, :headings => ['Bin type'.light_white, 'How much used'.light_white], :rows => rows, :style => {:width => 100, :padding_left => 1, :border_x => \"=\"}\n\n puts table\n end",
"def hit_chance hist, tn \n sum = 0\n \n #are we trying to hit a TN higher than any of our dice rolled?\n if (tn > (hist.length-1)) then \n return 0\n end \n \n #for each entry higher than or equal to our TN (every hit) add together the number of successes\n (tn..hist.length-1).each do |index| \n sum += hist[index]\n end\n \n return sum/@scale \n end",
"def samples_count(hash, status)\n soma = 0\n hash.each do |key, value|\n soma += value[status.to_sym] unless key == 'total'\n end\n return soma\n end",
"def biodiversity_index(specimens)\n all_species = specimens.uniq\n count = {}\n\n all_species.each do |species|\n count[species] = specimens.count(species)\n end\n\n number_of_species = all_species.length\n smallest_population_size = count.values.min \n largest_population_size = count.values.max\n\n number_of_species ** 2 * smallest_population_size / largest_population_size\n \nend",
"def calculate_h\n # Get all black and red cells and calculate the distance from the last cell or the first cell\n h = 0\n @state.each_with_index do |cell, index|\n if cell != 'F'\n h += (cell == 'B') ? @state.length - index : index\n end\n end\n return h\n end",
"def contar(texto)\n palavras = texto.split\n\n frequencies = Hash.new(0)\n\n palavras.each do |word|\n frequencies [word] += 1\n end\n\n frequencies = frequencies.sort_by do |wor, count|\n end\n frequencies.reverse!\n\n frequencies.each do |wor, count|\n puts wor + \" \" + count.to_s\n end\nend",
"def output_distrib_normal(params)\n recursive_hash(params[:stat].to_h, params[:tabs], params[:sort_type])\n end",
"def bar_graph(hash, title, filename)\n graph = Gruff::Bar.new\n graph.title = title\n graph.spacing_factor = 0.2\n\n hash.each do |name, runs|\n graph.data(name, runs)\n end\n graph.write(filename)\nend",
"def initialize(data, opts=Hash.new)\n prov_name=(data.respond_to?(:name)) ? data.name : \"\"\n opts_default={\n :name=>_(\"Histograma (%s)\") % prov_name,\n :width=>400,\n :height=>300,\n :margin_top=>10,\n :margin_bottom=>20,\n :margin_left=>30,\n :margin_right=>20,\n :minimum_x=>nil,\n :maximum_x=>nil,\n :minimum_y=>nil,\n :maximum_y=>nil,\n :bins=>nil,\n :line_normal_distribution=>false\n }\n @opts=opts_default.merge(opts)\n opts_default.keys.each {|k| send(\"#{k}=\", @opts[k]) }\n @data=data\n end",
"def test_histogram_min_and_max_with_fewer_buckets\n hist = ScoutApm::NumericHistogram.new(5)\n\n 10.times {\n (1..10).to_a.each do |i|\n hist.add(i)\n end\n }\n\n assert_equal 1.5, round(hist.quantile(0), 1)\n assert_equal 9.5, round(hist.quantile(100), 1)\n end",
"def calcIt\n a = [\"1\",\"5\",\"2\",\"3\",\"4\"]\n h = Hash.new(0)\n a.each do |v|\n h[v] += 1\n end\n h\n end",
"def sort_by_occurrence_h(input)\n output = input.each_with_object(Hash.new(0)){ |tag, counts| counts[tag] += 1 }\n output = Hash[output.sort_by{ |tags, counts| counts}.reverse]\n return output\n end",
"def calculate (bs, ap, buffer)\r\n\t\tpair_key = \"#{bs}-#{ap}\"\r\n\t\t@price_histogram[pair_key] = {} if !@price_histogram[pair_key]\r\n\t\t@price_histogram_topx[pair_key] = [] if !@price_histogram_topx[pair_key]\r\n\t\t\r\n\t # age histograms\r\n\t @price_histogram[pair_key].each do |k,v|\r\n\t \t@price_histogram[pair_key][k] = v * ap\r\n\t end\r\n\t # age histograms in top10 list\r\n\t @price_histogram_topx[pair_key].each do |t|\r\n\t \tt[1] = t[1] * ap\r\n\t end\r\n\t \t\r\n\t # calculate which bucket in the histogram the price belongs to\r\n\t bucket = (buffer[P].close / bs).to_i * bs\r\n\t # increase the bucket counter\r\n\t @price_histogram[pair_key][bucket] = (@price_histogram[pair_key][bucket] ? @price_histogram[pair_key][bucket] : 0) + 1\r\n\t\t# if the bucket belongs to the top10 list, increase the counter there too\r\n\t\tcorrected = false\r\n\t\t@price_histogram_topx[pair_key].each do |t|\r\n\t\t\tif t[0] == bucket\r\n\t\t\t\tt[1] = @price_histogram[pair_key][bucket]\r\n\t\t\t\tcorrected = true\r\n\t\t\t\tbreak\r\n\t\t\tend\r\n\t\tend\r\n\t\t\r\n\t\t# add the bucket to the top 10 (if we haven't increased an existing one)\r\n\t\tif !corrected\r\n\t\t\t@price_histogram_topx[pair_key].push([bucket,@price_histogram[pair_key][bucket]])\r\n\t\tend\r\n\t\t# re-sort the top10 prices by counter\r\n\t\t@price_histogram_topx[pair_key] = @price_histogram_topx[pair_key].sort_by { |k| -1 * k[1] }\r\n\t\t# chop off the last element to keep top10 array at the right length\r\n\t\tif @price_histogram_topx[pair_key].count > 10\r\n\t\t\t@price_histogram_topx[pair_key].pop\r\n\t\tend\r\n\t\t\r\n\t\t# is there a signal? compare current & previous bucket...\r\n\t\tbucket_current = (buffer[P].close / bs).to_i * bs\r\n\t\tbucket_previous = (buffer[P-1].close / bs).to_i * bs\r\n\t\t# ... if exiting a top10 bucket and entering a regular one - we have a signal!\r\n\t\tif bucket_current != bucket_previous && @price_histogram_topx[pair_key].map{ |t| t[0] }.include?(bucket_previous) && !@price_histogram_topx[pair_key].map{ |t| t[0] }.include?(bucket_current)\r\n\t\t\tif bucket_current > bucket_previous\r\n\t\t\t\treturn \"b\"\r\n\t\t\telse\r\n\t\t\t\treturn \"s\"\r\n\t\t\tend\r\n\t\telse\r\n\t\t\treturn \"h\"\r\n\t\tend\r\n\tend",
"def h(x)\n 2*x - @n - 1\n end",
"def freq(array)\n hash = Hash.new(0)\n array.each{|key| hash[key] += 1}\n hash\nend"
] |
[
"0.70034146",
"0.6895342",
"0.67857915",
"0.66723007",
"0.6634549",
"0.66141874",
"0.65223205",
"0.63947433",
"0.63616765",
"0.63451564",
"0.633878",
"0.63285637",
"0.6314085",
"0.63092387",
"0.62926716",
"0.6250752",
"0.61763084",
"0.6159175",
"0.6137487",
"0.61359644",
"0.611508",
"0.6074351",
"0.6035565",
"0.6003978",
"0.58670956",
"0.58376914",
"0.58164567",
"0.5815174",
"0.57903385",
"0.5787815",
"0.577593",
"0.57489693",
"0.5680798",
"0.5652172",
"0.5631667",
"0.5617759",
"0.5585134",
"0.5571141",
"0.5550648",
"0.5542091",
"0.5534201",
"0.55320424",
"0.5528745",
"0.5509371",
"0.5506185",
"0.5477392",
"0.5476051",
"0.5416354",
"0.5410482",
"0.54001325",
"0.5367702",
"0.5353233",
"0.53484535",
"0.5317622",
"0.53028375",
"0.5291576",
"0.52762216",
"0.52559006",
"0.52475125",
"0.5191832",
"0.51778215",
"0.51744425",
"0.51740414",
"0.51718575",
"0.5167166",
"0.5156047",
"0.5154722",
"0.5149682",
"0.51421",
"0.5130455",
"0.5119456",
"0.5119456",
"0.5116805",
"0.5084809",
"0.5081921",
"0.50758773",
"0.5073673",
"0.5066193",
"0.5055705",
"0.50533473",
"0.5051603",
"0.5050693",
"0.503447",
"0.5027846",
"0.5024253",
"0.5021049",
"0.50143754",
"0.50142807",
"0.500865",
"0.50045353",
"0.49984595",
"0.49982628",
"0.49972063",
"0.49971372",
"0.49882618",
"0.49748045",
"0.49732712",
"0.49688816",
"0.4948692",
"0.49331227"
] |
0.685367
|
2
|
codewars kata: number climber
|
def climb(n)
array = []
until n < 1
array.push(n)
n = n / 2
end
array.reverse
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def break_chocolate(n, m)\n !/\\A\\d+\\z/.match(n.to_s) || !/\\A\\d+\\z/.match(m.to_s) || n == 0 || m == 0 ? 0 : n * m - 1\nend",
"def break_chocolate(n, m)\n if n < 2\n 0\n else\n n * m - 1\n end\nend",
"def crackle(number)\n\treturn \"Crackle\" if number % 3 == 0\nend",
"def strong_num(n)\n array = n.to_s.chars.map(&:to_i)\n sumarray = []\n array.each do |number|\n sum = (1..number).inject(:*) || 1\n sumarray << sum\n end\n sumarray.sum == n ? \"STRONG!!!!\" : \"Not Strong !!\"\nend",
"def numero_cero(n)\n result = \"\" \n n.times do |i| \n if i == 0 || i == n-1\n n.times do |b| \n result += \"*\"\n end \n else\n n.times do |b| \n if b == 0 || b == n-1\n result += \"*\"\n elsif i == b\n result += \"*\"\n else\n result += \" \"\n end\n end \n end \n result += \"\\n\" \n end \n result\nend",
"def number_joy(n)\na = n.to_s.chars.map(&:to_i).reduce(:+)\nb = a.to_s.reverse.to_i\n(a * b) == n\nend",
"def fizzbuzz_kata(num) \n\t4 \nend",
"def interesting_number(number)\n number.each_char.map {|c| c.to_i}\n puts number\nend",
"def bomberMan(n, a, r, c)\n n.even? ? r.times.map {'O'* c } : ( n == 1 ? a : (n % 4 == 1 ? detonate(detonate(a)) : detonate(a)) )\nend",
"def break_chocolate(n, m)\n return 0 if n.zero? || m.zero?\n\n n * m - 1\nend",
"def carmichael(n)\n m = 1\n until (10**m).modulo(n) == 1\n m += 1\n end\n m\nend",
"def comb n\n #if integer has more than 1 digit \n if n >= 10\n #if the first digit is less than the second digit of the integer\n if get_first_digit(n) < get_first_digit(drop1(n))\n #switch first and second digits, continue combing\n (round_1_sig_fig(drop1(n)) * 10) + comb( (round_1_sig_fig(n) / 10) + drop1(drop1(n)) )\n else\n #digits are in correct positions, contiune combing\n round_1_sig_fig(n) + comb(drop1(n))\n end\n else\n #last digit reached, comb finshed.\n n\n end\n\nend",
"def MultiplicativePersistence(num)\n count = 0\n\n while num > 9\n num = num.to_s.split(\"\").map{|i| i.to_i}.inject(:*)\n count += 1\n end\n\n count\nend",
"def slippery_numbers(n)\nend",
"def k(n); 5 * n * n; end",
"def magic_numbers(count)\nend",
"def refined_super_digit(n, k)\n \nend",
"def refined_super_digit(n, k)\n \nend",
"def refined_super_digit(n, k)\n \nend",
"def new_numeral_maker(num)\n i = 'I' * ((num % 5) / 1)\n v = 'V' * ((num % 10) / 5)\n x = 'X' * ((num % 50) / 10)\n l = 'L' * ((num % 100) / 50)\n c = 'C' * ((num % 500) / 100)\n\n four_error = 'IIII'\n nine_error = 'VIIII'\n forty_error = 'XXXX'\n ninety_error = 'LXXXX'\n four_hundred_error = 'CCCC'\n\n # hundreds\n if c == four_hundred_error\n print('DC')\n else\n print(c)\n end\n\n # tens\n if l + x == ninety_error\n print('XC')\n elsif x == forty_error\n print('XL')\n else\n print(x)\n end\n\n # ones and teens\n if v + i == nine_error\n print('IX')\n elsif i == four_error\n print('IV')\n else\n print(v + i)\n end\nend",
"def numcase_number numcase\n return 0 if numcase.nil?\n return 0 if numcase.n < 5\n return numcase.n\n end",
"def chocolateFeast(n, c, m)\n answer = 0\n purchase = n / c \n answer += purchase\n free = purchase / m\n \n while free > 0 do\n answer += free\n wrappers = free * m\n purchase -= wrappers\n purchase += free\n free = purchase / m\n end\n answer\nend",
"def kaprekar(num)\n kaprekars_constant = 6174\n iterations = 0\n\n until num == kaprekars_constant\n num = (desc_digits(num) - asce_digits(num))\n iterations = iterations + 1\n end\n iterations\nend",
"def oldrconv number\n\tset = [1,5,10,50,100,500,1000]\n\tx = 0\n\tlen = set.length\n\twhile x < len\n\t\tresult = number/set[x]\n\t\tbreak if result < 1\n\t\tsres = result\n\t\tx = x + 1\n\tend\n\t\n\tbase = set[x -1]\n\t\n\tif (base !=1)\t\n\tfresult = number%base\n\telse\n\tfresult = number%5\n\tend\n\n\tif (base == 1)\n\t\tform = 'I'* sres\n\telsif (base == 5) \n\t\tform = 'V' * sres\n\telsif (base == 10)\n\t\tform = 'X'* sres\n\telsif (base ==50)\n\t\tform = 'L'* sres\n\telsif (base ==100)\n\t\tform = 'C'* sres\n\telsif (base == 500)\n\t\tform = 'D'* sres\n\telsif (base == 1000)\n\t\tform = 'M'* result\n\tend\n\tif (fresult == 0)\n\t\tputs form\n\telsif (fresult != 0 && base != 1)\n\t\tputs form + 'I'*fresult\n\telse\n\t\tputs 'I' * fresult\n\tend\nend",
"def total_card_combs(star_counter)\n c = 0\n star_counter.each { |num_of_stars| c += prmutation(5) * cmbnation(num_of_stars) if num_of_stars > 4 }\n return c\nend",
"def refined_super_digit(n, k)\n new_num = 0\n times = k\n numbers = n.to_s.split(\"\")\n if numbers.length <= 1\n return n\n end\n numbers.each do |i|\n new_num += i.to_i\n end\n new_n = times * new_num\n return super_digit(new_n) \nend",
"def refined_super_digit(n, k)\n refined = \"\"\n\n k.times do \n refined += n.to_s \n end \n refined = refined.to_i\n\n super_digit(refined)\n\nend",
"def exercise_119 (number)\n end",
"def bulls_cows(targ_num, num)\n\t#num to array\n\t#hash table?\n\ttarg_arr = targ_num.to_s.chars\n\tnum_arr = num.to_s.chars\n\n\thash = {}\n\tbull = 0\n\tcow = 0\n\ttarg_arr.each_with_index do |i,ind|\n\t\thash[i] ||= []\n\t\thash[i] << ind\n\tend\n\tnum_arr.each_with_index do |j,ind|\n\t\tif !hash[j].nil? && hash[j].include?(ind)\t\n\t\t\thash[j].delete(ind)\n\t\t\tbull += 1\n\t\telsif !hash[j].nil?\n\t\t\tcow += 1\n\t\tend\n\tend\n\tp bull, \"bulls\"\n\tp cow, \"cows\"\n\tp hash\nend",
"def break_chocolate(n, m)\n breaks = 0\n breaks += (n-1)\n n.times do |pieces|\n breaks += (m-1)\n end\n breaks\nend",
"def number_counting_seq(n)\r\n\r\nend",
"def digit; end",
"def consume_number; end",
"def disarium_number(n)\n array = n.to_s.chars.map(&:to_i)\n count, total = 1, 0\n array.each do |number|\n total += number ** count\n count += 1\n end\n total == n ? \"Disarium !!\" : \"Not !!\"\nend",
"def scream(number)\r\n\r\n if number == 0\r\n print \"crickets\"\r\n elsif number > 0\r\n print \"lol\"\r\n number.times do\r\n print \"ol\"\r\n end\r\n end\r\n \r\n\r\nend",
"def refined_super_digit(n, k)\n num_array = n.to_s.chars.map(&:to_i)*k\n array_sum = num_array.sum \n if array_sum <9 \n return array_sum\n else \n return super_digit(array_sum)\n end \nend",
"def numbers(n)\n\nend",
"def superDigit(n, k)\n target = n.split('').map(&:to_i).sum * k\n\n until target < 10\n target = target.digits.sum\n end\n\n target\nend",
"def code\n d = a + (7 * 362)\n b = c = 0\n loop do\n a = d\n while a != 0\n b = a\n a = 0\n loop do\n c = 2\n while c != 0\n break if b == 0\n\n b -= 1\n c -= 1\n end\n break if b == 0\n\n a += 1\n end\n b = 2 - c\n c = 0\n puts b\n end\n end\n end",
"def cracklepop_number(number)\n ret = number\n ret = 'Crackle' if number.divisible_by?(3)\n ret = 'Pop' if number.divisible_by?(5)\n ret = 'CracklePop' if number.divisible_by?(3, 5)\n\n ret\nend",
"def convert_numbers(input_number, result)\n if input_number >= 1000\n input_number -= 1000\n result << \"M\"\n convert_numbers(input_number, result)\n elsif input_number >= 900\n result << \"CM\"\n input_number -= 900\n convert_numbers(input_number, result)\n elsif input_number >= 500\n input_number -= 500\n result << \"D\"\n convert_numbers(input_number, result)\n elsif input_number >= 400\n input_number -= 400\n result << \"CD\"\n convert_numbers(input_number, result) \n elsif input_number >= 100\n input_number -= 100\n result << \"C\"\n convert_numbers(input_number, result)\n elsif input_number >= 90\n input_number -= 90\n result << \"XC\"\n convert_numbers(input_number, result)\n elsif input_number >= 50\n input_number -= 50\n result << \"L\"\n convert_numbers(input_number, result)\n elsif input_number >= 40\n input_number -= 40\n result << \"XL\"\n convert_numbers(input_number, result)\n elsif input_number >= 10\n input_number -= 10\n result << \"X\"\n convert_numbers(input_number, result)\n elsif input_number >= 9\n input_number -= 9\n result << \"IX\"\n convert_numbers(input_number, result)\n elsif input_number >= 5\n input_number -= 5\n result << \"V\"\n convert_numbers(input_number, result)\n elsif input_number >= 4\n input_number -= 4\n result << \"IV\"\n convert_numbers(input_number, result)\n elsif input_number >= 1\n input_number -= 1\n result << \"I\"\n convert_numbers(input_number, result)\n else\n result\n end\nend",
"def main\n print(cracklepop_numbers(1, 100))\nend",
"def super_digit(n)\n num_array = n.to_s.chars.map(&:to_i)\n sum = num_array.sum\n if sum <9\n return sum\n else \n return super_digit(sum)\n end\n \nend",
"def mod11(number); end",
"def greatHorizon numba\n movenum = 0\n greatproduct = 0\n while movenum < numba.length-3 do\n production = numba[movenum].to_i\n 1.upto(3) do |i|\n production *= numba[movenum+i].to_i\n # puts production\n end\n greatproduct = production if production > greatproduct\n movenum+=1\n end\n return greatproduct\nend",
"def coll_conject(int)\n num = int\n steps = 0\n while num > 1\n if num.even?\n num = num / 2\n else\n num = (num * 3) + 1\n end\n steps += 1\n end\n return steps\nend",
"def wonky_coins(n)\n\nend",
"def stair_climb(n)\n end",
"def persistence(n)\n count = 0\n while n > 9 do\n n = n.digits.inject(:*)\n count += 1\n end\n count\nend",
"def oneMore(number)\r\n symbol = number.to_s(2)\r\n kol = symbol.count(\"1\")\r\n puts(kol)\r\n #puts(12344.to_s(2))\r\n #puts (kol) #не_смог_через_return\r\nend",
"def luhnother(ccNumber)\n ccNumber = ccNumber.gsub(/\\d/,'').split(//).collect { |digit| digit.to_i }\n parity = ccNumber.length % 2\n sum = 0\n ccNumber.each_with_index do |digit,index|\n digit = digit * 2 if index%2==parity\n digit = digit - 9 if digit > 9\n sum = sum + digit\n end\n return (sum%10)==0\nend",
"def luhnother(ccNumber)\n ccNumber = ccNumber.gsub(/\\d/,'').split(//).collect { |digit| digit.to_i }\n parity = ccNumber.length % 2\n sum = 0\n ccNumber.each_with_index do |digit,index|\n digit = digit * 2 if index%2==parity\n digit = digit - 9 if digit > 9\n sum = sum + digit\n end\n return (sum%10)==0\nend",
"def collatz()\n print \"Please enter a positive number\\n\"\n number = gets.chomp.to_i\n while number != 1 do\n if number % 2 == 0\n number = number / 2\n puts number\n else number % 2 != 0\n number = number * 3 + 1\n puts number\n break if number == 1\n end\n end\nend",
"def collatz(n)\n if n.even? then\n # blocco eseguito se n e` numero pari\n return n/2 # esco restituendo il valore n/2\n else\n # blocco eseguito se n e` numero dispari\n return 3*n+1 # esco restituendo il valore 3*n+1\n end\nend",
"def staircase(n)\r\n # Write your code here\r\n empty = \" \"\r\n value = \"#\"\r\n n.times do |num|\r\n \tnumber = num + 1\r\n first = empty*(n-number).abs\r\n second = value*number\r\n puts first+second\r\n end\r\nend",
"def brut_force_solution\n (1...1000).inject(0){|sum, digit| ((digit % 3 == 0) || (digit % 5 == 0)) ? sum += digit : sum}\nend",
"def czech_organisation_number\n sum = 0\n base = []\n [8, 7, 6, 5, 4, 3, 2].each do |weight|\n base << sample((0..9).to_a)\n sum += (weight * base.last)\n end\n base << (11 - (sum % 11)) % 10\n base.join\n end",
"def collatz(num)\n\tcount = 0\n\twhile num > 1 do\n\t\tif num.even?\n\t\t\tnum /= 2\n\t\t\tcount += 1\n\t\telse\n\t\t\tnum = (num * 3) + 1\n\t\t\tcount += 1\n\t\tend\n\tend\n\tp \"Number of steps: #{count}\" \nend",
"def factorial(number)\n \t if (number >= 2)\n \t\tresult.each do |number| number * (number -1)\n \t\tnumber -=\n \tend\n\n \treturn result\n \telse\n \t\tnumber == 0 || number == 1\n \t\treturn 1\n \tend\n\t\t\n\nend\n#This is as close as i got to getting factorial to work without using refactoring, per instructions.\n#Couldnt really get this to work. ",
"def old_school num\n numeral = ''\n \n\n numeral += 'M'*(num/1000)\n num = num % 1000\n numeral += 'D'*(num/500)\n num = num % 500\n numeral += 'C'*(num/100)\n num = num % 100\n numeral += 'L'*(num/50)\n num = num % 50\n numeral += 'X'*(num/10)\n num = num % 10\n numeral += 'V'*(num/5)\n num = num % 5\n numeral += 'I'*(num/1)\n num = num % 1\n\n\n\n return numeral \n\nend",
"def decent_number(n)\n\tleft = 0\n\tright = 0\n\t(n+1).times do |i|\n\t\tleft = n - i \n\t\tright = n - left\n\t#\tputs \"#{left}%3 = #{left%3} | #{right}%5 = #{right%5}\"\n\t\tbreak if left % 3 == 0 && right % 5 == 0\n\tend\n\t#puts \"**l = #{left} r = #{right}\"\n\n\tif left % 3 == 0 && right % 5 == 0\n\t\tfives = \"5\"*left\n\t\tthrees = \"3\"*right\n\t\tputs fives+threes\n\telse\n\t\tputs -1\n\tend\nend",
"def refined_super_digit(n, k)\n # return super_digit(n * k)\n num = (n.to_s * k).to_i\n return super_digit(num)\nend",
"def final_chain_num(n)\n while n != 1 and n != 89\n n = sum_squares_of_digit(n)\n end\n n\nend",
"def number_in_a_can(number = 10)\n number.times { |n| puts \"The number is #{n}\" }\nend",
"def cen(num)\n cen = (((num -1) / 100) + 1)\n cen\nend",
"def digit!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 46 )\n\n \n # - - - - main rule block - - - -\n # at line 392:10: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 46 )\n\n end",
"def kaprekar(input)\n\t\tdef aux (input, count)\n\t\t\tif input == 6174\n\t\t\t\tcount\n\t\t\telse\n\t\t\t\tcount += 1\n\t\t\t\tarray = input.to_s.split(\"\").sort\n\t\t\t\tasc_number = array.join.to_i\n\t\t\t\tdesc_number = array.reverse.join.to_i\n\t\t\t\taux(desc_number - asc_number, count)\n\t\t\tend\n\t\tend\n\t\taux(input, 0)\n\tend",
"def check_miraban num\nend",
"def c(n, m) # m should <= n\n\treturn 1 if m == 1\n\tfactorial(n) / factorial(n - m)\nend",
"def silnia(n)\n silnia = 1\n while n != 0 do\n silnia *= n\n n -= 1\n end\n return silnia\nend",
"def featured2(number)\n number += 1\n number += 1 until number.odd? && number % 7 == 0\n\n loop do\n number_chars = number.to_s.split('')\n return number if number_chars.uniq == number_chars\n number += 14\n break if number >= 9_876_543_210\n end\n\n 'There is no possible number that fulfills those requirements.'\nend",
"def numeral(number)\n\tnumerals = {:I => 1, :V => 5, :X => 10, :L => 50, \n\t\t:C => 100, :D => 500, :M => 1000}\n\torder = [:M,:D,:C,:L,:X,:V,:I]\n\toutput = \"\"\n\torder.each do |n|\n\t\tif numerals[n] <= number\n\t\t\ttimes = number / numerals[n]\n\t\t\tremainder = number % numerals[n]\n\t\t\toutput += n.to_s * times\n\t\t\tnumber = remainder\n\t\tend\n\tend\n\toutput\nend",
"def inmj\n result = 0\n (1..9).each do |base|\n exponent = 1\n while (intGetLengthInt(base ** exponent) == exponent)\n result += 1\n exponent += 1\n end\n end\n result\nend",
"def num_convert\n\tputs 'give me a number(1...3000)'\n\tnum_input = gets.chomp\n\tif !num_input.empty?\n\t\tif num_input.to_i <= 0\n\t\t\tputs 'Must use positive integer' \n\t\t\treturn\n\t\telse\n\t\t\tputs roman_numeral num_input.to_i\n\t\t\tnum_convert\n\t\tend\n\tend\nend",
"def generate_code(number)\n charset = Array('A'..'Z') + Array('a'..'z')\n Array.new(number) { charset.sample }.join\nend",
"def dig_number(number)\n arr_dig = number.to_s.chars\n count = arr_dig.size\n arr_dig.map {|dig| dig.to_i ** count} \nend",
"def generate_code(number)\n charset = Array('A'..'Z') + Array(0..9)\n Array.new(number) { charset.sample }.join\n end",
"def refined_super_digit(n, k)\n concatenated = \"#{n}\" * k\n return super_digit(concatenated.to_i) \nend",
"def digit_factorials\n max = biggest_possible_digit_factorial\n results = []\n \n test_number = 10\n \n while test_number <= max\n results << test_number if is_curious?(test_number)\n test_number += 1\n end\n \n print results\n results.inject(:+)\nend",
"def integer_break(n)\nend",
"def problem5 ( )\n lcm_1_to_n(20)\nend",
"def digit_match(n, m)\n\nend",
"def to_num(input)\n result = 0\n #iterate on roman number hash\n MAPPING.each do |k,v|\n while input.index(k) == 0 #if \"CL\".index(\"C\") == 0\n result += v #assign value of current hash key\n input.slice!(0) #remove string \"C\" from input and so on\n end\n end\n result\n end",
"def refined_super_digit(n, k)\n s = \"\"\n k.times do\n s += n.to_s\n end\n return super_digit(s.to_i)\nend",
"def AdditivePersistence(num)\n count = 0\n\n while num > 9\n num = num.to_s.split(\"\").map{|i| i.to_i}.inject(:+)\n count += 1\n end\n\n count\nend",
"def numeralise!(num, ans=\"\", mapping = roman_mapping)\n return ans if num == 0\n \n mapping.keys.each do |key_num|\n next unless key_num <= num\n quotient, modulus = num.divmod(key_num)\n ans << (mapping[key_num] * quotient)\n return numeralise!(modulus, ans) if quotient > 0\n end\nend",
"def imc\n\t\tnum = (@peso/(@talla*@talla)).round(2)\n\t\tif num < 18.5\n\t\t\tnum #- Bajo peso\"\n\t\telsif num > 18.5 and num < 24.9\n\t\t\tnum #- Adecuado\"\n\t\telsif num > 25.0 and num < 29.9\n\t\t\tnum #- Sobrepeso\"\n\t\telsif num > 30.0 and num < 34.9\n\t\t\tnum #Obesidad grado 1\"\n\t\telsif num > 35.0 and num < 39.9\n\t\t\tnum #- Obesidad grado 2\"\n\t\telsif num > 40\n\t\t\tnum #- Obesidad grado 2\"\n\t\tend\t\t\t\n\tend",
"def collatz_sequence(number)\n sequence = [number]\n\n while number != 1\n number.even? ? number = (number / 2) : number = (3 * number) + 1\n sequence.push(number)\n end\n\n sequence\nend",
"def expanded_form(num)\n # Your code here\n ans = []\n len = num.to_s.length\n k = (\"1\" + \"0\" * len).to_i/10\n while num > 0\n if num/k >= 1\n ans << num/k * k\n num -= num/k * k\n k = k / 10\n elsif num < 10\n ans << num\n num -= num\n end\n end\n return ans.join(\" + \")\nend",
"def additivePersistence(number, times)\n # your magic\n numString = number.to_s\n sum = 0\n numString.each_char {|digit| sum += digit.to_i}\n\n if sum > 9 \n\t times += 1\n puts additivePersistence(sum, times)\n else\n puts times\n end\nend",
"def sheep_count(num)\n \nend",
"def refined_super_digit(n, k)\n return n if n < 10\n super_digit(n.digits.sum * k) # k magic hint from https://www.hackerrank.com/challenges/super-digit/forum\nend",
"def prime_factorization(num)\n \nend",
"def prime_factorization(num)\n \nend",
"def prime_factorization(num)\n \nend",
"def the3(number)\n english = ''\n digits = {'0' => '', '1' => 'one', '2' => 'two', '3' => 'three', '4' => 'four', '5' => 'five',\n '6' => 'six', '7' => 'seven', '8' => 'eight', '9' => 'nine'}\n for i in 0..2\n case i\n when 0 then english += digits[number[i]] + (number[i] == '0' ? '' : ' hundred ')\n when 1 then english += number[i] == '0' ? '' : the2(number[1..2])\n when 2 then english += number[i - 1] == '1' ? '' : digits[number[i]]\n end\n end\n return english\nend",
"def number_decoder( input )\n output = \"\"\n \n # build number to letter hash\n translator = Hash.new\n letters = ('A'..'Z').to_a\n letters.each_index{|i| translator [(i+1).to_s] = letters[i] }\n \n input.each(' ') do |nibble|\n\n \n num = nibble.strip.to_i\n if (num == 0 or num.nil?) then output << \" \"\n else\n case (num-1)/26\n when 0 then output << translator[num.to_s]# + ' '\n when 1 then output << translator[(num - 26).to_s]\n end\n end\n end\n \n output\nend",
"def factRubyStyle (n)\n\tn == 0? 1 : n * factRubyStyle(n-1)\nend",
"def luhns(a)\n\tb = a.to_s[0..-2].reverse.split(\"\").to_a.map{|v|v.to_i}\n\t(b.each_index{|i|i.even? ? b[i]=b[i]*2>9?b[i]*2-9:b[i]*2:i=i}.inject(:+)+a)%10==0\nend",
"def prime_factorization(num)\nend",
"def collatz_length(number)\n sequence_length = 1\n \n while number != 1\n number.even? ? number = (number / 2) : number = (3 * number) + 1\n sequence_length += 1\n end\n\n sequence_length\nend"
] |
[
"0.6796888",
"0.6543511",
"0.64249796",
"0.6331908",
"0.633165",
"0.6309971",
"0.628733",
"0.6256616",
"0.6237597",
"0.62044233",
"0.620167",
"0.61951876",
"0.6192066",
"0.6169189",
"0.6143555",
"0.61297655",
"0.6102379",
"0.6102379",
"0.60974514",
"0.6091644",
"0.6069785",
"0.60344094",
"0.6019538",
"0.6018353",
"0.6008641",
"0.59958196",
"0.5990738",
"0.59747815",
"0.59623533",
"0.59606606",
"0.59603035",
"0.5959442",
"0.5950527",
"0.59455305",
"0.59388506",
"0.5928245",
"0.5923498",
"0.5913976",
"0.5902221",
"0.5901329",
"0.5901319",
"0.5896727",
"0.58841515",
"0.587361",
"0.586807",
"0.58533835",
"0.5841816",
"0.58397543",
"0.58386725",
"0.5838179",
"0.58353376",
"0.58353376",
"0.5830605",
"0.5826121",
"0.5825559",
"0.58246887",
"0.5822106",
"0.5815216",
"0.5804485",
"0.5802016",
"0.57999897",
"0.5785613",
"0.5785591",
"0.5773352",
"0.5771448",
"0.5767566",
"0.5757572",
"0.57523483",
"0.5742588",
"0.5736775",
"0.57279354",
"0.572487",
"0.5721445",
"0.5720969",
"0.5719922",
"0.57170767",
"0.57156086",
"0.571459",
"0.57112396",
"0.5709706",
"0.57084996",
"0.5707473",
"0.57059354",
"0.5705637",
"0.5703403",
"0.56956834",
"0.5693108",
"0.5690151",
"0.56898856",
"0.5689294",
"0.5686605",
"0.5684964",
"0.5682927",
"0.5682927",
"0.5682927",
"0.5681302",
"0.56789434",
"0.5676366",
"0.5670244",
"0.5670013",
"0.5669968"
] |
0.0
|
-1
|
codewars kata: powers of 2
|
def powers_of_two(n)
(0..n).map{ |number| 2**number }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def powers_of_2\r\n\t\tunless $powers_of_2\r\n\t\t\t$powers_of_2 = [1]\r\n\t\t\t((BASE_BYTE << 3) - 1).times do |i|\r\n\t\t\t\t$powers_of_2[i + 1] = $powers_of_2[i] << 1\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\treturn $powers_of_2\r\n\tend",
"def self_powers_2\n (1..1000).map {|i| i**i}.reduce(:+) % (10**10)\nend",
"def powers_of_two(x)\n 0.upto(x) {|n| (2**n) if x >= (2**n)}.compact\nend",
"def power_of_2?(a) Math.log2(a.to_i).then { |x| x == x.to_i } == true end",
"def power_of_two?(num)\n product = 1\n\n while product < num \n product *= 2\n end \n\n product == num \nend",
"def powers_of_two(s)\n\tyield 1\n\ti = 2\n\twhile i < s\n\t\tyield i\n\t\ti = i * 2 \n\tend\nend",
"def power_of_two?(num)\n product = 1\n while product < num\n product *= 2\n end\n\n num == product\nend",
"def powersOfTwo(n)\n return (0..n).map {|x| 2**x}\nend",
"def pow_of_2(int)\n\tif int <= 0\n\t\treturn 1\n\tend\n\n\tint -= 1\n\treturn 2 * pow_of_2(int)\nend",
"def powersOfTwo(num)\n\treturn false if(num % 2 != 0)\n\treturn true if( num / 2 == 1)\n\tpowersOfTwo(num / 2)\n\nend",
"def perfect_power(n)\n\nend",
"def power_of_2?(n)\n n & (n - 1) == 0\nend",
"def power_of_two?(number)\n (0..number).each do|num| \n # 2**num == 16\n if 2**num == number\n return true\n end \n if 2**num > number\n return false \n end\n end \n return \"problem\"\nend",
"def pow2(x, n)\n if n == 0\n return 1\n end\n temp = pow2(x, n/2)\n if n % 2 == 0\n return temp * temp\n else\n return x*temp*temp\n end\nend",
"def test_powers_of_two\n 100.times do |p|\n n = 2 << p\n\n assert_equal n, n.to_ber.read_ber\n end\n end",
"def powers1(n)\n n.to_s(2).to_i.digits.map.with_index { |c, i| c.to_i * 2**i }.reject(&:zero?)\nend",
"def power(n)\n n ** 2\nend",
"def PowersofTwo(num)\n idx = 0\n\n while 2 ** idx <= num\n return true if 2 ** idx == num\n idx += 1\n end\n\n false\nend",
"def powers_of_two(num)\n until num < 2 || num.odd?\n return true if num == 2\n num /= 2\n end\n false\nend",
"def power_of_two?(n)\n n & (n-1) == 0\nend",
"def is_power_of_two(n)\n return false if n < 1\n return true if n == 1\n power = 1\n while power <= n\n power *= 2\n return true if power == n\n end\n false\nend",
"def power_of_two2( num )\n\n\n if num < 1\n return false\n end\n\n while true\n\n if num == 1\n return true\n\n elsif num % 2 == 0 # keep doing until remainder is not zero ( a factor of two )\n num = num / 2\n # puts( num ) # eventually num will equal to 1\n\n else\n return false\n end\n\n end # while\n\n\n\nend",
"def rpower(n) end",
"def is_power_of_two?(num)\n if(Math::log(num, 2) % 1 != 0)\n return false \n end \n return true\nend",
"def #power(a,b)\n\ta ** b\nend",
"def raise_to_power(x, y)\n #every shift left is like a * 2\n #11000\nend",
"def power_of_two?(num)\n\nend",
"def is_power_of_two?(num)\nresult = []\n\ni = 0\nuntil i == num\n\tresult.push(2 ** i)\n\ti += 1\nend\nif result.include?(num)\n\treturn true\nelse return false\nend\nend",
"def power(nb1, nb2)\n return nb1 ** nb2\nend",
"def power(n1, n2)\r\n n1.to_i ** n2.to_i\r\nend",
"def exp2(base, power)\n puts \"exp2\"\n return 1 if power == 0\n return base if power == 1 #\n\n if power.even?\n exp2(base, power / 2) ** 2\n else\n base * ( exp2(base, (power - 1) / 2) ** 2 )\n end\nend",
"def largest_power_of_2(n)\n if (n <= 0) #usage condition check\n return\n end\n exponent = 0\n current = BASE ** exponent\n while (current <= n)\n if (current == n)\n return exponent\n end\n exponent += 1\n current = BASE ** exponent # recalculate power\n end\n return exponent - 1\nend",
"def pow (base_num , pow_num)\n results=1\n pow_num.times do \n results*=base_num\n end \n results\nend",
"def exponent_v2(b, n)\n puts s += 1\n if n == 0 \n return 1\n elsif n == 1 \n return b\n elsif n.even?\n rec = exponent_v2(b, n / 2)\n rec * rec\n else \n rec = exponent_v2(b, (n - 1) / 2)\n b * rec * rec\n end\nend",
"def num_to_power(num, power)\n # count = 1\n return 1 if power == 0\n return num if power == 1\n num_multiply = power / 2\n product = 1\n num_multiply.times do\n product *= multiply(num, num)\n end\n if power % 2 == 1\n product *= num\n end\n product\nend",
"def power_of_two?(num)\n # i = 0\n # power = 2**i\n\n # while num >= power \n # if num == power\n # return true\n # else\n # i += 1 \n # power = 2**i\n # end \n # end\n # false\n\n (0..num).each do |ele|\n if 2**ele == num\n return true\n end\n end\n false\n\nend",
"def is_power_of_2?(n)\n return (n & (n-1)) == 0 # can be written as \"n & (n-1) == 0\" as well. Parenthesis added for clarity.\nend",
"def power(a,b)\n a.to_i ** b.to_i\nend",
"def power(n1, n2)\n return n1**n2\nend",
"def power_of_two?(num)\n\n return true if num == 1\n (1..num).each do |n| \n if 2**n == num\n return true\n end\n end\n false\nend",
"def power_of_two?(x)\n x > 0 && x & (x - 1) == 0\nend",
"def pow(n,p)\n ans = 1\n while p!=0 do\n ans = ans*n%BASE if p&1==1\n n=n*n%BASE\n p=p>>1\n end\n ans\n end",
"def nearest_power_of_2(num)\n temp = num\n temp -= 1\n temp |= temp >> 1\n temp |= temp >> 2\n temp |= temp >> 4\n temp |= temp >> 8\n temp |= temp >> 16\n temp += 1\n temp\nend",
"def pow( x, n)\n if (n == 0)\n return (1)\n elsif (n % 2 == 0)\n value = pow(x, n / 2)\n return (value * value)\n else\n value = pow(x, n / 2)\n return (x * value * value)\n end\nend",
"def power_to_the_n(num, power)\n if power == 0\n 1\n elsif power == 1\n num\n else \n counter = 2\n total = multiply(num, num)\n while counter < power\n total = multiply(total, num)\n counter += 1\n end\n total \n end \nend",
"def power(base, power)\n base ** power\nend",
"def power_of_n(n, power)\n result = 1\n power.times {result = multiply(n, result)} # similar to recursion\n result\nend",
"def ilog2(n)\r\n\t\tbits = (n.size - BASE_BYTE) << 3\r\n\t\treturn bits + Bisect.bisect_right(powers_of_2, n >> bits) - 1\r\n\tend",
"def power2(key)\n self.class.power2(key)\n end",
"def pow(a,b)\n power=1\n for i in 1..b\n power=power*a\n end\n return power\nend",
"def exp2(base, power)\n return 1 if power == 0\n half = exp2(base, power / 2)\n\n if power.even?\n half * half\n else\n # note that (power / 2) == ((power - 1) / 2) if power.odd?\n base * half * half\n end\nend",
"def dig_pow(n, p)\n power_arr = []\n\n digit_arr = n.to_s.chars.map(&:to_i)\n\n digit_arr.each do |digit|\n power_arr << (digit ** p)\n p += 1\n end\n\n\n if power_arr.sum % n == 0\n k = power_arr.sum / n\n else\n -1\n end\nend",
"def power(num,pow)\n if pow == 0\n num\n else\n total = 1\n count = 0\n while count < pow\n total *= num\n count += 1\n end\n return total\n end\nend",
"def power(n1, n2)\n n1 ** n2\nend",
"def power(b, n)\n\n\t# b^n.to_i\n\n\tb ** n\n\nend",
"def exp2(base, power)\n return 1 if power == 0\n\n half = exp2(base, power / 2)\n\n if power.even?\n half * half\n else\n # note that (power / 2) == ((power - 1) / 2) if power.odd?\n base * half * half\n end\nend",
"def power_of_n(num, exponent)\n num ** exponent\nend",
"def pow(base_num, pow_num)\n result = 1\n pow_num.times do |index|\n result = result * base_num\n end\n\n return result\nend",
"def object_of_power; end",
"def power (n1, n2)\n\tn = n1 ** n2\n\treturn n\nend",
"def power_of_n(number, power)\n array = [number] * power\n base_number = 1\n array.each do |num|\n base_number = multiply(base_number, num)\n end\n base_number\nend",
"def is_power_of_two?(num)\n return true if num == 1 \n\n result = num\n while result > 2 \n if result % 2 == 0\n result = result / 2\n return true\n end \n end\nend",
"def exp_two(num, power)\n return 1 if power == 0\n return num if power == 1\n if power.odd?\n exp = exp_two(num, (power - 1) / 2)\n num * exp * exp\n else\n exp = exp_two(num, power / 2)\n exp * exp\n end\nend",
"def mod_pow(base, power, mod)\n result = 1\n while power > 0\n result = (result * base) % mod if power & 1 == 1\n base = (base * base) % mod\n power >>= 1;\n end\n result\nend",
"def powerI(power, base)\n acc = 1\n power.times { acc *= base }\n return acc\nend",
"def power_of_2?(number)\n !number.to_s(2).match(/\\A10*\\Z/).nil?\nend",
"def power(base, power)\r\n base ** multiply(power, 1)\r\nend",
"def rec_exp_2(base, power)\nend",
"def is_power_of_two?(num)\n power = 1\n loop do\n break false if power > num\n break true if num == power\n power *= 2\n end\nend",
"def power(a, b)\n return a**b\nend",
"def calc(n,k)\n # the expressions '(1<<n)-1' and '2**n-1' are equivalent\n (k & ((1<<n)-1)) == 2**n-1\nend",
"def is_power_of_two(n)\n\n if Math.sqrt(n) % 1 == 0\n puts \"#{n} is a power of 2\"\n else\n puts \"#{n} is not a power of 2\"\n end\nend",
"def is_power_of_two?(num)\n \n if num < 1\n return false\n end\n \n while true \n if num == 1\n return true\n elsif num % 2 == 0\n num = num / 2 \n else\n return false \n end\n end\nend",
"def power(num, power)\n\tnum**power\nend",
"def power_to_the_n(number, power)\n return 1 if power == 0\n result = 1\n while power > 0\n result = multiply(result, number)\n power -= 1\n end\n result\nend",
"def power(num, power)\r\n num ** power\r\nend",
"def pow(base, exponent) #(3, 4) ==> 3 * 3 * 3 * 3 = \n return 1 if exponent == 0 \n #return base if exponent == 1\n base * pow(base, exponent - 1)\nend",
"def modpow(a, b, n, m)\n if n == 0\n [1, 0]\n elsif n % 2 == 0\n modpow((a * a) % m, (a * b + b) % m, n / 2, m)\n else\n c, d = modpow(a, b, n - 1, m)\n [(a * c) % m, (a * d + b) % m]\n end\nend",
"def pow base, p\n base ** p\n end",
"def raise_to_power_brute(x, y)\n result = x\n\n while y > 1\n result *= x\n y -= 1\n end\n\n result\nend",
"def pow(x, n)\n if n == 0\n return 1\n elsif n % 2 == 0\n return pow(x, n/2) * pow(x, n/2)\n else\n return x*pow(x, n-1)\n end\nend",
"def power(n)\r\n sum = (2**n).to_s.each_char.inject {|a, b| a.to_i + b.to_i}\r\n \"The Sum of The Digits of The Number 2**#{n} is: #{sum}\"\r\nend",
"def pow(base, exponent)\n\n result = 1\n exponent.times do \n result = base.to_i * result\n end\n result\nend",
"def pow(base, y)\n result = 1\n for i in 0..(y - 1)\n result = result * base\n end\n puts \"\\n#{base}^(#{y}) = #{result}\\n\"\n end",
"def power_of(num, exponent)\n product = multiply(num, num)\n \n (exponent - 2).times { product *= num }\n\n product\nend",
"def pow(base_num, pow_num)\n result = 1\n pow_num.times do\n result = result * base_num\n end\n return result\nend",
"def inmj\n result = 0\n (1..9).each do |base|\n exponent = 1\n while (intGetLengthInt(base ** exponent) == exponent)\n result += 1\n exponent += 1\n end\n end\n result\nend",
"def power_it(number_1, number_2)\n number_1 ** number_2\nend",
"def power_of_two?(num)\n until num.to_f <= 1\n num = num.to_f/2\n end\n num == 1\nend",
"def PowersofTwo(num)\n\n is_power_two=true\nwhile(num >1)\n is_power_two=false if num%2!=0\n num=num/2\nend\nis_power_two\nend",
"def pow(base_num, pow_num)\n result = 1\n pow_num.times do |index|#loop trough the code ex: if pow_num is = 3, the loop will trough 3 times.\n result = result * base_num\n end\n return result\nend",
"def power(n1, n2)\n output = n1\n i = 0\n \n while i < n2\n i += 1\n output = output * n1\n \n end\n return output\nend",
"def log2(n)\n return nil if n <= 0\n\n # return nil unless n is a power of 2\n return nil unless (n & (n - 1)).zero?\n\n bits = 0\n\n while n > 255\n n >>= 8\n bits += 8\n end\n\n while n > 0\n n >>= 1\n bits += 1\n end\n bits - 1\n end",
"def power(curr_value, to_power)\n curr_value**to_power\nend",
"def check_power(n)\n if n <= 1\n return [n, 1]\n end\n x = n\n b = 1\n c = 2\n while true\n found = false\n while c <= 8 * x.size\n res = NumberUtil::is_bth_power(x, c)\n if res\n x = res\n b *= c\n found = true\n break\n end\n if c >= 3\n c += 2\n else\n c += 1\n end\n end\n if found\n next\n else\n break\n end\n end\n return [x, b]\n end",
"def nth_powers(n)\n (1..9).to_a.map {|num| num**n}\nend",
"def power_to_n(num, power)\n result = 1\n power.times { result = multiply(result, num) }\n result\nend",
"def is_power_of_two?(num)\n return false if num < 1\n\n loop do\n num, rem = num.divmod(2)\n break false if rem != 0\n break true if num == 1\n end\nend",
"def my_pow(x, n)\n return x if n == 1\n return x * x if n == 2\n return x / x if n == -2\n\n if n > 0\n x * my_pow(x, n - 1)\n else\n my_pow(x, n + 1)\n end\nend",
"def exponentiation_2(b, n)\n return 1 if n == 0\n return b if n == 1\n\n if n.even?\n exponentiation_2(b, n / 2) ** 2\n else\n b * (exponentiation_2(b, (n - 1) / 2) ** 2)\n end\nend"
] |
[
"0.81443995",
"0.7788771",
"0.7522795",
"0.74974054",
"0.7483794",
"0.74133366",
"0.73411417",
"0.72870654",
"0.7227142",
"0.7213281",
"0.7207004",
"0.71964884",
"0.71784556",
"0.71650875",
"0.7154648",
"0.7154399",
"0.7143813",
"0.7033037",
"0.7027812",
"0.7021939",
"0.7021688",
"0.6984045",
"0.69777095",
"0.6959891",
"0.69531214",
"0.69523686",
"0.69449985",
"0.6936863",
"0.6933327",
"0.6917251",
"0.6909211",
"0.69060796",
"0.6870206",
"0.68650264",
"0.68648",
"0.68599164",
"0.6842023",
"0.6839039",
"0.68378544",
"0.68358916",
"0.6827358",
"0.6827186",
"0.68191713",
"0.681707",
"0.68161494",
"0.68146133",
"0.68141013",
"0.6807449",
"0.6803248",
"0.6798424",
"0.67979354",
"0.6789045",
"0.6786203",
"0.6785812",
"0.67680925",
"0.67651254",
"0.6744999",
"0.6743045",
"0.6738142",
"0.6731144",
"0.67297864",
"0.6723442",
"0.6717088",
"0.67156744",
"0.6697148",
"0.6693461",
"0.6691578",
"0.6691308",
"0.6684865",
"0.6676234",
"0.66697264",
"0.66696453",
"0.6668039",
"0.66529393",
"0.6646432",
"0.6644201",
"0.6639932",
"0.6636792",
"0.66364175",
"0.6633409",
"0.6613348",
"0.6608261",
"0.6600685",
"0.6599976",
"0.6590324",
"0.6590073",
"0.6580079",
"0.6571884",
"0.65624225",
"0.6559483",
"0.6557593",
"0.6550607",
"0.6541554",
"0.65384316",
"0.65231866",
"0.65146965",
"0.6510828",
"0.6495375",
"0.6485642",
"0.6482977"
] |
0.7446869
|
5
|
codewars kata: colour association
|
def colour_association(array)
array.map{|pair| Hash[pair.first, pair.last]}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def color(color); end",
"def colors; end",
"def colorize!; @colors = true; end",
"def colorized?; end",
"def scan_for_colors; end",
"def generate_color_scheme\n if values_bits[Constants::V_Use_of_colors]<=2.5 #No colors \n if values_bits[Constants::V_Type_of_BG]<4.5 and @image_colors[0].get_lightness > Constants::Min_lightness#image as bg\n scheme = 'dark'\n elsif values_bits[Constants::V_Type_of_BG]<4.5 and @image_colors[0].get_lightness < Constants::Min_lightness\n scheme = 'light'\n elsif values_bits[Constants::V_Darkness]<=4.5#Light\n scheme = 'dark'\n elsif values_bits[Constants::V_Darkness]>=4.5#Dark\n scheme = 'light'\n end\n \n if scheme == 'dark'\n @colors[0]=Colour.new(255,255,255)\n @colors[1]=Colour.new\n @colors[2]=Colour.new\n @colors[3]=Colour.new\n @colors[4]=Colour.new(40,40,40)\n @colors[5]=Colour.new(55,55,55)\n @colors[6]=Colour.new(70,70,70)\n @colors[7]=Colour.new\n elsif scheme == 'light'\n @colors[0]=Colour.new\n @colors[1]=Colour.new(255,255,255)\n @colors[2]=Colour.new(255,255,255)\n @colors[3]=Colour.new(255,255,255)\n @colors[4]=Colour.new(240,240,240)\n @colors[5]=Colour.new(235,235,235)\n @colors[6]=Colour.new(230,230,230)\n @colors[7]=Colour.new(255,255,255)\n end\n \n else #Colors\n #Main color (colors[1] - colors[3])\n if values_bits[Constants::V_Main_color]<=2 #Complementary main pic\n @colors[1] = @image_colors[1].get_complementary\n elsif values_bits[Constants::V_Main_color]>2 and values_bits[Constants::V_Main_color]<=5 #Contrast main pic\n @colors[1] = @image_colors[1].get_contrasted\n elsif values_bits[Constants::V_Main_color]>5 and values_bits[Constants::V_Main_color]<=8 #main_pic\n @colors[1] = @image_colors[1]\n else #random\n @colors[1] = Colour.new.get_random_color()\n end\n @colors[2] = colors[1].get_lighter\n @colors[3] = colors[1].get_darker\n \n #Accent colors (colors[4] - colors[6])\n if values_bits[Constants::V_Accent_colors]<=2 #secondary\n accent_colors = @image_colors[2].get_analogous\n @colors[4]=@image_colors[2]\n 2.times do |n|\n @colors[n+5] = accent_colors[n]\n end\n elsif values_bits[Constants::V_Accent_colors]>2 and values_bits[Constants::V_Accent_colors]<=4.5 #triadic\n accent_colors = colors[1].get_triadic\n 3.times do |n|\n @colors[n+4] = accent_colors[n]\n end\n elsif values_bits[Constants::V_Accent_colors]>4.5 and values_bits[Constants::V_Accent_colors]<=8 #analogous\n accent_colors = colors[1].get_analogous\n 3.times do |n|\n @colors[n+4] = accent_colors[n]\n end\n else #complementary\n @colors[4] = colors[1].get_complementary\n accent_colors = colors[4].get_analogous\n 2.times do |n|\n @colors[n+5] = accent_colors[n]\n end\n end\n \n #Background color (colors[0])\n if values_bits[Constants::V_BG_color]<7 #Plain background\n if values_bits[Constants::V_Darkness]>4.5 #Dark design \n @colors[0]=colors[1].get_dark\n else #Light design\n @colors[0]=colors[1].get_pale\n end\n else\n @colors[0]=Colour.new\n end\n \n #Text color (colors[7])\n if values_bits[Constants::V_Type_of_BG]>=4.5 #Contrast with plain background\n if values_bits[Constants::V_Darkness]<4.5 #Light bg\n @colors[7]=Colour.new\n else #Dark bg\n @colors[7]=Colour.new(255,255,255)\n end\n else #Contrast with picture as background\n if @image_colors[0].get_lightness > Constants::Min_lightness\n @colors[7]=Colour.new\n else\n @colors[7]=Colour.new(255,255,255)\n end\n end\n end\n \n @background = @colors[0]\n end",
"def colour_changer(key)\n @@colours = [key]\n end",
"def colorize_iterating map\n # map from country to its color\n colorized = {}\n map.each do |country, neighbors|\n local_colorized = colorized.clone # fake a functional view of colorized\n color = Ambit.choose Colors\n #puts \"considering #{color} for #{country}\"\n neighbors.each {|n| Ambit.assert colorized[n] != color}\n local_colorized[country] = color\n colorized = local_colorized\n end\n colorized\nend",
"def colour_graoh(colors, graph)\n graph.nodes.each do |node|\n \n all_neighbouring_colors = []\n \n node.neighbours.each do |neighbour|\n all_neighbouring_colors << neighbour.color if !all_neighbouring_colors.include?(neighbour.color)\n end\n \n colors.each do |color|\n node.color = color if !all_neighbouring_colors.include?(color)\n break\n end\nend",
"def hsla_color; end",
"def green\n colorize(32)\n end",
"def add_color\n if !color\n self.color = %w(\n #000000 #0000FF #00FF00 #FF0000 #FFFF00 #9900CC\n #CC0066 #00FFFF #FF00FF #C0C0C0 #00008B #FFD700\n #FFA500 #FF1493 #FF00FF #F0FFFF #EE82EE #D2691E\n #C0C0C0 #A52A2A #9ACD32 #9400D3 #8B008B #8B0000\n #87CEEB #808080 #800080 #008B8B #006400\n ).sample\n end\n end",
"def correct_colors(temp_array)\n temp_player_input = temp_array[1]\n temp_secret_code = temp_array[0]\n temp_player_input.each do |item|\n next unless temp_secret_code.include?(item)\n\n @matches.shift\n @matches << 'white'\n temp_secret_code[temp_secret_code.index(item)] = 'O'\n end\n end",
"def color_identity\n unless @color_identity\n @color_identity = []\n @color_identity << \"W\" if mana_cost =~ /W/i or text =~ /\\{W\\}/ or subtypes.include?(\"Plains\") or color_indicator =~ /\\bWhite\\b/\n @color_identity << \"U\" if mana_cost =~ /U/i or text =~ /\\{U\\}/ or subtypes.include?(\"Island\") or color_indicator =~ /\\bBlue\\b/\n @color_identity << \"B\" if mana_cost =~ /B/i or text =~ /\\{B\\}/ or subtypes.include?(\"Swamp\") or color_indicator =~ /\\bBlack\\b/\n @color_identity << \"R\" if mana_cost =~ /R/i or text =~ /\\{R\\}/ or subtypes.include?(\"Mountain\") or color_indicator =~ /\\bRed\\b/\n @color_identity << \"G\" if mana_cost =~ /G/i or text =~ /\\{G\\}/ or subtypes.include?(\"Forest\") or color_indicator =~ /\\bGreen\\b/\n end\n @color_identity\n end",
"def color; end",
"def color; end",
"def color; end",
"def correct_color?(array)\n @correct_colors = array & $code_strings\n end",
"def choose_colour(board,width,height,count,finished_game_counter,current_score)\n \n #prints the array\n board.each do |row|\n row.each do |column| \n \n #the field is coloured according to the element in the array \n if column == :red\n \n #prints the element as two space characters with a coloured background\n print column = \" \".colorize(:background => :red)\n elsif column == :green\n print column = \" \".colorize(:background => :green)\n elsif column == :blue\n print column = \" \".colorize(:background => :blue)\n elsif column == :yellow\n print column = \" \".colorize(:background => :yellow)\n elsif column == :magenta\n print column = \" \".colorize(:background => :magenta)\n elsif column == :cyan\n print column = \" \".colorize(:background => :cyan)\n end \n end\n puts\n end\n \n #display number of turns\n print \"Number of turns: \"\n turns(count)\n \n #display percentage completed\n print \"Current completion: \"\n completion(board,width,height,count,finished_game_counter,current_score)\n \n #gets user input r,g,y,b,c,m and increases count by one\n print \"Choose a colour: \"\n user_colour = gets.chomp.downcase\n count = count + 1\n \n #the user_colour variable will be set , depending on the user input\n if user_colour == \"r\"\n user_colour = :red\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n elsif user_colour == \"g\"\n user_colour = :green\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n elsif user_colour == \"b\"\n user_colour = :blue\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n elsif user_colour == \"y\"\n user_colour = :yellow\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n elsif user_colour == \"m\"\n user_colour = :magenta\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n elsif user_colour == \"c\"\n user_colour = :cyan\n change_colour(board,user_colour,width,height,count,finished_game_counter,current_score)\n \n #if user types q, he will return to the main menu\n elsif user_colour == \"q\"\n main_menu(width,height,current_score,finished_game_counter)\n end\nend",
"def red\n colorize(31)\n end",
"def green=(_); end",
"def rgb_color; end",
"def colors() = @colors ||= %i[blue green purple magenta cyan yellow red]",
"def colors(warm, cool)\n puts \"#{warm} is a contrast color to #{cool}\"\nend",
"def colorize(key, color)\n op = {:operation => :colorize, :key => key, :color => color}\n add_operation op\n end",
"def purple\n colorize(35)\n end",
"def nc\n Ncurses::COLOR_PAIR(@id)\n end",
"def color(*values); end",
"def color(*values); end",
"def color\n @color ||= COLORS[label.length%COLORS.length].to_sym\n end",
"def generate_palette_from_active\n begin\n if image_path_for_color_generator && File.exists?(image_path_for_color_generator)\n # find original colors because we don't store them\n @finded_colors = Colorcake.extract_colors(image_path_for_color_generator)\n end\n # store here original colors in right format\n coll = []\n colors.where(active: true).pluck(:id).each do |id|\n color = Color.find(id)\n @finded_colors.first.each do |k, v|\n if v[:search_color_id] == color.search_color_id\n coll << v[:original_color]\n end\n end\n end\n colors_for_palette = coll.inject({}) { |s, o| s.merge(o[0]) }\n generate_palette(colors_for_palette)\n rescue => e\n puts \"#{e.inspect}\"\n errors[:base] << e.message\n end\n end",
"def change_rainbow_colors\n # Write a solution that corrects the three colors in rainbow_colors, then returns the corrected array\n rainbow_colors = [\n \"yellow\",\n \"default\",\n \"light_cyan\"\n]\n rainbow_colors[0]=\"red\"\n rainbow_colors[1]=\"light_red\"\n rainbow_colors[2]=\"light_yellow\"\n rainbow_colors\nend",
"def get_green_to_red_scala n\n colors = []\n r = 0; g = 150; b = 0\n max = 255\n\n #se empieza en un g oscuro en 150 y se aclarece añadiendo g hasta 255\n #ni = numero iteraciones\n ni = (1*n/3)\n for i in 1..(1*n/3.to_f).floor\n g = 150 + (i*(max - 150)/ni.to_f).floor\n colors << rgb(r, g, b)\n end\n\n #una vez g esta en 255 se añade r desde 150 hasta 255 hasta llegar a amarillo\n #ni = numero iteraciones\n g = 255\n ni = 1 + (2*n/3.to_f).floor - (1*n/3.to_f).ceil\n for j in (1*n/3.to_f).ceil..(2*n/3.to_f).floor\n i = j - (1*n/3.to_f).ceil + 1\n r = 150 + (i*(max - 150)/ni.to_f).floor\n colors << rgb(r, g, b)\n end\n\n #una vez g y r estan en 255 se quita g hasta 0 hasta llegar a rojo\n #ni = numero iteraciones\n g = r = 255\n ni = 1 + n - (2*n/3.to_f).ceil\n for i in (2*n/3.to_f).ceil..n\n g = ((n - i)*(max/ni.to_f)).floor\n colors << rgb(r, g, b)\n end\n\n #se entrega la escala de verde a rojo\n colors\n end",
"def yellow\n colorize(33)\n end",
"def blue=(_); end",
"def bg_red; use_code(41) end",
"def ==(a_colour)\n values == a_colour.values\n end",
"def red\n colorize(:red)\nend",
"def colors_for(i, j)\n mode = :default\n if [i, j] == @cursor\n bg = @board.piece_in_hand.is_a?(NullPiece) ? :yellow : :light_blue\n # mode = :blink\n # elsif @board.piece_in_hand.filter_moves.include?([i,j])\n # bg = :white\n elsif (i + j).odd?\n bg = :white\n bg = :green if highlight && @board.piece_in_hand.filter_moves.include?([i,j])\n elsif (i + j).even?\n bg = :light_white\n bg = :light_green if highlight && @board.piece_in_hand.filter_moves.include?([i,j])\n end\n\n { background: bg, color: :black, mode: mode } #@board[[i, j]].color\n end",
"def rainbow; end",
"def much_green?(colors) ; colors[1] > 200 ; end",
"def colorChange(couleur)\n @color=couleur\n apply\n end",
"def pikapika\n puts \"▕▔╲┊┊┊┊┊┊┊╱▔▏┊┊┊\".colorize(:yellow)\n puts \"┊╲╱╲┊┊┊┊┊╱╲╱┊┊┊┊\".colorize(:yellow)\n puts \"┊┊╲┈╲▂▂▂╱┈╱┊┊┊╱╲\".colorize(:yellow)\n puts \"┊┊╱┈┈┈┈┈┈┈╲┊┊╱┈┈╲\".colorize(:yellow)\n puts \"┊┊▏▕▆▍▂▕▆▍▕┊╱┈┈┈╱\".colorize(:yellow)\n puts \"┊▕╭╮┈┳┻┳┈╭╮▏╲┈┈╱\".colorize(:yellow)\n puts \"┊┊╲╯┈╰━╯┈╰╱┊╱┈┈╲\".colorize(:yellow)\n puts \"┊┊╱┈┈┈┈┈┈┈╲┊╲┈┈┈╲\".colorize(:yellow)\n puts \"┊▕╲┈▕┈┈┈▏┈╱▏┊╱┈╱\".colorize(:yellow)\n puts \"┊▕┈▔▔┈┈┈▔▔┈▏╱┈╱┊\".colorize(:yellow)\n puts \"┊▕┈┈┈┈┈┈┈┈▕▔┈╱┊┊\".colorize(:yellow)\n puts \"┈┈╲┈┈┈┈┈┈┈╱▔▔┈┈┈\".colorize(:yellow)\n puts \"┈┈▕▂╱▔▔▔╲▂▏┈┈┈┈┈\".colorize(:yellow)\n #art from: http://textart4u.blogspot.com/2012/04/pikachu-text-art-ascii-art.html\nend",
"def s_generate_palette\n colors_hex = {}\n Color.where(:colorable_id => self.id, :colorable_type => self.class.superclass).each do |color|\n colors_hex['#' + SearchColor.find(color.search_color_id).color] = [color.distance]\n end\n self.palette = Colorcake.create_palette(colors_hex).keys.join(',')\n self.save\n end",
"def color_map\n {\n 'high_risk_ice_check_in' => '#800080',\n 'friend_in_detention' => '#e83737',\n }\n end",
"def add_correct_colors(temp_guess, temp_code, last_guess)\n must_place = {}\n last_guess.each_with_index do |color, slot|\n if color != nil && temp_code.include?(color)\n must_place[color] = slot\n end\n end\n must_place.each do |correct_color, prev_slot|\n temp_guess.each_with_index do |color, slot|\n if color == nil && prev_slot != slot\n temp_guess[slot] = correct_color\n break\n end\n end\n end\n temp_guess\n end",
"def find_color_codes\n color_codes.uniq(&:numeric_code)\n end",
"def green; end",
"def green; end",
"def colors_from_hash(match, hash); end",
"def calculate_color\n\n self.color || color_by_title\n end",
"def colors\n return\n end",
"def auxiliary_colour\n @cr[0xe] >> 4\n end",
"def colorize!(color_code) \"#{COLORS[color_code]}#{self.to_s}\\e[0m\" ; end",
"def red; end",
"def red; end",
"def possible_colors\n %w(R G B Y)\n end",
"def same_color?(other_suit)\n (black? && other_suit.black?) || (red? && other_suit.red?)\n end",
"def set_colour(r,g,b)\n\t\t@colour_r = LoopedArray.new [*r].map {|i| i % 256}\n\t\t@colour_g = LoopedArray.new [*g].map {|i| i % 256}\n\t\t@colour_b = LoopedArray.new [*b].map {|i| i % 256}\n\tend",
"def setup_pieces\n setup_color(:white)\n setup_color(:black)\n end",
"def dopp_colour(name)\n dopp = SHA1.hexdigest(name)\n\tr = (128 + (dopp[0..1].hex)/2).to_s(16)\n\tg = (128 + (dopp[2..3].hex)/2).to_s(16)\n\tb = (128 + (dopp[4..5].hex)/2).to_s(16)\n return [r,g,b].join()\nend",
"def green\n\t\tlight COLOR_KEY_GREEN\n\tend",
"def color_vavid(color)\n color == \"blue\" || color == \"green\"\nend",
"def qualified_color(candidates)\n candidates.each do |candidate| \n if experience?(candidate) && languages?(candidate) && last_15_days?(candidate) && over_17?(candidate)\n puts candidate.to_s.green\n else\n puts candidate.to_s.red\n end\n end\nend",
"def joining_criteria_report_color_for(value)\r\n\r\ncolors = Faveod::DistributedColors.n_colors(2)\r\ncase value\r\nwhen \"AND - matching all criteria\", 1\r\n return colors[0]\r\nwhen \"OR - matching one of the criteria\", 2\r\n return colors[1]\r\nend\r\nend",
"def getColor(colorname)\n# @color = { \"white\" => assignColor256(\"white\",255,255,255),\n# \"black\" => assignColor256(\"black\",0,0,0),\n# \"orange\" => assignColor256(\"orange\",255,0,0),\n# \"red\" => assignColor256(\"red\",0,255,0),\n# \"blue\" => assignColor256(\"blue\",0,0,255),\n# \"grey\" => assignColor256(\"grey\",120,120,120),\n# } ;\n col = @color[colorname] ;\n if(col.nil?) then\n f = File::new(RGBFILE) ;\n rval = -1 ; gval = -1 ; bval = -1 ;\n while(entry = f.gets)\n\tentry.strip! ;\n\trstr,gstr,bstr,name = entry.split ;\n\tif(name == colorname) then\n\t rval = rstr.to_i * 256 ;\n\t gval = gstr.to_i * 256 ;\n\t bval = bstr.to_i * 256 ;\n\t break ;\n\tend\n end\n if(rval < 0) then\n\tif(colorname =~ /^\\#([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/) then\n\t rstr = $1 ; gstr = $2 ; bstr = $3 ;\n\t rval = rstr.hex * 256 ; \n\t gval = gstr.hex * 256 ; \n\t bval = bstr.hex * 256 ; \n\telse\n\t $stderr << \"unknown color name:\" << colorname << \"\\n\" ;\n\tend\n end\n col = assignColor(colorname,rval,gval,bval) ;\n end\n return col ;\n end",
"def red=(_); end",
"def red\n end",
"def constrain_to_colors(array)\n array[0] > 255 ? array[0] = 255 : array[0] < 0 ? array[0] = 0 : array[0]\n array[1] > 255 ? array[1] = 255 : array[1] < 0 ? array[1] = 0 : array[1]\n array[2] > 255 ? array[2] = 255 : array[2] < 0 ? array[2] = 0 : array[2]\n return array\n end",
"def increment_correct_color(guess, code, clues)\n correct_colors = [] # To prevent duplicate colors from giving clues\n guess.each_with_index do |color, index|\n if !color.nil? && code.include?(color) && \n !correct_colors.include?(color)\n clues[:correct_color] += 1\n correct_colors << color\n end\n end\n\n clues\n end",
"def get_color\n @colors.each {\n |key, val| \n (val[:set] = true; return val[:syn]) unless val[:set]\n }\n DEFAULT_COLOR\n end",
"def two_color(g)\n @bipartite = true\n @color = Array.new(g.number_vertices + 1, :uncolored)\n num_vertices = 1\n\n @discovered = []\n\n process_edge =\n lambda do |x, y, w|\n if @color[x].eql?(@color[y])\n @bipartite = false\n puts \"Problem Edge: #{x} and #{y}\"\n end\n\n if @color[x].eql?(:white)\n @color[y] = :black\n else\n @color[y] = :white\n end\n \n end\n\n loop do\n if !@discovered[num_vertices]\n @color[num_vertices] = :white\n self.go(g, num_vertices, nil, nil, process_edge)\n end\n num_vertices += 1\n break if(num_vertices > g.number_vertices)\n end\n\n @bipartite\n end",
"def piece_color(piece); ((piece.color == :white) ? \"#FFEED5\" : \"#063848\") end",
"def create_color_pair(bgcolor, fgcolor)\n code = (bgcolor*10) + fgcolor\n FFI::NCurses.init_pair(code, fgcolor, bgcolor)\n return code\n end",
"def as_red\n @red += 1\n end",
"def recycle_colors(color_index)\n #\"or\" used for control flow\n colors[i+1] or 0\n end",
"def recycle_colors(color_index)\n #\"or\" used for control flow\n colors[i+1] or 0\n end",
"def possible_codes\n\t (0..5).each do |first|\n\t\t(0..5).each do |second|\n\t\t (0..5).each do |third|\n\t\t\t(0..5).each do |fourth|\n\t\t\t @set_of_codes << [COLORS[first],COLORS[second],COLORS[third],COLORS[fourth]]\n\t\t\tend\n\t\t end\n\t\tend\n\t end\n\tend",
"def in_check?(color)\n end",
"def correct_color_input?(input_ary, ref_ary)\n (input_ary - ref_ary).empty?\n end",
"def rgb(*args); end",
"def rgb(*args); end",
"def color_matches(code, guess)\n colormatches = 0\n guess.each{ |num| colormatches += 1 if code.any?{|x| x == num} }\n colormatches\n end",
"def _color\n\t\tcolor = Color.where(:inki_model_name => self.class.to_s, :model_id => self.id).first\n\t\tif color\n\t\t\tcolor.rgb_id\n\t\tend\n\tend",
"def green(text)\n colorize(text, 32)\nend",
"def change_rainbow_colors\n rainbow_colors = []\n # Write a solution that corrects the three colors in rainbow_colors, then returns the corrected array\nchange_rainbow_colors[0]= \"red\"\nchange_rainbow_colors[1]= \"light_red\"\nchange_rainbow_colors[2]= \"light_yellow\"\nreturn change_rainbow_colors\nend",
"def determine_color\n colors = {'Red' => 0, 'Green' => 0, 'Yellow' => 0, 'Blue' => 0}\n @hand.each do |card|\n colors[card.suit] += 1\n end\n return colors.key(colors.values.max)\n end",
"def firstWordSecondColor()\n\n\tcolor1 = $rng.rand(0..5)\n\tword1 = $rng.rand(6..11)\n\n\tcolor2 = $rng.rand(0..5)\n\tword2 = $rng.rand(6..11)\n\n\tprintJumble(color1,word1)\n\tprintJumble(color2,word2)\n\n\tlineArr = gets.chomp.split\n\n\tif (lineArr[0] == $arr[word1] && lineArr[1] == $arr[color2+6])\n\t\t\treturn 1\n\telse\n\t\t\treturn 0\n\tend\n\nend",
"def check_for_color_matches(guess, key)\n i = 0\n while i < guess.length\n match = key.index(guess[i])\n unless match.nil?\n @@color_matches.push(guess[i]) \n keep_color_matches = @@color_matches.dup\n key.delete_at(match)\n end\n i += 1\n end\n end",
"def isColor(c)\n if c == \"r\" or c == \"b\" or c == \"g\" or c == \"y\" or c == \"c\" or c == \"m\" then\n return true\n else\n return false\n end\nend",
"def merge( red , blue )\n return if red==blue || blue==last # base case: red or blue are empty\n if @compare[values[red],values[blue]] <= 0 # first red is less than first blue\n @always_reds << @initial_reds.shift\n else # first blue is less than first red\n tmp = values[blue]\n blue.downto(red) { |i| values[i] = values[i-1] }\n values[red] = tmp\n blue+=1\n @initial_reds << @initial_blues.shift\n @always_blues << @initial_reds.shift\n draw # lines are moving, so draw the current state as an image\n end\n red+=1 # red sits in front of blue, so whether we pull from red or blue, red shifts over 1\n merge( red , blue )\n end",
"def alternate(color)\n if color == :red\n return :blue\n else\n return :red\n end\nend",
"def aqi_range_colors\n { 0..50 => :green,\n 51..100 => :yellow,\n 101..150 => :orange,\n 151..200 => :red,\n 201..300 => :purple,\n 301..999 => :pink }\n end",
"def hash\n [ max_cfvo , max_color , mid_cfvo , mid_color , min_cfvo , min_color ].hash\n end",
"def yellow \n\t\tlight COLOR_KEY_YELLOW\n\tend",
"def setup_easier\n (1...ROWS).each do |row|\n (1...COLUMNS).each do |col|\n set_neighbour_colour(col, row) if rand(-1...COLOR_TABLE.size) == -1\n end\n end\n end",
"def count_correct_colors\n colors_by_difficulty.each do |color|\n if @code_guess.count(color) < @secret_code.count(color)\n @white_peg += @code_guess.count(color)\n else\n @white_peg += @secret_code.count(color)\n end\n end\n end",
"def add_colors\n $rainbow_colors.push(\"green\",\"blue\")\nend",
"def background_color(color); end",
"def choose_three(array)\n one=choose_one(array, false)\n #Monochromatic\n color = one['cw']\n two=find_same_color(color, array)\n puts color\n three = find_same_color(color, array)\n puts one['name'] + \", \" + two['name']+ \", \"+three['name']\nend"
] |
[
"0.6711947",
"0.6350977",
"0.6301483",
"0.6254664",
"0.62430394",
"0.61862665",
"0.61311495",
"0.6082481",
"0.60648423",
"0.6030823",
"0.60145295",
"0.5983263",
"0.59334964",
"0.5930534",
"0.5924699",
"0.5924699",
"0.5924699",
"0.59190124",
"0.5902911",
"0.58814967",
"0.5880108",
"0.5872462",
"0.586214",
"0.5857069",
"0.58568585",
"0.5855984",
"0.584778",
"0.5840498",
"0.5840498",
"0.5840396",
"0.58393025",
"0.58288604",
"0.5826795",
"0.58266467",
"0.5822664",
"0.5821438",
"0.58210534",
"0.581795",
"0.5800364",
"0.5792952",
"0.5788446",
"0.5780798",
"0.5763296",
"0.5756198",
"0.57264924",
"0.5725851",
"0.57227296",
"0.57226664",
"0.57226664",
"0.5722058",
"0.5720157",
"0.57156414",
"0.5714136",
"0.57122475",
"0.5705481",
"0.5705481",
"0.57052606",
"0.5688261",
"0.56824386",
"0.5682042",
"0.568057",
"0.56802344",
"0.56715184",
"0.56701535",
"0.5665738",
"0.5660257",
"0.56564605",
"0.5648945",
"0.5638363",
"0.5638157",
"0.56296176",
"0.56293035",
"0.56276757",
"0.56241786",
"0.5619128",
"0.5617689",
"0.5617689",
"0.5606612",
"0.56032485",
"0.5590009",
"0.5588506",
"0.5588506",
"0.55832076",
"0.5583073",
"0.5580156",
"0.5572127",
"0.55660397",
"0.5548889",
"0.55462617",
"0.5543299",
"0.5533881",
"0.5532106",
"0.55313075",
"0.5528217",
"0.5527112",
"0.5525091",
"0.5522044",
"0.5520594",
"0.55194616",
"0.55139124"
] |
0.6607406
|
1
|
codewars kata: rotate an array matrix
|
def rotate(matrix, direction)
if direction == "clockwise"
matrix.transpose.map{|i| i.reverse}
else
rotated = []
matrix.transpose.map{|i| i.reverse}.flatten.reverse.each_slice(matrix.size){
|a| rotated << a}
rotated
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def rotate_matrix(array)\n\n\nend",
"def rotate_matrix(arr)\n\nend",
"def rotate_matrix(arr)\n flipped_array = [] # initialize empty array\n transposed_arr = my_transpose(arr) # flip the rows with columns inside using a transpose method\n transposed_arr.each { |row| flipped_array << row.reverse } # once we reverse the new rows, it goes from 45 to 90 degrees rotation\n flipped_array\nend",
"def rotate_a(matrix)\n res = []\n n = matrix.size\n\n n.times do |row|\n new_row = []\n\n n.times do |col|\n new_row[col] = matrix[n - col - 1][row]\n end\n\n res[row] = new_row\n end\n\n res\nend",
"def rotate(matrix) \n rows, cols = matrix.size, matrix[0].size\n Array.new(cols) {|i| Array.new(rows) {|j| matrix[j][cols - i - 1]}}\n end",
"def rotate_matrix(len, mtx)\n (0..(len / 2)).each do |layer|\n first = layer\n last = len - 1 - layer\n (first..last - 1).each do |i|\n top = mtx[first][i]\n mtx[first][i] = mtx[last - i][first] # TOP <-- LEFT\n mtx[last - i][first] = mtx[last][last - i] # LEFT <-- BOTTOM\n mtx[last][last - i] = mtx[i][last] # BOTTOM <-- RIGHT\n mtx[i][last] = top\n end\n end\n mtx\nend",
"def rotate90(matrix)\n new_matrix = Array.new(matrix[0].size) { Array.new }\n matrix.each_with_index do |sub_array, row|\n matrix[0].size.times do |col|\n new_matrix[col][matrix.size - row - 1] = sub_array[col]\n end\n end\n\n new_matrix\nend",
"def rotate(arr)\n\nend",
"def rotate_matrix(matrix)\n (0...matrix.length).each do |row|\n col = row + 1\n while col < matrix.length\n matrix[row][col], matrix[col][row] = matrix[col][row], matrix[row][col]\n col += 1\n end\n end\n\n (0...matrix.length).each do |row|\n start_col = 0\n end_col = matrix.length - 1\n\n while start_col < end_col\n matrix[row][start_col], matrix[row][end_col] = matrix[row][end_col], matrix[row][start_col]\n start_col += 1\n end_col -= 1\n end\n end\n\n matrix\nend",
"def rotate(matrix)\n newMatrix, finalMatrix, i = [], [], 0\n (matrix.length > matrix[0].length ? matrix.length : matrix[0].length).times do\n matrix.map { |row| row[i] != nil ? newMatrix << row[i] : nil }\n i+=1\n end\n newMatrix.each_slice(matrix.length).to_a.reverse\n end",
"def rotate matrix \n min = 0;\n max = matrix.length-1\n\n while min < max and max >= matrix.length/2\n dif = 0\n while min + dif < max\n t1 = matrix[min][min+dif]\n t2 = matrix[min+dif][max]\n t3 = matrix[max][max-dif]\n t4 = matrix[max-dif][min]\n \n matrix[min][min+dif] = t4\n matrix[min+dif][max] = t1\n matrix[max][max-dif] = t2\n matrix[max-dif][min] = t3\n\n dif += 1\n end\n min += 1\n max -= 1\n end\n matrix\nend",
"def RotateMatrix (squareImg)\n r = squareImg.size - 1\n c = squareImg[0].size - 1\n\n (0..r/2).each do |row|\n (0..c/2).each do |col|\n\nsquareImg[row][col], squareImg[r - row][col], squareImg[r-row][c-col], squareImg[row][c-col] = squareImg[r - row][col], squareImg[r-row][c-col], squareImg[row][c-col], squareImg[row][col]\n\n\n end\n end\nsquareImg\nend",
"def rotate_matrix(image_matrix)\n reverse_matrix = image_matrix.reverse\n rotated_matrix = []\n (0...image_matrix.length).each do |i|\n col = reverse_matrix.map { |row| row[i] }\n rotated_matrix[i] = col\n end\n rotated_matrix\nend",
"def rotate90(matrix)\n size = matrix.first.size\n matrix.each_with_object(Array.new(size) {[]}) do |arr, new_arr|\n arr.each_with_index do |el, idx|\n new_arr[idx].unshift el\n end\n end\nend",
"def rotate90(original_matrix)\n num_rows = original_matrix[0].length\n num_columns = original_matrix.length\n new_matrix = []\n\n (0..(num_rows - 1)).each do |row|\n inner_array = []\n (num_columns - 1).downto(0).each do |column|\n inner_array.push(original_matrix[column][row])\n end\n new_matrix.push(inner_array)\n end\n new_matrix\nend",
"def rotate(matrix)\n n = matrix.length\n matrix = transpose(matrix, n)\n reverse_columns(matrix, n)\nend",
"def rotate matrix, direction\n direction == 'clockwise' ? matrix.reverse.transpose : matrix.transpose.reverse\nend",
"def rotate_matrix matrix\n\tlayer = 0\n\tfor layer in 0..(matrix.size / 2).ceil\n\t\tlast = matrix.size - 1 - layer\n\t\tfor i in layer..last-1 # not sure here \n\t\t\toffset = i - layer\n\t\t\ttop = matrix[layer][i]\n\n\t\t\tmatrix[layer][i] = matrix[last - offset ][layer] #7 4\n\n\t\t\tmatrix[last - offset][layer] = matrix[ last ][ last - offset ] #9 8\n\n\t\t\tmatrix[ last ][ last - offset] = matrix[ i ][last ] #3 6\n\n\t\t\t#top -> right\n\t\t\tputs i\n\t\t\tputs last\n\t\t\tmatrix[ i ][ last] = top\n\t\tend\n\tend\n\nend",
"def rotate_without_changing(arr)\n\nend",
"def rotate_90(array)\n a = copy array\n a.transpose.map { |e| e.reverse }\nend",
"def rotate90(matrix)\n columns = matrix[0].length\n new_matrix = []\n columns.times { new_matrix << [] }\n matrix.each_with_index do |row, ind|\n row.each_with_index do |elem, r_ind|\n new_matrix[r_ind].unshift(elem)\n end\n end\n new_matrix\nend",
"def array_rotation(arr, num)\n\tarr.rotate(num)\nend",
"def rotate_image(arr)\n last_index = arr.size - 1\n\n # i will essentially act as our layer\n i = 0\n while i < (arr.size / 2)\n \n # column index, j, which should always start at the same index as the layer\n # to avoid moving outer-layer elements\n j = i\n\n # this makes sure j never iterates over the last element in the layer, because\n # it will have already been rotated from the first rotation in that layer\n # NOTE: this mistake can best be shown in a 5x5 or larger, if we forgot this\n layer_offset = last_index - i\n\n while j < (layer_offset) # last_index = arr[i].size - 1 because the array is square\n # debugger\n\n # store the value in the top row\n stored = arr[i][j]\n\n # rotate left to top\n arr[i][j] = arr[last_index - j][i]\n\n # rotate bottom to left\n arr[last_index - j][i] = arr[layer_offset][last_index - j]\n\n # rotate right to bottom\n arr[layer_offset][last_index - j] = arr[j][layer_offset]\n\n # rotate top to right by replacing right with stored\n arr[j][layer_offset] = stored\n\n j += 1\n end\n \n i += 1\n end\n\n # The submission code shouldn't include this, this is just to visualize the result\n p \"#{arr.size}x#{arr.size} Rotated Matrix\"\n arr.each do |row|\n p row\n end\nend",
"def my_rotate(arr)\n print arr.rotate\n end",
"def rotate_b(matrix)\n n = matrix.size\n half_n = n / 2\n ceil_half_n = (n / 2.0).ceil\n\n ceil_half_n.times do |col|\n half_n.times do |row|\n t = matrix[row][col]\n matrix[row][col] = matrix[n - col - 1][row]\n matrix[n - col - 1][row] = matrix[n - row - 1][n - col - 1]\n matrix[n - row - 1][n - col - 1] = matrix[col][n - row - 1]\n matrix[col][n - row - 1] = t\n end\n end\n\n matrix\nend",
"def rotate(image)\n # image is a 2 dimentional array like [[1,2,3],[4,5,6], [7,8,9]]\n array = []\n cols = image[0].size\n image.size.times do \n array << Array.new(cols)\n end\n\n image.each_with_index do |rows_array, row|\n rows_array.each_with_index do |element, col|\n array[col][row] = element\n end\n end\n\n array\nend",
"def rotate_array(array,k,type=\"right\")\n puts \"Input array is\"\n p array\n reverse_array(array, 0, array.size-1)\n if type == \"right\"\n reverse_array(array,0,k-1)\n reverse_array(array,k,array.size-1)\n else\n reverse_array(array,0,k)\n reverse_array(array,k+1,array.size-1)\n end\n puts \"#{type} rotated array is\"\n p array\nend",
"def rotate_array(unrotated)\n unrotated[1..] + [unrotated.first]\nend",
"def rotate_array(unrotated)\n unrotated[1..] + [unrotated.first]\nend",
"def rotate90(matrix, degrees = 90)\n rotated = matrix\n (degrees / 90).times { rotated = rotated.transpose.map(&:reverse) }\n rotated\nend",
"def rotate_array(ar)\n ar[1..-1] << ar[0]\nend",
"def rotate(matrix, num_rotations=1)\n num_rotations.times.inject(matrix) { |result, transpose| result.transpose.map(&:reverse) }\n end",
"def rotate_array(array)\narray[1..-1] + [array[0]]\nend",
"def rotate_matrix(image, direction=:right)\n 0..(image.length / 2 - 1) do |i|\n ((0 + i)..(image.length - 1 - i)).each do |j|\n ij0 = rotate_destination([i, j], direction)\n ij1 = rotate_destination(ij0, direction)\n ij2 = rotate_destination(ij0, direction)\n \n register = image[ij0[0]]][ij0[1]]\n image[ij0[0]][ij0[1]] = image[i][j]\n image[i][j] = image[ij2[0]]][ij2[1]]\n image[ij2[0]][ij3[1]] = image[ij1[0]]][ij1[1]]\n image[ij1[0]][ij1[1]] = register\n end\n end",
"def my_rotate!(array, amt)\n\nend",
"def rotate_by(array, offset)\n offset.times do\n starting = array.length - offset\n (starting).downto(0) do |j|\n temp = array[j]\n array[j] = array[j-1]\n array[j-1] = temp\n end\n end\n return array\nend",
"def rotate_array(array)\n array[1, array.size] << array[0]\nend",
"def rotate!\n @grid = @grid.transpose.map{|c| c.reverse}\n end",
"def rotate_array(aArray, off_x, off_y, rel_angle, change_in_place=false)\r\n # - - - - - - - - - - - - - - - - - - - - -\r\nend",
"def rotate_array(arr)\nnew_arr = []\narr.each do |num|\nnew_arr << num\nend\t\nnew_arr << new_arr.shift\nend",
"def rotate_array(arr)\n [*arr[1..-1], *arr[0, 1]]\nend",
"def rotate_array(arr)\narr.drop(1) + arr[0...1]\nend",
"def my_rotate(rotation = 1)\n # debugger\n answer = []\n each_with_index { |x, i| answer[i] = x }\n if rotation > 0\n rotation.times { answer.push(answer.shift) }\n elsif rotation == 0\n answer\n else\n rotation.abs.times { answer.unshift(answer.pop) }\n end\n answer\n end",
"def rotate(matrix, degrees)\n rotations = degrees/90\n new_matrix = matrix.dup\n rotations.times do\n new_matrix = rotate90(new_matrix)\n end\n new_matrix\nend",
"def rotate(matrix, start_row, start_col, end_row, end_col, rotations)\n edge = []\n\n # top\n edge.concat start_col.upto(end_col - 1).collect { |c| matrix[start_row][c] }\n # right\n edge.concat start_row.upto(end_row - 1).collect { |r| matrix[r][end_col] }\n # bottom\n edge.concat end_col.downto(start_col + 1).collect { |c| matrix[end_row][c] }\n # left\n edge.concat end_row.downto(start_row + 1).collect { |r| matrix[r][start_col] }\n\n rotated = edge[rotations..-1] + edge[0, rotations]\n\n # top\n i = 0\n start_col.upto(end_col - 1) do |c|\n matrix[start_row][c] = rotated[i]\n i += 1\n end\n\n # right\n start_row.upto(end_row - 1) do |r|\n matrix[r][end_col] = rotated[i]\n i += 1\n end\n\n # bottom\n end_col.downto(start_col + 1) do |c|\n matrix[end_row][c] = rotated[i]\n i += 1\n end\n\n # left\n end_row.downto(start_row + 1) do |r|\n matrix[r][start_col] = rotated[i]\n i += 1\n end\n\n matrix\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]] \nend",
"def rotate(board)\n new_board = Array.new(9) {[]}\n\n i = 0\n while i < board.length\n board.each {|row| new_board[i] << row[i]}\n i += 1\n end\n\n new_board\nend",
"def rotate(array)\n array.map.with_index do |elem, index|\n if (index + 1) < array.size\n array[index + 1]\n else\n array[0]\n end\n end\nend",
"def rotate_array(array)\n array[1..-1] + array[0..0]\nend",
"def rotate(n)\n ## Builds a grid NXN filled with 0's.\n grid = Array.new(n) { Array.new(n) {0} }\n ## Builds new grid for output\n new_grid = Array.new(n) { Array.new(n) }\n\n ## Iterate through each array/row\n grid.each_with_index do |array, row|\n ## Then by each col of that row\n array.each_with_index do |element, col_index|\n new_grid[col_index][-(row+1)] = element\n end\n end\n new_grid\nend",
"def rotate_array(ary)\n ary[1..-1] + [ary[0]] # need to concatenate 2 arrays\nend",
"def rotate_array(arr)\n\narr_new = arr.clone\narr_new.push(arr_new[0]).shift\narr_new\nend",
"def rotate_array(array)\n array[1..-1] << array[0]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]] # brackets added to array[0] to force it to an array from integer.\nend",
"def rotate_array(arr, num)\n num.times do \n ele = arr.pop \n arr.unshif(ele)\n end\n return arr \nend",
"def rotate_arr(arr)\n result_arr = arr.map{|num| num}\n result_arr << result_arr[0]\n result_arr.shift\n result_arr\nend",
"def rotate(array, i)\n i.times { array << array.shift }\n array\nend",
"def rotate_array(ary)\n ary[1..-1] + [ary[0]]\nend",
"def rotate_array(ary)\n ary[1..-1] + [ary[0]]\nend",
"def rotate_array(ary)\r\n ary[1..-1] << ary[0]\r\nend",
"def rotate_matrix(n_by_n_matrix)\n # largest index\n n = n_by_n_matrix.first.count - 1\n half_of_n = (n_by_n_matrix.first.count/2).floor\n half_of_n.times do |c| # c = cycle\n v = n-(c*2) # v = vars to rotate\n v.times do |r| # r = rotation\n n_by_n_matrix[c][c+r], n_by_n_matrix[v+c-r][c] = n_by_n_matrix[v+c-r][c], n_by_n_matrix[c][c+r]\n n_by_n_matrix[v+c-r][c], n_by_n_matrix[v+c][v+c-r] = n_by_n_matrix[v+c][v+c-r], n_by_n_matrix[v+c-r][c]\n n_by_n_matrix[v+c][v+c-r], n_by_n_matrix[c+r][v+c] = n_by_n_matrix[c+r][v+c], n_by_n_matrix[v+c][v+c-r]\n end\n end\n n_by_n_matrix\nend",
"def rotate_ninety_degs(array,direction='clockwise')\n if direction == 'clockwise'\n return array.transpose.reverse\n else\n return array.transpose.each{|x| x.reverse!}\n end\nend",
"def rotate_array(array_of_numbers)\n rotated_array = array_of_numbers.clone\n rotated_array << rotated_array.shift\n\n rotated_array\nend",
"def rotate_array(a, d) #Input array \"a\" and rotation by \"d\" elemets\n finish =a.length-1\n block_swap(a,0,finish,d)\nend",
"def rotate_array(numbers)\n numbers[1..-1] + [numbers[0]]\nend",
"def rotate_array(numbers)\n numbers[1..-1] + [numbers[0]]\nend",
"def rotate_array(arr)\n results = arr.map { |n| n }\n results << results.shift\nend",
"def rotate_array(numbers)\n new_numbers = []\n new_numbers << numbers[1,numbers.size] << numbers[0]\n new_numbers.flatten\nend",
"def rotate_array_alt(arr)\n arr[1..-1] + [arr[0]]\nend",
"def rotate_array(arr)\n rotated = arr.clone\n rotated.insert(-1, rotated.shift)\nend",
"def rotate_array(array)\n array.drop(1) + array.take(1)\nend",
"def rotate_array(arr)\n arr[1...arr.size] + [arr[0]]\nend",
"def rotate_array(arr)\n arr[1...arr.size] + [arr[0]]\nend",
"def rotate(matrix, degrees)\n rotations = degrees / 90 % 4\n return matrix if rotations == 0\n new_matrix = rotate90(matrix)\n count = 1\n while count < rotations\n new_matrix = rotate90(new_matrix)\n count += 1\n end\n new_matrix\nend",
"def rotate_array(array)\n arr2 = []\n arr2.concat(array[1..-1]) << array[0]\nend",
"def rotate_backwards(arr)\n\nend",
"def rotateDataMatrix(dataMatrix)\n\n newDataMatrix = []\n\n for i in 0...dataMatrix[0].size()\n newDataMatrix[i] = []\n end\n\n for i in 0...dataMatrix.size()\n\n for j in 0...dataMatrix[i].size()\n newDataMatrix[j][i] = dataMatrix[i][j]\n end\n end\n\n newDataMatrix\n\n end",
"def rotate_array(ary)\n new_ary = []\n ary.each { |e| new_ary << e}\n new_ary << new_ary.shift\n new_ary\nend",
"def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend",
"def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend",
"def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend",
"def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend",
"def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend",
"def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend",
"def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend",
"def rotate_array(array)\n array.values_at(1..-1, 0)\nend",
"def rotate_array(arr)\n arr[1..(arr.size - 1)] << arr[0]\nend"
] |
[
"0.8922084",
"0.8662312",
"0.7869226",
"0.7834902",
"0.7665643",
"0.76367277",
"0.7614206",
"0.7582831",
"0.7570841",
"0.75581384",
"0.74848557",
"0.7463697",
"0.7423924",
"0.74125135",
"0.7396256",
"0.7371948",
"0.73608685",
"0.73164463",
"0.7310452",
"0.7274743",
"0.7247427",
"0.7150717",
"0.71362656",
"0.7111235",
"0.70603096",
"0.7031397",
"0.7024587",
"0.700086",
"0.700086",
"0.69943386",
"0.6943069",
"0.6911872",
"0.6910739",
"0.69022685",
"0.6873363",
"0.68613124",
"0.68483764",
"0.6848339",
"0.6831092",
"0.68282765",
"0.6802721",
"0.679735",
"0.6782835",
"0.67811424",
"0.677811",
"0.6773682",
"0.67671245",
"0.67622054",
"0.6759552",
"0.67574644",
"0.6751648",
"0.6741715",
"0.6732252",
"0.6723287",
"0.6723287",
"0.6723287",
"0.6723287",
"0.6723287",
"0.6723287",
"0.6723287",
"0.6723287",
"0.6723287",
"0.6723287",
"0.6723287",
"0.6723287",
"0.6723287",
"0.6715679",
"0.66940475",
"0.6692518",
"0.6677609",
"0.6649749",
"0.6649749",
"0.6647693",
"0.6647255",
"0.66397077",
"0.66337496",
"0.6632095",
"0.66212064",
"0.66212064",
"0.6615496",
"0.660294",
"0.65974057",
"0.65913385",
"0.6588669",
"0.65858054",
"0.65858054",
"0.65841806",
"0.6581247",
"0.6580169",
"0.65717727",
"0.65687734",
"0.656435",
"0.656435",
"0.656435",
"0.656435",
"0.656435",
"0.656435",
"0.656435",
"0.6560318",
"0.655117"
] |
0.74875474
|
10
|
codewars kata: matrix addition
|
def matrixAddition(a, b)
c = [] << a << b
c.transpose.map{ |i| i.transpose }.map{ |s|
s.map{ |p| p.reduce(&:+)}}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def matrix_addition(m1, m2)\n rows = m1.length\n cols = m1[0].length\n result = Array.new(rows) { Array.new(cols, 0)}\n (0...rows).each do |row|\n (0...cols).each do |col|\n result[row][col] = m1[row][col] + m2[row][col]\n end\n end\n \n result\nend",
"def matrix_addition(matrix_a, matrix_b)\n addition = Array.new(matrix_a.length) {Array.new(matrix_a[0].length)}\n\n matrix_a.each_with_index do |row, row_i|\n row.each_with_index do |col, col_i|\n addition[row_i][col_i] = matrix_a[row_i][col_i] + matrix_b[row_i][col_i]\n end\n end\n \n addition\nend",
"def matrix_addition(matrix1, matrix2)\nadded = []\ni = 0\n matrix1.length.times do\n k = 0\n pair = []\n while k < matrix1[0].length\n pair << matrix1[i][k] + matrix2[i][k]\n k += 1\n end\n added << pair\n i += 1\n end\n added\nend",
"def matrix_addition(matrix_1, matrix_2)\n new_matrix = Array.new(matrix_1.length) {Array.new(matrix_1.first.length)}\n new_matrix.each_with_index do |array, i1|\n array.each_with_index do |el, i2|\n new_matrix[i1][i2] = matrix_1[i1][i2] + matrix_2[i1][i2]\n end\n end\n new_matrix\nend",
"def matrix_addition(m1, m2)\n height = m1.length\n width = m1[0].length\n result = Array.new(height) { [0] * width }\n\n (0...height).each do |row|\n (0...width).each do |col|\n result[row][col] = m1[row][col] + m2[row][col]\n end\n end\n\n result\nend",
"def matrixAddition(a, b)\n n = a.length\n c = Array.new\n 0.upto(n-1) do |x|\n # reinitialize the sum_array otherwise values from previous iteration carry over\n sum_array = Array.new \n 0.upto(n-1) do |y|\n sum_array = sum_array.push(a[x][y] + b[x][y])\n end\n c[x] = sum_array\n end \n return c\nend",
"def matrix_addition(matrix1, matrix2)\n new_matrix = Array.new(matrix1.length) { Array.new(matrix1[0].length) }\n\n (0...matrix1.length).each do |i|\n (0...matrix1[i].length).each do |j|\n new_matrix[i][j] = matrix1[i][j] + matrix2[i][j]\n end\n end\n\n new_matrix\nend",
"def matrix_addition(matrix1, matrix2)\n new_matrix = Array.new(matrix1.size) { [] }\n\n matrix1.each_index do |i|\n matrix1[i].each_index do |j|\n new_matrix[i] << matrix1[i][j] + matrix2[i][j]\n end\n end\n new_matrix\nend",
"def matrix_addition(matrix1, matrix2)\n sum_matrix = []\n i = 0\n while i < matrix1.length\n j = 0\n row = []\n while j < matrix1[i].length\n row << matrix1[i][j] + matrix2[i][j]\n j += 1\n end\n sum_matrix << row\n i += 1\n end\n sum_matrix\nend",
"def matrix_addition(matrix_1, matrix_2)\n height = matrix_1.length\n width = matrix_1.first.length\n (0...height).map do |col|\n (0...width).map do |row|\n matrix_1[col][row] + matrix_2[col][row]\n end\n end\nend",
"def matrix_addition_reloaded(*matrices)\n\n length = matrices.first.length\n if (matrices.all? { |ele| ele.length == length})\n else\n return nil\n end\n\n matrices.inject do |acc, ele|\n # p acc\n i = 0\n sum_matrix = []\n while i < acc.length\n row_arr = []\n j = 0\n while j < acc.first.length\n # print acc[i][j]\n sum = acc[i][j]+ele[i][j]\n row_arr << sum\n j+= 1\n end\n sum_matrix << row_arr\n i += 1\n end\n sum_matrix\n end\nend",
"def matrix_addition(matrix_1 , matrix_2)\n i = 0\n sum = []\n\n while sum.length < matrix_1.length\n arr_1 = matrix_1[i]\n arr_2 = matrix_2[i]\n\n sum << matrix_plus(arr_1, arr_2)\n\n i += 1\n\n end\n sum\nend",
"def m_add(other)\n # Ensure proper dimensions\n if (other.num_rows != self.num_rows || other.num_cols != self.num_cols)\n raise \"Matrix dimensions must match\"\n end\n\n sum_matrix = MutableMatrix.new\n \n self.each_index do |row| # For reach row\n sum_matrix[row] = Array.new(self.num_cols, 0)\n self[row].each_index do |col| # For each col\n sum_matrix[row][col] = self[row][col] + other[row][col]\n end\n end\n return sum_matrix\n end",
"def matrix_addition (arr1, arr2)\n new_arr = []\n arr1.each.with_index do|subarr1, idx1|\n new_sub = []\n subarr1.each.with_index do |num1, idx2|\n new_sub << arr1[idx1][idx2] + arr2[idx1][idx2]\n end\n new_arr << new_sub\n end\n\n new_arr\nend",
"def matrixAddition(a1, a2)\n t = a1.zip(a2)\n t.map { |e1,e2| (e1.is_a? Array) ? matrixAddition(e1,e2) : e1+e2 }\nend",
"def matrix_addition_reloaded(*matrixs)\n # matrixs.each { |matrix| return nil if matrixs.first.length != matrix.length}\n # first_matrix = matrixs.first\n # matrix_sum = []\n # i = 0\n\n # while matrix_sum.length < first_matrix.length do \n # sum = 0 \n # sum += matrixs[i][i][i]\n # matrix_sum << sum\n\n # end\n # matrix_sum\n\n matrix = matrixs.first\n height = matrix.length\n width = matrix[0].length\n matrix_sum = Array.new(height) { [0] * width}\n\n matrixs.inject(matrix_sum) do |m1, m2|\n return nil if m2.length != height || m2[0].length != width\n matrix_addition(m1, m2)\n\n end\nend",
"def +(mat)\n end",
"def matrix_addition(a1, a2)\n t = a1.zip(a2)\n t.map { |e1,e2| (e1.is_a? Array) ? matrix_addition(e1,e2) : e1+e2 }\nend",
"def matrix_addition_reloaded(*matrices)\n return nil if matrices.any? {|matrix| matrices[0].length != matrix.length}\n\n new_matrix = Array.new(matrices.first.length) {Array.new(matrices.first.first.length, 0)}\n\n matrices.each_with_index do |matrix, mi|\n matrix.each_with_index do |array, ai|\n array.each_with_index do |el, eli|\n new_matrix[ai][eli] += el\n end\n end\n end\n new_matrix\nend",
"def matrix_addition(m1, m2)\n matrix_addition_reloaded(m1, m2)\nend",
"def +(matrizb)\r\n\t\t\r\n\t\t#sumita={}\r\n\t\t#for r in @m_Matrix.keys do \r\n\t\t#\tsum = {}\r\n\t\t#\tif matrizb.m_Matrix.keys.include? r\r\n\t\t#\t\tfor j in @m_Matrix[r].vector.keys do \r\n\t\t#\t\t\tsum[j] = @m_Matrix[r].vector[j]+matrizb[r].vector[j]\t\r\n\t\t#\t\t\tsumita[r] = {j=>sum[j]}\r\n\t\t#\t\tend\r\n\t\t#\telse\r\n\t\t#\t\tsum[r]=@m_Matrix[r]\r\n\t\t#\tend\r\n\t\t#end\r\n\t\t#SparseMatrix.new(sumita)\r\n\r\n\t\tfor r in @m_Matrix.keys do \r\n\t\t\tfor j in @m_Matrix[r].vector.keys do \r\n\t\t\t\tmatrizb[r][j]= @m_Matrix[r][j]+matrizb[r][j]\r\n\t\t\tend\r\n\t\tend\t\r\n\tmatrizb\r\n\tend",
"def +(mat)\n if (mat.nFil == @nFil && mat.mCol == @mCol)\n maux=Array.new(@nFil) { Array.new(@mCol) }\n \n (@nFil).times do |i|\n (@mCol).times do |j|\n maux[i][j] = @matriz[i][j]\n end\n end\n \n aux = Matriz.new(maux)\n (@nFil).times do |i|\n (@mCol).times do |j|\n aux.matriz[i][j] = @matriz[i][j] + mat.matriz[i][j]\n end\n end\n else\n aux = 0\n end\n aux\n end",
"def matrix_addition_reloaded(*matrices)\n height = matrices[0].size\n width = matrices[0][0].size\n return nil if matrices.select {|m| m.size == height && m[0].size == width}.count != matrices.count\n \n sum = Array.new(height) {|i| Array.new(width, 0)}\n\n (0...height).each do |h|\n (0...width).each do |w|\n matrices.each {|m| sum[h][w] += m[h][w]}\n end\n end\n sum\nend",
"def +(other)\r\n\t\t\r\n\t\t#if ((other.class.to_s == \"Densa\") && (other.fil == @fil) && (other.col == @col))\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t0.upto(@fil - 1) do |i| \r\n\r\n\t\t\t\tj = 0\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t(@col - 1).times do\r\n\t\t\t\t\t\r\n\t\t\t\t\t@matrix[i][j] = @matrix[i][j] + other.matrix[i][j]\r\n\t\t\t\t\tj += 1\r\n\t\t\t\t\t\r\n\t\t\t\tend\r\n\t\t\t\t\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\t#puts \"#{@matrix}\"\r\n\t\t\treturn @matrix\r\n\t\t\t\r\n\t\t#else\r\n\t\t\t#raise ArgumentError, \"Matrices de distinto tamanio\"\r\n\t\t#end\r\n\tend",
"def +(other)\n raise ArgumentError, \"Las dimensiones de las matrices no coinciden\" unless @filas == other.filas && @columnas == other.columnas\n new_mat = Array.new\n @filas.times do |i|\n fila = Array.new\n @columnas.times do |j|\n fila << @elementos[i][j] + other.at(i, j)\n end\n new_mat << fila\n end\n Matriz.new(new_mat)\n end",
"def matrix_addition_reloaded(*matricies)\n addition = matricies[0]\n \n i = 1\n while i < matricies.length\n return nil if matricies[i].length != addition.length\n addition = matrix_addition(addition, matricies[i])\n \n i += 1\n end\n \n addition\nend",
"def +(m)\n\t\t\t\tif(m.instance_of? Matriz_dispersa)\n\t\t\t\t\treturn m + self \n \n else\n\t\t\t\t\traise IndexError unless ((self.fil == m.fil) && (self.col == m.col)) #Las dimensiones tienes que ser iguales\n\t\n\t\t\t\t\n\t\t\t\t\tsuma = Matriz.new(self.fil, self.col)\n\n\t\t\t\t\tfor i in (0...self.fil)\n for j in (0...self.col)\n\t\t\t\t\t\t\tsuma[i][j] = self[i][j] + m[i][j]\n end\n\t\t\t\t\tend \n\n return suma \n\t\t\t\tend\n end",
"def matrix_addition_reloaded(*matrix) # collapses args into one array - extra outer [] shell \n if matrix_counter(matrix) == false\n return nil\n end\n\n if matrix.length == 1\n return matrix[0]\n end\n\n \n (1...matrix.length).each do |number|\n matrix[0] = matrix_addition(matrix[0], matrix[number])\n end\n\n matrix[0]\nend",
"def matrix_addition_reloaded(*arr)\n return nil if !arr.all? { |x| arr[0].length == x.length }\n sum = arr[0]\n 1.upto(arr.length - 1).each do |i|\n sum = matrix_addition(sum, arr[i])\n end\n sum\nend",
"def matrix_addition_reloaded(*matrices)\n return matrices[0] if matrices.length == 1\n \n sum_mat = nil\n\n # debugger\n\n (0...matrices.length-1).each do |n|\n temp = nil\n if sum_mat.nil?\n temp = matrices[n]\n else\n temp = sum_mat\n end\n if check_rowcol?(temp, matrices[n+1])\n neigbhor_sum = matrix_addition(temp, matrices[n+1])\n sum_mat = neigbhor_sum\n else\n return nil\n end\n end\n\n return sum_mat\nend",
"def +(other)\n raise ArgumentError, \"Las matrices no son cuadradas.\" unless @nfil == other.nfil && @ncol == other.ncol\n m = Array.new(@nfil){Array.new(@ncol){0}}\n for i in 0...nfil \n for j in 0...ncol\n m[i][j] = self.mat[i][j]+ other.mat[i][j]\n end\n end\n return Matriz.new(other.nfil,other.ncol,m) \n end",
"def +(other)\n i=0\n \tm_aux = @matriz\n while i < @fila\n j=0\n \twhile j < @columna\n \t m_aux[i][j] = m_aux[i][j] + other.matriz[i][j]\n \t j += 1\n \tend\n i += 1\n end\n Matriz.new(m_aux)\n end",
"def +(other)\n\t\t\tif ((@nfil != other.nfil) || (@ncol != other.ncol))\n\t\t\t\tputs \"No se pueden sumar las matrices\"\n\t\t\telse\n\t\t\t\telemento = Array.new(0)\n\t\t\t\tfor i in 0...filas\n\t\t\t\t\tfila = Array.new(0)\n\t\t\t\t\tfor j in 0...colum\n\t\t\t\t\t\tfila << pos[i][j] + other.pos[i][j]\n\t\t\t\t\tend\n\t\t\t\t\telemento << fila\n\t\t\t\tend\n\t\t\tend\n\t\t\tMatriz.new(@nfil, @ncol, elemento)\n\t\tend",
"def mat_add_or_subtract(mat1, mat2, operation='+')\n n = mat1.size\n result = n.times.map{ |x| [] }\n (0..n-1).each do |i|\n (0..n-1).each do |j|\n result[i] << (operation == '+' ? (mat1[i][j] + mat2[i][j]) : (mat1[i][j] - mat2[i][j]))\n end\n end\n result\nend",
"def matrix_addition_reloaded(*matrixes)\n return nil if !(matrixes.all? {|pair| matrixes[0].length == pair.length})\n # return matrixes if matrixes.length < 2\n \n matrixes.inject do |acc, el|\n matrix_addition(acc, el)\n end\n\nend",
"def matrixElementsSum(matrix)\r\n(0..matrix.length-2).each do |floor_number|\r\n\r\n (0..matrix[floor_number].length-1).each do |column_number|\r\n if matrix[floor_number][column_number] == 0\r\n matrix[floor_number+1].delete_at(column_number)\r\n matrix[floor_number+1].insert(column_number, 0)\r\n end\r\n end\r\n \r\nend\r\n\r\nreturn matrix.flatten.inject(:+)\r\n\r\nend",
"def +(m)\n matrix_cls = Matrix\n if m._isNumeric\n matrix_cls.Raise ErrOperationNotDefined, \"+\"\n elsif m._kind_of?(matrix_cls)\n # no coercion\n elsif m._kind_of?(Vector)\n m = matrix_cls.column_vector(m)\n else\n cr = m.coerce(self)\n return cr[0] | cr[1]\n end\n \n my_rows = @rows\n my_rows_size = my_rows.size\n my_column_size = self.column_size\n\n matrix_cls.Raise ErrDimensionMismatch unless my_rows_size == m.row_size and my_column_size == m.column_size\n #rows = (0 .. row_size - 1).collect { |i|\n # (0 .. column_size - 1).collect { |j|\n # self[i, j] + m[i, j]\n # }\n array_cls = Array\n rows = array_cls.new(my_rows_size)\n for i in 0..my_rows_size-1 do\n a_row = array_cls.new(my_column_size)\n for j in 0..my_column_size-1 do\n a_row[j] = self[i, j] + m[i, j]\n end\n rows[i] = a_row\n end\n matrix_cls.rows(rows, false)\n end",
"def +(other) \n \n aux=Matriz.new(@col,@fil)\n i=0\n self.fil.times do |i|\n\t j=0\n\t self.col.times do |j|\n\t aux[i][j]= valor[i][j] + other.get(i,j)\n\t j=j+1\n\t end\n\ti=i+1\n\tend\n aux\n end",
"def matrix_addition_reloaded(*matrices)\n first_m = matrices.first\n height = first_m.length\n width = first_m[0].length\n res = Array.new(height) {Array.new(width, 0)}\n \n matrices.inject(res) do |m1, m2|\n return nil if m1.length != m2.length || m1[0].length != m2[0].length\n matrix_addition(m1, m2)\n end\nend",
"def +(mat)\n if (mat.nFil == @nFil && mat.mCol == @mCol)\n aux = MatrizDensa.new(@matriz)\n for i in 0...@nFil do\n for j in 0...@mCol do\n aux.matriz[i][j] = @matriz[i][j] + mat.matriz[i][j]\n end\n end\n else\n aux = 0\n end\n aux\n end",
"def +(other)\r\n\t\t\r\n\t\t#if ((other.class.to_s == \"Dispersa\") && (other.fil == @fil) && (other.col == @col))\r\n\t\t\t\r\n\t\t\tmatrizSuma = Array.new(@fil) {Array.new(@col) {0}}\r\n\t\t\t\r\n\t\t\t0.upto(@numElementos - 1) do |i|\r\n\r\n\t\t\t\tmatrizSuma[@filM[i]][@colM[i]] = @eleM[i]\r\n\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\t0.upto(other.numElementos - 1) do |i|\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\tmatrizSuma[other.filM[i]][other.colM[i]] += other.eleM[i]\r\n\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t#puts \"suma = #{matrizSuma}\"\r\n\t\t\treturn matrizSuma\r\n\t\t\t\r\n\t\t#else\r\n\t\t\t#raise ArgumentError, \"Matrices de distinto tamanio\"\r\n\t\t#end\r\n\tend",
"def sumar (matrizb)\n\t\tsum = []\n\t\tx,y =0,0\n\t\twhile x < row\n\t\t\twhile y < col\n\t\t\t\tif y == 0\n\t\t\t\t\tsum << [matriz[x][y] + matrizb.matriz[x][y]]\n\t\t\t\telse\n\t\t\t\t\tsum[x] << matriz[x][y] + matrizb.matriz[x][y]\n\t\t\t\tend\n\t\t\t\ty= y+1\t\t\t\n\t\t\tend\n\t\t\tx=x+1\n\t\t\ty=0\n\t\tend\n\t\tMatriz.new (sum)\n\n\tend",
"def +(mat)\n if (mat.f == @f && mat.c == @c)\n resultado = Array.new\n for i in 0...@f do\n resultado[i] = Array.new\n for j in 0...@c do\n# \t if((!@matriz[i].nil?) && (!@matriz[i][j].nil?) && (!mat.matriz[i].nil?) && (!mat.matriz[i][j].nil?) && ((@matriz[i][j].class = Fraccion) || (mat.matriz[i][j] == Fraccion)))\n# \t resultado[i][j] = Fraccion.new(0,1)\n# \t else\n\t resultado[i][j] = 0 \n# \t end\n end\n end\n aux = Densa.new(resultado)\n nElementos = 0\n for i in 0...@f do\n for j in 0...@c do\n\t if ((!@matriz[i].nil?) && (!@matriz[i][j].nil?) && (!mat.matriz[i].nil?) && (!mat.matriz[i][j].nil?))\n aux.matriz[i][j] = @matriz[i][j] + mat.matriz[i][j]\n nElementos += 1\n\t elsif ((!@matriz[i].nil?) && (!@matriz[i][j].nil?) && ((!mat.matriz[i].nil?) || (!mat.matriz[i].nil? && !mat.matriz[i][j].nil?)))\n\t aux.matriz[i][j] = @matriz[i][j]\n nElementos += 1\n\t elsif ((!mat.matriz[i].nil?) && (!mat.matriz[i][j].nil?) && ((!@matriz[i].nil?) || (!@matriz[i].nil? && !@matriz[i][j].nil?)))\n\t aux.matriz[i][j] = mat.matriz[i][j]\n nElementos += 1\n\t end\n end\n end\n if ((@f * @c) * 0.4 > nElementos)\n aux = to_dispersa(aux)\n end\n else\n aux = \"No se pueden sumar\"\n end\n aux\n end",
"def mat_add_or_subtract(mat1, mat2, operation='+')\n n = mat1.size\n result = n.times.map{ |x| [] }\n (0..n-1).each do |i|\n (0..n-1).each do |j|\n result[i] << (operation == '+' ? (mat1[i][j] + mat2[i][j]) : (mat1[i][j] - mat2[i][j]))\n end\n end\n result\n end",
"def +(other) \n ms = @matrix.clone\n ms.merge!(other.hash){ |key, oldval, newval| newval + oldval}\n end",
"def + (other)\n\taux = Array.new(@m){Array.new(@n){0}}\n\tfor i in 0...@m do\n\t for j in 0...@n do\n\t aux[i][j] = self.matrixD[i][j] + other.matrixD[i][j]\n\t end\n\tend\n\tmr = MatrixDens.new(other.m, other.n)\n\tmr.rellenar(aux)\n\treturn(mr)\n end",
"def +(m)\n raise ArgumentError, \"m must be Matrix\" if not m.is_a? Matrix\n raise ArgumentError, \"m must have same size\" if m.cols != @cols || m.rows != @rows\n\n return Matrix.new(@rows, @cols) {|i,j| self[i,j] + m[i,j]}\n end",
"def exercise_1113 (matrix)\n end",
"def matrix_check_sum(matrix)\n return false if (matrix.length) != (matrix[0].length)\n (matrix.length).times do |i|\n rows = 0\n columns = 0\n (matrix[0].length).times do |j|\n rows += matrix[i][j]\n columns += matrix[j][i]\n end\n if rows != columns\n return false\n end\nend\nreturn true\nend",
"def +(m)\n raise ArgumentError, \"m must be Matrix\" if not m.is_a? Matrix\n raise ArgumentError, \"m must have same size\" if m.size() != self.size()\n\n return Matrix.new(@rows, @cols) {|i,j| self[i,j] + m[i,j]}\n end",
"def + (other)\n if (other.is_a?SparseMatrix)\n hash_aux = self.hash.merge(other.hash){|key, val1, val2| val1.merge(val2){|key2, val1_2, val2_2|val2_2 + val1_2}}\n mr = SparseMatrix.new(self.m, self.n)\n mr.rellenar(hash_aux)\n return (mr)\n \n else\n aux = Array.new(@m){Array.new(@n){0}}\n\tfor i in 0...@m do\n\t for j in 0...@n do\n\t aux[i][j] = self.matrixD[i][j] + other.matrixD[i][j]\n\t end\n\tend\n mr = MatrixDens.new(other.m, other.n)\n mr.rellenar(aux)\n return (mr)\n end\n end",
"def matrix_addition_reloaded(*matrices)\n matrix = matrices.first\n height = matrix.length\n width = matrix[0].length\n\n empty_matrix = Array.new(height) { [0] * width }\n matrices.inject(empty_matrix) do |m1, m2|\n return nil if m2.length != height or m2[0].length != width\n matrix_addition(m1, m2)\n end\nend",
"def matrix_addition_reloaded(*matrices)\n matrix = matrices.first\n height = matrix.length\n width = matrix[0].length\n\n empty_matrix = Array.new(height) { [0] * width }\n matrices.inject(empty_matrix) do |m1, m2|\n return nil if m2.length != height or m2[0].length != width\n matrix_addition(m1, m2)\n end\nend",
"def matrix_addition_reloaded(*matrices)\n\nend",
"def add_rows! *rows\r\n matrix_new = add_rows *rows\r\n @rows = matrix_new.to_a\r\n end",
"def diagonalSum(matrix)\n (0...matrix.size).map { |i| matrix[i][i] }.reduce(&:+)\nend",
"def diagonalSum(matrix)\ntotal = 0\n (0...matrix.length).each {|sub| total += matrix[sub][sub]}\nreturn total\nend",
"def matrix_check_sum(matrix)\n\n row_array = []\n column_array = []\n\n matrix.each do |row|\n row_sum = 0\n row.each do |element|\n row_sum += element\n end\n row_array << row_sum\n end\n\n column_length = matrix[0].length\n j = 0\n until j == column_length\n column_sum = 0\n matrix.each do |row|\n column_sum += row[j]\n end\n j += 1\n column_array << column_sum\n end\n\n if row_array == column_array\n return true\n else\n return false\n end\n\nend",
"def rec_matrix_multiplication(a, b)\n return a[0] * b[0] if a.length == 1\n\n a_splited = split_matrix(a, a.length)\n b_splited = split_matrix(b, a.length)\n\n a_b_1 = [matrix_sum(rec_matrix_multiplication(a_splited[0], b_splited[0]), rec_matrix_multiplication(a_splited[1], b_splited[2]))].flatten\n a_b_2 = [matrix_sum(rec_matrix_multiplication(a_splited[0], b_splited[1]), rec_matrix_multiplication(a_splited[1], b_splited[3]))].flatten\n a_b_3 = [matrix_sum(rec_matrix_multiplication(a_splited[2], b_splited[0]), rec_matrix_multiplication(a_splited[3], b_splited[2]))].flatten\n a_b_4 = [matrix_sum(rec_matrix_multiplication(a_splited[2], b_splited[1]), rec_matrix_multiplication(a_splited[3], b_splited[3]))].flatten\n\n row_length = a_b_1.count\n\n if row_length == 1\n result = [[a_b_1[0], a_b_2[0], a_b_3[0] , a_b_4[0]]]\n else\n result = \n [\n a_b_1[0..(row_length / 2) - 1] + a_b_2[0..(row_length / 2) - 1] +\n a_b_1[(row_length / 2).. - 1] + a_b_2[(row_length / 2).. - 1] +\n a_b_3[0..(row_length / 2) - 1] + a_b_4[0..(row_length / 2) - 1] +\n a_b_3[(row_length / 2).. - 1] + a_b_4[(row_length / 2).. - 1]\n ]\n end\n\n build(result[0], result[0].length)\nend",
"def crossingSum(matrix, a, b) \n sum = 0;\n \n matrix.each_with_index do |row, index|\n if a == index\n row.each { |x| sum += x}\n break\n end\n end\n\n matrix.transpose.each_with_index do |row, index|\n if b == index\n row.each_with_index { |col, index| sum += col if a != index }\n end\n end\n sum\nend",
"def concatenate_matrix(a, b, c, d, e, f)\n transform = Matrix[\n [a, b, 0],\n [c, d, 0],\n [e, f, 1]\n ]\n if state[:ctm]\n state[:ctm] = transform * state[:ctm]\n else\n state[:ctm] = transform\n end\n end",
"def +(other)\n raise ArgumentError , 'El argumento debe ser una matriz' unless other.is_a? Matriz\n raise ArgumentError , 'Las matrices deben ser del mismo tamano' unless @fil == other.fil and @col == other.col\n \n c = Matriz_Densa.new(@fil, @col)\n i = 0\n while(i < @fil)\n j = 0\n while(j < @col)\n c.matrix[i][j] = @matrix[i][j] + other.get(i,j)\n j += 1\n end \n i += 1\n end\n c\n end",
"def diagonalSum(matrix)\n sum = 0\n\n matrix.each_with_index do |current_arr, idx|\n sum += current_arr[idx]\n end\n\n sum\nend",
"def diagonalSum(matrix)\n # case Matrix[*matrix].column_size\n # when Matrix[*matrix].row_size\n x=0\n y=0\n p matrix.class\n while x<matrix.flatten.size do \n y=y+matrix.flatten[x]\n x=x+matrix.size+1 \n # print \"x= #{x}, y = #{y}, \"\n end\n y\nend",
"def add_two_matrices(left, right)\n\t\n\tif left.rows != right.rows or left.cols != right.cols\n\t\tthrow_error(\"Matrix dimensions don't match when adding two matrices.\", left, []) # TODO: Add stack trace (make a global)\n\tend\n\n\tnew_rows = []\n\tfor row_index in (0..left.rows - 1)\n\t\trow = []\n\t\tfor col_index in (0..left.cols - 1)\n\t\t\tcase [left.values[row_index][col_index], right.values[row_index][col_index]]\n\t\t\tin [Term, Term]\n\t\t\t\trow.append(add_two_terms(left.values[row_index][col_index], right.values[row_index][col_index]))\n\t\t\tin [Term, TermList]\n\t\t\t\trow.append(add_term_and_term_list(left.values[row_index][col_index], right.values[row_index][col_index]))\n\t\t\tin [TermList, Term]\n\t\t\t\trow.append(add_term_and_term_list(right.values[row_index][col_index], left.values[row_index][col_index]))\n\t\t\tin [TermList, TermList]\n\t\t\t\trow.append(add_term_list_and_term_list(left.values[row_index][col_index], right.values[row_index][col_index]))\n\t\t\tin [Fraction, Term]\n\t\t\t\trow.append(add_fraction_and_term(left.values[row_index][col_index], right.values[row_index][col_index]))\n\t\t\tin [Fraction, TermList]\n\t\t\t\trow.append(add_fraction_and_term_list(left.values[row_index][col_index], right.values[row_index][col_index]))\n\t\t\tin [Term, Fraction]\n\t\t\t\trow.append(add_fraction_and_term(right.values[row_index][col_index], left.values[row_index][col_index]))\n\t\t\tin [TermList, Fraction]\n\t\t\t\trow.append(add_fraction_and_term_list(right.values[row_index][col_index], left.values[row_index][col_index]))\n\t\t\tin [Fraction, Fraction]\n\t\t\t\trow.append(add_fraction_and_fraction(left.values[row_index][col_index], right.values[row_index][col_index]))\n\t\t\telse\n\t\t\t\tthrow_error(\"Matrix addition with matrices that don't contain only Terms, TermLists, and Fractions.\", left, []) # TODO: Add stack trace (make a global)\n\t\t\tend\n\t\tend\n\t\tnew_rows.append(row)\n\tend\n\treturn Matrix.new(left.line, left.col, new_rows)\nend",
"def matrix_addition_reloaded(*matrices)\n size = matrices.first.size\n return if matrices.any? { |m| m.size != size }\n\n new_matrix = matrices[0].dup\n matrices[1..-1].each do |mat2|\n new_matrix = matrix_addition(new_matrix, mat2)\n end\n new_matrix\nend",
"def +(other)\n c = Matriz_Densa.new(@filas, @columnas)\n 0.upto(@filas-1) do |i|\n 0.upto(@columnas-1) do |j|\n c.set(i, j, get(i,j) + other.get(i,j))\n end\n end\n c\n end",
"def matrix_check_sum(matrix)\n i = 0\n\n matrix.length.times do\n sum = 0\n\n matrix.each do |array|\n sum += array[i]\n end\n\n if sum != matrix[i].reduce(:+)\n return false\n end\n\n i += 1\n end\n\n return true\nend",
"def matrix_check_sum(matrix)\n num_of_rows = matrix.length\n\n sum_rows = []\n num_of_rows.times do |i|\n sum = 0\n num_of_rows.times do |j|\n sum += matrix[i][j]\n end\n sum_rows << sum\n end\n\n sum_cols = []\n num_of_rows.times do |i|\n sum = 0\n num_of_rows.times do |j|\n sum += matrix[j][i]\n end\n sum_cols << sum\n end\n\n if sum_rows == sum_cols\n return true\n else\n return false\n end\nend",
"def addRows(matrixPassed)\n rowSum = 0\n rowLen = 0\n rowIndex = 0\n matrixPassed.each do |sub|\n sub.each do |elements|\n rowSum = rowSum + elements\n rowLen = rowLen + 1\n end\n rowAvg = rowSum/rowLen\n puts \"Row# #{rowIndex+1} rowSum = #{rowSum}, rowLen = #{rowLen}, rowAvg = #{rowAvg}\"\n rowSum = 0\n rowLen = 0\n rowIndex = rowIndex + 1\n end\nend",
"def make_combined_matrix(array_one, array_two)\n result = []\n\n for i in 0..array_one.length-1\n row = []\n for j in 0.. array_two.length-1\n row.push(array_two[j] + array_one[i])\n end\n result.push(row)\n end\n\n return result\nend",
"def *(m) # m is matrix or vector or number\n matrix_cls = Matrix\n array_cls = Array\n if m._isNumeric\n # rows = @rows.collect { |row|\n # row.collect { |e| e * m }\n # }\n my_rows = @rows\n my_rows_size = my_rows.size\n rows = array_cls.new(my_rows_size)\n for i in 0..my_rows_size-1 do\n row = my_rows[i]\n r_size = row.size\n res_row = array_cls.new(r_size)\n for j in 0..r_size-1 do\n res_row[j] = row[j] * m\n end\n rows[i] = res_row\n end\n return matrix_cls.rows(rows, false)\n elsif m._kind_of?( Vector )\n m = matrix_cls.column_vector(m)\n r = self * m\n return r.column(0)\n elsif m._kind_of?( matrix_cls )\n # Matrix.Raise ErrDimensionMismatch if column_size != m.row_size\n # rows = (0 .. row_size - 1).collect { |i|\n # (0 .. m.column_size - 1).collect { |j|\n # vij = 0\n # 0.upto(column_size - 1) { |k| vij += self[i, k] * m[k, j] }\n # vij\n # }\n # }\n my_column_size = self.column_size\n other_column_size = m.column_size\n matrix_cls.Raise ErrDimensionMismatch if my_column_size != m.row_size\n my_rows = @rows\n my_rows_size = my_rows.size\n rows = array_cls.new(my_rows_size)\n for i in 0..my_rows_size-1 do\n res_row = array_cls.new(other_column_size)\n for j in 0..other_column_size-1 do\n vij = 0\n for k in 0..my_column_size-1 do\n vij += self[i, k] * m[k, j]\t\n end\n vij\n res_row[j] = vij\n end\n rows[i] = res_row\n end\n return matrix_cls.rows(rows, false)\n else\n cr = m.coerce(self)\n return cr[0] * cr[1]\n end\n end",
"def +(other)\t \n\t\tif(self.fil == other.fil and self.col == other.col)\n\t\t\t# SELF Matrices densas\n\t\t\tif self.instance_of?MatrizDensa\n\t\t\t\ttemp = MatrizDensa.new(self.fil, self.col, nil)\n\t\t\t\tif other.instance_of?MatrizDensa\n\t\t\t\t\t\n\t\t\t\t\t#for i in (0...@fil.to_i)\n\t\t\t\t\t@fil.to_i.times do |i| \n\t\t\t\t\t\n\t\t\t\t\t\t#for j in (0...@col.to_i)\n\t\t\t\t\t\t@col.to_i.times do |j|\n\t\t\t\t\t\t\ttemp.mat[i][j] = (@mat[i][j]) + (other.mat[i][j])\n\t\t\t\t\t\t\t\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tif other.instance_of?MatrizDispersa\n\t\t\t\t\t#for i in (0...@fil.to_i)\n\t\t\t\t\t@fil.to_i.times do |i| \n\t\t\t\t\t\n\t\t\t\t\t\t#for j in (0...@col.to_i)\n\t\t\t\t\t\t@col.to_i.times do |j| \n\t\t\t\t\t\n\t\t\t\t\t\t\tencontrado = 0\n\t\t\t\t\t\t\t#for k in (0...other.posx.size)\n\t\t\t\t\t\t\tother.posx.size.times do |k| \n\t\t\t\t\t\t\t\tif (i==other.posx[k] and j==other.posy[k] and encontrado==0)\n\t\t\t\t\t\t\t\t\ttemp.mat[i][j] = (self.mat[i][j]) + (other.valor[k])\n\t\t\t\t\t\t\t\t\tencontrado = 1\t\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tif (encontrado == 0)\n\t\t\t\t\t\t\t\ttemp.mat[i][j] = self.mat[i][j]\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# SELF Matriz Dispersa\n\t\t\tif self.instance_of?MatrizDispersa\n\t\t\t\tif other.instance_of?MatrizDensa\n\t\t\t\t\ttemp = MatrizDensa.new(self.fil, self.col, nil)\n\t\t\t\t\t#for i in (0...@fil.to_i)\n\t\t\t\t\t\t@fil.to_i.times do |i| \n\t\t\t\t\t\n\t\t\t\t\t\tfor j in (0...@col.to_i)\n\t\t\t\t\t\t\tencontrado = 0\n\t\t\t\t\t\t\t#for k in (0...self.posx.size.to_i)\n\t\t\t\t\t\t\tself.posx.size.times do |k| \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tif (i==self.posx[k] and j==self.posy[k] and encontrado==0)\n\t\t\t\t\t\t\t\t\ttemp.mat[i][j] = (other.mat[i][j]) + (self.valor[k])\n\t\t\t\t\t\t\t\t\tencontrado = 1\t\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tif (encontrado == 0)\n\t\t\t\t\t\t\t\ttemp.mat[i][j] = other.mat[i][j]\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\n\n\t\t\t\tif other.instance_of?MatrizDispersa\n\t\t\t\t\ttemp = MatrizDispersa.new(self.fil,self.col,[],[],[])\n\t\t\t\t\ttemp.valor = self.valor\n\t\t\t\t\ttemp.posx = self.posx\n\t\t\t\t\ttemp.posy = self.posy\n\n\t\t\t\t\t#for j in (0...other.posx.size.to_i)\n\t\t\t\t\tother.posx.size.to_i.times do |j| \n\t\t\t\t\t\n\t\t\t\t\t\tencontrado = false\n\t\t\t\t\t\t#for k in (0...self.posx.size.to_i)\n\t\t\t\t\t\tself.posx.size.times do |k| \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif(other.posx[j] == temp.posx[k] and other.posy[j] == temp.posy[k])\n\t\t\t\t\t\t\t\ttemp.valor[k] = temp.valor[k] + other.valor[j]\n\t\t\t\t\t\t\t\tencontrado = true\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif (encontrado == false)\n\t\t\t\t\t\t\ttemp.posx << other.posx[j]\n\t\t\t\t\t\t\ttemp.posy << other.posy[j]\n\t\t\t\t\t\t\ttemp.valor << other.valor[j]\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\n\t\t\treturn temp\n\t\telse \n\t\t\treturn nil\n\t\tend\n\tend",
"def sum(dim=0)\n reduce_along_dim(dim, 0.0) do |sum, sub_mat|\n sum + sub_mat\n end\n end",
"def concatenate_matrix(a, b, c, d, e, f)\n if state[:ctm]\n state[:ctm].left_multiply!(a,b,c,d,e,f)\n else\n state[:ctm] = TransformationMatrix.new(a,b,c,d,e,f)\n end\n invalidate_cached_values\n end",
"def get_sum(matrix, i)\n sum_ = 0\n for k in 1...matrix.length\n sum_ += matrix[i][k]\n end\n sum_\nend",
"def vector_add(w, x)\n sum_vector = @feature_count.times.map { |x| 0 }\n (0..@feature_count-1).each { |i| sum_vector[i] = w[i] + x[i] }\n sum_vector\nend",
"def matrix_check_sum(matrix)\n rows = matrix.length\n columns = matrix[0].length\n \n sum_rows = []\n matrix.each do |row|\n sum_rows.push(row.sum)\n end\n\n sum_columns = []\n columns.times do |i|\n sum = 0\n rows.times do |j|\n sum = sum + matrix[j][i]\n end\n sum_columns.push(sum)\n end\n \n rows.times do |i|\n columns.times do |j|\n if sum_rows[i] != sum_columns[j]\n return false\n end\n end\n end\n\n return true\nend",
"def * (other)\n i=0\n m_aux = Array.new(@fila) {Array.new(other.columna,0)}\n while i < @fila\n j = 0\n while j < other.columna\n m_aux[i][j] = 0\n k = 0\n while k < @columna\n m_aux[i][j] += matriz[i][k] * other.matriz[k][j]\n k += 1\n end\n j +=1\n end\n i +=1\n end\n Matriz.new(m_aux)\n end",
"def matrix_check_sum(matrix)\n rows = matrix.length\n cols = matrix[0].length\n\n rows.times do |row|\n row_sum = 0\n col_sum = 0\n cols.times do |col|\n row_sum += matrix[row][col]\n col_sum += matrix[col][row]\n end\n return false if row_sum != col_sum\n end\n return true\nend",
"def add_rows *rows\r\n matrix_a = self.to_a\r\n\r\n rows.each {|m|\r\n if m.column_size != self.column_size\r\n raise ArgumentError, \"number of columns should be identical\"\r\n end\r\n\r\n matrix_a += m.to_a\r\n }\r\n\r\n Matrix.rows(matrix_a)\r\n end",
"def sum\n [@r,@g,@b].inject(:+)\n end",
"def matrix\n end",
"def test_adding_an_otu_plus_adds_to_matrix\n setup2\n assert_equal 0, @mx.otus_plus.count \n o = Otu.create!(:name => 'foo')\n @mx.otus_plus << o\n @mx.reload\n\n # adds to the + list?\n assert_equal 1, @mx.otus_plus.count\n assert_equal o, @mx.otus_plus[0]\n\n # adds to the master list?\n assert_equal 1, @mx.otus.count\n assert_equal o, @mx.otus[0]\n end",
"def *(other)\n m = Array.new(@nfil){Array.new(@ncol){0}}\n for i in 0...nfil do\n for j in 0...other.ncol do \n for k in 0...ncol do\n m[i][j] = m[i][j] + self.mat[i][k] * other.mat[k][j]\n end\n end\n end\n return Matriz.new(self.nfil,other.ncol,m) \n end",
"def matrix_check_sum(matrix)\n puts \"NOT IMPLEMENTED\"\nend",
"def multiply(first_matrix, second_matrix)\n x = first_matrix[0][0] * second_matrix[0][0] + first_matrix[0][1] * second_matrix[1][0]; \n y = first_matrix[0][0] * second_matrix[0][1] + first_matrix[0][1] * second_matrix[1][1]; \n z = first_matrix[1][0] * second_matrix[0][0] + first_matrix[1][1] * second_matrix[1][0]; \n w = first_matrix[1][0] * second_matrix[0][1] + first_matrix[1][1] * second_matrix[1][1]; \n \n first_matrix[0][0] = x; \n first_matrix[0][1] = y; \n first_matrix[1][0] = z; \n first_matrix[1][1] = w; \n end",
"def *(other)\n \n aux=Matriz.new(@col,@fil)\n i=0\n while i < @fil\n\tj = 0\n\twhile j < other.col\n\t k = 0\n\t while k < @col\n\t aux.valor[i][j] = aux.valor[i][j] + (self.get(i,k)*other.get(k,j))\n\t k=k+1\n\t end\n\t j=j+1\n\tend\n\ti=i+1\n end\n aux\n end",
"def matrix_check_sum(matrix)\n i = 0\n\n while matrix[i] != nil\n j = 0\n row = 0\n column = 0\n\n while matrix[j] != nil\n row += matrix[i][j]\n column += matrix[j][i]\n j += 1\n end\n\n return false if row != column\n i += 1\n end\n return true\nend",
"def add_one_vector(*matrices)\n matrices.map { |m|\n \tnum_rows = m.row_size\n \tnum_cols = m.column_size \t\n \tcolumns = [ Array.new(num_rows) { 1.0 } ]\n \tcolumns.push *(m.column_vectors.map { |v| v.to_a })\n \tMatrix.columns(columns)\n }\n end",
"def +(other)\n\t if (other.is_a? Matriz_Dispersa)\n\t\tif(@alt==other.alt && @anc=other.anc)\n\t\t\tsuma=Matriz_Dispersa.new(@alt+1,@anc+1, [],[],[], (@n_elem+other.n_elem))\n\t\t\tm = 0\n\t\t\t0.upto(suma.n_elem-1) do |i|\n\t\t\t if(other.elem[i].is_a? Fixnum)\n\t\t\t suma.elem[i]=0\n\t\t\t end\n\t\t\t if(other.elem[i].is_a? Fraccion)\n\t\t\t suma.elem[i]=Fraccion.new(0,1)\n\t\t\t end\n\t\t\tend\n\t\t\t0.upto(@alt) do |i|\n\t\t\t 0.upto(@anc) do |j|\n\t\t\t 0.upto(@n_elem-1) do |h|\n\t\t\t if(i==@alto[h])\n\t\t\t\t0.upto(@n_elem-1) do |t|\n\t\t\t\t if(j == @alto[t] && h==t)\n\t\t\t\t suma.elem[m]=@elem[t]\n\t\t\t\t suma.alto[m]=@alto[t]\n\t\t\t\t suma.ancho[m]=@ancho[t]\n\t\t\t\t m = m+1\n\t\t\t\t end\n\t\t\t\tend\n\t\t\t end\n\t\t\t end\n\t\t\t 0.upto(other.n_elem-1) do |l|\n\t\t\t\tif(i==other.alto[l])\n\t\t\t\t 0.upto(other.n_elem-1) do |t|\n\t\t\t\t if(j==other.alto[t] && l==t)\n\t\t\t\t suma.elem[m]=(suma.elem[m]+other.elem[t])\n\t\t\t\t suma.alto[m]=other.alto[t]\n\t\t\t\t suma.ancho[m]=other.ancho[t]\n\t\t\t\t m = m+1\n\t\t\t\t end\n\t\t\t\t end\n\t\t\t\tend\n\t\t\t end\n\t\t\t end\n\t\t\tend\n\t\t\tsuma\n\t\telse\n\t\t puts \"no se puede realizar la suma\"\n\t\tend\n\t else\n\t if(other.is_a? Matriz_Densa)\n\t if(@alt==other.alt && @anc=other.anc)\n\t\tother.+(self.to_densa)\n\t else\n\t\tputs \"no se puede realizar la suma\"\n\t end\n\t end\n\t end\n\tend",
"def *(mat)\n if (@c == mat.f)\n result = Array.new\n for i in 0...@f do\n result[i] = Array.new\n for j in 0...@c do\n result[i][j] = 0\n end\n end\n aux = Densa.new(result)\n nElementos = 0\n for i in 0...@f do\n for j in 0...mat.c do\n for z in 0...@c do\n if ((!@matriz[i].nil?) && (!@matriz[i][z].nil?) && (!mat.matriz[z].nil?) && (!mat.matriz[z][j].nil?))\n aux.matriz[i][j] += @matriz[i][z] * mat.matriz[z][j]\n nElementos += 1\n end\n end\n end\n end\n if ((@f * @c) * 0.4 > nElementos)\n aux = to_dispersa(aux)\n end\n else\n aux = \"No se pueden multiplicar\"\n end\n aux\n end",
"def matrix_check_sum(matrix)\n per_line = matrix.length\n col_index = 0\n\n matrix.each do |row|\n row_sum = 0\n per_line.times do |i|\n row_sum += row[i]\n end\n\n col_sum = 0\n per_line.times do |i|\n col_sum += matrix[i][col_index]\n end\n\n if row_sum == col_sum\n col_index += 1\n else\n return false\n end\n\n end\n return true\nend",
"def sum_prod_diags(matrix)\n\n require 'matrix'\n \n # ability to rotate nested array 90 degrees (for right - to left calc)\n def rotate(matrix)\n newMatrix, finalMatrix, i = [], [], 0\n (matrix.length > matrix[0].length ? matrix.length : matrix[0].length).times do\n matrix.map { |row| row[i] != nil ? newMatrix << row[i] : nil }\n i+=1\n end\n newMatrix.each_slice(matrix.length).to_a.reverse\n end\n \n # get the diagonal and all lower diagonals\n def diags_sum_array(matrix)\n sum = []\n length = matrix.column(0).count\n \n d = matrix\n i = length\n while i > 0 do\n # multiply the values of the diagonal\n sum << d.each(:diagonal).inject(:*)\n d = d.first_minor(0,(i-1))\n i -= 1\n end\n \n # get the upper diagonals\n trans = matrix.transpose\n y = length - 1\n while y > 0 do\n # multiply the values of the diagonal\n trans = trans.first_minor(0,(y))\n sum << trans.each(:diagonal).inject(:*)\n y -= 1\n end\n \n return sum\n \n end\n\n # run for left to right calc\n d_sum = diags_sum_array(Matrix[*matrix])\n \n # run for right to left calc (using rotate array method)\n a_sum = diags_sum_array(Matrix[*rotate(matrix)])\n\n # add each result, return the difference in the two\n return d_sum.inject(:+) - a_sum.inject(:+)\n \nend",
"def concat(*matrices)\n rank = nil\n rank = matrices.pop unless matrices.last.is_a?(NMatrix)\n\n # Find the first matching dimension and concatenate along that (unless rank is specified)\n if rank.nil?\n rank = self.dim-1\n self.shape.reverse_each.with_index do |s,i|\n matrices.each do |m|\n if m.shape[i] != s\n rank -= 1\n break\n end\n end\n end\n elsif rank.is_a?(Symbol) # Convert to numeric\n rank = {:row => 0, :column => 1, :col => 1, :lay => 2, :layer => 2}[rank]\n end\n\n # Need to figure out the new shape.\n new_shape = self.shape.dup\n new_shape[rank] = matrices.inject(self.shape[rank]) { |total,m| total + m.shape[rank] }\n\n # Now figure out the options for constructing the concatenated matrix.\n opts = {stype: self.stype, default: self.default_value, dtype: self.dtype}\n if self.yale?\n # We can generally predict the new capacity for Yale. Subtract out the number of rows\n # for each matrix being concatenated, and then add in the number of rows for the new\n # shape. That takes care of the diagonal. The rest of the capacity is represented by\n # the non-diagonal non-default values.\n new_cap = matrices.inject(self.capacity - self.shape[0]) do |total,m|\n total + m.capacity - m.shape[0]\n end - self.shape[0] + new_shape[0]\n opts = {capacity: new_cap}.merge(opts)\n end\n\n # Do the actual construction.\n n = NMatrix.new(new_shape, opts)\n\n # Figure out where to start concatenation. We don't know where it will end,\n # because each matrix may have own size along concat dimension.\n pos = Array.new(self.dim) { 0 }\n\n matrices.unshift(self)\n matrices.each do |m|\n # Figure out where to start and stop the concatenation. We'll use\n # NMatrices instead of Arrays because then we can do elementwise addition.\n ranges = m.shape.map.with_index { |s,i| pos[i]...(pos[i] + s) }\n\n n[*ranges] = m\n\n # Move over by the requisite amount\n pos[rank] = pos[rank] + m.shape[rank]\n end\n\n n\n end",
"def sum_arr(arr_1, arr_2)\n [arr_1,arr_2].transpose.map { |el| el.reduce(&:+) }\nend",
"def matrix_check_sum(matrix)\n\n # incrementer for rows\n i = 0\n # incrementer for summing rows\n j = 0\n # incrementer for summing columns\n k = 0\n\n row_sum = 0\n column_sum = 0\n\n while i < matrix.length\n while j < matrix[i].length\n row_sum += matrix[i][j]\n j += 1\n end\n\n while k < matrix.length\n column_sum += matrix[k][i]\n k += 1\n end\n\n return false if row_sum != column_sum\n\n column_sum = 0\n row_sum = 0\n\n k = 0\n j = 0\n i += 1\n end\n\n return true\nend",
"def adjugate_matrix(m)\n rows, cols = matrix_dimensions(m)\n raise if rows != cols\n cofactor_matrix = new_matrix(rows, cols)\n 0.upto(rows-1) do |i|\n 0.upto(cols-1) do |j|\n cofactor_matrix[i][j] = ((-1)**(i+j))*matrix_determinant(minor_matrix(m, i, j))\n end\n end\n matrix_transpose(cofactor_matrix)\nend",
"def trace\n sum = 0\n # 0.upto(column_size - 1) do\n my_rows = @rows\n col_size = my_rows[0].size \n for i in 0..col_size-1 do \n row = my_rows[i]\n if row._equal?(nil)\n Matrix.Raise(ErrDimensionMismatch, 'not square') \n end\n sum += row[i]\n end\n sum\n end",
"def matrix_region_sum(matrix, top_left_coords, bottom_right_coords)\n\nend"
] |
[
"0.7869705",
"0.7850795",
"0.7777493",
"0.77681583",
"0.76983064",
"0.76678276",
"0.7649536",
"0.7621031",
"0.7506059",
"0.74922585",
"0.7410893",
"0.7402457",
"0.73622286",
"0.7308594",
"0.7256614",
"0.71787995",
"0.7162077",
"0.7141986",
"0.71276253",
"0.7099612",
"0.7067877",
"0.6983951",
"0.6930823",
"0.6928266",
"0.687552",
"0.6852915",
"0.6829261",
"0.6823644",
"0.6817472",
"0.67987686",
"0.6781001",
"0.67554444",
"0.6695557",
"0.6673244",
"0.6649793",
"0.66116124",
"0.65868825",
"0.6578575",
"0.6545662",
"0.65232736",
"0.6513388",
"0.6512472",
"0.65055627",
"0.6483635",
"0.6482117",
"0.6474265",
"0.6468381",
"0.6461542",
"0.64445925",
"0.64415634",
"0.6409354",
"0.636909",
"0.6365966",
"0.62939215",
"0.6284371",
"0.6211849",
"0.62081605",
"0.6196721",
"0.6188977",
"0.61730134",
"0.6172572",
"0.61695576",
"0.6162583",
"0.61579686",
"0.61326987",
"0.61103684",
"0.60985434",
"0.60739875",
"0.6052639",
"0.60470814",
"0.6033673",
"0.6031202",
"0.6009324",
"0.600527",
"0.6000453",
"0.5985513",
"0.59626955",
"0.5949502",
"0.59449834",
"0.59291995",
"0.5914123",
"0.59131896",
"0.591268",
"0.5905462",
"0.589461",
"0.588341",
"0.5877831",
"0.5868831",
"0.58588356",
"0.5852043",
"0.582828",
"0.58168024",
"0.578817",
"0.576893",
"0.5749986",
"0.5746961",
"0.5746286",
"0.57417715",
"0.5729053",
"0.57016313"
] |
0.8022373
|
0
|
codewars kata: josephus survivor this solution is built on this solution:
|
def josephus_survivor(n,k)
# (1..n) people are put into the circle
items = (1..n).to_a
Array.new(n){items.rotate!(k-1).shift}.last
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def josephus_survivor(n,k)\n result = 1\n for i in 1...n + 1\n result = (result + k - 1) % i + 1\n end\n \n result\nend",
"def josephus_survivor(n, k)\n survivors = (1..n).to_a\n loop do\n survivors.rotate!(k -1).shift\n return survivors[0] if survivors.length == 1\n end\nend",
"def josephus_survivor(n,k)\n arr = (1..n).to_a\n\n while arr.length > 1\n idx = k % arr.length\n\n if arr.length > k\n arr = arr.drop(k) + arr.take(k - 1)\n elsif arr.length == k \n arr = arr[0...-1]\n else\n arr = arr.drop(idx) + arr.take(idx - 1)\n end\n end\n \n arr[0]\nend",
"def josephus(items,k)\n killed = []\n # loop the following two until items == []\n until items.length == 0 do\n items = items.rotate(k)\n killed << items.pop\n end\n killed\nend",
"def josephus(items,k)\n result = []\n count = k\n until items.length == 0 do\n remove_these = []\n items.each_with_index do |item, i|\n if count == 1\n result << items[i]\n remove_these << i\n end\n count = count == 1 ? k : count -= 1\n end\n remove_these.reverse!\n remove_these.each do |r|\n items.delete_at(r)\n end\n end\n result\nend",
"def sluggish_octopus(fish)\n sorted = false\n until sorted\n sorted = true\n fish.each_with_index do |ele, idx|\n next if idx == fish.length - 1\n current = ele\n neighbor = fish[idx + 1]\n if neighbor.length > current.length\n fish[idx] = neighbor \n fish[idx + 1] = current\n sorted = false\n end\n end\n end\n\n fish.first\nend",
"def josephus(items,k)\n new_array = []\n while items.size > (k-1)\n new_array << items.delete_at(k-1)\n items.rotate!(k-1)\n end\n while items.size > 0\n items.rotate!(k-1)\n new_array << items.delete_at(0)\n end\n new_array\nend",
"def cavity grid\n # copy_g = grid\n\n # # size = copy_g[0].length\n\n # copy_g.delete_at(size-1)\n # copy_g.delete_at(0)\n\n # copy_g[0].delete_at(size-1)\n # copy_g[0].delete_at(0)\n\n # # p copy_g\n\n # center = []\n\n # size = grid.size -1\n\n\n # (1..size).each do |i|\n # j = size - i\n # center << [i,j]\n # center << [i,j+1]\n # end\n # p center\n\ncenter = []\ncavity = []\nsize = grid.size-1\n\ncopy_g = grid\n\ngrid.each_with_index do |x, xi|\n x.each_with_index do |y, yi|\n\n\n if xi != 0 && yi != 0 && xi != size && yi != size\n # p \"element [#{xi}, #{yi}] is #{y}\"\n center << [xi, yi]\n\n if grid[xi][yi + 1] < y && grid[xi][yi - 1] < y\n cavity << [xi, yi]\n copy_g[xi][yi] = 'X'\n end\n\n end\n end\nend\n\np center\np cavity\np copy_g\n\nend",
"def surge; end",
"def josephus(arr, k)\n removed_elements = []\n while arr.length > 0 do\n arr = arr.rotate(k)\n removed_elements << arr.pop\n end\n removed_elements\nend",
"def solve\n @time = Time.new\n for j in 0..@generations\n new_generation = Array.new\n @selection.init(@population)\n \n for i in 0..(@population_size/2)-1\n children = @reproduction.reproduce(@selection.select,@selection.select,@mutation)\n \n son = children[0]\n daughter = children[1]\n \n if son.fitness > @best_fitness\n @best_fitness = son.fitness\n @best_configuration = son.configuration.conf\n end\n \n if daughter.fitness > @best_fitness\n @best_fitness = daughter.fitness\n @best_configuration = daughter.configuration.conf\n end\n \n new_generation.push(son)\n new_generation.push(daughter)\n \n end\n \n @population = new_generation\n \n end\n @time = Time.new - @time\n end",
"def validate_survivors\n not(same_survivor? or invalid_survivors?) ? true : false\n end",
"def fitness\n -(0..5).map{|t| \n $pors_store = 0 # reset store\n t_val = t\n values = {:rec=>proc{$pors_store},:T=>proc{ cv=t_val; t_val=0; cv} } # using T destroys T\n (eval_genes(values) - N*t).abs \n }.sum - 0.1*size # find a tree that multiplies T by 3\n end",
"def josephus(items,k)\n n = -1\n out = []\n while items.length > 0 do \n n = (n + k) % items.length \n out.push(items.slice!(n))\n n -= 1 \n end\n out\nend",
"def phase_one\n eliminated = []\n 8.times do\n elim_tribe = @borneo.immunity_challenge\n index = @borneo.tribes.index(elim_tribe)\n element = elim_tribe.tribal_council\n @borneo.tribes[index].members = @borneo.tribes[index].members - Array(element)\n eliminated << element\n end\n puts \"Phase 1 eliminations: \".red\n puts \"----------------------------------------\"\n eliminated.each_with_index do |contestants,index|\n puts \"#{index+1}: #{contestants}\"\n end\n puts \"----------------------------------------\"\n eliminated.length\nend",
"def dominant_octopus(fish)\n #sorted = []\n return fish if fish.length < 2\n pivot = fish.first\n left = fish[1..-1].select { |feesh| feesh.length <= pivot.length }\n #p left\n right = fish[1..-1].select { |feesh| feesh.length > pivot.length }\n\n dominant_octopus(left) + [pivot] + dominant_octopus(right)\n \n\n\nend",
"def checkSrepIntersection\n (0..$sreps.length-1).each do |j|\n (0..$sreps.length-1).each do |i|\n if i != j\n $sreps[j].checkIntersection($sreps[i])\n end\n end\n end\n end",
"def custom_tour()\n\t\tchildren = Hash.new(-1)\n\t\tfor i in 0..@problem.size - 1\n\t\t\tchildren[i] = PriorityQueue.new()\n\n\t\t\t@problem.succesors(i).each do |node|\n\t\t\t\tchildren[i].push(node, h(node))\n\t\t\tend\n\t\tend\n\t\t\n\t\tvertices = [*1..@problem.size]\n\t\tvertices.delete(@problem.start)\n\t\toutput = [@problem.start]\n\t\twhile vertices.any?\n\t\t\tu = output.last\n\t\t\tchd = children[u]\n\t\t\tv = chd.pop()\n\n\t\t\tif not vertices.include? v\n\t\t\t\tv = chd.pop()\n\t\t\tend\n\n\t\t\th_val = 0\n\t\t\tif v != nil\n\t\t\t\th_val = h(v)\n\t\t\tend\n\n\t\t\tchildren.each do |key, value|\n\t\t\t\tchildren[key].delete(h_val)\t\n\t\t\tend\n\n\t\t\tif v == nil\n\t\t\t\treturn output\n\t\t\tend\n\t\t\tvertices.delete(v)\n\t\t\toutput.push(v)\n\t\tend\t\n\t\treturn output\t\t\n\tend",
"def outsense_edist(u, v)\n\n # initialize m and n\n m = u.length\n n = v.length\n\n # create hash of arrays where \n # hash.key holds h and array index holds d\n # thus hash[h][d] = front(h, d) = i\n front = Hash.new(Array.new)\n \n # initialize d with 0 for the first front\n d = 0\n\n # calculate front(0, 0)\n front[0][d] = lcplen(u, v, m, n)\n \n # till front(n - n, d) = m\n while front[n-m][d] != m-1\n\n # increase d\n d += 1\n \n # fronts calculated according to script\n ((-d)..d).each do |h|\n front[h][d] = outsense_next_front(front, h, d, u, v, m, n)\n end\n end\n\n # length of array with hash key m - n (= h) is \n # as long as the index of its last entry (= d) + 1\n return (front[m-n].length - 1)\nend",
"def find_neighboorhood(current_solution_vc)\n # se repite hasta que encuentre un par de valores buenos\n # puts \"vc: \" + current_solution_vc.inspect\n\n # clonar el arreglo\n current_solution = current_solution_vc.clone\n\n begin\n i = rand(current_solution.length)\n j = rand(current_solution.length)\n end while (i == current_solution.first or j == current_solution.first or i == j)\n item1 = current_solution[i]\n swapped_item1 = item1\n item2 = current_solution[j]\n current_solution[i] = item2\n current_solution[j] = swapped_item1\n\n # puts \"vn: \" + current_solution.inspect\n return current_solution\n # puts \"item1: #{item1}\"\n # puts \"item2: #{item2}\"\n\nend",
"def create_tour()\n\t\tchd = Hash.new(-1)\n\t\tfor i in 0..@problem.size - 1\n\t\t\tchd[i] = @problem.succesors(i)\n\t\tend\n\n\t\tvertices = [*1..@problem.size]\n\t\tvertices.delete(@problem.start)\n\t\toutput = [@problem.start]\n\t\twhile vertices.any?\n\t\t\tu = output.last\n\t\t\tchildren = chd[u]\n\t\t\tv = children.first\n\n\t\t\tif not vertices.include? v\n\t\t\t\tv = children[1]\n\t\t\tend\n\t\t\tchd.each do |key, value|\n\t\t\t\tchd[key].delete(v)\t\n\t\t\tend\n\n\t\t\tif v == nil\n\t\t\t\treturn output\n\t\t\tend\n\t\t\tvertices.delete(v)\n\t\t\toutput.push(v)\n\t\tend\t\n\t\treturn output\n\tend",
"def new_queen_safe?(parent, i, j, new_i, new_j)\n begin \n return false if i == new_i || j == new_j || (i - new_i).abs == (j - new_j).abs\n j = parent[i][j]\n i -= 1\n return true if i == -1 || j.nil?\n end while true\nend",
"def sluggish_octopus\n # O(n^2), iterate the array twice\n max = 0\n (0...FISHES.length).each do |idx|\n (0...FISHES.length).each do |subidx|\n max = subidx if FISHES[subidx] >= max\n end\n end\n FISHES[max]\n end",
"def solution(a)\r\n # write your code in Ruby 2.2\r\n #trangular\r\n # a[0] = 10\r\n # a[2] = 5\r\n # a[4] = 8\r\n # 10 + 5 > 8\r\n # 5 + 8 > 10\r\n #8 + 10 > 5\r\n \r\n \r\n l=a.count\r\n \r\n i=0\r\n while(i<l) do\r\n j=i+1\r\n while(j<l) do\r\n k=j+1\r\n \r\n \r\n while(k<l) do\r\n if((a[i] + a[j] > a[k]) && (a[j] +a[k] > a[i]) && (a[k] + a[i] >a[j]))\r\n return 1\r\n end\r\n k+=1 \r\n end \r\n \r\n j+=1 \r\n end\r\n i+=1\r\n end\r\n \r\n return 0\r\n \r\nend",
"def greedy(tg,faulty,replacements,n)\n result = Hash.new\n repl = Array.new(replacements.size) {|i| replacements[i]}\n # sort tg by # successors\n sort_by_subtree_size!(tg)\n\n # sort faulty by # successors\n faulty.sort_by!{|a| tg[0].index(lookup_task(tg,a))}\n \n faulty.each do |fault|\n # pick the replacement which minimizes starting time of fault\n choice = repl.min_by{|a| euclidean_distance(tg,result.merge({fault=>a}),n)}\n # add the mapping to the solution\n result[fault] = choice\n # remove the replacement from the set\n repl.delete(choice)\n end\n return result\nend",
"def hiv_protease(aa_array,start_aa=1)\n out_hash = {}\n sdrm = {}\n sdrm[23] = ['L',['I']]\n sdrm[24] = ['L',['I']]\n sdrm[30] = ['D',['N']]\n sdrm[32] = ['V',['I']]\n sdrm[46] = ['M',['I','L','V']]\n sdrm[47] = ['I',['V','A']]\n sdrm[48] = ['G',['V','M']]\n sdrm[50] = ['I',['V','L']]\n sdrm[53] = ['F',['L']]\n sdrm[54] = ['I',['V','L','M','T','A','S']]\n sdrm[73] = ['G',['S','T','C','A']]\n sdrm[76] = ['L',['V']]\n sdrm[82] = ['V',['A','T','S','F','L','C','M']]\n sdrm[83] = ['N',['D']]\n sdrm[84] = ['I',['V','A','C']]\n sdrm[85] = ['I',['V']]\n sdrm[88] = ['N',['D','S']]\n sdrm[90] = ['L',['M']]\n aa_length = aa_array.size\n end_aa = start_aa + aa_length - 1\n (start_aa..end_aa).each do |position|\n array_position = position - start_aa\n if sdrm.keys.include?(position)\n wt_aa = sdrm[position][0]\n test_aa = aa_array[array_position]\n if test_aa.size == 1\n unless wt_aa == test_aa\n if sdrm[position][1].include?(test_aa)\n out_hash[position] = [wt_aa,test_aa]\n end\n end\n else\n test_aa_array = test_aa.split(\"/\")\n if (test_aa_array & sdrm[position][1])\n out_hash[position] = [wt_aa,test_aa]\n end\n end\n end\n end\n return out_hash\nend",
"def num_jewels_in_stones(j, s)\n hash_table = {}\n (0..s.length-1).each do |i|\n if hash_table.include? s[i]\n hash_table[s[i]] = hash_table[s[i]] + 1\n else\n hash_table[s[i]] = 1\n end\n end\n\n count = 0\n (0..j.length-1).each do |i|\n if hash_table.include? (j[i])\n if hash_table[j[i]] != nil\n count = count + hash_table[j[i]]\n hash_table[j[i]] = nil\n else\n fail (\"Letters in J are not distinct\")\n end\n end\n end\n\n return count\nend",
"def editDist(hshJ, hshB, jac)\n inter = 0.0\n hshJ.each_key{|k|\n if hshB.has_key?(k)\n inter+=1.0\n end\n }\n\n if jac\n cUnion = hshJ.size+hshB.size-inter\n else\n cUnion = hshJ.size\n end\n\n (inter/cUnion)\nend",
"def conta_vicini(i,j,game)\n vicini = 0\n \n #### BORDI RIGIDI\n #if i > 0\n # vicini += 1 if game[:griglia][i-1][j]\n #end\n #if i > 0 && j > 0\n # vicini += 1 if game[:griglia][i-1][j-1]\n #end\n #if i > 0 && j < CELLE_PER_RIGA\n # vicini += 1 if game[:griglia][i-1][j+1]\n #end\n #if j > 0\n # vicini += 1 if game[:griglia][i][j-1]\n #end\n #if j < CELLE_PER_RIGA-1\n # vicini += 1 if game[:griglia][i][j+1]\n #end\n #if i < CELLE_PER_COLONNA-1 && j > 0\n # vicini += 1 if game[:griglia][i+1][j-1]\n #end\n #if i < CELLE_PER_COLONNA-1\n # vicini += 1 if game[:griglia][i+1][j]\n #end\n #if i < CELLE_PER_COLONNA-1 && j < CELLE_PER_RIGA-1\n # vicini += 1 if game[:griglia][i+1][j+1]\n #end\n \n #======================================================\n ### BORDI RICORSIVI\n i += CELLE_PER_COLONNA if i-1 < 0\n j += CELLE_PER_RIGA if j-1 < 0\n i -= CELLE_PER_COLONNA if i+1 >= CELLE_PER_COLONNA\n j -= CELLE_PER_RIGA if j+1 >= CELLE_PER_RIGA\n \n vicini += 1 if game[:griglia][i-1][j]\n vicini += 1 if game[:griglia][i-1][j-1]\n vicini += 1 if game[:griglia][i-1][j+1]\n vicini += 1 if game[:griglia][i][j-1]\n vicini += 1 if game[:griglia][i][j+1]\n vicini += 1 if game[:griglia][i+1][j-1]\n vicini += 1 if game[:griglia][i+1][j]\n vicini += 1 if game[:griglia][i+1][j+1]\n \n return vicini\nend",
"def tourSuivant( vue )\n\t\t@nbTour += 1\n\t\tlistePNJ = Array.new\n\t\tvue.each do |y|\n\t\t\ty.each do |x|\n\t\t\t\tif x.pnj\n\t\t\t\t\tlistePNJ.push(x.pnj)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tlistePNJ.each do |x|\n\t\t\tx.comportement( joueur )\n\t\tend\n\t\tif joueur.pointsDeVie <= 0\n\t\t\t@controleur.gameOver\n\t\tend\n\tend",
"def josephus(items, k)\n result = []\n items.length.times do\n items.rotate!(k - 1)\n result << items.shift\n end\n result\nend",
"def checkmate(k,a)\n # Checkmate test where king may be: k_attacks - used - king_attaks - cells_behind_the_king\n all = all_position\n p used = [k,a]\n k_attacks = king_position(k).uniq \n a_attacks = (amazon_postion(a) - free_cells(k,a)).uniq\n stand_positions = a_attacks - k_attacks - used\n safe_squares = (all - k_attacks - a_attacks - used).uniq\n ans = stand_positions.reduce([]){ |acc,x| \n if (safe_squares & king_position(x)).empty?\n p x\n acc.push(x) \n end\n acc\n }\n p ans\n ans.size\n \nend",
"def sluggish_octopus(fishes)\n length = fishes.length - 1\n\n\n (0..(length)).each do |i|\n longest = true\n\n ((i + 1)..length).each do |j|\n longest = false if fishes[j].length > fishes[i].length\n end\n\n return fishes[i] if longest == true\n end\nend",
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend",
"def floyd_warshall\n p = VoteMatrix.zero_with_candidates(vote_candidates)\n\n # for i from 1 to C\n # for j from 1 to C\n # if (i ≠ j) then\n # if (d[i,j] > d[j,i]) then\n # p[i,j] := d[i,j]\n # else\n # p[i,j] := 0\n row_count.times do |i|\n row_count.times do |j|\n next if i == j\n\n if self[i, j] > self[j, i]\n p[i, j] = self[i, j]\n else\n p[i, j] = 0\n end\n end\n end\n\n # for i from 1 to C\n # for j from 1 to C\n # if (i ≠ j) then\n # for k from 1 to C\n # if (i ≠ k and j ≠ k) then\n # p[j,k] := max ( p[j,k], min ( p[j,i], p[i,k] )\n row_count.times do |i|\n row_count.times do |j|\n next if i == j\n\n row_count.times do |k|\n next if i == k || j == k\n\n p[j, k] = [p[j, k], [p[j, i], p[i, k]].min].max\n end\n end\n end\n\n p\n end",
"def josephus(items,k)\n Array.new(items.size) { items.rotate!(k).pop }\nend",
"def josephus(list, step)\n \n link_to_update = list.head\n current_link = list.head\n \n while true\n (step - 2).times do \n link_to_update = link_to_update.nxt\n end\n \n step.times do \n current_link = current_link.nxt\n end\n \n return link_to_update.content if (link_to_update == current_link && step % 2 == 0)\n return current_link.content if (link_to_update == link_to_update.nxt && step % 2 == 1)\n \n link_to_update.nxt = current_link\n link_to_update = current_link\n end\n \nend",
"def josephus(n,m)\n\n while n.size>0\n puts n.rotate!(m-1).shift(1)\n josephus(n,m)\n end\nend",
"def solution4(a)\n left = 0\n right = a.size - 1\n distinct = 0\n\n while left <= right\n # puts \"left: #{left}, right: #{right}\"\n # puts \"a[l]: #{a[left]}, a[r]: #{a[right]}\"\n # puts \"distinct: #{distinct}\"\n if a[left].abs > a[right].abs\n begin\n left += 1\n end until a[left] != a[left - 1]\n elsif a[left].abs < a[right].abs\n begin\n right -= 1\n end until a[right] != a[right + 1]\n else\n begin\n left += 1\n end until a[left] != a[left - 1]\n begin\n right -= 1\n end until a[right] != a[right + 1] \n end\n\n distinct += 1\n end\n distinct\nend",
"def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end",
"def sluggish_octopus(array)\n array.each_with_index do |el,i|\n max_found = true\n array.each_with_index do |x,j|\n next if i == j\n max_found = false if el.length < x.length\n end\n return el if max_found == true\n end\nend",
"def recursive_solution\n\n end",
"def solve( n = 2_000 )\n # We can classify every tile according to its angular position around the\n # unit circle, setting position 0 at the top since that's where each row\n # starts in the problem statement. Positions 1-5 then follow every 60° as\n # we work our way counter-clockwise. Depending on which of these positions\n # each tile falls (or between which pair of positions), we use different\n # formulae to calculate its six neighbors to the N, NW, SW, S, SE, and NE:\n # \n # Pos 0: n even = fhp\n # N = n + ring (g) S = n - ring + 6 (a)\n # NW = n + ring + 1 (h) SE = n + ring - 1 (f)\n # SW = n + 1 NE = n + (2*ring + 5) (p)\n #\n # Pos 0-1: n even = bh, n odd = ag \n # N = n + ring (g) S = n - ring + 6 (a)\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + 1 NE = n - 1\n #\n # Pos 1: n even = bh, n odd = gi\n # N = n + ring (g) S = n + 1\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + ring + 2 (i) NE = n - 1\n #\n # Pos 1-2: n even = bh, n odd = ci\n # N = n - 1 S = n + 1\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 2: n even = hj\n # N = n - 1 S = n + ring + 3 (j)\n # NW = n + ring + 1 (h) SE = n + 1\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 2-3: n even = dj, n odd = ci\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - 1 SE = n + 1\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 3: n even = dj, n odd = ik\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - 1 SE = n + ring + 4 (k)\n # SW = n + ring + 2 (i) NE = n + 1\n #\n # Pos 3-4: n even = dj, n odd = ek\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - 1 NE = n + 1\n #\n # Pos 4: n even = jl\n # N = n + 1 S = n + ring + 3 (j)\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - 1 NE = n + ring + 5 (l)\n #\n # Pos 4-5: n even = fl, n odd = ek\n # N = n + 1 S = n - 1\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5: n even = fl, n odd = km\n # N = n + ring + 6 (m) S = n - 1\n # NW = n + 1 SE = n + ring + 4 (k)\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5-0, except last: n even = fl, n odd = gm\n # N = n + ring + 6 (m) S = n - ring (g)\n # NW = n + 1 SE = n - 1\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5-0, only last: n even = flo, n odd = gmo\n # N = n + ring + 6 (m) S = n - ring (g)\n # NW = n - ring + 1 (f) SE = n - 1\n # SW = n - (2*ring - 7) (o) NE = n + ring + 5 (l)\n #\n # From these formula, we can derive the difference between a tile and each\n # of its neighbors. If we arrange all potential differences in ascending\n # order, it becomes obvious that for n even or odd, some deltas will al-\n # ways be even, and thus can never be prime (>2).\n #\n # Furthermore, we can see that only in certain positions will a tile ever\n # differ from three neighbors by odd amounts (position 0 and just to the\n # right of position 0). In all other cases, at most two deltas will be\n # odd, meaning PD(n) will be 2 or less.\n #\n # n even n odd\n # a = ring - 6 even a\n # b = ring - 5 b even\n # c = ring - 4 even c\n # d = ring - 3 d even\n # e = ring - 2 even e\n # f = ring - 1 f even\n # g = ring even g\n # h = ring + 1 h even\n # i = ring + 2 even i\n # j = ring + 3 j even\n # k = ring + 4 even k\n # l = ring + 5 l even\n # m = ring + 6 even m\n # o = 2ring - 7 o o\n # p = 2ring + 5 p p\n pd3 = [1, 2]\n base, ring = 8, 12\n \n while pd3.size < n\n # Only at position 0 and one tile to the right will there ever be three\n # odd deltas, so those are the only ones we have to check for primality.\n # Both share a delta of f = ring - 1.\n if (ring - 1).prime?\n # Check the other odd deltas for position 0. \n pd3 << base if (ring + 1).prime? && (2*ring + 5).prime?\n\n # Check the other odd deltas for one tile to the right of position 0.\n pd3 << base + ring - 1 if (ring + 5).prime? && (2*ring - 7).prime?\n end\n\n # Advance the first tile of the current ring (base), and the number of\n # tiles it contains (ring). \n base += ring\n ring += 6\n end\n\n pd3[-1]\n end",
"def village; end",
"def vaporize_targets(hoa)\n\tresults = {}\n\tcount = rotation_count = 0\n\tloop do\n\t\tlist = hoa.sort_by{|k,v| [k, v.sort!]}\n\t\tprev_count = count\n\t\trotation_count += 1\n\t\tlist.each do |bearing, points|\n\t\t\t#puts 'vaporize_targets rotation_count: %d bearing: %d' % [rotation_count, bearing]\n\t\t\tif point = points.shift\n\t\t\t\tcount += 1\n\t\t\t\tpoint.vaporized = count\n\t\t\t\t#puts 'vaporized %4d %p' % [ count, point]\n\t\t\t\tresults[[point.x, point.y]] = point\n\t\t\tend\n\t\t\tif points.size == 0\n\t\t\t\thoa.delete(bearing)\n\t\t\tend\n\t\t\tnext\n\t\t\t# In place hash more loops\n\t\t\tpoints.each do |point|\n\t\t\t\tif point.distance < 0.5\n\t\t\t\t\t# puts 'Too close'\n\t\t\t\t\tnext\n\t\t\t\tend\n\n\t\t\t\tif point.vaporized > 0\n\t\t\t\t\t# puts 'already vaporized'\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tcount += 1\n\t\t\t\tpoint.vaporized = count\n\t\t\t\t#puts 'vaporized %4d %p' % [ count, point]\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\t\tbreak if prev_count == count\n\t\tprev_count = count\n\tend\n\tresults\nend",
"def verts(photos, name: \"Vert Aware\")\n # Let's say that we ahve only vertical ones.\n # Can we try a dumb way to see if we get anything better?\n # If s1 is large but s2 and s3 are small in a transition\n # then adding a vertical photo that has a large s2,s3 is optimal\n # how do we find that?\n\n # Is there some useful heuristic about having common and rare tags?\n slides = []\n\n tag_average = 0\n\n tag_count = 0\n\n photos.each do |photo|\n tag_count += photo.tags.size\n end\n\n included = {}\n\n tag_average = tag_count / photos.size\n tag_min = (tag_average / 3) * 2\n\n shorties = []\n photos.each do |photo|\n if photo.vertical? && photo.tags.size <= tag_min\n shorties << photo\n included[photo] = true\n end\n end\n\n index = 0\n while index < shorties.size\n p1 = shorties[index]\n p2 = shorties[index + 1]\n\n photo_array = [p1]\n\n if p2 != nil\n photo_array << p2\n end\n\n slides << Slide.new(photo_array)\n index += 2\n end\n\n photos.each do |photo|\n if !included.key?(photo)\n slides << Slide.new([photo])\n end\n end\n\n # We may need to break score down into a smaller piece\n\n # Find vertical photos on their own slide with low transition scores for slides before and after\n\n # Then extract those photos\n # Then add those to other slides where they can do good?\n\n # One of the general issues that we're having is that we don't\n # know if putting it there is gogin to be helpful before putting it there\n # Let's find the ideal place to put it before inserting it?\n\n # Seed by using another realtiveyl fast approach?\n\n SlideShow.new(slides: slides, name: name)\n end",
"def possible_king_moves(start_arr)\n\t\tx = start_arr[0]\n\t\ty = start_arr[1]\n\t\tcandidates = []\n\t\tcandidates << [x+1,y]\n\t\tcandidates << [x-1,y]\t\t\n\t\tcandidates << [x,y+1]\t\t\t\t\n\t\tcandidates << [x,y-1]\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\tcandidates << [x+1,y+1]\n\t\tcandidates << [x-1,y-1]\t\n\t\tcandidates << [x-1,y+1]\t\t\t\t\n\t\tcandidates << [x+1,y-1]\t\t\t\t\n\t\tchildren = candidates.select { |pos| pos[0] >= 0 && pos[1] >= 0 && pos[0] <= 7 && pos[1] <= 7}\n\t\tchildren.delete_if do |child|\n\t\t\tif !(@board[child] == \"*\")\n\t\t\t\t# If pieces not same color\n\t\t\t\tif @board[child].color == @board[start_arr].color\n\t\t\t\t\tif occupied(child)\n\t\t\t\t\t\tcan_do = true\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tchildren\n\tend",
"def josephus(n,m)\n arr = Array.new\n order = Array.new\n\n for i in 1..n\n arr[i] = i\n end\n\n arr.compact!\n\n for i in 0..n-1\n arr= arr.rotate(m-1)\n order << arr[0]\n arr[0] = nil\n arr.compact!\n end\n\n puts \"order: #{order.to_s}\"\nend",
"def find_cut(map)\n while map.length > 2\n # This is ok\n v1,v2 = get_vertices(map)\n # Merge \n map[v1] = merge_edges(map,v1,v2)\n # Delete\n remove_vertex(map,v2)\n # Remove occurences\n convert_vertex(map,v2,v1)\n # Remove loops\n remove_loops(map,v1)\n\n end\nend",
"def optimize_kevin_bacon_search\n\t\t# winning_attempts = []\n\t\t# find_kevin_bacon_2(winning_attempts)\n\t\t# if winning_attempts.count > 0\n\t\t\t# winning_attempts.each do |attempt|\n\t\t\t\t# compare with a neighbor, shorter one wins\n\t\t\t\t# there will be lots of ties we skip over\n\t\t# else\n\t\t\t# returns nil\n\t\t# end\n\t\twinning_attempts = []\n\t\tfind_save_kevin_bacon(start_node, winning_attempts)\n\t\twinning_attempts.compact!\n\t\tif winning_attempts.count == 0\n\t\t\tputs 'no bacon :('\n\t\telse\n\t\t\twinning_attempts.index do |i|\n\t\t\t\tif i != 0\n\t\t\t\t\tif winning_attempts[i - 1] < winning_attempts[i]\n\t\t\t\t\t\twinning_attempts.delete_at(i)\n\t\t\t\t\telse\n\t\t\t\t\t\twinning_attempts.delete_at(i - 1)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\twinning_attempts\n\tend",
"def floyd_warshall_variation()\n edges = %w( 0,1 1,2 2,3 1,3 )\n num = edges.join.gsub(\",\",\"\").split(\"\").uniq.size\n\n a = Array.new(num) { Array.new(num) { Array.new(num) } }\n \n # initialize\n num.times do |k|\n num.times do |i|\n num.times do |j|\n a[i][j][k] = Float::INFINITY\n a[i][j][k] = 0 if i == j\n a[i][j][k] = 1 if edges.include? \"#{i},#{j}\"\n end\n end\n end\n\n # run\n (1..num-1).each do |k|\n num.times do |i|\n num.times do |j|\n a[i][j][k] = [\n a[i][j][k-1] +\n a[i][k][k-1] * a[k][j][k-1]\n ].min\n end\n end\n end\n\n # print\n num.times do |i|\n num.times do |j|\n puts \"#{i},#{j}: #{a[i][j][num-1]}\"\n end\n end\n\nend",
"def evolve\n # For each non elite chromosome in the population\n @population[non_elite].each_index do |i| \n # Replace with a child from two elite parents\n @population[i] = breed @population[elite].sample, @population[elite].sample\n # Mutate the child\n @population[i].mutate @params[:mutate]\n end\n # Calculate the fitness of each chromosome\n @population.each { |c| c.fitness_function }\n # Sort the population by fitness\n @population.sort! { |a, b| b.fitness <=> a.fitness }\n end",
"def vertical_growth(uncovered_pairs,current_F)\r\n\t\tcurrent_F = current_F\r\n\t\ttPrime = []\r\n\t\t#scan every run\r\n\t\tuncovered_pairs.each do |u_pair|\r\n\t\t\t#calculate the index of the factor whose value doesn't form any pair with the factor under observation within the preexistent runs\r\n\t\t\tuncovered_F = u_pair[0][0].ord - 97\r\n\t\t\t#use the flag to indicate if the pair has been covered\r\n\t\t\tflag = false\r\n\t\t\t#scan every preexistent run\r\n\t\t\t@runs.each do |run|\r\n\t\t\t\t#if the run contains a placeholder to indicate the absence of a value where a value of the factor with index uncovered_F should be, overwrite the placeholder with the uncovered value\r\n\t\t\t\ttemp = run.dup\r\n\t\t\t\ttemp[uncovered_F] = u_pair[0]\r\n\t\t\t\tif run[uncovered_F].nil? && !pairs_for_run(temp).any? {|p| @infeasible_pairs.include? p}\r\n\t\t\t\t\trun[uncovered_F] = u_pair[0]\r\n\t\t\t\t\t#indicate that the pair is covered and break the loop\r\n\t\t\t\t\tflag = true\r\n\t\t\t\t\tbreak\r\n\t\t\t\tend\r\n\t\t\tend\r\n\r\n\t\t\t#if no placeholder was found create a new run\r\n\t\t\tif !flag\r\n\t\t\t\ttemp = []\r\n\t\t\t\t0.upto(current_F-1) do |j|\r\n\t\t\t\t\t#use placeholders for values belonging to factors different from the one whose value isn't covered (uncovered_F)\r\n\t\t\t\t\tif j != uncovered_F\r\n\t\t\t\t\t\ttemp << nil\r\n\t\t\t\t\t#save the value needing coverage\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\ttemp << u_pair[0]\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\t\t#append the second value of the uncovered pair, that belongs to the factor under observation (current_F)\r\n\t\t\t\ttemp << u_pair[1]\r\n\t\t\t\t#add the run obtained to the set of runs\r\n\t\t\t\ttPrime << temp\r\n\t\t\tend\r\n\t\tend\r\n\t\t#\r\n\t\t#replace each placeholder with a value of the corresponding factor selected in random fashion but respecting the constraints on infeasible pairs\r\n\t\t#\r\n\t\t#for each run obtained in the previous step\r\n\t\ttPrime.each do |run|\r\n\t\t\t#for each level of the run\r\n\t\t\trun.each_with_index do |val,index|\r\n\t\t\t\t#if the value is nil\r\n\t\t\t\tif run[index].nil?\r\n\t\t\t\t\t#create a copy of the run\r\n\t\t\t\t\ttemp = run.dup\r\n\t\t\t\t\t#generate a random index in the range that goes from zero to the number of levels of the factor - 1\r\n\t\t\t\t\ti = rand(0...@parameters[index].no_levels)\r\n\t\t\t\t\t#store this index\r\n\t\t\t\t\tj = i\r\n\t\t\t\t\tloop do\r\n\t\t\t\t\t\t#check if the level at index j is a valid one in the sense that doesn't form infeasible pairs\r\n\t\t\t\t\t\ttemp[index] = @parameters[index].values[j]\r\n\t\t\t\t\t\t#if it's valid stop the search\r\n\t\t\t\t\t\tbreak unless pairs_for_run(temp).any? {|p| @infeasible_pairs.include? p}\r\n\t\t\t\t\t\t#tries next level\r\n\t\t\t\t\t\tj+=1\r\n\t\t\t\t\t\t#if it reaches the last level of the factor restart from the first level in a circular fashion\r\n\t\t\t\t\t\tj = 0 if j == @parameters[index].no_levels\r\n\t\t\t\t\t\t#if no level is valid raise an exception\r\n\t\t\t\t\t\traise ArgumentError,\"The input provided doesn't allow the creation of valid runs(raised in vertical_growth)\" if j == i\r\n\t\t\t\t\tend\r\n\t\t\t\t\t#save the level thus obtained\r\n\t\t\t\t\trun[index] = temp[index]\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend\r\n\t\t#return the runs obtained by the Vertical_Growth method\r\n\t\ttPrime\r\n\tend",
"def solve jug_sizes, starting_state, has_drain, has_source\n if !block_given? \n raise \"Solve must be called with a block that checks a state (array of jug fill states) if it is a winning state.\"\n end\n\n if jug_sizes.length != starting_state.length \n raise \"The jug sizes array and starting state array must have the same length (i.e. for each jug there must be a size and fill state)\"\n end\n\n seen_states=[starting_state].to_set\n states_to_process = [[[], starting_state]]\n\n while states_to_process.length > 0\n state_to_process = states_to_process.delete_at(0)\n puts \"Processing state #{state_to_process[1]}...\"\n if yield(state_to_process[1]) \n puts \" problem solved.\"\n return state_to_process[0] \n end\n\n state=state_to_process[1]\n steps=state_to_process[0]\n\n for from in 0..jug_sizes.length-1\n for to in 0..jug_sizes.length-1\n next if from==to\n next if state[from]==0\n next if state[to]==jug_sizes[to]\n\n new_state=state[0..-1]\n if state[from] + state[to] > jug_sizes[to]\n new_state[to] = jug_sizes[to]\n poured_amount = jug_sizes[to] - state[to]\n new_state[from] = state[from] - poured_amount\n else\n new_state[to] = state[from] + state[to]\n new_state[from] = 0\n end\n\n puts \" after pouring from #{from} to #{to} reached #{new_state}.\"\n if !seen_states.include?(new_state)\n seen_states.add(new_state)\n new_steps = steps[0..-1]\n new_steps << \"#{from} -> #{to}\"\n states_to_process << [new_steps, new_state]\n end\n end\n end\n\n if has_drain \n for target in 0..jug_sizes.length-1\n new_state=state[0..-1]\n new_state[target]=0 \n puts \" after draining from #{target} reached #{new_state}.\"\n if !seen_states.include?(new_state)\n new_steps = steps[0..-1]\n new_steps << \"#{target} -> DRAIN\"\n states_to_process << [new_steps, new_state]\n end\n end\n end\n\n if has_drain \n for target in 0..jug_sizes.length-1\n new_state=state[0..-1]\n new_state[target]=jug_sizes[target]\n puts \" after filling #{target} reached #{new_state}.\"\n if !seen_states.include?(new_state)\n new_steps = steps[0..-1]\n new_steps << \"SOURCE -> #{target}\"\n states_to_process << [new_steps, new_state]\n end\n end\n end \n end\n\n raise \"No solution found.\"\nend",
"def duplicate_viol_candidates\n @partition.find_all { |part| part.size > 1 }\n end",
"def dij(linkPackageMap, native)\nputs \"start dij\"\ndist = Hash.new();\nprevNode = Hash.new();\ntraversed = Array.new;\nallNodes = linkPackageMap.keys;\n#for i in 0..allNodes.length - 1\n#\tdist[allNodes[i]] = -1;\n#\tprevNode[allNodes[i]] = nil;\n#end\ndist[native] = 0;\nprevNode[native] = native;\n#q = PriorityQueue.new\n#q[native] = 0;\n\nq = Pqueue.new();\nq.push(native, 0);\n\n\nuntil q.isEmpty()\n\tu, distance = q.pop();\n\ttraversed.push(u);\n\t#puts u;\n\t#puts distance;\n\tuNeighborMap = linkPackageMap[u].map();\n\t#puts uNeighborMap.keys;\n\tuNeighbors = uNeighborMap.keys\n\tfor i in 0..uNeighbors.length - 1\n\t\t#puts uNeighbors[i]\n\t\tif !traversed.include?(uNeighbors[i]) then\n\t\t\tnewDistance = dist[u].to_i + uNeighborMap[uNeighbors[i]].to_i;\n\t\t\tif dist[uNeighbors[i]] == nil then\n\t\t\t\tdist[uNeighbors[i]] = newDistance\n\t\t\t\tprevNode[uNeighbors[i]] = u;\n\t\t\telse \n\t\t\t\tif newDistance < dist[uNeighbors[i]] then\n\t\t\t\tdist[uNeighbors[i]] = newDistance\n\t\t\t\tprevNode[uNeighbors[i]] = u;\n\t\t\t\tend\n\t\t\tend\n\t\t\tq.push(uNeighbors[i], dist[uNeighbors[i]].to_i);\n\t\t\t#q[uNeighbors[i]] = dist[uNeighbors[i]].to_i;\n\t\tend\n\t\t\t\n\tend\n\nend\n\n\n\nnodes = prevNode.keys;\n#puts nodes;\nnativeNeighbor = linkPackageMap[native].map();\n#nativeNeighbor.each{|key, value| puts \"key : #{key} value : #{value}\"}\nfor i in 0 .. nodes.length - 1\n\tif prevNode[nodes[i]] == native then\n\t\tprevNode[nodes[i]] = nodes[i];\n\telse\n\t\twhile(!nativeNeighbor.include?(prevNode[nodes[i]]) )\n\t\t\tprevNode[nodes[i]] = prevNode[prevNode[nodes[i]]];\n\t\tend\t\n\tend\nend\n\nreturn dist, prevNode;\nend",
"def knight_moves\n\t\tnode = Square.new(@start)\n\t\t@queue << node\n\t\twhile @queue.empty? == false\n\t\t\tcurrent = @queue[0]\n\t\t\tif current.value == @final\n\t\t\t\tdisplay_result(current)\t\t\t\n\t\t\telse\n\n\t\t\t\t8.times do |num|\n\t\t\t\t\tx = current.value[0] + @row[num]\n\t\t\t\t\ty = current.value[1] + @col[num]\n\t\t\t\t\tif (x.between?(1,8) && y.between?(1,8)) && @revised.include?([x, y]) == false\n\t\t\t\t\t\tnode = Square.new([x, y])\n\t\t\t\t\t\tnode.parent = current\n\t\t\t\t\t\tnode.count = current.count + 1\n\t\t\t\t\t\t@queue << node\n\t\t\t\t\telse\n\t\t\t\t\t\tnext\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t@revised << current.value\n\t\t\t\t@queue.shift\n\t\t\tend\n\t\tend\n\t\tputs \"NOT FOUND !!!\"\n\t\tputs \"This program presumes a 8x8 Chess Board\"\n\t\tputs \"Therefore your coordinates must be between (1, 1) and (8, 8).\"\n\tend",
"def double_whammer(sudoku_cells)\n\n # 1. obtain the lists of cells that still need a value\n # 2. for each cell in the list look for other cells\n # which are in the same row, column or subgrid\n # that has the same potential values\n # 3. if such cells are found, remove from other\n # cells all those values from them\n working_list = get_working_list(sudoku_cells)\n\n #Those that are of the same row/column/subgrid\n #check if any of them has the same potential values\n working_list.each do |cell_a|\n check_list = working_list.find_all do |cell_b| \n !cell_a.eql?(cell_b) && (cell_a.row == cell_b.row || cell_a.column == cell_b.column || cell_a.same_subgrid?(cell_b))\n end\n \n check_list.each do |cell|\n if cell_a.same_potential?(cell)\n #if the match is found on the same row\n if cell_a.row == cell.row\n sudoku_cells[cell_a.row].each do |x|\n if x.value.zero? && !x.eql?(cell_a) && !x.eql?(cell)\n cell_a.potential_value_stack.each {|v| x.potential_value_stack.delete(x)}\n end\n end\n elsif cell_a.column == cell.column\n i = 0\n until i >= sudoku_cells.size do\n cell_a.potential_value_stack.each do |v|\n if !sudoku_cells[i][cell_a.column].eql?(cell_a) && !sudoku_cells[i][cell_a.column].eql?(cell)\n sudoku_cells[i][cell_a.column].potential_value_stack.delete(v)\n end\n end\n i += 1\n end\n elsif cell_a.same_subgrid?(cell)\n cell_a.block_family.each do |indexes|\n if !sudoku_cells[indexes[0]][indexes[1]].eql?(cell_a) && !sudoku_cells[indexes[0][1]].eql?(cell)\n cell_a.potential_value_stack.each do |v|\n sudoku_cells[indexes[0]][indexes[1]].potential_value_stack.delete(v)\n end\n end\n end\n end\n end\n end\n end\n\n # working_list.each do |cell|\n # puts \"[#{cell.row}, #{cell.column}]\"\n # end\n # puts \"Working list: #{working_list.size}\"\n # binding.pry\nend",
"def phase_one\r\n # start with empty elimination array\r\n council_elimination = []\r\n # loop 8 times (game mechanics)\r\n 8.times do\r\n # tribe which has lost the challenge\r\n loosing_tribe = @borneo.immunity_challenge\r\n # tribal council for the loosing tribe will eliminate one participants\r\n council_elimination << loosing_tribe.tribal_council\r\n end\r\n # return all eliminations (used for the test szenario)\r\n return council_elimination.length\r\nend",
"def solve\n # Generate uniques\n spaces = student_ids.product(bag_ids)\n\n visited_nodes = 0\n student_ids.each do |sid|\n bid = solver.choose(*bag_choices_for_student(sid))\n visited_nodes +=1\n partial_plan[sid] = bid\n solver.assert assigned_bags_are_unique(partial_plan)\n solver.assert assigned_bags_without_student_repeats(partial_plan)\n end\n\n puts \"Visited: #{visited_nodes} nodes\"\n partial_plan.to_a\n end",
"def uct(hull1,hull2)\n hull = hull1 + hull2\n edge = [right_most(hull_points(hull1)),left_most(hull_points(hull2))]\n list = []\n list.push(edge)\n visited = [edge.first,edge.last]\n while upper_tangent(hull,edge) == false do\n while upper_tangent(hull1,edge) == false do\n edge = [next_anti_point(hull1, edge[0],visited),edge[1]]\n visited.push(edge.first)\n list.push(edge)\n end\n while upper_tangent(hull2,edge) == false do\n edge = [edge[0],next_clock_point(hull2, edge[1],visited)]\n upper_tangent(hull2,edge)\n visited.push(edge.last)\n list.push(edge)\n end\n end\n\n list.map {|x| visited.push(x[0],x[1])}\n visited.uniq #deletion canditatates\n return edge, visited\nend",
"def minimum_proteins!(peptide_hits)\n #peptide_hit responds to .prots\n #peptide_hit responds to .aaseq\n \n #protein_hit responds to .id\n #protein_hit responds to .peps\n \n prot_to_peps, most_overlap, pep_to_prots = prepare_data(peptide_hits)\n \n prot_to_peps_sorted = prot_to_peps.sort_by do |prot, peps|\n # e.g. [ 0, 3, 2, 5]\n # [ 3 peptides with 1 unique protein, 2 peptides with 2 unique proteins,\n # 5 peptides with 3 unique proteins ]\n # !! the first index is always zero\n uniqueness_ar = Array.new(most_overlap+1,0)\n peps.each do |pep|\n size = pep_to_prots[pep].size\n uniqueness_ar[pep_to_prots[pep].size] += 1 # the num of proteins pep belongs to\n end\n uniqueness_ar\n end.reverse\n \n peps_seen = Set.new\n final_output_hash = {}\n prot_to_peps_sorted.each do |prot, peps_set|\n refined = peps_set.to_a.reject do |pep|\n if peps_seen.include?(pep)\n true\n else\n peps_seen << pep\n false\n end\n end\n \n final_output_hash[prot] = refined if refined.size > 0\n end\n \n final_peps_to_prots = Hash.new{ |h,k| h[k] = [] }\n final_output_hash.each do |prot, peps|\n peps.each {|pep| final_peps_to_prots[pep] << prot}\n end\n \n update_hits(peptide_hits, final_peps_to_prots)\n end",
"def search_jps\n open_list = [@nodes[@route.start_id]]\n close_list = []\n goal = @nodes[@route.goal_id]\n\n until open_list.empty?\n n = open_list.min_by { |node| @route.estimated_cost(node) }\n if n == goal\n @route.found = true\n break\n end\n\n close_list.push( open_list.delete(n) )\n\n adjacents_of_n = n.pruned_neighbors(@route.parent(n))\n adjacents_of_n.keys.each do |m|\n j = jump(n, clamp(m.x - n.x, -1, 1), clamp(m.y - n.y, -1, 1))\n next if j == nil or close_list.include?(j)\n h = @heuristic.call(j, goal)\n new_real_cost_j = @route.real_cost(n) + Math.sqrt((n.x-j.x)**2 + (n.y-j.y)**2) # g\n new_estimated_cost_j = new_real_cost_j + h # f = g + h\n if open_list.include?(j)\n # If estimated costs are equal then use real costs for more precise comparison (or we may get less optimal path).\n next if new_estimated_cost_j > @route.estimated_cost(j)\n next if new_estimated_cost_j == @route.estimated_cost(j) && new_real_cost_j >= @route.real_cost(j)\n @route.record(j, n, new_real_cost_j, h)\n else\n open_list.push(j)\n @route.record(j, n, new_real_cost_j, h)\n end\n @visited << j.id unless @visited.include? j.id # stats\n end\n @search_iter += 1 # stats\n end\n end",
"def solution(a)\n # write your code in Ruby 2.2\n binding.pry\n trips = Hash.new {|h,k| h[k]=0}\n start = 0\n ending = 0\n min = nil\n a.each_with_index do |trip,i|\n ending = i\n\n if trips[trip] == 0\n min = ending - start\n end\n trips[trip] += 1\n\n while start < ending\n break if trips[a[start]] - 1 == 0\n trips[start] -= 1\n start += 1\n min = ending - start if ending-start < min\n end\n end\n min\nend",
"def sluggish_octopus(array)\n\n sorted = false\n until sorted\n sorted = true\n\n array.each_index do |i|\n next if i == array.length - 1\n j = i + 1\n\n if array[i].length > array[j].length\n sorted = false\n array[i], array[j] = array[j], array[i]\n end\n end\n end\n array.last\n\nend",
"def dominant_octopus(fish)\n return fish if fish.length < 2\n pivot_el = [fish.first]\n left = fish[1..-1].select { |el| el.length <= fish.first.length }\n right = fish[1..-1].select { |el| el.length > fish.first.length }\n dominant_octopus(left) + pivot_el + dominant_octopus(right)\nend",
"def set_survivor\n @survivor = Survivor.find(params[:id])\n end",
"def set_survivor\n @survivor = Survivor.find(params[:id])\n end",
"def set_survivor\n @survivor = Survivor.find(params[:id])\n end",
"def carve_corridors(i,j, parent)\n\t\tdirs = Direction::DIRECTIONS.keys.shuffle\n\n\t\t# Pick a random direction\n\t\tdirs.each do |d_key|\n\t\t\t#Check the next two squares in that direction\n\t\t\tt_cells = [@cells[i][j]]\n\t\t\tfailed = false\n\t\t\tcorientrance = false\n\t\t\t(1..2).each do |step|\n\t\t\t\tjump = Direction::DIRECTIONS[d_key]\n\t\t\t\tif !t_cells[step-1].nil? && !failed\n\t\t\t\t\tt_cells[step] = @cells[t_cells[step-1].x+jump[0]][t_cells[step-1].y+jump[1]] \n\t\t\t\t\tfailed = true if t_cells[step].nil? || t_cells[step].type != Cell::UNALLOCATED \n\t\t\t\t\tif !t_cells[step].nil? && t_cells[step].type == Cell::ENTRANCE \n\t\t\t\t\t\tcorientrance = true \n\t\t\t\t\t\tfailed = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tfailed = true\n\t\t\t\tend\n\t\t\tend\n\t\t\t# If unallocated, carve and start next section\n\t\t\tif !failed\n\t\t\t\t# Create Corridor logical structure\n\t\t\t\tcorridor_obj = CorridorBranch.new(t_cells)\n\t\t\t\tt_cells.each do |c| \n\t\t\t\t\tc.type = Cell::CORRIDOR \n\t\t\t\t\tcorridor_map[c] = corridor_obj\n\t\t\t\tend\n\t\t\t\t# Add to corrdidor tree\n\t\t\t\tparent.children << corridor_obj if !parent.nil?\n\n\t\t\t\tl_cell = t_cells.last\n\t\t\t\tcarve_corridors(l_cell.x, l_cell.y,corridor_obj)\n\t\t\tend\n\t\t\t# special case for entrance corridor links\n\t\t\tif corientrance\n\t\t\t\t# Create Corridor logical structure\n\t\t\t\tcorridor_obj = CorridorBranch.new(t_cells)\n\t\t\t\tt_cells.each do |c| \n\t\t\t\t\tcorridor_map[c] = corridor_obj\n\t\t\t\tend\n\t\t\t\tl_cell = t_cells.last\n\t\t\t\t# Add to corrdidor tree\n\t\t\t\tparent.children << room_map[l_cell] if !parent.nil?\n\t\t\tend\n\t\tend\n\n\tend",
"def solve_prims\n linked, unlinked = [nodes.first], nodes[1..-1].dup\n end",
"def apply_solution array\n\n # Reverse the String to iterate right to left JUST because is easier :P\n index = find_small_neighbors array.reverse!\n \n return \"no answer\" unless index\n\n # Find rightmost successor to pivot in the suffix\n sec_index = array.index(array.slice(0..index).select{ |num| num > array[index] }.sort.first)\n # Swap with pivot\n array[index], array[sec_index] = array[sec_index], array[index]\n\n # Reverse the suffix REVERT rathern than sort\n solution = array.slice!(0..index-1).sort.join.reverse\n solution << array.join\n return solution.reverse\nend",
"def sweep; end",
"def remove_redundant_vertices(s, index)\n # puts \"**** remove_redundant_vertices:: string #{s}\"\n j = @num_vertices - 1\n verts = @vertices\n while j >= 0\n if(!verts[j].nil? and verts[j].index == index and s.casecmp(verts[j].name) != 0 and \n (s.downcase.include?(verts[j].name.downcase) and verts[j].name.length > 1)) \n #the last 'length' condition is added so as to prevent \"I\" (an indiv. vertex) from being replaced by nil\n # puts \"*** string index = #{index}... verts[j].index = #{verts[j].index}\"\n # puts \"**** remove_redundant_vertices setting #{verts[j].name} to nil!\"\n #search through all the edges and set those with this vertex as in-out- vertex to null\n if(!@edges.nil?)\n for i in 0..@edges.length - 1\n edge = @edges[i]\n if(!edge.nil? and (edge.in_vertex == verts[j] or edge.out_vertex == verts[j]))\n # puts \"edge #{edge.in_vertex.name} - #{edge.out_vertex.name}\"\n @edges[i] = nil #setting that edge to nil\n end \n end\n end\n #finally setting the vertex to null\n verts[j] = nil\n end\n j-=1\n end #end of while loop\n\n # puts \"**** remove_redundant_vertices Old @num_vertices:: #{@num_vertices}\" \n #recreating the vertices array without the nil values\n counter = 0\n vertices_array = Array.new\n for i in (0..verts.length-1)\n vertex = verts[i]\n if(!vertex.nil?)\n vertices_array << vertex\n counter+=1\n end\n end \n @vertices = vertices_array\n @num_vertices = counter+1 #since @num_vertices is always one advanced of the last vertex\nend",
"def majority_element(nums)\n len=nums.length\n maj_index=0\n count=1\n for i in 1...len\n if nums[i]==nums[maj_index]\n count+=1\n else\n count-=1\n end\n if count==0\n nums[maj_index]=nums[i]\n count=1\n end\n end\n candidate=nums[maj_index]\n count=0\n for i in 0...len\n if nums[i]==candidate\n count+=1\n end\n end\n \n if count > (len/2)\n return candidate\n else\n return -1\n end\nend",
"def unique_paths_with_obstacles(obstacle_grid)\n m, n = obstacle_grid.length, obstacle_grid[0].length\n m.times do |i|\n n.times do |j|\n if obstacle_grid[i][j] == 1\n obstacle_grid[i][j] = 0\n elsif i == 0 && j == 0\n obstacle_grid[i][j] = 1\n elsif i == 0\n obstacle_grid[i][j] = obstacle_grid[i][j-1] * 1\n elsif j == 0\n obstacle_grid[i][j] = obstacle_grid[i-1][j] * 1\n else \n obstacle_grid[i][j] = obstacle_grid[i-1][j] + obstacle_grid[i][j - 1]\n end \n end \n end \n\n obstacle_grid[m-1][n-1]\nend",
"def nexus(hsh)\n nexus = []\n hsh.each do |k, v|\n nexus << k if k == v\n end\n\n return nexus.min if nexus.empty? == false\n \n difference = 1\n loop do\n\n hsh.each do |k, v|\n if k - v == difference || v - k == difference\n nexus << k\n else\n next\n end\n end\n\n if nexus.empty?\n difference += 1\n else\n return nexus.min\n end\n end\nend",
"def exercise_method\n\n # => All jobs\n @old = Job.all\n @jobs=Set.new\n @jobs=@old\n @result=Set.new\n # => let remove the singles, independent one\n @jobs.each do |f| \n if f.predecessor_id.nil? && f.successor_id.nil?\n if @result.add?(f).nil?\n return 'Error 1'\n end\n @jobs.delete(f)\n end\n if f.predecessor_id==f.id || f.successor_id==f.id\n raise \"#{f.inspect}\"\n \n return 'Error 0'\n end\n end\n\n # => following successors\n @jobs.each do |f|\n if f.predecessor_id.nil? \n loop do\n if @result.empty?\n @result.add(f)\n elsif @result.add?(f).nil?\n return 'Error 2'\n end\n @jobs.delete(f)\n if !f.successor_id.nil?\n f = Job.find(f.successor_id)\n else\n f=nil\n end\n break if !f \n end\n end\n end\n \n if @jobs.any?\n return 'Error 3'\n end\n return @result\n end",
"def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend",
"def majority_vote(nums)\n candidate = nil\n count = 0\n nums.each do |num|\n candidate = num if count == 0\n if candidate == num\n count += 1\n else\n count -= 1\n end\n end\n\n count = 0\n nums.each do |num|\n if num == candidate\n count += 1\n end\n end\n\n return candidate if count > nums.size / 2\n return -1\nend",
"def josephus_2(items, k)\r\n Array.new(items.length) { items.rotate!(k).pop }\r\nend",
"def problem_60\n prime_check = lambda do |a,b|\n (a + b).to_i.prime? && (b + a).to_i.prime?\n end\n\n find_match = lambda do |a,k|\n r = a.select {|p| k != p && prime_check.call(k,p) }\n end\n\n primes = Primes.upto(10_000).map(&:to_s)\n primes.delete(\"2\")\n\n hit = {}\n\n primes.each do |p1|\n p1a = find_match.call(primes,p1)\n p1a.each do |p2|\n p2a = find_match.call(p1a,p2)\n p2a.each do |p3|\n p3a = find_match.call(p2a,p2)\n p3a.each do |p3|\n p4a = find_match.call(p3a,p3)\n p4a.each do |p4|\n p5a = find_match.call(p4a,p4)\n if p5a.length > 0\n p5a.each do |p5|\n a = [p1,p2,p3,p4,p5]\n sum = a.map(&:to_i).reduce(&:+)\n unless hit[sum]\n puts \"#{sum} #{a.inspect}\"\n else\n hit[sum] = true\n end\n return sum\n end\n end\n end\n end\n end\n end\n end\nend",
"def left_eliminate!\n # inv = Algebra.SquareMatrix(ground, rsize).unity\n k = ground.unity\n pi = 0\n each_j do |j|\n next unless i = (pi...rsize).find { |i1| !self[i1, j].zero? }\n if i != pi\n swap_r!(pi, i) # ; inv.swap_r!(pi, i)\n k = -k\n end\n c = ground.unity / self[pi, j] # this lets the entries be in ground\n multiply_r!(pi, c) # ; inv.multiply_r!(pi, c)\n k *= c\n each_i do |i0|\n next if i0 == pi\n d = self[i0, j] # / self[pi, j]\n mix_r!(i0, pi, -d) # ; inv.mix_r!(i0, pi, -d)\n end\n pi += 1\n end\n [left, k]\n end",
"def gettrys(tcoords)\n # Indexa coordenadas de las lineas con menor incognitas\n p \"hmiss............\"\n p tcoords[:hmiss]\n hlower_c = lowerabsent(tcoords[:hmiss]) # [{:hindex=>x, :coords=> [[]]\n vlower_c = lowerabsent(tcoords[:vmiss],\"v\") # [{:vindex=>x, :coords=>[[]]\n slower_c = lowerabsent(tcoords[:smiss],\"s\") # [{:sindex=>x, :coords=>[[]]\n\n # combierte las coordenadas en numeros -> contiene menor incognitas\n hlower_n = hlower_c.collect {|line| missto_n(line[:hindex])} # [{:hindex=>0, :numbers=>[3, 4]}, x]\n vlower_n = vlower_c.collect {|line| missto_n(line[:vindex],tcoords[:vwhole], \"v\")} # [{:vindex=>0, :numbers=>[3, 4]}, x]\n #slower_n = slower_c.collect {|line| missto_n(line[:sindex], tcoords[:swhole], \"s\")} # [{:sindex=>2, :numbers=>[4, 6, 8]}, x]\n p \"****** H vs V *******\"\n p hlower_c.length < vlower_c.length ? \"h < v\" : \"h > v\"\n # cantidad de incognitas decide si se usa h o v\n p lower_c = hlower_c.length < vlower_c.length ? hlower_c : vlower_c\n lower_n = lower_c[0].keys[0][0] == \"h\" ? hlower_n : vlower_n\n # le pone cuadro a cada coord y separa coordenadas, una por linea\n hvindex_sindex_coords = locatecoord_onsquere(lower_c, tcoords[:swhole])\n sqr_n = hvindex_sindex_coords.collect {|item| missto_n(item[:sindex], tcoords[:swhole],\"s\")}\n # buscar que sqr tiene menos coincidencias\n hvindex_sindex_coords.collect { |main|\n main[:sqr_options] = sqr_n.collect {|numbers| numbers[:numbers] if main[:sindex] == numbers[:sindex] }.compact.flatten\n main[:options] = lower_n.collect {|numbers| numbers[:numbers] if main[main.keys[0]] == numbers[numbers.keys[0]] }.compact.flatten\n main[:reduce] = main[:options] - ([1,2,3,4,5,6,7,8,9] - main[:sqr_options])\n\n }\n # numbers[:numbers] if main[main.keys[0]] == numbers[numbers.keys[0]]\n result = hvindex_sindex_coords.group_by {|g| g[:reduce].length}\n\n p \"*******start Result\"\n reduce_index = result.collect {|x,y| x }.min\n result[reduce_index].map {|e| p e} # inspect\n result[reduce_index].map do |item|\n\n case item.keys[0][0]\n when \"h\"\n if item[:reduce].length == 1\n x = item[:coord][0]\n y = item[:coord][1]\n @tbls[:notformated][x][y] = item[:reduce][0]\n @tbls[:formated][x][y] = formato(@tbls[:notformated][x][y].to_s,:red, :yellow)\n elsif item[:reduce].length > 1\n # Pregunta en linea vertical\n end\n when \"v\"\n p \"################## - caso vertical pendiente - ###################\"; exit\n end\n\n end\n\n end",
"def kochright\n v = start - finish\n v /= 3\n v + finish\n end",
"def solution(a, k)\n # write your code in Ruby 2.2\n \n unless a.empty?\n for i in 1..k\n last = a.pop\n a.insert(0, last)\n end\n end\n \n return a\nend",
"def num_jewels_in_stones(j, s)\n s.count(j)\nend",
"def problem_108(size = 1001)\n func = lambda do |a|\n if a.length == 1\n a[0]+1\n else\n m = a[0]\n (2*m+1) * func.call(a[1,a.length]) -m\n end\n end\n\n primes = Primes.upto(200)\n prime_number = lambda do |a|\n r = 1\n a.sort.reverse.each_with_index { |m,i| r *= primes[i] ** m }\n r\n end\n\n values = {}\n last = 0\n 1.upto(100).each do |nn|\n nn.groupings do |a|\n sols = func.call a\n ans = prime_number.call a\n# puts \"np=#{nn} sols=#{sols} ans=#{ans} => #{a.inspect}\"\n if values[sols]\n values[sols] = [values[sols],[ans,a]].min\n else\n values[sols] = [ans,a]\n end\n true\n end\n size.upto(size*5/4) do |num|\n if values[num]\n puts \"for np = #{nn} => #{num} => #{values[num].inspect}\"\n if last == values[num]\n puts \"factors = #{values[num][0].factors}\"\n return values[num][0] \n end\n last = values[num]\n break\n end\n end\n #values.sort.each do |k,v|\n # puts \"#{k} => #{v}\"\n #end\n end\n nil\nend",
"def hurdleRace(k, height)\n if height.max < k\n 0\n else\n height.max - k\n end\nend",
"def generate_cup_bracket(teams)\n @participants = teams\n @participant_number = @participants.length\n @levels = @participant_number.log2\n @levels = (1<<(@levels) == @participant_number) ? @levels -1 : @levels\n @total_matchups = 1<<(@levels)\n (@participant_number..(2*@total_matchups - 1)).each do |x| \n @participants << nil \n end\n \n # puts @levels\n\n left_index, right_index = 1, 2\n\n @tree = [[left_index, right_index]] \n @the_nodes = [] \n @match = 0\n\n (0..@levels).each do |level|\n game = (1<<level) - 1 \n nodes = @tree[-(game+1)/2,(game+1)/2].inject([]) {|s,e| s+e} \n @the_nodes << nodes\n i = 0\n nodes.each do |index| \n opponent = ((2*(game+1)-index+1) > @participant_number) ? nil : (2*(game+1) - index+1)\n if i < game\n @tree << [index, opponent]\n # puts \"[z]: #{index} vs #{opponent}\"\n else \n @tree << [opponent, index]\n # puts \"[M]: #{index} vs #{opponent}\"\n end \n i += 1\n end \n end\n \n @tree << [left_index, right_index]\n # puts \"[Final]: #{left_index} vs #{right_index}\"\n \n # @jornada = 0\n level = @levels\n counter = @levels + 1\n while counter > 0\n game = (1<<(level)) - 1 \n i = 0\n @the_nodes[counter-1].each do |index| \n next_game= \"\"\n\n player_1 = @participants[index-1].name \n home_id = @participants[index-1].id\n\n opponent = 'Bye' \n player_2 = 'Bye' \n away_id = nil\n\n unless (2*(game+1)-index+1) > @participant_number\n opponent = (2*(game+1) - index+1) \n player_2 = @participants[opponent-1].name \n away_id = @participants[opponent-1].id\n end\n\n\n last_game = get_the_last_game\n \n if level == @levels \n @game = Game.create!(:name => level_in_words(level), \n :cup_id => self.id, :home_id => home_id ,:away_id => away_id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'FirstGame', :jornada => last_game['jornada'], \n\t\t\t :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n\t\t\t :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n\t\t\t :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n\t\t\t :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n puts \"[#{level_in_words(level)}]: #{home_id} #{ away_id}\"\n \n else\n @previous_1 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, home_id], \n :order => \"id\") \n @previous_2 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, away_id], \n :order => \"id\")\n\n puts \"[#{level_in_words(level)}]: #{@previous_1.id} #{ @previous_2.id}\"\n\n @game = Game.create!(:name => level_in_words(level), \n :cup_id => self.id, :home_id => home_id ,:away_id => away_id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'SubsequentGame', :jornada => last_game['jornada'], \n\t\t\t :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n\t\t\t :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n\t\t\t :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n\t\t\t :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n @previous_1.next_game_id = @game.id\n @previous_1.save!\n @previous_2.next_game_id = @game.id\n @previous_2.save!\n end \n end\n\n level -= 1\n counter -=1\n end\n\n last_game = get_the_last_game\n \n # third place\n jornada = Game.last_cup_game(self).jornada.to_i + 1 \n @game = Game.create!(:name => level_in_words(99), :cup_id => self.id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'ThirdPlaceGame', :jornada => last_game['jornada'], \n :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n # final\n home_id = @participants[left_index-1].id\n away_id = @participants[right_index-1].id\n player_1 = @participants[left_index-1].name\n player_2 = @participants[right_index-1].name \n \n jornada = Game.last_cup_game(self).jornada.to_i + 1\n @previous_1 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, home_id], \n :order => \"id\") \n @previous_2 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, away_id], \n :order => \"id\")\n \n puts \"[#{level_in_words(0)}]: #{@previous_1.id} #{ @previous_2.id}\"\n \n last_game = get_the_last_game\n @game = Game.create!(:name => level_in_words(0), :cup_id => self.id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'FinalGame', :jornada => last_game['jornada'], \n :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n @previous_1.next_game_id = @game.id\n @previous_1.save!\n @previous_2.next_game_id = @game.id\n @previous_2.save!\n end",
"def virgilism_dentality(checkrowed, generatrix)\n unflickeringly_draftiness_goer()\n retrust(clavation_uneclipsed)\n thumby(afterknowledge, disproval)\n end",
"def asteroid_collision(asteroids)\n puts '-' * 43\n puts \"asteroid_collision: #{asteroids}\"\n\n return [] if asteroids.empty?\n\n res = []\n\n asteroids.each do |ast|\n puts res.to_s\n\n if res.empty?\n res.push(ast)\n next\n end\n\n temp = res.pop\n\n if (temp < 0) && (ast < 0)\n res.push(temp)\n res.push(ast)\n next\n end\n\n if (temp > 0) && (ast > 0)\n res.push(temp)\n res.push(ast)\n next\n end\n\n if (temp < 0) && (ast > 0)\n res.push(temp)\n res.push(ast)\n next\n end\n\n next if (temp**2) == (ast**2)\n\n if compare(temp, ast) == ast\n redo\n else\n res.push(temp)\n end\n end\n\n puts \" > #{res}\"\n\n res\nend",
"def solve_part_two\n input = File.read(ARGV[0])\n\n grid = Grid.from_puzzle_input(input)\n grid.create_all_carts\n\n until grid.carts.one?\n # Deleting elements while iterating them really confuses Ruby by the\n # looks of things; keep track of elements we need to delete using a \n # Set instead, ignoring them on future iterations then deleting at the\n # end\n scheduled_for_deletion = Set.new\n\n grid.carts.each do |cart|\n next if scheduled_for_deletion.include? cart\n\n cart.tick\n next unless grid.collision\n colls = grid.collisions\n\n colls.each do |coll|\n scheduled_for_deletion << coll[0] << coll[1]\n end\n end\n\n scheduled_for_deletion.each do |deleted_cart|\n grid.carts.delete(deleted_cart)\n end \n\n # Re-sort the array following the deletions\n grid.carts.sort_by! { |c| c.position.top * 1000 + c.position.left }\n end\n\n p grid.carts.first.position\nend",
"def min_cut(s)\n is_pali = Array.new(s.size){Array.new(s.size, false)}\n min_cuts = Array.new(s.size)\n (0...s.size).each do |i|\n min_num = Float::INFINITY # store max val\n (0..i).each do |j|\n if s[i] == s[j] && (j + 1 >= i || is_pali[j + 1][i - 1])\n is_pali[j][i] = true\n min_num = j == 0 ? 0 : [min_num, min_cuts[j - 1] + 1].min\n end\n end\n min_cuts[i] = min_num\n end\n min_cuts[s.size - 1]\nend",
"def sluggish_octopus(the_sea)\n the_sea.each_with_index do |fish1, idx|\n longest = true\n\n the_sea.each_with_index do |fish2, idx2|\n next if idx == idx2\n longest = false if fish1.length > fish2.length\n end\n\n return fish1 if longest\n end\nend",
"def walkright(i,j,object)\r\n w=0\r\n counter =4\r\n while w < 4\r\n if @nha2[i+w][j] == object\r\n counter =counter -1\r\n end\r\n w+=1\r\n end\r\n return counter\r\n end",
"def sluggish_octopus(fish)\n\n (0...fish.length-1).each do |idx1|\n (idx1+1...fish.length).each do |idx2|\n if fish[idx1].length > fish[idx2].length\n fish[idx1], fish[idx2] = fish[idx2], fish[idx1]\n end\n end\n end\n fish\nend",
"def carve_corridors(i, j, parent)\n dirs = Direction::DIRECTIONS.keys.shuffle\n\n # Pick a random direction\n dirs.each do |d_key|\n #Check the next two squares in that direction\n t_cells = [@cells[i][j]]\n failed = false\n corientrance = false\n (1..2).each do |step|\n jump = Direction::DIRECTIONS[d_key]\n if !t_cells[step-1].nil? && !failed\n t_cells[step] = @cells[t_cells[step-1].x+jump[0]][t_cells[step-1].y+jump[1]]\n failed = true if t_cells[step].nil? || t_cells[step].type != Cell::UNALLOCATED\n if !t_cells[step].nil? && t_cells[step].type == Cell::ENTRANCE\n corientrance = true\n failed = true\n break\n end\n else\n failed = true\n end\n end\n # If unallocated, carve and start next section\n if !failed\n # Create Corridor logical structure\n corridor_obj = CorridorBranch.new(t_cells)\n t_cells.each do |c|\n c.type = Cell::CORRIDOR\n corridor_map[c] = corridor_obj\n end\n # Add to corrdidor tree\n parent.children << corridor_obj if !parent.nil?\n\n l_cell = t_cells.last\n carve_corridors(l_cell.x, l_cell.y, corridor_obj)\n end\n # special case for entrance corridor links\n if corientrance\n # Create Corridor logical structure\n corridor_obj = CorridorBranch.new(t_cells)\n t_cells.each do |c|\n corridor_map[c] = corridor_obj\n end\n l_cell = t_cells.last\n # Add to corrdidor tree\n parent.children << room_map[l_cell] if !parent.nil?\n end\n end\n\n end",
"def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend",
"def swim(water, life)\n\n if water.name == -9 && life.name >= 0\n # ####puts \"fuck\"\n if life.type != \"seaweed\"\n if water.name == -9 && rand(3) == 0 && (rand(water.depth) != 0)\n if life.traits[1] < water.depth\n water.energy += (life.energy)\n Fighter.all.delete(life)\n Fighter.predos.delete(life)\n Fighter.plants.delete(life)\n Fighter.herbis.delete(life)\n life = nil\n end\n end\n end\n end\n GC.start(full_mark: true, immediate_sweep: true);\nend"
] |
[
"0.74130183",
"0.7368812",
"0.7291861",
"0.5909947",
"0.57460254",
"0.5739488",
"0.5589394",
"0.5555879",
"0.55484784",
"0.55193096",
"0.55116236",
"0.55075634",
"0.54860073",
"0.5452352",
"0.5448089",
"0.54232925",
"0.54025215",
"0.53847873",
"0.53834206",
"0.53795123",
"0.53444165",
"0.52866966",
"0.52662665",
"0.5196904",
"0.51900095",
"0.5182177",
"0.51796854",
"0.51702183",
"0.5161045",
"0.512349",
"0.511521",
"0.5107434",
"0.5102616",
"0.5093829",
"0.50900877",
"0.50740635",
"0.5073077",
"0.50723904",
"0.5071191",
"0.5070626",
"0.505799",
"0.5051882",
"0.5051226",
"0.5041841",
"0.5035583",
"0.5035151",
"0.5034651",
"0.50300306",
"0.5025168",
"0.50248814",
"0.5018686",
"0.50067645",
"0.50020796",
"0.49976325",
"0.4984467",
"0.49799383",
"0.4978174",
"0.49668133",
"0.49637547",
"0.49553782",
"0.49512762",
"0.49465653",
"0.4944529",
"0.49401644",
"0.49394828",
"0.49329236",
"0.4932762",
"0.4932762",
"0.4932762",
"0.4932612",
"0.49271277",
"0.49212828",
"0.49209908",
"0.4920073",
"0.4915649",
"0.49131304",
"0.49081072",
"0.4903861",
"0.4902153",
"0.49013966",
"0.48931238",
"0.4889405",
"0.48828584",
"0.48793143",
"0.48780498",
"0.48775437",
"0.4877511",
"0.48733494",
"0.48665965",
"0.48641694",
"0.48634326",
"0.48625323",
"0.48621035",
"0.4861126",
"0.48582235",
"0.48565117",
"0.4850569",
"0.48503184",
"0.48475945",
"0.48375168"
] |
0.7168867
|
3
|
codewars kata: sudoku solution validator
|
def validSolution(board)
array_of_boxes = Array.new
box = Array.new
i = 0
add_box_array = lambda do
3.times do
3.times do
row = board[i]
box.push(row[0]).push(row[1]).push(row[2])
i += 1
end
array_of_boxes << box
box = Array.new
end
end
reset_and_rotate = lambda do
i = 0
board.each{ |row| row.rotate!(3) }
end
add_reset_rotate = lambda do
add_box_array.call
reset_and_rotate.call
end
2.times {add_reset_rotate.call}
add_box_array.call
all_possible_arrays = (1..9).to_a.permutation.to_a
# each row & each column is a unique permutation of base_array
board.all?{ |row| all_possible_arrays.include?(row) } &&
board.uniq.size == 9 &&
board.transpose.all?{ |column| all_possible_arrays.include?(column) } &&
board.transpose.uniq.size == 9 &&
array_of_boxes.all? { |box| all_possible_arrays.include?(box) }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def valid_sudoku(table)\n sudoku_box_hash = { [0, 0] => {}, [0, 1] => {}, [0, 2] => {},\n [1, 0] => {}, [1, 1] => {}, [1, 2] => {},\n [2, 0] => {}, [2, 1] => {}, [2, 2] => {}}\n\n sudoku_row_hash = { 1 => {}, 2 => {}, 3 => {},\n 4 => {}, 5 => {}, 6 => {},\n 7 => {}, 8 => {}, 9 => {}}\n \n sudoku_col_hash = { 1 => {}, 2 => {}, 3 => {},\n 4 => {}, 5 => {}, 6 => {},\n 7 => {}, 8 => {}, 9 => {}}\n\n sudoku_diagonal_hash = {1 => {}, 9 => {}}\n\n table.each_with_index do |arr, i|\n arr.each_with_index do |ele, j|\n next if ele == \".\"\n # check and add diagonals\n if i == j \n return false if sudoku_diagonal_hash[1].include?(ele)\n sudoku_diagonal_hash[1][ele] = 1\n elsif i + j + 1 == 9 || i == 4 && j == 4\n return false if sudoku_diagonal_hash[9].include?(ele)\n sudoku_diagonal_hash[9][ele] = 1\n end\n\n # check these hashes for all elements\n return false if sudoku_row_hash[i + 1].include?(ele)\n return false if sudoku_col_hash[j + 1].include?(ele)\n return false if sudoku_box_hash[[i / 3, j / 3]].include?(ele)\n\n # can add if no return \n sudoku_row_hash[i + 1][ele] = 1\n sudoku_col_hash[j + 1][ele] = 1\n sudoku_box_hash[[i / 3, j / 3]][ele] = 1 # based off calculating indices of ecah sudoku box\n end\n end\n\n return true\nend",
"def valid_sudoku(table)\n \nend",
"def validSolution(board)\n return false if board.flatten.size != 81\n return false if board.flatten.any? { |el| el.class != Fixnum }\n return false if board.size != 9\n board.each do |row|\n return false if row.any? { |el| el < 1 || el > 9 }\n return false if row.uniq.size != 9\n end\n (0..8).each do |col|\n this_col = []\n (0..8).each do |el|\n this_col << board[el][col]\n end\n return false if this_col.uniq.size != 9\n end\n [-1, 2, 5].each do |xoffset|\n [-1, 2, 5].each do |yoffset|\n this_square = []\n (1..3).each do |x|\n (1..3).each do |y|\n this_square << board[x + xoffset][y + yoffset]\n end\n end\n return false if this_square.uniq.size != 9\n end\n end\n true\nend",
"def valid_sudoku(table)\n numbers = {}\n\n # iterate through each row and confirm valid\n row = 0\n while row < table.length\n table[row].each do |value|\n return false if !check_value(numbers, value)\n end\n\n numbers = {}\n row += 1\n end\n\n # iterate through each column and confirm valid\n numbers = {}\n col = 0\n while col < table[0].length\n (0..8).each do |x|\n value = table[x][col]\n\n return false if !check_value(numbers, value)\n end\n\n numbers = {}\n col += 1\n end\n\n # create list of each sub-box's upper left corner\n corners = []\n (0..2).each do |row|\n (0..2).each do |col|\n corners << [row * 3, col * 3]\n end\n end\n\n # iterate through the list of corners to see if each value is unique within the sub-box\n numbers = {}\n index = 0\n while index < corners.length\n (0..2).each do |x|\n (0..2).each do |y|\n x_point = corners[index][0] + x\n y_point = corners[index][1] + y\n value = table[x_point][y_point]\n\n return false if !check_value(numbers, value)\n end\n end\n\n numbers = {}\n index += 1\n end\n\n return true\nend",
"def valid_sudoku(table)\n # edge cases\n return false if table.nil? || table.size != 9 || table[0].size != 9\n # 3 new storages will count number of occurances of each element for columns, rows and sub-boxes\n rows = Array.new(9)\n i = 0\n while i < rows.size\n rows[i] = {\"1\"=>0,\"2\"=>0,\"3\"=>0,\"4\"=>0,\"5\"=>0,\"6\"=>0,\"7\"=>0,\"8\"=>0,\"9\"=>0}\n i += 1\n end\n\n columns = Array.new(9)\n i = 0\n while i < columns.size\n columns[i] = {\"1\"=>0,\"2\"=>0,\"3\"=>0,\"4\"=>0,\"5\"=>0,\"6\"=>0,\"7\"=>0,\"8\"=>0,\"9\"=>0}\n i += 1\n end\n\n sub_boxes = Array.new(9)\n i = 0\n while i < sub_boxes.size\n sub_boxes[i] = {\"1\"=>0,\"2\"=>0,\"3\"=>0,\"4\"=>0,\"5\"=>0,\"6\"=>0,\"7\"=>0,\"8\"=>0,\"9\"=>0}\n i += 1\n end\n\n # loop through the input table to populate the above created storages with occurance numbers\n i = 0 # i is a row counter\n while i < table.size\n j = 0 # j is a column counter\n while j < table.size\n if table[i][j] != \".\"\n rows[i][table[i][j]] += 1\n columns[j][table[i][j]] += 1\n # find a number of a box/hash by calculating (i/3)*3 + (j/3)\n # e.g. for the element at indexes 1,2 the box will be: (1/3)*3 + (2/3) = 0, first box\n sub_boxes[(i/3)*3 + (j/3)][table[i][j]] += 1\n end\n j += 1\n end\n i += 1\n end\n # check if any of table elements occured more than 1 time within a row, a column or a sub-box\n rows.each do |hash|\n return false if hash.any? { |key, value| value > 1}\n end\n columns.each do |hash|\n return false if hash.any? { |key, value| value > 1}\n end\n sub_boxes.each_with_index do |hash, i|\n return false if hash.any? { |key, value| value > 1}\n end\n\n return true\nend",
"def sudoku_valid? grid\n \n # grid has first index for row, 2nd index for column\n \n # Check every row\n grid.each do |row|\n seen = Set.new\n (0..9).each do |row_value|\n if !seen.add?(row_value)\n return false\n end\n end\n end\n \n # Check every column\n grid.each do |row|\n seen = Set.new\n row.each do |col_value|\n if !seen.add?(col_value)\n return false\n end\n end\n end\n \n # Check every 3x3\n [0,3,6].each do |offset|\n [0,3,6].each do |offset2|\n to_check = get3by3 grid, offset, offset2\n seen = Set.new\n to_check.each do |value|\n if !seen.add?(value)\n return false\n end\n end\n end\n end\n \n \n return true\nend",
"def valid_sudoku(table)\n\n return true if in_row?(table) && in_column?(table) && in_box?(table)\n\n return false\n\nend",
"def is_valid_sudoku(board)\n transposed_board = board.transpose\n board.each_with_index do |row, r_index|\n row.each_with_index do |cell, c_index|\n # check row\n # check column\n if !check_row(row, cell, c_index) || !check_row(transposed_board[c_index], cell, r_index)\n p \"False at: #{cell}, #{r_index}, #{c_index}\"\n return false\n end\n end\n end\n return true\nend",
"def valid_sudoku(table)\n row_list = {}\n col_list = {}\n\n i = 0\n while i < table.length \n j = 0\n\n while j < table[i].length\n \n row_num = table[i][j]\n col_num = table[j][i]\n\n row_list = update_sub_grid(row_list, row_num)\n return false if !row_list\n\n col_list = update_sub_grid(col_list, col_num)\n return false if !col_list\n\n j += 1\n end\n\n\n row_list = {}\n col_list = {}\n \n i += 1\n end\n\n\n starting_points = [\n [0, 0],\n [0, 3],\n [0, 6],\n [3, 0],\n [3, 3],\n [3, 6],\n [6, 0],\n [6, 3],\n [6, 6]\n ]\n\n starting_points.each do |row_start, col_start|\n return false if !valid_sub_grid(table, row_start, col_start)\n end \n\n return true\nend",
"def solve!\n return false unless valid?\n return @board.join if solved?\n\n unsolved = @board.index(\"0\")\n\n (1..9).each do |possible|\n @board[unsolved] = possible\n solution = Sudoku.new(@board.join).solve!\n return solution if solution\n end\n\n false\n end",
"def sudoku_clauses\n res = []\n\n #ensure each cell contains a digit\n (1..9).each do |i|\n (1..9).each do |j|\n #must contains at least one of 9 digits\n res << (1..9).map {|d| variable(i, j, d) }\n\n (1..9).each do |d|\n ((d+1)..9).each do |dp|\n #can not contain two digits at once\n res << [-variable(i, j, d), -variable(i, j, dp)]\n end\n end\n end\n end\n\n #ensure each rows and columns contain distinct values\n (1..9).each do |i|\n res += valid( (1..9).map{|j| [i, j]} )\n res += valid( (1..9).map{|j| [j, i]} )\n end\n\n #ensure 3x3 sub-grids regions have distinct values\n [1, 4, 7].each do |i|\n [1, 4, 7].each do |j|\n res += valid((0..8).map{|k| [i + k%3, j+k / 3]})\n end\n end\n\n res\n end",
"def validate(section)\n \n #Rows, Columns or Blocks\n #--------------------------------------------------\n section.each do |i|\n check = i.sort.join.squeeze(\"0\")\n if check.length > check.split(\"\").uniq.length\n\tputs \"***************************************************\"\n\tputs \"Failed Validation, Values did not meet sudoku rules\"\n\tputs \"***************************************************\"\n\treturn false\n end\n end \n \n #Return true if all validations passed\n #--------------------------------------------------\n return true\n end",
"def valid_sudoku(table)\n table.each do |row|\n row_map = {}\n row.each do |elem|\n if elem != '.'\n if row_map[elem] \n return false\n else\n row_map[elem] = 1\n end\n end\n end\n end\n \n i = 0\n 9.times do\n column_map = {}\n table.each do |row|\n col = row[i]\n if col != '.'\n if column_map[col] \n return false\n else\n column_map[col] = 1\n end\n end\n\n end\n k += 1\n end\n \n i = 0\n k = 0\n 9.times do\n box_map = {}\n while i < i + 3\n while k < k + 3\n \n end\n end \n end\n \n return true\nend",
"def valid_sudoku(table)\n subgrids = {}\n\n # return false if any element is repeated in a row\n table.each do |row|\n row_count = {}\n row.each do |element|\n if row_count[element]\n return false unless element == \".\"\n else\n row_count[element] = 1\n end\n end\n end\n\n # return false if any element is repeated in a column\n columns = {\n 0 => {},\n 1 => {},\n 2 => {},\n 3 => {},\n 4 => {},\n 5 => {},\n 6 => {},\n 7 => {},\n 8 => {},\n }\n table.each do |row|\n row.each_with_index do |element, index|\n if columns[index][element]\n return false unless element == \".\"\n else\n columns[index][element] = 1\n end\n end\n end\n\n first_subgrid = {}\n second_subgrid = {}\n third_subgrid = {}\n\n table[0..2].each do |row|\n row[0..2].each do |element|\n if first_subgrid[element]\n return false unless element == \".\"\n else\n first_subgrid[element] = 1\n end\n end\n\n row[3..5].each do |element|\n if second_subgrid[element]\n return false unless element == \".\"\n else\n second_subgrid[element] = 1\n end\n end\n\n row[6..8].each do |element|\n if third_subgrid[element]\n return false unless element == \".\"\n else\n third_subgrid[element] = 1\n end\n end\n end\n\n first_subgrid = {}\n second_subgrid = {}\n third_subgrid = {}\n\n table[3..5].each do |row|\n row[0..2].each do |element|\n if first_subgrid[element]\n return false unless element == \".\"\n else\n first_subgrid[element] = 1\n end\n end\n\n row[3..5].each do |element|\n if second_subgrid[element]\n return false unless element == \".\"\n else\n second_subgrid[element] = 1\n end\n end\n\n row[6..8].each do |element|\n if third_subgrid[element]\n return false unless element == \".\"\n else\n third_subgrid[element] = 1\n end\n end\n end\n\n first_subgrid = {}\n second_subgrid = {}\n third_subgrid = {}\n\n table[6..8].each do |row|\n row[0..2].each do |element|\n if first_subgrid[element]\n return false unless element == \".\"\n else\n first_subgrid[element] = 1\n end\n end\n\n row[3..5].each do |element|\n if second_subgrid[element]\n return false unless element == \".\"\n else\n second_subgrid[element] = 1\n end\n end\n\n row[6..8].each do |element|\n if third_subgrid[element]\n return false unless element == \".\"\n else\n third_subgrid[element] = 1\n end\n end\n end\n\n return true\nend",
"def valid_sudoku(table)\n store = {\n rows: {},\n cols: {},\n square: {},\n }\n # First loop it represents the first row we are checking\n # Second loop it represents the column.\n\n (0...9).each do |i|\n (0...9).each do |j|\n box = table[i][j]\n if !store[:rows][i] && box != \".\"\n store[:rows][i] = []\n store[:rows][i].push(box)\n elsif box != \".\" && !store[:rows][i].include?(box)\n store[:rows][i].push(box)\n elsif store[:rows][i] && store[:rows][i].include?(box)\n return false\n end\n\n if !store[:cols][j] && box != \".\"\n store[:cols][j] = []\n store[:cols][j].push(box)\n elsif box != \".\" && !store[:cols][j].include?(box)\n store[:cols][j].push(box)\n elsif store[:cols][j] && store[:cols][j].include?(box)\n return false\n end\n\n # Converting to float and the ceil to round up always.\n squareRowId = ((i + 1).to_f / 3).ceil\n squareColId = ((j + 1).to_f / 3).ceil\n # The squeare id is gonna be like\n # 1-1 , 1-2, 1-3\n # 2-1 , 2-2, 2-3\n # 3-1 , 3-2, 3-3\n\n squareId = \"#{squareRowId}-#{squareColId}\"\n\n # Here insted of checking rows and colums I will be checking the numbers inside of this\n # Squeare ids.\n if !store[:square][squareId] && box != \".\"\n store[:square][squareId] = []\n store[:square][squareId].push(box)\n elsif box != \".\" && !store[:square][squareId].include?(box)\n store[:square][squareId].push(box)\n elsif store[:square][squareId] && store[:square][squareId].include?(box)\n return false\n end\n end\n end\n return true\nend",
"def valid_sudoku(table)\n l = table.length\n # row, time l * l\n table.each do |row|\n return false if !sudoku_helper(row)\n end\n \n # column, time l * 2l\n l.times do |i|\n column = []\n l.times do |j|\n column << table[j][i]\n end\n return false if !sudoku_helper(column)\n end\n \n # area, time l * 2l\n x = Integer.sqrt(l)\n m = n = 0\n x.times do\n x.times do \n area = []\n x.times do |i|\n area += table[n + i][m...(m+x)]\n end\n return false if !sudoku_helper(area)\n m += x\n end\n n += x\n m = 0\n end\n return true\nend",
"def solve!\n \t# keep looping if previous board doesn't match current board (new grids are being solved)\n\t \twhile true do\n\t\t \t@sudoku.each_with_index do |row, rowindex|\n\t\t \t\trow.each_with_index do |cell, cellindex|\n\t\t \t\t\t# duplicate sudoku board to solve grids and compare with previous board\n\t\t \t\t\t@sudokudup = @sudoku.dup\n\t\t \t\t\t# get the array of numbers from current column \n\t\t \t\t\tcol = @sudoku.transpose[cellindex]\n\t\t \t\t\t# find unsolved grids\n\t\t \t\t\tnext if cell != 0\n\t\t \t\t\t# form an array of possible solutions, starting with all numbers from 1 to 9\n\t\t \t\t\tsolutions=(1..9).to_a\n\t\t \t\t\t# loop through numbers from 1 to 9, delete the number from solutions if it appears in current row/column\n\t\t \t\t\t1.upto(9) {|x| solutions.delete(x) if row.include?(x)}\n\t\t \t\t\t1.upto(9) {|x| solutions.delete(x) if col.include?(x)}\n\n\t\t \t\t\t# get the numbers from current box(3x3 grid)\n\t\t \t\t\t# example (number in each grids represent column index):\n\t\t \t\t\t# | 0 1 2 | - 0 (row/array index)\n\t\t \t\t\t# | 0 1 2 | - 1\n\t\t \t\t\t# | 0 1 2 | - 2\n\t\t \t\t\t# ---------\n\t\t \t\t\t# box_x returns the array/row index of the top left number of current box (refer to sample board)\n\t\t \t\t\tbox_x = (rowindex./3)*3\n\t\t \t\t\tbox = []\n\t\t \t\t\t# loop through the 3 rows in the box\n\t\t \t\t\t3.times do\n\t\t \t\t\t\t# box_y returns the column index of the top left number of current box (refer to sample board)\n\t\t \t\t\t\tbox_y=(cellindex./3)*3\n\t\t \t\t\t\t# loop through the 3 columns for each rows\n\t\t \t\t\t\t3.times do\n\t\t \t\t\t\t\t# insert current number into the 'box' array\n\t\t \t\t\t\t\tbox << @sudoku[box_x][box_y]\n\t\t \t\t\t\t\t# get the next column index from the current row\n\t\t \t\t\t\t\tbox_y += 1\n\t\t \t\t\t\tend\n\t\t \t\t\t\t# get the next row/array index\n\t\t \t\t\t\tbox_x += 1\n\t\t \t\t\tend\n\t\t \t\t\t# delete number from solutions if it appears in current box\n\t\t \t\t\t1.upto(9) {|x| solutions.delete(x) if box.include?(x)}\n\t\t \t\t\t# if solutions contain only 1 number, the current grid will be replaced with the number\n\t\t \t\t\t@sudoku[rowindex][cellindex] = solutions[0] if solutions.length == 1\n\t\t \t\tend\n\t\t \tend\n\t\t \tif @sudoku == @sudokudup\n\t\t \t\tguess\n\t\t \t\treturn @sudoku.flatten.join\n\t\t \t\tbreak\n\t\t \tend\n\t\tend\n end",
"def sudoku(rows)\n # constrain the non-zero elements to keep their current values, and\n # constrain the zero elements (i.e. the blanks) to be between 1 and 9\n constrain_each_row(rows)\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def sudoku_constraint(input)\n grid = grid_sub(input.split(''))\n grid = solve(grid)\nend",
"def sudoku_constraint(input)\n grid = grid_sub(input.split(''))\n grid = solve(grid)\nend",
"def check_sudoku(grid)\n return (check_rows(grid) and check_cols(grid) and check_squares(grid))\nend",
"def solve(row, col)\n\tif row == 9 then\n\t\treturn true\n\tend\n\t\n\tif col == 9 then\n\t\treturn solve(row +1, 0)\n\tend\n\t\n\tif @sudokuBoard[row][col] != 0 then\n\t\treturn solve(row, col +1)\n\tend\n\t\n\t1.upto(9) {\n\t|num|\n\t\n\tif check(row,col,num) then\n\t\t@sudokuBoard[row][col] = num\n\t\tif solve(row, col+1) then\n\t\t\treturn true\n\t\tend\n\tend\n\t}\n\t\n\t@sudokuBoard[row][col] = 0\n\treturn false\n\t\n\t\n\tend",
"def temp_test(sudoku_datas)\n sudoku_cells = prepare_sudoku_cells(sudoku_datas)\n # display_sudoku(sudoku_cells, \"Sudoku to solve\")\n # build the potential list of values for each cell\n build_potential_value_list(sudoku_cells)\n update_cells(sudoku_cells) # update the value of each cell\n counter = 0\n # continue to the try to solve\n # if the counter goes beyond a million\n # it's probably a bad sudoku\n \n display_sudoku(sudoku_cells, \"Test\")\n shed_potential_value_list(sudoku_cells)\n \n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n double_whammer(sudoku_cells)\n update_cells(sudoku_cells)\n display_sudoku(sudoku_cells, \"Test\")\n \nend",
"def test_solve_sudoku\n assert_equal(false, @sudoku_1.sudoku_complete?(@sudoku_1))\n @sudoku_1.solve_sudoku(@sudoku_1)\n assert_equal(true, @sudoku_1.sudoku_complete?(@sudoku_1))\n end",
"def validateBoard()\n #cycle through all lines in the file\n row = 0\n for row in 0..8\n # @gameboard index\n index = 0\n # array temp is used to store number appearing in the same row\n temp = Array.new\n # temp array index\n i = 0\n while index<@DIMENSION\n if (1..9).member? @gameboard[row * @DIMENSION + index]\n if temp.include? @gameboard[row * @DIMENSION + index]\n return false\n else\n temp[i] = @gameboard[row * @DIMENSION + index]\n i += 1\n end\n end\n index += 1\n end\n end\n #cycle through all columns in the file\n column = 0\n for column in 0..8\n # @gameboard index\n index = 0\n # array temp is used to store number appearing in the same row\n temp = Array.new\n # temp array index\n i = 0\n while index<@DIMENSION\n if (1..9).member? @gameboard[column + index * @DIMENSION]\n if temp.include? @gameboard[column+ index * @DIMENSION]\n return false\n else\n temp[i] = @gameboard[column+ index * @DIMENSION]\n i += 1\n end\n end\n index += 1\n end\n end\n #cycle through all @DEIMENSION squares in the file\n startIndex = 0\n rowBase = 0\n columnBase = 0\n for rowBase in 0..2\n startIndex = rowBase * 3 * @DIMENSION\n for columnBase in 0..2\n # array temp is used to store number appearing in the same row\n temp = Array.new\n # temp array index\n i = 0\n #find the real index in @gameboard\n l = 0\n for l in 0..2\n m = 0\n for m in 0..2\n index = startIndex + m * @DIMENSION + l\n if (1..9).member? @gameboard[index]\n if temp.include? @gameboard[index]\n return false\n else\n temp[i] = @gameboard[index]\n i += 1\n end\n end\n end\n end\n startIndex += 3\n end\n end\n return true\nend",
"def validate\n\n entireSet = Set.new([1, 2, 3, 4, 5, 6, 7, 8, 9])\n\n @rows = []\n 9.times { @rows.push(entireSet.dup) }\n\n @cols = []\n 9.times { @cols.push(entireSet.dup) }\n\n @box = []\n 3.times do\n subrow = []\n 3.times { subrow.push(entireSet.dup) }\n @box.push(subrow)\n end\n\n (0..8).each do |i|\n (0..8).each do |j|\n v = @grid[i,j]\n if v > 0\n raise \"dup number in row #{i} : #{v}\" unless @rows[i].delete?(v)\n raise \"dup number in column #{j} : #{v}\" unless @cols[j].delete?(v)\n raise \"dup number in box #{i/3}-#{j/3} : #{v}\" unless @box[i/3][j/3].delete?(v)\n end\n end\n end\n\n @poss = []\n @poss_grid = []\n (0..8).each do |i|\n poss_row = []\n (0..8).each do |j|\n if @grid[i,j] == 0 then\n p = Poss.new(i, j, @rows[i], @cols[j], @box[i/3][j/3])\n @poss.push(p)\n poss_row.push(p.to_a)\n else\n poss_row.push([])\n end\n end\n @poss_grid.push(poss_row)\n end\n @poss.sort! { |x, y| x.length <=> y.length }\n\n end",
"def guess\n \t# loop 1\n\t while true do\n\t\t @sudoku.each_with_index do |row, rowindex|\n\t\t row.each_with_index do |cell, cellindex|\n\t\t \t# *******************************************************\n\t\t \t# this part same as solve! method\n\t\t col = @sudoku.transpose[cellindex]\n\t\t # return to previous loop (loop 2) if sudoku board is completely solved\n\t\t return if !@sudoku.flatten.include?(0)\n\t\t next if cell != 0\n\t\t solutions=(1..9).to_a\n\t\t 1.upto(9) {|x| solutions.delete(x) if row.include?(x)}\n\t\t 1.upto(9) {|x| solutions.delete(x) if col.include?(x)}\n\t\t box_x=(rowindex./3)*3\n\t\t box=[]\n\t\t 3.times do\n\t\t \tbox_y=(cellindex./3)*3\n\t\t \t3.times do\n\t\t \t\tbox << @sudoku[box_x][box_y]\n\t\t \t\tbox_y += 1\n\t\t \tend\n\t\t box_x += 1\n\t\t \tend\n\t\t \t\t1.upto(9) {|x| solutions.delete(x) if box.include?(x)}\n\t\t \t\t# *******************************************************\n\t\t \t\t# return to previous loop/previous unsolved grid(loop 2) if no solutions found for current grid\n\t\t \treturn if solutions == []\n\t\t \tsolutions_index = 0\n\t\t \t# loop through each number in solutions array (loop 2)\n\t\t \twhile true do\n\t\t \t\t# replace current grid with a number with in solutions\n\t\t\t @sudoku[rowindex][cellindex] = solutions[solutions_index]\n\t\t\t # call itself\n\t\t\t guess\n\t\t\t # code start from this line if no solution found from previous recursion (from return if solutions == [])\n\t\t\t # break the loop if sudoku board is completely solved\n\t\t\t break if !@sudoku.flatten.include?(0) \n\t\t\t # change index to the next number in solutions\n\t\t\t solutions_index += 1\n\t\t\t \tif rowindex == 0 && cellindex ==0 && solutions_index == solutions.length\n\t\t\t\t \t@sudoku[rowindex][cellindex] = 0\n\t\t\t\t \t# stop recursion and goes to next loop(loop 1) if no solutions found at all\n\t\t\t\t \tbreak\n\t\t\t \telsif solutions_index == solutions.length\n\t\t\t \t@sudoku[rowindex][cellindex] = 0\n\t\t\t \t# return to previous loop/previous unsolved grid(loop 2) if no solutions found for current grid\n\t\t\t \treturn\n\t\t\t \tend\n\t\t \tend\n\t \tend\n\t \tend\n \tend\n end",
"def solve!\n simple_sudoku_logic\n puts \"HERE'S YOUR BOARD, SOLVED. ?\"\n display_board\n end",
"def solve_a_sudoku(sudoku_datas)\n sudoku_cells = prepare_sudoku_cells(sudoku_datas)\n # display_sudoku(sudoku_cells, \"Sudoku to solve\")\n # build the potential list of values for each cell\n build_potential_value_list(sudoku_cells)\n update_cells(sudoku_cells) # update the value of each cell\n counter = 0\n # continue to the try to solve\n # if the counter goes beyond a million\n # it's probably a bad sudoku\n until solved(sudoku_cells) || counter > 1000 #\n shed_potential_value_list(sudoku_cells)\n update_cells(sudoku_cells)\n # double_whammer(sudoku_cells)\n counter += 1\n end\n if (counter > 1000)\n return nil\n end\n sudoku_cells\nend",
"def solved?\n # Return whether the total passed in is equal to the total for a valid house.\n def is_valid_house_total?(total)\n return total == 45\n end\n\n # Return the total of adding up all the cells in this house.\n def house_total(house)\n return house.inject(0) {|sum, cell| sum + cell.to_i }\n end\n\n ## Check whether all the houses in the puzzle have valid totals.\n ##\n\n each_row do |row|\n return false unless is_valid_house_total?(house_total(row))\n end\n\n each_column do |column|\n return false unless is_valid_house_total?(house_total(column))\n end\n\n each_nonet do |nonet|\n return false unless is_valid_house_total?(house_total(nonet))\n end\n end",
"def solve\n\t\t\n\t\tcell_index = 0\n\t\t# move to the right position..\n\t\t# puts @unsolved.length.to_s + \" unknown cells!\"\n\n\t\twhile cell_index >= 0 && cell_index < @unsolved.length do\n\t\t\tcell = @unsolved[cell_index];\n\t\t\t\n\t\t\tpossible = cell.nextPossible()\t\n\n\t\t\tif possible > 9 || possible <= 0\n\t\t\t\tcell.set(0)\n\t\t\t\tcell_index -= 1\n\t\t\telse\n\t\t\t\tcell.set(possible)\n\t\t\t\tcell_index += 1\n\t\t\tend\t\t\t\t\t\t\t\n\t\tend\n\n\t\tif cell_index < 0\n\t\t\treturn false\n\t\telse\n\t\t\treturn true\n\t\tend\n\tend",
"def solved?\n cols = @grid.transpose\n return false unless (0..8).all? {|i| check_cols(i) && check_row(i)}\n (0..2).each do |horiz| \n (0..2).each {|vert| return false unless check_square(horiz,vert)}\n end\n true\n end",
"def validation(board, xblks, yblks)\n # row in valid\n\n \tfor x in 0..board.length-1\n \t\tcol = Array.new\n \t\trow = Array.new(board[x]) #need new array not modify board via reference\n\t\tblock = Array.new(board.length) {Array.new}\n \t\tfor y in 0..board.length-1\n if (board[y][x] != 0)\n\n \t\t\t\tcol.concat([board[y][x]])\n\t\t\tend\n\n\t\t\tputs [y, x]\n \t\t\tputs \"\"\n\t\t\tif (board[x][y] != 0)\n \t\t\t\tblk = (x/xblks).floor + yblks * (y/yblks).floor\n\t\t\t\tblock[blk-1].concat([board[x][y]])\n\t\t\tend\n \t \tend\n\t\trow.delete(0)\n\n \t\tif (col.uniq! != nil or row.uniq! != nil)\n\n\n\t\t\treturn false\n\t\tend\n\n\n \tend\n\n for each in block\n\t\tif each.uniq! != nil\n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\n end",
"def board_solved?\r\n # Check that all the cells are filled with values\r\n #\r\n (0 .. 8).each do |row|\r\n (0 .. 8).each do |col|\r\n return false unless board[row][col] > 0\r\n end\r\n end\r\n \r\n # Check column constraints\r\n #\r\n @board.each do |column|\r\n return false unless column.uniq.size == 9\r\n end\r\n \r\n # Check row constraints\r\n #\r\n @board.transpose.each do |column|\r\n return false unless column.uniq.size == 9\r\n end\r\n \r\n # Check box constraints\r\n #\r\n (0 .. 2).each do |box_x|\r\n (0 .. 2).each do |box_y|\r\n box_vals = []\r\n \r\n (0 .. 2).each do |i|\r\n (0 .. 2).each do |j|\r\n box_vals << @board[3 * box_x + i][3 * box_y + j]\r\n end\r\n end\r\n \r\n return false unless box_vals.uniq.size == 9\r\n end\r\n end\r\n \r\n true\r\n end",
"def run_tests()\n check_solution(1,\"aaabbc\", \"3a2bc\")\n check_solution(2, \"xxyyyyzz\", \"2x4y2z\")\n check_solution(3, \"qqqqq\", \"5q\")\n check_solution(4, \"mississippi\", \"mi2si2si2pi\")\nend",
"def run_tests()\n check_solution(1,\"aaabbc\", \"3a2bc\")\n check_solution(2, \"xxyyyyzz\", \"2x4y2z\")\n check_solution(3, \"qqqqq\", \"5q\")\n check_solution(4, \"mississippi\", \"mi2si2si2pi\")\nend",
"def run_tests()\n check_solution(1,\"aaabbc\", \"3a2bc\")\n check_solution(2, \"xxyyyyzz\", \"2x4y2z\")\n check_solution(3, \"qqqqq\", \"5q\")\n check_solution(4, \"mississippi\", \"mi2si2si2pi\")\nend",
"def solve(board_string)\n sudoku_board = string_breaker(board_string)\n i = 0\n until solved?(sudoku_board) || i == 80\n sudoku_board.each_with_index do |row, row_idx|\n row.each_with_index do |square, col_idx|\n if row[col_idx].is_a?(Array)\n row[col_idx] = solve_suite(row, square, row_idx, col_idx, sudoku_board)\n row[col_idx] = row[col_idx][0].to_i if row[col_idx].length == 1\n end\n end\n end\n i += 1\n end\n sudoku_board\nend",
"def solve_sudoku(board, empty_positions)\n i = 0\n\n while i < empty_positions.length\n rrow = empty_positions[i][0]\n ccolumn = empty_positions[i][1]\n number = board[rrow][ccolumn] + 1\n found = false\n\n while !found && number <= 9\n if check_value(board, rrow, ccolumn, number)\n found = true\n board[rrow][ccolumn] = number\n i += 1\n else\n number += 1\n end\n end\n\n if !found\n board[rrow][ccolumn] = 0\n i -= 1\n end\n end\n \n board\nend",
"def solved?(board_array)\n return valid?(board_array) && valid?(transpose_arrays(board_array)) && valid?(create_grid(board_array))\nend",
"def attempt_solution(row, col)\n end",
"def b_check sym \n\t\t#check rows\n\t\ti=0\n\t\twhile i<@arr.length\n\t\t\tgame_finished=true\n\t\t\tj=0\n\t\t\twhile j<@arr.length\n\t\t\t\tif @arr[i][j]!=sym\n\t\t\t\t\tgame_finished=false\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\t\tj=j+1\n\t\t\tend\n\t\t\tif game_finished\n\t\t\t\treturn game_finished\n\t\t\tend\n\t\t\ti=i+1\n\t\tend\n\t\t# check colmns\n\t\ti=0\n\t\twhile i<@arr.length\n\t\t\tgame_finished=true\n\t\t\tj=0\n\t\t\twhile j<@arr.length\n\t\t\t\tif @arr[j][i]!=sym\n\t\t\t\t\tgame_finished=false\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\t\tj=j+1\n\t\t\tend\n\t\t\tif game_finished\n\t\t\t\treturn game_finished\n\t\t\tend\n\t\t\ti=i+1\n\t\tend\n\t\t#check diagonals\n\t\ti=0\n\t\tgame_finished=true\n\t\tj=@arr.length-1\n\t\twhile i<@arr.length\n\t\t\tif @arr[i][j]!=sym\n\t\t\t\tgame_finished=false\n\t\t\t\tbreak\n\t\t\tend\n\t\t\ti=i+1\n\t\t\tj=j-1\n\t\tend\n\t\tif game_finished\n\t\t\treturn game_finished\n\t\tend\n\n\t\ti=0\n\t\tgame_finished=true\n\t\tj=0\n\t\twhile i<@arr.length\n\t\t\tif @arr[i][j]!=sym\n\t\t\t\tgame_finished=false\n\t\t\t\tbreak\n\t\t\tend\n\t\t\ti=i+1\n\t\t\tj=j+1\n\t\tend\n\t\tif game_finished\n\t\t\treturn game_finished\n\t\tend\n\t\treturn false\n\tend",
"def loadFromFile(fileName)\n inFile = File.new(fileName, \"r\")\n index = 0\n\n # Iterate over the lines from the file.\n inFile.each_line do |line|\n # line is a string containing one line from the file.\n\n ### The code to process the line goes here. ###\n\t\tvals = line.split\n\t\t# The collect block will iterate over each item in vals (strings)\n\t\t# and perform the function (convert to int) returning the set as a new array.\n\t\t@sudokuBoard[index] = vals.collect { |x| x.to_i }\n index = index + 1\n end\n\t\n\t\n\t# Returns whether a number can be placed in this column\n\t#\n\t# @param col A number representing the board column\n\t# @param num A number we're checking\n\t# @return Returns true if the number is valid in the column, false otherwise\n\tdef checkCol(col, num)\n\t\t0.upto(BOARD_SIZE-1){\n\t\t|row| \n\t\tif num == @sudokuBoard[row][col] then\n\t\t\treturn false\n\t\tend\n\t\t}\n\t\treturn true\n\n\tend\n\t# Returns whether a number can be placed in this row\n\t#\n\t# @param row A number representing the board row\n\t# @param num A number we're checking\n\t# @return Returns true if the number is valid in the row, false otherwise\n\tdef checkRow(row, num)\n\t\tdisjointSet = @sudokuBoard[row] - [num]\n\t\tif disjointSet.length == 9 then\n\t\t\t# Safe to add sum to the row.\n\t\t\treturn true\n\t\telse\n\t\t\t# Unsafe to add sum to the row, since it already existed there.\n\t\t\treturn false\n\t\tend\n\t\t\n\tend\n\t\n\t# Returns whether a number can be placed in this subgrid\n\t#\n\t# @param row A number representing the board row\n\t# @param col A number representing the board column\n\t# @param num A number we're checking\n\t# @return Returns true if the number is valid in the subgrid, false otherwise\n\tdef checkSubgrid(row, col, num)\n\t\tx = (row / 3) * 3\n\t\ty = (col / 3) * 3\n\n\t\tbox = @sudokuBoard[x][y..(y+2)] + @sudokuBoard[x+1][y..(y+2)] + @sudokuBoard[x+2][y..(y+2)]\n\t\tdisjointSet = box - [num]\n\t\tif disjointSet.length == 9 then\n\t\t\t# Safe to add num to the row.\n\t\t\treturn true\n\t\telse\n\t\t\t# Unsafe to add num to the row, since it already existed there.\n\t\t\treturn false\n\t\tend\n\t\t\n\t\n\t\n\t\n\tend\n\t\n\t# Returns whether a number can be placed per sudoku rules\n\t#\n\t# @param row A number representing the board row\n\t# @param col A number representing the board column\n\t# @param num A number we're checking\n\t# @return Returns true if the number is valid in this postion, false otherwise\n\tdef check(row, col, num)\n\t\treturn checkCol(col,num) && checkRow(row,num) && checkSubgrid(row,col,num)\n\t\n\tend\n\t\n\t# A recursive backtracking function to solve sudoku boards \n\t#\n\t# @param row A number representing the board row\n\t# @param col A number representing the board column\n\t# @return Returns true if the board is solved, false otherwise\n\tdef solve(row, col)\n\tif row == 9 then\n\t\treturn true\n\tend\n\t\n\tif col == 9 then\n\t\treturn solve(row +1, 0)\n\tend\n\t\n\tif @sudokuBoard[row][col] != 0 then\n\t\treturn solve(row, col +1)\n\tend\n\t\n\t1.upto(9) {\n\t|num|\n\t\n\tif check(row,col,num) then\n\t\t@sudokuBoard[row][col] = num\n\t\tif solve(row, col+1) then\n\t\t\treturn true\n\t\tend\n\tend\n\t}\n\t\n\t@sudokuBoard[row][col] = 0\n\treturn false\n\t\n\t\n\tend\n\t\t\n\n inFile.close\nend",
"def solution_checker(array)\n if array.length > 1\n # Create a board that can be manipulated without affecting the original board\n internal_board = []\n column_counter = 1\n row_counter = 1\n 4.times do\n 4.times do\n internal_board.push(Square.new([column_counter, row_counter]))\n column_counter = column_counter + 1\n end\n row_counter = row_counter + 1\n column_counter = 1\n end\n #Label squares on the board as occupied\n array.each do |piece|\n square = internal_board.find {|s| s.location == piece.location}\n square.occupied = true\n square.piece = piece\n end\n array.each_with_index do |piece, index|\n if array.include?(piece) && piece != array.last\n original_square = internal_board.find {|s| s.location == piece.location}\n blocker = piece.impediments?([(array[index + 1]).column, (array[index + 1]).row], internal_board)\n if blocker\n break\n elsif piece.move([(array[index + 1]).column, (array[index + 1]).row])\n captured_piece = array[index + 1]\n array.uniq!{|piece| piece.location}\n original_square.occupied = false\n original_square.piece = nil\n new_moves = array.permutation.to_a\n new_moves.each do |new_array|\n new_array.map {|a| a.dup}\n end\n new_moves.each do |new_array|\n solution_checker(array)\n end\n else\n break\n end\n else\n break\n end\n end\n end\nend",
"def solve(arr = @input_arr)\n number_array = NumberArray.new\n pos = number_array.first_free_position arr\n # sudoku is solved, there are no free spaces in output_arr\n return arr unless pos\n ('1'..'9').each do |num|\n arr[pos] = num\n next unless number_array.valid_sudoku? pos, arr\n temp_sol = solve arr.dup\n return temp_sol if temp_sol\n end\n false\n end",
"def sudoku2(grid)\n \n i = 0\n \n while i < grid.length\n hash = Hash.new(0)\n j = 0\n\n while j < grid[0].length\n hash[grid[i][j]] += 1\n return false if hash[grid[i][j]] > 1 && grid[i][j] != '.'\n j += 1\n end\n i += 1\n end\n\n i = 0\n\n while i < grid[0].length\n hash = Hash.new(0)\n j = 0\n\n while j < grid.length\n hash[grid[j][i]] += 1\n return false if hash[grid[j][i]] > 1 && grid[j][i] != '.'\n j += 1\n end\n i += 1\n end\n\n true && grid_builder(grid)\nend",
"def valid_sudoku(table)\n # seen_set = Set.new()\n # for i in \nend",
"def run_tests()\n check_solution(1, [1, 4, 10, 13, 15], true)\n check_solution(2, [1, 4, 10, 10, 13, 15], true)\n check_solution(3, [1, 2, 5, 3, 4 ], false)\nend",
"def run_tests()\n check_solution(1, [1, 4, 10, 13, 15], true)\n check_solution(2, [1, 4, 10, 10, 13, 15], true)\n check_solution(3, [1, 2, 5, 3, 4 ], false)\nend",
"def has_solution(n)\n# Store input in variable N\n$N = n\n\n#Declare and initialize variables to find the maximum number of times 6, 9 and 20 divide into N\n$A_1 = $N/$x\n$A_2 = $N/$y\n$A_3 = $N/$z\n\n#Declare and initialize arrays to store potential combinations, where A is number of 6 packs, B number of 9 packs and C number of 20 packs\n@A = (0..$A_1).to_a\n@B = (0..$A_2).to_a\n@C = (0..$A_3).to_a\n\n#Declare function to calculate different combinations of A, B and C\ndef test(i,j,k)\nreturn @A[i]*$x + @B[j]*$y + @C[k]*$z\nend\n\n#Loop to exhaustively test combinations of A, B and C, with values ranging between 1 and the maximum number of times 6, 9 and 20 divide into N\nfor i in (0..$A_1)\n for j in (0..$A_2)\n for k in (0..$A_3)\n #Use declared function test to check each combination of i,j and k, and if it is equal to N, print out values of i, j and k\n if test(i,j,k) == $N\n return true\n end\n end\n end\nend\n\nend",
"def check_diagonal\n RulesContracts.classic_model(@game_state_model)\n # testing for bitboard errors\n # (0..7).each { |y|\n # (0..7).each { |x|\n # if @grid[y][x] == 1 and y <= 4 and x >= 3\n # puts \" #{x}/#{y} #{@grid[y][x]} || #{x-1}/#{y+1} #{@grid[y + 1][x - 1]} || #{x-2}/#{y+2} #{@grid[y + 2][x - 2]} || #{x-3}/#{y+3} #{@grid[y + 3][x - 3]}\"\n # puts \"#{@grid[y][x] == 1 and @grid[y + 1][x - 1] == 1 and @grid[y + 2][x - 2] == 1 and @grid[y + 3][x - 3] == 1}\"\n # end\n # }\n # }\n \n (0..7).each { |y|\n (0..7).each { |x|\n if y <= 4 and x <= 4\n if @grid[y][x] == 2 and @grid[y + 1][x + 1] == 2 and @grid[y + 2][x + 2] == 2 and @grid[y + 3][x + 3] == 2\n @winner = 1\n return true\n elsif @grid[y][x] == 1 and @grid[y + 1][x + 1] == 1 and @grid[y + 2][x + 2] == 1 and @grid[y + 3][x + 3] == 1\n @winner = 0\n return true\n end \n end\n if y <= 4 and x >= 3\n if @grid[y][x] == 2 and @grid[y + 1][x - 1] == 2 and @grid[y + 2][x - 2] == 2 and @grid[y + 3][x - 3] == 2\n @winner = 1\n return true\n elsif @grid[y][x] == 1 and @grid[y + 1][x - 1] == 1 and @grid[y + 2][x - 2] == 1 and @grid[y + 3][x - 3] == 1\n @winner = 0\n return true\n end\n end\n if y >= 3 and x <= 4\n if @grid[y][x] == 2 and @grid[y - 1][x + 1] == 2 and @grid[y - 2][x + 2] == 2 and @grid[y - 3][x + 3] == 2\n @winner = 1\n return true\n elsif @grid[y][x] == 1 and @grid[y - 1][x + 1] == 1 and @grid[y - 2][x + 2] == 1 and @grid[y - 3][x + 3] == 1\n @winner = 0\n return true\n end \n end\n if y >= 3 and x >= 3\n \n if @grid[y][x] == 2 and @grid[y - 1][x - 1] == 2 and @grid[y - 2][x - 2] == 2 and @grid[y - 3][x - 3] == 2\n @winner = 1\n return true\n elsif @grid[y][x] == 1 and @grid[y - 1][x - 1] == 1 and @grid[y - 2][x - 2] == 1 and @grid[y - 3][x - 3] == 1\n @winner = 0\n return true\n end \n \n end \n }\n }\n return false\n end",
"def solve(puzzle, row, column = 0)\n return puzzle.flatten if column == 4\n return nil if permissible_values(puzzle, row, column).empty?\n p \"puzzle: #{puzzle}\"\n p \"row: #{row}\"\n p \"column: #{column}\"\n blank_puzzle.each { |i_in_row|\n i_in_row.each { |i_in_column|\n permissible_values(puzzle, i_in_row, i_in_column).map do |value|\n solve(update_puzzle(puzzle.dup, value, row, column), row, column + 1)\n end\n }\n }\nend",
"def row_checker(puzzle_digit_location_hash)\n for i in 0...ROW_LENGTH\n current_row = row_selector(i, puzzle_digit_location_hash)\n current_row_digits = digit_selector(current_row)\n current_row_digits.size == current_row_digits.uniq.size ? solution_okay = true : solution_okay = false\n break if solution_okay == false\n end\n solution_okay\n end",
"def solve\n fail 'invalid game given' unless @grid.valid?\n puts \"missing values #{@grid.missing}, filled #{@grid.filled}\"\n end",
"def double_whammer(sudoku_cells)\n\n # 1. obtain the lists of cells that still need a value\n # 2. for each cell in the list look for other cells\n # which are in the same row, column or subgrid\n # that has the same potential values\n # 3. if such cells are found, remove from other\n # cells all those values from them\n working_list = get_working_list(sudoku_cells)\n\n #Those that are of the same row/column/subgrid\n #check if any of them has the same potential values\n working_list.each do |cell_a|\n check_list = working_list.find_all do |cell_b| \n !cell_a.eql?(cell_b) && (cell_a.row == cell_b.row || cell_a.column == cell_b.column || cell_a.same_subgrid?(cell_b))\n end\n \n check_list.each do |cell|\n if cell_a.same_potential?(cell)\n #if the match is found on the same row\n if cell_a.row == cell.row\n sudoku_cells[cell_a.row].each do |x|\n if x.value.zero? && !x.eql?(cell_a) && !x.eql?(cell)\n cell_a.potential_value_stack.each {|v| x.potential_value_stack.delete(x)}\n end\n end\n elsif cell_a.column == cell.column\n i = 0\n until i >= sudoku_cells.size do\n cell_a.potential_value_stack.each do |v|\n if !sudoku_cells[i][cell_a.column].eql?(cell_a) && !sudoku_cells[i][cell_a.column].eql?(cell)\n sudoku_cells[i][cell_a.column].potential_value_stack.delete(v)\n end\n end\n i += 1\n end\n elsif cell_a.same_subgrid?(cell)\n cell_a.block_family.each do |indexes|\n if !sudoku_cells[indexes[0]][indexes[1]].eql?(cell_a) && !sudoku_cells[indexes[0][1]].eql?(cell)\n cell_a.potential_value_stack.each do |v|\n sudoku_cells[indexes[0]][indexes[1]].potential_value_stack.delete(v)\n end\n end\n end\n end\n end\n end\n end\n\n # working_list.each do |cell|\n # puts \"[#{cell.row}, #{cell.column}]\"\n # end\n # puts \"Working list: #{working_list.size}\"\n # binding.pry\nend",
"def solve(board_string)\n board_array = []\n separated_board_string = board_string.split('')\n board_array << (separated_board_string[0..8])\n board_array << (separated_board_string[9..17])\n board_array << (separated_board_string[18..26])\n board_array << (separated_board_string[27..35])\n board_array << (separated_board_string[36..44])\n board_array << (separated_board_string[45..53])\n board_array << (separated_board_string[54..62])\n board_array << (separated_board_string[63..71])\n board_array << (separated_board_string[72..80])\n board_array\n\n# temp_array = board_array.join\n# while board_array.include?(\"-\")\n 50.times { sudoku_solver(board_array) }\n # end\n board_array\nend",
"def solved?(board)\n board.all? { |row| row.flatten.length == 9 && row.sort == [1,2,3,4,5,6,7,8,9] }\nend",
"def run_tests()\n check_solution(1, [1, 3, 5, 4], [5])\n check_solution(2, [4, 2, 3, 6, 10], [4, 10])\n check_solution(3, [4, 2, 11, 6, 10], [4, 11, 10])\nend",
"def valid?\n tally = Hash.new(0)\n tally[:xxx] = 1\n \n 5.times do |u|\n 5.times do |h|\n if !@solution[h][u].nil?\n tally[@solution[h][u]] += 1\n end\n end\n return true if tally.values.max < 2\n end\n puts \"invalid: #{tally.inspect}\"\n puts self.to_s\n return false\n end",
"def propagate_rule_implications(tag)\n while true\n updated_cell_count = 0\n\n # Per rule #1 from http://byteauthor.com/2010/08/sudoku-solver/, any cells that only have a \n # single candidate value must resolve to that value, so just set the cell value to the single candidate solution\n # and then verify that the partial solution is still valid; if the partial solution is invalid, then we need to reject this \n # candidate solution and backtrack\n cells_with_implied_solution = @cells.select {|cell| cell.candidate_values.count == 1 }\n cells_with_implied_solution.each do |cell|\n return false unless update_cell(tag, cell, cell.candidate_values.first)\n updated_cell_count += 1\n end\n\n # Per rule #2 from http://byteauthor.com/2010/08/sudoku-solver/, within a given 3x3 box, if a cell in the\n # box has a candidate solution that no other cell in the same box has as a candidate solution, then the cell\n # with the unique candidate solution should be set to that unique value - that cell is solved.\n three_by_three_boxes.each do |box|\n count = deduce_cell_values_from_group_of_related_cells(tag, box)\n return false if count < 0\n updated_cell_count += count\n end\n\n # Per rule #3 from http://byteauthor.com/2010/08/sudoku-solver/, within a given 9-cell row or column, if a cell\n # in the row or column has a candidate solution that no other cell in the same row or column has as a candidate solution, \n # then the cell with the unique candidate solution should be set to that unique value - that cell is solved.\n rows.each do |row|\n count = deduce_cell_values_from_group_of_related_cells(tag, row)\n return false if count < 0\n updated_cell_count += count\n end\n cols.each do |col|\n count = deduce_cell_values_from_group_of_related_cells(tag, col)\n return false if count < 0\n updated_cell_count += count\n end\n\n # Per rule #4 from http://byteauthor.com/2010/08/sudoku-solver/, within each 3x3 box, if we observe that a given value\n # is only allowed in a single row or single column within the box, then, (1) in the case of a row, we can remove that \n # value from from the candidate values of the cells in the adjacent boxes on the same row, or, (2) in the case of a column,\n # we can remove that value from the candidate values of the cells in the adjacent boxes on the same column.\n three_by_three_boxes.each do |box_cells|\n cells_per_candidate_value = (1..9).reduce({}) do |memo, number|\n memo[number] = box_cells.select {|cell| cell.candidate_values.include?(number) }\n memo\n end\n\n cells_per_candidate_value.each do |candidate_value, cells|\n if cells.map(&:row_index).uniq.count == 1\n # this branch implies that all the cells within this 3x3 box that have <candidate_value> as a candidate value are all\n # on one row, therefore, <candidate_value> may not appear on the same row in other 3x3 boxes\n row_index = cells.first.row_index\n (row(row_index) - cells).each do |cell|\n pre_rejection_candidates = cell.candidate_values\n cell.reject_candidates(tag, candidate_value)\n post_rejection_candidates = cell.candidate_values\n updated_cell_count += 1 if pre_rejection_candidates.count != post_rejection_candidates.count\n end\n elsif cells.map(&:col_index).uniq.count == 1\n # this branch implies that all the cells within this 3x3 box that have <candidate_value> as a candidate value are all\n # on one column, therefore, <candidate_value> may not appear on the same column in other 3x3 boxes\n col_index = cells.first.col_index\n (col(col_index) - cells).each do |cell|\n pre_rejection_candidates = cell.candidate_values\n cell.reject_candidates(tag, candidate_value)\n post_rejection_candidates = cell.candidate_values\n updated_cell_count += 1 if pre_rejection_candidates.count != post_rejection_candidates.count\n end\n end\n end\n end\n\n # Per Naked Pairs Rule from http://byteauthor.com/2010/08/sudoku-solver-update/, for any given row (or column), if two cells\n # - let's call them A and B - on the same row (or column) have the exact same candidate values, such that the candidate \n # values consist only of two values, then no other cell on the same row (column) may be either of the two candidate values, \n # so we can remove the two values from the candidate value sets of every cell except A and B on that row (or column).\n # Note: the Naked Pairs rule is the same as rule #1 with a different length requirement.\n cells_with_two_candidate_values = @cells.select {|cell| cell.candidate_values.count == 2 }\n cells_grouped_by_row_index = cells_with_two_candidate_values.group_by(&:row_index)\n cells_grouped_by_col_index = cells_with_two_candidate_values.group_by(&:col_index)\n cells_grouped_by_row_index.each do |row_index, cells|\n cell_pairings = cells.combination(2).to_a\n cell_pairings.each do |cell1, cell2|\n if cell1.candidate_values == cell2.candidate_values\n (row(row_index) - [cell1, cell2]).each do |cell|\n pre_rejection_candidates = cell.candidate_values\n cell.reject_candidates(tag, cell1.candidate_values)\n post_rejection_candidates = cell.candidate_values\n updated_cell_count += 1 if pre_rejection_candidates.count != post_rejection_candidates.count\n end\n end\n end\n end\n cells_grouped_by_col_index.each do |col_index, cells|\n cell_pairings = cells.combination(2).to_a\n cell_pairings.each do |cell1, cell2|\n if cell1.candidate_values == cell2.candidate_values\n (col(col_index) - [cell1, cell2]).each do |cell|\n pre_rejection_candidates = cell.candidate_values\n cell.reject_candidates(tag, cell1.candidate_values)\n post_rejection_candidates = cell.candidate_values\n updated_cell_count += 1 if pre_rejection_candidates.count != post_rejection_candidates.count\n end\n end\n end\n end\n\n # Per Lines Rule from http://byteauthor.com/2010/08/sudoku-solver-update/, within each 3x3 box,\n # if we observe that a given value is only allowed in a single row or single column within the box, then, (1) in the case\n # of a row, we can remove that value from the candidate values of the cells in the other rows within the same box, or,\n # (2) in the case of a column, we can remove that value from the candidate values of the cells in the other columns within\n # the same box.\n rows.each do |row_cells|\n cells_per_candidate_value = (1..9).reduce({}) do |memo, number|\n memo[number] = row_cells.select {|cell| cell.candidate_values.include?(number) }\n memo\n end\n\n cells_per_candidate_value.select {|candidate_value, cells| cells_in_same_box?(cells) }.\n each do |candidate_value, cells_in_same_box|\n # we want to reject <candidate_value> from the candidate values of the cells in the same box at <cells.first>\n # in the other rows.\n (box_by_cell_coords(*cells_in_same_box.first.coords) - cells_in_same_box).each do |cell|\n pre_rejection_candidates = cell.candidate_values\n cell.reject_candidates(tag, candidate_value)\n post_rejection_candidates = cell.candidate_values\n updated_cell_count += 1 if pre_rejection_candidates.count != post_rejection_candidates.count\n end\n end\n end\n cols.each do |col_cells|\n cells_per_candidate_value = (1..9).reduce({}) do |memo, number|\n memo[number] = col_cells.select {|cell| cell.candidate_values.include?(number) }\n memo\n end\n\n cells_per_candidate_value.select {|candidate_value, cells| cells_in_same_box?(cells) }.\n each do |candidate_value, cells_in_same_box|\n # we want to reject <candidate_value> from the candidate values of the cells in the same box at <cells.first>\n # in the other columns.\n (box_by_cell_coords(*cells_in_same_box.first.coords) - cells_in_same_box).each do |cell|\n pre_rejection_candidates = cell.candidate_values\n cell.reject_candidates(tag, candidate_value)\n post_rejection_candidates = cell.candidate_values\n updated_cell_count += 1 if pre_rejection_candidates.count != post_rejection_candidates.count\n end\n end\n end\n\n break if updated_cell_count == 0\n end\n\n true\n end",
"def test_complete_sudoku_true\n assert_equal(true, @c_sudoku_1.sudoku_complete?(@c_sudoku_1))\n end",
"def is_safe(x, y, sol)\n return true if x >= 0 && x < 8 && y >= 0 && y < 8 && sol[x][y] == -1\n return false\nend",
"def solved?(board)\n if\n board.each do |row|\n end\n else\n false\n end\n\nend",
"def run_tests\n check_solution(1, [6, 29, 18, 2, 72, 19, 18, 10, 37], 18, 2)\n check_solution(2, [6, 29, 18, 2, 72, 19, 18, 10, 37], 9, -1)\nend",
"def check_valid (size)\n #checks length of string correct according to n x m\n if @arg.length != size\n puts \"String length incorrect\"\n end\n #checks if outer wall is all 1's\n string=''\n @col_nums.times do\n string+='1'\n end\n if !@arg[0..@col_nums-1].eql? string\n puts \"Invalid maze (outer wall)\"\n end\n (0..@row_nums*@col_nums-1).step(@col_nums) do |i|\n if @arg[i] != \"1\" || @arg[i-1] != \"1\"\n puts \"Invalid maze (outer wall)\"\n break\n end\n end\n #cell centers should be 0's\n #takes values of cell centers and uses coordinates for make_cell method\n (@col_nums..@row_nums*@col_nums-1).step(@col_nums*2) do |i|\n (1..@col_nums-2).step(2) do |j|\n if @arg[i+j]!=\"0\"\n puts \"Invalid maze (cell center)\"\n break\n else\n make_cell(i+j)\n end\n end\n end\n #cell corners should be 1's\n (0..@row_nums*@col_nums-1).step(@col_nums*2) do |i|\n (0..@col_nums-2).step(2) do |j|\n if @arg[i+j]!=\"1\"\n puts \"Invalid maze (cell corner)\"\n break\n end\n end\n end\n end",
"def cell_validate\n height = 2 * self.down - 1\n width = 2 * self.across - 1\n for i in (1..height).step(2) do\n for j in (1..width).step(2) do\n wall_num = calculate_boundary_sum(i,j)\n if(wall_num == 4 || wall_num == 0)\n puts \"[#{j/2},#{i/2}] is an invalid cell. Please enter another valid string\"\n self.valid = false\n end\n end\n end\n end",
"def run_tests\n check_solution(1, (100..200).to_a, 135, 35)\n check_solution(2, [13, 19, 24, 29, 32, 37, 43], 35, -1)\nend",
"def solved sol\n\tfor i in 0...sol.size\n\t\tfor j in 0...sol[i].size\n\t\t\tif sol[i][j].ord < 'a'.ord\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\tend\n\n\treturn true\nend",
"def validate_comb(board_view, comb)\n comb.each_with_index do |value, idx|\n return false unless board_view[idx].include?(value)\n end\n true\nend",
"def valid?\n # Valid puzzle has 9 rows.\n unless @puzzle.size == 9\n raise RuntimeError, \"Sudoku puzzle must have 9 rows.\"\n end\n\n # Valid puzzle has 9 columns of 9 cells.\n each_row do |row|\n unless row.size == 9\n raise RuntimeError, \"Each row in the Sudoku puzzle must have 9 cells.\"\n end\n end\n\n # Valid puzzle has valid cells.\n each do |cell|\n cell.valid?\n end\n\n #TODO: Find out if there are conflicts in row, column or nonet.\n\n # If we get this far without error, the puzzle is valid.\n return true\n end",
"def external_check?(row,col)\n \n #Get values available in this block\n #------------------------------------------------------------------\n values = [@rows[row], @cols[col], @blks[find_block(row,col)]] #Values related to the section\n values = values.flatten.uniq.join.gsub(\"0\",\"\")\n values = \"123456789\".tr(values,\"\")\n \n section = []\n \n #Check row\n #Get values available in the other blocks in the current row\n #---------------------------------------------------------------------------------------------------\n 9.times do |i|\n if @rows[row][i] == \"0\"\n\tsection << internal_check(row,i) unless col==i\n end\n end\n \n section = section.join.split(\"\").sort.uniq.join.gsub(\"0\",\"\")\n values_row = values.tr(section,\"\")\n \n if values_row.length == 1\n @rows[row][col] = values_row.to_s\n adjust_values\n return true\n else\n return false\n end \n #Check column\n #Get values available in the other blocks in the current column\n #---------------------------------------------------------------------------------------------------\n 9.times do |i|\n if @rows[row][i] == \"0\"\n\tsection << internal_check(i,col) unless row==i\n end\n end\n \n section = section.join.split(\"\").sort.uniq.join.gsub(\"0\",\"\")\n \n values_col = values.tr(section,\"\")\n if values_col.length == 1\n @rows[row][col] = values_col.to_s\n adjust_values\n return true\n else\n return false\n end \n \n #Check block\n #Get values available in the other blocks in the current block\n #---------------------------------------------------------------------------------------------------\n blk = find_block(row,col)\n case blk\n when 0\n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r-1,c-1) unless r=row and c=col\n\tend\n end\n when 1\n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r-1,c+2) unless r=row and c=col\n\tend\n end\n when 2\n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r-1,c+5) unless r=row and c=col\n\tend\n end\n when 3\n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r+2,c-1) unless r=row and c=col\n\tend\n end\n when 4\n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r+2,c+2) unless r=row and c=col\n\tend\n end\n when 5\n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r+2,c+5) unless r=row and c=col\n\tend\n end\n when 6\n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r+5,c-1) unless r=row and c=col\n\tend\n end\n when 7\n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r+5,c+2) unless r=row and c=col\n\tend\n end\n else \n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r+5,c+5) unless r=row and c=col\n\tend\n end\n end \n \n @blks[blk].each do |i|\n if @rows[row][i] == \"0\"\n\tsection << internal_check(row,i) unless col==i\n end\n end\n \n section = section.join.split(\"\").sort.uniq.join.gsub(\"0\",\"\")\n \n values_block = values.tr(section,\"\") \n if values_block.length == 1\n @rows[row][col] = values_block.to_s\n adjust_values\n return true\n else\n return false\n end \n end",
"def checker\n @correct_pos = 0\n @correct_num = 0\n x = 0\n @guess.each do |i|\n if (i == @solution[x])\n @correct_pos += 1\n elsif @solution.include?(i)\n @correct_num += 1\n end\n x += 1\n end\n end",
"def test_empty_spaces_some_empty\n result = @sudoku_1.empty_spaces(@sudoku_1.squares[1])\n assert_equal([[0, 5], [1, 3], [1, 5], [2, 4]], result)\nend",
"def board_is_valid?(board)\n conflicts(board) == 0\nend",
"def check_if_all_combos_tried(row, col, forward)\n \n if @board_indicator[row][col] == 0 && @board[row][col] == 9 && row == @row_of_first_empty_square && col == @col_of_first_empty_square\n return true\n else\n return false\n end\n # if all initial holes are filled with'9', all combos were tried\n # all_combos_tried = true\n # (0..8).each do |k|\n # (0..8).each do |j|\n # if @board_indicator[k][j] == 0 && @board[k][j] < 9\n # all_combos_tried = false\n # #break\n # end\n # end\n # end\n # puts all_combos_tried\n # all_combos_tried\n end",
"def check_solution(possible_values)\n # possible.value_at(key) compared to \n # possible.value_at(*value) => array of values from possible given array of indexes in \"value\"\n # if any of the value_at values, are +- 1 from comparison value, then this fails.\n SEQUENCE_CHECKS.any? do |check_cell_id, adjacent_cell_ids|\n # must convert the cell_ids to indexes \n cell_index = check_cell_id - 1\n adjacent_indexes = adjacent_cell_ids.map{ |id| id - 1 }\n\n # retrieve the values for those indexes\n cell_value = possible_values[cell_index]\n adjacent_values = possible_values.values_at(*adjacent_indexes)\n\n # see if any of the adjacent values are in sequence with the check cell\n adjacent_values.any? { |v| (cell_value - v).abs == 1 }\n end\nend",
"def guessing_method\n smallest_num_of_possibilities = 9\n\n loop_board do |cell|\n smallest_num_of_possibilities = cell.possibilities.length if cell.possibilities.length < smallest_num_of_possibilities && cell.content.is_a?(Array)\n end\n\n loop_board do |cell|\n if cell.possibilities.length == smallest_num_of_possibilities\n cell.possibilities.each do |guess_value|\n\n guessing_board_copy = Marshal.load(Marshal.dump(self))\n guessing_board_copy.full_board[cell.tri_square_index][cell.square_index][cell.tri_cell_index][cell.cell_index].content = guess_value\n guessing_board_copy.full_board[cell.tri_square_index][cell.square_index][cell.tri_cell_index][cell.cell_index].possibilities = []\n\n if guessing_board_copy.solve!\n self.full_board = guessing_board_copy.full_board\n return guessing_board_copy\n end\n end\n return false\n end\n end\n end"
] |
[
"0.7846883",
"0.77814215",
"0.77255124",
"0.7709284",
"0.7637136",
"0.75797176",
"0.7521248",
"0.7473625",
"0.74645483",
"0.7441738",
"0.74179155",
"0.73958385",
"0.7388276",
"0.73526496",
"0.7319035",
"0.72637045",
"0.72590715",
"0.7211477",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.72022873",
"0.7161208",
"0.7161208",
"0.71496934",
"0.7143495",
"0.70453817",
"0.7010292",
"0.698841",
"0.6919825",
"0.691786",
"0.68954706",
"0.68909484",
"0.6848928",
"0.6801517",
"0.67975605",
"0.6790183",
"0.67863405",
"0.6687926",
"0.6687926",
"0.6687926",
"0.66684335",
"0.6668114",
"0.66477525",
"0.66114086",
"0.660393",
"0.6590649",
"0.6581314",
"0.65704495",
"0.65648186",
"0.6543913",
"0.65410274",
"0.65410274",
"0.6529848",
"0.65249294",
"0.6519892",
"0.65182346",
"0.6480698",
"0.6474573",
"0.6459533",
"0.64497954",
"0.64443564",
"0.6432162",
"0.6412794",
"0.6405829",
"0.6396345",
"0.6392521",
"0.6363237",
"0.6361603",
"0.63205093",
"0.63152224",
"0.6296086",
"0.62915826",
"0.6259147",
"0.62563884",
"0.6256352",
"0.6248529",
"0.62446696",
"0.62387246",
"0.6227515",
"0.6221957"
] |
0.71205944
|
45
|
codewars kata: josephus permutation for best solutions, see
|
def josephus(items,k)
new_array = []
while items.size > (k-1)
new_array << items.delete_at(k-1)
items.rotate!(k-1)
end
while items.size > 0
items.rotate!(k-1)
new_array << items.delete_at(0)
end
new_array
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def solve\n perms = (1..9).to_a.permutation.map {|p| p.join}\n prods = []\n\n perms.each do |p|\n (1..2).each do |len|\n a, b, c = p[0, len].to_i, p[len..4].to_i, p[5, 4].to_i\n prods << c if a * b == c\n end\n end\n \n prods.uniq.reduce( :+ )\n end",
"def pythagoreans (n)\n return (1..n).to_a.permutation(3).to_a.select { |a,b,c| a**2 + b**2 == c**2 }.each(&:sort!).uniq\nend",
"def solution(a)\n # write your code in Ruby 2.2\n \n is_perm = 0\n \n n = a.length\n b = [0]*n\n \n \n a.each do |v|\n break if v > n \n break if b[v] == 1 \n b[v] = 1\n end\n \n sum = b.inject(:+)\n if sum == n\n is_perm = 1\n end\n \n is_perm\nend",
"def q(a);a.permutation;end",
"def permuted_nums()\r\n\t# *2...*6 must have the same digits (and length) as the original.\r\n\t# That's why the first character must be 1.\r\n\t# And the second character must be less that 7.\r\n\trunner = 123455\r\n\tmax = 170000\r\n\twhile runner < max\r\n\t\trunner += 1\r\n\t\t\r\n\t\tmult_count = 1\r\n\t\t(2..6).each{ |mult_num| \r\n\t\t\ttmp = runner * mult_num\r\n\t\t\t\r\n\t\t\tif !is_permutation_of(tmp, runner)\r\n\t\t\t\tbreak\r\n\t\t\tend\r\n\t\t\tif mult_num == 6\r\n\t\t\t\treturn runner\r\n\t\t\tend\r\n\t\t\tmult_count += 1\r\n\t\t}\r\n\tend\r\n\tputs ''\r\n\treturn false\r\nend",
"def permutationEquation(p)\n n = p.size\n (1..n).map do |x|\n res = 0\n p.each do |y|\n res = y if p[p[y - 1] - 1] == x\n end\n res\n end\nend",
"def getPermutations3(s,perm=[])\n subresult = getPermutations2(s[1..3])\n subresult.each do |item|\n perm.push(item.insert(0,s[0]))\n end\n if perm.length >= factorial(s.length)\n return perm\n else\n s = rotateChar(s)\n getPermutations3(s,perm)\n end\nend",
"def permute(nums, solution = [], results = []\n return results << solution.clone if solution.size == nums.size\n\n nums.each do |num|\n next if solution.include?(num)\n\n solution << num\n permute(nums, solution, results)\n solution.pop\n end\n results\nend",
"def permutations(array)\n \nend",
"def permute(list)\n if (list.length <= 1)\n return [list]\n end\n permutations = []\n count = 1\n list.each do |item|\n sublist_permutations = permute(list - [item])\n sublist_permutations.each do |permutation|\n permutation.unshift(item)\n permutations << permutation\n #puts \"Permutations : #{permutations.join(', ')}\"\n #puts \"permutation lists: #{permutations.each {permutation.join(', ')}}\"\n end\n end\n return permutations\nend",
"def solution(a)\n # write your code in Ruby 2.2\n permutation = Array(1..a.size)\n # puts permutation\n return 1 if permutation - a == []\n 0\nend",
"def permute_comb(nums, params, result, h)\n\treturn params if params.length == nums.length\n\n\t\n h.keys.each do|e|\n \tif h[e] > 0\n \t\tparams << e\n \t\th[e] -= 1\n \t\tel = permute_comb(nums, params.clone, result, h)\n \t\tresult << el if !el.empty?\n params.pop\n h[e] +=1\n end \n end\t\n\n result\t\n\nend",
"def permutation(array)\n answer_arr = []\n return array if array.length == 1\n array.each_index do |i|\n perm = permutation(array - [array[i]])\n perm.each do |el|\n answer_arr << ([array[i]] + [el]).flatten\n end\n perm.each do |el|\n answer_arr << ([el] + [array[i]]).flatten\n end\n end\n answer_arr.uniq\nend",
"def PermutationStep(num)\n possibilities = []\n possibilities = num.to_s.chars.map(&:to_i).permutation.to_a\n possibilities.reject! {|comb| comb.join.to_i <= num}\n possibilities.map! {|comb| comb.join.to_i}\n possibilities.empty? ? -1 : possibilities.min\nend",
"def josephus(n,m)\n\n while n.size>0\n puts n.rotate!(m-1).shift(1)\n josephus(n,m)\n end\nend",
"def perm(nums, i, result)\n return result << nums.dup if i == nums.size\n\n (i...nums.size).each do |j|\n nums[i], nums[j] = nums[j], nums[i]\n perm(nums, i + 1, result)\n nums[i], nums[j] = nums[j], nums[i]\n end\nend",
"def permutations(array)\n\nend",
"def permutations(array)\n\nend",
"def permutations(array)\n\nend",
"def permutations(array)\n\nend",
"def permute_unique(nums, solution = [], results = [], visited_indices = {}, found = {}, start = 0)\n\n # if solution.size == nums.size && !found[solution]\n # found[solution] = 1\n # return results << solution.clone\n # end\n\n return results << solution.clone if solution.size == nums.size\n\n (0...nums.length).each do |idx|\n next if nums[idx] == nums[idx - 1] && idx != start\n\n next if visited_indices[idx]\n visited_indices[idx] = 1\n solution << nums[idx]\n\n permute_unique(nums, solution, results, visited_indices, found, idx + 1)\n\n visited_indices.delete(idx)\n solution.pop\n end\n results\nend",
"def josephus(n,m)\n arr = Array.new\n order = Array.new\n\n for i in 1..n\n arr[i] = i\n end\n\n arr.compact!\n\n for i in 0..n-1\n arr= arr.rotate(m-1)\n order << arr[0]\n arr[0] = nil\n arr.compact!\n end\n\n puts \"order: #{order.to_s}\"\nend",
"def permutation(array)\n return array if array.length == 1\n\n smaller = permutation(array[0...-1])\n combination_array = []\n (smaller.length + 1).times do |index|\n combination_array += smaller.dup.insert(index, array[-1])\n # debugger\n end\n combination_array\nend",
"def permutations(a, i)\n if i == a.size \n puts to_decimal(a)\n gets\n return\n end\n\n for j in i..a.size-1\n a[j], a[i] = a[i], a[j]\n permutations(a, i + 1)\n a[j], a[i] = a[i], a[j]\n end\nend",
"def min_permutation n\n n.to_s.chars.sort.join.to_i\nend",
"def permutations(sequence)\n return sequence if sequence.empty?\n\n ch = sequence.delete_at(0)\n underlying = Set.new([ch])\n sequence.each do |ch|\n new_set = Set.new\n underlying.each do |permutation|\n (0..permutation.length).each do |idx|\n new_set.add(permutation.dup.insert(idx, ch))\n end\n end\n underlying = new_set\n end\n underlying.each\nend",
"def permutations(elements)\n return [elements] if elements.size <= 1\n result = []\n elements.uniq.each do |p|\n _elements = elements.dup\n _elements.delete_at(elements.index(p))\n permutations(_elements).each do |perm|\n result << (perm << p)\n end\n end\n result\nend",
"def josephus(items,k)\n n = -1\n out = []\n while items.length > 0 do \n n = (n + k) % items.length \n out.push(items.slice!(n))\n n -= 1 \n end\n out\nend",
"def permutation (array)\n# yields permutation set WITH duplicates\nend",
"def josephus_survivor(n,k)\n result = 1\n for i in 1...n + 1\n result = (result + k - 1) % i + 1\n end\n \n result\nend",
"def kaprekar n\n k = max_permutation(n) - min_permutation(n)\n if k == n then k else kaprekar k end\nend",
"def ptn(a)\n if a.size == 1 then\n return [a]\n end\n ret = Array.new\n # 重ならないパターン\n ret += a.perms\n # 重なるパターン\n h1 = Hash.new\n for i in 0..a.size - 1\n for j in i + 1..a.size - 1\n key = [a[i], 0, a[j]].to_s\n if !h1.key?(key) then\n h1.store(key, nil)\n h2 = Hash.new\n # a[i]とa[j]を範囲をずらしながら重ねる\n for k in 0..a[i].size + a[j].size\n t = [0] * a[j].size + a[i] + [0] * a[j].size\n for m in 0..a[j].size - 1\n t[k + m] += a[j][m]\n end\n # 余分な0を取り除く\n t.delete(0)\n # 4より大きい値がないかチェック\n next if t.any? {|v| v > 4}\n # 9より長くないかチェック\n next if t.size > 9\n # 重複チェック\n if !h2.key?(t.to_s) then\n h2.store(t.to_s, nil)\n # 残り\n t2 = a.dup\n t2.delete_at(i)\n t2.delete_at(j - 1)\n # 再帰呼び出し\n ret += ptn([t] + t2)\n end\n end\n end\n end\n end\n return ret\nend",
"def permutations(string)\nend",
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend",
"def next_permutation(nums)\n i, j = nums.size - 2, nums.size - 1\n i -= 1 while i >= 0 && nums[i] >= nums[i + 1]\n if i >= 0\n j -= 1 while nums[j] <= nums[i]\n nums[i], nums[j] = nums[j], nums[i]\n end\n nums[i + 1..-1] = nums[i + 1..-1].reverse\n nums\nend",
"def getPermutations2(s,perm=[])\n substring = s[1..2]\n perm.push(s[0] + substring)\n perm.push(s[0] + substring.reverse)\n if perm.length >= factorial(s.length)\n return perm\n else\n s = rotateChar(s)\n getPermutations2(s,perm)\n end\nend",
"def permutation_number\n number = 0\n unused = Array.new(@@size, true)\n (1..@@size).each do |i|\n l = 1\n j = 1\n while j != @state_array[i - 1] do\n l += 1 if unused[j - 1]\n j += 1\n end\n number += (l - 1) * (@@size - i).factorial\n unused[@state_array[i - 1] - 1] = false\n end\n return number\n end",
"def permutations(array)\n # debugger\n return [array] if array.length == 1\n perms = permutations(array[0..-2])\n other_perms = []\n perms.each do |perm|\n other_perms += (0..perm.length).map do |idx|\n temp = perm.dup\n temp.insert(idx, array[-1])\n end\n end \n other_perms\nend",
"def lexicographic_permutation(k)\n k -= 1\n s = self.dup\n n = s.length\n n_less_1_factorial = (n - 1).factorial # compute (n - 1)!\n (1..n-1).each do |j|\n tempj = (k / n_less_1_factorial) % (n + 1 - j)\n s[j-1..j+tempj-1]=s[j+tempj-1,1]+s[j-1..j+tempj-2] unless tempj==0\n n_less_1_factorial = n_less_1_factorial / (n- j)\n end\n s\n end",
"def permutations(p)\r\n p.to_s.scan(/\\d/).permutation.map{|e| e.join}.sort\r\nend",
"def permutations(array)\n return [array] if array.length == 1\n\n perms = []\n array.each do |el|\n dupped = array.dup\n dupped.delete(el)\n permutations(dupped).each { |perm| perms << [el] + perm }\n end\n\n perms\nend",
"def permutations(arr)\n # return nil if arr.empty?\n return [arr] if arr.length == 1\n # grab first element to append to all perms of smaller array\n first_el = arr.shift\n # get permutations of shrunken array\n subset_perms = permutations(arr)\n total_permutations = []\n # iterate through all smaller perms\n subset_perms.each do |sub|\n # add first element to all possible indices of perms array\n # and add to total_perms array\n (0..sub.length).each do |i|\n subset = sub[0...i] + [first_el] + sub[i..-1]\n total_permutations << subset\n end\n end\n total_permutations\nend",
"def permutations(array)\n results = []\n\n 1000.times do \n premutation = array.shuffle\n results << array << premutation\n end\n\n results.uniq.sort\nend",
"def palindrome_permutation(str)\n\nend",
"def permutations(str)\nend",
"def josephus(items,k)\n result = []\n count = k\n until items.length == 0 do\n remove_these = []\n items.each_with_index do |item, i|\n if count == 1\n result << items[i]\n remove_these << i\n end\n count = count == 1 ? k : count -= 1\n end\n remove_these.reverse!\n remove_these.each do |r|\n items.delete_at(r)\n end\n end\n result\nend",
"def pythagoreans (n)\n triples = []\n a = 1\n b = 1\n c = 1\n\n for c in (1..n)\n for b in (1..c)\n for a in (1..b)\n if a**2 + b**2 == c**2\n triples << [a,b,c]\n end\n end\n end\n end\n\n return triples.sort\nend",
"def permsol(str)\n str.chars.permutation.to_a.map(&:join).uniq \nend",
"def solve\n max = nil\n\n # Start with the longest possible and work down. \n 9.downto( 1 ) do |i|\n max = Array.new( i ) {|j| 1 + j}.permutation.to_a.map! {|j| j.join.to_i}.select {|j| j.prime? }.max\n break if max\n end\n \n max\n end",
"def num_creator_2()\n\tlist_of_pandigs = [1,21,321,4321,54321,654321,7654321,87654321,987654321]\n\tlist_of_all_permutations = []\n\n\tlist_of_pandigs.each do |pandig|\n\t\ttemp_list = []\n\t\tpandig.to_s.each_char do |char|\n\t\t\ttemp_list << char.to_i\n\t\t\tlist_of_all_permutations << temp_list.permutation(temp_list.count).to_a\n\t\tend\n\tend\n\tclean_list = []\n\n\tlist_of_all_permutations.each do |perm|\n\t\tperm.each do |perm2|\n\t\t\t# if is_pandigital(perm2, pandigidictcreator()) == true\n\t\t\t\tclean_list << perm2.join()\n\t\t\t# end\n\t\tend\n\t\t# p perm\n\tend\n\treturn clean_list\nend",
"def permutations(array)\n #[1,2]\nreturn [array] if array==[1]\n\n\n\n\nprevious=permutations(array[0...-1])\nlast = array.last\nresult=[]\nprevious.each do |ele|\n (0...array.length-1).each do |i|\n result << ele[0..i]+[last]+ele[i+1..-1]\n \n \n end\n result << [last]+ele\n\n end\n result\nend",
"def perm_recur(ans=\"\",s)\n if s.length == 0\n return\n end\n\n if s.length == 1\n puts ans + s\n return\n end\n \n if s.length == 2\n puts ans + s[0] + s[1] \n puts ans + s[1] + s[0]\n return\n end\n\n (0..s.size-1).each do |l|\n new = s.chars.rotate(l).join('')\n element = new[0] \n rest = new[1..new.size-1]\n perm_recur(ans + element, rest)\n end\nend",
"def permutation(string)\n return [string] if string.size < 2\n char = string[0]\n perms = permutation(string[1..-1])\n result = []\n perms.each do |perm|\n result << char + perm\n (1..perm.length-1).each do |i|\n result << perm[0..i-1] + char + perm[i..-1]\n end\n result << perm + char\n end\n result.uniq\nend",
"def nth_permutation_of( to_permute, desired_permutation )\n if to_permute.length == 1\n to_permute\n else\n first_char = to_permute.delete_at( (desired_permutation - 1) / (to_permute.length - 1).factorial )\n [ first_char, *nth_permutation_of( to_permute, ((desired_permutation) % to_permute.length.factorial) ) ]\n end\nend",
"def prmutation(num)\n factrl(num)\nend",
"def permutations(sequence)\n return sequence if sequence.empty?\n ch = sequence.delete_at(0)\n underlying = Set.new([ch])\n sequence.each do |ch|\n new_set = Set.new\n underlying.each do |permutation|\n (0..permutation.length).each do |idx|\n new_set.add(permutation.dup.insert(idx, ch))\n end\n end\n underlying = new_set\n end\n underlying.each\n end",
"def permutation(numbers,i)\n temp = numbers[i] #la variable temp prend la valeur de l'index courant\n numbers[i] = numbers[i+1] #l'index courant prend la valeur de l'index suivant\n numbers[i+1] = temp #l'index suivant prend la valeur de la variable temp\n return true #la fonction retourne vrai\nend",
"def permutation_threshold\n available_letters_permutations = ('A'..'Z').to_a.size**2\n available_numbers_permutations = (0..9).size**3\n available_letters_permutations * available_numbers_permutations\n end",
"def permutations(string)\n perms = []\n combos = string.split('').permutation.to_a.map { |combo| combo.join('') }\n combos.each { |combo| perms << combo if !perms.include?(combo) }\n perms\nend",
"def permutations(array)\n return [array] if array.length <= 1\n \n \n # Similar to the subsets problem, we observe that to get the permutations\n # of [1, 2, 3] we can look at the permutations of [1, 2] which are\n # [1, 2] and [2, 1] and add the last element to every possible index getting\n # [3, 1, 2], [1, 3, 2], [1, 2, 3], [3, 2, 1], [2, 3, 1]\n \n # pop off the last element\n first = array.shift\n # make the recursive call\n perms = permutations(array)\n # we will need an array to store all our different permutations\n total_permutations = []\n \n \n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm[0...i] + [first] + perm[i..-1]\n end\n end\n total_permutations\nend",
"def switch\n #switch = min_switch\n #p switch.sort\n #switch.sort.take(@size / 2)\n solutions = []\n 1.upto(@products.size) do |min_prod|\n found = false\n @products.combination(min_prod).each do |comb|\n products_copy, guesses_copy = @products.dup, @guessed_order.dup\n products_copy.delete_values(*comb)\n guesses_copy.delete_values(*comb)\n if products_copy == guesses_copy\n found ||= true\n solutions << comb.sort\n end\n end\n return solutions.sort[0] if found\n end\n end",
"def get_signed_permutations(n)\r\n numbers = (-n..n).to_a\r\n numbers.delete(0)\r\n perms = numbers.permutation(n).to_a\r\n perms = perms.select{|item| item.map{|subitem|subitem.abs()}.uniq.length == item.length}\r\n return perms.uniq\r\nend",
"def unclean_find_permutations str\n # ArrayList<String> \n permutations = []\n permutations << \"\"\n\n# char [] \n strArray = str.chars\n\n# for (char c :\n strArray.each do |c|\n\n # ArrayList<String>\n tempList = []\n\n # for (String s :\n permutations.each do |s|\n # {\n for i in 0..s.length\n tempList << s[0...i] + c + s[i..s.length]\n\n # tempList << s+c\n end\n\n permutations = tempList\n # }\n end\n end\n\n # permutations.uniq\n permutations\nend",
"def permutations(arr)\n return arr if arr.length <= 1\n perm = [arr]\n sub_perm = permutations(arr[1..-1])\n curr_el = arr[0]\n p sub_perm\n p \" sub_perm #{sub_perm} \"\n if sub_perm.length > 1\n\n sub_perm.each do |subArr|\n temp = []\n (0...subArr.length).each do |i|\n temp = subArr[0..i] + [curr_el] + subArr[i + 1..-1]\n end\n perm << temp\n end\n end\n # puts \" sub_perm #{sub_perm} \"\n # sub_perm.each do |subArr|\n # subArr << curr_el\n # perm << subArr\n # end\n # sub_perm << curr_el\n # perm << sub_perm\nend",
"def naive_algorithm(arr)\n\tproduct = 0\n\tarr.each do |i|\n\t arr.each do |j|\n\t \tp = arr[i] * arr[j]\n\t \tproduct = p if product < p\n\t end\t\n\tend\t\t\n\tproduct\nend",
"def permutations(array)\n return [array] if array.length <= 1\n\n\n # Similar to the subsets problem, we observe that to get the permutations\n # of [1, 2, 3] we can look at the permutations of [1, 2] which are\n # [1, 2] and [2, 1] and add the last element to every possible index getting\n # [3, 1, 2], [1, 3, 2], [1, 2, 3], [3, 2, 1], [2, 3, 1]\n\n # pop off the last element\n first = array.shift\n # make the recursive call\n perms = permutations(array)\n # we will need an array to store all our different permutations\n total_permutations = []\n\n\n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm[0...i] + [first] + perm[i..-1]\n end\n end\n total_permutations\nend",
"def permutations(string)\n string.chars.permutation.to_a.map(&:join).uniq\nend",
"def problem_60a\n num_cut = 5\n# simple\n pairs = {}\n seen_primes = []\n num_primes = 0\n last = start = Time.now\n Primes.each do |p|\n next if p == 2\n b = p.to_s\n seen_primes.each_index do |sp_i|\n sp = seen_primes[sp_i]\n a = sp.to_s\n ai,bi = a.to_i,b.to_i\n ab = (a + b).to_i\n ba = (b + a).to_i\n\n if ba.prime? && ab.prime?\n # We have a pair that works both ways so add the peer to each prime\n pairs[ai] = aa = ((pairs[ai] || []) << bi).uniq\n pairs[bi] = bb = ((pairs[bi] || []) << ai).uniq\n next unless pairs[bi].length >= num_cut - 1 # bi is biggest of pair\n\n check = ([ai] + aa) & ([bi] + bb)\n if check.length >= num_cut\n puts \"Try #{check.inspect}\"\n perm = check.permutation(2).to_a\n new = perm.select do |x,y|\n (x.to_s + y.to_s).to_i.prime? && (x.to_s + y.to_s).to_i.prime?\n end\n if new.length == perm.length\n n = new.flatten.uniq\n sum = n.reduce(&:+)\n puts \"#{n.inspect} *** #{sum}\"\n return sum\n end\n end\n end\n end\n seen_primes << p\n end\n nil\nend",
"def permutations(string)\n string.chars.permutation(string.length).map(&:join).uniq\nend",
"def test_permute_valid\n word = ['abc']\n exp = ['abc','acb','bca','cab','cba','bac'].sort\n assert_equal exp, @grapher.permute(word).sort\n end",
"def permutations(array)\n return [array] if array.length <= 1\n\n # Similar to the subsets problem, we observe that to get the permutations of \n # [1, 2, 3] we can look at the permutations of [1, 2] which are [1, 2] and \n # [2, 1] and add the last element to every possible index getting [3, 1, 2], \n # [1, 3, 2], [1, 2, 3], [3, 2, 1], [2, 3, 1], [2, 1, 3]\n\n # pop off the last element\n first = array.shift\n\n # make the recursive call\n perms = permutations(array)\n\n # we will need an array to store all our different permutations\n total_permutations = []\n\n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).to_a.each do |i|\n total_permutations << perm[0...i] + [first] + perm[i..-1]\n end\n end\n\n total_permutations\nend",
"def permute(arr)\n return [array] if array.length <= 1\n\n first = array.shift\n perms = permute(array)\n total_permutations = []\n \n \n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm[0...i] + [first] + perm[i..-1]\n end\n end\n total_permutations\nend",
"def permutations\n puts \"Input please?\"\n answer1 = gets.chomp\n\n puts \"Another one!\"\n answer2 = gets.chomp\n\n puts \"Another one!\"\n answer3 = gets.chomp\n\n total = answer1 + answer2 + answer3\n (0...total.length).each do |x|\n (0...total.length).each do |y|\n (0...total.length).each do |z|\n print total[x]+total[y]+total[z]\n puts \"\"\n end\n end\n end\nend",
"def permutations(array)\n return array if array.length <= 1\n\n if array.length == 2\n return [array, array.reverse]\n end\n\n final_array = []\n\n array.length.times do\n set = array.take(array.length - 1)\n\n final_array += permutations(set).map do |item|\n item += [array.last]\n end\n\n next_item = array.shift\n array.push(next_item)\n end\n\n final_array\nend",
"def permutations(string)\n string.chars.permutation(string.length).to_a.map { |arr| arr.join }.uniq\nend",
"def permutations(str)\n permutation(str.chars)\nend",
"def p1\n perm \" 1 2 4 3 4 3 5 6 \"\nend",
"def permutation_step(num)\r\n perms = num.to_s.chars.map {|x| x.to_i}.permutation.to_a.map do |perm_arr|\r\n perm_arr.map {|x| x.to_s}.join.to_i\r\n end\r\n\r\n perms.select {|n| n > num}.min.nil? ? -1 : perms.select {|n| n > num}.min\r\nend",
"def cp1\n\tnumPerm = []\n\tpermPrime = true\n\ttotal = 0;\n\t100.upto(200) do |x|\n\t\t#if (x % 1000 == 0) then p x end\n\t\tif(isPrime(x) == false) then next end\n\t\tnumPer = splitNumberifOdd(x)\n\t\tif(numPer == false) then next end\n\t\tnumPer = numPer.permutation().to_a\n\t\tnumPer = numPer.map {|y| y.join.to_i}\n\t\tpermPrime = true\n\t\tnumPer.each do |perm|\n\t\t\t#printf \"checking %s \\n\", perm\n\t\t\tif(isPrime(perm) == false) then permPrime = false; printf \"x %d- failed %d \\n\",x, perm; break end\n\t\tend\n\t\t#p permPrime\n\t\tif (permPrime == true) then total = total + 1; p x end\n\tend\n\ttotal + 13\nend",
"def permutations(paths)\n permutations = paths.map(&:downcase).map(&:all_permutations)\n permutations = permutations.flatten.sort_by(&:length).reverse\n permutations\nend",
"def solution(x, a)\n perm = (1..x).to_a\n return -1 unless (perm - a).empty?\n a.index(a.uniq.last)\nend",
"def permutation(string)\n return [string] if string.size < 2\n char = string[0]\n total_perms = []\n perms = permutation(string[1..-1])\n\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_perms << perm[0...i] + char + perm[i..-1]\n end\n end\n\n total_perms\nend",
"def solve( n = 16 )\n max = 0\n \n (1..10).each do |a|\n (1..10).each do |b|\n next if b == a\n (1..10).each do |c|\n next if c == b || c == a\n (1..10).each do |d|\n next if d == c || d == b || d == a\n (1..10).each do |e|\n next if e == d || e == c || e == b || e == a\n\n rotate = 3*[a, b, c, d, e].each_with_index.min[1]\n (1..10).each do |f|\n next if f == e || f == d || f == c || f == b || f == a\n (1..10).each do |g|\n next if g == f || g == e || g == d || g == c || g == b || g == a\n \n t = a + f + g\n (1..10).each do |h|\n next if h == g || h == f || h == e || h == d || h == c || h == b || h == a\n next unless t == b + g + h\n\n (1..10).each do |i|\n next if i == h || i == g || i == f || i == e || i == d || i == c || i == b || i == a\n next unless t == c + h + i\n\n (1..10).each do |j|\n next if j == i || j == h || j == g || j == f || j == e || j == d || j == c || j == b || j == a\n next unless t == d + i + j && t == e + j + f\n\n s = [a, f, g, b, g, h, c, h, i, d, i, j, e, j, f]\n rotate.times {s.push s.shift}\n\n s = s.join\n next if n != s.length\n\n max = [max, s.to_i].max\n end\n end\n end\n end\n end\n end\n end\n end\n end\n end\n\n max\n end",
"def lexicographic_permutations\n a=Array.new\n (1..self.length.factorial).each { |i| a << self.lexicographic_permutation(i) }\n a\n end",
"def permutations(n,k)\n binding.pry\n return 1 if k==0\n return n if k==1\n return factorial(n) if k==n\n (((n-k+1)..n).inject(1) {|ac,v| ac * v})\n #factorial(x).quo(factorial(x-n))\n end",
"def permutations(string)\n permute(string, 0, string.length)\nend",
"def getPermutations(s)\n result = []\n for i in 0..2\n substring = s[1..2]\n result.push(s[0] + substring)\n result.push(s[0] + substring.reverse)\n s = rotateChar(s)\n end\n\n return result\nend",
"def lets_premute_even_more(array)\n i = 0\n output_array = []\n\n while i < array.length\n first_letter = array[i]\n j = 0\n while j < array.length\n if i == j\n else\n second_letter = array[j]\n combo = first_letter + second_letter\n output_array << combo\n end\n j += 1\n end\n i += 1\n end\n return output_array\nend",
"def permutations(array)\n debugger\n return [array] if array.length <= 1\n # pop off the last element\n first = array.shift\n # make the recursive call\n perms = permutations(array)\n # we will need an array to store all our different permutations\n total_permutations = []\n\n\n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm[0 ... i] + [first] + perm[i .. -1]\n end\n end\n total_permutations\nend",
"def is_palindrome_permutation()\n puts \"not implemented\"\nend",
"def test_permutations\n find = Finder.new\n arr = [\"CAKE\", \"ANT\", \"TRY\"]\n word_list = [\"CAKE\", \"NAT\"]\n result = find.permutations(arr, word_list)\n expected = [\"CAKE\", \"NAT\"]\n assert_equal expected, result\n end",
"def possibilities(words)\n words.each do |word, translations|\n sorted = translations.sort\n words[word] = sorted.each_index.map {|i|\n sorted.combination(i+1).to_a\n }.flatten(1).sort\n end\nend",
"def get_partial_permutations(n,k)\r\n result = 1\r\n while (k > 0)\r\n result *= n\r\n n -= 1\r\n k -= 1\r\n end\r\n return (result % 1000000)\r\nend",
"def add_permutations()\n\t \n\t #get the first permutation\n\t current_index = 0\n\t first_permutation = ''\n\t # create the first permutation\n\t while current_index < @regex_map.length\n\t current_q = 0\n\t while current_q < @regex_map[current_index][:quantifier]\n\t first_permutation << @regex_map[current_index][:character_set][0]\n\t\t current_q += 1\n\t\tend\n\t current_index += 1\n\t end\n\t \n\t @codes << first_permutation\n\n\t #get the last permutation\n\t current_index = 0\n\t final_permutation = ''\n\t #create the last permutation\n while current_index < @regex_map.length\n\t current_q = 0\n\t\twhile current_q < @regex_map[current_index][:quantifier]\n\t\t final_permutation << @regex_map[current_index][:character_set][-1]\n\t\t current_q += 1\n\t\tend\n\t\tcurrent_index += 1\n\t end\n\t \n\t #while the current permutation is not equal to the final permutation, increment\n\t current_permutation = String.new(@codes[0])\n\t puts current_permutation \n\t \n\t while current_permutation != final_permutation\n\t\tcurrent_permutation = increment(current_permutation)\n\t\t@codes << String.new(current_permutation)\n\t end\n\t \n\t p @codes\n \nend",
"def problem_106\n a = [1,2,3,4]\n a = [1,2,3,4,5,6,7]\n a = [1,2,3,4,5,6,7,8,9,10,11,12] \n \n num = 0\n seen = {}\n # Don't do length of 1, they are ordered\n # Because they are size ordered, and 2 smalls are bigger than a large\n 2.upto(a.length/2) do |n|\n puts \"n = #{n}\"\n a.combination(n) do |set_a|\n b = a - set_a\n break if b.length < n\n b.combination(n) do |set_b|\n key = [set_a,set_b].sort\n next if seen[key]\n seen[key] = true\n index = 0\n state = 0\n 0.upto(set_a.length-1) do |i|\n break unless set_b[i] && set_a[i]\n if set_a[i] < set_b[i]\n state -= 1\n else\n state += 1\n end\n end\n\n# print \"#{set_a.inspect} #{set_b.inspect} #{state}\"\n if state.abs <= (set_a.length - 2) ||\n (state < 0 && set_a.last > set_b.last) ||\n (state > 0 && set_a.first < set_b.first)\n# puts \" good\"\n num += 1\n else\n# puts \"\"\n end\n end\n end\n end\n num\nend",
"def josephus(items,k)\n killed = []\n # loop the following two until items == []\n until items.length == 0 do\n items = items.rotate(k)\n killed << items.pop\n end\n killed\nend",
"def perm(arr)\n return [arr] if arr.length <= 1\n result = []\n arr.each_index do |idx|\n temp = perm(arr[0...idx] + arr[idx+1..-1])\n subset = temp.map { |sub| [arr[idx]] + sub }\n result += subset\n end\n\n result\n\n\n\n\n # return [arr] if arr.length <= 1\n # result = []\n #\n # arr.each_index do |idx|\n #\n # other_perm = perm(arr[0...idx] + arr[idx+1..-1])\n # row = other_perm.map { |subarr| [arr[idx]] + subarr }\n # result += row\n # end\n #\n # result\nend",
"def win_possibilities(piece)\n\t\t[ [ [piece[0],piece[1]],[piece[0]+1,piece[1]],[piece[0]+2,piece[1]],[piece[0]+3,piece[1]] ],\n\t\t[ [piece[0]-1,piece[1]],[piece[0],piece[1]],[piece[0]+1,piece[1]],[piece[0]+2,piece[1]] ],\n\t\t[ [piece[0]-2,piece[1]],[piece[0]-1,piece[1]],[piece[0],piece[1]],[piece[0]+1,piece[1]] ],\n\t\t[ [piece[0]-3,piece[1]],[piece[0]-2,piece[1]],[piece[0]-1,piece[1]],[piece[0],piece[1]] ],\n\t\t[ [piece[0],piece[1]],[piece[0],piece[1]+1],[piece[0],piece[1]+2],[piece[0],piece[1]+3] ],\n\t\t[ [piece[0],piece[1]-1],[piece[0],piece[1]],[piece[0],piece[1]+1],[piece[0],piece[1]+2] ],\n\t\t[ [piece[0],piece[1]-2],[piece[0],piece[1]-1],[piece[0],piece[1]],[piece[0],piece[1]+1] ],\n\t\t[ [piece[0],piece[1]-3],[piece[0],piece[1]-2],[piece[0],piece[1]-1],[piece[0],piece[1]] ],\n\t\t[ [piece[0],piece[1]],[piece[0]+1,piece[1]+1],[piece[0]+2,piece[1]+2],[piece[0]+3,piece[1]+3] ],\n\t\t[ [piece[0]-1,piece[1]-1],[piece[0],piece[1]],[piece[0]+1,piece[1]+1],[piece[0]+2,piece[1]+2] ],\n\t\t[ [piece[0]-2,piece[1]-2],[piece[0]-1,piece[1]-1],[piece[0],piece[1]],[piece[0]+1,piece[1]+1] ],\n\t\t[ [piece[0]-3,piece[1]-3],[piece[0]-2,piece[1]-2],[piece[0]-1,piece[1]-1],[piece[0],piece[1]] ],\n\t\t[ [piece[0],piece[1]],[piece[0]+1,piece[1]-1],[piece[0]+2,piece[1]-2],[piece[0]+3,piece[1]-3] ],\n\t\t[ [piece[0]-1,piece[1]+1],[piece[0],piece[1]],[piece[0]+1,piece[1]-1],[piece[0]+2,piece[1]-2] ],\n\t\t[ [piece[0]-2,piece[1]+2],[piece[0]-1,piece[1]+1],[piece[0],piece[1]],[piece[0]+1,piece[1]-1] ],\n\t\t[ [piece[0]-3,piece[1]+3],[piece[0]-2,piece[1]+2],[piece[0]-1,piece[1]+1],[piece[0],piece[1]] ] ]\n\tend",
"def permutations(n,k)\n return 1 if k==0\n return n if k==1\n return factorial(n) if k==n\n (((n-k+1)..n).inject(1) {|ac,v| ac * v})\n #factorial(x).quo(factorial(x-n))\n end",
"def permutations(arr)\n return [[]] if arr.empty? \n \n #last element arr\n #putting before and after every index of a perm\n #permuatations(arr[0..-2])\n #last = arr[-1]\n \n last = arr[-1]\n perms = permutations(arr[0..-2])\n result = [] \n perms.each do |sub_arr| #[a,b]\n current_perms = []\n (0..sub_arr.length).each do |i|\n dup = sub_arr.dup \n current_perms << dup.insert(i,last) # dup = ['b','a']\n end \n result += current_perms\n end \n\n result \nend",
"def permutations(arr)\n arr = arr.dup\n return [arr] if arr.length == 1\n\n last_el = arr.pop\n base = permutations(arr) # [[1]]\n\n results = []\n base.each do |perm|\n (perm.length + 1).times do |i|\n result = perm[0...i] + [last_el] + perm[i..-1]\n results << result\n end\n end\n\n results\nend"
] |
[
"0.7508187",
"0.699553",
"0.6897742",
"0.6764146",
"0.6730608",
"0.67267084",
"0.66697866",
"0.65802777",
"0.65519947",
"0.6541124",
"0.6524825",
"0.6521009",
"0.6516781",
"0.6487009",
"0.6468073",
"0.6419668",
"0.64172673",
"0.64172673",
"0.64172673",
"0.64172673",
"0.6404755",
"0.6345628",
"0.6337261",
"0.632316",
"0.6315742",
"0.6304902",
"0.62865806",
"0.62801987",
"0.62702394",
"0.62572163",
"0.6254388",
"0.625262",
"0.6245394",
"0.62433594",
"0.6241642",
"0.6231914",
"0.6210759",
"0.6209642",
"0.6208106",
"0.6205423",
"0.62048876",
"0.6198495",
"0.619054",
"0.6189263",
"0.6183155",
"0.6163785",
"0.61470723",
"0.61435175",
"0.61319834",
"0.61240476",
"0.6120944",
"0.61172706",
"0.6117252",
"0.6117137",
"0.61117303",
"0.610088",
"0.60990006",
"0.6094855",
"0.6084916",
"0.60818106",
"0.60813874",
"0.60792214",
"0.60671526",
"0.60652363",
"0.60629725",
"0.60540265",
"0.6037873",
"0.6036259",
"0.60345036",
"0.60309416",
"0.6028296",
"0.60267204",
"0.6017267",
"0.60161924",
"0.60151094",
"0.6005129",
"0.59980637",
"0.59827375",
"0.5981366",
"0.5979082",
"0.59773886",
"0.59696794",
"0.59612477",
"0.59491",
"0.5941118",
"0.59353137",
"0.592744",
"0.59237486",
"0.59161085",
"0.5913038",
"0.5908806",
"0.59061027",
"0.5902194",
"0.589164",
"0.5886212",
"0.58852863",
"0.588422",
"0.58787125",
"0.5859412",
"0.58587855",
"0.5853396"
] |
0.0
|
-1
|
codewars kata: format a string of names
|
def list(names)
array = names.map{|n| n.values}
if array.size > 2
array[0..-2].join(", ") + " & #{array[-1][0]}"
else
array.join(" & ")
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def format_name(str)\n\tnames = str.split(\" \")\n\tformatted = \"\"\n\n\tnames.each do |name|\n\t\tformatted += name[0].upcase + name[1..-1].downcase + \" \"\n\tend\n\n\treturn formatted\n\n\t# name.each do |word|\n\t# \tword.each_char.with_index do |char, idx|\n\t# \t\tif idx == 0\n\t# \t\t\tupLetter = char.upcase\n\t# \t\t\tformatted << upLetter\n\t# \t\telse\n\t# \t\t\tdownLetter = char.downcase\n\t# \t\t\tformatted << downLetter\t\n\t# \t\tend\n\t# \tend\n\t# end\n\t# return formatted.join(\"\")\n\t# print formatted\nend",
"def format_name(str)\r\n \tformat = []\r\n\twords = str.split(\" \")\r\n \twords.each do |word|\r\n word = word[0].upcase + word[1..-1].downcase\r\n format << word\r\n end\r\n \treturn format.join(\" \")\r\nend",
"def format_name(str)\n\tnames = str.split(\" \")\n proper = []\n names.each do |name|\n proper << name[0].upcase + name[1..-1].downcase\n end\n return proper.join(\" \")\nend",
"def format_name(str)\n str.split.map{|val| val[0].upcase + val[1..-1].downcase}.join(\" \")\n end",
"def format_name(name)\n name.split(' ').join('_')\n end",
"def format_name(name)\n name.split(' ').join('_')\n end",
"def format_name(str)\n\tnames = str.split(\" \")\n \tnames.each_with_index do |name, i|\n names[i] = name[0].upcase + name[1..-1].downcase\n end\n \treturn names.join(\" \")\nend",
"def format_name(str)\n names = str.split(\" \")\n formatted_names = []\n \n names.each do |name|\n formatted_names << name[0].upcase + name[1..-1].downcase\n end\n\n return formatted_names.join(\" \")\nend",
"def format_name(str)\n parts = str.split(\" \")\n print parts\nend",
"def format_name(name)\n names = name.split(\" \")\n formatted_names = []\n names.each do |singleName|\n singleName = singleName.downcase\n singleName[0] = singleName[0].upcase\n formatted_names << singleName\n end\n return formatted_names.join(\" \")\nend",
"def format_name(str)\n parts = str.split(\" \")\n new_parts = []\n\n parts.each do |part|\n new_parts << part[0].upcase + part[1..-1].downcase\n end \n\n return new_parts\nend",
"def format_name(first, last)\nif first.length<1 || last.length<1\n\tnil\nelse\n first = first.split.join\n last = last.split.join\n str = (first[0]+last).downcase.gsub(/[^0-9a-z]/i, '')\nend\nend",
"def format_name(name)\n name[2..-2].humanize.downcase.gsub ' | ', ': '\n end",
"def format_name(str)\n \n formatted_name = []\n \n str.split.each do |word|\n formatted_word = word.downcase\n formatted_word[0] = formatted_word[0].upcase\n formatted_name.push(formatted_word)\n end\n return formatted_name.join(\" \")\nend",
"def format_name(name)\n name.split.map(&:capitalize)\n .join(' ')\nend",
"def format_name(str)\n norm_arr = []\n str_arr = str.split(\" \")\n\n str_arr.each do |word|\n word = word.downcase\n word[0] = word[0].upcase\n norm_arr << word\n end\n\n return norm_arr.join(\" \")\nend",
"def format_name(str)\n str = str.downcase\n name = []\n str.split(\" \").each do |ele| \n ele[0] = ele[0].upcase\n name << ele\n end\n return name.join(\" \")\nend",
"def format_name(str)\n parts = str.split(\" \")\n new_parts = []\n\n parts.each do |part|\n new_parts << part[0].upcase + part[1..-1].downcase\n end \n\n new_name = new_parts.join(\" \")\n return new_name\nend",
"def format_name(first, last)\n return nil if first.empty? || last.empty?\n first.gsub! (/[^a-z]/i, \"\")\n last.gsub! (/[^a-z]/i, \"\")\n ((first.split(\" \").join[0]<<last).split(\" \").join.downcase)\n\nend",
"def formate_name(name)\n # name.split.map{|p| p.split(\"-\").map{|m| m.split(\"'\").map{|n| (n.length > 1 ? n.capitalize : n) }.join(\"'\")}.join(\"-\")}.join(\" \")\n name.gsub(/[^\\s\\-']{02,}/, &:capitalize)\n\n end",
"def formate_name(name)\n # name.split.map{|p| p.split(\"-\").map{|m| m.split(\"'\").map{|n| (n.length > 1 ? n.capitalize : n) }.join(\"'\")}.join(\"-\")}.join(\" \")\n name.gsub(/[^\\s\\-']{02,}/, &:capitalize)\n\n end",
"def format_name(str, deprecated = false)\n boldness = deprecated ? \"\" : \"**\"\n words = str.split\n if words.length.even?\n genus = words.shift\n words[0] = genus + \" \" + words[0]\n end\n i = words.length - 1\n while i >= 0\n words[i] = \"#{boldness}__#{words[i]}__#{boldness}\"\n i -= 2\n end\n\n words.join(\" \")\n end",
"def format_name(str)\n parts = str.split(\" \")\n new_parts = []\n \n parts.each do |part|\n new_parts << part[0].upcase + part[1..-1].downcase\n end\n \n return new_parts.join(\" \")\n end",
"def format_name(first, last)\n\treturn nil if first.empty? || last.empty?\n (first.gsub(/[\\W0-9_]/, \"\")[0] + last.gsub(/[\\W0-9_]/, \"\")).downcase\nend",
"def format_name(str)\n names = str.split (\" \")\n new_name = []\n\n names.each do |name|\n new_name << name[0].upcase + name[1..-1].downcase\n # 2nd character to end (-1 last character of string)\n end\n\n return new_name.join(\" \")\nend",
"def format_name(str)\n parts = str.split(' ')\n new_parts = []\n\n parts.each do |part|\n new_parts << part[0].upcase + part[1..-1].downcase\n end\n\n return new_parts.join(' ')\nend",
"def codeName (str)\n\tstr = str.to_s.downcase.split(' ')\n\tk = str[0]\n\tstr[0] = str[1]\n\tstr[1] = k\n\tvowels = \"aeiou\"\n\tconsonants = \"bcdfghjklmnpqrstvwxyz\"\n\t\n\tlastName = str[0].chars\n\tfirstName = str[1].chars\n\t\n\tfor i in 0..(lastName.length-1)\n\t\tif lastName[i] == \"a\" || lastName[i] == \"e\" || lastName[i] == \"i\" || lastName[i] == \"o\" || lastName[i] == \"u\"\n\t\t\tlastName[i] = vowels[vowels.index(lastName[i])+1]\n\t\telse\n\t\t\tlastName[i] = consonants[consonants.index(lastName[i])+1]\n\t\tend\n\tend\n\t\n\tfor i in 0..(firstName.length-1)\n\t\tif firstName[i] == \"a\" || firstName[i] == \"e\" || firstName[i] == \"i\" || firstName[i] == \"o\" || firstName[i] == \"u\"\n\t\t\tfirstName[i] = vowels[vowels.index(firstName[i])+1]\n\t\telse\n\t\t\tfirstName[i] = consonants[consonants.index(firstName[i])+1]\n\t\tend\n\tend\n\tstr[0] = lastName.join('').capitalize\n\tstr[1] = firstName.join('').capitalize\n\tstr.join(' ')\n\t\nend",
"def format_name(first, last)\n(First[0]+last).downcase\nend",
"def format_name\n [@comment[:first], @comment[:last]].join(' ')\n end",
"def names\n nameparts = name.split(' ')\n firstinitial = nameparts.second ? \"#{firstname[0, 1]}.\" : ''\n secondname = nameparts.third ? nameparts.second : ''\n secondinitial = nameparts.third ? \"#{secondname[0, 1]}.\" : ''\n middlenames = nameparts.length > 2 ? nameparts.from(1).to(nameparts.from(1).length - 2) : []\n middleinitials = ''\n middlenames.each_with_index do |name, index|\n middleinitials << ' ' if index.positive?\n middleinitials << \"#{name.to_s[0, 1]}.\"\n end\n lastname = nameparts.last\n names = []\n names << full_name # Joseph Aloysius Hansom\n names << \"#{title} #{name}\" if titled? # Sir Joseph Aloysius Hansom\n names += aka # Boz, Charlie Cheese, and Crackers\n names << \"#{title} #{firstinitial} #{middleinitials} #{lastname}\" if titled? && nameparts.length > 2\n names << \"#{title} #{firstinitial} #{lastname}\" if titled? && nameparts.length > 1\n names << name if name != full_name # Joseph Aloysius Hansom\n if name.include? ',' # George Inn, Barcombe\n names << name.split(/,/).first\n return names\n end\n names << \"#{title} #{name.split(/ of /).first}\" if name.include?(' of ') && titled? # King Charles II [of England]\n names << name.split(/ of /).first if name.include?(' of ') # [King] Charles II [of England]\n names << \"#{firstname} #{middleinitials} #{lastname}\" if nameparts.length > 2 # Joseph A[loysius]. R[obert]. Hansom\n names << \"#{firstinitial} #{middleinitials} #{lastname}\" if nameparts.length > 2 # J. A. R. Hansom\n names << \"#{firstname} #{nameparts.second} #{lastname}\" if nameparts.length > 2 # Joseph Aaron Hansom\n names << \"#{firstname} #{secondinitial} #{lastname}\" if nameparts.length > 2 # Joseph A. Hansom\n names << \"#{firstinitial} #{secondname} #{lastname}\" if nameparts.length > 2 # J. Aaron Hansom\n names << \"#{title} #{firstname} #{lastname}\" if nameparts.length > 2 && titled? # Sir Joseph Hansom\n names << \"#{firstname} #{lastname}\" if nameparts.length > 2 # Joseph Hansom\n names << \"#{firstinitial} #{lastname}\" if nameparts.length > 1 # J. Hansom\n names << \"#{title} #{lastname}\" if titled? # Lord Carlisle\n names << \"#{title} #{firstname}\" if titled? # Sir William\n names << firstname if nameparts.length > 1 # Charles\n names << lastname if nameparts.length > 1 # Kitchener\n names.uniq\n end",
"def format_name(str)\n\twords = str.split(\" \")\n \tnewWord = \"\"\n \n \twords.each do |word|\n newWord += word[0].upcase + word[1..-1].downcase + \" \"\n end\n return newWord\nend",
"def fake_name(name)\n name = name.split.rotate\n name.map! do |n|\n n.downcase!\n vowels = 'aeiou'\n vowels_shifted = vowels.split('').rotate.join\n consonants = 'bcdfghjklmnpqrstvwxyz'\n consonants_shifted = consonants.split('').rotate.join\n\n n.tr!(vowels, vowels_shifted)\n n.tr!(consonants, consonants_shifted)\n\n n = n.split('')\n n[0] = n[0].upcase\n n = n.join\n end\n name = name.join(' ')\nend",
"def format_name(str)\n parts = str.split(\" \") # A space separates each word\n new_parts = []\n\n parts.each do |part| # Iterate over each part using .each. Note: each part is a single element from the array, which is a string.\n\n # We need to target the first element of the string.\n new_parts << part[0].upcase + part[1..-1].downcase\n # give you upper case version of index 0. + concatenation\n # when you slice a string, you use square brackets, but you don't put a single number. You'll use a range and go all the way to the end, which is index -1 (note: -2 is the second to last element of a string)\n end\n\n return new_name = new_parts.join(\" \") # first we split on a space, now we join on a space\nend",
"def createlabelname(name)\t\t\n\n\t\tsplitname=name.split(\"/\")\n\t\tfor i in 1..splitname.length do\n# If the name is within brackets, then actual name of the person is unknown\n\t\t\tif(splitname[i-1] =~ /^\\(.+\\)/) \n\t\t\t\tsplitname[i-1] = \"(....)\\\\n\" \n\t\t\tend\n\t\tend\t\n\t\t\t\n\t\tname=splitname.join(\"\")\n\n# Initialize long name\n\t\tsplitname=name.split(\" \")\n\t\tfor i in 1..splitname.length do\n# If there are more than 2 names, and this is not 1st name or last name, and it is not already initialized, and this is not 2nd name while the first name is a title such as \"Ompu\"\n\t\t\tif(splitname.length>2 && i != 1 && i != splitname.length && !(i==2 && (splitname[0].strip==\"Ompu\" || splitname[0].strip==\"O.\" || splitname[0].strip==\"Amani\"|| splitname[0].strip==\"A.\" || splitname[0].strip==\"Aman\" || splitname[0].strip==\"Datu\" || splitname[0].strip==\"Nai\" || splitname[0].strip==\"Apa\" || splitname[0].strip==\"Pu\" || splitname[0].strip==\"Na\" || splitname[0].strip==\"Boru\" || splitname[0].strip==\"Apa\" || splitname[0].strip==\"Raja\")) )\n\t\t\t\t\tsplitname[i-1] = splitname[i-1][0,1].capitalize + \".\"\n\t\t\tend\t\n\t\tend\n\n# Put each name in new line to shorthen it\n#\t\tname.gsub!(\" \",\"\\n\")\n\n\t\tfor i in 1..splitname.length do\n# If this name is not an initial (ended by \".\"), or if it is an initial but before a non-initial\n\t\t\tif(splitname[i-1] && splitname[i])\n\t\t\t\tif(splitname[i-1][-1,1] != \".\" || (splitname[i-1][-1,1] == \".\" && splitname[i][-1,1] != \".\"))\n#\t\t\t\t\tif $orientation==\"horizontal\" then splitname[i-1]=splitname[i-1] + \" \"\n#\t\t\t\t\telse splitname[i-1]=splitname[i-1] + \"\\\\n\" end\n\t\t\t\t\tsplitname[i-1]=splitname[i-1] + \"\\\\n\"\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tname=splitname.join(\"\")\n\n\t\tlabel= name\t\n\t\treturn label\n\tend",
"def format_sort_name(name, author)\n str = format_name(name, :deprecated).\n sub(/^_+/, \"\").\n gsub(/_+/, \" \"). # put genus at the top\n sub(/ \"(sp[-.])/, ' {\\1'). # put \"sp-1\" at end\n gsub(/\"([^\"]*\")/, '\\1'). # collate \"baccata\" with baccata\n sub(\" subg. \", \" {1subg. \").\n sub(\" sect. \", \" {2sect. \").\n sub(\" subsect. \", \" {3subsect. \").\n sub(\" stirps \", \" {4stirps \").\n sub(\" subsp. \", \" {5subsp. \").\n sub(\" var. \", \" {6var. \").\n sub(\" f. \", \" {7f. \").\n strip.\n sub(/(^\\S+)aceae$/, '\\1!7').\n sub(/(^\\S+)ineae$/, '\\1!6').\n sub(/(^\\S+)ales$/, '\\1!5').\n sub(/(^\\S+?)o?mycetidae$/, '\\1!4').\n sub(/(^\\S+?)o?mycetes$/, '\\1!3').\n sub(/(^\\S+?)o?mycotina$/, '\\1!2').\n sub(/(^\\S+?)o?mycota$/, '\\1!1')\n\n # put autonyms at the top\n 1 while str.sub!(/(^| )([A-Za-z-]+) (.*) \\2( |$)/, '\\1\\2 \\3 !\\2\\4')\n\n if author.present?\n str += \" \" + author.\n gsub(/\"([^\"]*\")/, '\\1'). # collate \"baccata\" with baccata\n gsub(/[Đđ]/, \"d\"). # mysql isn't collating these right\n gsub(/[Øø]/, \"O\").\n strip\n end\n str\n end",
"def abbrev_name(name)\r\n # name.split.map { |s| s[0]}.join('.').upcase\r\n # name.upcase.split.map(&:chr).join\".\"\r\n \r\n newname = name.split(' ')\r\n newname[0][0].capitalize + '.' + newname[1][0].capitalize\r\nend",
"def format_name(first, last)\n if first == \"\" || last == \"\"\n return nil\n end\n new_first = first.gsub(/\\W+/,\"\")\n new_last = last.gsub(/\\W+/,\"\")\n username = new_first[0] + new_last\n username = username.downcase.gsub(/\\d/,\"\")\n\nend",
"def format_name(first, last)\n\tf_return = \"\"\n\tl_return = \"\"\n\tif first[0]\n\t\tf_return = first.gsub(\" \", \"\")\n\t\tf_return =f_return.gsub(/[^A-Za-z]/, '')\n\t\tf_return = f_return[0].downcase\n\telse\n\t\tf_return = \"\"\n\tend\n\tif last[0]\n\t\tl_return = last.gsub(\" \", \"\")\n\t\tl_return = l_return.gsub(/[^A-Za-z]/, '')\n\t\tl_return.downcase!\n\telse\n\t\tlast = \"\"\n\tend\n if f_return[0] && l_return[0]\n \treturn f_return+l_return\n else\n \treturn nil\n end\nend",
"def name_pretty\n to_s.underscore.split(\"_\").map(&:capitalize).join(\" \")\n end",
"def format_name(first, last)\n first.gsub!(/\\d|\\W|_/, \"\")\n last.gsub!(/\\d|\\W|_/, \"\")\n if first.empty? || last.empty?\n nil\n else\n first.split(\" \").join.downcase[0] + last.split(\" \").join.downcase\n end\nend",
"def namify\n self.name.split(\" \").map{|x| x.first.capitalize}[0..1].join(\"\")\n end",
"def name_format\n self.name.gsub!(/[^0-9a-z\\-_ ]/i, '_') unless self.name.nil?\n self.name.gsub!(/\\s+/, '-') unless self.name.nil?\n self.name = self.name.downcase unless self.name.nil?\n end",
"def name_format\n self.name.gsub!(/[^0-9a-z\\-_ ]/i, '_') unless self.name.nil?\n self.name.gsub!(/\\s+/, '-') unless self.name.nil?\n self.name = self.name.downcase unless self.name.nil?\n end",
"def get_name_initials(names)\n output = []\n names.each do |name|\n first, last = name.split(\" \")\n output << [first[0], last[0]].join\n end\n output\nend",
"def spyname(real_name)\n spy_array = []\n split_name = real_name.reverse.split('')\n split_name.join.chars\n split_name.map! do|name|\n name.tr!(\"aeiouAEIUO\",\"eiouaEIOUA\")\n name.tr!(\"bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ\",\"cdfghjklmnpqrstvwxyzbCDFGHJKLMNPQRSTVWXYZB\")\n spy_array << name.to_str\nend\n p spy_array.join\nend",
"def translate_name(name)\nreversed_name = name.split(' ').reverse\nnew_first = reversed_name[0].chars.map {|x|\n x.next\n }\nnew_last = reversed_name[1].chars.map {|x|\n x.next\n }\nnew_name = \"#{new_first.join} #{new_last.join}\"\nend",
"def formatted_name(data)\n '' << data[:Title] << ' ' <<\n initials(data[:\"First Names\"]) <<\n data[:Surname]\n end",
"def format_name(first, last)\n if first.length == 0\n p nil\n elsif last.length == 0\n p nil\n else\n first_name = first.delete(\" \")\n last_name = last.delete(\" \")\n first_init = first_name[0]\n name_temp = first_init + last_name\n name_v1 = name_temp.delete(\" \").downcase\n p name_v1\n end\nend",
"def format_name\n name.observation_name\n end",
"def namify(paths)\n first = paths[0]\n rest = paths[1..-1].reduce([]) { |a, e| a << \"[#{e}]\" }.join('')\n \"#{first}#{rest}\"\n end",
"def normalize_name(name, prefixes); end",
"def rearrange(name)\n match = /(\\w+), (\\w+)( \\w+)?/.match(name) # (1)\n\n last_name = match[1]\n first_name = match[2]\n if match[3]\n separator = \"#{match[3][0,2]}. \" # (2)\n else\n separator = ' ' # (3)\n end\n \n \"#{first_name}#{separator}#{last_name}\" # (4)\nend",
"def process_names(agent_name)\r\n agent_name.reverse!\r\n coded_name = []\r\n for\r\n name in agent_name\r\n coded_name << (name.chars.map {|letter| shift_char(letter)}).join(\"\")\r\n end\r\n coded_name.map! {|name| name.capitalize}\r\n return coded_name\r\nend",
"def formatNameForCompare( name ) \n nameArr = formatNameFromString( name )\n\n firstName = nameArr[0]\n if ( firstName.size >= 8 ) then\n firstName = firstName[0-7]\n else\n sizeDiff = 8 - firstName.size\n firstName = firstName + \" \".times(sizeDiff)\n end\n\n middleInitial = nameArr[1][0]\n\n lastName = nameArr[2]\n if( lastName.size >= 8 ) then \n lastName = lastName[0-7]\n else \n sizeDiff = 8 - lastName.size\n lastName = lastName + \" \".times(sizeDiff)\n end\n formatName = [firstName, middleInitial, lastName]\n formatName\n end",
"def format_name(first, last)\n return nil if last.empty? || first.empty?\n first = first.gsub(/[^A-Za-z]/, '')\n last = last.gsub(/[^A-Za-z]/, '')\n (first[0] + last).downcase\nend",
"def format_name(first, last)\n return nil if last.empty? || first.empty?\n first = first.gsub(/[^A-Za-z]/, '')\n last = last.gsub(/[^A-Za-z]/, '')\n (first[0] + last).downcase\nend",
"def spy_name_map(str)\n# reverse first and last name\n\t# str = str.downcase\n\tsplit_name = str.split(' ')\n\treverse_name = split_name.reverse\n\tspy_name = reverse_name.join(' ')\n\tstored_names = []\n\nletters = spy_name.split('')\ni = 0\n\n\tletters.map! { |letter| letter.next }\n\tspy_final = letters.join('')\n# if spy_final.include? '!'\nspy_final = spy_final.gsub!('!', ' ')\n\tstored_names << spy_final\n\tp spy_final\nend",
"def name_parts(namething, count)\n parts = namething.split(\" \")\n first_name_count = parts.count - count\n return nil if count < 1\n { given: parts.first(first_name_count).join(\" \"), family: parts.last(count).join(\" \") }\n end",
"def format_name(name)\n properly_formatted_name = name.split(\" \").map { |n| n.capitalize }\n properly_formatted_name.join(' ')\n end",
"def make_fake_name (name)\n\t# Swap first & last name\n\tswap_name = name.split(' ').reverse.join(' ')\n\n\tfake_name = ''\n\tindex = 0\n\twhile index < swap_name.length\n\t\tchar = swap_name[index]\n\t\tif char == ' '\n\t\t\tfake_name += ' '\n\t\telse\n\t\t\tif char == char.downcase\n\t\t\t\tfake_name += get_swapped_char(char)\n\t\t\telse\n\t\t\t\tfake_name += get_swapped_char(char.downcase).upcase\n\t\t\tend\n\t\tend\n\n\t\t# Increment counter\n\t\tindex += 1\n\tend\n\n\tfake_name\nend",
"def createValidName(inname)\r\n outname = inname.gsub(/[\\s\\/\\\\?*#+]/,'') # Remove illegal chars (replace with underscore).\r\n outname.gsub!(/_+/,\"_\") # Replace consecutive uscores with single uscore.\r\n outname.gsub!(/\\./,\"-\") # Replace period with dash.\r\n\r\n outname\r\n end",
"def abbrev_name(name)\n \"#{name[0]}.#{name.split[1][0]}\".upcase\nend",
"def to_initials(name)\n initials = \"\"\n arrName = name.split(' ')\n arrName.each { | name | initials += name[0] }\n return initials\nend",
"def formatNameFromString( name )\n name.split(\",\")\n end",
"def formatNameFromString( name )\n name.split(\",\")\n end",
"def listing_name(text)\n\t\t\tar = text.split(', ')\n\t\t\tlastname = ar[0]\n\t\t\tfirstpart = ar[1]\n\t\t\tinitials = firstpart.gsub(/([[:upper:]])[a-zé]+/, '\\1.')\n\t\t\tinitials + ' ' + lastname\n\t\tend",
"def format_name(first, last)\n if last == '' || first == ''\n word = nil\n else\n user_name = ''\n user_name += first.gsub(' ', '').gsub(/[^0-9A-Za-z]/, '')[0]\n user_name += (last.gsub(' ','').gsub(/[^0-9A-Za-z]/, ''))\n user_name.gsub(/\\d/, '').downcase\n end\nend",
"def name\n name_parts.compact.join(' ')\n end",
"def to_initials(name)\n # Write your code here\n new_name = name.split(\" \")\n\n first_ini = new_name[0][0]\n second_ini = new_name[1][0]\n\n puts \"#{first_ini.upcase}#{second_ini.upcase}\"\n\n # new_name1=new_name.split(\"\")\n # new_string1 =[]\n # new_name.each do |x|\n # new_string1 << x = x.shift\n # new_string2 = x.join(\"\")\n # end\n\nend",
"def get_spy_name(names)\n # no space in between names or too manynames\n if names.count(\" \") == 0\n print \"Enter 2 names\"\n return nil\n elsif names.count(\" \") > 1\n print \"Enter just 2 names\"\n return nil\n end\n\n names_arr = swap_names(names)\n\n names_arr.map!{ |name|\n chars_array = name.chars\n\n chars_array.map!{ |char|\n char = next_letter(char)\n }\n }\n\n # capitalize first letter of both names\n names_arr[0][0].capitalize!\n names_arr[1][0].capitalize!\n\n #insert space after new first name\n names_arr.insert(1, ' ')\n\n return names_arr.join()\nend",
"def spy_name(str)\n #CREATE VARIABLES FOR VOWELS AND CONSONANTS\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n consonants = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n #CHANGE STRING FIRST INTO ARRAY THAT MAKES EACH WORD A VALUE THEN REVERSE THEM. \n #THEN TURN ARRAY BACK INTO STRING AND DOWNCASE ANY LETTER.\n #THEN TURN STRING BACK INTO ARRAY THAT TAKES EACH INDIVIDUAL CHARACATER AS A VALUE.\n str = str.split(' ').reverse.join.downcase\n str = str.split('')\n #CREATE TEMPORARY VARIABLE STR_NEW TO EQUEL STR THEN CHANGE BUMP EACH \n #VOWEL AND CONSONANT TO THE NEXT ONE IN LINE. \n str_new = str.map do |char|\n if vowels.include?(char)\n vowels.rotate(1)[vowels.index(char)]\n elsif consonants.include?(char)\n consonants.rotate(1)[consonants.index(char)]\n else\n char\n end\n end\n #TURN ARRAY BACK INTO STRING.\n str_new.join\nend",
"def band_name(name)\n return name.to_s.capitalize << name.to_s[1..-1] if name[0] == name[-1]\n\n article = 'The'\n article << ' ' << name.to_s.capitalize\nend",
"def normalize_name(name)\n return name.to_s if !name.is_a?(String) && !name.is_a?(MatchData)\n name = name.captures.compact.join('-') if name.is_a?(MatchData)\n name.split('-').map { |s| s[/\\A[0-9]\\Z/].nil? ? s : \"0#{s}\" }.join('-').upcase\nrescue\n name.to_s\nend",
"def fakeName(name)\r\n\tnameLen = name.length\r\n\tnameIndex = 0\r\n\tvowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\r\n\tcons = [\"b\", \"c\",\"d\", \"f\",\"g\", \"h\",\"j\", \"k\",\"l\", \"m\",\"n\", \"p\",\"q\", \"r\",\"s\", \"t\",\"v\", \"x\", \"z\",\"w\", \"y\"]\r\n\tnewName = \"\"\r\n\twhile nameIndex < nameLen\r\n\t\tvowelArrayIndex = 0\r\n\t\tvowels.each do |vow|\r\n\t\t\tif name[nameIndex] == vow\r\n\t\t\t\tnextchar = next_vowel(vowelArrayIndex)\r\n\t\t\t\tnewName = newName + nextchar\r\n\t\t\tend\r\n\t\t\tvowelArrayIndex += 1\r\n\t\tend\r\n\t\tvowelArrayIndex = 0\r\n\t\tconsArrayIndex = 0\r\n\t\tcons.each do |cons|\r\n\t\t\tif name[nameIndex] == cons\r\n\t\t\t\tnextchar = next_cons(consArrayIndex)\r\n\t\t\t\tnewName = newName + nextchar\r\n\t\t\tend\r\n\t\t\tconsArrayIndex += 1\r\n\t\tend\r\n\t\tnameIndex += 1\r\n\tend\r\n\treturn newName\r\nend",
"def fake_name(name)\n fake_name = name.chars.map! do |letter|\n if letter == \" \"\n letter = \" \"\n elsif \"aeiou\".include?(letter)\n letter = next_vowel(letter)\n elsif \"zdhnt\".include?(letter)\n letter = pre_vowel_scramble(letter)\n else\n letter.next\n end\n end\n fake_name = fake_name.join\n swap_name_order(fake_name)\nend",
"def format_name\n put_together_name(:full)\n end",
"def to_initials(name)\n parts = name.split(\" \")\n print parts\nend",
"def to_initials(name)\r\n\tnames = name.split(\" \")\r\n initials = \"\"\r\n \tnames.each do |name|\r\n initials += name[0]\r\n end\r\n return initials\r\nend",
"def initials(name)\n name = name.split\n name[0..-2].map { |name| name[0].upcase }.join('.') + '.' + name.last.capitalize\nend",
"def mangle_name(name)\r\n name.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').gsub(/([a-z\\d])([A-Z])/,'\\1 \\2')\r\n end",
"def to_initials(name)\n str = \"\"\n name.split(\" \").each { |ele| str += ele[0] }\n return str\nend",
"def format_name(first, last)\n first.empty? || last.empty? ? nil :\n (first.gsub(/[^A-z]/, \"\")[0] + last.gsub(/[^A-z]/, \"\")).downcase\nend",
"def handle\n @name.to_str.strip.downcase.split(/[_ ]+/).join(\"_\")\n end",
"def alias_maker(name)\n \n consonants = \"bcdfghjklmnpqrstvwxz\"\n next_cons = \"cdfghjklmnpqrstvwxzb\"\n \n name.downcase.tr(consonants,next_cons)\n .tr('aeiouy', 'eiouya')\n .split.reverse.each {|word| word.capitalize!}\n .join(' ')\n\n # Separated methods on lines 24-27 for readability\n # First .tr changes all consonants to next\n # Second .tr changes all vowels to next vowel\n # Split names to reverse and capitalize them\n # Rejoin to a single string\n\nend",
"def undercover_name(name)\n name.downcase.split(' ').map!{|name| name.split('').map! {|letter| next_letter(letter)}.join('').capitalize}.reverse.join(\" \")\nend",
"def make_fake_name (name)\n\t# Swap first & last name\n\tswap_name = name.split(' ').reverse.join(' ')\n\n\t# Swap characters - change all vowels to next vowel,\n\t# and all consonants to next consonant\n\n\t# Initialize fake_name & index (counter) variables \n\tfake_name = ''\n\tindex = 0\n\twhile index < swap_name.length\n\t\tchar = swap_name[index]\n\n\t\t# For each character\n\t\tif char == ' '\n\t\t\t# If space, add space\n\t\t\tfake_name += ' '\n\t\telse\n\t\t\t# Handle lower & uppercase properly\n\t\t\tif char == char.downcase\n\t\t\t\tfake_name += get_swapped_char(char)\n\t\t\telse\n\t\t\t\tfake_name += get_swapped_char(char.downcase).upcase\n\t\t\tend\n\t\tend\n\n\t\t# Increment counter\n\t\tindex += 1\n\tend\n\n\tfake_name\nend",
"def to_initials(name)\n\tnames = name.split(\" \")\n \tinitials = \"\"\n \tnames.each do |nom|\n initials += nom[0].upcase\n end\n return initials\nend",
"def initials(name)\n idx = 0\n new_str = ''\n\n loop do\n new_str << name.split[idx][0].upcase\n new_str << '.'\n idx += 1\n break if idx == name.split.length - 1\n end\n \n new_str << name.split[-1].capitalize\n\n new_str\nend",
"def format_name(first, last)\n if first.empty? || last.empty?\n nil\n else\n formatted_first = first.delete(' ')\n formatted_last = last.delete(' ')\n return (formatted_first[0] + formatted_last).downcase\n end\nend",
"def _prepareName ( name )\n name.to_s.gsub /[\\W]/, ''\n end",
"def reformat_twofaced_names(card)\n end",
"def format_name(name)\n name.match(/\\,/).nil? ? name : \"#{name.split(\", \").reverse.join(\" \")}\"\n end",
"def to_initials1(name)\n parts = name.split(\" \")\n initials = \"\"\n parts.each { |part| initials += part[0] }\n return initials\nend",
"def format_name(first, last)\n if (first.empty? || last.empty?)\n nil\n else\n (first.gsub(/\\s+/, '')[0]+last.gsub(/\\s+/, '')).downcase\n end\nend",
"def fake_name_c2(real_name)\n\treal_full_name = real_name.split(\" \")\n\treal_first_name = real_full_name[0] \n\treal_last_name = real_full_name[1]\n\ti = 0\n\tfake_first_name = \"\"\n\tfake_last_name = \"\"\n\tvowel_index = \"\"\n\tlength_first = real_first_name.length\n\tlength_last = real_last_name.length \n\t\twhile i < length_last\n\t\tif real_last_name[i] == \"z\"\n\t\t\tfake_last_name += \"a\"\n\t\telsif real_last_name[i] == \"a\" || real_last_name[i] ==\"e\" || \n\t\t\t real_last_name[i] == \"i\" || real_last_name[i] == \"o\" || \n\t\t\t real_last_name[i] == \"u\"\n\t\t\tfake_last_name += real_last_name[i] \n\t\telse \n\t\t\tfake_last_name += real_last_name[i].next \n\t\tend \n\t\ti+=1\n\tend\n\tfake_last_name\nend",
"def humanize_renderer(str)\n str.split(\"_\").map{ |split| split.capitalize }[0...-1].join(\" \")\n end",
"def format_attribute_name name\n return name if name !~ /_/ && name =~ /[A-Z]+.*/\n name.split('_').map{ |e| e.capitalize }.join \n end",
"def name_change(normal_name)\nvowels = \"aeiouAEIOU\".split(\"\")\nconsonants = \"bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ\".split(\"\")\n\nchanged_name = normal_name.split(\" \")\nchanged_name[0], changed_name[1] = changed_name[1], changed_name[0]\n split_name = changed_name.join(\" \")\nname = split_name.split(\"\")\n\nnew_name = \"\"\nname.each_with_index do |letter, letter_index|\n if vowels.include?(letter)\n vowels.each_with_index do |vowel, vowel_index|\n if letter === vowel\n if letter === \"u\"\n new_name << \"a\"\n elsif letter === \"U\"\n new_name << \"A\"\n else\n new_name << vowels[vowel_index+1]\n end\n end\n end\nend\n if consonants.include?(letter)\n consonants.each_with_index do |consonant, consonant_index|\n if letter === consonant\n if letter === \"z\"\n new_name << \"b\"\n elsif letter === \"Z\"\n new_name << \"B\"\n else\n new_name << consonants[consonant_index+1]\n end\n end\n end\nend\n if letter === \" \"\n new_name << \" \"\n end\n end\n new_name\nend",
"def to_initials(name)\n parts = name.split(\" \")\n initials = \"\"\n parts.each { |part| initials += part[0] }\n return initials\nend",
"def format_name(level, full_name)\n lnname = ' '*level+full_name\n if (lnname.length > 60)\n lnname[0..3]+'...'+lnname[-54,lnname.length-1]\n else\n lnname\n end\n end",
"def name_2_id( a_string ) \n return a_string.gsub(\"[\",\"_\").gsub(\"]\",\"\");\n end"
] |
[
"0.752265",
"0.7367414",
"0.7313556",
"0.7094018",
"0.70486385",
"0.70486385",
"0.70415807",
"0.70291847",
"0.70199776",
"0.69859535",
"0.69590485",
"0.69549334",
"0.69225585",
"0.69204056",
"0.6917172",
"0.6906009",
"0.6902796",
"0.6856452",
"0.685421",
"0.6841637",
"0.6841637",
"0.68208176",
"0.6818283",
"0.68143827",
"0.6809321",
"0.6786415",
"0.6784902",
"0.6743849",
"0.67129296",
"0.6686092",
"0.66839457",
"0.66822505",
"0.6672913",
"0.6655422",
"0.6616106",
"0.65767336",
"0.6569059",
"0.65571177",
"0.6555663",
"0.65497446",
"0.6539035",
"0.6538965",
"0.65385437",
"0.6537319",
"0.6535082",
"0.6534193",
"0.65341806",
"0.6523086",
"0.6501662",
"0.6495374",
"0.6493436",
"0.6486486",
"0.6478949",
"0.6461901",
"0.6444969",
"0.6444969",
"0.6399164",
"0.63842374",
"0.6360445",
"0.6359087",
"0.6347598",
"0.63446254",
"0.6339495",
"0.63251853",
"0.63251853",
"0.631772",
"0.6314052",
"0.62898064",
"0.62835556",
"0.628147",
"0.627282",
"0.62724054",
"0.62718356",
"0.6266781",
"0.6262908",
"0.625588",
"0.62545973",
"0.625232",
"0.62504834",
"0.62496287",
"0.62489474",
"0.6248677",
"0.6248369",
"0.62432903",
"0.62276435",
"0.6225137",
"0.6220842",
"0.621937",
"0.62142956",
"0.62071234",
"0.6205818",
"0.6202372",
"0.6201424",
"0.617362",
"0.6171979",
"0.6170634",
"0.61667645",
"0.6164516",
"0.61593753",
"0.6157991",
"0.6156262"
] |
0.0
|
-1
|
codewars kata: counting in the amazon
|
def count_arara(n)
arara_array = []
(n/2).times{ |i| arara_array << "adak" }
(n%2).times{ |i| arara_array << "anane" }
arara_array.join(" ")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def customer_pet_count(number)\n return number[:pets].count\nend",
"def count_occurence(array)\n counts = Hash.new(0)\n array.each { |name| counts[name] += 1 }\n puts counts\n\n price_calculator=PriceCalculator.new\n price_calculator.sepitem_quantity(counts)\n\n end",
"def customer_pet_count(customers)\n return customers[:pets].count()\nend",
"def customer_pet_count(customer)\n return customer[:pets].count()\nend",
"def stock_count(pet_shop)\n return pet_shop[:pets].count()\nend",
"def stock_count(pet_shop)\n return pet_shop[:pets].count()\nend",
"def count; end",
"def count; end",
"def count; end",
"def customer_pet_count(customer)\n return customer[:pets].count()\n # return customer[:pets].length()\n # return customer[:pets].size()\n end",
"def stock_count(pet_shop)\n pet_shop[:pets].count()\nend",
"def hitCount(uris, aA, aB, aC, aD)\n\n\thitCountStart = Time.now\n\taAll = []\n\taAll << aA << aB << aC << aD\n\n countA = 0\n\tcountB = 0\n\tcountC = 0\n\tcountD = 0\n\n\n\taA = aA.downcase\n\taB = aB.downcase\n\taC = aC.downcase\n\taD = aD.downcase\n\t\n\n\taTotal = []\n\tbTotal = []\n\tcTotal = []\n\tdTotal = []\n\n\tplaintexts=[]\n\n\tn = uris.size\n\n\tn.times {|i|\n\t\tif Time.now - hitCountStart < 8\n\t\t\tbegin\n\t\t\t\tbegin\n\t\t\t \tdoc = Nokogiri::HTML(open(uris[i]))\n\t\t\t \tdoc.css('script, link').each { |node| node.remove }\n\t\t\t \t\tplaintexts << doc.css('body').text.downcase.split(\"\\n\"). collect { |line| line.strip }.join(\"\\n\")\n\t\t\t \trescue\n\t\t\t \t\tputs \"Nokogiri could not read\"\n\t\t\t \tend\n\t\t \t#rescue\n\t\t \t#\t\"Nokogiri fault\"\n\n\t\t \t\t\t\t\t\n\t\t\tplaintexts[i].each_line { |bar|\n\n\t\t\t\tbegin\n\t\t\t\t\tcountA += bar.scan(/\\b#{aA}\\b/i).size\n\t\t\t\trescue\n\t\t\t\tend\t\t\t\t\t\n\t\t\t\tbegin\n\t\t\t\t\tcountB += bar.scan(/\\b#{aB}\\b/i).size\n\t\t\t\trescue\n\t\t\t\tend\n\t\t\t\tbegin\t\t\t\t\t\n\t\t\t\t\tcountC += bar.scan(/\\b#{aC}\\b/i).size\n\t\t\t\trescue\n\t\t\t\tend\t\n\t\t\t\tbegin\t\t\t\t\n\t\t\t\t\tcountD += bar.scan(/\\b#{aD}\\b/i).size\n\t\t\t\trescue\n\n\t\t\t\tend\n\n\t\t\t}\n\t\t\tputs \"A = \" + countA.to_s +\t\" B = \" + countB.to_s + \" C = \" + countC.to_s +\t\" D = \" + countD.to_s\n\t\tend\n\tend\n\t}\nend",
"def customer_pet_count (customer)\n return customer[:pets].count\nend",
"def customer_pet_count(customer)\n return customer[:pets].count\nend",
"def customer_pet_count(customer)\n return customer[:pets].count\nend",
"def customer_pet_count(customer)\n return customer[:pets].count\nend",
"def get_brand_revenue_count(brand_key_details,brand_revenue,brand_purchase_cnt)\n\tbrand_key_details[\"purchases\"].each do |purchase_brand|\n brand_purchase_cnt += 1\n brand_revenue = sum(sum: brand_revenue , sum1: purchase_brand[\"price\"] , sum2: purchase_brand[\"shipping\"] )\n end\n return brand_revenue , brand_purchase_cnt\nend",
"def customer_pet_count(customer)\n return customer[:pets].length\nend",
"def customer_pet_count(customer)\n return customer[:pets].length\nend",
"def customer_pet_count(customer)\n customer[:pets].length()\nend",
"def customer_pet_count(supplied_customer)\n return supplied_customer[:pets].length\nend",
"def stock_count(count)\n return count[:pets].count\nend",
"def stock_count(pet_shop_pet_count)\n return pet_shop_pet_count[:pets].length\nend",
"def book_count\n # ALL the books\n # if that particular book the author is me\n # all_my_books\n all_my_books.count\n #code\n end",
"def stock_count(pet_shop)\nreturn pet_shop[:pets].length\nend",
"def count_item(item)\n # model class for item\n model = item[0].capitalize.constantize\n price = model.price\n amount = item[1]\n price * amount * tax_coefficient(model) * discount_coefficient(item[0])\n end",
"def get_product_sales_count(toy_name,sales_sum,purchase_price_sum,product_purchase_cnt)\n\ttoy_name[\"purchases\"].each do |purchase_num|\n sales_sum = sum(sum: purchase_num[\"price\"] , sum1: purchase_num[\"shipping\"] , sum2: sales_sum)\n purchase_price_sum = sum(sum: purchase_num[\"price\"] ,sum1: purchase_price_sum)\n product_purchase_cnt += 1\n end\n return sales_sum,purchase_price_sum,product_purchase_cnt\nend",
"def stock_count(petshop)\n return petshop[:pets].size()\n end",
"def stock_count(pet_shop)\n return pet_shop[:pets].count\nend",
"def stock_count(pet_shop)\n return pet_shop[:pets].count\nend",
"def stock_count(pet_shop)\n return pet_shop[:pets].count\nend",
"def product_count(product_to_find)\n product_count_helper = 0\n @products.each do |z|\n if z.name == product_to_find.name\n product_count_helper += 1\n end\n end\n product_count_helper\n end",
"def genre_count(term)\n #count the genres in object.get_genres\n genres = Hash.new(0)\n object.get_genres(term).each do |genre|\n case\n when genre.include?(\"rap\")\n genres[:rap]+=1\n when genre.include?(\"pop\")\n genres[:pop]+=1\n when genre.include?(\"country\")\n genres[:country]+=1\n when genre.include?(\"indie\")\n genres[:indie]+=1\n when genre.include?(\"hip\")\n genres[\"hip hop\"]+=1\n when genre.include?(\"rock\")\n genres[:rock]+=1\n when genre.include?(\"jazz\")\n genres[:jazz]+=1\n when genre.include?(\"instrumental\")\n genres[:instrumental]+=1\n when genre.include?(\"r&b\")\n genres[\"r&b\"]+=1\n else\n genres[:misc] +=1\n end\n end\n genres\n end",
"def customer_pet_count(customer_hash)\n return customer_hash[:pets].length\nend",
"def customer_pet_count(customer_hash)\n return customer_hash[:pets].count\nend",
"def customer_pet_count(customer)\n customer[:pets].count\nend",
"def stock_count(pet_shop)\n return pet_shop[:pets].length\nend",
"def stock_count(shop)\n return shop[:pets].length\nend",
"def stock_count(shop)\n return shop[:pets].length\nend",
"def stock_count(shop)\n return shop[:pets].length\nend",
"def product_tot_purchases(array_item)\n\tarray_item[\"purchases\"].length\nend",
"def offense_counts; end",
"def offense_counts; end",
"def get_page_count( rb, tagged )\n\n verbose( \"Getting #{$params[ :product ]} page count...\" )\n verbose( \"Only looking for #{$params[ :product ]} tagged with \\\"#{tagged}\\\"\" ) if tagged \n\n # Download the first page of art and grab the body.\n page = grab_art_page( rb, tagged, 1 )\n\n # Find the number of the last page of art.\n last = page.elements.to_a( \"//li[@class='page-link']/a\" ).last\n\n # If we managed to get that...\n if last then\n # ...return it as a number.\n verbose( \"Done (max page is #{last.text.to_i}).\" )\n last.text.to_i\n else\n # ...or, if we didn't, moan...\n $stderr.puts \"Could not find maximum page number. Assuming just one page.\"\n # ...and assime it's a single page.\n 1\n end\n \nend",
"def test_count\n Vault::Log.count('countable')\n assert_equal '1', logged_data['count#test-app.countable']\n assert_equal 'test-deploy', logged_data['source']\n end",
"def get_count(input)\n input.count('aeiou')\nend",
"def photos_count(info_count)\n x = info_count.inject(Hash.new(0)) { |h, e| h[e] += 1 ; h }\nend",
"def increment_item_count(cart, item_name)\n index = 0\n while index < cart.length do\n current_item = cart[index]\n if ( current_item[:item] == item_name )\n current_item[:count] += 1\n end\n index += 1\n end\n cart\nend",
"def _increment_count metadata, location = nil\n\n con = Mysql2::Client.new(:host => $config['awesomizer']['host'], \n :username => $config['awesomizer']['user'], \n :password => $config['awesomizer']['pass'], \n :database => $config['awesomizer']['database']) \n # TODO: the 'duplicate key' clause of this query\n # is nice, but it means that the code does a\n # Voyager lookup each and every time a code is\n # scanned, even for items already in the database.\n # it would be more efficient to check for the bibid\n # first and only do the voyager lookup if we don't\n # have the metadata yet.\n con.query(\"insert into items (bibid, title, author, oclc_id, votes) values ('#{metadata[:bibid]}', '#{metadata[:title]}', '#{metadata[:author]}', '#{metadata[:oclc_id]}', 1) on duplicate key update votes=votes+1\")\nend",
"def count\n end",
"def count\n end",
"def ab_counts(_experiment, _alternative)\n raise \"Not implemented\"\n end",
"def count_triple\nend",
"def books_per_publisher(books, publishers)\n publisher_count = Hash.new { 0 }\n books.each do |book|\n if publishers.include? book.publisher\n publisher_count[book.publisher] += 1\n end\n end\n publisher_count\nend",
"def count_items(electives)\n electives.length #counts number of items in the array\nend",
"def count_books author\n books = @books[author]\n if books == nil\n puts \"No such author\"\n else\n puts books.length\n end\n end",
"def test_it_can_count_items_per_id\n assert_equal 475, @sa.item_count_per_merchant_id.count\n end",
"def count_by_brand(products, brand)\n # selected = products.select do |product|\n # product[:brand] == brand\n # end\n # selected.count\n filter_by_brand(products, brand).count\nend",
"def solution0(a)\n\n total_count = 0\n elem_counts = Hash.new(0)\n\n a.each do |elem|\n elem_counts[elem] += 1\n total_count += 1 if elem_counts[elem] == 2\n end\n\n return total_count\n\nend",
"def stock_count(stock_number)\n return stock_number [:pets].count\nend",
"def stock_count(shop)\n shop[:pets].length \nend",
"def counter\n Weed::Stats.by_total({ :bucket_id => id })\n end",
"def count_in_list(list, item_to_count)\n\trunning_total_of_number = 0 #the running total is 0\n\tlist.each do |item|\t\t\t\t\t#go through the list. example, the first element of 1 is the placeholder.\n\tif item == item_to_count #if this #1 is equal to 1\n\trunning_total_of_number += 1 #then the the running total increases by 1\n\t# do it with the second number. the .each acts like a coda.\nend\n # You'll need three things:\n # 1. A running total of the number of times you've seen the item\n # 2. A way to loop/iterate through the list\n # 3. A way to add to the running total as you see the item\n\nend\n\treturn running_total_of_number #return the # of times item_to_count has appeared\nend",
"def count_item\n count = 0\n @g_net.each do |followers|\n count += 1 unless !followers or followers.empty?\n end\n count\n end",
"def count_plays(year)\n s = get_shakey[\"William Shakespeare\"]\n .select { |k, v|\n v[\"finished\"] == year\n }.each { |key, val|\n puts val[\"title\"]\n }.count\nend",
"def count_YZ\nend",
"def owner_pet_count(owner)\n return owner[:pets].length()\nend",
"def customer_pet_count(customer_array)\n customer_array[:pets].count\nend",
"def hit_count()\n #This is a stub, used for indexing\n end",
"def count(products) #este nome pode ser o que nós quisermos porque só está dentro do método\n products.count\nend",
"def how_many(srt)\n arr = srt.split(\" \")\n count = {}\n\n #arr.map{ |s| \"#{s} #{arr.count s}\" }\n\n # arr.each do |s|\n # s.downcase!\n # count[s] = count.key?(s) ? count[s]+1 : 1\n # end\nend",
"def count a\nend",
"def stock_count(stock)\n return stock[:pets].length\nend",
"def get_searchproduct_count_anonymous\n\t\tresponse_search = Partay.get('http://shoponline.tescolotus.com/api/v1/search/products?query=Sugar&page=1&sortBy=Relevance', :headers => {'Content-Type' => 'application/json', 'language' => 'en-gb', 'region' => 'TH'})\n\t\tsearch_result=JSON(response_search)\n\t\tself.total_product_count(JSON(search_result)[\"pageInformation\"][\"totalCount\"])\n\t\tputs total_search_count\n\n\tend",
"def getCount(inputStr)\n inputStr.downcase.count('aeiou')\nend",
"def getCount(inputStr)\n inputStr.downcase.count('aeiou')\nend",
"def count\n count = 0\n each do |data|\n count += 1\n end\n count\n end",
"def get_total_purchases(toy)\n\treturn toy['purchases'].length\nend",
"def test_customer_pet_count\n count = customer_pet_count(@customers[0])\n assert_equal(0, count)\n end",
"def samples_count(hash, status)\n soma = 0\n hash.each do |key, value|\n soma += value[status.to_sym] unless key == 'total'\n end\n return soma\n end",
"def number_of_products(product)\n @basket[product.to_s]\n end",
"def getCount(s)\n s.count('aeiou')\nend",
"def bike_count\n bikes.count\n end",
"def add_item_counts(cart:[])\n cart.each do |item|\n item.map { |food_item, info| info[:count] = count_item(food_item, cart) }\n end\nend",
"def keyword_catalog_count(keyword, catalog_names)\n catalog_names.reduce(0) do |hits, catalog_name|\n matches = @sources.find({\n :_keywords => keyword,\n :catalog_name => catalog_name,\n })\n hits + ((matches.count > 0) ? 1 : 0)\n end\n end",
"def occurences_count\n\t\t\t\t\t\tHash.new(0).tap do |result|\n\t\t\t\t\t\t each { |item| result[item] += 1 }\n\t\t\t\t\t\tend\n\t\t\t\tend",
"def count(list)\n list.each do |hash|\n total += 1\n end\n return total\n end",
"def count_pet\n pets.count\n end",
"def counts\n\t\tputs \"Counting number of IPs within the CIDR store:\" if @verbose\n\t\tcnt=0\n\t\t@known_cidr_blks.keys.map do |key|\n\t\t\tcnt=cnt+size(key)\n\t\tend\n\t\tputs \"Total number of trusted IPs: #{cnt}\" if @verbose\n\t\treturn cnt\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n\tend",
"def count_occ(usages_list)\n count = 0\n usages_list.each do |k,v|\n if k['location']['type'] == 'pipeline'\n count += 1\n end\n end\n return count\nend",
"def count_duplicates( keywords )\n counted_keywords = Hash.new(0)\n keywords.each do |keyword|\n counted_keywords[keyword.downcase] += 1\n end\n\n return counted_keywords\nend",
"def countApplesAndOranges(s, t, a, b, apples, oranges)\n sam_apples_count = 0\n sam_oranges_count = 0\n apples.each do |apple|\n apple_position = apple + a\n if (apple_position >= s && apple_position <= t) then\n sam_apples_count += 1\n end\n end\n \n oranges.each do |orange|\n orange_position = orange + b\n if (orange_position >= s && orange_position <= t) then\n sam_oranges_count += 1\n end\n end\n \n puts sam_apples_count\n puts sam_oranges_count\nend",
"def get_count(input_str)\n input_str.downcase.count(\"aeiou\")\nend",
"def number_of_certifications(text)\n result = 0\n @certifications.each do |c|\n if text.downcase.include?(c)\n result += 1\n end\n end\n return result\nend",
"def get_items_count(name, tag, container)\n eval(SELECTOR_MAPPING[container][name][tag][ELEMENT]).count.to_i\n end",
"def getCount(inputStr)\n inputStr.downcase.count(\"aeiou\")\nend",
"def counts\r\n @counts\r\n end",
"def getCount(inputStr)\n inputStr.downcase.count('aeiou')\nend",
"def count ( nucleotide, strand )\n\tstrand.upcase.count( nucleotide )\nend",
"def number_of_awards(text)\n result = 0\n @awards.each do |a|\n if text.downcase.include?(a)\n result += 1\n end\n end\n return result\nend",
"def counting\n puts \"hard to do right\"\n end"
] |
[
"0.61818135",
"0.6120547",
"0.60995364",
"0.6076927",
"0.6065874",
"0.6065874",
"0.604398",
"0.604398",
"0.604398",
"0.6012398",
"0.59976244",
"0.59915614",
"0.59774286",
"0.5966205",
"0.5953364",
"0.5953364",
"0.59507114",
"0.5947938",
"0.5947938",
"0.59430945",
"0.59278554",
"0.5919793",
"0.5912751",
"0.5905452",
"0.5903781",
"0.5902787",
"0.5899815",
"0.5899105",
"0.58752793",
"0.58752793",
"0.587497",
"0.58723634",
"0.5867535",
"0.58598363",
"0.5856697",
"0.5836522",
"0.5835458",
"0.58172923",
"0.5805814",
"0.5805814",
"0.5798065",
"0.5793765",
"0.5793765",
"0.5789627",
"0.5780525",
"0.5772271",
"0.57617974",
"0.57617694",
"0.5761581",
"0.57555354",
"0.57555354",
"0.5754834",
"0.57525504",
"0.5729418",
"0.572619",
"0.5711216",
"0.57097155",
"0.5700075",
"0.5663362",
"0.56630945",
"0.5661982",
"0.5657526",
"0.5649719",
"0.56414634",
"0.56412",
"0.5639362",
"0.56389207",
"0.56307095",
"0.56292903",
"0.5626848",
"0.5624667",
"0.56177974",
"0.5614312",
"0.56098413",
"0.560134",
"0.560134",
"0.55963385",
"0.5571549",
"0.5568553",
"0.5565327",
"0.55591184",
"0.55591",
"0.55570316",
"0.5556545",
"0.55562073",
"0.55465466",
"0.55240965",
"0.55237126",
"0.5518533",
"0.5512046",
"0.5510952",
"0.5503116",
"0.5501611",
"0.5493048",
"0.54905355",
"0.54809123",
"0.547987",
"0.5479533",
"0.5469934",
"0.5466663",
"0.5460383"
] |
0.0
|
-1
|
codewars kata: is a number prime?
|
def isPrime(num)
# returns whether num is a prime number
num > 1 && (2...num).none?{|n| num % n == 0}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def is_prime?(n)\n end",
"def prime?(number)\n # binding.pry\n return false if number < 2\n (2..number - 1 ).each do|num|\n if (number % num) == 0\n return false\n end\n end\n true\nend",
"def is_prime? (number)\n return false if number < 1\n 2.upto(Math.sqrt(number)) do |x|\n return false if number % x == 0\n end \n true\nend",
"def is_prime?(number)\n return true if number == 2\n 2.upto(number/2) do |x|\n return false if number%x == 0\n end\n return true\nend",
"def prime?(number)\n (2...number).each do |x|\n return false if (number % x).zero?\n end\n true\n end",
"def prime?(num)\n Math.sqrt(num).to_i.downto(2).each { |i| return false if (num % i).zero? }\n true\nend",
"def is_prime?(num)\n return false if num == 1\n return true if num == 2 \n (2..Math.sqrt(num)+1).each do |x|\n return false if num%x == 0\n end\n true\nend",
"def is_prime(number)\n if number == 1\n return true\n end\n 2.upto(number) do |x|\n if (number % x == 0) && (number != x)\n return false\n end\n end\n return true\nend",
"def prime?(number)\n if number == 0 or number == 1\n return false\n end\n i = 2\n while i < number\n if number % i == 0\n return false\n end\n i += 1\n end\n return true\nend",
"def prime? (number)\n if number == 2\n return true\n elsif number < 2\n return false\n else\n for num in 2..Math.sqrt(number)\n if number % num == 0\n return false\n else\n return true\n end\n end\n end\nend",
"def is_prime?(number)\n remainders = (2...number).map { |d| number % d}\n !remainders.include?(0) && number > 1\nend",
"def prime?(int)\n \nend",
"def is_prime?(num)\n 2.upto(num / 2) do |n|\n return false if num % n == 0\n end\n true\nend",
"def is_prime?(number)\n if number <= 1\n return false\n end\n\n i = 2\n while i < number\n if (number % i) == 0\n return false\n end\n i += 1\n end\n return true\nend",
"def prime?(num)\n return false if num == 1\n return true if num == 2 or num == 3 or num == 5 or num == 7\n return false if num % 2 == 0 or num % 3 == 0 or num % 5 == 0 or num % 7 == 0\n (11..Math.sqrt(num).ceil).each do |i| \n return false if num % i == 0\n end\n true \nend",
"def prime?(num)\n track = 0\n return false if num < 2\n (2..num).each { |c| track += 1 if num % c == 0 }\n return track == 1 ? true : false\nend",
"def is_prime_number(num)\n (2...num).all? {|n| num % n != 0}# has factors\nend",
"def is_prime?(number)\n i = number - 1\n until i < 2\n if number % i == 0\n return false\n end\n i -= 1\n end\n return true\nend",
"def is_prime?(num)\n return 2 if num == 2\n (2...num).each do |n|\n return false if num % n == 0\n end\n true\nend",
"def is_prime?(n)\n root = Math.sqrt(n)\n return false if n < 2\n return true if n < 4\n return false if n %2 == 0\n return true if n < 9\n return false if n % 3 == 0\n i = 5\n while i < root\n return false if n % i == 0\n return false if n % (i + 2) == 0\n i += 6\n end\n return true\nend",
"def is_prime number\n\ti = 1\n\tnot_prime = 0\n\tloop do\n\t\tbreak if i == number / 2\n\t\tif number % i == 0\n\t\t\tnot_prime = 1\n\t\tend\n\t\tbreak if not_prime == 1\n\t\ti = i + 1\n\tend\n\tnot_prime\nend",
"def isPrime(num)\n return false if num < 2\n\n sqrt_num = Math.sqrt(num).floor\n 2.upto(sqrt_num){|i|\n if num % i == 0\n return false # 割り切れたら素数でない\n end\n }\n return true\nend",
"def is_prime?(number)\n (2...number).each do |factor|\n if number % factor == 0\n return false\n end\n end\n return true\nend",
"def is_prime?(number)\n for i in 2..(number-1)\n if (number % i) == 0\n return false\n break\n end\n end\n true\nend",
"def is_prime?(num)\n return false if num.even?\n for i in (2..((num/2.round) + 1))\n return false if num % i == 0\n end\n return true\nend",
"def is_prime?(num)\n return false if num.even?\n for i in (2..((num/2.round) + 1))\n return false if num % i == 0\n end\n return true\nend",
"def is_prime?(number)\r\n (2...number).each do |n|\r\n return false if number % n == 0\r\n end\r\n true\r\nend",
"def is_prime?(num)\n\n return false if num<2\n\n (2...num).none? {|factor| num%factor == 0}\n\nend",
"def is_prime?(num)\n return false if num <2\n return (2..num/2).none? {|i| num%i==0}\nend",
"def is_prime?(num)\n if !num.is_a?(Integer) || ( num.class == Float && !num.nan? && num == num.floor ) || num <= 1\n false\n else\n (2...num).each do |i|\n if num % i == 0\n return false\n end\n end\n true\n end\nend",
"def is_prime?(num)\n ('1' * num) !~ /^1?$|^(11+?)\\1+$/\n end",
"def is_prime?(number)\n return false if number < 2\n (2...number).to_a.none?{ |integer| number % integer == 0 }\nend",
"def is_prime?(num)\n if !is_integer?(num)\n return false\n elsif num <= 1\n return false\n else\n (2..(num-1)).each do |el|\n if num % el == 0\n return false\n end\n end\n end\n return true\nend",
"def prime?(int)\n return false if int <= 1\n (2..Math.sqrt(int)).none? { |i| (int % i).zero? }\nend",
"def is_prime?(num)\n (2...num).each do |i|\n if num % i == 0\n return false\n end\n end\n num > 2\nend",
"def is_prime?(number)\n (2...number).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\n \nend",
"def is_prime?(num)\n (2...num).each {|el| return false if num % el == 0}\n true\nend",
"def is_prime?(i)\r\n 2.upto(Math.sqrt(i).to_i) {|j|\r\n return false if i % j == 0\r\n }\r\n true\r\nend",
"def is_prime?(num)\n (2..num/2).none?{|el| num % el == 0}\nend",
"def is_prime?(num)\n 2.upto(num-1) do |i|\n return false if num%i==0\n end\n true\nend",
"def is_prime?(num)\n return true if num == 1 || num == 2\n return false if num % 2 == 0\n int = 3\n while int <= Math::sqrt(num)\n return false if num % int == 0\n int += 2\n end\n true\nend",
"def prime?(number)\n return false if number == 1\n 2.upto(number - 1) do |index|\n return false if number % index == 0\n end\n true\nend",
"def PrimeNumber?(number)\n return false if number<2 || number%2 ==0\n (3..number-1).select(&:odd?).each do |i|\n return false if number%i == 0\n end\n true\nend",
"def is_prime?(num)\n\n return false if num <= 1\n return true if num == 2\n\n i = 2\n while i < num\n return false if num % i == 0\n i += 1\n end\n\n true\n\nend",
"def is_prime?(num)\n (2...num).each do |el|\n return false if num % el == 0\n end\n true\nend",
"def prime?(num)\n if num == 2\n true\n elsif num > 1 && num % num == 0 && num % 1 == 0 && !(2 .. (num - 1)).to_a.any?{|number| num % number == 0}\n true\n else\n false\n end\nend",
"def is_prime?(num)\n Math.sqrt(num).floor.downto(2).each do |i|\n false if num % i == 0\n end\n true\nend",
"def prime?(num)\n return false if num < 2\n\n return true if num <= 3\n\n return false if (num % 2).zero? || (num % 3).zero?\n\n i = 5\n while i < Math.sqrt(num)\n return false if (num % i).zero?\n\n i += 1\n end\n true\nend",
"def is_prime?(num)\n (2...num).none? { |div| num % div == 0 }\nend",
"def is_prime?(num)\n for i in (2...num/2)\n if num % i == 0\n return false\n end\n end\n return true\nend",
"def prime?(num)\n if num < 3\n num.even? ? true : false\n else\n for i in 2...num\n return false if num % i == 0\n end\n true\n end\nend",
"def prime?(num)\n # return false if num < 2\n return true if [2, 3].include? num\n return false if (num % 2).zero? || (num % 3).zero?\n\n i = 5\n s = 2\n\n while (i * i) <= num\n return false if (num % i).zero?\n\n i += s\n s = 6 - s\n end\n true\nend",
"def is_prime?\n return false if num <= 1\n Math.sqrt(num).to_i.downto(2).each {|i| return false if num % i == 0}\n true\nend",
"def is_prime?(num)\nend",
"def prime?(number)\n return false if 2 > number\n (2...number).each { |i| return false if number % i == 0 }\n true\nend",
"def is_prime?(num)\n (2...num).each do |i|\n return false if num % i == 0\n end\n true\nend",
"def is_prime?(number)\n factors = (2...(number))\n if number == 2 || number == 3\n return true\n elsif number == 0 || number == 1\n return false\n elsif factors.any? {|factor| number % factor == 0 }\n return false\n else return true\n end\nend",
"def is_prime?(num)\n return false if num < 2\n (2...num).none? { |factor| num % factor == 0 }\nend",
"def is_prime?(num)\n return false if num < 2\n (2...num).none? { |factor| num % factor == 0 }\nend",
"def is_prime?(num)\n return false if num < 2\n (2...num).none? { |factor| num % factor == 0 }\nend",
"def prime?(num)\n if 0 == num or 1 == num\n return false\n else\n return (2..Math.sqrt(num)).all? { |x| num % x != 0}\n end\nend",
"def is_prime?(num)\n (2..num / 2).each do |n|\n return false if num % n == 0\n end\n true\nend",
"def is_prime?(number)\n (2..(number - 1)).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\nend",
"def is_prime?(number)\n (2..(number - 1)).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\nend",
"def is_prime?(number)\n (2..(number - 1)).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\nend",
"def is_prime?(number)\n if number < 1\n return false\n end\n divisor = 2\n while number % divisor != 0\n divisor += 1\n if number == divisor\n return true \n end\n end\n return false\n end",
"def isPrime(num)\n\tif num % 2 == 0\n\t\treturn false\n\tend\n\tmax = Math.sqrt(num)\n\tfor i in 3..max \n\t\tif num % i == 0\n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\nend",
"def is_prime?(num)\n return false if num < 2\n (2...num).each { |factor| return false if num % factor == 0}\n true\nend",
"def is_prime?(num)\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n true\nend",
"def is_prime?(num)\n return true if num == 1\n (2...num).all? {|i| (num % i) != 0}\nend",
"def is_prime?(num)\n return false if num < 2\n (2...num).each do |i|\n return false if num%i == 0\n end\n return true\nend",
"def prime?(num)\n return false if num == 1\n (2...num).each do |number|\n return false if num % number == 0\n end\n return true\nend",
"def is_prime?(num)\n if num > 2 \n if num % 2 == 0\n return false\n end\n i = 3 # start at 3\n maxn = num**(0.5) # go up to the square root of num\n while i <= maxn\n if num % i === 0\n return false\n end\n i = i+2 # count up by 2 to check only odd numbers\n end\n true\n elsif num == 2 # special case for 2\n true\n else\n false\n end\nend",
"def is_prime?(n) \n Math.sqrt(n).to_i.downto(2).each do |i| \n return false if n % i == 0\n end\nend",
"def is_prime?(num)\n (2...num).each do |n|\n if num % n == 0\n return false\n end\n end\n true\nend",
"def prime?(integer)\n return false if integer < 2 || (integer.even? && integer != 2)\n\n n = Math.sqrt(integer).floor\n (2..n).none? { |x| (integer % x).zero? }\nend",
"def is_prime?(n)\n (2...n).each { |factor| return false if n % factor == 0 } \n n > 1\nend",
"def is_prime?(num)\n i = 2\n while i < num\n return false if num % i == 0\n i+=1\n end\n true\nend",
"def is_prime?(num)\n i = 2\n while i < num\n return false if num % i == 0\n i+=1\n end\n true\nend",
"def is_prime?(number)\n return false if number < 2\n i = 2\n while i <= Math.sqrt(number) # See below why we stop at square root of number\n return false if number % i == 0\n i += 1\n end\n true\nend",
"def prime?(num)\n return false if num <= 1\n Math.sqrt(num).to_i.downto(2).each {|i| return false if num % i == 0}\n true\n end",
"def is_prime?(integer)\n return false if integer == 1\n (2...integer).to_a.all? {|num| integer % num != 0}\nend",
"def is_prime?(num)\n return false if num <= 1\n\n (2...num).each do |fact|\n return false if num % fact == 0\n end\n\n true\nend",
"def check_prime? n \nn_max_two=Math.sqrt(n).floor \nnot_count=0 \nfor i in 2..n_max_two\n if n % i == 0 \nnot_count +=1 \n end \nend \nif not_count > 0 \n return false \n else \n return true \nend \nend",
"def prime?(num)\n if num < 2\n return false\n elsif num == 2\n return true\n end\n\n (2...num).each do |n|\n if num % n == 0\n return false\n end\n end\n true\nend",
"def is_prime?(n)\n 2.upto(Math.sqrt(n).to_i) { |num| return false if n % num == 0 }\n n == 1 ? false : true\nend",
"def is_prime?(num)\n return if num <= 1\n (2..Math.sqrt(num)).none? { |i| (num % i).zero? }\nend",
"def is_prime?(num)\n (2...num).none? { |el| num % el == 0 }\nend",
"def prime?(number)\n (2..(number-1)).each do |possible_factor|\n return false if number % possible_factor == 0\n end\n true\nend",
"def isPrime(num)\nreturn false if num < 2\n(2..(Math.sqrt(num))).each do |x|\n return false if num % x == 0\nend\ntrue\nend",
"def prime?(num)\n return false if num == 1\n return true if num == 2\n (2...num).each do |divisor|\n return false if num % divisor == 0\n end\n true\nend",
"def is_prime?(num)\n for i in (2..Math.sqrt(num))\n return false if num % i == 0\n end\n true\nend",
"def is_prime?(x)\r\n if x == 1\r\n return false\r\n end\r\n for n in (1..Math.sqrt(x).ceil)\r\n if x%n == 0 \r\n if n != 1 && n != x\r\n return false\r\n end\r\n end\r\n end\r\n return true\r\nend",
"def prime?(number)\n\nreturn false if number < 2\n\n (2...number).each do |x|\n return false if number % x == 0\n end\nreturn true\n\nend",
"def isprime?(num)\n\n return false if num<2\n\n (2...num).each do |factor|\n return false if num % factor == 0\n end\n\n return true\n\nend",
"def is_prime?(number)\n number = number.abs\n return false if number < 2\n return true if number < 4\n\n factor = 2\n while factor * factor <= number\n return false if number % factor == 0\n factor += 1\n end\n\n true\nend",
"def is_prime?(number)\n number = number.abs\n return false if number < 2\n return true if number < 4\n\n factor = 2\n while factor * factor <= number\n return false if number % factor == 0\n factor += 1\n end\n\n true\nend",
"def is_prime?(number)\n number = number.abs\n return false if number < 2\n return true if number < 4\n\n factor = 2\n while factor * factor <= number\n return false if number % factor == 0\n factor += 1\n end\n\n true\nend",
"def is_prime?(num)\n (2...num).none? {|i| num % i == 0}\nend",
"def isPrime?(num)\n if num < 2\n return false\n end\n\n (2...num).each do |n|\n if num % n == 0\n return false\n end\n end\n return true\nend",
"def prime number\n return true if number==2\n max = Math.sqrt number\n for i in 2..max\n return false if number%i==0\n end\n return true\nend"
] |
[
"0.8356683",
"0.82777596",
"0.82546204",
"0.8216675",
"0.8204239",
"0.81969416",
"0.8196109",
"0.8195269",
"0.8177309",
"0.8171434",
"0.81647146",
"0.81625396",
"0.81564415",
"0.8153163",
"0.81516963",
"0.81494",
"0.81445074",
"0.8143539",
"0.8141808",
"0.81406075",
"0.81337637",
"0.81332415",
"0.8133211",
"0.81312966",
"0.8122121",
"0.8122121",
"0.8121642",
"0.81196743",
"0.8119603",
"0.81189954",
"0.8118704",
"0.8111538",
"0.8108382",
"0.8105862",
"0.81041723",
"0.81026584",
"0.81017363",
"0.8101367",
"0.81000483",
"0.8097584",
"0.80975515",
"0.8097219",
"0.8096146",
"0.8095933",
"0.80919755",
"0.8091317",
"0.8091154",
"0.80894595",
"0.80872416",
"0.8084631",
"0.8082821",
"0.80821043",
"0.8075589",
"0.8073331",
"0.80712134",
"0.80695534",
"0.80691695",
"0.80687165",
"0.80687165",
"0.80687165",
"0.8067045",
"0.8067028",
"0.8064719",
"0.8064719",
"0.8064719",
"0.80623686",
"0.80617803",
"0.80615956",
"0.80595726",
"0.80592775",
"0.8058221",
"0.8057167",
"0.80558187",
"0.8051057",
"0.8050761",
"0.80492866",
"0.80462915",
"0.8045319",
"0.8045319",
"0.8043256",
"0.8040646",
"0.80393195",
"0.8036184",
"0.80357987",
"0.80345833",
"0.8034064",
"0.80322933",
"0.80296",
"0.80281156",
"0.8026221",
"0.8024511",
"0.802283",
"0.802201",
"0.80196",
"0.80173105",
"0.80149037",
"0.80149037",
"0.80149037",
"0.8013719",
"0.8010327",
"0.80084735"
] |
0.0
|
-1
|
codewars kata: vasya and stairs
|
def numberOfSteps(steps, m)
((steps/2 + steps%2)..steps).find{ |n| n%m==0 } || -1
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def preprovide_saily_kainsi(akamatsu_demoniacally)\n gibbergunyah_nutcrack(mollycot_copolymerization, capitulator_polyphylogeny, overjob)\n lid_polytonalism(pneumoenteritis_ribby)\n pricklefish(overdraft, phleboplasty_poleaxe)\n end",
"def sittinae_hooey(scrawny_appulsion, termly)\n end",
"def king_richard_iii; end",
"def sk! ; k! ; s! ; end",
"def sweep_stairs\n climb_stair\n pick_beeper\n climb_stair\n pick_beeper\n climb_stair\n pick_beeper\n turn_off\n end",
"def difficultly(qoph_ridding, fadedness_santalaceae)\n biopsychologist_hamidian_tachardiinae()\n inigo()\n huddock_konde(phrenitic, mistake, condurango_cymoscope)\n end",
"def countingValleys(n, s)\n valleys, counter, flag, prev_flag = 0, 0, \"sea level\", \"\"\n s.chars.each do |x|\n prev_flag = flag\n if x == \"U\" \n counter += 1 \n elsif x == \"D\"\n counter -= 1\n end\n flag = \"valley\" if counter < 0\n flag = \"sea level\" if counter == 0 \n if prev_flag == \"valley\" && flag == \"sea level\"\n valleys += 1\n elsif prev_flag == \"sea level\" && flag == \"valley\"\n valleys += 1\n end\n end\n valleys/2\nend",
"def staircase(height)\n\t(1..height).each do |i|\n \t(1..height-i).each do |j|\n \t\tprint(\" \") \n \tend\n \t(1..i).each do |k|\n \tif k == i then\n \tputs(\"#\")\n \telse\n \tprint(\"#\")\n \tend\n \tend\n\tend\nend",
"def superweening_adorningly(counterstand_pyrenomycetales)\n end",
"def conta_vicini(i,j,game)\n vicini = 0\n \n #### BORDI RIGIDI\n #if i > 0\n # vicini += 1 if game[:griglia][i-1][j]\n #end\n #if i > 0 && j > 0\n # vicini += 1 if game[:griglia][i-1][j-1]\n #end\n #if i > 0 && j < CELLE_PER_RIGA\n # vicini += 1 if game[:griglia][i-1][j+1]\n #end\n #if j > 0\n # vicini += 1 if game[:griglia][i][j-1]\n #end\n #if j < CELLE_PER_RIGA-1\n # vicini += 1 if game[:griglia][i][j+1]\n #end\n #if i < CELLE_PER_COLONNA-1 && j > 0\n # vicini += 1 if game[:griglia][i+1][j-1]\n #end\n #if i < CELLE_PER_COLONNA-1\n # vicini += 1 if game[:griglia][i+1][j]\n #end\n #if i < CELLE_PER_COLONNA-1 && j < CELLE_PER_RIGA-1\n # vicini += 1 if game[:griglia][i+1][j+1]\n #end\n \n #======================================================\n ### BORDI RICORSIVI\n i += CELLE_PER_COLONNA if i-1 < 0\n j += CELLE_PER_RIGA if j-1 < 0\n i -= CELLE_PER_COLONNA if i+1 >= CELLE_PER_COLONNA\n j -= CELLE_PER_RIGA if j+1 >= CELLE_PER_RIGA\n \n vicini += 1 if game[:griglia][i-1][j]\n vicini += 1 if game[:griglia][i-1][j-1]\n vicini += 1 if game[:griglia][i-1][j+1]\n vicini += 1 if game[:griglia][i][j-1]\n vicini += 1 if game[:griglia][i][j+1]\n vicini += 1 if game[:griglia][i+1][j-1]\n vicini += 1 if game[:griglia][i+1][j]\n vicini += 1 if game[:griglia][i+1][j+1]\n \n return vicini\nend",
"def sol inp\n k, ins = inp.split(' ',2)\n k = k.to_i\n ps, pr, pi, pu, pw, pd, pl = ins.split.map(&:to_f)\n\n @ps = ps\n @pr = pr\n @pu = pu\n @pw = pw\n @pd = pd\n @pl = pl\n\n #\n # required_wins = 2\n # # winning 1st set\n # first_set = ps*pi + pr*(1-pi)\n # # winning 2nd set\n # first_set * winning_another_set + (1-first_set)*winning_another_set\n #\n # required_wins.times do |i|\n # count = 0\n # while count <= i\n # wins[i] = win_scene(pi,ps,pr, count)\n # count+=1\n # break if count == i\n # lose_scene(pi,ps,pr, pr,count)\n # end\n # end\n\n # winning second set after winning first + winning second set after winning one\n # wins[0]*win_scene(pi,ps,pr) + (1-wins[0])*lose_scene(pi,ps,pr)\n\n def win_scene(pi,round,required_wins,current_wins)\n return 0 if round >= required_wins\n # puts \"w #{' '*round},#{required_wins},#{current_wins})\"\n sunny = (round == 0) ? pi : (pi+(@pu*@pw))\n sunny = 1.0 if sunny > 1\n sunny = 0.0 if sunny < 0\n chance = sunny*@ps + (1-sunny)*@pr\n binding.pry if chance > 1\n\n if required_wins == current_wins+1\n chance\n else\n # return 0 if round > 100\n return 0 if (10**7*chance).to_i < 1\n wins = win_scene(sunny,round+1,required_wins,current_wins+1)\n # lose = lose_scene(sunny,round+1,required_wins,current_wins+1)\n chance * (wins)#+ (1-chance)*lose\n end\n end\n\n def lose_scene(pi,round,required_wins,current_wins)\n return 0 if round >= required_wins\n # puts \"l #{' '*round},#{required_wins},#{current_wins})\"\n sunny = (round == 0) ? pi : (pi-(@pd*@pl))\n sunny = 1.0 if sunny > 1\n sunny = 0.0 if sunny < 0\n chance = sunny*@ps + (1-sunny)*@pr\n binding.pry if chance > 1\n\n if required_wins == current_wins\n chance\n else\n # return 0 if round > 100\n return 0 if (10**7*chance).to_i < 1\n wins = win_scene(sunny,round+1,required_wins,current_wins+1)\n # lose = lose_scene(sunny,round+1,required_wins,current_wins+1)\n chance * (wins) #+ (1-chance)*lose\n end\n end\n\n # a = win_scene(pi,0,1,0)\n b = win_scene(pi,0,k,0)\n c = lose_scene(pi,0,k,0)\n # c = (k > 1) ? lose_scene(pi,1,k,0) : 0\n\n puts b\n puts c\n b +c\n # wtf?\n # 0.4* win_scene(pi,0,k,0)+ (1-0.6)*lose_scene(pi,0,k,0)\n\n# def smth(pi, ps, pr, setcount=0)\n# arr[1] = arr[0]\n# end\n# # set 2+ ?\n# set2 = ((ps+pu)*pw + ps*(1-pw))*pi\n# (1-set1)*((ps-pd)*pl + ps*(1-pl))\n# if k > 1\n# (k-1).times do\n#\n# end\n# end\nend",
"def stylish_chef\n best_hairstyle = \"Guy Fieri\"\n return \"Martha Stewart\"\n \"Guy Fieri\"\nend",
"def strain; end",
"def sw(t, s, c)\n\n end",
"def biomagnetism_doughface_sissiness(avignonese_antrorsely)\n end",
"def victory(joueur)\n\t\t# On définit les 8 possibilités de victoires si elles se vérifient les 3 dans la combinaison donnée alors la partie s'arrête\n\t\tif (plateau[0] == joueur.value) && (plateau[1] == joueur.value) && (plateau[2] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\n\t\telsif (plateau[3] == joueur.value) && (plateau[4] == joueur.value) && (plateau[5] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[0] == joueur.value) && (plateau[3] == joueur.value) && (plateau[6] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[2] == joueur.value) && (plateau[4] == joueur.value) && (plateau[6] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[0] == joueur.value) && (plateau[4] == joueur.value) && (plateau[8] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[2] == joueur.value) && (plateau[5] == joueur.value) && (plateau[8] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[1] == joueur.value) && (plateau[4] == joueur.value) && (plateau[7] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telse\n\t\t\treturn\n\t\tend\n\tend",
"def stair_jumps(stairs)\n return 0 if stairs < 0\n return 1 if stairs == 0\n\n return stair_jumps(stairs - 1) + stair_jumps(stairs - 2) + stair_jumps(stairs - 3)\nend",
"def victorymethod\r\n\tputs \"\"\r\n\tputs \"\"\r\n\tputs \"\"\r\n\tputs \"*******************************************************************************************************\"\r\n\t\r\n\tif $v25 == 0 and $v50 == 0 and $v75 == 0\r\n\t\tflawlessvictory\r\n\telse \r\n\t\tif $v25 == 1 and $v50 == 0 and $v75 == 0\r\n\t\t\tvictory25\r\n\t\telse \r\n\t\t\tif $v25 == 0 and $v50 == 1 and $v75 == 0\r\n\t\t\t\tvictory50\r\n\t\t\telse \r\n\t\t\t\tif $v25 == 0 and $v50 == 0 and $v75 == 1\r\n\t\t\t\t\tvictory75\r\n\t\t\t\telse \r\n\t\t\t\t\tif $v25 == 1 and $v50 == 1 and $v75 == 0\r\n\t\t\t\t\t\tvictory2550\r\n\t\t\t\t\telse \r\n\t\t\t\t\t\tif $v25 == 1 and $v50 == 0 and $v75 == 1\r\n\t\t\t\t\t\t\tvictory2575\r\n\t\t\t\t\t\telse \r\n\t\t\t\t\t\t\tif $v25 == 0 and $v50 == 1 and $v75 == 1\r\n\t\t\t\t\t\t\t\tvictory5075\t\r\n\t\t\t\t\t\t\telse \r\n\t\t\t\t\t\t\t\tif $v25 == 1 and $v50 == 1 and $v75 == 1\r\n\t\t\t\t\t\t\t\t\tvictory255075\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\tend\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\r\nend",
"def lcs_backtrack_pam(v, w, sigma)\n <<-DOC\n LCSBACKTRACK(v, w)\n for i ← 0 to |v|\n si, 0 ← 0\n for j ← 0 to |w| \n s0, j ← 0\n for i ← 1 to |v|\n for j ← 1 to |w|\n si, j ← max{si-1, j, si,j-1, si-1, j-1 + 1 (if vi = wj)}\n if si,j = si-1,j\n Backtracki, j ← \"↓\"\n if si, j = si, j-1\n Backtracki, j ← \"→\"\n if si, j = si-1, j-1 + 1\n Backtracki, j ← \"↘\"\n return Backtrack\n DOC\n # puts v\n # puts w\n\n pam = pam_250()\n s = []\n backtrack = []\n\n max_score = 0\n max_i = 0\n max_j = 0\n\n (0..(v.length)).each {|i| s[i] = []}\n (0..(v.length)).each {|i| backtrack[i] = []}\n\n (0..(v.length)).each do |i| \n # s[i][0] = i*(-sigma)\n s[i][0] = 0\n backtrack[i][0] = \"down\"\n end\n\n (0..(w.length)).each do |j| \n # s[0][j] = j*(-sigma)\n s[0][j] = 0\n backtrack[0][j] = \"right\"\n end\n\n (1..(v.length)).each do |i|\n (1..(w.length)).each do |j|\n # print \"i #{i} j #{j} #{v[i-1]} #{w[j-1]} #{pam[v[i-1]][w[j-1]]} \"\n down_val = s[i-1][j] - sigma\n right_val = s[i][j-1] - sigma\n diag_val = s[i-1][j-1] + pam[v[i-1]][w[j-1]]\n s[i][j] = [down_val, right_val, diag_val].max\n if s[i][j] <= 0\n s[i][j] = 0\n backtrack[i][j] = \"free\"\n elsif s[i][j] == down_val\n backtrack[i][j] = \"down\"\n elsif s[i][j] == right_val\n backtrack[i][j] = \"right\"\n elsif s[i][j] == diag_val\n backtrack[i][j] = \"diag\"\n end\n # print [down_val, right_val, diag_val].join(\" \") + \" \"\n # print \"S: \" + s[i][j].to_s + \" \"\n # print \"Backtrack: \" + backtrack[i][j] + \" \\n\"\n if max_score <= s[i][j]\n max_score = s[i][j]\n max_i = i\n max_j = j\n end\n end \n end\n\n return [s[max_i][max_j], max_i, max_j, backtrack]\n end",
"def function_a(v1)\n\tprint \"Please input an adjective: \"\n\tinput = gets.chomp.downcase.capitalize\n#\tputs input\n\tprint \"Please input a business: \"\n\tinput2 = gets.chomp.downcase\n\ta1 = \"\"\n\ta1 = input2[0].match(/a|e|i|o|u/).nil? ? \"a \" : \"an \"\n#\tputs input2\n\tprint \"Please input an animal: \"\n\tinput3 = gets.chomp.downcase\n\ta2 = \"\"\n\ta2 = input3[0].match(/a|e|i|o|u/).nil? ? \"a \" : \"an \"\n#\tputs input3\n\tprint \"Please input a noise: \"\n\tinput4 = gets.chomp.downcase\n\ta3 = \"\"\n\ta3 = input4[0].match(/a|e|i|o|u/).nil? ? \"a \" : \"an \"\n#\tputs input4, \"\",\n\tputs \"\"\n\tputs v1.upcase,\n\t\tinput + \" Macdonald had \" + a1 + input2 + \", E-I-E-I-O\",\n\t\t\"And on that \" + input2 + \" he had \" + a2 + input3 + \", E-I-E-I-O\",\n\t\t\"With \" + a3 + input4 + \" \" + input4 + \" here\",\n\t\t\"And \" + a3 + input4 + \" \" + input4 + \" there,\",\n\t\t\"Here \" + a3 + input4 + \", there \" + a3 + input4 + \",\",\n\t\t\"Everywhere \" + a3 + input4 + \" \" + input4 + \",\",\n\t\tinput + \" Macdonald had \" + a1 + input2 + \", E-I-E-I-O!\"\nend",
"def goodVsEvil(good, evil)\n # good_power, evil_power = 0, 0\n # good.split.each_with_index do |num, i|\n # if i < 3\n # good_power += num.to_i * (i + 1)\n # elsif i < 5\n # good_power += num.to_i * i\n # elsif i == 5\n # good_power += num.to_i * 2 * i\n # end\n # end\n god = good.split.each_with_index.inject(0) do |sum, (num, i)|\n if i < 3\n sum + num.to_i * (i + 1)\n elsif i < 5\n sum + num.to_i * i\n elsif i == 5\n sum + num.to_i * 2 * i\n end\n end\n \n \n evl = evil.split.each_with_index.inject(0) do |sum, (num, i)|\n case i\n when 0\n sum + num.to_i * (i + 1)\n when 1, 2, 3\n sum + num.to_i * 2\n when 4\n sum + num.to_i * (i - 1)\n when 5\n sum + num.to_i * i\n when 6\n sum + num.to_i * (i + 4) \n end\n end\n \n if evl > god\n str = \"Evil eradicates all trace of Good\"\n elsif evl < god\n str = \"Good triumphs over Evil\"\n else\n str = \"No victor on this battle field\"\n end\n \n \"Battle Result: #{str}\"\nend",
"def sisoku(a, b)\r\n puts a+b\r\n puts a-b\r\n puts a*b\r\n puts a/b\r\n end",
"def vogal(str)\n vogals = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n cons = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n# splitting the string given into arrays \n str = str.chars\n str_new = str.map do |char|\n#looping the string into the next letter\n if vogals.include?(char)\n vogals.rotate(1)[vogals.index(char)]\n else cons.include?(char)\n cons.rotate(1)[cons.index(char)]\n end\n end\n#joining the strings back\n str_new.join\nend",
"def remanet(concupiscibleness, torve_resack)\n seeker(bloomery, crumbcloth_lacepod, inspirant_inalterably)\n antispadix_provencalize(galactophthysis, saintlike)\n japheth(auresca, squamatine, vitalist_pheal)\n end",
"def wreathmaking(squilla, noncarbonate_tilly, angionosis_parvolin)\n prealarm_plaidie_premolar(philofelist, unacceptableness_printless)\n suzan()\n end",
"def proof_of_stake\n title(\"Proof of Stake\")\n\n eco_scale = \"https://en.wikipedia.org/wiki/Economies_of_scale\"\n pros1 = \"Energy efficient\"\n pros2 = \"More expensive to attack for attackers\"\n pros3 = \"Not susceptible to ecnomies of scale \\n\\t (for more details about this topic click on this link:\\n\\t #{eco_scale}).\"\n\n pros = [pros1, pros2, pros3]\n\n nothing_at_stake = \"https://medium.com/coinmonks/understanding-proof-of-stake-the-nothing-at-stake-theory-1f0d71bc027\"\n cons = \"nothing-at-stake problem \\n(for more details click on this link:\\n#{nothing_at_stake})\"\n\n\n ppc = {name: \"Peercoin\", website: \"https://peercoin.net/\"}\n pivx = {name: \"Pivx\", website: \"https://pivx.org/\"}\n rdd = {name: \"Reddcoin\", website: \"https://reddcoin.com/\"}\n\n used_by = [ppc, pivx, rdd]\n\n consensus_type = \"Competitive consensus\"\n\n\n explanation = \"\"\"\n The proof of stake was created as an alternative to the proof of work (PoW),\n to tackle inherent issues in the latter. Here instead of using mining, you\n have to have some stake(coins) in the system. So, if you own 10% of the\n stake(coins), then your probability of mining next block will be 10%.\n \"\"\"\n\n further_reading = \"https://en.wikipedia.org/wiki/Proof_of_stake\"\n\n p_o_s = {\n \"pros\" => pros,\n \"cons\" => cons,\n \"used_by\" => used_by,\n \"consensus_type\" => consensus_type,\n \"explanation\" => explanation,\n \"further_reading\" => further_reading\n }\n\n choice = \"0\"\n\n while !choice.include?(\"Q\") && !choice.include?(\"q\")\n choice = consensus_features\n if choice.include?(\"1\")\n puts \"Pros:\"\n p_o_s[\"pros\"].each_with_index { |val, index| puts \"\\t#{index+1}) #{val}\" }\n\n cons = p_o_s[\"cons\"]\n puts \"Cons: #{cons}\"\n elsif choice.include?(\"2\")\n puts \"Used by:\"\n p_o_s[\"used_by\"].each_with_index do\n |valeur, index|\n puts \"#{index+1})\"\n valeur.each do\n |key, value| puts \" #{key}: #{value}\"\n end\n end\n puts \"And others.\"\n elsif choice.include?(\"3\")\n consensus_type = p_o_s[\"consensus_type\"]\n puts \"Type: #{consensus_type}\"\n elsif choice.include?(\"4\")\n explanation = p_o_s[\"explanation\"]\n puts \"Explanation: #{explanation}\"\n elsif choice.include?(\"5\")\n further_reading = p_o_s[\"further_reading\"]\n puts \"Further Reading: #{further_reading}\"\n elsif choice.include?(\"Q\") || choice.include?(\"q\")\n break\n else\n puts \"Error\"\n end\n end\n\nend",
"def swasify(word)\r\n word = word.upcase.gsub(' ','').strip\r\n width = (word.length*2 - 1)*4 - 3\r\n sc = width/2\r\n word.split('')[0..-2].each do |letter|\r\n puts \" \"*sc + letter\r\n sc -= 2\r\n end\r\n sc2 = word.length*4 - 5\r\n puts \" \"*sc + word[-1] + \" \"*sc2 + word[-1]\r\n sc3 = 3\r\n \r\n word.split('')[1..-2].reverse.each do |letter|\r\n sc += 2\r\n sc2 -= 4 \r\n puts \" \"*sc + letter + \" \"*sc2 + letter + \" \"*sc3 + letter\r\n sc3 += 4\r\n end\r\n\r\n puts (word[0] + ' '*sc3)*2 + word[0]\r\n\r\n sc = 2\r\n word.split('')[1..-2].each do |letter|\r\n sc3 -= 4\r\n puts \" \"*sc + letter + \" \"*sc3 + letter + \" \"*sc2 + letter\r\n sc += 2\r\n sc2 += 4\r\n end\r\n\r\n sc2 = word.length*4 - 5\r\n puts \" \"*sc + word[-1] + \" \"*sc2 + word[-1]\r\n sc += sc2 - 1\r\n word.split('')[0..-2].reverse.each do |letter|\r\n puts \" \"*sc + letter\r\n sc -= 2\r\n end \r\nend",
"def hiv_protease(aa_array,start_aa=1)\n out_hash = {}\n sdrm = {}\n sdrm[23] = ['L',['I']]\n sdrm[24] = ['L',['I']]\n sdrm[30] = ['D',['N']]\n sdrm[32] = ['V',['I']]\n sdrm[46] = ['M',['I','L','V']]\n sdrm[47] = ['I',['V','A']]\n sdrm[48] = ['G',['V','M']]\n sdrm[50] = ['I',['V','L']]\n sdrm[53] = ['F',['L']]\n sdrm[54] = ['I',['V','L','M','T','A','S']]\n sdrm[73] = ['G',['S','T','C','A']]\n sdrm[76] = ['L',['V']]\n sdrm[82] = ['V',['A','T','S','F','L','C','M']]\n sdrm[83] = ['N',['D']]\n sdrm[84] = ['I',['V','A','C']]\n sdrm[85] = ['I',['V']]\n sdrm[88] = ['N',['D','S']]\n sdrm[90] = ['L',['M']]\n aa_length = aa_array.size\n end_aa = start_aa + aa_length - 1\n (start_aa..end_aa).each do |position|\n array_position = position - start_aa\n if sdrm.keys.include?(position)\n wt_aa = sdrm[position][0]\n test_aa = aa_array[array_position]\n if test_aa.size == 1\n unless wt_aa == test_aa\n if sdrm[position][1].include?(test_aa)\n out_hash[position] = [wt_aa,test_aa]\n end\n end\n else\n test_aa_array = test_aa.split(\"/\")\n if (test_aa_array & sdrm[position][1])\n out_hash[position] = [wt_aa,test_aa]\n end\n end\n end\n end\n return out_hash\nend",
"def outsense_edist(u, v)\n\n # initialize m and n\n m = u.length\n n = v.length\n\n # create hash of arrays where \n # hash.key holds h and array index holds d\n # thus hash[h][d] = front(h, d) = i\n front = Hash.new(Array.new)\n \n # initialize d with 0 for the first front\n d = 0\n\n # calculate front(0, 0)\n front[0][d] = lcplen(u, v, m, n)\n \n # till front(n - n, d) = m\n while front[n-m][d] != m-1\n\n # increase d\n d += 1\n \n # fronts calculated according to script\n ((-d)..d).each do |h|\n front[h][d] = outsense_next_front(front, h, d, u, v, m, n)\n end\n end\n\n # length of array with hash key m - n (= h) is \n # as long as the index of its last entry (= d) + 1\n return (front[m-n].length - 1)\nend",
"def output_lcs_pam(backtrack, v, w, i, j)\n\n v_str = \"\"\n w_str = \"\"\n\n loop do\n # break if (i == 0 || j == 0)\n break if (i == 0)\n # puts i.to_s + \" \" + j.to_s + \" \" + backtrack[i][j]\n if backtrack[i][j] == \"free\"\n break\n elsif backtrack[i][j] == \"down\"\n v_str += v[i-1]\n w_str += \"-\"\n i -= 1\n elsif backtrack[i][j] == \"right\"\n v_str += \"-\"\n w_str += w[j-1]\n j -= 1\n else\n v_str += v[i-1]\n w_str += w[j-1]\n i -= 1\n j -= 1\n end\n end\n\n puts v_str.reverse\n puts w_str.reverse\n\n end",
"def kochright\n v = start - finish\n v /= 3\n v + finish\n end",
"def kcode() end",
"def pig_latin(word)\n\nif word[0..0] =~ /[A-Z]/\n is_cap = true\nelse\n is_cap = false\nend\n\n if word.slice(0) == \"a\" ||\n word.slice(0) == \"e\" ||\n word.slice(0) == \"i\" ||\n word.slice(0) == \"o\" ||\n word.slice(0) == \"u\"\n word += \"way\"\n\n elsif word.slice(0..1) == \"qu\"\n word = word.slice(2..word.length) + word.slice(0..1) + \"ay\"\n\n elsif word.slice(1) == \"a\" ||\n word.slice(1) == \"e\" ||\n word.slice(1) == \"i\" ||\n word.slice(1) == \"o\" ||\n word.slice(1) == \"u\"\n word = word.slice(1..word.length) + word.slice(0) + \"ay\"\n\n elsif word.slice(2) == \"a\" ||\n word.slice(2) == \"e\" ||\n word.slice(2) == \"i\" ||\n word.slice(2) == \"o\" ||\n word.slice(2) == \"u\"\n word = word.slice(2..word.length) + word.slice(0..1) + \"ay\"\n\n elsif word.slice(3) == \"a\" ||\n word.slice(3) == \"e\" ||\n word.slice(3) == \"i\" ||\n word.slice(3) == \"o\" ||\n word.slice(3) == \"u\"\n word = word.slice(3..word.length) + word.slice(0..2) + \"ay\"\n\n end\n if is_cap == true\n return word.capitalize\n else\n return word\n end\nend",
"def staircase(num)\n to_return = {}\n 1.upto num do |x|\n next if x.even? == true\n all_nums = Array.new(x) {|i| i + 1}\n even_nums = all_nums.select {|i| i.even? == true}\n to_return[x] = even_nums\n end\n to_return\nend",
"def survery_results(vampire_level)\n case vampire_level\n when 0\n puts 'Probably not a vampire'\n when 1 || 6\n puts 'Probably a vampire'\n when 2\n puts 'Almost certainly a vampire'\n when 3\n puts 'Definitely a vampire'\n when 5\n puts 'Results inconclusive.'\n end\n puts '--------------------------------'\nend",
"def cherty_hottish(define, henchboy, systematically_youthen)\n sprag_squamaceous(demilitarize)\n osiridean_seedily(coopering_frenzelite, columellia)\n end",
"def scoobydoo(villian, villians)\n letters = ('a'..'z').to_a\n numbers = (0..25).to_a\n letters_to_numbers = letters.zip(numbers).to_h\n numbers_to_letters = numbers.zip(letters).to_h\n\n villians_downcase = villians.map { |v| v.downcase.delete(' ') }\n villians_hash = (villians_downcase).zip(villians).to_h\n\n s = villian.reverse.chars.rotate(5)\n new = []\n (0...s.size).each do |i|\n if i.even?\n new[i] = s[i]\n else\n num = (letters_to_numbers.fetch(s[i]) + 5) % 26\n new[i] = numbers_to_letters.fetch(num)\n end\n end\n\n villians_hash.fetch(new.join)\n\nend",
"def sluggish_octopus(the_sea)\n the_sea.each_with_index do |fish1, idx|\n longest = true\n\n the_sea.each_with_index do |fish2, idx2|\n next if idx == idx2\n longest = false if fish1.length > fish2.length\n end\n\n return fish1 if longest\n end\nend",
"def strauss; end",
"def checker(a,player)\ncounter = 0\ni = 5\ncontroller = 0\nplayer = player\n\nwhile (i >= 0 && counter != 4)\nj = 0\n\twhile ( j <= 5 && counter != 4)\n\t\tcontrol = 1\n\t\tstorer = j \n\t\tstorer2 = i\n\t\tcounter = 0\n\n\t\twhile(a[storer2][storer] != \" \" && counter != 4 && control != 0)\t\n\t\t\tif (a[storer2][storer+1] != nil && a[storer2][storer] == player && storer <= 5)\n\t\t\tcounter = counter + 1\n\t\t\tstorer = storer + 1\n\t\t\telse\n\t\t\tcounter = 1\n\t\t\tcontrol = 0\n\t\t\tend\n\t\tend\n\t\t\tif (counter == 4)\n\t\t\treturn true\n\t\t\tend\n\n\t\tstorer = j\n\t\tstorer2 = i\n\t\tcontrol = 1\n\t\tcounter = 0\n\n\t\twhile(a[storer2][storer] != \" \" && counter != 4 && control != 0)\n\t\t\tif(a[storer2-1][storer+1] != nil && player == a[storer2][storer] && storer <= 5 && storer2 >=0)\n\t\t\tcounter = counter + 1\n\t\t\tstorer2 = storer2 - 1\n\t\t\tstorer = storer + 1\n\t\t\telse\n\t\t\tcounter = 1\n\t\t\tcontrol = 0\n\t\t\tend\n\t\tend\n\t\t\tif (counter == 4)\t\t\t\n\t\t\treturn true\n\t\t\tend\n\n\n\t\tstorer = j\n\t\tstorer2 = i\n\t\tcontrol = 1\n\t\tcounter = 0\n\n\t\twhile(a[storer2][storer] != \" \" && counter != 4 && control != 0)\n\t\t\tif(a[storer2-1][storer] != nil && a[storer2][storer] == player && storer2 >= 0)\n\t\t\tcounter = counter + 1\n\t\t\tstorer2 = storer2 - 1\n\t\t\telse\n\t\t\tcounter = 1\n\t\t\tcontrol = 0\n\t\t\tend\n\n\t\tend\n\t\t\tif (counter == 4)\n\t\t\treturn true\n\t\t\tend\n\n\t\tstorer = j\n\t\tstorer2 = i\n\t\tcontrol = 1\n\t\tcounter = 0\n\n\t\twhile(a[storer2][storer] != \" \" && counter != 4 && control != 0)\n\t\t\tif(a[storer2-1][storer-1] != nil && a[storer2][storer] == player && storer2 >= 0 && storer >=0)\n\t\t\tcounter = counter + 1\t\t\t\n\t\t\tstorer2 = storer2 - 1\n\t\t\tstorer = storer - 1\n\t\t\telse\t\t\t\n\t\t\tcounter = 1\n\t\t\tcontrol = 0\n\t\t\tend\n\t\tend\n\n\t\t\tif (counter == 4)\n\t\t\treturn true\n\t\t\tend\n\n\tj = j +1\n\tend\ni = i - 1\nend\nend",
"def stir_mixing_bowl\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 17 )\n value = nil\n stir_mixing_bowl_start_index = @input.index\n ordinal39 = nil\n num40 = nil\n\n success = false # flag used for memoization\n\n begin\n # rule memoization\n if @state.backtracking > 0 and already_parsed_rule?( __method__ )\n success = true\n return value\n end\n # at line 246:5: stir ( ( WS the )? ( WS ordinal )? WS mixing WS bowl )? WS for_ WS num WS minutes EOF\n @state.following.push( TOKENS_FOLLOWING_stir_IN_stir_mixing_bowl_993 )\n stir\n @state.following.pop\n # at line 246:10: ( ( WS the )? ( WS ordinal )? WS mixing WS bowl )?\n alt_35 = 2\n look_35_0 = @input.peek( 1 )\n\n if ( look_35_0 == WS )\n look_35_1 = @input.peek( 2 )\n\n if ( look_35_1.between?( ST, TH ) || look_35_1.between?( T__16, T__17 ) || look_35_1.between?( T__40, T__41 ) )\n alt_35 = 1\n end\n end\n case alt_35\n when 1\n # at line 246:11: ( WS the )? ( WS ordinal )? WS mixing WS bowl\n # at line 246:11: ( WS the )?\n alt_33 = 2\n look_33_0 = @input.peek( 1 )\n\n if ( look_33_0 == WS )\n look_33_1 = @input.peek( 2 )\n\n if ( look_33_1.between?( T__16, T__17 ) )\n alt_33 = 1\n end\n end\n case alt_33\n when 1\n # at line 246:12: WS the\n match( WS, TOKENS_FOLLOWING_WS_IN_stir_mixing_bowl_997 )\n @state.following.push( TOKENS_FOLLOWING_the_IN_stir_mixing_bowl_999 )\n the\n @state.following.pop\n\n end\n # at line 246:21: ( WS ordinal )?\n alt_34 = 2\n look_34_0 = @input.peek( 1 )\n\n if ( look_34_0 == WS )\n look_34_1 = @input.peek( 2 )\n\n if ( look_34_1.between?( ST, TH ) )\n alt_34 = 1\n end\n end\n case alt_34\n when 1\n # at line 246:22: WS ordinal\n match( WS, TOKENS_FOLLOWING_WS_IN_stir_mixing_bowl_1004 )\n @state.following.push( TOKENS_FOLLOWING_ordinal_IN_stir_mixing_bowl_1006 )\n ordinal39 = ordinal\n @state.following.pop\n\n end\n match( WS, TOKENS_FOLLOWING_WS_IN_stir_mixing_bowl_1010 )\n @state.following.push( TOKENS_FOLLOWING_mixing_IN_stir_mixing_bowl_1012 )\n mixing\n @state.following.pop\n match( WS, TOKENS_FOLLOWING_WS_IN_stir_mixing_bowl_1014 )\n @state.following.push( TOKENS_FOLLOWING_bowl_IN_stir_mixing_bowl_1016 )\n bowl\n @state.following.pop\n\n end\n match( WS, TOKENS_FOLLOWING_WS_IN_stir_mixing_bowl_1020 )\n @state.following.push( TOKENS_FOLLOWING_for__IN_stir_mixing_bowl_1022 )\n for_\n @state.following.pop\n match( WS, TOKENS_FOLLOWING_WS_IN_stir_mixing_bowl_1024 )\n @state.following.push( TOKENS_FOLLOWING_num_IN_stir_mixing_bowl_1026 )\n num40 = num\n @state.following.pop\n match( WS, TOKENS_FOLLOWING_WS_IN_stir_mixing_bowl_1028 )\n @state.following.push( TOKENS_FOLLOWING_minutes_IN_stir_mixing_bowl_1030 )\n minutes\n @state.following.pop\n match( EOF, TOKENS_FOLLOWING_EOF_IN_stir_mixing_bowl_1032 )\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = {\n :cmd => :stir_mixing_bowl,\n :args => {\n :mixing_bowl => ordinal39.to_i,\n :minutes => ( num40.nil? ? nil : num40.value )\n }\n }\n \n # <-- action\n end\n\n success = true\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 17 )\n memoize( __method__, stir_mixing_bowl_start_index, success ) if @state.backtracking > 0\n\n end\n \n return value\n end",
"def sea; end",
"def sweep_stairs\n turn_off\n end",
"def climb_stairs(n)\n return 1 if n == 1\n return 2 if n == 2\n phi = (Math.sqrt(5) + 1)/2\n inverse_phi = (Math.sqrt(5) - 1)/2\n \n return ((phi ** (n + 1) - (inverse_phi ** n))/Math.sqrt(5)).round\nend",
"def translate(a)\n\tvoyel = [\"a\",\"e\",\"i\",\"o\",\"u\"]\ncheck = 0\nn = 0\nx = a \n words = a.split(/\\W+/)\n words.each do |a|\n\tok = voyel.include?(a[0])\n\tif ok == true \n\t\ta = a + \"ay\"\n\t\treturn a \n\tend\n while check <= 4\n\tb = a.slice(0..check)\n\n\tcheck = check + 1\n \n\tok = voyel.include?(x[check])\n\ttest1 = \"qu\".include?(x[check])\n\tif test1 == true \n\t\tif check == 1\n\t\t\tb = a.slice(0..check)\n\t\t\ta = a + b + \"ay\"\n\t\treturn a[2..-1]\n\t elsif check == 2\n\t \tb = a.slice(1..check)\n\t \t\ta = a + b + \"ay\"\n\t \treturn a[3..-1]\n\t elsif check == 3 \n\t \t\ta = a + b + \"ay\"\n\t \treturn a[4..-1]\n\t end\n\tend\n\n\tif ok == true \n\t\tif check == 1\n\t\t\ta = a + b + \"ay\"\n\t\treturn a[1..-1]\n\t elsif check == 2\n\t \t\ta = a + b + \"ay\"\n\t \treturn a[2..-1]\n\t elsif check == 3 \n\t \t\ta = a + b + \"ay\"\n\t \treturn a[3..-1]\n\t end\n\tend\nend\nend\nend",
"def sharp; accidental; end",
"def swim\n\t\tputs \"swim swim swim\" \n\tend",
"def sammy(vel)\nend",
"def pig_latin(word)\n if word.slice(0..1) == \"qu\"\n word = word.slice(1..word.length) + word.slice(0) + \"ay\" \n elsif word.slice(0) == \"a\" ||\n word.slice(0) == \"e\" ||\n word.slice(0) == \"i\" ||\n word.slice(0) == \"o\" ||\n word.slice(0) == \"u\"\n word += \"way\"\n elsif word.slice(1) == \"a\" ||\n word.slice(1) == \"e\" ||\n word.slice(1) == \"i\" ||\n word.slice(1) == \"o\" ||\n word.slice(1) == \"u\"\n word = word.slice(1..word.length) + word.slice(0) + \"ay\"\n elsif word.slice(2) == \"a\" ||\n word.slice(2) == \"e\" ||\n word.slice(2) == \"i\" ||\n word.slice(2) == \"o\" ||\n word.slice(2) == \"u\"\n word = word.slice(2..word.length) + word.slice(0..1) + \"ay\"\n else word.slice(3) == \"a\" ||\n word.slice(3) == \"e\" ||\n word.slice(3) == \"i\" ||\n word.slice(3) == \"o\" ||\n word.slice(3) == \"u\"\n word = word.slice(3..word.length) + word.slice(0..2) + \"ay\"\n end\n return word\nend",
"def koan_4\nend",
"def dominant_octopus(fish)\n #sorted = []\n return fish if fish.length < 2\n pivot = fish.first\n left = fish[1..-1].select { |feesh| feesh.length <= pivot.length }\n #p left\n right = fish[1..-1].select { |feesh| feesh.length > pivot.length }\n\n dominant_octopus(left) + [pivot] + dominant_octopus(right)\n \n\n\nend",
"def vocal_en_nombre_piloto(pilotos) \n pos = 0\n mayor = 0\n\n for i in 0..pilotos.size-1\n nombre = pilotos[i].downcase\n\n contador = 0\n for j in 0..nombre.size-1\n letra = nombre[j]\n if letra == 'a' || letra == 'e' || letra == 'i' || letra =='o' || letra =='u'\n contador = contador + 1\n end\n end\n\n if contador > mayor\n mayor = contador\n pos = i\n end\n end\n\n return pilotos[pos]\n\nend",
"def dominant_octopus(the_sea)\n\nend",
"def solution4(input)\n end",
"def kingdom\n end",
"def spy_name(str)\n #CREATE VARIABLES FOR VOWELS AND CONSONANTS\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n consonants = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n #CHANGE STRING FIRST INTO ARRAY THAT MAKES EACH WORD A VALUE THEN REVERSE THEM. \n #THEN TURN ARRAY BACK INTO STRING AND DOWNCASE ANY LETTER.\n #THEN TURN STRING BACK INTO ARRAY THAT TAKES EACH INDIVIDUAL CHARACATER AS A VALUE.\n str = str.split(' ').reverse.join.downcase\n str = str.split('')\n #CREATE TEMPORARY VARIABLE STR_NEW TO EQUEL STR THEN CHANGE BUMP EACH \n #VOWEL AND CONSONANT TO THE NEXT ONE IN LINE. \n str_new = str.map do |char|\n if vowels.include?(char)\n vowels.rotate(1)[vowels.index(char)]\n elsif consonants.include?(char)\n consonants.rotate(1)[consonants.index(char)]\n else\n char\n end\n end\n #TURN ARRAY BACK INTO STRING.\n str_new.join\nend",
"def determine_pair(main_code)\n #double for loop?\n test_code = main_code.clone\n\n for i in (0..99) do\n\n test_code[1] = i\n\n for i in (0..99) do\n test_code[2] = i\n computed = test_code.clone\n computer(computed)\n if computed[0]==19690720\n puts \"When origin=19690720, noun= #{test_code[1]}, verb=#{test_code[2]}\"\n\n end\n\n end\n\n end\n\nend",
"def puf_syndrome\n \n end",
"def staircase(n)\n\tanswer = Hash.new\n\tevens = []\n\todds = []\n\n\t1.upto(n) do |x|\t\t\t#0 is even\n\t\tevens << x if x.even?\n\t\todds << x if x.odd?\n\tend\n\todds.each do |x|\n\t\tanswer[x] = evens.select do |y|\n\t\t\ty if y < x\n\t\t\tend\n\t\tend\nend",
"def determine_vampire(name, correct_age, serve_garlic, health_insurance, employee_num, allergy)\n vampire_scale = 0\n if correct_age && (serve_garlic || health_insurance)\n vampire_scale = 1\n end\n if !correct_age && (!serve_garlic || !health_insurance)\n vampire_scale = 2\n end\n if !correct_age && !serve_garlic && !health_insurance\n vampire_scale = 3\n end\n if name == \"Drake Cula\" || name == \"Tu Fang\"\n vampire_scale = 4\n end\n\n if allergy == \"sunshine\" #If employee gave allergy of \"sunshine\", skips other criteria and prints that they are \"Probably a vampire\"\n vampire_scale = 2\n end\n\n puts \"*************************************\"\n puts \" VAMPIRE TEST RESULTS\"\n puts \"\"\n case vampire_scale\n when 0\n puts \"Employee #{employee_num + 1}: Results inconclusive.\"\n when 1\n puts \"Employee #{employee_num + 1}: Probably not a vampire.\"\n when 2\n puts \"Employee #{employee_num + 1}: Probably a vampire.\"\n when 3\n puts \"Employee #{employee_num + 1}: Almost certainly a vampire.\"\n when 4\n puts \"Employee #{employee_num + 1}: Definitely a vampire\"\n end\n puts \"*************************************\"\nend",
"def climbingStaircase(n, k,arr = [])\n if n.zero?\n [arr]\n else\n (1..[k,n].min).map {|i| climbingStaircase(n-i,k,arr + [i])}.flatten(1)\n end\nend",
"def koan_3\nend",
"def staircase(n)\n (1..n).each { |i|\n print(\" \"*(n-i) + \"#\"*i + \"\\n\") unless n == i\n }\n print \"#\"*n; $stdout.flush\nend",
"def transform line\n i = 1\n tortoise = line[i]\n hare = line[i * 2]\n while tortoise != hare\n i += 1\n tortoise = line[i]\n hare = line[i * 2]\n end\n v = i\n\n mu = 0\n tortoise = line[mu]\n hare = line[v * 2 + mu]\n while tortoise != hare\n mu += 1\n tortoise = line[mu]\n hare = line[v * 2 + mu]\n end\n\n lam = 1\n hare = line[mu + lam]\n while tortoise != hare\n lam += 1\n hare = line[mu + lam]\n end\n #puts \"v mu lam %d %d %d\" % [v, mu, lam]\n \n line[mu, lam] \nend",
"def checkmate(k,a)\n # Checkmate test where king may be: k_attacks - used - king_attaks - cells_behind_the_king\n all = all_position\n p used = [k,a]\n k_attacks = king_position(k).uniq \n a_attacks = (amazon_postion(a) - free_cells(k,a)).uniq\n stand_positions = a_attacks - k_attacks - used\n safe_squares = (all - k_attacks - a_attacks - used).uniq\n ans = stand_positions.reduce([]){ |acc,x| \n if (safe_squares & king_position(x)).empty?\n p x\n acc.push(x) \n end\n acc\n }\n p ans\n ans.size\n \nend",
"def stairway\n puts '''\n ___\n ___|\n ___|\n ___|\n ___|\n ___|\n ___|\n ___|\n |\n '''\n end",
"def knight_radiant; end",
"def vrat_soucet_vah(jedinec)\n soucet = 0\n citac = 0\n jedinec.each do |prvek| \n if(prvek)then\n soucet += @pole_vah[citac].to_i\n end\n citac +=1\n end\n return soucet\n end",
"def solution(a, b, k)\n # write your code in Ruby 2.2\n e = b / k\n s = (a-1) / k\n\n e - s\nend",
"def pikapika\n puts \"▕▔╲┊┊┊┊┊┊┊╱▔▏┊┊┊\".colorize(:yellow)\n puts \"┊╲╱╲┊┊┊┊┊╱╲╱┊┊┊┊\".colorize(:yellow)\n puts \"┊┊╲┈╲▂▂▂╱┈╱┊┊┊╱╲\".colorize(:yellow)\n puts \"┊┊╱┈┈┈┈┈┈┈╲┊┊╱┈┈╲\".colorize(:yellow)\n puts \"┊┊▏▕▆▍▂▕▆▍▕┊╱┈┈┈╱\".colorize(:yellow)\n puts \"┊▕╭╮┈┳┻┳┈╭╮▏╲┈┈╱\".colorize(:yellow)\n puts \"┊┊╲╯┈╰━╯┈╰╱┊╱┈┈╲\".colorize(:yellow)\n puts \"┊┊╱┈┈┈┈┈┈┈╲┊╲┈┈┈╲\".colorize(:yellow)\n puts \"┊▕╲┈▕┈┈┈▏┈╱▏┊╱┈╱\".colorize(:yellow)\n puts \"┊▕┈▔▔┈┈┈▔▔┈▏╱┈╱┊\".colorize(:yellow)\n puts \"┊▕┈┈┈┈┈┈┈┈▕▔┈╱┊┊\".colorize(:yellow)\n puts \"┈┈╲┈┈┈┈┈┈┈╱▔▔┈┈┈\".colorize(:yellow)\n puts \"┈┈▕▂╱▔▔▔╲▂▏┈┈┈┈┈\".colorize(:yellow)\n #art from: http://textart4u.blogspot.com/2012/04/pikachu-text-art-ascii-art.html\nend",
"def am(amida, y, x)\n #p \"==== NOW ===\"\n #p y \n #p x\n #p amida\n\n if y == H \n #p \"=====GOAL\"\n if x + 1 == K\n $cnt = $cnt + 1\n end\n return\n end\n\n if x < W - 1\n to_right_amida = Marshal.load(Marshal.dump(amida))\n to_right_amida[y][x] = 1\n am(to_right_amida, y + 1, x + 1)\n end\n\n to_streight_amida = Marshal.load(Marshal.dump(amida))\n am(to_streight_amida, y + 1, x)\n\n if x > 0\n to_left_amida = Marshal.load(Marshal.dump(amida))\n to_left_amida[y][x - 1] = 1\n am(to_left_amida, y + 1, x - 1)\n end\nend",
"def staircase(n)\r\n # Write your code here\r\n empty = \" \"\r\n value = \"#\"\r\n n.times do |num|\r\n \tnumber = num + 1\r\n first = empty*(n-number).abs\r\n second = value*number\r\n puts first+second\r\n end\r\nend",
"def kind\n# if [side1, side2, side3].uniq?\n# return :scalene\n# elsif side1 == side2 and side2 == side3\n# # self = equilateral\n# return :equilateral\n# else\n# return :isosceles\n# end\n\n\n# if side1 || side2 || side3 < 0\n# begin\n# raise TriangleError\n# rescue TriangleError => error\n# puts error.message\n# end\n if side1 <= 0 || side2 <= 0 || side3 <= 0\n raise TriangleError\n elsif (side1 + side2) <= side3 || (side2 + side3) <= side1 || (side1 + side3) <= side2\n raise TriangleError\n elsif side1 == side2 and side2 == side3\n #self = equilateral\n return :equilateral\n elsif\n side1 == side2 || side2 == side3 || side1 == side3\n #side1 == side2 and side1 != side3 || side2 == side3 and side1 != side3\n # self = isosceles\n return :isosceles\n else\n #self = scalene\n return :scalene\n end\n\n\n end",
"def suivre; end",
"def solution(roman)\n split = roman.split(\"\")\n last_value = 0\n split.reduce(0) do |final, char|\n current = CONVERSION[char.upcase]\n binding.pry\n if current >= last_value\n final += current\n else\n final -= current\n end\n binding.pry\n last_value = current\n final\n end\nend",
"def slop!; end",
"def slop!; end",
"def triangle_bk(s1, s2, s3)\n sorted_sides = [s1, s2, s3].sort\n if sorted_sides.any? { |side| side <= 0} || (sorted_sides[0] + sorted_sides[1] <= sorted_sides[2])\n :invalid\n elsif sorted_sides.all? { |side| side == sorted_sides[0]}\n :equilateral\n elsif sorted_sides[0] != sorted_sides[1] && sorted_sides[1] != sorted_sides[2]\n :scalene\n else\n :isosceles\n end\nend",
"def silly_adjective; end",
"def stairs\n warrior.direction_of_stairs\n end",
"def word\n i = rand(78)\n if i <= 2\n \"ie\"\n elsif i <= 3\n \"au\"\n elsif i < 10\n v + c\n elsif i < 17\n c + v\n elsif i < 25\n v + c + v\n elsif i < 33\n c + v + c\n elsif i < 43\n v + c + v + c\n elsif i < 53\n c + v + c + v\n elsif i < 68\n v + c + v + c + v\n elsif i < 71\n c + v + c + v + c\n elsif i < 74\n v + c + v + c + v + c\n elsif i < 76\n c + v + c + v + c + v\n elsif i < 77\n v + c + v + c + v + c + v\n elsif i <= 78\n c + v + c + v + c + v + c\n end\nend",
"def solution(s, p, q)\n # write your code in Ruby 2.2\n g = s.length + 1\n a = (s.length + 1)**3\n c = (s.length + 1)**2\n tmp = []\n res = []\n tmp.push 0\n o = 0\n s.split('').each do |i|\n o += if i == 'T'\n 1\n elsif i == 'G'\n g\n elsif i == 'C'\n c\n else\n a\nend\n tmp.push o\n end\n (0...p.length).each do |k|\n o = tmp[q[k] + 1] - tmp[p[k]]\n if o >= a\n res.push 1\n elsif o >= c\n res.push 2\n elsif o >= g\n res.push 3\n else\n res.push 4\n end\n end\n res\nend",
"def crack_vigenere file\n answer = \"\"\n words = gets_key_word_from_file file, (find_key_lengths_by_file file)\n words.each.with_index do |word, i|\n answer += \"Attempt: #{i + 1} : #{word} \\n\".red + \"#{v_decode_file 'secretcode.txt', word} \\n\"\n end\n answer\nend",
"def take_bath\n self.hygiene += 4\n return \"♪ Rub-a-dub just relaxing in the tub ♫\"\n @hygiene\n end",
"def slaughter_mice cages, index, debug = false\r\n\t# start off the slaughter by starting at the index\r\n\tcages = rearrange cages, index\r\n\r\n\t# the eating loop\r\n\tloop {\r\n\t\tp cages if debug\r\n\r\n\t\tcaughtIndex = nil # assume we fail\r\n\t\tcages.each_with_index do |cage, i|\r\n\t\t\tif cage == i+1 # arrays are 0-indexed\r\n\t\t\t\tcaughtIndex = i # the cage with the mouse we are going to eat\r\n\t\t\t\tbreak # out of each_with_index\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\t# did we fail?\r\n\t\treturn false unless caughtIndex\r\n\r\n\t\t# nope! yay!\r\n\t\t# now eat the mouse\r\n\t\tcages = nom cages, caughtIndex\r\n\t\tputs \"nommed #{caughtIndex}\" if debug\r\n\r\n\t\t# did we eat all of them?\r\n\t\treturn true if cages.empty?\r\n\t}\r\nend",
"def mycelial_gristmilling()\n xenopteri_shebang(sectwise_cessor, ungular_pietism)\n end",
"def staircase(n)\n n.times do |i|\n (n-1-i).times { |i| print ' '}\n (i+1).times { |i| print '#'}\n puts\n end\nend",
"def shodan\n\t\tprint (\"\\n\"+$lin+\"\\n\")\n\t\tprint (\"\\n Ok, you can try to test \\n (f) Test honypot ip's file \\n (h) Test target host on honypot \\n (s) Shodan search \\n (b) Back \\n\\n\")\n\t\tprint (\" --> \")\n\t\tway = gets().chomp()\n\t\tif way == \"f\" then\n\t\t\thonyf\n\t\telsif way == \"h\"\n\t\t\thonyt\n\t\telsif way == \"s\"\n\t\t\tshod\n\t\telsif way == \"b\"\n\t\t\twhiche\n\n\t\tend\n\tend",
"def dominant_octopus(fish)\n return fish if fish.length < 2\n pivot_el = [fish.first]\n left = fish[1..-1].select { |el| el.length <= fish.first.length }\n right = fish[1..-1].select { |el| el.length > fish.first.length }\n dominant_octopus(left) + pivot_el + dominant_octopus(right)\nend",
"def karatsuba(x, y)\n midway_x = x.to_s.length/2\n x_array = x.to_s.split('')\n a = x_array[0...midway_x].join('').to_i\n b = x_array[midway_x...(x_array.length)].join('').to_i\n\n midway_y = y.to_s.length/2\n y_array = y.to_s.split('')\n c = y_array[0...midway_y].join('').to_i\n d = y_array[midway_y...(y_array.length)].join('').to_i\n\n puts \"x: #{x}, a: #{a}, b: #{b}\"\n puts \"y: #{y}, c: #{c}, d: #{d}\"\n\n n = midway_x * 2\n\n step1 = a * c\n step2 = b * d\n step3 = (a+b) * (c+d)\n step4 = step3 - step2 - step1\n step5 = (10**n * step1) + step2 + (step4 * 10**(n/2))\n\n puts \"\\nstep1: #{step1}\"\n puts \"step2: #{step2}\"\n puts \"step3: #{step3}\"\n puts \"step4: #{step4}\"\n puts \"\\nstep5: #{step5}\"\nend",
"def adiposis(androtomy_vallary, untriumphant_bombidae, octuply_cytomitome)\n kobellite(donkeyism, microperthite_billsticking, skiffless)\n end",
"def solve(s)\n s_arr = s.split(\" \")\n acro = \"\"\n s_arr.each do |word|\n if word.downcase != 'and'\n acro += word[0].upcase\n end\n end\n\n return acro\nend",
"def snake_it_up(string)\n if string[0] = \"s\"\n counter = 0\n newword= string\n while (counter < 10) do\n newword[counter] = newword[0] + newword[counter]\n counter += 1\n #binding.pry\n end\nnewword\nelse\n string\n end\nend",
"def output_lcs_blosum(backtrack, v, w, i, j)\n\n v_str = \"\"\n w_str = \"\"\n\n loop do\n # break if (i == 0 || j == 0)\n break if (i == 0)\n # puts i.to_s + \" \" + j.to_s + \" \" + backtrack[i][j]\n if backtrack[i][j] == \"down\"\n v_str += v[i-1]\n w_str += \"-\"\n i -= 1\n elsif backtrack[i][j] == \"right\"\n v_str += \"-\"\n w_str += w[j-1]\n j -= 1\n else\n v_str += v[i-1]\n w_str += w[j-1]\n i -= 1\n j -= 1\n end\n end\n\n # puts v_str.reverse\n # puts w_str.reverse\n return [v_str.reverse, w_str.reverse]\n # return [v_str, w_str]\n <<-DOC\n OUTPUTLCS(backtrack, v, i, j)\n if i = 0 or j = 0\n return\n if backtracki, j = \"↓\"\n OUTPUTLCS(backtrack, v, i - 1, j)\n else if backtracki, j = \"→\"\n OUTPUTLCS(backtrack, v, i, j - 1)\n else\n OUTPUTLCS(backtrack, v, i - 1, j - 1)\n output vi \n DOC\n\n # return if (i == 0 || j == 0)\n # if backtrack[i][j] == \"del\"\n # output_lcs_blosum(backtrack, v, w, i-1, j) \n # print \"-\"\n # elsif backtrack[i][j] == \"add\"\n # output_lcs_blosum(backtrack, v, w, i, j-1) \n # print \"-\"\n # # elsif backtrack[i][j] == \"mismatch\"\n # # output_lcs(backtrack, v, w, i-1, j-1) \n # # print \"-\"\n # else\n # output_lcs_blosum(backtrack, v, w, i-1, j-1) \n # print v[i-1]\n # print w[j-1]\n # end\n end",
"def sluggish_octopus(fishes) \n fishes.each_with_index do |fish1, i1|\n max_length = true\n fishes.each_with_index do |fish2, i2|\n next if i1 == i2\n # puts \"#{fish1} --- #{fish2}\"\n max_length = false if fish1.length < fish2.length\n end\n\n return fish1 if max_length == true\n end\nend",
"def villain; end",
"def villain; end",
"def villain; end",
"def flaw_mutations_determination(roll)\n case roll\n when 01..02\n @@flaw_mutations << \"Abnormal Anxiety\"\n when 03..04\n @@flaw_mutations << \"Altered Digestive Tract\"\n when 05..06\n @@flaw_mutations << \"Baldness\"\n when 07..17\n @@flaw_mutations << \"Birth Defect\"\n when 18..19\n @@flaw_mutations << \"Blocked Sinuses\"\n when 20..21\n @@flaw_mutations << \"Chronic Acne\"\n when 22..23\n @@flaw_mutations << \"Chronic Dermatitis\"\n when 24..25\n @@flaw_mutations << \"Chronic IngrownHairs\"\n when 26..27\n @@flaw_mutations << \"Chronic Ulcers\"\n when 28..29\n @@flaw_mutations << \"Coronary Thrombosis\"\n when 30..31\n @@flaw_mutations << \"Degenerated Nervous System\"\n when 32..33\n @@flaw_mutations << \"Dizziness\"\n when 34..35\n @@flaw_mutations << \"Early Menopause (females only)\"\n when 36..37\n @@flaw_mutations << \"Excessive Lung Fluid\"\n when 38..39\n @@flaw_mutations << \"Exhaustion\"\n when 40..41\n @@flaw_mutations << \"Extensive Warts\"\n when 42..43\n @@flaw_mutations << \"Extreme Halitosis\"\n when 44..45\n @@flaw_mutations << \"Faulty Immune System\"\n when 46\n @@flaw_mutations << \"Flammable Tissues\"\n when 47\n @@flaw_mutations << \"Hemophilia\"\n when 48..49\n @@flaw_mutations << \"Hormone Disorder\"\n when 50..51\n @@flaw_mutations << \"Inadequate Nerve Endings\"\n when 52\n @@flaw_mutations << \"Increased Aging\"\n when 53\n @@flaw_mutations << \"Increased Flatulence\"\n when 54..57\n @@flaw_mutations << \"Intense Allergy\"\n when 58..59\n @@flaw_mutations << \"Male Menopause (males only)\"\n when 60..61\n @@flaw_mutations << \"Migraine Headaches\"\n when 62..63\n @@flaw_mutations << \"Osteoporosis\"\n when 64..65\n @@flaw_mutations << \"Permanent Rhinitis\"\n when 66..67\n @@flaw_mutations << \"Perpetual Hiccups\"\n when 68..69\n @@flaw_mutations << \"Pre-Senile Dementia\"\n when 70..71\n @@flaw_mutations << \"Psoriasis\"\n when 72..73\n @@flaw_mutations << \"Reactionary Scent\"\n when 74\n @@flaw_mutations << \"Repeat Paralysis\"\n when 75\n @@flaw_mutations << \"Sonic Intolerance\"\n when 76..77\n @@flaw_mutations << \"Sterility\"\n when 78..79\n @@flaw_mutations << \"Tapeworms\"\n when 80..81\n @@flaw_mutations << \"Tooth Decay\"\n when 82..86\n @@flaw_mutations << \"Toxic Susceptibility\"\n when 87..88\n @@flaw_mutations << \"Tranquilizer Agent\"\n when 89..94\n @@flaw_mutations << \"Visual Disorder\"\n when 95..96\n @@flaw_mutations << \"Voice Disorder\"\n when 97..98\n @@flaw_mutations << \"Weeping\"\n when 99..00\n @@flaw_mutations << \"Whistle Croup\"\n end\n end",
"def solve_two_vs_three_vs_five\n return if @arr[1].nil? || @arr[6].nil?\n\n #p \"1,6: #{@arr[1]},#{@arr[6]}\"\n\n @words.filter{|x| x.length == 5 && @hash[x].nil?}.each{|w|\n if @arr[1].chars.all?{|c| w.chars.include?(c)}\n solved(3, w)\n elsif w.chars.all?{|c2| @arr[6].chars.include?(c2)}\n solved(5, w)\n else\n solved(2, w)\n end\n }\n end",
"def stir_ingredient_into_the_mixing_bowl\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 18 )\n value = nil\n stir_ingredient_into_the_mixing_bowl_start_index = @input.index\n ordinal41 = nil\n text42 = nil\n\n success = false # flag used for memoization\n\n begin\n # rule memoization\n if @state.backtracking > 0 and already_parsed_rule?( __method__ )\n success = true\n return value\n end\n # at line 256:5: stir WS text WS into ( WS the )? ( WS ordinal )? WS mixing WS bowl EOF\n @state.following.push( TOKENS_FOLLOWING_stir_IN_stir_ingredient_into_the_mixing_bowl_1049 )\n stir\n @state.following.pop\n match( WS, TOKENS_FOLLOWING_WS_IN_stir_ingredient_into_the_mixing_bowl_1051 )\n @state.following.push( TOKENS_FOLLOWING_text_IN_stir_ingredient_into_the_mixing_bowl_1053 )\n text42 = text\n @state.following.pop\n match( WS, TOKENS_FOLLOWING_WS_IN_stir_ingredient_into_the_mixing_bowl_1055 )\n @state.following.push( TOKENS_FOLLOWING_into_IN_stir_ingredient_into_the_mixing_bowl_1057 )\n into\n @state.following.pop\n # at line 256:26: ( WS the )?\n alt_36 = 2\n look_36_0 = @input.peek( 1 )\n\n if ( look_36_0 == WS )\n look_36_1 = @input.peek( 2 )\n\n if ( look_36_1.between?( T__16, T__17 ) )\n alt_36 = 1\n end\n end\n case alt_36\n when 1\n # at line 256:27: WS the\n match( WS, TOKENS_FOLLOWING_WS_IN_stir_ingredient_into_the_mixing_bowl_1060 )\n @state.following.push( TOKENS_FOLLOWING_the_IN_stir_ingredient_into_the_mixing_bowl_1062 )\n the\n @state.following.pop\n\n end\n # at line 256:36: ( WS ordinal )?\n alt_37 = 2\n look_37_0 = @input.peek( 1 )\n\n if ( look_37_0 == WS )\n look_37_1 = @input.peek( 2 )\n\n if ( look_37_1.between?( ST, TH ) )\n alt_37 = 1\n end\n end\n case alt_37\n when 1\n # at line 256:37: WS ordinal\n match( WS, TOKENS_FOLLOWING_WS_IN_stir_ingredient_into_the_mixing_bowl_1067 )\n @state.following.push( TOKENS_FOLLOWING_ordinal_IN_stir_ingredient_into_the_mixing_bowl_1069 )\n ordinal41 = ordinal\n @state.following.pop\n\n end\n match( WS, TOKENS_FOLLOWING_WS_IN_stir_ingredient_into_the_mixing_bowl_1073 )\n @state.following.push( TOKENS_FOLLOWING_mixing_IN_stir_ingredient_into_the_mixing_bowl_1075 )\n mixing\n @state.following.pop\n match( WS, TOKENS_FOLLOWING_WS_IN_stir_ingredient_into_the_mixing_bowl_1077 )\n @state.following.push( TOKENS_FOLLOWING_bowl_IN_stir_ingredient_into_the_mixing_bowl_1079 )\n bowl\n @state.following.pop\n match( EOF, TOKENS_FOLLOWING_EOF_IN_stir_ingredient_into_the_mixing_bowl_1081 )\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = {\n :cmd => :stir_ingredient_into_the_mixing_bowl,\n :args => {\n :mixing_bowl => ordinal41.to_i,\n :ingredient => ( text42.nil? ? nil : text42.value )\n }\n }\n \n # <-- action\n end\n\n success = true\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 18 )\n memoize( __method__, stir_ingredient_into_the_mixing_bowl_start_index, success ) if @state.backtracking > 0\n\n end\n \n return value\n end"
] |
[
"0.6092161",
"0.5839368",
"0.581617",
"0.5801575",
"0.5756847",
"0.5713174",
"0.56979847",
"0.56849897",
"0.56801516",
"0.56405145",
"0.56197953",
"0.5580649",
"0.55666673",
"0.55611664",
"0.5553605",
"0.55462885",
"0.55389935",
"0.552456",
"0.54853827",
"0.54641163",
"0.545166",
"0.5448788",
"0.54431415",
"0.5409756",
"0.53998977",
"0.53670853",
"0.535735",
"0.5333057",
"0.5330754",
"0.5319463",
"0.53136206",
"0.5299803",
"0.52963257",
"0.5292409",
"0.5284146",
"0.52785957",
"0.52611506",
"0.52609646",
"0.5256319",
"0.52476203",
"0.52423704",
"0.5242367",
"0.52394193",
"0.52391464",
"0.5237812",
"0.5236139",
"0.5223654",
"0.52190214",
"0.5218563",
"0.5217331",
"0.52061933",
"0.52055484",
"0.52017474",
"0.5201373",
"0.52010983",
"0.5194296",
"0.5188754",
"0.518725",
"0.5182117",
"0.51802033",
"0.5170612",
"0.51699436",
"0.51691467",
"0.5147277",
"0.5136781",
"0.513518",
"0.5134608",
"0.51335186",
"0.5131689",
"0.5113788",
"0.5109453",
"0.5108761",
"0.5103272",
"0.5095988",
"0.50867635",
"0.50863296",
"0.50863296",
"0.50830853",
"0.5077956",
"0.5073843",
"0.5070181",
"0.5060372",
"0.50521356",
"0.5050354",
"0.50454825",
"0.50367",
"0.50355446",
"0.5031838",
"0.5031143",
"0.5029026",
"0.50275856",
"0.5022577",
"0.5016159",
"0.5015436",
"0.5015083",
"0.5014349",
"0.5014349",
"0.5014349",
"0.501333",
"0.50113094",
"0.50107926"
] |
0.0
|
-1
|
codewars kata: sum of topleft to bottomright diagonals
|
def diagonalSum(matrix)
(0...matrix.size).map { |i| matrix[i][i] }.reduce(&:+)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sum_of_diagonals\r\n\tresult = []\r\n\tresult.push 1\r\n\twidth = 3\r\n\twhile width <= 1001\r\n\t\tresult.push width**2, width**2 - (width-1), width**2 - (width-1)*2, width**2 - (width-1)*3\r\n\t\twidth += 2\r\n\tend\r\n\treturn result.reduce(:+)\r\nend",
"def sum_diagonals(width)\r\n\t# Start on 1 so sum = 1\r\n\tsum = 1\r\n\tcounter = 1\r\n\t# Iterate through number of layers of spiral\r\n\t(2...width).step(2).each do |x|\r\n\t\t# Sum diagonals for each side\r\n\t\t4.times do\r\n\t\t\tcounter += x\r\n\t\t\tsum += counter\r\n\t\tend\r\n\tend\r\n\tputs sum\r\nend",
"def sum_diagonals(n)\n return n if n <= 1\n 4 * (n**2) - 6 * (n-1) + sum_diagonals(n-2)\nend",
"def diagonalSum(matrix)\ntotal = 0\n (0...matrix.length).each {|sub| total += matrix[sub][sub]}\nreturn total\nend",
"def count_diagonals(x, y)\n total_count = 0\n \n # Upper Left\n if x - 1 >= 0 and y + 1 < $height and $canvas[x - 1][y + 1] == 1 then total_count += 1 end\n # Bottom Left\n if x - 1 >= 0 and y - 1 >= 0 and $canvas[x - 1][y - 1] == 1 then total_count += 1 end\n # Upper Right\n if x + 1 < $width and y + 1 < $height and $canvas[x + 1][y + 1] == 1 then total_count += 1 end\n # Bottom Right\n if x + 1 < $width and y - 1 >= 0 and $canvas[x + 1][y - 1] == 1 then total_count += 1 end\n\n return total_count\nend",
"def matrix_region_sum(matrix, top_left_coords, bottom_right_coords)\n\nend",
"def right_to_diagonal_left_approach\n largest_prod = 0\n\n for each_row in (0..15)\n for col in (0..19)\n each_col = 19 - col\n a = $grid_of_numbers[each_row][each_col]\n b = $grid_of_numbers[each_row+1][each_col-1]\n c = $grid_of_numbers[each_row+2][each_col-2]\n d = $grid_of_numbers[each_row+3][each_col-3]\n #puts \"#{a} #{b} #{c} #{d}\"\n curr_prod = a*b*c*d\n if curr_prod > largest_prod\n largest_prod = curr_prod\n end\n end\n end\n \n return largest_prod\nend",
"def left_to_diagonal_right_approach\n largest_prod = 0\n for each_row in (0..15)\n for each_col in (0..15)\n a = $grid_of_numbers[each_row][each_col]\n b = $grid_of_numbers[each_row+1][each_col+1]\n c = $grid_of_numbers[each_row+2][each_col+2]\n d = $grid_of_numbers[each_row+3][each_col+3]\n\n curr_prod = a*b*c*d\n if curr_prod > largest_prod\n largest_prod = curr_prod\n end\n end\n end\n \n return largest_prod\nend",
"def diagonal_slide(row, col) # oh cool try the .downto here instead of the reverse always nice to try new things even though it doesn't make for the most sensical code as per https://stackoverflow.com/questions/2070574/is-there-a-reason-that-we-cannot-iterate-on-reverse-range-in-ruby love it the last time you did reverse just because you didn't think about it until later now knowing this you can do it this way love it ah nevermind no need but would have been great to write smaller.downto(0).map oh well lol remember that for some other time love Ruby what a great language\n (row <= col) ? (smaller, larger = row, col) : (smaller, larger = col, row) # establish which number is the smaller of the two and the larger love it you have some crazy short code lol. For the nw and se diagonals\n nw = check_blocking_pieces((1..smaller).map { |offset| [row-offset, col-offset] }) # go by smaller because that's which one will hit 0 first\n ne = check_blocking_pieces((1..(7-row)).map { |offset| [row+offset, col-offset] if ((col-offset) >= 0) }.compact) # Need to use .compact to remove all the nil elements that were returned by .map since can't quite use select or reject since you *do* want to return the evaluation of the array but ah well code smells http://ruby-doc.org/core-1.9.3/Array.html#method-i-compact if you don't get rid of these nils then in the check_blocking_pieces() you'll run into an error since it'll be trying to get an index of a nil value in moves lol amaizng that even the most misleading errors you can debug with debugger and a good eye fuck byebug is so powerful # go by larger but check that the thing doesn't go out of bounds, the only bounds that it could go out if you have the row correct is col-offset being less than 0 # ahh these return nil for everything it doesn't return for so that's the error love it great catch # don't know what you would do without byebug it's literally god mode\n sw = check_blocking_pieces((1..(7-col)).map { |offset| [row-offset, col+offset] if ((row-offset) >= 0) }.compact) # go up until col == 7 as long as row is above or equal to 0, could do it the other way too, as long as col <= 7 go until row hits 0, but same thing\n se = check_blocking_pieces((1..(7-larger)).map { |offset| [row+offset, col+offset] }) # increase up until the largest one equals 7 basically there might be some nil issues with this but this should work can't wait to check it if you add them all up and there are some nils they might not add let's see, ah nope thankfully map returns an empty array fucking love it Ruby is the best\n (nw + ne + sw + se)\nend",
"def matrix_region_sum(matrix, top_left_coords, bottom_right_coords)\n ix = top_left_coords[0]\n iy = top_left_coords[1]\n jx = bottom_right_coords[0]\n jy = bottom_right_coords[1]\n result = 0\n i = ix\n while i <= jx\n j = iy\n while j <= jy\n result += matrix[i][j]\n j += 1\n end\n i += 1\n end\n result\nend",
"def matrix_region_sum(matrix, top_left_coords, bottom_right_coords)\n\n x1, y1 = top_left_coords\n x2, y2 = bottom_right_coords\n sum = 0\n (x1..x2).each do |x|\n (y1..y2).each do |y|\n puts matrix[x][y]\n sum += matrix[x][y]\n end\n end\n sum\n\nend",
"def diagonalCount(n)\n\n#First number saved as \"start.\"\"\nstart = n**2\n\n#Solution is the variable to which we add all elements of the diagonals.\nsolution = 0\n\n#Increment is the gap between elements of diagonals. \nincrement = n - 1\n\n#The first loop continues until start == 1.\nwhile start > 1\n\n#The number of diagonal elements for each \"increment.\"\nk = 4\n\n#The second, nested loop, which repeats four times for each increment\n#and adds the diagonal entries (stored in the \"start\" variable)\n#to solution.\nwhile k > 0\nsolution += start\nstart -= increment\nk -= 1\nend\n\n#After each sequence of 4 entries, we subtract two from the increment\n#variable to add the diagonal elements in the next \"square\" within the\n#grid.\nincrement -= 2\n\nend\n\n#After the final loop is complete, start will equal 1, but will not\n#have been added to solution. The final step is to add 1 and output\n#the solution.\n\nputs solution + 1\n\nend",
"def diagonalSum(matrix)\n # case Matrix[*matrix].column_size\n # when Matrix[*matrix].row_size\n x=0\n y=0\n p matrix.class\n while x<matrix.flatten.size do \n y=y+matrix.flatten[x]\n x=x+matrix.size+1 \n # print \"x= #{x}, y = #{y}, \"\n end\n y\nend",
"def matrix_region_sum(matrix, top_left_coords, bottom_right_coords)\n sum = 0\n (top_left_coords[0]..bottom_right_coords[0]).each do |row|\n (top_left_coords[1]..bottom_right_coords[1]).each do |col|\n sum += matrix[row][col]\n end\n end\n\n sum\nend",
"def squaragonal?(array)\n diag_right = 1\n diag_left = 1\n\n (0...array.length - 1).each do |i|\n (0...array.length - 1).each do |j|\n diag_right += 1 if array[i][j] == array[i + 1][j + 1]\n # diag_left += 1 if array[array.length - i - 1][j] == array[array.length - i - 2][j + 1]\n diag_left += 1 if array[-(i + 1)][j] == array[-(i + 2)][j + 1]\n end\n end\n if diag_right == array.length || diag_left == array.length\n return true\n else\n return false\n end\nend",
"def diagonals\n down_diag = []\n up_diag = []\n \n # push sets of coordinates that make up both diagonals\n 0.upto(@size - 1) do |idx|\n down_diag << [idx, idx]\n up_diag << [idx, @size - 1 - idx]\n end\n\n [down_diag, up_diag].map do |diag|\n diag.map { |pos| self[pos] }\n end\n end",
"def diagonals\n vals = [[], []]\n (0...size).each do |i|\n vals[0].push(get_square({:column => i, :row => i}))\n vals[1].push(get_square({:column => i, :row => size - i - 1}))\n end\n vals.map {|v| Row.new(size, {:vals => v}) }\n end",
"def corner_sum(n)\n return 1 if n == 1\n # n*n + n*n - (n-1) + n*n - 2*(n-1) + n*n - 3*(n-1) \n return 4*n*n - 6*(n-1)\nend",
"def spiral_corner_sum(size)\n return 1 if size == 1\n \n step = size - 1\n top_right = size ** 2\n top_left = top_right - step\n bottom_left = top_left - step\n bottom_right = bottom_left - step\n \n return top_right + top_left + bottom_left + bottom_right\nend",
"def matrixElementsSum(matrix)\r\n(0..matrix.length-2).each do |floor_number|\r\n\r\n (0..matrix[floor_number].length-1).each do |column_number|\r\n if matrix[floor_number][column_number] == 0\r\n matrix[floor_number+1].delete_at(column_number)\r\n matrix[floor_number+1].insert(column_number, 0)\r\n end\r\n end\r\n \r\nend\r\n\r\nreturn matrix.flatten.inject(:+)\r\n\r\nend",
"def diagonal_left\n end",
"def diagonals\n [board.map.with_index { |row, i| row[i] },\n board.map.with_index { |row, i| row[row.size - i - 1] }]\n end",
"def solve( n = 1_001 )\n # For each enclosing rectangle, index 0 < i < (n - 1)/2, the corner values\n # are given by:\n #\n # lr[0] = ll[0] = ul[0] = ur[0] = 1, and\n #\n # lr[i+1] = lr[i] + 8*i + 2\n # ll[i+i] = ll[i] + 8*i + 4 = lr[i] + 10*i + 4\n # ul[i+1] = ul[i] + 8*i + 6 = lr[i] + 12*i + 6\n # ur[i+i] = ur[i] + 8*i + 8 = lr[i] + 14*i + 8\n #\n # The sum of the corners of rectangle i for 0 < i is then given by\n #\n # sum[i+1] = lr[i+1] + ll[i+1] + ul[i+1] + ur[i+1] = 4*lr[i] + 44*i + 20\n # sum[i+1] = sum[i] + 32*i + 20\n\n sum = 4\n total = 0\n\n 0.upto( n >> 1 ) do |i|\n total += sum\n sum += ((i << 3) + 5) << 2\n end\n\n # The center 1 was counted four times, so adjust.\n total - 3\n end",
"def matrix_region_sum(matrix, top_left_coords, bottom_right_coords)\n total_sum = 0\n\n (top_left_coords[0]..bottom_right_coords[0]).each do |row_idx|\n (top_left_coords[1]..bottom_right_coords[1]).each do |col_idx|\n total_sum += matrix[row_idx][col_idx]\n end\n end\n\n total_sum\nend",
"def diagonals\n down_diag = [[0, 0], [1, 1], [2, 2]]\n up_diag = [[0, 2], [1, 1], [2, 0]]\n \n [down_diag, up_diag].map do |diag|\n diag.map { |row, col| @rows[row][col] }\n end\n end",
"def sum_prod_diags(matrix)\n\n require 'matrix'\n \n # ability to rotate nested array 90 degrees (for right - to left calc)\n def rotate(matrix)\n newMatrix, finalMatrix, i = [], [], 0\n (matrix.length > matrix[0].length ? matrix.length : matrix[0].length).times do\n matrix.map { |row| row[i] != nil ? newMatrix << row[i] : nil }\n i+=1\n end\n newMatrix.each_slice(matrix.length).to_a.reverse\n end\n \n # get the diagonal and all lower diagonals\n def diags_sum_array(matrix)\n sum = []\n length = matrix.column(0).count\n \n d = matrix\n i = length\n while i > 0 do\n # multiply the values of the diagonal\n sum << d.each(:diagonal).inject(:*)\n d = d.first_minor(0,(i-1))\n i -= 1\n end\n \n # get the upper diagonals\n trans = matrix.transpose\n y = length - 1\n while y > 0 do\n # multiply the values of the diagonal\n trans = trans.first_minor(0,(y))\n sum << trans.each(:diagonal).inject(:*)\n y -= 1\n end\n \n return sum\n \n end\n\n # run for left to right calc\n d_sum = diags_sum_array(Matrix[*matrix])\n \n # run for right to left calc (using rotate array method)\n a_sum = diags_sum_array(Matrix[*rotate(matrix)])\n\n # add each result, return the difference in the two\n return d_sum.inject(:+) - a_sum.inject(:+)\n \nend",
"def crossingSum(matrix, a, b) \n sum = 0;\n \n matrix.each_with_index do |row, index|\n if a == index\n row.each { |x| sum += x}\n break\n end\n end\n\n matrix.transpose.each_with_index do |row, index|\n if b == index\n row.each_with_index { |col, index| sum += col if a != index }\n end\n end\n sum\nend",
"def gen_diagonal_up(row,col)\n array_diagonals =[]\n 0.upto(5).each do |num|\n if ( row - num < 0 || col + num > 6)\n break\n end\n\n array_diagonals << [row-num, col+num] \n end\n array_diagonals.map{|coordinates| @grid[coordinates[1]][coordinates[0]]}\n end",
"def check_diagonally_right(x, y, numbers_in_product)\n (0...numbers_in_product).inject(1) do |product, i|\n product * matrix[y+i][x+i]\n end\n end",
"def check_diagonals\n 0.upto(2) do |i|\n 0.upto(3) do |j|\n if (@board[j][i].to_s + @board[j + 1][i + 1].to_s + @board[j + 2][i + 2].to_s + @board[j + 3][i + 3].to_s).match(/RRRR|BBBB/) != nil\n return true\n end\n end\n 3.upto(6) do |j|\n if (@board[j][i].to_s + @board[j - 1][i + 1].to_s + @board[j - 2][i + 2].to_s + @board[j - 3][i + 3].to_s).match(/RRRR|BBBB/) != nil\n return true\n end\n end\n end\n return false\n end",
"def diagonalSum(matrix)\n sum = 0\n\n matrix.each_with_index do |current_arr, idx|\n sum += current_arr[idx]\n end\n\n sum\nend",
"def squareRaySolver(dim)\n sum = 0\n until dim < 1\n sum += squareHelper(dim)\n dim = dim - 2\n end\n sum\nend",
"def potential_diagonal_moves is_king=false\n moves = []\n\n # Possible moves\n # - all possible combination of increment/decrement of r_idx/c_idx\n\n r_min = is_king ? (r_idx - 1 >= 0 ? r_idx - 1 : r_idx) : 0\n c_min = is_king ? (c_idx - 1 >= 0 ? c_idx - 1 : c_idx) : 0\n r_max = is_king ? (r_idx + 1 <= 7 ? r_idx + 1 : r_idx) : Board::WIDTH - 1\n c_max = is_king ? (c_idx + 1 <= 7 ? c_idx + 1 : c_idx) : Board::WIDTH - 1\n\n # top-right: row-decrement, column-increment [4, 5] [3, 6]\n r = r_idx - 1\n c = c_idx + 1\n while (r >= r_min) && (c <= c_max)\n moves << [r, c]\n r -= 1\n c += 1\n end\n\n # bottom-right: row-increment, column-increment [4, 5] [5, 6]\n r = r_idx + 1\n c = c_idx + 1\n while (r <= r_max) && (c <= c_max)\n moves << [r, c]\n r += 1\n c += 1\n end\n\n # bottom-left: row-increment, column-decrement [4, 5] [5, 4]\n r = r_idx + 1\n c = c_idx - 1\n while (r <= r_max) && (c >= c_min)\n moves << [r, c]\n r += 1\n c -= 1\n end\n\n # top-left: row-decrement, column-decrement [4, 5] [3, 4]\n r = r_idx - 1\n c = c_idx - 1\n while (r >= r_min) && (c >= c_min)\n moves << [r, c]\n r -= 1\n c -= 1\n end\n\n # TODO\n # - refactor to avoid repeated pattern of code without compromising with runtime\n\n moves\n end",
"def diagonals\n container = Array.new()\n diag_array_1 = []\n diag_array_2 = []\n for i in 0..@size-1\n diag_array_1 << i * (@size+1) \n end\n for i in 0..@size-1\n diag_array_2 << (i * (@size-1)) + @size-1\n end\n container << diag_array_1\n container << diag_array_2\n return container\n end",
"def inner_up\n # looking up at the bottom of the inner grid\n return 0 if inner.nil?\n # sum bottom edge\n (0..@size-1).map { |x| inner.get_loc(x, @size - 1) ? 1 : 0 }.sum\n end",
"def sum_region(row1, col1, row2, col2)\n sum = @matrix[row2][col2]\n sum -= @matrix[row2][col1 - 1] if col1 > 0\n sum -= @matrix[row1 - 1][col2] if row1 > 0\n sum += @matrix[row1 - 1][col1 - 1] if row1 > 0 && col1 > 0\n sum\n end",
"def traverse_spiral(matrix)\n l = 0\n r = matrix[0].length - 1\n b = matrix.length - 1\n t = 0\n dir = 0\n\n # loop until top bound equals bottom bounds and left bounds equals right\n while (t <= b && l <= r)\n\n if dir == 0\n (l..r).each{ |left_index| puts matrix[t][left_index] }\n t += 1\n end\n\n if dir == 1\n (t..b).each{ |top_col_ind| puts matrix[top_col_ind][r] }\n r -= 1\n end\n\n if dir == 2\n (r).downto(l) { |right_index| puts matrix[b][right_index] }\n b -= 1\n end\n\n if dir == 3\n (b).downto(t) { |bot_col_index| puts matrix[bot_col_index][l] }\n l += 1\n end\n\n dir = (dir + 1) % 4\n end\nend",
"def squaragonal?(mat)\n n = mat.length\n # check UL to BR\n f_ele = mat[0][0]\n i = 0\n j = 0\n all_same = true\n while i<n\n all_same &= f_ele == mat[i][i]\n i+=1\n end\n return true if all_same\n # check BL to UR\n # debugger\n f_ele = mat[n-1][0]\n j = n-1\n i = 0\n all_same = true\n while i<n\n all_same &= f_ele == mat[i][j]\n i+=1\n j-=1\n end\n return true if all_same\n false\nend",
"def check_diagonally_left(x, y, numbers_in_product)\n (0...numbers_in_product).inject(1) do |product, i|\n product * matrix[y+i][x-i]\n end\n end",
"def outer_spiral_and_inner(a) \n\n # get the dimension of the matrix\n n = Math.sqrt(a.length).to_i \n\n # first row\n outer = Array.new\n for c in 0..n-1 \n outer << a[c]\n end\n\n if a.length > 1 # done if a.length <= 1\n # right side edge\n for r in 2..n-1 \n outer << a[r*n-1]\n end\n\n # last row going right to left\n (n*n-1).downto((n-1)*n) do |c| \n outer << a[c]\n end\n\n # left side edge bottom up\n (n-2).downto(1) do |r| \n outer << a[r*n]\n end\n\n # get the inner matrix\n inner = Array.new\n for r in 1..n-2\n for c in 1..n-2\n inner << a[r*n+c]\n end\n end\n end\n\n return outer, inner\nend",
"def main_diagonal\n (0...@game.rows).collect { |i| @game.board.board[i][i] }\n end",
"def diagonalDifference(arr)\n (0...arr.size).inject(0) do |acc, index|\n left = arr[index][calc_left(arr.size, index)]\n right = arr[index][calc_right(arr.size, index)]\n acc + (left - right)\n end.abs\nend",
"def diagonals\n [\n [@board[0][0], @board[1][1], @board[2][2]],\n [@board[0][2], @board[1][1], @board[2][0]]\n ]\n end",
"def squaragonal?(grid)\n diagnoal?(grid) || diagnoal?(grid.reverse)\nend",
"def spiral(diagonals)\n\nif diagonals % 2 == 0\n puts \"Please enter an odd number\"\nend\n\ni = 1\nsum = 0\n\nwhile i <= diagonals\n if i == 1\n sum += i\n i += 2\n end\n square = i * i\n difference = i - 1\n sum = sum + (square * 4) - (difference * 6)\n i += 2\nend\n\nsum\n\nend",
"def diagonal_left_right\n func = lambda do |arr, mark|\n return mark if arr.all? { |el| el == mark } end\n\n left = []; len = @grid.length\n (0...len).each { |i| left << @grid[i][i] }\n\n right = []; len = @grid.length - 1\n (0...@grid.length).each { |i| right << @grid[i][len-i] }\n\n return :X if (func.call(left, :X) == :X) || (func.call(right, :X) == :X)\n return :O if (func.call(left, :O) == :O) || (func.call(right, :O) == :O)\n end",
"def spiral(rows, cols)\n # check for and handle wonky inputs\n if !rows.is_a?(Integer) || rows <= -1\n puts \"Whoops: Input rows = #{rows} is invalid; rows must be an integer >= 0.\"\n return\n elsif !cols.is_a?(Integer) || cols <= -1\n puts \"Whoops: Input cols = #{cols} is invalid; cols must be an integer >= 0.\"\n return\n end\n\n # prepare rows & columns in array of arrays\n res = Array.new(rows) { Array.new(cols) }\n level = 0 # count of cycles\n num = 1\n\n until num > (rows * cols)\n # top going right\n level.upto(cols-level-1) do |i|\n res[level][i] = num\n num += 1\n end\n break if num > (rows * cols)\n\n # right going down\n (level+1).upto(rows-level-1) do |i|\n res[i][cols-level-1] = num\n num += 1\n end\n break if num > (rows * cols)\n\n # bottom going left\n (cols-level-2).downto(level) do |i|\n res[rows-level-1][i] = num\n num += 1\n end\n break if num > (rows * cols)\n\n # left going up\n (rows-level-2).downto(level+1) do |i|\n res[i][level] = num\n num += 1\n end\n level += 1 # level completed\n end\n\n # print as matrix\n res.each {|sub_arr| print sub_arr, \"\\n\"}\nend",
"def diagonalDifference(arr)\n n = arr.length\n primary = (0..n - 1).reduce(0) do |sum, i|\n sum + arr[i][i]\n end\n secondary = (0..n - 1).reduce(0) do |sum, i|\n sum + arr[i][n - 1 - i]\n end\n (primary - secondary).abs\nend",
"def diagAve(arr, i, j) # (arr= input, i=0 , j = 0)\n \n nums = [arr[i][j]]\n\n # we iterate through matrix as long as we are inbound\n while (i+1 > 0 && j-1 >= 0)\n\n if (i+1 < arr.length && j-1 < arr[0].length)\n i+=1\n j-=1\n nums.push(arr[i][j])\n else\n break\n end\n end\n\n length = nums.length\n (nums.reduce(:+))/length\nend",
"def valid_diagonal(top, right, n)\n bits = 0\n\n if top\n if right\n (@size - n).times { |i|\n if @state[((@size + 1) * i) + n]\n bits += 1\n end\n }\n else\n (n + 1).times { |i|\n if @state[((@size - 1) * i) + n]\n bits += 1\n end\n }\n end\n else\n n_pos = n + ((@size - 1) * @size)\n if right\n (@size - n).times { |i|\n if @state[n_pos - ((@size - 1) * i)]\n bits += 1\n end\n }\n else\n (n + 1).times { |i|\n if @state[n_pos - ((@size + 1) * i)]\n bits += 1\n end\n }\n end\n end\n\n if bits > 1\n return false\n else\n return true\n end\n end",
"def min_path_sum2(grid)\n m = grid.size - 1 \n n = grid[0].size - 1 \n arr = Array.new(m+1) {Array.new(n+1, 0)}\n # Two dimensional array , initialization has a trap\n # if arr = Array.new(m, Array.new(n, 0)) , change one element , all lines' elements will be changed.\n (n+1).times do |i| \n if i == 0\n arr[0][0] = grid[0][0]\n else\n arr[0][i] = arr[0][i-1] + grid[0][i]\n end \n end \n flag = grid.transpose\n (m+1).times do |i| \n if i == 0\n arr[0][0] = grid[0][0]\n else\n arr[i][0] = arr[i-1][0] + grid[i][0]\n end \n end \n (1..m).each do |i| \n (1..n).each do |j| \n arr[i][j] = [arr[i][j-1], arr[i-1][j]].min + grid[i][j]\n end \n end \n arr.last.last\nend",
"def trace\n sum = 0\n # 0.upto(column_size - 1) do\n my_rows = @rows\n col_size = my_rows[0].size \n for i in 0..col_size-1 do \n row = my_rows[i]\n if row._equal?(nil)\n Matrix.Raise(ErrDimensionMismatch, 'not square') \n end\n sum += row[i]\n end\n sum\n end",
"def pytha_tri\n for i in (0...500)\n for j in (i+1...500)\n for k in (j+1...500)\n if (i+j+k == 1000) && (i*i + j*j == k*k)\n return i*j*k\n end\n end\n end\n end\nend",
"def unique_paths_iterative(m, n)\n return 0 if m == 0 || n == 0\n\n grid = Array.new(m) { Array.new(n) {0} }\n grid[0][0] = 1\n\n row = 0\n column = 0\n\n while row < m\n while column < n\n # check top\n if row > 0\n grid[row][column] += grid[row - 1][column]\n end\n # check left\n if column > 0\n grid[row][column] += grid[row][column - 1]\n end\n\n column += 1\n end\n column = 0\n row += 1\n end\n\n grid[row - 1][column - 1]\nend",
"def sum_region(row1, col1, row2, col2)\n r1,c1 = row1+1, col1+1\n r2,c2 = row2+1, col2+1\n p [\"r1c1\",r1,c1] if @d\n p [\"r2c2\",r2,c2] if @d\n a = @mx[r2][c2]\n l = @mx[r2][c1-1]\n u = @mx[r1-1][c2]\n ul = @mx[r1-1][c1-1]\n a - l - u + ul\n end",
"def squareHelper(dim)\n corner4 = dim*dim\n subtractor = dim - 1\n if dim == 1\n return 1\n else\n return corner4 + (corner4 - subtractor) + (corner4 - subtractor*2) + (corner4 - subtractor*3)\n end\nend",
"def min_path_sum(grid)\n row = grid.length\n col = grid[0].length\n\n i, j = 0, 0\n\n while i < row && j < col\n if i == 0 && j != 0\n grid[i][j] = grid[i][j] + grid[i][j - 1]\n elsif i != 0 && j == 0\n grid[i][j] = grid[i][j] + grid[i - 1][j]\n elsif i != 0 && j != 0\n grid[i][j] = grid[i][j] + [grid[i][j - 1], grid[i - 1][j]].min\n end\n\n i += 1\n j += 1\n end\n\n grid[-1][-1]\nend",
"def identify_neighbours\n @x.times{ |r|\n @y.times{|c| \n #+1,+1 0,+1 +1,0\n @mat[r][c].add_neighbour @mat[r+1][c+1] unless @mat[r+1].nil? || @mat[r+1][c+1].nil?\n @mat[r][c].add_neighbour @mat[r][c+1] unless @mat[r].nil? || @mat[r][c+1].nil?\n @mat[r][c].add_neighbour @mat[r+1][c] unless @mat[r+1].nil? || @mat[r+1][c].nil?\n \n #-1,-1 0,-1 -1,0\n @mat[r][c].add_neighbour @mat[r-1][c-1] unless @mat[r-1].nil? || @mat[r-1][c-1].nil?\n @mat[r][c].add_neighbour @mat[r-1][c] unless @mat[r-1].nil? || @mat[r-1][c].nil?\n @mat[r][c].add_neighbour @mat[r][c-1] unless @mat[r].nil? || @mat[r][c-1].nil?\n \n #+1,-1 -1,+1\n @mat[r][c].add_neighbour @mat[r-1][c+1] unless @mat[r-1].nil? || @mat[r-1][c+1].nil?\n @mat[r][c].add_neighbour @mat[r+1][c-1] unless @mat[r+1].nil? || @mat[r+1][c-1].nil?\n \n }\n \n } \n end",
"def diagonalize floor = 0\n raise 'err: not 2d' unless self[0].class == Array\n size = self.length + self[0].length - 1\n array = Array.new(size) {Array.new}\n # acquire top and main diagonal\n self.length.times do |row|\n (0 .. row).each do |col|\n array[row] << self[row-col][col]\n end\n end\n # now cover the additional bottom diagonals\n sides_difference = self.length[0] - self.length\n if sides_difference == 0\n (1 .. self.length - 1).reverse_each do |row|\n offset_value = 0\n temp_arr = []\n while row + offset_value < self.length\n temp_arr << self[self.length - 1 - offset_value][row + offset_value]\n offset_value += 1\n end\n array[self.length - 1 + row] = temp_arr\n end\n else\n (1 .. self[0].length - 1).reverse_each do |row|\n offset_value = 0\n temp_arr = []\n while row + offset_value < self[0].length\n temp_arr << self[self.length - 1 - offset_value][row + offset_value]\n offset_value += 1\n end\n array[self[0].length - 2 + row] = temp_arr\n end\n end\n\n # phew... now to trim and format\n unless floor == 0\n index = 0\n while index < size\n if array[index].length < floor\n array.slice! index\n size -= 1\n index -= 1\n end\n index += 1\n end\n end\n\n (0..size-1).each do |index|\n while array[index].length < self.length\n array[index] << nil\n end\n end\n array\n end",
"def sum_region(row1, col1, row2, col2)\n row1.upto(row2).reduce(0) do |sum, row|\n if col1.zero?\n sum += sum_matrix[row][col2]\n else\n sum += sum_matrix[row][col2] - sum_matrix[row][col1 - 1]\n end\n end\n end",
"def hourglassSum(arr)\r\n rc_arr = [\r\n [0, 0, 0, 0],\r\n [0, 0, 0, 0],\r\n [0, 0, 0, 0],\r\n [0, 0, 0, 0]\r\n ]\r\n\r\n arr.each_with_index do |row, i|\r\n row.each_with_index do |cell, j|\r\n rc_arr[i][j] += cell if (0..3).include?(j) && (0..3).include?(i)\r\n rc_arr[i][j-1] += cell if (0..3).include?(j-1) && (0..3).include?(i)\r\n rc_arr[i][j-2] += cell if (0..3).include?(j-2) && (0..3).include?(i)\r\n\r\n rc_arr[i-1][j-1] += cell if (0..3).include?(j-1) && (0..3).include?(i-1)\r\n\r\n rc_arr[i-2][j] += cell if (0..3).include?(j) && (0..3).include?(i-2)\r\n rc_arr[i-2][j-1] += cell if (0..3).include?(j-1) && (0..3).include?(i-2)\r\n rc_arr[i-2][j-2] += cell if (0..3).include?(j-2) && (0..3).include?(i-2)\r\n end\r\n end\r\n\r\n rc_arr.flatten.max\r\nend",
"def diagonals(arr)\n \n #define slices of array where diagonal lines can be drawn \n slices = [arr[23..36],arr[43..56],arr[63..76],arr[83..96],arr[103..116],arr[123..136],arr[143..156],arr[163..176]]\n \n #define holders for results \n diagonal_ans = []\n helper_hash = {}\n\n slices.map do |slice|\n for i in slice\n #make two sets of diagonals for each index currently selected\n #because the number of elements in each diagonal is 4, so there is no center element\n key_num1 = (arr[i-19]*arr[i]*arr[i+21]*arr[i+42])\n key_num2 = (arr[i-38]*arr[i-19]*arr[i]*arr[i+21])\n val_arr1 = [arr[i-19],arr[i],arr[i+21],arr[i+42]]\n val_arr2 = [arr[i-38],arr[i-19],arr[i],arr[i+21]]\n \n #retain the larger of the two possible diagonals for a given element \n key_num1 > key_num2 ? helper_hash[key_num1] = val_arr1 : helper_hash[key_num2] = val_arr2\n \n end\n diagonal_ans = helper_hash.max_by{|k,v| v}\n end\n @@maximums << diagonal_ans\n puts \"Diagonal max is\"\n p diagonal_ans\n\n end",
"def diagonalDifference(arr)\n # Write your code here\n sum_a = 0\n sum_b = 0\n arr.each_with_index do |row, i|\n sum_a += row[i]\n sum_b += row[row.size-1-i]\n end\n (sum_a - sum_b).abs\nend",
"def solution(s)\n grid = s.split(/\\n/).map { |row| row.split(/\\s/).map(&:to_i) }\n \n search = ->(table) do\n table.map do |row|\n row.each_cons(4).map do |seg|\n seg.reduce(:*)\n end.max\n end.max\n end\n\n squeeze = ->(table, opts={inverse: false}) do\n table.map.with_index do |row,depth|\n row.rotate(opts[:inverse] ? -depth : depth)\n end.transpose\n end\n\n [\n search[grid], # horizontal\n search[grid.transpose], # vertical\n search[squeeze[grid]], # down_diagonals\n search[squeeze[grid, inverse: true]] # up_diagonals\n ].max\nend",
"def get_diagonal_moves\n northwest_moves = []\n northeast_moves = []\n southwest_moves = []\n southeast_moves = []\n (1...ChessBoardConstants::BOARD_DIMENSIONS).each do |step|\n northwest_moves << { row: @row + step, col: @col - step }\n northeast_moves << { row: @row + step, col: @col + step }\n southwest_moves << { row: @row - step, col: @col - step }\n southeast_moves << { row: @row - step, col: @col + step }\n end\n return select_legal_moves(northwest_moves) +\n select_legal_moves(northeast_moves) +\n select_legal_moves(southwest_moves) +\n select_legal_moves(southeast_moves)\n end",
"def pyramid_sum(base)\n\nend",
"def get_diagonal(representation)\n diagonals = []\n for k in (0..7)\n arr = []\n arr2 = []\n for i in (0..6)\n for j in (0..5)\n if (i == (j - k))\n arr << representation[i][j]\n end\n if ((i-k) == j)\n arr2 << representation[i][j]\n end\n end\n end\n diagonals.push(arr, arr2)\n end\n\n determine_winner(diagonals)\nend",
"def calculate_boundary_sum(i,j)\n wall_num = 0\n self.plane[i-1][j-1..j+1].sum == 3? wall_num += 1: wall_num\n self.plane[i+1][j-1..j+1].sum == 3? wall_num += 1: wall_num\n self.plane[i-1..i+1].map{|a| a[j-1]}.sum == 3? wall_num += 1: wall_num\n self.plane[i-1..i+1].map{|a| a[j+1]}.sum == 3? wall_num += 1: wall_num\n wall_num = 0 if(self.plane[i-1][j-1] == 0 || self.plane[i-1][j+1] == 0||self.plane[i+1][j-1] == 0||self.plane[i+1][j+1] == 0)\n return wall_num\n end",
"def check_diagonals(piece)\n #create padding array e.g. [[],[nil],[nil,nil]] etc\n padding = [*0..(grid.length - 1)].map { |i| [nil] * i }\n\n #pad the grid on both sides to shift each row over i elements\n padded1 = padding.reverse.zip(grid).zip(padding).map(&:flatten)\n diagonals_up = padded1.transpose.map(&:compact)\n\n #pad the opposite direction to get diagonals the other way\n padded2 = padding.zip(grid).zip(padding.reverse).map(&:flatten)\n diagonals_down = padded2.transpose.map(&:compact)\n\n #combine all the diagonals\n diagonals = diagonals_up + diagonals_down\n\n #check diagonals for groups of four\n diagonals.each do |diag|\n diag.each_cons(4).each do |combination|\n return true if combination.all? { |a| a == piece }\n end\n end\n false\n end",
"def no_pieces_in_between_diagonal?(from_row, from_column, to_row, to_column)\n row = from_row\n column = from_column\n if to_row > from_row && to_column > from_column\n row += 1\n column += 1\n until row == to_row\n return false unless @state[row][column] == nil\n row += 1\n column += 1\n end\n elsif to_row > from_row && to_column <= from_column\n row += 1\n column -= 1\n until row == to_row\n return false unless @state[row][column] == nil\n row += 1\n column -= 1\n end\n elsif to_row <= from_row && to_column <= from_column\n row -= 1\n column -= 1\n until row == to_row\n return false unless @state[row][column] == nil\n row -= 1\n column -= 1\n end\n elsif to_row <= from_row && to_column > from_column\n row -= 1\n column += 1\n until row == to_row\n return false unless @state[row][column] == nil\n row -= 1\n column += 1\n end\n end\n true\n end",
"def problem18(r) \n h = r.length\n sum = 0\n for i in 0..h-1 \n \n end\nend",
"def squaragonal?(arr)\n left_daig(arr) || right_daig(arr)\nend",
"def board_diagonal_values(board, left_diagonal = true)\n values = []\n start_at = left_diagonal ? 1 : 3\n BOARD_HEIGHT.times do\n values << board[start_at]\n start_at += BOARD_WIDTH\n start_at = left_diagonal ? start_at + 1 : start_at - 1\n end\n values\nend",
"def make_diagonal\n each{|x,y,val| set x,x,x+1 if x==y}\n self\n end",
"def check_diagonal2\n cell = @last_cell_played\n count = 1\n while cell.rd && cell.rd.color == cell.color\n cell = cell.rd\n end\n while cell.lu && cell.lu.color == cell.color\n cell = cell.lu\n count += 1\n end\n return true if count >= 4\n false\n end",
"def matrix_check_sum(matrix)\n\n row_array = []\n column_array = []\n\n matrix.each do |row|\n row_sum = 0\n row.each do |element|\n row_sum += element\n end\n row_array << row_sum\n end\n\n column_length = matrix[0].length\n j = 0\n until j == column_length\n column_sum = 0\n matrix.each do |row|\n column_sum += row[j]\n end\n j += 1\n column_array << column_sum\n end\n\n if row_array == column_array\n return true\n else\n return false\n end\n\nend",
"def am(amida, y, x)\n #p \"==== NOW ===\"\n #p y \n #p x\n #p amida\n\n if y == H \n #p \"=====GOAL\"\n if x + 1 == K\n $cnt = $cnt + 1\n end\n return\n end\n\n if x < W - 1\n to_right_amida = Marshal.load(Marshal.dump(amida))\n to_right_amida[y][x] = 1\n am(to_right_amida, y + 1, x + 1)\n end\n\n to_streight_amida = Marshal.load(Marshal.dump(amida))\n am(to_streight_amida, y + 1, x)\n\n if x > 0\n to_left_amida = Marshal.load(Marshal.dump(amida))\n to_left_amida[y][x - 1] = 1\n am(to_left_amida, y + 1, x - 1)\n end\nend",
"def getWays(n, c)\n # Write your code here\n w = n\n m = c.length\n dp = Array.new(m+1){Array.new(w+1)}\n 0.upto(m) do |i|\n dp[i][0] = 1\n end\n 0.upto(w) do |j|\n dp[0][j] = 0\n end\n 1.upto(m) do |i|\n 1.upto(w) do |j|\n x = j-c[i-1] >= 0 ? dp[i][j-c[i-1]] : 0\n y = j >= 1 ? dp[i-1][j] : 0\n dp[i][j] = x+y\n end\n end\n p dp\n dp[m][w]\nend",
"def steps(maze)\n width = maze[0].length\n height = maze.length\n\n dup = Array.new(height) { Array.new(width) {0} }\n\n i = 0\n # across the top\n while i < width\n if maze[0][i] == 1\n dup[0][i] = 1\n else\n break\n end\n i += 1\n end\n\n j = 0\n # across the left side\n while j < height\n if maze[j][0] == 1\n dup[j][0] = 1\n else\n break\n end\n j += 1\n end\n\n i = 1\n j = 1\n # center\n while j < height\n while i < width\n if maze[j][i] == 1\n counter = 0\n # above\n if maze[j - 1][i] == 1\n counter += dup[j - 1][i]\n end\n # left\n if maze[j][i - 1] == 1\n counter += dup[j][i - 1]\n end\n dup[j][i] = counter\n end\n i += 1\n end\n i = 1\n j += 1\n end\n\n dup[height - 1][width - 1]\nend",
"def right_tri(tri)\n\nend",
"def esxlRecurse i, j\n esxlStraightRecurse(i, j) + esxlDiagonalRecurse(i, j)\nend",
"def diagonals\n [\n [self.r1_c1, self.r2_c2, self.r3_c3],\n [self.r1_c3, self.r2_c2, self.r3_c1]\n ]\n end",
"def check_diag1(board)\n (0..2).to_a.each_with_object(Hash.new(0)) do |i, m|\n m[board[i][i]] += 1 if board[i][i]\n end\nend",
"def matrix_check_sum(matrix)\n return false if (matrix.length) != (matrix[0].length)\n (matrix.length).times do |i|\n rows = 0\n columns = 0\n (matrix[0].length).times do |j|\n rows += matrix[i][j]\n columns += matrix[j][i]\n end\n if rows != columns\n return false\n end\nend\nreturn true\nend",
"def diagonals\n s = board_state\n first_diagonal = s[0] + s[4] + s[8]\n second_diagonal = s[2] + s[4] + s[6]\n [first_diagonal, second_diagonal]\n end",
"def diagonal_win\n 6.times do\n end\n end",
"def sum_of_interior_angles\n 180 * (@number_of_sides - 2)\n end",
"def diag_abs(mat)\n\tdiag1 = 0\n\tdiag2 = 0\n\t(0..mat.size-1).each do |i|\n \tdiag1 += mat[i][i].to_i\n \tdiag2 += mat[i][mat.size-i-1].to_i\n\tend\n\t(diag1-diag2).abs\nend",
"def diagnoal(offset=0)\n\t\tdiag = Array.new()\n\t\t\n\t\tif(offset >= 0)\n\t\t\t0.upto(width - 1 - offset) {|i| diag.push(self[i][i+offset])}\n\t\telse\n\t\t\toffset = -offset\n\t\t\t0.upto(height - 1 - offset) {|i| diag.push(self[i+offset][i])}\n\t\tend\n\t\n\t\treturn diag\n\tend",
"def squaragonal?(matrix)\n key1 = matrix[0][0]\n key2 = matrix[0][matrix.size - 1]\n test_dr = true\n test_dl = true\n\n (0...matrix.size).each do |i|\n test_dr = false unless matrix[i][i] == key1\n end\n\n j = matrix.size - 1\n (0...matrix.size).each do |i|\n test_dl = false unless matrix[i][j] == key2\n j -= 1\n end\n\n test_dr || test_dl\nend",
"def antidiagonal_starts\n result = []\n # Insert the antidiagonal starts along the bottom edge first, beginning on\n # the right side\n (1..size).each do |n|\n result.push MatrixPosition.new(size-1, size-n)\n end\n\n # Start at 2 since the last iterator covered (size-1, 0)\n (2..size).each do |n|\n result.push MatrixPosition.new(size-n, 0)\n end\n\n result\n end",
"def get_diagonal_difference(\n matrix:\n )\n primary_dia, secondary_dia = 0, 0\n array_length = matrix[0].length - 1\n # Calculate diagonal sum\n (0...matrix[0].length).each do |index|\n \tprimary_dia += matrix[index][index]\n \tsecondary_dia += matrix[index][array_length]\n \tarray_length -= 1\n end\n # Return absolute value of the difference between to diagonals\n (primary_dia - secondary_dia).abs\nend",
"def hourglassSum(arr)\n m = Matrix[*arr]\n\n # minimum possible result\n result = -9*7\n\n for i in (0..3)\n for j in (0..3)\n aux = lilHourglass(m.minor((i..i+2),(j..j+2)) )\n if aux > result\n result = aux \n end\n end\n end\n result\nend",
"def runAlgorithm(row)\n for column in 0..@width-1\n if @columns[column] >= 0 then\n next\n end\n\n ixDiag1 = row + column\n if @diagonals1[ixDiag1] then\n next\n end\n\n ixDiag2 = @lastRow - row + column\n if @diagonals2[ixDiag2] then\n next\n end\n\n @columns[column] = row\n @diagonals1[ixDiag1] = true\n @diagonals2[ixDiag2] = true\n\n if row == @lastRow then\n @solutions.push(@columns.dup)\n else\n runAlgorithm(row + 1)\n end\n\n @columns[column] = -1\n @diagonals1[ixDiag1] = false\n @diagonals2[ixDiag2] = false\n end\n end",
"def four_sum(arr, target)\n arr = arr.sort\n size = arr.size\n res = []\n (0...size).each do |i|\n (i + 1...size).each do |j|\n left = j + 1\n right = size - 1\n while left < right\n sum = arr[i] + arr[j] + arr[left] + arr[right]\n res << [arr[i], arr[j], arr[left], arr[right]] if sum == target\n if sum > target\n right -= 1\n else\n left += 1\n end\n end\n end\n end\n res\nend",
"def spiral_order(a)\n return [] if a.empty?\n res = []\n left, top = 0, 0\n bottom, right = a.length - 1, a[0].length - 1\n\n while left <= right && top <= bottom\n for i in (left..right)\n res << a[top][i]\n end\n top += 1\n for i in (top..bottom)\n res << a[i][right]\n end\n right -= 1\n if top <= bottom\n # decreament for loop\n for i in (right).downto(left)\n res << a[bottom][i] \n end\n bottom -= 1\n end\n if left <= right\n for i in (bottom).downto(top)\n res << a[i][left]\n end\n left += 1\n end\n end\n res\nend",
"def calculate_total_paths(m,n)\n return 1 if m == 1 and n == 1\n paths = []\n for i in (0..m)\n paths << Array.new(0,n)\n end\n\n # initialze borders\n for j in (0...n)\n paths[0][j] = 1\n end\n\n for i in (0...m)\n paths[i][0] = 1\n end\n\n paths[0][0] = 0\n\n for i in (1...m)\n for j in (1...n)\n paths[i][j] = paths[i][j-1] + paths[i-1][j]\n end\n end\n paths[m-1][n-1]\nend",
"def test_adding_neighbors_from_left_corner\n grid = [\n [1],\n [2, 2, 2],\n [3, 3, 3],\n ]\n assert_equal 4, Spiral.add_neighbors(grid, 0)\n end",
"def part_of_diag_l_up(starting, ending)\n result = []\n x = starting[0] - 1\n y = starting[1] + 1\n while x > ending[0] && y < ending[1]\n result << @boxes[x][y]\n x -= 1\n y += 1\n end\n result\n end",
"def squaragonal?(matrix)\n d = matrix.length\n flag = 0\n n = matrix[0][0]\n (d-1).times do |r|\n if !(matrix[r+1][r+1] == n)\n flag = 1\n break\n end\n end\n return true if flag == 0\n\n #flag = 0\n n = matrix[-1][0]\n (d-1).times do |r|\n if !(matrix[-(r+2)][r+1] == n)\n #flag = 1\n return false\n #break\n end\n end\n true #if flag == 0\n #false\nend"
] |
[
"0.7635922",
"0.75126874",
"0.72006476",
"0.6884646",
"0.6704825",
"0.6654649",
"0.66140956",
"0.6585282",
"0.6578061",
"0.6566153",
"0.64192814",
"0.64164245",
"0.64109206",
"0.640933",
"0.6396608",
"0.6395183",
"0.63911545",
"0.6368086",
"0.6345855",
"0.6331328",
"0.6316184",
"0.6300593",
"0.6291293",
"0.62759733",
"0.6257431",
"0.6256654",
"0.6220138",
"0.62102515",
"0.62060666",
"0.6201886",
"0.61765784",
"0.60742724",
"0.6042115",
"0.603622",
"0.60287285",
"0.6003771",
"0.59997714",
"0.5993596",
"0.59782684",
"0.59761685",
"0.5957591",
"0.5952895",
"0.5940355",
"0.5934694",
"0.5929286",
"0.5923337",
"0.5898309",
"0.5891493",
"0.58861303",
"0.5884626",
"0.5851714",
"0.5838144",
"0.58318055",
"0.582479",
"0.58093894",
"0.5806006",
"0.5802573",
"0.5787753",
"0.5787289",
"0.5783385",
"0.578306",
"0.57668847",
"0.5766765",
"0.5763873",
"0.5756073",
"0.57425135",
"0.57413596",
"0.5739256",
"0.5734289",
"0.5731431",
"0.5725555",
"0.5721153",
"0.571929",
"0.5704398",
"0.5697995",
"0.5697286",
"0.5695639",
"0.56940895",
"0.5687794",
"0.56870073",
"0.56780136",
"0.56732017",
"0.5670392",
"0.56617445",
"0.5652994",
"0.5650912",
"0.5647211",
"0.5639841",
"0.56331736",
"0.5633101",
"0.5626867",
"0.5625704",
"0.5624892",
"0.5616779",
"0.5612354",
"0.56119496",
"0.56100607",
"0.5603867",
"0.5597481",
"0.5596928"
] |
0.6602211
|
7
|
codewars kata: musical pitch classes
|
def pitch_class(note)
array_with_sharps = [
'B#', 'C#', 'D', 'D#', 'E', 'E#', 'F#', 'G', 'G#', 'A', 'A#', 'B']
array_with_flats = [
'C','Db', 'D', 'Eb', 'Fb', 'F', 'Gb', 'G', 'Ab', 'A', 'Bb', 'Cb']
array_with_sharps.index(note) ||
array_with_flats.index(note)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def kids_musical; end",
"def get_pitch\n 12 * (@octave - 1) + @@letters[@letter] + @@accidentals[@accidental]\n end",
"def codepoints\n Phonology.sounds.codepoints(features)\n end",
"def musician; end",
"def musician; end",
"def strikes\r\n @pitches.select{|pitch| pitch.outcome == 'S'}\r\n end",
"def midisynth (synthName=:beep, midiArray=\" \", amp: 1.0, amp_slide: 1, pan: 0, pan_slide: 1, attack: -1, decay: -1, sustain: -1, release: -1, attack_level: -1, decay_level: -1, sustain_level: -1, env_curve: -1, slide: -1, pitch: -1)\r\n #add case statement for each synth to set parameters\r\n use_synth synthName\r\n numofnotes = midiArray.length\r\n numofnotes.times do |i|\r\n if i.to_i < (numofnotes.to_i - 1)\r\n msleep = midiArray[i+1].split(\",\")[2].to_i/120.to_f #time until next note plays\r\n msleep = msleep.round(2)\r\n else\r\n msleep = 1\r\n end\r\n noterelease = midiArray[i].split(\",\")[4].to_f/120\r\n noteToPlay = midiArray[i].split(\",\")[5].to_f\r\n play noteToPlay, amp: amp\r\n sleep msleep\r\n end\r\nend",
"def build_pitch\n if @original_pitch\n self.pitch = @original_pitch.to_i(@pattern)\n @key = calculate_key_from_pitch(@pitch)\n @octave = calculate_octave_from_pitch(@pitch)\n @accidental = calculate_accidental_from_pitch(@pitch)\n else\n @key = @original_key.upcase\n @octave = (@original_octave && @original_octave.to_i) || 5\n @accidental = @original_accidental.downcase if @original_accidental\n self.pitch = calculate_pitch_from_key_octave_and_accidental(@key, @octave, @accidental)\n end\n @pitch\n end",
"def mode_Samples(midi_input = [ \"0\", 0, 0 ])\n\t\t# button to change samples bank to the left\n\t\tif (midi_input[1] == 26) then\n\t\t\t$meme_sample_ID_offset = ($meme_sample_ID_offset + 8) % $meme_samples_filelist.size\n\t\t\tputs \"SAMPLES BANK: #{$meme_sample_ID_offset}\"\n\t\t\tputs \"- BANK SWITCH --------------------------------------------------->>>>\"\n\t\t\t0.upto(7){ |i|\n\t\t\t\tputs \"#{$meme_samples_filelist[$meme_sample_ID_offset + i]}\"\n\t\t\t}\n\t\t\tputs \"- BANK SWITCH ---------------------------------------------------<<<<\"\n\t\tend\n\t\t# button to change samples bank to the right\n\t\tif (midi_input[1] == 25) then\n\t\t\t$meme_sample_ID_offset = ($meme_sample_ID_offset - 8) % $meme_samples_filelist.size\n\t\t\tputs \"SAMPLES BANK: #{$meme_sample_ID_offset}\"\n\t\t\tputs \"- BANK SWITCH --------------------------------------------------->>>>\"\n\t\t\t0.upto(7){ |i|\n\t\t\t\tputs \"#{$meme_samples_filelist[$meme_sample_ID_offset + i]}\"\n\t\t\t}\n\t\t\tputs \"- BANK SWITCH ---------------------------------------------------<<<<\"\n\t\tend\n\t\t# line 1 and 2 buttons plays samples - plays samples\n\t \tif (midi_input[1] < 13) then #\n\t\t\tid = get_linear_PAD_ID(midi_input[1])\n\t\t\tsid = ($meme_sample_ID_offset + id) % $meme_samples_filelist.size\n\n\t\t\t# Get play position infos relative to this sample for \"trim\" >>>>\n\t\t\tlength = get_sample_length($meme_samples_filelist[sid])\n\t\t\tputs \"l: #{length}\"\n\t\t\tputs \"sample_start_pos: #{$sample_start_pos}\"\n\t\t\tstart_pos = $sample_start_pos * length\n\t\t\tstart_pos_HMS = Time.at(start_pos).utc.strftime(\"%H:%M:%S.%L\")\n\t\t\tputs \"start_pos: #{start_pos}\"\n\t\t\tputs \"start_pos_HMS: #{start_pos_HMS}\"\n\t\t\t# Get play position <<<<\n\t\t\t\n\t\t\t\n\t\t\tcmd = \"play -v #{$sample_volume} \\\"#{$meme_samples_filelist[sid]}\\\" \"\n\t\t\tcmd += \"rate #{$sample_sampling_rate} \"\n\t\t\tcmd += \"speed #{$sample_speed} \"\n\t\t\tcmd += \"pitch #{$sample_pitch} \"\n\t\t\tcmd += \"tempo #{$sample_tempo} \"\n\t\t\tcmd += \"#{$sample_reverse == true ? \"reverse\" : \"\"} \"\n\t\t\tcmd += \"trim =#{start_pos_HMS} \"\n\t\t\t\n\t\t\tcmd += $sample_phaser[0] == true ? \"phaser #{$sample_phaser[1].round(2)} #{$sample_phaser[2].round(2)} #{$sample_phaser[3].round(2)} #{$sample_phaser[4].round(2)} #{$sample_phaser[5].round(2)} #{$sample_phaser[6]} \" : \"\"\n\t\t\tcmd += $sample_flanger[0] == true ? \"flanger #{$sample_flanger[1].round(2)} #{$sample_flanger[2].round(2)} #{$sample_flanger[3].round(2)} #{$sample_flanger[4].round(2)} #{$sample_flanger[5].round(2)} #{$sample_flanger[6]} #{$sample_flanger[7].round(2)} #{$sample_flanger[8]} \" : \"\"\n\t\t\tcmd += $sample_reverb[0] == true ? \"reverb #{$sample_reverb[1].round(2)} #{$sample_reverb[2].round(2)} #{$sample_reverb[3].round(2)} #{$sample_reverb[4].round(2)} #{$sample_reverb[5].round(2)} #{$sample_reverb[6].round(2)} \" : \"\"\n\t\t\tcmd += $sample_overdrive[0] == true ? \"overdrive #{$sample_overdrive[1].round(2)} #{$sample_overdrive[2].round(2)} \" : \"\"\n\t\t\t\n\t\t\t\t\t\t\n\t\t\tcmd += \" > /dev/null 2>&1\" #[ false, 3, 9.5, 0, 70, 2, \"sin\", 100, \"quadratic\" ]\n\n\t\t\tputs cmd\n\t\t\tt = Thread.new(){\n\t\t\t\tsystem(cmd)\n\t\t\t}\n\t\tend\n\n\t\t# \n\t\tif (midi_input[1] == 13) then\n\t\t\tplay_random_clip()\n\t\t\tputs \"play_random_clip()\"\n\t\tend\n\t\t# \n\t\tif (midi_input[1] == 15) then\n\t\t\tplay_random_clip_fx_random()\n\t\t\tputs \"play_random_clip_fx_random()\"\n\t\tend\n\t\t# \n\t\tif (midi_input[1] == 16) then\n\t\t\tslice_random_sample()\n\t\t\tputs \"slice_random_sample()\"\n\t\tend\n\t\t# \n\t\tif (midi_input[1] == 18) then\n\t\t\tslice_random_sample_random_speed()\n\t\t\tputs \"slice_random_sample_random_speed()\"\n\t\tend\n=begin\n\t\t# last button before 'solo', line 1 -\n\t\tif (midi_input[1] == 22) then\n\t\t\t$sample_reverse = !$sample_reverse\n\t\t\tputs \"REVERSE: #{$sample_reverse}\"\n\t\tend\n\t\t# last button before 'solo', line 2 - stops all sample plays instantly\n\t\tif (midi_input[1] == 24) then\n\t\t\tcmd = \"pkill -9 play > /dev/null 2>&1\"\n\t\t\tputs cmd\n\t\t\tt = Thread.new(){\n\t\t\t\tsystem(cmd)\n\t\t\t}\n\t\tend\n=end\nend",
"def melody scales\n oct = rand(4) + 2\n scales.scale.map {|note|\n MidiCalc.new(Pitch.new(note, oct)).pc_to_midi\n }.shuffle\nend",
"def %(pitch) to_hz / pitch.to_hz end",
"def pitch _args\n \"pitch _args;\" \n end",
"def unit\n [\"teaspoon\", \"cup\", \"pinch\"].sample\nend",
"def get_poss_type(note_set)\n pitches = note_set.map { |note| note.pitch }\n pitch_set = pitches.map { |pitch| pitch % 12 }.uniq\n\n interval_loop = case pitch_set.length\n when 2\n sorted = pitches.sort.uniq { |p| p % 12 }\n (sorted[1] - sorted[0]) % 12\n when 1\n 0\n else\n ordered = pitch_set.sort\n ordered << ordered[0] + 12 # To compare first and last pitches\n ordered.each_cons(2).map{ |p, q| q - p }.join.to_i\n end\n return @@loops[interval_loop]\n end",
"def king_richard_iii; end",
"def chord\n note_num = 4\n samples = []\n count = 0\n duration = nil\n\n while duration.nil?\n puts Rainbow(\"For how many seconds should your chord be played?\").blue\n duration = STDIN.gets.chomp.to_i\n if duration < 1 || duration > 40 || !duration.is_a?(Integer)\n puts Rainbow(\"Please enter a number of seconds greater than 1 and less than 150!\").yellow\n duration = nil\n end\n end\n\n while count <= note_num - 1\n frequency *= 2 if count == 3\n amplitude = 0.25\n num_samples = Notes.SAMPLE_RATE * duration\n\n case count\n when 0\n frequency = Notes.get_notes\n voice = generate_sinewave(num_samples, frequency, amplitude)\n voice_1 = voice\n when 1\n frequency = Notes.get_notes\n voice = generate_sinewave(num_samples, frequency, amplitude)\n voice_2 = voice\n when 2\n frequency = Notes.get_notes\n voice = generate_sinewave(num_samples, frequency, amplitude)\n voice_3 = voice\n when 3\n frequency = Notes.get_notes\n frequency *= 2\n voice = generate_sinewave(num_samples, frequency, amplitude)\n voice_4 = voice\n end\n\n if count >= 3\n samples = [voice_1, voice_2, voice_3, voice_4].transpose.map {|x| x.reduce(:+)}\n export_samples(samples.flatten)\n end\n count += 1\n end\n samples\nend",
"def bass_intro\n play :f2, sustain: 3\n sleep 3.66\n play :g2, sustain: 0.66\n sleep 0.66\n play :a2, sustain: 0.66\n sleep 0.93\n play :c3, sustain: 3.5\n sleep 4.4\n play :D3, sustain: 0.66\n sleep 0.66\n play :e3, sustain: 0.66\n sleep 0.93\n play :d3, sustain: 3.5\n sleep 4.4\n play :e3, sustain: 0.66\n sleep 0.66\n play :f3, sustain: 0.66\n sleep 0.93\n play :bb2, sustain: 3.5\n sleep 4.4\n play :e3, sustain: 0.66\n sleep 0.66\n play :f3, sustain: 0.66\n sleep 0.93\n play :f2, sustain: 3.5\n sleep 4.4\n play :g2, sustain: 0.66\n sleep 0.66\n play :a2, sustain: 0.66\n sleep 0.93\n play :c3, sustain: 3.5\n sleep 4.4\n play :d3, sustain: 0.66\n sleep 0.66\n play :f3, sustain: 0.66\n sleep 0.93\n play :a2, sustain: 4\n sleep 5.4\n play :a2, sustain: 0.66\n sleep 0.66\n play :bb2, sustain: 3.5\n sleep 4.4\n play :E3, sustain: 0.66\n sleep 0.66\n play :f3, sustain: 0.66\n sleep 1.66\nend",
"def cigaret_tar\n Unitwise(0.00001, 'kilogram')\n end",
"def chords\n \n end",
"def intro_verse\n 4.times do\n play chord(:F, :major)\n sleep 1.5\n end\n \n 4.times do\n play chord(:C, :major)\n sleep 1.5\n end\n \n 4.times do\n play chord(:D, :minor7)\n sleep 1.5\n end\n \n 4.times do\n play chord(:Bb, :major)\n sleep 1.5\n end\n \n 4.times do\n play chord(:F, :major)\n sleep 1.5\n end\n \n 4.times do\n play chord(:C, :major)\n sleep 1.5\n end\n \n 4.times do\n play chord(:A, :minor)\n sleep 1.5\n end\n \n 4.times do\n play chord(:Bb, :major)\n sleep 1.5\n end\nend",
"def kincaid\n (11.8 * syllables_per_word) + (0.39 * words_per_sentence) - 15.59\n end",
"def pitch\n @pitch || build_pitch\n end",
"def speech; end",
"def ftom(pitch)\n (69 + 12 * (Math.log2(pitch / 440.0))).round\n end",
"def calculate_accidental_from_pitch(value)\n ACCIDENTALS_FOR_PITCH[value % 12]\n end",
"def get_adjective\n\t\t[\"pretty\", \"ugly\", \"hideous\"].sample\n\tend",
"def wave\n bell.mix(saw, saw.pitch(0.505))\n end",
"def make_sound()\n\n if @type == \"Guitar\"\n return \"Twing Twang...\"\n elsif @type == \"Piano\"\n return \"Plink Plonk...\"\n end #End of if statement\n\n end",
"def scorePaper m\n\t\t[1,0] \n\tend",
"def play(notes)\n\n md = /(\\w):(.+)/.match(notes)\n \n notetype = @notes[md[1]]\n d = @seq.note_to_delta(notetype)\n\n # n.b channel is inverse of string - chn 0 is str 6 \n md[2].split('|').each_with_index do |fret, channel| \n if fret.to_i.to_s == fret\n fret = fret.to_i\n oldfret = @prev[channel]\n @prev[channel] = fret \n\n if oldfret\n oldnote = @tuning[channel] + oldfret\n @track.events << MIDI::NoteOffEvent.new(channel,oldnote,0,d)\n d = 0\n end\n \n noteval = @tuning[channel] + fret\n @track.events << MIDI::NoteOnEvent.new(channel,noteval,80 + rand(38),d)\n d = 0\n end\n end\n end",
"def psh_bonuses(roll)\n case roll\n when 1..5\n @@skills << \"Brawling\"\n puts \"Brawling skill\"\n when 6..10\n @@skills << \"Stealth\"\n puts \"Stealth skill\"\n when 11..15\n @@skills << \"Weapons Expert\"\n puts \"Wpn expert!\"\n when 16..20\n @@skills << \"Dodge\"\n puts \"Dodge skill\"\n when 21..37\n @@endurance += 1\n @@strength += 1\n @@agility += 1\n @@accuracy += 1\n @@willpower += 1\n @@intelligence += 1\n @@perception += 1\n @@appearance += 1\n puts \"+1 to each attribute\"\n when 38..44\n @@endurance += (d(6) + d(6))\n puts \"+2d6 endurance\"\n when 45..51\n @@strength += (d(6) + d(6))\n puts \"+2d6 strength\"\n when 52..58\n @@agility += (d(6) + d(6))\n puts \"+2d6 agility\"\n when 59..65\n @@accuracy += (d(6) + d(6))\n puts \"+2d6 accuracy\"\n when 66..74\n @@intelligence += (d(6) + d(6) + d(6))\n puts \"+3d6 intelligence\"\n when 75..83\n @@willpower += (d(6) + d(6))\n puts \"+2d6 willpower\"\n when 84..90\n @@appearance += (d(6) + d(6) + d(6))\n puts \"+3d6 appearance\"\n when 91..97\n @@skills << \"Martial Arts\"\n puts \"Martial arts skill!\"\n when 98..99\n @@endurance += 2\n @@strength += 2\n @@agility += 2\n @@accuracy += 2\n @@willpower += 2\n @@intelligence += 2\n @@perception += 2\n @@appearance += 2\n puts \"+2 to each attribute\"\n when 100\n @@endurance += d(6)\n @@strength += d(6)\n @@agility += d(6)\n @@accuracy += d(6)\n @@willpower += d(6)\n @@intelligence += d(6)\n @@perception += d(6)\n @@appearance += d(6)\n puts \"JACKPOT -- +d6 to EACH Attribute!\"\n end\n\n end",
"def musical_score_types\n types = []\n types << 'MS' if %w[c d].include?(record.leader[6])\n return types\n end",
"def recognize\nend",
"def pbPlayCry(pokemon,volume=90,pitch=nil)\n return if !pokemon\n if pokemon.is_a?(Numeric)\n pbPlayCrySpecies(pokemon,0,volume,pitch)\n elsif !pokemon.egg?\n if pokemon.respond_to?(\"chatter\") && pokemon.chatter\n pokemon.chatter.play\n else\n pkmnwav = pbCryFile(pokemon)\n if pkmnwav\n pbSEPlay(RPG::AudioFile.new(pkmnwav,volume,\n (pitch) ? pitch : (pokemon.hp*25/pokemon.totalhp)+75)) rescue nil\n end\n end\n end\nend",
"def flaw_mutations_determination(roll)\n case roll\n when 01..02\n @@flaw_mutations << \"Abnormal Anxiety\"\n when 03..04\n @@flaw_mutations << \"Altered Digestive Tract\"\n when 05..06\n @@flaw_mutations << \"Baldness\"\n when 07..17\n @@flaw_mutations << \"Birth Defect\"\n when 18..19\n @@flaw_mutations << \"Blocked Sinuses\"\n when 20..21\n @@flaw_mutations << \"Chronic Acne\"\n when 22..23\n @@flaw_mutations << \"Chronic Dermatitis\"\n when 24..25\n @@flaw_mutations << \"Chronic IngrownHairs\"\n when 26..27\n @@flaw_mutations << \"Chronic Ulcers\"\n when 28..29\n @@flaw_mutations << \"Coronary Thrombosis\"\n when 30..31\n @@flaw_mutations << \"Degenerated Nervous System\"\n when 32..33\n @@flaw_mutations << \"Dizziness\"\n when 34..35\n @@flaw_mutations << \"Early Menopause (females only)\"\n when 36..37\n @@flaw_mutations << \"Excessive Lung Fluid\"\n when 38..39\n @@flaw_mutations << \"Exhaustion\"\n when 40..41\n @@flaw_mutations << \"Extensive Warts\"\n when 42..43\n @@flaw_mutations << \"Extreme Halitosis\"\n when 44..45\n @@flaw_mutations << \"Faulty Immune System\"\n when 46\n @@flaw_mutations << \"Flammable Tissues\"\n when 47\n @@flaw_mutations << \"Hemophilia\"\n when 48..49\n @@flaw_mutations << \"Hormone Disorder\"\n when 50..51\n @@flaw_mutations << \"Inadequate Nerve Endings\"\n when 52\n @@flaw_mutations << \"Increased Aging\"\n when 53\n @@flaw_mutations << \"Increased Flatulence\"\n when 54..57\n @@flaw_mutations << \"Intense Allergy\"\n when 58..59\n @@flaw_mutations << \"Male Menopause (males only)\"\n when 60..61\n @@flaw_mutations << \"Migraine Headaches\"\n when 62..63\n @@flaw_mutations << \"Osteoporosis\"\n when 64..65\n @@flaw_mutations << \"Permanent Rhinitis\"\n when 66..67\n @@flaw_mutations << \"Perpetual Hiccups\"\n when 68..69\n @@flaw_mutations << \"Pre-Senile Dementia\"\n when 70..71\n @@flaw_mutations << \"Psoriasis\"\n when 72..73\n @@flaw_mutations << \"Reactionary Scent\"\n when 74\n @@flaw_mutations << \"Repeat Paralysis\"\n when 75\n @@flaw_mutations << \"Sonic Intolerance\"\n when 76..77\n @@flaw_mutations << \"Sterility\"\n when 78..79\n @@flaw_mutations << \"Tapeworms\"\n when 80..81\n @@flaw_mutations << \"Tooth Decay\"\n when 82..86\n @@flaw_mutations << \"Toxic Susceptibility\"\n when 87..88\n @@flaw_mutations << \"Tranquilizer Agent\"\n when 89..94\n @@flaw_mutations << \"Visual Disorder\"\n when 95..96\n @@flaw_mutations << \"Voice Disorder\"\n when 97..98\n @@flaw_mutations << \"Weeping\"\n when 99..00\n @@flaw_mutations << \"Whistle Croup\"\n end\n end",
"def alejandro1\n # Variable creation.\n # Data structure (way of storing data): List\n notes = [:b4, :b4, :b4, :d4, :e4, :fs4, :fs4, :e4,\n :fs4, :fs4, :fs4, :cs4, :cs4, :cs4, :cs4] # :r is rest.\n \n durations = [0.5, 0.25, 0.25, 0.5, 0.5, 0.5, 1, 0.5,\n 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5]\n \n play_pattern_timed notes, durations\nend",
"def next_pitch\n @window = @source.next_window\n @sample = @window.sample\n\n shifts = limited_samples.map{|x| x[:index]}\n return nil if shifts.size < 2\n\n # What is this doing?\n @sample.pop( @sample.size - shifts.last )\n @sample.shift( shifts.first )\n shifts.pop\n\n (shifts.size.to_f / @sample.size.to_f) * @window.rate\n end",
"def profile_random_kmer_motif(text, k, profile)\n # We have previously defined the notion of a Profile-most probable k-mer in a string.\n # We now define a Profile-randomly generated k-mer in a string Text. For each k-mer Pattern in Text,\n # compute the probability Pr(Pattern | Profile), resulting in n = |Text| - k + 1 probabilities (p1, …, pn).\n # These probabilities do not necessarily sum to 1, but we can still form the random number generator\n # Random(p1, …, pn) based on them. \n\n # Profile-most rofile-randomly generated k-mer\n # Input: A string Text, an integer k, and a 4 × k matrix Profile.\n # Output: A Profile-random k-mer in Text.\n\n # puts profile\n # puts text\n # puts k\n kmers_arr = kmers(text,k)\n kmers_prob_arr = []\n kmers_arr.each do |kmer|\n kmers_prob_arr << dna_profile_probability(kmer, profile)\n end\n\n # prob_sum = 0.0\n # puts \"prob_arr: \" + kmers_prob_arr.join(\" \")\n # kmers_prob_arr.each {|i| prob_sum += i}\n # puts \"prob_sum: \" + prob_sum.to_s\n prob_sum = kmers_prob_arr.inject(:+)\n # puts \"inject sum: \" + kmers_prob_arr.inject(:+).to_s\n normalized_probability_arr = kmers_prob_arr.map {|i| (i+0.0)/prob_sum}\n # puts \"normalized_probability_arr: \" + normalized_probability_arr.join(\" \")\n # prob_sum = 0.0\n # normalized_probability_arr.each {|i| prob_sum += i}\n # puts \"norm_prob_sum: \" + prob_sum.to_s\n\n rand_num = biased_random_number(normalized_probability_arr)\n # puts kmers_arr\n # puts \"Rand\" + rand_num.to_s + \"random\"\n return kmers_arr[rand_num]\n end",
"def pitch_counts\n games = pitcher_games\n pitches = pitches_for_games(games)\n counts = pitches.collect{|pitches| pitches.size}\n counts\n end",
"def tongue_twister; end",
"def play_score_note(notes, opts = {})\n # cl \"NOTES: #{notes.inspect}\".red\n opts[:vscale] ||= 1.0\n ped = opts[:pedal]\n hand = opts[:hand]\n zzz = nil\n z_candidate = nil\n\n notes.each do |n|\n if n[1].is_a? Array\n # note with legato value, i.e. different sustain & sleep values\n # TODO: if chord, last note's legato value will be used? no legato in chords?\n dur, zzz = n[1]\n # cl \"n1: #{n[1].inspect}, dur: #{dur}, zzz: #{zzz}\".green\n else\n dur = n[1]\n z_candidate = n[1]\n end\n\n if ped && ped[ hand ]\n cl \"PEDAL from inside play_score_note: #{ped.inspect}\" #if opts[:hand] = :l\n cl \"BPM: #{current_bpm}\".green\n ped[ hand ] << n[0]\n # cl \"P ADD #{n[0]}, #{hand}\"\n dur = 10000 # effectively disable note-off\n end\n\n dcl \"mplay(note:#{n[0]}, sustain:#{n[1]}, velocity:#{n[2]})\"\n mplay note:n[0], sustain:dur, velocity:n[2] * opts[:vscale], **opts\n end\n\n # cl \"DUR: #{notes[0][1]}, SLEEP: #{notes[0][1]}\"\n # sleep for either specified legato sleep time, or last-note-in-chord's duration time\n sleep zzz || z_candidate\nend",
"def pound_sterling(pence); end",
"def alejandro1\n # Variable creation.\n # Data structure (way of storing data): List\n notes = [:b4, :b4, :b4, :d4, :e4, :fs4, :fs4, :e4,\n :fs4, :fs4, :fs4, :c4, :c4, :c4, :c4] # :r is rest.\n \n durations = [0.5, 0.25, 0.25, 0.5, 0.5, 0.5, 1, 0.5,\n 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5]\n \n play_pattern_timed notes, durations\nend",
"def calculate_pitch_from_key_octave_and_accidental(key, octave, accidental)\n pitch = 12 * octave\n pitch += PITCHES[key]\n pitch += ACCIDENTALS[accidental] || 0\n pitch\n end",
"def sheetlisten()\n n=0.5\n i=0\n while i<@songstr.length-1\n case @songstr[i]\n when 'a' \n play :a\n when 'b' \n play :b\n when 'c' \n play :c\n when 'd' \n play :d\n when 'e' \n play :e\n when 'f' \n play :f\n when 'g' \n play :g\n else\n if(!is_numeric?(@songstr[i]))\n puts(\"invalid char\")\n end\n end\n if(!is_numeric?(@songstr[i+1]))\n sleep 0.5\n else\n case @songstr[i+1]\n when '2' \n #for halfnote at regular speed: sleep 1\n n=1\n when '8' \n #for eighth\n n=0.25\n when '6' \n #for sixteenth note\n n=0.125\n end\n sleep n\n i+=1\n end\n i+=1\n end\n end",
"def of_type(type)\r\n @pitches.select{|pitch| pitch.pitch_type == type}\r\n end",
"def mood\n if self.nausea > self.happiness\n \"sad\"\n else\n \"happy\"\n end\n end",
"def chord; end",
"def mood\n if self.nausea && self.happiness\n self.nausea > self.happiness ? (return \"sad\") : (return \"happy\")\n end\n end",
"def chord_types; end",
"def inplay\r\n @pitches.select{|pitch| pitch.outcome == 'X'}\r\n end",
"def get_a_sample_note\n Card[\"Death Star uses dark side of the Force\"]\nend",
"def scorePaper m\n\t\t[0,1]\n\tend",
"def treasure\n [\"ring\", \"necklace\", \"dagger\", \"amulet\", \"ruby\", \"sapphire\", \"piece of jade\", \"human skull\", \"tarask skull\"].sample\nend",
"def k_factor\n if pro? or pro_rating?\n Player::PRO_K_FACTOR\n elsif starter?\n Player::STARTER_K_FACTOR\n else\n Player::DEFAULT_K_FACTOR\n end\n end",
"def emotional_adjective; end",
"def k_factor\n if pro? || pro_rating?\n Player::PRO_K_FACTOR\n elsif starter?\n Player::STARTER_K_FACTOR\n else\n Player::DEFAULT_K_FACTOR\n end\n end",
"def notes_from_training\n end",
"def jack_handey; end",
"def potion; end",
"def plays(h)\n\th.each do |bros, inst|\n\t\tputs \"#{bros.to_s.capitalize} Marx plays the #{inst}\"\n\tend\nend",
"def virus_effects\n predicted_deaths\n speed_of_spread\n end",
"def virus_effects\n predicted_deaths\n speed_of_spread\n end",
"def virus_effects\n predicted_deaths\n speed_of_spread\n end",
"def virus_effects\n predicted_deaths\n speed_of_spread\n end",
"def virus_effects\n predicted_deaths\n speed_of_spread\n end",
"def samples; end",
"def samples; end",
"def k_matematica!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 46 )\n\n\n\n type = K_MATEMATICA\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 437:3: ( 'sin' | 'cos' | 'cot' | 'tan' | 'asin' | 'acos' | 'atan' | 'log' | 'loge' | 'logn' | 'fac' | 'avg' | 'abs' | 'fraction' | 'max' | 'min' | 'count' | 'res' )\n # at line 437:3: ( 'sin' | 'cos' | 'cot' | 'tan' | 'asin' | 'acos' | 'atan' | 'log' | 'loge' | 'logn' | 'fac' | 'avg' | 'abs' | 'fraction' | 'max' | 'min' | 'count' | 'res' )\n alt_13 = 18\n case look_13 = @input.peek( 1 )\n when 0x73 then alt_13 = 1\n when 0x63 then look_13_2 = @input.peek( 2 )\n\n if ( look_13_2 == 0x6f )\n case look_13 = @input.peek( 3 )\n when 0x73 then alt_13 = 2\n when 0x74 then alt_13 = 3\n when 0x75 then alt_13 = 17\n else\n raise NoViableAlternative( \"\", 13, 9 )\n\n end\n else\n raise NoViableAlternative( \"\", 13, 2 )\n\n end\n when 0x74 then alt_13 = 4\n when 0x61 then case look_13 = @input.peek( 2 )\n when 0x73 then alt_13 = 5\n when 0x63 then alt_13 = 6\n when 0x74 then alt_13 = 7\n when 0x76 then alt_13 = 12\n when 0x62 then alt_13 = 13\n else\n raise NoViableAlternative( \"\", 13, 4 )\n\n end\n when 0x6c then look_13_5 = @input.peek( 2 )\n\n if ( look_13_5 == 0x6f )\n look_13_15 = @input.peek( 3 )\n\n if ( look_13_15 == 0x67 )\n case look_13 = @input.peek( 4 )\n when 0x65 then alt_13 = 9\n when 0x6e then alt_13 = 10\n else\n alt_13 = 8\n\n end\n else\n raise NoViableAlternative( \"\", 13, 15 )\n\n end\n else\n raise NoViableAlternative( \"\", 13, 5 )\n\n end\n when 0x66 then look_13_6 = @input.peek( 2 )\n\n if ( look_13_6 == 0x61 )\n alt_13 = 11\n elsif ( look_13_6 == 0x72 )\n alt_13 = 14\n else\n raise NoViableAlternative( \"\", 13, 6 )\n\n end\n when 0x6d then look_13_7 = @input.peek( 2 )\n\n if ( look_13_7 == 0x61 )\n alt_13 = 15\n elsif ( look_13_7 == 0x69 )\n alt_13 = 16\n else\n raise NoViableAlternative( \"\", 13, 7 )\n\n end\n when 0x72 then alt_13 = 18\n else\n raise NoViableAlternative( \"\", 13, 0 )\n\n end\n case alt_13\n when 1\n # at line 437:4: 'sin'\n match( \"sin\" )\n\n\n when 2\n # at line 437:10: 'cos'\n match( \"cos\" )\n\n\n when 3\n # at line 437:16: 'cot'\n match( \"cot\" )\n\n\n when 4\n # at line 437:22: 'tan'\n match( \"tan\" )\n\n\n when 5\n # at line 437:28: 'asin'\n match( \"asin\" )\n\n\n when 6\n # at line 437:35: 'acos'\n match( \"acos\" )\n\n\n when 7\n # at line 437:42: 'atan'\n match( \"atan\" )\n\n\n when 8\n # at line 437:49: 'log'\n match( \"log\" )\n\n\n when 9\n # at line 437:55: 'loge'\n match( \"loge\" )\n\n\n when 10\n # at line 437:62: 'logn'\n match( \"logn\" )\n\n\n when 11\n # at line 437:69: 'fac'\n match( \"fac\" )\n\n\n when 12\n # at line 437:75: 'avg'\n match( \"avg\" )\n\n\n when 13\n # at line 437:81: 'abs'\n match( \"abs\" )\n\n\n when 14\n # at line 437:87: 'fraction'\n match( \"fraction\" )\n\n\n when 15\n # at line 437:98: 'max'\n match( \"max\" )\n\n\n when 16\n # at line 437:104: 'min'\n match( \"min\" )\n\n\n when 17\n # at line 437:110: 'count'\n match( \"count\" )\n\n\n when 18\n # at line 437:118: 'res'\n match( \"res\" )\n\n\n end\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 46 )\n\n\n end",
"def plays(h)\n\th.each do |bros, inst|\n\t\tputs \"#{bros.capitalize} Marx plays the #{inst}\"\n\tend\nend",
"def techno_percussion len\n self << len.Dist # bass drum\n mapee_last.clear_hits\n mapee_last << 4.eqly_spaced\n # max len is full, min quarter\n h_num = mapee_last.hits.count\n h_num = 1 if h_num == 0\n mapee_last.length= rand_range(len*0.666/h_num, len*0.11/h_num) \n\n self << len.Dist # snare\n mapee_last.clear_hits\n mapee_last << [0.25,0.75]\n h_num = mapee_last.hits.count\n h_num = 1 if h_num == 0\n mapee_last.length= rand_range(len/h_num, len/h_num/2) \n \n self << len.Dist # hi\n mapee_last.clear_hits\n mapee_last << 4.eqly_spaced\n mapee_last.hits.move(0.125) # offbeats\n h_num = mapee_last.hits.count\n h_num = 1 if h_num == 0\n mapee_last.length= rand_range(len*0.666/h_num, len*0.666/h_num/2) \n \n self\n end",
"def initialize(music_note)\n if /\\A(a|a#|b|c|c#|d|d#|e|f|f#|g|g#)-?\\d+\\z/i === music_note\n @letter = music_note[/[^-?\\d+]+/].upcase\n @octave = music_note[/-?\\d+/].to_i\n else\n begin\n raise \"'#{music_note}' is not a music note.\"\n rescue => ex\n puts ex.message.to_s\n puts 'Valid notes are :'\n puts \"#{NOTES.join(' ')} (case insensitive), followed by octave number.\"\n end\n end\n end",
"def keystream_letter\n move_joker_a\n move_joker_b\n triple_cut\n count_cut\n count_down\nend",
"def virus_effects\n predicted_deaths\n speed_of_spread\nend",
"def cue_up args\n \n #make the shot if in cue mode\n if args.state.angle_chosen\n return power args\n elsif args.state.aim_type == 2\n return rotation_angle args\n elsif args.state.angle_locked\n return fine_angle_adjustment args\n else\n return choose_angle args\n end\nend",
"def thirty_minute_yoga_classes\n end",
"def virus_effects\n predicted_deaths \n speed_of_spread \n end",
"def virus_effects\n predicted_deaths \n speed_of_spread \n end",
"def microgram? = unit == 'microgram'",
"def balls\r\n @pitches.select{|pitch| pitch.outcome == 'B'}\r\n end",
"def criminal_skills(roll)\n case roll\n when 1..2\n if @@skills.include? \"Barter\"\n @@criminal_skill_rolls += 1\n else\n @@skills << \"Barter\" # 1 pt max\n end\n when 3..9\n @@skills << \"Climbing\"\n when 10..13\n @@skills << \"Disguise Artist\"\n when 14..19\n @@skills << \"Dodge\"\n when 20..21\n @@skills << \"Driver\"\n when 22\n if @@skills.include? \"Erotic Arts\"\n @@criminal_skill_rolls += 1\n else\n @@skills << \"Erotic Arts\" # max 1 skill pt in this area\n end\n when 23..25\n if @@skills.include? \"Forgery\"\n @@criminal_skill_rolls += 1\n else\n @@skills << \"Forgery\"\n @@literacy = \"Literate\"\n end\n when 26..29\n @@skills << \"Gambler\"\n when 30..31\n @@skills << \"Grapple\"\n when 32\n @@skills << \"Gun Slinger\"\n when 33\n @@skills << \"Gunsmith\"\n when 34..37\n @@skills << \"Junk Crafter\"\n when 38..41\n @@skills << \"Knife Fighter\"\n when 42..47\n @@skills << \"Knife Thrower\"\n when 48..51\n @@skills << \"Lying\"\n when 52\n @@skills << \"Medic\"\n when 53..54\n if @@skills.include? \"Navigate by Stars\"\n @@criminal_skill_rolls += 1\n else\n @@skills << \"Navigate by Stars\" # max 1 point in this skill\n end\n when 55\n @@skills << \"Negotiating\"\n when 56..66\n @@skills << \"Pick Locks\"\n when 67..77\n @@skills << \"Pick Pocket\"\n when 78\n @@skills << \"Pilot\"\n when 79\n @@skills << \"Relic Knowledge\"\n when 80..81\n @@skills << \"Riding\"\n when 82\n @@skills << \"Sniper\"\n when 83..88\n @@skills << \"Stealth\"\n when 89..91\n @@skills << \"Tracking\"\n when 92..94\n @@skills << \"Unarmed Combat\"\n when 95\n @@skills << \"Wilderness Survival\"\n when 96..100\n @@skills << \"Weapons Expert\"\n # if rolled more than once, take a second level in the same weapon or randomly roll a new weapon -- player's choice. Mutants and cyborgs can choose to apply the weapon expert skill to a mutation or implant, as desired.\n end\nend",
"def play_random_clip()\n 0.upto(8){\n\tid = rand($full_sample_filelist.size)\n=begin\t\n\t# Theses variables are used by the sample playing - affected to the last line of knobs\n\t$sample_volume = 1.0\n\t$sample_speed = 1.0\n\t$sample_reverse = false\n\t$sample_sampling_rate = 44100\n\t$sample_start_pos = 0.0\n\t$sample_phaser = [ false, 0.95, 0.95, 3, 0.6, 2, \"-t\" ] # active gain-in gain-out delay decay speed [-s(inusoid)|-t(riangle)]\n\t$sample_flanger = [ false, 3, 9.5, 0, 70, 2, \"sin\", 100, \"quadratic\" ] # [active, delay depth regen width speed shape phase interp]\n\t$sample_reverb = [ false, 99, 99, 100, 100, 0, 0, ] # active, reverb, HF-damping, room-scale, stereo-depth, pre-delay, wet-gain\n=end\n\tcmd = \"play -v #{$sample_volume} \\\"#{$full_sample_filelist[id]}\\\" \"\n\tcmd += \"rate #{$sample_sampling_rate} \"\n\tcmd += \"speed #{$sample_speed} \"\n\tcmd += \"#{$sample_reverse == true ? \"reverse\" : \"\"} \"\n\tcmd += \"trim =0.0 \"\n\t\n\tcmd += $sample_phaser[0] == true ? \"phaser #{$sample_phaser[1].round(2)} #{$sample_phaser[2].round(2)} #{$sample_phaser[3].round(2)} #{$sample_phaser[4].round(2)} #{$sample_phaser[5].round(2)} #{$sample_phaser[6]} \" : \"\"\n\tcmd += $sample_flanger[0] == true ? \"flanger #{$sample_flanger[1].round(2)} #{$sample_flanger[2].round(2)} #{$sample_flanger[3].round(2)} #{$sample_flanger[4].round(2)} #{$sample_flanger[5].round(2)} #{$sample_flanger[6]} #{$sample_flanger[7].round(2)} #{$sample_flanger[8]} \" : \"\"\n\tcmd += $sample_reverb[0] == true ? \"reverb #{$sample_reverb[1].round(2)} #{$sample_reverb[2].round(2)} #{$sample_reverb[3].round(2)} #{$sample_reverb[4].round(2)} #{$sample_reverb[5].round(2)} #{$sample_reverb[6].round(2)} \" : \"\"\n\t\n\tcmd += \" > /dev/null 2>&1\" #[ false, 3, 9.5, 0, 70, 2, \"sin\", 100, \"quadratic\" ]\n\n\tputs cmd\n \tThread.new(){\n\t\tif(rand(2) < 1) then # thread it and jump to next sample instantly\n\t\t\tThread.new(){\n\t\t\t\tsystem(cmd)\n\t\t\t}\n\t\telse\n\t\t\tsystem(cmd)\n\t\tend\n \t####sleep(rand(1.0))\n \t}\n\n }\nend",
"def audio; end",
"def mood\n if nausea && happiness\n self.nausea > self.happiness ? \"sad\" : \"happy\" \n end\n end",
"def three_of_a_kind_better_kicker\n [5.♠, 7.♡, J.♠, J.♣, J.♢]\n end",
"def play_3_note_chord(note_one, note_two, note_three)\n play note_one\n play note_two\n play note_three\nend",
"def possible_plays\n [:paper, :rock, :scissors, :spock, :lizard]\n end",
"def mood\n if self.happiness && self.nausea\n self.happiness > self.nausea ? \"happy\" : \"sad\"\n end\n end",
"def virus_effects \n predicted_deaths \n speed_of_spread\n end",
"def classifySample(sample)\n if sample =~/VIR|viral/\n return \"VIR\"\n elsif sample =~/LG/ || sample =~/01a/\n return 3.0\n elsif sample =~/SM/ || sample =~/01b/ || sample =~/GS-25-/ || sample =~/GOS108XLRVAL-4F-1-400_FG5HGJH01/ || sample =~/GOS108XLRVAL-4F-1-400_FG5HGJH02/ || sample =~/GOS108XLRVAL-4F-1-400_FJGGSX101/\n return 0.8\n elsif sample =~/00[b|c|d]/\n return 0.22\n else\n return 0.1\n end\nend",
"def initialize\n @word = Spicy::Proton.noun(min:5)\n @word_array = word.split(\"\")\n @display_array = Array.new(word.length, \"_\")\n @candles = Array.new(5, \",\")\n @user_guesses = []\n @cake = \"\\t _|||||_ \\n\\t {~*~*~*~}\\n\\t__{*~*~*~*}__\\n\\t-------------\"\n end",
"def drum_sounds max_amp=0.5, layers =1\n tot = count\n amp = max_amp.to_f / tot #out of total drums\n tot.times do |i| \n this_amp = amp\n wei = (i+1).to_f/(tot+1)\n# this_amp = max_amp if wei < 0.4 # if bass-ish\n range = 0.0\n seqs= 1\n if wei > 0.7 # if hihat-ish\n this_amp /= 3 \n mapee(i).drum(wei, this_amp, 0.04, 1, layers)\n mapee(i)[0].snd.toneseq.tonepart(0).do_all {|tone| tone.saturations.start = 0.5 + rand(3).to_f/10}\n mapee(i)[0].snd.toneseq.do_all{|tp| tp.do_all {|tone|\n tone.detail = 10000\n tone.amp.exp = 0.12\n } }\n else\n if wei > 0.35 && wei < 0.65\n range = 0.5\n seqs= 2+rand(2)\n end\n mapee(i).drum(wei, this_amp, range, seqs, layers)\n end\n end\n end",
"def analyze_hand\n pairs = 0\n straight = 0\n flush = 0\n\n # for now be conservative\n @play = 3\n\n # check for pairs\n\n\n # check for flush\n\n # check for straight\n\n\n\n # check for special hands\n #full house\n #royal flush\n #straight flush\n \n end",
"def pitching_stats(conditions = {})\n\t\tend",
"def mov_macros_2b(amp=0.1)\n use_bpm 70\n with_fx :level, amp: amp do\n in_thread do\n 2.times do |i|\n sample :bd_haus, rate: 1 - 0.25 * i, amp: 5\n sample :bd_klub, rate: 1 - 0.25 * i, amp: 5\n n = [2, 4, 8].choose\n pan = rrand(-1, 0)\n with_fx :echo, phase: 0.5 / n, mix: rrand(0.8,1) do\n sample :elec_soft_kick, pan: pan, rate: 1, amp: 1\n end\n sleep 0.25\n\n sleep 0.125\n # play chord(:f2, :major), amp: 3 * i, release: 0.25\n sample :bd_haus, rate: 1 - 0.25 * i, amp: 5\n sleep 0.125\n\n n = [3, 4, 8].choose\n with_fx :echo, phase: 0.5 / n, mix: 0.1 do\n sample :elec_soft_kick, rate: 1, amp: 2\n end\n sleep 0.25\n\n sample :bd_haus, rate: 1 - 0.25 * i, amp: 2\n n = [4, 4, 4, 8].choose\n pan = 0\n with_fx :echo, phase: 0.5 / n, mix: rrand(0.8,1) do\n sample :elec_soft_kick, pan: pan, rate: 1, amp: 2\n # sample :elec_triangle\n end\n sleep 0.25\n end\n end\n end\nend",
"def play_random_clip_fx_random()\n 0.upto(8){\n\tid = rand($full_sample_filelist.size)\n\t# Theses variables are used by the sample playing - affected to the last line of knobs\n\t$my_sample_volume = 0.2 + rand() * 0.8\n\tif($my_sample_volume > $sample_volume) then\n\t\t$my_sample_volume = $sample_volume\n\tend\n\n\t$my_sample_speed = 0.1 + rand(0.9)\n\t$my_sample_reverse = rand(2) < 1 ? false : true\n\t$my_sample_sampling_rate = 44100\n\t$my_sample_start_pos = 0.0 + rand(0.0..1.0)\n\t$my_sample_phaser = [ rand(2) < 1 ? false : true, \n\t\t\t\t0.95, 0.95, 3, 0.6, 2, \"-t\" ] # active gain-in gain-out delay decay speed [-s(inusoid)|-t(riangle)]\n\t$my_sample_flanger = [ rand(2) < 1 ? false : true, \n\t\t\t\t3, 9.5, 0, 70, 2, \"sin\", 100, \"quadratic\" ] # [active, delay depth regen width speed shape phase interp]\n\t$my_sample_reverb = [ rand(2) < 1 ? false : true, \n\t\t\t\t99, 99, 100, 100, 0, 0, ] # active, reverb, HF-damping, room-scale, stereo-depth, pre-delay, wet-gain\n\n\tcmd = \"play -v #{$my_sample_volume * 0.2} \\\"#{$full_sample_filelist[id]}\\\" \"\n\tcmd += \"rate #{$my_sample_sampling_rate} \"\n\tcmd += \"speed #{$my_sample_speed.round(2)} \"\n\tcmd += \"#{$my_sample_reverse == true ? \"reverse\" : \"\"} \"\n#=begin \n## TODO fix trim\n\tlength = get_sample_length($full_sample_filelist[id])\n\tputs \"l: #{length}\"\n\tputs \"sample_start_pos: #{$my_sample_start_pos}\"\n\tstart_pos = $my_sample_start_pos.round(2) * length.round(2)\n\tstart_pos_HMS = Time.at(start_pos).utc.strftime(\"%H:%M:%S.%L\")\n\tcmd += \"trim =#{start_pos_HMS} \"\n#=end\t\n\tcmd += $my_sample_phaser[0] == true ? \"phaser #{$my_sample_phaser[1].round(2)} #{$my_sample_phaser[2].round(2)} #{$my_sample_phaser[3].round(2)} #{$my_sample_phaser[4].round(2)} #{$my_sample_phaser[5].round(2)} #{$my_sample_phaser[6]} \" : \"\"\n\tcmd += $my_sample_flanger[0] == true ? \"flanger #{$my_sample_flanger[1].round(2)} #{$my_sample_flanger[2].round(2)} #{$my_sample_flanger[3].round(2)} #{$my_sample_flanger[4].round(2)} #{$my_sample_flanger[5].round(2)} #{$my_sample_flanger[6]} #{$my_sample_flanger[7].round(2)} #{$my_sample_flanger[8]} \" : \"\"\n\tcmd += $my_sample_reverb[0] == true ? \"reverb #{$my_sample_reverb[1].round(2)} #{$my_sample_reverb[2].round(2)} #{$my_sample_reverb[3].round(2)} #{$my_sample_reverb[4].round(2)} #{$my_sample_reverb[5].round(2)} #{$my_sample_reverb[6].round(2)} \" : \"\"\n\n\tcmd += \" > /dev/null 2>&1\" #[ false, 3, 9.5, 0, 70, 2, \"sin\", 100, \"quadratic\" ]\n\n\tputs cmd\n\tThread.new(){\n\t\tif(rand(2) < 1) then # thread it and jump to next sample instantly\n\t\t\tThread.new(){\n\t\t\t\tsystem(cmd)\n\t\t\t}\n\t\telse\n\t\t\tsystem(cmd)\n\t\tend\n \t####sleep(rand(1.0))\n\t}\n\n }\nend",
"def mood \n if self.happiness && self.nausea\n mood = self.happiness - self.nausea\n mood > 0 ? \"happy\" : \"sad\"\n end\n end",
"def mtof(pitch)\n 440.0 * (2.0 ** ((pitch.to_f-69)/12))\n end",
"def virus_effects\n predicted_deaths\n speed_of_spread\n print\n end",
"def virus_effects\n predicted_deaths\n speed_of_spread\n print\n end"
] |
[
"0.6830662",
"0.66093254",
"0.6191168",
"0.6015732",
"0.6015732",
"0.5954493",
"0.5947296",
"0.5781961",
"0.5736594",
"0.5706084",
"0.5689379",
"0.5654669",
"0.562302",
"0.56144446",
"0.56059366",
"0.5603963",
"0.5546832",
"0.5532935",
"0.55315226",
"0.5530795",
"0.5498791",
"0.54811496",
"0.5419755",
"0.5400061",
"0.53914547",
"0.5385191",
"0.53791744",
"0.5366147",
"0.53651863",
"0.5349149",
"0.5345526",
"0.53429586",
"0.53417635",
"0.5335223",
"0.5316054",
"0.530925",
"0.5302615",
"0.5298279",
"0.52763176",
"0.5274824",
"0.52632946",
"0.52615523",
"0.5245425",
"0.52441645",
"0.5240447",
"0.52396584",
"0.5237593",
"0.5236548",
"0.52331156",
"0.52245516",
"0.52207667",
"0.52199656",
"0.5218274",
"0.521721",
"0.5216651",
"0.5216535",
"0.5212462",
"0.520999",
"0.5207652",
"0.5206468",
"0.5203085",
"0.5202024",
"0.5202024",
"0.5202024",
"0.5202024",
"0.5202024",
"0.51949507",
"0.51949507",
"0.5189543",
"0.51870227",
"0.5178493",
"0.5171007",
"0.516982",
"0.516684",
"0.5161645",
"0.515864",
"0.5157615",
"0.5157615",
"0.51575303",
"0.515298",
"0.5149917",
"0.5147862",
"0.5146613",
"0.5145904",
"0.5144863",
"0.51371545",
"0.51362836",
"0.513089",
"0.5127372",
"0.5125581",
"0.5114068",
"0.511392",
"0.5112617",
"0.51121205",
"0.5108955",
"0.51044434",
"0.5104291",
"0.5100538",
"0.5099065",
"0.5099065"
] |
0.6328365
|
2
|
Implement a method that accepts 3 integer values a, b, c. The method should return true if a triangle can be built with the sides of given length and false in any other case. (In this case, all triangles must have surface greater than 0 to be accepted). Solution TIL the sum of any 2 sides of a triangle must be greater than the third side
|
def isTriangle(a,b,c)
if (a > 0) || (b > 0) || (c > 0)
if ((a + b) > c) && ((a + c) > b) && ((b + c) > a)
return true
else
return false
end
else
return false
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def valid_triangle?(a, b, c)\n if (a + b > c) && (a + c > b) && (b + c > a)\n true\n else\n false\n end\nend",
"def valid_triangle?(a, b, c)\n a + b > c && a + c > b && b + c > a\nend",
"def valid_triangle?(a, b, c)\n a + b > c && a + c > b && b + c > a\nend",
"def valid_triangle?(a, b, c)\n a + b > c && a + c > b && b + c > a\nend",
"def valid_triangle?(a, b, c)\n a + b > c && b + c > a && c + a > b\nend",
"def valid_triangle?(a, b, c)\n if a + b > c && a + c > b && b + c > a\n return true\n else\n return false\n end\nend",
"def valid_triangle?(a, b, c)\n if a <= 0 || b <= 0 || c <= 0\n return false\n end\n\n if a + b >= c && a + c >= b && b + c >= a\n return true\n else\n return false\n end\nend",
"def valid_triangle?(a, b, c)\n if a == 0 or b == 0 or c == 0\n return false\n elsif a == b and b == c and a == c\n return true\n elsif a + b < c or a + c < b or b + c < a\n return false\n else\n return true\n end\nend",
"def valid_triangle?(a, b, c)\n ((a+b>c) && (b+c>a) && (a+c>b))? true:false\nend",
"def valid_triangle?(a, b, c)\n if (a==0 || b==0 || c==0)\n return false\n elsif (a+b<=c) || (a+c<=b) || (c+b<=a)\n return false\n elsif (a==b && a==c && b==c)\n return true\n elsif (a==b || a==c || b==c)\n return true\n elsif (((a**2)+(b**2))==(c**2) || ((a**2)+(c**2))==(b**2) || ((c**2)+(b**2))==(a**2))\n return true\n else\n return false\n end\nend",
"def is_triangle(a,b,c)\n if a + b <= c || a + c <= b || b + c <= a\n false\n else \n true\n end \nend",
"def valid_triangle?(a, b, c)\n\tif a + b > c && a + c > b && b + c > a\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend",
"def isTriangle(a,b,c)\n a + b > c && b + c > a && a + c > b\nend",
"def valid_triangle?(a,b,c)\n\n integer_cant_be_zero = (a == 0) || (b == 0) || (c == 0)\n invalid_triangle = ((a + b) < c) || ((b + c) < a) || ((a + c) < b)\n equilateral_triangle = (a == b) && (b == c)\n isoceles_triangle = (a == b) || (b == c) || (a == c)\n c_b_squared_equ_a_squared = (a > b) && (a > c) && (c**2 + b**2 == a**2)\n a_c_squared_equ_b_squared = (b > a) && (b > c) && (c**2 + a**2 == b**2)\n b_a_squared_equ_c_squared = (c > a) && (c > b) && (b**2 + a**2 == c**2)\n\n if integer_cant_be_zero || invalid_triangle\n return false\n elsif equilateral_triangle || isoceles_triangle\n return true\n elsif c_b_squared_equ_a_squared || a_c_squared_equ_b_squared || b_a_squared_equ_c_squared\n return true\n end\n\nend",
"def isTriangle(a,b,c)\n a + b > c && b + c > a && a + c > b\nend",
"def isTriangle(a,b,c)\n (a+b>c && a+c>b && c+b>a)? true : false\nend",
"def valid_triangle?(a, b, c)\n # Your code goes here!\na+b > c && a+c > b && b+c >a\nend",
"def valid_triangle? triple\n a, b, c = triple\n return false if a + b <= c\n return false if a + c <= b\n return false if b + c <= a\n\n true\nend",
"def valid_triangle?(a, b, c)\n # Your code goes here!\n if (c + b > a) && (a + c > b) && (a + b >c)\n true\n else\n false\n end\n \nend",
"def validity \n if @a + @b <= @c || @c + @a <= @b || @b + @c <=@a\n puts \"These is not a valid triangle, please make sure 2 sides are greater than the addition of one.\"\n return false \n else \n return true \n end \n end",
"def triangle(a, b, c)\r\n lengths = [a,b,c].sort\r\n return :invalid if lengths.any? { |side| side == 0 } || lengths[0..1].sum <= lengths.max\r\n if lengths.each_cons(2).any? { |pair| pair[0] == pair [1] }\r\n lengths.uniq.size == 1 ? :equilateral : :isosceles\r\n else\r\n :scalene\r\n end\r\nend",
"def checktriangle(a, b, c)\n if a + b <= c\n return false\n elsif b + c <= a\n return false\n elsif c + a <= b\n return false\n else\n return true\n end\nend",
"def triangle(a, b, c)\n return :invalid if [a, b, c].any?(&:zero?) # if any length is 0\n return :invalid unless [a, b, c].sort[0..1].sum > [a, b, c].max # sum of smaller > largest\n return :equilateral if a == b && b == c # if all sides are the same length\n return :isosceles if [a, b, c].uniq.size == 2 # if one length is repeated 2x\n :scalene # all other valid triangles\nend",
"def valid_triangle?(num_1, num_2, num_3)\n if (num_1 + num_2 > num_3) && (num_2 + num_3 > num_1) && (num_1 + num_3 > num_2)\n return true\n else\n return false\n end\nend",
"def isTriangle(a,b,c)\n a+b>c && a + c > b && b + c > a ? true : false\nend",
"def triangle(a, b, c)\n tri = [a, b, c].sort\n\n if tri[0..1].sum <= tri[2] then :invalid\n elsif tri.any? { |side| side <= 0 } then :invalid\n elsif tri[0] == tri[1] && tri[1] == tri[2] then :equilateral\n elsif tri[0] != tri[1] && tri[0] != tri[2] && tri[1] != tri[2] then :scalene\n else :isosceles\n end\nend",
"def triangle(a, b, c)\n sides = [a, b, c]\n\n # https://stackoverflow.com/a/11361502\n raise TriangleError if sides.min <= 0\n\n # my original answer\n #sides.each do |item|\n # if item <= 0\n # raise TriangleError\n # end\n #end\n\n # https://stackoverflow.com/a/11361502\n x, y, z = sides.sort\n raise TriangleError if x + y <= z\n\n # my original answer\n #if a + b <= c or b + c <= a or c + a <= b\n # raise TriangleError\n #end\n\n # https://stackoverflow.com/questions/4742692/a-more-elegant-solution-to-ruby-koans-triangle-rb\n case sides.uniq.size\n when 1 then :equilateral\n when 2 then :isosceles\n else :scalene\n end\n\n # my original answer\n #if a == b and b == c\n # :equilateral\n #elsif a == b or b == c or c == a\n # :isosceles\n #else\n # :scalene\n #end\nend",
"def valid_triangle?(side1, side2, side3)\n\tif ((side1 + side2 > side3) && (side2 + side3 > side1) && (side3 + side1 > side2))\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend",
"def triangle(a, b, c)\n sides = a, b, c\n case\n when sides.any? { |side| side.zero? }\n :invalid\n when sides.any? { |side| sides.reduce(:+) - side < side }\n :invalid\n when sides.all? { |side| side == sides.first }\n :equilateral\n when sides == sides.uniq\n :scalene\n else\n :isosceles\n end\nend",
"def valid_triangle?(a, b, c)\n if (a + b > c) && (a + c > b) && (b + c) > a\n\ttrue\n else\n\tfalse\n end\n\n\n # arr = [a, b, c]\n # largest_side = a\n # index = 0\n # for i in arr\n # \tif i >= largest_side\n # \t\tlargest_side = i\n # \t\tindex_of = arr.index(i)\n # \tend\n # end\n # arr.delete_at(index_of)\n # puts arr\n # angle = (arr[0]**2 + arr[1]**2 - largest_side**2).to_f / (2*arr[0]*arr[1])\n # if largest_side**2 == (arr[0])**2 + (arr[1])**2 - 2*arr[0]*arr[1]*angle\n # \ttrue\n # else\n # \tfalse\n # end\n\n\n\n # if (a**2 == b**2 + c**2) || (b**2 == c**2 + a**2 ) || (c**2 == b**2 + a**2)\n # \ttrue\n # else\n # \tfalse\n # end\n\nend",
"def valid_triangle? (num1,num2,num3)\n if num1 + num2 < num3\n true\n elsif num1 + num3 < num2\n true\n elsif num2 + num3 < num1\n true\n else\n false\n end\nend",
"def triangle(a, b, c)\n sides = [a, b, c]\n \n return :invalid if sides.include?(0) || sides.max >= sides.min(2).sum\n return :equilateral if sides.max == sides.min\n return :isosceles if sides.tally.value?(2)\n :scalene\nend",
"def triangle(a, b, c)\n #sort arguments by length\n triangle_array = [a, b, c].sort\n\n #initialize variables to sorted sides\n x = triangle_array[0]\n y = triangle_array[1]\n z = triangle_array[2]\n \n # rule out invalid triangles\n if x + y <= z || (x*y*z) == 0\n return :invalid\n end\n\n if x == y && x == z\n :equilateral\n elsif x == y || x == z || y == z\n :isosceles\n else\n :scalene\n end\nend",
"def isTriangle(a, b, c)\n a, b, c = [a, b, c].sort\n a + b > c\nend",
"def valid_triangle?(a,b,c)\n if a != 0 && b != 0 && c != 0\n if a >= b\n largest = a \n sum = b \n else largest = b\n sum = a\n end\n \n if c > largest \n sum += largest \n largest = c \n else sum = c\n end\n\n if sum >= largest \n return \"true\"\n else return \"false\"\n end\n\n else\n return false\n end\nend",
"def triangle(a, b, c)\n if a==0||b==0||c==0\n\traise TriangleError, \"one of the sides equals zero\"\n end\n if (a+b<=c)||(a+c<=b)||(b+c<=a)\n\traise TriangleError, \"2 any sides must be greater then 1\"\n end\n if a<0||b<0||c<0\n\traise TriangleError, \"negative sides\"\n end\n if (a==b) && (a==c) && (b==c)\n :equilateral\n\telsif (a==b)||(a==c)||(b==c)\n :isosceles\n\telse \n :scalene\nend\n\nend",
"def valid_triangle?(s1, s2, s3)\n triangle = [s1,s2,s3]\n triangle.sort!\n triangle[2] < triangle[0] + triangle[1] ? true : false\nend",
"def triangle(n1, n2, n3)\n sides = [n1, n2, n3].sort\n case\n when sides.any?{|side| side <= 0 }, sides[0..1].sum <= sides.last\n :invalid\n when sides.uniq.size == 1\n :equilateral\n when sides.uniq.size == 2\n :isosceles\n else\n :scalene\n end\nend",
"def isTriangle(a,b,c)\n # your code\n a, b, c = [a, b, c].sort\n if a + b > c\n true\n else \n false\n end\nend",
"def triangle(num1, num2, num3)\n sides = [num1, num2, num3]\n\n sides.sort!\n\n return :invalid if sides[0..1].sum <= sides.last\n\n\n if sides.uniq.size == 1\n :equilateral\n elsif sides.uniq.size == 2\n :isosceles\n elsif sides.uniq.size == 3\n :scalene\n end\nend",
"def valid_triangle?(angle1, angle2, angle3)\n sides = [angle1, angle2, angle3]\n\n return true if sides.reduce(:+) == 180 && sides.all? { | num| num > 0}\n false\nend",
"def triangle(a, b, c)\n #\n # My first solution\n #\n # # Test that the triangle is valid\n # # No side can be <= 0\n # raise TriangleError if a <= 0 || b <= 0 || c <= 0\n # # Sum of any two sides must be > third side\n # raise TriangleError if a >= b+c || b >= a+c || c >= a+b\n\n # return :equilateral if a == b && b == c\n # return :isosceles if a == b || b == c || a == c\n # return :scalene\n #\n\n #\n # The Stack Overflow assisted version\n #\n\n # Sort the triangle sides in ascending order such that a is the smallest\n a, b, c = sides = [a, b, c].sort\n\n # If a <= 0\n raise TriangleError if a <= 0 || a + b <= c\n # Slightly easier to read version:\n # raise TriangleError unless a > 0 || a + b > c\n\n # Find out how many unique lengths there are. If 1, return :equilateral; if\n # 2, return :isoceles; if 3, return :scalene. Note the clever usage of the\n # negative indexing into the array to directly map the number of unique sides\n # to the type of triangle without needing to pad the array\n [:scalene, :isosceles, :equilateral][-sides.uniq.size]\nend",
"def triangle(a, b, c)\n sorted_triangle_sizes = [a, b, c].sort\n return :invalid if sorted_triangle_sizes.include?(0) || sorted_triangle_sizes[0] + sorted_triangle_sizes[1] < sorted_triangle_sizes[2]\n\n return :equilateral if a == b && a == c\n return :isosceles if a == b && a != c\n return :scalene\nend",
"def triangle(side1, side2, side3)\n sides = [side1, side2, side3]\n largest_side = sides.max\n\n case\n when 2 * largest_side > sides.reduce(:+), sides.include?(0)\n :invalid\n when side1 == side2 && side2 == side3\n :equilateral\n when side1 == side2 || side1 == side3 || side2 == side3\n :isosceles\n else\n :scalene\n end\nend",
"def triangle(side1, side2, side3)\n sides = [side1, side2, side3]\n largest_side = sides.max\n\n case\n when 2 * largest_side > sides.reduce(:+), sides.include?(0)\n :invalid\n when side1 == side2 && side2 == side3\n :equilateral\n when side1 == side2 || side1 == side3 || side2 == side3\n :isosceles\n else\n :scalene\n end\nend",
"def triangle(a, b, c)\n sides = [a,b,c]\n validate_sides(sides)\n\n unique_side_lengths = sides.uniq.length\n\n case unique_side_lengths\n when 1\n :equilateral\n when 2\n :isosceles\n when 3\n :scalene\n end\nend",
"def valid_triangle?(side1, side2, side3)\n\n triangle_sides = [side1, side2, side3].sort\n triangle_sides[0] + triangle_sides[1] > triangle_sides[2] \nend",
"def right_triangle?(a, b, c)\n a**2 + b**2 == c**2\nend",
"def is_valid_triangle?(sides)\n !(sides.include?(0) || sides.sum != 180)\nend",
"def triangle(side1, side2, side3)\n sides = [side1, side2, side3].sort\n\n if sides.count(0) > 0 || sides[0] + sides[1] <= sides[2]\n :invalid\n elsif sides.uniq.size == 1\n :equilateral\n elsif sides.uniq.size == 2\n :isosceles\n elsif sides.uniq.size == 3\n :scalene\n end\nend",
"def triangle(s1, s2, s3)\n sides = [s1, s2, s3]\n return :invalid if sides.any?(0) || sides.max > sides.reduce(:+) - sides.max\n type_of_triangle(sides)\nend",
"def valid_triangle?(side1, side2, side3)\n\n triangle_sides=[side1, side2, side3].sort\n\n p (triangle_sides[0] + triangle_sides[1]) > triangle_sides[2]\n\nend",
"def triangle(side1, side2, side3)\n side_array = [side1, side2, side3].sort\n if side_array.include?(0)\n :invalid\n elsif !((side1 + side2) > side3) || !((side2 + side3) > side1)\n :invalid\n elsif side1 == side2 && side1 == side3\n :equilateral\n elsif (side1 == side2 && side1 != side3) || side2 == side3 && side2 != side1 || side1 == side3 && side1 != side2\n :isosceles\n elsif side1 != side2 && side1 != side3 && side3 != side2\n :scalene\n end\nend",
"def triangle_validation (sides) #unsure about stuff in parens here, if need etc\n #if is_triangle(a, b, c) then True elseif print \"This is not a valid triangle\" end\n #if has_3_sides(sides) then True elseif print \"You must enter THREE sides\" end\n\n if not has_3_sides(sides)\n print \"You must enter THREE sides\\n\"\n return false\n end\n if not is_triangle(sides[0], sides[1], sides[2])\n print \"This is not a valid triangle\\n\"\n return false\n end\n return true\n\n #if not is_triangle(a, b, c) then return False and print \"This is not a valid triangle\" end\n #if not has_3_sides(sides) then return False and print \"You must enter THREE sides\" end\n # return True if is_triangle(a, b, c) and has_3_sides(sides)\n #return False if is not has_3_sides(sides)\n #if False print \"You must enter THREE sides\"\nend",
"def triangle(len1, len2, len3)\n lengths = [len1, len2, len3].sort\n return :invalid unless valid_triangle?(lengths)\n return :equilateral if lengths.all?(lengths[0])\n return :scalene if lengths.uniq == lengths\n return :isosceles\nend",
"def in_triangle?(a, b, c)\n point = self - a; b -= a; c -= a\n m = (point.x * b.y - b.x * point.y) / (c.x * b.y - b.x * c.y)\n return false unless m.between?(0, 1)\n l = (point.x - m * c.x) / b.x\n l.between?(0, 1) && (m + l) <= 1\n end",
"def right_triangle?(side_a, side_b, side_c)\n side_a**2 + side_b**2 == side_c**2\nend",
"def triangle(first, second, third)\n sides_array = [first, second, third]\n max_value = sides_array.max\n sum_of_smaller_sides = sides_array.sum - max_value\n check_array = sides_array.uniq\n\n if sides_array.include?(0) || sum_of_smaller_sides < max_value\n return :invalid\n elsif check_array.size == 1\n return :equilateral\n elsif check_array.size == 2\n return :isosceles\n else\n return :scalene\n end\nend",
"def triangle(side1, side2, side3)\n sides = [side1, side2, side3]\n return :invalid if sides.max > sides.sum / 2 || sides.min.zero?\n case sides.uniq.size\n when 1 then :equilateral\n when 2 then :isosceles\n else :scalene\n end\nend",
"def triangle(s1, s2, s3)\n sides = [s1, s2, s3]\n longest_side = sides.max\n\n case\n when largest_side > sides.reduce(:+) - largest_side, sides.include?(0)\n :invalid\n when s1 == s2 && s2 == s3\n :equilateral\n when s1 == s2 || s1 == s3 || s2 == s3\n :issoceles\n else\n :scalene\n end\nend",
"def is_valid_triangle(s1, s2, s3)\n new_arr = [s1, s2, s3]\n new_arr.sort!\n if new_arr[0] + new_arr[1] <= new_arr[2]\n false\n else\n true\n end\nend",
"def is_triangle(side1,side2,side3)\n sides = [side1,side2,side3]\n unique_sides = sides.uniq.length\n raise TriangleError if triangle_error_found?(sides)\n type_of_triangle(unique_sides)\nend",
"def triangle(a, b, c)\n arr = [a, b, c]\n puts \n if checkLengths(arr.dup) || arr.any? {|x| x < 1} \n raise TriangleError, 'That was wrong biatch'\n end\n uni = arr.uniq!\n return :scalene unless uni\n case uni.length \n when 1\n :equilateral\n when 2\n :isosceles\n end\nend",
"def triangle(a, b, c)\n if numbers_below_possible(a, b, c)\n raise TriangleError, \"One of the sides are 0 or negative (below allowed)\"\n end\n\n if triangle_not_possible(a, b, c)\n raise TriangleError, \"Triangle not possible with values passed\"\n end\n\n if a == b && a == c\n return :equilateral\n end\n\n if a == b || a == c || b == c\n return :isosceles\n end\n\n :scalene\nend",
"def triangle(side1, side2, side3)\n if side1 + side2 > side3 && side2 + side3 > side1 && side1 + side3 > side2\n if side1 == side2 && side2 == side3\n return :equilateral\n elsif side1 == side2 || side2 == side3 || side1 == side3\n return :isosceles\n else\n return :scalene\n end\n else\n return :invalid\n end\nend",
"def triangle(side1, side2, side3)\n arr = [side1, side2, side3].sort\n return :invalid if arr[0] + arr[1] <= arr[2]\n return :equilateral if arr[0] == arr[1] && arr[1] == arr[2]\n return :isosceles if arr.uniq.size == 2\n return :scalene if arr.uniq.size == 3\nend",
"def triangle(x,y,z)\n sides = [x, y, z].sort \n return :invalid unless sides.all?{ |e| e.is_a?(Numeric) && e > 0 }\n return :invalid if sides[0] + sides[1] <= sides[2]\n # Now, since the sides are sorted, we can do the following:\n if sides[0] == sides[2]\n :equilateral\n elsif sides[0] == sides[1] || sides[1] == sides[2]\n :isosceles\n else\n :scalene\n end\nend",
"def triangle(a_side, b_side, c_side)\n # WRITE THIS CODE\n sum = a_side + b_side + c_side\n minimum = [a_side, b_side, c_side].min\n maximum = [a_side, b_side, c_side].max\n raise TriangleError unless minimum.positive? && (maximum < sum - maximum)\n\n return :equilateral if equilateral?(a_side, b_side, c_side)\n\n return :isosceles if isosceles?(a_side, b_side, c_side)\n\n :scalene\nend",
"def is_valid_triangle(angle1, angle2, angle3)\n angles = [angle1, angle2, angle3]\n if angles.reduce(:+) == 180 && angle1 != 0 && angle2 != 0 && angle3 != 0\n true\n else\n false\n end\nend",
"def check_error(val_a, val_b, val_c)\n raise TriangleError if (val_b + val_c <= val_a) || (val_c + val_a <= val_b)\n raise TriangleError if val_a + val_b <= val_c\nend",
"def validate(*sides)\n any_zero = ->(args) { args.any?(&:zero?) }\n any_negative = ->(args) { args.any?(&:negative?) }\n one_bigger_or_equal_than_sum_of_others = ->(args) do\n *rest, last = args.sort\n last >= rest.sum\n end\n\n [any_zero, any_negative, one_bigger_or_equal_than_sum_of_others]\n .each { |check| raise TriangleError.new if check.call(sides) }\nend",
"def triangle(side_1, side_2, side_3)\n ordered_array = [side_1, side_2, side_3].sort\n if !ordered_array.all? { |side| side > 0 }\n return :invalid\n end\n if (ordered_array[0] + ordered_array[1]) <= ordered_array[2]\n return :invalid\n end\n if (side_1 == side_2) && (side_2 == side_3)\n :equilateral\n elsif (side_1 == side_2) || (side_1 == side_3) || (side_2 == side_3)\n :isosceles\n else\n :scalene\n end\nend",
"def triangle(a,b,c)\n raise TriangleError unless is_valid_triangle?(a,b,c)\n h = [a]\n h << b unless h.include?(b)\n h << c unless h.include?(c)\n return :equilateral if h.length == 1\n return :isosceles if h.length == 2\n :scalene\nend",
"def triangle(side1, side2, side3)\n arr = [side1, side2, side3].sort\n if side1 == side2 && side2 == side3\n :equilateral\n elsif (arr[0] + arr[1]) < arr[2] || arr.include?(0)\n :invalid\n elsif arr[0] == arr[1] || arr[1] == arr[2]\n :isosceles\n else\n :scalene\n end\nend",
"def triangle_bk(s1, s2, s3)\n sorted_sides = [s1, s2, s3].sort\n if sorted_sides.any? { |side| side <= 0} || (sorted_sides[0] + sorted_sides[1] <= sorted_sides[2])\n :invalid\n elsif sorted_sides.all? { |side| side == sorted_sides[0]}\n :equilateral\n elsif sorted_sides[0] != sorted_sides[1] && sorted_sides[1] != sorted_sides[2]\n :scalene\n else\n :isosceles\n end\nend",
"def triangle(side1, side2, side3)\n arr = [side1, side2, side3].sort!\n if arr[0] + arr[1] <= arr[2]\n :invalid\n elsif arr[0] == arr[1] && arr[0] == arr[2]\n :equilateral\n elsif arr[0] == arr[1] || arr[0] == arr[2] || arr[1] == arr[2]\n :isosceles\n else\n :scalene\n end\nend",
"def valid_triangle?(angles)\n return false if angles.any?(&:zero?)\n\n angles.sum == 180\nend",
"def valid?(side1, side2, side3)\n return false if (side1 <= 0) || (side2 <= 0) || (side3 <= 0)\n tmp = [side1, side2, side3]\n tmp.sort!\n tmp[0..1].sum > tmp[-1]\nend",
"def triangle(*sides)\n # could have used sides.includes?(0)\n return :invalid unless sides.none?(&:zero?)\n return :invalid if sides.max > sides.reduce(:+) - sides.max\n return :equilateral if sides.min == sides.max\n return :isosceles if sides.count { |x| x == sides.max } == 2\n :scalene\nend",
"def triangle(side1, side2, side3)\n arr = [side1, side2, side3]\n if arr.sum != 180 || arr.any?(0)\n :invalid\n elsif arr.any?(90)\n :right\n elsif arr.any? { |n| n > 90 }\n :obtuse\n else\n :acute\n end\nend",
"def valid_triangle(deg1, deg2, deg3)\n return :invalid if deg1 + deg2 + deg3 != 180\n return :invalid if deg1 <= 0 || deg2 <= 0 || deg3 <= 0\n :valid\nend",
"def triangle?((x1, y1), (x2, y2), (x3, y3))\n return false if (x1, y1) == (x2, y2) || (x1, y1) == (x3, y3) || (x2, y2) == (x3, y3)\n return false \n true\nend",
"def has_3_sides(x)\n x.length==3\nend",
"def triangle(a, b, c)\n\t\n\tcheckValidity(a,b,c)\n\t\n\tif (equilateral?(a,b,c))\n\t\treturn :equilateral\n\tend\n\tif (isosceles?(a,b,c))\n\t\treturn :isosceles\n\tend\n\t:scalene\nend",
"def triangle(side1, side2, side3)\n sides = [side1, side2, side3]\n sides.sort!\n return :invalid if sides.include?(0) || sides[0] + sides[1] < sides[2]\n sides_uniq = sides.uniq\n case sides_uniq.length\n when 1 then return :equilateral\n when 2 then return :isosceles\n when 3 then return :scalene\n end\nend",
"def test_error(val_a, val_b, val_c)\n raise TriangleError if val_a <= 0 || val_b <= 0 || val_c <= 0\n sum = (val_a + val_b + val_c) / 2.0\n raise TriangleError if ((sum - val_a) * (sum - val_b) * (sum - val_c)) <= 0\nend",
"def initialize(side_one_length, side_two_length, side_three_length)\n @side_one_length = side_one_length\n @side_two_length = side_two_length\n @side_three_length = side_three_length\n #I find working with an array of the three sides easier than working with the instance variables\n triangle_sides = []\n triangle_sides << @side_one_length\n triangle_sides << @side_two_length\n triangle_sides << @side_three_length\n #No sides of a triangle may be equal to zero\n if triangle_sides.any?{|side| side <= 0}\n raise TriangleError\n #The sum of the lengths of any two sides of a triangle always\n #exceeds the length of the third side. I have to check\n #to see if this is true, and if not I need to raise a \n #TriangleError\n elsif (triangle_sides[0] + triangle_sides[1] <= triangle_sides[2]) || (triangle_sides[1] + triangle_sides[2] <= triangle_sides[0]) || (triangle_sides[0] + triangle_sides[2] <= triangle_sides[1])\n raise TriangleError\n # An equilateral triangle has all sides equal\n elsif triangle_sides.all?{|side| side == triangle_sides[0]}\n @kind = :equilateral \n #An isosceles triangle has 2 sides that are equal, so here I'm checking to see that any two sides are equal.\n elsif triangle_sides[1] == triangle_sides[2] || triangle_sides[0] == triangle_sides[2] || triangle_sides[0] == triangle_sides[1]\n @kind = :isosceles\n #scalene triangles have no equal sides. Similar to what I just did but instead they cannot be equal\n elsif (triangle_sides[0] != triangle_sides[1] || triangle_sides[2]) && (triangle_sides[1] != triangle_sides[2])\n @kind = :scalene\n end\n end",
"def test_triangle\n if @side1.eql?(@side2) && @side2.eql?(@side3)\n \"It's an equilateral\"\n elsif @side1.eql?(@side2) || @side2.eql?(@side3)\n \"It's an isosceles\"\n elsif @side1.eql?(@side2) == false && @side2.eql?(@side3) == false\n \"It's a scalene triangle\"\n else\n \"Not a triangle\"\n end\n end",
"def triplet_check(a,b,c)\n\tif a**2+b**2 == c**2\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend",
"def triangle(x, y, z)\n sides = [x, y, z]\n largest_side = sides.max\n\n # binding.pry\n case\n when sides.inject(:+) != 180, sides.include?(0)\n puts :invalid\n when sides.inject(:+) == 180 && sides.include?(90)\n puts :right\n when sides.inject(:+) == 180 && largest_side > 90\n puts :obtuse\n else \n puts :acute\n end\nend",
"def triangle(num1, num2, num3)\n if (num1 + num2 + num3) != 180\n return :invalid \n elsif num1 == 0 || num2 == 0 || num3 == 0 \n return :invalid\n elsif num1 > 90 || num2 > 90 || num3 > 90\n return :obtuse \n elsif num1 == 90 || num2 == 90 || num3 == 90\n return :right \n else \n :acute\n end\nend",
"def triangle(a, b, c)\n angles = [a, b, c]\n case\n when angles.any? { |x| x <= 0 } || angles.sum != 180 then :invalid\n when angles.any? { |x| x == 90 } then :right\n when angles.all? { |x| x < 90 } then :acute\n when angles.any? { |x| x > 90 } then :obtuse\n end\nend",
"def check_polygon\n return false if @points.length < 3\n zpoints = Array.new(@points)\n zpoints += [@points[0], @points[1]]\n side_prev = zcrossproduct(zpoints[0], zpoints[1], zpoints[2])\n for i in 1...(zpoints.length-2)\n side_next = zcrossproduct(zpoints[i], zpoints[i+1], zpoints[i+2])\n return false if (side_prev * side_next < 0)\n end\n return true\n end",
"def triangle(a, b, c)\n angles = [a, b, c]\n\n # angles.sum = angles.reduce(:+) \n return :invalid if angles.sum != 180 || angles.any?(0)\n return :right if angles.any?(90)\n return :acute if angles.all? { |angle| angle < 90 }\n :obtuse\nend",
"def solution(a)\n return 0 if a.count < 3\n \n a.sort!\n for i in (2...a.count)\n x = a[i - 2]\n y = a[i - 1]\n z = a[i]\n \n return 1 if x + y > z && x + z > y && z + y > x\n end\n \n return 0\nend",
"def triangle(a1, a2, a3)\n angles = [a1, a2, a3]\n\n return :invalid if angles.sum != 180 || angles.include?(0)\n return :right if angles.include?(90)\n return :acute if angles.max < 90\n return :obtuse if angles.max > 90\nend",
"def test\n # triangle inequality theorem\n if ( ((@a+@b)>@c) && ((@a+@c)>@b) && ((@b+@c)>@a) )\n if (@a==@b && @b==@c)\n @type = \"equilateral\"\n @base = @a\n @height = sqrt((@c**2) - (@a/2.0)**2) # pythagoras\n elsif ((@a*@a + @b*@b) == @c*@c)\n @type = \"right\"\n @base = @a\n @height = @b\n elsif (@a == @b) # smaller sides are equal\n @type = \"isosceles\"\n @base = @c # base is larger side\n @height = sqrt(@b**2 - (@c/2.0)**2)\n elsif (@b == @c) # larger sides are equal\n @type = \"isosceles\"\n @base = @a # base is smaller side\n @height = sqrt(@c**2 - @a**2)\n else\n @type = \"scalene\"\n @base = @c\n \n # simplified algebra used to find height of scalene\n x = (@a**2 + @c**2 - @b**2) / (2.0*@c)\n @height = sqrt(@a**2 - x**2)\n \n end\n @valid = true\n else\n @type = \"not a triangle\"\n @valid = false\n end\n end",
"def triangle(a, b, c)\n angles = [a, b, c]\n sum = angles.reduce(:+)\n case\n when sum != 180 || angles.any? { |ang| ang <= 0 }\n :invalid\n when angles.any? { |ang| ang == 90 }\n :right\n when angles.any? { |ang| ang > 90 }\n :obtuse\n when angles.all? { |ang| ang < 90 }\n :acute\n end\nend",
"def triangle(angle1, angle2, angle3)\n sides = [angle1, angle2, angle3]\n return :invalid if invalid_triangle? [angle1, angle2, angle3]\n return :acute if acute? sides\n return :obtuse if obtuse? sides\n return :right if right? sides\nend",
"def triangle(a, b, c)\n angles = [a, b, c]\n\n case\n when angles.sum != 180 || angles.min <= 0\n :invalid\n when angles.max == 90\n :right\n when angles.max > 90\n :obtuse\n else\n :acute\n end\nend"
] |
[
"0.84237313",
"0.84212184",
"0.84212184",
"0.84212184",
"0.8406885",
"0.8390796",
"0.8382921",
"0.83159995",
"0.82350993",
"0.82110083",
"0.8201444",
"0.8188584",
"0.8181286",
"0.8174385",
"0.8160924",
"0.8151479",
"0.81469566",
"0.8139616",
"0.8134575",
"0.81237066",
"0.8118345",
"0.8113645",
"0.8086668",
"0.805923",
"0.8055877",
"0.8010556",
"0.7966001",
"0.79103005",
"0.7869432",
"0.7865008",
"0.7844474",
"0.771778",
"0.7708261",
"0.77004397",
"0.7682792",
"0.7678705",
"0.7664571",
"0.7656215",
"0.7622292",
"0.7606031",
"0.7593992",
"0.7588648",
"0.75522614",
"0.7540493",
"0.7540493",
"0.75393724",
"0.75238204",
"0.75159746",
"0.75065446",
"0.75005686",
"0.7472327",
"0.7470102",
"0.74609154",
"0.74572635",
"0.744365",
"0.7434619",
"0.74168026",
"0.74062234",
"0.7369906",
"0.735811",
"0.73346704",
"0.7322858",
"0.73082453",
"0.73065925",
"0.722993",
"0.72199214",
"0.7201757",
"0.7200425",
"0.71658635",
"0.71516454",
"0.7088043",
"0.7057946",
"0.70477563",
"0.70411927",
"0.69865435",
"0.69773316",
"0.691647",
"0.68802255",
"0.6844027",
"0.68284583",
"0.6806973",
"0.6764939",
"0.6763237",
"0.6755217",
"0.672543",
"0.6676126",
"0.66688603",
"0.6599011",
"0.6581097",
"0.6470038",
"0.6460279",
"0.64429724",
"0.64298546",
"0.6410575",
"0.6373324",
"0.63158333",
"0.63126147",
"0.6296708",
"0.6274296",
"0.62414545"
] |
0.8319327
|
7
|
Insert a row into the matrix of voices to search
|
def add_row( group_id, row, number_to_transpose = 0 )
@groups[group_id - 1] ||= []
@groups[group_id - 1] << MiltonsMachine::Core::ForteSet.new(row).transpose_mod12(number_to_transpose)
@max_group_index = @groups.length - 1
@max_column_index = @groups[0][0].length - 1
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add_row(pos)\n start = pos[:at].to_i\n count = pos[:count].to_i\n rows.each do |row|\n row.position += count if row.position >= start\n end\n count.times { rows.new(position: pos[:at]) }\n saved = rows.collect {|row| row.save }\n saved.all?\n end",
"def insert_row(row, index=@rows.length)\n @rows.insert(index, row)\n end",
"def add_row( new_row, pos=@table.size)\n @table.insert(pos, new_row)\n end",
"def insert(number, counter, who)\r\n # Printed Array\r\n @nha[number-1][counter] = act_player[who]\r\n # Search through Array\r\n @nha2[number-1][counter] = act_player[who]\r\n \r\n end",
"def set_row( row_index, vector )\n @rows[row_index] = vector.to_a\n end",
"def push_row(other_row)\n\t\t# initialize the new array\n\t\tnew_row = Array.new(@headers.length)\n\t\t\n\t\t# Iterate headers, building our new row\n\t\t0.upto @headers.length-1 do |index|\t\t\n\t\t\t\n\t\t\t# Put the value into the corresponding column in our CSV\n\t\t\tnew_row[index] = other_row[ @headers[index] ]\n\t\tend\n\t\t\n\t\t# Add this row into our matrix\n\t\t@matrix<< new_row\n\tend",
"def linsert(key, where, pivot, value); end",
"def linsert(key, where, pivot, value); end",
"def add_row\n @rows += 1\n @current_cards.push [@deck.removeAny, @deck.removeAny, @deck.removeAny]\n end",
"def <<(row)\n add_row(row)\n end",
"def add_row\n unless @current_row.nil?\n # Add the row to the puzzle.\n @puzzle << @current_row\n # And clear the row.\n @current_row = nil\n end\n end",
"def <<(row)\n @rows << row\n end",
"def append_sudoku(lat, lng, row = -1, col = -1)\n\n end",
"def insert(pixel, x, y)\n self.matrix[x,y]=pixel\n end",
"def insert_play_on_board(player, turno)\n row_pos = 0\n #Verifica si el primer caracter del turno es letra, si si se obtiene su equivalente en numero siendo a = 0 y z = 26\n if turno[0].to_i == 0\n (\"a\"..\"z\").each_with_index do |letra, i|\n if turno[0] == letra\n row_pos = i\n end\n end\n else #Si el primer caracter no fue letra significa que es numero y se procede a obtener el equivalente de la letra\n (\"a\"..\"z\").each_with_index do |letra, i|\n if turno[1] == letra\n row_pos = i\n end\n end\n end\n col_pos = (turno[0].to_i != 0 ? turno[0].to_i : turno[1].to_i) - 1\n #Se pregunta que amenos que el espacio donde se piensa colocar la ficha sea un lugar vacio se inserta si no se descarta\n unless @tablero.component(row_pos, col_pos) != \" \"\n @tablero.send(:[]=, row_pos, col_pos, player.ficha)\n return true\n else\n puts \"Lo siento ese lugar esta ocupado krnal\"\n return false\n end\n end",
"def add_rows! *rows\r\n matrix_new = add_rows *rows\r\n @rows = matrix_new.to_a\r\n end",
"def append(row,text)\n\t\t@text[row] = @text[row].dup\n\t\t@text[row] += text\n\tend",
"def add(row)\n @data << row\n end",
"def row_search \n horizontal_words = []\n search = @@boards_templates[1].to_s.scan(/...../).each_slice(1).to_a\n rows = search.join \n @@boards_templates[0].each { |x| rows.include?(x) ? horizontal_words << x : rows.reverse.include?(x) ? horizontal_words << x : \"No hay palabras en dirección horizontal\" }\n horizontal_words\n end",
"def insert(pixel, x, y)\n if @matrix[x] == nil\n @matrix[x] = []\n end\n @matrix[x][y] = pixel\n\n end",
"def insert(idx, row)\n order_check(row)\n super\n end",
"def row(this_speaker)\n\t\tindexarray = []\n\t\tspeakees = @hash[this_speaker.to_sym].flatten.sort!\n\t\tspeakees.each do |name|\n\n\t\t\tif @speakers.index(name) != nil\n\t\t\tindexarray << @speakers.index(name)\n\t\t\tend\n\n\t\tend\n\n\t\t#Create row of length @speakers\n\t\tmatrixrow = Array.new(@speakers.length, 0)\n\t\tindexarray.each do |i|\n\t\t\tmatrixrow[i] = 1\n\t\tend\n\t\treturn matrixrow\n\tend",
"def insert row_ind\n row = @row_refs[row_ind]\n return if row.nil? || row.repeated?\n @row_refs.insert_after(row_ind, row.send(:insert_after))[1]\n end",
"def append_row!(*args)\r\n insert_row!(*args)\r\n end",
"def <<(row)\n @rows << row\n self\n end",
"def populate_row(row, key)\n alphabet.each do |letter|\n row << letter unless key.include? letter\n end\n\n row\n end",
"def populate_inbound_archs\n new_vertices = []\n @a.each do |key, value|\n value[0].each do |vertex|\n # puts vertex\n # @a[vertex].insert(1, Array.new()) if @a[vertex][1] == false\n if @a[vertex]\n @a[vertex][1] << key\n # puts @a[vertex].inspect\n else\n # puts \"detected alone vertex '#{vertex}'\"\n new_vertices << [vertex, [[], [key], false]]\n end\n end\n end\n new_vertices.each do |data|\n @a[data[0]] = data[1]\n end\n end",
"def matrix_safe_insert(matrix, char, x, y)\n return if x < 0 || x >= matrix.first.size\n return if y < 0 || y >= matrix.size\n matrix[y][x] = char\n end",
"def addRow\n\t\tnew_row = @vars.values\n\t\tcsvrow = new_row.to_csv\n\t\t@arrayOfRows.push(csvrow)\n\tend",
"def replace_existing_element(matrix,element, current_row, current_col)\r\n matrix[current_row][current_col] = element\r\n end",
"def splitrow(row,col)\n\t\ttext = @text[row].dup\n\t\t@text[row] = text[(col)..-1]\n\t\tinsertrow(row,text[0..(col-1)])\n\tend",
"def update_head_vertical_location(row)\n locate_head[0] = row\n end",
"def add(piece, index)\n @board.each_with_index do |row, position|\n if (row[index] != \"\\u26b3\") || (position == 5)\n row[index] == \"\\u26b3\" ? row[index] = piece : @board[position-1][index] = piece\n break\n end\n end\n end",
"def next_row\n observation_matrix.observation_matrix_rows.where('position > ?', position).order(:position).first\n end",
"def insert(row, values)\n values = Array(values)\n unless values.empty?\n @data.expand(row, values.count)\n @data.values.insert row, Array.new([@data.columns_count, values.count].max) { |index| values[index] }\n end\n self\n end",
"def create_row(r)\n row = Array.new\n self.board.each { |a|\n row << a[r]\n }\n row\n end",
"def insert(pixel, x, y)\n x = validateX(x)\n y = validateY(y)\n @matrix[\"#{x}, #{y}\"] = pixel\n end",
"def linsert(key, where, pivot, value)\n send_command([:linsert, key, where, pivot, value])\n end",
"def putrc(row, column, key, data, data_matrix = DATAMATRIX_KEY)\n # if the data_matrix for this collection does not exist yet, initialize it.\n initialize_part_data(data_matrix)\n @map[data_matrix][row][column][key] = data\n end",
"def insert(pixel, x, y)\n return \"Enter valid position\" unless inbounds?(x, y)\n matrix[x][y] = pixel\n end",
"def row_to_find\n create_coded_row\n end",
"def scanCsvRow(row)\n return if !checkWalkingAgent(row) ;\n agentId = getAgentIdInCsvRow(row) ;\n time = getCurrentTimeInCsvRow(row) ;\n posIndex = getCurrentPosIndexInCsvRow(row) ;\n index = [time, posIndex] ;\n \n grid = @gridTable[index] ;\n if(grid.nil?) then\n grid = Grid.new(self, posIndex, time) ;\n @gridTable[index] = grid ;\n end\n\n grid.addAgent(agentId) ;\n end",
"def add_row(row)\n size = row.size\n raise ArgumentError.new(\"Given a row of data with #{size} entries, but there are only #{@table_columns.size} columns in the table\") unless size == @table_columns.size\n @data << row\n end",
"def insert(pixel, x, y)\n return nil if x > self.width || y > self.height\n @matrix[x][y] = pixel\n end",
"def check_row(row)\n @possible_solutions_row = []\n (1..9).each do |i|\n if @board_grid[row].include?(i.to_s) == false\n @possible_solutions_row << i.to_s\n end\n end\n @possible_solutions_row\n end",
"def insert(v)\n \n end",
"def place_piece(piece, col)\n #Transpose the grid so sub arrays are now columns instead of rows\n t = grid.transpose \n #Start at end of column subarray and place piece in first blank spot\n t[col].length.downto(0) do |row|\n if t[col][row] == BLANK\n t[col][row] = piece\n break\n end\n end\n @grid = t.transpose\n end",
"def row(index)\n end",
"def insert row_ind, count=1\n @row_refs.insert(row_ind,count)\n end",
"def insert(value)\n records << value\n record_id = records.count - 1\n\n trigrams = hash(value)\n trigrams.each do |tri|\n index[tri] ||= []\n index[tri] << record_id\n end\n end",
"def push(*rows)\n rows.each { |row| self << row }\n self\n end",
"def set_cell(args)\n arr = @rows.flatten\n arr[arr.find_index(args[:position])] = args[:piece]\n @rows = arr.enum_for(:each_slice, 3).to_a\n end",
"def insert_number(number, cords)\n puts \"#{number} is present in row!\" if is_present_in_row?(number, cords)\n puts \"#{number} is present in column!\" if is_present_in_column?(number, cords)\n puts \"#{number} is present in subgrid!\" if is_present_in_subgrid?(number, cords)\n @grid[cords[0]][cords[1]] = number\n end",
"def mark!(row, col, player)\n return false if invalid_indices(row, col) || !@m[row][col].nil?\n @m[row][col] = player.to_s\n true\n end",
"def fix_row(row)\n values = (1..SIZE).to_a\n values.each do |v|\n if reducable(row, v)\n row = replace_possible_with_known(row, v)\n end\n end\n row\nend",
"def fix_row(row)\n values = (1..SIZE).to_a\n values.each do |v|\n if reducable(row, v)\n row = replace_possible_with_known(row, v)\n end\n end\n row\nend",
"def add_row(encrypted_row_data)\n @encrypted_rows << encrypted_row_data\n end",
"def populate_board\n #the six rows get updated\n players.each do |player|\n rows = player == players[0] ? [ 0,1,2 ] : [ 5,6,7 ]\n piece_count = 0\n col = 0\n\n player.pieces.each do |piece|\n\n rows.shift if piece_count % 4 == 0 and piece_count != 0\n\n col_start = rows[0] % 2 == 1 ? 0 : 1\n col = 0 if (col_start == 0 || col_start == 1) && piece_count % 4 == 0\n\n piece.position = [col + col_start, rows[0]]\n squares[[col + col_start, rows[0]]] = piece\n\n col += 2\n piece_count += 1\n\n end\n\n end\n\n end",
"def set_pieces\n @pieces.each do |piece|\n y , x = piece.location\n @rows[y][x] = piece\n end\n end",
"def row(r)\n return matrix[r].map{|e| e.dup}\n end",
"def matrix_replace(row, column, newvalue)\n self[row*9 + column] = newvalue\n end",
"def place_row(color, i)\n @grid[i].each_with_index do |el, j|\n case j\n when 0\n el << Rook.new(color, [i, j], self)\n when 1\n el << Knight.new(color, [i, j], self)\n when 2\n el << Bishop.new(color, [i, j], self)\n when 3\n el << Queen.new(color, [i, j], self)\n when 4\n el << King.new(color, [i, j], self)\n when 5\n el << Bishop.new(color, [i, j], self)\n when 6\n el << Knight.new(color, [i, j], self)\n when 7\n el << Rook.new(color, [i, j], self)\n end\n end\n end",
"def put(key, value)\n row = key >> 10\n puts \"Insert: #{key},#{value} => row = #{row}\" if @d\n column = @a[row].index{|(i,v)| i == key}\n\n if column\n @a[row][column][1] = value\n else\n @a[row].push([key, value])\n end\n end",
"def setrow(row,text)\n\t\told = @text[row]\n\t\t@text[row] = text\n\tend",
"def get_row(row)\n row = $boggle_board[row]\nend",
"def populate_matrix_with_row_headers\n create_empty_array\n collect_row_headers\n replace_row_helpers\nend",
"def add_row(row, mark: false)\n row.transform_keys!(&:as_sym)\n # Make sure there is a column for each known header and each new key\n # present in row.\n new_heads = row.keys - headers\n new_heads.each do |h|\n # This column is new, so it needs nil items for all prior rows lest\n # the value be added to a prior row.\n items = Array.new(size, nil)\n columns << Column.new(header: h, items: items, tolerant: tolerant_col?(h))\n end\n headers.each do |h|\n # NB: This adds a nil if h is not in row.\n column(h) << row[h]\n end\n self\n end",
"def add(element)\n bin_row = bin_row(element)\n element_rows(element).each { |y|\n return false if ((@rows[y] & bin_row) != 0)\n }.each { |y|\n @rows[y] = @rows[y] | bin_row\n }\n self\n end",
"def load(arg)\n index = 0\n @mat.each do | _ ,row|\n (0..row.length-1).each do |i|\n row[i] = arg[index]\n index += 1\n end\n end\n end",
"def sen_settg(row,column); det.table(:index, 12)[row][column]; end",
"def append_row row, row_type\n send(row_type) << row\n end",
"def add_row(row)\n\n # Delete row if it already exists\n $rows.delete_if { |r| r['file_path'] == row['file_path'] }\n $rows << row\n\n # rewrite csv:\n update_csv($rows)\nend",
"def add_piece(column, symbol) #todo: extract position finding ?\n position = grid[column].inject { |memo, space| memo > space.to_i ? memo : space }\n available_index = grid[column].index(position)\n grid[column][available_index] = symbol\n end",
"def insert(cartridge) # :nodoc:\n cartridge.versions.each do |version|\n @index[cartridge.name][version][cartridge.cartridge_version] = cartridge\n @index[cartridge.name][version][nil] = cartridge\n @index[cartridge.name][nil][nil] = cartridge\n end\n\n cartridge\n end",
"def add_node_to_distance_matrix(distance_matrix, distances)\n n = distance_matrix.length\n row = Array.new(n) { 0 }\n row[0] = $n\n distance_matrix.first.push($n)\n for i in 1...n\n row[i] = distances.shift\n distance_matrix[i].push(row[i])\n end \n distance_matrix.push(row + [0] )\n distance_matrix\nend",
"def matrix_find(row, column)\n self[row*9 + column]\n end",
"def updateboard\n #scan through \n board_temp = []\n (0...@board.length).each do |iy|\n new_row = []\n (0...@board[iy].length).each do |ix|\n\n ## Following rules of Conway's GOL\n val = case neighbors([iy,ix])\n when 0, 1\n 0\n when 2\n @board[iy][ix]\n when 3 \n 1\n when 4,5,6,7,8\n 0 \n end\n new_row << val\n end\n board_temp << new_row\n end\n ## Replace board with new board, decided to use a new board because its \n ## confusing to update the existing board when considering neighbors\n @board = board_temp\n end",
"def set_row_by_idx(idx, value)\n @row[idx] = value\n end",
"def move_row(pos)\n from = pos[:from].to_i\n dest = pos[:dest].to_i\n moving = nil\n\n # Moving down\n if dest > from\n rws = rows.where(position: from..dest)\n rws.each do |row|\n if row.position == from\n moving = row\n moving.position = -1\n else\n row.position -= 1\n end\n end\n moving.position = dest\n\n # Moving up\n else\n rws = rows.where(position: dest..from)\n rws.each do |row|\n if row.position == from\n moving = row\n moving.position = -1\n else\n row.position += 1\n end\n end\n moving.position = dest\n end\n\n saved = rws.map(&:save)\n saved.all?\n end",
"def push_to_robot_scent_array(position)\n @robot_scent_positions << position\n end",
"def insert_before(pivot, item)\n conn.linsert key, :before, pivot, item\n end",
"def get_row(row)\n @boggle_board[row]\n end",
"def add_move_to_history(file, row, to_file, to_row)\n\t\tpiece = self[file, row]\n if piece.nil?\n to_ascii\n puts \"add_move_to_history nil piece\"\n for line in caller\n puts line\n end\n gets\n end\n\t\tif piece.instance_of? King\n\t\t\tif piece.castling? to_file, to_row\n\t\t\t\tcastling = true\n\t\t\telse\n\t\t\t\tcastling = false\n\t\t\tend\n\t\tend\n\t\tfirst_move = !piece.has_moved\n\t\tmove_hash = {\n\t\t\t:from_file => file, :from_row => row, \n\t\t\t:to_file => to_file, :to_row => to_row, \n\t\t\t:piece => piece, :captured_piece => self[to_file, to_row],\n\t\t\t:first_move => first_move, :castling => castling\n\t\t}\n\t\t@history << move_hash\n\tend",
"def add_back_row(color, row)\n backrow = [Rook, Knight, Bishop, Queen, King, Bishop, Knight, Rook]\n backrow.map.with_index { |piece, column| piece.new(color, [row, column]) }\n end",
"def edit_ingredient(r,i)\n ingredient_select = prompt_list_of_ingredients(r,i)\n new_ingredient_pair = gets_new_ingredient_pair\n # iteration over ingredients array with index and deletes and inserts hashes at index when ingredient names match.\n i.each_with_index do |ingredient_pair,index|\n ingredient_pair.each do |ing,p|\n if ingredient_select == ing \n i.delete_at(index)\n i.insert(index, new_ingredient_pair)\n end\n end\n end\nend",
"def get_row(row)\n\t$boggle_board[row]\nend",
"def insert_row!(*args)\r\n after, before = nil, nil\r\n opts = (Hash === args.last || Numeric === args.last) ? args.pop : {}\r\n case opts\r\n when Numeric\r\n before = opts\r\n when Hash\r\n after = opts[:after]\r\n before = opts[:before]\r\n end\r\n input = args.flatten\r\n \r\n # get input column count and assign default headers\r\n init_blank_headers!(input.size) if headers.empty?\r\n \r\n # pad or truncate row based on headers\r\n input = normalized_columns(input)\r\n unless after or before\r\n @data += input\r\n else\r\n if after\r\n after = [after, row_count].min\r\n @data.insert( [index_of_next_row_start(after), @data.size].min, *input)\r\n end\r\n if before\r\n before = [before, row_count].min\r\n @data.insert(index_of_row_start(before), *input)\r\n end\r\n end\r\n \r\n init_caches!\r\n self\r\n end",
"def add_to_board(board, tet, loc)\n\t\nend",
"def apply(matrix, line, column, value)\n matrix[line, column] = value\n end",
"def insert_array(data, start_cell, direction = 'right')\n direction = get_direction(direction)\n row_offset = 0\n col_offset = 0\n\n data.each do |val|\n @ws.range(start_cell).offset(row_offset, col_offset).value = val\n case direction\n when DOWN\n row_offset += 1\n when UP\n row_offset += -1\n when TORIGHT\n col_offset += 1\n when TOLEFT\n col_offset += -1\n end\n end\n end",
"def other_way(matrix)\n result = []\n (0..2).each do |column_index|\n new_row = (0..2).map {|row_index| matrix[row_index][column_index]}\n result << new_row\n end\n result\nend",
"def push(sdata)\n row = Hash.new\n @columns.each do |column,value|\n nvalue = sdata.shift()\n row.store(column,nvalue)\n row.store(column,value) if row[column].nil?\n end\n @data.push(row)\n end",
"def insert(tuples)\n pks = tuples.map { |tuple| relation.insert(tuple) }\n relation.where(relation.primary_key => pks).to_a\n end",
"def insert_(array, item, index)\n array = array.insert(index, item)\n puts array\n return array\n \nend",
"def find_preexisting_row(row)\n row_proc.call(row)\n end",
"def insert_word(word, x, y)\n for i in 0...word.length\n @grid[x][y+i] = word[i]\n end\n end",
"def linsert(key, where, pivot, value)\n node_for(key).linsert(key, where, pivot, value)\n end",
"def add_neighbor(x, y)\n @waiting.push([[x-1,y], [x-2,y], \"up\"]) if x-1 > 1 && @maze_table[x-2][y] == \"w\"\n @waiting.push([[x+1,y], [x+2,y], \"down\"]) if x+1 < 2*@m-1 && @maze_table[x+2][y] == \"w\"\n @waiting.push([[x,y-1], [x,y-2], \"left\"]) if y-1 > 1 && @maze_table[x][y-2] == \"w\"\n @waiting.push([[x,y+1], [x,y+2], \"right\"]) if y+1 < 2*@n-1 && @maze_table[x][y+2] == \"w\"\n end",
"def add_row_vector(row_vector)\n AddRowVector.new(\n first_row_vector: self,\n second_row_vector: row_vector\n ).call\n end",
"def increase_rows(row)\n @sheet_data.size.upto(row) do\n @sheet_data << Array.new(@sheet_data[0].size)\n end\n end"
] |
[
"0.60751975",
"0.58774453",
"0.58319384",
"0.58024424",
"0.5738995",
"0.57133186",
"0.55922806",
"0.55922806",
"0.5532868",
"0.5526674",
"0.55206406",
"0.5471927",
"0.5442886",
"0.54363483",
"0.54328674",
"0.5431411",
"0.539794",
"0.537761",
"0.53758556",
"0.5372628",
"0.5345907",
"0.5327235",
"0.5326055",
"0.5319959",
"0.5274903",
"0.5255287",
"0.52532196",
"0.5217693",
"0.5175477",
"0.51514286",
"0.5147973",
"0.512661",
"0.50883615",
"0.507547",
"0.5074128",
"0.5055138",
"0.5054688",
"0.5052513",
"0.5050099",
"0.5030261",
"0.50296026",
"0.50228244",
"0.50203305",
"0.5014898",
"0.50140387",
"0.5010686",
"0.49944082",
"0.49811643",
"0.49803916",
"0.49463937",
"0.4944401",
"0.49430564",
"0.49425247",
"0.49421313",
"0.49304172",
"0.49304172",
"0.49233156",
"0.492255",
"0.49186808",
"0.491303",
"0.49080086",
"0.4892192",
"0.48819423",
"0.48760006",
"0.4873127",
"0.48729905",
"0.48722622",
"0.48703605",
"0.486903",
"0.4862051",
"0.48553798",
"0.4849337",
"0.48478326",
"0.48438668",
"0.48407993",
"0.4833269",
"0.4809946",
"0.47928894",
"0.4787584",
"0.4782753",
"0.47807962",
"0.4779245",
"0.4768713",
"0.47575343",
"0.47458962",
"0.47422713",
"0.4729207",
"0.4728748",
"0.47276172",
"0.4721659",
"0.4721111",
"0.47190982",
"0.47172332",
"0.47169122",
"0.471467",
"0.47139606",
"0.4712935",
"0.47059366",
"0.47051212",
"0.46999857"
] |
0.48094237
|
77
|
Insert a set into the search dictionary
|
def add_search_set( search_set, number_to_transpose = 0 )
@search_sets << Set.new( MiltonsMachine::Core::ForteSet.new(search_set).transpose_mod12(number_to_transpose) )
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def insert(val)\n hash[val] = Set.new unless hash[val]\n hash[val].add(values.size)\n values.push(val)\n hash[val].size == 1\n end",
"def __add_keys_to(set) # used by parser # [\n lim = @_st_tableSize\n lim = lim + lim\n kofs = 0\n while kofs < lim\n k = self.__at(kofs)\n if k._not_equal?(RemoteNil)\n set.add(k) # k,v pair\n else\n v = self.__at(kofs + 1)\n if v._not_equal?(RemoteNil)\n if v._isFixnum\n # internal collision chain\n idx = v\n begin\n ck = self.__at(idx)\n if ck._not_equal?(RemoteNil)\n set.add(ck)\n end\n idx = self.__at(idx + 2)\n end while idx._isFixnum\n else\n # a collision bucket , which is a small Hash \n v.__add_keys_to(set)\n end\n end\n end\n kofs += 2\n end\n end",
"def add_qualifier_keys( set ); end",
"def create_set(set_id,search_str)\n\t\t\targs = search_str.split(\" \")\n\t\t\tself.dbsearch(args)\n\t\t\tself.cmd_db_set_create(set_id)\n\t\tend",
"def add(*args)\n args.flatten! # allow [] as a param\n args.each do |arg|\n arg = arg.to_sym if arg.is_a? String\n @set << arg unless @set.include? arg # avoid duplicates\n end\n end",
"def set(values); end",
"def atomic_array_add_to_sets\n @atomic_array_add_to_sets ||= {}\n end",
"def add_all(set)\n raise NotImplementedError\n end",
"def add_to_set(set, word)\n\tif !(set.key?(word))\n\t\tset.merge!(word => 1)\n\telse\n\t\tset[word] += 1\n\tend\nend",
"def parse_set\n @current_set = Set.new\n @current_match.add_set @current_set\n end",
"def search_builder(*args)\n super.tap do |builder|\n if @set\n builder.set = @set\n end\n end\n end",
"def add(val)\n @set.include?(val) ? nil : @set.push(val)\n end",
"def find(dict)\n Ohm::Set.new(\n model, namespace, [:SINTER, key, *model.filters(dict)]\n )\n end",
"def restrict_to_set(solr_params)\n if set && set.respond_to?(:uri)\n solr_params[:fq] ||= []\n solr_params[:fq] << \"#{ActiveFedora::SolrQueryBuilder.solr_name(\"set\", :symbol)}:#{RSolr.solr_escape(set.uri)}\"\n end\n end",
"def MakeSet(dset, x)\n unless dset[x] \n # add x to the disjoint-set tree\n dset[x] = {parent: x, size:1}\n end\nend",
"def cmd_db_set_add_to(*args)\n\t\t\treturn fun_usage unless args.count > 0\n\t\t\t\n\t\t\tset_id = args[0]\n\t\t\tif is_valid_set?(set_id)\n\t\t\t\t@sets[set_id].merge!(@working_set)\n\t\t\telse\n\t\t\t\tprint_error \"#{set_id} is not a valid set id\"\n\t\t\tend\n\t\tend",
"def add(_, working_set = nil)\n return unless working_set\n entries.insert(position + 1, working_set)\n go_forward_history(nil)\n end",
"def set(hash)\n if @where\n raise QueryError, 'Filtering has already been provided. Must filter after setting values.'\n end\n\n @sets ||= {}\n hash.each do |key, value|\n @sets[key] = value_escape(value)\n end\n self\n end",
"def add_to_set(adds)\n prepare_atomic_operation do |ops|\n process_atomic_operations(adds) do |field, value|\n existing = send(field) || attributes[field]\n if existing.nil?\n attributes[field] = []\n # Read the value out of attributes:\n # https://jira.mongodb.org/browse/MONGOID-4874\n existing = attributes[field]\n end\n values = [ value ].flatten(1)\n values.each do |val|\n existing.push(val) unless existing.include?(val)\n end\n ops[atomic_attribute_name(field)] = { \"$each\" => values }\n end\n { \"$addToSet\" => ops }\n end\n end",
"def add_set(set_id, item_ids)\n raise \"implemented in subclass\"\n end",
"def add_each_to_set(adds)\n view.update_many(\"$addToSet\" => collect_each_operations(adds))\n end",
"def combine(dict)\n Ohm::Set.new(\n model, namespace, [:SINTER, key, [:SUNION, *model.filters(dict)]]\n )\n end",
"def test_find_words_dict_empty\n words = ['apple','bat','candy']\n dict = Set.new\n assert_equal [], @grapher.find_words(words, dict)\n end",
"def new_set\r\n @sets[@current_set_name] = @current_set\r\n @current_set = []\r\n end",
"def add(namespace:, name:, tags:)\n @registry[key(namespace, name)] = Set.new(tags)\n end",
"def insert(value)\n records << value\n record_id = records.count - 1\n\n trigrams = hash(value)\n trigrams.each do |tri|\n index[tri] ||= []\n index[tri] << record_id\n end\n end",
"def intersect(other)\n set = MyHashSet.new\n to_a.each { |el| set.insert(el) if other.include?(el) }\n set\n end",
"def linsert(key, where, pivot, value); end",
"def linsert(key, where, pivot, value); end",
"def enter_object_id_search_data(data_set)\n enter_object_nums data_set\n enter_resp_depts data_set\n enter_collections data_set\n enter_record_statuses data_set\n enter_titles data_set\n enter_object_names data_set\n end",
"def dictionary_set\n @@dictionary_set ||= Set.new.tap do |set|\n DICTIONARY_BREAK_ENGINES.each do |break_engine|\n set.merge(break_engine.word_set)\n end\n end\n end",
"def set_finder(search_param, set)\n render_output(set.grep(/#{search_param}/).to_a.sort) unless search_param.blank?\n end",
"def set_intersect(*keys)\n timeout_retry(3, 3){\n write \"SINTER #{keys.join(' ')}\\r\\n\"\n Set.new(multi_bulk_reply)\n }\n end",
"def push cv\r\n\t\t@set.push cv\r\n\tend",
"def test_find_words_valid\n words = ['apple','bat','cat']\n dict = Set['apple','bat','cat']\n assert_equal Set[\"apple\"], @grapher.find_words(words, dict)\n end",
"def set(ot)\n merge(ot)\n self\n end",
"def getset(key); end",
"def test_create_dict_set_is_a_set\n assert_kind_of Set, @grapher.create_dict_set('wordlist.txt')\n end",
"def entry_set; end",
"def sets\n end",
"def new_result_sets_for(searches)\n new_result_sets = Hash.new\n searches.each do |s|\n new_result_sets[s] = s.new_results if s.new_results.count > 0 \n end\n return new_result_sets\n end",
"def registerTSet(tset, pattern)\n pat = pattern.collect do |el|\n (el.is_a?(Symbol) && el.to_s.end_with?('?')) ? nil : el\n end\n @tsets[tset] = pat\n\n # seed tset which already stored data\n find(pat).each do |t|\n tset.addTuple(t)\n end\n tset\n end",
"def in_admin_set(solr_parameters)\n solr_parameters[:fq] ||= []\n solr_parameters[:fq] << \"{!term f=#{Hyrax.config.admin_set_predicate.qname.last}_ssim}#{collection.id}\"\n end",
"def add_entries(new_entries)\r\n new_entries.each { |entry|\r\n @entries << entry\r\n date_key = entry.date.strftime(\"%Y-%m-%d\")\r\n entry_set = @entries_by_date[date_key]\r\n if not entry_set\r\n entry_set = Set.new\r\n @entries_by_date[date_key] = entry_set\r\n end\r\n entry_set << entry\r\n }\r\n end",
"def visit_set(binding_type)\n orig_input = self.input # save\n out_set = Set.new\n et = binding_type.element_type\n for ev in orig_input.value\n candidate = visit_list_element(ev, et)\n if out_set.include? candidate\n report_error('vapi.bindings.typeconverter.set.duplicate.element', candidate)\n end\n out_set << candidate\n end\n self.input = orig_input # restore\n self.result = out_set\n end",
"def initialize()\n @restaurants = SortedSet.new\n end",
"def add_node(id)\n @g[id] = Set.new\n end",
"def _insert_values\n identifier_hash(super)\n end",
"def new_input_set()\n return SearchInputSet.new()\n end",
"def set(sets)\n view.update_many(\"$set\" => collect_operations(sets))\n end",
"def set_search_params \n # TODO: figure out how to do this without having to change params to symbols\n symbolic_params = {}\n search_params.each_pair do |key, value|\n symbolic_params.merge!(key.to_sym => value)\n end\n @search_params = symbolic_params\n end",
"def union(dict)\n Ohm::Set.new(\n model, namespace, [:SUNION, key, [:SINTER, *model.filters(dict)]]\n )\n end",
"def new_input_set()\n return SearchInputSet.new()\n end",
"def new_input_set()\n return SearchInputSet.new()\n end",
"def &(enum)\n new_set = TreeSet.new\n enum.each do |val|\n new_set << val if self.include?(val)\n end\n new_set\n end",
"def test_find_words_multiple\n words = ['apple','candy','bat']\n dict = Set['apple','bat','candy','cat']\n assert_equal Set[\"apple\",\"candy\"], @grapher.find_words(words, dict)\n end",
"def union(other)\n set = MyHashSet.new\n (to_a + other.to_a).uniq.each { |el| set.insert(el) }\n set\n end",
"def initialize_set(h)\n set(h) unless h.empty?\n end",
"def initialize_set(h)\n set(h) unless h.empty?\n end",
"def add_for_namespace(namespace:, tags:)\n @registry[namespace] = Set.new(tags)\n end",
"def rset; end",
"def setByApplyingConditionsToSet(set)\n if @predicate\n if set.is_a?(NSOrderedSet)\n # TODO not the most efficient way of doing this when there are also sort descriptors\n filtered = set.array.filteredArrayUsingPredicate(@predicate)\n set = NSOrderedSet.orderedSetWithArray(filtered)\n else\n set = set.filteredSetUsingPredicate(@predicate)\n end\n end\n\n unless @sortDescriptors.empty?\n set = set.set if set.is_a?(NSOrderedSet)\n sorted = set.sortedArrayUsingDescriptors(@sortDescriptors)\n set = NSOrderedSet.orderedSetWithArray(sorted)\n end\n\n set\n end",
"def insert(key)\n end",
"def hset(key, *attrs); end",
"def lset(key, index, value); end",
"def lset(key, index, value); end",
"def apply_harvesting_set_membership(sets)\n\t\t#We delete previous set memberships and move to new set\n old_sets = harvesting_set_membership.dup\n old_sets.each { |s| self.remove_relationship(:is_member_of_collection, s) }\n sets.delete_if { |s| s == \"\"}.each { |s| self.add_relationship :is_member_of_collection, s }\n\tend",
"def apply_harvesting_set_membership(sets)\n\t\t#We delete previous set memberships and move to new set\n old_sets = harvesting_set_membership.dup\n old_sets.each { |s| self.remove_relationship(:is_member_of_collection, s) }\n sets.delete_if { |s| s == \"\"}.each { |s| self.add_relationship :is_member_of_collection, s }\n\tend",
"def new_input_set()\n return SearchByKeywordInputSet.new()\n end",
"def check(words:)\n dictionary = Set.new([\"hello\", \"my\", \"name\", \"is\", \"orange\"])\n corrected = []\n words.each do | word |\n dictionary.include?(word) ? corrected.push(word) : corrected.push(\"~#{word}~\")\n end\n corrected\nend",
"def insert(num)\n false if include?(num)\n self[num] << num\n true\n end",
"def sets\n with_caching({}, 'sets') do\n sibling_nodes_for('set').map {|n| Set.new(n, authentication_options) }\n end\n end",
"def matching_sets(path, type); end",
"def to_set\n require 'set' unless defined?(::Set)\n each.to_set\n end",
"def initialize args={}\n assign(args)\n @associated_objects = Hash.new{ |h, k| h[k] = Set.new }\n end",
"def intersection(other_set)\n new_set = []\n # Fill our empty array with elements that are members of both sets\n other_set.set.each do |element|\n new_set.push(element) if @set.include?(element)\n end\n Set.new(new_set)\n end",
"def populateSearch\n Search.transaction do\n search = Search.new\n @results.keys.each do |key|\n s = search.search_stonks.new\n s.stonk = Stonk.find_by symbol: key\n s.count = @results[key]\n end\n search.save!\n end\n end",
"def prepare_suggested_searches\n @suggested_searches = [\n # { label_key: 'search_suggestion_whale_mass',\n # params: {\n # sort: 'desc',\n # min: 10000,\n # taxon_concept_id: 7649,\n # attribute: 'http://purl.obolibrary.org/obo/VT_0001259',\n # unit: 'http://purl.obolibrary.org/obo/UO_0000009' }},\n # { label_key: 'search_suggestion_cavity_nests',\n # params: {\n # q: 'cavity',\n # attribute: 'http://eol.org/schema/terms/NestType' }},\n { label_key: 'search_suggestion_diatom_shape',\n params: {\n attribute: 'http://purl.obolibrary.org/obo/OBA_0000052',\n taxon_concept_id: 3685 }} #,\n # { label_key: 'search_suggestion_blue_flowers',\n # params: {\n # q: 'http://purl.obolibrary.org/obo/PATO_0000318',\n # attribute: 'http://purl.obolibrary.org/obo/TO_0000537' }}\n ]\n end",
"def store(key, process, options)\n has_keys?(key, options[:has_keys]) if(options.has_key?(:has_keys))\n contains?(validator.filtered, validator.datas[key].values, options[:contains]) if(options.has_key?(:contains))\n super(key, process, options)\n end",
"def in_temporary_set(*contents)\n index = RedisInteger.new(\"blendris:temporary:index\").increment\n\n temporary_set = RedisSet.new(\"blendris:temporary:set:#{index}\")\n temporary_set << contents\n\n begin\n yield temporary_set\n ensure\n temporary_set.clear\n end\n\n self\n end",
"def insert_all(iter)\n iter.each {|v|\n insert v\n }\n nil\n end",
"def new_input_set()\n return SiteSearchInputSet.new()\n end",
"def new_input_set()\n return SearchWordsInputSet.new()\n end",
"def new_input_set()\n return SearchBySubjectInputSet.new()\n end",
"def add_to_search_list\n list = FFI::MemoryPointer.new(:pointer)\n status = Sec.SecKeychainCopySearchList(list)\n Sec.check_osstatus(status)\n ruby_list = CF::Base.typecast(list.read_pointer).release_on_gc.to_ruby\n ruby_list << self unless ruby_list.include?(self)\n status = Sec.SecKeychainSetSearchList(CF::Array.immutable(ruby_list))\n Sec.check_osstatus(status)\n self\n end",
"def add_restriction(res, key, value)\n if res[key].nil?\n res[key] = [value]\n else\n res[key] << value unless res[key].include? value\n end\n end",
"def to_set\n a = Set.new\n @index.each_value do |s|\n s.each do |t|\n a << t\n end\n end\n a\n end",
"def merge(other_set)\n requires_set(other_set, __method__)\n MySet.new(members + other_set.members)\n end",
"def nsindexset\n if self.length == 0\n raise \"An index set must have at least one index\"\n end\n\n set = NSMutableIndexSet.indexSet\n self.each do |val|\n set.addIndex val\n end\n set\n end",
"def nsindexset\n if self.length == 0\n raise \"An index set must have at least one index\"\n end\n\n set = NSMutableIndexSet.indexSet\n self.each do |val|\n set.addIndex val\n end\n set\n end",
"def getset(key, value); end",
"def getset(key, value); end",
"def entry_set=(_arg0); end",
"def hset(key, *attrs)\n node_for(key).hset(key, *attrs)\n end",
"def initialize()\r\n @entries = Set.new\r\n @entries_by_date = {}\r\n end",
"def to_set(klass = Set, *args, &block)\n return self if instance_of?(Set) && klass == Set && block.nil? && args.empty?\n klass.new(self, *args, &block)\n end",
"def aset(index, value)\n end",
"def set; end",
"def set; end",
"def new_input_set()\n return SchoolSearchInputSet.new()\n end"
] |
[
"0.6177171",
"0.607688",
"0.59745497",
"0.5956627",
"0.5948206",
"0.59259856",
"0.58951247",
"0.58811456",
"0.5874943",
"0.58352625",
"0.5789481",
"0.5749088",
"0.5687204",
"0.56850153",
"0.5616526",
"0.56158483",
"0.56066525",
"0.5598883",
"0.55987775",
"0.55276084",
"0.5527185",
"0.55235875",
"0.5507035",
"0.5482435",
"0.5480263",
"0.5469509",
"0.5444485",
"0.54222935",
"0.54222935",
"0.5417644",
"0.54155034",
"0.5414508",
"0.54142165",
"0.5405483",
"0.5385895",
"0.53776544",
"0.53719383",
"0.5351602",
"0.5346083",
"0.5334151",
"0.5320153",
"0.5319264",
"0.5317124",
"0.5313567",
"0.52990115",
"0.5287754",
"0.528279",
"0.52815527",
"0.5255676",
"0.5246996",
"0.52356195",
"0.52317077",
"0.5223764",
"0.5223668",
"0.5217392",
"0.5213562",
"0.52134174",
"0.5212955",
"0.5212955",
"0.52079517",
"0.51868767",
"0.517833",
"0.5174558",
"0.51650214",
"0.5158778",
"0.5158778",
"0.51479954",
"0.51479954",
"0.512198",
"0.5121676",
"0.5114627",
"0.5109709",
"0.50968623",
"0.5086933",
"0.5073575",
"0.50670236",
"0.506081",
"0.5058181",
"0.50522774",
"0.5048528",
"0.5044567",
"0.50430125",
"0.5042546",
"0.50404865",
"0.5038182",
"0.5037927",
"0.50251377",
"0.5024555",
"0.5011418",
"0.5011418",
"0.5010042",
"0.5010042",
"0.50097305",
"0.50057566",
"0.5005505",
"0.5000633",
"0.49984562",
"0.4987076",
"0.4987076",
"0.49868366"
] |
0.6488078
|
0
|
Run the rotation_analysis and print out the results
|
def run_rotation_analysis
initialize_run
rotate_group
print_summary
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def print_rotation_count\n @rotation_count += 1\n print \"\\r\\e#{@rotation_count} of #{@maximum_rotations} processed...\"\n $stdout.flush\n end",
"def main\n north_south = 0\n east_west = 0\n rotation = 0\n\n standard_rotations = {\n 0 => { north_south: 0, east_west: 1 },\n 90 => { north_south: 1, east_west: 0 },\n 180 => { north_south: 0, east_west: -1 },\n 270 => { north_south: -1, east_west: 0 },\n }\n input_lines.map do |line|\n [line[0], line[1..-1].to_i]\n end.each do |instruction, value|\n #binding.pry if instruction == \"F\" && value == 11\n\n case instruction\n when 'F'\n north_south += value * standard_rotations[rotation][:north_south]\n east_west += value * standard_rotations[rotation][:east_west]\n when 'N'\n north_south += value\n when 'S'\n north_south -= value\n when 'E'\n east_west += value\n when 'W'\n east_west -= value\n when 'L'\n rotation += value\n when 'R'\n rotation -= value\n else\n raise \"bad instruction. oh no.\"\n end\n\n rotation += 360 while rotation < 0\n rotation -= 360 while rotation >= 360\n end\n\n distance = north_south.abs + east_west.abs\n\n puts distance\nend",
"def outputResultsVerbose tracer, input\n rotationTest = (tracer.length/2).to_i\n standingAt = -1\n (0..(tracer.length-1)).each do |posit|\n if standingAt == -1\n p \"Start with the \" + input[tracer[posit]] + \" at position \" + tracer[posit].to_s\n standingAt = tracer[posit]\n else\n dir = 1\n move = tracer[posit] - standingAt\n if move < 0\n move *= -1\n\tdir = -1\n end\n if move > rotationTest\n\tmove = (tracer.length - move)\n dir *= -1\n end\n dirWords = (dir == 1 ? \"clockwise\" : \"counterclockwise\")\n p \"Move \" + move.to_s + \" steps \" + dirWords + \" to the \" + input[tracer[posit]] + \" (position \" + tracer[posit].to_s+ \")\"\n standingAt = tracer[posit]\n end\n end\nend",
"def runAnalyzer(num_samples,inhash)\n # select profile for run\n show do \n title \"Select #{QIAXCEL_TEMPLATE[inhash[:sampleTypes]]}\" # this is just a profile name, should be ok for other polymerases\n note \"Click <b>Back to Wizard</b> if previous data is displayed.\"\n check \"Under <b>Process -> Process Profile</b>, make sure <b>#{QIAXCEL_TEMPLATE[inhash[:sampleTypes]]}</b> is selected.\"\n end\n \n # select alignment marker\n ref_marker = (inhash[:sampleTypes] == 'DNA') ? REF_MARKERS[inhash[:type_ind]][inhash[:cutoff_ind]] : REF_MARKERS[inhash[:type_ind] ]\n show do \n title \"Select alignment marker\"\n check \"Under <b>Marker</b>, in the <b>Reference Marker </b> drop-down, select <b>#{ref_marker}</b>. A green dot should appear to the right of the drop-down.\"\n end\n \n # empty rows\n if inhash[:sampleTypes] == 'RNA'\n num_samples = num_samples + 1 # Include the ladder in the first well of the first stripwell\n nonempty_rows = (num_samples/WELLS_PER_STRIPWELL.to_f).ceil\n (num_samples % WELLS_PER_STRIPWELL) > 0 ? nonempty_rows + 1 : nonempty_rows\n else\n nonempty_rows = (num_samples/WELLS_PER_STRIPWELL.to_f).ceil\n end\n show do \n title \"Deselect empty rows\"\n check \"Under <b>Sample selection</b>, deselect all rows but the first #{nonempty_rows}.\"\n end\n \n # check \n show do \n title \"Perform final check before running analysis\"\n note \"Under <b>Run Check</b>, manually confirm the following:\"\n check \"Selected rows contain samples.\"\n check \"Alignment marker is loaded (changed every few weeks).\"\n end\n \n # run and ask tech for remaining number of runs\n run_data = show do \n title \"Run analysis\"\n note \"If you can't click <b>Run</b>, and there is an error that reads <b>The pressure is too low. Replace the nitrogen cylinder or check the external nitrogen source</b>, close the software, and reopen it. Then restart at title - <b>Select #{QIAXCEL_TEMPLATE[inhash[:sampleTypes]]} </b>\"\n check \"Otherwise, click <b>Run</b>\"\n note \"Estimated time of experiment is given at the bottom of the screen\"\n get \"number\", var: \"runs_left\", label: \"Enter the number of <b>Remaining Runs</b> left in this cartridge\", default: 0\n #image \"frag_an_run\"\n end\n \n # return\n run_data[:runs_left]\n \n end",
"def run_examination\n if stream.missing?\n @original_width, @original_height = 1, 1\n false\n else\n output = `identify -format \"%w %h %[exif:Orientation]\" #{stream.path} 2> /dev/null`\n if $?.success? && output.present?\n width, height, orientation = *output.scan(/(\\d+) (\\d+) (\\d?)/).first.map{|s| s.to_i}\n rotated = (5..8).include?(orientation)\n @original_width = rotated ? height : width\n @original_height = rotated ? width : height\n true\n else\n Bulldog.logger.warn \"command failed (#{$?.exitstatus})\"\n @original_width, @original_height = 1, 1\n false\n end\n end\n end",
"def run_program()\n final_words()\n segmented_output()\n end",
"def initialize_run\n @summary_totals.clear\n @rotation_count = 0\n\n # Compute total number of rotation permutations for the run.\n # number_of_columns^(number_of_groups - 1)\n @maximum_rotations = @groups[0][0].length ** @max_group_index\n end",
"def run()\r\n rounds.times do |i|\r\n round(i+1)\r\n end\r\n #$stderr.puts \"#{name} Finished!\\n\"\r\n #below codes is used to output report\r\n output()\r\n end",
"def run_challenge\n @rovers = []\n print_welcome\n get_plateau_coordinates\n get_rover_instructions\n print_output\n end",
"def zrotation\n end",
"def setup_rotation\n return TSBS.error(@acts[0], 3, @used_sequence) if @acts.size < 4\n @angle = @acts[1]\n change_angle(@acts[2], @acts[3])\n end",
"def analyze\n format_results\n end",
"def perform\n result_file = nil\n \n # Create the alignment files\n result_file = generate_alignment if @task == :all || @task == :align\n \n # Identify the clusters\n result_file = identify_clusters if @task == :all || @task == :cluster\n \n result_file\n end",
"def display_results(result_array)\n puts \"------------------- Completed run ----------------------------\"\n puts \"Samples: #{result_array.length}\"\n puts \"Min time: #{result_array.min}\"\n puts \"Max time: #{result_array.max}\"\n puts \"Average time: #{result_array.mean}\"\n puts \"Standard Deviation: #{result_array.standard_deviation}\"\n puts \"Values: #{result_array.inspect}\" if @show_values\n puts \"--------------------------------------------------------------\"\n end",
"def print_array(arr)\n print(\"Rotated array is: \" + arr.join(\", \") + \"\\n\")\n return\nend",
"def create_analysis_views\n puts \"====================\"\n puts \"creating analysis views for #{self.name}\"\n puts \"====================\"\n\n run_analysis_views\n\n puts \"> done\"\n puts \"====================\"\n end",
"def test_complete_rotation\n rover = MarsRover.new\n rover.command('LLLL')\n assert_equal([0,0,'N'], rover.position)\n end",
"def show_results(generated_files: true)\n @end_time = Time.now\n tree = if generated_files\n [' ',\n \"Generated files: #{@out_dir}\",\n ' ',\n TTY::Tree.new(@out_dir).render]\n else\n ''\n end\n puts\n puts TTY::Box.frame(\"Start : #{@start_time}\",\n \"End : #{@end_time}\",\n \"Time : #{@end_time - @start_time} sec\",\n *tree,\n title: { top_left: \" #{self.class.name} \" },\n width: TTY::Screen.width, padding: 1)\n end",
"def analyze_sonorities\n sonority_to_test = Set.new # A work space for slicing\n result_counts = [] # Success counters of columns\n\n # Loop on columns in the matrix and extract out the sonority. Compare that to the dictionary of vertical sets to\n # compute a score for each column.\n\n @groups[0][0].each_index do |column_id| # Loop on number of number of columns\n result_counts[column_id] = 0 # Initialize counter for column\n sonority_to_test.clear\n\n # Slice through the voices of all groups and their rows to create a sonority to test.\n @groups.each_index do |group_id|\n @groups[group_id].each_index { |row_id| sonority_to_test.add( @groups[group_id][row_id][column_id] ) }\n end\n\n # Search the dictionary of vertical sets we are looking for and increment column counter if found.\n @search_sets.each { |set_to_search| result_counts[column_id] += 1 if set_to_search.subset?(sonority_to_test) }\n end\n\n # Accumulate a cross total of column result to create a final score for the current rotation snapshot.\n score = result_counts.inject(0) { |sum, col_result| sum += col_result }\n\n # If we meet the search criteria then add results to report totals and optionally print details.\n if @minimax_score.include?(score)\n accumulate_summary_totals(score)\n\n # Optionally print details of this rotation snapshot.\n print_details(result_counts, score) if @report_details\n end\n\n print_rotation_count unless @report_details # run progress meter if in summary mode\n\n end",
"def index\n @rotations = Rotation.all\n end",
"def index\n @rotations = Rotation.all\n end",
"def print_results\n puts \"running time\\t\\t\\t= #{@time / 1000.0}s\"\n puts \"mean\\t\\t\\t\\t= #{mean}\"\n puts \"stddev\\t\\t\\t\\t= #{stddev}\"\n print \"95% confidence interval\\t\\t= #{confidence_interval}\\n\"\n end",
"def after_run\n check_output_files\n show_results\n end",
"def create_analysis_tables_and_views\n puts \"====================\"\n puts \"creating analysis tables and views for #{self.name}\"\n puts \"====================\"\n\n run_analysis_tables\n run_analysis_views\n\n puts \"> done\"\n puts \"====================\"\n end",
"def analyze_samples\n run_data = show do \n title \"Run analysis\"\n note \"If you can't click \\\"run\\\", and there is an error that reads, \\\"The pressure is too low. Replace the nitrogen cylinder or check the external nitrogen source,\\\" \n close the software, and reopen it. Then repeat steps 9-13.\"\n check \"Otherwise, click run\"\n note \"Estimated time is given at the bottom of the screen\"\n get \"number\", var: \"runs_left\", label: \"Enter the number of \\\"Remaining Runs\\\" left in this cartridge.\", default: 0\n image \"Actions/Fragment Analyzer/frag_an_run.jpg\"\n end\n\n while run_data[:runs_left].nil? && !debug\n run_data = show do \n title \"Enter remaining runs\"\n warning \"Please enter the number of remaining runs left in this cartridge.\"\n get \"number\", var: \"runs_left\", label: \"Enter the number of \\\"Remaining Runs\\\" left in this cartridge.\", default: 0\n end\n end\n run_data\n end",
"def basic_anatomical_reconstruction\n\n # Create the T1 & other Anatomicals\n @commands << \"convert_visit.rb #{@raw_directory} #{@config[:subj_processed_dir]}\"\n\n # Create the ASL\n modality_dir = File.join(@config[:subj_processed_dir], @config[:modality])\n Dir.mkdir_p modality_dir unless File.exists? modality_dir \n Dir.chdir modality_dir do\n # fmap_make /Data/vtrak1/raw/dempsey.plaque.visit1/plq20005_1959_04072011/009\n #(Or, to search automatically: )\n @commands << \"fmap_make `list_visit #{@raw_directory} -g #{@config[:modality]}`\"\n\n # Link the T1 into the ASL directory for easy visualization if you want.\n\n # File.symlink(\"../unknown/plq02002_Ax-FSPGR-BRAVO_003.nii\", \"plq02002_Ax-FSPGR-BRAVO_003.nii\")\n end\n end",
"def run\n create_log_folder\n \n in_tmp_dir do\n start_frame = tmp_path START_FRAME\n extract_start_transition_frame(start_frame) # 1.\n \n end_frame = tmp_path END_FRAME\n extract_end_transition_frame(end_frame) # 2.\n \n transitions = tmp_path TRANSITIONS\n Cmd::GenerateTransitionFrames.new(start_frame, end_frame, transitions, INNER_FRAMES_AMOUNT).run! *logs('3_generate_transition_frames') # 3.\n \n Queue.run *FORMATS.map{ |format| proc{ transition(format) } }, close_connection_before_execution: true # 4.\n end\n \n outputs\n end",
"def display_results\n make\n display_best\n display_mutations unless @mutations\n end",
"def show\n if (@analysis.done?)\n # TODO: Refactor, this is not nice here.\n As2Init.new(@analysis)\n end\n\n end",
"def rotation\n {\n axis: @r[0],\n angle: @r[1],\n matrix: @r[2]\n }\n end",
"def generate_output\n write_average_fitness('output/average.txt')\n write_best_fitness('output/best.txt')\n write_survivors('output/survivors.txt')\n write_traits('output/traits.txt')\n end",
"def run\n\t\tif File.exists? @outdir then\n\t\t\t$stderr.puts \"*error: #{@outdir} exists\"\n\t\t\t$stderr.puts \"Remove/move, just do something!\"\n\t\t\texit 1\n\t\tend\n\n\t\twriteInitialContents\n\t\texpandContents\n\t\tperformEquation\n\n\t\tDir.mkdir @outdir\n\t\twritePlist\n\t\twriteHints\n\t\tclean\n\tend",
"def my_rotate(rotation = 1)\n # debugger\n answer = []\n each_with_index { |x, i| answer[i] = x }\n if rotation > 0\n rotation.times { answer.push(answer.shift) }\n elsif rotation == 0\n answer\n else\n rotation.abs.times { answer.unshift(answer.pop) }\n end\n answer\n end",
"def rotate(angle, around_x=0, around_y=0, &rendering_code); end",
"def run_align_assess\n filename = self.generate_fasta_alignment_file_for_all\n string = \"./lib/AlignAssess_wShorterID #{filename} P\"\n seq_array = Array.new\n if system(string)\n seq_id_array = self.sequences.map{|s| s.seq_id}\n new_filename = filename + \"_assess\"\n f = File.new(new_filename, \"r\")\n flag = false\n read_row= 999999999\n cur_row = 0\n while (line = f.gets)\n if cur_row > read_row && flag\n if line == \"\\n\"\n flag =false\n else\n seq_array << line.split(\"\\t\")\n end\n elsif line == \"Pair-wise %ID over shorter sequence:\\n\"\n flag=true\n read_row = cur_row + 2\n end\n cur_row +=1\n end\n range = seq_array.length - 1\n #seq_array.each do |row|\n for row_num in 0..range\n for i in 1..range#(row_num) \n PercentIdentity.first_or_create(:seq1_id=>seq_id_array[row_num],\n :seq2_id=>seq_id_array[i],\n :alignment_name => self.alignment_name,\n :percent_id=>seq_array[row_num][i])\n # print \"[#{row_num}:#{i-1}=>#{row[i]}],\"\n end\n #print \"\\n\"\n end\n end\n end",
"def run()\n\t\tputs \"#{@name} ran for #{@meters} meters in #{self.getTimeLapse} seconds\"\n\t\t# chiama funzione per stampare quante volte ha respirato\n\t\tself.breathe\n\tend",
"def run_score\n filename = self.generate_fasta_alignment_file\n string = \"./lib/score_mac #{filename} temp_data/#{self.alignment_name}_res.txt temp_data/#{self.alignment_name}_dif.txt temp_data/#{self.alignment_name}_alignments.txt\"\n puts string\n if system(string)\n \n end\n end",
"def show\n if CLI.options[:output]\n # <= Sortie dans un fichier\n p = File.expand_path('./occurences')\n error \"La sortie en fichier est à implémenter\"\n else\n # Sortie en console\n display_table_occurences\n end\n end",
"def show\n @inputs = @analysis_configuration.analysis_parameters.inputs\n @outputs = @analysis_configuration.analysis_parameters.outputs\n end",
"def display_results\r\n if @errors.empty?\r\n if @test_diff.empty?\r\n @out.puts \"Output matches exactly\"\r\n else\r\n @out.puts \"Test diff:\"\r\n @out.puts @test_diff\r\n end\r\n else\r\n @errors.each {|error| @out.puts error }\r\n end\r\n end",
"def run\n case @operacion\n when :lectura\n raise RuntimeError , 'Numero de operandos invalidos' unless @operandos.size() == 1\n \n @resultado = @operandos[0] # Densa\n if(@modo_resultado == :dispersa)\n @resultado = Matriz_Dispersa.copy(@operando[0])\n elsif(@modo_resultado == :auto)\n if(@resultado.null_percent > 0.6) # Pasar a dispersa si tiene más de un 60% de elementos nulos\n @resultado = Matriz_Dispersa.copy(@operando[0])\n end\n end\n \n if(@modo == :consola)\n puts @resultado.to_s\n elsif(@modo == :fichero)\n File.open('output.me', 'w') { |file| file.write(@resultado.to_s) }\n end\n #--\n # Fin lectura\n #++\n when :suma\n raise RuntimeError , 'Numero de operandos invalidos' unless @operandos.size() == 2\n \n @resultado = @operandos[0].suma_noauto(@operandos[1]) # Densa\n if(@modo_resultado == :dispersa or (@modo_resultado == :auto and @resultado.null_percent >= 0.6))\n @resultado = Matriz_Dispersa.copy(@resultado)\n end\n \n if(@modo == :consola)\n puts @resultado.to_s\n elsif(@modo == :fichero)\n File.open('output.me', 'w') { |file| file.write(@resultado.to_s) }\n end\n #--\n # Fin suma\n #++\n when :resta\n raise RuntimeError , 'Numero de operandos invalidos' unless @operandos.size() == 2\n\n @resultado = @operandos[0].resta_noauto(@operandos[1]) #Densa\n if(@modo_resultado == :dispersa or (@modo_resultado == :auto and @resultado.null_percent >= 0.6))\n @resultado = Matriz_Dispersa.copy(@resultado)\n end\n\n if(@modo == :consola)\n puts @resultado.to_s\n elsif(@modo == :fichero)\n File.open('output.me', 'w') { |file| file.write(@resultado.to_s) }\n end\n #--\n # Fin resta\n #++\n when :multiplicacion\n raise RuntimeError, 'Numero de operandos invalidos' unless @operandos.size() == 2\n\n @resultado = @operandos[0].multiplicacion_noauto(@operandos[1]) #Densa\n if(@modo_resultado == :dispersa or (@modo_resultado == :auto and @resultado.null_percent >= 0.6))\n @resultado = Matriz_Dispersa.copy(@resultado)\n end\n\n if(@modo == :consola)\n puts @resultado.to_s\n elsif(@modo == :ficehro)\n File.open('output.me', 'w') { |file| file.write(@resultado.to_s) }\n end\n #--\n # Fin multiplicacion\n #++\n else\n puts \"ERROR: Unknown option\", @operacion\n end\n end",
"def test_print_usage\n fr = FileReader.new\n assert_output(\"Usage: ruby verifier.rb <name_of_file>\\n\"\\\n \"\\tname_of_file = name of file to verify\\n\") { fr.print_usage }\n end",
"def run(result)\n result.module_name = \"FDF\"\n result.options = @options\n analyse result\n @show.call \"Done! Everything worked fine!\"\n @show.call \"You can now run generate_result to extract interesting informations.\"\n true\n end",
"def write\n\n # reverse alignments\n @first_result.reverse!\n @second_result.reverse!\n\n # Create middle section for matches/mismatches\n index = 0\n @first_result.length.times do\n if @first_result[index] == @second_result[index]\n @central_alignment << \"|\"\n else\n @central_alignment << \" \"\n end\n index += 1\n end\n\n offset = @start_first > @start_second ? @start_first.to_s.length : @start_second.to_s.length\n border = \"\"\n\n (offset+1).times do # lines up center with alignments\n border << \"=\"\n end\n\n # formats beginning and end of sequence output\n @first_result.insert(0, @start_first.to_s << \"=\")\n @first_result << \"=\" << @max_cell_row.to_s\n @second_result.insert(0, \"\" << @start_second.to_s << \"=\")\n @second_result << \"=\" << @max_cell_column.to_s\n @central_alignment.insert(0, border)\n @central_alignment << border\n\n # separate sequences and center into at most chunks of at most 60\n first_chunks = @first_result.scan(/.{1,60}/)\n central_chunks = @central_alignment.scan(/.{1,60}/)\n second_chunks = @second_result.scan(/.{1,60}/)\n\n length = first_chunks.length\n\n File.open(\"result.txt\", 'w') {|file| \n i = 0\n length.times do\n file.puts first_chunks[i]\n file.puts central_chunks[i]\n file.puts second_chunks[i]\n file.puts\n i += 1\n end\n }\n\n end",
"def run\n pegs = read_input\n usage! if pegs.empty?\n\n numerator, denominator = GearCalculator.answer(pegs)\n puts \"[#{numerator}, #{denominator}]\"\n end",
"def rotate(direction)\n\t\tnew_vector = (@robot.vectors[@robot_direction] + TURNING[direction]) % @robot.vectors.length\n\t\t@robot_direction = @robot.vectors.key(new_vector)\n\t\tputs \"Roger, roger. I\\'ve turned to the #{direction}! I\\'m now facing #{@robot_direction}\"\n\tend",
"def create_rotation\n end",
"def run_analysis\n prepare_pml\n unless analysis_entry\n die(\"Analysis entry '#{options.analysis_entry}' not found (check for typos, inlined functions or code not reachable from program entry)\")\n end\n options.use_trace_facts = true if options.compare_trace_facts\n options.trace_analysis = true if options.use_trace_facts\n trace_analysis if options.trace_analysis\n sweet_analysis if options.enable_sweet\n transform_down([\"llvm.bc\"],\"llvm\")\n transform_down([\"user.bc\"],\"user\")\n\n flow_srcs = [\"llvm\", \"user\"]\n wcet_analysis(flow_srcs) if options.compare_trace_facts\n\n flow_srcs.push(\"trace\") if options.use_trace_facts\n flow_srcs.push(\"sweet\") if options.enable_sweet\n\n # FIXME: check if this is necessary (CFRG testsuite)\n flow_srcs.push(\"trace.support\") if options.enable_sweet && options.trace_analysis\n\n # TODO we should (also?) add a 'configuration' name to the TimingEntry that refers to an analysis-configuration name\n options.timing_output = [options.timing_output,'trace'].compact.join('/') if options.use_trace_facts\n\n wcet_analysis(flow_srcs)\n report(additional_report_info)\n pml\n end",
"def parrot\n puts \"Squawk!\"\nend",
"def execute(directory = \"results\", mode: :csv)\n pos = 0\n @log.scan(EXAMPLE_PATTERN).size.times { |_| pos = extract_tests(pos) }\n\n path_name = Pathname.pwd + directory + \"#{Date.today.strftime('%Y%m%d')}.#{mode}\"\n if mode == :csv\n CSV.open(path_name, \"w\") do |csv|\n csv << %w[seconds example file]\n @collection.aggregate.each { |test| csv << test.to_a }\n end\n else\n File.open(path_name, \"w\") do |file|\n file.puts Date.today.strftime(\"%Y%m%d\")\n file.puts @collection.aggregate.map.with_index(1) { |test, i| \"#{i}. #{test}\" }\n end\n end\n\n path_name\n end",
"def format_sar\n %x[ sar -f #{SAR_OUT} > #{SAR_TXT} ]\n end",
"def run\n init\n\n printer = config.flamegraph? ? Printers::Flamegraph : Printers::Simple\n\n at_exit do\n File.write(build_path(), JSON.dump(result)) if config.json?\n printer.dump(result)\n end\n\n start\n end",
"def create\n @rotation = Rotation.new(rotation_params)\n\n respond_to do |format|\n if @rotation.save\n format.html { redirect_to @rotation, notice: 'Rotation was successfully created.' }\n format.json { render :show, status: :created, location: @rotation }\n else\n format.html { render :new }\n format.json { render json: @rotation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def calculate_results\n Repository::Config.new(@repo, @log, @process, @type).status(5) {\n files = files_to_analyze\n puts '-----Files to analyze done (Step 1)'\n files = prepare_files_to_rate files\n puts '-----Prepare files to rate done (Step 2)'\n files = count_total_lines files\n puts '-----Count total lines done (Step 3)'\n files = count_errors files\n puts '-----Count errors done (Step 4)'\n files = grade_categories files\n puts '-----Grade categories done (Step 5)'\n files = grade_files files\n puts '-----Grade files done (Step 6)' + files.to_s\n gpa = grade_repo files\n puts '-----Grade repos done (Step 7)' + gpa.to_s\n gpa_percent = get_overall_grades files\n puts '-----Grade overall percentage done (Step 8)' + gpa_percent.to_s\n cat_issues = get_category_issues files\n puts '-----Get categories issues done (Step 9)' + cat_issues.to_s\n store_cat_issues cat_issues\n puts '-----Store category issues done (Step 10)'\n store_grades gpa, gpa_percent\n puts '-----Store grades done (Step 11)'\n }\n end",
"def run\n _image_files = image_files\n\n specified_camera = @roll.camera\n camera = @config.cameras.find { |camera| camera.tag == specified_camera }\n raise \"Camera #{specified_camera} not found in config.yml\" unless camera\n\n @roll.frames.each_with_index do |frame, i|\n break if i >= _image_files.count\n\n specified_lens = frame.lens || @roll.lens\n lens = camera.lenses.find { |lens| lens.tag == specified_lens }\n raise \"Lens #{specified_lens} not found for frame #{frame.number}\" unless lens\n\n relative_path = _image_files[i].gsub(%r(^#{Dir.pwd}/), \"\")\n puts \"Processing frame #{frame.number}\\n #{relative_path}\" unless @silent\n\n ExifToolImage.new(_image_files[i]).tap do |exif|\n exif[\"Artist\"] = @roll.artist || @config.artist\n exif[\"Copyright\"] = template_copyright(@config, @roll, frame)\n exif[\"DateTimeOriginal\"] = frame.date_captured || @roll.date_captured\n exif[\"CreateDate\"] = frame.date_scanned || @roll.date_scanned\n exif[\"Make\"] = camera.make\n exif[\"Model\"] = camera.model\n exif[\"LensModel\"] = lens.model\n exif[\"ISO\"] = @roll.iso\n exif[\"ExposureTime\"] = frame.shutter || @roll.shutter\n exif[\"FNumber\"] = frame.aperture || @roll.aperture\n exif[\"FocalLength\"] = frame.focal_length || lens.focal_length || @roll.focal_length\n exif[\"Flash\"] = frame.flash ? 1 : 0\n exif[\"Orientation\"] = frame.orientation || 1\n\n exif.save\n end\n end\n end",
"def output\n @rovers.each do |rover|\n puts '%d %d %s' %rover.position if @map.rover_inside_plateu?(rover)\n end\n end",
"def sample_roi\n system(\"3dROIstats -mask_f2short -mask raparc.a2009s+aseg.nii plq20005_Ax-FSPGR-BRAVO_003.nii rASL_plq20005_fmap.nii > stats.txt\")\n end",
"def display_results\n print_header\n print_detailed_report\n write_csv_report\n display_status\n end",
"def run\n puts \"\"\n puts \"Welcome to Mission Control!\"\n mission_loop\n print_session_statistics\n end",
"def auto_rotate\n Jhead.call(\"-autorot\", @match, @pattern)\n end",
"def rotations\n self.to_s.rotations.collect { |s| s.to_i }\n end",
"def run\n # header\n cols = [:title, :candidates, :s30, :s40, :s50, :c_tm, :s_tm, :correct]\n puts cols.join(\"\\t\")\n\n # simhash: 5..9\n @matcher.options[:candidates] = :simhash\n 5.upto(9).each do |i|\n @matcher.options[:simhash_max_hamming] = i\n report(\"simhash #{i}\")\n end\n\n # ngrams: 5..3\n @matcher.options[:candidates] = :ngrams\n 5.downto(3).each do |i|\n @matcher.options[:ngram_overlaps] = i\n report(\"ngrams #{i}\")\n end\n\n # all\n @matcher.options[:candidates] = :all\n report(\"all\")\n end",
"def rotor_array\n @rotor_array\n end",
"def test_rotate\n assert_equal :portrait, @driver.orientation\n\n @@core.wait do\n @driver.rotation = :landscape\n assert_equal :landscape, @driver.orientation\n end\n\n @@core.wait do\n @driver.rotation = :portrait\n assert_equal :portrait, @driver.orientation\n end\n end",
"def analyze\n @analysis = Analysis.new(directory)\n @analysis.scan\n #@analysis.save!\n end",
"def output_results\n if @annotated_paths.any?\n puts(\"Annotated #{@annotated_paths.join(', ')}\")\n @flags.include?(:error_on_annotation) ? 1 : 0\n else\n puts('Nothing to annotate')\n 0\n end\n end",
"def display_results\r\n if @errors.empty?\r\n @out.puts @results\r\n else\r\n @errors.each{ |error| @out.puts error }\r\n end\r\n end",
"def transform\n if rotate\n \"rotate(#{rotate},#{x},#{y})\"\n else\n nil\n end\n end",
"def main\n \n operations.each do |op|\n in_collection = op.input(INPUT).collection\n keep_plt = op.input(KEEP_PLT).val.to_s\n \n # export_filename(collection=in_collection, method='timeseries', timepoint=20) # timepoint is duration of timeseries plate reader\n filename = Item.find(in_collection.id).get('timeseries_filename')\n \n # Directs tech through biotek plate reader software in order to export time series measurements\n export_timeseries_data(filename)\n \n # Find measurements and upload\n show {\n title \"Locating Upload\"\n separator\n note \"The file you just exported should be in the <b>'_UWBIOFAB'</b> directory\"\n note \"It is called: #{filename}\"\n }\n # Show block upload button and retrieval of file uploaded\n up_show, up_sym = upload_show(filename)\n if (up_show[up_sym].nil?)\n show {warning \"No upload found for Plate Reader measurement. Try again!!!\"}\n up_show, up_sym = upload_show(filename)\n else\n upload = find_upload_from_show(up_show, up_sym)\n key = \"#{filename}\"\n associate_to_plans(key, upload)\n associate_to_item(in_collection, key, upload)\n end\n \n (keep_plt == 'No') ? (in_collection.mark_as_deleted) : (in_collection.location = 'Bench')\n in_collection.save\n if (keep_plt == 'No')\n show {\n title \"Cleaning Up...\"\n separator\n note \"Rinse out Plate <b>#{in_collection}</b> with DI H2O and bleach\"\n note \"Then rinse once more with EtOH\"\n }\n else\n show {\n title \"Cleaning Up...\"\n separator\n note \"Move <b>#{in_collection}</b> to <b>#{in_collection.location}</b>\"\n }\n end\n end\n \n end",
"def analyze_data(results_array)\n my_results = MovieTest.new(results_array) #create object of the MovieTest class to analyze data.\n puts \"Mean error = #{my_results.mean_error}\"\n puts \"Stddev = #{my_results.stddev}\"\n puts \"rms error = #{my_results.rms_error}\"\n my_results.to_array\n end",
"def execute\n setup\n begin\n data = main\n rescue ArgumentError => e\n warn e.message\n exit 1\n end\n puts format_data(data)\n end",
"def printInfo(adjacencyMatrix, degreeArray)#print the details of the matrix and its degrees\n\tputs\"M A T R I X :\"\n\tputs adjacencyMatrix.to_a.map(&:inspect) #print out the adjacency matrix *adapted from stack overflow*\n\tputs \"D E G R E E S OF N O D E S :\"\n\tputs degreeArray.inspect #print out all degrees in the array\n\tputs \"\\n\"\nend",
"def get_analyzer_results(analyzer, the_samples)\n output = Array.new\n analyzer_base = analyzer.sub('.py', '')\n puts the_samples\n puts analyzer\n the_samples.each do |sample|\n output << \"results/#{$jobid}/#{$selection}#{$jetcorrection}/iso#{$isolation}/#{analyzer_base}/#{sample}.root\"\n #output << \"results/#{$jobid}/#{analyzer_base}/#{sample}.root\"\n end\n return output\nend",
"def runsims( direction )\n\n $RotationAngle = $angles[direction]\n\n # Save rotation angle for reporting\n $gRotationAngle = $RotationAngle\n\n Dir.chdir( $run_path )\n debug_out (\"\\n Changed path to path: #{Dir.getwd()} for simulation.\\n\")\n\n # Rotate the model, if necessary:\n # Need to determine how to do this in HOT2000. The OnRotate() function in HOT2000 *interface*\n # is not accessible from the CLI version of HOT2000 and hasn't been well tested.\n\n\n # make a back-up copy, in case HOT2000 crashses mid-run and empties the runfille\n\n\n # Command to execute H2k.\n runThis = \"HOT2000.exe -inp ..\\\\#{$h2kFileName}\"\n\n\n\n\n # JB TODO: What does this comment mean? --> AF: Extra counters to count ls tmpval how many times we've tried HOT2000.\n keepTrying = true\n tries = 1\n # This loop actually calls hot2000!\n pid = 0\n\n $runH2KTime = Time.now - Time.now\n\n\n while keepTrying do\n\n startH2Krun = Time.now\n\n $gStatus[\"H2KExecutionAttempts\"] = tries\n\n FileUtils.cp(\"..\\\\#{$h2kFileName}\", \"..\\\\run_file_file_#{tries}.h2k\")\n\n runThis = \"HOT2000.exe -inp ..\\\\run_file_file_#{tries}.h2k\"\n\n begin\n\n pid = Process.spawn( runThis, :new_pgroup => true )\n stream_out (\"\\n Attempt ##{tries}: Invoking HOT2000 (PID #{pid}) ...\")\n runStatus = Timeout::timeout($maxRunTime){\n Process.waitpid(pid, 0)\n }\n status = $?.exitstatus\n rescue Timeout::Error\n\n begin\n Process.kill('KILL', pid)\n rescue\n # do nothing - process may have died on its own?\n end\n\n\n status = -1\n\n sleep(2)\n end\n\n\n endH2Krun = Time.now\n\n $runH2KTime = $runH2KTime + ( endH2Krun - startH2Krun )\n\n stream_out(\" Hot2000 (PID: #{pid}) finished with exit status #{status} \\n\")\n\n if status == -1\n warn_out(\"\\n\\n Attempt ##{tries}: Timeout on H2K call after #{$maxRunTime} seconds.\" )\n keepTrying = true # Successful run - don't try agian\n\n elsif status == 0\n\n\n stream_out( \" The run was successful (#{$runH2KTime.round(2).to_s} seconds)!\\n\" )\n keepTrying = false # Successful run - don't try agian\n\n FileUtils.cp(\"..\\\\run_file_file_#{tries}.h2k\", \"..\\\\#{$h2kFileName}\")\n\n elsif status == 3 || status == nil # Pre-check message(s)\n\n\n warn_out( \" The run completed but had pre-check messages (#{$runH2KTime.round(2).to_s} seconds)!\" )\n keepTrying = false # Successful run - don't try agian\n\n FileUtils.cp(\"..\\\\run_file_file_#{tries}.h2k\", \"..\\\\#{$h2kFileName}\")\n\n #elsif status == nil\n # # Get nil status when can't load an h2k file.\n #\n # fatalerror( \"When spawning H2K, process returned nil return code after #{$runH2KTime.round(2).to_s} seconds; HOT2000 message box or couldn't load file!\\n\" )\n # keepTrying = false # Give up.\n\n end\n\n\n if ( keepTrying && tries < $maxTries ) # Unsuccessful run - try again for up to maxTries\n tries = tries + 1\n keepTrying = true\n\n # if run failed, overwrite the h2k file with the backup. Needed because if H2k times out, or crashes mid-run,\n # the h2k file may be corrupted.\n\n\n # Try to kill the process again to make sure there are no zombies holding write access to h2k files.\n\n elsif ( keepTrying && tries == $maxTries )\n\n warn_out(\"Max number of execution attempts (#{$maxTries}) reached. Giving up.\")\n fatalerror(\"Hot2000 evaluation could not be completed successfully\")\n keepTrying = false # Give up.\n\n end\n\n begin\n Process.kill('KILL', pid)\n sleep(2)\n rescue\n # do nothing - process may have died on its own?\n end\n\n\n\n\n\n end\n\n $gStatus[\"H2KExecutionTime\"] = $runH2KTime\n\n $NumTries = tries\n\n\n\n Dir.chdir( $gMasterPath )\n debug_out (\"\\n Moved to path: #{Dir.getwd()}\\n\")\n\n # Save output files\n $OutputFolder = \"sim-output\"\n if ( ! Dir.exist?($OutputFolder) )\n if ( ! system(\"mkdir #{$OutputFolder}\") )\n fatalerror( \"Could not create #{$OutputFolder} below #{$gMasterPath}! MKDir Return code: #{$?}\\n\" )\n end\n else\n if ( File.exist?(\"#{$OutputFolder}\\\\Browse.rpt\") )\n if ( ! system(\"del #{$OutputFolder}\\\\Browse.rpt\") ) # Delete existing Browse.Rpt\n fatalerror(\"Could not delete existing Browse.rpt file in #{$OutputFolder}! Del Return code: #{$?}\\n\" )\n end\n end\n end\n\n # Copy simulation results to sim-output folder in master (for ERS number)\n # Note that most of the output is contained in the HOT2000 file in XML!\n if ( Dir.exist?(\"sim-output\") )\n stream_out (\"\\n Copying results.\")\n FileUtils.cp(\"#{$run_path}\\\\Browse.rpt\", \".\\\\sim-output\\\\\")\n\n if ( $gReadROutStrTxt )\n if ( File.file?(\"#{$run_path}\\\\ROutStr.txt\") )\n FileUtils.cp(\"#{$run_path}\\\\ROutStr.txt\", \".\\\\sim-output\\\\\")\n debug_out( \"\\n\\n Copied output file Routstr.txt to #{$gMasterPath}\\\\sim-output.\\n\" )\n else\n fatalerror(\"Could not copy Routstr.txt to #{$OutputFolder}! Copy return code: #{$?}\\n\" )\n end\n end\n\n #if ( ! system(\"copy /Y #{$run_path}\\\\Browse.rpt .\\\\sim-output\\\\\") )\n #if ( ! FileUtils.cp(\"#{$run_path}\\\\Browse.rpt\", \".\\\\sim-output\\\\\") )\n # fatalerror(\"\\n Fatal Error! Could not copy Browse.rpt to #{$OutputFolder}!\\n Copy return code: #{$?}\\n\" )\n #else\n # debug_out( \"\\n\\n Copied output file Browse.rpt to #{$gMasterPath}\\\\sim-output.\\n\" )\n #end\n end\n\nend",
"def print_results\r\n @cordinators.each do |c|\r\n print c.klass.to_s.ljust(25, ' ')\r\n c.print_stats\r\n end\r\n end",
"def report\n if (@position_x.is_a? Integer) && (@position_x.is_a? Integer) && (ToyEnums::ALL_DIRECTION.include? @current_rotation)\n puts [@position_x, @position_y, @current_rotation].join(',')\n else\n raise ToyEnums::MSG_ERROR\n end\n end",
"def run_report\n comparison_values.tap do |results|\n display_report(results)\n end\n end",
"def print_usage\n puts \"Usage: ruby gen_k_pivot_algorithm <k> <t1> ... <t_k+1>\"\n exit(1)\nend",
"def perform\n config = ThinkingSphinx::Configuration.instance\n \n output = `#{config.bin_path}#{config.indexer_binary_name} --config #{config.config_file} --rotate #{index}`\n puts output unless ThinkingSphinx.suppress_delta_output?\n \n true\n end",
"def shout\n\t\tputs @x.to_s+\" \"+@y.to_s+\" \"+@orientations.key(@orientation.to_i)+\"\t\"+@status.to_s\n\tend",
"def launch_analysis(t, values)\n\t begin\n\t window(title: \"Running #{t.task}\", width: 750, height: 512) do\n\t background \"#B2E5F4\" .. \"#F1E1F4\"\n\t @job = t.launch_job(values)\n\t stack(margin:30, width:1.0) do\n\t\t subtitle t.task\n\t\t para strong(\"Command:\")\n\t\t edit_box @job.cmd, width:1.0, height:40, state:\"readonly\"\n\t\t para \"\"\n\t\t para strong(\"Start time: \"), @job.start_time.ctime\n\t\t para strong(\"Log: \"), @job.log_path\n\t\t @running = edit_box \"\", state:\"readonly\",\n\t\t\t\t\t width:1.0, height: 275\n\t\t animate(4) do |frame|\n\t\t unless @running.nil?\n\t\t\t@running.text = @job.log\n\t\t\tif @job.alive?\n\t\t\t @running.text += \"\\n#{@job.status}\"+(\".\"*(frame%4))\n\t\t\telse\n\t\t\t para \"\"\n\t\t\t para strong(\"Running time: \"),@job.running_time,\"s.\"\n\t\t\t @running = nil\n\t\t\tend\n\t\t end\n\t\t end\n\t end\n\t end\n\t rescue => e\n\t Shoes.alert \"#{e}\\n\\n#{e.backtrace.first}\"\n\t end\n end",
"def output\n print_headings\n \n line_order.each do |line_name|\n stats = statistics[line_name]\n \n arr = [line_headings[line_name]] + column_order.collect {|col| stats[col]}\n print_line(arr)\n end\n \n print_separator\n print_summary\n end",
"def run_experiment\n test_fitness\n experiment_status\n while !concluded?\n new_generation\n test_fitness\n experiment_status\n end\n end",
"def testi_display_result\n\t\t\tputs testi_stats\n\t\tend",
"def compute_sphere_rotation_matrix\n # puts \"\\n #{__method__.to_s} enter\"\n # log_sphere_point_when(@sphere_point_when)\n\n # Perp vector is the axis of rotation of the sphere\n # as we roll the arcball from point A to point B\n #\n v_perp = @sphere_point_when[:mouse_down].cross(@sphere_point_when[:mouse_draged])\n\n\n # Just return the identity if we didn't move significantly\n #return Geo3d::Matrix.identity if (v_perp.length < EPSILON)\n\n\n # In the quaternion values,\n # w is cosine (theta / 2), where theta is rotation angle\n #\n v_perp.w = @sphere_point_when[:mouse_down].dot(@sphere_point_when[:mouse_draged])\n\n v_perp.normalize!\n\n # Compute new rotation matrix\n q = Geo3d::Quaternion.new(v_perp.x, v_perp.y, v_perp.z, v_perp.w)\n\n # arc_ball_rotation_matrix\n q.to_matrix\n end",
"def run\n return if $test\n #Run number\n n = 0\n\n IO.popen(RSlave, \"w+\") { |p|\n if @collect\n collectVariants(p)\n elsif @agg\n @topdir = Dir.pwd\n aggregateRuns(p, @topdir)\n else\n raise ArgumentError, \"No vector file specified\", caller[0] if not @agg and ARGV.size < 1\n\n vecFile = ARGV.shift\n singleRun(p, vecFile, n)\n end\n\n p.puts %{q(\"no\")}\n\n }\n\n rescue Errno::EPIPE => err\n $defout.old_puts err\n $defout.old_puts err.backtrace\n $defout.old_puts \"last R command: #{$lastCommand.shift}\"\n end",
"def run_demo(directory)\n # uses graphs passed to driver class when instantiated\n @graphs.each do |graph|\n before = Time.now\n vertex_states = self.send(@algorithm,graph,0)\n after = Time.now\n running_time = after - before\n n = graph.vertices.count\n end_vertex = n - 1\n # reconstructs the path from the processed vertex states\n path = construct_path(vertex_states,end_vertex)\n # get the cost from the last node in the graph\n total_cost = vertex_states[end_vertex].shortest_distance\n # write to file the path and cost\n output_to_file(directory,@algorithm, path, total_cost,end_vertex, running_time)\n end\n end",
"def results\n results = result_maker(RACER_RECORDS)\n total_time = total_time_maker(RACER_RECORDS)\n @view.display_results(results, total_time)\n end",
"def debug_final_report\n\t\t\tsuper\n\t\t\tif @debug_level > 0\n\t puts \"Lowest OLD: \\t#{@lowest_old[0].to_a}\"\n\t puts \"Angle: \\t\\t#{@get_angle.(@current_point, @start_vector)}\"\n\t\t\tend\n\t\tend",
"def angle_debug()\n #@angle = (@angle + 1) % 360 if @eq_id == 0\n if Input.trigger?(Input::NUMBERS[1])\n @sox += 1\n puts @sox\n elsif Input.trigger?(Input::NUMBERS[2])\n @sox -= 1\n puts @sox\n elsif Input.trigger?(Input::NUMBERS[3])\n @soy += 1\n puts @soy\n elsif Input.trigger?(Input::NUMBERS[4])\n @soy -= 1\n puts @soy\n elsif Input.trigger?(Input::NUMBERS[5])\n @sox = 0\n puts @sox\n elsif Input.trigger?(Input::NUMBERS[6])\n @soy = 0\n puts @soy\n end if @parent.is_a?(Game_Player) if @eq_id == 0\n end",
"def run\n\t\t\tsummary\n\t\tend",
"def report_simulations_run(simulations)\n simulations.each do |sim|\n puts\n puts sim.class.to_s\n #puts sim.variant_description\n puts sim.options.inspect\n puts \"total_clicks: #{sim.total_clicks}\"\n puts \"actual sum: #{sim.actual_sum}\"\n puts \"estimated sum: #{sim.estimated_sum}\"\n puts \"absolute deviation: #{sim.absolute_deviation}\"\n puts \"fraction deviation: #{sim.fraction_deviation}\"\n end\nend",
"def display(results, options={})\n results.keys.sort.each do |file|\n puts \"#{file}:\"\n results[file].each do |note|\n puts \" * #{note.to_s(options)}\"\n end\n puts\n end\n end",
"def run_it\n run_through_directory\n file_array_parser\n remove_initial_and_format_change\n array_to_hash\n final_name_info\n create_goal_file\nend",
"def compression\n \n ##Preparing directory structure for \"project\" area to display html\n system(\"mkdir -p #{@outputDir}/htmlPages/#{@studyName1}/QIIME/#{@jobName1}\")\n system(\"cp -r #{@outputDir}/QIIME_result/plots #{@outputDir}/htmlPages/#{@studyName1}/QIIME/#{@jobName1}\")\n \n Dir.chdir(\"#{@outputDir}/QIIME_result\")\n #system(\"tar -zcf #{@sampleSetName1}.tar.gz * --exclude=*.log --exclude=*.sra --exclude=*.sff --exclude=*.local.metadata\")\n system(\"tar czf raw.results.tar.gz * --exclude=filtered_aln --exclude=taxa --exclude=aln --exclude=plots\")\n system(\"tar czf phylogenetic.result.tar.gz filtered_aln\")\n system(\"tar czf taxanomy.result.tar.gz taxa\")\n system(\"tar czf fasta.result.tar.gz aln\")\n system(\"tar czf plots.result.tar.gz plots\")\n \n Dir.chdir(@scratch)\n \n end",
"def printProbe\n puts \"Your origin was (#{@x},#{@y},#{@z})\"\n puts \"Traveled #{@traveled_distance}\"\n puts \"Visited #{@visited_stars}\"\n puts \"Explored #{@explored_planets}\"\n puts \"Remaining fuel #{@fuel}\"\n end",
"def main\r\n operations.make\r\n \r\n intro\r\n \r\n # Prepares tubes, buffers, and other equiptment to extract RNA either mechanical/enzymaticall and takes into account the RNA kit used(RNeasy/miRNeasy)\r\n rna_extraction_prepartion(INPUT, OUTPUT, METHOD, CELL_LYSIS)\r\n \r\n # Fresh overnights/cells need to be quenched and pelleted before extraction\r\n over_ops = operations.select { |op| op.input(INPUT).object_type.name == 'Yeast Overnight Suspension'}\r\n (!over_ops.empty?) ? quenching(over_ops, INPUT) : nil\r\n \r\n # Assumption is that samples that are not overnights will be in the -80 freezer - this gathers the remaining samples that will be processed in this experiment\r\n remaining_ops = operations.select { |op| op.input(INPUT).object_type.name != 'Yeast Overnight Suspension'}\r\n \r\n # Retrieves the remaining operations that are NOT overnights\r\n (!remaining_ops.empty?) ? show {warning \"<b> If you are gathering your samples from the freezer, keep them on ice from this step until noted.</b>\"} : nil\r\n (!remaining_ops.empty?) ? (take remaining_ops.map {|op| op.input(INPUT).item}, interactive: true): nil\r\n \r\n # Groups operations by cell lysing method and processes them by method\r\n group_by_lysis = operations.map.group_by {|op| op.input(CELL_LYSIS).val}.sort\r\n group_by_lysis.each {|lys_arr| cell_lysis(lys_arr) }\r\n \r\n # Return chemicals back to appropriate storage\r\n clean_fumehood\r\n \r\n # Directs tech to use Qiagen kits - Once cell have been processed to lysates \r\n qiagen_kit\r\n \r\n delete_input_items \r\n \r\n nanodrop_rna_extracts(INPUT, OUTPUT)\r\n \r\n delete_input_items\r\n \r\n operations.store\r\n return {}\r\n end",
"def output_results\n puts(output_copy)\n exit_code = 0\n exit_code = 1 if @changed_files.any? && @flags.include?(:error_on_annotation)\n exit_code\n end",
"def run\n puts \"Rubyist #{@rubyist.id} starting in #{@current_location.name}.\"\n (1..@turns).each { |current_turn| prospect_location(current_turn) }\n # Print Results of run\n finished\n end",
"def run_pasv_cli\n exit_status = nil\n # We need an outdir. The PASV CLI creates this dir so we can't create a tmpdir. Best we can do is try to give it a unique name.\n #\n # %24N yoctosecond (24 digits)\n date_fmt = \"%Y_%m_%d_%H_%M_%S_%L_%24N\"\n\n outdir = nil\n # Keep looping until you get a dirname that doesn't currently exist.\n loop do\n time = Time.new.strftime date_fmt\n token = SecureRandom.hex(64)\n\n # The chances of making a duplicate here from some other thread or OS operation should be LOW\n outdir = File.join Dir.tmpdir, \"#{token}_#{time}\"\n\n break unless Dir.exist? outdir\n end\n\n\n\n # First we need to write the files to some Tempfile\n # fsync\n\n\n # defaults\n\n if self.aligner == \"clustalo\"\n aln_params = '\\--threads 1'\n io_format_str = '\\-i %s \\-o %s'\n elsif self.aligner == \"mafft\"\n aln_params = '\\--thread 1 \\--quiet'\n io_format_str = '%s > %s'\n end\n\n p [aln_params, io_format_str]\n\n Tempfile.open do |ref_f|\n self.ref_file.download do |data|\n ref_f.puts data\n end\n\n # Ensure the data is actually written to file now.\n ref_f.fsync\n\n Tempfile.open do |query_f|\n self.query_file.download do |data|\n query_f.puts data\n end\n\n query_f.fsync\n\n # And now we build the PASV command while the tempfiles are still in scope.\n cmd = \"ruby #{PasvsHelper::PASV_EXE} --refs #{ref_f.path} --queries #{query_f.path} --aligner #{self.aligner} --alignment-parameters '#{aln_params}' --io-format-string '#{io_format_str}' --start #{self.roi_start} --end #{self.roi_end} --threads #{PasvsHelper::THREADS} --outdir #{outdir} --min-count #{PasvsHelper::MIN_COUNT} 500 501\"\n\n puts \"Command will be: #{cmd}\"\n\n PasvsHelper::RyaTime.time_it cmd, Rya::AbortIf.logger do\n exit_status = PasvsHelper::RyaProcess.run_it cmd\n end\n end\n end\n\n # If the exit_status is zero, we need to zip up the tmp folder and give it as a download.\n puts exit_status\n\n if exit_status.success?\n outdir\n end\n end"
] |
[
"0.6004163",
"0.5732051",
"0.5711006",
"0.5667199",
"0.55585",
"0.5506489",
"0.5484848",
"0.53235203",
"0.5312208",
"0.52817506",
"0.5261955",
"0.52441883",
"0.52290374",
"0.5205131",
"0.51918006",
"0.51675093",
"0.51662785",
"0.51654243",
"0.51544803",
"0.5140026",
"0.5140026",
"0.5135415",
"0.512743",
"0.5090884",
"0.5052154",
"0.5033929",
"0.5027841",
"0.50258964",
"0.49958023",
"0.49910107",
"0.498836",
"0.4981905",
"0.49506748",
"0.4927267",
"0.49242204",
"0.49223635",
"0.490918",
"0.49077424",
"0.48988757",
"0.48916128",
"0.4886113",
"0.48799583",
"0.4879958",
"0.48606095",
"0.4852812",
"0.48514682",
"0.48500025",
"0.48414126",
"0.48361984",
"0.48202989",
"0.48197442",
"0.47954863",
"0.47952747",
"0.47898218",
"0.4782082",
"0.47774336",
"0.4774655",
"0.47727498",
"0.4770397",
"0.47610527",
"0.4759214",
"0.47465935",
"0.4740305",
"0.47390956",
"0.47348562",
"0.4731273",
"0.47288486",
"0.4722407",
"0.47175488",
"0.47114378",
"0.47093502",
"0.47089538",
"0.4707928",
"0.47070518",
"0.47044393",
"0.46932584",
"0.46931985",
"0.4684273",
"0.46810478",
"0.46809602",
"0.467622",
"0.46761277",
"0.46756542",
"0.4674308",
"0.46719208",
"0.46559015",
"0.46548852",
"0.46488672",
"0.4645209",
"0.4644554",
"0.46422404",
"0.46416724",
"0.463795",
"0.46295857",
"0.4628221",
"0.46249992",
"0.46190554",
"0.46177587",
"0.46143582",
"0.46142238"
] |
0.85818535
|
0
|
Initialize the environment before the analysis is run
|
def initialize_run
@summary_totals.clear
@rotation_count = 0
# Compute total number of rotation permutations for the run.
# number_of_columns^(number_of_groups - 1)
@maximum_rotations = @groups[0][0].length ** @max_group_index
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize_environment\n end",
"def initialize_environment\n end",
"def setup_environment; end",
"def initialize env\n @env = env\n super()\n end",
"def initialize env\n @env = env\n super()\n end",
"def setup\n # noop\n end",
"def init!\n @logger = @config = @database_config = nil\n\n load_application_config\n load_database_config\n note \"Loading #{env} environment (#{Ajaila::VERSION})\"\n load_classes\n note \"Establishing database connection\"\n establish_database_connection\n note \"Running auto-upgrade migrations\"\n run_auto_upgrade_migrations\n note \"Application has been initialized\"\n self\n end",
"def check_and_set_environment\n check_env\n set_env\n end",
"def init_globals\n $process_vars = ThreadSafeHash::ThreadSafeHashMonitored.new(Params['enable_monitoring'])\n $tmp_content_data_file = nil # will be init during execution\n $testing_memory_active = false\n $testing_memory_log = nil\n $indexed_file_count = 0\n $local_content_data = nil\n $local_content_data_lock = nil\n $remote_content_data_lock = nil\n $remote_content_data = nil\n $last_content_data_id = nil\n end",
"def environment; end",
"def pre_run_initialize\n @evaluator = @evaluator_class.new(self) if @evaluator.nil?\n @evolver = @evolver_class.new(self) if @evolver.nil?\n end",
"def initialize_env(named_params)\n _init_attrs(named_params.fetch(:imf))\n @source_path = named_params.fetch(:data)\n im_path = _initialize_ingest_manifest(named_params)\n _initialize_collection_manifest(im_path: im_path, named_params: named_params)\n _initialize_config(ingest_manifest_path: im_path, named_params: named_params)\n end",
"def env=(environment); end",
"def env=(environment); end",
"def initialize\n # Create temporary data directory\n create_data_dir\n\n # Init connection to ADS\n init_ads\n\n # Initialize Data science toolkit\n init_dstk\n\n # Init connection to SQLite\n # init_sqlite3\n end",
"def setup\n @executor = NagiosHerald::Executor.new\n @options = {}\n @options[:env] = File.join(File.dirname(__FILE__), '..', 'env_files', 'check_disk.CRITICAL_ICINGA')\n end",
"def class_init\n @environments_by_name = {}\n @environments = []\n end",
"def initialize\n @environment = ENV['RACK_ENV'] || ENV['RAILS_ENV']\n @environments = []\n @required_variables = []\n @optional_variables = []\n @slack_webhook_url = nil\n @slack_notifier = nil\n @logger = Logger.new(STDERR)\n end",
"def pre_initialize\n end",
"def initialize\n envConfigFile = \"#{$ROOT}/../config/envConfig.yml\"\n @envConfig = loadYAMLFile(envConfigFile)\n stepsFile = \"#{$ROOT}/../config/steps.csv\"\n @steps = loadCSVFile(stepsFile)\n pageObjectsFile = \"#{$ROOT}/../config/pageObjects.csv\"\n @pageObjects = loadCSVFile(pageObjectsFile)\n @reportFolder = generatedReportFolder\n @isProcess = true\n @skipCurrentStep = false\n @report = []\n end",
"def initialize(env)\n @env = env\n end",
"def initialize(env)\n @env = env\n end",
"def before_setup\n # do nothing by default\n end",
"def setup\n\t\n # create an instance of the measure\n @measure = VentilationQAQC.new\n \n #create an instance of the runner\n @runner = OpenStudio::Ruleset::OSRunner.new\t\n\t\n # get arguments \n @arguments = @measure.arguments()\n\n # make argument map\n make_argument_map\n\t\n # Make an empty model\n @model = OpenStudio::Model::Model.new\n\t@runner.setLastOpenStudioModel(@model)\n\t\n\t# Create a fake sql file - our measure will crash if @runner has no sql file set.\n\t# We don't get data from this file because we get data from our patched SqlFile class instead (see above)\n\tsqlFile = OpenStudio::SqlFile.new(OpenStudio::Path.new(sqlPath))\n\t@runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sqlPath))\n\t\n\t$serieses[\"Zone Mechanical Ventilation Mass Flow Rate|ZONE1\"] = OpenStudio::TimeSeries.new(OpenStudio::Date.new, OpenStudio::Time.new(1.0), (0..364).to_a.to_vector, \"m^3/s\")\n end",
"def initialize(*args)\n @env = args.first\n end",
"def init_env type:\n # puts \" initializing env\" if debug\n # print \"(newenv) \" #if debug\n AtariWrapper.new gym.make(type), downsample: compr.downsample,\n skip_type: skip_type, preproc: preproc\n end",
"def initialize()\n begin\n puts \"Eis::Runner::init called\" if $DEBUG\n @loaded_modules = []\n generate_module_list()\n handle = InputHandler.new()\n set_environment()\n rescue ArgumentError =>e\n puts \"\\e[31mERROR\\e[0m: No config file given...\" + e\n puts \"--------------------------------------------\"\n raise\n end\n end",
"def on_startup\n sentiment_corpus = File.read('corpuses/training/training.msqrd')\n @sentiment = Marshal.load sentiment_corpus\n log \"Loaded training data 📚\"\n log 'Ready to start diagnosing patients!'\n log \" 🏥 The Doctor is in! 🏥 \"\n @threshold = 0.15\n @value = 0\n end",
"def at_init\n\n\t\tend",
"def init_env\n @resource_descriptions = HashWithIndifferentAccess.new { |h, version| h[version] = {} }\n @controller_to_resource_id = {}\n @param_groups = {}\n\n # what versions does the controller belong in (specified by resource_description)?\n @controller_versions = Hash.new { |h, controller| h[controller] = [] }\n end",
"def static_env=(_arg0); end",
"def static_env=(_arg0); end",
"def static_env=(_arg0); end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def initialize(env)\n @environment = env\n set_default_options\n end",
"def post_init\n end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def env; end",
"def setup()\n end",
"def environment\n @environment ||= nil\n end",
"def post_setup\n end",
"def pre_initialize; end",
"def load_environment!\n raise NotImplementedError\n end",
"def setup_context\n self['console'] = Console.new\n load RUNTIME_PATH\n\n opal = self['opal']\n opal['loader'] = Loader.new opal, self\n opal['fs'] = FileSystem.new opal, self\n opal['platform']['engine'] = 'opal-gem'\n\n # eval \"opal.require('core');\", \"(opal)\"\n require_file 'core'\n end",
"def setup\n\t\tend",
"def setup\n\t\tend",
"def app_init!(rails_env)\n if rails_env.development? || rails_env.demo?\n # If we are running a rake command like `rake db:seed` or\n # `rake db:schema:load`, we do not want to try and seed the fakes\n # because our schema may not be loaded yet and it will fail!\n if running_rake_command?\n load!\n else\n load_fakes_and_seed!\n end\n end\n end",
"def do_initialize\n begin\n Puppet.initialize_settings\n Puppet[:parser] = 'future' # this is required in order to work with puppet 3.8\n Puppet[:trusted_node_data] = true\n rescue ArgumentError => e\n\n rescue Puppet::DevError => e\n # do nothing otherwise calling init twice raises an error\n end\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def init\n end",
"def init\n end",
"def init\n end",
"def setup\n # suppress ActiveRecord logging\n ActiveRecord::Base.logger.level = Logger::WARN\n\n @importer_run = ImporterRun.new\n @transformer = Transformer.new(context: context, transformations: transformations, options: transformation_options)\n @thread_pool = ETL::ThreadPool.new(options.pool)\n @data_scrubber = ETL::DataScrubber.new(options.destination_model)\n invoke_callback(:before_run)\n end",
"def initialize(env={})\n @env = env\n end",
"def run_init_script; end",
"def init\n self['env'] ||= 'development'\n\n n = (self['port'] || 3000).to_i\n assert n >= 0 && n <= 65535\n self['port'] = n\n\n n = (self['workers'] || self['worker'] || ((CpuCounter.count + 1)/ 2)).to_i\n assert n > 0 && n < 1000\n self['workers'] = n\n\n unless self['root']\n set :root, Dir.pwd\n end\n self['root'] = File.realpath File.expand_path self['root']\n\n # todo warn paths not under project?\n self['views'] = project_path(self['views'] || 'views')\n if self['public']\n self['public'] = project_path(self['public'])\n end\n\n if self['assets']\n self['assets'] = project_path(self['assets'])\n end\n\n self.logger = create_logger\n\n assert !self['before_fork'] || self['before_fork'].respond_to?('call')\n assert !self['after_fork'] || self['after_fork'].respond_to?('call')\n\n self['timeout'] ||= 120\n timeout = self['timeout'].to_i\n assert timeout > 0 && timeout < 2**30\n self['timeout'] = timeout\n Ext.set_inactive_timeout timeout\n end",
"def initialize_environment(args, options, config)\n raise Errors::CLIMissingEnvironment.new if !config[:env]\n @env = config[:env]\n @env.ui = UI::Shell.new(@env, shell) if !@env.ui.is_a?(UI::Shell)\n end",
"def setup\n\t\t# Do nothing\n\tend",
"def setup\n\t\t# Do nothing\n\tend",
"def initialize(environment)\n @environment = environment\n @found = false\n @force_parse = false\n\n @additional_modules = []\n end",
"def setup\n print_status \"Collecting local exploits for #{session.session_type}...\"\n # Initializes an array\n @local_exploits = []\n # Collects exploits into an array\n framework.exploits.each do |name, _obj|\n mod = framework.exploits.create name\n next unless mod\n set_module_options mod\n next unless is_module_wanted? mod\n @local_exploits << mod\n end\n end",
"def initvars\n @provider_instances = []\n @needs_flush = false\n @failed = false\n end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end"
] |
[
"0.81184566",
"0.81184566",
"0.7133543",
"0.6778874",
"0.6778874",
"0.6455739",
"0.63816494",
"0.6365875",
"0.6364734",
"0.6351953",
"0.6346537",
"0.63257307",
"0.6317991",
"0.6317991",
"0.63162154",
"0.63154835",
"0.63026214",
"0.62400603",
"0.6180285",
"0.6179776",
"0.61613435",
"0.61613435",
"0.6158328",
"0.6122429",
"0.6104377",
"0.6087228",
"0.60818124",
"0.60749954",
"0.60574853",
"0.6052276",
"0.6051072",
"0.6051072",
"0.6051072",
"0.6040185",
"0.6040185",
"0.60365516",
"0.6025449",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6014826",
"0.6011719",
"0.6006654",
"0.5998421",
"0.5998222",
"0.59937465",
"0.59923506",
"0.5992094",
"0.5992094",
"0.59844595",
"0.59788734",
"0.5969587",
"0.5969587",
"0.5969587",
"0.5969587",
"0.5969587",
"0.5960051",
"0.5960051",
"0.5960051",
"0.5945266",
"0.59336275",
"0.5931522",
"0.5924409",
"0.5923082",
"0.5920129",
"0.5920129",
"0.5916938",
"0.5909104",
"0.5906002",
"0.5905957",
"0.5905957",
"0.5905957",
"0.5905957",
"0.5905957",
"0.5905957",
"0.5905957",
"0.5905957",
"0.5905957",
"0.5905957",
"0.5905957",
"0.5905957",
"0.5905957",
"0.5905957"
] |
0.0
|
-1
|
A recursive routine that rotates a group of voices in the horizontal matrix. If it is at depth, performs the final vertical analysis for the current rotations; otherwise, just calls itself to process the next group in the hierarchy.
|
def rotate_group( level = -1 )
level += 1
if level == 0 # First group always remains static
rotate_group(level) # Recursive call to process next group of rows
else
# Rotate each pitch to the right for each row in this group. If its the last group then analyze the verticals
# in each column across all groups; otherwise recursively call to process next group of rows.
0.upto(@max_column_index) do
@groups[level].each { |row| row.rotate!(-1) }
level == @max_group_index ? analyze_sonorities : rotate_group(level)
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def run_rotation_analysis\n initialize_run\n rotate_group\n print_summary\n end",
"def spiral_access(arrays, &block)\n # checks if arrays has no sub-arrays\n if arrays.empty?\n return\n end\n\n# top row\n first_set = arrays[0]\n first_set.each do |x|\n block.call x\n end\n #removes the first array (top row)\n arrays.shift\n\n if arrays.empty?\n return\n end\n\n# right column\n second_set = arrays.transpose.last\n second_set.each do |x|\n block.call x\n end\n # removes the end values of each array (right column)\n arrays.map(&:pop)\n\n if arrays.empty?\n return\n end\n\n# bottom row\n third_set = arrays[-1].reverse\n third_set.each do |x|\n block.call x\n end\n # removes the last array (bottom row)\n arrays.pop\n\n if arrays.empty?\n return\n end\n\n# left column\n fourth_set = arrays.transpose.first.reverse\n fourth_set.each do |x|\n block.call x\n end\n # removes the first values of the arrays (left column)\n arrays.map(&:shift)\n\n # recursive step\n spiral_access(arrays, &block)\n\n\nend",
"def rotate_by(angle, axis)\n\t\t# rotate only if cuboid is rotatable\n\t\t# determine the new dimensions for the cuboid from the old position and the given angle and axis of rotation\n\t\t# To achieve this, hold the index corresponding to the given 'axis' fixed and swap the other two idices. This is because there will be no change in dimensions in the axis of rotation. The other two indices are swapped beacuse they are perpendicular to each other and the angle of rotation is 90 degrees per rotation. The direction of rotation will be determined by the sign of the angle, where I take positive angles to be clockwise and negative angles to be counter-clockwise\n\t\tnum_of_rotations = angle.abs / 90 # determine how many roations to make\n\n\t\twhile num_of_rotations > 0 \n\t\t\tpivot = angle <= 0 ? (-1) : 1 # determine the sign from the angle. The pivot will either roatate towards the origin (0,0,0) or away from it\n\t\t\tif axis == 0\n\t\t\t\t@curr_origin = [curr_origin[0], curr_origin[1], curr_origin[2] + dimensions[2] * pivot]\n\t\t\t\t@dimensions = [dimensions[0], dimensions[2], dimensions[1]]\n\t\t\telsif axis == 1\n\t\t\t\t@curr_origin = [curr_origin[0] + dimensions[0] * pivot, curr_origin[1], curr_origin[2]]\n\t\t\t\t@dimensions = [dimensions[2], dimensions[1], dimensions[0]]\t\n\t\t\telse \n\t\t\t\t@curr_origin = [curr_origin[0], curr_origin[1] + dimensions[1] * pivot, curr_origin[2]]\n\t\t\t\t@dimensions = [dimensions[0], dimensions[1], dimensions[2]]\n\t\t\tend\n\n\t\t\tnum_of_rotations -= 1 # ignore angles smaller than 90 and round down thsoe greater than 90 to the nearest multiple of 90.\n\t\tend\n\n\t\t[@curr_origin, @dimensions] # return the curr_origin and dimensions to confirm rotation was successful\n\tend",
"def _rotate_face(v,face)\n ents = Sketchup.active_model.entities\n l = []\n limit = 0\n if face == 1\n limit = @outter_limit\n else\n limit = @inner_limit\n end\n index = 0\n while index < v.length\n if v[index] != 0;break;end\n index=index +1\n end\n ents.each{|g| \n if face == 1\n if g.bounds.center.to_a[index] > limit;l.insert(-1,g)\n end\n else\n if g.bounds.center.to_a[index] < limit;l.insert(-1,g)\n end\n end\n }\n group = ents.add_group l\n _rotate(group,group.bounds.center,v)\n end",
"def apply_rotation\n if @rotation_block != nil\n (1..@rotation.modulo(@rotation_cycle)).each do |i|\n @blocks.each do |block|\n old_x = block.x\n old_y = block.y\n block.x = @rotation_block.x + (@rotation_block.y - old_y)\n block.y = @rotation_block.y - (@rotation_block.x - old_x)\n end\n end\n end\n end",
"def rotate_image(arr)\n last_index = arr.size - 1\n\n # i will essentially act as our layer\n i = 0\n while i < (arr.size / 2)\n \n # column index, j, which should always start at the same index as the layer\n # to avoid moving outer-layer elements\n j = i\n\n # this makes sure j never iterates over the last element in the layer, because\n # it will have already been rotated from the first rotation in that layer\n # NOTE: this mistake can best be shown in a 5x5 or larger, if we forgot this\n layer_offset = last_index - i\n\n while j < (layer_offset) # last_index = arr[i].size - 1 because the array is square\n # debugger\n\n # store the value in the top row\n stored = arr[i][j]\n\n # rotate left to top\n arr[i][j] = arr[last_index - j][i]\n\n # rotate bottom to left\n arr[last_index - j][i] = arr[layer_offset][last_index - j]\n\n # rotate right to bottom\n arr[layer_offset][last_index - j] = arr[j][layer_offset]\n\n # rotate top to right by replacing right with stored\n arr[j][layer_offset] = stored\n\n j += 1\n end\n \n i += 1\n end\n\n # The submission code shouldn't include this, this is just to visualize the result\n p \"#{arr.size}x#{arr.size} Rotated Matrix\"\n arr.each do |row|\n p row\n end\nend",
"def spiral_access(arr, &block)\n #count how many rows = e.g. length of first\n if arr.length > 1\n rows = arr.length - 1\n columns = arr[0].length - 1\n #puts rows, columns\n #count how many columns, e.g. in the first array\n #create a placeholder\n var_arr = []\n #first go across the top\n var_arr= arr[0]\n var_arr.each {|nr| block.call(nr)}\n # then take the last element in each array\n (1..(columns-1)).each do |x|\n var_arr = arr[x]\n block.call(var_arr.delete_at(columns))\n end\n #then go reverse along the last array\n var_arr = arr.delete_at(-1).reverse\n var_arr.each {|nr| block.call(nr)}\n #puts var_arr.join(' ')\n #then take the first elements up till n2\n (columns-1).downto(1) do |x|\n var_arr = arr[x]\n #puts var_arr.join(' ')\n block.call(var_arr.delete_at(0))\n end\n arr.delete_at(0)\n #puts arr.join(' ')\n spiral_access(arr,&block)\n elsif arr.length == 1\n arr[0].any? ? block.call(arr[0][0]) : arr[0]\n else\n arr\n\n end\n\n #then call it again for the rest\nend",
"def rotate(matrix, degrees)\n rotations = degrees / 90 % 4\n return matrix if rotations == 0\n new_matrix = rotate90(matrix)\n count = 1\n while count < rotations\n new_matrix = rotate90(new_matrix)\n count += 1\n end\n new_matrix\nend",
"def rotate_matrix matrix\n\tlayer = 0\n\tfor layer in 0..(matrix.size / 2).ceil\n\t\tlast = matrix.size - 1 - layer\n\t\tfor i in layer..last-1 # not sure here \n\t\t\toffset = i - layer\n\t\t\ttop = matrix[layer][i]\n\n\t\t\tmatrix[layer][i] = matrix[last - offset ][layer] #7 4\n\n\t\t\tmatrix[last - offset][layer] = matrix[ last ][ last - offset ] #9 8\n\n\t\t\tmatrix[ last ][ last - offset] = matrix[ i ][last ] #3 6\n\n\t\t\t#top -> right\n\t\t\tputs i\n\t\t\tputs last\n\t\t\tmatrix[ i ][ last] = top\n\t\tend\n\tend\n\nend",
"def rotate matrix \n min = 0;\n max = matrix.length-1\n\n while min < max and max >= matrix.length/2\n dif = 0\n while min + dif < max\n t1 = matrix[min][min+dif]\n t2 = matrix[min+dif][max]\n t3 = matrix[max][max-dif]\n t4 = matrix[max-dif][min]\n \n matrix[min][min+dif] = t4\n matrix[min+dif][max] = t1\n matrix[max][max-dif] = t2\n matrix[max-dif][min] = t3\n\n dif += 1\n end\n min += 1\n max -= 1\n end\n matrix\nend",
"def rotate_array(array,k,type=\"right\")\n puts \"Input array is\"\n p array\n reverse_array(array, 0, array.size-1)\n if type == \"right\"\n reverse_array(array,0,k-1)\n reverse_array(array,k,array.size-1)\n else\n reverse_array(array,0,k)\n reverse_array(array,k+1,array.size-1)\n end\n puts \"#{type} rotated array is\"\n p array\nend",
"def spiral_access(arrays, iteration=0, &block)\n y_max = arrays.length - 1\n x_max = arrays.first.length - 1\n\n # base step\n return if y_max/2 < iteration || x_max/2 < iteration\n\n # top row\n # 1st Pass: 0.upto(4) do\n iteration.upto x_max-iteration do |x|\n # 1st Pass(1): arrays[0][0]\n # 1st Pass(2): arrays[0][1]\n # 1st Pass(3): arrays[0][2]\n # 1st Pass(4): arrays[0][3]\n # 1st Pass(5): arrays[0][4]\n block.call arrays[iteration][x]\n end\n\n # right column\n # 1st Pass: 1.upto(4) do\n (iteration + 1).upto y_max-iteration do |y|\n # 1st Pass(1): arrays[1][4]\n # 1st Pass(1): arrays[2][4]\n # 1st Pass(1): arrays[3][4]\n # 1st Pass(1): arrays[4][4]\n block.call arrays[y][x_max-iteration]\n end\n\n # bottom row\n # 1st Pass: 3.downto(0) do\n (x_max - 1 - iteration).downto iteration do |x|\n # 1st Pass(1): arrays[4][3]\n # 1st Pass(1): arrays[4][2]\n # 1st Pass(1): arrays[4][1]\n # 1st Pass(1): arrays[4][0]\n block.call arrays[y_max-iteration][x]\n end\n\n # left column\n # 1st Pass: 3.downto(1) do\n (y_max - 1 - iteration).downto iteration+1 do |y|\n # 1st Pass(1): arrays[3][0]\n # 1st Pass(1): arrays[2][0]\n # 1st Pass(1): arrays[1][0]\n block.call arrays[y][iteration]\n end\n\n # recursive step\n # 1st Pass: spiral_access arrays, 1\n spiral_access arrays, iteration+1, &block\n end",
"def rotate_matrix(len, mtx)\n (0..(len / 2)).each do |layer|\n first = layer\n last = len - 1 - layer\n (first..last - 1).each do |i|\n top = mtx[first][i]\n mtx[first][i] = mtx[last - i][first] # TOP <-- LEFT\n mtx[last - i][first] = mtx[last][last - i] # LEFT <-- BOTTOM\n mtx[last][last - i] = mtx[i][last] # BOTTOM <-- RIGHT\n mtx[i][last] = top\n end\n end\n mtx\nend",
"def analyze_sonorities\n sonority_to_test = Set.new # A work space for slicing\n result_counts = [] # Success counters of columns\n\n # Loop on columns in the matrix and extract out the sonority. Compare that to the dictionary of vertical sets to\n # compute a score for each column.\n\n @groups[0][0].each_index do |column_id| # Loop on number of number of columns\n result_counts[column_id] = 0 # Initialize counter for column\n sonority_to_test.clear\n\n # Slice through the voices of all groups and their rows to create a sonority to test.\n @groups.each_index do |group_id|\n @groups[group_id].each_index { |row_id| sonority_to_test.add( @groups[group_id][row_id][column_id] ) }\n end\n\n # Search the dictionary of vertical sets we are looking for and increment column counter if found.\n @search_sets.each { |set_to_search| result_counts[column_id] += 1 if set_to_search.subset?(sonority_to_test) }\n end\n\n # Accumulate a cross total of column result to create a final score for the current rotation snapshot.\n score = result_counts.inject(0) { |sum, col_result| sum += col_result }\n\n # If we meet the search criteria then add results to report totals and optionally print details.\n if @minimax_score.include?(score)\n accumulate_summary_totals(score)\n\n # Optionally print details of this rotation snapshot.\n print_details(result_counts, score) if @report_details\n end\n\n print_rotation_count unless @report_details # run progress meter if in summary mode\n\n end",
"def rotate_matrix(array)\n\n\nend",
"def rotate_matrix(arr)\n\nend",
"def rotate!(direction)\n return if stopped?\n can_rotate = nil\n new_blocks = nil\n game.hypothetical do\n hypothetical_rotated_tetromino = hypothetical_tetromino\n new_blocks = hypothetical_rotated_tetromino.rotate_blocks(direction)\n can_rotate = !hypothetical_rotated_tetromino.stopped? && !hypothetical_rotated_tetromino.right_blocked? && !hypothetical_rotated_tetromino.left_blocked?\n end\n if can_rotate\n remove_from_playfield\n self.orientation = ORIENTATIONS[ORIENTATIONS.rotate(direction == :right ? -1 : 1).index(@orientation)]\n self.blocks = new_blocks\n update_playfield(@row, @column)\n end\n rescue => e\n puts e.full_message\n end",
"def zrotation\n end",
"def rotate(matrix, degrees)\n case degrees\n when 90\n rotate90(matrix)\n when 180\n rotate90(rotate90(matrix))\n when 270\n rotate90(rotate90(rotate90(matrix)))\n when 360\n rotate90(rotate90(rotate90(rotate90(matrix))))\n else\n p \"You passed #{degrees}, I can only handle 90, 180, 270 and 360\"\n end\nend",
"def setup_rotation\n return TSBS.error(@acts[0], 3, @used_sequence) if @acts.size < 4\n @angle = @acts[1]\n change_angle(@acts[2], @acts[3])\n end",
"def spiral_access(arrs, iteration = 0, &block)\n maxY = arrs.length - 1\n maxX = arrs.first.length - 1\n \n return if maxY/2 < iteration || maxX/2 < iteration\n \n # top row\n iteration.upto maxX-iteration do |x|\n block.call arrs[iteration][x]\n end\n\n # right column\n (iteration + 1).upto maxY-iteration do |y|\n block.call arrs[y][maxX-iteration]\n end\n\n # bottom row\n (maxX - 1 - iteration).downto iteration do |x|\n block.call arrays[maxY-iteration][x]\n end\n\n # left column\n (maxY - 1 - iteration).downto iteration+1 do |y|\n block.call arrays[y][iteration]\n end\n\n spiral_access arrs, iteration+1, &block\n \nend",
"def rec_build(level, direction, rotation, fractal_list)\r\n # At the lowest level, add an actual piece to the array\r\n if (level == 0)\r\n fractal_list.push((direction + rotation) % 360)\r\n return\r\n end\r\n \r\n # At higher levels, we need to define the shape of the fractal\r\n for piece_direction in @base_fractal\r\n rec_build(\r\n level - 1, # Drill down to the next level\r\n piece_direction, # Take direction from the base array\r\n (direction + rotation) % 360, # Rotate lower-level according to higher level structure\r\n fractal_list) # Append to the list\r\n end\r\n end",
"def rotate matrix, direction\n direction == 'clockwise' ? matrix.reverse.transpose : matrix.transpose.reverse\nend",
"def rotate(matrix, direction)\n if direction == \"clockwise\"\n matrix.transpose.map{|i| i.reverse}\n else\n rotated = []\n matrix.transpose.map{|i| i.reverse}.flatten.reverse.each_slice(matrix.size){\n |a| rotated << a}\n rotated\n end\nend",
"def redesign\n reset_mat\n recur_divide(0, 0, m, n, cut_dir(c, r))\n end",
"def spiral_access(arrays, loop = 0, &block)\n\n\tx_limit = arrays[0].length - 1 # number of elements in each nested array\n\ty_limit = arrays.length - 1 # number of arrays in array\n\n\treturn if y_limit/2 < loop || x_limit/2 < loop # this means your at the end of the spiral\n\n\tloop.upto (x_limit - loop) do |x| # for the top row, left to right\n\t\tblock.call arrays[loop][x]\n\tend\n\n\t(loop + 1).upto (y_limit - loop) do |y| # for the right hand side top to bottom\n\t\tblock.call arrays[y][x_limit - loop]\n\tend\n\n\t(x_limit - 1 - loop).downto loop do |x| # for the bottom row right to left\n\t\tblock.call arrays[y_limit - loop][x]\n\tend\n\n\t(y_limit - 1 - loop).downto (loop + 1) do |y| # for the left hand side bottom up\n\t\tblock.call arrays[y][loop]\n\tend\n\n\tspiral_access(arrays, loop + 1, &block) # recursion to go down the spiral\n\nend",
"def RotateMatrix (squareImg)\n r = squareImg.size - 1\n c = squareImg[0].size - 1\n\n (0..r/2).each do |row|\n (0..c/2).each do |col|\n\nsquareImg[row][col], squareImg[r - row][col], squareImg[r-row][c-col], squareImg[row][c-col] = squareImg[r - row][col], squareImg[r-row][c-col], squareImg[row][c-col], squareImg[row][col]\n\n\n end\n end\nsquareImg\nend",
"def rotate(arr)\n\nend",
"def step!\n if rotors[1].notches.include? positions[1] #if middle rotor at a notch\n positions[2] = (positions[2] + 1) % 26 #step leftmost rotor\n end\n if ((rotors[1].notches.include? positions[1]) || #if middle rotor at a notch OR\n ( rotors[0].notches.include? positions[0])) #if rightmost rotor at a notch\n positions[1] = (positions[1] + 1) % 26 #step middle rotor\n end\n positions[0] = (positions[0] + 1) % 26 #always step rightmost rotor\n end",
"def rotate(axis = :x, walls = [])\n\n # check to see if there are already impedements\n walls.each do |wall|\n return false if self.intersects?(wall)\n end\n\n case axis\n when :x\n if !walls.empty?\n dist = Math.sqrt((@h/2) ** 2 + (@w/2) ** 2)\n temp = Cuboid.new(@origin, @l, dist, dist)\n\n walls.each do |wall|\n return false if temp.intersects?(wall)\n end\n end\n\n rotate_x\n\n when :y\n if !walls.empty?\n dist = Math.sqrt((@l/2) ** 2 + (@w/2) ** 2)\n temp = Cuboid.new(@origin, dist, @h, dist)\n\n walls.each do |wall|\n return false if temp.intersects?(wall)\n end\n end\n\n rotate_y\n\n when :z\n if !walls.empty?\n dist = Math.sqrt((@h/2) ** 2 + (@l/2) ** 2)\n temp = Cuboid.new(@origin, dist, dist, @w)\n\n walls.each do |wall|\n return false if temp.intersects?(wall)\n end\n end\n\n rotate_z\n else\n raise ArgumentError, \"Please use a symbol to identify the axis: :x, :y, or :z\"\n end\n\n self.vertices\n end",
"def rot90(k=1,axes=[0,1])\n case k % 4\n when 0\n view\n when 1\n swapaxes(*axes).reverse(axes[0])\n when 2\n reverse(*axes)\n when 3\n swapaxes(*axes).reverse(axes[1])\n end\n end",
"def spiral_access array, &block\n\nn = array[0].size - 1\ni = 0\n\nuntil n<i\narray[i][i..n].each{|num| block.call num}\n(i+1).upto(n){|num| block.call array[num][n]}\narray[n].reverse[i+1..n].each{|num| block.call num}\n(i+1).upto(n-1){|num| block.call array.reverse[num][i]}\n\ni +=1\nn-= 1\nend\nend",
"def my_rotate(arr)\n print arr.rotate\n end",
"def traverse_spiral(matrix)\n l = 0\n r = matrix[0].length - 1\n b = matrix.length - 1\n t = 0\n dir = 0\n\n # loop until top bound equals bottom bounds and left bounds equals right\n while (t <= b && l <= r)\n\n if dir == 0\n (l..r).each{ |left_index| puts matrix[t][left_index] }\n t += 1\n end\n\n if dir == 1\n (t..b).each{ |top_col_ind| puts matrix[top_col_ind][r] }\n r -= 1\n end\n\n if dir == 2\n (r).downto(l) { |right_index| puts matrix[b][right_index] }\n b -= 1\n end\n\n if dir == 3\n (b).downto(t) { |bot_col_index| puts matrix[bot_col_index][l] }\n l += 1\n end\n\n dir = (dir + 1) % 4\n end\nend",
"def rotate_origo(angle_x = 0, angle_y = 0, angle_z = 0)\n\t\t@rect.each do |a|\n\t\t\ta.each do |b|\n\t\t\t\tx = b[0]; y = b[1]; z = b[2]\n\n\t\t\t\tx, y, z = rotate_point(x, y, z, 0, 0, 0, angle_x, angle_y, angle_z)\n\n\t\t\t\tb[0] = x; b[1] = y; b[2] = z\n\t\t\tend\n\t\tend\n\tend",
"def rotate3(num)\n length = num.inspect.length\n max_rotate = rotate2(num, length)\n loop do \n length -= 1\n max_rotate = rotate2(max_rotate, length)\n break if length == 0\n end\n max_rotate\nend",
"def wrap_step(row, col, dir)\n drow, dcol = Step::DELTA[dir]\n puts \"WS #{row}, #{col}, #{drow}, #{dcol}\" if $sus\n\n # row face, col face\n # row offset, col offset\n rowf, rowo = row.divmod(esize)\n colf, colo = col.divmod(esize)\n\n # where we'd go in the planar map...\n nrow = row + drow\n ncol = col + dcol\n # ... and what face it would mean\n nrowf = nrow / esize\n ncolf = ncol / esize\n\n # simple case: staying on the same face\n return [@dir, [nrow, ncol]] if nrowf == rowf && ncolf == colf\n\n # now nrow nrowf are invalid\n puts \"cube wrap #{[row, col]} -> #{[nrow, ncol]} from face #{[rowf, colf]} dir #{Step::FACES[dir]}\"\n\n transitions = case esize\n when 50\n TRANSITIONS_INPUT\n when 4\n TRANSITIONS_SAMPLE\n else\n raise \"Now you have to hardcode another cube, good luck\"\n end\n face_transition = transitions[rowf][colf]\n raise \"Bug: no transition defined here\" if face_transition == NOFACE\n\n ft_idx = [:r, :d, :l, :u][dir]\n big_transition = face_transition[ft_idx]\n\n nrowf = rowf + big_transition.face_row_delta\n ncolf = colf + big_transition.face_col_delta\n\n transition = big_transition.transition\n te = TransitionEvaluator.new(rowo, colo, esize)\n nrowo, ncolo = te.eval(transition)\n\n ndir = (dir + transition.dir_change) % 4\n nrow = nrowf * esize + nrowo\n ncol = ncolf * esize + ncolo\n\n ret = [ndir, [nrow, ncol]]\n puts \"cube wrap step returning #{ret.inspect}\"\n ret\n end",
"def rotate(edge, direction)\n edges = get_edges\n current_direction = edges[edge]\n return false if direction == current_direction\n puts \"rotate #{id} so that #{edge} is #{direction} - at the moment #{edge} is showing #{current_direction}\"\n ROTATIONS[direction][current_direction].split(',').each { |cmd| self.send(cmd) }\n edges = get_edges\n current_direction = edges[edge]\n puts \"..rotated #{id} so that #{edge} is now showing #{current_direction}\"\n raise \"WRONG ROTATION\" if direction != current_direction\n return true\n end",
"def my_rotate(rotation = 1)\n # debugger\n answer = []\n each_with_index { |x, i| answer[i] = x }\n if rotation > 0\n rotation.times { answer.push(answer.shift) }\n elsif rotation == 0\n answer\n else\n rotation.abs.times { answer.unshift(answer.pop) }\n end\n answer\n end",
"def rotateWithRightChild(k1)\n # puts \"Checking the data for rotateWithRightChild #{k1.data}\"\n k2 = k1.right\n k1.right = k2.left\n k2.left = k1\n return k2\n end",
"def rotate\n g = Grid.new\n self.each do |point,v|\n g[Point.new(point.y,point.x)] = v\n end\n (0..g.height - 1).each do |y|\n ( 0..g.width/2.ceil - 1 ).each do |x|\n tmp = g[Point.new(x,y)]\n g[Point.new(x,y)] = g[Point.new(g.width - x - 1, y )]\n g[Point.new(g.width - x - 1,y)] = tmp\n end\n end\n g\n end",
"def esxlRecurse i, j\n esxlStraightRecurse(i, j) + esxlDiagonalRecurse(i, j)\nend",
"def recurse_result_set(result, options = {}, &block)\n return result unless block_given? \n inner_recursion = options.delete(:inner_recursion)\n result_set = inner_recursion ? result : result.dup\n \n parent_id = (options.delete(:parent_id) || result_set.first[result_set.first.parent_col_name]) rescue nil\n options[:level] ||= 0\n options[:nested] = true unless options.key?(:nested)\n \n siblings = options[:nested] ? result_set.select { |s| s.parent_id == parent_id } : result_set \n siblings.sort! {|a,b| a.send(options[:sort_on]) <=> b.send(options[:sort_on])} if options[:sort_on]\n siblings.each do |sibling|\n result_set.delete(sibling) \n block.call(sibling, options[:level])\n opts = { :parent_id => sibling.id, :level => options[:level] + 1, :inner_recursion => true, :sort_on => options[:sort_on]} \n recurse_result_set(result_set, opts, &block) if options[:nested]\n end\n result_set.each { |orphan| block.call(orphan, options[:level]) } unless inner_recursion\n end",
"def rotate!( *args )\n super( *args )\n reset_positions_inside\n end",
"def rotate\n\t\t# Compute the rotation using matrix transposition\n\t\tnew_points = rotate_points(@active_piece[:points])\n\n\t\t# Update active piece (if required, i.e. no collision detected)\n\t\t@active_piece[:points] = new_points unless collision?(new_points)\t\t\n\tend",
"def spiral_access(array2d, &block)\n\n if array2d.length * array2d[0].length == 0 then return end\n\n i = 0\n\n x = 0\n x_dir = 1\n\n y = 0\n y_dir = 0\n\n t = 0\n while true do\n\n if t == (array2d.length * array2d[0].length) then break end\n\n block.call array2d[y][x]\n\n if x_dir > 0 then\n x += 1\n if x >= array2d.length - i then\n\n x = array2d.length - i - 1\n y += 1\n\n x_dir = 0\n y_dir = 1\n end\n\n elsif x_dir < 0 then\n x -= 1\n if x < i then\n x = i\n y -= 1\n\n x_dir = 0\n y_dir = -1\n end\n\n elsif y_dir > 0 then\n y += 1\n if y >= array2d[0].length - i then\n\n y = array2d[0].length - i - 1\n x -= 1\n\n x_dir = -1\n y_dir = 0\n end\n\n elsif y_dir < 0 then\n y -= 1\n if y <= i then\n\n i += 1\n\n y = i\n x += 1\n\n x_dir = 1\n y_dir = 0\n end\n end\n\n t += 1\n \n end\nend",
"def rotate(turn)\n face_value = (FACE_DIRECTIONS[@face] + TURN_DIRECTIONS[turn]) % FACE_DIRECTIONS.length\n if face_value == 0\n @face = FACE_DIRECTIONS.key(4)\n else\n @face = FACE_DIRECTIONS.key(face_value)\n end\n report\n end",
"def group_slides(song)\n ordered = song[:order].dup\n skipped = []\n skipped.push(ordered.shift) while ordered.any? && ordered.first =~ /(title|blank) slide/\n unvisited = []\n unvisited.unshift(ordered.pop) while ordered.any? && ordered.last =~ /(title|blank) slide/\n\n infos = Hash.new { |h,k| h[k] = {:pre => Set.new, :post => Set.new} }\n ordered.each_cons(2) do |a,b|\n infos[a][:post] << b\n infos[b][:pre] << a\n end\n infos[ordered.first][:pre] << :first\n infos[ordered.last][:post] << :last\n\n groups = {}\n group_members = {}\n new_order = []\n ordered.each do |name|\n if group_name = group_members[name]\n if groups[group_name].first == name\n #puts \"REPEAT #{group_name} (#{name})\"\n new_order << group_name\n end\n else\n group_name = name\n new_order << group_name\n group = groups[group_name] = [name]\n group_members[name] = group_name\n cur = infos[name]\n #puts \"NEW GROUP #{name} #{cur}\"\n while cur && cur[:post].size == 1\n nxt_name = cur[:post].first\n nxt = infos[nxt_name]\n if nxt && nxt[:pre].size == 1 && !group.include?(nxt_name)\n #puts \" ... #{nxt_name} #{nxt}\"\n group << nxt_name\n group_members[nxt_name] = group_name\n cur = nxt\n else\n cur = nil\n end\n end\n end\n end\n [\"title slide\", \"blank slide\"].each do |n|\n if groups[n] && groups[n].size == 1\n groups.delete n\n end\n end\n\n new_parts = {}\n groups.each do |group_name, orig_part_names|\n new_parts[group_name] = orig_part_names.inject([]) { |a, name|\n slide = song[:parts][name]\n if slide.nil?\n if name == \"blank slide\"\n slide = [\"\"]\n else\n slide = [\"MISSING:#{name}\"]\n end\n end\n a + slide\n }\n end\n\n (song[:parts].keys - group_members.keys).each do |name|\n new_parts[name] = song[:parts][name]\n end\n\n {\n :parts => new_parts,\n :order => skipped + new_order + unvisited,\n :keywords => song[:keywords],\n }\nend",
"def rot #@\n a = pop\n b = pop\n c = pop\n push a\n push c\n push b\n end",
"def rotate(direction)\n #possible states\n orientations = [\"N\",\"E\",\"S\",\"W\"]\n currentOrientation = orientations.index(@name)\n case direction\n when \"l\"\n newOrientation = (currentOrientation - 1)%4\n set(orientations[newOrientation])\n when \"r\"\n newOrientation = (currentOrientation + 1)%4\n set(orientations[newOrientation])\n else\n # TODO: Exception\n end\n\n end",
"def spiral_rearrange1 array\n\t#rearrange 2d array of arrays square into a single spiral order arranged array. \n\tif array.flatten.length == 1\n\t\tresult = []\n\t\treturn result << array.flatten[0]\n\tend\n\n\tordered_array = []\n\tn = array.length - 1\n\tx = 0; y = 0\n while true\n\twhile true\n\t\tif array[x][y] != []\n\t\t\tordered_array << array[x][y]\n\t\t\tarray[x][y] = []\n\t\telse\n\t\t\tbreak\n\t\tend\t\n\t\tif y < n && array[x][y+1] != []\n\t\t\ty += 1\n\t\tend\n\tend\n\n\tx += 1\n\t\n\twhile true\n\t\tif array[x][y] != []\n\t\t\tordered_array << array[x][y]\n\t\t\tarray[x][y] = []\n\t\telse\n\t\t\tbreak\n\t\tend\n\t\tif x < n && array[x+1][y] != []\n\t\t\tx += 1\n\t\tend\n\tend\n\n\ty -= 1\n\n\twhile true\n\t\tif array[x][y] != []\n\t\t\tordered_array << array[x][y]\n\t\t\tarray[x][y] = []\n\t\telse\n\t\t\tbreak\n\t\tend\n\t\tif y > 0 && array[x][y-1] != []\n\t\t\ty -= 1\n\t\tend\t\n\tend\n\n\tx -= 1\n\n\twhile true\n\t\tif array[x][y] != []\n\t\t\tordered_array << array[x][y]\n\t\t\tarray[x][y] = []\n\t\telse\n\t\t\tbreak\n\t\tend\n\t\tif x > 0 && array[x-1][y] != []\n\t\t\tx -= 1\n\t\tend\t\n\tend\n\n\ty += 1\n\n\tif array[x][y] == []\n\t\tbreak\n\tend \n end\n\n\treturn ordered_array\nend",
"def rotate(board, val)\n @angles.rotate!(val)\n if (0...height).any? { |y| (0...width).any? { |x| pt = (Point.new(x, y) + @position); pt.x >= board.width || pt.y >= board.height || board[pt.y][pt.x].is_a?(Block) } }\n @angles.rotate!(val * -1)\n end\n self\n end",
"def turtle_trail dir spaces\n if dir == '0'\n world [x] [y+1] = m\n turtle_trail (dir spaces-1) ##trying to make this recursive\n end\n elsif dir == 90\n world [x+1] [y] = m\n turtle_trail (dir spaces-1)\n end",
"def rotate(matrix, start_row, start_col, end_row, end_col, rotations)\n edge = []\n\n # top\n edge.concat start_col.upto(end_col - 1).collect { |c| matrix[start_row][c] }\n # right\n edge.concat start_row.upto(end_row - 1).collect { |r| matrix[r][end_col] }\n # bottom\n edge.concat end_col.downto(start_col + 1).collect { |c| matrix[end_row][c] }\n # left\n edge.concat end_row.downto(start_row + 1).collect { |r| matrix[r][start_col] }\n\n rotated = edge[rotations..-1] + edge[0, rotations]\n\n # top\n i = 0\n start_col.upto(end_col - 1) do |c|\n matrix[start_row][c] = rotated[i]\n i += 1\n end\n\n # right\n start_row.upto(end_row - 1) do |r|\n matrix[r][end_col] = rotated[i]\n i += 1\n end\n\n # bottom\n end_col.downto(start_col + 1) do |c|\n matrix[end_row][c] = rotated[i]\n i += 1\n end\n\n # left\n end_row.downto(start_row + 1) do |r|\n matrix[r][start_col] = rotated[i]\n i += 1\n end\n\n matrix\nend",
"def rotate_counter_clockwise\n @view = VIEWS[view]\n end",
"def visit(visitor, result=Array.new, level=0)\n # {{{\n if visitor.match(self) then\n result += self\n \n my_children_groups = User_Group_Hierarchy.select { |g|\n g.where(g['node_id__parent'] == attr['user_group_id'])\n }\n \n my_children_groups.each { |g|\n g.visit(visitor, result, level+1)\n }\n return result\n \n end\n return nil\n end",
"def find_rotation_point(words, begin_idx = 0, end_idx = words.length - 1, i = 0)\n if words[begin_idx..end_idx].length == 2\n puts \"I found a winner\"\n puts \"#{words[begin_idx]} is the pivoting word\"\n return \"which occurs at index #{begin_idx}\"\n end\n\n pivot = (end_idx - begin_idx) / 2\n pivot += 1 if begin_idx == 0 && end_idx == words.length - 1\n\n if words[pivot][i].ord < words[end_idx][i].ord #switch is before\n return find_rotation_point(words, begin_idx, pivot, i)\n elsif words[pivot][i].ord > words[end_idx][i].ord\n return find_rotation_point(words, pivot + begin_idx, end_idx, i)\n elsif i == words[pivot].length\n return pivot\n else\n return find_rotation_point(words, begin_idx, end_idx, i + 1)\n end\nend",
"def rotate90(original_matrix)\n num_rows = original_matrix[0].length\n num_columns = original_matrix.length\n new_matrix = []\n\n (0..(num_rows - 1)).each do |row|\n inner_array = []\n (num_columns - 1).downto(0).each do |column|\n inner_array.push(original_matrix[column][row])\n end\n new_matrix.push(inner_array)\n end\n new_matrix\nend",
"def spiral(rows, cols)\n # check for and handle wonky inputs\n if !rows.is_a?(Integer) || rows <= -1\n puts \"Whoops: Input rows = #{rows} is invalid; rows must be an integer >= 0.\"\n return\n elsif !cols.is_a?(Integer) || cols <= -1\n puts \"Whoops: Input cols = #{cols} is invalid; cols must be an integer >= 0.\"\n return\n end\n\n # prepare rows & columns in array of arrays\n res = Array.new(rows) { Array.new(cols) }\n level = 0 # count of cycles\n num = 1\n\n until num > (rows * cols)\n # top going right\n level.upto(cols-level-1) do |i|\n res[level][i] = num\n num += 1\n end\n break if num > (rows * cols)\n\n # right going down\n (level+1).upto(rows-level-1) do |i|\n res[i][cols-level-1] = num\n num += 1\n end\n break if num > (rows * cols)\n\n # bottom going left\n (cols-level-2).downto(level) do |i|\n res[rows-level-1][i] = num\n num += 1\n end\n break if num > (rows * cols)\n\n # left going up\n (rows-level-2).downto(level+1) do |i|\n res[i][level] = num\n num += 1\n end\n level += 1 # level completed\n end\n\n # print as matrix\n res.each {|sub_arr| print sub_arr, \"\\n\"}\nend",
"def rotate!\n @num_rotations = (@num_rotations+1) % NUM_SIDES\n end",
"def rotate90(matrix)\n size = matrix.first.size\n matrix.each_with_object(Array.new(size) {[]}) do |arr, new_arr|\n arr.each_with_index do |el, idx|\n new_arr[idx].unshift el\n end\n end\nend",
"def rotate( rotate_count = 1 )\n \n load_parent_state\n \n return super\n \n end",
"def spiral_access(array, &block)\n unless array.length == 0 || array[0].length == 0\n array[0].length.times { final_array << array[0].shift }\n array.delete_at(0)\n array.length.times { |i| final_array << (array[i].pop)}\n array.last.length.times { final_array << (array.last.pop)} unless array.last.nil?\n array.delete_at(array.length-1)\n count = array.length -1\n while count >= 0\n final_array << (array[count].shift)\n count -= 1\n end\n two_d(array, &block) unless array.length == 0\n end\n final_array.delete(nil)\n final_array.each { |x| block.call x }\nend",
"def update_angle( angle, node, match, angle_deg, current_word ) # TODO add param 'word', passed in from tree.hist_control.current_word\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# word is presently nil class and is causing major errors\n\t\t# set new_rotation_char (+,-) based on sign\n\t\t@literal = \"+\"\n\t\t\n\t\t@pos1 = node.str_pos\n\t\t@pos2 = match.str_pos\n\t\t# switch positions to make sure that pos1 < pos2 always, so there's a valid range later\n\t\tif @pos2 < @pos1\n\t\t\t@pos3 = @pos1\n\t\t\t@pos1 = @pos2\n\t\t\t@pos2 = @pos3\n\t\tend\n\t\t\n\t\tif @pos1 == @pos2\n\t\t\tputs \"WordController#update_angle: Well, we're fucked. How are these positions equal?\"\n\t\tend\n\t\t\n\t\t#now that @pos1 is definitely the smallest, step forward from there until you hit the first bracket\n\t\t@next_bracket = \"\"\n\t\t@pos = @pos1\n\t\t#puts \"WordController#update_angle: before while\"\n\t\twhile @next_bracket == \"\" do\n\t\t\t#puts \"WordController#update_angle: while\"\n\t\t @pos += 1\n\t\t if current_word.word[@pos..@pos] == \"[\" or current_word.word[@pos..@pos] == \"]\"\n\t\t\t\t@next_bracket = @pos\n\t\t end\n\t\t @next_bracket = current_word.word.length-1 if @pos >= current_word.word.length\n\t\t break if @pos > current_word.word.length\n\t\tend\n\t\t#puts \"WordController#update_angle: after while\"\n\t\t\n\t\tif angle > 0\n\t\t\t@literal = \"-\"\n\t\tend\n\t\t\n\t\t@times = (angle/angle_deg).abs.to_i # determines angle based on angle_deg increment\n\t\tputs \"times \" + @times.to_s\n\t\t@rotation_literal_set = \"\"\n\t\t@times.times do\n\t\t#puts \"WordController#update_angle: times.times do rotation literal set\"\n\t\t\t@rotation_literal_set << @literal\n\t\tend\n\t\tif @rotation_literal_set == \"\"\n\t\t\t@rotation_literal_set << @literal\n\t\tend\n\t\t\t\t\n\t\t#puts \"WordController#update_angle: @rotation_literal_set = #{@rotation_literal_set}\"\n\t\t#puts \"WordController#update_angle: @next_bracket = #{@next_bracket}\"\n\t\t#puts \"WordController#update_angle: pos1: \" + @pos1.to_s + \", pos2: \" + @pos2.to_s\n\t\t\n\t\t\n\t\t# replace any +/- with \n\t\t# regex starting at str_pos for a line of rotation literals +,-, more later\n\t\t\t# replace with angle/system_angle.times do @rotation_string << new_rot_char\n\t\t\n\t\t#puts \"WordController#update_angle: word[range]: \" + current_word.word[ @pos1..@next_bracket ].to_s\n\t\tcurrent_word.word[ @pos1..@next_bracket ] = current_word.word[ @pos1..@next_bracket ].gsub( /(\\++|-+)/, @rotation_literal_set )\n\t\tputs \"WordController#update_angle CURRENT WORD: \" + current_word.word.to_s\n\t\treturn current_word\n\tend",
"def rotate_matrix(arr)\n flipped_array = [] # initialize empty array\n transposed_arr = my_transpose(arr) # flip the rows with columns inside using a transpose method\n transposed_arr.each { |row| flipped_array << row.reverse } # once we reverse the new rows, it goes from 45 to 90 degrees rotation\n flipped_array\nend",
"def runAlgorithm(row)\n for column in 0..@width-1\n if @columns[column] >= 0 then\n next\n end\n\n ixDiag1 = row + column\n if @diagonals1[ixDiag1] then\n next\n end\n\n ixDiag2 = @lastRow - row + column\n if @diagonals2[ixDiag2] then\n next\n end\n\n @columns[column] = row\n @diagonals1[ixDiag1] = true\n @diagonals2[ixDiag2] = true\n\n if row == @lastRow then\n @solutions.push(@columns.dup)\n else\n runAlgorithm(row + 1)\n end\n\n @columns[column] = -1\n @diagonals1[ixDiag1] = false\n @diagonals2[ixDiag2] = false\n end\n end",
"def expansionclave(iteracion)\n t_mclave=@m_clave\n aux=Array.new(4){Array.new(4)}\n #operacion del rotword (rotando la ultima columna de la matriz de las claves)\n aux[0][3],aux[1][3],aux[2][3],aux[3][3]=t_mclave[1][3],t_mclave[2][3],t_mclave[3][3],t_mclave[0][3]\n\n #relleno la matriz completa con los demas elementos de la matrz de la clave\n for i in 0...4\n for j in 0...3\n aux[i][j]=t_mclave[i][j]\n end\n end\n #se busca en la sbox los valores de la matriz\n aux[0][3],aux[1][3],aux[2][3],aux[3][3]=get_sbox(aux[0][3].to_i(16)).to_s(16).rjust(2,'0'),get_sbox(aux[1][3].to_i(16)).to_s(16).rjust(2,'0'),get_sbox(aux[2][3].to_i(16)).to_s(16).rjust(2,'0'),get_sbox(aux[3][3].to_i(16)).to_s(16).rjust(2,'0')\n #se realiza la operación de principal de la epansion de claves\n aux[0][0]=(@m_clave[0][0].to_i(16)^aux[0][3].to_i(16)^Rcon[0][iteracion]).to_s(16).rjust(2,'0')\n aux[1][0]=(@m_clave[1][0].to_i(16)^aux[1][3].to_i(16)^Rcon[1][iteracion]).to_s(16).rjust(2,'0')\n aux[2][0]=(@m_clave[2][0].to_i(16)^aux[2][3].to_i(16)^Rcon[2][iteracion]).to_s(16).rjust(2,'0')\n aux[3][0]=(@m_clave[3][0].to_i(16)^aux[3][3].to_i(16)^Rcon[3][iteracion]).to_s(16).rjust(2,'0')\n for i in 0...4\n for j in 1...4\n aux[i][j]=(@m_clave[i][j].to_i(16)^aux[i][j-1].to_i(16)).to_s(16).rjust(2,'0')\n end\n end\n\n @m_clave=aux\n end",
"def Transform3dIsRotateAroundLine(arg0, arg1, arg2, arg3)\n ret = _invoke(1610744073, [arg0, arg1, arg2, arg3], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_R8])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def spiral_order(a)\n return [] if a.empty?\n res = []\n left, top = 0, 0\n bottom, right = a.length - 1, a[0].length - 1\n\n while left <= right && top <= bottom\n for i in (left..right)\n res << a[top][i]\n end\n top += 1\n for i in (top..bottom)\n res << a[i][right]\n end\n right -= 1\n if top <= bottom\n # decreament for loop\n for i in (right).downto(left)\n res << a[bottom][i] \n end\n bottom -= 1\n end\n if left <= right\n for i in (bottom).downto(top)\n res << a[i][left]\n end\n left += 1\n end\n end\n res\nend",
"def spiral_iterator\n m = matrix_clone\n result = []\n actions = {\n right: lambda { m.shift },\n down: lambda { m.map { |row| row.pop }},\n left: lambda { m.pop.reverse },\n up: lambda { m.map { |row| row.shift }},\n }\n command_sequence = actions.keys.cycle\n result += actions[command_sequence.next].call until m.empty?\n result\n end",
"def restructure\n node_id = params[:node_id].to_i\n parent_id = params[:parent_id].to_i\n prev_id = params[:prev_id].to_i\n next_id = params[:next_id].to_i\n\n render :text => \"Do nothing\" and return if parent_id.zero? && prev_id.zero? && next_id.zero?\n\n @realty_category ||= parent.realty_categories.find(node_id)\n\n if prev_id.zero? && next_id.zero?\n @realty_category.move_to_child_of parent.realty_categories.find(parent_id)\n elsif !prev_id.zero?\n @realty_category.move_to_right_of parent.realty_categories.find(prev_id)\n elsif !next_id.zero?\n @realty_category.move_to_left_of parent.realty_categories.find(next_id)\n end\n end",
"def rearrange_recursively(klass, items, parent = nil)\n last = nil\n items.each do |item|\n record = klass.find(item['id'])\n if last\n record.move_to_right_of(last)\n else\n parent ? record.move_to_child_of(parent) : record.move_to_root\n end\n last = record\n if item['children']\n rearrange_recursively klass, item['children'], record\n end\n end\n end",
"def each_block\n 0.upto(3) do |x|\n 0.upto(3) do |y|\n # TODO: Move the bitwise and into #rotation.\n # Not sure now there's a rotate method for each direction.\n c = Tetrominos[@shape][@rotation & 3][y][x]\n yield x, y, c if c == 1\n end\n end\n end",
"def do_chain_layout(sugar) \n seen_chains = []\n sugar.residue_composition.select { |r| ['GlcNAc','Gal'].include?(r.name(:ic)) }.each { |chain_start|\n debug(\"CHAIN:Start residue name is #{chain_start.name(:ic)}\")\n next if seen_chains.include?(chain_start)\n debug(\"CHAIN:Not seen before\")\n child_chains = sugar.get_chains_from_residue(chain_start).sort_by { |chain| chain.size }\n debug(\"CHAIN:In total there are #{child_chains.size} chains from this position\")\n child_chains.each { |child_chain|\n debug(\"CHAIN:A chain size is #{child_chain.size}\")\n next unless child_chain.size > 1\n debug(\"CHAIN: Doing a chain layout\")\n chain_desc = child_chain.collect {|r| r.name(:ic)+\"#{r.anomer},#{r.paired_residue_position}\"}.join(',')\n debug(\"CHAIN:Chain is #{chain_desc}\")\n\n chain_end = child_chain[-1]\n \n child_chain.reject! { |c| seen_chains.include?(c) }\n\n if child_chain.size > 0\n layout_chain(child_chain)\n seen_chains += child_chain\n end\n debug(\"CHAIN:Trying to arrange children for #{chain_end.name(:ic)}\")\n \n layout_chain_terminals(chain_end)\n\n seen_chains += (sugar.residue_composition(chain_end))[1..-1]\n }\n }\n return seen_chains\n # All chains should be starting at 0,0 and be laid out as straight (or shifted up for 6) lines\n end",
"def rotate_robot(command, unit)\n if /#{RIGHT}/.match?(command)\n case unit\n when 1\n $current_direction += 1\n when 2\n $current_direction += 2\n when 3\n $current_direction += 3\n else\n $current_direction += 0\n end\n elsif /#{LEFT}/.match?(command)\n case unit\n when 1\n $current_direction += 3\n when 2\n $current_direction += 2\n when 3\n $current_direction += 1\n else\n $current_direction += 0\n end\n end\n $current_direction %= 4\nend",
"def rotate direction\n # Check if the toy robot has been placed on the table yet\n return unless placed?\n\n # Calculate new direction by finding out the next or previous item on the const array DIRECTIONS\n curr_index = DIRECTIONS.find_index(@direction)\n \n # If the result would be out of bounds, wrap around.. \n\n\n if (direction == 1 and curr_index == 3)\n # if direction = right and the robot's direction is :west\n # we wrap around the array, so new direction = :north\n\n new_index = 0 \n elsif direction == -1 and curr_index == 0\n # if direction = left and the robot's direction is :north\n # we wrap around the array, so new direction = :west\n\n new_index = 3 \n else\n # Calculate new index based on index of the robot's position on the DIRECTIONS array \n # and the direction the robot is turning\n new_index = curr_index + direction\n end\n\n @direction = DIRECTIONS[new_index]\n end",
"def rotate_array(arr)\n rotated_arr = []\n if arr.length > 1\n arr.each_index do |index|\n next if index + 1 >= arr.length\n rotated_arr.push(arr[index + 1])\n end\n end\n rotated_arr.push(arr[0])\n rotated_arr\nend",
"def rotate_matrix(image, direction=:right)\n 0..(image.length / 2 - 1) do |i|\n ((0 + i)..(image.length - 1 - i)).each do |j|\n ij0 = rotate_destination([i, j], direction)\n ij1 = rotate_destination(ij0, direction)\n ij2 = rotate_destination(ij0, direction)\n \n register = image[ij0[0]]][ij0[1]]\n image[ij0[0]][ij0[1]] = image[i][j]\n image[i][j] = image[ij2[0]]][ij2[1]]\n image[ij2[0]][ij3[1]] = image[ij1[0]]][ij1[1]]\n image[ij1[0]][ij1[1]] = register\n end\n end",
"def rotate(direction)\n return unless was_executed_valid_place_command?\n\n orientation_keys = orientation.keys\n orientation_index = orientation_keys.index(@current_orientation) + direction\n @current_orientation = orientation_keys[orientation_index].nil? ? orientation_keys[0] : orientation_keys[orientation_index]\n @table.board[@current_position_x][@current_position_y] = abbreviate(@current_orientation)\n\n print_board\n end",
"def rotate_row(y,num)\n row_cells = @cells.select {|c| c.y == y}\n new_cells = row_cells.map {|c| c.rotate(num,0)}\n @cells.subtract(row_cells)\n @cells.merge(new_cells)\n end",
"def rotate(command)\n turn = directions[@rover_facing]\n @rover_facing = command == 'L' ? turn.first : turn.last\n end",
"def rotate_row(a, b, screen)\n edge = screen[a].pop(b)\n screen[a].unshift(edge)\n screen[a].flatten!\n\n screen\nend",
"def rotate(matrix, degrees)\n rotations = degrees/90\n new_matrix = matrix.dup\n rotations.times do\n new_matrix = rotate90(new_matrix)\n end\n new_matrix\nend",
"def rotate_without_changing(arr)\n\nend",
"def rotations\n s = self\n rots = Array[s]\n (1..s.length-1).each do |i|\n s=s[1..s.length-1]+s[0,1]\n rots << s\n end\n rots\n end",
"def transform line\n i = 1\n tortoise = line[i]\n hare = line[i * 2]\n while tortoise != hare\n i += 1\n tortoise = line[i]\n hare = line[i * 2]\n end\n v = i\n\n mu = 0\n tortoise = line[mu]\n hare = line[v * 2 + mu]\n while tortoise != hare\n mu += 1\n tortoise = line[mu]\n hare = line[v * 2 + mu]\n end\n\n lam = 1\n hare = line[mu + lam]\n while tortoise != hare\n lam += 1\n hare = line[mu + lam]\n end\n #puts \"v mu lam %d %d %d\" % [v, mu, lam]\n \n line[mu, lam] \nend",
"def rotate(direction)\n if !self.on_table # No rotation is possible if the robot has not been placed\n return false\n end\n\n new_orientation = 0\n\n # Turning right or left means a 90 degres rotation\n # Left is a negative rotation\n # Right is a positive rotation\n case direction\n when \"left\"\n new_orientation = self.orientation - 90 \n\n # The rotation is looping in the interval [0 270] with a step of 90 \n if new_orientation < 0\n new_orientation = 270 \n end\n\n when \"right\"\n new_orientation = self.orientation + 90\n\n # The rotation is looping in the interval [0 270] with a step of 90 \n if new_orientation > 270\n new_orientation = 0\n end\n\n else\n return false # If the direction was neither right or left, return false\n end\n\n self.orientation = new_orientation\n end",
"def rotate(left_or_right)\n facing = [\"N\",\"E\",\"S\",\"W\"]\nif left_or_right == \"L\"\n final = facing[facing.index(@direction)-1]\n @direction = final\nelsif left_or_right == \"R\"\n final = facing[(facing.index(@direction)+1) % facing.length]\n @direction = final\n else\n puts \"error\"\n end\nend",
"def my_rotate!(array, amt)\n\nend",
"def rotate(mesh, params = {})\n\traise StandardError, \":mesh is nil or not a TriMesh\" if (mesh.nil? or !(mesh.kind_of? TriMesh))\n\traise StandardError, \":degree is nil or not a Number\" if (params[:degree].nil? or !(params[:degree].is_a? Numeric))\n\traise StandardError, \"Define :axis with :x, :y, :z or as a Line\" if (params[:axis].nil?) or (not (params[:axis].kind_of? Symbol) and not (params[:axis].kind_of? Line))\n\traise StandardError, \":vector is not a Vector3\" if not (params[:vector].kind_of? Vector3 ) and not params[:vector].nil?\n\traise StandardError, \"Define :axis with :x, :y, :z\" if (params[:axis].kind_of? Symbol) and ((params[:axis] != :x) and (params[:axis] != :y) and (params[:axis] != :z))\n\traise StandardError, \"No vector is allowed if Line is defined\" if not (params[:vector].nil?) and (params[:axis].kind_of? Line)\n\n\t#assign Variables\n\tdegree = params[:degree] * Math::PI / 180\n\taxis = params[:axis]\n\t(vec = params[:vector].nil? ? (mesh.center) : params[:vector]) if axis.kind_of? Symbol\n\n\t#Do Rotation\n\t# Math.cos( degree * Math::PI/180 )\n\tif axis.kind_of? Symbol\n\t\tmesh = translate mesh, :vector => (vec * -1)\n\t\tnew_vecs = Array.new\n\t\tif axis == :x \n\t\t\tmesh.vertices.each do | vector |\n\t\t\t\ty = vector.y * Math.cos(degree) - vector.z * Math.sin(degree)\n\t\t\t\tz = vector.y * Math.sin(degree) + vector.z * Math.cos(degree)\n\t\t\t\tnew_vecs << (Vector3.new vector.x, y, z)\n\t\t\tend\n\t\telsif axis == :y \n\t\t\tmesh.vertices.each do | vector |\n\t\t\t\tx = vector.z * Math.sin(degree) + vector.x * Math.cos(degree)\n\t\t\t\tz = vector.z * Math.cos(degree) - vector.x * Math.sin(degree)\n\t\t\t\tnew_vecs << (Vector3.new x, vector.y, z)\n\t\t\tend\n\t\telsif axis == :z \n\t\t\tmesh.vertices.each do | vector |\n\t\t\t\tx = vector.x * Math.cos(degree) - vector.y * Math.sin(degree)\n\t\t\t\ty = vector.x * Math.sin(degree) + vector.y * Math.cos(degree)\n\t\t\t\tnew_vecs << (Vector3.new x, y, vector.z)\n\t\t\tend\n\t\tend\n\t\tmesh = TriMesh.new new_vecs, mesh.tri_indices\n\t\tmesh = translate mesh, :vector => vec\n\telsif axis.kind_of? Line\n\t\tvec = axis.base_point\n\t\tdir = axis.direction - vec\n\t\tx_rot = Vector3.new(0, dir.y, dir.z).angle(dir) / Math::PI / 180\n\t\ty_rot = Vector3.new(dir.x, 0, dir.z).angle(dir) / Math::PI / 180\n\t\tmesh = translate mesh, :vector => (vec * -1)\n\t\tmesh = rotate mesh, :axis => :x, :degree => -x_rot\n\t\tmesh = rotate mesh, :axis => :y, :degree => -y_rot\n\t\tmesh = rotate mesh, :axis => :z, :degree => degree\n\t\tmesh = rotate mesh, :axis => :y, :degree => y_rot\n\t\tmesh = rotate mesh, :axis => :x, :degree => x_rot\n\t\tmesh = translate mesh, :vector => vec\n\tend\n\tmesh\nend",
"def group\n index = 1\n if is_primitive_sentence?\n @left_sentence = Sentence.new(@classified[index].value,@level)\n @operator = @classified[index + 1]\n @right_sentence = Sentence.new(@classified[index + 2].value,@level)\n @left_sentence.father, @right_sentence.father = self, self\n\n elsif is_negated_sentence?\n @operator = @classified[index]\n #Exemplo: (~a) ou (~1)\n if @classified[index+1].instance_of?(Proposition) or @classified[index+1].instance_of?(Constant)\n @right_sentence = Sentence.new(@classified[index+1].value,@level)\n @right_sentence.father = self\n else\n #Exemplo: #(~(a & b)) ou (~(~a))\n index_closed_parenthesis = index_closed_parenthesis(@level+1)\n aux = @classified[index+1..index_closed_parenthesis].map{|el|el.value}*\"\"\n @right_sentence = Sentence.new(aux,@level+1).group\n @right_sentence.father = self\n end\n\n elsif is_left_derivative?\n index_closed_parenthesis = index_closed_parenthesis(@level+1)\n aux = @classified[index..index_closed_parenthesis].map{|el|el.value}*\"\"\n @left_sentence = Sentence.new(aux,@level+1).group\n @operator = @classified[index_closed_parenthesis + 1]\n @right_sentence = Sentence.new(@classified[index_closed_parenthesis + 2].value,@level)\n @left_sentence.father, @right_sentence.father = self, self\n\n elsif is_right_derivative?\n @left_sentence = Sentence.new(@classified[index].value,@level)\n @operator = @classified[index + 1]\n index_closed_parenthesis = index_closed_parenthesis(@level+1,index)\n aux = @classified[(index+2)..index_closed_parenthesis].map{|el|el.value}*\"\"\n @right_sentence = Sentence.new(aux,@level+1).group\n @left_sentence.father, @right_sentence.father = self, self\n\n elsif is_both_derivative?\n index_closed_parenthesis = index_closed_parenthesis(@level+1)\n aux = @classified[index..index_closed_parenthesis].map{|el|el.value}*\"\"\n @left_sentence = Sentence.new(aux,@level+1).group\n @operator = @classified[index_closed_parenthesis + 1]\n index = index_closed_parenthesis + 2\n index_closed_parenthesis = index_closed_parenthesis(@level+1,index)\n aux = @classified[index..index_closed_parenthesis].map{|el|el.value}*\"\"\n @right_sentence = Sentence.new(aux,@level+1).group\n @left_sentence.father, @right_sentence.father = self, self\n end\n self\n end",
"def test_rotate\n assert_equal :portrait, @driver.orientation\n\n @@core.wait do\n @driver.rotation = :landscape\n assert_equal :landscape, @driver.orientation\n end\n\n @@core.wait do\n @driver.rotation = :portrait\n assert_equal :portrait, @driver.orientation\n end\n end",
"def rotate!\n @grid = @grid.transpose.map{|c| c.reverse}\n end",
"def back_substitution(matrix)\n (matrix.length - 1).downto(0) do |pivot_idx|\n # Multiply the current vector position by the pivot_idx inverse (1/pivot_idx)\n inverse = 1 / matrix[pivot_idx][pivot_idx]\n matrix[pivot_idx][-1] *= inverse\n matrix[pivot_idx][pivot_idx] = 1r # We know it will be 1\n puts \"Multiply the #{format_ordinal pivot_idx + 1} row by its diagonal inverse: \"\\\n \"#{inverse.to_s.split('').join(' ')}\"\n\n if (pivot_idx - 1).negative?\n puts 'And we don\\'t have to zero any row'\n else\n puts 'We iterate over the rows above the current pivot index, to zero them'\n print_new_line\n (pivot_idx - 1).downto(0) do |row|\n if !matrix[row][pivot_idx].zero?\n puts \"Cancel R#{row + 1} #{format_ordinal row + 1} coefficient: \" \\\n \"R#{row + 1} <- R#{row + 1} #{matrix[row][pivot_idx] >= 0 ? '-' : '+'} \" \\\n \"( #{matrix[row][pivot_idx].abs.to_s.split('').join(' ')} ) * R#{pivot_idx + 1}\"\n\n matrix[row][-1] -= matrix[row][pivot_idx] * matrix[pivot_idx].last\n matrix[row][pivot_idx] = 0r # We know it will be 0\n else\n puts \"The #{format_ordinal row + 1} coefficient in R#{row + 1} is already zeroed, \" \\\n 'so we follow along'\n end\n end\n end\n\n print_new_line\n puts 'After it, this is the matrix'\n pp_matrix matrix\n print_separator\n end\n\n puts 'And in the reduced row echelon form we have:'\n pp_matrix matrix\n print_separator\n\n matrix\nend",
"def rotate(by = 1)\n return if @current_position.nil?\n index = DIRECTIONS.index(@current_position.dir)\n index = (index + by) % DIRECTIONS.length\n @current_position.dir = DIRECTIONS[index]\n end",
"def rotations pattern, replacement\n return enum_for __method__, pattern, replacement unless block_given?\n\n yield pattern, replacement\n yield pattern.reverse, replacement\n\n pattern_flipped = pattern.map { |row| row.reverse }\n\n yield pattern_flipped, replacement\n yield pattern_flipped.reverse, replacement\n\n pattern_rotate = pattern_flipped.map { |row|\n row.reverse.chars\n }.transpose.map { |row|\n row.reverse.join\n }\n\n yield pattern_rotate, replacement\n yield pattern_rotate.reverse, replacement\n yield pattern_rotate.map { |row| row.reverse }, replacement\n\n pattern_rotate_2 = pattern.map { |row|\n row.chars\n }.transpose.map { |row|\n row.join\n }\n\n yield pattern_rotate_2.reverse, replacement\nend",
"def rotate_array_k_steps(array, k)\n n = array.size\n puts \"Input array is\"\n p array\n shifts = (n.to_f/k).ceil\n # binding.pry\n current = nil\n for i in 0..k-1\n current = array[i] if current.nil?\n nxt = (i+k)%n\n shifts.times do\n temp = array[nxt]\n array[nxt] = current\n current = temp\n nxt = (nxt+k)%n\n end\n end\n puts \"Rotated array is\"\n p array\n p current\nend",
"def mill_spiral(\r\n mill,\r\n cent_x,\r\n cent_y,\r\n inner_diam,\r\n outer_diam,\r\n channel_width,\r\n wall_thick,\r\n depth = nil)\r\n# - - - - - - - - - - - - - - - - - - -\r\n cut_inc = mill.cut_increment\r\n degree_inc = 1.0\r\n min_radius = inner_diam / 2.0\r\n max_radius = outer_diam / 2.0\r\n delta_radius = max_radius - min_radius\r\n \r\n if (depth == nil)\r\n depth = mill.cut_depth\r\n end #if\r\n\r\n # have to allow bit radius on\r\n # both sides of the cutting tool\r\n # for cutting tool compensation\r\n\r\n adjusted_channel_width = channel_width - mill.bit_radius\r\n if adjusted_channel_width < mill.bit_diam\r\n # our channel can not be less than\r\n # one bit thick\r\n adjusted_channel_width = mill.bit_diam\r\n end #if\r\n\r\n channel_start_max_radius = (min_radius + channel_width) - mill.bit_radius\r\n\r\n no_passes = (adjusted_channel_width / cut_inc) + 1.0\r\n usage_per_circle = (channel_width + wall_thick) * 1.05\r\n increase_per_degree = usage_per_circle / 360\r\n\r\n #print \"(mill_spiral no_passes=\", no_passes, \" usage_per_circle = \", usage_per_circle, \" increase per degree=\", increase_per_degree, \" min_radius=\", min_radius, \" max_radius=\", max_radius, \" cut_inc = \", cut_inc,\" tool adjusted channel_width=\", adjusted_channel_width, \")\\n\"\r\n\r\n pass_beg_radius = min_radius + mill.bit_radius\r\n pass_max_radius = (max_radius - channel_width) + mill.bit_radius\r\n\r\n\r\n\r\n passcnt = 0\r\n while (true)\r\n # one pass here for each width\r\n # of the bit we need to make\r\n curr_radius = pass_beg_radius\r\n deg = 0.0\r\n\r\n # Move the head to start of the spiral\r\n mill.retract()\r\n first_point = calc_point_from_angle(cent_x, cent_y, deg, curr_radius)\r\n mill.move(first_point.x, first_point.y)\r\n mill.plung(depth)\r\n\r\n while curr_radius <= pass_max_radius\r\n # mill a single pass of the \r\n # spiral\r\n aPoint = calc_point_from_angle(cent_x, cent_y, deg, curr_radius)\r\n mill.move(aPoint.x, aPoint.y)\r\n curr_radius += increase_per_degree\r\n deg += 1.0\r\n if (deg >= 360)\r\n deg = 0\r\n end #if\r\n\r\n end #while\r\n if (pass_beg_radius >= channel_start_max_radius)\r\n # our last pass was our final\r\n # for the specified channel width\r\n break\r\n elsif (pass_beg_radius + cut_inc) > channel_start_max_radius\r\n # one more cut increment will put us over the\r\n # the max channel width so we adjust the cut_inc\r\n # down so the last pass takes off just enough\r\n cut_inc = channel_start_max_radius - pass_beg_radius\r\n end #if\r\n pass_beg_radius += cut_inc\r\n pass_max_radius += cut_inc\r\n end # for\r\nend",
"def lvlres\n @level = 0\n lvlup\n end",
"def horizontal_dirs\n moves = []\n # Add moves to the left...\n moves += grow_unblocked_moves_in_dir( 0, -1)\n # ...to the right...\n moves += grow_unblocked_moves_in_dir( 0, 1)\n # ...moves up...\n moves += grow_unblocked_moves_in_dir( 1, 0)\n # ...and moves down.\n moves += grow_unblocked_moves_in_dir(-1, 0) \n moves\n end"
] |
[
"0.58914447",
"0.5213453",
"0.5172878",
"0.51578546",
"0.5112639",
"0.51018625",
"0.4927041",
"0.4922093",
"0.48874027",
"0.48260832",
"0.47970814",
"0.47718576",
"0.475144",
"0.46488744",
"0.46468467",
"0.46234345",
"0.45963815",
"0.4594693",
"0.45883408",
"0.4579273",
"0.4543127",
"0.44991976",
"0.44955063",
"0.4491886",
"0.447835",
"0.44622016",
"0.44604063",
"0.44587588",
"0.44346222",
"0.44151643",
"0.44150355",
"0.44136658",
"0.4404908",
"0.43986183",
"0.4398341",
"0.43764487",
"0.4373866",
"0.4369972",
"0.43515807",
"0.43455604",
"0.43385753",
"0.43376333",
"0.43348062",
"0.4322629",
"0.43140286",
"0.4300501",
"0.429317",
"0.42931187",
"0.4287961",
"0.42750806",
"0.42741802",
"0.42674455",
"0.42593324",
"0.42571136",
"0.42474496",
"0.4237654",
"0.42325723",
"0.42291212",
"0.42174113",
"0.4208055",
"0.42072037",
"0.41942286",
"0.41928747",
"0.41790956",
"0.41772866",
"0.4175451",
"0.41715285",
"0.41624278",
"0.41563618",
"0.415061",
"0.415025",
"0.41470745",
"0.41469356",
"0.41428572",
"0.41410178",
"0.41361174",
"0.412851",
"0.41279158",
"0.41265804",
"0.41249877",
"0.4122322",
"0.41201627",
"0.41185436",
"0.4113397",
"0.41132593",
"0.41100398",
"0.4103896",
"0.4099399",
"0.40977564",
"0.40960404",
"0.40845278",
"0.4080551",
"0.40785682",
"0.40781283",
"0.40733323",
"0.40706828",
"0.40637243",
"0.40589607",
"0.40526333",
"0.40506053"
] |
0.73768514
|
0
|
Step through each column in the matrix of rotated rows (voices) and look for patterns of sets from a dictionary to create a score for each column (found) and for the entire matrix of rows (total found).
|
def analyze_sonorities
sonority_to_test = Set.new # A work space for slicing
result_counts = [] # Success counters of columns
# Loop on columns in the matrix and extract out the sonority. Compare that to the dictionary of vertical sets to
# compute a score for each column.
@groups[0][0].each_index do |column_id| # Loop on number of number of columns
result_counts[column_id] = 0 # Initialize counter for column
sonority_to_test.clear
# Slice through the voices of all groups and their rows to create a sonority to test.
@groups.each_index do |group_id|
@groups[group_id].each_index { |row_id| sonority_to_test.add( @groups[group_id][row_id][column_id] ) }
end
# Search the dictionary of vertical sets we are looking for and increment column counter if found.
@search_sets.each { |set_to_search| result_counts[column_id] += 1 if set_to_search.subset?(sonority_to_test) }
end
# Accumulate a cross total of column result to create a final score for the current rotation snapshot.
score = result_counts.inject(0) { |sum, col_result| sum += col_result }
# If we meet the search criteria then add results to report totals and optionally print details.
if @minimax_score.include?(score)
accumulate_summary_totals(score)
# Optionally print details of this rotation snapshot.
print_details(result_counts, score) if @report_details
end
print_rotation_count unless @report_details # run progress meter if in summary mode
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def find_candidates(matrix)\n primary_line = row_index(matrix, @keys.first)\n\n list = []\n\n if column = matrix.column_with(content: primary, line: primary_line)\n list << {\n line: primary_line,\n column: column,\n value: primary\n }\n else\n matrix.row(primary_line).to_a.each_with_index do |column, index|\n if column.empty?\n list << {\n line: primary_line,\n column: index,\n value: primary\n }\n end\n end\n end\n\n list\n end",
"def score_motifs(motifs)\n # motifs is a ruby Matrix\n # To define scoring, consider t DNA sequences, each of length n, and select a k-mer \n # from each sequence to form a collection Motifs, which we represent as a t × k motif matrix.\n # Our goal is to select k-mers resulting in the most “conserved” motif matrix, meaning the matrix with the \n # most upper case letters (and thus the fewest number of lower case letters). Leaving aside the question of\n # how we select such k-mers, we will first focus on how to score the resulting motif matrices,\n # defining Score(Motifs) as the number of unpopular (lower case) letters in the motif matrix Motifs.\n # Our goal is to find a collection of k-mers that minimizes this score.\n\n # Motifs\n # T C G G G G g T T T t t \n # c C G G t G A c T T a C\n # a C G G G G A T T T t C\n # T t G G G G A c T T t t\n # a a G G G G A c T T C C\n # T t G G G G A c T T C C\n # T C G G G G A T T c a t\n # T C G G G G A T T c C t\n # T a G G G G A a c T a C\n # T C G G G t A T a a C C\n\n # Score \n # 3 + 4 + 0 + 0 + 1 + 1 + 1 + 5 + 2 + 3 + 6 + 4 = 30 \n\n # For now lets assume the input 'motifs' contain the upcase and lowercase encoded in it\n # If not we have to implement that in figuring out the score\n score = 0\n\n (0..(motifs.column_count-1)).each do |col_i|\n col_array = motifs.column(col_i)\n dna_freq = { \"A\" => 0, \"C\" => 0, \"G\" => 0, \"T\" => 0}\n col_array.each do |val|\n # score += 1 if val == val.downcase\n dna_freq[val.upcase] += 1\n end\n cnt_arr = dna_freq.values.sort\n count = 0\n cnt_arr.pop\n cnt_arr.each {|val| count += val}\n score += count\n end\n\n return score\n end",
"def match()\n array_rows = @tablero.row_vectors() #Obtiene un array con todas las filas del tablero\n array_cols = @tablero.column_vectors() #Obtiene un array con todas las columnas del tablero\n diagonal1 = []\n diagonal2 = []\n diagonals = []\n #Obtiene la diagonal normal\n (0...@tablero.row_vectors.length).each do |i|\n diagonal1.push(@tablero.component(i, i))\n end\n #Obtiene la diagonal invertida\n (0...@tablero.row_vectors.length).each do |i|\n diagonal2.push(@tablero.component(i, @tablero.row_vectors.length - i - 1))\n end\n diagonals.push(diagonal1, diagonal2) #Los arrays de las diagonales se asignan a otro array\n\n #Se pregunta si existe algun match en filas o columnas o en las diagonales, si si regresa true\n if look_for_a_match(array_rows) || self.look_for_a_match(array_cols) || self.look_for_a_match(diagonals)\n return true\n else\n return false\n end\n end",
"def encontrar\t\n\t\t@fil.to_i.times do |i| \n\t\t\t@col.to_i.times do |j| \t\t\t\t\n\t\t\t\tif yield(mat[i][j]) \n\t\t\t\t\treturn [i,j]\n\t\t\t\tend\t\t\t\t\t\n\t\t\tend\n\t\tend\n\tend",
"def make_matrixes col, row\n\n if row == 1 or col == 1\n return [ # matrixes\n [ # matrix\n Array.new(row, []), # rows\n [] # groups\n ]\n ]\n end\n\n #\n # type make_row_patterns : [[Int]]\n # when col = 3\n # => [[], [0], [1], [2], [0, 2]]\n make_row_patterns = -> {\n patterns = (0...col).to_a.subset(0, (col / 2.0).ceil)\n .select { |nums|\n nums.each_cons(2).none? { |ns| ns[0] + 1 == ns[1] }\n }\n }\n\n #\n # type make_row_patterns_hash : { [Int] => [Int] }\n # when col = 3\n # => {\n # [] => [[], [0], [1], [2], [0, 2]],\n # [0] => [[], [1], [2]],\n # [1] => [[], [0], [2], [0, 2]],\n # [2] => [[], [0], [1]],\n # [0, 2] => [[], [1]]\n # }\n #\n make_row_patterns_hash = -> {\n ps = make_row_patterns.call\n ps.each_with_object({}) { |nums, h|\n h[nums] = ps.select { |ns|\n ns.size + nums.size < col and\n ns - nums == ns\n }\n }\n }\n\n #\n # type patterns : { [Int] => [Int] }\n #\n patterns = make_row_patterns_hash.call\n\n #\n # type matrixes : [matrix]\n # type matrix : [rows, groups]\n # type rows : [row]\n # type row : [Int]\n # type groups : [Group]\n #\n matrixes = patterns.keys.map { |row|\n [[row], row.map { |x| Group.new [Point.make(x, 0)] }]\n }\n\n #\n # loop : apply flat_map\n (1...row).each { |y|\n matrixes = matrixes.flat_map { |matrix|\n rows = matrix.first\n groups = matrix[1]\n patterns[rows.last].map { |pattern|\n #\n # merge pattern with groups\n #\n # what a pain logic!!\n #\n new_groups = []\n catch(:pattern) do\n old_groups = groups.clone\n pattern.lazy.map { |x| Point.make x, y }\n .each { |point|\n\n # new_groups.map.size === 0, 1\n ngs = new_groups.lazy.map { |group|\n [group, group.corner_points(point)]\n }.select { |group_corners|\n group_corners[1].size > 0\n }.map { |g_c|\n\n # if group has (two) corner points,\n # when the group surround.\n if g_c[1].size > 1\n new_groups = nil\n throw :pattern\n end\n\n g_c[0]\n }.to_a\n new_groups = new_groups - ngs\n\n # old_groups.map.size === 0, 1, 2\n ogs = old_groups.lazy.map { |group|\n [group, group.corner_points(point)]\n }.select { |group_corners|\n group_corners[1].size > 0\n }.map { |g_c|\n\n # if group has (two) corner points,\n # when the group surround.\n if g_c[1].size > 1\n new_groups = nil\n throw :pattern\n end\n\n g_c[0]\n }.to_a\n old_groups = old_groups - ogs\n\n # new_group\n new_group = if ngs.empty? and ogs.empty?\n Group.new [point]\n else\n n_g = (ngs + ogs)\n .inject { |g_s, g| g_s.merge g }\n .add(point)\n\n # if group has (two) side points,\n # when the group surround.\n if n_g.side_points(col, row).size > 1\n new_groups = nil\n throw :pattern\n end\n\n n_g\n end\n new_groups << new_group\n }\n end # end of catch(:pattern)\n\n if new_groups\n [rows + [pattern], new_groups]\n else\n nil\n end\n }.compact\n }\n }\n matrixes\nend",
"def buildMatchMatrix(fields, headers)\n matrix = []\n fields.each_with_index do |f,fi|\n matrix.append []\n headers.each_with_index do |h,hi|\n lcs_length = lcs(fields[fi].downcase,headers[hi].downcase).length.to_f\n x = lcs_length / fields[fi].length.to_f\n y = lcs_length / headers[hi].length.to_f\n avg = (x + y) / 2\n matrix[fi].append avg\n end\n end\n matrix\n end",
"def check_diag1(board)\n (0..2).to_a.each_with_object(Hash.new(0)) do |i, m|\n m[board[i][i]] += 1 if board[i][i]\n end\nend",
"def parse_example_matrix\n \n weights = Hash.new\n compatibilities = Set.new\n \n @input_matrix.each_with_index do |row, x|\n row.each_with_index do |cur_tile, y|\n weights[cur_tile] = 0 if !weights.key?(cur_tile)\n weights[cur_tile] += 1\n \n valid_dirs(x, y).each do |dir|\n other_tile = @input_matrix[x + dir[0]][y + dir[1]]\n compatibilities.add([cur_tile, other_tile, dir])\n end\n end\n end\n \n @weights = weights\n @compatibilities = compatibilities\n end",
"def find_words(lines, words, sec, point_map)\n found = {}\n max = @letters.length\n lines.each_with_index do |s, i|\n start = 0\n while start < 15\n pattern = ''\n match_regex = ''\n j = start\n while j <= 14 do\n break if s[j] == '!'\n #puts \"** #{i},#{j}\"\n match_regex << (s[j] == '?' ? \"(#{sec[i][j].keys.join('|')})\" : (s[j] == '*' ? '.' : s[j]))\n pattern << s[j]\n break if pattern.count(\".?\") >= max\n j += 1\n end\n if j && j < 14 && s[j] != '!' && words[i][j+1]\n pattern += words[i][j+1]\n match_regex += words[i][j+1]\n end\n\n\n #puts \"regex: #{match_regex}\"\n found.merge!(match(pattern, start, i, words[i], sec[i], point_map[i], match_regex)) unless pattern == ''\n\n if '.?!*'.include?(s[start])\n start += 1\n else\n start += words[i][start].length + 1\n end\n\n end\n end\n #puts \"found: #{found.inspect}\"\n found\n end",
"def solution \n row_search \n columns_search \n diagonal_search\n end",
"def index_of_coincidence(matrix)\n\n matrix.inject([]) do |indices, row_letters|\n frequencies = letter_frequencies(row_letters)\n\n indices << (\"A\"..\"Z\").inject(0) { |a,v|\n x = frequencies[v]\n a += x*(x-1)\n a\n } / (row_letters.size * (row_letters.size - 1))\n end\n\nend",
"def execute(m,row,col)\n for i in 0..m.size-1\n aux = m[i][col] \n if aux != 0\n for j in 1..m[0].size-1\n if i != row \n m[i][j] -= (aux * m[row][j]).to_f\n m[i][j] = 0 if m[i][j] > -0.001 && m[i][j] < 0.001\n end \n end\n if i != row \n print \"L#{i} = L#{i}-#{aux<0 ? '('+aux.to_s+')': aux}L#{row} \\n\".italic.blue\n #print_matrix(m,row,col, i)\n end \n end\n end\n m\nend",
"def exercise_1113 (matrix)\n end",
"def valid_sudoku(table)\n table.each do |row|\n row_map = {}\n row.each do |elem|\n if elem != '.'\n if row_map[elem] \n return false\n else\n row_map[elem] = 1\n end\n end\n end\n end\n \n i = 0\n 9.times do\n column_map = {}\n table.each do |row|\n col = row[i]\n if col != '.'\n if column_map[col] \n return false\n else\n column_map[col] = 1\n end\n end\n\n end\n k += 1\n end\n \n i = 0\n k = 0\n 9.times do\n box_map = {}\n while i < i + 3\n while k < k + 3\n \n end\n end \n end\n \n return true\nend",
"def cover(matrix, rows, cols, line_num = rows.size - 1)\n\t\t\tif line_num <= 0\n\t\t\t\treturn false if line_num < 0\n\t\t\t\trows.each do |i|\n\t\t\t\t\trow = matrix[i]\n\t\t\t\t\tcols.each do |j|\n\t\t\t\t\t\treturn false if row[j].zero?\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\treturn [], []\n\t\t\tend\n\n\t\t\t# Count the number of 0's per row and column\n\t\t\tzeros_per_row = Array.new(@size, 0)\n\t\t\tzeros_per_col = Array.new(@size, 0)\n\t\t\trows.each do |i|\n\t\t\t\trow = matrix[i]\n\t\t\t\tcols.each do |j|\n\t\t\t\t\tnext unless row[j].zero?\n\t\t\t\t\tzeros_per_row[i] += 1\n\t\t\t\t\tzeros_per_col[j] += 1\n\t\t\t\tend\n\t\t\tend\n\n\t\t\trow_max = zeros_per_row.max\n\t\t\tcol_max = zeros_per_col.max\n\t\t\tif row_max < col_max\n\t\t\t\treturn [], [] if col_max.zero?\n\t\t\t\tj = zeros_per_col.index(col_max)\n\t\t\t\trows_cover, cols_cover = cover(matrix, rows, cols - [j], line_num - 1)\n\t\t\t\treturn rows_cover, cols_cover.unshift(j) if rows_cover\n\n\t\t\t\tzeros = rows.map {|i| matrix[i][j].zero?? i : nil}.compact\n\t\t\t\trows_cover, cols_cover = cover(matrix, rows - zeros, cols - [j], line_num - zeros.size)\n\t\t\t\treturn rows_cover + zeros, cols_cover if rows_cover\n\t\t\telse\n\t\t\t\treturn [], [] if row_max.zero?\n\t\t\t\ti = zeros_per_row.index(row_max)\n\t\t\t\trows_cover, cols_cover = cover(matrix, rows - [i], cols, line_num - 1)\n\t\t\t\treturn rows_cover.unshift(i), cols_cover if rows_cover\n\n\t\t\t\trow = matrix[i]\n\t\t\t\tzeros = cols.map {|jj| row[jj].zero?? jj : nil}.compact\n\t\t\t\trows_cover, cols_cover = cover(matrix, rows - [i], cols - zeros, line_num - zeros.size)\n\t\t\t\treturn rows_cover, cols_cover + zeros if rows_cover\n\t\t\tend\n\n\t\t\treturn false\n\t\tend",
"def calcAdjustment(matrix,totalGenes)\n #score adjustment for col/row sum\n colAdj = 0\n matrix.colSums.each{|sum|\n colAdj += Math.log2star(sum)\n }\n \n rowAdj = 0\n matrix.rowSums.each{|sum|\n rowAdj += Math.log2star(sum)\n }\n\n # each row gets sorted by its sum \n rowSortAdj = matrix.rowSums.calcUniqPermutationsLog2\n colSortAdj = matrix.colSums.calcUniqPermutationsLog2\n sortAdj = rowSortAdj + colSortAdj\n\n # score adjustment for which set of N genes to use \n # (think \"multiple testing\" via binomial coefficient)\n testAdj = Math.binomCoefficientLog2(totalGenes,matrix.numRows)\n\n return colAdj + rowAdj + testAdj +sortAdj\nend",
"def runAlgorithm(row)\n for column in 0..@width-1\n if @columns[column] >= 0 then\n next\n end\n\n ixDiag1 = row + column\n if @diagonals1[ixDiag1] then\n next\n end\n\n ixDiag2 = @lastRow - row + column\n if @diagonals2[ixDiag2] then\n next\n end\n\n @columns[column] = row\n @diagonals1[ixDiag1] = true\n @diagonals2[ixDiag2] = true\n\n if row == @lastRow then\n @solutions.push(@columns.dup)\n else\n runAlgorithm(row + 1)\n end\n\n @columns[column] = -1\n @diagonals1[ixDiag1] = false\n @diagonals2[ixDiag2] = false\n end\n end",
"def find_word( file, target_letter_height, iterations )\n\n points = []\n File.open( file , \"r\" ) do |f|\n f.each_line do |line|\n matches = /position=<\\s*([^\\s]+),\\s*([^\\s]+)> velocity=<\\s*([^\\s]+),\\s*([^\\s]+)>/.match( line )\n points << Point.new( matches[1].to_i, matches[2].to_i, matches[3].to_i, matches[4].to_i )\n end\n end\n\n iter_counter = 0\n candidate_grid = nil\n candidate_iteration = nil\n cols_at_height_current = 0\n \n loop do\n\n break if iter_counter >= iterations\n\n allpoints = {}\n xmaxes = Hash.new( 0 )\n \n points.each do |p|\n p.x = p.xvel + p.x \n p.y = p.yvel + p.y \n key = \"#{p.x},#{p.y}\"\n \n # if we have not yet seen this point, then count its x pos\n if ! allpoints.key?( key )\n xmaxes[p.x] = xmaxes[p.x] + 1\n end\n \n allpoints[key] = 1\n end\n\n # figure out how many columns we have, that are at the same row value\n cols_at_height = 0\n xmaxes.each do |k,v|\n cols_at_height = cols_at_height + 1 if v == target_letter_height\n end\n\n if cols_at_height > cols_at_height_current\n cols_at_height_current = cols_at_height\n candidate_grid = allpoints.dup\n candidate_iteration = iter_counter\n end\n \n iter_counter += 1\n end\n\n [ candidate_iteration + 1, candidate_grid ]\nend",
"def sudoku_check(sudoku, grid_lines, grid_columns)\n results = []\n sudoku.each do |line|\n line_check = Hash.new(0)\n line.each do |cell|\n if cell.length == 1\n line_check[cell[0]] += 1\n end\n end\n results << line_check\n end\n\n return results\nend",
"def find_best_seats(arrangment_hash, columns)\n center_seat = columns/2\n alloted_seat = nil\n arrangment_hash.each do |l|\n row = l.keys.first.split(\"\", 2)\n @request_seats.times do |m|\n # If row has eeven single unavailable seat\n if l.values.include? (\"U\")\n # Loop trough seats\n loop_through_center(l, center_seat)\n break if @request_seats == 0 \n else\n # If all the seats in row is available then allot center seat\n l[row.first + center_seat.to_s] = \"U\"\n @request_seats -= 1\n @result << \"Alloted seat is #{row.first + center_seat.to_s}\"\n break if @request_seats == 0 \n end\n end\n end\n puts arrangment_hash\n end",
"def experimental_layout(string, matrix)\n matrix.each_with_index do |row, idx|\n if row.include? string\n matrix = matrix[idx..(idx + 8)] \n # Removing rows and columns from 96 well format\n arr = matrix[1..matrix.length].map do |row|\n if string == 'sample_id_mat'\n row[1..row.length].map {|i| i.to_i}\n else\n row[1..row.length].map {|i| i}\n end\n end\n return arr\n end\n end\n end",
"def matrix_check_sum(matrix)\n per_line = matrix.length\n col_index = 0\n\n matrix.each do |row|\n row_sum = 0\n per_line.times do |i|\n row_sum += row[i]\n end\n\n col_sum = 0\n per_line.times do |i|\n col_sum += matrix[i][col_index]\n end\n\n if row_sum == col_sum\n col_index += 1\n else\n return false\n end\n\n end\n return true\nend",
"def check_matrix\n @matrix.each_with_index do |current_point, i|\n @edges.clear # Set up the edge buffer.\n check_triangles(current_point)\n check_edges(i)\n end\n end",
"def fleiss(matrix)\n debug = true\n\n # n Number of rating per subjects (number of human raters)\n n = checkEachLineCount(matrix) # PRE : every line count must be equal to n\n i_N = matrix.size\n k = matrix[0].size\n\n if debug\n puts \"#{n} raters.\"\n puts \"#{i_N} subjects.\"\n puts \"#{k} categories.\"\n end\n\n # Computing p[]\n p = [0.0] * k\n (0...k).each do |j|\n p[j] = 0.0\n (0...i_N).each {|i| p[j] += matrix[i][j] } \n p[j] /= i_N*n \n end\n\n puts \"p = #{p.join(',')}\" if debug\n\n # Computing f_P[] \n f_P = [0.0] * i_N\n\n (0...i_N).each do |i|\n f_P[i] = 0.0\n (0...k).each {|j| f_P[i] += matrix[i][j] * matrix[i][j] } \n f_P[i] = (f_P[i] - n) / (n * (n - 1)) \n end \n\n puts \"f_P = #{f_P.join(',')}\" if debug\n\n # Computing Pbar\n f_Pbar = sum(f_P) / i_N\n puts \"f_Pbar = #{f_Pbar}\" if debug\n\n # Computing f_PbarE\n f_PbarE = p.inject(0.0) { |acc,el| acc + el**2 }\n\n puts \"f_PbarE = #{f_PbarE}\" if debug \n\n kappa = (f_Pbar - f_PbarE) / (1 - f_PbarE)\n puts \"kappa = #{kappa}\" if debug \n\n kappa \nend",
"def find_pivot(col, m)\n aux = 999999\n row = 0\n num_cols = m[0].size\n init = m[0][0] == 'z' ? 1:2\n for i in init..m.size-1\n div = (m[i][col] != 0) ? (m[i][num_cols-1] / m[i][col]) : -1\n if div < aux && div >= 0\n aux = div\n row = i \n end\n end\n m[row][0] = 'X' + (col).to_s\n print \"Encontrar o pívot => m[#{row}][#{col}] = #{m[row][col]}\".italic.blue\n row\nend",
"def color_matches(loc=@counter)\n code = get_code_remainder(loc)\n guess = get_guess_remainder(loc)\n x = 0\n y = 0\n index = 0\n totalmatches = 0\n matches = 0\n guess.each{|g|\n code.each{ |c| \n if c == g && matches == 0\n matches += 1\n guess[x] = 0\n code[y] = 5\n end\n y += 1\n }\n y = 0\n totalmatches += 1 if matches > 0\n matches = 0\n x += 1\n }\n totalmatches\n end",
"def score\n h = @horizontal.reject { |(x,y),r| x==r }\n v = @vertical.reject { |(x,y),r| y==r }\n \n hs = h.map { |position,right|\n x,y = position\n value, mult = (x..right).reduce([0,1]) { |(total, word_multiple),x|\n value = @board.tile_at([x,y]).value\n word_multiplier = 1\n\n if @pending.at(x,y)\n space = @board.at(x,y)\n value *= space.letter_multiplier\n word_multiplier = space.word_multiplier\n end\n [total+value, word_multiple*word_multiplier]\n }\n value*mult\n }\n vs = v.map { |position,bottom|\n x,y = position\n value, mult = (y..bottom).reduce([0,1]) { |(total, word_multiple),y|\n value = @board.tile_at([x,y]).value\n word_multiplier = 1\n\n if @pending.at(x,y)\n space = @board.at(x,y)\n value *= space.letter_multiplier\n word_multiplier = space.word_multiplier\n end\n [total+value, word_multiple*word_multiplier]\n }\n value*mult\n }\n (hs.reduce(:+)||0) + (vs.reduce(:+)||0) \n end",
"def matrix_check_sum(matrix)\n\n row_array = []\n column_array = []\n\n matrix.each do |row|\n row_sum = 0\n row.each do |element|\n row_sum += element\n end\n row_array << row_sum\n end\n\n column_length = matrix[0].length\n j = 0\n until j == column_length\n column_sum = 0\n matrix.each do |row|\n column_sum += row[j]\n end\n j += 1\n column_array << column_sum\n end\n\n if row_array == column_array\n return true\n else\n return false\n end\n\nend",
"def compare_all_rows\n @guess_rows.map do |guess|\n right_color = 0 \n right_spot = 0\n guess.get_pins.each.with_index do |pin, index|\n if pin == @correct_row.get_pins[index]\n right_spot += 1\n end\n end\n right_color = (guess.get_pins & @correct_row.get_pins).count\n [right_spot, right_color - right_spot, guess]\n end\n end",
"def pairs(matrix)\n # calculate concordant #p matrix\n rs=matrix.row_size\n cs=matrix.column_size\n conc=disc=ties_x=ties_y=0\n (0...(rs-1)).each do |x|\n (0...(cs-1)).each do |y|\n ((x+1)...rs).each do |x2|\n ((y+1)...cs).each do |y2|\n # #p sprintf(\"%d:%d,%d:%d\",x,y,x2,y2)\n conc+=matrix[x,y]*matrix[x2,y2]\n end\n end\n end\n end\n (0...(rs-1)).each {|x|\n (1...(cs)).each{|y|\n ((x+1)...rs).each{|x2|\n (0...y).each{|y2|\n # #p sprintf(\"%d:%d,%d:%d\",x,y,x2,y2)\n disc+=matrix[x,y]*matrix[x2,y2]\n }\n }\n }\n }\n (0...(rs-1)).each {|x|\n (0...(cs)).each{|y|\n ((x+1)...(rs)).each{|x2|\n ties_x+=matrix[x,y]*matrix[x2,y]\n }\n }\n }\n (0...rs).each {|x|\n (0...(cs-1)).each{|y|\n ((y+1)...(cs)).each{|y2|\n ties_y+=matrix[x,y]*matrix[x,y2]\n }\n }\n }\n {'P'=>conc,'Q'=>disc,'Y'=>ties_y,'X'=>ties_x}\n end",
"def find_intersections(staff)\n intersections = {}\n \n # don't worry about the last (lowest) line of the staff, since there is nothing to \n # compare it to\n for line in 0..(staff.length-1)\n for noteplace in 0..(staff[line].length-1)\n note_a = staff[line][noteplace]\n \n for l in staff[(line+1)..-1]\n to_remove = []\n for note_b in l\n if intersection(note_a, note_b)\n if intersections[note_a].nil?\n intersections[note_a] = []\n end\n intersections[note_a].push(note_b)\n to_remove.push(note_b)\n end\n end\n to_remove.each do |rnote|\n l.delete(rnote)\n end\n end\n end\n end\n\n columns = []\n sorted_keys = intersections.keys.sort\n sorted_keys.each do |key|\n column = []\n # a thing in column should look like [\"3\",\"e\"] or [\"5\",\"A\"]\n # the info contained is the fret and the line it's on('string')\n column.push([key[3],key[2]])\n intersections[key].each do |k|\n column.push([k[3],k[2]])\n end\n # so, columns will contain things like [[\"3\",\"e\"],[\"3\",\"A\"][\"5\",\"B\"][\"5\",\"G\"]]\n columns.push(column)\n end\n columns\n\n end",
"def assign_or_cover(matrix)\n\t\t\trows = @size.times.to_a\n\t\t\tcols = @size.times.to_a\n\t\t\tcoordinates = []\n\t\t\trows_cover = []\n\t\t\tcols_cover = []\n\n\t\t\t# Temporary assignment\n\t\t\t# Also find blocks possible to assign.\n\t\t\tclassify = Hash.new{|hash, key| hash[key] = []}\n\t\t\tloop do\n\t\t\t\tassigned = false\n\n\t\t\t\t# Find zeros in each row\n\t\t\t\tclassify.clear\n\t\t\t\trows.dup.each do |i|\n\t\t\t\t\trow = matrix[i]\n\t\t\t\t\tzero_cols = cols.map {|j| row[j].zero?? j : nil}.compact\n\n\t\t\t\t\tcase zero_cols.size\n\t\t\t\t\twhen 0\n\t\t\t\t\t\trows_cover += rows.select do |i2|\n\t\t\t\t\t\t\tcols.map {|j| matrix[i2][j]}.include?(0)\n\t\t\t\t\t\tend\n\t\t\t\t\t\treturn nil, [rows_cover, cols_cover]\n\t\t\t\t\twhen 1\n\t\t\t\t\t\tj = zero_cols.first\n\t\t\t\t\t\trows.delete(i)\n\t\t\t\t\t\tcols.delete(j)\n\t\t\t\t\t\tcoordinates << [i, j]\n\t\t\t\t\t\tcols_cover << j\n\t\t\t\t\t\tassigned = true\n\t\t\t\t\telse\n\t\t\t\t\t\tclassify[zero_cols] << i\n\t\t\t\t\t\tif zero_cols.size <= classify[zero_cols].size\n\t\t\t\t\t\t\tzero_cols.zip(classify[zero_cols]) do |jj, ii|\n\t\t\t\t\t\t\t\trows.delete(ii)\n\t\t\t\t\t\t\t\tcols.delete(jj)\n\t\t\t\t\t\t\t\tcoordinates << [ii, jj]\n\t\t\t\t\t\t\t\tcols_cover << jj\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tassigned = true\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# Find zeros in each col\n\t\t\t\tclassify.clear\n\t\t\t\tcols.dup.each do |j|\n\t\t\t\t\tzero_rows = rows.map {|i| matrix[i][j].zero?? i : nil}.compact\n\n\t\t\t\t\tcase zero_rows.size\n\t\t\t\t\twhen 0\n\t\t\t\t\t\tcols_cover += cols.select do |j2|\n\t\t\t\t\t\t\trows.map {|i| matrix[i][j2]}.include?(0)\n\t\t\t\t\t\tend\n\t\t\t\t\t\treturn nil, [rows_cover, cols_cover]\n\t\t\t\t\twhen 1\n\t\t\t\t\t\ti = zero_rows.first\n\t\t\t\t\t\trows.delete(i)\n\t\t\t\t\t\tcols.delete(j)\n\t\t\t\t\t\tcoordinates << [i, j]\n\t\t\t\t\t\trows_cover << i\n\t\t\t\t\t\tassigned = true\n\t\t\t\t\telse\n\t\t\t\t\t\tclassify[zero_rows] << j\n\t\t\t\t\t\tif zero_rows.size <= classify[zero_rows].size\n\t\t\t\t\t\t\tzero_rows.zip(classify[zero_rows]) do |ii, jj|\n\t\t\t\t\t\t\t\trows.delete(ii)\n\t\t\t\t\t\t\t\tcols.delete(jj)\n\t\t\t\t\t\t\t\tcoordinates << [ii, jj]\n\t\t\t\t\t\t\t\trows_cover << ii\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tassigned = true\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tbreak unless assigned\n\t\t\tend\n\n\t\t\treturn coordinates, nil if rows.empty?\n\n\t\t\t# Try to completely assign\n\t\t\tsub_coordinates = assign(matrix, rows, cols)\n\t\t\t@assign_cache.clear\n\t\t\treturn coordinates + sub_coordinates, nil if sub_coordinates\n\n\t\t\t# Cover zeros by rows and cols\n\t\t\tr_cover, c_cover = cover(matrix, rows, cols)\n\t\t\treturn nil, [rows_cover + r_cover, cols_cover + c_cover]\n\t\tend",
"def checkEachLineCount(matrix)\n n = sum(matrix[0])\n # Raises an exception if lines contain different number of ratings \n matrix.each{|line|raise \"Line count != #{n} (n value).\" if sum(line) !=n}\n n # The number of ratings\nend",
"def preprocess(lines, words, point_map)\n pre = []\n pattern = ''\n lines.each_with_index do |s, i|\n pre[i] = []\n s.each_char.each_with_index do |c, j|\n next unless '.?!*'.include?(c)\n s[j] = '.'\n if i > 0 && i < 14 && words[j][i-1] && words[j][i+1]\n pattern = \"#{words[j][i-1]}.#{words[j][i+1]}\"\n start = i - words[j][i-1].length\n elsif i > 0 && words[j][i-1]\n pattern = \"#{words[j][i-1]}.\"\n start = i - words[j][i-1].length\n elsif i < 14 && words[j][i+1]\n pattern = \".#{words[j][i+1]}\"\n start = i\n elsif point_map[i][j] == '*'\n s[j] = '*'\n next\n else\n next\n end\n permutations(@letters, pattern) do |p|\n #puts \"perm: #{p}, pattern: #{pattern}\"\n if @word_set.has_key? p.downcase\n s[j] = '?'\n letter = p[pattern.index('.')]\n #puts \"point map #{point_map[j]}, start: #{start}\"\n (pre[i][j] ||= {})[letter] = {:word => p, :score => points(p, pattern, point_map[j][start, pattern.length])}\n end\n end\n s[j] = '!' if s[j] != '?'\n end\n end\n #puts pre.inspect\n pre\n end",
"def get_accuracy_matrix\n matrix = Hash.new\n\n (1..ISSUE_NAMES.length).each do |i| #for every pair\n (1..ISSUE_NAMES.length).each do |j|\n \n num_incr = 0\n num_decr = 0\n EXPERT_GRAPHS.each_value do |expert| #count how many experts had an edge in each direction\n num_incr += 1 if expert[[i,j]] == 1\n num_decr += 1 if expert[[i,j]] == -1\n end\n \n matrix[[i,j,1]] = RUBRIC[num_incr] #have increase and decrease, so technically 3d matrix\n matrix[[i,j,-1]] = RUBRIC[num_decr]\n end\n end\n \n #matrix.each {|key,value| puts key.to_s+\":\"+value.to_s if value > 0}\n ### should probably just hard-code this once it's done...\n return matrix\n end",
"def diagonal_search \n diagonal = []\n diagonal_words = []\n search = @@boards_templates[1].to_s.scan(/./).each_slice(5).to_a\n for ca in 2..7 \n down = ca \n for row in 0..ca\n if row <= 4 \n diagonal << search[down][row]\n down -= 1 \n end \n end \n end\n diagonal = diagonal.join \n @@boards_templates[0].each { |x| diagonal.include?(x) ? diagonal_words << x : diagonal_words.reverse.include?(x) ? diagonal_words << x : \"No hay palabras en dirección diagonal\" }\n #diagonal_words \n end",
"def find_lower_negative(m)\n lower = 0\n col = -1\n for j in 1..m[0].size-2\n if lower > m[0][j] #|| (lower == m[0][j] && lower != 0)\n lower = m[0][j]\n col = j \n end\n end \n col\nend",
"def detect_st( str, matrix )\n matrix.map do |combination|\n detect_single str, combination\n end\n end",
"def igual (mat)\n end",
"def search_matrix(matrix, target)\n (0..matrix[0].length).each do |num|\n p num\n end\nend",
"def columns_search \n column = [] \n search = @@boards_templates[1].to_s.scan(/./).each_slice(5).to_a\n for h in 0..4\n for v in 0..7 \n column << search[v][h] \n end \n end \n vertical_words = []\n vertical = column.join\n @@boards_templates[0].each do |x| \n if vertical.include?(x)\n vertical_words << x\n elsif vertical.reverse.include?(x)\n vertical_words << x \n end \n end \n vertical_words\n end",
"def back_substitution(matrix)\n (matrix.length - 1).downto(0) do |pivot_idx|\n # Multiply the current vector position by the pivot_idx inverse (1/pivot_idx)\n inverse = 1 / matrix[pivot_idx][pivot_idx]\n matrix[pivot_idx][-1] *= inverse\n matrix[pivot_idx][pivot_idx] = 1r # We know it will be 1\n puts \"Multiply the #{format_ordinal pivot_idx + 1} row by its diagonal inverse: \"\\\n \"#{inverse.to_s.split('').join(' ')}\"\n\n if (pivot_idx - 1).negative?\n puts 'And we don\\'t have to zero any row'\n else\n puts 'We iterate over the rows above the current pivot index, to zero them'\n print_new_line\n (pivot_idx - 1).downto(0) do |row|\n if !matrix[row][pivot_idx].zero?\n puts \"Cancel R#{row + 1} #{format_ordinal row + 1} coefficient: \" \\\n \"R#{row + 1} <- R#{row + 1} #{matrix[row][pivot_idx] >= 0 ? '-' : '+'} \" \\\n \"( #{matrix[row][pivot_idx].abs.to_s.split('').join(' ')} ) * R#{pivot_idx + 1}\"\n\n matrix[row][-1] -= matrix[row][pivot_idx] * matrix[pivot_idx].last\n matrix[row][pivot_idx] = 0r # We know it will be 0\n else\n puts \"The #{format_ordinal row + 1} coefficient in R#{row + 1} is already zeroed, \" \\\n 'so we follow along'\n end\n end\n end\n\n print_new_line\n puts 'After it, this is the matrix'\n pp_matrix matrix\n print_separator\n end\n\n puts 'And in the reduced row echelon form we have:'\n pp_matrix matrix\n print_separator\n\n matrix\nend",
"def determine_center_position(rows, columns)\n values = Hash.new \n rows.each do |row| \n columns.each do |column| \n values[@matrix[row][column]] = [row, column]\n end \n end \n highest_value_square(values)\nend",
"def format_in_coll_input_rc_list(row_rc_set)\n \n # Find where row_rc_set starts and repeats for replicates \n # row_rc_set starts from the if it is coming from the first column of the input collection ie: in_c == 0\n triplicate_row_starting_idx = row_rc_set.each_index.select{|idx| \n in_r, in_c = row_rc_set[idx]\n in_c == 0\n }\n \n # Slicing input triplicates by the position of the [X,0] index\n increment = triplicate_row_starting_idx[0] + triplicate_row_starting_idx[1]\n \n # Build formatted matrix with dimensions of 4 by 9\n formatted_input_rc_matrix = []\n last_row = []\n triplicate_row_starting_idx.map {|idx| \n # Use starting idx and increment to take a section of row_rc_set, then slice by 9 to fit dimensions\n arr = row_rc_set[idx...(idx + increment)].each_slice(9).map{|s|s}\n \n # If the row_rc_set.length is > 9 then arr will have two slices, the first will go into our formatted matrix\n # The second (remaining samples) will go onto the last_row array\n arr.each_with_index {|slice, a_i|\n # If it is the first slice, check length, fill to 9 if necessary, then push to formatted matrix\n if a_i == 0\n if slice.length == 9\n formatted_input_rc_matrix.push(slice)\n else\n (9 - slice.length).times { slice.push(-1)}\n formatted_input_rc_matrix.push(slice)\n end\n else\n # If it is the second smaller slice push each rc_tuple to the last_row arr\n slice.each {|rc| last_row.push(rc) }\n end\n }\n }\n # Finally, fill last_row array to 9 if necessary, then push to formatted_input_rc_matrix\n if (last_row.length != 9) \n (9 - last_row.length).times { last_row.push(-1)}\n end\n formatted_input_rc_matrix.push(last_row)\n \n return formatted_input_rc_matrix\n end",
"def sen_ratg(row,column); det.table(:index, 13)[row][column]; end",
"def set_zeroes(matrix)\n marked_rows = []\n marked_cols = []\n\n matrix.each_with_index do |row_arr, row_idx|\n row_arr.each_with_index do |cell, col_idx|\n if cell == 0\n marked_rows << row_idx unless marked_rows.include?(row_idx)\n marked_cols << col_idx unless marked_cols.include?(col_idx)\n end\n end\n end\n\n matrix.each_with_index do |row_arr, row_idx|\n row_arr.each_with_index do |_, col_idx|\n if marked_rows.include?(row_idx) || marked_cols.include?(col_idx)\n matrix[row_idx][col_idx] = 0\n end\n end\n end\n\n matrix\nend",
"def listEdges(matrix)\n edges = {}\n hitList = {}\n\n matrix.each_with_index do |line, i|\n aI = @alphaHash[i]\n line.each_with_index do |node, j|\n dist = matrix[i][j]\n aJ = @alphaHash[j]\n if dist != -1\n edge = (i < j ? \"#{aI}#{aJ}\" : \"#{aJ}#{aI}\")\n edges[aI] = {} if edges[aI].nil?\n edges[aJ] = {} if edges[aJ].nil?\n edges[aI][aJ] = dist\n edges[aJ][aI] = dist\n hitList[edge] = dist\n end\n end\n end\n\n hitList = Hash[hitList.sort_by {|k,v| v*-1}]\n [edges,hitList]\nend",
"def print_matrix\n persons = unique_points.to_a.sort{|x, y| x.id <=> y.id}\n print \"\\t \"\n #persons.each{ |p| print(\" #{p.id} \") }\n persons.each do |p|\n len = p.id.to_s.length\n len == 1 ? print(\" #{p.id} \") : print(\" #{p.id} \")\n end\n puts\n (0...persons.count).each do |i|\n p = persons[i]\n puts\n row = am[i]\n print(\"#{p.name} \")\n if p.name.length < 7\n print(\"\\t \")\n elsif p.name.length == 7\n print(\" \")\n else\n print(\"\")\n end\n row.each do |cell|\n len = cell.to_s.length\n if cell.nil?\n print(\" -- \")\n else\n len == 1 ? print(\" #{cell} \") : print(\" #{cell} \")\n end\n end\n print(\" #{p.id}\")\n end\n nil\n end",
"def sigCalc(matrix)\n\n d = 0\n mutsRemaining = matrix.rowSums.sum\n bitsRemaining = matrix.numRows * matrix.numCols\n geneSums = Array.new(matrix.rowSums)\n\n #look at one sample at a time\n matrix.colHeader.each_index{|sampIndex|\n sample = matrix.getColByIndex(sampIndex)\n foundOne = false\n sampSum = sample.sumNum\n\n #now, look at each bit in that sample\n sample.each_index{|geneIndex|\n bit = sample[geneIndex]\n\n # We have already seen a one, and are betting the XOR pattern,\n # or we know there are no more mutations here due to the sums\n if foundOne == true || mutsRemaining == 0\n d += calcD(probNull(bit),probA0(bit))\n\n else #estimate the mutation probability\n d += calcD(probNull(bit),probA1(bit, geneSums[geneIndex], (matrix.numCols-sampIndex), sampSum, sample.length-geneIndex, mutsRemaining,bitsRemaining))\n end\n\n if bit == 1\n foundOne = true\n geneSums[geneIndex] -= 1\n sampSum -= 1\n\tmutsRemaining -= 1\n end\n bitsRemaining -=1\n }\n }\n return d\nend",
"def contar_algo(matriz, algo)\n contador = 0\n for a in 0..matriz.length-1\n for b in 0..matriz[0].length-1\n if matriz[a][b] == algo\n contador +=1\n end\n end\n end\n return contador\nend",
"def check_matches\n #check for horizontal matches\n match_found = false \n for i in (0..@width-3)\n for j in (0..@height-1)\n if (@board[i][j] and @board[i+1][j] and @board[i+2][j] and \n @board[i][j].color == @board[i+1][j].color and @board[i][j].color == @board[i+2][j].color)\n @board[i][j].marked = @board[i+1][j].marked = @board[i+2][j].marked = true\n match_found = true\n end\n end\n end\n #check for vertical matches\n for i in (0..@width-1)\n for j in (0..@height-3)\n if (@board[i][j] and @board[i][j+1] and @board[i][j+2] and \n @board[i][j].color == @board[i][j+1].color and @board[i][j].color == @board[i][j+2].color)\n @board[i][j].marked = @board[i][j+1].marked = @board[i][j+2].marked = true\n match_found = true\n end\n end\n end\n\n return match_found \n end",
"def solve(file)\r\n x, y = Integer($sx), Integer($sy)\r\n visited = []\r\n discovered = []\r\n value = $table[\"#{x} #{y}\"]\r\n value = value.to_s\r\n direction, weight = value.split(/\\s/,2)\r\n discovered.push(\"#{x} #{y}\")\r\n \r\n while discovered.size != 0\r\n current = discovered.pop\r\n x, y = current.split(/\\s/)\r\n x = Integer(x)\r\n y = Integer(y)\r\n value = $table[current]\r\n value = value.to_s\r\n direction, weight = value.split(/\\s/,2)\r\n \r\n if visited.include?(current) == false\r\n visited.push(current)\r\n direction = direction.split(//)\r\n \r\n i = 0\r\n while i < direction.size\r\n case direction[i]\r\n when \"u\"\r\n y = y - 1\r\n if visited.include?(\"#{x} #{y}\") == false\r\n discovered.push(\"#{x} #{y}\")\r\n if \"#{x} #{y}\" == \"#{$ex} #{$ey}\"\r\n result = true\r\n end\r\n end\r\n y = y + 1\r\n when \"d\"\r\n y = y + 1\r\n if visited.include?(\"#{x} #{y}\") == false\r\n discovered.push(\"#{x} #{y}\")\r\n if \"#{x} #{y}\" == \"#{$ex} #{$ey}\"\r\n result = true\r\n end\r\n end\r\n y = y - 1\r\n when \"l\"\r\n x = x - 1\r\n if visited.include?(\"#{x} #{y}\") == false\r\n discovered.push(\"#{x} #{y}\")\r\n if \"#{x} #{y}\" == \"#{$ex} #{$ey}\"\r\n result = true\r\n end\r\n end\r\n x = x + 1\r\n when \"r\"\r\n x = x + 1\r\n if visited.include?(\"#{x} #{y}\") == false\r\n discovered.push(\"#{x} #{y}\")\r\n if \"#{x} #{y}\" == \"#{$ex} #{$ey}\"\r\n result = true\r\n end\r\n end\r\n x = x - 1\r\n end\r\n i = i + 1\r\n end\r\n end\r\n end\r\n puts discovered\r\n if result == true\r\n puts result\r\n else\r\n puts false\r\n end\r\n end",
"def apply_rules\n @matrix.each(&:apply_rules!)\n end",
"def find_word_in_matrix (matrix, word)\n\t$find_next_found = false\n\t\n\tmatrix.each_index do |row_index|\t\t\n\t\tmatrix[row_index].each_index do |col_index|\n\t\t\tif matrix[row_index][col_index] == word[0]\t\t\t\t\t\t\t\n\t\t\t\tfind_next(matrix, word, 0, row_index, col_index)\n\t\t\tend\n\t\tend\n\tend\n\n\t$find_next_found\nend",
"def match\n \n # Identify matching cells, track them\n \n # Match skill names\n i = 0\n \n 5.times do |search_row_i|\n 5.times do |result_row_i|\n # Match skill name (column = 0)\n match_keyword(i, [search_row_i, 0], [result_row_i, 0])\n \n if match_id_exists?(i)\n \n # Match skill years experience\n match_integer(i, [search_row_i, 1], [result_row_i, 1])\n \n # Match skill details\n match_keyword_array(i, [search_row_i, 2], [result_row_i, 2])\n end\n \n i += 1\n end\n end\n \n # Match additional job-related stuff (job type, job location)\n \n \n # Calculate points\n calc_skill_names([[0, 1], [5, 6]], false, 50, 10)\n calc_skill_names([[2, 3, 4], [7, 8, 9], [10, 15, 20], [11, 16, 21]], (pct > 0), 40, 10) \n calc_skill_names([[12, 13, 14], [17, 18, 19], [22, 23, 24]], (pct > 0), 30, 10)\n \n calc_additional_attributes({:years_experience_pct => 5, :skill_details_first_pct => 2.5, :skill_details_additional_pct => 1})\n \n # puts \"---------- PCT: \" + @pct.to_s\n \n end",
"def match_position_by_pixel_rows\n\n catch :found_match do\n search_rows.times do |y|\n search_cols.times do |x|\n\n catch :try_next_position do\n puts \"Checking search image at #{x}, #{y}\" if @verbose\n\n template_image.rows.times do |j|\n\n t_width = template_image.columns\n\n # Just check first row, not full string\n t_row = template_image.export_pixels_to_str(0, j, t_width, 1)\n s_row = search_image.export_pixels_to_str(x, y+j, t_width, 1)\n\n if s_row != t_row\n # if any row doesn't match, move on.\n throw :try_next_position\n end\n\n end # template_image.columns.times do\n\n # Success! We made it through all rows \n # at this position.\n self.match_result = x, y\n throw :found_match\n\n end # catch :try_next_position\n\n end\n end\n end # catch :found_match\n return match_result\n end",
"def print_verification_of_position_info\r\n #Test to see if characters are correct\r\n puts \"characters from position matrix----------start\"\r\n @list_of_word_rows.each do |word_row|\r\n word_row.position_list.each do |position|\r\n print position.character\r\n end\r\n puts \"\"\r\n end\r\n puts \"words from position matrix----------end\"\r\n puts \"\"\r\n\r\n #Test to see if word starts and ends are correct\r\n puts \"start and end of words from position matrix----------start\"\r\n @list_of_word_rows.each do |word_row|\r\n word_row.position_list.each do |position|\r\n if position.start_of_word\r\n print \"^\"\r\n print position.character\r\n print position.word_number\r\n end\r\n #If the character is a single letter word, then the char is both the start and end of the word.\r\n #Don't reprint the character, which has already been printed\r\n if position.start_of_word && position.end_of_word\r\n print \"*\"\r\n #If the character is at the end of a word, print the character\r\n elsif position.end_of_word\r\n print position.character\r\n print position.word_number\r\n print \"*\"\r\n end\r\n if !position.start_of_word && !position.end_of_word\r\n print position.character\r\n if position.character != \" \"\r\n print position.word_number\r\n end\r\n end\r\n end\r\n puts \"\"\r\n end\r\n puts \"start and end of words from position matrix----------end\"\r\n\r\n #Test to see if word numbers are correct\r\n puts \"word numbers from position matrix----------start\"\r\n @list_of_word_rows.each do |word_row|\r\n word_row.position_list.each do |position|\r\n print position.word_number.to_s + \" \"\r\n end\r\n puts \"\"\r\n end\r\n puts \"word numbers from position matrix----------end\"\r\n\r\n\r\n #Test to see if line starts and ends are correct\r\n puts \"\"\r\n puts \"start and end of lines from position matrix----------start\"\r\n @list_of_word_rows.each do |word_row|\r\n word_row.position_list.each do |position|\r\n if position.start_of_line\r\n print \"-\"\r\n elsif position.end_of_line\r\n print \"+\"\r\n else\r\n print position.character\r\n end\r\n end\r\n puts \"\"\r\n end\r\n puts \"start and end of lines from position matrix----------end\"\r\n end",
"def find_claiming_pair\n iterator((1..3)){|col,line|\n scan_claiming_pair_line(col,line)\n reduce_solved\n scan_claiming_pair_col(col,line)\n reduce_solved\n }\n self\n end",
"def find_secondaries\n\n if File.exist?(@reciprocal_hits)\n # puts \"reciprocal output already exists\"\n else\n length_hash = Hash.new\n fitting = Hash.new\n @evalues.each do |h|\n length_hash[h[:length]] = [] if !length_hash.key?(h[:length])\n length_hash[h[:length]] << h\n end\n\n (10..@longest).each do |centre|\n e = 0\n count = 0\n s = centre*0.1\n s = s.to_i\n s = 5 if s < 5\n (-s..s).each do |side|\n if length_hash.has_key?(centre+side)\n length_hash[centre+side].each do |point|\n e += point[:e]\n count += 1\n end\n end\n end\n if count>0\n mean = e/count\n fitting[centre] = mean\n end\n end\n hits = 0\n @missed.each_pair do |id, list|\n list.each do |hit|\n l = hit.alnlen.to_i\n e = hit.evalue\n e = 1e-200 if e==0\n e = -Math.log10(e)\n if fitting.has_key?(l)\n if e >= fitting[l]\n if !@reciprocals.key?(id)\n @reciprocals[id] = []\n found = false\n @reciprocals[id].each do |existing_hit|\n if existing_hit.query == hit.query &&\n existing_hit.target == hit.target\n found = true\n end\n end\n if !found\n @reciprocals[id] << hit\n hits += 1\n end\n end\n end\n end\n end\n end\n end\n return hits\n end",
"def adjacent_mines(row, col)\n count = 0\n if @field[row + 1].nil? && @field[row][col + 1].nil?\n count = 0\n count += 1 if @field[row - 1][col - 1].contains_mine?\n count += 1 if @field[row - 1][col].contains_mine?\n count += 1 if @field[row][col - 1].contains_mine?\n elsif @field[row + 1].nil? && @field[row][col - 1].nil?\n count = 0\n count += 1 if @field[row - 1][col + 1].contains_mine?\n count += 1 if @field[row - 1][col].contains_mine?\n count += 1 if @field[row][col + 1].contains_mine?\n elsif @field[row - 1].nil? && @field[row][col + 1].nil?\n count = 0\n count += 1 if @field[row + 1][col - 1].contains_mine?\n count += 1 if @field[row + 1][col].contains_mine?\n count += 1 if @field[row][col - 1].contains_mine?\n elsif @field[row - 1].nil? && @field[row][col - 1].nil?\n count = 0\n count += 1 if @field[row + 1][col + 1].contains_mine?\n count += 1 if @field[row + 1][col].contains_mine?\n count += 1 if @field[row][col + 1].contains_mine?\n elsif @field[row - 1].nil?\n count = 0\n count += 1 if @field[row][col - 1].contains_mine?\n count += 1 if @field[row][col + 1].contains_mine?\n count += 1 if @field[row + 1][col - 1].contains_mine?\n count += 1 if @field[row + 1][col].contains_mine?\n count += 1 if @field[row + 1][col + 1].contains_mine?\n elsif @field[row + 1].nil?\n count = 0\n count += 1 if @field[row - 1][col - 1].contains_mine?\n count += 1 if @field[row - 1][col].contains_mine?\n count += 1 if @field[row - 1][col + 1].contains_mine?\n count += 1 if @field[row][col - 1].contains_mine?\n count += 1 if @field[row][col + 1].contains_mine?\n elsif @field[row][col + 1].nil?\n count = 0\n count += 1 if @field[row - 1][col - 1].contains_mine?\n count += 1 if @field[row - 1][col].contains_mine?\n count += 1 if @field[row][col - 1].contains_mine?\n count += 1 if @field[row + 1][col - 1].contains_mine?\n count += 1 if @field[row + 1][col].contains_mine?\n elsif @field[row][col - 1].nil?\n count = 0\n count += 1 if @field[row - 1][col + 1].contains_mine?\n count += 1 if @field[row - 1][col].contains_mine?\n count += 1 if @field[row][col + 1].contains_mine?\n count += 1 if @field[row + 1][col + 1].contains_mine?\n count += 1 if @field[row + 1][col].contains_mine?\n else\n count = 0\n adjacent_cells(row, col).each do |cell|\n if cell.contains_mine?\n count += 1\n end\n end\n end\n count\n end",
"def row_checker(flat_board_array)\n first_row_indexes = [0,1,2,3,4,5,6,7,8]\n current_row = 0\n until current_row >= 9\n indexes = first_row_indexes.map { |index| index + current_row * 9}\n hash_of_vals = {}\n indexes.each do |index|\n if hash_of_vals[flat_board_array[index]] && flat_board_array[index] != 0\n return false\n else \n hash_of_vals[flat_board_array[index]] = 1\n end\n end\n current_row += 1\n end\n \n return true\nend",
"def scoreExclusivity(mat)\n covered = 0\n xor = 0\n mat.first.each_index{|i|\n sum = 0\n mat.each{|node|\n sum += node[i].to_i\n }\n if sum == 1\n xor += 1\n covered += 1\n elsif sum > 1\n covered += 1\n end\n }\n \n return xor.to_f/covered.to_f\nend",
"def place_mine_indicators\n @board.each_with_index do |r, row|\n r.each_with_index do |_c, col|\n unless @board[row][col].is_a_mine\n count = 0\n if row - 1 >= 0\n count += 1 if col - 1 >= 0 && @board[row - 1][col - 1].is_a_mine\n count += 1 if @board[row - 1][col].is_a_mine\n count += 1 if col + 1 < @board.size && @board[row - 1][col + 1].is_a_mine\n end\n count += 1 if col - 1 >= 0 && @board[row][col - 1].is_a_mine\n count += 1 if col + 1 < @board.size && @board[row][col + 1].is_a_mine\n if row + 1 < @board.size\n count += 1 if col - 1 >= 0 && @board[row + 1][col - 1].is_a_mine\n count += 1 if @board[row + 1][col].is_a_mine\n count += 1 if col + 1 < @board.size && @board[row + 1][col + 1].is_a_mine\n end\n @board[row][col].set_value(count)\n end\n end\n end\n end",
"def each_match(hash)\n line[:type, :all].count.times do |i|\n next unless hash.all? { |k, v| line[k, :all][i] == v }\n yield(\n :type => line[:type, :all][i],\n :ssn => line[:ssn, :all][i],\n :ein => line[:ein, :all][i],\n :amount => line[:amount, :all][i]\n )\n end\n end",
"def matching(mweid, mwe, leftconst, s_id, sentence, lemma, sentpos, consthash, outdata)\n\tm_frg, leftconst, totallen = 0, leftconst[0].scan(/.{1,2}/), 0\n\n\tlemma.each_with_index do |lempart, idx| \t# sentence loop\n\t\tif mwe[0] == lempart \t# 文の形態素とMWEの形態素が一部マッチ\n\t\t\tm_frg, start_idx = 1, idx\n\t\t\tstartlen, endlen = totallen+1, totallen\n\t\t\tfor cnt in 0..mwe.length-1 do\n\t\t\t\tif lemma[idx+cnt] != mwe[cnt]\n\t\t\t\t\tm_frg = 0\n\t\t\t\t\tbreak\n\t\t\t\telse\n\t\t\t\t\tendlen += lemma[idx+cnt].length\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# 品詞等の制約を確認\t\t\t\n\t\t\tconstlist = consthash[leftconst[0]]\t\t# leftconst[1]は全て\"90\"\n\t\t\tif m_frg == 1\n\t\t\t\tm_frg = constCheck(constlist, sentpos[start_idx-2], start_idx, m_frg)\n\t\t\t\tm_frg = constCheck(constlist, sentpos[start_idx-1], start_idx, m_frg) unless m_frg != 0\n\t\t\tend\n\t\t\t# MWEが完全にマッチしたとき\n\t\t\tif m_frg == 1\n\t\t\t\tprecont, matched, postcont, startlen, endlen = splitCont(mwe, start_idx, sentence)\t\t# 出現形の文に対してのstartlen等を取得\n\t\t\t\toutdata.push([mweid, s_id, startlen.to_s, endlen.to_s, precont, matched, postcont])\t# startlen, endlen: 標準形の文に対してのもの\n\t\t\t\t# outdata.push([mweid, s_id, startlen.to_s, endlen.to_s, precont, matched, postcont, meaning])\t# startlen, endlen: 標準形の文に対してのもの\n\t\t\t\tm_frg = 0\n\t\t\tend\n\t\tend\n\t\ttotallen += lempart.length\n\tend\n\n\treturn outdata\nend",
"def valid_sudoku(table)\n # edge cases\n return false if table.nil? || table.size != 9 || table[0].size != 9\n # 3 new storages will count number of occurances of each element for columns, rows and sub-boxes\n rows = Array.new(9)\n i = 0\n while i < rows.size\n rows[i] = {\"1\"=>0,\"2\"=>0,\"3\"=>0,\"4\"=>0,\"5\"=>0,\"6\"=>0,\"7\"=>0,\"8\"=>0,\"9\"=>0}\n i += 1\n end\n\n columns = Array.new(9)\n i = 0\n while i < columns.size\n columns[i] = {\"1\"=>0,\"2\"=>0,\"3\"=>0,\"4\"=>0,\"5\"=>0,\"6\"=>0,\"7\"=>0,\"8\"=>0,\"9\"=>0}\n i += 1\n end\n\n sub_boxes = Array.new(9)\n i = 0\n while i < sub_boxes.size\n sub_boxes[i] = {\"1\"=>0,\"2\"=>0,\"3\"=>0,\"4\"=>0,\"5\"=>0,\"6\"=>0,\"7\"=>0,\"8\"=>0,\"9\"=>0}\n i += 1\n end\n\n # loop through the input table to populate the above created storages with occurance numbers\n i = 0 # i is a row counter\n while i < table.size\n j = 0 # j is a column counter\n while j < table.size\n if table[i][j] != \".\"\n rows[i][table[i][j]] += 1\n columns[j][table[i][j]] += 1\n # find a number of a box/hash by calculating (i/3)*3 + (j/3)\n # e.g. for the element at indexes 1,2 the box will be: (1/3)*3 + (2/3) = 0, first box\n sub_boxes[(i/3)*3 + (j/3)][table[i][j]] += 1\n end\n j += 1\n end\n i += 1\n end\n # check if any of table elements occured more than 1 time within a row, a column or a sub-box\n rows.each do |hash|\n return false if hash.any? { |key, value| value > 1}\n end\n columns.each do |hash|\n return false if hash.any? { |key, value| value > 1}\n end\n sub_boxes.each_with_index do |hash, i|\n return false if hash.any? { |key, value| value > 1}\n end\n\n return true\nend",
"def searchCol (twoLetters)\n\t\ti = 0\n\t\ta = 0\n\t\twhile twoLetters[0] != @matrizAbcd[a][i]\n\t\t\ti += 1\n\t\t\t# Si no encuentra la letra en la fila, cambia a la siguiente y reinicia puntero\n\t\t\tif i >= @matrizAbcd[a].length\n\t\t\t\ta +=1\n\t\t\t\ti = 0\n\t\t\tend\n\t\tend\n\t\ta = 0\n\t\t# Busca la segunda letra en la columna\n\t\twhile twoLetters[1] != @matrizAbcd[a][i]\n\t\t\ta += 1\n\t\t\t# Si no encuentra la segunda letra, regresa false\n\t\t\tif a >= @matrizAbcd.length\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\t\tif twoLetters[1] == @matrizAbcd[a][i]\n\t\t\treturn true\n\t\tend\n\tend",
"def verify_matrix(matrix, rows_array, columns_array)\n rows = matrix.size\n columns = matrix[0].size\n\n rows.times do |row|\n columns.times do |column|\n if (rows_array.include?(row) || columns_array.include?(column))\n if matrix[row][column] != 0\n puts \"BUG!!! matrix[#{row}][#{column}] should be 0\"\n return false\n end\n elsif matrix[row][column] != 1\n puts \"BUG!!! matrix[#{row}][#{column}] should be 1\"\n return false\n end\n end\n end\n return true\nend",
"def squarocol?(matrix)\n d = matrix.length\n d.times do |i|\n return true if matrix[i].all?{ |el| el == matrix[i][0]}\n end\n\n\n \n d.times do |c|\n flag = 0\n n = matrix[0][c]\n d.times do |r|\n if !(matrix[r][c] == n)\n flag = 1\n break\n end\n end\n return true if flag == 0\n end\n false\nend",
"def matrix_check_sum(matrix)\n rows = matrix.length\n columns = matrix[0].length\n \n sum_rows = []\n matrix.each do |row|\n sum_rows.push(row.sum)\n end\n\n sum_columns = []\n columns.times do |i|\n sum = 0\n rows.times do |j|\n sum = sum + matrix[j][i]\n end\n sum_columns.push(sum)\n end\n \n rows.times do |i|\n columns.times do |j|\n if sum_rows[i] != sum_columns[j]\n return false\n end\n end\n end\n\n return true\nend",
"def valid_sudoku(table)\n store = {\n rows: {},\n cols: {},\n square: {},\n }\n # First loop it represents the first row we are checking\n # Second loop it represents the column.\n\n (0...9).each do |i|\n (0...9).each do |j|\n box = table[i][j]\n if !store[:rows][i] && box != \".\"\n store[:rows][i] = []\n store[:rows][i].push(box)\n elsif box != \".\" && !store[:rows][i].include?(box)\n store[:rows][i].push(box)\n elsif store[:rows][i] && store[:rows][i].include?(box)\n return false\n end\n\n if !store[:cols][j] && box != \".\"\n store[:cols][j] = []\n store[:cols][j].push(box)\n elsif box != \".\" && !store[:cols][j].include?(box)\n store[:cols][j].push(box)\n elsif store[:cols][j] && store[:cols][j].include?(box)\n return false\n end\n\n # Converting to float and the ceil to round up always.\n squareRowId = ((i + 1).to_f / 3).ceil\n squareColId = ((j + 1).to_f / 3).ceil\n # The squeare id is gonna be like\n # 1-1 , 1-2, 1-3\n # 2-1 , 2-2, 2-3\n # 3-1 , 3-2, 3-3\n\n squareId = \"#{squareRowId}-#{squareColId}\"\n\n # Here insted of checking rows and colums I will be checking the numbers inside of this\n # Squeare ids.\n if !store[:square][squareId] && box != \".\"\n store[:square][squareId] = []\n store[:square][squareId].push(box)\n elsif box != \".\" && !store[:square][squareId].include?(box)\n store[:square][squareId].push(box)\n elsif store[:square][squareId] && store[:square][squareId].include?(box)\n return false\n end\n end\n end\n return true\nend",
"def checkwinner\r\n\t\t\t\r\n\t\t\t@matrix.each do |row|\r\n\t\t\t\trow.join.gsub(\"|\",\"\")\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\t#check horizontal winners\r\n\t\t\t@matrix.each do |row|\r\n\t\t\t if row.join.include? \"XXXX\"\r\n\t\t\t\t@winner = 2\t\r\n\t\t\t elsif row.join.include? \"OOOO\"\r\n\t\t\t\t@winner = 1\r\n\t\t\t end\r\n\t\t\tend\r\n\r\n\t\t\t#check vertical winners\r\n\t\t\t@matrix.transpose.each do |row|\r\n\t\t\t if row.join.include? \"XXXX\"\r\n\t\t\t\t@winner = 2\t\r\n\t\t\t elsif row.join.include? \"OOOO\"\r\n\t\t\t\t@winner = 1\r\n\t\t\t end\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\tfor row_nr in 0..@matrix.count-4\r\n\t\t\t for col_nr in 0..@matrix[0].count-4\r\n\t\t\t\tel_1 = @matrix[row_nr] [col_nr]\r\n\t\t\t\tel_2 = @matrix[row_nr+1][col_nr+1]\r\n\t\t\t\tel_3 = @matrix[row_nr+2][col_nr+2]\r\n\t\t\t\tel_4 = @matrix[row_nr+3][col_nr+3]\r\n\r\n\t\t\t\tif el_1 + el_2 + el_3 + el_4 == 'XXXX'\r\n\t\t\t\t @winner = 2\t\r\n\t\t\t\telsif el_1 + el_2 + el_3 + el_4 == 'OOOO'\r\n\t\t\t\t @winner = 1\r\n\t\t\t\tend\r\n\t\t\t end\r\n\t\t\tend\r\n\t\t\t#right to left\r\n\t\t\tfor row_nr in 0..@matrix.count-4\r\n\t\t\t for col_nr in 0..@matrix[0].count-4\r\n\t\t\t\tel_1 = @matrix.reverse[row_nr] [col_nr]\r\n\t\t\t\tel_2 = @matrix.reverse[row_nr+1][col_nr+1]\r\n\t\t\t\tel_3 = @matrix.reverse[row_nr+2][col_nr+2]\r\n\t\t\t\tel_4 = @matrix.reverse[row_nr+3][col_nr+3]\r\n\r\n\t\t\t\tif el_1 + el_2 + el_3 + el_4 == 'XXXX'\r\n\t\t\t\t @winner = 2 \r\n\t\t\t\telsif el_1 + el_2 + el_3 + el_4 == 'OOOO'\r\n\t\t\t\t @winner = 1\r\n\t\t\t\tend\r\n\t\t\t end\r\n\t\t\tend\r\n\t\r\n\t\t\treturn @winner\r\n\t\tend",
"def _fetch_counts_matrix(int_id)\n counts = {}\n\n DNA.letters.each do |base|\n base_counts = []\n cur = @dbh.query(\"SELECT VAL FROM MATRIX_DATA WHERE ID=#{int_id}\" \\\n \" and ROW='#{base}' ORDER BY COL\")\n cur.each { |r| base_counts << r[\"VAL\"] }\n counts[base] = base_counts.map(&:to_f)\n end\n\n return Bio::Motifs::GenericPositionMatrix.new(DNA, counts)\n end",
"def each_exact_cover\n nodes = [] # List of nodes that are currently \"covered\"\n\n while true\n\n if empty?\n # Success. Matrix is empty because every column is covered once.\n yield nodes.collect &:row_id\n end\n\n if column = choose_column\n # Cover a new column and pick the first node in it.\n column.cover\n node = column.down\n else\n # Uncover columns until we find one with a node we haven't tried.\n node = backtrack!(nodes)\n return if node.nil? # Tried everything\n end\n\n # Try the node (push it and cover its columns).\n nodes.push node\n node.choose_except_self_column\n\n end\n end",
"def output_matrices(p)\n m = matrixjson(p)\n m.each do |d|\n puts d[0]\n d[1].each do |mr|\n mr.each do |c|\n print \"#{c}#{c.to_s == \" \" || c < 10 ? ' ' : ''} \"\n end\n puts\n end\n puts\n end\nend",
"def make_word_from_board?(letters, word, i, j)\n matched_dices = []\n unmatched_dices = []\n letter_used = letters.map {|column| column.map { false }}\n letter_used[i][j] = true\n matched_dices.push([i, j])\n word_pos = 1\n while word_pos < word.size\n letter_matched = false\n # move a step next to the current letter to check if we can form the word\n (i-1..i+1).each do |m|\n # ignore if our matching window is outside the dices\n if m == -1 || m == letters.size\n next\n end\n (j-1..j+1).each do |n|\n # ignore if our matching window is outside the dices\n if n == -1 || n == letters[0].size\n next\n end\n # ignore for the central dice\n if m == i && n == j\n next\n end\n # ignore if letter at the position has already been used\n if letter_used[m][n]\n next\n end\n # skip if the dice is already unmatched\n if unmatched_dices.find{|dice| dice[0] == m && dice[1] == n}\n next\n end\n if letters[m][n] == word[word_pos]\n i = m\n j = n\n letter_matched = true\n letter_used[i][j] = true\n matched_dices.push([i, j])\n break\n end\n end\n if letter_matched\n word_pos += 1\n break\n end\n end\n unless letter_matched\n # return false when only a single letter is matching\n if word_pos == 1\n return false\n end\n word_pos -= 1\n # get the last matched dice\n i, j = matched_dices.pop\n letter_used[i][j] = false\n unmatched_dices.push([i, j])\n end\n end\n true\n end",
"def matching(mweid, mwe, leftconst, s_id, sentence, lemma, sentpos, consthash, outdata)\n\tm_frg, leftconst, totallen = 0, leftconst[0].scan(/.{1,2}/), 0\n\n\tlemma.each_with_index do |lempart, idx| \t# sentence loop\n\t\tif mwe[0] == lempart \t# 文の形態素とMWEの形態素が一部マッチ\n\t\t\tm_frg, start_idx = 1, idx\n\t\t\tstartlen, endlen = totallen+1, totallen\n\t\t\tfor cnt in 0..mwe.length-1 do\n\t\t\t\tif lemma[idx+cnt] != mwe[cnt]\n\t\t\t\t\tm_frg = 0\n\t\t\t\t\tbreak\n\t\t\t\telse\n\t\t\t\t\tendlen += lemma[idx+cnt].length\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# 品詞等の制約を確認\t\t\t\n\t\t\tconstlist = consthash[leftconst[0]]\t\t# leftconst[1]は全て\"90\"\n\t\t\tif m_frg == 1\n\t\t\t\tm_frg = constCheck(constlist, sentpos[start_idx-2], start_idx, m_frg)\n\t\t\t\tm_frg = constCheck(constlist, sentpos[start_idx-1], start_idx, m_frg) unless m_frg != 0\n\t\t\tend\n\t\t\t# MWEが完全にマッチしたとき\n\t\t\tif m_frg == 1\n\t\t\t\tprecont, matched, postcont, startlen, endlen = splitCont(mwe, start_idx, sentence)\t\t# 出現形の文に対してのstartlen等を取得\n\t\t\t\t# p \"outdata:\", outdata\n\t\t\t\t# p \"mweid:\", mweid\n\t\t\t\t# p \"s_id:\", s_id\n\t\t\t\t# p \"matched:\", matched\n\t\t\t\t# p \"precont:\", precont\n\t\t\t\t# p \"postcont:\", postcont\n\t\t\t\t# p \"meaning:\", meaning\n\t\t\t\t# p startlen, endlen\n\t\t\t\toutdata.push([mweid, s_id, startlen.to_s, endlen.to_s, precont, matched, postcont])\t# startlen, endlen: 標準形の文に対してのもの\n\t\t\t\t# outdata.push([mweid, s_id, startlen.to_s, endlen.to_s, precont, matched, postcont, meaning])\t# startlen, endlen: 標準形の文に対してのもの\n\t\t\t\tm_frg = 0\n\t\t\tend\n\t\tend\n\t\ttotallen += lempart.length\n\tend\n\n\treturn outdata\nend",
"def populate(lines)\n\t\ti = 1\n\t\t@matrix.each_index do |x|\n\t\t\t# split each line into an array of integers and map to a 2 dimensional array\n\t\t\t@matrix[x] = lines[i].split(' ').map(&:to_i)\n\t\t\ti+=1\t\n\t\tend\t\n\tend",
"def verify_word_on_board(w, hash_table)\n w = w.upcase # Since the letters on board is in capital letter\n\n p hash_table\n i = 0\n searched_index = {} # Hash table to keep track what has been searched\n (0...w.length).each { |i| searched_index.store(i, -1)} # Initiate values to indicate that no letters have been searched\n\n while i >= 0 && i < w.length\n # puts \"\\nStart of while loop, i = #{i}, searching letter #{w[i]}...\" ###\n move = false\n\n unless hash_table[w[i]].empty?\n # print \"Letter #{w[i]} exist at #{hash_table[w[i]]}\\n\" ###\n hash_table[w[i]].each_with_index do | value , index |\n # puts \"Scanning through #{w[i]} at position #{value}\" ###\n \n # This unmark the position that was used previously during backtracking.\n if value + @total_letters < 0\n # puts \"Position #{hash_table[w[i]][index]} of #{w[i]} is restored...\" ###\n hash_table[w[i]][index] += (@total_letters * 2)\n # puts \"Position of #{w[i]} is now #{hash_table[w[i]][index]}.\" ###\n end\n\n if index <= searched_index[i] # This skips letters that are already searched\n # puts \"#{w[i]} at #{hash_table[w[i]][index]} is already searched.\" ###\n next\n end\n\n if value >= 0\n \n # The position is subtrated by no of total letters to indicate that it has been searched.\n # No of total letters is used so that duplicate of hash table is not required.\n \n if i == 0 || is_adjacent(hash_table[w[i]][index],(@total_letters + hash_table[w[i-1]][searched_index[i-1]]))\n hash_table[w[i]][index] -= @total_letters\n # puts \"#{value} has been subracted by @total_letters to #{hash_table[w[i]][index]}\" ###\n \n \n searched_index[i] = index\n # puts \"Moving to next letter, searched_index[#{i}] now has been updated to #{searched_index[i]}\" ###\n move = true\n i += 1\n break\n end\n\n end\n end\n\n end\n\n # i -= 1 if move == false\n if move == false\n if i > 0\n # puts \"Previously used #{w[i-1]} position of #{hash_table[w[i-1]][searched_index[i-1]]} is being marked for restoration.\" ###\n \n hash_table[w[i-1]][searched_index[i-1]] -= @total_letters # To mark position to be restored to original value as it will not be used anymore\n # puts \"Current position of #{w[i-1]} is #{hash_table[w[i-1]][searched_index[i-1]]}.\" ###\n searched_index[i] = -1\n end\n\n\n # puts \"Letter #{w[i]} is not available/not adjacent and i will be subtracted\" ###\n i -= 1\n end\n\n end\n\n # Restore back all coordinates for next word\n\n\n restore_hash_table(hash_table)\n\n # Check whether word exists.\n if i >= 0 \n puts \"#{w} exists!\"\n return true\n else\n puts \"#{w} is not available.\"\n return false\n end\n \n end",
"def gridChallenge(grid)\n grid.each do |row|\n row.sort!\n end\n columns = grid.first.size\n size = grid.size\n\n \n (0..(columns - 1)).each do |col|\n list = []\n (0..(size -1)).each do |row| \n list << grid[row][col]\n end\n return 'NO' if list != list.sort\n end\n\n 'YES'\nend",
"def connect_four_helper(last_played_column_index, column_indices, heights)\n last_played_height = @columns[last_played_column_index].length\n if column_indices.length != heights.length then raise \"Invalid input\" end\n\n matches = 0\n column_indices.each_with_index do |column_index, heights_array_index|\n break if not pieces_match?(last_played_column_index, last_played_height, \n column_index, heights[heights_array_index])\n matches += 1\n end\n return matches\n end",
"def grid_pattern(g_mat, p_mat)\n rows_g = g_mat.size\n cols_g = g_mat[0].size\n rows_p = p_mat.size\n cols_p = p_mat[0].size\n i = 0\n j = rows_p - 1\n while j < rows_g do\n k = 0\n l = cols_p - 1\n while l < cols_g do\n ans = true\n (i..j).each do |m|\n ans = ans && ((g_mat[m])[k..l] == p_mat[m-i])\n end\n if ans then\n return true\n end\n k += 1\n l += 1\n end\n break if found \n i += 1\n j += 1\n end\n return false\nend",
"def find_matrix(input, size, result)\n datasize = input.lines.length\n 0.upto(datasize - size) do |top|\n testline = input.lines[top].chomp\n w_subst = result[:W] ? [] : testline.scan(/W{#{size}}/)\n n_subst = result[:N] ? [] : testline.scan(/N{#{size}}/)\n next if w_subst.length.zero? && n_subst.length.zero?\n 0.upto(datasize - size) do |left|\n testcol = input.lines[top..(top+size-1)].map{|line| line.chomp.chars[left] }.join\n next if testcol != 'W'*size && testcol != 'N'*size\n beta = mat(input, [left, top], [left + size - 1, top + size - 1]).flatten.join\n w_bool = beta == 'W'*size*size\n n_bool = beta == 'N'*size*size\n return [w_bool, n_bool] if w_bool || n_bool\n end\n end\n [false, false]\nend",
"def valid_sudoku(table)\n subgrids = {}\n\n # return false if any element is repeated in a row\n table.each do |row|\n row_count = {}\n row.each do |element|\n if row_count[element]\n return false unless element == \".\"\n else\n row_count[element] = 1\n end\n end\n end\n\n # return false if any element is repeated in a column\n columns = {\n 0 => {},\n 1 => {},\n 2 => {},\n 3 => {},\n 4 => {},\n 5 => {},\n 6 => {},\n 7 => {},\n 8 => {},\n }\n table.each do |row|\n row.each_with_index do |element, index|\n if columns[index][element]\n return false unless element == \".\"\n else\n columns[index][element] = 1\n end\n end\n end\n\n first_subgrid = {}\n second_subgrid = {}\n third_subgrid = {}\n\n table[0..2].each do |row|\n row[0..2].each do |element|\n if first_subgrid[element]\n return false unless element == \".\"\n else\n first_subgrid[element] = 1\n end\n end\n\n row[3..5].each do |element|\n if second_subgrid[element]\n return false unless element == \".\"\n else\n second_subgrid[element] = 1\n end\n end\n\n row[6..8].each do |element|\n if third_subgrid[element]\n return false unless element == \".\"\n else\n third_subgrid[element] = 1\n end\n end\n end\n\n first_subgrid = {}\n second_subgrid = {}\n third_subgrid = {}\n\n table[3..5].each do |row|\n row[0..2].each do |element|\n if first_subgrid[element]\n return false unless element == \".\"\n else\n first_subgrid[element] = 1\n end\n end\n\n row[3..5].each do |element|\n if second_subgrid[element]\n return false unless element == \".\"\n else\n second_subgrid[element] = 1\n end\n end\n\n row[6..8].each do |element|\n if third_subgrid[element]\n return false unless element == \".\"\n else\n third_subgrid[element] = 1\n end\n end\n end\n\n first_subgrid = {}\n second_subgrid = {}\n third_subgrid = {}\n\n table[6..8].each do |row|\n row[0..2].each do |element|\n if first_subgrid[element]\n return false unless element == \".\"\n else\n first_subgrid[element] = 1\n end\n end\n\n row[3..5].each do |element|\n if second_subgrid[element]\n return false unless element == \".\"\n else\n second_subgrid[element] = 1\n end\n end\n\n row[6..8].each do |element|\n if third_subgrid[element]\n return false unless element == \".\"\n else\n third_subgrid[element] = 1\n end\n end\n end\n\n return true\nend",
"def valid_sudoku(table)\n sudoku_box_hash = { [0, 0] => {}, [0, 1] => {}, [0, 2] => {},\n [1, 0] => {}, [1, 1] => {}, [1, 2] => {},\n [2, 0] => {}, [2, 1] => {}, [2, 2] => {}}\n\n sudoku_row_hash = { 1 => {}, 2 => {}, 3 => {},\n 4 => {}, 5 => {}, 6 => {},\n 7 => {}, 8 => {}, 9 => {}}\n \n sudoku_col_hash = { 1 => {}, 2 => {}, 3 => {},\n 4 => {}, 5 => {}, 6 => {},\n 7 => {}, 8 => {}, 9 => {}}\n\n sudoku_diagonal_hash = {1 => {}, 9 => {}}\n\n table.each_with_index do |arr, i|\n arr.each_with_index do |ele, j|\n next if ele == \".\"\n # check and add diagonals\n if i == j \n return false if sudoku_diagonal_hash[1].include?(ele)\n sudoku_diagonal_hash[1][ele] = 1\n elsif i + j + 1 == 9 || i == 4 && j == 4\n return false if sudoku_diagonal_hash[9].include?(ele)\n sudoku_diagonal_hash[9][ele] = 1\n end\n\n # check these hashes for all elements\n return false if sudoku_row_hash[i + 1].include?(ele)\n return false if sudoku_col_hash[j + 1].include?(ele)\n return false if sudoku_box_hash[[i / 3, j / 3]].include?(ele)\n\n # can add if no return \n sudoku_row_hash[i + 1][ele] = 1\n sudoku_col_hash[j + 1][ele] = 1\n sudoku_box_hash[[i / 3, j / 3]][ele] = 1 # based off calculating indices of ecah sudoku box\n end\n end\n\n return true\nend",
"def solve\n\t\trowData = @data[0].split(\" \")\n\t\tcolData = @data[1].split(\" \")\n\n\t\t@rows = self.getCandidates(rowData, colData.size)\n\t\t@cols = self.getCandidates(colData, rowData.size)\n\n\t\tbegin\n\t\t\tnumChanged = self.reduceMutual(@cols, @rows)\n\t\t\tif (numChanged == -1)\n\t\t\t\treturn\n\t\t\tend\n\t\tend while (numChanged > 0)\n\n\t\t@rows.each do |row|\n\t\t\tfor i in 0...(@cols.size)\n\t\t\t\tprint row[0][i]? \"# \" : \". \"\n\t\t\tend\n\t\t\tprint \"\\n\"\n\t\tend\n\t\treturn self\n\tend",
"def readColumnsCrieteria ws,columnNumber,criterion,maxColumns\r\n returnVal = []\r\n maxColumns.times do |row|\r\n row = row + 2\r\n match = true\r\n criterion.each do |key,val|\r\n value = ws.cells(row,key).value\r\n unless criterion[key].match(value.to_s)\r\n match = false \r\n end\r\n end\r\n #if the given crieteria matches, push the value to the array\r\n if match\r\n value = ws.cells(row,columnNumber).value\r\n returnVal.push value \r\n end\r\n #check if the given criterion are matching\r\n end\r\n returnVal \r\nend",
"def print_map\n map.each_with_index do |row, i|\n row.each_with_index do |col , j|\n #puts col\n if col == 'R'\n print 'R'\n elsif col == 'S'\n print 'S'\n elsif col == 'B'\n print 'B'\n elsif col == 'W'\n print 'W'\n else\n print '#'\n end\n end\n puts ''\n end\n end",
"def next_generation(matrix)\n @temp_universe = matrix\n @new_generation = create_matrix\n (1..@temp_universe.size - 2).each do |r|\n (1..@temp_universe[r].size - 2).each do |c|\n # verify our universe and set if a cell will be alive or will die\n cell = @temp_universe[r][c]\n # verify alive neighbours\n alives = alive_neighbors(r, c)\n if cell == 1\n if alives < 2\n @new_generation[r][c] = 0\n elsif [2, 3].include?(alives)\n @new_generation[r][c] = 1\n elsif alives > 3\n @new_generation[r][c] = 0\n end\n elsif cell.zero? && alives == 3\n @new_generation[r][c] = 1\n end\n end\n end\n @new_generation\n end",
"def ratings(row,column); det.table(:index, 12)[row][column]; end",
"def calcularActitud\n\t\n\t@aptitud = 0\n\t\n\tself.each_with_index do |item, index|\t\n\t\t\t\n\t\t\t\tprincipalTemp = calcularDiagonalPrincipal(index, item)\n\t\t\t\tsecondaryTemp = calcularDiagonalSecundaria(index, item)\n\t\t\t\t#puts \"principal es #{principalTemp}\"\n\t\t\t\t\n\t\t\t\t#puts \"secundario es #{secondaryTemp}\"\t\n\t\t\t\t\n\t\t\t\tprincipalTemp.row(0).each_with_index do |value , newindex|\n\t\t\t\t\n\t\t\t\t\tif (self[value] == principalTemp.row(1)[newindex] && index != value)\n\t\t\t\t\t\t\n\t\t\t\t\t\t@aptitud -=1\n\t\t\t\t\t\t\n\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tsecondaryTemp.row(0).each_with_index do |value , newindex|\n\t\t\t\t\t\n\t\t\t\t\tif (self[value] == secondaryTemp.row(1)[newindex] && index != value)\n\t\t\t\t\t\t@aptitud -=1\n\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\n\t\t\t\tend\n\tend\n \n end",
"def calculate\n max_row_index, max_column_index = setup\n\n bordered_image.noise[0..max_row_index].each_with_index do |row, row_index|\n row[0..max_column_index].each_with_index do |_, index|\n row_range, column_range = calculate_window_range(row_index, index, invader)\n radar_window = bordered_image.noise_range(row_range, column_range)\n similarity = window_similarity(invader, radar_window)\n update_similarity(matrix, similarity, row_range, column_range) if similarity\n end\n end\n\n matrix\n end",
"def adjust_values\n @cols = @rows.transpose\n @blks[0] = [@rows[0][0], @rows[0][1], @rows[0][2], @rows[1][0], @rows[1][1], @rows[1][2], @rows[2][0], @rows[2][1], @rows[2][2]] #1\n @blks[1] = [@rows[0][3], @rows[0][4], @rows[0][5], @rows[1][3], @rows[1][4], @rows[1][5], @rows[2][3], @rows[2][4], @rows[2][5]] #2\n @blks[2] = [@rows[0][6], @rows[0][7], @rows[0][8], @rows[1][6], @rows[1][7], @rows[1][8], @rows[2][6], @rows[2][7], @rows[2][8]] #3\n @blks[3] = [@rows[3][0], @rows[3][1], @rows[3][2], @rows[4][0], @rows[4][1], @rows[4][2], @rows[5][0], @rows[5][1], @rows[5][2]] #4 \n @blks[4] = [@rows[3][3], @rows[3][4], @rows[3][5], @rows[4][3], @rows[4][4], @rows[4][5], @rows[5][3], @rows[5][4], @rows[5][5]] #5\n @blks[5] = [@rows[3][6], @rows[3][7], @rows[3][8], @rows[4][6], @rows[4][7], @rows[4][8], @rows[5][6], @rows[5][7], @rows[5][8]] #6\n @blks[6] = [@rows[6][0], @rows[6][1], @rows[6][2], @rows[7][0], @rows[7][1], @rows[7][2], @rows[8][0], @rows[8][1], @rows[8][2]] #7\n @blks[7] = [@rows[6][3], @rows[6][4], @rows[6][5], @rows[7][3], @rows[7][4], @rows[7][5], @rows[8][3], @rows[8][4], @rows[8][5]] #8\n @blks[8] = [@rows[6][6], @rows[6][7], @rows[6][8], @rows[7][6], @rows[7][7], @rows[7][8], @rows[8][6], @rows[8][7], @rows[8][8]] #9 \n solved\n end",
"def generate\n (0..@horizontal_size-1).each do |column|\n (0..@vertical_size-1).each do |row|\n val = Settings.get_random.rand(0..10)\n @map[column][row] = val > 3 ? 1 : 2\n end\n end\n end",
"def main\n\n while line = ARGF.gets do \n next if line.match(\"^#\")\n \n cols = line.chomp.split(/\\s+/)\n \n allelec = [0,0,0,0]\n pos = cols[1] \n cols[3..-1].each do |gt|\n a = gt.split(';')\n 1.upto(4) do |i|\n n = a[i].to_i\n# a[1..-1].each do |n|\n if n > 0\n allelec[i-1] += 1\n end\n # allelec += n.to_i\n end\n end\n \n ga = allelec.select {|g| g > 0}\n if ga.size > 1\n puts line\n# if pos == \"121320556\"\n # $stderr.puts ga.join(\"\\t\")\n # end\n end\n end\nend",
"def matrix_convert_to_0(matrix)\n columns = {}\n row_count = 0\n zero_count = 0\n\n matrix.each_with_index do |row, r|\n row.each_with_index do |cell, c|\n\n #look at a row if you find a zero, save the spot(move this into a hash)\n if cell == 0\n columns[c] = 1\n zero_count = 1\n end\n end\n\n #if zero exists in row, change entire row to zero\n #keep track of how many rows are changed\n if zero_count > 0\n row.each_with_index do |cell, c|\n row[c] = 0\n row_count +=1\n end\n end\n end\n\n if row_count == matrix.length\n return\n end\n\n n = 0\n #for each value in columnshash, change all column values to 0\n columns.each do |c, value|\n matrix.length.times do |r|\n matrix[r][c] = 0\n n += 1\n end\n n = 0\n end\nend",
"def score_word(word) \n points = {\n [\"A\", \"E\", \"I\", \"O\", \"U\", \"L\", \"N\", \"R\", \"S\", \"T\"] => 1,\n [\"D\", \"G\"] => 2,\n [\"B\", \"C\", \"M\", \"P\"] => 3,\n [\"F\", \"H\", \"V\", \"W\", \"Y\"] => 4,\n [\"K\"] => 5,\n [\"J\", \"X\"] => 8,\n [\"Q\", \"Z\"] => 10\n }\n\n score = 0 \n score += 8 if (word.length > 6) && (word.length < 11) \n\n tile_split = word.upcase.split(\"\")\n\n tile_split.each do |letter| \n points.each do |score_chart, point|\n score += point if score_chart.include?(letter) \n end \n end \n return score\nend",
"def row_search \n horizontal_words = []\n search = @@boards_templates[1].to_s.scan(/...../).each_slice(1).to_a\n rows = search.join \n @@boards_templates[0].each { |x| rows.include?(x) ? horizontal_words << x : rows.reverse.include?(x) ? horizontal_words << x : \"No hay palabras en dirección horizontal\" }\n horizontal_words\n end",
"def run\n\n line1 = gets.strip.split(\" \").map!{ |e| e.to_i }\n\n number_of_lines = line1[0]\n m = line1[1]\n k = line1[2]\n q = line1[3]\n\n maxtrix = Hash.new\n number_of_lines.times do |row|\n line = gets.strip.split(\" \").map!{ |e| e.to_i }\n\n m.times do |col|\n maxtrix[[row,col]] = line[col]\n end\n end\n\n last_line = gets.strip.split(\" \").map!{ |e| e.to_i }\n empty_slot = [last_line[0]-1,last_line[1]-1]\n caocao = [last_line[2]-1,last_line[3]-1]\n exit = [last_line[4]-1,last_line[5]-1]\n\n maxtrix[empty_slot] = \"E\"\n maxtrix[caocao] = \"C\"\n maxtrix[exit] = \"D\"\n\n knowledge_base = Hash.new\n\n printmap(number_of_lines, m, maxtrix)\nend",
"def solve(matrix)\n \n count = 0\n (0...matrix.length).each do |i1|\n largest_row_idx = matrix[i1].index(matrix[i1].max)\n unless matrix[i1].max < matrix[i1][largest_row_idx]\n count += 1\n end\n \n end\n return count \nend"
] |
[
"0.6071914",
"0.6060902",
"0.5704503",
"0.5675834",
"0.5618278",
"0.5469362",
"0.5383137",
"0.53829545",
"0.5379066",
"0.53445876",
"0.5334156",
"0.530029",
"0.5285457",
"0.5284604",
"0.5281336",
"0.52338374",
"0.5212867",
"0.5174232",
"0.51719266",
"0.5152324",
"0.51519656",
"0.51498586",
"0.514257",
"0.5138471",
"0.5127859",
"0.5118014",
"0.50920963",
"0.5041549",
"0.5037414",
"0.50168616",
"0.49937102",
"0.4982888",
"0.49766597",
"0.49585927",
"0.49560156",
"0.49537298",
"0.4949763",
"0.4944809",
"0.49362117",
"0.49301034",
"0.49299186",
"0.4924419",
"0.49218434",
"0.4918663",
"0.49107388",
"0.48975134",
"0.48926544",
"0.4886039",
"0.48628774",
"0.4862682",
"0.48626587",
"0.4857884",
"0.4849555",
"0.48388258",
"0.48332924",
"0.4829038",
"0.48271352",
"0.48069668",
"0.4803784",
"0.48029792",
"0.479815",
"0.4795728",
"0.47950622",
"0.47931728",
"0.47929662",
"0.47925326",
"0.4787612",
"0.47764003",
"0.47718975",
"0.47603837",
"0.47559986",
"0.47559312",
"0.47408167",
"0.47374517",
"0.47370222",
"0.473496",
"0.47345558",
"0.4727331",
"0.4723734",
"0.4723631",
"0.4711432",
"0.4707943",
"0.47049272",
"0.46987215",
"0.46956673",
"0.46951526",
"0.46906644",
"0.46857923",
"0.468558",
"0.46844655",
"0.46836066",
"0.46825618",
"0.4675524",
"0.4671467",
"0.46612534",
"0.46561414",
"0.46530023",
"0.46529257",
"0.46505395",
"0.46483937"
] |
0.5937408
|
2
|
Accumulate current permutation search result counts into the reports summary totals. For example: if the total column score was 9 for the current rotation of the rows, summary_totals[9] would be incremented to reflect that a matrix solution was found with score = 9
|
def accumulate_summary_totals( score )
@summary_totals[score] ||= 0
@summary_totals[score] += 1
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def summarize_results(results)\n sort_order = ['scenario', 'step', 'failed', 'flaky', 'undefined', 'skipped', 'pending', 'passed']\n\n ['scenario', 'step'].map do |group|\n group_results = results.grep(/^\\d+ #{group}/)\n next if group_results.empty?\n\n sums = sum_up_results(group_results)\n sums = sums.sort_by { |word, _| sort_order.index(word) || 999 }\n sums.map! do |word, number|\n plural = \"s\" if (word == group) && (number != 1)\n \"#{number} #{word}#{plural}\"\n end\n \"#{sums[0]} (#{sums[1..-1].join(\", \")})\"\n end.compact.join(\"\\n\")\n end",
"def summaries\n header = summarize_per.header\n summaries = default_summaries\n operand.each { |tuple| summaries.summarize_by(header, tuple) }\n summaries\n end",
"def total\n sum = 0\n\n @four_result.each do |result|\n sum += result\n end\n @six_result.each do |result|\n sum += result\n end\n @eight_result.each do |result|\n sum += result\n end\n @ten_result.each do |result|\n sum += result\n end\n @twelve_result.each do |result|\n sum += result\n end\n @twenty_result.each do |result|\n sum += result\n end\n @percentile_result.each do |result|\n sum += result\n end\n\n sum\n end",
"def calcAdjustment(matrix,totalGenes)\n #score adjustment for col/row sum\n colAdj = 0\n matrix.colSums.each{|sum|\n colAdj += Math.log2star(sum)\n }\n \n rowAdj = 0\n matrix.rowSums.each{|sum|\n rowAdj += Math.log2star(sum)\n }\n\n # each row gets sorted by its sum \n rowSortAdj = matrix.rowSums.calcUniqPermutationsLog2\n colSortAdj = matrix.colSums.calcUniqPermutationsLog2\n sortAdj = rowSortAdj + colSortAdj\n\n # score adjustment for which set of N genes to use \n # (think \"multiple testing\" via binomial coefficient)\n testAdj = Math.binomCoefficientLog2(totalGenes,matrix.numRows)\n\n return colAdj + rowAdj + testAdj +sortAdj\nend",
"def opc_total()\n opx_err(\"Command \\\"total\\\" ignored, Tabulator state: EMPTY\") if opx_empty_state?()\n tab = opx_instantiate_tabulator()\n state = opc_state(tab, true)\n if ([\"ACCUMULATING\", \"DONE\"].include?(state))\n if (state == \"DONE\")\n opx_print(\"Writing Tabulator Spreadsheet: \" +\n \"#{TABULATOR_SPREADSHEET_FILE}\\n\")\n lines = opx_file_write_spreadsheet(tab, true)\n #opx_print(\"\\nFinal Vote Count Data (CSV Spreadsheet Format):\\n\\n\")\n #opx_print(lines)\n else\n lines = opx_file_write_spreadsheet(tab, false)\n #opx_print(\"\\nPartial Vote Count Data (CSV Spreadsheet Format):\\n\\n\")\n #opx_print(lines)\n opx_print(\"\\n\")\n opx_err(\"Command \\\"total\\\" REJECTED, Counts MISSING (See Above)\")\n end\n end\n end",
"def print_summary\n puts \"\\n\\nScore : # Instances\\n\" << (\"=\" * 19)\n @summary_totals.each_with_index { |value, index| puts \" %5d:%8d\\n\" % [index, value] unless value.nil? }\n puts \"\\n** End of Report\"\n end",
"def print_details( result_counts, score )\n puts ('=' * 10) << \"\\n\"\n @groups.each_with_index { |group, index| group.each { |row| puts \"#{row} Group \" << (index + 1).to_s } }\n puts '-' * (@groups[0][0].length * 3)\n puts \"#{result_counts} Score\"\n puts \"\\nTotal Score: #{score}\\n\"\n end",
"def calculate_total_seqs\n file_summaries.sum(&:seqs)\n end",
"def summarize_suite(suite, tests)\n summary = Hash.new(0)\n summary[:name] = suite.to_s\n tests.each do |test|\n summary[:\"#{result(test)}_count\"] += 1\n summary[:assertion_count] += test.assertions\n summary[:test_count] += 1\n summary[:time] += test.time\n end\n summary[:has_errors_or_failures] = (summary[:fail_count] + summary[:error_count]) > 0\n summary[:has_skipps] = summary[:skip_count] > 0\n summary\n end",
"def summary(results, session_count)\n # header\n method = :ok\n headers = [\"Total: #{session_count}\"]\n messages = []\n\n headers << \"Ok: #{results[:ok].size}\" unless results[:ok].empty?\n\n [:warning, :critical].each do |type|\n next if results[type].empty?\n method = type\n label = type.to_s.capitalize\n headers << \"#{label}: #{results[type].size}\"\n messages << [label, results[type].compact.sort.join(\"\\n\\n\")]\n end\n\n [method, [headers, messages].flatten]\n end",
"def total_count\n @total_count ||= @possibility_distribution.inject(0) { |sum, n| sum + n.last }\n end",
"def total_summary\n\n products = {}\n products.store(:item_cost, item_cost)\n products.store(:extras_cost, extras_cost)\n\n supplements = {}\n supplements.store(:pick_up_place, pickup_place_cost)\n supplements.store(:return_place, return_place_cost)\n supplements.store(:time_from_cost, time_from_cost)\n supplements.store(:time_to_cost, time_to_cost)\n supplements.store(:driver_age_cost, driver_age_cost)\n supplements.store(:category_supplement_1, category_supplement_1_cost)\n supplements.store(:category_supplement_2, category_supplement_2_cost)\n supplements.store(:category_supplement_3, category_supplement_3_cost)\n supplements.store(:supplement_1, supplement_1_cost)\n supplements.store(:supplement_2, supplement_2_cost)\n supplements.store(:supplement_3, supplement_3_cost)\n\n deposit = {}\n deposit.store(:product_deposit_cost, product_deposit_cost)\n\n totals = {}\n totals.store(:total_cost, total_cost)\n totals.store(:total_paid, total_paid)\n totals.store(:total_pending, total_pending)\n\n summary = {products: products,\n supplements: supplements,\n deposit: deposit,\n totals: totals }\n\n end",
"def summarizeMain(subKeys = nil)\n counts = Hash.new\n total = 0\n @role.keys.each {|name|\n if (subKeys.nil? || subKeys.include?(name))\n category = @role[name].first\n if (counts[category].nil?)\n counts[category] = [name]\n else\n counts[category].push(name)\n end\n total += 1.0\n end\n }\n return counts, total\n end",
"def total\n @frame.inject(0){|rez, item| item ? rez + item[:score] : rez }\n end",
"def total_hits_count\n return top_hits_count + all_hits_count\n end",
"def calcular_total hash\n p hash.inject(0) { |sum, tuple| sum += tuple[1] }\n end",
"def total_output\n @outputs.inject(:+)\n end",
"def summarize_results!(all_results)\n \t summaries = {}\n \t all_results.each do |paramset, results|\n \t File.open(@dir + \"/results-#{param_string(paramset)}.yaml\", 'w' ) do |out|\n \t\t\tYAML.dump(results, out)\n \t\tend\n \t\tsummaries[paramset] = {}\n \t\t# create an array of arrays\n \t\tres = results.keys.map do |key| \n \t\t # calculate stats\n \t\t a = results[key]\n \t\t if a.all? {|el| el.is_a? Numeric }\n \t\t summaries[paramset][\"#{key} mean\"] = Stats::mean(a)\n \t\t summaries[paramset][\"#{key} SD\"] = Stats::standard_deviation(a)\n \t\t [key] + a + [Stats::mean(a), Stats::standard_deviation(a)]\n \t\t else\n \t\t [key] + a + [\"--\", \"--\"]\n \t end\n \t\t end\n\t\t \n \t\t ls = results.keys.map{|v| [7, v.to_s.length].max }\n \t\t\n \t\tls = [\"Std Deviation\".length] + ls\n \t\tres = header_column + res\n \t\tres = res.transpose\n \t\tout = build_table res, ls\n \t\tFile.open(@dir + \"/#{paramset}-summary.mmd\", 'w') do |f|\n \t\t f << \"## Results for #{@experiment} with parametres #{param_string(paramset, \", \")} ##\\n\\n\"\n \t\t f << out\n \t\t end\n\t\t end\n\t\t \n\t\t # Build CSV file with all of the results\n\t\t #puts summaries.inspect\n\t\t \n\t\t summaries = summaries.to_a\n #puts summaries.inspect\n\t\t keys1 = summaries.first.first.keys\n\t\t keys2 = summaries.first.last.keys\n\t\t #puts keys1.inspect, keys2.inspect, \"=====\"\n CSV.open(@dir + \"/results.csv\", \"w\") do |csv|\n \t csv << keys1 + keys2\n \t summaries.each do |summary|\n \t #puts summary.first.inspect\n \t #puts summary.first.values_at(*keys1).inspect + summary.last.values_at(*keys2).inspect\n \t csv << summary.first.values_at(*keys1) + summary.last.values_at(*keys2)\n \t \n \t end\n \t end\n\t\t \n\t end",
"def total_score\n total = 0\n @cards.each do |card|\n total += card.value\n end\n\n sorted_cards = @cards.sort\n\n straights = get_straight(sorted_cards).reverse\n straights.each do |straight|\n total += 40\n sorted_cards.slice!(straight[0]..straight[1])\n end\n\n three_cards = get_number_of_a_kind(sorted_cards, 3)\n three_cards.each do |three|\n total += 20\n sorted_cards.slice!(three[0]..three[1])\n end\n\n pairs = get_number_of_a_kind(sorted_cards, 2)\n pairs.each do |pair|\n total += 10\n sorted_cards.slice!(pair[0]..pair[1])\n end\n\n total\n end",
"def getTotals(page)\n\t\ttotalsRow = page.css(\"table.dbd\")[0].css(\"tr.toprow\").last\n\t\tgames = totalsRow.css(\"td.letter\")[0].text.to_i\n\t\t\n\t\t# From Totals Row\n\t\tab = totalsRow.css(\"td.number\")[1].text.to_i\n\t\truns = totalsRow.css(\"td.number\")[2].text.to_i\n\t\thits = totalsRow.css(\"td.number\")[3].text.to_i\n\t\tdbl = totalsRow.css(\"td.number\")[4].text.to_i\n\t\ttpl = totalsRow.css(\"td.number\")[5].text.to_i\n\t\thr = totalsRow.css(\"td.number\")[6].text.to_i\n\t\trbi = totalsRow.css(\"td.number\")[7].text.to_i\n\t\tbb = totalsRow.css(\"td.number\")[8].text.to_i\n\t\thbp = totalsRow.css(\"td.number\")[10].text.to_i\n\t\tcs = totalsRow.css(\"td.number\")[13].text.to_i\n\t\tsh = totalsRow.css(\"td.number\")[14].text.to_i\n\t\tsf = totalsRow.css(\"td.number\")[15].text.to_i\n\t\tgdp = totalsRow.css(\"td.number\")[16].text.to_i\n\t\t\t\t\n\t\t# From Summary Row\n\t\tba = page.css(\"table.dbd\")[1].css(\"tr\")[1].css(\"td\")[0].text.to_f\n\t\toba = page.css(\"table.dbd\")[1].css(\"tr\")[1].css(\"td\")[1].text.to_f\n\t\tslug = page.css(\"table.dbd\")[1].css(\"tr\")[1].css(\"td\")[2].text.to_f\n\t\tops = oba.to_f + slug.to_f\n\t\t\n\t\tsolution = [games,ab,runs,hits,dbl,tpl,hr,rbi,bb,hbp,cs,sh,sf,gdp,ba,oba,slug,ops]\n\t\tvorp = calcVORP(solution)\n\t\tsolution << vorp\n\t\treturn solution\n\tend",
"def total\n @total ||= (\n tally = 0\n each do |w|\n tally += w.count\n end\n tally\n )\n end",
"def total\n #use group matches instead of numFound for grouped response\n if response[:numFound].nil? \n self[:grouped][blacklight_config['index']['group']]['matches'].to_s.to_i \n else \n response[:numFound].to_s.to_i\n end\n end",
"def summarise()\n summary = Hash.new\n page_count = 0\n\n @nodes.each {|node|\n if summary.include?(node['content_type'])\n summary[node['content_type']] += 1\n else\n summary[node['content_type']] = 1\n end\n }\n\n summary.keys.sort.each {|node_type|\n count = summary[node_type].to_i\n page_count += count\n puts \"%-50s: %s\" % [node_type, count]\n }\n\n puts \"%-50s: %s\" % ['Total pages:', page_count]\n puts \"See output CSV in #{csv_output_path}\"\n end",
"def calc_stats\n #puts \"bad_biz = #{@bad_business_records.length}\"\n #puts \"bad_user = #{@bad_user_records.length}\"\n #puts \"good_biz = #{@good_business_records.length}\"\n #puts \"good_user = #{@good_user_records.length}\"\n \n @total_rec_cnt = @bad_business_records.length + @bad_user_records.length +\n\t @good_business_records.length + @good_user_records.length\n @well_formed_rec_cnt = @good_business_records.length + @good_user_records.length\n @malformed_rec_cnt = @bad_business_records.length + @bad_user_records.length\n @biz_rec_cnt = @businesses.length\n @user_rec_cnt = @users.length\n end",
"def get_cout_total_passages\n\t sum = 0\n\t self.putoparcelles.each do |putoparcelle|\n \t\tsum += putoparcelle.pulve.get_cout_total_passage_col(self)\n end\n sum\n end",
"def summary\n \"Results: #{results[:critical].size} critical, \" \\\n \"#{results[:warning].size} warning, \" \\\n \"#{results[:unknown].size} unknown, #{results[:ok].size} ok\"\n end",
"def total\n roll_all.reduce(&:+)\n end",
"def update_totals\n # update_adjustments\n self.payment_total = payments.completed.map(&:amount).sum\n self.item_total = line_items.map(&:amount).sum\n \n self.adjustment_total = adjustments.eligible.map(&:amount).sum\n self.total = item_total + adjustment_total + gift_packaging_total\n end",
"def total_entries\n populate\n return 0 if @results[:total_found].nil?\n \n @total_entries ||= @results[:total_found]\n end",
"def total_count #:nodoc:\n total == 1 && !@group.nil? && @group['matches'] > 1 ? @group['matches'] : total\n end",
"def total\n @total ||= (\n tally = 0\n each do |b|\n tally += b.count\n end\n tally\n )\n end",
"def print_summary\n stats = [statistics[:total_code_loc], statistics[:total_spec_loc]]\n stats.push(stats[1].to_f / stats[0].to_f)\n \n puts \" Code LOC: %s Test LOC: %s Code to Test Ratio: 1:%1.1f\" % stats\n puts\n end",
"def hits_overall\n @categories.inject(0) { |sum, (name, cat)| sum + cat[:hits] }\n end",
"def summary\n \n end",
"def output_summary\n output_summary = \"\"\n unless $matches_played.empty?\n output_summary << \"Team | MP | W | D | L | P \"\n output_summary << \" \\n \"\n\n # sorting the results on the basis of points if points are greater than 0\n $points = $points.sort.to_h\n $points.each do |team, val|\n output_summary << \"#{team} | #{$matches_played[team]} | #{$wins[team] || 0} | #{$draws[team] || 0} | #{$loses[team] || 0} | #{val || 0}\"\n output_summary << \" \\n \"\n end\n\n # finding teams with 0 points\n $matches_played.delete_if { |k,_| $points.key?(k) }\n\n # output the teams with 0 points\n $matches_played.each do |team, val|\n output_summary << \"#{team} | #{val} | #{$wins[team] || 0} | #{$draws[team] || 0} | #{$loses[team] || 0} | #{$points[team] || 0}\"\n output_summary << \" \\n \"\n end\n end\n output_summary\nend",
"def update_totals\n # update_adjustments\n self.payment_total = payments.completed.map(&:amount).sum\n \n self.item_total = order_items.map(&:amount).sum\n self.billing_total = order_items.map(&:cost).sum\n self.customer_total = item_total\n self.full_total = order_items.map(&:full).sum\n end",
"def row_totals(rows_in, tot_out)\n\t\tfor logrow in rows_in\n\t\t\t@numeric_col.each do |fld|\n\t\t\t\ttot_out[fld] += logrow.send(fld) if logrow.send(fld)\n\t\t\tend\n\t\tend\n\t\t@numeric_col.each do |fld|\n\t\t\ttot_out[fld] = '' if tot_out[fld] == 0\n\t\tend\n\tend",
"def update_totals\n # update_adjustments\n self.payment_total = payments.completed.map(&:amount).sum\n self.item_total = line_items.map(&:amount).sum\n self.adjustment_total = adjustments.eligible.map(&:amount).sum\n self.total = item_total + adjustment_total\n end",
"def accumulate_numbers(ranking)\n @count = 0\n ranking.each { |entry|\n @count += entry[1]\n }\n end",
"def calculate_score\n @results.collect { |mir| mir.send(@column.to_sym) }.sum\n end",
"def summary(permutations = 99, seed = nil)\n p_val = mc(permutations, seed)\n { stat: stat, p: p_val }\n end",
"def totals\n @totals.map do |action, values|\n if values.is_a?(Array) && !values.empty?\n values.map do |value|\n \"#{action}[]=#{value}\"\n end\n end\n end.join('&')\n end",
"def total_score(play)\n sum = 0;\n play.decision_array.each_with_index{|v, i|\n sum += 1 if v == decision_array[i] && i != 0 # exclude an example\n }\n sum\n end",
"def calculate_results\n Repository::Config.new(@repo, @log, @process, @type).status(5) {\n files = files_to_analyze\n puts '-----Files to analyze done (Step 1)'\n files = prepare_files_to_rate files\n puts '-----Prepare files to rate done (Step 2)'\n files = count_total_lines files\n puts '-----Count total lines done (Step 3)'\n files = count_errors files\n puts '-----Count errors done (Step 4)'\n files = grade_categories files\n puts '-----Grade categories done (Step 5)'\n files = grade_files files\n puts '-----Grade files done (Step 6)' + files.to_s\n gpa = grade_repo files\n puts '-----Grade repos done (Step 7)' + gpa.to_s\n gpa_percent = get_overall_grades files\n puts '-----Grade overall percentage done (Step 8)' + gpa_percent.to_s\n cat_issues = get_category_issues files\n puts '-----Get categories issues done (Step 9)' + cat_issues.to_s\n store_cat_issues cat_issues\n puts '-----Store category issues done (Step 10)'\n store_grades gpa, gpa_percent\n puts '-----Store grades done (Step 11)'\n }\n end",
"def total_results\n @set['totalResults'].to_i\n end",
"def count_results(result_array)\n results = empty_counter\n result_array.each do |topic|\n topic.keys.each {|key| results[key] += topic[key]}\n end\n results\n end",
"def total_num_assignment_teams\n assignment_team_counts.inject(:+)\n end",
"def apply_roll_to_total(roll_reason, roll_result)\n case roll_reason\n when :basic, :reroll_new_die, :reroll_new_keeper, :reroll_replace\n @total = roll_result\n when :reroll_add\n @total += roll_result\n when :reroll_subtract\n @total -= roll_result\n when :reroll_use_best\n @total = [@value, roll_result].max\n when :reroll_use_worst\n @total = [@value, roll_result].min\n end\n end",
"def total_results\n totalItems\n end",
"def total_score\n\t\t0 + score_one.to_i + score_two.to_i + score_three.to_i + score_four.to_i\n\tend",
"def summary\n calculate\n\n num_width = [@num_files, @num_items].max.to_s.length\n undoc_width = [\n @undoc_attributes,\n @undoc_classes,\n @undoc_constants,\n @undoc_items,\n @undoc_methods,\n @undoc_modules,\n @undoc_params,\n ].max.to_s.length\n\n report = RDoc::Markup::Verbatim.new\n\n report << \"Files: %*d\\n\" % [num_width, @num_files]\n\n report << \"\\n\"\n\n report << \"Classes: %*d (%*d undocumented)\\n\" % [\n num_width, @num_classes, undoc_width, @undoc_classes]\n report << \"Modules: %*d (%*d undocumented)\\n\" % [\n num_width, @num_modules, undoc_width, @undoc_modules]\n report << \"Constants: %*d (%*d undocumented)\\n\" % [\n num_width, @num_constants, undoc_width, @undoc_constants]\n report << \"Attributes: %*d (%*d undocumented)\\n\" % [\n num_width, @num_attributes, undoc_width, @undoc_attributes]\n report << \"Methods: %*d (%*d undocumented)\\n\" % [\n num_width, @num_methods, undoc_width, @undoc_methods]\n report << \"Parameters: %*d (%*d undocumented)\\n\" % [\n num_width, @num_params, undoc_width, @undoc_params] if\n @coverage_level > 0\n\n report << \"\\n\"\n\n report << \"Total: %*d (%*d undocumented)\\n\" % [\n num_width, @num_items, undoc_width, @undoc_items]\n\n report << \"%6.2f%% documented\\n\" % percent_doc\n report << \"\\n\"\n report << \"Elapsed: %0.1fs\\n\" % (Time.now - @start)\n\n RDoc::Markup::Document.new report\n end",
"def results(ballots, candidates)\n\n candidates.each do |can, points|\n ballots.each do |ballot|\n ballot.each do |num, vote|\n if can == vote && num == 1\n candidates[can] += 4\n elsif can == vote && num == 2\n candidates[can] += 2\n elsif can == vote && num == 3\n candidates[can] += 1\n end\n end\n end\n end\n return candidates\n\nend",
"def addRows(matrixPassed)\n rowSum = 0\n rowLen = 0\n rowIndex = 0\n matrixPassed.each do |sub|\n sub.each do |elements|\n rowSum = rowSum + elements\n rowLen = rowLen + 1\n end\n rowAvg = rowSum/rowLen\n puts \"Row# #{rowIndex+1} rowSum = #{rowSum}, rowLen = #{rowLen}, rowAvg = #{rowAvg}\"\n rowSum = 0\n rowLen = 0\n rowIndex = rowIndex + 1\n end\nend",
"def print_course_class_total_item_counts\n puts \"=> Course Class Total Item Counts\"\n @course_classes.each do |course_class|\n puts \"% 20s % 4d\" % [ course_class, course_class.count ]\n end\n end",
"def sum_counts(term,counts,labels)\n positive = counts.map.with_index { |e, i| e if i % 2 == 0 }.compact.inject(0) { |e, s| e + s }\n negative = counts.map.with_index { |e, i| e if i % 2 != 0 }.compact.inject(0) { |e, s| e + s }\n report do |reporter|\n if positive > 0\n labels = labels.map{|name| \"#{name}:%i/%i\" }.join(\",\")\n count_string = \" %-20s #{labels} -> %i/%i/%.1f\" %\n [term.to_ruby, *counts, positive, positive+negative, (positive/(positive+negative).to_f*100)]\n reporter.call(count_string.hl(:green))\n else\n reporter.call(\" #{term.to_ruby}\".hl(:red))\n end\n end\n return positive, negative\n end",
"def total_members_by(geo, results)\n totals = results.each_with_object(Hash.new(0)) do |res,counts|\n next unless [\"us\",\"ca\"].include?(res.country)\n counts[res.send(geo.to_sym)] += res.members.to_i\n end\n puts \"TOTAL: #{totals.values.inject(:+)}\"\n \n totals = totals.sort_by { |geo,count| -count }\n puts \"Total members by #{geo.to_s}: \"\n totals.each do |k,v|\n puts \"#{k}: #{v}\"\n end\nend",
"def aggregate_stats(valid_token_result)\n r = {}\n valid_token_result.map do |type|\n type.values.last.values.first\n end.each do |t|\n r.merge!(t) { |k,old,new| old + new }\n end\n\n # recompute percentages\n r[:unique_percent_valid] = r[:unique_valid].to_f / r[:unique_tested]\n r[:unique_coverage] = r[:unique_tested].to_f / r[:unique_candidates]\n r[:total_percent_valid] = r[:total_valid].to_f / r[:total_tested]\n r[:total_coverage] = r[:total_tested].to_f / r[:total_candidates]\n r\nend",
"def total_per_component(&block)\n @scms.sort.each do | name, linehash |\n output name, 0, linehash.values.sum, &block\n end\n end",
"def totals\n Array.new(dimensions.size) + report[\"data\"][\"totals\"][0][\"values\"]\n end",
"def update_total_score\n @total_score += @score\n end",
"def summarise!( header )\n load( summarise( header ).to_a.unshift [ header, 'Count' ] )\n end",
"def summary_report(problems)\n summary_table = summary_header\n i = 0\n\n problems.each do |file, problem_list|\n report_line = summary_file_line(file, problem_list)\n\n report_line = if i % 2 == 1\n on_intense_black { report_line }\n else\n bold { report_line }\n end\n\n summary_table << '# ' << report_line << reset << \"|\\n\"\n i += 1\n end\n\n summary_table << line\n summary_table << summary_level_totals(problems)\n summary_table << '# ' << bold{ summary_first_col('TOTAL', 67) }\n summary_table << '|'\n summary_table << bold { total_problems(problems).to_s.rjust(6) }\n summary_table << \" |\\n\"\n summary_table << line\n\n puts summary_table\n end",
"def weight_results(results)\n weights = Hash.new { |hash, key| hash[key] = 0 }\n\n results.each do |set|\n set.each do |item|\n weights[item.name] += item.hits\n end\n end\n\n weights\n end",
"def sum_overall\n @categories.inject(0.0) { |sum, (name, cat)| sum + cat[:sum] }\n end",
"def summarize_results(fn)\n body = \"\"\n results = get_test_results(fn)\n total = results[:error].length + results[:fail].length + results[:pass].length\n total_failed = results[:fail].length + results[:error].length\n\n body << \"Tests Executed: \" + total.to_s + \"\\n\"\n body << \"Passed: \" + results[:pass].length.to_s + \"\\n\"\n body << \"Failed: \" + results[:fail].length.to_s + \"\\n\"\n body << \"Error: \" + results[:error].length.to_s + \"\\n\"\n body << ((results[:pass].length.to_f/total).round(4) * 100).to_s + \"% Passed\" + \"\\n\"\n\n if results[:error].length != 0 || results[:fail].length != 0\n body << \"\\n\"\n body << \"Failed/Errored Tests:\\n\"\n (results[:error].concat(results[:fail])).each do |test|\n body << \" #{test}\\n\"\n end\n end\n \n puts \"-\" * 50\n puts body\n puts \"-\" * 50\n \n summary = {}\n summary[:body] = body\n \n bottom_line = \"#{total_failed}/#{total} failed\"\n summary[:bottom_line] = bottom_line\n \n return summary\n end",
"def total\n count\n end",
"def total\n if @dirty\n @total = 0\n @frequencies.each_value { |freq| @total += freq }\n end\n\n return @total\n end",
"def summarize!\n %i[critical warning unknown].each do |status|\n send(status, summary) unless results[status].empty?\n end\n ok(summary)\n end",
"def summary; end",
"def summary; end",
"def summary; end",
"def summary; end",
"def summary\n stats = Hash.new { |h,k| h[k] = {} }\n @stats.each do |field, actions|\n actions.each do |action|\n col = action.column_name\n ## register the value of this \"stats\" for the column name\n action.iterate do |ts,value|\n stats[ts][col] = value\n end\n end\n end\n return stats\n end",
"def summarize_suite(suite, tests); end",
"def summarize_suite(suite, tests); end",
"def running_total(numbers)\n sum = 0\n running_sums = []\n numbers.each_with_object(running_sums) do |number, array|\n sum += number\n array << sum\n end\n \n running_sums\nend",
"def result_summary_msg(result_type)\n if result_type == :pass && all_pass?\n all_pass_result_summary_msg\n else\n \"#{send(\"#{result_type}_result_count\")} #{result_type}\"\n end\n end",
"def summate_activity_counts\n activity_count = 0\n all_user_projects_subscriptions.find_each do |subscription|\n next if subscription.empty_summary?\n if count = subscription.summary.values.first[:count].to_i\n activity_count += count\n end\n end\n activity_count\n end",
"def score_factor_count\n com_count = self.complaints.finished.count\n dep_review_count = count_scorable_department_reviews\n city_review_count = count_scorable_city_reviews\n petition_count = self.petitions.finished.count\n return score_count = com_count + dep_review_count + city_review_count + petition_count\n end",
"def total_count\n raw_history['total_results']\n end",
"def overall_total\n puts \"Portfolio Total: $#{sprintf('%.2f', @all_totals)}\"\n end",
"def inject_total(unique_values, &block)\n unique_values.inject(0) do |total, num|\n n_in_code = count_hits(num, secret_code)\n n_in_guess = count_hits(num, guess)\n total += block.call(n_in_code, n_in_guess)\n end\nend",
"def result_summary\n options = { style: 'font-size: 25px;' }\n summary = if matches_exist?\n [bold_tag(pluralize(result_count, 'result'), options), filter_text]\n else\n [\n bold_tag(@query, options),\n 'not found -',\n pluralize(result_count, 'similar result'),\n filter_text\n ]\n end\n safe_join(summary, ' ')\n end",
"def summary(args, options)\n\n experiments = options.experiments.split(',')\n machines = options.machines.split(',')\n\n data = Ppbench::load_data(args)\n filtered_data = Ppbench::filter(\n data,\n experiments: experiments,\n machines: machines\n )\n aggregated_data = Ppbench::aggregate(filtered_data)\n\n rows = []\n aggregated_data.each do |experiment, machines|\n machines.each do |machine, data|\n mtr = data.map { |e| e[:transfer_rate] }.median / 1000 # median transfer rate\n tpr = data.map { |e| e[:tpr] }.median # median round trip latency\n rps = 1000 / tpr # median request per second\n\n rows << [experiment, machine, data.count, \"%.2f\" % mtr, \"%.2f\" % rps, \"%.2f\" % tpr]\n end\n rows << :separator\n end\n rows.pop\n\n print(\"We have data for: \\n\")\n table = Terminal::Table.new(:headings => ['Experiment', 'Machine', 'Samples', 'Transfer (kB/s)', \"Requests/sec\", \"Latency (ms)\"], :rows => rows)\n table.align_column(2, :right)\n table.align_column(3, :right)\n table.align_column(4, :right)\n table.align_column(5, :right)\n print(\"#{table}\\n\")\nend",
"def total_score \n \t\t@scores_array.reduce(0, :+) \n\tend",
"def aggregate(query)\n #query.model.last_query = query\n #y query\n _layout = layout(query.model)\n opts = query.fmp_options\n #opts[:template] = self.class.fmresultset_template_path\n prms = query.to_fmp_query\n #[prms.empty? ? _layout.all(:max_records=>0).foundset_count : _layout.count(prms)]\n [prms.empty? ? _layout.view.total_count : _layout.count(prms)]\n end",
"def summary(profile_report, num_compliant, num_non_compliant)\n report = {\n 'compliant' => num_compliant,\n 'non_compliant' => num_non_compliant\n }\n\n if profile_report['documented_missing_parameters']\n report['documented_missing_parameters'] = profile_report['documented_missing_parameters'].count\n end\n\n if profile_report['documented_missing_resources']\n report['documented_missing_resources'] = profile_report['documented_missing_resources'].count\n end\n\n total_checks = num_non_compliant + num_compliant\n report['percent_compliant'] = total_checks == 0 ? 0 : ((num_compliant.to_f/total_checks) * 100).round(0)\n\n return report\nend",
"def count_total()\n self.regulatory_elements.count\n end",
"def summary\n end",
"def summary\n end",
"def sum_probability_matrices(*args)\r\n result = Array.new(@length) { Array.new(@teams, 0) }\r\n (0..@length - 1).each do |x|\r\n (0..@teams - 1).each do |y|\r\n (0..args.size - 1).each do |z|\r\n result[x][y] += args[z][x][y]\r\n end\r\n end\r\n end\r\n result\r\n end",
"def summarize\n print \"# of asks: #{ask_count}\\n# of bids: #{bid_count}\\nAsk volume: #{ask_volume.to_s('F')}\\nBid volume: #{bid_volume.to_s('F')}\\n\"\n $stdout.flush\n end",
"def allotment_total_of_research\n allotment_total = 0\n researches.each do |research|\n allotment_total += research.allotment unless research.allotment.blank?\n end\n return allotment_total\n end",
"def get_cout_total_produits\n\t sum = 0\n\t self.putoparcelles.each do |putoparcelle|\n \t\tputoparcelle.pulve.putoproduits.each do |putoproduit|\n \t\t\tsum += putoproduit.get_cout_total_parcelle(self)\n end\n end\n sum\n end",
"def summary\n s = tests.keys.size\n puts \"\\n#{s} tests, #{@success_count} succeeded, #{@failure_count} failed\"\n end",
"def total_reps\n\t\ttotal_reps = self.reps1 + self.reps2 + self.reps3 \t\n\tend",
"def get_alternative_total_score()\n # TODO The method get_total_score() above does not seem correct. Replace with this method.\n total_score = 0\n\n self.scores.each { |score| total_score = total_score + score.score }\n\n total_score\n end",
"def print_total_score\n calculate_score\n end",
"def num_submatrix_sum_target(matrix, target)\n row = matrix.size\n col = matrix[0].size\n (0...row).each do |i|\n (1...col).each do |j|\n matrix[i][j] += matrix[i][j - 1]\n end\n end\n res= 0\n (0...col).each do |i|\n (i...col).each do |j|\n counter = {}\n counter[0] = 1\n curr = 0\n (0...row).each do |k|\n curr += matrix[k][j] - (i > 0 ? matrix[k][i -1] : 0)\n res += counter.fetch(curr - target, 0) #getOrDefault\n counter[curr] = counter.fetch(curr, 0) + 1\n end\n end\n end\n res\nend",
"def total_visit\n parsed_result.each do |result|\n visit_hash[result.first] = result.last.count\n end\n visit_hash.sort_by{|k,v| v}.reverse.to_h\n end"
] |
[
"0.60953057",
"0.600039",
"0.58985794",
"0.58219343",
"0.577207",
"0.57419056",
"0.5726415",
"0.5687661",
"0.56077826",
"0.5471726",
"0.54679525",
"0.5459991",
"0.54142916",
"0.5409908",
"0.5407839",
"0.5400387",
"0.5379317",
"0.5376566",
"0.5373155",
"0.537284",
"0.53650963",
"0.5358947",
"0.53265",
"0.5302608",
"0.52945894",
"0.5289429",
"0.52755725",
"0.52687407",
"0.5265879",
"0.5264313",
"0.52401394",
"0.523666",
"0.52243775",
"0.52080375",
"0.52065057",
"0.5202578",
"0.51969177",
"0.5195851",
"0.51889473",
"0.5180389",
"0.5176212",
"0.5173056",
"0.51686513",
"0.5168077",
"0.5166684",
"0.5166231",
"0.5163914",
"0.51275533",
"0.51179",
"0.5113621",
"0.5106866",
"0.5105867",
"0.51010287",
"0.50930035",
"0.50915563",
"0.5084243",
"0.50834304",
"0.5077381",
"0.50769854",
"0.50762033",
"0.5073891",
"0.5070578",
"0.50670743",
"0.506535",
"0.50614405",
"0.50549763",
"0.5049653",
"0.5037775",
"0.5036872",
"0.5036872",
"0.5036872",
"0.5036872",
"0.5036674",
"0.50333846",
"0.50333846",
"0.50286996",
"0.5021213",
"0.50103825",
"0.50099736",
"0.5006505",
"0.5005382",
"0.5002563",
"0.49979243",
"0.498675",
"0.4986536",
"0.49840558",
"0.4980607",
"0.49752918",
"0.49714577",
"0.49714577",
"0.49644613",
"0.49569097",
"0.4955309",
"0.4954698",
"0.49490458",
"0.49472383",
"0.49472016",
"0.4942433",
"0.49369773",
"0.4934811"
] |
0.7095955
|
0
|
Print out the details of each analysis we are looking for
|
def print_details( result_counts, score )
puts ('=' * 10) << "\n"
@groups.each_with_index { |group, index| group.each { |row| puts "#{row} Group " << (index + 1).to_s } }
puts '-' * (@groups[0][0].length * 3)
puts "#{result_counts} Score"
puts "\nTotal Score: #{score}\n"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def analyze\n format_results\n end",
"def print_summary\n stats = [statistics[:total_code_loc], statistics[:total_spec_loc]]\n stats.push(stats[1].to_f / stats[0].to_f)\n \n puts \" Code LOC: %s Test LOC: %s Code to Test Ratio: 1:%1.1f\" % stats\n puts\n end",
"def display_results\n print_header\n print_detailed_report\n write_csv_report\n display_status\n end",
"def testi_display_result\n\t\t\tputs testi_stats\n\t\tend",
"def results\r\n print_books\r\n print_toys\r\n print_classes\r\n end",
"def print_metadata_analysis\n # options[:create_query] = create_query\n # options[:import_query] = import_query\n export = CsvImportAnalyzer::MetadataAnalysis.new(options)\n export.metadata_print\n end",
"def show\n @inputs = @analysis_configuration.analysis_parameters.inputs\n @outputs = @analysis_configuration.analysis_parameters.outputs\n end",
"def print_results\n Report::print(@result_set)\n end",
"def display_results\n\n title1 = sprintf(TITLE_ROW, \"METH\", \"PATH\", \"CALLED\", \"RESPONSE TIME(ms)\",\"\", \"\", \"\", \"\",\"\",\"\", \"DYNO\", \"MESSAGE\", \"SIZE\")\n puts(title1)\n printf(TITLE_ROW, \"\", \"\", \"Times\", \"Mean\",\" : \",\"Median\",\" : \",\"Mode\",\" : \", \"Range\", \"Busiest\", \"Average\", \"Max\")\n puts('-'*title1.length)\n @endpoints.each do | ep |\n if ep.called == 0 then\n printf(TITLE_ROW, ep.ep_method,ep.ep_path, \" Never\", \" \",\" : \",\" \",\" : \",\" \",\" : \", \" \", \" \", \" \", \" \")\n else\n printf(DATA_ROW,\n ep.ep_method,\n ep.ep_path,\n ep.called,\n ep.averages[:responses].mean,\n ep.averages[:responses].median,\n ep.averages[:responses].mode,\n ep.averages[:responses].range,\n ep.busiest_dyno,\n ep.averages[:bytes].mean,\n ep.averages[:bytes].hi)\n end\n end\n\n if @endpoints.unprocessed_lines > 0\n puts \"There were #{@endpoints.unprocessed_lines} Unprocessed Lines of data from #{@loglines} total lines in the log!\"\n else\n puts \"All #{@loglines} total lines in the log were processed!\"\n end\n end",
"def print_summary\n puts \"\\n\\nScore : # Instances\\n\" << (\"=\" * 19)\n @summary_totals.each_with_index { |value, index| puts \" %5d:%8d\\n\" % [index, value] unless value.nil? }\n puts \"\\n** End of Report\"\n end",
"def output_details(files) \n @stdout.puts\n @stdout.puts \"Details\".bold\n files.each do |t|\n fname = t.path\n @stdout.puts \"File: %s\" % [((t.status == FileData::STATUS_OK) ? fname : fname.red)]\n @stdout.puts \"Includes: %s\" % [format_fds(t.includes)] unless t.includes.empty?\n @stdout.puts \"Included by: %s\" % [format_fds(t.included_by)] unless t.included_by.empty?\n @stdout.puts \"References: %s\" % [format_fds(t.references)] unless t.references.empty?\n @stdout.puts \"Referenced by: %s\" % [format_fds(t.referenced_by)] unless t.referenced_by.empty?\n unless t.status == FileData::STATUS_NOT_FOUND\n # show that part only if file exists\n @stdout.puts \"Size: %s (%d)\" % [format_size(t.size),t.size]\n if (t.docbook)\n @stdout.puts \"Type: DocBook, Version #{t.version}, Tag: #{t.tag}\"\n else\n @stdout.puts \"MIME: #{val_s(t.mime)}\"\n end\n @stdout.puts \"Timestamp: %s\" % [t.ts]\n @stdout.puts \"SHA1: %s\" % [t.checksum]\n end\n @stdout.puts \"Error: %s\" % [t.error_string.to_s.red] unless (t.error_string.nil?) \n @stdout.puts\n end\n end",
"def output_details_grouped io, threshold = nil\n calculate\n\n scores.sort_by { |_, n| -n }.each do |klass, total|\n io.puts\n\n io.puts \"%8.1f: %s\" % [total, \"#{klass} total\"]\n\n method_scores[klass].each do |name, score|\n self.print_score io, name, score\n end\n end\n end",
"def output\n print_headings\n \n line_order.each do |line_name|\n stats = statistics[line_name]\n \n arr = [line_headings[line_name]] + column_order.collect {|col| stats[col]}\n print_line(arr)\n end\n \n print_separator\n print_summary\n end",
"def stats_summary\n html = \"\"\n %w(inhale exhale cycle).each do |phase|\n %w(min max avg).each do |stat|\n time = format_time(self.meditations.map {|med| med.send(phase + \"_\" + stat)}.max)\n html += \"record #{phase} #{stat}: #{time}<br>\"\n end\n end\n html\n end",
"def helper\n \"Display the list of results generated by analysis modules.\"\n end",
"def show_stat\n \t\tputs \"=============Statistics============\"\n \t\tputs \"Score: #{get_score}\"\n \t\tputs \"Total time: \" + \"%0.2f\" %(@end_time - @start_time + @save_time) + \" seconds\"\n \t\tputs \"Number of sets found: #{@number_of_correct}\"\n \t\tputs \"#{@number_of_hint}/#{@total_hint} hints used\"\n \tend",
"def puts_report(step)\n puts \"STEP #{step}\"\n puts \"CONCEPTS: \"\n puts @concepts_list\n puts \"PROPERTIES: \"\n @properties_list.each do |p_name, p_type|\n puts \"#{p_name} --> #{p_type}\"\n end\n puts \"\\n\"\n end",
"def output_details io, max = nil\n io.puts\n\n each_by_score max do |class_method, score, call_list|\n self.print_score io, class_method, score\n\n if option[:details] then\n call_list.sort_by { |k,v| -v }.each do |call, count|\n io.puts \" %6.1f: %s\" % [count, call]\n end\n io.puts\n end\n end\n end",
"def print_results\r\n @cordinators.each do |c|\r\n print c.klass.to_s.ljust(25, ' ')\r\n c.print_stats\r\n end\r\n end",
"def inspect\n test_cases.each do |tc|\n puts tc.print\n end\n end",
"def print_results\n puts \"running time\\t\\t\\t= #{@time / 1000.0}s\"\n puts \"mean\\t\\t\\t\\t= #{mean}\"\n puts \"stddev\\t\\t\\t\\t= #{stddev}\"\n print \"95% confidence interval\\t\\t= #{confidence_interval}\\n\"\n end",
"def report_simulations_run(simulations)\n simulations.each do |sim|\n puts\n puts sim.class.to_s\n #puts sim.variant_description\n puts sim.options.inspect\n puts \"total_clicks: #{sim.total_clicks}\"\n puts \"actual sum: #{sim.actual_sum}\"\n puts \"estimated sum: #{sim.estimated_sum}\"\n puts \"absolute deviation: #{sim.absolute_deviation}\"\n puts \"fraction deviation: #{sim.fraction_deviation}\"\n end\nend",
"def print_details()\n\t$details.each {|k, v| puts \"#{k}: #{v}\"}\nend",
"def report io = $stdout\n only = option[:only]\n\n data = analyze only\n\n io.puts \"Total score (lower is better) = #{self.total}\"\n\n if option[:summary] then\n io.puts\n\n self.summary.sort_by { |_,v| -v }.each do |file, score|\n io.puts \"%8.2f: %s\" % [score, file]\n end\n\n return\n end\n\n data.each_with_index do |item, count|\n prefix = \"%d) \" % (count + 1) if option[:number]\n\n match = item.identical? ? \"IDENTICAL\" : \"Similar\"\n\n io.puts\n io.puts \"%s%s code found in %p (mass%s = %d)\" %\n [prefix, match, item.name, item.bonus, item.mass]\n\n item.locations.each_with_index do |loc, i|\n loc_prefix = \"%s: \" % (?A.ord + i).chr if option[:diff]\n extra = \" (FUZZY)\" if loc.fuzzy?\n io.puts \" %s%s:%d%s\" % [loc_prefix, loc.file, loc.line, extra]\n end\n\n if option[:diff] then\n io.puts\n\n nodes = hashes[item.structural_hash]\n\n sources = nodes.map do |s|\n msg = \"sexp_to_#{File.extname(s.file).sub(/./, \"\")}\"\n self.respond_to?(msg) ? self.send(msg, s) : sexp_to_rb(s)\n end\n\n io.puts n_way_diff(*sources)\n end\n end\n end",
"def info\n puts \"All stations:\"\n @stations.each.with_index(1) do |station|\n puts \"#{station.name}: \"\n station.show_trains(\"Cargo\")\n station.show_trains(\"Passenger\")\n end\n\n puts \"All routes:\"\n show_routes\n puts \"All trains:\"\n show_trains\n puts \"All wagons:\"\n show_wagons\n end",
"def print\n # TODO: add a flag for textmate, the ugliest format ever:\n # txmt://open?url=file:///path/to/file.rb&line=86&column=3\n\n puts \"Files: #{@num_files}\"\n puts \"Total Classes: #{@num_classes}\"\n puts \"Total Modules: #{@num_modules}\"\n puts \"Total Methods: #{@num_methods}\"\n\n puts\n puts \"Module coverage: #{coverage_rating(:module)}%\"\n puts \" Not covered:\"\n @coverage[:module][:not_covered].sort_by {|o| o.name}.each do |itm|\n location = itm.in_files.first.file_absolute_name || \"no known location\"\n puts \" #{itm.name}:\"\n puts \" #{location}\"\n end\n\n puts\n \n puts\n puts \"Class coverage: #{coverage_rating(:class)}%\"\n puts \" Not covered:\"\n @coverage[:class][:not_covered].sort_by {|o| o.name}.each do |itm|\n location = itm.in_files.first.file_absolute_name\n puts \" #{itm.name}\"\n puts \" #{location}\"\n end\n\n puts\n\n puts\n puts \"Method coverage: #{coverage_rating(:method)}%\\n\"\n puts \" Not covered:\"\n @coverage[:method][:not_covered].sort_by {|o| [o.parent.name, o.name]}.each do |itm|\n location = itm.token_stream.first.text.sub(/^# File /, '').sub(/, line (\\d+)$/, ':\\1')\n puts \" #{itm.parent.name}##{itm.name}:\"\n puts \" #{location}\"\n end\n \n puts\n end",
"def dump_all\n puts \"----------------------------------------------------------------------\"\n puts \" AUDIT ID: #{self.id}\\t\\t\\tDESIGN: #{self.design.directory_name}\"\n puts \" DESIGN CHECKS: #{self.design_checks.size.to_s}\"\n puts \" SELF COMPLETE: #{self.designer_complete?.to_s} \" +\n \" #{self.designer_completed_checks.to_s} (#{self.self_percent_complete.to_s}%)\\t\\t\" +\n \" PEER COMPLETE: #{self.auditor_complete?.to_s} \" +\n \" #{self.auditor_completed_checks.to_s} (#{self.peer_percent_complete.to_s}%)\"\n puts \"----------------------------------------------------------------------\"\n\n self.design_checks.each do |design_check|\n printf(\" DESIGN CHECK ID: %5d\\n\", design_check.id)\n printf(\" Self Auditor: %25s Result: %10s At: %25s\\n\",\n User.find(design_check.designer_id).name,\n design_check.designer_result,\n design_check.designer_checked_on.format_dd_mm_yy_at_timestamp.to_s) if design_check.designer_id > 0\n printf(\" Peer Auditor: %25s Result: %10s At: %25s\\n\",\n User.find(design_check.auditor_id).name,\n design_check.auditor_result,\n design_check.auditor_checked_on.format_dd_mm_yy_at_timestamp.to_s) if design_check.auditor_id > 0\n end\n \n puts \"----------------------------------------------------------------------\"\n end",
"def print_summary\r\n traverse do |node|\r\n print node.effectively_skipped? ? '-' : '+'\r\n case\r\n when node.test? then print 'T'\r\n when node.suite? then print 'S'\r\n when node.static? then print 'X'\r\n else print '?'\r\n end\r\n print node.indented_name(' ')\r\n tags = node.effective_tags.to_a\r\n unless tags.empty?\r\n # highlight the tags that are explicit on this node\r\n tags = tags.map {|tag| node.explicit_tags.include?(tag) ? \"*#{tag}\" : tag }\r\n print \" [#{tags.join(',')}]\"\r\n end\r\n print \"\\n\"\r\n end\r\n end",
"def display_results\r\n if @errors.empty?\r\n @out.puts @results\r\n else\r\n @errors.each{ |error| @out.puts error }\r\n end\r\n end",
"def output_details io, max = nil\n io.puts\n\n each_by_score max do |class_method, score, call_list|\n return 0 if option[:methods] and class_method =~ /##{@@no_method}/\n self.print_score io, class_method, score\n\n if option[:details] then\n call_list.sort_by { |k,v| -v }.each do |call, count|\n io.puts \" %6.1f: %s\" % [count, call]\n end\n io.puts\n end\n end\n # io.puts\n end",
"def print_result(result)\n puts result.solutions\n result.fragments.each do |fragment|\n puts fragment\n end\n end",
"def analyze\n explain(:analyze=>true)\n end",
"def show_stats(diff, average, stdev)\n puts 'Average error is: ' + average.to_s\n puts 'Standard deviation of the error is: ' + stdev.to_s\n (0..4).each do |off|\n puts 'Number of predictions ' + off.to_s + ' off from actual value was: ' + diff[off].to_s\n end\n end",
"def diagnostics; end",
"def diagnostics; end",
"def diagnostics; end",
"def diagnostics; end",
"def print_contents\n\t\tputs \"Artist: %s\" % [@artist]\n\t\tputs \"Album: %s\" % [@title]\n\t\tputs \"Released: %s\" % [@year]\n\n\t\tif @cd_count > 0\n\t\tputs \"CD(%d): %s\" % [@cd_count, @cd_id]\n\t\tend\n\n\t\tif @tape_count > 0\n\t\tputs \"Tape(%d): %s\" % [@tape_count, @tape_id]\n\t\tend\n\n\t\tif @vinyl_count > 0\n\t\tputs \"Vinyl(%d): %s\" % [@vinyl_count, @vinyl_id]\n\t\tend\n\n\tend",
"def summary; end",
"def summary; end",
"def summary; end",
"def summary; end",
"def print_results\n if @results.empty?\n puts 'No results found'\n return\n end\n\n tab_length = @results.first.keys.max_by(&:length).length\n @results.each do |result|\n result.each do |k, v|\n printf(\"%-#{tab_length}s %s\\n\", k, v.is_a?(Array) ? v.join(', ') : v)\n end\n puts '----------------------------------------------------------------------'\n end\n end",
"def verbose_report\n result = header\n result += \":\\n#{smell_list}\" if should_report\n result += \"\\n\"\n result\n end",
"def show_stats\n res = \"\\n\"\n res += \"#{@grid}\\n\"\n res += \"initial problem + #{@steps.join(\" + \")}\\n\"\n res += \"max_poss : #{max_poss}\\n\"\n res += \"min_depth : #{min_depth}\\n\"\n res += \"degree_of_freedom: #{dof}\\n\"\n each_poss(min_depth) { |poss| res += \"#{poss}\\n\" }\n res += \"\\n\"\n res\n end",
"def summary\n \n end",
"def dump_summary *args; end",
"def output_results\n if @annotated_paths.any?\n puts(\"Annotated #{@annotated_paths.join(', ')}\")\n @flags.include?(:error_on_annotation) ? 1 : 0\n else\n puts('Nothing to annotate')\n 0\n end\n end",
"def display_cohort_info\n puts '=========================================='\n puts @name\n puts \"Start Phase 0: #{@p0_start_date}\"\n puts \"Start Immersive: #{immersive_start_date}\"\n puts \"Graduate: #{graduation_date}\"\n puts \"Enrollment: #{self.num_of_students}\"\n puts \"Current Phase: #{currently_in_phase}\"\n end",
"def show_basic\n puts \"#{@total_packet_count} total packets captured\"\n puts \"#{@rinda_packet_count} Rinda packets captured\"\n puts \"#{@drb_packet_count} DRb packets captured\"\n puts \"#{@drb_messages_sent} messages sent\"\n puts \"#{@drb_results_received} results received\"\n puts \"#{@drb_exceptions_raised} exceptions raised\"\n end",
"def all_metrics\n output = `cube_info #{@fname} -l`\n output.split(\"\\n\")\n end",
"def show_statistics(statistics, format)\n puts 'Assessment\\'s statistics'\n puts AssessmentSerializer::serialize_statistics(statistics, format)\n puts\n end",
"def summarize_suite(suite, tests); end",
"def summarize_suite(suite, tests); end",
"def print_stats\n puts \"==================================================\"\n puts \"================= Statistics =====================\"\n puts \"==================================================\"\n \n calc_stats()\n \n puts \"Total Records = #{@total_rec_cnt}\"\n puts \"Well Formed Records = #{@well_formed_rec_cnt}\"\n puts \"Malformed Records = #{@malformed_rec_cnt}\"\n puts \"Unique Business Records = #{@biz_rec_cnt}\"\n puts \"Unique User Records = #{@user_rec_cnt}\"\n puts \"\"\n end",
"def summary\n end",
"def summary\n end",
"def summary_at_exit\n reporter = Speciny::Reporter.new(@description)\n @tests.each do |example, result|\n reporter.print_test_result(example, result)\n end\n end",
"def display_results(result_array)\n puts \"------------------- Completed run ----------------------------\"\n puts \"Samples: #{result_array.length}\"\n puts \"Min time: #{result_array.min}\"\n puts \"Max time: #{result_array.max}\"\n puts \"Average time: #{result_array.mean}\"\n puts \"Standard Deviation: #{result_array.standard_deviation}\"\n puts \"Values: #{result_array.inspect}\" if @show_values\n puts \"--------------------------------------------------------------\"\n end",
"def print_final_report\n puts; puts; puts \"=== FINAL DATABASE COUNTS ===\"\n puts; puts end_of_task_report\n puts; puts; puts \"=== BY SCHOOL ===\"\n puts by_school_report\n puts; AssessmentsReport.new.print_report\n end",
"def analysis\n @analysis || {}\n end",
"def display_info\n\t\tputs \"Total track number: #{@track_list.length}\"\n\t\tputs \"Total artist number: #{@artist_list.length}\"\n\t\tputs \"Last three played track:\"\n\t\t@last_played.each do |last_played_track|\n puts \"------------ Track Info -------------\"\n\t\t\tputs \"#{last_played_track.to_s}\"\n\t\tend\n\tend",
"def show\n @tags = TestTag.with_diagnostic(@diagnostic)\n @profiles = @diagnostic.profiled_testings.group_by(&:test_profile)\n end",
"def show\n @test_results = @test_run.test_results\n end",
"def report_results( timings )\n t = timings.first\n output.puts \n output.puts \" Total files read : #{\"%12d\" % t.value_stats.count}\"\n output.puts \" Total bytes read : #{\"%12d\" % t.value_stats.sum}\"\n output.puts \" Minimum filesize : #{\"%12d\" % t.value_stats.min}\"\n output.puts \" Average filesize : #{\"%16.3f\" % t.value_stats.mean}\"\n output.puts \" Maximum filesize : #{\"%12d\" % t.value_stats.max}\"\n output.puts \" Stddev of sizes : #{\"%16.3f\" % t.value_stats.stddev}\"\n output.puts\n\n output.puts [\"%28s\" % \"read order\", \"%20s\" % \"Elapsed time (sec)\", \"%22s\" % \"Read rate (bytes/sec)\" ].join(\" \")\n output.puts \"-\" * 72\n timings.each do |timing|\n p = [ ]\n p << \"%28s\" % timing.name\n p << \"%20.3f\" % timing.timed_stats.sum\n p << \"%22.3f\" % timing.rate\n output.puts p.join(\" \")\n end\n output.puts\n end",
"def print_stats\n\t\t\tputs \"Min: #{min}\"\n\t\t\tputs \"Max: #{max}\"\n\t\t\tputs \"Expected: #{expected}\"\n\t\t\tputs \"Std Dev: #{standard_deviation}\"\n\t\t\tputs \"Variance: #{variance}\"\n\n\t\t\t@probability_distribution.each { |k,v| \n\t\t\t\tputs \"P(#{k}) => #{v}\"\n\t\t\t}\n\t\tend",
"def print_all_sites\n\t\tputs \"\\nSummary Report of the site store:\"\n\t\tsites=@known_sites.keys.sort\n\t\tsites.each do |site|\n\t\t\tputs site\n\t\tend\n\t\tputs \"End of the summary\"\n\trescue => ee\n\t\tputs \"Exception on method #{__method__} \"\n\tend",
"def display_info\n @all_domains.each do |key, domain|\n puts \"Domain : \" + domain.domain_name\n puts domain.email_statistics.inspect\n puts \"*\" * 80\n end\n end",
"def display_features\n puts\n puts \"Features:\"\n @features.each { |feature| puts \" * #{feature}\"}\n puts\n end",
"def collectives_report\n collectives = get_collectives\n\n puts \" %-30s %s\" % [ \"Collective\", \"Nodes\" ]\n puts \" %-30s %s\" % [ \"==========\", \"=====\" ]\n\n collectives[:collectives].sort_by {|key,count| count.size}.each do |collective|\n puts \" %-30s %d\" % [ collective[0], collective[1].size ]\n end\n\n puts\n puts \" %30s %d\" % [ \"Total nodes:\", collectives[:nodes] ]\n puts\n end",
"def dumpResults()\r\n @listener.context.dumpDpms()\r\n @listener.context.dumpPpms()\r\n @listener.context.dumpLookups()\r\n @listener.context.dumpRules()\r\n @listener.context.dumpRulesets()\r\n end",
"def printOverview\n @nodes.each do |node|\n puts node.nodeID + \" \" + (node.e0.to_s) +\n (node.e1.to_s) + \n (node.w0.to_s) + \n (node.w1.to_s)\n end\n end",
"def show_info()\n\t\tputs \"ID: #{@@id}\"\n\t\tputs \"Name: #{@car_name}\"\n\t\tputs \"Make: #{@@make}\"\n\t\tputs \"Cost: #{calc_total_cost} INR\"\n\t\tputs\n\t\tputs \"Review: #{@review}\"\n\t\tputs \"Rating: #{@rating} stars\"\n\tend",
"def run\n\t\t\tsummary\n\t\tend",
"def index\n @analyses = Analysis.all\n end",
"def display_analyze_output(json, options={})\n return unless json['tokens']\n\n output = [] << ''\n\n max_length = json['tokens'].map { |d| d['token'].to_s.size }.max\n\n output << Helpers.table(json['tokens'].map do |t|\n [\n t['position'],\n t['token'].ljust(max_length+5).ansi(:bold),\n \"#{t['start_offset']}–#{t['end_offset']}\",\n t['type']\n ]\n end).to_s\n output.join(\"\\n\")\n end",
"def exams_statistics\n end",
"def run events\n events.each do |event| \n interprete event\n end\n# return\n puts \"Statistics:\"\n @counts.each do |k,v|\n puts \"#{k.inspect} =>\"\n i = 0\n step = 6\n while i < v.size\n puts \"\\t#{v[i,step]}\"\n i += step\n end\n end\n end",
"def print_output_head(index)\n puts \"\\nPrinting dataset for %.2f\" %\n (@meta_data.domain_z.lower + (index * @meta_data.domain_z.step))\n puts \"\\n\"\n end",
"def display\n puts (\"[\" + @id.name + \", \" + @id.version + \"]\").green.bold\n puts \"author = \".blue + @author\n print \"wrapper = \".blue + @wrapper.to_s\n puts \", unique = \".blue + @unique.to_s\n puts\n\n puts \"[Path:]\".green.bold\n puts @path\n\n #\n # Display the provided elements\n #\n\n puts \"\\n[Provide]\".green.bold\n @provide.each do |context|\n puts \"\\n<Context #{context.name}>\".blue.bold\n OCMSet::SECTIONS.each { |section| context[section].each { |k| puts k } }\n end\n\n #\n # Display the required elements\n #\n\n if @require != nil then\n puts \"\\n[Require]\".green.bold\n OCMSet::SECTIONS.each { |section| @require[section].each { |k| puts k } }\n end\n\n end",
"def show\n @preliminaries = Match.preliminary.group_by { |m| m.group.to_s }.sort_by { |group, m| group }\n @finals = Match.final.group_by { |m| m.round }\n @tips = current_user.tips\n @user = current_user\n end",
"def print_report\n # total_bikes = @fleet.count \n # broken_bikes = @fleet.count {|b| b.is_broken?}\n # working_bikes = total_bikes-broken_bikes\n total_people = @people.count\n total_stations = @stations.count\n # show_stations = @stations.each do {|name, capacity| puts \"#{name}, #{capacity}\"}\n #tell me its name and capcity\n # puts \"Total bikes: #{total_bikes}\"\n # puts \"Broken bikes: #{broken_bikes}\"\n # puts \"Working bikes: #{working_bikes}\"\n puts \"Total people: #{total_people}\"\n # puts \"People with bikes: #{people_with_bikes}\"\n puts \"People without bikes #{people_without_bikes.count}\" \n puts \"Number of stations: #{total_stations}\" \n puts \"Stations:\"\n @stations.each do |station|\n puts \"#{station.name}, #{station.capacity}, #{station.bikes.count}\"\n end\n # result = \"total bikes #{total_bikes}\\n\" + \"broken bikes #{broken_bikes}\\n\" + \"working bikes #{working_bikes}\\n\"\n # result + \"total people #{total_people}\\n\" + \"people with bikes #{people_with_bikes}\\n\" + \"people without bikes #{people_without_bikes}\\n\" + \"number of stations #{total_stations}\\n\" + \"stations #{show_stations}\"\n end",
"def runAnalyzer(num_samples,inhash)\n # select profile for run\n show do \n title \"Select #{QIAXCEL_TEMPLATE[inhash[:sampleTypes]]}\" # this is just a profile name, should be ok for other polymerases\n note \"Click <b>Back to Wizard</b> if previous data is displayed.\"\n check \"Under <b>Process -> Process Profile</b>, make sure <b>#{QIAXCEL_TEMPLATE[inhash[:sampleTypes]]}</b> is selected.\"\n end\n \n # select alignment marker\n ref_marker = (inhash[:sampleTypes] == 'DNA') ? REF_MARKERS[inhash[:type_ind]][inhash[:cutoff_ind]] : REF_MARKERS[inhash[:type_ind] ]\n show do \n title \"Select alignment marker\"\n check \"Under <b>Marker</b>, in the <b>Reference Marker </b> drop-down, select <b>#{ref_marker}</b>. A green dot should appear to the right of the drop-down.\"\n end\n \n # empty rows\n if inhash[:sampleTypes] == 'RNA'\n num_samples = num_samples + 1 # Include the ladder in the first well of the first stripwell\n nonempty_rows = (num_samples/WELLS_PER_STRIPWELL.to_f).ceil\n (num_samples % WELLS_PER_STRIPWELL) > 0 ? nonempty_rows + 1 : nonempty_rows\n else\n nonempty_rows = (num_samples/WELLS_PER_STRIPWELL.to_f).ceil\n end\n show do \n title \"Deselect empty rows\"\n check \"Under <b>Sample selection</b>, deselect all rows but the first #{nonempty_rows}.\"\n end\n \n # check \n show do \n title \"Perform final check before running analysis\"\n note \"Under <b>Run Check</b>, manually confirm the following:\"\n check \"Selected rows contain samples.\"\n check \"Alignment marker is loaded (changed every few weeks).\"\n end\n \n # run and ask tech for remaining number of runs\n run_data = show do \n title \"Run analysis\"\n note \"If you can't click <b>Run</b>, and there is an error that reads <b>The pressure is too low. Replace the nitrogen cylinder or check the external nitrogen source</b>, close the software, and reopen it. Then restart at title - <b>Select #{QIAXCEL_TEMPLATE[inhash[:sampleTypes]]} </b>\"\n check \"Otherwise, click <b>Run</b>\"\n note \"Estimated time of experiment is given at the bottom of the screen\"\n get \"number\", var: \"runs_left\", label: \"Enter the number of <b>Remaining Runs</b> left in this cartridge\", default: 0\n #image \"frag_an_run\"\n end\n \n # return\n run_data[:runs_left]\n \n end",
"def report\n sprintf \"Number of paragraphs %d \\n\" <<\n \"Number of sentences %d \\n\" <<\n \"Number of words %d \\n\" <<\n \"Number of characters %d \\n\\n\" <<\n \"Average words per sentence %.2f \\n\" <<\n \"Average syllables per word %.2f \\n\\n\" <<\n \"Flesch score %2.2f \\n\" <<\n \"Flesh-Kincaid grade level %2.2f \\n\" <<\n \"Fog Index %2.2f \\n\",\n num_paragraphs, num_sentences, num_words, num_characters,\n words_per_sentence, syllables_per_word,\n flesch, kincaid, fog\n end",
"def print_statistics(opts)\n puts \"-> statistics\"\n puts \" ----------\"\n printf(\"%7s: %4d\\n%7s: %4d\\n%7s: %4d\\n%7s: %4d\\n%7s: %4d\\n\",\n \" total\", opts[:valid_counter] + \n opts[:invalid_counter] +\n opts[:skip_counter] +\n opts[:double_counter],\n \" valid\", opts[:valid_counter],\n \" invalid\", opts[:invalid_counter],\n \" drop\", opts[:skip_counter],\n \" double\", opts[:double_counter])\n puts\n puts \"-> pattern: #{opts[:pattern].inspect}\"\n puts \"-> scan pattern: #{opts[:scan_pattern].inspect}\"\n puts\n puts \"-> files operated on\"\n puts \" -----------------\"\n puts \" values read from: #{opts[:infile]}\"\n puts \" valid values written to: #{opts[:valid_file]}\"\n puts \" invalid values written to: #{opts[:invalid_file]}\"\n if opts[:note]\n puts\n puts \"-> Note\"\n puts \" ----\"\n puts opts[:note]\n end\n end",
"def print_findings()\n\n # Print totals\n puts \"Total Findings: #{$findings.size}\"\n puts \"======================\"\n puts \"Log Messages: #{$logCount}\"\n puts \"Security Notes: #{$noteCount}\"\n puts \"Security Warnings: #{$warningCount}\"\n puts \"Security Holes: #{$holeCount}\"\n puts \"Other Findings: #{$miscCount}\"\n puts\n\n # Print each finding\n $findings.each do |key, value|\n print \"==> OID: \"\n\t puts key\n \n # If we are printing results with IP addresses\n if $noip == false then\n # Print out all IP addresses for each result\n puts \"Host(s) :\"\n\t value.each do |port, ips|\n puts\n puts port\n puts \"-------\"\n ips.each do |ip|\n puts ip\n end\n puts\n\t end\n end\n \n $descriptions[key].each do |desc, ports|\n puts\n puts \"******************Description************************\"\n puts desc\n puts\n if $noip == false then\n puts \"------------------IP Addresses-----------------------\"\n puts\n \n ports.each do |port, ips|\n puts\n puts port\n puts \"-------\"\n ips.each do |ip|\n puts ip\n end\n puts\n end\n puts\n end\n puts \"*****************************************************\"\n end\n\n # Seperator\n 2.times do puts end\n puts \"=============================================================\"\n 2.times do puts end\n end\n\nend",
"def display_each\n puts \" * #{self.experience} experience at #{self.company_name}\"\n end",
"def display\n\t\t\"SUITE: #{@suite}, RANK: #{@rank}, VALUE: #{@value}\"\n\tend",
"def display_planet_details\n puts \"Name: #{@name}, Primary Export: #{@primary_export}, Year-Length: #{@year_length}\"\n end",
"def get_analyzer_results(analyzer, the_samples)\n output = Array.new\n analyzer_base = analyzer.sub('.py', '')\n puts the_samples\n puts analyzer\n the_samples.each do |sample|\n output << \"results/#{$jobid}/#{$selection}#{$jetcorrection}/iso#{$isolation}/#{analyzer_base}/#{sample}.root\"\n #output << \"results/#{$jobid}/#{analyzer_base}/#{sample}.root\"\n end\n return output\nend",
"def show\n @data.each do | row |\n row.each do | cell |\n if cell.infected?\n print \"%3s\" % cell.virus.generation\n else\n print \" #{cell.content} \"\n end\n end\n puts\n end\n end",
"def output_details_grouped io, max = nil\n scores = Hash.new 0\n methods = Hash.new { |h,k| h[k] = [] }\n\n each_by_score max do |class_method, score, call_list|\n klass = class_method.split(/#|::/).first\n\n methods[klass] << [class_method, score]\n scores[klass] += score\n end\n\n scores.sort_by { |_, n| -n }.each do |klass, total|\n io.puts\n\n io.puts \"%8.1f: %s\" % [total, \"#{klass} total\"]\n methods[klass].each do |name, score|\n self.print_score io, name, score\n end\n end\n end",
"def display_results\r\n if @errors.empty?\r\n if @test_diff.empty?\r\n @out.puts \"Output matches exactly\"\r\n else\r\n @out.puts \"Test diff:\"\r\n @out.puts @test_diff\r\n end\r\n else\r\n @errors.each {|error| @out.puts error }\r\n end\r\n end",
"def show\n @analysis = Analysis.find(params[:id])\n end",
"def auto_analyze; end",
"def inspect\n str = self.to_s\n str << \"\\n-------------------------------------------------------\\n\"\n str << \"Algorithms:\\n\"\n @algorithms.each do |a|\n str << a.inspect()\n end\n\n return str\n end",
"def dump\n if @ctx.checks.one? && @ctx.checks.first.kind_of?(Pippi::Checks::MethodSequenceFinder)\n @ctx.checks.first.dump\n end\n @ctx.report.problems.each do |problem|\n @io.puts(problem.to_text)\n end\n end",
"def print_info\n self.values.each do |value|\n puts value\n end\n end",
"def show_details\n print @name.upcase + \": #{@name} has #{@moons} moons and a diameter of #{@diameter} miles.\"\n print \"It is #{@color} in color and associated with the #{@zodiac} zodiac sign.\"\n puts \"#{@name} is #{@distance} miles from the sun and has a solar rotation of #{@rotation} earth days!\"\n end",
"def display(results, options={})\n results.keys.sort.each do |file|\n puts \"#{file}:\"\n results[file].each do |note|\n puts \" * #{note.to_s(options)}\"\n end\n puts\n end\n end"
] |
[
"0.6977242",
"0.67322606",
"0.6679173",
"0.6597362",
"0.65840834",
"0.6583778",
"0.65064",
"0.65007865",
"0.6453068",
"0.6433837",
"0.64218104",
"0.6385697",
"0.63795054",
"0.6377932",
"0.6339181",
"0.633183",
"0.63238513",
"0.6282346",
"0.6279356",
"0.6272472",
"0.626294",
"0.62567806",
"0.62281257",
"0.6179956",
"0.6168902",
"0.6160058",
"0.61555874",
"0.6136564",
"0.613399",
"0.6094992",
"0.60735124",
"0.60668236",
"0.60657847",
"0.60655546",
"0.60655546",
"0.60655546",
"0.60655546",
"0.605467",
"0.60408515",
"0.60408515",
"0.60408515",
"0.60408515",
"0.6035776",
"0.6023792",
"0.60141283",
"0.60051656",
"0.5990398",
"0.59872985",
"0.5970707",
"0.5957671",
"0.5957497",
"0.59556645",
"0.59313875",
"0.59313875",
"0.5926919",
"0.5904666",
"0.5904666",
"0.5902358",
"0.5897029",
"0.58936816",
"0.58902895",
"0.58791023",
"0.5877371",
"0.58721554",
"0.5871922",
"0.58676517",
"0.585317",
"0.58517843",
"0.58467007",
"0.583892",
"0.5838588",
"0.5832242",
"0.5821634",
"0.580823",
"0.58007026",
"0.58006424",
"0.5799425",
"0.5799102",
"0.57948434",
"0.57865363",
"0.57823914",
"0.5767555",
"0.5747391",
"0.57451427",
"0.5743688",
"0.5738543",
"0.573447",
"0.57229906",
"0.57211506",
"0.57190406",
"0.57121694",
"0.57103103",
"0.57083344",
"0.5705551",
"0.57043225",
"0.5700986",
"0.5695997",
"0.56922716",
"0.5686658",
"0.56798875"
] |
0.635644
|
14
|
Print out a progress indicator of how many rotations / permutations have been processed and how many are remaining.
|
def print_rotation_count
@rotation_count += 1
print "\r\e#{@rotation_count} of #{@maximum_rotations} processed..."
$stdout.flush
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show_progress\n\t\t\t# bar_size is between 0 and 30\n finish_size = (((@top_card-12).to_f / (@deck.length-11).to_f) * 30).to_i\n\t\t\tremain_size = 30 - finish_size\n\t\t\tprint \"\\nProgress: \"\n\t\t\tfinish_size.times {print '▓'}\n\t\t\tremain_size.times {print '░'}\n\t\t\tputs\n\t\t\tputs\n end",
"def progress; end",
"def progress; end",
"def progress; end",
"def progress; end",
"def progress; end",
"def print_game_progress(count)\n puts \"#{\".\" * 50}\"\n puts \"\\nWord : #{@incomplete_word}\"\n puts \"Attempts Left: #{@limit - count}\"\n unless @incorrect_guesses.empty?\n puts \"Incorrect inputs: #{@incorrect_guesses.join(\", \")}\"\n end\n puts \"#{\".\" * 50}\"\n end",
"def print_progress_bar_at i\n if (i%PROGRESSOR_SAMPLE_PERIOD == 0)\n print '.'\n $stdout.flush\n end\nend",
"def describe_progress\n if @options[:num]\n \"#{@messages.size} of #{@options[:num]} message#{'s' if @messages.size!=1} collected\"\n else\n \"#{@messages.size} message#{'s' if @messages.size!=1} collected\"\n end \n end",
"def print_progress(current, total, started_at)\n if total.nil?\n print_progress_nosize(current, started_at)\n return\n end\n ratio = [current.to_f / total, 1.0].min\n percent = (ratio * 100.0).round(1)\n arrow = (ratio * 20.0).floor\n time_spent = Time.now.to_i - started_at\n print(\"\\r[\")\n print('=' * [arrow - 1, 0].max)\n print('>')\n print('.' * (20 - arrow))\n print(\"] #{pretty_filesize(current)}/#{pretty_filesize(total)} (#{percent}% at #{pretty_filesize(current.to_f / time_spent)}/s) \")\n end",
"def print_status\n next_run = ((@@next_task-Time.now)/60.0).round(2)\n\n print \"\\r\"\n print \"#{Time.now} #{[@chains.count,@steps_done].min}/#{@chain_count} chains active - #{@chains.sum(&:remaining_task_count)}/#{@task_count} Tasks remaining - Next task will run in #{next_run} minutes\"\n\n EM.add_timer 1, proc {\n print_status\n }\n end",
"def progress()\n percent = (($ops / $total_ops) * 100).floor\n if (percent <= 99)\n $progress.progress = percent\n $ops += 1\n else\n $progress.finish\n end\nend",
"def progress_output\n arr = @progress.map do |key, value|\n \"#{key}: #{value}\\n\"\n end\n arr.join('')\n end",
"def step(step_increment = 1)\n @current_steps+= step_increment\n new_markers = @max_steps != 0 ? (@current_steps / @steps_per_marker).to_i : max_markers\n\n new_percentage = @max_steps != 0 ? @current_steps * 100 / @max_steps : 100\n if @use_ansi and new_percentage != @current_percentage\n # This part uses ANSI escape sequences to show a running percentage\n # to the left of the progress bar\n print \"\\e[1D\" * (@current_markers + 5) if @current_percentage != 0 # go left\n print \"#{new_percentage}%\".rjust(4) << \" \"\n print \"\\e[1C\" * @current_markers if @current_markers != 0 # go back right\n $stdout.flush rescue nil\n @current_percentage = new_percentage\n end\n\n if new_markers > @current_markers\n print '.' * (new_markers - @current_markers)\n @current_markers = new_markers\n $stdout.flush rescue nil\n end\n if @current_steps == @max_steps\n print '.' * (max_markers - @current_markers) + ' '\n $stdout.flush rescue nil\n end\n end",
"def progression counter,opts = {}\n (@steps = nil; return) if opts[:reset]\n @steps ||= (1..10).map{ |n| [(@num_rows.to_f / 10.to_f) * n,n*10] }\n return if @steps.empty?\n c,perc = @steps[0] \n if counter > c\n Logger.<<(__FILE__,\"INFO\",\"Having processed #{perc}% now ...\",inline: true)\n @steps.shift\n end\n end",
"def show_progress(collection, say=\"Progress\", &block)\n progress_bar = ProgressBar.new say, collection.count\n\n collection.each do |thing|\n block.call thing\n progress_bar.increment\n end\n\n puts # distinguish progress_bar output from other output\nend",
"def progress(array)\n array.each_with_index {|e,i| \n printf ANSI.left(50) + \"Starting item #{i +1} ...\"\n yield(e)\n }\n print \"\\n\"\n end",
"def progress\n @progress.scan(/_|\\w/).join(' ')\n end",
"def progress\n l = length\n l.zero? ? 0 : 100 * time / l\n end",
"def progress\n l = length\n l.zero? ? 0 : 100 * time / l\n end",
"def progress\n l = length\n l.zero? ? 0 : 100 * time / l\n end",
"def indicate_progress\n @iteration_counter += 1\n @progress_rate ||= resolver_ui.progress_rate\n if iteration_rate.nil?\n if Time.now - started_at >= @progress_rate\n self.iteration_rate = @iteration_counter\n end\n end\n\n if iteration_rate && (@iteration_counter % iteration_rate) == 0\n resolver_ui.indicate_progress\n end\n end",
"def print_progress\n @data[\"print_progress\"]\n end",
"def progress(size, file)\n\t\tprint '.'\n\t\tsleep 1.5\n\t\tprint '.'\n\t\tsleep 1.5\n\t\tprint '.'\n\t\tsleep 1.5\n\t\tpercent = (File.size? file).to_f / size.to_f\n\t\tpercent = percent * 100\n\t\tpercent = ((percent*20).round / 20.0)\n\t\tprint \"\\e[1;37m#{percent}\\e[0m%\"\n\tend",
"def show\n calculate_progress\n ##complete_goal\n end",
"def step(number_steps = 1)\n @current_progress+= number_steps\n if ((@current_progress - number_steps) / @steps_per_progress_bar_marker).to_i \\\n < (@current_progress / @steps_per_progress_bar_marker).to_i\n @marker_counter += 1\n putc '.' \n puts if @marker_counter == @bar_length # after the last marker is printed, add a new_line\n $stdout.flush\n end\n end",
"def progress\n return 100 unless @history.first\n completed_size = @history.first.jobs.select(&:completed?).size\n completed_size * 100 / @history.first.jobs.size\n end",
"def progress\n return @procs_queue.size / @initial_size.to_f\n end",
"def display_progress\n\t\t@progress_key.join(\" \")\n\tend",
"def progress\n total_steps_count = self.steps.count\n\n if total_steps_count.zero?\n 0.0\n else\n approved_steps_count = self.steps.where(state: 'approved').count\n (approved_steps_count * 100.0 / total_steps_count).round(2)\n end\n end",
"def progress_bar(progress_ratio)\n max = @screen_size * 0.8\n print \"\\r\\t[#{progress_ratio.round(2)*100}%] [\"\n print \"#\".magenta * (progress_ratio * max)\n print \"] DONE!\\n\" if progress_ratio == 1\n end",
"def progress=(_arg0); end",
"def progress=(_arg0); end",
"def progress=(_arg0); end",
"def progress=(_arg0); end",
"def loading_bar\n loading_array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n 1.upto(loading_array.length.to_i) do |i|\n printf(\"\\rCycles Complete: %d\", i)\n sleep(0.1)\n end\n end",
"def progress_info\n\n color=\"#AAAAAA\"\n progress=0\n message=\"Log not available.\"\n\n if self.cluster_stdout\n\n color=\"blue\"\n progress=0\n message=\"Execution not started.\"\n\n self.cluster_stdout.each_line do |line| \n if /\\([0-9]* run \\/ [0-9]* fail \\/ [0-9]* done \\/ [0-9]* left\\)/.match(line)\n run = /[0-9]* run/.match(line)[0].to_s.split[0].to_f \n done = /\\/ [0-9]* done/.match(line)[0].to_s.split[1].to_f\n failed = /\\/ [0-9]* fail/.match(line)[0].to_s.split[1].to_f\n left = /\\/ [0-9]* left/.match(line)[0].to_s.split[1].to_f\n progress=100*(run+done+failed)/(run+done+failed+left)\n # set toolbar color \n red=255*(failed)/(failed+done+run)\n blue=255*(run).to_f/(failed+done+run).to_f\n green=128*(done).to_f/(failed+done+run).to_f\n color=\"rgb(#{red.to_i},#{green.to_i},#{blue.to_i})\"\n if progress!= 100 && (\n\t CbrainTask::COMPLETED_STATUS.include?(self.status) ||\n\t CbrainTask::FAILED_STATUS.include?(self.status) ||\n\t self.status == \"Post Processing\" ||\n\t self.status == \"Data Ready\")\n color=\"red\"\n end\n if progress==100\n\t color=\"green\"\n end\n message=\"PSOM tasks: #{run.to_i} run / #{failed.to_i} fail / #{done.to_i} done / #{left.to_i} left\"\n end\n end\n end \n return {:color => color,:percentage => progress, :message => message, :show_percentage => true}\n end",
"def show_progress=(_arg0); end",
"def progress\n total = asset.pieces.count\n downloaded = total - piece_downloads.incomplete.count\n [downloaded, total]\n end",
"def minimal_progress_callback(state)\n case state\n when :start then print '|'\n when :step then print '.'\n when :end then puts\n end\n\n $stdout.flush\n end",
"def progress_counter(enum)\n Enumerator.new do |y|\n count = 0\n enum.each do |x|\n if (count += 1) == 100\n count = 0\n STDERR.print '.' # STDOUT could be redirected, so we print to STDERR\n end\n y.yield(x)\n end\n end\n end",
"def indicate_progress\n end",
"def progress(msg, nontty_log = T.unsafe(nil)); end",
"def describe_progress\n str = \"#{identifier}: #{@title.capitalize} collection \"\n str << \"in response to #{@options[:m_id]} \" if @options[:m_id]\n str << \"didn't complete within #{@options[:timeout]}s, \"\n str << \"reached #{@messages.size}/#{@options[:num]}\"\n str\n end",
"def show_progress\n\t\t@placeholder.join(\" \")\n\tend",
"def report_progress(progress, total, show_parts=true)\n if total && total > 0\n percent = (progress.to_f / total.to_f) * 100\n line = \"Progress: #{percent.to_i}%\"\n line << \" (#{progress} / #{total})\" if show_parts\n else\n line = \"Progress: #{progress}\"\n end\n\n info(line, :new_line => false)\n end",
"def render_progress passed, total\n\t\n\t\ts = '<div class=\"progress bar\">';\n\t\t(passed).times do\n\t\t\ts << '<span class=\"p\"></span>'\n\t\tend\n\t\ts<< '<span class=\"c\"></span>'\n\t\t(total-passed-1).times do\n\t\t\ts << '<span class=\"r\"></span>'\n\t\tend\n\t\ts << '</div>'\n\t\t\n\t\treturn s.html_safe\n\tend",
"def calc_progress\n p = 0.25\n unless self.compile_errors.nil?\n p = 0.5\n end\n\n if self.correct\n p = 1.0\n else\n unless self.results.nil?\n p_tc = 0.0\n self.results.each do |id,result|\n unless result['error']\n p_tc = p_tc + 1\n end\n end\n p = p + ((p_tc/self.results.size) * 0.5)\n end\n end\n\n p\n end",
"def progress()\n return 1.0 * @done_time_units / @total_time_units\n end",
"def progress(lesson)\n \"%0.2f%\" % (chapters_completed.where(lesson: lesson).count / lesson.chapters.count.to_f * 100)\n end",
"def progress\n if processed\n return 100.0\n end\n\n response = Zencoder::Job.progress(zencoder_job_id)\n \n if response.body[\"state\"] == \"finished\"\n processed!\n return 100.0\n end\n\n return response.body[\"progress\"] if response.body[\"progress\"]\n\n return 0.0\n end",
"def calculate_progress\n result = self.progress_status\n (100 * result.values.count(true) / result.values.compact.count).to_s\n end",
"def sample_progress_bar\n\trequire_relative 'lib/console'\n\t\n\tprogress = Console.logger.progress(\"Progress Bar\", 10)\n\t\n\t10.times do |i|\n\t\tsleep 1\n\t\t\n\t\tprogress.increment\n\tend\nend",
"def print_board\n @race_progress.each do |player, advance|\n p advance\n puts \"#{\"-\"*(advance >= @length ? @length : advance)}#{player}#{\"/\"*(advance >= @length ? 0 : @length-advance)}\"\n end\n end",
"def print_final_count finished_driver\r\n\t\tif finished_driver.num_books == 1\r\n\t\t\tputs \"#{finished_driver.name} obtained #{finished_driver.num_books} book!\"\r\n\t\telse\r\n\t\t\tputs \"#{finished_driver.name} obtained #{finished_driver.num_books} books!\"\r\n\t\tend\r\n\t\t\r\n\t\tif finished_driver.num_toys == 1\r\n\t\t\tputs \"#{finished_driver.name} obtained #{finished_driver.num_toys} dinosaur toy!\"\r\n\t\telse\r\n\t\t\tputs \"#{finished_driver.name} obtained #{finished_driver.num_toys} dinosaur toys!\"\r\n\t\tend\r\n\t\t\r\n\t\tif finished_driver.num_classes == 1\r\n\t\t\tputs \"#{finished_driver.name} attended #{finished_driver.num_classes} class!\"\r\n\t\telse\r\n\t\t\tputs \"#{finished_driver.name} attended #{finished_driver.num_classes} classes!\"\r\n\t\tend\r\n\t\t\r\n\tend",
"def display\n if @count.to_f/@tries.to_f < .33\n print @progress.join.green\n puts\n elsif @count.to_f/@tries.to_f > .33 && @count.to_f/@tries.to_f < .66\n print @progress.join.orange\n puts\n elsif @count.to_f/@tries.to_f > .66\n print @progress.join.red\n end\n\nend",
"def stage2Conclusion\n sleep(2)\n puts \"Awesome that was a lot better, but I think a little more will make her perfect\"\n sleep(1)\n puts \"Let's increase her intelligence\"\n sleep(2)\n puts \"ai.intelligence = 60\"\n bar = TTY::ProgressBar.new(\"Initializing [:bar]\", total: 50)\n # make the bar load slowly\n 30.times do\n sleep(0.04)\n bar.advance # by default increases by 1\n end\n 10.times do\n sleep(0.5)\n bar.advance # by default increases by 1\n end\n 3.times do\n sleep(1)\n bar.advance # by default increases by 1\n end\n puts \"\"\n\n msg = 'Error!'.colorize(:red)\n 10.times do\n puts \"\\r#{ msg }\"\n sleep 0.1\n puts \"\\r#{ ' ' * msg.size }\" # Send return and however many spaces are needed.\n sleep 0.1\n end\n\n i = 60\n while i < 900\n puts \"ai.intelligence = #{i}\".colorize(:red)\n sleep(0.1)\n i += 50\n end\n smart = TTY::ProgressBar.new(\"Initializing [:bar]\", total: 100)\n 100.times do\n sleep(0.01)\n smart.advance # by default increases by 1\n end\n sleep(0.5)\n 30.times do\n puts \"1010101010000101010100101010101111110101010010001101000101010101010101010101010101001010101010101010101010101010101010101010101010101010101001010101010101010010101\".colorize(:red)\n sleep(0.05)\n puts \"1011110101001010101010101010110000100101010101011101010010100101010110100011010101010101010101010010110101100110101010101010101001010110101010101011010001110111100\".colorize(:red)\n sleep(0.05)\n puts \"1011110101001010101111100111110000100101010101011101010010100101010110100011010100010101010111100101101010001010100011111101100101010000101010110110101101011110101\".colorize(:red)\n sleep(0.05)\n end\n\n 30.times do\n puts \"\"\n end\n\n end",
"def progress(msg, nontty_log = :debug)\n send(nontty_log, msg) if nontty_log\n return unless show_progress\n icon = \"\"\n if defined?(::Encoding)\n icon = PROGRESS_INDICATORS[@progress_indicator] + \" \"\n end\n @mutex.synchronize do\n print(\"\\e[2K\\e[?25l\\e[1m#{icon}#{msg}\\e[0m\\r\")\n @progress_msg = msg\n if Time.now - @progress_last_update > 0.2\n @progress_indicator += 1\n @progress_indicator %= PROGRESS_INDICATORS.size\n @progress_last_update = Time.now\n end\n end\n Thread.new do\n sleep(0.05)\n progress(msg + \".\", nil) if @progress_msg == msg\n end\n end",
"def progress\n summary = exec_summary\n summary.progress.num_completed_scan_ranges.to_f / summary.progress.total_scan_ranges.to_f\n end",
"def get_progresses\n if @all_count > 0\n @progress_ch = 100 * @memorized_count_ch / @all_count\n @progress_ja = 100 * @memorized_count_ja / @all_count\n else\n @progress_ch = 0\n @progress_ja = 0\n end\n end",
"def percent_complete\n return 100 if completed?\n return 0 unless record_count.to_i > 0\n if collect_output?\n ((output.count.to_f / record_count) * 100).to_i\n else\n # Approximate number of input records\n input_records = input.count.to_f * slice_size\n ((1.0 - (input_records.to_f / record_count)) * 100).to_i\n end\n end",
"def progressable; end",
"def progress_line; end",
"def progress(run_id)\r\n @result_count = self.get_results(run_id)[:result].length - 1\r\n run = Run.find(run_id)\r\n @result = ((@result_count.to_f / run.units.count.to_f) * 100).round(2)\r\n end",
"def get_progress()\n @result_tfile.rewind\n progress = @result_tfile.each_line.collect do |line|\n group = line.scan(/Completed (\\d+) requests/)\n group = group.empty? ? 0 : group[0][0]\n end\n progress.reject{|x| x == 0}.length * 10\n end",
"def progress_percentage\n total_amount = 0\n # proceed_amount = 0\n total_amount = card_sub_tasks.map(&:service_card_count).reduce(:+)\n # card_sub_tasks.each do |card_sub_task|\n # if card_sub_task.proceed == CardSubTask::PROCEED_FINISHED || card_sub_task.proceed == CardSubTask::PROCEED_ERROR\n # proceed_amount += card_sub_task.service_card_count\n # elsif card_sub_task.proceed == CardSubTask::PROCEED_PROCESSING\n # proceed_amount += card_sub_task.service_cards.count\n # end\n # end\n return percentagere = \"#{sprintf(\"%.1f\", proceed_amount.to_i / total_amount.to_f * 100)}%\"\n end",
"def progress(arr, options = {})\n bar = ProgressBar.new arr.length, options\n bar.show\n arr.each { |v| bar.increment yield(v) }\n end",
"def generic_recipe_step\n puts \"On it!\"\n print_progress_bar\nend",
"def generic_recipe_step\n puts \"On it!\"\n print_progress_bar\nend",
"def generic_recipe_step\n puts \"On it!\"\n print_progress_bar\nend",
"def show_progress\n progress_string=''\n @word_to_guess.each do |letter_in_word_to_guess|\n if has_been_guessed_correctly?(letter_in_word_to_guess)\n progress_string += letter_in_word_to_guess\n else\n progress_string += '_'\n end\n end\n return progress_string\n end",
"def update_progress(steps)\n return unless progress_printer\n unless @progress_printer_instance\n total_records =\n session.left.select_one(\"select count(*) as n from #{session.left.quote_table_name(left_table)}\")['n'].to_i +\n session.right.select_one(\"select count(*) as n from #{session.right.quote_table_name(right_table)}\")['n'].to_i\n @progress_printer_instance = progress_printer.new(total_records, session, left_table, right_table)\n end\n @progress_printer_instance.step(steps)\n end",
"def progress_mark; end",
"def final_summary\n puts\n puts <<-eos\n --------------------------------------------------------------------------\n Complete Summary:\n Execution time: #{as_time_elapsed(Time.now - @start)}\n\n Up To Date: #{@uptodate}\n\n Failures: #{@failed}\n\n Added: #{@added}\n Updated: #{@updated}\n Bytes copied: #{as_byte_size(@copied_bytes)}\n\n Removed: #{@removed}\n Bytes freed: #{as_byte_size(@freed_bytes)}\n --------------------------------------------------------------------------\n eos\n puts\n STDOUT.flush\n end",
"def progress(run)\n return unless run.started?\n\n progress = Progress.new(run)\n\n progress_bar = tag.progress(\n value: progress.value,\n max: progress.max,\n class: [\"progress\"] + STATUS_COLOURS.fetch(run.status)\n )\n progress_text = tag.p(tag.i(progress.text))\n tag.div(progress_bar + progress_text, class: \"block\")\n end",
"def carp(job, state = 'done'.green, v = 1)\n return if @verbose < v\n dots = 70 - job.size\n job += ' ' + '.' * dots if dots > 0\n puts job + ' ' + state\n end",
"def images_conversion_progress\n return (\"%.2f\" % (number_of_completed_images * 1.0 / self.number_of_images_entry)).to_f if self.is_pdf_convertible? \n return 1\n end",
"def print_output\r\n\t\t\tprint \"Files: #@num_files \\n\"\r\n\t\t\tprint \"Lines of Code: #@total \\n\"\r\n\t\t\tprint \"Blank Lines: #@blank_lines \\n\"\r\n\t\t\tprint \"Total Lines: #@lines\"\r\n\t\tend",
"def update_progress(total, done)\n percentage = total.zero? ? 100 : ((done.to_f / total) * 100).to_i\n progress(percentage)\n end",
"def progress(status)\n #For each SUT\n $sut.each do |ip, sut|\n #We check the status that we determined earlier,\n #depending on it we call the progress functions\n if status[ip]['status'] == 'Autotest'\n autotestprogress(status, sut, ip)\n elsif status[ip]['status'] == 'Stability'\n stabilityprogress(status, sut, ip)\n elsif status[ip]['status'] == 'CanWakeupTest'\n status[ip]['progress'] == 'Not implemented'\n elsif status[ip]['status'] == 'Manual'\n #If the test is manual, we just say it is not implemented yet. Do not know if it ever will,\n #because it is kind of impossible to know where manual test results will be saved.\n status[ip]['progress'] = 'Not implemented'\n elsif status[ip]['status'] == \"Idle\"\n latest = `ls -td #{$autotestpath}#{sut[:name]}*/ | head -n 1`[0...-1]\n latest = `ls -td #{latest}2017*/ | head -n 1`[0...-1]\n failed = `find #{latest} -name *TestRun.txt`[0...-1]\n if failed == '' && latest != ''\n status[ip]['progress'] = \"Last test failed to proceed\"\n status[ip]['progresscolor'] = \"color:red;\"\n else\n #Idle will be shown as empty in progress tab\n status[ip]['progress'] = ' '\n status[ip]['progresscolor'] = \"color:white;\"\n end\n end\n end\nend",
"def progress_rate\n 1\n end",
"def perform\n total = options['length'].to_i || 10\n num = 0\n while num < total\n at(num, total, \"At #{num} of #{total}\")\n sleep(1)\n num += 1\n end\n completed\n end",
"def order\n header_length = 80\n all_rolls = sorted_rolls\n self.progressbar = ProgressBar.create(:progress_mark => '='.colorize(:green), :length => header_length, :total => all_rolls.length)\n\n # pre installs\n #\n # Yuyi.say '=' * header_length, :color => :green\n Yuyi.say 'APPETIZERS', :justify => :center, :padding => header_length\n\n self.progressbar.reset\n all_rolls.each do |file_name|\n @rolls[file_name].appetizers\n self.progressbar.increment\n end\n Yuyi.say\n\n\n # main installs\n #\n # Yuyi.say '=' * header_length, :color => :green\n Yuyi.say 'ENTREES', :justify => :center, :padding => header_length\n\n self.progressbar.reset\n all_rolls.each do |file_name|\n @rolls[file_name].entree\n self.progressbar.increment\n end\n Yuyi.say\n\n\n # post installs\n #\n # Yuyi.say '=' * header_length, :color => :green\n Yuyi.say 'DESSERT', :justify => :center, :padding => header_length\n\n self.progressbar.reset\n all_rolls.each do |file_name|\n @rolls[file_name].dessert\n self.progressbar.increment\n end\n Yuyi.say\n\n\n Yuyi.say 'YUYI COMPLETED', :color => :light_blue, :justify => :center, :padding => header_length\n Yuyi.say '=' * header_length, :color => :light_blue\n Yuyi.say\n end",
"def run_with_progress(message, size, progr = nil, &block)\n if(progr_object = (progr || progressor))\n progr_object.run_with_progress(message, size, &block)\n else\n dummy_prog = Object.new\n class << dummy_prog\n def inc\n end\n end\n block.call(dummy_prog)\n end\n end",
"def progress\n data.progress\n end",
"def progress\n return @progress\n end",
"def progress_stats\n word_count = Float(Word.all.length)\n quizzed_count = Float(Quiz.all.uniq { |noun| noun.word_id }.length)\n rate = quizzed_count / word_count\n rate.round(2) * 100\n end",
"def inc_progress(activity_rank)\n #diff = (@rank - activity_rank).abs\n ranks = [-8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8]\n true_diff = ranks.index(activity_rank) - ranks.index(@rank)\n if true_diff < 0\n if true_diff <= -2\n nil\n else\n @progress += 1\n end\n elsif true_diff == 0\n @progress += 3\n else\n @progress += (10*true_diff*true_diff)\n end\n while @progress >= 100\n self.increase_rank\n @progress -= 100\n end\n end",
"def check_progress\n succeed(self) if finished?\n end",
"def approximate_pi\n puts \"each dot is #{PROGRESSOR_SAMPLE_PERIOD} picks out of #{NUMBER_OF_SAMPLES} total samples\"\n\n running_total_of_circle_hits = 0\n\n NUMBER_OF_SAMPLES.times do |i|\n running_total_of_circle_hits += 1 if random_coordinate_inside_unit_circle\n\n print_progress_bar_at i\n end\n\n puts '' # ends the progress bar\n\n (4.0 * running_total_of_circle_hits) / NUMBER_OF_SAMPLES\nend",
"def final_metrics\n Rails.logger.info(\"\\n \\n Priority sync finished at #{Time.zone.now} \\n \\n EPs attempted to sync: #{@run_log.size} \\n EPs successfully synced: #{@run_log.size - @error_log.size} \\n EPs errored: #{@error_log.size} \\n\")\n end",
"def report_progress\n backup_size = (@backup.size + @backup.wal_file_size) / 1024 ** 2\n du = target_path_exists? ? target_path_disk_usage / 1024 ** 2 : 0\n percent = du.to_f / backup_size.to_f * 100\n percent = 100.0 if percent >= 100.0\n message = \"#{percent.to_i}% of Backup #{@backup.id} (#{@backup.server}) recovered\" \n at(percent.to_i, 100, message)\n @log.info(message)\n end",
"def progress(object)\n reporter.progress(object)\n end",
"def progress(*args, &block)\n @@progress_block = block if block\n @@progress_block.call(*args) if defined?(@@progress_block) && args.length>0\n end",
"def number_of_produce\n puts \"There are #{@produce_left} #{@produce}s left on your #{@type} tree.\"\n end",
"def print_course_class_total_item_counts\n puts \"=> Course Class Total Item Counts\"\n @course_classes.each do |course_class|\n puts \"% 20s % 4d\" % [ course_class, course_class.count ]\n end\n end",
"def start_progress(max_progress)\n @show_progress = true\n @max_progress = max_progress\n @progress = 0\n display\n end",
"def update_window_title_and_progressbar\n all = @all_failed_questions.size\n\n # find index of current question, set to 0 if not found\n current = @all_failed_questions.index { |q| q[1] == current_question}\n current ||= -1\n current += 1\n\n corr = @corrected.size\n\n if @prog\n count = \"Fixed: #{corr} / #{all}\"\n if all == count || all == 0 && count == 0\n @prog.text = \"All done!\"\n @prog.fraction = 1\n else\n @prog.text = count\n @prog.fraction = corr.to_f / all.to_f\n end\n end\n\n title = []\n title << \"PEST: Fix\"\n title << \"Viewing: #{current} / #{all}\"\n title << count if count\n if current_question\n title << \"Question: #{current_question[\"question\"].db_column}\"\n title << current_path\n end\n @window.set_title title.join(\" | \")\n end",
"def progress(percentage, description = nil)\n reply({:progress => percentage, :description => description}, {:message_type => 'progress'})\n end",
"def inc number=0.0\n\t\t@progress_bar.fraction = (@prog += number)\n\tend"
] |
[
"0.7286469",
"0.6606537",
"0.6606537",
"0.6606537",
"0.6606537",
"0.6606537",
"0.6561013",
"0.65301615",
"0.6503656",
"0.64372945",
"0.63917756",
"0.63744324",
"0.63731664",
"0.63432467",
"0.63100976",
"0.6208046",
"0.6141926",
"0.6137373",
"0.6123387",
"0.6123387",
"0.6123387",
"0.6120851",
"0.61131227",
"0.6111462",
"0.6073504",
"0.6063105",
"0.6050203",
"0.6032532",
"0.602139",
"0.6004525",
"0.5995598",
"0.5954433",
"0.5954433",
"0.5954433",
"0.5954433",
"0.59511",
"0.59406674",
"0.59291327",
"0.59262776",
"0.5918463",
"0.59138477",
"0.59057957",
"0.58844256",
"0.5869537",
"0.58538395",
"0.58326644",
"0.58319706",
"0.5818745",
"0.5814508",
"0.57964694",
"0.57721317",
"0.57655406",
"0.5757625",
"0.574418",
"0.573931",
"0.5707981",
"0.56991476",
"0.56661",
"0.56596994",
"0.56581",
"0.56432563",
"0.5605948",
"0.56050473",
"0.5575314",
"0.5556923",
"0.55538243",
"0.5545904",
"0.5538723",
"0.5538723",
"0.5538723",
"0.5501622",
"0.5499774",
"0.5486832",
"0.5477983",
"0.54711425",
"0.5462692",
"0.54591864",
"0.5448387",
"0.5413472",
"0.54103523",
"0.5406688",
"0.54052037",
"0.537767",
"0.5358087",
"0.534261",
"0.5324406",
"0.5307206",
"0.53029644",
"0.5299384",
"0.5293884",
"0.52937746",
"0.52782845",
"0.52627856",
"0.5257102",
"0.524654",
"0.5232876",
"0.5226588",
"0.522611",
"0.5226095",
"0.5225141"
] |
0.7456358
|
0
|
Prints a summary section for the entire report
|
def print_summary
puts "\n\nScore : # Instances\n" << ("=" * 19)
@summary_totals.each_with_index { |value, index| puts " %5d:%8d\n" % [index, value] unless value.nil? }
puts "\n** End of Report"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def summary\n \n end",
"def dump_summary( summary )\n\t\thtml = self.render_summary( summary )\n\t\t@output.puts( html )\n\t\t@output.flush\n\tend",
"def summary\n end",
"def summary\n end",
"def summary\n # TODO\n end",
"def summary; end",
"def summary; end",
"def summary; end",
"def summary; end",
"def summary\n #render unless @output\n @summary\n end",
"def print_summary(ui)\n # Print whether it passed/failed at the top\n if failed?\n ui.puts \"\\n[!] Failed\\n\".red\n else\n ui.notice \"Passed\"\n end\n\n # A generic proc to handle the similarities between\n # errors and warnings.\n do_rules = proc do |name, rules|\n unless rules.empty?\n ui.puts \"\"\n ui.section(name.bold) do\n rules.each do |rule|\n title = rule.title.bold + \" - #{rule.object_applied_to}\"\n subtitles = [rule.description, link(rule.ref)]\n subtitles += [rule.metadata[:files].join(\":\")] if rule.metadata[:files]\n ui.labeled(title, subtitles)\n ui.puts \"\"\n end\n end\n end\n end\n\n # Run the rules\n do_rules.call(\"Errors\".red, errors)\n do_rules.call(\"Warnings\".yellow, warnings)\n end",
"def print_summary\r\n traverse do |node|\r\n print node.effectively_skipped? ? '-' : '+'\r\n case\r\n when node.test? then print 'T'\r\n when node.suite? then print 'S'\r\n when node.static? then print 'X'\r\n else print '?'\r\n end\r\n print node.indented_name(' ')\r\n tags = node.effective_tags.to_a\r\n unless tags.empty?\r\n # highlight the tags that are explicit on this node\r\n tags = tags.map {|tag| node.explicit_tags.include?(tag) ? \"*#{tag}\" : tag }\r\n print \" [#{tags.join(',')}]\"\r\n end\r\n print \"\\n\"\r\n end\r\n end",
"def render_summary\n summary = nil\n\n end",
"def print_summary\n stats = [statistics[:total_code_loc], statistics[:total_spec_loc]]\n stats.push(stats[1].to_f / stats[0].to_f)\n \n puts \" Code LOC: %s Test LOC: %s Code to Test Ratio: 1:%1.1f\" % stats\n puts\n end",
"def summary\n {}\n end",
"def puts_summary(io)\n io.puts(\"\\n#{[coverage_text, successful_text, failed_text, total_text].join(' ')}\")\n end",
"def stats_summary\n html = \"\"\n %w(inhale exhale cycle).each do |phase|\n %w(min max avg).each do |stat|\n time = format_time(self.meditations.map {|med| med.send(phase + \"_\" + stat)}.max)\n html += \"record #{phase} #{stat}: #{time}<br>\"\n end\n end\n html\n end",
"def summarize(summary_logger)\n summary_logger.notify <<-HEREDOC\n Test Suite: #{@name} @ #{start_time}\n\n - Host Configuration Summary -\n HEREDOC\n\n average_test_time = elapsed_time / test_count\n\n summary_logger.notify format(%[\n\n - Test Case Summary for suite '#{@name}' -\n Total Suite Time: %.2f seconds\n Average Test Time: %.2f seconds\n Attempted: #{test_count}\n Passed: #{passed_tests}\n Failed: #{failed_tests}\n Errored: #{errored_tests}\n Skipped: #{skipped_tests}\n Pending: #{pending_tests}\n Total: #{@total_tests}\n\n - Specific Test Case Status -\n ], elapsed_time, average_test_time)\n\n grouped_summary = @test_cases.group_by { |test_case| test_case.test_status }\n\n summary_logger.notify \"Failed Tests Cases:\"\n (grouped_summary[:fail] || []).each do |test_case|\n summary_logger.notify print_test_result(test_case)\n end\n\n summary_logger.notify \"Errored Tests Cases:\"\n (grouped_summary[:error] || []).each do |test_case|\n summary_logger.notify print_test_result(test_case)\n end\n\n summary_logger.notify \"Skipped Tests Cases:\"\n (grouped_summary[:skip] || []).each do |test_case|\n summary_logger.notify print_test_result(test_case)\n end\n\n summary_logger.notify \"Pending Tests Cases:\"\n (grouped_summary[:pending] || []).each do |test_case|\n summary_logger.notify print_test_result(test_case)\n end\n\n summary_logger.notify(\"\\n\\n\")\n end",
"def summary\n calculate\n\n num_width = [@num_files, @num_items].max.to_s.length\n undoc_width = [\n @undoc_attributes,\n @undoc_classes,\n @undoc_constants,\n @undoc_items,\n @undoc_methods,\n @undoc_modules,\n @undoc_params,\n ].max.to_s.length\n\n report = RDoc::Markup::Verbatim.new\n\n report << \"Files: %*d\\n\" % [num_width, @num_files]\n\n report << \"\\n\"\n\n report << \"Classes: %*d (%*d undocumented)\\n\" % [\n num_width, @num_classes, undoc_width, @undoc_classes]\n report << \"Modules: %*d (%*d undocumented)\\n\" % [\n num_width, @num_modules, undoc_width, @undoc_modules]\n report << \"Constants: %*d (%*d undocumented)\\n\" % [\n num_width, @num_constants, undoc_width, @undoc_constants]\n report << \"Attributes: %*d (%*d undocumented)\\n\" % [\n num_width, @num_attributes, undoc_width, @undoc_attributes]\n report << \"Methods: %*d (%*d undocumented)\\n\" % [\n num_width, @num_methods, undoc_width, @undoc_methods]\n report << \"Parameters: %*d (%*d undocumented)\\n\" % [\n num_width, @num_params, undoc_width, @undoc_params] if\n @coverage_level > 0\n\n report << \"\\n\"\n\n report << \"Total: %*d (%*d undocumented)\\n\" % [\n num_width, @num_items, undoc_width, @undoc_items]\n\n report << \"%6.2f%% documented\\n\" % percent_doc\n report << \"\\n\"\n report << \"Elapsed: %0.1fs\\n\" % (Time.now - @start)\n\n RDoc::Markup::Document.new report\n end",
"def summary\n summary = \"\n - Name: #{@name}\n - Color: #{@color}\n - Mass (in kg): #{@mass_kg}\n - Distance From Sun (in km): #{@distance_from_sun_km}\n - Fun Fact: #{@fun_facts}\"\n\n #returns summary as string\n return summary\n end",
"def summary_report(problems)\n summary_table = summary_header\n i = 0\n\n problems.each do |file, problem_list|\n report_line = summary_file_line(file, problem_list)\n\n report_line = if i % 2 == 1\n on_intense_black { report_line }\n else\n bold { report_line }\n end\n\n summary_table << '# ' << report_line << reset << \"|\\n\"\n i += 1\n end\n\n summary_table << line\n summary_table << summary_level_totals(problems)\n summary_table << '# ' << bold{ summary_first_col('TOTAL', 67) }\n summary_table << '|'\n summary_table << bold { total_problems(problems).to_s.rjust(6) }\n summary_table << \" |\\n\"\n summary_table << line\n\n puts summary_table\n end",
"def dump_summary *args; end",
"def summary\n summary =\n \" - Name: #{@name}\\n\"+\n \" - Color: #{@color}\\n\"+\n \" - Mass (in kg): #{@mass_kg}kg\\n\"+\n \" - Distance From Sun (in km): #{@distance_from_sun_km} million km.\\n\"+\n \" - Fun Fact: #{@fun_fact}\"\n return summary\n end",
"def summary\n report = raw_summary\n\n ret = \"\"\n report.keys.sort { |a,b| a.to_s <=> b.to_s }.each do |key|\n ret += \"#{Puppet::Util::Metric.labelize(key)}:\\n\"\n\n report[key].keys.sort { |a,b|\n # sort by label\n if a == :total\n 1\n elsif b == :total\n -1\n else\n report[key][a].to_s <=> report[key][b].to_s\n end\n }.each do |label|\n value = report[key][label]\n next if value == 0\n value = \"%0.2f\" % value if value.is_a?(Float)\n ret += \" %15s %s\\n\" % [Puppet::Util::Metric.labelize(label) + \":\", value]\n end\n end\n ret\n end",
"def summary\n report = raw_summary\n\n ret = \"\"\n report.keys.sort_by(&:to_s).each do |key|\n ret += \"#{Puppet::Util::Metric.labelize(key)}:\\n\"\n\n report[key].keys.sort { |a,b|\n # sort by label\n if a == TOTAL\n 1\n elsif b == TOTAL\n -1\n else\n report[key][a].to_s <=> report[key][b].to_s\n end\n }.each do |label|\n value = report[key][label]\n next if value == 0\n value = \"%0.2f\" % value if value.is_a?(Float)\n ret += \" %15s %s\\n\" % [Puppet::Util::Metric.labelize(label) + \":\", value]\n end\n end\n ret\n end",
"def print_summary\n update_now_date_time\n calc_difference\n puts \"#{DueText.minutes} #{till_or_since}: \\t #{calc_mins_till.round(2)} #{DueText.minutes_suffix} \\n\n #{DueText.hours} #{till_or_since}: \\t #{calc_hours_till.round(2)} #{DueText.hours_suffix} \\n\n #{DueText.days} #{till_or_since}: \\t #{calc_days_till.round(2)} #{DueText.days_suffix} \\n\n #{DueText.weeks} #{till_or_since}: \\t #{calc_weeks_till.round(2)} #{DueText.weeks_suffix} \\n\n #{DueText.months} #{till_or_since}: \\t #{calc_months_till.round(2)} #{DueText.months_suffix} \\n\n #{DueText.years} #{till_or_since}: \\t #{calc_years_till.round(2)} #{DueText.years_suffix}\"\n end",
"def print_report\n sum = 0.0\n puts \"\\nSummary:\"\n puts '-'*8\n @days.each do |day|\n puts \"#{day[:day].strftime(\"%m/%d/%y\")}, %.2f hours\" % day[:hours]\n sum += day[:hours]\n end\n puts \"\\nTotal hours = %.2f\" % sum\n days = elapsed_days(@days[0][:day])\n puts \"Elapsed days = %d\" % days\n puts \"Average hrs per week = %.2f\" % (sum / (days / 7.0))\n puts\n end",
"def print_report(total_contacts, duplicate_contacts, invalid_contacts)\n print \"Summary:\\n\"\n print \"Total Valid Contacts: #{total_contacts}\\nDuplicate Contacts: #{duplicate_contacts}\\nInvalid Contacts: #{invalid_contacts}\\n\\n\"\n end",
"def summary\n @errors_file.write \"\\n =Summary=\"\n @errors_file.write \"\\n ==========================================================================================================\"\n @errors_file.write \"\\n API: #{@url}\"\n @errors_file.write \"\\n MSISDN: #{@MSISDN}\"\n @errors_file.write \"\\n Number of Requests: #{@number_of_requests-1}\"\n @errors_file.write \"\\n Number of Errors/Timeouts: #{@number_of_timeouts}\"\n @errors_file.write \"\\n Avg Response Time: #{@resonse_time/@total_number_of_requests}\"\n @errors_file.write \"\\n Max Response Time: #{@max_resonse_time}\"\n @errors_file.write \"\\n Max Response Time: #{@min_resonse_time}\"\n @errors_file.write \"\\n ==========================================================================================================\"\n summary_print\nend",
"def summary(workspace_id, params={})\n get_report('summary', workspace_id, params)\n end",
"def summary\n resource = pointer[\"resource\"]\n content, id = self.get_page_content\n line_limit = @ruhoh.db.config(resource)['summary_lines']\n line_count = 0\n line_breakpoint = content.lines.count\n\n content.lines.each_with_index do |line, i|\n if line =~ /^\\s*$/ # line with only whitespace\n if line_count >= line_limit\n line_breakpoint = i\n break\n end\n else\n line_count += 1\n end\n end\n\n summary = content.lines.to_a[0, line_breakpoint].join\n\n # The summary may be missing some key items needed to render properly.\n # So search the rest of the content and add it to the summary.\n content.lines.with_index(line_breakpoint) do |line, i|\n # Add lines containing destination urls.\n if line =~ /^\\[[^\\]]+\\]:/\n summary << \"\\n#{line}\"\n end\n end\n\n summary = master.render(summary)\n Ruhoh::Converter.convert(summary, id)\n end",
"def print_summary(dsobj)\n dshash = get_dshash(dsobj)\n ds_pollint_m = dshash['pollint_s'].to_i / 60\n dp_alert_count = 0.to_i\n\n # iterate over each datapoint\n dshash['datapoints'].each { |datapoint|\n dphash = get_dphash(datapoint)\n\n # is the alert trigger set on this datapoint\n if ( dphash['alert_trigger'].size > 0 )\n # yes, increment the alert count var\n dp_alert_count += 1\n end\n\n }\n\n puts \"Summary:\\n\"\n\n puts \" - datasource name:\\t\" + dshash['name'] + \"\\n\"\n puts \" - display name:\\t\" + dshash['dname'] + \"\\n\"\n puts \" - applies to:\\t\\t\" + dshash['applies'] + \"\\n\"\n puts \" - search keywords:\\t\" + dshash['tags'] + \"\\n\"\n puts \" - polling interval:\\t\" + ds_pollint_m.to_s + \"m\\n\"\n puts \" - multi instance:\\t\" + dshash['multi'] + \"\\n\"\n puts \" - datapoints:\\t\\t\" + dshash['datapoints'].size.to_s + \"\\n\"\n puts \" - datapoint alerts:\\t\" + dp_alert_count.to_s + \"\\n\"\n puts \" - graphs:\\t\\t\" + dshash['graphs'].size.to_s + \"\\n\"\n puts \" - overview graphs:\\t\" + dshash['ographs'].size.to_s + \"\\n\"\n puts \"=====================\\n\"\n end",
"def create_summary\r\n puts \"Creating a summary...\"\r\n #@lists.disp_summary\r\n create_html_summary\r\n file = File.open('test.html','w')\r\n file << @html\r\n file.close\r\n end",
"def project_summary\n move_down 50\n summary = [[\"Project Summary\",\"\",\"\",\"\"],\n [\"Project Name\",\"Sales Person\",\"Project Status\",\"No. of Sites\"],\n [@project.project_name, \"#{@project.sales_person.sales_person_first_name} #{@project.sales_person.sales_person_last_name}\", @project.project_status.project_status_name ,@project.project_sites.count],\n [\"Project Setting\",\"Procurement Tool\",\"Deal Type\",\"Irrigation Responsibility\"],\n [@project.project_setting.project_setting_name,@project.procurement_tool.procurement_tool_name,@project.deal_type.deal_type_name,@project.irrigation_responsibility.irrigation_responsibility_name]\n ]\n table summary do\n rows(0..1).font_style = :bold\n row(3).font_style = :bold\n rows(0).background_color = \"a414e2\"\n rows(0).text_color = \"FFFFFF\"\n self.row_colors = [\"addbed\",\"25b2ea\"]\n column(0).width = 160\n column(1).width = 125\n column(2).width = 126\n column(3).width = 126\n columns(0..3).size = 10\n column(0).row(0).borders = :top, :left\n columns(1..2).row(0).borders = :top, :bottom\n column(3).row(0).borders = :top, :bottom, :right\n end\n end",
"def summary\n if key? 'summary'\n self['summary'].to_s.thru_erb.to_html\n else\n case html.gsub(%r{<(h\\d).*?>.*?</\\1>}m, '') # omit headings from summary\n\n # the first HTML block-level element\n when %r{\\A\\s*<(\\w+).*?>.*?</\\1>}m\n $&\n\n # the first paragraph (a run of text delimited by newlines)\n when /\\A.*?(?=\\r?\\n\\s*\\r?\\n)/m\n $&\n\n end\n end\n end",
"def summaryX\n render :layout => \"general\"\n end",
"def final_summary\n puts\n puts <<-eos\n --------------------------------------------------------------------------\n Complete Summary:\n Execution time: #{as_time_elapsed(Time.now - @start)}\n\n Up To Date: #{@uptodate}\n\n Failures: #{@failed}\n\n Added: #{@added}\n Updated: #{@updated}\n Bytes copied: #{as_byte_size(@copied_bytes)}\n\n Removed: #{@removed}\n Bytes freed: #{as_byte_size(@freed_bytes)}\n --------------------------------------------------------------------------\n eos\n puts\n STDOUT.flush\n end",
"def print_stats\n puts \"==================================================\"\n puts \"================= Statistics =====================\"\n puts \"==================================================\"\n \n calc_stats()\n \n puts \"Total Records = #{@total_rec_cnt}\"\n puts \"Well Formed Records = #{@well_formed_rec_cnt}\"\n puts \"Malformed Records = #{@malformed_rec_cnt}\"\n puts \"Unique Business Records = #{@biz_rec_cnt}\"\n puts \"Unique User Records = #{@user_rec_cnt}\"\n puts \"\"\n end",
"def summary\n divider = \"-\" * 60\n \"#{divider}\\n#{title}\\n#{divider}\\nReleased: \" +\n \"#{release_date.strftime(\"%d %b %Y\")}\\n#{divider}\\n#{plot}\\n#{divider}\" +\n \"\\nCast: #{cast}\\n#{divider}\\n#{rating_summary}\\n\"\n end",
"def print_header\n unless @detailed.nil?\n puts sprintf('%-30s %-10s %-10s', 'Time', 'Req/s', 'Avg resp (ms)')\n end\n end",
"def Summary\n summary = \"\"\n # translators: summary header for messages generated through autoinstallation\n summary = Summary.AddHeader(summary, _(\"Messages\"))\n summary = Summary.OpenList(summary)\n\n # Report configuration - will be normal messages displayed?\n # '%1' will be replaced by translated string \"Yes\" or \"No\"\n summary = Summary.AddListItem(\n summary,\n Builtins.sformat(\n _(\"Display Messages: %1\"),\n @display_messages ?\n # translators: summary if the messages should be displayed\n _(\"Yes\") :\n _(\"No\")\n )\n )\n # Report configuration - will have normal messages timeout?\n # '%1' will be replaced by number of seconds\n summary = Summary.AddListItem(\n summary,\n Builtins.sformat(_(\"Time-out Messages: %1\"), @timeout_messages)\n )\n # Report configuration - will be normal messages logged to file?\n # '%1' will be replaced by translated string \"Yes\" or \"No\"\n summary = Summary.AddListItem(\n summary,\n Builtins.sformat(\n _(\"Log Messages: %1\"),\n @log_messages ?\n # translators: summary if the messages should be written to log file\n _(\"Yes\") :\n _(\"No\")\n )\n )\n summary = Summary.CloseList(summary)\n # translators: summary header for warnings generated through autoinstallation\n summary = Summary.AddHeader(summary, _(\"Warnings\"))\n summary = Summary.OpenList(summary)\n # Report configuration - will be warning messages displayed?\n # '%1' will be replaced by translated string \"Yes\" or \"No\"\n summary = Summary.AddListItem(\n summary,\n Builtins.sformat(\n _(\"Display Warnings: %1\"),\n @display_warnings ?\n # translators: summary if the warnings should be displayed\n _(\"Yes\") :\n _(\"No\")\n )\n )\n # Report configuration - will have warning messages timeout?\n # '%1' will be replaced by number of seconds\n summary = Summary.AddListItem(\n summary,\n Builtins.sformat(_(\"Time-out Warnings: %1\"), @timeout_warnings)\n )\n # Report configuration - will be warning messages logged to file?\n # '%1' will be replaced by translated string \"Yes\" or \"No\"\n summary = Summary.AddListItem(\n summary,\n Builtins.sformat(\n _(\"Log Warnings: %1\"),\n @log_warnings ?\n # translators: summary if the warnings should be written to log file\n _(\"Yes\") :\n _(\"No\")\n )\n )\n summary = Summary.CloseList(summary)\n # translators: summary header for errors generated through autoinstallation\n summary = Summary.AddHeader(summary, _(\"Errors\"))\n summary = Summary.OpenList(summary)\n # Report configuration - will be error messages displayed?\n # '%1' will be replaced by translated string \"Yes\" or \"No\"\n summary = Summary.AddListItem(\n summary,\n Builtins.sformat(\n _(\"Display Errors: %1\"),\n @display_errors ?\n # translators: summary if the errors should be displayed\n _(\"Yes\") :\n _(\"No\")\n )\n )\n # Report configuration - will have error messages timeout?\n # '%1' will be replaced by number of seconds\n summary = Summary.AddListItem(\n summary,\n Builtins.sformat(_(\"Time-out Errors: %1\"), @timeout_errors)\n )\n # Report configuration - will be error messages logged to file?\n # '%1' will be replaced by translated string \"Yes\" or \"No\"\n summary = Summary.AddListItem(\n summary,\n Builtins.sformat(\n _(\"Log Errors: %1\"),\n @log_errors ?\n # translators: summary if the errors should be written to log file\n _(\"Yes\") :\n # translators: summary if the errors should be written to log file\n _(\"No\")\n )\n )\n summary = Summary.CloseList(summary)\n # summary = Summary::AddHeader(summary, _(\"Yes or No Messages (Critical Messages)\"));\n # summary = Summary::OpenList(summary);\n # // Report configuration - will be error messages displayed?\n # // '%1' will be replaced by translated string \"Yes\" or \"No\"\n # summary = Summary::AddListItem(summary, sformat(_(\"Display Yes or No Messages: %1\"), (display_yesno_messages) ?\n # \t\t\t\t\t\t _(\"Yes\") : _(\"No\")));\n # // Report configuration - will have error messages timeout?\n # // '%1' will be replaced by number of seconds\n # summary = Summary::AddListItem(summary, sformat(_(\"Time-out Yes or No Messages: %1\"), timeout_yesno_messages));\n # // Report configuration - will be error messages logged to file?\n # // '%1' will be replaced by translated string \"Yes\" or \"No\"\n # summary = Summary::AddListItem(summary, sformat(_(\"Log Yes or No Messages: %1\"), (log_yesno_messages) ?\n # \t\t\t\t\t\t _(\"Yes\") : _(\"No\")));\n # summary = Summary::CloseList(summary);\n summary\n end",
"def summary\n authenticated_post(\"summary\").body\n end",
"def summarise\n headerless = self.body.gsub(/\\<h\\d.*?\\>.*?\\<\\/h\\d\\>/m, '')\n summary = ActionView::Base.full_sanitizer.sanitize(headerless).strip.match(/^(.+?)[\\.\\r\\n]/m)&.captures&.first || self.title\n\n return \"#{ summary }.\"\n end",
"def run\n\t\t\tsummary\n\t\tend",
"def draw_summary_table\n header = [\"Date\", \"Issue Number\", \n \"Total Subscribers\", \"Change in Subscribers\"]\n\n body = report.table(:date,:number,:count,:delta)\n\n document.table([header]+body) do |t|\n t.header = true\n t.style(t.columns(1..-1)) { |c| c.align = :right }\n end\n end",
"def summary_table\n update_now_date_time\n calc_difference\n labels = [DueText.period, ' ', DueText.duration, DueText.measure]\n rows = summary_array\n puts tabulate(labels, rows, { 'indent' => 4, 'style' => 'fancy' })\n end",
"def summary_at_exit\n reporter = Speciny::Reporter.new(@description)\n @tests.each do |example, result|\n reporter.print_test_result(example, result)\n end\n end",
"def html_report_stats\n @report << '<div id=\"title\"> General Statistics</div>'\n stat_tab = Ruport::Data::Table(%w[Stat Value])\n stat_tab << ['Number of servers Seen', @num_servers]\n stat_tab << ['Number of clients Seen', @num_clients]\n @num_by_cipher.each do |cipher, num|\n stat_tab << ['Encryption: ' + cipher, num]\n end\n @report << stat_tab.to_html\n @report << '<br /><br />'\n end",
"def summary\n comment = @policy.describe(@grades)\n if (comment)\n comment = \" (#{comment})\"\n else\n comment = \"\"\n end\n mygrade = grade\n if mygrade\n mygrade = \"#{mygrade.round(1)}\"\n else\n mygrade = \"[No grades available]\"\n end\n if ((0 == @percent) || (100 == @percent) || (-100 == @percent)) \n dots = @@dots[@type.length + 1 .. -1]\n puts \"#{@type} #{dots}: #{mygrade}#{comment}\"\n else\n dots = @@dots[@type.length + 9 .. -1]\n percentText = \"#{@percent.round(1)}\"\n if (@percent < 10) \n percentText = \" #{percentText}\"\n end\n puts \"#{@type} #{dots} (#{percentText}%): #{mygrade}#{comment}\"\n end\n end",
"def write_to_screen!\n puts report_title\n puts report_body.lines.take(show_count)\n end",
"def summary *args\n @summary = args.first if args.size > 0\n end",
"def summary\n summary =\"Planet #{name} is the color #{color} and it weights #{mass_kg}. and its #{distance_from_sun_km} km away from the sun. Here's a fun fact: #{fun_fact}.\"\n return summary\n end",
"def summary\n \"Results: #{results[:critical].size} critical, \" \\\n \"#{results[:warning].size} warning, \" \\\n \"#{results[:unknown].size} unknown, #{results[:ok].size} ok\"\n end",
"def show_summary!\n @runopts[:show_log] = false\n end",
"def summary\n @items.map { |i| \"* #{i.title}\" }.join(\"\\n\")\n end",
"def summarize!\n %i[critical warning unknown].each do |status|\n send(status, summary) unless results[status].empty?\n end\n ok(summary)\n end",
"def define_summary(name, opts = {}, &block)\n define_metric(:summary, name, opts, &block)\n end",
"def summary_detail\n Classifieds::Listing.format_cols([@name, @location], SUMMARY_COL_FORMATS)\n end",
"def display_results\n print_header\n print_detailed_report\n write_csv_report\n display_status\n end",
"def summary\n\t\tobject.summary || \"\"\n\tend",
"def summary\n @data['summary']\n end",
"def summary\n return @summary\n end",
"def summary\n return @summary\n end",
"def summary\n return @summary\n end",
"def summary\n \"#{name} (#{email})\"\n end",
"def summary(text)\n Runner.instance.summary = text\n end",
"def summary\n response = get \"summary\", {}\n Hashie::Mash.new(response)\n end",
"def dump_summary(duration, example_count, failure_count, pending_count)\n end",
"def dump_summary(duration, example_count, failure_count, pending_count)\n end",
"def dump_summary(*args)\n output.puts super(*args).to_yaml\n output.puts \"...\"\n end",
"def print_report\n # total_bikes = @fleet.count \n # broken_bikes = @fleet.count {|b| b.is_broken?}\n # working_bikes = total_bikes-broken_bikes\n total_people = @people.count\n total_stations = @stations.count\n # show_stations = @stations.each do {|name, capacity| puts \"#{name}, #{capacity}\"}\n #tell me its name and capcity\n # puts \"Total bikes: #{total_bikes}\"\n # puts \"Broken bikes: #{broken_bikes}\"\n # puts \"Working bikes: #{working_bikes}\"\n puts \"Total people: #{total_people}\"\n # puts \"People with bikes: #{people_with_bikes}\"\n puts \"People without bikes #{people_without_bikes.count}\" \n puts \"Number of stations: #{total_stations}\" \n puts \"Stations:\"\n @stations.each do |station|\n puts \"#{station.name}, #{station.capacity}, #{station.bikes.count}\"\n end\n # result = \"total bikes #{total_bikes}\\n\" + \"broken bikes #{broken_bikes}\\n\" + \"working bikes #{working_bikes}\\n\"\n # result + \"total people #{total_people}\\n\" + \"people with bikes #{people_with_bikes}\\n\" + \"people without bikes #{people_without_bikes}\\n\" + \"number of stations #{total_stations}\\n\" + \"stations #{show_stations}\"\n end",
"def print_summary(products_with_errors)\n info_and_log(\"\\n--------\\nSUMMARY:\\n\")\n @products.sort.each do |product|\n result = products_with_errors.include?(product) ? '-' : '+'\n info_and_log(\" #{product}: #{result}\")\n end\n end",
"def summary_information\n @summary_information ||= create_summary_information\n end",
"def summary\n if first_line =~ /^#/\n first_line.sub(/^#*/, '').strip\n else\n ''\n end\n end",
"def verbose_report\n result = header\n result += \":\\n#{smell_list}\" if should_report\n result += \"\\n\"\n result\n end",
"def report\n table = Terminal::Table.new(headings: ['Basic', 'Result']) do |t|\n t << [\"Number of paragraphs\", number_of_paragraphs]\n t << [\"Number of sentences\", number_of_sentences]\n t << [\"Number of words\", number_of_words]\n t << [\"Number of characters\", number_of_characters]\n t << [\"Number of syllables\", number_of_syllables]\n\n t << :separator\n t << [\"Average words per sentence\", mean_of_words_per_sentence]\n t << [\"Average syllables per word\", mean_of_syllables_per_word]\n t << [\"Average syllables per content word\", syllables_per_content_word]\n\n t << :separator\n t << [\"Verbs Ocurrencies\", verb_incidence]\n t << [\"Nouns Ocurrencies\", noun_incidence]\n t << [\"Adjective Ocurrencies\", adjective_incidence]\n t << [\"Adverb Ocurrencies\", adverb_incidence]\n t << [\"Pronoun Ocurrencies\", pronoun_incidence]\n t << [\"Content Word Ocurrencies\", content_word_incidence]\n t << [\"Function Word Ocurrencies\", function_word_incidence]\n\n t << :separator\n t << [\"Flesch score\", flesch]\n end\n puts table\n end",
"def output\n print_headings\n \n line_order.each do |line_name|\n stats = statistics[line_name]\n \n arr = [line_headings[line_name]] + column_order.collect {|col| stats[col]}\n print_line(arr)\n end\n \n print_separator\n print_summary\n end",
"def render_summary( summary )\n\t\ttemplate = self.load_template( SUMMARY_TEMPLATE )\n\t\treturn template.result( binding() )\n\tend",
"def print_summary\n raise InternalError.new( \"@key is empty for #{self.class}\" ) if \"#{@key}\".empty?\n\n log_params = []\n log_params += [ \"(#{@alt_source.to_s})\", [:CYAN, :BOLD] ] unless @alt_source.nil?\n log_params += [\"#{@key} = \", [], \"#{@value.inspect}\", [:BOLD] ]\n notice(*log_params)\n end",
"def report(io = $stdout)\n io.puts \"%8.1f: %s\" % [total, \"flog total\"]\n io.puts \"%8.1f: %s\" % [average, \"flog/method average\"]\n\n return if option[:score]\n\n max = option[:all] ? nil : total * THRESHOLD\n if option[:group] then\n output_details_grouped io, max\n else\n output_details io, max\n end\n ensure\n self.reset\n end",
"def print_final_report\n puts; puts; puts \"=== FINAL DATABASE COUNTS ===\"\n puts; puts end_of_task_report\n puts; puts; puts \"=== BY SCHOOL ===\"\n puts by_school_report\n puts; AssessmentsReport.new.print_report\n end",
"def output_report\n\t\toutput_start\n\t\toutput_head\n\t\toutput_body_start\n\t\toutput_body\n\t\toutput_body_end\n\t\toutput_end\n\tend",
"def get_sections_summary(opts = {})\n data, _status_code, _headers = get_sections_summary_with_http_info(opts)\n data\n end",
"def summary_detail\n Classifieds::Listing.format_cols([@title, @mileage, @price], SUMMARY_COL_FORMATS)\n end",
"def summarize\n print \"# of asks: #{ask_count}\\n# of bids: #{bid_count}\\nAsk volume: #{ask_volume.to_s('F')}\\nBid volume: #{bid_volume.to_s('F')}\\n\"\n $stdout.flush\n end",
"def raw_summary\n report = { \"version\" => { \"config\" => configuration_version, \"puppet\" => Puppet.version } }\n\n @metrics.each do |name, metric|\n key = metric.name.to_s\n report[key] = {}\n metric.values.each do |name, label, value|\n report[key][name.to_s] = value\n end\n report[key][\"total\"] = 0 unless key == \"time\" or report[key].include?(\"total\")\n end\n (report[\"time\"] ||= {})[\"last_run\"] = Time.now.tv_sec\n report\n end",
"def summarize_results(fn)\n body = \"\"\n results = get_test_results(fn)\n total = results[:error].length + results[:fail].length + results[:pass].length\n total_failed = results[:fail].length + results[:error].length\n\n body << \"Tests Executed: \" + total.to_s + \"\\n\"\n body << \"Passed: \" + results[:pass].length.to_s + \"\\n\"\n body << \"Failed: \" + results[:fail].length.to_s + \"\\n\"\n body << \"Error: \" + results[:error].length.to_s + \"\\n\"\n body << ((results[:pass].length.to_f/total).round(4) * 100).to_s + \"% Passed\" + \"\\n\"\n\n if results[:error].length != 0 || results[:fail].length != 0\n body << \"\\n\"\n body << \"Failed/Errored Tests:\\n\"\n (results[:error].concat(results[:fail])).each do |test|\n body << \" #{test}\\n\"\n end\n end\n \n puts \"-\" * 50\n puts body\n puts \"-\" * 50\n \n summary = {}\n summary[:body] = body\n \n bottom_line = \"#{total_failed}/#{total} failed\"\n summary[:bottom_line] = bottom_line\n \n return summary\n end",
"def dump_summary(summary)\n @output_hash[:version] = Inspec::VERSION\n @output_hash[:statistics] = {\n duration: summary.duration,\n }\n end",
"def report(io = $stdout)\n io.puts \"%8.1f: %s\" % [total_score, \"flog total\"]\n io.puts \"%8.1f: %s\" % [average, \"flog/method average\"]\n\n return if option[:score]\n\n if option[:group] then\n output_details_grouped io, threshold\n else\n output_details io, threshold\n end\n ensure\n self.reset\n end",
"def summary\n description_section.first\n end",
"def setup_summary_report\n assign_to_from_dates\n @filter = @filter.remove_blanks_in_arrays\n @filter_name = @filter[:name]\n assign_grouping_type\n assign_facilities\n end",
"def summary=(value)\n @summary = value\n end",
"def summary=(value)\n @summary = value\n end",
"def summary=(value)\n @summary = value\n end",
"def create_summary_doc\n label = 'Summary Information'\n doc = self.base_doc.merge({\n :xml_display => @xml.at(\"/ead/archdesc/did\").to_xml,\n :id => generate_id('summary'),\n :title_t => label,\n :hierarchy => [self.title, label]\n })\n doc\n end",
"def summary\n return \"\\nThis planet is called #{@name}. It is #{@color} in color, #{@mass_kg} kilograms in weight, \n and #{@distance_from_sun_km} kilometers from the sun. A fun fact about this planet: #{@fun_fact}.\"\n end",
"def summary(id)\n connection.get do |req|\n req.url \"job/#{id}/summary\"\n end\n end",
"def print_sales_report\n$report_file.puts \"\n ##### ######\n # # ## # ###### #### # # ###### ##### #### ##### #####\n # # # # # # # # # # # # # # # #\n ##### # # # ##### #### ###### ##### # # # # # # #\n # ###### # # # # # # ##### # # ##### #\n # # # # # # # # # # # # # # # # #\n ##### # # ###### ###### #### # # ###### # #### # # #\n********************************************************************************\n\"\nend",
"def create_html_summary\r\n puts \"Creating HTML...\"\r\n @dmds = @lists.last\r\n @html = '<html>'\r\n @html += '<head><link rel=\"stylesheet\" href=\"styles.css\"></head>'\r\n @html += '<body>'\r\n @html += \"<h3>Actions</h3>\\n<ul>\"\r\n @html += actions_html\r\n @html += \"</ul>\\n\"\r\n #@html += \"<h3>Prios diff</h3>\\n<ul>\"\r\n #@html += prio_diff_html\r\n #@html += \"</ul>\\n\"\r\n #@html += \"<h3>Closed DMD</h3>\\n<ul>\"\r\n #@html += closed_dmd_html\r\n #@html += \"</ul>\\n\"\r\n @html += \"<h3>Open DM</h3>\"\r\n ano, evo = sas_report\r\n @html += \"<table><tr><td>Nature of changes</td><td>P0</td><td>P1</td><td>P2/P3</td><td>Total</td></tr>\r\n <tr><td>Anomalies</td><td>#{ano['0']}</td><td>#{ano['1']}</td><td>#{ano['2']+ano['3']}</td><td>#{ano['0']+ano['1']+ano['2']+ano['3']}</td></tr>\r\n <tr><td>Evolutions</td><td>#{evo['0']}</td><td>#{evo['1']}</td><td>#{evo['2']+evo['3']}</td><td>#{evo['0']+evo['1']+evo['2']+evo['3']}</td></tr>\r\n <tr><td>Total</td><td>#{ano['0']+evo['0']}</td><td>#{ano['1']+evo['1']}</td><td>#{ano['2']+ano['3']+evo['2']+evo['3']}</td><td>#{ano['0']+evo['0']+ano['1']+evo['1']+ano['2']+ano['3']+evo['2']+evo['3']}</td></tr>\r\n <table>\"\r\n count = prios_hash\r\n @html += \"<h3>Non analysed DMD, by priority</h3><ul>\\n\"\r\n @html += \"<b>Stats</b><ul>TBD: #{count['TBD']}<br/>P0: #{count['0']}<br/>P1: #{count['1']}<br/>P2: #{count['2']}<br/>P3: #{count['3']}<br/></ul>\\n\"\r\n @html += \"#{priority_html(priority_dmd)}</ul>\\n\"\r\n @html += \"<h3>Evo</h3>\\n<ul>#{priority_html(priority_evo)}</ul>\\n\"\r\n @html += \"<h3>Analysed but not batched DMD</h3>\\n<ul>#{analysed_html(analysed_dmd)}</ul>\\n\"\r\n @html += \"<h3>Has workload but not 'analysed' DMD</h3>\\n<ul>#{analysed_html(workload_dmd)}</ul>\\n\"\r\n @html += \"<h3>Decided DMD</h3>\\n<ul>#{decided_html(decided_dmd)}</ul>\\n\"\r\n @html += \"<h3>Last updated</h3>\\n<ul>#{last_updated_html(last_updated_dmd)}</ul>\\n\"\r\n @html += '</body>'\r\n @html += '</html>'\r\n end",
"def summary (view_id, options = nil)\n\t\t\trr = ReportRequest.new\n\t\t\trr.view_id = view_id\n\t\t\t# rr.filters_expression=\"ga:pagePath==/\"\n\t\t\trr.metrics = [set_metric(options)]\n\t\t\trr.date_ranges = [set_date_range(options)]\n\n\t\t\treport(rr)\n\t\tend"
] |
[
"0.72487986",
"0.72418725",
"0.7203269",
"0.7203269",
"0.7200281",
"0.71919674",
"0.71919674",
"0.71919674",
"0.71919674",
"0.712414",
"0.70546436",
"0.70524293",
"0.70318073",
"0.7016436",
"0.6937847",
"0.6918684",
"0.68868417",
"0.6867476",
"0.6850022",
"0.68379134",
"0.6809722",
"0.68086493",
"0.67720276",
"0.6765058",
"0.67551047",
"0.673113",
"0.6712575",
"0.67052424",
"0.66947854",
"0.66846335",
"0.66685617",
"0.66642106",
"0.6654842",
"0.6633934",
"0.66162086",
"0.6615282",
"0.66147053",
"0.6612965",
"0.65839475",
"0.6582193",
"0.65758514",
"0.65638065",
"0.65454054",
"0.6516143",
"0.649152",
"0.6483143",
"0.64763844",
"0.64626956",
"0.64554214",
"0.6423043",
"0.63928473",
"0.6376021",
"0.63675416",
"0.6359971",
"0.6358229",
"0.63564026",
"0.63409126",
"0.633587",
"0.6334166",
"0.6332591",
"0.63298047",
"0.6328706",
"0.6328706",
"0.6328706",
"0.6325404",
"0.63240457",
"0.63237745",
"0.6311534",
"0.6311534",
"0.62989426",
"0.6295781",
"0.6285214",
"0.62787306",
"0.62769634",
"0.62724614",
"0.6251649",
"0.6247685",
"0.6245077",
"0.6244441",
"0.62406844",
"0.6238999",
"0.62383103",
"0.6215665",
"0.62037635",
"0.62036175",
"0.62033457",
"0.62003547",
"0.619709",
"0.61934334",
"0.61923546",
"0.61865807",
"0.6185621",
"0.6185621",
"0.6185621",
"0.6173783",
"0.61703527",
"0.6165375",
"0.6152399",
"0.6137123",
"0.613206"
] |
0.77893555
|
0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.