5750
Creating custom collections in Swift — Swift by Sundell
Using custom collections can be a really powerful tool to handle groups of values in a more predictable and easy-to-use way. While it probably shouldn't always be your go-to solution as soon as you're dealing with multiple values, in the right situations it can really help you write cleaner code.

Understanding how things like collections work under the hood can also be really helpful when debugging, or to give you insight as to how code dealing with collections can be optimized. And what better way to learn more about collections than building your own? 😄
swiftlang  collections 
2 days ago
AudioKit/AudioKit: Swift audio synthesis, processing, & analysis platform for iOS, macOS and tvOS
AudioKit is an audio synthesis, processing, and analysis platform for iOS, macOS, and tvOS.
ios  osx  audio  lang:swift  is:repo 
2 days ago
Sash Zats on Twitter: "[1/4] When performing intensive animations or other auxiliary work consider creating a helper checking following (in no particular order):"
When performing intensive animations or other auxiliary work consider creating a helper checking following (in no particular order):

• NSProcessInfo thermalState - is device already working hard
• NSProcessInfo isLowPowerModeEnabled - is user trying to safe battery
• UIAccessibilityIsReduceMotionEnabled - is user sensitive to motion
• UIDevice batteryState & batteryLevel - to know when device is not charging and low on battery
ios  animation  bestpractices  uikit  is:tweet 
2 days ago
Swift.org - Swift Local Refactoring
Walkthrough of how local refactorings are implemented for Swift in Xcode 9.
xcode  xcode9  refactoring  swiftlang 
6 days ago
Go concurrency considered harmful – Sargun Dhillon – Medium
Go is a super neat language that seems to have found an ever-growing number of programmers adopting it. Its approachable type system, and concurrency semantics make it perfect to be immediately productive. Unfortunately, as the language, and its usage has evolved, these semantics have fallen short for real world scenarios.

In my perfect world, we would adopt Erlang/OTP. Unfortunately, pragmatism suggests that this future is unlikely. Instead, as we develop Go 2.0, we should try to take lessons from languages that came before it. I intend to write two additional articles on what we can learn from Erlang’s error handling semantics, operability, and type system. If there is enough interest, I’ll turn them into experience reports.

Sharing by communicating is an awesome idea. I would dare to say that it’s the right approach, but it’s hard to do without help.The things that would have helped me here, would be a type system that prevents mutable types from being passed as a value over the channel, and ensuring that my code is concurrency, and type safe. Another nicety would be goroutine IDs, and termination (preemption) semantics. This way, a parent process could preempt a set of goroutines, rather than having to come up with hacky synchronization points.
golang  erlang  concurrency  synchronization 
10 days ago
golang-standards/project-layout: Standard Go Project Layout
This is a basic layout for Go application projects. It represents the most common directory structure with a number of small enhancements along with several supporting directories common to any real world application.
is:repo  golang  project_layout  organization  packaging  lang:go 
10 days ago
How to Write Go Code - The Go Programming Language
This document demonstrates the development of a simple Go package and introduces the go tool, the standard way to fetch, build, and install Go packages and commands.
golang  project_layout  organization  packaging  workspace  testing 
10 days ago
Go Project Layout – golang-learn – Medium
A good introduction to structuring a Go project.
Is there a standard way to organize your code? What if you need to have multiple application binaries? What does it mean to be ‘go gettable’?
golang  project_layout  organization  packaging  bestpractices 
10 days ago
With network crackdown, China seeks to fortify Great Firewall- Nikkei Asian Review
BEIJING -- China is taking great pains to enforce a ban on virtual private networks, which let citizens skirt restrictions on internet activity, and the crackdown represents the latest step in the country's yearslong quest to silence online dissent.
china  gfw  censorship  vpn 
12 days ago
Concurrency in Erlang & Scala: The Actor Model
Nice walkthrough of considerations in Erlang's and Scala's actor implementations.
This article described the actor model for the implementation of concurrency in applications, as an alternative to threading and locking. It highlighted Erlang and Scala, two languages with an implementation of the actor model and showed how these languages implement this model.

Erlang is a pure functional language, providing little more than the basic features of functional languages. This should certainly not be seen as a weakness though: this simplicity allows it to optimize specifically for the cases for which it was defined as well as implement more advanced features like hot-swapping of code.

Scala on the other hand uses a mix of object-oriented and functional styles. This makes it easier for a programmer to write code, especially given the extra constructs offered by Scala, but this flexibility comes with a warning: discipline should be used to avoid inconsistencies.

