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 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 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 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 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 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
# Rakefile | |
require File.expand_path('../config/application', __FILE__) | |
Rails.application.load_tasks | |
# Replace yarn with npm | |
Rake::Task['yarn:install'].clear if Rake::Task.task_defined?('yarn:install') | |
Rake::Task['webpacker:yarn_install'].clear | |
Rake::Task['webpacker:check_yarn'].clear |
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
# DEPRECATED checkout my dotfiles/install script for the up to date version | |
# https://github.com/dmshvetsov/dotfiles/blob/master/install | |
set -e | |
ssh -q git@github.com | true | |
if [ $? -eq 0 ]; then | |
echo "SSH to github OK" | |
else | |
echo "Cannot connect to github via SSH. Are you added your SSH key to your github account?" |
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 doIfExist(obj, predicateValuesPaths, fn) { | |
const values = predicateValuesPaths.map((keyPath) => get(obj, keyPath)) | |
if (all(values, truthy)) { | |
return fn(...values) | |
} | |
return | |
} |
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 Roman | |
NUMS = [ | |
[10, 'X'], | |
[9, 'IX'], | |
[5, 'V'], | |
[4, 'IV'], | |
[1, 'I'] | |
].freeze | |
def self.from(val) |
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 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 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 | |
* | |
*/ |
NewerOlder