Graph theory (network) library for visualisation and analysis
26 days ago
Swift Development with Visual Studio Code
Visual Studio Code (VSCode) is a cross-platform text and source code editor from Microsoft. It’s one of the most exciting open source projects today, with regular updates from hundreds of contributors. VSCode was among the first tools to support Language Server Protocol (LSP), which has played a large part in providing a great developer experience, in a variety of languages and technologies. With the previously announced support for LSP for Swift now available in early development, it’s a great time to see how this integration works for yourself. So this week, we’ll walk through the process of how to get started with Swift’s new Language Server Protocol support in Visual Studio Code on macOS. If you haven’t tried writing Swift outside Xcode, or are already a VSCode user and new to the language entirely, this article will tell you everything you need to know. Swift support for Language Server Protocol is still in early development and doesn’t currently offer pre-built packages for the language server (sourcekit-lsp ) or the Visual Studio Code extension. For now, downloading, building, and installing these components and their dependencies is a manual process that requires some familiarity with the command line (it should take about 15 minutes on a reasonably fast internet connection). When LSP support is made generally available, it will be much easier to get everything set up. Step 0: Install Xcode If you don’t already have Xcode installed on your machine, open the Terminal app and run the following command: $ xcode-select --install Running this command presents a system prompt. Click the “Get Xcode” button and continue installation on the App Store. Step 1: Install Visual Studio Code Download Visual Studio Code and install it to your system Applications folder. Open the app and follow the instructions for launching from the command line. You’ll need to have the code command accessible from $PATH in order to install the SourceKit-LSP extension later on. Electron apps have a reputation for being big and slow, but don’t let that stop you from giving VSCode a try — it’s performance and memory footprint are comparable to a native app. Step 2: Install the Latest Swift Toolchain Go to and download the latest trunk development snapshot (at the time of writing, this was from November 16th, 2018). Once it’s finished downloading, run the package to install the Xcode toolchain. To enable it, open Xcode, select the “Xcode > Pre
8 weeks ago
Functional architecture: a definition
How do you know whether your software architecture follows good functional programming practices? Here's a way to tell. Over the years, I've written articles on functional architecture, including Functional architecture is Ports and Adapters, given conference talks, and even produced a Pluralsight course on the topic. How should we define functional architecture, though? People sometimes ask me about their F# code: How do I know that my F# code is functional? Please permit me a little detour before I answer that question. What's the definition of object-oriented design? # Object-oriented design (OOD) has been around for decades; at least since the nineteen-sixties. Sometimes people get into discussions about whether or not a particular design is good object-oriented design. I know, since I've found myself in such discussions more than once. These discussions usually die out without resolution, because it seems that no-one can provide a sufficiently rigorous definition of OOD that enables people to determine an outcome. One thing's certain, though, so I'd like to posit this corollary to Godwin's law: As a discussion about OOD grows longer, the probability of a comparison involving Alan Kay approaches 1. Not that I, in any way, wish to suggest any logical relationship between Alan Kay and Hitler, but in a discussion about OOD, sooner or later someone states: "That's not what Alan Kay had in mind!" That may be true, even. My problem with that assertion is that I've never been able to figure out exactly what Alan Kay had in mind. It's something that involves message-passing and Smalltalk, and conceivably, the best modern example of this style of programming might be Erlang (often, ironically, touted as a functional programming language). This doesn't seem to be a good basis for determining whether or not something is object-oriented. In any case, despite what Alan Kay had in mind, that wasn't the object-oriented programming we got. While Eiffel is in many ways a strange programming language, the philosophy of OOD presented in Object-Oriented Software Construction feels, to me, like something from which Java could develop. I'm not aware of the detailed history of Java, but the spirit of the language seems more compatible with Bertrand Meyer's vision than with Alan Kay's. Subsequently, C# would hardly look the way it does had it not been for Java. The OOD we got wasn't the OOD originally envisioned. To make matters worse
8 weeks ago
Streaming Multipart Requests
Foundation’s URL loading is robust. iOS 7 brought the new URLSession architecture, making it even more robust. However, one thing that it’s never been able to do natively is multipart file uploads. What is a multipart request? Multipart encoding is the de facto way of sending large files over the internet. When you select a file as part of a form in a browser, that file is uploaded via a multipart request. A multipart request mostly looks like a normal request, but it specifies a unqiue encoding for the HTTP request’s body. Unlike JSON encoding ({ "key": "value" } ) or URL string encoding (key=value ), multipart encoding does something a little bit different. Because of the body of a request is just a long stream of bytes, the entity parsing the data on the other side needs to be able to determine when one part ends and another begins. Multipart requests solve this problem using a concept of “boundaries”. In the Content-Type header of the request, you define a boundary: Accept: application/json Content-Type: multipart/form-data; boundary=khanlou.comNczcJGcxe The exact content of the boundary is not important, it just needs to be a series of bytes that is not present in the rest of the body (so that it can meaningfully act as a boundary). You can use a UUID if you like. Each part can be data (say, an image) or metadata (usually text, associated with a name, to form a key-value pair). If it’s an image, it looks something like this: -- Content-Disposition: form-data; name=; filename= Content-Type: image/jpeg And if it’s simple text: -- Content-Disposition: form-data; name= Content-Type: text/plain After the last part in the rqeuest, there’s one more boundary, which includes an extra two hyphens, ---- . (Also, note that the new lines all have to be CRLF.) That’s pretty much it. It’s not a particularly complicated spec. In fact, when I was writing my first client-side implementation of multipart encoding, I was a bit scared to read the RFC for multipart/form-data. Once I took a look at it, however, I understood the protocol a lot better. It’s surprisingly readable, and nice to go straight to the source for stuff like this. That first implementation was in the Backchannel SDK, which is still open source. You can see the BAKUploadAttachmentRequest and the BAKMultipartRequestBuilder , which combine to perform the bulk of the multipart handling code. This particular implementation only handles a single file and no metadata, but it serves a
9 weeks ago
« earlier      
3d 3dprinting adhesive aesthetics ai algebra algorithm amplifier analytics anodizing ansible appcode appkit apple architecture archive arduino artist audio authentication autocomplete aws backbone.js backpacking backup bag bike blockchain bluetooth book bootstrap buck bundler cad calendar camera canada canvas capacitive capitalism career categorytheory checkers cheese chef china circleci circuits cli climatechange clojure clojurescript clothing cms cocoa coffee coffeescript concurrency containers coq coredata coreimage coretext cpu crdt cs css cucumber currentevents d3 database datamapper datasheet datastructures debugging design dialog distributed diy docker documentary documentation dreamhost dyld eagle ebooks education elixir email ember energy erlang facebook fashion flow focus fodmap fonts food formal-methods forms free french frp functional furniture gallery game gameboy geolocation geometry git github golang google graphics growth-mindset guide habits hackintosh hamburger hardware haskell health heroku history home howto html html5 i2c icons ide ideas ie ifttt images infosec interface interiordesign interview ios iot ipad iphone javascript journal jquery js json keyboard kinect lambda language languages layout learning less liberalism libraries library lightbox lighting lightroom linux lisa lisp list lldb logging mac macosx manual manufacturing map math mechanism meditation microcontroller ml mobile modal modular mongodb monoid multitouch music music-theory mvc nas network networking newton nlp node node.js numpy objective-c ocr oil opengl opensource opentype opera opinion optimization osx painting papers patterns paypal pcb pdf performance pgp philosophy photography photoshop php physics pi pictograms plastic playgrounds plugin politics polygons postmodernism pottery print processing productivity programming proofs prototype ps2 psychology ptrace purescript pwm python qmatrix quantum race rails rake reading recipe reference regex relationships repl resistive resources resp responsive retina reversing roberto-bolano rome rspec rsync ruby russia rust sass science scipy screencast scripting scroll sec security semigroup sensor sessions sewing shelving shoebox sinatra skim slider slideshow smalltalk snowflake socialism solar soundproofing sourcery speaker speaking spi ssh standards starred statechart statemachine stoicism storage store stripboard stub svg swift swimming syncing synthesis sysadmin table talk tau tcp tech testing text textmate texture threads timelapse timemachine tmux tools tor toread travel tumblr tutorial twitter typography ubuntu ui unix unread vanagon vegan via:adhd360 via:alexbaldwin via:beergeek via:brandonsek via:edogal via:emha via:geekgirl397 via:lukecanvin via:mandrl via:masterjo via:michfern via:mintchaos via:modelcitizen via:orchard via:popular via:samwithans via:sic1 via:sunpig via:votive via:zlmc video vim virtualization visualization visuals warden webapp webdev weldon wireframe woodworking work workflow writing xcode xib

Copy this bookmark: