2016 week 44 in programming

H.264 is Magic

Now we’re getting to the juicy bits! Ha puns! If you took an information theory class, you might remember information entropy. Information entropy is the number of bits required to represent some information. The fine grill on that MacBook pro has a high information content in the higher frequency components of that image. Because now, you can take that frequency domain image and then mask out the edges - discard information which will contain the information with high frequency components. The numbers represent the information entropy of that image as a fraction of the original. So there must be some way to discard color information to shed even more weight. Our frames now tiny - since we discarded most of the detail information and half of the color information.

Pornhub Bypasses Ad Blockers With WebSockets

If WebSocket data was not visible to Chrome extensions via the webRequest API, they could not be blocked without some heavy duty hacks. Then in August 2016, an employee of the company that owns Pornhub.com started arguing against adding the WebSocket blocking capabilities to the Chrome API. Pornhub is the 63rd most visited site on the Internet according to Alexa. Watching the BugReplay browser recording, you can see a number of network requests triggered that are blocked by AdBlock: They are marked Failed in the network traffic, and if you click one to inspect the detail pane you can see the failed reason is net::ERR BLOCKED BY CLIENT. That is the error reported by Chrome when an asset is blocked from loading. The name of the domain where the WebSocket connects is “Ws://ws.adspayformy.site.” A decent joke aimed at ad blockers :). When the WebSocket loads, the browser sends a frame with a JSON encoded payload for each of the spots it has available for ads. Ad Blockers primarily work using the webRequest API, so constructing the ad by transmitting the data over the WebSocket as base64 is a pretty clever way of dodging the blocker. A contributor wrote a patch adding the ability to block WebSockets using the webRequest api. For AdBlock Plus, “The wrapper performs a dummy web request before WebSocket messages are sent/received. The extension recognizes these dummy web requests as representing a WebSocket message. It intercepts and blocks them if the corresponding WebSocket message should be blocked. The WebSocket wrapper then allows / blocks the WebSocket message based on whether the dummy web request was blocked or not.” via.

Why I became a software engineer

I hear of stories of many software engineers who always knew they were going to work with computers because they started tinkering with them when they were kids. All these are very common for software engineers in the US & Europe but for many of us in Africa? We didn’t see a computer until we were halfway through high school. That’s how I started learning how to code seriously. Now how do I make students register online for their courses? I can’t build another windows application and expect them to download it. That’s what led to learning about web development using ASP.net. I didn’t become a software engineer because I enjoyed coding or grew up around computers or any of that. I became a software engineer because the problems I cared about solving required me to learn how to code.

UTF8. Everywhere. Now, please.

The above code point will be encoded as four code units ‘f0 b2 90 bf’ in UTF-8, two code units ‘d889 dc3f’ in UTF-16 and as a single code unit ‘0003243f’ in UTF-32. For some abstract characters, there exist representations using multiple code points, in addition to the single coded character form. The abstract character can be coded by the single code point U+01F5 latin small letter g with acute, or by the sequence <U+0067 latin small letter g, U+0301 combining acute accent>. A programmer might count characters as code units, code points, or grapheme clusters, according to the level of the programmer’s Unicode expertise. Working with a variable length encoding, where ASCII-inherited code points are shorter than other code points may seem like a difficult task, because encoded character boundaries within the string are not immediately known. Even in the Unicode formalism some code points correspond to coded character and some to non-characters. Counting coded characters or code points is important.

Touch ID support for sudo in MacOS Terminal

Sudo-touchid is a fork of sudo with Touch ID support on macOS. Once compiled, it will allow you to authenticate sudo commands with Touch ID in the Terminal on supported Macs. Sudo must be owned by uid 0 and have the setuid bit set. Sudo chown root:wheel sudo && sudo chmod 4755 sudo. Sudo -s. If you don’t have a Mac with a biometric sensor, sudo-touchid will fall back to the regular password prompt. Replacing the system’s sudo program is quite risky and requires disabling System Integrity Protection. Sudo chown root:wheel /usr/local/bin/sudo && sudo chmod 4755 /usr/local/bin/sudo. Now you should be able to enter sudo in any Terminal window and authenticate with Touch ID!.

