Skip to content

Instantly share code, notes, and snippets.

pragma solidity ^0.4.25;
// TRC20 contract interface
contract Token {
function balanceOf(address) public view returns (uint);
}
contract BatchBalance {
/* Fallback function, don't accept any TRX */

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@fogmoon
fogmoon / css triangle tooltip
Created July 26, 2022 14:35 — forked from Quinten/css triangle tooltip
tooltip triangle on the top of an element in css
#element:before {
content: "";
position: absolute;
width: 0;
height: 0;
border-left: 16px solid transparent;
border-right: 16px solid transparent;
border-bottom: 16px solid #fff;
top: -15px;
left: 27px;
@fogmoon
fogmoon / zip_file_format
Created August 3, 2022 15:52 — forked from freecnjet/zip_file_format
Zip file format.
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#pragma warning(disable:4996)
/************************************************************************/
/* Zip file struct */
/* */
@fogmoon
fogmoon / README.md
Created September 5, 2022 18:00 — forked from yorickdowne/README.md
Verify a public GPG signature - example Lighthouse

Eh?

So a FOSS project might have signed releases with a GPG sig. How do you verify it on a Linux machine?

Example sigp/lighthouse, but same idea for any project.

Install gpg: sudo apt install gpg

Grab their PGP key ID from their download page and gpg --keyserver pgp.mit.edu --recv THEIRKEYID and wait

@fogmoon
fogmoon / ity-bity-living-space.md
Created September 5, 2022 18:06
Ethereum node on 1TB SSD

Overview

As of August 2022, a 1TB SSD is getting tight to run an Ethereum node in. The recommendation now is for 2TB of space. I wanted to see what it takes to still fit into 1TB.

EIP-4844 will increase space need by another 200 GiB or so, which may make 1TB setups plain not feasible. This is a 2023 discussion however.

Options

  • Geth with offline prune every 2-3 months ... this would be a stop-gap, as offline prune takes the node down, including any validators on it
  • Future Geth without prune ... this might work well.
@fogmoon
fogmoon / memcached.txt
Created November 20, 2022 16:24 — forked from xeoncross/memcached.txt
description of memcached stats
watch "echo stats | nc 127.0.0.1 11211"
accepting_conns The Memcached server is currently accepting new connections.
auth_cmds Number of authentication commands processed by the server - if you use authentication within your installation. The default is IP (routing) level security which speeds up the actual Memcached usage by removing the authentication requirement.
auth_errors Number of failed authentication tries of clients.
bytes Number of bytes currently used for caching items, this server currently uses ~6 MB of it's maximum allowed (limit_maxbytes) 1 GB cache size.
bytes_read Total number of bytes received from the network by this server.
bytes_written Total number of bytes send to the network by this server.
@fogmoon
fogmoon / memcache.md
Created November 20, 2022 16:53 — forked from ashikawa/memcache.md
コンソールで memcache と戦う方法
@fogmoon
fogmoon / jwt-expiration.md
Created March 27, 2023 15:43 — forked from soulmachine/jwt-expiration.md
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

@fogmoon
fogmoon / cloudflare-workers-apilityio.js
Created April 19, 2023 12:20 — forked from diegoparrilla/cloudflare-workers-apilityio.js
Using Cloudflare Workers and https://Apility.io API add to the request headers information of the blacklists of abusers that contains the IP address of the client.
addEventListener('fetch', event => {
event.respondWith(fetchAndCheckOrigin(event.request))
})
async function fetchAndCheckOrigin(req) {
try {
startTime = new Date();
const body = await req.body;
const ip = req.headers.get('cf-connecting-ip');
const es = req.headers.get('cf-ipcountry');