leftpad

8 results back to index


pages: 292 words: 66,588

Learning Vue.js 2: Learn How to Build Amazing and Complex Reactive Web Applications Easily With Vue.js by Olga Filipova

Amazon Web Services, business logic, continuous integration, create, read, update, delete, en.wikipedia.org, Firefox, Google Chrome, leftpad, MVC pattern, pull request, side project, single page application, single source of truth, Skype, source of truth, web application

We are expecting to see something like 01:05. So, we need the leftpad filter! Let's create it. Go to the main.js file and add a leftpad filter after the uppercase filter definition: //main.js Vue.filter('leftpad', (value) => { if (value >= 10) { return value } return '0' + value }) Open the CountdownComponent component and let's again split min and sec to the different interpolation brackets and add filters to each of them: //CountdownComponent.vue <template> <div class="well"> <div class="pomodoro-timer"> <span>{{ min | leftpad }}:{{ sec | leftpad }}</span> </div> </div> </template> Replace min and sec in data with 1 and 5, respectively, and have a look.

Now we have a title that changes each time the Pomodoro state is being toggled: Automatic change of the title based on the state of the timer Nice, isn't it? Left-pad time values using computed properties Now let's apply the same logic for left padding our minute and second numbers. Let's add two computed properties, min and sec, in our computed section in the data options and apply the simple algorithm to pad the numbers with 0 on the left. Of course, we could use a famous left-pad project ( https://github.com/stevemao/left-pad ), but to keep things simple and not to break the whole Internet ( http://www.theregister.co.uk/2016/03/23/npm_left_pad_chaos/ ), let's apply a simple logic of our own: computed: { title: function () { return this.pomodoroState === POMODORO_STATES.WORK ?

Implementing a shopping list using jQuery Implementing a shopping list using Vue.js Analyzing data binding using developer tools Bringing user input to the data with two-way binding Rendering the list of items using the v-for directive Check and uncheck shopping list items Adding new shopping list items using the v-on directive Using Vue.js in an existing project Vue.js 2.0! Projects using Vue.js Grammarly Optimizely FilterBlend PushSilver Book roadmap Let's manage time! Toggle the title by using computed properties Left-pad time values using computed properties Keep state with start, pause, and stop buttons Exercise Summary 2. Fundamentals – Installing and Using MVVM architectural pattern DefineProperty, getters, and setters Comparing with other frameworks React Angular Vue Vue.js fundamentals Reusable components Vue.js directives Plugins in Vue.js Exercise Application state and Vuex vue-cli Vue plugins for IDEs Installing, using, and debugging a Vue.js application Installing Vue.js Standalone CDN Bower CSP-compliant npm vue-cli Dev build Debugging your Vue application Scaffolding our applications Scaffolding the shopping list application Bootstraping your Pomodoro application Exercise Summary 3.


pages: 1,136 words: 73,489

Working in Public: The Making and Maintenance of Open Source Software by Nadia Eghbal

Amazon Web Services, Apollo 11, barriers to entry, Benevolent Dictator For Life (BDFL), Big Tech, bitcoin, Clayton Christensen, cloud computing, commoditize, commons-based peer production, context collapse, continuous integration, crowdsourcing, cryptocurrency, David Heinemeier Hansson, death of newspapers, Debian, disruptive innovation, Dunbar number, en.wikipedia.org, eternal september, Ethereum, Firefox, Free Software Foundation, Guido van Rossum, Hacker Ethic, Hacker News, Induced demand, informal economy, information security, Jane Jacobs, Jean Tirole, Kevin Kelly, Kickstarter, Kubernetes, leftpad, Mark Zuckerberg, Menlo Park, Neal Stephenson, Network effects, node package manager, Norbert Wiener, pirate software, pull request, RFC: Request For Comment, Richard Stallman, Ronald Coase, Ruby on Rails, side project, Silicon Valley, Snapchat, social graph, software as a service, Steve Jobs, Steve Wozniak, Steven Levy, Stewart Brand, tacit knowledge, the Cathedral and the Bazaar, The Death and Life of Great American Cities, The Nature of the Firm, TikTok, Tragedy of the Commons, transaction costs, two-sided market, urban planning, web application, wikimedia commons, Yochai Benkler, Zimmermann PGP

Npm published a postmortem of the affair, in which they noted that a developer named Cameron Westland “stepped in and published a functionally identical version of left-pad” within ten minutes. After some developers continued to hit versioning errors (Westland’s version was listed as 1.0.0, but some dependencies had specified an older version of left-pad), npm itself “took the unprecedented step” of restoring Koçulu’s original library, which he had deleted. While npm’s users continued to debate the ethical and policy implications of this decision for months afterward, the time between Koçulu “breaking the internet” and the restoration of normal operations was just two and a half hours.246 Left-pad was widely depended upon, and its disappearance had noticeable effects, but it was also trivially easy to replace.

In 2016, a developer named Azer Koçulu, who felt unhappy with npm over a naming dispute, decided to take down all his modules without warning, declaring in a blog post titled “I’ve Just Liberated My Modules” that “NPM is someone’s private land where corporate is more powerful than the people, and I do open source because, Power To The People.”244 One of those liberated modules was a library called left-pad, a simple function that would right-justify your text. It was just seventeen lines long. But because several other large npm packages used left-pad—including Babel, a JavaScript compiler downloaded 11 million times per week—suddenly, thousands of developers everywhere started hitting errors in what was described by the media as a “break the internet” moment.245 The effect was certainly disruptive. In terms of dependencies, the fact that so many developers immediately felt its absence suggests that left-pad was widely depended on. But was it valuable?

While npm’s users continued to debate the ethical and policy implications of this decision for months afterward, the time between Koçulu “breaking the internet” and the restoration of normal operations was just two and a half hours.246 Left-pad was widely depended upon, and its disappearance had noticeable effects, but it was also trivially easy to replace. This property is known as substitutability—the ability of goods or services to be replaced by other alternatives—and it applies to a lot of open source code, particularly as one goes higher up the application stack. While left-pad is an extreme example, software substitutability helps us understand why frontend web frameworks like Angular or Vue are harder to monetize than are databases like MongoDB and MySQL. There are lots of frontend frameworks to choose from (though switching costs substantially increase after you’ve chosen one to build with), but I’m less likely to want to make my own production-quality database.


pages: 139 words: 35,022

Roads and Bridges by Nadia Eghbal

AGPL, Airbnb, Amazon Web Services, barriers to entry, Benevolent Dictator For Life (BDFL), corporate social responsibility, crowdsourcing, cryptocurrency, data science, David Heinemeier Hansson, Debian, DevOps, en.wikipedia.org, Firefox, Free Software Foundation, GnuPG, Guido van Rossum, Ken Thompson, Khan Academy, Kickstarter, leftpad, Marc Andreessen, market design, Network effects, platform as a service, pull request, Richard Stallman, Ruby on Rails, Salesforce, side project, Silicon Valley, Skype, software is eating the world, the Cathedral and the Bazaar, Tragedy of the Commons, Y Combinator

Azer, a Node.js developer, hosted a number of libraries on a package manager platform called npm. After a conflict with npm over trademark rights on one of his projects, Azer, frustrated with the outcome, decided to remove everything he had ever published to npm. [100] One of those libraries, left-pad, was referenced in hundreds of other software projects. Although it was just a few lines of code, by removing the left-pad project, Azer broke countless other software developers’ processes. Azer’s decision caused so many issues that npm made the unprecedented decision to republish his library, against Azer’s will, in order to restore functionality to the rest of the ecosystem. [101] Npm also revised its policies to make it harder for developers to remove their libraries without warning, recognizing how individual actions could negatively affect so many others. [102] Software not getting the necessary maintenance it needs Building digital infrastructure in a haphazard fashion means that all software gets built more slowly and inefficiently.


pages: 602 words: 207,965

Practical Ext JS Projects With Gears by Frank Zammetti

a long time ago in a galaxy far, far away, Albert Einstein, corporate raider, create, read, update, delete, database schema, en.wikipedia.org, fake news, Firefox, full text search, Gordon Gekko, Kickstarter, Larry Wall, leftpad, loose coupling, Ronald Reagan, web application

It’s a simple positional insert, which means that subsequent arguments will be inserted sequentially into the target string, which is the first argument. So, “Barack” is inserted in place of token {0}, and “Michelle” into token {1}. The text in the alert() pop-up after that work is what you see in Figure 1-15. Figure 1-15. The output of String.format() Next up is the leftPad() method, which gives you a convenient way to pad out values (most usually numbers, but not necessarily): alert(String.leftPad("1234", 8, "0")); C ha P t e r 1 ■ I N t r O D U C I N G W e B D e V e LO P M e N t W I t h e X t JS The first argument is the value to pad out, and the second is the final length we want it to be. The final argument is the character to pad the first argument with, if its length initially is less than the second argument.

The final argument is the character to pad the first argument with, if its length initially is less than the second argument. So here the alert() message says “00001234,” and if you don’t believe me take a look at Figure 1-16! Figure 1-16. The output of String.leftPad() The toggle() method is next, and it’s a deceptively simple little function: var s = "Republican"; alert(s.toggle("Republican", "Democrat")); Here, the message in the alert() is as shown in Figure 1-17. Figure 1-17. The output of String.toggle() toggle() has compared the value of the string s to the literal string “Republican”. If it matches, then it toggles the value and returns the second argument, “Democrat” in this case.

See Gears (browser extension) GPL open source license, 262 Gray Extended theme, 499, 502 Grid widget, 93 SQL Workbench sample application and, 388 TimekeeperExt sample application and, 198, 202, 212, 223–227 GroupingStore, 102, 509 grow configuration option, 78, 81 growMax configuration option, 78, 81 growMin configuration option, 78, 81 H handlePlayerDrop() method, 455, 480, 481, 482 hasListener() method, 35 Header.js file, for LocalBusinessSearch sample application, 341–350 head tag, 134 height configuration option, 82 Help.js, for SQL Workbench sample application, 430–433 Help menu, TimekeeperExt sample application and, 231 hide() method Dueling Cards sample game and, 456 OrganizerExt sample application and, 165 TimekeeperExt sample application and, 256 hideBorders configuration option, 61 highlight() method, 346 htmlDecode() method, 48 HtmlEditor widget, 79 htmlEncode() method, 48 HttpProxy, 102 I icon images, 133 icon views for OrganizerExt sample application, 180 switching view modes and, 189 id configuration option, 60 IDEs (integrated development environments), 13 id property, 151 images card stack, for Dueling Cards sample game, 458 preloading, 455 images field, for Dueling Cards sample game, 450 imagesSizes field, for Dueling Cards sample game, 451 img directory for CabinetExt sample application, 262 for OrganizerExt sample application, 133 for SQL Workbench sample application, 374 for TimekeeperExt sample application, 199 565 566 nINDEX increment configuration option, 99 index.htm file for CabinetExt sample application, 263 for OrganizerExt sample application, 133, 134 for SQL Workbench sample application, 374 for TimekeeperExt sample application, 199, 200 indexOf() method, 21 IndicatorsCode.js file, for Dueling Cards sample game, 460–463 init() method CabinetExt sample application and, 263, 268, 277 LocalBusinessSearch sample application and, 336 OrganizerExt sample application and, 135, 149, 154 plug-ins and, 123 TimekeeperExt sample application and, 206, 214 initMain() method OrganizerExt sample application and, 155, 157 TimekeeperExt sample application and, 214, 216 initOpponent() method, 486, 487 insert() method, 39 insertAfter() method, 39 insertBefore() method, 39 insertFirst() method, 39 integrated development environments (IDEs), 13 is() method, 43 isAir property, 25 isArray() method, 28 isAutoRefreshing() method, 44 isBorderBox property, 25 isChrome property, 25 isDate() method, 28, 192 isEmpty() method, 28, 525 isGecko property, 25 isGecko2property, 25 isGecko3property, 25 isIE property, 25 isIE6 property, 25 isIE7 property, 25 isIE8 property, 25 isLeapYear() method, 23 isLinux property, 25 isMac property, 25 isOpera property, 25 isReady property, 25 isSafari2 property, 25 isSafari3 property, 25 isSafari property, 25 isStrict property, 25 isUpdating() method, 44 isValidDrop() method, 480 isValid() method, 85 isValidRow() method, 151 isVisible() method CabinetExt sample application and, 274 Dueling Cards sample game and, 465 isWindows property, 25 items array, 60, 61 items configuration option, 61 itemSelector configuration option, 181 J JavaScript imports, 19 JavaScript libraries, 14 JavaScript Object Notation (JSON), 314 join() method, 525 jQuery, 14 js directory for CabinetExt sample application, 262 for OrganizerExt sample application, 133 for TimekeeperExt sample application, 199 JSON (JavaScript Object Notation), 314 JSON class, 49 JSON-P (JSON with Padding), 312–316 JsonStore, 102 K Kant, Mrinal, 371 keyup event handler, TimekeeperExt sample application and, 253 L layout attribute, 60 layout configuration option, 61 layouts, 60, 62–75, 171 leftPad() method, 32 length property, 279 libraries, 14 licensing for Ext Core, 55 for Ext JS, 16, 55, 262 line charts, 118 nI N D E X listDatabases() method, 386, 390, 392 listeners configuration option, 60 listTableDetails() method, 396 listTables() method, 389, 393, 414 list views for OrganizerExt sample application, 179, 181 switching view modes and, 189 load() method, 102 DataStore, 364 ResultsStore, 367 ScriptTagProxy, 316, 356 loadData() method, TimekeeperExt sample application and, 215, 216 loadDefaults() method, 339 loadexception event, 160 LocalBusinessSearch (sample application), 322–369 adding features to, 369 code for, 327–368 favorites for, 328, 338, 345, 358 LocalBusinessSearch.js file for, 334–339 maps for, 353–357 markup for, 323 search functionality for, 360–369 structure of/files for, 322 what the application does, 310 LocalServer component (Gears), 124 lowercase() method, 46, 302 M Mac OS, Fisheye lists and, 341 magic numbers, 336, 338 main region.


pages: 1,038 words: 137,468

JavaScript Cookbook by Shelley Powers

business logic, Firefox, Google Chrome, hypertext link, leftpad, semantic web, SQL injection, web application, WebSocket

The use of the JavaScript object prototype property is covered in Recipe 16.3. 1.11 Left- or Right-Pad a String Problem You need to create a string that’s left- or right-padded with a given character. Solution Test the length of the string, then generate a padding string consisting of duplications of a given character to either concatenate to the original string (if padding to the right) or attaching to the beginning of the string (if padding to the left). The following left-pads the existing string with the nonbreaking space named character (&nbsp;): <!DOCTYPE html> <head> <title>Recipe 1.12</title> </head> <body> <div id="result"></div> <script> var prefLineLength = 20; var oldStr = "This is a string"; var diff = prefLineLength - oldStr.length; var filler = '&nbsp;'; for (var i = 0; i < diff; i++) { oldStr=filler + oldStr; } document.getElementById("result").innerHTML=oldStr; </script> </body> Discussion You don’t want to pad strings that go into a database, because you want to keep the data in the database as small and efficient as possible.

= (inequality) operator, 6 height attribute (canvas element), 327 inform function (JsUnit), 394 height property (bounding rectangle), 272 inherit value (CSS display property), 276 hexadecimal numbers, converting to decimals, inheritance, objects, 366–369 59 inline-block value (CSS display property), 276 hidden attribute, 277 inline CSS values, getting, 240 hiding form elements, 171–173 inner functions, 104 hiding page elements, 276–277 innerHeight property (window element), 270 collapsing sidebars, 292–295 innerHTML property, 241–242, 244 using tabs (divided content), 284–289 innerHTML property, 422 ARIA accessibility with, 320–323 input, form (see forms) hiding page sections, 299–300 input, validating (see validating) highlighting input elements, finding all checked, 233–234 actions with color flashes, 316–320 insertBefore method, 244, 248, 254 all instances of pattern, 28–31 inserting elements first paragraph of div elements, 227–230 adding paragraphs to divs, 248 history elements, 143 and then adding text, 249–251 host property (location element), 151 at end to page, 246–247 hosting libraries as open source, 397–399 before existing elements, 242–246 hostname property (location element), 151 with innerHTML property, 241–242 hover-based pop-up windows, 289–292 Internet Explorer’s Developer Tools, 194–196 href property (location element), 151 using breakpoints, 196–197 HTML, embedding SVG into, 339–345 iPhone applications, building, 494–495 integrating with canvas, 347–350 iPhoneOrientation events, 141 HTML, processing Ajax text results as, 422 isExtensible method (Object), 378 html elements, 211 isFrozen method (Object), 381 HTML tab (Firebug), 186 isNaN function, 181 HTML tags, replacing with named entities, 36 ISO 8601 formatted dates, 43–44 HTML5 drag-and-drop, 132–140 converting string to Date object, 45–47 HTML5 postMessage API, 430–434 HTML5 shims, 247 HTMLElement objects, 244 J hyperlinks, replacing links with, 254–257 JavaScript, handling when disabled, 177–180 -- (decrement) operator, 58 JavaScript Compressor, 397 join method (Array), 73–74 I jQuery.fn property, 404 jQuery framework, 399, 400–402 \i flag (regular expressions), 26 converting libraries to plug-ins, 404–407 id attribute (form element), 213 RDF plug-in, 450–455 image dimensions, basing on page, 149–150 using jQuery plug-ins, 402–404 image elements jQuery Validation plug-in, 403 accessing all in article, 221–222 JSON (JavaScript Object Notation), 435 using Selectors API, 222–226 converting objects to strings, 445–446 Index | 519 converting RDFa into, 450–455 listener/sender functionality, 431 generating JavaScript objects with, 442– literals, 1 443 live regions, accessibility of, 323–324 parsing JSON-formatted strings, 444–445 LN10 property (Math), 56 JSONP (JSON with Padding), 423 LN2 property (Math), 56 JsUnit, testing code with, 392–396 load events, 115 load method (media elements), 355 K localeCompare method (String), 8 localStorage objects, 476–479 keyboard events, 116, 129–132 location data for elements, 273–276 with textarea elements, 162 location elements, 143, 150 keyboard listening, page overlays with, 308– bookmarking dynamic pages, 153 312 log method (Math), 57 keydown events, 130 LOG10E property (Math), 56 keypress events, 130 LOG2E property (Math), 56 with form elements, 162 && (logical AND) operator, 11 keys method (Object), 375, 376 long polling, 429 keyup events, 130 loops through array elements, 71 -khtml-user-drag CSS setting, 135 lowercase (see case) L M language property (Navigator), 146 \m flag (regular expressions), 26 lastIndex property (RegExp), 30 Mac Dashboard widgets, 489–490 lastIndexOf method (Array), 78 map method (Array), 83 lastIndexOf method (String), 9 match method (String), 26 left-padding strings, 19–20 matching (see regular expressions) left property (bounding rectangle), 272, 273 math, 55 length property (NodeList), 216 (see also numbers) length property (String), 11 calculating arc lengths, 67–68 < (less than) operator, 7 converting degrees and radians, 64–65 <= (less than or equal) operator, 7 finding circles that fit page elements, 65– libraries, 389–411 67 combining several, 408–411 summing column of numbers, 62–64 converting to jQuery plug-ins, 404–407 Math objects, 56–57 external, using, 400–402 building clock with, 345–346 hosting as open source, 397–399 max-age= parameter (cookies), 463 JsUnit, testing code with, 392–396 max method (Math), 57 minify, to compress code, 397 media (see rich media) packaging code into files, 390–392 media attribute, 148 using existing jQuery plug-ins, 402–404 @media rule, 149 LIFO (last-in, first-out), 76–77 memoization (caching calculations), 109–112 line charts (canvas), 330–333 message property (Error), 183 line feed (\n), 16 meta elements, 211 matching in regular expressions, 23 method chaining, 236, 385–387, 402 lineNumber property (Error), 183 methods, object lines in textareas, processing, 16–17 creating, 362–364 links, replacing links with, 254–257 keeping private, 361–362 links collection (document element), 212 preventing any changes to, 380–381 listeners (see event listeners) 520 | Index Microformat annotations (hCalendar), 447– new keyword, 360 450 new line (\n), 16 microformats, working with, 448 matching in regular expressions, 23 Microsoft OpenOffice macros, creating, 498– NodeList collection, 216 500 nodes, DOM, 211 mimeTypes collection (Navigator), 146 nonempty strings, checking for, 10–12 min method (Math), 57 nonbreaking space character, 19 mobile development, 140 none value (CSS display property), 276 mobile phone applications, building, 494–495 noscript elements, 178 mobile widgets, creating, 489–494 :not pseudoselector, 224 modularizing code, 391 :nth-child pseudoclass, 230 % (modulo) operator, 230 Number objects, 55 mouse events, 116 numbers, 55–68 capturing mouse-click information, 119– concatenating with strings, 4 122 converting decimals to hexadecimals, 59 hover-based pop-up windows with, 289– converting degrees and radians, 64–65 292 calculating arc lengths, 67–68 with textarea elements, 162 converting strings into, 61–62 mouse gesture events, 117 dates (see date and time) moving elements within pages, 254 incremental counters, 57–58 Mozilla extensions, building, 486 matching in regular expressions, 23, 27 multidimensional arrays, 71–73 random, generating, 59–60–61 flattening into single dimension, 79–80 social security numbers, validating, 26–28 multimedia (see rich media) sorting array elements numerically, 74 multiple form submissions, preventing, 169– summing column of, 62–64 171 NVDA screen reader, 297 N O \n (new line) character, 16 objects, 359–387 matching in regular expressions, 23 adding getter/setter functionality, 364–366 name attribute (form element), 213 adding new properties, 369–374 name property (Error), 183 chaining methods, 385–387 named entities, 36 creating, 360–361 @namespace statement, 224 enumerating properties of, 374–377 namespace variations expanding with prototype, 362–364 adding attributes to elements, 252 as function arguments, 96–98 creating elements or attributes, 245 inheriting functionality of, 366–369 element queries and, 218, 224 members of, keeping private, 361–362 embedding SVG into HTML, 340 one-off objects, 381–383 namespaceURI property, 225 preventing any changes to, 380–381 namespacing your JavaScript, 381–383 preventing extensibility of, 377–378 NaN property (Number), 56 preventing property descriptor changes, NaN value, 181 379–380 navigator elements, 143, 145 Office applications, creating macros for, 498– negation (:not) pseudoselector, 224 500 nested elements, propagating events through, offset, element, 273 126–129 onblur event Netflix-style pop-up windows, 289–292 accessing form element data, 162 Network page (Dragonfly), 200 highlighting invalid form fields, 303 Index | 521 onchange event page overlays, 281–283 accessing form element data, 162 adding keyboard accessibility to, 308–312 highlighting invalid form fields, 302 page space, 269–295 onclick events, 119–122 collapsible form sections, 277–280, 312– one-off objects, 381–383 316 onfocus event, accessing form element data, collapsible sidebars, 292–295 162 hiding elements until needed, 276–277 onload events, 117–118 hover-based pop-up windows, 289–292 onmessage event handler (WebSocket), 429 measuring area of window, 270–271 onmouseout event, for hover-based pop-up overlays for pages, 281–283 windows, 289 adding keyboard accessibility to, 308– onmouseover event, for hover-based pop-up 312 windows, 289 position data for page elements, 273–276 onpopevent event handler, 465–469 using tabs (divided content), 284–289 onreadystatechange property ARIA accessibility with, 320–323 (XMLHttpRequest), 420 pages (web pages) open method (window element), 145 accessing all images in, 216–221 open method (XMLHttpRequest), 414, 418 automatic periodic updates, 427–430 open sourcing code, 397–399 circles sized to fit, 65–67 OpenOffice macros, creating, 498–500 detecting page loads, 117–118 Opera widgets, creating, 490–494 dynamic Opera’s Dragonfly, 198–200 bookmarking, 153–156 using breakpoints, 201 preserving state for Back and Refresh, operators, overloaded, 3 156–157 Orca screen reader, 297 embedding SVG into HTML, 339–345 ordering hiding or showing sections of, 299–300 array elements (see sorting arrays) integrating SVG and canvas in, 347–350 orientation events (Safari), 140–142 modifying image dimensions for, 149–150 outer functions, 104 moving elements within, 254 overflow property, 269 positions of elements on, 273–276 overlays for pages, 281–283 removing paragraphs from, 260–261 adding keyboard accessibility to, 308–312 using tabs (divided content), 284–289 overloaded operators, defined, 3 ARIA accessibility with, 320–323 overrideMimeType method warning about leaving, 146–147 (XMLHttpRequest), 415, 436 when JavaScript is off, 177–180 paragraphs (see p elements) P parcel-descriptor.xml files, 498 ( ) (parentheses) in regular expressions, 24, 32– p elements, 211 34 finding parent element for, 226 parent elements, finding, 226 highlighting first in each div, 227–230 parentNode property, 215, 226 inserting new, 248 parse method (JSON), 444 and adding text to, 249–251 parseFloat function, 62 moving within page, 254 parseInt function, 61 removing from pages, 260–261 parsing JSON-formatted strings, 444–445 packaging code into files, 390–392 partial functions, 104 padding property (bounding rectangle), 272 password elements, 162 padding strings, 19–20 path method (canvas), 330 page elements (see elements) path= parameter (cookies), 463 page fragments, 458–461 522 | Index pathname property (location element), 151 private members of objects, 361–362 pattern matching (see regular expressions) privileged methods, 362 pause method (media elements), 355 processing XML documents, 436–437 % (modulo) operator, 230 product property (Navigator), 146 performance of application, profiling, 190– profiling application performance, 190–194 194 prompt pop up boxes, 144 .


pages: 419 words: 102,488

Chaos Engineering: System Resiliency in Practice by Casey Rosenthal, Nora Jones

Amazon Web Services, Asilomar, autonomous vehicles, barriers to entry, blockchain, business continuity plan, business intelligence, business logic, business process, cloud computing, cognitive load, complexity theory, continuous integration, cyber-physical system, database schema, DevOps, fail fast, fault tolerance, hindsight bias, human-factors engineering, information security, Kanban, Kubernetes, leftpad, linear programming, loose coupling, microservices, MITM: man-in-the-middle, no silver bullet, node package manager, operational security, OSI model, pull request, ransomware, risk tolerance, scientific management, Silicon Valley, six sigma, Skype, software as a service, statistical model, systems thinking, the scientific method, value engineering, WebSocket

., Site Reliability Engineering (Sebastopol, CA: O’Reilly, 2016), Chapter 28. 2 This intriguing behavioral tendency is also exhibited in real-life physical emergencies such as building fires: see Lea Winerman, “Fighting Fire with Psychology,” APA Monitor on Psychology, Vol. 35, No. 8 (Sept. 2004). 3 For a great read on this topic, see Ben Treynor et al., “The Calculus of Service Availability,” Communications of the ACM, Vol. 60, No. 9 (Sept. 2017). 4 One notorious public example was the removal of the left-pad package from the Node Package Manager repository (www.npmjs.com) in March 2016, which caused the builds of uncountable JavaScript projects around the globe to stop working. 5 Lottery factor is a metaphor of the risk resulting from information and capabilities not being shared among team members, as exemplified by a team member winning the lottery and quitting without notice.


pages: 696 words: 111,976

SQL Hacks by Andrew Cumming, Gordon Russell

Apollo 13, bioinformatics, book value, business intelligence, business logic, business process, database schema, en.wikipedia.org, Erdős number, Firefox, full text search, Hacker Conference 1984, Hacker Ethic, leftpad, Paul Erdős, SQL injection, Stewart Brand, web application

Convert Your Dates Suppose you have dates in user-supplied input in this format6/18/2006and you need to create date literals for an INSERT statement such as this one: DATE '2006-06-18'. Here's how you can accomplish this in Perl: foreach ('6/18/2006', '12/13/2006'){ if (/(\d+)\/(\d+)\/(\d\d\d\d)/){ # Capture date parts into $1, $2, $3 my $m = substr("0$1", -2); # Left-pad with zeros if needed my $d = substr("0$2", -2); my $y = $3; $sql = "INSERT INTO d VALUES (DATE '$y-$m-$d')"; print "$sql\n"; } else { warn "Could not parse date: $!"; } } Note that we in-lined the user-supplied values directly into the INSERT statement. In theory, this would have opened us up to an SQL injection attack [Hack #48].


pages: 480 words: 122,663

The Art of SQL by Stephane Faroult, Peter Robson

business intelligence, business logic, business process, constrained optimization, continuation of politics by other means, database schema, full text search, invisible hand, it's over 9,000, leftpad, SQL injection, technological determinism

All you have to specify is the node you wish to start from (start with) and how each two successive rows returned relate to each other (connect by < a column of the current row > = prior < a column of the previous row >, or connect by < a column of the previous row > = prior < a column of the current row >, depending on whether you are walking down or up the tree). For indentation, Oracle maintains a pseudo-column named level that tells you how many levels away from the starting point you are. I am using this pseudo-column and left-padding the description with as many spaces as the current value of level. My query is: select lpad(description, length(description) + level) description, commander from adjacency_model connect by parent_id = prior id start with commander = 'Général de Division Dominique Vandamme' And the results are: DESCRIPTION COMMANDER ------------------------------- ----------------------------------------------- III Corps Général de Division Dominique Vandamme 8th Infantry Division Général de Division Baron Etienne-Nicolas Lefol 2nd Brigade Général de Brigade Baron Corsin 37th Rgmt de Ligne Colonel Cornebise 1st Brigade Général de Brigade Billard (d.15th) 23rd Rgmt de Ligne Colonel Baron Vernier 15th Rgmt Léger Colonel Brice ... 10th Infantry Division Général de Division Baron Pierre-Joseph Habert 2nd Brigade Général de Brigade Baron Dupeyroux 70th Rgmt de Ligne Colonel Baron Maury 22nd Rgmt de Ligne Colonel Fantin des Odoards 2nd (Swiss) Infantry Rgmt Colonel Stoffel 1st Brigade Général de Brigade Baron Gengoult 88th Rgmt de Ligne Colonel Baillon 34th Rgmt de Ligne Colonel Mouton Division Artillery 18/2nd Foot Artillery Captain Guérin 40 rows selected.