Skip to content

Instantly share code, notes, and snippets.

@vietlq
vietlq / g++_clang_linter.sh
Created August 24, 2017 16:37
g++/clang Flags for Linter
g++ -Wall -Wno-unknown-pragmas -Wno-pragmas -Wno-unused -Wno-char-subscripts \
-Werror -fno-implicit-templates -Wno-long-long \
-c your_file.cpp
@vietlq
vietlq / query_github.py
Created September 20, 2017 06:32
VietFOSS: Query GitHub GraphQL using Python
# The original: https://github.com/VietFOSS/vn-foss/blob/master/query_github.py
import os, requests
GH_PERSONAL_TOKEN = os.environ['GH_PERSONAL_TOKEN']
GH_GRAPHQL_EP = '''https://api.github.com/graphql'''
GH_AUTH_VALUE = "bearer %s" % GH_PERSONAL_TOKEN
GH_HEADERS = {
"Authorization": GH_AUTH_VALUE,
"Content-Type": "application/x-www-form-urlencoded",
@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 / 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 / rinkeby_01.txt
Created October 5, 2017 20:43
Ether for Rinkeby
0x827c4C5789957dfd8A6a90d904bef931CE1B8Fee
@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 / test_v3_scrypt_aes_128_ctr_utc.json
Created October 14, 2017 13:01
VISCHub: Sample UTC JSON file for Ethereum Wallet
{
"version": 3,
"id": "f50f0234-d25c-42a9-8c2f-e777fafe5c2a",
"address": "389d46c0d5d20c8220ad236b5a25b348c67e3021",
"Crypto": {
"ciphertext": "7cc66b5740d2ce0942b5beef2a997f5d85a9ab0e10a166a9f31cc16372c72204",
"cipherparams": {
"iv": "d8acc1c0a3a18c61acc33ca05eeb19bf"
},
"cipher": "aes-128-ctr",
@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