The differences between these languages should be seen and evaluated in their design context. Both however provide an easy to use implementation of the actor model, which greatly facilitates the implementation of concurrency in applications.
erlang  scala  concurrency  async  message_passing  actor_model  oop  safety 
12 days ago
Fault Tolerance doesn't come out of the box | Erlang Solution blog
One of the biggest selling points of Elixir is the means it gives you to write fault tolerant applications via its concurrency model. Processes can broadcast their failure to dependant processes which can take appropriate action. You decide how processes should respond to failure based on your use case. There is no single solution.
concurrency  faulttolerance  erlang  supervisors  actor_model 
13 days ago
Who Supervises The Supervisors? | Learn You Some Erlang for Great Good!
The OTP supervisors, fortunately, provide the flexibility to handle such cases (and more). They let you define how many times a worker should be restarted in a given period of time before giving up. They let you have more than one worker per supervisor and even let you pick between a few patterns to determine how they should depend on each other in case of a failure.
concurrency  faulttolerance  erlang  supervisors  actor_model 
13 days ago
Errors and Processes | Learn You Some Erlang for Great Good!
A link is a specific kind of relationship that can be created between two processes. When that relationship is set up and one of the processes dies from an unexpected throw, error or exit (see Errors and Exceptions), the other linked process also dies.

This is a useful concept from the perspective of failing as soon as possible to stop errors: if the process that has an error crashes but those that depend on it don't, then all these depending processes now have to deal with a dependency disappearing. Letting them die and then restarting the whole group is usually an acceptable alternative. Links let us do exactly this.
faulttolerance  errors  erlang  concurrency  actor_model 
13 days ago
Four years later, the Ann Arbor Chronicle is still weird and wonky — and it’s growing » Nieman Journalism Lab
From 2012:
For four years, Mary Morgan and Dave Askins have been the change David Simon was waiting for.

The married couple’s website, the Ann Arbor Chronicle, doesn’t just cover the planning commission, as the Wire creator once suggested bloggers never would; it covers the taxicab board. It doesn’t just publish local election results; it publishes fact-checked 13,482-word summaries of the fifth-ward city council candidate forum, 10 days after the event took place. Morgan, Askins, and seven paid freelancers contribute. On a busy day, the Chronicle posts three stories; on a slow day, it posts nothing.
annarbor  journalism  newspapers  a2council  a2chronicle 
13 days ago
major/MySQLTuner-perl: MySQLTuner is a script written in Perl that will assist you with your MySQL configuration and make recommendations for increased performance and stability.
MySQLTuner is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief format along with some basic performance suggestions.
mysql  performance  sysadmin  is:repo 
17 days ago
The Go Programming Language Specification - Assignability
A value x is assignable to a variable of type T ("x is assignable to T") in any of these cases:

• x's type is identical to T.
• x's type V and T have identical underlying types and at least one of V or T is not a defined type.
• T is an interface type and x implements T.
• x is a bidirectional channel value, T is a channel type, x's type V and T have identical element types, and at least one of V or T is not a defined type.
• x is the predeclared identifier nil and T is a pointer, function, slice, map, channel, or interface type.
• x is an untyped constant representable by a value of type T.
golang  assignment  nil  assignability 
17 days ago
mikeash.com: Friday Q&A 2017-08-25: Swift Error Handling Implementation
Swift's error handling invites comparison with exceptions in other languages, such as C++. C++'s exception handling is extremely complicated internally, but Swift takes a different approach. Instead of unwind tables to achieve "zero-cost" in the common case, Swift returns thrown errors in a special register, and the caller checks that register to see if an error has been thrown. This adds a bit of overhead when errors aren't thrown, but avoids making things enormously complicated the way C++ does. It would take serious effort to write Swift code where the overhead from error handling makes any noticeable difference.


Nice look into how this actually gets implemented under the hood and why this is so different from C++ exceptions.
swiftlang  error_handling  throws  exceptions 
23 days ago
jbrennan/Prototope: Swift library of lightweight interfaces for prototyping, bridged to JS
Prototope is a lightweight, high-performance prototyping framework. Its goals are:

