value = [3, 4, 5, 6]
longer_value = [3, 4, 5, 6, 8]
iter_value = iter(value)
print([*value])
# >>> [3, 4, 5, 6]
print([*value]*2)
# >>> [3, 4, 5, 6, 3, 4, 5, 6]
print([*iter(value)]*2)
This file contains hidden or 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 binarySearch = (length: number, condition: (idx: number) => boolean): number => { | |
| let [left, right] = [0, length]; // insertion point may be after the last element | |
| // half-open interval [left, right) so no candidates when left === right | |
| while (left < right) { | |
| const mid = Math.floor((left + right) / 2); | |
| if (condition(mid)) { // monotonic condition | |
| right = mid; // mid might still be the first true | |
| } else { | |
| left = mid + 1; |
This file contains hidden or 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/sh | |
| # This command installs binaries at specified versions | |
| # into $GOBIN, $GOPATH/bin or $HOME/bin. | |
| # It assumes Go 1.11. | |
| if [ $# = 0 ]; then | |
| usage: vgoget cmdpackage[@version]... >&2 | |
| exit 2 | |
| fi | |
| d=`mktemp -d` | |
| cd "$d" |
This file contains hidden or 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
| /** | |
| * Prints out the keys that changed and their old and new values. Useful for deeply | |
| * nested objects. | |
| * Bare minimum Typescript annotations to pass compiling | |
| **/ | |
| import _ from 'lodash'; | |
| import { useEffect, useRef } from 'react'; | |
| const isObject = (v: any) => v && typeof v === 'object'; |
This file contains hidden or 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 | |
| tabname() { | |
| printf "\e]1;$1\a" | |
| } | |
| new_tab() { | |
| TAB_NAME=$1 | |
| COMMAND=$2 | |
| osascript \ |
This file contains hidden or 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
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.10; | |
| import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; | |
| import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; | |
| import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; | |
| import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol"; | |
| import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol"; | |
| import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; | |
| import "@openzeppelin/contracts/utils/Strings.sol"; |
This file contains hidden or 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
| <template> | |
| <div>Hi I am the about page {{ info }}</div> | |
| </template> | |
| <script> | |
| export default { | |
| props: { | |
| info: String | |
| }, | |
| beforeRouteEnter(to, from, next) { |
This file contains hidden or 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 { GtmInstance } from './types' | |
| // will need this for multiple container environments | |
| export default ({ $gtm }: { $gtm: GtmInstance }) => { | |
| const gtagId = process.env.GOOGLE_TAG_MANAGER_ID | |
| if (gtagId) { | |
| $gtm.init(gtagId) | |
| $gtm.push({ event: 'gtm.js', 'gtm.start': new Date().getTime() }) | |
| } | |
| } |
A brief example on how to use npx to run gist based scripts.
Read the article here https://neutrondev.com/npm-vs-npx-whats-the-difference/
NewerOlder