Search

2/24/2014

Bitcoins the hard way

Ken Shirriff's blog: Bitcoins the hard way: Using the raw Bitcoin protocol Ken Shirriff's blog: Bitcoin mining the hard way: the algorithms, protocols, and bytes

Electrum Bitcoin Wallet

Electrum Bitcoin Wallet

Instant on: Your client does not download the blockchain, it uses a remote server. Forgiving: Your wallet can be recovered from a secret seed. Safe: Your seed or private keys are not sent to the server. Information received from the server is verified using SPV No downtimes: Several public servers are available, you can switch instantly. Ubiquitous: You can use the same wallet on different computers, it will auto-synchronize. Cold Storage: You can have secure offline wallets and still safely spend from an online computer. Open: You can export your private keys into other Bitcoin clients. Tested and audited: Electrum is open source and was first released in November 2011.

2/17/2014

Oleg Andreev - Bitcoin Non-Technical FAQ

Oleg Andreev - Bitcoin Non-Technical FAQ

How fast are the transactions? Transactions are secured by being included in a block. Blocks are generated approximately every 10 minutes. Including the time to propagate a transaction through the network, today it usually takes about 15 minutes to verify inclusion in a block. For better security, one can wait until more blocks are added after the block with the transaction. How transactions are secured? Transactions are grouped into blocks and each block contains the signature of the previous block, thus making up a chain of blocks. The security of the system is based on computational difficulty to generate blocks parallel to the main chain. The more blocks are created after the block containing your transaction, the harder it is to fork the chain and make the transaction invalid. Therefore, no transaction is 100% confirmed. Instead, there is a confirmation number — a number of blocks built after the transaction. Zero confirmations means that the transaction is not yet included in any block (unconfirmed). One confirmation means that the transaction is included in one block and there are no more blocks after it yet. Today for small transactions one or two confirmations (10-20 minutes) are considered enough. For bigger transactions it is recommended to wait for at least six confirmations (1 hour). One known exception is 120 confirmations required by the protocol for the use of generated bitcoins. This is because miners (those who create blocks) have the most of computing power in the network and must have extra incentive to play fairly and generate blocks in the main chain without attempting to double-spend their rewards. What do miners do exactly? Miners create blocks. To create a block one needs to create a file containing unconfirmed transactions (that are not yet included in any other block), add a timestamp, a reference to the latest block and a transaction sending 50 bitcoins from nowhere to any address. Then, the miner needs to compute a signature for the block (which is basically a very long number). This signature is called hash and the process of computing is called hashing. Computing a single hash takes very little time. But to make a valid block, the value of its hash must be smaller than some target number. The hash function is designed to be hard to reverse. That is, you cannot easily find some file contents that will produce the desired hash. You must alternate the contents of the given file and hash it again and again until you get a certain number. In the case of Bitcoin, there is a field in a file called “nonce” which contains any number. Miners increment that number each time they compute a hash until they find a hash small enough to be accepted by other clients. This may take a lot of computing resource depending on how small is the target hash value. The smaller the value, the smaller the probability of finding a valid hash. There is no guarantee that you need to spend a certain amount of time to find a hash. You may find it quickly or not find it at all. But in average, the small enough value of block hash takes time to create. This constitutes a protection against creation of a parallel chain: to fork the chain you will need to spend more resources than the people who created the original blocks What are the parameters of the network? Here are some parameters of the Bitcoin chain. They may be different for alternative currencies based on the Bitcoin software (like Namecoin). The minimum amount of bitcoins is 0.00000001 BTC. Blocks are created every 10 minutes. Block size is limited to 1 Mb. Difficulty is adjusted every 2016 blocks (approx. every two weeks) Initial reward for a block is 50 BTC. Reward is halved every 210 000 blocks (approx. four years). Points #5 and #6 imply that the total number of bitcoins will not exceed 21 million. Why are blocks created every 10 minutes? The 10 minute interval is designed to give enough time for the new blocks to propagate to other miners and allow them to start computation from a new point as soon as possible. If the interval was too short, miners would frequently create new blocks with the same parent block, which would lead to a waste of electricity, a waste of network bandwidth and delays in transaction confirmations. If it was too long, a transaction would take longer to get confirmed. Why is the block size limited to 1 Mb? The block size is limited to make a smoother propagation through the network, the same reason why the 10 minute interval was chosen. If the blocks were allowed to be 100 Mb in size, they would be transferred slower, potentially leading to many abandoned blocks and a decrease in the overall efficiency. Today a typical size of a block is 50-200 Kb which makes a lot of room for growth. In the future it is possible to increase block size when the networks get faster. Decreasing time interval would not change much because the security of transactions depends on the actual time, not the number of blocks. How can the protocol be changed? The protocol is a list of rules that every client must follow in order to validate transactions and have their transactions validated by others. Hence, if you change the rules for yourself, other clients will simply reject your transactions and you probably will not be able to accept theirs. This makes it hard to change the protocol. If there is a change that a vast majority of clients will find useful, then it is possible to publicly agree that starting with the block number X, new rules will apply. This will give a certain amount of time to everyone to update the software.

