/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
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.5.2; | |
contract Array { | |
uint256[] internal numbers; | |
constructor() public { | |
numbers.push(1); | |
numbers.push(2); | |
numbers.push(3); | |
} | |
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
#!/usr/bin/env bash | |
set -e | |
if [ -z "$1" ] | |
then | |
echo 'Error: Registry-mirror url required.' | |
exit 1 | |
fi | |
MIRROR_URL=$1 |
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 { deepStrictEqual } = require("assert"); | |
function flat(data) { | |
function* _flat(arr) { | |
for (const v of arr) { | |
if (v instanceof Array) { | |
yield* _flat(v); | |
} else { | |
yield v; | |
} |
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 { deepStrictEqual } = require("assert"); | |
const table = "ABCDEFGHIJKLMNOPQRSTUVWXWZ"; | |
const tableLength = table.length; | |
// 13.1 | |
{ | |
const func1 = row => { | |
let result = 0; | |
const rowlength = row.length; |
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 { deepEqual } = require("assert"); | |
/** | |
* router path resolver | |
* @param {string} path | |
* @param {{[key: string]: string}} data | |
*/ | |
const router = (path, data) => { | |
for (const [key, value] of Object.entries(data)) { | |
path = path.replace(new RegExp(":" + key, "g"), value); |
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 fib_rec(n) { | |
if (n <= 1) { | |
return 1; | |
} | |
return fib_rec(n - 1) + fib_rec(n - 2); | |
} | |
function fib_loop(n) { | |
let [pre, cur] = [0, 1]; |
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
/** | |
* move k index from array | |
* @param {number[]} arr | |
* @param {number} k | |
*/ | |
function move(arr, k) { | |
if (k == 0) { | |
return arr; | |
} | |
let length = arr.length; |
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
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
fmt.Println(find("abcabcd")) | |
} |
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.5.0; | |
interface Callable { | |
function test() external returns (address); | |
} | |
// user: 0xca35b7d915458ef540ade6068dfe2f44e8fa733c | |
// TestAddress: 0xbbf289d846208c16edc8474705c748aff07732db | |
// CallAddress: 0x692a70d2e424a56d2c6c27aa97d1a86395877b3a | |
// user call Test.callTest(CallAddress) |