• enabling rapid iteration
• high performance execution
• concepts easily mapped onto production implementation
lang:swift  prototyping  tool  is:repo 
24 days ago
Did you know that the NSA uses Uber Drivers and Soccer Moms to Spy on You?
In the United States there are thousands of otherwise normal citizens with camera equipped cars driving the streets spying on your every move. Each day your car’s license plate is often scanned more than a dozen times, in several locations, by several different scanners from several different companies. The most common scanners are deployed on private vehicles and are capable of scanning 1,800 plates per minute. This data from these scans is uploaded to several different national license plate databases and sold to banks and law enforcement organizations — including the NSA.
nsa  ALPR  surveillance 
24 days ago
proposal/12914-monotonic.md at master · golang/proposal
Implemented in Go 1.9.
Comparison and subtraction of times observed by time.Now can return incorrect results if the system wall clock is reset between the two observations. We propose to extend the time.Time representation to hold an additional monotonic clock reading for use in those calculations. Among other benefits, this should make it impossible for a basic elapsed time measurement using time.Now and time.Since to report a negative duration or other result not grounded in reality.
golang  time 
24 days ago
proposal/18130-type-alias.md at master · golang/proposal
Implemented in Go 1.9.
We propose to add to the Go language a type alias declaration, which introduces an alternate name for an existing type. The primary motivation is to enable gradual code repair during large-scale refactorings, in particular moving a type from one package to another in such a way that code referring to the old name interoperates with code referring to the new name. Type aliases may also be useful for allowing large packages to be split into multiple implementation packages with a single top-level exported API, and for experimenting with extended versions of existing packages.
golang  typealias 
24 days ago
koalaman/shellcheck: ShellCheck, a static analysis tool for shell scripts
The goals of ShellCheck are

• To point out and clarify typical beginner's syntax issues that cause a shell to give cryptic error messages.
• To point out and clarify typical intermediate level semantic problems that cause a shell to behave strangely and counter-intuitively.
• To point out subtle caveats, corner cases and pitfalls that may cause an advanced user's otherwise working script to fail under future circumstances.
bash  scripting  shell  lint  tool  sh  is:repo 
24 days ago
What Are Python Generators? – dbader.org
Whereas a return statement disposes of a function’s local state, a yield statement suspends the function and retains its local state.

• Generator functions are syntactic sugar for writing objects that support the iterator protocol.
• Generators abstract away much of the boilerplate code needed when writing class-based iterators.
The yield statement allows you to temporarily suspend execution of a generator function and to pass back values from it.
• Generators start raising StopIteration exceptions after control flow leaves the generator function by any means other than a yield statement.
python  generators  coroutines 
25 days ago
nmdias/DefaultsKit: Simple, Strongly Typed UserDefaults for iOS, macOS and tvOS
DefaultsKit leverages Swift 4's powerful Codable capabilities to provide a Simple and Strongly Typed wrapper on top of UserDefaults. It uses less than 70 lines of code to acomplish this.
NSUserDefaults  UserDefaults  lang:swift  Codable  is:repo 
25 days ago
Concrete proposal for async semantics in Swift
This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.
swiftlang  async  async_await  concurrency  is:gist 
5 weeks ago
Named Constants
Hard-coded numbers that appear out of nowhere in code mean nothing to anybody but the initial programmer. Reading them is almost as fun as reading disassembled output. These so-called "magic numbers" that appear in code are unnecessary in most modern languages.

When these numbers have complicated origins (like the transcendental number e) or are subject to random changes (like the size of a buffer), it is a much better idea to a) give them a name, b) put their definitions in a central area (relative to their context, like the top of a file or class definition). This way, you can lend meaning to the code and improve flexibility.
naming  bestpractices  programming  constants 
5 weeks ago
Using A Custom Font With Dynamic Type
Using a custom font with dynamic type has always been possible but it took some effort to get it to scale for each text style as the user changed the dynamic type size. Apple introduced a new font metrics class in iOS 11 that makes it much less painful.
ios  UIKit  UIFontMetrics  dynamic_type 
5 weeks ago
Peter Bourgon · Logging v. instrumentation
In my opinion, my thesis from GopherCon 2014 still holds: services should only log actionable information. That includes serious, panic-level errors that need to be consumed by humans, or structured data that needs to be consumed by machines. An example of the former would be a message signaling that a required database has become completely unavailable. An example of the latter would be a message indicating a media object has been played, recorded so an end-of-day batch process might calculate owed royalties. Logs read by humans should be sparse, ideally silent if nothing is going wrong. Logs read by machines should be well-defined, ideally with a versioned schema.

