Skip to content

Instantly share code, notes, and snippets.

@Tonyce
Tonyce / OpenZeppelin_ReentrancyGuard.sol
Created October 11, 2024 14:30 — forked from nathan-websculpt/OpenZeppelin_ReentrancyGuard.sol
Here is an example of the OpenZeppelin Reentrancy Guard in use
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.3/contracts/security/ReentrancyGuard.sol";
contract Attackee is ReentrancyGuard {
mapping(address => uint) public attackeeBalances;
function depositIntoAttackee() external payable {
var blobUrl = URL.createObjectURL(blob);
var link = document.createElement("a"); // Or maybe get it from the current document
link.href = blobUrl;
link.download = "image.jpg";
// link.innerText = "Click here to download the file";
document.body.appendChild(link); // Or append it whereever you want
link.click();
link.remove();
@Tonyce
Tonyce / apple-touch-startup-image.html
Created August 6, 2024 14:18 — forked from EvanBacon/apple-touch-startup-image.html
An example of full iOS PWA startup image (splash screen) support.
<html>
<head>
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-touch-fullscreen" content="yes" />
<meta name="apple-mobile-web-app-title" content="Expo" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
<link
rel="apple-touch-icon"
sizes="180x180"
@Tonyce
Tonyce / approve.js
Created March 8, 2024 01:32 — forked from markcarey/approve.js
Farcaster Frame Txn Example POST Handler
"txn": async function(req) {
return new Promise(async function(resolve, reject) {
var frame = {};
frame.id = req.params.id;
frame.square = true;
frame.postUrl = `https://frm.lol/frames/${req.params.id}`;
const frameResult = await util.validate(req); // neynar frame validation endpoint
if (frameResult.valid == true) {
if ("transactionId" in req.body.untrustedData) {
// transaction has completed
name: Deploy
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
const file = document.querySelector("input[type=file]").files[0];
const reader = new FileReader();
reader.readAsArrayBuffer(file);
reader.onload = () => {
const key = require("../arweave-keyfile.json");
const arweave = Arweave.init({
host: "arweave.net",
port: 443,
@Tonyce
Tonyce / LambdaConstants.java
Created February 11, 2022 11:00 — forked from seeebiii/LambdaConstants.java
Available default environment variables in AWS Lambda. Just copy&paste into your Node or Java project.
public class Constants {
/**
* Contains the path to your Lambda function code.
*/
public static final String LAMBDA_TASK_ROOT = System.getenv("LAMBDA_TASK_ROOT");
/**
* The environment variable is set to one of the following options, depending on the runtime of the Lambda function:
* AWS_Lambda_nodejs, AWS_Lambda_nodejs4.3, AWS_Lambda_nodejs6.10
var readline = require('readline'),
rl = readline.createInterface(process.stdin, process.stdout);
rl.setPrompt('OHAI> ');
rl.prompt();
rl.on('line', function(line) {
switch(line.trim()) {
case 'exit':
rl.close();
@Tonyce
Tonyce / main.rs
Created March 5, 2020 12:09 — forked from Sherlock-Holo/main.rs
third runtime with tokio
// from https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=fbb7daec1be993d3a4cd6f6181f332a0
use std::future::Future;
use std::pin::Pin;
use std::thread;
use futures::future::{pending, poll_fn};
use lazy_static::lazy_static;
use tokio::runtime::{Handle, Runtime};
@Tonyce
Tonyce / crypto-aes-256-gcm-demo.js
Created June 27, 2019 04:19 — forked from rjz/crypto-aes-256-gcm-demo.js
example using node.js crypto API with aes-256-gcm
const buffer = require('buffer');
const crypto = require('crypto');
// Demo implementation of using `aes-256-gcm` with node.js's `crypto` lib.
const aes256gcm = (key) => {
const ALGO = 'aes-256-gcm';
// encrypt returns base64-encoded ciphertext
const encrypt = (str) => {
// Hint: the `iv` should be unique (but not necessarily random).