Turning speech into actionable data

Introducing Wit Speech API

How does it work? Behind the scene, Wit combines various state-of-the-art Natural Language Processing techniques and several speech recognition engines in order to achieve low latency and high robustness to both surrounding noise and paraphrastic variations (there are millions of ways to say the same thing). Fortunately, you don’t need to care about all this machinery. We focus all our energy into creating the simplest developer experience possible. You can be up and running in a few minutes using our website. Wit will adapt to your domain over time, from ice-cream distribution to space missions. Wit makes no assumptions and remains 100% configurable.

Oleg Andreev - Journalist's guide to describe Bitcoin and not look like an idiot

Oleg Andreev - Journalist's guide to describe Bitcoin and not look like an idiot

When writing about Bitcoin many journalists use certain phrases that are not quite correct and do not explain anything to everyone else. Dear journalist, if you read this short article you will finally understand what are you talking about and outperform 99% of your colleagues. In a short paragraph, Bitcoin can be described like this (you can take my text without asking): Bitcoin is a payment network with its own unit of account and no single controlling entity behind it. Users make transactions between each other directly and verify them independently using cryptographic signatures. To prevent duplicate spendings, many specialized computers spend a lot of computing power to agree on a single history of transactions. Due to historical reasons, this process is called “mining” because new bitcoins are created as a reward for performing this work. Anyone who validates next block of transactions can claim transaction fees and a fixed amount of new bitcoins. Transactions are validated at a constant rate (10 minutes in average) and every four years allowed amount of new bitcoins is halved. This means that the total amount of bitcoins is limited by the protocol (21M total, 11M already created). Transaction fees are not fixed and determined by the market. Bitcoin mining is secondary to the whole idea and the term “mining” is unfortunate (early Bitcoins were generated before anyone was doing any transactions yet, so the whole process was called “mining” instead of “paying for transaction verification”). One common pitfall is to start talking about mining without describing its real purpose. It is not to generate new units (who would need them?), it is to validate transactions. Bitcoins are valuable only because of robust payment network which is maintained by the miners. And miners get paid for their work in form of transaction fees and newly generated bitcoins. Second common pitfall is to say that miners “solve complex algorithms”. They do not solve anything. They do two things: transaction verification (checking digital signatures and throwing away invalid and duplicate transactions), and a long and boring computation which means a repetitive computation of a well-known algorithm with slightly different input until a “good enough” number appears as a result that will be accepted by other users as a proof of performed work. This has nothing to do with “math problems” or any other intellectual task. It is merely a way to guarantee that the resulting number really took some time to produce. This allows people to build a single chain of transactions and see that it would be economically impossible to produce a parallel chain (without trusting each other personally). The last pitfall in describing mining is saying something like “tasks are getting more complex over time”. Tasks are not getting any more complex. The are all the same and not complex at all (any amateur programmer can understand them). But the difficulty of a boring “proof of work” is adjusted by everyone every 2 weeks to maintain the same rate of transaction validation (10 minutes). If people throw more resources at mining, difficulty will rise. If mining gets less profitable, some computers will be shut down and the difficulty will get lower. If a miner produces a “proof” which is not difficult enough, it will not be accepted by other users. The last point is related to amount of units available. In fact, “1 Bitcoin” is a name for 100 million smallest units, thus the total amount of units ever possible is around 2100 trillion. Alternative currencies based on Bitcoin source code sometimes advertise more units (e.g. Litecoin has 4 times more), but the difference is only in names and divisibility of the total money supply, not in actual value (if you cut a pie in 10 pieces instead of 5, the total value does not really change). So it would be fair to mention that 1 bitcoin is much more divisible than dollars and euros. Hopefully, this knowledge will help you to avoid common mistakes when writing your article and make some friends in enthusiastic Bitcoin community.

