Skip to content

Instantly share code, notes, and snippets.

View rzvl's full-sized avatar
🎯
Focusing

Reza rzvl

🎯
Focusing
View GitHub Profile
@rzvl
rzvl / hamchain-cal.js
Created July 22, 2024 09:37
HamsterChain Calculator
function calcProperties(p6) {
const p5 = Math.floor(p6 / 4.5);
const p4 = Math.floor(p5 / 4.5);
const p3 = Math.floor(p4 / 4.5);
const p2 = Math.floor(p3 / 4);
const p1 = Math.floor(p2 / 5);
console.log(p1.toLocaleString(), p2.toLocaleString(), p3.toLocaleString(), p4.toLocaleString(), p5.toLocaleString(), p6.toLocaleString())
}
function calcFoods(f6) {
@rzvl
rzvl / tsconfig.json
Last active April 12, 2022 15:05
Minimal tsconfig file settings
{
"compilerOptions": {
"rootDir": "./src",
"outDir": "./public",
"target": "es5"
},
// this setting forces TS not to compile any file out of 'src' folder
"include": ["src"]
}

Constant vs. Immutable Variables in Solidity

feature / variable constant immutable
cannot be modified ✔️ ✔️
can be assigned at constructor ✔️
define at file level ✔️
gas price compared to regular variables lowest lower
supported types strings + value types only value types
@rzvl
rzvl / ArrayReplaceLast.sol
Created March 20, 2022 22:37
Remove an element by replacing last
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
contract ArrayReplaceLast {
uint[] public arr;
function remove(uint _index) public {
arr[_index] = arr[arr.length - 1];
arr.pop();
}
@rzvl
rzvl / shift-remove.sol
Last active March 20, 2022 22:21
Remove an element by shifting
contract Array {
uint[] arr;
function remove(uint _index) private {
require(_index < arr.length, "index out of bound");
for (uint i = _index; i < arr.length - 1; i++) {
arr[i] = arr[i + 1];
}
@rzvl
rzvl / words-on-line.css
Created July 10, 2021 18:30
CSS technique for a horizontal line with words in the middle
h1 {
display: flex;
flex-direction: row;
}
h1:before, h1:after{
content: "";
flex: 1 1;
border-bottom: 1px solid;
margin: auto;
}
@rzvl
rzvl / clearfix.css
Last active July 10, 2021 18:32
The clearfix hack
.wrapper::after {
content: "";
clear: both;
display: block;
}
/* The modern way of solving this problem is to use the value flow-root of the display property. */
@rzvl
rzvl / minimal-table-styles.css
Created June 25, 2021 17:12
Minimal Table Styles from MDN
html {
font-family: sans-serif;
}
table {
border-collapse: collapse;
border: 2px solid rgb(200,200,200);
letter-spacing: 1px;
font-size: 0.8rem;
}
@rzvl
rzvl / reset.css
Last active April 26, 2022 16:27
My preferred reset settings for CSS
/* variables declared here - these are the colors for our pages, as well as the font stacks and sizes. */
:root {
--black: #171321;
--dkblue: #0d314b;
--plum: #4b0d49;
--hotmag: #ff17e4;
--magenta: #e310cb;
--aqua: #86fbfb;
--white: #f7f8fa;
--font-size: 1.3rem;