TLDR: Use for...of instead of forEach() in asynchronous code.
For legacy browsers, use for(...;...;...) or [].reduce()
To execute the promises in parallel, use Promise.all([].map(...))
| func line(from p1: SCNVector3, to p2: SCNVector3) -> SCNNode? { | |
| // Draw a line between two points and return it as a node | |
| var indices = [Int32(0), Int32(1)] | |
| let positions = [p1, p2] | |
| let vertexSource = SCNGeometrySource(vertices: positions) | |
| let indexData = Data(bytes: &indices, count:MemoryLayout<Int32>.size * indices.count) | |
| let element = SCNGeometryElement(data: indexData, primitiveType: .line, primitiveCount: 1, bytesPerIndex: MemoryLayout<Int32>.size) | |
| let line = SCNGeometry(sources: [vertexSource], elements: [element]) | |
| let lineNode = SCNNode(geometry: line) |
| #!/usr/bin/env node | |
| import fs from 'fs' | |
| import jose from 'node-jose' | |
| import pem from 'pem' | |
| async function run () { | |
| try { | |
| // keystore to stick our node-jose keys before we do signing | |
| let keystore = jose.JWK.createKeyStore() |
| let styles: [UIFont.TextStyle] = [ | |
| // iOS 17 | |
| .extraLargeTitle, .extraLargeTitle2, | |
| // iOS 11 | |
| .largeTitle, | |
| // iOS 9 | |
| .title1, .title2, .title3, .callout, | |
| // iOS 7 | |
| .headline, .subheadline, .body, .footnote, .caption1, .caption2, | |
| ] |
| <?php | |
| // This is sample code to draw some of the charts I blogged about here: | |
| // https://medium.com/ios-os-x-development/keeping-your-wits-as-an-indie-app-developer-3b5b14428e1f | |
| // | |
| // A few disclaimers: | |
| // 1. This assumes you have at least 30 days of sales data in order to draw the Trailing 7 Days Chart | |
| // 2. This assumes you have over 52 consecutive weeks of data in order to draw the Trailing Year Chart | |
| // 3. I don't really know PHP. Everything this does, I had to look it up while writing it. If you actually know PHP, sorry. There are surely better ways. | |
| // | |
| // the results of this PHP script is intended to be drawn using the Flot library. |
| // Lefalet shortcuts for common tile providers - is it worth adding such 1.5kb to Leaflet core? | |
| L.TileLayer.Common = L.TileLayer.extend({ | |
| initialize: function (options) { | |
| L.TileLayer.prototype.initialize.call(this, this.url, options); | |
| } | |
| }); | |
| (function () { | |
| # extracted from http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip | |
| # under public domain terms | |
| country_bounding_boxes = { | |
| 'AF': ('Afghanistan', (60.5284298033, 29.318572496, 75.1580277851, 38.4862816432)), | |
| 'AO': ('Angola', (11.6400960629, -17.9306364885, 24.0799052263, -4.43802336998)), | |
| 'AL': ('Albania', (19.3044861183, 39.624997667, 21.0200403175, 42.6882473822)), | |
| 'AE': ('United Arab Emirates', (51.5795186705, 22.4969475367, 56.3968473651, 26.055464179)), | |
| 'AR': ('Argentina', (-73.4154357571, -55.25, -53.628348965, -21.8323104794)), | |
| 'AM': ('Armenia', (43.5827458026, 38.7412014837, 46.5057198423, 41.2481285671)), |
| /* | |
| * An AngularJS Service for intelligently geocoding addresses using Google's API. Makes use of | |
| * localStorage (via the ngStorage package) to avoid unnecessary trips to the server. Queries | |
| * Google's API synchronously to avoid `google.maps.GeocoderStatus.OVER_QUERY_LIMIT`. | |
| * | |
| * @author: benmj | |
| * @author: amir.valiani | |
| * | |
| * Original source: https://gist.github.com/benmj/6380466 | |
| */ |
| /*global angular: true, google: true, _ : true */ | |
| 'use strict'; | |
| angular.module('geocoder', ['ngStorage']).factory('Geocoder', function ($localStorage, $q, $timeout) { | |
| var locations = $localStorage.locations ? JSON.parse($localStorage.locations) : {}; | |
| var queue = []; | |
| // Amount of time (in milliseconds) to pause between each trip to the |
| # | |
| # Sample nginx.conf optimized for EC2 c1.medium to xlarge instances. | |
| # Also look at the haproxy.conf file for how the backend is balanced. | |
| # | |
| user "nginx" "nginx"; | |
| worker_processes 10; | |
| error_log /var/log/nginx_error.log info; |