Skip to content

Instantly share code, notes, and snippets.

View maurelian's full-sized avatar
💯

Maurelian maurelian

💯
View GitHub Profile
@maurelian
maurelian / gist:e9a226782c1830376ac79baf87447002
Last active October 5, 2023 16:42
vrepo (view repo) alias for getting source and opening it in your editor quickly.
vrepo () {
if [[ $# -ne 1 ]]
then
echo "Usage: vRepo <github URL or org/repo-name>"
return 1
fi
if [[ $1 == *"github.com"* ]]
then
urlPath=$(echo $1 | sed 's/.*github.com\///')
org=$(echo $urlPath | cut -d '/' -f1)
@maurelian
maurelian / chat
Last active July 13, 2023 16:24 — forked from spullara/chat
Use this command to get suggestions on how to do things on the command line.
#!/bin/bash
TOKEN=< OpenAI token from https://platform.openai.com/account/api-keys >
PROMPT="You are the best at writing shell commands. Assume the OS is Ubuntu. I want you to respond with only the shell commands separated by semicolons and no commentary. Here is what I want to do: $@"
RESULT=`curl -s https://api.openai.com/v1/chat/completions \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $TOKEN" \
-d "{
\"model\": \"gpt-3.5-turbo\",
\"messages\": [{\"role\": \"user\", \"content\": \"$PROMPT\"}]
}" | jq '.choices[] | .message.content' -r`

Feel free to copy and paste this list into a README, issue or elsewhere in your project.

Audit prep checklist (reference)

  • Documentation (A plain english description of what you are building, and why you are building it. Should indicate the actions and states that should and should not be possible)
    • For the overall system
    • For each unique contract within the system
  • Clean code
  • Fix compiler warnings
@maurelian
maurelian / twitter_is_down.txt
Last active June 29, 2023 22:13
Official gist for discussing future twitter outages
That's OK. We can still talk about it here, right?
...
Right?

NSLOC stands for 'Normalized Source Code', which is a custom measurement we use (among others) when evaluating the complexity of a codebase.

To get the NSLOC count of a file:

  1. For all functions, reduce any multiline function declarations to a single line.
  2. Remove all comments
  3. Remove all empty lines
  4. Count the remaining lines

Example:

@maurelian
maurelian / gpt-ownable-non-bug.md
Created December 12, 2022 16:25
Smart contract bug reported by chatGPT

Description

A security vulnerability has been identified in the Ownable contract. The vulnerability lies in the constructor function, which allows anyone to become the owner of the contract without any authentication or authorization. This could potentially allow malicious actors to gain control of the contract and use it for malicious purposes.

The vulnerability can be exploited by sending a transaction to the contract from any address. This would set the _owner variable to the address of the sender, granting them full control of the contract. This could allow malicious actors to modify the contract, transfer funds, or otherwise

@maurelian
maurelian / UtxoToken.sol
Last active December 23, 2022 21:26
UTXO Token
pragma solidity ^0.4.10;
// Based on Alex Miller's design, with minor revisions to appease the compiler, and incorporate Christian Lundkvist's
// input about hash collisions.
contract Bitcoin {
struct UTXO {
address owner;
uint value;
@maurelian
maurelian / composability.md
Last active October 20, 2022 16:55
Composability Gotchas

Ethereum Composability Security Guidelines

The following is an informal compendium of ways you can screw up when mixing and matching smart contracts:

ERC20

0x1889dc51448166ca751b713f4532e293c9f22cbd7a2354ec4c1ec18012cf50ec

@maurelian
maurelian / console.sol
Last active February 25, 2022 18:44
A JS style console.log() function for solidity.
pragma solidity ^0.4.10;
// Update: Just use HardHat's: https://github.com/nomiclabs/hardhat/blob/master/packages/hardhat-core/console.sol
// Enables event logging of the format `console.log('descriptive string', variable)`,
// without having to worry about the variable type (as long as an event has been declared for that type in the
// Console contract.
contract Console {
event LogUint(string, uint);