grunt cookbook

Discover grunt cookbook, include the articles, news, trends, analysis and practical advice about grunt cookbook on alibabacloud.com

"Python Cookbook" "Data Structure and algorithm" 4. Find the largest or smallest n elements

errorTraceback (most recent): File"", Line 1,inchIndexerror:index out of range>>> Heappush (a,3)>>>a[3]>>> Heapreplace (a,2)#Delete (Heappop (a)->3) first, then join (Heappush (a,2))3>>>a[2]>>> Heappush (a,5) >>> Heappush (a,9)>>> Heappush (a,4)>>>a[2, 4, 9, 5]>>> Heapreplace (a,6)#first find the minimum value from heap A and return, then add 62>>>a[4, 5, 9, 6]>>> Heapreplace (a,1)#1 is added later, before 1, the minimum value in a is 4 .4>>>a[1, 5, 9, 6]>>> a=[2,4,6] >>> b=[1,3,5]>>>

"Python Cookbook" "Data Structure and algorithm" 18. Map names to elements of a sequence

Problem: You want to access the element by name to reduce the dependency on the location in the structureSolution: Use the named Tuple collections.namedtuple (). It is a factory method that returns a subclass of the standard tuple type in Python, gives it a type name and the corresponding field name , returns a class that can be instantiated, gives you a defined field name to pass in the value, and so on.The primary purpose of a named tuple is to decouple the code from the location of the elemen

"Python Cookbook" "Data Structure and algorithm" 16. Extracting subsets from a dictionary

Problem: Want to create a dictionary, which is itself a subset of another dictionarySolution: Use dictionary derivation (dictionary comprehension) to easily solve#example of extracting a subset from a dictionary fromPprintImportpprintprices= { 'ACME': 45.23, 'AAPL': 612.78, 'IBM': 205.55, 'HPQ': 37.20, 'FB': 10.75}#Make A dictionary of pricesP1 = {Key:value forKey, ValueinchPrices.items ()ifValue > 200 }Print("All prices") Pprint (p1)#Make A dictionary of tech stocksTech_names = {'AAPL

"Python Cookbook" "Data Structure and algorithm" 8. Dictionary-related Computational problems

=min (Zip (Prices.keys (), Prices.values ())) #zip () parameter is incorrect in order to get the wrong value>>>Min_price3 ('AAPL', 612.78)>>> Max_price3 =max (Zip (Prices.keys (), Prices.values ())) #zip () parameter is incorrect in order to get the wrong value >>>Max_price3 ('IBM', 205.55)>>>When doing these calculations, note that zip () creates an iterator whose contents can only be consumed once. For example:>>> pirces_and_names=Zip (prices.values (), Prices.keys ())>>> pirces_and_names mi

"Python Cookbook" "Data Structure and algorithm" 1 breaks a sequence into separate variables

If the object is an iterative (any sequence), it can be decomposed, including tuples, lists, strings, files, iterators, and generators, which can be decomposed into separate variables by a simple assignment operation.The only requirement: The total number of variables matches the sequence, otherwise an error will occur;Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5, 20:32:19) [MSC v.1500 32bit (Intel)] on Win32type"Copyright","credits" or "license ()" forMore information.>>> p=[4,5]>>>p[4, 5]>>> x,

"Python Cookbook" "String and text" 9. Uniform representation of Unicode text as canonical form

experimentImportunicodedatan_s1= Unicodedata.normalize ('NFC', s1) n_s2= Unicodedata.normalize ('NFC', S2)Print('n_s1 = = n_s2?', n_s1 = =n_s2)Print('len (n_s1) =', Len (N_S1),'Len (N_S2)', Len (n_s2))Print('*****************************')#(d) Example of normalizing to a decomposed form and stripping accentsT1 = Unicodedata.normalize ('NFD', s1) T2= Unicodedata.normalize ('NFD', S2)Print('T1 = = t2?', t1==T2)Print('len (t1) =', Len (T1),'len (t2) =', Len (T2))Print("'. Join (c forCinchT1if not

"Python Cookbook" "String and Text" 14. String joins and merges

