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
| function groupBy<T extends Record<string, string | number>, K extends keyof T>(list: T[], groupByKey: K): Record<T[K], T[]> { | |
| return list.reduce((acc, item) => { | |
| const groupValue = item[groupByKey] | |
| if (!acc[groupValue]) { | |
| acc[groupValue] = [item] | |
| } else { | |
| acc[groupValue].push(item) | |
| } | |
| return acc | |
| }, {} as Record<T[K], T[]>) |
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
| module 0xA::pyth_oracle_n_coin_transfer_a { | |
| struct State { | |
| // a place where depositor, asset and amount is stored | |
| } | |
| public entry fun colatarize_asset<Asset>(depositor: &signer, amount: u64) { | |
| let resource_account = get_resource_account(); | |
| coint::transfe<Asset>( | |
| depositor, | |
| resource_account, |
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
| type DotPrefix<T extends string> = T extends '' ? '' : `.${T}`; | |
| type DotNestedKey<T> = ( | |
| T extends object | |
| ? { | |
| [K in Exclude<keyof T, symbol>]: `${K}${DotPrefix< | |
| DotNestedKey<T[K]> | |
| >}`; | |
| }[Exclude<keyof T, symbol>] | |
| : '' | |
| ) extends infer 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
| import dotenv from "dotenv"; | |
| dotenv.config(); | |
| import assert from "assert"; | |
| import * as web3 from "@solana/web3.js"; | |
| import * as fs from "fs"; | |
| /** | |
| * Constants | |
| */ |
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
| function doIfExist(obj, predicateValuesPaths, fn) { | |
| const values = predicateValuesPaths.map((keyPath) => get(obj, keyPath)) | |
| if (all(values, truthy)) { | |
| return fn(...values) | |
| } | |
| return | |
| } |
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
| class Roman | |
| NUMS = [ | |
| [10, 'X'], | |
| [9, 'IX'], | |
| [5, 'V'], | |
| [4, 'IV'], | |
| [1, 'I'] | |
| ].freeze | |
| def self.from(val) |
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 K = 1000 | |
| const M = 1000 * K | |
| const KB = 1000 | |
| const MB = 1000 * KB | |
| const GB = 1000 * MB | |
| const TB = 1000 * GB | |
| const PB = 1000 * TB | |
| function Calc () { | |
| this.value = 100 * K |
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 { resolve } from 'path'; | |
| import fs from 'fs'; | |
| import { createBlobService } from 'azure-storage'; | |
| import config from 'config'; | |
| /** | |
| * Service to handle files downloads requests | |
| * | |
| */ |
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
| /* | |
| //so far we've worked with some basic operators | |
| Positive and negative operators (unary) | |
| + | |
| - | |
| Arithmetic (binary) | |
| + | |
| - | |
| / | |
| * |
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
| curl https://dmitryshvetsov.com/sitemap.xml | \ | |
| grep -e loc | \ | |
| sed 's:<loc>\(.*\)<\/loc>$:\1:g' | \ | |
| sed -e 's/^[[:space:]]*//' | \ | |
| sed 's/https:\/\/dmitryshvetsov\.com/http:\/\/localhost:8000/' | \ | |
| while read -r line; do open $line; done |
NewerOlder