Quantcast
Channel: Hacker News
Viewing all 25817 articles
Browse latest View live

Show HN: Bitcoin investing using Dollar Cost Averaging strategy

$
0
0

README.md

This node script let you set a daily amount to invest on crypto currency (Bitcoin in this case) via the kraken crypto exchange.

Dollar Cost Averaging

Dollar-cost averaging (DCA) is an investment technique of buying a fixed dollar amount of a particular investment on a regular schedule, regardless of the share price. The investor purchases more shares when prices are low and fewer shares when prices are high.

Dollar Cost Averaging has being initially used in the stock market to pursue an investment on an higher number of stocks with the same amount spend, just by investing it in a longer period of time due to the volatility of the stocks.

In the case of crypto-currency is well known that the volatility of those assets is way higher than the traditional shares purchased in the stock market. This makes the Dollar Cost Averaging strategy well suited for this type of investments.

How you should chose investment amount and range

This highly depends on your risk level, in my case what I've done is setting up a total investment amount. Let's say I want to invest 1000$ and I want to spread my investment for 3 months. I also know I want to invest daily to take advantage of the volatility of the bitcoin against the dollar.

1000 / (3 * 30) = 1000 / 90 = ~11$ / day

I will then setup my .env file

KRAKEN_KEY=myKrakenKeyHere
KRAKEN_SECRET=myKrakenSecretKeyHere
INVESTMENT_AMOUNT=11.11

Pre-requisites

In order to make it work you will need

  • A bitcoin wallet obviously. I've used a desktop/paper wallet Electrum
  • A way to exchange EUR with Bitcoins and other crypto-currencies. This repo uses Kraken Exchange
  • node.js 8
  • npm

Getting started

Once you have registered your bitcoin wallet, you have your kraken account with enough funds and you've installed node js, you can start

Clone the project locally

git clone github.com/0x13a/bitcoin-trading-dca &&cd bitcoin-trading-dca

Install the dependencies

Run

This should be runned once a day, every day, after lunch or setup a cronjob that runs it for you every day


Lispyville: a lisp-editing environment suited towards evil users

$
0
0

README.org

Welcome to LispyVille!

lispyville.el’s main purpose is to provide a lisp-editing environment suited towards evil users. It can serve as a minimal layer on top of lispy-mode for better integration with evil, but it does not require use of lispy’s keybinding style. The provided commands allow for editing lisp in normal state and will work even without lispy-mode enabled.

Here are the main features of lispyville:

  • Provides “safe” versions of vim’s yank, delete, and change related operators that won’t unbalance parentheses
  • Provides lisp-related motions/commands
  • Integrates evil with lispy by providing commands to more easily switch between normal state and special and by providing options for integrating visual state with lispy’s special

Note that this package does not create any new evil states; it assumes that the user will be using lispy in insert or emacs state.

lispyville.el has a similar intent to evil-cleverparens and related packages. It creates “safe” versions of standard evil editing commands. For example, it ensures that dd will not unbalance parenthesis but instead only delete the “safe” portion of the line. This allows the evil’s line-oriented commands to become far more useful for lisps.

The primary difference between lispyville and other similar packages is that it uses lispy instead of smartparens or paredit. This matters because lispyville is primarily intended to be used in conjunction with lispy. Lispy already has a lot in common with evil. Unlike smartparens and paredit, lispy’s primary keybindings are just letters. It may help to think of lispy as just an additional evil state. The main difference is that you can automatically enter and exit it without having to use ESC.

However, if you’d rather stick to mainly vim keybindings, lispyville will also eventually provide “key themes” to replicate all of evil-cleveparens’ keybindings as well as the keybindings of some other popular evil/lisp editing packages. I also plan to add key themes that are more similar to lispy’s keybindings.

