and a - みる会図書館


検索対象: 全ての本
1415311件見つかりました。

1. Surreptitious Software

4.5 Data Encodings #define FALSE ① Ⅱ① 267 BOOlean expressrons are used in tWO ways: tO control the flO " in control flO 嶬 , state- ments and tO compute values that are stored in bOOlean variables. use OR and AND in control flO 嶬 " statements, and ORV and ANDV when an expresslon lS used in an asslgnment statement. BOOL b BOOL a = TRUE ; #define TRUE 1 FALSE ; typedef int BOOL ; else if (a Ⅱ b) if (a b) BOOL d = BOOL c e1se (a b) = (a Ⅱ b) an example: else if (ORA(a,b)) if (ANDA(a,b)) TA b = EA(FALSE) ; TA a = EA(TRUE) ; TA c e1se TA d = 0RVA(ANDVA(a (b) , EA(FALSE)) ; = ANDVA(ORVA(a , b) , EA(TRUE) ) ; 1 ; can use the same techniques showing this encoding bOOlean values tO encode any enumerable type with a small range. 4.5.2.1 AIgorithm OBFBDKMRVb001[281: Multiple Values Since there are so few boolean values, you can use multiple values tO encode true and multiple values tO encode false. ln this example, any integers divisible bY 2 represent true' and any integers divisible by う rep resent fal s e : typedef int TC ; TC EC(BOOL e) {return ( e ) ? 2 ☆ ( 3 ☆ ( rand ( ) % 1 ①①①の + rand ( ) % 2 + 1 ) : 3 ☆ ( 2 ☆ ( rand ( ) % 1 ①①①の + 1 ) ; } BOOL DC ()C e) {return ( ( e % 2 ) = = ① ) ?TRUE : FALSE ; } BOOL ORC()C a , TC b) {return (a*b)%2==@ ; } TC ORVC()C a, TC b) {return EC(((a*b)%2==@)) ; } BOOL ANDC()C a, TC b) {return gcd(a.b)%2==@ ; } TC ANDVC()C a, TC b) {return EC((gcd(a,b)%2==9)) ; }

2. Building the Realtime User Experience