async/await support landed in Firefox Nightly

Support for async/await has been added in the Nightly build from the 31st of October. Time to start removing those JavaScript transpilers from your experimental projects, and testing native browser support 😉. Here’s a demo. If your browser supports async/await natively, you will see “YES”.

Visual Sudio Code 1.7 rolled back to 1.6

Would you like your source code formatted each time you save? VS Code now supports “Format On Save” which will automatically pick up relevant installed formatter extensions and format the whole document on each save. Since we made VS Code available, we’ve had the debt item that some languages were implemented inside VS Code directly and they were not implemented as an extension. As you can see from the recommendations setting above, we recommend that anybody working on the VS Code codebase use the TSLint and ESLint extensions. VS Code prompts a user to install the recommended extensions when a workspace is opened for the first time. Another use case is to create a set of extensions for a particular scenario like PHP development to help a PHP developer get started with VS Code quickly. The Yeoman generator for VS Code extensions has been updated to use TypeScript version 2.0.x. If you start a new VS Code extension, simply install yeoman and the extension generator using npm install -g yo generator-code and run it using yo code. An extension would be able to configure a linter from a warning via a code action.

A Random Walk Through Ada (2014) – “I find myself wondering why I should write in C++ any more”

Package AnimalsPkg is type Animal is tagged null record; procedure Vocalise(creature: Animal); type Dog is new Animal with null record; procedure Vocalise(creature: Dog); end; package body AnimalsPkg is procedure Vocalise(creature: Animal) is begin Put Line(” “); end; procedure Vocalise(creature: Dog) is begin Put Line(“Woof”); end; end;. Declare package AnimalsPkg is type Animal is abstract tagged null record; procedure Vocalise(creature: Animal) is abstract; type Dog is new Animal with null record; procedure Vocalise(creature: Dog); type Cat is new Animal with null record; procedure Vocalise(creature: Cat); end; package body AnimalsPkg is procedure Vocalise(creature: Dog) is begin Put Line(“Woof”); end; procedure Vocalise(creature: Cat) is begin Put Line(“Meow”); end; end; use AnimalsPkg; procedure Kick(creature: Animal’Class) is begin creature. Package DeadlySeriousBusinessPackage is type Object is tagged private; type ObjectRef is access Object’class; function Create return ObjectRef; private type Object is tagged null record; end; package body DeadlySeriousBusinessPackage is function Create return ObjectRef is this: ObjectRef := new Object; begin return this; end; end;. Declare task Fifo is entry Push(value: in integer); entry Pop(value: out integer); end; task body Fifo is i: integer; begin loop accept Push(value: in integer) do i := value; end; accept Pop(value: out integer) do value := i; end; end loop; end; i: integer; begin Fifo.Push(7); Fifo.Pop(i); end;. Declare task Fifo is entry Push(value: in integer); entry Pop(value: out integer); end; task body Fifo is i: integer; begin loop select accept Push(value: in integer) do i := value; end; or accept Pop(value: out integer) do value := i; end; or terminate; end select; end loop; end; i: integer; begin Fifo.Push(7); Fifo.Pop(i); end;. Declare protected Fifo is procedure Push(value: in integer); procedure Pop(value: out integer); private i: integer; end; protected body Fifo is procedure Push(value: in integer) is begin i := value; end; procedure Pop(value: out integer) is begin value := i; end; end; i: integer; begin Fifo.Push(7); Fifo.Pop(i); end;. Declare type Thing is record value: integer; end record; type ThingRef is access Thing; function NewThing return ThingRef is begin return new Thing; end; procedure FreeThing is new Ada.Unchecked Deallocation( Thing, ThingRef); p: ThingRef; begin p := NewThing; FreeThing(p); end;.

WebAssembly Browser Preview

Today we’re happy to announce, in tandem with Firefox and Edge, a WebAssembly Browser Preview. WebAssembly or wasm is a new runtime and compilation target for the web, designed by collaborators from Google, Mozilla, Microsoft, Apple, and the W3C WebAssembly Community Group. The binary format and JS API documents outline the binary encoding of WebAssembly and the mechanism to instantiate WebAssembly modules in the browser, respectively. V8 continues to optimize the implementation of WebAssembly in the TurboFan compiler. Js to WebAssembly under the hood so that existing asm. Js sites can reap some of the benefits of WebAssembly ahead-of-time compilation. Barring major design changes arising from community feedback, the WebAssembly Community Group plans to produce an official specification in Q1 2017, at which point browsers will be encouraged to ship WebAssembly on-by-default.