keyword;#example.py##Example of combining text via generatorsdefsample ():yield " is" yield "Chicago" yield " not" yield "Chicago?"#(a) use Join () to simply connect them togetherText ="'. Join (sample ())Print(text)Print('======================')#(b) Redirect these fragments to I/OImportSYS forPartinchsample (): Sys.stdout.write (part) Sys.stdout.write ('\ n')Print('**************************')#(c) intelligently combine I/O operations in a mixed mannerdefCombine (source, maxsize): Par

"Python Cookbook" "String and Text" 5. Find and Replace text

(Datepat.sub (change_date, text))Print(Re.sub (R'(\d+)/(\d+)/(\d+)', Change_date, text))Print('++++++++++++++++++++++++++++++++')# Total number of replacements obtained by RE.SUBN () newtext,n =datepat.subn (r " \3-\1-\2 " , text) print (NewText) print (N) >>> ================================ RESTART ================================>>> yeh,but No, But yeh,but no,but yeh,but no,but yehyeah,but yes,but yeah,but yes,but yeah,but no,but yeah------------------------- - -is 2012-11-27. Pycon

Python cookbook (data structure and algorithm) method for saving the last N elements, pythoncookbook

Python cookbook (data structure and algorithm) method for saving the last N elements, pythoncookbook This example describes how to save the last N elements in Python. We will share this with you for your reference. The details are as follows: Problem:We hope to make a limited history statistics for the last few records during iteration or other forms of processing. Solution:Select collections. deque. The following code performs a simple text match on

Unity Shaders and Effects Cookbook (3-6) Create anisotropic high light type (Anisotropic) to simulate brushed metal effects

for vertex shaders.vertex:128 instruction limit. fragment:96 instruction Limit (texture + arithmetic), temporary registers and 4 texture indirections.3.0Compiles the shader under Shader Model 3. Model 3 is more powerful and flexible than 2 but is less compatible.Vertex:no instruction limit.fragment:1024 instruction Limit (texture + arithmetic), temporary registers and 4 texture indirections.It is the possible to override these limits using #pragma profileoption directive.For example, #pragma pr

Unity Shaders and Effects Cookbook (7-3) blend with vertex colors in the terrain

=tex2d (_maintex,in.uv_maintex); Half4 secondcolor=tex2d (_ Secondtex,in.uv_secondtex); float4 heightcolor=tex2d (_heightmap,in.uv_maintex); float redchannel=1- IN.VERTEXCOLOR.R; The vertex color R also stores the height data, 1 minus the height data stored in the height graph is the ratio of float RHEIGHT=HEIGHTCOLOR.R * REDCHANNEL; The r actual data of the height graph float invertheight=1-heightcolor.r;float finalheight= (invertheight * redchannel) *4;float finalBlend= Saturate (rheight + fin

"Python Cookbook" Learning Notes

Class and object of the 8th chapter 2016.5.38.1 Changing the object's string display __str__ and __repr__%s and%r, mentioned Eval, I didn't use it.8.2 Formatting a custom string __format__8.3 Let the object support context management, __enter__ and __exit__, you can use the WITH8.4 Ways to save memory when creating a large number of objects __slot__,__slot__ is more of a memory-optimized tool than a wrapper tool to prevent users from adding new properties to an instance.8.5 Encapsulating propert

Unity Shaders and Effects Cookbook (5-1) Litsphere lighting Model

) {fixed4 c = fixed4 (1,1,1,1); C.rgb = c * s.albed O;C.A = S.alpha;return C;}In the unlit illumination model function, no processing is done and no illumination is accepted.void Vert (inout appdata_full v,out Input o) {unity_initialize_output (input,o); Tangent_space_rotation;o.tan1=mul (ROTATION,UNITY_MATRIX_IT_MV[0].XYZ); O.tan2=mul (rotation,UNITY_MATRIX_IT_MV[1 ].XYZ);}In the vertex function, in order to correctly retrieve the spherical map, we need to multiply the tangent rotation matrix r

Unity Shaders and Effects Cookbook (7-2) for vertex animation in Surface Shader

