Skip to content

Instantly share code, notes, and snippets.

View viswanathkgp12's full-sized avatar

Viswanath viswanathkgp12

View GitHub Profile
@hrkrshnn
hrkrshnn / generic.org
Last active April 21, 2024 01:51
Some generic writeup about common gas optimizations, etc.

Upgrade to at least 0.8.4

Using newer compiler versions and the optimizer gives gas optimizations and additional safety checks for free!

The advantages of versions 0.8.* over <0.8.0 are:

  • Safemath by default from 0.8.0 (can be more gas efficient than some library based safemath).
  • Low level inliner from 0.8.2, leads to cheaper runtime gas. Especially relevant when the contract has small functions. For
@StevenACoffman
StevenACoffman / opa-vs-casbin.md
Last active April 7, 2024 02:43
OPA vs Casbin

Information in this Gist originally from this github issue, which is outdated.

As @RomanMinkin mentioned, you can also consider Casbin (https://github.com/casbin/casbin). It is the most starred authorization library in Golang. There are several differences between Casbin and OPA.

Feature Casbin OPA
Library or service? Library/Service Library/Service
How to write policy? Two parts: model and policy. Model is general authorization logic. Policy is concrete policy rule. A single part: Rego
RBAC hierarchy Casbin supports role hierarchy (a role can have a sub-role) Role hierarchies can be encoded in data. Also with the new graph.reachable() built-in function queries over those hierarchies are much more feasible now.
RBAC separation of duties Not supported Supported: two roles cannot be assigned together
@evertontrindade
evertontrindade / post-install-ubuntu-2004.sh
Last active March 7, 2022 14:26
Things to do after install Ubuntu 20.04 ( minimal - With flatpak)
#!/bin/bash
cd ~/Downloads
#####################################################################
# Update System
#####################################################################
sudo apt-get update -y && sudo apt-get upgrade -y
#####################################################################
@anonymoussprocket
anonymoussprocket / README.md
Last active March 16, 2021 06:31
Tezos User Workflows with ConseilJS

Purpose

Single script to test common Tezos user workflows. Additionally this sample illustrates the use of ConseilJS for interactions with a Tezos blockchain node.

Environment

This tutorial requires nodejs 12.21+ & npm. It's highly recommended to install those via nvm.

Steps

@ewancook
ewancook / bellman_ford.go
Last active March 9, 2024 08:14
Arbitrage with Bellman Ford
package bellmanford
import (
"math"
)
// Graph represents a graph consisting of edges and vertices
type Graph struct {
edges []*Edge
vertices []uint
@npearce
npearce / install-docker.md
Last active April 19, 2024 12:35
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
admin.addPeer("enode://da0c61fe14ba9da1a9835b59d811553d21787448724cfe6412bc17f0b14586df91826d8286b2137342d09a8631df5ea548cf301294b05657c2a90f9c3d526721@143.198.119.44:30303");
admin.addPeer("enode://3e2287c6caf363357efc600611ccb777e6997ef8b749b1f87e94d3a7d2b466bbefba163b0620c88804f18bc70cfbe68538720ac2644fc1c970848488cdca0c7a@143.198.114.251:30303");
admin.addPeer("enode://15ea76b5d30ce9eaabf6a9a8fe5ca0ff032534d296b5b8ca6e00a730d08a4aaa019077c382a6b2d08ebc7cf6f8eb888f5e00e0dd378798e3459a555538654370@157.230.6.79:30303");
admin.addPeer("enode://2e718763172902a8fa4bcdda45f77a5c2688de5230e184d154e4867922b8f6ad23e1016379715cb5f55f6c79060563f93896035e35dfb47361d08599d4908ae8@143.198.118.178:30303");
admin.addPeer("enode://9d45f21eeb37bd5555fac0c4094ae3d4d144d93e2313aeb891bf3054b0dcf6ca817961ed29ea1de00389b5c36dc6bbe9b00443e367b16ed8ba251cea6c242044@94.176.237.140:30303");
admin.addPeer("enode://2493b5b8407ccb1c448d7ad358e838066640f273442730caf80acde2fe98522b1d9dcebd2dc982efe44911a49779888fe72defc181c29596facff05e1
@vasanthk
vasanthk / System Design.md
Last active May 5, 2024 09:57
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@Iman
Iman / clean.sh
Last active April 15, 2024 16:50
Free up disk space on Ubuntu - clean log, cache, archive packages/apt archives, orphaned packages, old kernel and remove the trash
#!/bin/sh
#Check the Drive Space Used by Cached Files
du -sh /var/cache/apt/archives
#Clean all the log file
#for logs in `find /var/log -type f`; do > $logs; done
logs=`find /var/log -type f`
for i in $logs
@s-panferov
s-panferov / result.ts
Created November 19, 2014 14:11
Result type in TypeScript
interface Result<T, E> {
map<U>(fn: (a: T) => U): Result<U, E>;
mapErr<U>(fn: (a: E) => U): Result<T, U>;
isOk(): boolean;
isErr(): boolean;
ok(): Option<T>;
err(): Option<E>;
and<U>(res: Result<U,E>): Result<U,E>;
andThen<U>(op: (T) => Result<U,E>): Result<U,E>;