Tech Notes: React, JSX, and CoffeeScript

Tech Notes: React, JSX, and CoffeeScript

CoffeeScript instead of JSX If you're using CoffeeScript, your source code isn't JavaScript to begin with. But turns out that CoffeeScript's flexible syntax makes it relatively painless to use the underlying API directly. Start with shortening the DOM alias and writing more or less the same code as above. Also note that you don't need to explicitly return as the last statement in a function is implictly returned, and that the function literal syntax for argumentless function is just a bare ->:
R = React.DOM
# ...

render: ->
  R.p(null, R.a({href:'foo'}, 'bar'))
But you can do better. First, CoffeeScript knows to insert the curlies on an object literal because of the embedded colon.
  R.p(null, R.a(href:'foo', 'bar'))
And then you can remove the parens by splitting across lines. When providing args to a function, a comma+newline+indent continues the argument list. Much like Python, the visual layout follows the semantic nesting.
  R.p null,
    R.a href:'foo', 'bar'
In fact, beyond the first argument, the trailing commas are optional when you have newlines. Here's the same thing again with two links inside the <p>:
  R.p null,
    R.a href:'foo', 'bar'  # note omitted comma here
    R.a href:'foo2', rel:'nofollow', 'second link'
CoffeeScript also makes every statement into an expression, which is a familiar feeling coming from functional programming. It means you can use statement-like keywords like if and for on the right hand side of an equals sign, or even within a block of code like the above. Here's a translation of the (7-line) <ol> example from above.
R.ol null,
  for result in @results
    R.li key:result.id, result.text
There is one final feature of CoffeScript that I find myself using, which is an alternative syntax for object literals. For example, suppose in the above example the "key" attribute needs to be computed from some more complicated expression:
R.ol null,
  for result, index in @results
    resultKey = doSomeLookup(result, index)
    R.li key:resultKey, result.text
The simplification is that, within a curly-braced object literal, entries without a colon use the variable name as the key. The above could be equivalently written:
R.ol null,
  for result, index in @results
    key = doSomeLookup(result, index)
    R.li {key}, result.text
This is particularly useful when the attributes you want to set have meaningful names -- key is pretty vague, but if you construct an href and a className variable it's pretty clear where they are going to be used. These can be mixed with normal key-value pairs, too, like:
href = ...
className = ...
R.li {href, className, rel:'nofollow'}, ...
Putting it all together, here's a larger example, part of an implementation of an "inline edit" widget. To the user, this widget is some text with a "change" button to its right, where clicking on "change" swaps the line of text out for an edit field positioned in the same place, allowing the user to make a change to the value directly. (Like how it works in a spreadsheet.) The first branch of the if is the widget's initial state; the @edit function flips on the @state.editing flag.
render: ->
  if not @state.editing
    R.div null,
      @props.text
      ' '  # space between text and button
      R.span className:'link-button mini-button', onClick:@edit, 'change'
  else
    R.div style:{position:'relative'},
      R.input
        style:{position:'absolute', top:-16, left:-7}
        type:'text', ref:'text', defaultValue:@props.text
        onKeyUp:@onKey, onBlur:@finishEdit
To get a feel for these rules, you can just experiment and look at the generated JavaScript. Or you can go to coffeescript.org and click the "Try CoffeeScript" tab, where you can enter nonsense expressions there just to experiment with the syntax.

2/15/2014

Netflix颠覆HR:我们只雇「成年人」 | 极客公园

Netflix颠覆HR:我们只雇「成年人」 | 极客公园