These additions don't do anything other than configure some variables about how often [ 0 send out SMS alerts, which number to use when sending them, and the API to use in order [ 0 send them. Depending on the traffic you re expecting tO get on your site, you'll probably want [ 0 configure the numbers [ 0 ensure that you re getting enough alert messages, but not tOO many. TO actually send the message, we're going tO have tO monitor the number 0f currently active users on the site. Once that number goes above our newly created Analytics. SMS alert current users, we re going [ 0 send a message. 从々 can easily add that [ 0 the Ana1ytics. update data method. At the bottom of Ana1ytics. update data, after you ve counted the current number Of active users and stored it in the active user count variable, add the following code tO your げ . 〃ツ file: def update data(self) : # did we find a user that isn ・ t looking at anything? delete them! if not len(self. users[x]) : del self. users[x] # if the active user count goes about the 5M5 threshold if active user count 〉 Analytics. SMS alert current use て 5 : # and we haven ・ t recently sent a message 竏 AnaIytics. SMS last send く (time. time() - Ana1ytics.5M5 send interval) : logging ・ inf0("Sending an SMS A1ert ! " ) # note the current time Ana1ytics.5M5 last send = time. time() # build the URL u て 1 = Ana1ytics. SMS_api base url url 十 = ー十 u て 1 escape(Ana1ytics. SMS alert mobile number) url + = '&body= ・ + u て 1 escape("Current1y %d users on the site! " ) % ( len ( 5e1 + ・ users ) ) ) # make the API request f = urllib. urlopen(url) + ・ read() The update data method was already counting the current number of active users, so the only addition we had tO make was tO check whether that number went above our predetermined limit. lfit did, we check tO see whetherwe ve recentlysent out a message, and if not, we simply make the API call to our SMS application. If you set the SMS alert current users low enough, you'll be able to see the SMS message after opening a few tabs on your browser. If you h00k ⅱ up t0 a live site, you should see a message like Figure 屮 8. Customized Analytics ー 215

3. Building the Realtime User Experience

/ / start pinging ・ Ana1ytics ・ ping(); This code doesn't do anything too complicated. We build the start of an object called Ana1ytics, which will contain all 0f the client-side tracking functionality. First, we de- fine a few variables that we'll be using throughoutthe object. The variable uid will be used [ 0 contain the unique identifier for each user WhO loads this page. The variables start time and last activity are used tO contain the time ofwhen the script first gets started and tO monitor the time Of the last user interaction, respectively. The final var- iable defined is called ping_url. This is used t0 inform the script which base URL to use when pinging the server. ln this case, we'll be se ハ ring this COde from our Tornado server, and the ping_url be determined by the server and populated into this field. This iS a small convenience that will allOW us tO serve thiS up and copy the file tO different servers. You could get some performance gains by se ハ ring this file from a content de- 1 ⅳ e network (CDN) and hard-coding this value in place. The next bit of code here defines the start method, which is called from each web page tO get the analytics process started. lnside this methOd we populate the timing variables start time and last activity. Next, we call the method setupUID, which will be de- fined next. Once we have the basic variables set up and the UID has been either generated or loaded, the next job is t0 attach callback methods [ 0 any 0f the events that signal the user has been active. If the user moves a mouse, presses a key, CliCkS, or scrolls, Ⅵ℃ want t0 know and update the last activity field. The only eventthat we want t0 track differently is the onbeforeunload event, which is the event that is called when a user navigates away from the page. When this happens, we want t0 not only 10g the time, but alSO ensure we get in one last ping tO the server. The ping iS defined next, but before we get t0 that, let's set up the uid field by writing the setupUID method. ln your 尾記行襯 e - ana s file, add the following method: Ana1ytics. setupUID = function() { / / check fo て a cookie "realtime analytics" var cookie name = document. cookie. split(/\; ?/g); var cookies for(var i = 0 ; i く cookies. length; + + i ) { var name = cookies[i] . split(" = COOkie name) { if (name = Ana1ytics. uid = cookies[i]. split("= return; / / if we're here, we need to generate and store a UID / / generate the UID AnaIytics. uid = new Date(). getTime(). toString(); ' + Math. f100r(Math. random() * 10000 の ; Ana1ytics. uid + = 190 ー Chapter 9 : Measuring U 史「 Engagement: Analytics on the Realtime Web

4. Building the Realtime User Experience

var time time. html(' ldle Time: data. append(time); ー S ( て 011 x: 十 u . X 十 Y : / / if the user is idle, add them to the idle list if (). status ・ ldle ・ ) idle list. append(li); / / otherwise tO the active list else active list. append(li); 206 ー Chapter 9 : Measuring User Engagement: Analytics on the Realtime Web and let Other tabs rest. You should see the page views Jump right ont0 the screen and on [ 0 which you've installed the JavaScript tracking code. CIick around in some tabs point one browser at 厄印 : / / loca 0 立 : 8888 /. Then, load up a few tabs full of the website browser. Assuming that you started your server on port 8888 of your local machine, Start up the server again and load up a couple 0f different tabs or windows in your web h that one method, we're already populating two of the lists that we've created. active users liSt. the status is "ldle," we add it tO the idle users listed; otherwise, it goes ontO the two lists. To do that, we check the status field as it was supplied by the server. If Once we've added all of the data to the LI element, we have [ 0 append it to one of the iS the X and y scroll position. seconds, we convert i い 0 minutes. Also, appended t0 that same HTML SPAN element amount of time during which the user has been idle. If that number is more than 60 The first field we add to that DIV is the referrer information. After that, we append the DIV container in order tO house the rest of the secondary data that we're going to view. Once we have displayed the current URL and domain that user is viewing, we build a web properties at the same time from the same URL. creator, we can add our JavaScript COde on [ 0 any number Of sites and watch all Of our domain the user iS currently viewing. Adding the domain iS useful because, as a website current page and linking 0ff t0 that URL. We then append a slash, and after thatthe about a particular session. The firstthing we add t0 that is an anchor tag displaying the lnside that loop, we create an LI elementthat is going t0 be used t0 house all the data they are browsing. server side, we loop through b0 市 the users themselves and the current list 0f URLs the users that we've received. Much like the Ana1ytics. update data method on the idle users elements and promptly clear them out. Then, we 100P through the list of wrapping it in HTML tags. TO get started, we use jQuery [ 0 grab the active users and simple. For the most part, we're JLISt taking the data we receive from the Object and This is a big chunk of code, and it may look fairly intimidating, but it's actually very

5. Building the Realtime User Experience

# build the data object to pass to the user_ping method data This change simply checks to see whether the parameter designed to signalthat the user iS exiting the page, e, exists. If it does, we call the newly created remove_user url method [ 0 remove this from the array. Once that happens, there is no sense in con- tinuing on with the method, SO we simply return right then and there. Prior t0 adding the Ana1ytics. update data and Ana1ytics. remove_user url methods, we were collecting statistics that essentially created a running tOtal Of all the users whO had viewed the site, which wasn't very useful. NOW we're gleaning the tiniest bit of information about what users are dOing, and we stop tracking them when they leave the page. With this information, it starts [ 0 become interesting tO watch the users as they bounce around the site. Let's build a simple page tO view the information we re currently gathering. Viewing the Traffic TO view the information that we've collected thus far, we re going tO build a simple HTML page that pings the server to getthe lateststats. ln order to set this up, we need to build a couple of things. We need to make an HTML template and tell Tornado [ 0 render it upon request. Then, we need t0 write a JavaScript file to ping and display the data, and finally a server-side method to prepare and return the results when asked. Let's start on the server side. ln your げ . 〃ツ file, modify the Application object tO respond t0 the following URLs: class App1ication(tornad0. web. App1ication) : def init_(self) : # create an application-wide version 0 千 the analytics object self. analytics = Ana1ytics() # map the tWO controller classes tO the URLS handlers PingHand1er), (r"/js/?", JSHandler), HomeHand1er) , (r"/get/stats/?", GetStatsHandIer), This just adds two new URL handlers and tells Tornad0 which controller classes to use when we receive requests on / and /get/stats. We'll use the first URL to host the HTML template and the second URL to hostthe methods needed when we ping the server through JavaScript. First, let's create the HomeHandler class. AISO in your 覊既 file, add the following code: Customized Analytics ー 201

6. Building the Realtime User Experience

variables measure the time since the last actual HTTP ping from the client and the time since the user last moved hiS mouse or interacted with the page in S01 れ e way. If the last activity variable is less than the Ana1ytics. live session time, we know that we have an active user. Otherwise, we say that this user is and update the status field 0f the object. We then check t0 see whether the last ping_in_seconds happened outside the ping timeout time. If it did, we remove the user from the object by calling the remove user url method, which we'll define next. That method will re- move Just one 0f the URL entries for a given user. lf, after running through the 100P , we end up removing all Of the entries for a given user, we remove the entire user from the users Object. The update data method called a method t0 remove a URL entry from a specific user Object in our big users dictionary. Let'S define that method now. ln your server.py file, add the following method to your Ana1ytics object: def remove user url(self, uid, url) : # make sure we have a user here. if uid not in self. users: return # try tO remove the user/url mapping try: del self. users[uid] [url] except Exception, e: logging. error("Error remove user: %s, %url: %s", uid, url) This method, remove user url, simply removes a specific URL mapping from a specific user inside our Analytics. users Object. TO dO this, we Just check tO see if the entry exists and remove ⅱ . ThiS means that we now have the ability tO add and remove information about users and URLS as they come and go from the site. while it's a good [ 0 ensure that we remove users after a predetermined amount 0f time, our JavaScript code actually sends a differenttype 0f ping when we know that the user is leaving the page. 嶬 have an event handler set up t0 track when the beforeunload event occurs, and when it does, the client will immediately ping the server tO let us know that the user is leaving. Let's update our PingHandler class tO remove the user when that happens. ln your 覊翔既 file, add the highlighted code to the PingHandler class: class PingHand1er(tornado. web. RequestHand1er) : def get(self) : # setup some 10 ( al convenience variables fO て later = self. get argument(' u ・ ) uid = self. request. headers[ ・ Referer ・ ] url # remove the user 竏 they're leaving the page ping_on_exit = self. get argument( ・ e ・ ) if ping_on exit 15 not None and ping_on exit self. application. analytics ・ remove_user url(uid, u て 1 ) return 200 ー Chapter 9 : Measuring User Engagement: AnaIytics on the Realtime Web

7. THE BEST SOFTWARE WRITINGⅠ

ADAM BOSWORTH 33 This is where the action will be. Learning Avalon19 or Swing isn't going tO matter. Machine learning and inference and data minrng 、 vill. For the first time S1nce computers came along, AI iS the mainstream. I find this deeply satisfying. lt says that in the end the value is in our humanity, our diversity, our complexity, and our ability tO learn tO COI- laborate. lt says that it is the human side, the flexible side, the organic side of the 嶬 b that is going to be important and not the dry and ana- lytic and taxonomical side, not the systematized and rigid and stratified side that will matter. ln the end, I am profoundly encouraged and hopeful that the growth on the b is one that is slowly improving the civility and tenor of discourse. Just as porn seems tO be an unpleasant leading user Of tech- nology, SO does crude and vituperative communicatlon seem tO be a pattern for early adopters, and it is a relief tO see that forms Of gover- nance, trust, and deliberation are now emergrng. There are those who will say that all this is utopian. If utopian means not being afraid tO dream, then indeed it is. SO was Tim's initial vision Of umversal access tO informatlon. SO iS Google's 1 Ⅱ 1SSIOn. T. E. La 、 vrence wrote in the 立怩〃門〃 4 0 ー W な do 川 , "AII men dream: but not equally. Those who dream by night in the dusty recesses of their minds wake in the day to find that it was vanity: but the dreamers of the day are dan- gerous men, for they may act their dream with open eyes, tO make it possible. '' I encourage all Of you tO act on your dreams with open eyes. I encourage all 0f you t0 dream 0f an lnternet that enables people t0 work together, tO communicate, tO collaborate, and tO discover. I encourage all Of you tO remember that, in the long run, we are all human and, as you add value, add it in ways that are simple, flexible, sloppy, and, in the end, everything that the Platonists in you abhor. 19. The graphical programming library for Microsoft's planned "Longhorn" operating system. ー Ed. 20. A graphical programming library for Java. ー Ed.

8. Betty Crocker's Cookbook

138 COOKIES LEARN WITH Sweeteners Butter PerfectIy Softened ー SOFTENING BUTTER Butter T00 So ln addition tO adding sweetness tO COOkies and bars, S 、 veeteners alSO aid in bro 、 and affect the texture ofbaked goods ・ Most recipes call for granulated white sugar, brown sugar or bOth, but Other types Of S 、 are used, such as honey or maple syrup. The higher the sugar-to- flour rat10 ln a recipe, the more tender and crisp the cookies will be. Leavening Cookies usually call for one or れ vo types of leavening, either baking soda or baking powder, which react with liquids tO form a gas that causes the COOkies tO rise. Baking powder and baking soda are not interchange- able. You want leaveners to be fresh, so always check the expiration dates on the containers. If the product is older than the date on the label, the leavening power is significantly decreased or completely gone, so cookies and bars made with it will be flat and dense in texture. Eggs Eggs add richness, moisture and structure tO COOkies. Yet, t00 many eggs can make cookies crumbly. All the recipes in this book have been tested with large eggs ・ Egg product substitutes, made of egg whites can be used in place of whole eggs, but cookies made with them may be drier. Butter Pa 「 tia 〃 / MeIted also used. When nuts are called for in a recipe, メ ou can peanuts. Hazelnuts, cashews and macadamia nutS are MOSt recipes call for walnuts, pecans, almonds or Nuts and Peanuts soda, the leavening wont work very well. dough with the flour. The reason? Without the baking baking soda already in it, add the baking soda to your the recipe you re using doesn't have 1 / 4 teaspoon 0f Buttermilk can be substituted for regular milk, but if more. Add 0n1 メ as much liquid as your recipe calls 応 r. tO make COOkies crisper by causing them tO spread Liquids such as water, fruit Juice, cream and milk te nd Liquids eat it, too—safely, that is! these optlons, you can have your cookie dough and like to nibble on it while baking cookies. With some cookie dough never gets baked, because you ctl メ safe to eat raw. We happen to ow that your area) or egg product substitutes; both are per- with pasteurized raw whole eggs ()f available in made with raw whole eggs ・ Or make your cookies eggs. The solution? Don't eat unbaked dough bactena, can be contracted by eatmg raw whOle very senous and potentially fatal 応 od poisonmg cookie dough? A word of caution: S almonella, a Note: Can't break the habit of nibbling on raw

9. Barron's Sat, 15th Edition

764 G ti れ吶猷 0 CO ル 2 ね $ 0 c お Many individual scholarships are available from ね bO 「 unions, benevolent societies, patriotic organi- zations, and business. LOOk in your high schOOl guidance Office and in yourlocallibrary for informa- tion on private scholarships such as these as well as local scholarships available in your community. Awards made available by local fraternal societies, women's ClubS. CiViC and business organizations, ethnic and religious groups, alumni, and PTAS are numerous but usuaily modest in dollars and cents value. Your parents' employer orlabor union may turn out tO be another source Of aid. The largest independently funded scholarship pro- gram in the United States is administered by the National Merit Scholarship Corporation and is funded by company foundations and colleges and universities. Scholarship recipients are selected on the basis Of their score on the Preliminary Scholas- tic Aptitude Test/NationaI Merit Sch01arship Qualify- ing Test (PSAT/NMSQT), Other academic factors, and their character. For further information, write tO the National Merit Scholarship Corporation, One American Plaza, Evanston, lllinois 60201 , and ask fo 「 the PSAT/NMSQT Student Bulletin. ence in the amount Of money available fO 「 student to offer, and since there is an often enormous differ- grants, loans, and student-employment opportunities Since each college has different scholarships, eral and state programs. colleges Often act as agents Of distribution for fed- 旧 addition tO their own scholarship and grant funds, drama, 0 「 journalism. students with special talents in such areas as music, ships may be given tO attract outstanding athletes or achievement and/or financial need. spe&ial scholar- grants are awarded in recognition Of academic tion t0 compiete payment Of all expenses. These and grants that range from partial payment Of tui- Nearly every college Offers a number Of scholarships aid from one college tO another, it is important that you get your information about student aid directly from the financial aid office Of each college you are thinking Of applying tO. HOW A 叩 for FinanciaI Aid MO need-based financial aid programs, whether they are government programs, private programs, or individual college programs, require applicants tO file either the FinanciaI Aid Form (FAF) Of the CO ト lege Sch01arship Service or the Family FinanciaI Statement (FFS) Of the American CoIIege Testing Program t0 apply fO 「 the various types Of aid avail- able. B0th financial aid forms ask the applicant to itemize all family information and financial data per- tinent tO the candidate's application for aid. は is important tO find out which form or forms the colleges you are applying tO require. Some schools will want their own aid application filed in addition t0 either the FAF or the FFS. And some government and private programs request additionalforms as well; they use the FAF or FFS as an initial qualifying form but then require a separate application for their program. Both FAF and FFS forms are available 行 om your high school guidance counselor 0 ロ OC 引 college financial aid offices. We've left the two most important facts about apply- ing for financial aid forlast: ( 1 ) you must apply for financial aid; you are not automatically considered fO 「 aid when you apply t0 a college; and ( 2 ) apply as earlY as possible SO that you have th. e best possible chance at a share 0f the available funds before they are used up on applicants whO applied for aid ear- lier. There is no getting away from the fact that you'll have t0 d0 some research, and that you and your parents will have tO spend some time filling out some rather detailed forms. But there is no way tO get around this paperwork when you're applying fO 「 any kind 0f financial aid. SO be patient and be thor- ough; hopefully, your efforts will pay Off.

10. Building the Realtime User Experience

time. strftime("%I:%M:%S %p", time. localtime()), expire_time ・ : expire time}) def user_ping(self, data) : This changes two parts of the Ana1ytics object. First, we add a member variable called data that is available to our newly created data ping method as well as throughout the object. This code also creates the data ping method itself. lnside that method we simply build the data object. This object is a dictionary with any number ofkeys. The keys are strings supplied by the data type variable. We create an entry using that key and ini- tialize a variable if it's not already there. Knowing that we have an entry for this specific data type, we can now append the data as a dictionary. The only modification that we make is tO add another field that contains the current time SO we can display it if needed. At this point we can accept data from any source and store it internally in our ObJect. We're alSO going tO need [ 0 return it [ 0 the client when the request comes in for /get/ stats. MOdify the GetStatsHand1er class tO return this new data object as well as the Other objects: class GetStatsHand1er(tornado. web. RequestHand1er) : def post(self) : # print the results self. write(dict(users=a. users, pages=sortable pages[ : 5 ] , data=a. data)) We're collecting data from an API URL and returning it to the web client through the /get/stats URL. However, we're still ignoring that expire time sent during the initial API request. We need to periodically look at the data that we receive and throw out any data that has expired. TO d0 that, we can Just append some code t0 the end of the Ana1ytics. update data method: def update data(self) : # 100P through the data keys fo て x in 5e1十 . data. keys() : # for each key, clear out the data and keep only what we need tmp_data = self. data [x] self. data[x] for d in tmp data: # if the expire time has not yet passed, keep the data 竏 time. time() く d[ 'expire time ・ ] : self. data[x] . append(d) This new addition [ 0 the method simply looks at all of the data and determines which values are still valid. Looping through each key in the dictionary, this method makes a copy 0f the data for that entry and clears it ou [. Then, looping through each key in that array, we check tO see whether the ⅱ 1 れ e has expired by comparing it tO the current time. Customized Analytics ー 211