While lispyville can be used without lispy-mode, some additional setup may be required to make editing lisp comfortable. For example, ( would need to be explicitly bound to lispy-parens for auto-pairing behavior (and the other functionality provided by lispy-pair). If your gripe with lispy is its style of having “special” locations where letter keys act as commands, you can still use lispy-mode for the “normal” keybindings it provides by not using special in your lispy “key theme”:

(lispy-set-key-theme '(lispy c-digits))

You can always override these keybindings later.

Lispyville is a minor mode. To enable it wherever lispy is enabled, you can add the following to your configuration:

(add-hook 'lispy-mode-hook#'lispyville-mode)

The operators behave similarly to evil-cleverparens’ operators with a few exceptions. The delete operator will always act safely by ignoring unmatched delimiters, whereas cleverparens will sometimes splice. While cleverparens’ yank operators will attempt to add unmatched delimiters, lispyville’s yank operators will simply exclude the unmatched delimiters, which is consistent with how the delete operator works. The operators will also work in visual block mode, unlike with cleverparens. The user can also choose whether or not they want to act safely on delimiters in strings and comments (see Lispy Settings).

Y acts like a safe y$ unlike in evil and cleverparens. If anyone takes issue with this change, I can add a command for its regular functionality, but I think most people dislike the default inconsistency between Y and D in vim.

Additionally, I think that the function used for safe behavior is a lot more sanely implemented in lispyville than in other related packages (it intelligently analyzes a region once instead of repeatedly calling check-parens).

I’ve added this functionality directly to lispy, and if you want lispy’s copy, delete, and/or paste commands to keep parentheses balanced, you can set the relevant options for lispy (see Lispy Settings).

By default, the only keys that lispyville remaps are the operators and C-w. To allow for the user to choose between various sets of keybindings without making them manually remap every command, lispyville provides “key themes” similarly to how lispy does.

The user can still define commands in lispyville-mode using evil-define-key or something like general, but lispyville-set-key-theme can also be used to define keys. It takes one argument which is a list of symbols corresponding to the different themes. By default, most commands will be mapped in normal and visual state. The default states are listed below. To change them, a list of the symbol and the states to map the keys in can be used instead.

As an example, the following command will map the “operators” theme in the normal and visual states, the “escape” theme in just the insert state, and the “additional-movement” theme in the normal, visual, and motion states:

(with-eval-after-load 'lispyville
  (lispyville-set-key-theme
   '(operators
     c-w
     (escape insert)
     (additional-movement normal visual motion))))

lispyville-set-key-theme will not reset lispyville’s keymap, so it will not remove user-defined keybindings (unless they are overwritten by a key in one of the themes). The keybindings will be added in the order of the list, so if there is overlap between the listed themes, the one listed last will take precedence.

Operators Key Theme

The corresponding symbol is operators. The default states are normal and visual. These are safe versions of the corresponding evil operators that won’t unbalance parentheses. Like with cleverparens, dd will bring closing delimiters that are on a line by themselves to the previous line while cc won’t. To disable this behavior, lispyville-dd-stay-with-closing can be set to a non-nil value.

keycommand
ylispyville-yank
dlispyville-delete
clispyville-change
xlispyville-delete-char-or-splice
Ylispyville-yank-line
Dlispyville-delete-line
Clispyville-change-line
Xlispyville-delete-char-or-splice-backwards

C-w Key Theme

The corresponding symbol is c-w. The default states are emacs and insert. This is the safe version of evil-delete-backward-word. It will act as lispydelete-backwards after delimiters (and delete everything within the delimiters).

The reason no safe version of evil-delete-backward-char-and-join is provided is because lispy already maps DEL to lispy-delete-backwards, which is much more useful.

keycommand
C-wlispyville-delete-backwards-word

S Operators Key Theme

The corresponding symbol is s-operators. The default states are normal and visual. I’ve separated the s operators because I prefer to use cl and cc and bind the s keys to something else entirely.

keycommand
slispyville-substitute
Slispyville-change-whole-line

Additional Movement Key Theme

The corresponding symbol is additional-movement. The default state is motion (inherited in the normal, visual, and operator states). This key theme is the equivalent of cleverparen’s additional movement keys. [ and ] are like the reverse of lispy-flow. { and } are like lispy-flow. ( and ) are like lispy-left and lispy-right. Also see here for some extra information on automatically enter special after executing these motions.

keycommand
Hlispyville-backward-sexp
Llispyville-forward-sexp
M-hlispyville-beginning-of-defun
M-llispyville-end-of-defun
[lispyville-previous-opening
]lispyville-next-closing
{lispyville-next-opening
}lispyville-previous-closing
(lispyville-backward-up-list
)lispyville-up-list

lispyville-left is an alias for lispyville-backward-up-list, and lispyville-right is an alias for lispyville-up-list.

There is also the unbound lispyville-beginning-of-next-defun.

Slurp/Barf Key Themes

Two key themes are provided for slurping and barfing keybindings. The default state for both is normal. Note that the commands in both key themes work with digit arguments. A positive argument will barf or slurp that many times like in cleverparens. Additionally, for the slurp commands, an argument of -1 will slurp to the end of the line where the sexp after the closing paren ends, and an argument of 0 will slurp as far as possible. See the documentation for lispy-slurp for more information. Also see here for some extra information on automatically entering special after executing these commands.

Note that the commands for both key themes will act on the paren after the point, meaning that the point should be before a closing paren to be considered “on” it.

The slurp/barf-cp key theme provides commands that act the same as cleverparens’ slurp and barf keys or lispy’s lispy-slurp-or-barf-right and lispy-slurp-or-barf-left. > and < can be thought of arrows that will move the paren at point in the corresponding direction. If there is no paren at the point, the keys will take the action they would on a right paren but will not move the point.

keycommand
>lispyville->
<lispyville-<

The slurp/barf-lispy key theme provides commands that act the same as the default lispy-slurp and lispy-barf. In this case, > and < can be thought to correspond to “grow” and “shrink” respectively. > will always slurp, and < will always barf. If there is no paren at the point, the keys will take the action they would on a right paren but will not move the point.

keycommand
>lispyville-slurp
<lispyville-barf

For both < bindings, if lispyville-barf-stay-with-closing is non-nil and barfing would move the closing delimiter behind the point, the point will instead be put on the closing delimiter.

Additional Key Theme

The corresponding symbol is additional. The default states are normal and visual. This key theme is the equivalent of cleverparen’s “additional bindings” keys. It is currently incomplete. M-j is comparable to evil-cp-drag-forward and lispy-move-down. M-k is comparable to evil-cp-drag-backward and lispy-move-up.

keycommand
M-jlispyville-drag-forward
M-klispyville-drag-backward

lispyville-move-down is an alias for lispyville-drag-forward, and lispyville-move-up is an alias for lispyville-drag-backward.

Escape Key Theme

The corresponding symbol is escape. The default states are insert and emacs. See here for more information.

keycommand
ESClispyville-normal-state

Mark Key Themes

The corresponding symbols are mark and mark-special. The default states are normal and visual. While the commands from mark will enter visual state, the commands from mark-special will enter lispyville-preferred-lispy-state. See here for more information.

keycommand
vwrapped lispy-mark-symbol
Vwrapped lispy-mark
C-vwrapped lispy-mark

Mark Toggle Key Theme

The corresponding symbol is mark-toggle. The default states are insert and emacs. Note that v will be bound in visual state (not changeable).

keycommand
vlispyville-toggle-mark-type
ESClispyville-escape

The idea of this theme is to use the same key you used to get into visual state or special to toggle between them and to use ESC to get rid of the region. For example, after entering visual state, you can press v to enter lispy special or ESC to return to normal state and cancel the region. After marking something with lispy, you can press the key for lispy-mark-list (I use v, but it is m by default) to enter visual state or ESC to return to insert or emacs state and cancel the region.

Note that this requires also binding lispyville-toggle-mark-type in lispy after it loads:

(lispy-define-key lispy-mode-map "m"#'lispyville-toggle-mark-type);; or v for better consistency (I swap m and v)
(lispy-define-key lispy-mode-map "v"#'lispyville-toggle-mark-type)

By re-purposing v in visual state (which normally enters visual line mode) to enter lispy special and re-purposing m (or v) in lispy special with an active region to enter visual state (while moving m’s normal functionality to ESC), this functionality is achieved without requiring any complicated keybindings. Note that the toggle key will still act as lispy-mark-list in lispy special if you use a prefix arg (other than 1).

When using this theme with the mark theme, the mark theme should be specified first. If you would prefer that ESC always enters normal state (instead of returning you to lispy special with no region if you are in lispy special with a region), you can specify the escape theme after the mark-toggle theme.

More Fluid Transitioning Between Normal State and Special

Getting to special when in insert or emacs state is already pretty easy. You can use ) or [ and ] (if you like those keybindings) to jump to a special location at any time. If you want to get there from normal state, it’s a bit more tedious, since you need to first navigate to a special location and then enter insert or emacs state.

Lispyville provides an option that will automatically enter insert or emacs state for lispyville navigation commands that would put you at a paren. To enable this behavior, lispyville-motions-put-into-special can be set to a non-nil value. If you prefer to edit in emacs-state, you can set lispyville-preferred-lispy-state to emacs.

Note that this behavior will not affect the use of motions with an operator or in visual state (which wouldn’t make sense).

There is also an option for commands called lispyville-commands-put-into-special that can be customized in the same way. The currently applicable commands are the slurp and barf commands.

Visual State and Special Integration

Lispyville tries to be unobtrusive by default, only rebinding the major operator keys. Since there are many potential ways to better integrate evil’s visual state with lispy’s special (with the region active), lispyville doesn’t make a default choice for the user.

Using Both Separately

This is probably the simplest method of improving things. By default, pressing escape after using something like lispy-mark from special will enter normal state but won’t cancel the region. Lispyville provides lispyville-normal-state to deactivate the region and enter normal state in one step. You can map it manually or use the escape key theme (e.g. (lispyville-set-key-theme '(... (escape insert emacs)))).

On the other hand, if you want to map a key in normal state to mark something with a lispy command like lispy-mark, normally evil’s visual state will be entered, and the selection will be off by a character. lispyville-wrap-command can be used to create commands that will enter a specific evil state and ensure that the resulting selection is correct. It is mainly meant to be used with visual and special:

;; enter visual state after `lispy-mark-symbol' with correct selection
(evil-define-key 'normal lispyville-mode-map"v" (lispyville-wrap-command lispy-mark-symbol visual));; enter lispy special after `lispy-mark-symbol' with correct selection
(evil-define-key 'normal lispyville-mode-map"v" (lispyville-wrap-command lispy-mark-symbol special))

To toggle between special and visual state at any time, you can use the mark-toggle key theme.

Using Only Lispy’s Mark Commands

Lispy’s special mark state won’t always work correctly when entered with an active region it wouldn’t normally mark (e.g. half of a symbol is marked). Because of this, you’ll probably want to rebind v, V, and C-v. Lispyville provides a key theme to remap v to a wrapped version of lispy-mark-symbol and V and C-v to a wrapped version of lispy-mark (e.g. (lispyville-set-key-theme '(... mark-special))).

The old way of automatically switching to insert or emacs state was found to have serious bugs, so I do not currently recommend using it. Instead, you need to wrap all selection-related functions that you use with lispyville-wrap-command.

Using Only Evil’s Mark Commands

One can have all lispy mark commands enter evil’s visual state instead:

(lispyville-enter-visual-when-marking)

The behavior can be removed by running lispyville-remove-marking-hooks.

Final Notes

If you prefer evil or lispy for working with regions but don’t want to use either all of the time, it’s probably best to pick the one you find the most useful and bind some keys from the other in the relevant keymap.

I may add a key theme for this, but I personally prefer to mainly using lispy’s keys, as they are generally more useful than the default evil motions and will keep the region balanced. Evil’s commands can be more useful for editing comments, so I’m personally using the first solution (Using Both Separately) to choose which to use.

Note that you can still use the mark-toggle keybinding to switch between visual and special even if you run (lispyville-enter-special-when-marking) (use not recommended) or (lispyville-enter-visual-when-marking).

I’ve added the main functions behind safe deletion and copying directly to lispy. To have lispy’s commands always act safely on a region, lispy-safe-delete, lispy-safe-copy, and lispy-safe-paste can be set to non-nil values. Lispyville’s commands keep delimiters balanced regardless of these settings. Lispyville does not yet have a safe paste operator though.

The options that will affect lispyville’s behavior are lispy-safe-threshold, lispy-safe-actions-ignore-strings, lispy-safe-actions-ignore-comments, and lispy-safe-actions-no-pull-delimiters-into-comments.

lispy-safe-threshold is the maximum size a region can be before operators will no longer attempt to keep delimiters balanced. If you ever have an issue with the limit, you can try increasing it and see if there are any performance issues. I haven’t tested performance on larger regions, so any feedback would be appreciated.

The “ignore” options will determine whether commands will ignore unbalanced delimiters in comments and strings. It is recommended to keep these options at their default value (true).

When lispy-safe-actions-no-pull-delimiters-into-comments is non-nil, lispy/lispyville commands will avoid pulling unmatched delimiters into comments (e.g. dd on a line after a comment will keep unmatched closing delimiters on the same line instead of commenting them out).

By default, lispyville-mode will automatically make the following changes when turned on for maximum safety levels:

(setq lispy-safe-delete t
      lispy-safe-copy t
      lispy-safe-paste t
      lispy-safe-actions-no-pull-delimiters-into-comments t)

To prevent lispyville from changing lispy variables, you can set lispyville-no-alter-lispy-options to a non-nil value.

Show HN: Kubernetes as a back-end for OpenFaaS

$
0
0

README.md

This is a plugin to enable Kubernetes as an OpenFaaS backend. The existing CLI and UI are fully compatible. It also opens up the possibility for other plugins to be built for orchestation frameworks such as Nomad, Mesos/Marathon or even a cloud-managed back-end such as Hyper.sh or Azure ACI.

Update:Watch the demo and intro to the CNCF Serverless Workgroup

OpenFaaS is an event-driven serverless framework for containers. Any container for Windows or Linux can be leveraged as a serverless function. OpenFaaS is quick and easy to deploy (less than 60 secs) and lets you avoid writing boiler-plate code.

Stack

In this README you'll find a technical overview and instructions for deploying FaaS on a Kubernetes cluster but Docker Swarm is also natively supported.

FaaS

You can watch my intro from the Dockercon closing keynote with Alexa, Twitter and Github demos or a complete walk-through of FaaS-netes showing Prometheus, auto-scaling, the UI and CLI in action.

If you'd like to know more about the OpenFaaS project head over to - https://github.com/alexellis/faas

QuickStart

If you're looking to just get OpenFaaS deployed on Kubernetes follow the QuickStart guide or read on for a technical overview.

Technical overview

The code in this repository is a daemon or micro-service which can provide the basic functionality the FaaS Gateway requires:

  • List functions
  • Deploy function
  • Delete function
  • Invoke function synchronously

Any other metrics or UI components will be maintained separately in the main OpenFaaS project.

Motivation for separate micro-service:

  • Kubernetes go-client is 41MB with only a few lines of code
  • After including the go-client the code takes > 2mins to compile

So rather than inflating the original project's source-code this micro-service will act as a co-operator or plug-in. Some additional changes will be needed in the main OpenFaaS project to switch between implementations.

There is no planned support for dual orchestrators - i.e. Swarm and K8s at the same time on the same host/network.

Get started with the code

Let's try it out:

  • Create a single-node cluster on our Mac
  • Deploy a function manually with kubectl
  • Build and deploy the FaaS-netes microservice
  • Make calls to list the functions and invoke a function

I'll give instructions for creating your cluster on a Mac with minikube, but you can also use kubeadm on Linux in the cloud by following this tutorial.

Create a cluster on Mac:

$ minikube start --vm-driver=xhyve

You can also omit --vm-driver=xhyve if you want to use VirtualBox for your local cluster.

Deploy FaaS-netes and the API Gateway

$ kubectl apply -f ./faas.yml,monitoring.yml

The monitoring.yml file provides Prometheus and AlertManager functionality for metrics and auto-scaling behaviour.

If you're using kubeadm and RBAC then you can run in a cluster role for FaaS-netes:

$ kubectl apply -f ./rbac.yml

Deploy a tester function

You have three options for deploying a function:

The CLI can build OpenFaaS functions into Docker images that you can share via the Docker Hub. These can also be deployed through the same tool using a YAML format.

Available at: https://github.com/alexellis/faas-cli

Note: currently Kubernetes OpenFaaS functions can only be named a-zA-Z and dash (-).

The OpenFaaS UI is accessible in a web-browser on port 31112 with the IP of your node.

See below for a screenshot.

  • Manual deployment + service with a label of "faas_function=<function_name>"
$ kubectl delete deployment/nodeinfo ; \
  kubectl delete service/nodeinfo ; \
  kubectl run --labels="faas_function=nodeinfo" nodeinfo --port 8080 --image functions/nodeinfo:latest ; \
  kubectl expose deployment/nodeinfo
  • The label faas_function=<function_name> marks this as a "function"

Now try it out

Function List

The function list is available on the gateway and is also used by the OpenFaaS UI.

Find the gateway service:

$ kubectl get service gateway
NAME      CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
gateway   10.106.11.234   <nodes>       8080:31112/TCP   1h

You can now use the node's IP address and port 31112 or the Cluster IP and port 8080.

Using the internal IP:

$ minikube ssh 'curl -s 10.106.11.234:8080/system/functions'

[{"name":"nodeinfo","image":"functions/nodeinfo:latest","invocationCount":0,"replicas":1}]

Or via the node's IP and NodePort we mapped (31112):

$ curl -s http://$(minikube ip):31112/system/functions

[{"name":"nodeinfo","image":"functions/nodeinfo:latest","invocationCount":0,"replicas":1}]

Invoke a function via the API Gateway

Using the IP from the previous step you can now invoke the nodeinfo function with a HTTP POST and an empty body.

curl -s --data "" http://$(minikube ip):31112/function/nodeinfo
Hostname: nodeinfo-2186484981-lcm0m

Platform: linux
Arch: x64
CPU count: 2
Uptime: 19960

The --data flag turns the curl from a GET to a POST. Right now OpenFaaS functions are invoked via a POST to the API Gateway.

The nodeinfo function also supports a parameter of verbose to view network adapters - to try this set the --data flag to verbose.

Manually scale a function

Let's scale the deployment from 1 to 2 instances of the nodeinfo function:

$ kubectl scale deployment/nodeinfo --replicas=2

You can now use the curl example from above and you will see either of the two replicas.

Auto-scale your functions

Given enough load (> 5 requests/second) OpenFaaS will auto-scale your service, you can test this out by opening up the Prometheus web-page and then generating load with Apache Bench or a while/true/curl bash loop.

Here's an example you can use to generate load:

ip=$(minikube ip); while [ true ] ; do curl $ip:31112/function/nodeinfo -d "" ; done

Prometheus is exposed on a NodePort of 31119 which shows the function invocation rate.

$ open http://$(minikube ip):31119/

Here's an example for use with the Prometheus UI:

rate(gateway_function_invocation_total[20s])

It shows the rate the function has been invoked over a 20 second window.

The OpenFaaS complete walk-through on Kubernetes Video shows auto-scaling in action and how to use the Prometheus UI.

Test out the UI

You can also access the OpenFaaS UI through the node's IP address and the NodePort we exposed earlier.

$ open http://$(minikube ip):31112/

If you've ever used the Kubernetes dashboard then this UI is a similar concept. You can list, invoke and create new functions.

Get involved

Please Star the FaaS and FaaS-netes Github repo.

Contributions are welcome - see the contributing guide for OpenFaaS.

The OpenFaaS complete walk-through on Kubernetes Video shows how to use Prometheus and the auto-scaling in action.

Software development and screen readers at 450 words per minute

$
0
0

"Something's a little bit off here." That's what I predict your first thought to be upon seeing my cubicle for the first time. There's no screen or mouse in sight. Instead there's a guy hammering away on a keyboard, staring at seemingly nothing.

A picture of the author standing at a desk. There's a keyboard and a laptop with its lid closed.

It's only me, and my colleagues can assure you that I'm mostly harmless. I'm a software developer working at Vincit offices in Tampere. I'm also blind. In this blog post I'm going to shed some light on the way I work.

Are you blind as in actually blind?

Correct. I can perceive sunlight and some other really bright lights but that's about it. In essence, nothing that would be useful for me at work.

What are you doing there, then?

The same as almost everyone else, that is: making software and bantering with my colleagues whenever the time permits. I have worked in full stack web projects with a focus on the backend. I have also taken up the role of a general accessibility consultant – or police; depends on how you look at it.

How do you use the computer?

The computer I use is a perfectly normal laptop running Windows 10. It's in the software where the "magic happens". I use a program called a screen reader to access the computer. A screen reader intercepts what's happening on the screen and presents that information via braille (through a separate braille display) or synthetic speech. And it's not the kind of synthetic speech you hear in today's smart assistants. I use a robotic-sounding voice which speaks at around 450 words per minute. For comparison, English is commonly spoken at around 120-150 words per minute. There's one additional quirk in my setup: Since I need to read both Finnish and English regularly I'm reading English with a Finnish speech synthesizer. Back in the old days screen readers weren't smart enough to switch between languages automatically, so this was what I got used to. Here's a sample of this paragraph being read as I would read it:

And here's the same text spoken by an English speech synthesizer:

A mouse is naturally not very useful to me so I work exclusively at the keyboard. The commands I use should be familiar to anyone reading this post: Arrow keys and the tab key move you around inside a window, alt+tab changes between windows etc. Screen readers also have a whole lot of shortcuts of their own, such as reading various parts of the active window or turning some of their features on or off.

It's when reading web pages and other formatted documents that things get a little interesting. You see, a screen reader presents its information in chunks. That chunk is most often a line but it may also be a word, a character or any other arbitrary piece of text. For example, if I press the down arrow key on a web page I hear the next line of the page. This type of reading means that I can't just scan the contents of my screen the same way a sighted person would do with their eyes. Instead, I have to read through everything chunk by chunk, or skip over those chunks I don't care about.

Speech or braille alone can't paint an accurate representation of how a window is laid out visually. All the information is presented to me in a linear fashion. If you copy a web page and paste it into notepad you get a rough idea of how web pages look to me. It's just a bunch of lines stacked on top of another with most of the formatting stripped out. However, a screen reader can pick up on the semantics used in the HTML of the web page, so that links, headings, form fields etc. are announced to me correctly. That's right: I don't know that a check box is a check box if it's only styled to look like one. However, more on that later; I'll be devoting an entire post to this subject. Just remember that the example I just gave is a crime against humanity.

I spend a good deal of my time working at the command line. In fact I rarely use any other graphical applications than a web browser and an editor. I've found that it's often much quicker to do the task at hand on the command line than to use an interface which was primarily designed with mouse users in mind.

So, given my love of the command line, why am I sticking with Windows, the operating system not known for its elegant command line tools? The answer is simple: Windows is the most accessible operating system there is. NVDA, my screen reader of choice is open source and maintained more actively than any other screen reader out there. If I had the choice I would use Mac OS since in my opinion it strikes a neat balance between usability and functionality. Unfortunately VoiceOver, the screen reader built in to Mac OS, suffers from long release cycles and general neglect, and its navigation models aren't really compatible with my particular way of working. There's also a screen reader for the Gnome desktop and, while excellently maintained for such a minor user base, there are still rough edges that make it unsuitable for my daily use. So, Windows it is. I've been compensating for Windows' inherent deficiencies by living inside Git Bash which comes with an excellent set of GNU and other command line utilities out of the box.

How can you code?

It took me quite a long time to figure out why this question was such a big deal for so many people. Remember what I said earlier about reading text line by line? That's how I read code. I do skip over the lines that aren't useful to me, or maybe listen only halfway through them just for context, but whenever I actually need to know what's going on I have to read everything as if I were reading a novel. Naturally I can't just read through a huge codebase like that. In those cases I have to abstract some parts of the code in my mind: this component takes x as its input and returns y, never mind what it actually does.

This type of reading makes me do some coding tasks a little bit differently than my sighted colleagues. For example, when doing a code review I prefer to look at the raw diff output whenever I can. Side-by-side diffs are not useful to me, in fact they are a distraction if anything. The + and - signs are also a far better indicator of modified lines than background colours, not because I couldn't get the names of those colours, but because "plus" takes far less time to say than some convoluted shade of red that is used for highlighting an added line. (I am looking at you, Gerrit.)

You might think that indentation and other code formatting would be totally irrelevant to me since those are primarily visual concerns. This is not true: proper indentation helps me just as much as it does a sighted programmer. Whenever I'm reading code in braille (which, by the way, is a lot more efficient than with speech) it gives me a good visual clue of where I am, just like it does for a sighted programmer. I also get verbal announcements whenever I enter an indented or unindented block of text. This information helps me to paint a map of the code in my head. In fact Python was the first real programming language I picked up (Php doesn't count) and its forced indentation never posed a problem for me. I'm a strong advocate of a clean and consistent coding style for a number of reasons, but mostly because not having one makes my life much more difficult

Which editor do you prefer?

Spoiler alert: The answer to this question doesn't start with either V or E. (Granted, I do use Vim for crafting git commit messages and other quick notes on the command line. I consider myself neutral on this particular minefield.) A year ago my answer would have been, of all things, Notepad++. It's a lightweight, well-made text editor that gets the job done. However, a year ago I hadn't worked in a large-scale Java project. When that eventually happened it was time to pick between Notepad++ and my sanity. I ended up clinging to the latter (as long as I can, anyway) and ditching Notepad++ in favour of IntelliJ IDEA. It has been my editor of choice ever since. I have a deeply-rooted aversion towards IDEs since most of them are either inaccessible or inefficient to work with solely on the keyboard. Chances are that I would have switched to using an IDE a lot sooner if I was sighted.

But why Notepad++, you might ask. There are more advanced lightweight editors out there like Sublime text or Atom. The answer is simple: neither of them is accessible to screen readers. Text-mode editors like Vim aren't an option either, since the screen reader I use has some problems in its support of console applications that prevent those editors from being used for anything longer than a commit message. Sadly, accessibility is the one thing that has the last word on the tools I use. If it's not workable enough that I can use it efficiently, it's out of the question.

Do you ever work with frontend code?

You would think that frontend development was so inherently visual that it would be no place for a blind developer, and for the most part that is true. You won't find me doing a basic Proof-of-Concept on my own, since those projects tend to be mostly about getting the looks right and adding the real functionality later.

However, I've had my fair share of Angular and React work too. How's that? Many web apps of today have a lot going on under the hood in the browser. For example, I once worked a couple of weeks adding internationalization support to a somewhat complex Angular app. I didn't need to do any visual changes at all.

I've found that libraries like Bootstrap are a godsend for people like me. Because of the grid system I can lay out a rough version of the user interface on my own. Despite this all the interface-related changes I'm doing are going through a pair of eyes before shipping to the customer. So, to sum up: I can do frontend development up to a point, at least while not touching the presentation layer too much.

How about all the things you didn't mention?

There are certainly a lot of things I had to leave out of this blog post. As promised I'll be devoting a post to the art of making web pages more accessible, since the lack of proper semantics is one of my pet peeves. However, there's a good chance I won't leave it at that. Stay tuned!

German students win hyperloop competition, reaching 200 mph

$
0
0

A team of 30 students from Germany won the SpaceX Hyperloop Pod competition on Sunday, with their prototype pod reaching a speed of 324 kilometers per hour (201 miles per hour).

The team, named WARR Hyperloop, was one of three finalists to participate in Sunday’s competition, held at SpaceX’s headquarters in Hawthorne, CA. The teams were tasked with developing a prototype pod to travel down a 1.2-kilometer (0.75-mile) tube, as part of SpaceX CEO Elon Musk’s vision for a Hyperloop high-speed transport system. The pod that reached the highest maximum speed would be crowned the winner.

WARR’s prototype, a lightweight, carbon-fiber pod, comfortably beat submissions from the two other teams, whose members hailed from Switzerland, Canada and the US. The 176-pound WARR pod is powered by a 50kW electric motor and features four pneumatic friction brakes that allow the pod to come to a standstill within five seconds, according to the team’s website.

The team from Munich Technical University also won the prize for fastest pod at the first Hyperloop Pod competition in January, when its prototype reached a speed of 58 mph. Musk congratulated WARR in a tweet on Sunday, adding in a subsequent tweet that it may be possible to reach “supersonic” speeds in the test Hyperloop tube.

The significance of plot without conflict (2012)

$
0
0

In the West, plot is commonly thought to revolve around conflict: a confrontation between two or more elements, in which one ultimately dominates the other. The standard three- and five-act plot structures–which permeate Western media–have conflict written into their very foundations. A “problem” appears near the end of the first act; and, in the second act, the conflict generated by this problem takes center stage. Conflict is used to create reader involvement even by many post-modern writers, whose work otherwise defies traditional structure.

The necessity of conflict is preached as a kind of dogma by contemporary writers’ workshops and Internet “guides” to writing. A plot without conflict is considered dull; some even go so far as to call it impossible. This has influenced not only fiction, but writing in general–arguably even philosophy. Yet, is there any truth to this belief? Does plot necessarily hinge on conflict? No. Such claims are a product of the West’s insularity. For countless centuries, Chinese and Japanese writers have used a plot structure that does not have conflict “built in”, so to speak. Rather, it relies on exposition and contrast to generate interest. This structure is known as kishōtenketsu.

Kishōtenketsu contains four acts: introduction, development, twist and reconciliation. The basics of the story–characters, setting, etc.–are established in the first act and developed in the second. No major changes occur until the third act, in which a new, often surprising element is introduced. The third act is the core of the plot, and it may be thought of as a kind of structural non sequitur. The fourth act draws a conclusion from the contrast between the first two “straight” acts and the disconnected third, thereby reconciling them into a coherent whole. Kishōtenketsu is probably best known to Westerners as the structure of Japanese yonkoma (four-panel) manga; and, with this in mind, our artist has kindly provided a simple comic to illustrate the concept.

Each panel represents one of the four acts. The resulting plot–and it is a plot–contains no conflict. No problem impedes the protagonist; nothing is pitted against anything else. Despite this, the twist in panel three imparts a dynamism–a chaos, perhaps–that keeps the comic from depicting merely a series of events. Panel four reinstates order by showing us how the first two panels connect to the third, which allows for a satisfactory ending without the need for a quasi-gladiatorial victory. It could be said that the last panel unifies the first three. The Western structure, on the other hand, is a face-off–involving character, theme, setting–in which one element must prevail over another. Our artist refitted the above comic into the three-act structure to show this difference.

The first panel gives the reader a “default position” with which to compare later events; and the second panel depicts a conflict-generating problem with the vending machine. The third panel represents the climax of the story: the dramatic high point in which the heroine's second attempt "defeats" the machine and allows the can to drop. The story concludes by depicting the aftermath, wherein we find that something from the first act has changed as a result of the climax. In this case, our heroine sans beverage has become a heroine avec beverage.

What this shows is that the three-act plot, unlike kishōtenketsu, is fundamentally confrontational. It necessarily involves one thing winning out over another, even in a minor case like the one above. This conclusion has wide-ranging implications, since both formats are applied not just to narratives, but to all types of writing. Both may be found under the hood of everything from essays and arguments to paragraphs and single sentences. As an example, the reader might re-examine the first two paragraphs of this article, in which a “default position” is set up and then interrupted by a “problem” (namely, the existence of kishōtenketsu). The following paragraphs deal with the conflict between the two formats. This paragraph, which escalates that conflict by explaining the culture-wide influence of each system, is the beginning of the climax.

As this writer is already making self-referential, meta-textual remarks, it is only appropriate that the article’s climax take us into the realm of post-modern philosophy. It is a worldview obsessed with narrative and, perhaps unconsciously, with the central thesis of the three-act structure. Jacques Derrida, probably the best known post-modern philosopher, infamously declared that all of reality was a text–a series of narratives that could only be understood by appealing to other narratives, ad infinitum. What kinds of narratives, though? Perhaps a benign, kishōtenketsu-esque play between disconnection and reconnection, chaos and order? No; for Derrida, the only narrative was one of violence. As a Nietzschean, he believed that reality consisted, invariably, of one thing dominating and imposing on another, in a selfish exercise of its will to power. The “worst violence”, he thought, was when something was completely silenced and absorbed by another, its difference erased. Apparently, Derrida was uncontent with the three-act structure’s nearly complete control over Western writing: he had to project it onto the entire world. Eurocentrism has rarely had a more shining moment.

Kishōtenketsu contains no such violence. The events of the first, second and third acts need not harm one another. They can stand separately, with Derrida’s beloved difference intact. Although the fourth act unifies the work, by no means must it do violence to the first three acts; rather, it is free merely to draw a conclusion from their juxtaposition, as Derrida does when he interprets one narrative through the lens of another. A world understood from the kishōtenketsu perspective need never contain the worst violence that Derrida fears, which would make his call for deconstruction–the prevention of silence through the annihiliation of structure–unnecessary. Is it possible that deconstruction could never have been conceived in a world governed by kishōtenketsu, rather than by the three-act plot? Is the three-act structure one of the elements behind the very worldview that calls for its deconstruction? Can the Western narrative of the will to power remain coherent in the face of a rival narrative from the East? This writer would prefer to ask than to answer these questions.

Now, dear readers, comes the aftermath. The dust left over from the climax is settling. Kishōtenketsu has been shown to generate plot without conflict, which reveals as insular nonsense the West’s belief that they are inseparable. The repercussions of this extend to all writing; and, if this writer's conclusion is to be believed, to philosophy itself. Despite this, it should be noted that many of history’s greatest works have been built on the three- and five-act structures. By no means should they be discarded. Rather, they should be viewed as tools for telling certain types of stories. At the same time, this writer would like to end by calling for a renewed look at kishōtenketsu in the West. It offers writers the opportunity to explore plots with minimal or no conflict. Perhaps it could even change our worldview.

Still Eating Oranges

To Survive in Tough Times, Restaurants Turn to Data-Mining

$
0
0

“Silicon Valley looks at inefficiencies in the world, and they aim to disrupt the food space,” said Erik Oberholtzer, a founder and the chief executive of Tender Greens, a quick-service chain based in Los Angeles that is using data to guide its East Coast expansion. “I mean that in a good way.”

In the old days, restaurateurs used ledgers to track sales, and scribbled notes about their customers’ preferences or idiosyncrasies. Then along came point-of-sale software and reservation services that provided more sophisticated records and analysis, but created a tech tower of Babel, with most systems speaking their own dialect.

Avero, a Manhattan-based company founded in 1999, defined the next generation of analytics: It translated data into a common language, added external data and generated an easy-access overview of inventory, food costs and sales, accounting, scheduling and customer behavior. “Not 40 systems with 40 passwords,” said Avero’s founder, Damian Mogavero.

Newer companies now aspire to eliminate the need for translation, to create an analytics program that integrates all aspects of a restaurant’s operations into one system, with one password, in real time with mobile access, said Shu Chowdhury, the chief executive of a start-up called Salido, based in SoHo. One of its initial investors is the chef Tom Colicchio, who is using it as he revamps and expands his chain of ‘Wichcraft sandwich shops.

Photo
Tender Greens uses data research to help make the restaurant more efficient and to guide its East Coast expansion.Credit Emily Berl for The New York Times

These new tools make a paradoxical promise: that they can take restaurants back to the good old days, before the business grew so big.

“The goal,” Mr. Oberholtzer said, “is to leverage the technology to do what we would do if we had one little restaurant and we were there all the time and knew every customer by name.”

Mr. Oberholtzer and his two partners opened the first of two dozen cafeteria-style restaurants in Culver City, Calif., in 2006, and plan to open an equal number in the Northeast by 2020. Every new Tender Greens will rely on what he calls “a whole rebuild of technology,” because the 11-year-old system it uses is about as up-to-date as a beeper.

He has decided on a combination of three systems that “play well with others,” he said, so there’s no communications problem: Brink POS software, a point-of-sale system that Mr. Oberholtzer says “is robust enough to handle volume and simple enough for our teams to use easily,” an essential combination for an expanding company; Olo, to coordinate online ordering and delivery; and the Punchh mobile app, which logs each customer’s name, email address and purchase history.

“It gives us ways to recognize people who’ve been in regularly, or haven’t been in for a while or have specific preferences,” Mr. Oberholtzer said.

A regular diner who always orders the niçoise salad will get a message on the app about the halibut special. A diner who always orders vegetarian options will not get the message about the summer hog roast. “We want to accommodate everyone’s needs,” Mr. Oberholtzer said, “sometimes before they even mention them.”

In Chicago, at the Michelin-starred Oriole, where 28 diners sit down each night to a $190 tasting menu, the owners, Noah and Cara Sandoval, rely on data from the Upserve system to identify their top 100 guests in terms of numbers of visits and amount spent, but that’s just the start. The system also creates a profile with every first-time reservation.

“You can’t know that someone’s going to become a regular, so you don’t necessarily keep track of those people,” Ms. Sandoval said. “But the system does.” It also tracks the top 100’s dining companions when they split the check. Upserve sends a list of credit card numbers, dates of visits and items bought; the restaurant matches each number to a name, and a search on Google, Facebook and LinkedIn provides a face to go with it.

“We’re sure to recognize them” the next time they come in, so the staff can welcome them back by name, Ms. Sandoval said. “It surprises people, in a nice way, when they didn’t make the reservation themselves.”

Photo
“Silicon Valley looks at inefficiencies in the world, and they aim to disrupt the food space,” said Erik Oberholtzer, a founder and the chief executive of Tender Greens.Credit Emily Berl for The New York Times

Even the type of credit card contributes to the dossier. If a customer pays with an airline card, a server might mention travel. If a customer is a sports fan, he will most likely get a server who is as well.

The food gets similar scrutiny. Upserve offers a “magic quadrant” feature that divides dishes into four categories— “greatest hits,” “underperformers,” “one-hit wonders” that are popular with first-timers but not with repeat visitors, and “hidden gems,” which regulars like and first-timers don’t — to help the Sandovals understand which are popular, and which prompt diners to return.

Customers who find the mining of personal data invasive can opt out, up to a point, but it requires effort: To avoid detection, they have to pay cash and not make reservations. Those who participate actively in the process get more information in return.

In June 2015, the online reservation service OpenTable, which represents 43,000 restaurants worldwide, started to provide customized recommendations, just as Netflix and Amazon suggest programs or products based on a customer’s history.

If users sign up for the company’s app and allow OpenTable access to their GPS, they receive recommendations for restaurants in the United States and several foreign countries, said Scott Jampol, the company’s senior vice president for marketing.

And if data can help a customer find a restaurant, it can also help a restaurant find its customers. To pinpoint potential locations in the Northeast that best reach what Mr. Oberholtzer calls Tender Greens’s “psychographic” — the college-educated diner who cares about health and locally produced food — he starts with data from a customer analytics firm that specializes in site selection.

He refines that list with Google searches like “plant-forward lifestyle,” he said, and looks at where delivery systems like Uber and DoorDash do a lot of business.

“You overlay and look for redundancy,” he said, “and that begins to tell the story of where you want to be.”

But successful growth makes it hard to keep a sharp eye on operations. Charlee Williamson has been with the New Orleans-based Ralph Brennan Restaurant Group for 24 years, and keeps track of six managers and 78 servers at the Jazz Kitchen, thousands of miles away at Disneyland in California. She relies on the Server Scorecard, a feature offered by Avero.

Photo
Casey Cohen, Shu Chowdhury and Matthew Gaines, co-founders of Salido.Credit Cole Wilson for The New York Times

The scorecard ranks servers on multiple criteria, which makes it easier for Ms. Williamson to identify the right waiter, for example, for a large party with children. She might not pick the server who sells the most. The more appropriate match could be a server who ranks higher in tip percentage than in sales, thanks to grateful families who tend to order less alcohol.

The message to restaurateurs is simple: Ignore data at your peril, said Mr. Mogavero, the author of a recent book, “The Underground Culinary Tour,” about how data has transformed the restaurant industry.

Start-ups aspire to create even more streamlined software, but it isn’t easy. “We’re making a moon shot here,” said Mr. Chowdhury of Salido, which originally set an August deadline for “a fully operational stack” of features but is only about three-quarters of the way there. The company has extended its deadline to early 2018, as development work continues with 64 existing clients.

The basic point-of-sale part of the program is already in use in New York at Made Nice, the new fast-casual restaurant from the chef Daniel Humm and Will Guidara, owners of Eleven Madison Park and the NoMad, and at Jean-George Vongerichten’s ABC Kitchen.

Still, some early adopters approach the new systems warily. Mr. Guidara, who also uses Avero at Eleven Madison Park, thinks technology is great for a fast-casual operation that emphasizes volume and delivery, and for the business side at a fine-dining operation. It has no place, he said, when it comes to service at Eleven Madison Park or the NoMad, where he and Mr. Humm rely on traditional methods of high-end hospitality: expertise, eye contact and a hair-trigger response to a diner’s every need.

“When I worked as a controller, in accounting capacities, we used it quite often,” Mr. Guidara said. “But from an experiential, guest-facing point of view, we don’t use it. That’s never been how we approach things.”

The chef David Kinch owns Manresa in Northern California, which won its third Michelin star in 2016. His reservationist does a Google search every guest to ferret out basic information like occupation or interests, and then he relies on a highly trained staff, including a concierge and two master sommeliers, to work the room and ensure everyone is happy.

“I’m pushed constantly about these new systems,” Mr. Kinch said. “People say it’s all about the guest? I think that couldn’t be further from the truth. I place a tremendous value on direct eye contact and a genuine smile.”

At Oriole, the Sandovals have left sake on the menu despite data showing that it doesn’t sell well. “We go by our gut,” Ms. Sandoval said. “It pairs well with a lot of the courses, it’s very versatile, and it speaks to how we’re willing not to go the traditional route.”

The sheer glut of new restaurant data systems can be overwhelming, even to those who embrace them.

“At least once a week, I get something about a new start-up with a new gadget that’s going to make our lives so much better,” said Sisha Ortuzar, Mr. Colicchio’s partner at ‘Wichcraft. “They’re distractions. We just want to get back to making sandwiches.”

Follow NYT Food on Facebook, Instagram, Twitter and Pinterest. Get regular updates from NYT Cooking, with recipe suggestions, cooking tips and shopping advice.

Continue reading the main story

Ask HN: What maths are critical to pursuing ML/AI?

$
0
0

Part II

(2) Linear Algebra

(2.1) Linear Equations

The start of linear algebra was seen in high school algebra, solving systems of linear equations.

E.g., we seek numerical values of x and y so that

     3 x - 2 y = 7

     -x  + 2 y = 8
So, that is two equations in the two unknowns x and y.

Well, for positive integers m and n, we can have m linear (linear is in the above example but omitting here a careful definition) equations in n unknowns.

Then depending on the constants, there will be none, one, or infinitely many solutions.

E.g., likely the central technique of ML and data science is fitting a linear equation to data. There the central idea is the set of normal equations which are linear (and, crucially, symmetric andnon-negative semi-definite as covered carefully in linear algebra).

(2.2) Gauss Elimination

The first technique for attacking linear equations is Gauss elimination. There can determine if there are none, one, or infinitely many solutions. For one solution, can find it. For infinitely many solutions can find one solution and for the rest characterize them as from arbitrary values of several of the variables.

(2.3) Vectors and Matrices

A nice step forward in working with systems of linear equations is the subject of vectors and matrices.

A good start is just

     3 x - 2 y = 7

     -x  + 2 y = 8
we saw above. What we do is just rip out the x and y, call that pair a vector, leave the constants on the left as amatrix, and regard the constants on the right side as another vector. Then the left side becomes the matrix theoryproduct of the matrix of the constants and the vector of the unknowns x and y.

The matrix will have two rows and two columns written roughly as in

   /         \
   |  3  - 2 |
   |         |
   | -1    2 |
   \         /
So, this matrix is said to be 2 x 2 (2 by 2).

Sure, for positive integers m and n, we can have a matrix that is m x n (m by n) which means m rows and n columns.

The vector of the unknowns x and y is 2 x 1 and is written

   /   \
   | x |
   |   |
   | y |
   \   /
So, we can say that the matrix is A; the unknowns are the components of vector v; the right side is vector b; and that the system of equations is
     Av = b
where the Av is the matrix product of A and v. How is this product defined? It is defined to give us just what we had with the equations we started with -- here omitting a careful definition.

So, we use a matrix and two vectors as new notation to write our system of linear equations. That's the start of matrix theory.

It turns out that our new notation is another pillar of civilization.

Given a m x n matrix A and an n x p matrix B, we can form the m x p matrix product AB. Amazingly, this product is associative. That is, if we have p x q matrix C then we can form m x q product

ABC = (AB)C = A(BC)

It turns out this fact is profound and powerful.

The proof is based on interchanging the order two summation signs, and that fact generalizes.

Matrix product is the first good example of a linear operator in a linear system. The world is awash in linear systems. There is a lot on linear operators, e.g., Dunford and Schwartz,Linear Operators. Electronic engineering, acoustics, and quantum mechanics are awash in linear operators.

To build a model of the real world, for ML, AL, data science, ..., etc., the obvious first cut is to build a linear system.

And if one linear system does not fit very well, then we can use several in patches of some kind.

(2.4) Vector Spaces

For the set of real numbers R and a positive integer n, consider the set V of all n x 1 vectors of real numbers. Then V is a vector space. We can write out the definition of a vector space and see that the set V does satisfy that definition. That's the first vector space we get to consider.

But we encounter lots more vector spaces; e.g., in 3 dimensions, a 2 dimensional plane through the origin is also a vector space.

Gee, I mentioned dimension; we need a good definition and a lot of associated theorems. Linear algebra has those.

So, for matrix A, vector x, and vector of zeros 0, the set of all solutions x to

Ax = 0

is a vector space, and it and its dimension are central in what we get in many applications, e.g., at the end of Gauss elimination, fitting linear equations to data, etc.

(2.5) Eigen Values, Vectors

Eigen in German translates to English as special, unique, singular, or some such.

Well, for a n x n matrix A, we might have that

Ax = lx

for number l. In this case what matrix A does to vector x is just change its length by l and keep its direction the same. So, l and x are quite special. Then l is aneigenvalue of A, and x is a corresponding eigenvector of A.

These eigen quantities are central to the crucial singular value decomposition, the polar decomposition, principal components, etc.

(2.6) Texts

A good, now quite old, intermediate text in linear algebra is by Hoffman and Kunze, IIRC now available for free as PDF on the Internet.

A special, advanced linear algebra text is P. Halmos, Finite Dimensional Vector Spaces written in 1942 when Halmos was an assistant to John von Neumann at the Institute for Advanced Study. The text is an elegant finite dimensional introduction to infinite dimensional Hilbert space.

At

http://www.american.com/archive/2008/march-april-magazine-co...

is an entertaining article about Harvard's course Math 55. At one time that course used that book by Halmos and also, see below, Baby Rudin.

For more there is

Richard Bellman, Introduction to Matrix Analysis.

Horn and Johnson, Matrix Analysis.

There is much more, e.g., on numerical methods. There a good start is LINPACK, the software, associated documentation, and references.

(5) More

The next two topics would be probability theory and statistics.

For a first text in either of these two, I'd suggest you find several leading research universities, call their math departments, and find what texts they are using for their first courses in probability and statistics. I'd suggest you get the three most recommended texts, carefully study the most recommended one, and use the other two for reference.

Similarly for calculus and linear algebra.

For more, that would take us into a ugrad math major. Again, make some phone calls for a list of recommended texts. One of those might be

W. Rudin, Principles of Mathematical Analysis.

aka, "Baby Rudin". It's highly precise and challenging.

For more,

H. Royden, Real Analysis

W. Rudin, Real and Complex Analysis

L. Breiman, Probability

M. Loeve, Probability

J. Neveu, Mathematical Foundations of the Calculus of Probability

The last two are challenging.

For Bayesian, that's conditional expectation from the Radon-Nikodym theorem with a nice proof by John von Neumann in Rudin's Real and Complex Analysis.

After those texts, often can derive the main results of statistics on your own or just use Wikipedia a little. E.g., for the Neyman-Pearson result in statistical hypothesis testing, there is a nice proof from the Hahn decomposition from the Radon-Nikodym theorem.


How Uploadcare Built a Stack That Handles 350M File API Requests per Day

$
0
0

By Dmitry Mukhin, CTO at Uploadcare.


Uploadcare is a file infrastructure as a service solution. We offer building blocks for handling files that provide simple controls for managing complex technologies. These controls include our widget, Upload API, REST API, and CDN API. All together these APIs handle 350M requests per day.

With only a few lines of code you get the ability to upload, store, process, cache, and deliver files. We support uploads from Dropbox, Facebook, and many other external sources. We also allow our users to upload files directly to their storage.

Widget uploading workflow

Yes, you can handle files on your own and you can get the basic system up and running pretty fast. What about storage? Uptime? A clear and friendly UI? Fast delivery to remote regions? For most of the use cases we analyzed, there is no sense in investing in developing your own file infrastructure.

Setting up Uploadcare is quick and solves many of the issues users traditionally experience when handling both large files and batches of smaller ones. Additionally you no longer need to test your system in every browser and maintain the infrastructure.

Uploadcare has built an infinitely scalable infrastructure by leveraging AWS. Building on top of AWS allows us to process 350M daily requests for file uploads, manipulations, and deliveries. When we started in 2011 the only cloud alternative to AWS was Google App Engine which was a no-go for a rather complex solution we wanted to build. We also didn’t want to buy any hardware or use co-locations.

Our stack handles receiving files, communicating with external file sources, managing file storage, managing user and file data, processing files, file caching and delivery, and managing user interface dashboards.

From the beginning we built Uploadcare with a microservice based architecture.

These are the challenges we faced in each layer of our stack.

Backend

At its core, Uploadcare runs on Python. The Europython 2011 conference in Florence really inspired us, coupled with the fact that it was general enough to solve all of our challenges informed this decision. Additionally we had prior experience working in Python.

We chose to build the main application with Django because of its feature completeness and large footprint within the Python ecosystem.

All the communications within our ecosystem occur via several HTTP APIs, Redis, Amazon S3, and Amazon DynamoDB. We decided on this architecture so that our our system could be scalable in terms of storage and database throughput. This way we only need Django running on top of our database cluster. We use PostgreSQL as our database because it is considered an industry standard when it comes to clustering and scaling.

Uploads, External sources

Uploadcare lets users upload files using our widget. We support multiple upload sources including APIs that only require URLs.

Uploaded files are received by the Django app where the majority of the the heavy lifting is done by Celery. It’s great for handling queues and it’s got a great community with tons of tutorials and examples to leverage. Celery handles uploading large files, retrieving files from different upload sources, storing files, and pushes files to Amazon S3. All the communications with external sources are handled by separate Amazon EC2 instances where load balancing is handled by AWS Elastic Load Balancer. The EC2 instances responsible for uploads are kept separate from the rest of the application.

Uploads diagram

The only two issues we have experienced with AWS are inaccurate reports from the AWS status page and failing to plan ahead when reserving resources to reduce costs and inefficiencies.

File storage, User and file data

We use Amazon S3 for storage. The EC2 upload instances, REST API, and processing layer all communicate with S3 directly. S3 gives us the ability to store customer files forever if they desire it.

File and user data are managed with a heavily customized Django REST framework. At first we used the out of the box Django REST framework as it helped us to rapidly deploy features. However, as our vision of how a REST API should work evolved we implemented customizations to fit our use cases. The footprint of our custom additions has grown large enough that updating the framework is a pain point. We're looking to modify this part of our stack to avoid adding further customizations that would compound this problem.

We use the micro framework Flask to handle sensitive data and OAuth communications. It is lightweight and efficient and doesn’t include any features that we don’t need such as queues, an ORM layer, or caches.

We explore this topic in more detail in an article on cloud-security on our blog explaining how Uploadcare gets content from social media and how we treat end user privacy.

Processing

The 350M API requests we handle daily include many processing tasks such as image enhancements, resizing, filtering, face recognition, and GIF to video conversions.

Our file processing requirements necessitate using asynchronous frameworks for IO-bound tasks. Tornado is the one we currently use and aiohttp is the one we intend to implement in production in the near future Both tools support handling huge amounts of requests but aiohttp is preferable as it uses asyncio which is Python-native.

Processing and delivery diagram

Our real-time image processing is a CPU-bound task. Since Python is in the heart of our service, we initially used PIL followed by Pillow. We kind of still do. When we figured resizing was the most taxing processing operation, Alex, our engineer, created the fork named Pillow-SIMD and implemented a good number of optimizations into it to make it 15 times faster than ImageMagick. Thanks to the optimizations, Uploadcare now needs six times fewer servers to process images. Here, by servers I also mean separate EC2 instances handling processing and the first layer of caching. The processing instances are also paired with ELB which helps ingest files to the CDN.

Caching, Delivery

There are three layers of caching which help improve the overall performance:

  • Caching in the processing engine so that same operations are not run many times
  • Caching inside CDN-Shield, for CDN edges not to hammer origins and cache things more effectively
  • Cache on the CDN edges as the frontier closest to consumer devices

For delivery, files are then pushed to Akamai CDN with the help of nginx and AWS Elastic Load Balancer. We also use Amazon CloudFront but due to the lack of coverage, we moved to Akamai as default CDN. Also, Akamai has many cool features, for instance, it allows us to automatically adjust imagea formats to user browsers.

It's also worth adding that our file receive/deliver ratio is strongly biased toward delivery.

Front-end

Simple controls over complex technologies, as we put it, wouldn't be possible without neat UIs for our user areas including start page, dashboard, settings, and docs.

Initially, there was Django. Back in 2011, considering our Python-centric approach, that was the best choice. Later, we realized we needed to iterate on our website more quickly. And this led us to detaching Django from our front end. That was when we decided to build an SPA.

Building SPA for our front page, docs, and other site sections from scratch is an ongoing process. It's done with Node.js which is asynchronous and provides isomorphic rendering. In order to communicate with our older Django-based front end, it uses JSON API through nginx. And that's a rule of thumb we stick to: once separated, the communications between our front and back end will still be carried out via JSON API.

For building user interfaces, we're currently using React as it provided the fastest rendering back when we were building our toolkit. And it’s not just it: React has a great community which helps you code less and build more. It’s worth mentioning Uploadcare is not a front-end-focused SPA: we aren’t running at high levels of complexity. If it were, we’d go with Ember.

However, there's a chance we will shift to the faster Preact, with its motto of using as little code as possible, and because it makes more use of browser APIs.

On the client, we work with data using Redux.js and do routing via React Router. The latter is a great example of the awesome React community.

One of our future tasks for our front end is to configure our Webpack bundler to split up the code for different site sections. Currently, when you load a site page, you also get the code for all the other pages. Webpack is also a code-less-build-more tool with vast amounts of community examples to use as starter kits. We were thinking of using Browserify or Rollup, but they did not have a runtime and either worked slower than Webpack or required us to do way more coding to provide similar functionality. Plus, async chunks are easier to handle with Webpack.

As for the static site pages, many of them are Markdown-formatted files sitting in a GitHub repo. Overall, we’re using a GitHub Pull Request Model for deployment. The files from a repo then go through jinja2-inspired nunjucks followed by markdown-it and posthtml. Our docs are built this way, for instance.

For styles, we use PostCSS along with its plugins such as cssnano which minifies all the code.

As you can tell, we like the idea of post-processors. posthtml, for instance is a parser and a stringifier providing an Abstract Syntax Tree which is easy to work with.

All that allows us to provide a great user experience and quickly implement changes where they are needed with as little code as possible.

Deployment

As I mentioned above, we use the GitHub Pull Request Model. Certain parts of the process are automatic while others require manual intervention. We use the following steps:

  • We create a branch in a repo with one of our features
  • Commits are made to the branch. That’s followed by automatic tests inTeamCity
  • If tests pass, a PR is created followed by both auto tests and code review by the dev team
  • If tests pass/review ok, we merge changes to the staging branch which is then automatically deployed via TeamCity and Chef
  • When deployed, we run integration tests via TeamCity
  • If everything is green, we merge changes to the production branch and run one more battery of tests automatically via TeamCity
  • If tests pass and we ensure it’s not some Friday night, we deploy to production. Chef scripts here are run by devops.

Deployment flow

We get notified about deployment status via a Slack channel. Regarding reports, we get a lot of input from our monitoring stack which includes Rollbar for reporting errors and exceptions, LogDNA for logging, Pingdom for testing our services externally, Amazon CloudWatch for monitoring AWS stats, and Datadog for consolidating reports and monitoring health status of our servers and services.

Team administration, tasks, communication

Along with Slack, there's also G Suite for emails, Trello for planning, HelpScout and Intercom for customer success communications and client relations, and more.

Vision

Since we provide the complete set of building blocks for handling files, we encourage everyone out there to use similar building blocks for different parts of their products. Our stack is a great example of that— it's a collection of pre-built components. And we can always go on and add more to the list. For instance, we're using Segment to send data for analyses, which, in turn, are carried out by Kissmetrics,Keen IO, Intercom, and others. We’re using Stripe for processing payments.

We practice what we preach: focus on what you want to create and let those building blocks handle the specific tasks they were made for.


'Snowdrift' game tops 'Prisoner's Dilemma' in explaining cooperation (2007)

$
0
0
Photo caption: In the Snowdrift Game, individuals gain direct benefits from cooperative acts, which may indicate why cooperation is favored by natural selection. (Photo of 1977 blizzard in Buffalo, New York)

When it comes to explaining the evolution of human cooperation, researchers have traditionally looked to the iterated Prisoner’s Dilemma (IPD) game as the paradigm. However, the observed degree of cooperation among humans is generally higher than predicted by mathematical models using the IPD, leaving unanswered the question of why humans cooperate to the extent they do.

A group of researchers from the University of Lausanne in Switzerland and the University of Edinburgh in the UK suggests that a different game, called the “iterated Snowdrift game” (ISD), may more realistically reflect social situations that humans face, compared with the IPD. In experimental tests, the proportion of cooperative acts in the ISD game (48%) was significantly higher than those in the IPD (29%).

The cause for this difference is due to the higher risks of being exploited in the IPD compared with the ISD, where the risk of being exploited by someone who doesn’t cooperate when you do is lower.

“In principle, natural selection predicts individuals to behave selfishly,” Rolf Kümmerli, co-author of the study, told PhysOrg.com. “However, we observe cooperation in humans and other organisms, where cooperation is costly for the actor but benefits another individual. The question is why does natural selection favor such cooperation? One solution to this problem is given by the ‘Snowdrift’ game (but not by the PD), where individuals gain direct benefits from their cooperative acts.”

The situation of the Snowdrift game involves two drivers who are trapped on opposite sides of a snowdrift. Each has the option of staying in the car or shoveling snow to clear a path. Letting the opponent do all the work is the best option (with a pay-off of 300 used in this study), but being exploited by shoveling while the opponent sits in the car still results in a pay-off of 100. (The other two possibilities, both shoveling and both sitting, have pay-offs of 200 and 0, respectively.)

Compare this with the Prisoner’s Dilemma. For a quick synopsis, two prisoners being questioned each have the choice to either defend the other’s innocence or betray the other’s guilt. As in the Snowdrift game, the best option is to betray your opponent while he defends you (pay-off of 400), and next for both of you to defend each other (pay-off of 300). Also, as in the Snowdrift game, both of you betraying results in a pay-off of 0.

However, the significant difference is in the greater risk in the Prisoner’s Dilemma when you cooperate while your opponent defects: while shoveling snow always helps you out, even when the opponent sits (100 pay-off), defending an opponent who betrays you results in the worst outcome for you—a pay-off of -100. In the study, participants cooperated more in the ISD because they could always obtain individual benefits by cooperating, while the costs of cooperating were shared between cooperators.

The researchers noticed other interesting trends in the study, which involved 96 participants (38 female and 58 male) divided into 16 groups and arranged in 48 pairs, not knowing their partner’s identity or gender. Each pair repeated (“iterated”) both games 12 times, though were initially told the number of repetitions was randomly determined. The researchers created global competition by revealing that the players with the four highest pay-offs would receive monetary awards.

Players who employed “Tit-for-Tat” and “Pavlovian” strategies—known to increase pay-offs in the IPD—had better pay-offs in both games than players who did not use these strategies. Further, the researchers found that female participants were twice as likely to use one of these strategies as male participants in the ISD (but not the IPD), resulting in both greater cooperation in female-female pairs compared with male-male pairs, as well as greater pay-offs for individual females. Interestingly, these results contrast with the theory of social sciences, suggesting that there is no simple rule on how males and females behave in different social dilemmas.

“The most significant result is that humans adapt the degree of cooperation according to the social context (ISD or IPD) and the behavior and gender of their partner,” Kümmerli said.

Besides offering a potential explanation for the high levels of cooperation among humans, the ISD may also have more real-life associations than the IPD. For example, as the researchers point out, two scientists collaborating on a report would benefit if the other worked harder. But when your collaborator doesn’t do any work, it’s probably better for you to do all the work yourself. You’ll still end up with a completed project, rather than life in prison.

“Many natural situations of cooperation are much more similar to the SD than to the PD,” Kümmerli said. “For that reason, I think that the SD can provide more indications why cooperation is favored by natural selection than the PD. However, the PD is still a useful tool for mathematical models and to demonstrate differences in cooperation between two groups and in treatment of the gender differences in our study.”

Citation: Kümmerli, Rolf, Colliard, Caroline, Fiechter, Nicolas, Petitpierre, Blaise, Russier, Flavien, and Keller, Laurent. “Human cooperation in social dilemmas: comparing the Snowdrift game with the Prisoner’s Dilemma.” Proc. R. Soc. B, doi:10.1098/rspb.2007.0793.

Copyright 2007 PhysOrg.com.
All rights reserved. This material may not be published, broadcast, rewritten or redistributed in whole or part without the express written permission of PhysOrg.com.

Disabling Intel ME 11 via undocumented mode

$
0
0

Our team of Positive Technologies researchers has delved deep into the internal architecture of Intel Management Engine (ME) 11, revealing a mechanism that can disable Intel ME after hardware is initialized and the main processor starts. In this article, we describe how we discovered this undocumented mode and how it is connected with the U.S. government's High Assurance Platform (HAP) program.

Disclaimer: The methods described here are risky and may damage or destroy your computer. We take no responsibility for any attempts inspired by our work and do not guarantee the operability of anything. For those who are aware of the risks and decide to experiment anyway, we recommend using an SPI programmer.

Introduction

Intel Management Engine is a proprietary technology that consists of a microcontroller integrated into the Platform Controller Hub (PCH) chip and a set of built-in peripherals. The PCH carries almost all communication between the processor and external devices; therefore Intel ME has access to almost all data on the computer. The ability to execute third-party code on Intel ME would allow for a complete compromise of the platform. We see increasing interest in Intel ME internals from researchers all over the world. One of the reasons is the transition of this subsystem to new hardware (x86) and software (modified MINIX as an operating system). The x86 platform allows researchers to make use of the full power of binary code analysis tools. Previously, firmware analysis was difficult because earlier versions of ME were based on an ARCompact microcontroller with an unfamiliar set of instructions.

Unfortunately, analysis of Intel ME 11 was previously impossible because the executable modules are compressed by Huffman codes with unknown tables. Nonetheless, our research team (Dmitry Sklyarov, Mark Ermolov, and Maxim Goryachy) managed to recover these tables and created a utility for unpacking images. The utility is available on our GitHub page.

After unpacking the executable modules, we proceeded to examine the software and hardware internals of Intel ME. Our team has been working on this for quite some time, and we have accumulated a large amount of material that we plan to publish. This is the first in a series of articles on the internals of Intel ME and how to disable its core functionality. Experts have long wondered about such an ability in order to reduce the risk of data leaks associated with any potential zero-day vulnerabilities in Intel ME.

How to disable ME

Some users of x86 computers have asked the question: how can one disable Intel ME? The issue has been raised by many, including Positive Technologies experts. [, ]. And with the recently discovered critical (9.8/10) vulnerability in Intel Active Management Technology (AMT), which is based on Intel ME, the question has taken on new urgency.

The disappointing fact is that on modern computers, it is impossible to completely disable ME. This is primarily due to the fact that this technology is responsible for initialization, power management, and launch of the main processor. Another complication lies in the fact that some data is hard-coded inside the PCH chip functioning as the southbridge on modern motherboards. The main method used by enthusiasts trying to disable ME is to remove everything "redundant" from the image while maintaining the computer's operability. But this is not so easy, because if built-in PCH code does not find ME modules in the flash memory or detects that they are damaged, the system will not start.

The me_cleaner project, in development for several years, has created a special utility for deleting most of the image and leaving only the components vital for the main system. But even if the system starts, the joy is short-lived—after about 30 minutes, the system may shut down automatically. The reason is that, after some failures, ME enters Recovery Mode, in which it can operate only for a certain period of time. As a result, the cleaning process becomes more complicated. For example, with earlier versions of Intel ME, it was possible to reduce the image size to 90 KB but the Intel ME 11 image can only be reduced to 650 KB.


Figure 1. Support for Skylake and later architectures in me_cleaner

Secrets in QResource

Intel allows motherboard manufacturers to set a small number of ME parameters. For this, the company provides hardware manufacturers with special software, including utilities such as Flash Image Tool (FIT) for configuring ME parameters and Flash Programming Tool (FPT) for programming flash memory directly via the built-in SPI controller. These programs are not provided to end users, but they can be easily found on the Internet.


Figure 2. Compressed XML files

From these utilities, you can extract a large number of XML files (detailed description of the process). These files contain a lot of interesting information: the structure of ME firmware and description of the PCH strap, as well as special configuration bits for various subsystems integrated into the PCH chip. One of the fields, called "reserve_hap", drew our attention because there was a comment next to it: "High Assurance Platform (HAP) enable".


Figure 3. PCH strap for High Assurance Platform

Googling did not take long. The second search result said that the name belongs to a trusted platform program linked to the U.S. National Security Agency (NSA). A graphics-rich presentation describing the program can be found here. Our first impulse was to set this bit and see what happens. Anyone with an SPI programmer or access to the Flash Descriptor can do this (on many motherboards, access rights to flash memory regions are set incorrectly).


Figure 4. Status of ME after activating the HAP bit

After the platform is loaded, the MEInfo utility reports a strange status: "Alt Disable Mode." Quick checks showed that ME did not respond to commands or react to requests from the operating system. We decided to figure out how the system goes into this mode and what it means. By that time, we had already analyzed the main part of the BUP module, which is responsible for initialization of the platform and sets the status displayed by MEInfo. In order to understand how BUP works, a more detailed description of the Intel ME software environment is necessary.

Intel ME 11 architecture overview 

Starting with the PCH 100 Series, Intel has completely redesigned the PCH chip. The architecture of embedded microcontrollers was switched from ARCompact by ARC to x86. The Minute IA (MIA) 32-bit microcontroller was chosen as the basis; it is used in Intel Edison microcomputers and SoCs Quark and based on a rather old scalar Intel 486 microprocessor with the addition of a set of instructions (ISA) from the Pentium processor. However, for the PCH, Intel manufactures this core with 22-nm semiconductor technology, making the microcontroller highly energy-efficient. There are three such cores in the new PCH: Management Engine (ME), Integrated Sensors Hub (ISH), and Innovation Engine (IE). The latter two can be enabled or disabled depending on the PCH model and the target platform; the ME core is always enabled.


Figure 5. Three x86 processors in the PCH

Such an overhaul required changing ME software as well. In particular, MINIX was chosen as the basis for the operating system (previously, ThreadX RTOS had been used). Now ME firmware includes a full-fledged operating system with processes, threads, memory manager, hardware bus driver, file system, and many other components. A hardware cryptoprocessor supporting SHA256, AES, RSA, and HMAC is now integrated into ME. User processes access hardware via a local descriptor table (LDT). The address space of a process is also organized through an LDT—it is just part of the global address space of the kernel space whose boundaries are specified in a local descriptor. Therefore, the kernel does not need to switch between the memory of different processes (changing page directories), as compared to Microsoft Windows or Linux, for instance.

Keeping in mind this overview of Intel ME software, now we can examine how the operating system and modules are loaded.

Intel ME loading stages

Loading starts with the ROM program, which is contained in the built-in PCH read-only memory. Unfortunately, no way to read or rewrite this memory is known to the general public. However, one can find pre-release versions of ME firmware on the Internet containing the ROMB (ROM BYPASS) section which, as we can assume, duplicates the functionality of ROM. So by examining such firmware, it is possible to reproduce the basic functionality of the initialization program.

Examining ROMB allows determining the purpose of ROM that is performing hardware initialization (for example, initialization of the SPI controller), verifying the digital signature of the FTPR header, and loading the RBE module located in the flash memory. RBE, in turn, verifies the checksums of the KERNEL, SYSLIB, and BUP modules and hands over control to the kernel entry point.

It should be noted that ROM, RBE, and KERNEL are executed at the zero privilege level (in ring-0) of the MIA kernel.


Figure 6. Verifying integrity of SYSLIB, KERNEL, and BUP in RBE

The first process that the kernel creates is BUP, which runs in its own address space in ring-3. The kernel does not launch any other processes itself; this is done by BUP itself, as well as a separate LOADMGR module, which we will discuss later. The purpose of BUP (BringUP platform) is to initialize the entire hardware environment of the platform (including the processor), perform primary power management functions (for example, starting the platform when the power button is pressed), and start all other ME processes. Therefore, it is certain that the PCH 100 Series or later is physically unable to start without valid ME firmware. Firstly, BUP initializes the power management controller (PMC) and the ICC controller. Secondly, it starts a whole string of processes; some of them are hard-coded (SYNCMAN, PM, VFS), and the others are contained in InitScript (similar to autorun), which is stored in the FTPR volume header and digitally signed.


Figure 7. Starting SYNCMAN and PM

Thus, BUP reads InitScript and starts all processes that conform to the ME startup type and are IBL processes.


Figure 8. Processing InitScript


Figure 9. List of modules with the IBL flag

If a process fails to start, BUP will not start the system. As shown in Figure 9, LOADMGR is the last IBL process on the list. It starts the remaining processes, but unlike BUP, if an error occurs during module startup, LOADMGR will just proceed to the next one.

This means that the first way to "slim down" Intel ME is to remove all modules that do not have the IBL flag in InitScript, which will significantly reduce the firmware size. But our initial task was to find out what happens to ME in HAP mode. For this, let us examine the BUP software model.


Figure 10. Startup of modules in ME

BringUP

If you look closely at how the BUP module works, you can say that a classic finite state machine is implemented inside it. Execution is functionally divided into two components: initialization stages (finite state machine) and execution of service requests of other processes after the system is initialized. The number of initialization stages may vary depending on the platform and SKU (TXE, CSME, SPS, consumer, corporate) but the main stages are common to all versions.

Stage 1

During the initial stage, the sfs internal diagnostic file system (SUSRAM FS, a file system located in non-volatile memory) is created, the configuration is read, and, most importantly, the PMC is queried about what caused the startup: power-on of the platform, restart of the entire platform, ME restart, or waking up from sleep. This stage is called boot flow determination. Subsequent stages in the work of the initialization finite automaton depend on it. In addition, several modes are supported: normal and a set of service modes in which the main ME functionality is disabled (HAP, HMRFPO, TEMP_DISABLE, RECOVERY, SAFE_MODE, FW_UPDATE, and FD_OVERRIDE).

Stage 2

At the next stage, the ICC controller is initialized and the ICC profile (responsible for clock frequencies of the main consumers) is loaded. Boot Guard is initialized and cyclic polling for processor startup confirmation is started.

Stage 3

BUP awaits a message from the PMC confirming that the main processor has started. After that, BUP starts the PMC asynchronous polling cycle for power events (restart or shutdown of the platform) and proceeds to the next stage. If such an event occurs, BUP will perform the requested action between the initialization stages.

Stage 4

At this stage, internal hardware is initialized. Also, BUP starts the heci (a special device designed to receive commands from the BIOS or the operating system) polling cycle for the DID (DRAM Init Done message) from the BIOS. It is this message that allows ME to determine that the main BIOS has initialized RAM and reserved a special region, UMA, for ME, and then proceed to the next stage.

Stage 5

Once the DID is received, BUP—depending on the mode, which is determined by various factors—either starts IBL processes from InitScript (in normal mode) or hangs in a loop, which it can exit only when it receives a message from the PMC, for example as a result of a request to restart or shut down the system.

It is at this stage that we find HAP processing; in this mode, BUP hangs instead of executing InitScript. This means that the remaining sequence of actions in normal mode has nothing to do with HAP and will not be considered. The main thing we would like to note is that in HAP mode, BUP initializes the entire platform (ICC, Boot Guard) but does not start the main ME processes.


Figure 11. Determining HAP mode


Figure 12. Switching ME to Stage 5 causing it to hang


Figure 13. Stage 5

Setting the HAP bit

The aforementioned facts help to reveal the second method of disabling Intel ME:
1. Set the HAP bit.
2. In the CPD section of the FTPR, remove or damage all modules except those required by BUP for startup:
  • RBE
  • KERNEL
  • SYSLIB
  • dBUP
3. Fix the checksum of the CPD header (for more details on the structure of ME firmware, see this paper).
So how can we set the HAP bit? We can use the FIT configuration files and determine the location of the bit in the image, but there is a simpler way. In the ME Kernel section of FIT, you can find a Reserved parameter. This is the particular bit that enables HAP mode.


Figure 14. HAP mode activation bit

HAP and Boot Guard

We also found some code in BUP that, when HAP mode is enabled, sets an additional bit in Boot Guard policies. Unfortunately, we have not succeeded in finding out what this bit controls.


Figure 15. Setting an additional bit for Boot Guard

Support for ME 11 in me_cleaner

While this article was being prepared, the me_cleaner developers updated their utility. Now it also removes all the modules from the images except RBE, KERNEL, SYSLIB, and BUP, but it does not set the HAP bit, which forces ME into TemporaryDisable mode. We were curious to find out what happens with this approach.

We found that deleting partitions with the ME file system results in an error during reading of the cfg_rules file. This file contains a number of different system settings. Among them, as we believe, is the flag that we called "bup_not_temporary_disable". If this flag is not set, the entire subsystem is switched to TemporaryDisable mode, and since the flag is a global variable initialized by zero, the read error is regarded as a configuration requiring disconnection.

We also checked the firmware of server and mobile versions of ME (SPS 4.x and TXE 3.x). In the server version, this flag is always set to 1; in the mobile version, it is ignored. This means that this method will not work in server and mobile versions (Apollo Lake) of ME.


Figure 16. Reading the cfg_rules file

Closing thoughts

So we have found an undocumented PCH strap that can be used to switch on a special mode disabling the main Intel ME functionality at an early stage. We can prove this by the following facts:

  1. Binary analysis of Intel ME firmware, as described in this paper.
  2. If we remove some critical ME modules and enable HAP mode, Intel ME does not crash. This proves that HAP disables ME at an early stage.
  3. We are quite sure that Intel ME is unable to exit this mode because we have not found code capable of doing so in the RBE, KERNEL, and SYSLIB modules.

Similarly, we are sure that the ROM integrated into the PCH is practically the same as ROMB, which also does not contain any code allowing an exit from HAP mode.

Hence HAP protects against vulnerabilities present in all modules except RBE, KERNEL, SYSLIB, ROM, and BUP. However, unfortunately this mode does not protect against exploitation of errors at earlier stages.

Intel representatives have been informed about the details of our research. Their response has confirmed our hypothesis about the connection of the undocumented mode with the High Assurance Platform program. With their permission, we quote Intel's answer below:

Mark/Maxim, 
In response to requests from customers with specialized requirements we sometimes explore the modification or disabling of certain features. In this case, the modifications were made at the request of equipment manufacturers in support of their customer’s evaluation of the US government’s “High Assurance Platform” program.  These modifications underwent a limited validation cycle and are not an officially supported configuration.

We believe that this mechanism is designed to meet a typical requirement of government agencies, which want to reduce the possibility of side-channel leaks. But the main question remains: how does HAP affect Boot Guard? Due to the closed nature of this technology, it is not possible to answer this question yet, but we hope to do so soon.

Mark Ermolov, Maxim Goryachy

A Lisper's first impression of Julia

$
0
0
I have recently looked at Julia, a new programming language developed at MIT that promises to be a dynamic programming language that is suitable for scientific computing with a high-performance implementation. It is an interesting project that heavily borrows from Common Lisp, Dylan, and Scheme, and you can rightfully argue that Julia itself is actually a Lisp dialect. While I wasn’t very impressed with some other recent Lisp dialects (Arc, Clojure), Julia puts a couple of very interesting features on the table. Below is a discussion of the more salient aspects of Julia, as seen from a Common Lispers perspective. It is based on the documentation of the prerelease version 0.3 of Julia.

Julia is closest to Dylan in many regards. It uses a somewhat mainstream syntax rather than s-expressions. Unlike Dylan, you can nevertheless write ‘full’ macros, since macro definitions are implemented in Julia, not some template language, and backquote/quasiquote is integrated with the Julia syntax. Julia is a Lisp-1 (like Scheme or Dylan) rather than a Lisp-2 (like Common Lisp or ISLISP), which makes it necessary to add macro hygiene features. Fortunately, this does not mean you have to deal with the rather painful syntax-case construct of some Scheme dialects, but you can still use far simpler backquote/quasiquote constructions, just with macro hygiene taken care of by default. Julia also allows you to selectively break hygiene. Although I usually strongly prefer the simplicity of Common Lisp’s non-hygienic macro system, the fact that Julia is a Lisp-1 turns macro hygiene into a real problem, so I guess this is a reasonable design.

Julia provides object-oriented programming from the ground up, similar to Dylan. It centers on generic functions rather than classes, where methods are defined outside classes and allow for multiple dispatch, just like in Dylan and Common Lisp. Like Dylan, and unlike Common Lisp, it does not distinguish between functions and generic functions: All functions can have methods, you do not have to make up your mind whether you want methods or plain functions. Unlike in Common Lisp, there are no method combinations, no before/after/around methods, and call-next-method is not directly supported, but has to be done manually. This is probably to simplify method dispatch, maybe to have some performance advantages, though I find it hard to imagine that adding method combinations would make things substantially worse.

You still need a class hierarchy to drive method dispatch. Unlike in Common Lisp, there is no multiple inheritance, only single inheritance. In fact, there is actually no real inheritance, because in Julia, only leaf classes of the class hierarchy are allowed to define slots/fields. All superclasses are required to be “abstract,” without any slot definitions. Also, Julia classes cannot be redefined at runtime, so in fact Julia classes are much closer to Common Lisp’s structured types rather than classes.

Julia’s execution model is based on dynamic compilation. As a user, you don’t have to compile your code at all, source code is just compiled on the fly (similar as in Clozure Common Lisp). Julia inlines functions on the fly, including generic functions, and can de-optimize when function definitions change at runtime. This is more flexible than in Common Lisp, where inlined functions can get out of sync with their potentially changed definitions. Also, while the Common Lisp specification does not say anything with regard to being able to inline generic functions or not, there are aspects in the CLOS MOP specification that prevent generic functions from being inlined, at least for user-defined extensions of generic functions. Julia definitely seems more “modern” here.

In Julia, there is no distinction between variable binding and variable assignment. If you assign to a variable that has not been used before in the same lexical environment, it is silently introduced. In Common Lisp/Scheme/Dylan, there is a distinction between ‘let forms that introduce variable bindings, and assignments (setq/setf/set!) that perform assignments. I’m highly skeptical of Julia’s design here, because this potentially leads to bugs that are hard to find: A simple typo in your source code just may go unnoticed.

In Julia, all variables are lexically scoped (except for some seemingly quirky scoping semantics for global variables, see below). There are no special / dynamically scoped variables in Julia, which is a major omission in my book. Some academics don’t like special scoping, but their presence in Common Lisp is incredibly useful in practice, especially but not only for multi-threading!

Julia’s default representation for integers is either 32-bit or 64-bit integers, depending on the target architecture, which silently wrap around. Julia also supports “BigInts” that can be arbitrarily large, but you have to ask for them explicitly. In Common Lisp, integers are by default arbitrarily large, which I think is an advantage. Due to type tagging in Common Lisp implementations, even “big” integers are typically allocated as immediate values rather than on the heap when they fall into the “fixnum” range. I didn’t find anything in the Julia documentation that discusses this aspect of “BigInt.”

In Julia, all mathematical operations are generic functions and can be extended by user-defined methods. This is a strong advantage for Julia. In Common Lisp, mathematical operations are “plain” functions which cannot be extended. Due to some aspects in the design of Common Lisp’s generic functions, it’s hard to inline (or open-code) them, which is why for performance reasons, it’s better to express mathematical (and other such performance-critical functions) as “plain” functions. Apart from that, the support for number types seems to be on par between Julia and Common Lisp (complex types, rational numbers, floating point numbers, etc.)

In Julia, strings are unicode strings by default. My knowledge about unicode support in Common Lisp implementations is limited, so I cannot really make any comparisons here. One interesting aspect in Julia’s string support is that there can be user-defined macros to parse them and construct other syntactic entities out of them. This feels somewhat similar to read macros in Common Lisp, although with a slightly different scope.

Julia’s support for functions is similar to Common Lisp: They can be first class and anonymous (lambda expressions). There are varargs (&rest), optional and keyword arguments. In Common Lisp, optional and keyword arguments cannot be dispatched on in methods. In Julia, optional arguments can be dispatched on, but not keywords. (This is a pity, dispatch on keyword arguments would be very interesting, and is something I wanted to add as part of Closer to MOP for a long time!)

Julia’s support for control flow is much more limited than in Common Lisp. There are equivalents for progn, cond/if, for and while loops. Unlike Common Lisp, there is no support for a full loop facility, or even for a simple goto construct. Common Lisp clearly wins here. Julia’s support for exception handling is also limited: No handler-bind, no restarts, unlike in Common Lisp, which are also really useful features.

Julia’s type system has some interesting differences to Common Lisp: There is a distinction between mutable and immutable classes. Immutable classes disallow any side effects on their fields. This seems to be primarily directed at enabling stack allocation as an optimization. In Common Lisp, you would use dynamic extent declarations when allocating structs (or other data types) to achieve similar performance improvements. I’m not sure why it would matter that the fields need to be read-only for such an optimization, but if this covers most cases, maybe this is good enough.

Julia allows for returning and receiving multiple values from function calls, similar to Common Lisp. This is a feature I like a lot in Common Lisp, so I’m happy it’s also in Julia. In Julia, this is achieved by an explicit tuple type representation which doesn’t exist in this form in Common Lisp. In Lisp, you could also return/receive lists instead of multiple values, which would correspond to this kind of tuple type, but lists add an additional performance overhead, which multiple values and, presumably, tuples in Julia don’t have.

Julia supports parametric types. I don’t see at the moment why this is relevant. You could achieve similar functionality also with some macrology. Maybe I’m missing something here.

There is a whole section on constructors (make-instance / make-struct) in the Julia manual. This makes me suspicious, this should be an easier topic.

Julia has a module system. It supports export and automatic import of explicitly exported identifiers. You can also still access non-exported identifiers with additional syntax. This is good, because module designers may not always perfectly anticipate what users actually need to access. Common Lisp’s package system supports a similar distinction between external and internal definitions that can be accessed in different ways. I slightly prefer Common Lisp’s ability to use the package name as a prefix even for explicitly exported definitions. There is no feature in Julia to rename imported identifiers, which is something where Common Lisp’s support for explicit package name prefixes can come in very handy. I would like to see something like Oberon’s support for renaming identifiers on import in some Lisp dialect someday, because I believe that is the most complete solution for dealing with potential name conflicts.

In terms of meta-programming, apart from macros, Julia also supports (top-level) eval, like Common Lisp. Julia’s support for “reflection” is much weaker than Common Lisp’s CLOS MOP: You can only inspect types at runtime, but you cannot modify them (and language designers should stop calling something “reflection” that is clearly just “introspection”).

Both Julia and Common Lisp support multi-dimensional arrays. Common Lisp’s arrays are in row-major order, starting at index 0 in every dimension. Julia’s arrays are column-major order, starting at index 1 in every dimension. Julia’s support for multi-dimensional arrays is a library feature, whereas Common Lisp’s support is built into the language. Julia supports both dense and sparse matrices, where Common Lisp supports only dense matrices out of the box.

There are a lot of libraries that ship with Julia targeted at scientific computing.

Julia supports parallel programming with a model built on top of message passing: If you want to run parallel algorithms, you essentially start several instances of Julia that communicate with each other. The model does not support shared memory, and there is no multi-threading within a Julia instance (although there seem to be discussions among the Julia designers to add this in the future). The model is built on top of MPI as an implementation backend. However, the actual programming model supports single-sided communication: You can ask a function to be executed in some other Julia worker process, and can later synchronize with it to fetch results. On top of that, there are some high-level constructs provided as library features, such parallel maps and loops. Julia’s message passing model ensures that within a Julia instance, only one task is executed at a time, so there is yet no need to provide low-level synchronization mechanisms, such as locks or atomic operations. The lack of shared-memory parallelism is problematic because many parallel algorithms that are very easy to express with shared memory become quite complicated in a distributed memory setting. On the other hand, Julia’s model easily supports true distributed programming: You can configure Julia to run several instances across a cluster, and use them in a quite straightforward way: substantially easier than what you have to do with, say, MPI, and much closer with regard to ease of use to modern PGAS languages like Chapel or X10.

The ANSI specification for Common Lisp does not mention anything about multi-threading or parallel programming at all, but many Common Lisp implementations add support for shared-memory parallelism. I will not go into details here, but let me just briefly state that, for example, the LispWorks implementation of Common Lisp provides excellent support for symmetric multiprocessing that is at least on par with what you can find in most other language implementations in terms of parallel programming support. However, unfortunately, support for true distributed memory models seems almost non-existent in Common Lisp, apart for some basic support for MPI in a library that was maintained only for a very short period of time a couple of years ago. Julia looks like a good source of inspiration for adding such features to Common Lisp.

However, one aspect of Julia’s message passing approach seems problematic, as far as I can tell: You can pass closures between different instances of Julia, but it’s not clear how free variables in a lambda expression are bound. It seems that lexical variables are bound and serialized to another process, but global variables are not serialized and need to be present in any presence that may execute the closure. Experiments with adding side effects to free variables in lambda expressions that are passed to other processes seem to suggest that the semantics of this combination of features are unpredictable. At least, I have not been able to figure out what happens when — sometimes variables seem to be updated at the sender’s side, sometimes not — and I didn’t find a discussion of this topic in the Julia manual.

Anyway, as you can tell, there are a lot of interesting features in Julia, and it’s definitely worth a try.

Where did wealthy inventor live in 1991? California’s taxman wants to know

$
0
0

A California tax board is scheduled this week to finally resolve a 24-year dispute that could blow a hole in the state budget.

The Board of Equalization will decide whether former Southern California inventor Gilbert Hyatt was a La Palma resident when he started cashing in on the proceeds from a lucrative microprocessor patent he received in 1990.

Hyatt maintains he had moved to Las Vegas by the time most of the money started rolling in; state tax collectors contend he was a California resident for longer than he admits.

If Hyatt wins, the state may have to pay him tens of millions of dollars in legal fees he’s accumulated since auditors at the Franchise Tax Board began investigating him in 1993. H.D. Palmer, spokesman for the Department of Finance, said state officials are watching the case because of its potential to affect the general fund.

If the state wins, Hyatt would be on the hook for at least $13.3 million in taxes and penalties from 1991 and 1992. At past court appearances, the state has argued that Hyatt owes more than $55 million when interest is tacked on to those initial charges.

The saga could end on Tuesday if the Board of Equalization, an elected tax board that has authority over personal income tax complaints, sides with Hyatt, now approaching 80.

The Franchise Tax Board, which conducted the audits that determined Hyatt failed to report income he earned in California, cannot appeal decisions by the Board of Equalization. If Hyatt loses, he’ll be able to pursue an appeal in civil court. In fact, he has a case moving forward at the U.S. 9th Circuit Court of Appeals.

But the clock is ticking on the Board of Equalization.

In January, it’ll lose most of its authority as California’s tax court and be replaced by a new Office of Tax Appeals. The new office will be staffed with appointed administrative law judges instead of the elected officials who now preside over tax disputes.

That means any delay this week could push the long-running case into the new tax appeal system lawmakers created in June when they voted to strip the Board of Equalization of most of responsibilities after a series of scandals suggested it had misused public resources and failed to properly allocate taxes among different government departments.

Board of Equalization member George Runner, who opposed the law that shrank his agency’s authority, said business owners like Hyatt and other companies are better off having their cases considered by the elected representatives.

“The ability to take this to a group of unbiased elected officials is better than taking it to a group of state employees who in the long run benefit from a decision for the state,” Runner said.

Hyatt’s high stakes case has twice reached the U.S. Supreme Court. Hyatt once won a judgment against California tax collectors that would have compelled the state to pay him $490 million, but the most recent Supreme Court case in 2016 capped the payout at $50,000. That lawsuit centered on what a Nevada jury considered to be heavy-handed tactics by Franchise Tax Board investigators who dug through Hyatt’s trash and scared off his potential business partners.

The Franchise Tax Board has already spent $25 million trying to collect the money while defending itself from Hyatt’s lawsuits, department spokesman Jacob Roper said.

“This is a well-known case, well documented,” Runner said. “It’s promoted and looked at as a very complex case, but in the end, it’s all about residency. Where did this individual live?”

Create Page Layout Visualizations in R

$
0
0

README.md

ggpage is a package to create pagestyled visualizations of text based data. It uses ggplot2 and final returns are ggplot2 objects.

Installation

You can install ggpage from github with:

# install.packages("devtools")devtools::install_github("EmilHvitfeldt/ggpage")

Example

The package includes The Tinder-box by H.C. Andersen for examples.

library(ggpage)

head(tinderbox, 10)## # A tibble: 10 x 2##                                                                           text##                                                                          <chr>##  1 "A soldier came marching along the high road: \"Left, right - left, right.\##  2 had his knapsack on his back, and a sword at his side; he had been to the w##  3 and was now returning home. As he walked on, he met a very frightful-lookin##  4 witch in the road. Her under-lip hung quite down on her breast, and she sto##  5 "and said, \"Good evening, soldier; you have a very fine sword, and a large##  6 knapsack, and you are a real soldier; so you shall have as much money as ev##  7                                                               "you like.\""##  8                               "\"Thank you, old witch,\" said the soldier."##  9 "\"Do you see that large tree,\" said the witch, pointing to a tree which s## 10 "beside them. \"Well, it is quite hollow inside, and you must climb to the ## # ... with 1 more variables: book <chr>

The basic workflow with ggpage is using either

  • ggpage_quick for a quick one function call plot or,
  • combining ggpage_build and ggpage_plot to do analysis (NLP for example) before the final plot is produced.

For a simple demontration we apply ggpage_quick to our tinderbox object.

# Also pipeable# tinderbox %>% ggpage_quick()

The same result would be achived by using

tinderbox %>% 
  ggpage_build() %>% 
  ggpage_plot()

But this approach allows us to introduce more code between ggpage_build and ggpage_plot giving us multiple more ways to enhance the plots

tinderbox %>%
  ggpage_build() %>%
  mutate(long_word=stringr::str_length(word) >8) %>%
  ggpage_plot(aes(fill=long_word)) +
  labs(title="Longer words throughout The Tinder-box") +
  scale_fill_manual(values= c("grey70", "blue"),labels= c("8 or less", "9 or more"),name="Word length")

And it will nicely with other tidyverse packages

library(ggpage)
library(purrr)
library(gganimate)prebuild<-tinderbox %>%
  ggpage_build() %>%
  left_join(get_sentiments("afinn"), by="word") midbuild<- map_df(.x=0:50*10+1,~prebuild %>% 
                    mutate(score= ifelse(is.na(score), 0, score), score_smooth=zoo::rollmean(score, .x, 0),score_smooth=score_smooth/ max(score_smooth),rolls= .x))p<-midbuild %>%
  ggpage_plot(aes(fill=score_smooth, frame=rolls)) +
  scale_fill_gradient2(low="red", high="blue", mid="grey", midpoint=0) +
  guides(fill="none") +
  labs(title="Smoothed sentiment of The Tinder-box, rolling average of")

gganimate(p, interval= .2)

Inside continues to bet on email, the “largest social network”

$
0
0

Email, not Facebook, is the largest social network.

That’s the view held by the team behind Inside, a company focused entirely on growing and monetizing its motley collection of newsletters. Closing in on a year, the company founded by serial entrepreneur and investor Jason Calcanis— known for Weblogs Inc. and his early investments in Uber, among other things — has around 300,000 subscribers across 30 newsletters, and average open rates just above 40 percent and click rate of 10 percent across all the newsletters. The collection includes the Jason Calacanis newsletter, a general interest daily news briefing, and quirkier offerings like Inside Space (on outer space and travel), Inside Trump (on the president of the United States), Inside Streaming (for “cord cutters”), and Inside Beer (for sellers or brewers).

“We looked at the way news is consumed today on social media, with Facebook being the number place where all of that happens. A lot of publishers are talking to Facebook right now, but none of them know what Facebook is going to look like — it’s a platform controlled by a public company that has a lot of shareholders and other forces they need to answer to,” Austin Smith, Inside’s general manager, said. “Email will never be controlled in that way, and people are just as engaged with their inboxes as they have always been.”

It’s recently launched its paid subscription options for the newsletters at $10 a month for premium access to one newsletter, or $25 for premium access to an unlimited number of Inside verticals — a paid subscription removes ads and gets you…well, more emails. The more popular newsletters in the network average a “couple of hundred” paying subscribers; the smaller newsletters have around 50.

The newsletters also take ads: Either a company pays for a monthly sponsorship and gets a logo and callout in the newsletter, in addition to access to an Inside premium subscriptions bundle for their company, or advertisers can pay for more one-off native ads inside a newsletter (Inside doesn’t have an ad sales team so isn’t “super aggressive” about running them). Between ads and premium subscriptions, the company is not yet profitable (that’s “within eyesight,” it’s said) and may or may not be looking to raise funding in the meantime (“no comment”). Early on it had focused on metrics like opens-per-week, but with the rollout of subscription offerings, “enough readers are paying us so we don’t necessarily need to focus on volume as much as if we were only ad-supported,” Smith said.

Inside staffers float ideas for new topical newsletters to join the family, and readers “vote” by signing up to the potential newsletter with their emails; Inside will assign a writer and start a newsletter for ideas that collect at least 2,000 addresses (or attract a major advertiser to sponsor it). Some of the newer Inside newsletters such as Inside Trump, Inside Space, Inside Internet of Things, and Inside Beer all launched after hitting that minimum. Inside Bitcoin, for instance, went from the 2,000 pre-subscribers it had before anything launched to 7,000 subscribers a few days later.

“We found before we had the pre-subscribe feature, the most challenging thing for us was to get the first thousand, two thousand subscribers,” Smith said. It’s hard to get that word-of-mouth going when there’s nothing to build off of, and word of mouth is best way these things grow.”

Most of the company’s five full-time staffers and around 10 freelancers currently putting together all of Inside’s newsletters are tech-oriented generalists who have to cross multiple disparate beats. The team is still trying to figure out how much — and what — to offer premium subscribers, the right mix of original versus curation/aggregation, and the volume of new newsletters the team can handle. Several of the newsletters, such as the ones on Amazon and VR/AR industries, come out daily. News out of the Trump administration is so frequent that the twice-weekly Inside Trump digest has issued breaking alerts. Right now, Inside newsletters average about 60 to 70 curated content from other sources and up to around 40 percent original content, according to Kim Lyons, managing editor at Inside.

“Our current mix is working, though I’d like to get us to even more original reporting. But I’m interested more in doing the deeper dives rather than the breaking stuff, since there are a lot of news outlets that do that really well already, and trying to duplicate that with the size of the staff we have is not practical,” Lyons said. “Our sense is that we’re not writing for a completely beginner audience. What’s interesting to subscribers is, which drone companies are doing new things, what are the new regulations everything in this space is struggling with right now, how is that administration policy change going to affect my business?” At the moment, Inside’s audience is about 80 percent U.S.-based and mostly concentrated in the Bay Area, which makes sense given the industries it covers.

Premium offerings vary across newsletters. For some, a premium subscription comes with a occasional special research reports (e.g., Inside AI, written by angel investor in the space Rob May, compiles a monthly one). For others, it might mean one original article blurred out in a newsletter. (Inside’s newsletter CMS is built to handle toggling between paid-for and free content.)

“We try to make sure we don’t just have news of the day but news that you may have missed and is not getting attention elsewhere, and will take time to get our hands on an important issue that people are still only peripherally aware of,” Lyons said. “The most pushback we’ve had is from non-premium readers when they see an article they can’t read inside their newsletter, which we always knew was going to annoy some people who just don’t want to pay.”

“It’s still a process, building all this. But it’s super cool though to see readers actually do want to pay for it,” Smith said.


Investor Alert: Public Companies Making ICO-Related Claims

$
0
0

The SEC’s Office of Investor Education and Advocacy is warning investors about potential scams involving stock of companies claiming to be related to, or asserting they are engaging in, Initial Coin Offerings (or ICOs).  Fraudsters often try to use the lure of new and emerging technologies to convince potential victims to invest their money in scams.  These frauds include “pump-and-dump” and market manipulation schemes involving publicly traded companies that claim to provide exposure to these new technologies. 

Recent Trading Suspensions

Developers, businesses, and individuals increasingly are using ICOs – also called coin or token launches or sales – to raise capital.  There has been media attention regarding this form of capital raising.  While these activities may provide fair and lawful investment opportunities, there may be situations in which companies are publicly announcing ICO or coin/token related events to affect the price of the company’s common stock.

The SEC may suspend trading in a stock when the SEC is of the opinion that a suspension is required to protect investors and the public interest.  Circumstances that might lead to a trading suspension include:

  • A lack of current, accurate, or adequate information about the company – for example, when a company has not filed any periodic reports for an extended period;
  • Questions about the accuracy of publicly available information, including in company press releases and reports, about the company’s current operational status and financial condition; or
  • Questions about trading in the stock, including trading by insiders, potential market manipulation, and the ability to clear and settle transactions in the stock.

The SEC recently issued several trading suspensions on the common stock of certain issuers who made claims regarding their investments in ICOs or touted coin/token related news.  The companies affected by trading suspensions include First Bitcoin Capital Corp., CIAO Group, Strategic Global, and Sunshine Capital.  

Investors should be very cautious in considering an investment in a stock following a trading suspension.  A trading suspension is one warning sign of possible microcap fraud (microcap stocks, some of which are penny stocks and/or nanocap stocks, tend to be low priced and trade in low volumes).  If current, reliable information about a company and its stock is not available, investors should consider seriously the risk of making an investment in the company’s stock.  For more on trading suspensions, see our Investor Bulletin: Trading in Stock after an SEC Trading Suspension – Be Aware of the Risks.

Pump-and-Dump and Market Manipulations

One way fraudsters seek to profit is by engaging in market manipulation, such as by spreading false and misleading information about a company (typically microcap stocks) to affect the stock’s share price.  They may spread stock rumors in different ways, including on company websites, press releases, email spam, and posts on social media, online bulletin boards, and chat rooms.  The false or misleading rumors may be positive or negative.  

For example, “pump-and-dump” schemes involve the effort to manipulate a stock’s share price or trading volume by touting the company’s stock through false and misleading statements to the marketplace.  Pump-and-dump schemes often occur on the Internet where it is common to see messages posted that urge readers to buy a stock quickly or to sell before the price goes down, or a promoter will call using the same sort of pitch.  In reality, the author of the messages may be a company insider or paid promoter who stands to gain by selling their shares after the stock price is “pumped” up by the buying frenzy they create.  Once these fraudsters “dump” their shares for a profit and stop hyping the stock, the price typically falls, and investors lose their money.  Learn more about these schemes in our Updated Investor Alert: Fraudulent Stock Promotions.

Tips for Investors

  • Always research a company before buying its stock, especially following a trading suspension.  Consider the company’s finances, organization, and business prospects. This type of information often is included in filings that a company makes with the SEC, which are available for free and can be found in the Commission’s EDGAR filing system.
  • Some companies are not required to file reports with the SEC. These are known as “non-reporting” companies. Investors should be aware of the risks of trading the stock of such companies, as there may not be current and accurate information that would allow investors to make an informed investment decision.
  • Investors should also do their own research and be aware that information from online blogs, social networking sites, and even a company’s own website may be inaccurate and potentially intentionally misleading.
  • Be especially cautious regarding stock promotions, including related to new technologies such as ICOs.  Look out for these warning signs of possible ICO-related fraud:
    • Company that has common stock trading claims that its ICO is “SEC-compliant” without explaining how the offering is in compliance with the securities laws; or
    • Company that has common stock trading also purports to raise capital through an ICO or take on ICO-related business described in vague or nonsensical terms or using undefined technical or legal jargon.
  • Look out for these warning signs of possible microcap fraud:
    • SEC suspended public trading of the security or other securities promoted by the same promoter;
    • Increase in stock price or trading volume happening at the same time as the promotional activity;
    • Press releases or promotional activity announcing events that ultimately do not happen (e.g., multiple announcements of preliminary deals or agreements; announcements of deals with unnamed partners; announcements using hyperbolic language);
    • Company has no real business operations (few assets, or minimal gross revenues);
    • Company issues a lot of shares without a corresponding increase in the company’s assets; and
    • Frequent changes in company name, management, or type of business.

Additional Resources

Investor Bulletin:  Initial Coin Offerings

Updated Investor Alert: Social Media and Investing -- Stock Rumors

Investor Alert: Be Aware of Stock Recommendations On Investment Research Websites

Report possible securities fraud to the SECReport a problem or ask the SEC a question.  Visit Investor.gov, the SEC’s website for individual investors.


The Office of Investor Education and Advocacy has provided this information as a service to investors.  It is neither a legal interpretation nor a statement of SEC policy.  If you have questions concerning the meaning or application of a particular law or rule, please consult with an attorney who specializes in securities law.

Uber's New CEO

$
0
0

In the last seven months, Uber has endured:

  • The #DeleteUber campaign
  • The fallout from Susan Fowler Rigetti’s blog post, including the Holder investigation and report
  • A lawsuit from Waymo alleging the theft of intellectual property
  • Multiple revelations of past misconduct, including Greyball, which has prompted an investigation from the Department of Justice
  • The forced resignation of founder and CEO Travis Kalanick, and then, earlier this month, an explosive lawsuit against Kalanick from the company’s biggest investor

And, at the end of all that drama — and this is only a partial list (as of the time of this writing Techmeme has had 280 posts about Uber in 2017) — Dara Khosrowshahi, the very successful, very stable, and very well-compensated CEO of Expedia, jumped at the opportunity to take the helm, beating out GE CEO Jeffrey Immelt and and Hewlett Packard Enterprise CEO Meg Whitman for the honor…it’s an honor, right?

In fact, I think Khosrowshahi is a great choice for CEO, and understanding why goes a long ways towards explaining why the Uber job remains an attractive one, even after the worst seven-month stretch in startup history.

Aggregation

Most news stories are making the obvious point that Khosrowshahi is qualified because he is a CEO for a tech company in the travel industry. What is even more relevant, though, is that Khosrowshahi is the CEO of an aggregator. Expedia and other online travel agents (and their associated stables of sites) have built businesses by focusing on discovery: instead of having to find hotels directly, a customer can go to Expedia and simply search for a location.

This, by extension, draws supply; while hotels may complain about having to pay OTA fees, the truth is the volume driven by the OTAs is well worth the cost — and Khosrowshahi has been willing to remind hotels of that fact. Indeed, Khosrowshahi had to learn just how powerful the effect of aggregation on suppliers can be. In an oral history on Skift about online travel, Khosrowshahi (who was then CFO of Expedia controlling-shareholder IAC/Interactive) recounted how it was that the company passed on Booking.com:

I think the Expedia team had taken a look at Booking.com and Active [Hotels, acquired by Priceline in 2005 and 2004, respectively] and again had passed. And, I think it was because we were attached to the merchant model and we were attached to high margins at the time.

The merchant model Khosrowshahi is referring to is where an OTA buys rooms at a wholesale rate and then sells them to end users; the advantage is a bigger margin on the sale of a room plus a positive cash cycle: the customer pays immediately but the OTA doesn’t pay the hotel until the stay occurs. The disadvantage, though, is that it requires making deals with hotels to buy rooms. Former Priceline CEO Jeffery Boyd, in the same oral history, explained what made Booking.com unique:

What the guys at Booking.com did the best really was that they understood how to basically address the entire market and not just the big chain hotels, the Accors and Marriotts and Hiltons in London, but ultimately leads to find demand for and service hotels in all countries, small towns, small hotels.

Booking.com used the agency model: instead of selling rooms at a markup Booking collected a commission on the rooms booked through its service. This meant significantly lower margins, no money until the stay occurred, and even then collection required some sort of enforcement mechanism.

The payoff, though, was tremendous: Booking.com, unlike Expedia, had minimal transactions costs for customers and suppliers. Hotels could sign up for Booking.com on their own instead of having to negotiate a deal, which meant it was Booking.com that led the industry in growth for many years; the full payoff of owning discovery in a world of drastically reduced distribution and transaction costs comes not from extracting margin from a limited set of suppliers, but rather from expanding the market to the greatest extent possible, creating the conditions for a virtuous cycle of more customers -> more suppliers -> more customers.

To Khosrowshahi’s credit he learned this lesson: Expedia was in big trouble in the years after he took over, and one of the changes Khosrowshahi made was to add the agency model to Expedia’s properties (Expedia now has a hybrid approach). It is a lesson that will serve him well as Uber’s CEO; the fundamental mistake made in so much Uber analysis comes from believing that drivers are the key to the model. For example, there was a very popular piece of analysis some months ago premised on evaluating the cost of driving for Uber relative to driving for a traditional cab company. It was a classic example of getting the facts right and missing the point.

In fact, what makes Uber so valuable — and still so attractive, despite all of the recent troubles — is its position with riders. The more riders Uber has, the more drivers it will attract, even if the economics are worse relative to other services: driving at a worse rate is better than not driving at a better one.

To that end, Uber’s strength — and its sky-high valuation — comes from the company’s ability to acquire customers cheaply thanks to a combination of the service’s usefulness and the effects of aggregation theory: as the company acquires users (and as users increases their usage) Uber attracts more drivers, which makes the service better, which makes it easier to acquire marginal users (not by lowering the price but rather by offering a better service for the same price). The single biggest factor that differentiates multi-billion dollar companies is a scalable advantage in customer acquisition costs; Uber has that.

Indeed, Uber’s position is in this respect stronger than Expedia’s: Expedia is an aggregator of sorts, but a huge portion of its audience in fact starts with a Google search, which means Expedia must pay Google a huge “tax”, in the form of search ads, to acquire users. Moreover, Expedia lives in constant fear that Google is simply going to fill the OTA role directly; that is why Expedia was a complainant in the EU’s antitrust case against Google. An even more pressing concern is Airbnb, which is forging its own customer relationship and own supply, and could (should?) move into hotel booking as well.

Finance

Expedia’s experience with Google as intermediary has its advantages: OTAs like Expedia and Priceline are, by necessity, the absolute best at testing and measuring the return on investment of outbound marketing, particular search advertising. That specific skill may not be particularly useful to Uber, but what the company certainly needs is a far more disciplined and exact approach to its accounting.

A few months ago, when Uber lost its head of finance Gautam Gupta, The Information reported that:

Financial-performance data tools that Uber executives use for internal purposes have a long way to go, according to two people who have been briefed about the issue. For instance, Uber until recently didn’t have a way to accurately calculate the amount in bonuses that Uber paid to drivers in, say, the past week.

As I noted in a Daily Update at the time, this is staggering: Uber cannot measure the “single most important factor in [its] profitability” on something approaching a real-time basis. Moreover, as I wrote then:

The implication of this lack of tracking is that Uber may not have a clear picture as to what its unit costs are; as I noted in a Daily Update last year about Uber’s unit economics, driver bonuses based on meeting a quota of rides in a specific time period are absolutely variable costs that should be allocated to a unit cost calculation. But, if Uber doesn’t even know what those costs are in anything approaching real time, how can it really know what its unit costs are?

No wonder Benchmark, the investor that is suing Kalanick, listed the lack of a CFO as a reason for its lawsuit. And in that light, Khosrowshahi’s finance background is an asset, not a liability. Nothing is more important for Uber than getting its books straight, because I suspect the company’s tactics might change as well. From that Daily Update:

It is worrisome that these bonuses are the key to profitability; I have long argued that Uber wins not by monopolizing drivers (i.e. supply) but by monopolizing riders (i.e. demand). And, optimizing for demand would suggest giving drivers a bigger cut of each ride such that marginal drivers (i.e. those that aren’t in a position to earn those volume bonuses) are encouraged to come on to the network and improve liquidity. Of course, higher driver payouts quite obviously impact unit economics; if bonuses, at least in Uber’s accounting, do not, then its easy to see how a suboptimal decision that favors bonuses over higher payouts could result. Accounting matters!

In other words, I think that Uber’s use of the bonus model with drivers has the whiffs of Expedia using a merchant model: it makes sense in the short term (in this case, monopolizing the time of professional drivers such that they can’t drive for the competition) but it ignores the long term value of having less friction for suppliers to come on board (that is, the part time drivers that overwhelmingly favor Lyft). Khosrowshahi’s painful lesson with Booking.com may be an advantage here as well.

Turnarounds

I noted that Expedia was in trouble at the beginning of Khosrowshahi’s tenure; in fact, the company’s situation deteriorated over Khosrowshahi’s first few years, culminating in a $2.52 billion loss for 2008. To be fair the biggest part of that loss was the write-down of intangible assets layered on top of the Great Recession, but the truth was that Expedia had been slumping for a long time.

In response Khosrowshahi did something that may have seemed quite risky: instead of trying to apply a quick fix to the business, he led a complete rebuild of the underlying platform that powered Expedia and its various house brands. This new platform not only enabled the shift to the agency model noted above, but dramatically improved the company’s ability to test and iterate its offering. Moreover, because the platform was designed to work with multiple brands, it set Expedia up for its recent acquisition binge, including Orbitz and HomeAway; critics say the company has bought growth, I say that owning more customer touchpoints, provided you can execute against them, is exactly what an aggregator should be doing.

The deeper takeaway, though, is that Khosrowshahi has demonstrated the patience and resolve to fix problems at their root. In the case of Uber, the business may be in better shape than Expedia’s was (pending the fixing of finance, of course), but as this year has made clear the culture needs a fundamental reworking, not simply a fresh coat of paint. Khosrowshahi seems like an ideal candidate to take on the problem at a fundamental level, and has already shown at Expedia that he is willing to walk the walk on issues of sexism in particular.


It is easy to mock Uber and the ridiculous CEO selection process that resulted in Khosrowshahi getting the job. Even the final selection process itself was a joke: in the span of 24 hours the presumed favorite shifted from Immelt to Whitman to the surprise selection of Khosrowshahi, with Uber reporters literally changing their stories by the minute as board members leaked like sieves in an attempt to rally public opinion to their sides.1 Without question Uber has been horrifically served by its board of directors — all of them.

And yet, the company has landed on a candidate that I am quite enthused about, and that, I think, is a reminder of just why Uber is so compelling. So many tech startups blather on about changing the world; Uber actually is, for the better. To that end, I would argue that one of Kalanick’s greatest failings was in his inability to sell Uber: the company offers a compelling service for riders, an economically attractive one for drivers (who drive by choice), and makes the cities within which it operates better. That the company has managed to become a pariah is the most powerful testament there is to Kalanick’s failure as CEO.

To that end I hope Kalanick and the other members of the board truly give Khosrowshahi the space he needs to rework Uber’s culture, finances, strategy, and image. The fact of the matter is that Uber’s missteps have already cost it much of its global ambitions; Kalanick in particular needs to give the space for Khosrowshahi to aggregate the opportunity that remains.

  1. As an aside, Immelt would have been a terrible choice: he has no relevant experience, particularly given his job at an old-line company with zero experience in aggregation effects. Whitman, on the other hand, pioneered the aggregation model at Ebay; however, because of Ebay it seems clear that Whitman was closely aligned with Benchmark, which may have made board dynamics with Kalanick untenable. Moreover, Whitman’s experience at HP-E isn’t really relevant at all []

How rare earth metals rose from obscurity

$
0
0
[+]Enlarge
Five piles of rare earth powders.

Rare-earth oxides (clockwise from top center): praseodymium, cerium, lanthanum, neodymium, samarium, and gadolinium.

Credit: Peggy Greb/USDA/Science Source

In 1965, this message appeared on a Holiday Inn sign in Ames, Iowa, to greet the attendees of the 5th Rare Earth Research Conference (RERC). Rare-earth chemistry was at a fulcrum point in its history. Previously, during World War II, chemists working in Ames at Iowa State University had played a critical role in rare-earth technology. As part of the Manhattan Project in 1942, the researchers developed methods to remove traces of rare-earth metals from the uranium used to create the first nuclear chain reaction and to make the first nuclear bombs.

In brief

The rare earths, a collection of 17 elements including the lanthanides—lanthanum to lutetium—along with scandium and yttrium, have become indispensable components in many essential technologies of modern life, including smart phones, LEDs, and medical imaging. But not much was known about rare-earth chemistry until the 1960s. Since then, researchers have uncovered the elements’ abundant magnetic, luminescent, electrochemical, and other properties. The Rare Earth Research Conference, held recently in Ames, Iowa, brought together researchers who discussed the evolution of rare-earth chemistry, new research trends, and the need for sound natural resource management to ensure their sustainable use for future technologies.

Not much was known about the chemistry of the rare earths in the 1940s, or even by the 1960s. This group of 17 elements, which include the lanthanides—lanthanum to lutetium—along with scandium and yttrium, seemed to consist of fairly unreactive metals that all behaved similarly. Most of the research and development involving the elements was metallurgical, not chemical. Until 1965, the major applications for the rare earths included using mixtures of rare-earth oxides for polishing lenses and mirrors, using cerium and lanthanum oxides as promoters in zeolite catalysts for petroleum refining, and using “mischmetal” rare-earth alloys with iron as flints for lighters.

Flash forward to this past June, and rare earthers were back in Ames for the first time since 1965, for the 28th RERC. The Holiday Inn sign is long gone from the still-cozy midwestern college town, and the world of rare earths has changed.

In 1965, the “counterculture revolution” was under way, and many of the world’s young adults were protesting in favor of peace over nuclear power and the nuclear weapons of the Cold War. At the same time, they were falling in love with modern conveniences, driving demand for microwave ovens, early versions of personal computers and video games, and televisions. Coincidentally, 1965 witnessed the launch of the first major commercial use for a highly purified rare-earth material: Europium-doped yttrium salts began to be used as red phosphors in the picture tube of color television sets.

Now 52 years on, the internet rules nearly everyone’s lives, and handheld devices have greater capabilities than those early bulky computers and televisions. Much of the technology evolution since the 5th RERC has come about as researchers discovered that rare earths have abundant magnetic, luminescent, electrochemical, and thermal properties that have made possible smart phones, electric cars, light-emitting diodes, wind turbines, medical imaging, and more. This year’s RERC served as a grand review of this rare-earth chemistry, highlighting how adding a dash of rare-earth metals to materials is like adding a bit of magic fairy dust—the metals help everything perform better.

“The remarkable properties of the rare earths have long engaged the imagination of the scientific community,” said rare earther Ana de Bettencourt-Dias of the University of Nevada, Reno, one of this year’s conference organizers. She marveled at the metals’ importance in applications as varied as automobile starter motors, audio speakers, lasers, and colored glass.

The conference revealed new research trends showing that rare-earth chemistry is still very much a scientific frontier of the periodic table, with further technological developments to come. The discussion in Ames also turned to the need for better environmental stewardship of rare-earth element resources to ensure their sustainable, socially responsible use in existing and future technologies.

Although labeled as a “rare earth” conference, scientists in Ames included the actinides such as uranium on the agenda, given the kinship between lanthanides and actinides as fellow f-block elements. The actinides are increasingly being used in nuclear medicine and as catalysts.

[+]Enlarge
A Holiday Inn sign in Ames, Iowa, in 1965 says "Welcome Rare Earthers," greeting attendees to the Rare Earth Research Conference.

A new term, “rare earthers,” was created for attendees of the 5th Rare Earth Research Conference when the Holiday Inn welcomed them to Ames, Iowa, in 1965.

Credit: Vitalij Pecharsky/Ames Laboratory

The f-element relationship is actually how rare-earth chemistry got started. For the Manhattan Project, scientists needed pure uranium, lots of it, fast and at a low price. Rare-earth impurities in uranium could prevent a nuclear reactor from working by absorbing the neutrons needed to keep the chain reaction going. So the rare earths had to be removed. Yet the chemical similarity of the lanthanides makes it extremely difficult to isolate them from one another and to separate them from uranium and other actinides. Iowa State chemistry professor Frank H. Spedding, an expert on rare earths, helped guide solution processing efforts to make tons of pure uranium oxide and a new high-temperature smelting method—called the Ames process—to make tons of pure uranium metal.

After WWII, in 1947, Spedding helped create and became director of Ames Laboratory, a U.S. Department of Energy national laboratory with a mission to further develop rare earths, initially for military uses and space exploration. Building on their earlier work, Spedding and his team developed an ion-exchange method to extract rare earths from minerals, enabling better separation of the rare-earth metals on a larger scale.

“Rare-earth research became commonplace after the groundbreaking work performed in Ames in the 1940s and 1950s,” explained materials scientist Vitalij Pecharsky of Iowa State and Ames Laboratory, another RERC organizer. “Spedding and his colleagues made pure rare earths available in quantities required for broad chemistry and physics research and applications for the first time.”

Pecharsky said his own research developing new rare-earth magnetic materials was made possible by those pioneering efforts. For example, his work with one of those pioneers, Karl A. Gschneidner Jr., who passed away last year and was memorialized at the conference, led to the invention of Gd5Si2Ge2. This material’s temperature, Pecharsky explained, can be altered by exposing it to a changing magnetic field. Such magnetocaloric materials are being developed for high-efficiency refrigeration that uses a quarter of the energy of current systems.

“Rare earths remain a favorite playground for both basic and applied science,” Pecharsky said, “driven by the potential for their everyday applications.”

Kenneth N. Raymond of the University of California, Berkeley, another rare-earth-playground leader, was recognized during the conference as this year’s Spedding Award winner, a prize that honors outstanding achievement in rare-earth research and education. Raymond’s award lecture, “Lanthanides in Bondage: From Basics to Business,” which led off the conference, reviewed his 40-plus-year career studying lanthanide luminescence and developing biomedical applications for the rare earths.

Starting out, Raymond worked with other leading researchers of the day—UC Berkeley’s Glenn T. Seaborg and Andrew Streitwieser—to determine crystal structures of new lanthanide and actinide complexes. “Although there were a number of these compounds known, there was almost no structural information about them,” Raymond said. “So I set about to change that.” Raymond developed predictive models for the structure and bonding of lanthanide and actinide compounds based on the ionic radii of the metals.

[+]Enlarge
A photo shows a small ingot of Gd5Si2Ge2, a material whose temperature can be altered by exposing it to a changing magnetic field, a property that could be used in high-efficiency refrigeration.

Gd5Si2Ge2, a material created at Ames Laboratory, exhibits a giant magnetocaloric effect: Its temperature can be altered by exposing it to a changing magnetic field, a property that could be used in high-efficiency refrigeration.

Credit: Courtesy of Grant Luchmann

Subsequent studies have enabled chemists to better understand the electronic transitions possible in lanthanide complexes when they are excited by light, and helped researchers design sequestering agents for plutonium and other heavy elements used to prepare and reprocess nuclear fuels.

Although lanthanides are weaker light emitters than organic dyes such as rhodamine B and fluorescein, Raymond said, they provide a technical advantage because their luminescence lasts longer, which allows better detection. Understanding the photochemistry of these lanthanide complexes when they are attached to drugs, proteins, and antibodies has proved valuable for developing new types of diagnostic assays and medical imaging.

In 2001, Raymond cofounded Lumi­phore to commercialize terbium, europium, and other lanthanide luminescent complexes. These complexes are now used in assay kits sold by other companies to test saliva, blood, or tissues for drugs of abuse, hospital bacterial infections, and fetal and neonatal diseases. The technology is also being developed for biological imaging­—for example, to study protein-protein interactions in living cells.

“We have learned a lot about the fundamental coordination chemistry of lanthanides over the years, and it’s still an interesting subject for research,” Raymond said. “Maybe the biggest thing for me is that if you put these metals in bondage, that is, incorporate them inside chelating ligands, the chemistry can be used to practical effect.”

William J. Evans, another rare earther, agrees. Evans and his coworkers at the University of California, Irvine, are one of several research groups who have been designing new metal complexes that are shaking up the conventional wisdom about rare-earth element oxidation states. Their findings point to new approaches for manipulating the magnetic, optical, and catalytic properties of rare earths.

“When I started working with rare-earth metals in the 1970s, they were considered an exotic part of the periodic table—people had to stop and think about where those metals are positioned,” Evans told C&EN. “My research advisers thought I was crazy to go to work in this area, because there was no demonstrated importance in the chemistry of these elements.” But Evans said the dearth of work on lanthanides was their allure.

Today, the attitude toward rare earths is much different, Evans said, because people have heard of their many uses. “So now when I say I am a rare-earth chemist, people have an idea that these are useful, interesting, and strategically important metals.”

Conventional wisdom among chemists until recently held that most rare earths exist only in the +3 oxidation state in molecular complexes. Each of the 17 elements in the rare-earth collection have three ionizable electrons—two s electrons and one d electron. Moving across the row of lanthanides from lanthanum to lutetium, each element has an additional electron that takes up a position in a 4f orbital. Because the 4f orbitals don’t extend far enough from the atom, they tend not to directly participate in bonding, yet they still influence the elements’ magnetic and optical properties. That’s a broad, simplistic view; the real situation “is complicated,” Evans said.

Researchers found early on with rare earths that cerium readily assumes a +4 oxidation state in compounds, and later researchers began to find that other elements could take on +2 or possibly +5 oxidation states. By the late 1990s, chemists had isolated lanthanide(II) complexes for six of the elements. At the time, the researchers rationalized their results by noting the ions were stabilized by having filled, nearly filled, half-filled, or nearly half-filled 4f orbitals.

But as researchers continued to investigate, they discovered that ligands with the right electronic properties could provide additional stability, leading to additional +2 complexes. In 2013, Evans and Matthew R. MacDonald in his group reported complexes for the final seven elements, completing the lanthanide(II) series to show that it could be done. The team actually didn’t make the promethium complex, because the element is radioactive and doesn’t occur naturally. But the researchers expect it should follow suit and form a +2 complex.

The lanthanide(II) complexes are especially interesting, Evans noted, because they are kind of a hybrid between transition metals and lanthanide metals. They don’t appear to have a 6s electron, but rather a 5d electron like a transition metal, in addition to any 4f electrons. And they display one-electron redox chemistry, which is not always typical for transition metals. “It’s like they are a new type of metal,” he said.

Evans and his colleagues have since found that the dysprosium(II) and holmium(II) complexes exhibit the highest magnetic moments reported to date for any single metal ion complex. They haven’t figured out how to use this breakthrough practically yet, Evans said. One idea is that these complexes could function as single-molecule magnets and be used in thin-film coatings for computer hard drives to increase the density of data storage.

As for what’s next with rare-earth chemistry, Evans asked: Why not try to make +1 rare-earth complexes? He thinks as chemists continue to tinker with new electron configurations, they should be able to further elaborate on rare-earth technologies. “Hopefully, future research will allow us to use these metals more efficiently and reduce the tremendous demand on them for their special properties.”

As Evans alluded, the demand for rare earths could lead to their commercial demise. Access to the metals has always been tenuous, leading to worries that one day demand for them may outstrip supply.

To head off that scenario, Gisele Azimi of the University of Toronto, another rare earther speaking at the conference, sees an opportunity for developing better strategies to ensure sustainable supplies of rare earths. These include finding new sources of the metals, developing better extraction technology for them, improving the efficiency of rare-earth-metal usage in products, and closing the loop on their use with better recycling.

[+]Enlarge
Ames Laboratory scientist Ikenna Nlebedim holds samples of neodymium-iron-boron magnets sourced and manufactured entirely in the U.S., part of the Ames Lab’s Critical Materials Institute’s role in supporting American manufacturing.

Ames Laboratory scientist Ikenna Nlebedim holds samples of neodymium-iron-boron magnets sourced and manufactured entirely in the U.S. The magnets are the result of the lab’s Critical Materials Institute’s role in supporting American manufacturing and national security interests.

Credit: Ames Laboratory

Despite their name, rare-earth elements are not rare. All the metals except radioactive promethium are actually more abundant in Earth’s crust than silver, gold, and platinum. When the first rare earths were discovered in the late 18th century, they were found as complex mixtures of metal oxides in various minerals. The minerals were initially, and incorrectly, classified as “earths,” a geological term denoting nonmetallic substances that are insoluble in water and resistant to chemical change by heating. Furthermore, because of their geochemical properties, rare-earth elements don’t concentrate in ore deposits but are widely dispersed, so they only seemed to be scarce.

Global rare-earth reserves, at more than 130 million metric tons, appear to be ample, Azimi noted. However, most of those reserves either are too low in concentration to be extracted economically, or they are not readily accessible, such as metals locked away in deep-sea manganese-based nodules or hydrothermal deposits.

“Currently, the demand for rare earths is increasing at a rate of about 5% annually,” Azimi said. Some rare-earth applications require large amounts of the metals: Wind turbines use some 600 kg of rare-earth metals apiece. Some uses need intermediate amounts: Electric vehicle batteries use 5 to 10 kg of rare earths each. And some uses require small amounts: Phosphors in lighting may use a fraction of a gram per bulb.

The key issue at the moment is that China is home to about 25% of the world’s rare-earth reserves, yet economic forces have aligned so that China now accounts for roughly 90% of the global supply. This situation has made sourcing rare earths precarious, subject to price and supply swings that are disruptive to product manufacturers.

That leaves mining companies outside China caught in an industrial catch-22: If they want to grab a larger piece of the market, the companies must ramp up production of rare earths, but they must do so without saturating the market with supply to avoid lowering prices. While companies deal with those economic conditions, they are also increasingly being judged for their environmental stewardship and their social responsibility to the communities they operate in.

The U.S., Australia, Brazil, and Canada have large reserves of rare earths, Azimi said, but little active mining is currently going on in those countries because of the cost. The real challenge going forward, she said, is going to be scaling up supply at a rate that matches increases in demand. “Opening new mines takes time—a decade or more—for prospecting, permitting, and construction. It’s expensive and has environmental downsides.” From digging in the ground to producing pure rare-earth oxides and pure metals, the process uses a lot of water, acids, organic solvents, and extraction chemicals.

One solution Azimi is promoting is to rescue rare-earth metals from existing stockpiles of mining wastes. For example, she is working with residue called red mud from bauxite mining to produce aluminum, and leftovers called phosphogypsum from phosphate rock mining that makes fertilizer. These materials contain 300 to 500 ppm of rare-earth metals, which is more concentrated than the roughly 0.2 to 60 ppm levels of the elements found in natural mineral deposits. With millions of tons of these waste materials piled up globally, thousands of tons of rare-earth metals could be procured, she said. Other researchers at the conference discussed coal ash and spent nuclear fuel from power plants as additional secondary sources of rare earths.

Rare earths are also plentiful in electronic waste, Azimi explained. Used fluorescent lights, computer hard drives, large permanent magnets, and batteries tend to end up in landfills. “Only 1% of their rare-earth content is being recycled,” Azimi said. “It is absolutely imperative to develop recycling processes to address the sustainability challenges associated with these critical materials.”

That’s a big challenge for e-waste because most consumer products aren’t designed to be recycled. In addition, the metals are often used in combination for specific applications and need to be separated again. For example, neodymium-based permanent magnets (Nd2Fe14B) contain some dysprosium to improve thermal performance.

Azimi’s group is working toward a designer acid-leaching process to recover rare earths from red mud and phosphogypsum. At RERC, she described how her team is further using the metals to design rare-earth-containing materials for new commercial uses. For example, the researchers are working on rare-earth oxide ceramics as transparent waterproof coatings for applications such as heat exchangers, airplanes, and solar panels. These materials use a minimal amount of rare earths and they are thermally stable, so they last longer than other types of hydrophobic coatings, which could help address the rare-earth supply challenge, she said

Other methods being used or tested to recycle e-waste include traditional coordination and chelation chemistry, ionic liquid extraction, metal-adsorbing bacteria, and the Ames high-temperature metallurgical process. For example, Eric J. Schelter of the University of Pennsylvania and his group have been developing a new type of targeted metal separation process that uses tailored nitroxide ligands to efficiently separate mixtures of rare-earth metals when recycling magnets and lighting phosphors.

“Rare earths have become indispensable and, in many cases, irreplaceable components of materials that are essential in modern life,” said Schelter, one of the conference organizers. “Moving forward, I’m excited to see the magnetic properties of rare-earth molecules and molecular clusters reach their potential, for f-element complexes to catalytically drive multielectron transformations, and for the realization of highly efficient chemistries for recycling rare earths from consumer materials.”

Technical solutions to the long-term sustainable use of rare earths undoubtedly will come from further research and design of new materials, such as core-shell nanoparticles that use just a dash of rare earths or even thin films of single molecules that achieve the same magnetic, optical, and other magical rare-earth properties as bulkier materials. Some researchers are looking to rare earths as a guide to exploit transition- and main-group metals to mimic rare-earth properties. Those developments might be on the agenda the next time rare earthers reunite in Ames.

DeepL Translator – AI Assistance for Language

$
0
0
  • Any language (detect)
  • English
  • German
  • French
  • Spanish
  • Italian
  • Dutch
  • Polish
Type or paste text here.
(English, French, German, Spanish, Italian, Dutch, Polish)
  • English
  • German
  • French
  • Spanish
  • Italian
  • Dutch
  • Polish

No matches for this word in the Linguee dictionary.

To look up words in the dictionary, just clicktap on them.

DeepL’s networks consistently outperform other translation systems, making ours the world’s best translation machine. Try it out for yourself or read on to see a quantitative comparison of our system to others.

The gold standard for comparison of machine translation systems is the direct blind test.

DeepL Translator, Google Translate, Microsoft Translator, and Facebook are fed 100 sentences to translate. Professional translators are then asked to assess the translations, without knowing which system produced which results. Here are the results of a test run in August 2017:

75%
50%

Number of Wins

25%
0%English → GermanEnglish → FrenchEnglish → Spanish
50%

Number of Wins

25%
0%German → EnglishFrench → EnglishSpanish → English

We encourage you to test it out yourself.

Researchers also measure their systems’ translation performance in terms of BLEU scores on specific, predefined test sets (called newstest).
Our neural network systems achieve scores beyond any yet published:

31 45 
3044
2943
28

BLEU Score

42
2741
2640
25newstest2014 English → German39newstest2014 English → French

Publications:

1) Specific details of our network architecture will not be published at this time. DeepL Translator is based on a single, non-ensemble model. Scores calculated using multi-bleu.pl script (Moses).
2) Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, Illia Polosukhin. Attention is all you need. arXiv preprint arXiv:1706.03762, 2017.
3) Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N. Dauphin. Convolutional sequence to sequence learning. arXiv preprint arXiv:1705.03122v2, 2017.
4) Jie Zhou, Ying Cao, Xuguang Wang, Peng Li, and Wei Xu. Deep recurrent models with fast-forward connections for neural machine translation. CoRR, abs/1606.04199, 2016.
5) Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang Macherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Google’s neural machine translation system: Bridging the gap between human and machine translation. arXiv preprint arXiv:1609.08144, 2016.
6) Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton, and Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts layer. arXiv preprint arXiv:1701.06538, 2017.