Netflix 究竟是如何吸引和管理人才的? 只招最优秀的,把不够优秀的请走 回溯到 2001 年,互联网泡沫破灭打乱了公司的 IPO 计划,我们还裁掉了 1/3 的员工。但圣诞节时转机来了,DVD 播放机成为热门礼品,公司的 DVD 邮寄订阅业务也意外暴涨。 有一天我和工程师约翰谈话,说希望尽快替他找到帮手。裁员之前,约翰手下有三名工程师。可他的回答却出人意料:“我宁可自己做,也不要二流手下。”原来,过去约翰要花大量时间去管理员工并收拾他们的烂摊子。 这句话日后反复在我耳畔回响:你能为员工提供的最佳福利,不是请客吃饭和团队活动,而是招募优秀的员工,让他们和最优秀的人一起工作! 如果你希望团队里都是最优秀的员工,那么你必须要请能力不足的人离开。 2002 年形势好转后,Netflix 成功 IPO,当时公司急需专业精算师和经验丰富的财务专员,而会计劳拉已经不胜任这份工作。劳拉曾为公司做出了很大的贡献,有人提议给她特设一个职位,但我直接告诉她,我们愿意提供一笔可观的离职补偿金。 当时,我甚至做好了迎接泪水的准备,没想到劳拉很轻松地说:她对离开表示遗憾,但丰厚的离职补偿金可以让她考虑重返校园或参加培训,寻找新的职业发展路径。 只雇用、奖励和容忍「成年人」 从业三十年,我发现很多大公司的 HR 往往花太多时间用于拟定人力资源管理的条例,以应付一小撮与公司利益不一致的员工,结果往往得不偿失。我们根本不会让这种人进入公司,我们筛选出的人是真正的“成年人”。 自 Netflix 创始起,我们就制定了带薪假期的规定,并且一直用内部的办公系统记录出勤情况。公司上市后,审计师提出异议,认为应引入正式的办公考勤系统,对员工的休假时间做出清晰的解释。但里德和我都认为,只要不违反相关法律,何必在意繁文缛节? 现在,Netflix 的员工可以自行决定休假计划,HR 只是给出指导性意见。比如,财务部门的员工不要在季初和季末最繁忙时休假;如果要连续休假 30 天,要先与 HR 面谈。 在差旅和报销制度上,我们告诉员工,公司想节省开支,希望员工把公司的钱当成自己的钱,这大大降低了公司成本。很多公司都通过代理机构订票,但如果相信员工会遵守「公司利益最优先原则」,让他们自行在网上订票,就可以省下一大笔中介费。 和很多经理一样,我也会时不时和员工吃工作餐,如果是为了招聘或销售目的,餐费就可以报销;如果是和同事不涉及工作的用餐,餐费则不能报销。总之,只要遵循「成年人」做法的原则,绝大多数员工都会遵守制度。 对员工直言他们的表现 在很久以前,我们就取消了正式的评估制度。某些职能部门员工的业绩好坏一目了然,而且,偶尔一次的考核也没有连贯性。 比如,工程师玛利亚被招进公司是负责查找漏洞的。但由于技术的更新,我们很快发现这项工作可以全自动化。经理要求玛利亚参加评估,以防炒掉她时可能出现的劳务纠纷。但是我说:“大家都知道这出戏会怎么演下去。你先定目标,她根本无法达标,你每周都要跟她进行一次难堪的谈话,最后她还是会被炒掉。这对 Netflix 又有什么好处?” 我建议他,不妨直接告诉玛利亚:你的能力已经不符合公司需要了。以我的经验,只要告知实情,人们总是能够应对变化。 取消了正式的业绩评估后,我们设立了「非正式的」360 度考评制度。我们提出尽可能简洁的问题:你觉得你的同事「应该做什么」、「不要做什么」。简单、诚恳、定期地以探讨的方式进行评估,效果远远好过正式考评制度。 而对于管理者,我们的要求是,要确保员工理解公司发展的核心动力和盈利模式。即使你招到了充满干劲的员工,你仍需要告诉他们公司是怎么赚钱的,让他们理解怎么做能帮助公司成功。 股票期权不应是“金手铐” 在伊拉克战争期间,时任美国国防部部长拉姆斯菲尔德说:“你是要带着已有的军队参战,而不是带领一支你所期待的队伍。”不过,我却告诉 Netflix 的经理们要反其道而行之:伟大的团队完成伟大的工作,打造一支伟大的团队就是你的首要职责。 Netflix 从 DVD 邮寄租赁业务向流媒体服务转型时,就曾面临这样的挑战。我们急需那些曾在亚马逊和谷歌等大公司有云计算研发经验的人才,但显然,这些人才不容易被挖。 此时,我们的薪酬体制起了很大的作用。Netflix 的薪酬原则也遵循这样的理念:坦诚待人、把员工当成年人对待。比如,公司提供的年薪中没有「绩效奖金」,因为我们相信市场主导的薪酬标准,只要招对了人,没有年终奖既不会让他们变懒,也不会让他们变笨。事实上,我们通常会给出高出市场平均水平的薪酬,在年终也会发放超出员工预期的福利。 另外,一般公司都会在提供一份有竞争力年薪的同时,搭配固定的股票期权。而我们让员工自己选择股票期权在整体薪酬中的占比。每个月公司都以稍低于股价的价格发放一定的期权,而且允许即时兑现。 我们觉得,股票期权不应该是为了降低离职率的「金手铐」,如果你获得了更好的发展机会,就该在离开时带走你应得的全部。

