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
pragma solidity ^0.8.3; | |
contract MyContract { | |
address payable private owner; | |
uint256 totalTokens; | |
constructor() public payable { | |
owner = payable(msg.sender); | |
totalTokens = 1000000000000; | |
} |
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
#!/bin/bash | |
echo '========== Welcome to Bitbucket -> Github migration!!! ==========' | |
echo 'Please insert github repository URL ->' | |
read -p '[URL] : ' githubURL | |
echo 'Checkout to master branch...' | |
git reset --hard HEAD | |
git co master |
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 { useState, useCallback } from 'react'; | |
export function useCircularCounter( | |
initialValue: number = 0, | |
max: number | |
): [number, () => void, () => void, () => void] { | |
const [value, setValue] = useState(initialValue); | |
const init = useCallback(() => setValue(0), []); |
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
function SuperClass (name = 'name') { | |
this.name = name; | |
} | |
SuperClass.prototype.say = function () { | |
console.log(`Hi, I am ${this.name}`); | |
} | |
function SubClass (name) { | |
SuperClass.apply(this, [name]); | |
} |
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
class MaxHeap { | |
constructor (maxLevel = 1) { | |
this.nodes = []; | |
} | |
// phase2 | |
insert (value) { | |
this.nodes.push(value); | |
this.bubbleUp(); | |
} |
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
#!/bin/bash | |
RED='\033[31m' | |
GREEN='\033[32m' | |
YELLOW='\033[33m' | |
NO_COLOR='\033[0m' | |
TILDE='~' | |
echo -e "[${YELLOW}Insert path of your project directory.${NO_COLOR}]" |
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
let avg = 0; | |
const numbers = []; | |
function average (numbers = []) { | |
const sum = numbers.reduce((prev, current) => prev + current, 0); | |
return sum/numbers.length; | |
} | |
console.time('avg1'); | |
for (let i = 1; i < 100001; i++) { | |
numbers.push(i); |
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
#!/bin/bash | |
echo '=====================================================================' | |
echo '========Please insert the directory name that you want to go=========' | |
echo '=====================================================================' | |
read -p '[Git Directory Path] : ' prompt | |
cd ~/$prompt |
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
const N = 624; | |
const M = 397; | |
const F = 1812433253; | |
const UPPER_MASK = (2 ** 32) / 2; // 0x80000000 | |
const LOWER_MASK = UPPER_MASK - 1; // 0x7fffffff | |
const MATRIX_A = 0x9908b0df; | |
class MersenneTwister { | |
constructor () { |
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
const state = [1827981275, 1295982171]; | |
function xorshift128plus () { | |
let s1 = state[0]; | |
let s0 = state[1]; | |
state[0] = s0; | |
s1 ^= s1 << 23; | |
s1 ^= s1 >> 17; | |
s1 ^= s0; |