Skip to content

Instantly share code, notes, and snippets.

@vietlq
vietlq / Rinkeby.md
Created October 5, 2017 20:33 — forked from learner-long-life/Rinkeby.md
How to get on Rinkeby Testnet in less than 10 minutes

How to get on Rinkeby Testnet in less than 10 minutes

Following instructions from the excellent https://www.rinkeby.io/

Synchronizing a Full Node

A full node lets you access all state. There is a light node (state-on-demand) and wallet-only (no state) instructions as well,

@vietlq
vietlq / decrypt.py
Created October 9, 2017 22:16 — forked from vayn/decrypt.py
Example of PyCrypto AES decryption
import base64
import hashlib
import hmac
from Crypto.Cipher import AES
key = base64.decodebytes(b'v4QC6l4ttEogiBYvjLyvbA==')
nonce = base64.decodebytes(b'3iNVHJXuCfYoU9QP49DGqw==')
ct = base64.decodebytes(b'x9WM3Qy15Xw/2Z6pGVKXVA==')
@vietlq
vietlq / random.md
Created November 13, 2017 14:10 — forked from joepie91/random.md
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

Building a Facebook application and hosting it in Heroku

Introduction

With Facebook's Graph API and the creation of the Open Graph protocol, it is now easier then ever before to read and write data from and to the "social graph". Here's a few of the possibilities:

  • You could turn your webpage into a fully-featured Facebook-like page, just like if you were inside Facebook.
import Html exposing (..)
import Html.Events exposing (..)
main : Program Never Model Msg
main =
Html.program
{ init = init
, view = view
, update = update
, subscriptions = \_ -> Sub.none
@vietlq
vietlq / curl-problem.md
Created December 24, 2017 19:58 — forked from jonatanrdsantos/curl-problem.md
curl port 443: Network is unreachable problem

How to solve the curl port 443: Network is unreachable problem:

joridos@localhost:~/Documents/github$ opam init
default    Downloading https://opam.ocaml.org/urls.txt
'opam init' failed.
# opam-version    1.1.1
# os              linux
Cannot download https://opam.ocaml.org/urls.txt, please check your connection settings.
joridos@localhost:~/Documents/github$ curl https://opam.ocaml.org/urls.txt
@vietlq
vietlq / default.reg
Created December 27, 2017 21:50 — forked from P4/default.reg
Color schemes for Windows Command Prompt
Windows Registry Editor Version 5.00
; Default color scheme
; for Windows command prompt.
; Values stored as 00-BB-GG-RR
[HKEY_CURRENT_USER\Console]
; BLACK DGRAY
"ColorTable00"=dword:00000000
"ColorTable08"=dword:00808080
; BLUE LBLUE
@vietlq
vietlq / Ethereum_private_network.md
Created January 6, 2018 21:42 — forked from 0mkara/Ethereum_private_network.md
Ethereum private network configuration guide.

Create your own Ethereum private network

Introduction

Used nodes:

Linux raspberrypi 4.9.41-v7+ #1023 SMP Tue Aug 8 16:00:15 BST 2017 armv7l GNU/Linux
Linux localhost.localdomain 4.14.5-200.fc26.x86_64 #1 SMP Mon Dec 11 16:29:08 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
package main
import (
"github.com/syndtr/goleveldb/leveldb"
"fmt"
"encoding/binary"
"github.com/ethereum/go-ethereum/core/types"
"bytes"
"github.com/ethereum/go-ethereum/rlp"
)
@vietlq
vietlq / docker-cleanup-resources.md
Created January 27, 2018 19:49 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm