This article is now published on my website: Prefer Subshells for Context.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fetch the changes from the remote | |
git fetch origin | |
# show commit logs of changes | |
git log master..origin/master | |
# show diffs of changes | |
git diff master..origin/master | |
# apply the changes by merge.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Add copy to clipboard from IPython! | |
To install, just copy it to your profile/startup directory, typically: | |
~/.ipython/profile_default/startup/ | |
Example usage: | |
%clip hello world | |
# will store "hello world" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This enables a publicly available server to forward connections to your computer behind a NAT. | |
# So if you access http://xx.xx.xx.xx:8080/ on your browser, traffic is redirected to your machine behind a NAT. | |
# on your local host, type: | |
ssh -R xx.xx.xx.xx:8888:localhost:80 root@xx.xx.xx.xx | |
# now wait for your shell, and type: | |
socat TCP-LISTEN:8080,FORK TCP:127.0.0.1:8888 | |
# This command outputs nothing, just keep it running. While you don't ^C, your tunnel is up and running! |
Chromium OS is cool. Chromium OS with crouton is cooler. Chromium OS with Docker is even cooler. This is specifically a guide for the Chromebook Pixel 2 (2015), but I can't think of any reason it wouldn't work with other devices.
To create a symlink to a Google Drive file or document there are a few methods.
You can right click the original file in the Google Drive UI and select Organize
and then Add Shortcut
There are also keyboard shortcuts. These shortcuts will change/have changed as of August 1st, 2024. Prior to August 2024 you could select the document you want to symlink, then hit Shift+Z and you'll be presented with a menu to choose the folder you'd like to add a symlink to
After August 2024, the keyboard shortcut is
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# please run: mkdir /tmp/img ; docker export $(docker create centos) | tar -C /tmp/img/ -xvf - | |
# before this script | |
import os | |
import ctypes | |
from multiprocessing import Process | |
CLONE_NEWUSER = 0x10000000 | |
CLONE_NEWPID = 0x20000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from eth_utils import encode_hex | |
from web3 import HTTPProvider, Web3 | |
from solc import compile_source | |
from web3.contract import ConciseContract | |
# Solidity source code | |
contract_source_code = ''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We require the Hardhat Runtime Environment explicitly here. This is optional | |
// but useful for running the script in a standalone fashion through `node <script>`. | |
// When running the script with `hardhat run <script>` you'll find the Hardhat | |
// Runtime Environment's members available in the global scope. | |
const hre = require("hardhat"); | |
async function main() { | |
// Hardhat always runs the compile task when running scripts through it. | |
// If this runs in a standalone fashion you may want to call compile manually | |
// to make sure everything is compiled |
OlderNewer