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: UNLICENSED | |
pragma solidity 0.8.26; | |
contract Queue { | |
uint256[] public data; | |
uint256 public maxCapacity; //mutable | |
// might consider making them private | |
uint256 public front; | |
uint256 public back; |
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
--- clone using CREATE opcode --- | |
function _cloneWithV1(address _contract) | |
private | |
returns (address result) | |
{ | |
bytes20 addressBytes = bytes20(_contract); | |
// solhint-disable-next-line no-inline-assembly | |
assembly { | |
let clonePlaceholder := mload(0x40) |
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 _swapTokenToEth( | |
address[] memory swapPath, | |
uint256 exchangeAmount, | |
uint256 deadline, | |
uint256 slippage, | |
uint256 ethPerToken | |
) internal returns (uint256) { | |
uint256[] memory amounts = | |
sushiswapRouter.getAmountsOut(exchangeAmount, swapPath); | |
uint256 sushiAmount = amounts[amounts.length - 1]; //amount of ETH |
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
"use strict"; | |
var __importDefault = (this && this.__importDefault) || function (mod) { | |
return (mod && mod.__esModule) ? mod : { "default": mod }; | |
}; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
exports.callTest = exports.testMoveFromPolygon = void 0; | |
const sdk_1 = require("@composable-finance/sdk"); | |
const vaults_1 = require("@composable-finance/sdk/dist/src/config/vaults"); | |
const L2Vault_json_1 = __importDefault(require("@composable-finance/sdk/dist/src/utils/abi/L2Vault.json")); | |
const ethers_1 = require("ethers"); |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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 PrefixInteger(num, length) { | |
return (Array(length).join('0') + num).slice(-length); | |
} |
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
+new Date() |
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
var a = [4,5,6]; | |
var b = [7,8,9]; | |
Array.prototype.push.apply(a, b); |
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
Every JavaScript object has an internal property called [[Prototype]]. If you look up a property via obj.propName or obj['propName'] and the object does not have such a property - which can be checked via obj.hasOwnProperty('propName') - the runtime looks up the property in the object referenced by [[Prototype]] instead. If the prototype-object also doesn't have such a property, its prototype is checked in turn, thus walking the original object's prototype-chain until a match is found or its end is reached. | |
Some JavaScript implementations allow direct access to the [[Prototype]] property, eg via a non-standard property named __proto__. In general, it's only possible to set an object's prototype during object creation: If you create a new object via new Func(), the object's [[Prototype]] property will be set to the object referenced by Func.prototype. | |
------------------------------------------------------------------------------ | |
var obj = new Object(); | |
obj.test = function() { alert('Hello?'); }; | |
In |
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.goDeep = function(levels, func){ | |
var iterateChildren = function(current, levelsDeep){ | |
func.call(current, levelsDeep); | |
if(levelsDeep > 0) | |
$.each(current.children(), function(index, element){ | |
iterateChildren($(element), levelsDeep-1); | |
}); | |
}; |