Skip to content

Instantly share code, notes, and snippets.

@oleganza
oleganza / gist:8cc921e48f396515c6d6
Last active October 14, 2024 19:22
Proof that Proof-of-Work is the only solution to Byzantine Generals' problem

In reply to "@Vlad_Roberto: No, not a programmer. I just know there's better ways to doing anything without massive energy consumption & Banks."

The problem of blockchain synchronization is the following:

Imagine you are sitting in a bunker. You have no idea what people are out there and what are their intentions. You only receive some incoming messages from strangers that may contain anything. They can be just random garbage or deliberately crafted messages to confuse you or lie to you. You never know. You cannot trust anyone.e

The problem of "money" or any other "social contract" is that everyone should be able to know what the majority agrees to without trusting some intermediaries (otherwise they can easily obuse their special position). If everyone votes for "X", then you sitting in a bunker must somehow independently figure out that all those other people indeed voted for "X" and not for "Y" or "Z". But remember: you cannot trust anyone's message and messages are the only thing you get from the outsi

@staltz
staltz / introrx.md
Last active May 15, 2025 10:37
The introduction to Reactive Programming you've been missing
import cv2
import numpy as np
class BagOfFeatures:
"""This is a class of Bag-of-Features by K-means for OpenCV"""
codebookSize=0
classifier=None
def __init__(self, codebookSize):
self.codebookSize=codebookSize
self.classifier=cv2.KNearest()
@Zer0t3ch
Zer0t3ch / voronoi-generator.js
Last active August 2, 2017 20:48
Point/Line Manager for my Voronoi diagram generator
/**=- VERSION 1.2 -=**/
var canvas, c;
var dots = [ ];
var lines = [ ];
var count = 0;
var m = {
mousePos : function(canvas, evt) {
var rect = canvas.getBoundingClientRect();
@richardkundl
richardkundl / shuffle.cs
Created August 20, 2014 18:27
Fisher-Yates algorithm shuffle an array with O(n) time complexity
/// <summary>
/// Fisher-Yates algorithm with O(n) time complexity
/// </summary>
/// <param name="array">array to be shuffled</param>
/// <returns>shuffled array</returns>
public static int[] FisherYates(int[] array)
{
Random r = new Random();
for (int i = array.Length - 1; i > 0; i--)
{
@whistler
whistler / import.sh
Created March 16, 2015 17:31
Copy files to another repository while saving git history
# copied from http://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history/
git clone <git repository A url> # clone source repository
cd <git repository A directory>
git remote rm origin # to make sure it doesn't affect the original repository
git filter-branch --subdirectory-filter <directory 1> -- --all # remove all files other than the ones needed
mkdir <directory 1> # move them into another directory where they will be stored in the destination repository (if needed)
mv * <directory 1>
git add .
git commit
/*
* OGL_OCV_common.cpp
* Common interop between OpenCV and OpenGL
*
* Created by Roy Shilkrot on 2/16/2015
* Copyright 2015 Roy Shilkrot. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
@Smerity
Smerity / uniq_tasks_10k.txt
Created August 7, 2015 02:50
Analysis of duplicated data within bAbi Tasks v1.2
Unique samples in tasks_1-20_v1-2/en-10k/qa10_indefinite-knowledge_{}.txt
Train length: 9989
Test length: 1000
Intersection: 0
Unique samples in tasks_1-20_v1-2/en-10k/qa11_basic-coreference_{}.txt
Train length: 9827
Test length: 997
Intersection: 25
Unique samples in tasks_1-20_v1-2/en-10k/qa12_conjunction_{}.txt
Train length: 9991
@kod3r
kod3r / The Technical Interview Cheat Sheet.md
Last active August 26, 2015 01:03 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@kod3r
kod3r / tsws
Last active September 7, 2015 04:18 — forked from dfletcher/tsws
Totally simple web server using Bash and netcat (nc)
Moved to a proprer repositoy, TSWS is a real boy now!
https://github.com/dfletcher/tsws
PRs welcomed.