Skip to content

Instantly share code, notes, and snippets.

View tennisonchan's full-sized avatar

Tennison Chan tennisonchan

  • Truewind
  • San Francisco
View GitHub Profile
@tennisonchan
tennisonchan / contracts...Controller.sol
Last active January 15, 2022 05:27
Ethernaut-5-Telephone-0x0b6F6CE4BCfB70525A31454292017F640C10c768
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "./Telephone.sol";
contract Controller {
Telephone public originalContract = Telephone(0x88E435a53D3cccb830CDEde7a5bA2A165E7CAe1c);
function callChangeOwner () public {
@tennisonchan
tennisonchan / contracts...CoinFlip.sol
Last active January 15, 2022 04:58
Ethernaut - CoinFlip - 0x4dF32584890A0026e56f7535d0f2C6486753624f
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import '@openzeppelin/contracts@3.4.0/math/SafeMath.sol';
contract CoinFlip {
using SafeMath for uint256;
uint256 public consecutiveWins;
uint256 lastHash;
# /bin/bash
# Create a file that will be used for swap
sudo fallocate -l 1G /swapfile
# If `fallocate` is not installed or if you get an error message saying fallocate failed: `Operation not supported`
# You can use the following command to create the swap file
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
# Only the root user should be able to write and read the swap file. To set the correct permissions type
@tennisonchan
tennisonchan / cloudbuild.yaml
Last active March 30, 2020 00:55
GCR cloud build
steps:
# npm install
- name: 'gcr.io/cloud-builders/npm'
args: ['install']
# run unit tests
- name: 'gcr.io/cloud-builders/npm'
args: ['run', 'test:unit']
# run build
@tennisonchan
tennisonchan / docker_push_gcr.sh
Last active March 30, 2020 00:18
create and push the docker image to Google Container Registry gcr.io
# add the Dockerfile
# build the docker
sudo docker build ./
# copy the docker image id <docker_image_id>
# run the docker image local on 8080
sudo docker run -p 8080:8080 [SOURCE_IMAGE]
# from the node 10 image
FROM node:10
# set the working dir
WORKDIR /usr/src/app
# define the env variables port and host
ENV PORT 8080
ENV HOST 0.0.0.0
#bin/bash
# show an interactive process viewer for Unix
htop
# to allocate 1G file space to /swapfile
sudo fallocate -l 1G /swapfile
# write input from /dev/zero to /swapfile for block size of 1024
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
@tennisonchan
tennisonchan / Aaron Swartz: Guerilla Open Access Manifesto
Created October 12, 2019 02:01
Aaron Swartz: Guerilla Open Access Manifesto
Information is power. But like all power, there are those who want to keep it for themselves. The world’s entire scientific and cultural heritage, published over centuries in books and journals, is increasingly being digitized and locked up by a handful of private corporations. Want to read the papers featuring the most famous results of the sciences? You’ll need to send enormous amounts to publishers like Reed Elsevier.
There are those struggling to change this. The Open Access Movement has fought valiantly to ensure that scientists do not sign their copyrights away but instead ensure their work is published on the Internet, under terms that allow anyone to access it. But even under the best scenarios, their work will only apply to things published in the future. Everything up until now will have been lost.
That is too high a price to pay. Forcing academics to pay money to read the work of their colleagues? Scanning entire libraries but only allowing the folks at Google to read them? Providing scientific a
# based off of this code https://gist.github.com/nandajavarma/a3a6b62f34e74ec4c31674934327bbd3
# Brandon Skerritt
# https://skerritt.tech
def binary_search(the_array, item, start, end):
if start == end:
if the_array[start] > item:
return start
else:
return start + 1
@tennisonchan
tennisonchan / tmux-cheatsheet.markdown
Created June 17, 2019 21:11 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname