AuthorPepa

I Feel It Coming

Zvýšení limitu RAM pro NodeJS aplikaci

Defaultně dostane NodeJS script maximálně 1.76GB RAM na 64bitovém systému. Což je asi na jednovláknové aplikace dost, nicméně se vám může stát, tak jako mě, že potřebujete zaalokovat nějaké opravdu větší pole a byť máte stroj s 16GB RAM, Node vám vráti chybu při pokusu alokovat paměť.

Pak se vám bude hodit parametr příkazové řádky –max_old_space_size, který V8 říká kolik si má vzít RAMky a posune defaultní limit na vámi zadanou hodnotu:

SQL Queries Succinctly

SQL Queries Succinctly (v PDF)

Jaký je rozdíl mezi Javou a JavaScriptem?

Q: What’s the difference between JavaScript and Java?

A: One is essentially a toy, designed for writing small piecess of code, and traditionally used and abused by inexperienced programmers. The other is scripting language for browser.

🙂

Výpočet GEO vzdálenosti v JavaScriptu

Výpočet dle Haversine formula

ESLint

Dnes jsem přešel z JSHintu na ESLint. Tím asi nejpádnějším důvodem je podpora Reactu, respektive jeho JSX a lepší monžnosti konfigurovatelnosti. Musím ale dodat, že jsem se bránil do poslední chvíle. Důvodem byla třeba rychlost lintování: JSHint mi zdrojáky lintoval rychleji… A tohle je informace, kterou se nikde nedočtete.

Než jsem switchnul, pročetl jsem kde co, abych zjistil, že:

  • JSHint je fork původního JSLintu
  • ESLint je dnes už asi více používaný než JSHint, který je tady nicméně déle
  • velké a významné IT používají ESLint…

ESLint, stejně jako JSHint, fungují dobře jak v Atomu, tak i Sublime, což jsou dnes už jediné editory, které dnes používám (když nepočítám Vim…).

Co se mi asi na ESLintu o trochu víc líbí je jeho konfigurace. Konfigurační soubor můžete mít jak v JSON souboru, tak v JS, ale i v Yamlu. V rámci projektu můžete mít v root adresáři výchozí konfiguraci pro ESLint a v dalších jeho podadresářích můžete mít specifické, upravené konfiguráky dle konkrétní potřeby. Vedle toho můžete použít něčí best-practice vzorový konfigurák, ten použít jako základ a upravit jen to chcete jinak…

V ESLintu samozřejmě funkují inlajnované directivy pro linter vkládané přímo do souborů se zdrojáky, stejně jako v JSHintu.

Instalace

Základy CURL

Pokud píšete nějakou REST aplikaci a potřebujete nějak komunikovat se serverem, a tím myslím třeba něajak efektivně mu posílat data, a třeba i dávkově, a nevyhovuje vám HTTPie nevyhovuje, nebo inklinujete k něčemu tradičnímu, pak rozhodně zkuste CURL.

CURL je moncný nástroj, který toho umí mnohem víc, než jen odesílání POST requestů. Samozřejmostí je modifikace hlaviček a například také SSL komunikace.

NodeJS, Module patterns

NodeJS Module Patterns

Novinky v MongoDB 3.4

Na konci minulého roku vyšla nová verze MongoDB ve verzi 3.4, která je nyní ready for production deployment.
What’s New in MongoDB 3.4 white paper

Pěkný článek popisující novinky verze 3.4 o třech částech: 1.díl, 2.díl, 3.díl.

Novinky

Native Graph Processing

Applications storing data in MongoDB frequently contain data that represents graph or tree type hierarchies. Graph and hierarchical data is commonly queried to uncover indirect or transitive relationships. MongoDB 3.4 offers this functionality via a new aggregation stage called $graphLookup to recursively lookup a set of documents with a specific defined relationship to a starting document. Developers can specify the maximum depth for the recursion, and apply additional filters to only search nodes that meet specific query predicates. $graphLookup can recursively query within a single collection, or across multiple collections.
MongoDB $graphLookup operator for graph processing

Faceted Navigation

Faceting is a popular analytics and search capability that allows an application to group information into related categories by applying multiple filters to query results. Facets allow users to narrow their search results by selecting a facet value as a filter criteria. Facets also provide an intuitive interface to exploring a data set, and allow convenient navigation to data that is of most interest. MongoDB 3.4 introduces new aggregation pipeline stages for the bucketing, grouping and counting of one or more facets in a single round trip to the database. As a result, developers can generate richer and intuitive experiences to help users navigate complex data sets.
MongoDB faceted navigation

Multi-Language Collations

Each language has different rules governing the comparison and sorting of data. In order to create intuitive, localized user experiences, applications must handle non-English text with the appropriate rules for that language. For example, French has detailed rules for sorting names with accents on them. German phonebooks order words differently than the German dictionary. MongoDB 3.4 significantly expands language support capabilities to allow users to build applications that adhere to language-specific comparison rules. Support for collations – the rules governing text comparisons and sorting – has been added throughout the MongoDB Query Language and indexes for over 100 different languages and locales. Each collation can also be further customized to provide precise control over case sensitivity, numeric ordering, whitespace handling, and more.
collation in MongoDB from the documentation

