Skip to content

Instantly share code, notes, and snippets.

Avatar

Oleg Andreev oleganza

View GitHub Profile
View Gitbox restart
-----------
Please try this:
1. Quit Gitbox.
2. Delete ~/Library/Preferences/com.oleganza.gitbox.plist
3. Run in Terminal: defaults delete com.oleganza.gitbox
4. Run in Terminal: git config --global push.default matching
5. Open Gitbox.
View gist:9845265
### Keybase proof
I hereby claim:
* I am oleganza on github.
* I am oleganza (https://keybase.io/oleganza) on keybase.
* I have a public key whose fingerprint is AB70 0EB4 91D6 3812 D5B0 AE40 6456 F1F5 C543 2530
To claim this, I am signing this object:
@oleganza
oleganza / gist:10458460
Created Apr 11, 2014
js password generator
View gist:10458460
// Based on oi.js by Dan Kaminsky https://gist.github.com/PaulCapestany/6148566
var base58alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
function millis() { return Date.now(); }
function flip_coin() { n=0; then = millis()+1; while(millis()<=then) { n=!n; } return n; }
function get_fair_bit() { while(1) { a=flip_coin(); if(a!=flip_coin()) { return(a); } } }
function get_random_6bit(){ n=0; bits=6; while(bits--){ n<<=1; n|=get_fair_bit(); } return n; }
function get_password(length) {
var password = "";
var offset = 0; // offset allows us to go through the infinite alphabet thus minimizing bias towards lower characters.
@oleganza
oleganza / BIP-Fractional-Storage-Identifier.md
Last active Aug 29, 2015
BIP: Fractional Storage Identifier
View BIP-Fractional-Storage-Identifier.md

BIP: Fractional Storage Identifier

Abstract

In Bitcoin we might want to have fractional storage of blocks and transaction state so that many more nodes can fully validate incoming blocks without sacrificing a lot of disk space. We propose a scheme that allows nodes to advertise which fraction of the data set they can provide and enables uniform distribution of such fractions among nodes. The scheme also allows reducing individual fraction at no extra cost to scale with the gbrowth of the network.

Scheme

View BIP-Fractional-Full-Node.md

BIP Draft: Fractional Full Node

Abstract

We explore the way to make full Bitcoin nodes store only a fraction of data while being able to fully validate every incoming block and get information about any output or transaction.

Strategy

@oleganza
oleganza / filter-api-diff.rb
Created Jun 5, 2014
Strip away "method->property" updates from iOS/OSX API diffs
View filter-api-diff.rb
# Oleg Andreev @oleganza
#
# This is a script that strips away all lines about converting methods to properties.
# Filtered file is easier to read to find what's new.
#
# 1. Save html file with API diff.
# 2. Run filter-api-diff.rb <name-of-the-file.html>
# 3. Open <name-of-the-file.html>-filtered.html in Safari.
#
# This script adds absolute URLs for stylesheets, no worries about them.
View gist:85f32f6ad860c0d53f8c
// Y-combinator in Swift.
func Y<y,⒴>(𝖸:((y)->⒴)->((y)->⒴))->((y)->⒴){
var Y:((y)->⒴)!;Y=𝖸{Y($0)};return Y
}
// Couldn't find a way to avoid such explicitness.
// If types are defined in the inner function, compiler cannot infer type of 'f'.
let factorial = Y {(f:((Int)->Int)) -> ((Int)->Int) in
return {n in
@oleganza
oleganza / gist:9805d0c42172803253a7
Last active Aug 29, 2015
Replacement for ?: operator in Clang
View gist:9805d0c42172803253a7
// Replacement for Clang's (a ?: b) in Swift.
// Note: does not yet handle case when 'false' is supplied as Any? or AnyObject? type.
operator infix ||| { associativity left precedence 140 }
// Version for arbitrary optionals.
@infix func |||<A>(a:A?, b: @auto_closure ()->A?) -> A? {
if let x = a {
return a
}
View gist:bd14f60643395706efaa

A reader asked me over email recently:

Have you posted anything or had any thoughts on Ghash.IO situation?

Nothing on this. I think it's just early volatility in bitcoin space. Some company (CEX) got serious about making a private mining farm and made a whopping share. Others will follow soon.

The dirty little secret of the blockchain is that it's not secure until increasing the hashrate by even 1% is an enormous economic feat. Currently it's not impossibly expensive to build your own farm with significant share - therefore the network is not very theoretically secure. Even if every existing pool had no more than 10%, you can't be sure that some guy does not unleash enormous hashing power at once and reverts some transactions.

When more companies start building private farms (and they will, it's the only cost-efficient way to mine; individual miners will soon disappear), you'll see more even distribution of the hashrate, but most importantly, the growth of hashrate will get slower. Because the slo

@oleganza
oleganza / async_swift_promises.md
Created Jun 25, 2015
Async Swift with explicit Promises
View async_swift_promises.md
// Before
func makeSandwich(completionHandler: (result:Sandwich)->Void)

// After
async func makeSandwich() -> Sandwich

// Informally equivalent to: