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.0; | |
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; | |
import "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; | |
using MessageHashUtils for bytes; | |
using ECDSA for bytes32; | |
contract AddressExtractor { |
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
fn qs(a: &mut [i32]) { | |
if a.len() <= 1 { return; } | |
// track index of the first element that >= pivot (last element) | |
// gte = greater than or equal | |
let mut first_gte_index = 0; | |
let pivot_index = a.len() - 1; | |
for i in 0..pivot_index { | |
if a[i] >= a[pivot_index] { continue; } | |
a.swap(i, first_gte_index); |
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
# Show list of process affinities omitting threads | |
for pid in $(ps --ppid 2 -p 2 --deselect -o pid=); do taskset -pc $pid 2>/dev/null; done |
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 { ethers } = require("ethers"); | |
const rpcUrl = '' | |
const contractAddress = '' | |
const abi = [] | |
async function main() { | |
const provider = new ethers.JsonRpcProvider(rpcUrl); | |
const signer = new ethers.Wallet("", provider) | |
const contract = new ethers.Contract(contractAddress, abi, signer); |
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
def subs(str1, str2) | |
return nil if str2.size > str1.size | |
str1.each_char.with_index do |char, index| | |
next if char != str2[0] | |
match = true | |
str2[1..].each_char.with_index do |_, str2_slice_index| | |
str2_index = str2_slice_index + 1 | |
next if str2[str2_index] == str1[index + str2_index] |
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 Curry { | |
constructor(fn) { | |
return this.curry(fn, fn.length, []) | |
} | |
curry(fn, argRestCounter, args) { | |
if (argRestCounter === 0) return fn(…args); | |
return arg => this.curry(fn, argRestCounter — 1, […args, arg]); | |
} | |
} |
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
pipeline = [] | |
define_method :use, -> middleware do | |
pipeline.unshift(middleware) | |
end | |
class One | |
def initialize(app) | |
@app = app | |
end |
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 torch | |
from torch import nn | |
import numpy as np | |
net = nn.Sequential( | |
torch.nn.Linear(2, 1) | |
) | |
def fun(x1, x2): | |
return 2 * x1 + 3 * x2 + 5 |
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
# Carrierwave works incorrectly with file formatting. If you do not override | |
# path and url methods it will return you incorrect path and url to webp file | |
# respectively. Also you should add removing callback because Carrierwave could | |
# not delete webp file by itself because of incorrect path. | |
# Remove this hacks if this issue will be fixed. | |
class ItemGalleryUploader < ApplicationUploader | |
WEBP_VERSION_NAME = :webpver | |
WEBP_CONV_OPTIONS = {quality: 80, method: 5}.freeze | |
before :remove, :clear_webp_file |
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
# Carrierwave works incorrectly with file formatting. If you do not override | |
# path and url methods it will return you incorrect path and url to webp file | |
# respectively. Also you should add removing callback because Carrierwave could | |
# not delete webp file by itself because of incorrect path. | |
# Remove this hacks if this issue will be fixed. | |
class ItemGalleryUploader < ApplicationUploader | |
WEBP_VERSION_NAME = :webpver | |
def filename | |
splitted = original_filename.split('.') |
NewerOlder