Aggregation Pipeline Enhancements

MongoDB 3.4 continues to extend the aggregation pipeline by adding new capabilities within the database that simplify application-side code, as well as optimizer enhancements that improve performance.
MongoDB 3.4 aggregation pipeline enhancements from the documentation

Decimal Data Type

Decimal128 is a 16 byte decimal floating-point number format. Decimal128 supports 34 decimal digits of significance and an exponent range of −6143 to +6144. MongoDB 3.4 adds support for the decimal data type which represents decimal128 values. Unlike the double data type, which only stores approximations of decimal values, the decimal data type stores the exact value.
MongoDB decimal data type

Visualizing MongoDB Data

Building on its initial release, the Connector for BI has been reengineered to improve performance, simplify installation and configuration, and support Windows. Performance and scalability has been improved by moving more query execution down to the MongoDB processes themselves. Queries and complex aggregations are executed natively within the database, thus reducing latency and bandwidth consumption. The Connector for BI is part of the Advanced Analytics suite available with MongoDB Enterprise Advanced.
MongoDB Connector for BI documentation

MongoDB Connector for Apache Spark

MongoDB Connector for Apache Spark has been updated to support the latest Spark 2.0 release.

MongoDB Zones: Sophisticated Data Distribution

MongoDB zones (superceding tag-aware sharding in earlier MongoDB releases) allow precise control over where data is physically stored, accommodating a range of deployment scenarios – for example by geographic region, by hardware configuration, or by application feature. Administrators can continuously refine data placement rules by modifying shard key ranges, and MongoDB will automatically migrate the data to its new zone.
MongoDB zones

Elastic Scalability

Faster Cluster Balancing & Node Synchronization: The balancer process now supports parallel data migrations. Multiple node pairs can perform balancing migrations simultaneously, significantly improving balancing throughput as nodes are added or removed from the cluster, or as data is redistributed across nodes.
Intra-Cluster Network Compression: MongoDB 3.4 introduces a new option to compress the wire protocol used for intra-cluster communications. Based on the snappy compression algorithm, network traffic can be compressed by up to 70%, providing major performance benefits in bandwidth-constrained environments, and reduced networking costs.

Linearizable Reads

MongoDB 3.4 adds a new readConcern level of “linearizable”. This option confirms the primary replica is still connected to a quorum (majority) of replica nodes before returning results to the client. When used to perform reads against a single document, linearizable read concern provides two guarantees: First, it guarantees that the returned data reflects only writes that are committed to a majority of nodes in the replica set, and therefore will not roll back in the future as a result of a replica set election. Second, it guarantees that the read is not stale. This means that the returned data reflects the last write operation to the document that successfully replicated to a majority of nodes. In order to provide the extra guarantees, using linearizable read concern level will have a significant impact on read latency.
reviewing the linearizable read concern documentation

Expanded Platform Support

MongoDB 3.4 has been ported to the ARM v8-64 bit platform. MongoDB 3.4 has been ported to IBM’s POWER8 and zSeries platforms.

Enterprise-Grade Security for Regulatory Compliance

LDAP Authorization: When configured with an LDAP server for authorization, MongoDB 3.4 will allow user authentication via LDAP, Active Directory, Kerberos, or X.509 without requiring local user documents in the $external database.
Read-Only Views: New in MongoDB 3.4, DBAs can define non-materialized views that expose only a subset of data from an underlying collection.

MongoDB Compass

The latest Compass release expands functionality to allow users to manipulate documents directly from the GUI, optimize performance, and create data governance controls.

Operational Management for DevOps Teams

Ops Manager is the simplest way to run MongoDB on your own infrastructure, making it easy for operations teams to deploy, monitor, backup, and scale MongoDB. Ops Manager is available as part of MongoDB Enterprise Advanced, and its capabilities are also available in Cloud Manager, a tool hosted by MongoDB in the cloud.

Ops Manager Monitoring

Ops Manager now allows telemetry data to be collected every 10 seconds, up from the previous minimum 60 seconds interval.

MongoDB Atlas: VPC Peering

MongoDB Atlas offers the latest 3.4 release (community edition) as an option. In addition, MongoDB Atlas also now offers AWS Virtual Private Cloud (VPC) peering. Each MongoDB Atlas group is provisioned into its own AWS VPC, thus isolating the customer’s data and underlying systems from other MongoDB Atlas users. With the addition of VPC peering, customers can now connect their application servers deployed to another AWS VPC directly to their MongoDB Atlas cluster using private IP addresses.

Lodash

Ať už píšete svoji aplikaci v jakémkoliv jazyce, určitě používáte nějaké ty knihovny pro takové ty základní funkcionality, jako je hledání v poli, porovnávání objektů a podobně.

Pokud píšete v JavaScriptu, pak se vám určitě bude líbit Lodash. Najdete v něm téměř všechny základní funkcionality ať už pro práci s čísli, poli, řetězci a podobně. Krom samotného rozsahu jeho nespornou výhodou je výborná dokumentace.

© 2017 pepa.holla.cz

Theme by Anders NorénUp ↑