Loading dictionary...

The dictionary is available again in a minute.

Due to high load on the servers, the dictionary is currently not available.

Teleport, a TCP socket framework written in Go

$
0
0

README.md

Teleport is a versatile, high-performance and flexible TCP socket framework.

It can be used for peer-peer, rpc, gateway, micro services, push services, game services and so on.

简体中文

teleport_server

AB Testing 1: [Mac 4CPU 8GB] [single-process single-conn] teleport: QPS 41358teleport_frame_client_ab_test

AB Testing 2: [Mac 4CPU 8GB] [single-process single-conn] teleport/socket: QPS 55419teleport_socket_client_ab_test

1. Version

versionstatusbranch
v2releasemaster
v1releasev1

2. Install

go get -u github.com/henrylee2cn/teleport

3. Feature

  • Server and client are peer-to-peer, have the same API method
  • Packet contains both Header and Body two parts
  • Support for customizing head and body coding types separately, e.g JSONProtobuf
  • Body supports gzip compression
  • Header contains the status code and its description text
  • Support push, pull, reply and other means of communication
  • Support plug-in mechanism, can customize authentication, heartbeat, micro service registration center, statistics, etc.
  • Whether server or client, the peer support reboot and shutdown gracefully
  • Support reverse proxy
  • Detailed log information, support print input and output details
  • Supports setting slow operation alarm threshold
  • With a connection I/O buffer
  • Use I/O multiplexing technology

