Skip to content

Instantly share code, notes, and snippets.

🐼

Dionysis Zindros dionyziz

🐼
Block or report user

Report or block dionyziz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View reentrancy.js
class Bank {
constructor() {
this.attacker_balance = 1;
}
withdraw() {
if (this.attacker_balance == 1) {
console.log('Sending ' + this.attacker_balance + ' ETH to attacker');
send_money_to_attacker(this.attacker_balance);
}
View rangeSumBST-func-simple.py
import operator
from functools import partial, reduce
def flatten(node):
if not node:
return []
return flatten(node.left) + [node.val] + flatten(node.right)
def rangeSumBST(root, L, R):
return reduce(operator.add,
View rangeSumBST-func.py
import operator
from functools import partial
class Node:
def __init__(self, val, left, right):
self.val = val
self.left = left
self.right = right
def lfilter(f, node):
View riddle.py
def ask(r):
p <- [0, 1] # define whether we will speak the truth or not
s <- [0, 1] # define "ya" as "yes" or "no" randomly
if r: # question has truthful answer
if p: # we are speaking the truth
if s: # the meaning of "ya" is "yes"
return "ya"
else:
return "da"
else: # we are lying
View blur.cpp
#include <cstdio>
#include <iostream>
#include <cairo.h>
using namespace std;
struct RGBA {
int a, r, g, b;
};
const int bytes_per_row = 4;
View gist:44629ec6b21d2f4adb6c4d0146136fa3
diff --git a/construction.tex b/construction.tex
index 79aa218..babee01 100644
--- a/construction.tex
+++ b/construction.tex
@@ -144,11 +144,18 @@ We will now show that the savings from the interlink set technique are significa
We can split it up at some arbitrary index $k \geq 0$:
- \begin{align*}
- \sum_{j=0}^\infty (2^{-i})^j &= \sum_{j=0}^k 2^{-ij} + \sum_{j=k+1}^\infty (2^{-i})^j\\
View missing-number.cpp
#include <iostream>
using namespace std;
int main() {
const int N = 10;
int numbers[] = {0, 2, 1, 3, 10, 4, 6, 7, 8, 5};
int answer = 0;
for (int bit = 0; (1 << bit) <= N; ++bit) {
View lis.py
def longest_increasing_subsequence(sequence):
best_length = -1
for bitmask in range(2**len(sequence)):
subsequence = []
for bit_idx in range(len(sequence)):
if bitmask & (1 << bit_idx):
subsequence.append(sequence[bit_idx])
if not sorted(subsequence) == subsequence:
continue
if len(subsequence) > best_length:
View gist:5b7e134279f692cbdd56701f0f0546e4
{
"compilerOptions": {
/* Basic Options */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": ["es2016", "DOM"], /* Specify library files to be included in the compilation. */
"resolveJsonModule": true, /* Allows for importing, extracting types from and generating .json files.
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
View judge-chai.js
const chai = require('chai')
const chaiAsPromised = require('chai-as-promised')
async judge() {
expect(tx.isSane(), 'TX not sane')
.to.be.true
expect(tx.inputs.length, 'TX doesn\'t have 1 input')
.to.equal(1)
expect(tx.outputs[0].value, `TX doesn't pay ${SATOSHI_VALUE / SATOSHIS_IN_BTC} BTC`)
.to.equal(SATOSHI_VALUE)
You can’t perform that action at this time.