Skip to content

Instantly share code, notes, and snippets.

@PaulLaux
PaulLaux / .zshrc
Created December 31, 2022 12:52
zsh minimal config
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/home/px1/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes

Keybase proof

I hereby claim:

  • I am paullaux on github.
  • I am paullaux (https://keybase.io/paullaux) on keybase.
  • I have a public key ASAHyAhakY5YMJLfVmp_MS443UO7RTnHkIDDcYIQiVqjxgo

To claim this, I am signing this object:

@PaulLaux
PaulLaux / install-alacritty-ubuntu.sh
Last active December 24, 2018 08:39 — forked from Aaronmacaron/install-alacritty-ubuntu.sh
Install Alacritty on Ubuntu
#!/bin/bash
# This installs alacritty terminal on ubuntu (https://github.com/jwilm/alacritty)
# You have to have rust/cargo installed for this to work
# Install required tools
sudo apt-get install -y cmake libfreetype6-dev libfontconfig1-dev xclip
# Download, compile and install Alacritty
git clone https://github.com/jwilm/alacritty
@PaulLaux
PaulLaux / redux-saga-poll.js
Last active September 4, 2018 06:30
Polling pattern using redux-saga
export default function* defaultSaga() {
// ...
// The polling will start only after the first CHECK_BALANCES ends
yield [
fork(watchPollData),
takeLatest(CHECK_BALANCES, checkAllBalances),
];
}
// Start Polling when first call to checkAllBalances succeded or fails
@PaulLaux
PaulLaux / ethereum-transaction-register-redux-saga-channel.js
Last active September 3, 2018 11:14
Register to events generated by an Ethereum transaction
function* commitEthSendAsync() {
try {
const web3 = yield select(makeSelectWeb3());
// ...
contractInstance.methods.commit().send({
from: defaultAccount,
gasPrice,
value: web3.utils.toWei(amount.toString(), 'ether'),
}).once('transactionHash', (tx) => {
transactionChannel.put({
@PaulLaux
PaulLaux / ethereum-transaction-state-redux-saga-channel.js
Last active September 3, 2018 10:25
Updating ethereum transaction state using redux-saga channels
import { channel } from 'redux-saga';
const transactionChannel = channel();
/* Init Dapp */
function* initDappAsync(action) {
// ...
// fork to handle channel events
yield fork(handleChannelEvents);
}
@PaulLaux
PaulLaux / eth-hot-wallet-send-token.js
Last active August 30, 2018 08:13
Sending token via Ethereum smart contract interaction with redux-saga
// full source: https://github.com/PaulLaux/eth-hot-wallet/blob/master/app/containers/Header/saga.js#L203
export function* SendTransaction() {
try {
// ...
const contractAddress = tokenInfo.contractAddress;
const sendParams = { from: fromAddress, value: '0x0', gasPrice, gas: maxGasForTokenSend };
const tokenAmount = amount * (10 ** tokenInfo.decimals);
function sendTokenPromise(tokenContractAddress, sendToAddress, sendAmount, params) {
return new Promise((resolve, reject) => {
@PaulLaux
PaulLaux / eth-hot-wallet-contract-methods.js
Last active August 30, 2018 08:04
Calling Ethereum contract methods via Web3.js
// Automatically determines the use of call or sendTransaction based on the method type
myContractInstance.myMethod(param1 [, ...][, callback]);
// Explicitly calling this method - simulate execution and return result
// No cost, no actual transaction is sent to the blockchain
myContractInstance.myMethod.call(param1 [, ...] [, callback]);
// Explicitly sending a transaction to this method
myContractInstance.myMethod.sendTransaction(param1 [, ...] [, callback]);
@PaulLaux
PaulLaux / eth-hot-wallet-sendTransaction.js
Last active August 29, 2018 10:43
Promisify web3.js sendTransaction to use it with saga.js
// https://github.com/PaulLaux/eth-hot-wallet/blob/master/app/containers/Header/saga.js#L203
export function* SendTransaction() {
try {
// ...
let tx;
const sendAmount = new BigNumber(amount).times(Ether);
const sendParams = { from: fromAddress, to: toAddress, value: sendAmount, gasPrice, gas: maxGasForEthSend };
function sendTransactionPromise(params) {
return new Promise((resolve, reject) => {
@PaulLaux
PaulLaux / eth-hot-wallet-store.js
Created August 29, 2018 06:35
Save encrypted keystore into local storage
import localStore from 'store/dist/store.modern';
/* keystore will be saved to local storage under this key */
export const localStorageKey = 'ks';
/**
* Save wallet to localStorage
*/
export function* saveWalletS() {
try {