4. Architecture

4.1 Keywords

  • Peer: A communication instance may be a client or a client
  • Session: A connection session, with push, pull, reply, close and other methods of operation
  • Context: Handle the received or send packets
  • Pull-Launch: Pull data from the peer
  • Pull-Handle: Handle and reply to the pull of peer
  • Push-Launch: Push data to the peer
  • Push-Handle: Handle the push of peer
  • Router: Register handlers

4.2 Execution level

Peer -> Connection -> Socket -> Session -> Context

4.3 Packet

HeaderLength | HeaderCodecId | Header | BodyLength | BodyCodecId | Body

Notes:

  • HeaderLength: uint32, 4 bytes, big endian
  • BodyLength: uint32, 4 bytes, big endian
  • HeaderCodecId: uint8, 1 byte
  • BodyCodecId: uint8, 1 byte
typePacketstruct {// HeaderCodec header codec nameHeaderCodecstring`json:"header_codec"`// BodyCodec body codec nameBodyCodecstring`json:"body_codec"`// header contentHeader *Header `json:"header"`// body contentBodyinterface{} `json:"body"`// header lengthHeaderLengthint64`json:"header_length"`// body lengthBodyLengthint64`json:"body_length"`// HeaderLength + BodyLengthLengthint64`json:"length"`
}