Instrumentation is for all remaining diagnostic information about your service. In contrast to logging, services should instrument every meaningful number available for capture. Metrics are (or should be) cheap to record and report, and instrumentation systems are more useful the more data they contain, which is a virtuous cycle: the more you have, the better-off you are.
logging  bestpractices  instrumentation  monitoring 
5 weeks ago
thockin/go-build-template: A Makefile/Dockerfile example for Go projects.
This is a skeleton project for a Go application, which captures the best build techniques I have learned to date. It uses a Makefile to drive the build (the universal API to software projects) and a Dockerfile to build a docker image.
structure  golang  docker  is:repo 
5 weeks ago
The Twelve-Factor App
I. Codebase
One codebase tracked in revision control, many deploys

II. Dependencies
Explicitly declare and isolate dependencies

III. Config
Store config in the environment

IV. Backing services
Treat backing services as attached resources

V. Build, release, run
Strictly separate build and run stages

VI. Processes
Execute the app as one or more stateless processes

VII. Port binding
Export services via port binding

VIII. Concurrency
Scale out via the process model

IX. Disposability
Maximize robustness with fast startup and graceful shutdown

X. Dev/prod parity
Keep development, staging, and production as similar as possible

XI. Logs
Treat logs as event streams

XII. Admin processes
Run admin/management tasks as one-off processes
12factor  software_architecture  bestpractices  logging  deployment 
5 weeks ago
Peter Bourgon · Go best practices, six years in
The Top Tips:

1. Put $GOPATH/bin in your $PATH, so installed binaries are easily accessible.
2. Put library code under a pkg/ subdirectory. Put binaries under a cmd/ subdirectory.
3. Always use fully-qualified import paths. Never use relative imports.  
4. Defer to Andrew Gerrand’s naming conventions.  
5. Only func main has the right to decide which flags are available to the user.  
6. Use struct literal initialization to avoid invalid intermediate state.  
7. Avoid nil checks via default no-op implementations.  
8. Make the zero value useful, especially in config objects.  
9. Make dependencies explicit!  
10. Loggers are dependencies, just like references to other components, database handles, commandline flags, etc.  
11. Use many small interfaces to model dependencies.  
12. Tests only need to test the thing being tested.  
13. Use a top tool to vendor dependencies for your binary.  
14. Libraries should never vendor their dependencies.  
15. Prefer go install to go build.  

Go has always been a conservative language, and its maturity has brought relatively few surprises and effectively no major changes. Consequently, and predictably, the community also hasn’t dramatically shifted its stances on what’s considered best practice. Instead, we’ve seen a reification of tropes and proverbs that were reasonably well-known in the early years, and a gradual movement “up the stack” as design patterns, libraries, and program structures are explored and transformed into idiomatic Go.
golang  bestpractices  dependencies  dependency-injection  nil  logging  testing  dependency_management 
5 weeks ago
Peter Bourgon · A theory of modern Go
tl;dr: magic is bad; global state is magic → no package level vars; no func init
golang  bestpractices  state  globals  interfaces  dependency-injection 
5 weeks ago
« earlier      
373proj a2council accessibility algorithms america android animation annarbor api apple applewatch appstore arc art associated_types async autolayout aviation bash bestpractices business c c++ charting ci clang cli clips clojure cocoa cocoa_touch cocoapods coffee color complexity concurrency coreanimation coredata corefoundation couchdb cryptography cs css culture cycling d3 data debugging dependency-injection design designpatterns detroit development diy dmx512 documentation elecdiy election2016 electronics embedded encryption engineering enum error_handling extensions facebook filetype:pdf finance flying foia font friends functionalprogramming game gcd generics gif git github golang graphics health html html5 http humor icons inspiration internet interop ios ios10 ios7 ios8 ios9 is:gist is:repo is:tweet is:video java javascript journalism jquery json keyboard keychain kvo lang:swift layout life lighting linux management markdown matlab media:document memorymanagement michigan mocking music mvvm networking newspapers nginx notifications nsa nsurlsession nyc nytimes nytnow objective-c oop option_type osx parser performance photog photography php politics privacy productivity programming protocol_extensions protocols python quote radio reactivecocoa reactiveprogramming reactjs reactnative refactoring reference resources rest ruby rust_lang rx rxjava safety scala search security shop simplicity society software software_architecture solid srp ssl startups stm8 strings swiftlang sysadmin tdd testing tls tool tools travel turbojet tutorial twitter type_members types ui uicollectionview uiimage uikit uitableview uiviewcontroller umich unicode unix ux via:andrewsardone via:androidweekly via:cdzombak via:iosdevweekly via:mattb visualization watchkit water weather web_dev windows wordpress work xcode xctest

Copy this bookmark:



description:


tags: