Skip to content

Instantly share code, notes, and snippets.

View Pet3ris's full-sized avatar
🎯
Focusing

Peteris Erins Pet3ris

🎯
Focusing
View GitHub Profile
@Pet3ris
Pet3ris / XBankLendingVault.cairo
Created April 4, 2023 16:12
Yagi XBank Lending Vault Code
# SPDX-License-Identifier: AGPL-3.0-or-later
%lang starknet
from starkware.cairo.common.bool import TRUE, FALSE
from starkware.cairo.common.cairo_builtins import HashBuiltin
from starkware.starknet.common.syscalls import get_caller_address, get_contract_address
from starkware.cairo.common.uint256 import ALL_ONES, Uint256, uint256_check, uint256_eq
from openzeppelin.token.erc20.interfaces.IERC20 import IERC20
@Pet3ris
Pet3ris / packing.cairo
Created December 26, 2021 18:57
Bitwise packing & unpacking in cairo
%lang starknet
%builtins pedersen range_check bitwise
from starkware.cairo.common.cairo_builtins import BitwiseBuiltin, HashBuiltin
from starkware.cairo.common.bitwise import bitwise_and
from starkware.cairo.common.math import assert_nn_le
const WORD = 2 ** 16
const MASK = WORD - 1
const MASK2 = MASK * WORD
@Pet3ris
Pet3ris / ComptrollerExcerpt.sol
Last active September 6, 2021 10:20
Buggy setCompSpeedInternal
/**
* @notice Set COMP speed for a single market
* @param cToken The market whose COMP speed to update
* @param compSpeed New COMP speed for market
*/
function setCompSpeedInternal(CToken cToken, uint compSpeed) internal {
uint currentCompSpeed = compSpeeds[address(cToken)];
if (currentCompSpeed != 0) {
// note that COMP speed could be set to 0 to halt liquidity rewards for a market
Exp memory borrowIndex = Exp({mantissa: cToken.borrowIndex()});
  • 1978
  • The City and Man consists of provocative essays by the late Leo Strauss on Aristotle's Politics, Plato's Republic, and Thucydides' Peloponnesian Wars. Together, the essays constitute a brilliant attempt to use classical political philosophy as a means of liberating modern political philosophy from the stranglehold of ideology. The essays are based on a long and intimate familiarity with the works, but the essay on Aristotle is especially important as one of Strauss's few writings on the philosopher who largely shaped Strauss's conception of antiquity. The essay on Plato is a full-scale discussion of Platonic political philosophy, wide in scope yet compact in execution. When discussing
@Pet3ris
Pet3ris / fsm.clj
Created January 25, 2012 13:27
Finite State Machine in Clojure core.logic
(ns fsm
(:refer-clojure :exclude [==])
(:use [clojure.core.logic]))
;; Encoding a Finite State Machine and recognizing strings in its language in Clojure core.logic
;; We will encode the following FSM:
;;
;; (ok) --+---b---> (fail)
;; ^ |
@Pet3ris
Pet3ris / PromiseQueue.re
Created August 14, 2020 22:15
Lazy promise queue implementation in ReasonML
// Lazy PromiseQueue implementation
type pair('a) = ('a, t('a))
and t('a) = {next: Lazy.t(Js.Promise.t(option(pair('a))))};
let build = promise => {next: promise};
let empty: t('a) = lazy(Js.Promise.resolve(None)) |> build;
@Pet3ris
Pet3ris / yulast.json
Created August 11, 2020 11:54
YUL ast output from Solidity
{
"AST": {
"nodeType": "YulBlock",
"src": "355:175:0",
"statements": [
{
"nodeType": "YulVariableDeclaration",
"src": "369:22:0",
"value": {
"arguments": [
@Pet3ris
Pet3ris / list.txt
Created July 14, 2020 17:16
Webpack npm list
npm list
awesome-project@2.0.0 /Users/p/Dev/misc/webpack-parser
├─┬ @fullhuman/postcss-purgecss@1.1.0
│ └─┬ purgecss@1.1.0
│ ├── glob@7.1.2 deduped
│ ├─┬ postcss@7.0.14
│ │ ├─┬ chalk@2.4.2
│ │ │ ├─┬ ansi-styles@3.2.1
│ │ │ │ └── color-convert@1.9.0 deduped
@Pet3ris
Pet3ris / dydx.sol
Created June 8, 2020 11:25
dYdX solo in one file
/*
Copyright 2019 dYdX Trading Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
@Pet3ris
Pet3ris / PML.h
Created May 30, 2011 19:39
C++ marathon match libary
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <sys/time.h>
/** p=- *************************** Settings **********************************/
#define LENOVO_XP
#define TIME_LIMIT 9.8