4.4 Header

typeHeaderstruct {// Packet idIdstring// Service typeTypeint32// Service URIUristring// Body encoding typeGzipint32// As reply, it indicates the service status codeStatusCodeint32// As reply, it indicates the service status textStatusstring
}

5. Usage

  • Create a server or client peer
varcfg = &tp.PeerConfig{DefaultReadTimeout:   time.Minute * 3,DefaultWriteTimeout:  time.Minute * 3,TlsCertFile:          "",TlsKeyFile:           "",SlowCometDuration:    time.Millisecond * 500,DefaultHeaderCodec:   "protobuf",DefaultBodyCodec:     "json",DefaultBodyGzipLevel: 5,PrintBody:            true,DefaultDialTimeout:   time.Second * 10,ListenAddrs: []string{"0.0.0.0:9090",
	},
}varpeer = tp.NewPeer(cfg)// It can be used as a server
peer.Listen()// It can also be used as a client at the same timevarsess, err = peer.Dial("127.0.0.1:8080", "peerid-client")if err != nil {
	tp.Panicf("%v", err)
}
  • Define a controller and handler for pull request
// Home controllertypeHomestruct {
	tp.PullCtx
}// Test handlerfunc(h *Home) Test(args *[2]int) (int, tp.Xerror) {a:= (*args)[0]b:= (*args)[1]return a + b, nil
}
  • Define controller and handler for push request
