Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Peteris Erins Pet3ris

🎯
Focusing
View GitHub Profile
@Pet3ris
Pet3ris / packing.cairo
Created Dec 26, 2021
Bitwise packing & unpacking in cairo
View packing.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 Sep 6, 2021
Buggy setCompSpeedInternal
View ComptrollerExcerpt.sol
/**
* @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()});
View cityandman.md
  • 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 / PromiseQueue.re
Created Aug 14, 2020
Lazy promise queue implementation in ReasonML
View PromiseQueue.re
// 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 Aug 11, 2020
YUL ast output from Solidity
View yulast.json
{
"AST": {
"nodeType": "YulBlock",
"src": "355:175:0",
"statements": [
{
"nodeType": "YulVariableDeclaration",
"src": "369:22:0",
"value": {
"arguments": [
@Pet3ris
Pet3ris / list.txt
Created Jul 14, 2020
Webpack npm list
View list.txt
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 Jun 8, 2020
dYdX solo in one file
View dydx.sol
/*
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 / idea.scala
Created Dec 25, 2012
Typed type tensors in scala
View idea.scala
sealed trait Tensor[V] {
val n, m: Int
def apply(vs: List[V], vds: List[V => Double]): Double
}
case class TUnit[V](v: V) extends Tensor[V] {
val n = 1
val m = 0
def apply(vs: List[V], vds: List[V => Double]): Double = vds head(v)
}
View tlp.clj
; Temporal logic programming with explicit time using core.logic
; we assume relations s, <o and constants zero, one, four are defined as in
; https://github.com/frenchy64/Logic-Starter/blob/master/src/logic_introduction/numbers.clj
; we start by using 'next' to define a Fibonacci relation
; that is equal to F(n) at time n
; We use the small trick that if a number
; has a predecessor and then another, then it is at least 2
(defn fib [v t]
@Pet3ris
Pet3ris / pinducer.hs
Created Dec 6, 2012
Basic program induction
View pinducer.hs
{-# LANGUAGE GADTs #-}
import Control.Monad
-- Basic program inducer
--
-- usage:
-- take 5 $ solve [(1, 2::Int), (2, 3)]
-- => [(+ 1 X),(+ X 1),(+ 0 (+ 1 X)),(+ 0 (+ X 1)),(+ 1 (+ 0 X))]
-- Expressions of the target language