slice

Menu Button Assistance

Hi, Based on this menu structure: menu system I want to purely use a CSS based Menu System but am unsure what is the best way to approach to get the blue gel 2D button look based on "Home" and "About Us" ? I basically would like to know how to achieve this button look and then in CSS use this background button and then be able to add...

Parser in Ruby: #slice! inside #each_with_index = missing element

Let's say, I want to separate certain combinations of elements from an array. For example data = %w{ start before rgb 255 255 255 between hex FFFFFF after end } rgb, hex = [], [] data.each_with_index do |v,i| p [i,v] case v.downcase when 'rgb' then rgb = data.slice! i,4 when 'hex' then hex = data.slice! i,2 end end pp [r...

Python - randomly partition a list into n nearly equal parts

Hi, I have read the answers to the Python: Slicing a list into n nearly-equal-length partitions question. This is the accepted answer: def partition(lst, n): division = len(lst) / float(n) return [ lst[int(round(division * i)): int(round(division * (i + 1)))] for i in xrange(n) ] I am wondering, how does one modify these s...

.slice and .wrapall

Hi, I'm using a bit of code suggested by a member on stackoverflow and adapted by me to wrap every 3 li items as part of a mega menu. The code is: var lis = $("ul > li"); for(var i = 0; i < ls.length; i+=3) { lis.slice(i, i+3).wrapAll("<div class='new'></div>"); } Unfortunately this will grab child li's from the next parent menu to ...

How to remove 'None' from an Appended Multidimensional Array using numpy

Hello all, I need to take a csv file and import this data into a multi-dimensional array in python, but I am not sure how to strip the 'None' values out of the array after I have appended my data to the empty array. I first created a structure like this: storecoeffs = numpy.empty((5,11), dtype='object') This returns an 5 row by 11 ...

Is it possible to override the cookie duration for specific subdirectories when using Windows Identity Foundation? (WIF)

I'm considering using IE8 Slices with my website and need to provide some kind of authentication. If you don't know what webslices are, check this link out: http://blogs.msdn.com/b/ie/archive/2009/03/11/web-slice-and-feed-authentication-developer-guidelines.aspx I'd like to know if it's possible to override the cookie duration when us...

What is :: (double colon) in Python?

I know I can use something like string[3:4] to get a substring in Python, but what is the is something[::3]? Sorry but it's hard to search for this on Google. ...

Fake array slicing operator: Make it shorter

Is there some innovative way to make the "print" shorter without too much confusion? And which of the "print" do you like most? define('_','_'); function _j($a, $b) { return $a._.$b; } // Output 0_0 print (0)._.(0); print _j(0,0); Update What I want to do is to have slice syntax that are in Python/Ruby into PHP eg. a[1:3] a[1,3...

Slicing-à-la-Photoshop in Javascript

Hello, I am trying to do something very hard (well, hard to me at least): I would like to create a slicer (like Photoshop's one) in Javascript. For now, I just concluded the Photoshop function creates "immuable" points each time you do a slice, and create 4 automatics slices (more if the slice overlap more than one other) around, whic...

Python 3 string slice behavior inconsistent

Wanted an easy way to extract year month and day from a string. Using Python 3.1.2 Tried this: processdate = "20100818" print(processdate[0:4]) print(processdate[4:2]) print(processdate[6:2]) Results in: ...2010 ... ... Reread all the string docs, did some searching, can't figure out why it'd be doing this. I'm sure this is a no b...

How do I get a slice of a referenced array in Perl?

I have a reference to an array $arr_ref. I would like to get a reference to an array containing only cells i..j in the original array. ...

Jquery, What does slice return on failure?

I can't find this anywhere, how do you check to see if slice is returning elements still in the list? Like $('.class').slice(n-th,n-th); When n-th variables are increased throughout the index of the return class by slicing, how do you know when slice returns on an invalid index? Hope I explained that well. Here is the example code of w...

How To Slice a Simple Polygon with a Line

I have a simple polygon (convex or concave, but no holes) that I need to slice into parts with a line segment. I'm not sure how to actually determine how many polygons result after the slice, or how to group the vertices. Basic convex cases the always results in 2 sub-polygons are easy, but how would I deal with a complicated concave sh...

ruby: Range is empty, but slicing with it produces elements?

I'm learning Ruby, and have just gotten into some stuff about arrays and ranges. I've run into something about slices that, while it makes sense at first glance, confuses me a bit when i look deeper into it. irb says that (2..-1).to_a is an empty array. Meaning no values in the range, right? But if i use that same range in [:a, :b, :c...

How do I customize and slice Jquery Automatic, Infinate Carousel rotating slideshow into separate image links?

Hi jquery experts. I recently read top ten jquery techniques in Web designer mag and like the carousel effect on http://www.struttcouture.com. But I would like to customize it a little more. For example is there a way to slice up the images so different sections of each image can be made into links with in divs instead of unordered lis...

How to return the maximum element of a list in Python?

Hello, I am trying to simplify this function at his maximum, how can I do? def eleMax(items, start=0, end=None): if end is None: end = len(items) return max(items[start:end]) I though of def eleMax(items, start=0, end=-1): return max(items[start:end]) But the last element is deleted from the list. Thank for y...

python slice how to, I know the python slice but how can I use built-in slice object for it?

I want to know what's the use of built-in function slice and how can I use it, the direct way of pythonic slicing I know l1[start:stop:step], I want to know if I have object of slice then howto? ...

Slice notation in scala ?

Is there something similar to slice notation in python in scala ? I think this is really a useful operation that should be incorporated in all languages. ...

Javascript fastest way to duplicate an Array - slice vs for loop

In order to duplicate an Array in Javascript, does anyone know (and maybe tested) if it's faster to use slice method: var dup_array = original_array.slice(); or doing a for loop: for(var i = 0, l = original_array.lenght; i < l; ++i) dup_array[i] = original_array[i]; UPDATE: (just to clarify myself) I know both ways do only a ...

Any way to hide Slicer Values in Excel 2010

I know that Excel 2010 Slicers will visually indicate when there is no data associated with a particular slicer selection. For example, they are faded in color for 2010 if you have no values in 2010. Is there some setting where I can hide them altogether? If I have sales in 2007, 2009, and 2010; but not 2008 can the slicer list omit 2...