Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Geonwoo Shin thomashin

🏠
Working from home
Block or report user

Report or block thomashin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View spec.k
behaviour transfer of Token
interface transfer(address To, uint256 Value)
types
FromBal : uint256
ToBal : uint256
storage
@thomashin
thomashin / mocha-guide-to-testing.js
Created Jun 12, 2019 — forked from samwize/mocha-guide-to-testing.js
Explain Mocha's testing framework - describe(), it() and before()/etc hooks
View mocha-guide-to-testing.js
// # Mocha Guide to Testing
// Objective is to explain describe(), it(), and before()/etc hooks
// 1. `describe()` is merely for grouping, which you can nest as deep
// 2. `it()` is a test case
// 3. `before()`, `beforeEach()`, `after()`, `afterEach()` are hooks to run
// before/after first/each it() or describe().
//
// Which means, `before()` is run before first it()/describe()
View Feeling Good: Justin's Program.md

I decided to write this guide because I have been pretty happy recently. I would go as far as to say that I am the happiest I’ve ever been (in a sustained way) in my adult life, and completely independent of my external circumstances. This is how I’ve done it.

Background In our society today it is easy to get caught on the hedonic treadmill: the belief that happiness is just around the corner if one can only achieve the next milestone, or experience the next life experience. This is a trap. As someone who has achieved more and more success over time, and experienced more and more fun, positive, exciting things, no achievement or experience has ever resulted in a sustained increase to baseline happiness for me.

Expectations for how you will feel once you achieve your goal lead to an endless cycle of suffering. Either you get what you want and then set new, higher, loftier goals, or you don’t get what you want and end up feeling miserable. In The Score Takes Care of Itself, Bill Walsh tells of winning three S

@thomashin
thomashin / 12 tips for writing clean and scalable JavaScript.md
Created May 7, 2019
12 tips for writing clean and scalable JavaScript
View 12 tips for writing clean and scalable JavaScript.md

1. Isolate your code

topic과 분리해서 명백한 로직의 덩어리가 필요하다. 만약 함수를 작성하면 반드시 하나의 목적을 가지는 것으로 작성해야 한다. 하나의 함수에서 여러 목적의 기능이 들어가면 안된다.

또한 에러를 줄이기 위해서는 함수 내부에서만 상태 변경을 일으켜야 한다. 만약 함수 외부에서 상태를 변경시키고자 할 땐 함수에서 데이터를 리턴받아서 사용한다.

2. Modularization

만약 여러 개의 함수가 같은 방식으로 비슷한 것을 처리할 땐 하나의 모듈로 처리할 수 있다.

@thomashin
thomashin / gist:84bc5e829059238b99f12b641e9568aa
Created May 7, 2019
12 tips for writing clean and scalable JavaScript.md
View gist:84bc5e829059238b99f12b641e9568aa
### 1. Isolate your code
topic과 분리해서 명백한 로직의 덩어리가 필요하다. 만약 함수를 작성하면 반드시 **하나의 목적**을 가지는 것으로 작성해야 한다. 하나의 함수에서 여러 목적의 기능이 들어가면 안된다.
또한 에러를 줄이기 위해서는 함수 내부에서만 상태 변경을 일으켜야 한다. 만약 함수 외부에서 상태를 변경시키고자 할 땐 함수에서 데이터를 리턴받아서 사용한다.
### 2. Modularization
만약 여러 개의 함수가 같은 방식으로 비슷한 것을 처리할 땐 하나의 모듈로 처리할 수 있다.
View Attacker.js
pragma solidity ^0.5.0;
import "./PaymentSharer.sol";
contract Attacker {
address private victim;
address payable owner;
constructor() public {
owner = msg.sender;
View PaymentSharer.js
pragma solidity ^0.5.0;
contract PaymentSharer {
mapping(uint => uint) splits;
mapping(uint => uint) deposits;
mapping(uint => address payable) first;
mapping(uint => address payable) second;
function init(uint id, address payable _first, address payable _second) public {
require(first[id] == address(0) && second[id] == address(0));
View StorageVariableIndexOrder.sol
pragma solidity ^0.4.24;
contract A {
uint256 public a;
uint256 public b;
}
contract B {
uint256 public c;
uint256 public d;
View delegatecall.sol
pragma solidity ^0.4.24;
contract D {
function callSetN(address _e, uint _n) public {
_e.call.value(10).gas(6712353)(bytes4(keccak256("setN(uint256)")), _n);
// E's storage is set, D is not modified
}
function callcodeSetN(address _e, uint _n) public {
_e.callcode.value(10).gas(6712353)(bytes4(keccak256("setN(uint256)")), _n);
You can’t perform that action at this time.