// Msg controllertypeMsgstruct {
	tp.PushCtx
}// Test handlerfunc(m *Msg) Test(args *map[string]interface{}) {
	tp.Infof("receive push(%s):\nargs: %#v\nquery: %#v\n", m.Ip(), args, m.Query())
}
  • Define a handler for unknown pull request
funcUnknownPullHandle(ctxtp.UnknownPullCtx, body *[]byte) (interface{}, tp.Xerror) {varvinterface{}codecName, err:= ctx.Unmarshal(*body, &v, true)if err != nil {returnnil, tp.NewXerror(0, err.Error())
	}
	tp.Infof("receive unknown pull:\n codec: %s\n content: %#v", codecName, v)return"this is reply string for unknown pull", nil
}
  • Define a handler for unknown push request
funcUnknownPushHandle(ctxtp.UnknownPushCtx, body *[]byte) {varvinterface{}codecName, err:= ctx.Unmarshal(*body, &v, true)if err != nil {
		tp.Errorf("%v", err)
	} else {
		tp.Infof("receive unknown push:\n codec: %s\n content: %#v", codecName, v)
	}
}
// AliasPlugin can be used to set aliases for pull or push servicestypeAliasPluginstruct {Aliasesmap[string]string
}// NewAliasPlugin creates a new NewAliasPluginfuncNewAliasPlugin() *AliasPlugin {return&AliasPlugin{Aliases: make(map[string]string)}
}// Alias sets a alias for the uri.// For example Alias("/arith/mul", "/mul")func(p *AliasPlugin) Alias(aliasstring, uristring) {
	p.Aliases[alias] = uri
}// Name return name of this plugin.func(p *AliasPlugin) Name() string {return"AliasPlugin"
}// PostReadHeader converts the alias of this service.func(p *AliasPlugin) PostReadHeader(ctxtp.ReadCtx) error {varu = ctx.Input().Header.Uriif p.Aliases != nil {if a = p.Aliases[u]; a != "" {
			ctx.Input().Header.Uri = a
		}
	}returnnil
}
  • Register above handler and plugin