2/10/2014

#7300 (Keypress not getting arrow keys in chrome) – jQuery Core - Bug Tracker

Events - keydown, keypress, keyup

keypress Fires when an actual character is being inserted in, for instance, a text input. It repeats while the user keeps the key depressed.
JavaScript Madness: Keyboard Events
There are many other special keys on a typical keyboard that do not normally send characters. These include the four arrow keys, navigation keys like Home and Page Up, special function keys like Insert and Delete, and the function keys F1 through F12. Internet Explorer and WebKit 525 seem to classify all of these with the modifier keys, since they generate no text, so in those browsers there is no keypress event for them, only keyup and keydown. Many other browsers, like Gecko, do generate keypress events for these keys, however.
#7300 (Keypress not getting arrow keys in chrome) – jQuery Core - Bug Tracker
I've reviewed the bulk of tickets regarding keypress on both the Chrome, Chromium and Webkit bug trackers and it would appear that there are no intentions on supporting correct keypress behavior from any of these camps now or in the future. The reason for this is that a) keypress and its behavior is not mentioned specifically in any specs and b) Although FireFox and Opera support this feature, Webkit (used by Chrome and Safari) decided to copy the IE behavior in this case which reserves arrow keypresses for internal browser behavior only. There is no way that jQuery can circumvent this behavior and it is instead recommended that you use keydown instead as this is supported.
keyboard events -
Detecting arrow key presses in JavaScript - Stack Overflow Use keydown, not keypress for non-printable keys such as arrow keys:
function checkKey(e) {
    e = e || window.event;
    alert(e.keyCode);
}

document.onkeydown = checkKey;
arrow keys are only triggered by onkeydown, not onkeypress keycodes are: left = 37 up = 38 right = 39 down = 40

pjscrape: A web-scraping framework written in Javascript, using PhantomJS and jQuery

pjscrape: A web-scraping framework written in Javascript, using PhantomJS and jQuery

Overview pjscrape is a framework for anyone who's ever wanted a command-line tool for web scraping using Javascript and jQuery. Built to run with PhantomJS, it allows you to scrape pages in a fully rendered, Javascript-enabled context from the command line, no browser required.

2/07/2014

Chrome 線上應用程式商店 - OneTab

Chrome 線上應用程式商店 - OneTab

Save up to 95% memory and reduce tab clutter in Google Chrome. Whenever you find yourself with too many tabs, click the OneTab icon to convert all of your tabs into a list. When you need to access the tabs again, you can either restore them individually or all at once. When your tabs are in the OneTab list, you will save up to 95% of memory because you will have reduced the number of tabs open in Google Chrome.

command line smushit

http://abhirama.wordpress.com/2010/10/20/a-command-line-tool-to-run-smush-it/

java -jar smushit.jar -imageDir=/foo -verbose=true -dryRun=false -imgExtensions=gif,png,jpeg

jsdelivr

https://github.com/jsdelivr/jsdelivr.com/commit/c958acc742a1bb8d2966ff48a09632284e1dfa05
http://www.jsdelivr.com/

lists: https://github.com/jsdelivr/jsdelivr/tree/master/files

2/04/2014

appear.in – one click video conversations

appear.in – one click video conversations

Video conversations with up to 8 people for free. No login – no installs