Surf (Input in, InOut surfaceoutput o) {half4 c = tex2d (_maintex, In.uv_maintex); O. Albedo = C.rgb;o. Alpha = C.A;} ENDCG} FallBack "Diffuse"}The book also adds a mix of colors to make the effect look more dazzling, not here.Transfer from Http://blog.csdn.net/huutu http://www.thisisgame.com.cnLearn about a function mentioned in the book LerpLerp interpolation functionfloat f = lerp (from,to,t) = from* (1-t) + to*tWhen t = 0 returns from, when t = 1 returns to. When t = 0.5 returns the mean of

Concurrency in C # Cookbook notes

(processingtasks);}Alternatively, this can written as:Static Asynctaskint> Delayandreturnasync (intval) { awaitTask. Delay (TimeSpan. FromSeconds (Val)); returnVal;}//This method is now prints "1", "2", and "3".Static AsyncTask Processtasksasync () {//Create a sequence of tasks.taskint> Taska = Delayandreturnasync (2); Taskint> TASKB = Delayandreturnasync (3); Taskint> TASKC = Delayandreturnasync (1); vartasks =New[] {Taska, TASKB, TASKC};varProcessingtasks = tasks. Select (Asynct = { varresult

Unity Shaders and Effects Cookbook (4-5) cubemap with Fresnel reflections

(dot (o.normal,normalize (in.viewdir))), Rim=pow (Rim,_rimpower), O. Albedo = c.rgb;//So rim=0,o when the line of sight is perpendicular to the surface. Emission = 0. The closer the line of sightVertical, the smaller the reflection. O.emission= (Texcube (_CUBEMAP,IN.WORLDREFL). RGB * _reflectionamount) *rim;o. Specular=_specpower;o. Gloss=1.0;o. Alpha = C.A;} ENDCG} FallBack "Diffuse"}The code comment is already there.I drew a picture, too.The effect of the final implementationThe area where th

Smooth python and cookbook Study Notes (7), pythoncookbook

Smooth python and cookbook Study Notes (7), pythoncookbook1. Read and Write compressed data files Use the gzip and bz2 modules to read and write compressed files. However, pay attention to the file mode. The default format is binary. 1 # Read the compressed file 2 import gzip 3 with gzip.open('somefile.gz ', 'rt') as f: 4 text = f. read () 5 6 import bz2 7 with bz2.open('somefile.bz2 ', 'rt') as f: 8 text = f. read () 9 10 # Write compressed data 11

Smooth python and cookbook Study Notes (6), pythoncookbook

Smooth python and cookbook Study Notes (6), pythoncookbook1. iterate multiple sequences at the same time (zip (function )) You can use the zip () function to iterate multiple sequences at the same time. >>> X = [1, 2, 3, 4, 5, 6]>>> Y = [121, 223, 116, 666, 919, 2333]>>> for x, y in zip(X, Y):... print(x, y)...1 1212 2233 1164 6665 9196 2333 Zip (a, B) is used to create an iterator that generates tuples (x, y), x is taken from sequence a, and y is

Nhibernate.3.0.cookbook Chapter Fifth section setting up a base entity class

Framework Framework specification. If X. Equals (y), then X. GetHashCode () and Y. GetHashCode () should return the same value, which in turn is not required (if X. GetHashCode () and Y. GetHashCode () returns the same value, X. Equals (y) can return false), and X and Y can also share a hash code when they are not equal. In our entity base class, we simply use the hash code value of the ID.Supplemental knowledgeFor more knowledge about equals and GetHashCode, see the MSDN documentation for Http

"Python Cookbook" "Data Structure and algorithm" 2 explode elements from an arbitrary length of an iterative object

The n elements are decomposed from an iterative object, but the length of an iterative object may exceed N, and an exception of "too many decomposition values" appears.Use "* expression" to resolve the problem:Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb, 22:43:06) [MSC v.1600 32bit (Intel)] on Win32type"Copyright","credits" or "license ()" forMore information.>>> *headdata,current=[10,3,2,6,8,5]#* Modified variables are located in the first position of the list, easy to separate head and tail>>>head

Total Pages: 15 1 .... 11 12 13 14 15 Go to: Go

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.