aliasesPlugin:=NewAliasPlugin()
aliasesPlugin.Alias("/alias", "/origin")
{pullGroup:= peer.PullRouter.Group("pull", aliasesPlugin)
	pullGroup.Reg(new(Home))
	peer.PullRouter.SetUnknown(UnknownPullHandle)
}
{pushGroup:= peer.PushRouter.Group("push")
	pushGroup.Reg(new(Msg), aliasesPlugin)
	peer.PushRouter.SetUnknown(UnknownPushHandle)
}

6. Demo

server.go

package mainimport ("time"

	tp "github.com/henrylee2cn/teleport"
)funcmain() {go tp.GraceSignal()
	tp.SetShutdown(time.Second*20, nil, nil)varcfg = &tp.PeerConfig{
		DefaultReadTimeout:   time.Minute * 3,
		DefaultWriteTimeout:  time.Minute * 3,
		TlsCertFile:          "",
		TlsKeyFile:           "",
		SlowCometDuration:    time.Millisecond * 500,
		DefaultHeaderCodec:   "protobuf",
		DefaultBodyCodec:     "json",
		DefaultBodyGzipLevel: 5,
		PrintBody:            true,
		ListenAddrs: []string{"0.0.0.0:9090","0.0.0.0:9091",
		},
	}varpeer = tp.NewPeer(cfg)
	{group:= peer.PullRouter.Group("group")
		group.Reg(new(Home))
	}
	peer.PullRouter.SetUnknown(UnknownPullHandle)
	peer.Listen()
}// Home controllertypeHomestruct {
	tp.PullCtx
}// Test handlerfunc(h *Home) Test(args *map[string]interface{}) (map[string]interface{}, tp.Xerror) {
	h.Session().Push("/push/test?tag=from home-test", map[string]interface{}{"your_id": h.Query().Get("peer_id"),"a":       1,
	})returnmap[string]interface{}{"your_args":   *args,"server_time": time.Now(),
	}, nil
}funcUnknownPullHandle(ctxtp.UnknownPullCtx, body *[]byte) (interface{}, tp.Xerror) {varvinterface{}codecName, err:= ctx.Unmarshal(*body, &v, true)if err != nil {returnnil, tp.NewXerror(0, err.Error())
	}
	tp.Debugf("unmarshal body: codec: %s, content: %#v", codecName, v)return []string{"a", "aa", "aaa"}, nil
}