How to contribute to an open source project on GitHub - a step-by-step guide

A step by step guide that will show you how to contribute to an open source project on GitHub, one of the most popular and used git repository hosting services. The way people contribute to an open source project on GitHub is using pull requests. If you decided to contribute to an open source project on GitHub it’s probably because you’ve been using that project and you found a bug or had an idea for a new feature. When deciding to contribute to an open source project make sure to check it’s still active otherwise your work might remain a pull request forever. Once you are on the main page of the project you want to contribute to look for notes and files that explain how the mantainers expect you contribute to the project. To fork a project on GitHub simply click the Fork button on the top-right corner of a project page. I hope you enjoyed this tutorial explaining how to contribute to an open source project on GitHub.

DeepMind and Blizzard to release StarCraft II as an AI research environment | DeepMind

None

Minoca OS: A new open source operating system

Today we’re thrilled to announce that Minoca OS has gone open source. We are releasing the entirety of the Minoca OS source code under the GNU GPLv3. We’re excited to build a community of users and developers around this new operating system, and we need help. What is Minoca OS?Minoca OS is a general purpose operating system written completely from the ground up. Under the hood, Minoca contains a powerful driver model between device drivers and the kernel. We took a look at the operating systems out there, and realized it had been over 25 years since the major operating systems had been written. We wanted to see if with 25 years of hindsight and a clean slate we could create something interesting and unique in the operating systems space.

Vigil, the eternal morally vigilant programming language

Vigil is a very safe programming language, and an entry in the January 2013 PLT Games competition. Many programming languages claim to take testing, contracts and safety seriously, but only Vigil is truly vigilant about not allowing code that fails to pass programmatic specifications. Vigil is very similar to Python with the minor proviso that you must provide a main() function which will be automatically called for you. If a function fails to uphold what it has sworn to do, it is wrong and must be punished. When a Vigil program is executed, Vigil itself will monitor all oaths that have been made. If an oath is broken, the offending function will be duly punished. Run Vigil again and it will take care of that for you.

Learn LATEX in Minutes

LaTeX, which is pronounced «Lah-tech» or «Lay-tech», is a document preparation system for high-quality typesetting. LaTeX is just a text document, readily converted to PDF. LaTeX separates content and style. LaTeX offers a lot of functions by default, but in some situations it can come in handy to use so called packages. To add an image to the LaTeX file , you need to use figure environment and the graphicx package. Insert code into LaTeX First method ✅. One aspect of text compiling that is of the utmost importance to programmers and developers is how to professionally insert codes into the document. LaTeX supports syntax for these languages 💬. As you can see, with the wrapper you can easily insert code without worrying about how the syntax is formatted. Multiple files in LaTeX. When we use LaTeX, we may face a problem that a document is too long to be handle.

Distrusting WoSign and StartCom Certificates

None

OPA, A live memory debugger for C programs

None

How VS Code 1.7 overloaded npmjs.org

We didn’t start caching 404s for every package, and don’t plan to, because that creates annoying race conditions for fresh publishes, which is why most CDNs don’t cache 404s in the first place. There are any number of ways to fix this, and we’ll work with Microsoft to find the best one, but fundamentally you just need a more network-efficient way of finding out which type declarations exist. Might I suggest having a bloom filter containing all the existing type declaration and only querying the registry if the bloom filter reports the type declaration as a positive. Since the filter can be really small it will probably scale a lot better than a complete list of all type-declarations, and a new filter could be downloaded by the clients every now and then. Depends on the bloom filter, but for the fixed size, fixed hash functions, and other implementations in the same general vein, it would just be XOR of both of the bloom filters. Slightly different for counting filters, where something along the lines of subtraction would get you what you need. Can you speak to why it is so expensive on the NPM side to serve a 404? Would a bloom filter like another commenter mentioned be helpful?

