Skip to content

Instantly share code, notes, and snippets.

@vietlq
vietlq / index.js
Created March 20, 2018 08:46 — forked from AndrewJakubowicz/index.js
Example of using neon after `neon new ... ` step
// JS calling Rust
var addon = require('../native');
console.log(addon.hello());
// -> "hello node"
console.log(addon.adder(1,2));
// -> 3
console.log(addon.objAdder({a: 2, b: 5}));
Verifying my Blockstack ID is secured with the address 1JgATzmvUGYJZYfQnHqTMo5GCfAgcPnQT6 https://explorer.blockstack.org/address/1JgATzmvUGYJZYfQnHqTMo5GCfAgcPnQT6
@vietlq
vietlq / send_transfer_call.sol
Created March 9, 2018 10:56 — forked from tomw1808/send_transfer_call.sol
This is an example of the difference between "address.send()", "address.call.value()()" and "address.transfer()" in Solidity. If you like this example, then checkout my courses I do on Udemy (https://vomtom.at/tag/course/)
pragma solidity ^0.4.13;
contract someContract {
mapping(address => uint) balances;
function deposit() payable {
balances[msg.sender] += msg.value;
}
@vietlq
vietlq / call-then-sendtx-pattern.js
Created March 6, 2018 07:41 — forked from ethers/call-then-sendtx-pattern.js
call-then-sendtx pattern for Ethereum Dapps
/*
In Ethereum, a contract can be written so that it returns a value for eth_call.
A Dapp can then check for success or error value of eth_call, before calling eth_sendTransaction,
to take advantage of eth_call effectively being a "preview" of the code flow that the transaction
will take. In traditional client-server, clients can't ask servers beforehand what's going to
happen when the client makes a call; with Dapps contracts can be written so that clients can ask
for a "preview" of what is going to happen, before any funds/ethers are actually utilized
(eth_call does not cost any ethers).
Note: it is possible that in between eth_call and when eth_sendTransaction is actually mined,
@vietlq
vietlq / bitcoin-pay.rb
Created February 9, 2018 16:22 — forked from Sjors/bitcoin-pay.rb
This script demonstrates how a bitcoin transaction is created and signed. Just pass in your own address and private key and it will prepare a transaction for you. You can then copy & paste that transaction into a webservice like Blockchain to send it. I wrote this mostly to understand better how it works. I sometimes had to "cheat" and look at t…
#!/usr/bin/env ruby
require 'open-uri'
require 'JSON'
require 'digest/sha2'
require 'pry'
require 'bigdecimal'
require 'bitcoin' # Because I need to cheat every now and then
# Usage:
# gem install pry json ffi ruby-bitcoin
@vietlq
vietlq / howto_nat_traversal.md
Created February 5, 2018 11:39 — forked from mildred/howto_nat_traversal.md
How To TCP NAT Traversal using Node.js and a STUN Server

How To TCP NAT Traversal using Node.js and a STUN Server

With the scarecity of IPv4 addresses, and IPv6 still not available at large, NAT traversal is becoming a necessity. Especially with the generalisation of Carrier-grade NATs that you can find on mobile connections. Even with IPv6 you may suffer NAT66. Imagine your mobile device that gets only a single Ipv6 address, and you want to share it on your computer.

The solution might be in a decentralized protocol for address attribution such

@vietlq
vietlq / pr.md
Created February 1, 2018 17:36 — forked from karlhorky/pr.md
Fetch all GitHub pull requests to local tracking branches
@vietlq
vietlq / curl.md
Created January 29, 2018 13:01 — forked from btoone/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@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