client.go

package mainimport ("time"

	tp "github.com/henrylee2cn/teleport"
)funcmain() {go tp.GraceSignal()
	tp.SetShutdown(time.Second*20, nil, nil)varcfg = &tp.PeerConfig{
		DefaultReadTimeout:   time.Minute * 3,
		DefaultWriteTimeout:  time.Minute * 3,
		TlsCertFile:          "",
		TlsKeyFile:           "",
		SlowCometDuration:    time.Millisecond * 500,
		DefaultHeaderCodec:   "protobuf",
		DefaultBodyCodec:     "json",
		DefaultBodyGzipLevel: 5,
		PrintBody:            false,
	}varpeer = tp.NewPeer(cfg)
	peer.PushRouter.Reg(new(Push))

	{
		varsess, err = peer.Dial("127.0.0.1:9090", "simple_server:9090")if err != nil {
			tp.Panicf("%v", err)
		}varreplyinterface{}varpullcmd = sess.Pull("/group/home/test?peer_id=client9090",map[string]interface{}{"conn_port": 9090},&reply,
		)if pullcmd.Xerror != nil {
			tp.Fatalf("pull error: %v", pullcmd.Xerror.Error())
		}
		tp.Infof("9090reply: %#v", reply)
	}

	{
		varsess, err = peer.Dial("127.0.0.1:9091")if err != nil {
			tp.Panicf("%v", err)
		}varreplyinterface{}varpullcmd = sess.Pull("/group/home/test_unknown?peer_id=client9091",map[string]interface{}{"conn_port": 9091},&reply,
		)if pullcmd.Xerror != nil {
			tp.Fatalf("pull error: %v", pullcmd.Xerror.Error())
		}
		tp.Infof("9091reply test_unknown: %#v", reply)
	}
}// Push controllertypePushstruct {
	tp.PushCtx
}// Test handlerfunc(p *Push) Test(args *map[string]interface{}) {
	tp.Infof("receive push(%s):\nargs: %#v\nquery: %#v\n", p.Ip(), args, p.Query())
}

7. License

Teleport is under Apache v2 License. See the LICENSE file for the full license text

Viewing all 25817 articles
Browse latest View live