The Price Of GPL

Some will take issue with the use of strong words like “Stolen code,” and “Theft,” with respect to a GPL violation. Many developers seem to prefer remaining willfully oblivious to the consequences of using GPL code. “It’s OK for us to use GPL code anywhere, as long as we contribute back changes.“It’s only a small amount of GPL code, so the license doesn’t apply. The price of GPL is fairly obvious and easy to understand, even if there is some bickering about what constitutes “linked code. " You don’t have to be a legal expert to get the gist of it: if you want to link your software with GPL code, you must also make your software’s source code available. So what am I supposed to do? Not use any GPL source code at all in any of my proprietary products? Exactly. Because the price of GPL is too much for me, and I don’t steal source code.

Happy Dennis Ritchie Day!

That’s just C. Dennis was also half of the team that created Unix, which in some form or other runs all the machines at Google’s data centers and probably at most other server farms. Most web servers run above Unix kernels; most non-Microsoft web browsers run above Unix kernels in some form, even in many phones. In the late 1970s, Dennis joined with Steve Johnson to port Unix to the Interdata. Unix, in the unusual position of being written in a “High-level language,” could be made to run on a machine other than the PDP-11. The hardware didn’t matter any more, since it all ran Unix. Cheap hardware meant cheap Unix installations; we all won. If Unix hadn’t been ported to the Interdata, the Internet, if it even existed, would be a very different place today.

from stackoverflow import quick_sort

Do you ever feel like all you’re doing is copy/pasting from Stack Overflow? From stackoverflow import quick sort will go through the search results of [python] quick sort looking for the largest code block that doesn’t. Syntax error in the highest voted answer from the highest voted question. Code, it checks the next highest voted answer for code blocks. »> from stackoverflow import quick sort, split into chunks »> print(quick sort. Chunk(“Very good chunk func” ) »> print(“Gotta take a break”) gotta take a break »> from time import time »> t1 = time() »> from stackoverflow import time delay »> print(“That’s enough, let’s continue coding”, time() - t1) that’s enough, let’s continue coding 5.7283220291137695 »> print(“I wonder who made split into chunks”, split into chunks. This module is PSF-licensed as I blatantly copied multiple lines of code from the Python standard library.

H.265 is Weaponized Science

Each CU can be recursively splitted in Transform Units with the same quad-tree approach used in CTBs. Differently from AVC that used mainly a 4×4 transform and occasionally an 8×8 transform, HEVC has several transform sizes: 32×32, 16×16, 8×8 and 4×4. The adaptive nature of CBT, CU and TU partitions plus the higher accuracy plus the larger transform size are among the most important features of HEVC and the reason of the performance improvement compared to AVC. HEVC implements a sofisticated scan order and coefficient signaling scheme that improves signaling efficiency. HEVC drops also the support for MBAFF or similar techniques to code interlaced video. The merge mode is similar, the main difference is that the candidates list is calculated from neighboring MV and is not added to a delta MV. It is the equivalent of “Skip” mode in AVC. Similarly to AVC, HEVC specifies motion vectors in 1/4-pel, but uses an 8-tap filter for luma and a 4-tap 1/8-pel filter for chroma. CABAC in HEVC is almost identical to CABAC in AVC with minor changes and simplifications to allow a parallel decoding. Since HEVC decoding is much more complex than AVC, several technique to allow a parallal decoding have been implemented. The adaptive subdivision of picture in prediction areas, the use of advanced intra-prediction, inter-prediction and bigger transform sizes can absolutely guarantee, in the long term, a considerably higher efficiency of HEVC compared to AVC. But the complexity of the encoding is really much higher.

The Silent Majority of Experts

Forth, I wasn’t the only person frustrated by the lack of people doing interesting things with the language. Elizabeth Rather, co-founder of Forth, Inc., offered the following explanation: there are people solving real problems with Forth, but they don’t hang-out in the newsgroup. There were a number of game developers with public faces in the 1990s, but the key people responsible for the original version of The Need for Speed, released in 1994, remained unknown and behind the scenes. Yes, there are many people who blog and otherwise publicly discuss development methodologies and what they’re working on, but there are even more people who don’t. Other people are working on commercial products and can’t divulge the inner workings of their code. All we’re seeing is an intersection of the people working on interesting things and who like to write about it-and that’s not the whole story. Your time may better spent getting in there and trying things rather than reading about what other people think.

Scala 2.12.0 is now available

Scala 2.12.0 is the result of merging over 500 pull requests out of about 600 received PRs. The contributions to 2.12.x over the last 2 years were split as 64/32/4 between the Scala team at Lightbend, the community and EPFL. The new encodings of traits, lambdas and lazy vals were developed in fruitful collaboration with the Dotty team at EPFL. Binary compatibility. Since Scala 2.10, minor releases of Scala are binary compatible with each other. Scala 2.12 standardizes on the “GenBCode” back end, which emits code more quickly because it directly generates bytecode from Scala compiler trees, while the previous back end used an intermediate representation called “ICode”. The Scala distribution is built using -opt:l:classpath, which improves the performance of the Scala compiler by roughly 5% compared to a non-optimized build. The Java 8 compatibility module for Scala has received an overhaul for Scala 2.12. Even though interoperability of Java 8 SAMs and Scala functions is now baked into the language, this module provides additional convenience for working with Java 8 SAMs. Java 8 streams support was also added during the development cycle of Scala 2.12. Releases are available for both Scala 2.11 and Scala 2.12.

Why hardware development is hard, part 1: Verilog is terrible

Why hardware development is hard, part 1: Verilog is weird Why hardware development is hard, part 1: Verilog is weird. How is it possible that a reasonable description of something in Verilog turns into something completely wrong in hardware? You can think of hardware as some state, with pure functions connecting the state elements. To write Verilog that will produce correct hardware, you have to first picture the hardware you want to produce. We hardware folks are so used to the vast majority of legal Verilog constructs producing unsynthesizable garbage that we don’t find it the least bit surprising that you not only do you not get compile-time errors, you don’t even get run-time errors, from writing naive Verilog code. With hardware, we train up a new generation of people who think that Verilog is as productive as any language could be every few years! I won’t even get into how Verilog is so inexpressive that many companies use an ad hoc tool to embed a scripting language in Verilog or generate Verilog from a scripting language. It’s not as high level, but it’s the only hardware description language with a modern type system that I’ve been able to discuss with hardware folks without people objecting that Haskell is a bad idea.

Mercurial 4.0 has been released

Rollback: add a config knob for entirely disabling the command subrepo: use unset instead of env -u to fix test on BSDs.templates: add support for filelog webcommand in json style templates: add support for filerevision webcommand in json style templates: add support for search webcommand in json style templates: add support for summary webcommand in json style update: fix bare -clean to work on new branch. Notify: do not load style file if template is specified record: deprecate the extension registrar: add templatefilter to mark a function as template filter registrar: add templatefunc to mark a function as template function registrar: add templatekeyword to mark a function as template keyword registrar: remove useless base classes remove: add progress support remove: fix -force option help description. Batchget: add support for backing up files builddeb: add -distid option to specify Distributor ID changegroup: introduce cg3, which has support for exchanging treemanifests changelog: add a new method to get files modified by a changeset checkunknownfiles: make control flow clearer crecord: edit during hg crecord should preserve cursor position. Match: add option to return line and lineno from readpattern mercurial: pass ui to extensions. Files() in conditions commit: improve -close-branch documentation commit: mark internal-only option commit: no longer allow empty commit with the ‘force’ argument config: give it an includepaths option for looking for config files files: recurse into subrepos automatically with an explicit path import-checker: add xargs like mode import-checker: don’t treat modules as relative one if not found import-checker: exclude mercurial packages installed into the system path import-checker: loop to get list of locally defined modules at first import: cross-reference patch. Allowemptycommit to allow empty commits log: add a status template patch: add ‘extra’ argument to makememctx patch: add fuzz config flag. Subrepo: add ‘cat’ support for git subrepos subrepo: add basic support to hgsubrepo for the files command subrepo: add include/exclude support for diffing git subrepos subrepo: add status support for ignored and clean files in git subrepos subrepo: change arguments of abstractsubrepo.

comments powered by Disqus