Skip to content

Instantly share code, notes, and snippets.

View tanopwan's full-sized avatar

Tanopwan Wongpichitkun tanopwan

  • Bangkok, Thailand
View GitHub Profile
@tanopwan
tanopwan / Certificate.sol
Last active October 8, 2022 08:05
Foundry Workshop
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
contract Certificate is ERC721 {
constructor() ERC721("Certificate", "CERT") {}
function mint(address to, uint256 tokenId) public {
_mint(to, tokenId);
@tanopwan
tanopwan / index.html
Last active September 19, 2022 13:06
Javascript/Typescript Canvas - Draw masking rect on image with undo feature
<canvas id="canvas" width="460" height="300" />
@tanopwan
tanopwan / pipeline_redis.groovy
Created March 23, 2021 02:12
Groovy script to set keys to redis using pipeline in {batchSize} for {batchCount} times
import redis.clients.jedis.Jedis;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import groovy.time.TimeCategory
JedisPool pool = new JedisPool(new JedisPoolConfig(), "localhost");
Jedis jedis = pool.getResource();
@tanopwan
tanopwan / api.json
Last active March 6, 2021 10:37
ABI for contract 0xA625AB01B08ce023B2a342Dbb12a16f2C8489A8F (Alpaca IFairLaunch)
{"status":"1","message":"OK","result":"[{\"inputs\":[{\"internalType\":\"contract AlpacaToken\",\"name\":\"_alpaca\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_devaddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_alpacaPerBlock\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_startBlock\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_bonusLockupBps\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_bonusEndBlock\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"pid\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Deposit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"u
@tanopwan
tanopwan / main.go
Last active June 1, 2023 23:02
How to peek the data from the reader stream ie. from TCP connection using bufio
package main
import (
"bufio"
"log"
"net"
"net/http"
"os"
"strings"
"time"
@tanopwan
tanopwan / KeyProvider.java
Created December 2, 2020 12:26
Interface class for org.apache.orc.impl
package org.apache.orc.impl;
import java.io.IOException;
import java.security.Key;
import java.util.List;
import java.util.Random;
import org.apache.hadoop.conf.Configuration;
import org.apache.orc.impl.HadoopShims.KeyMetadata;
import org.apache.orc.impl.HadoopShims.KeyProviderKind;
class AwsKeystore(
private val kmsClient: AWSKMS,
private val awsKmsKeyId: String,
private val awsKmsKeySpec: String
): KeyProvider {
private val keys: TreeMap<String, KeyVersion> = TreeMap()
private val currentVersion: Map<String, Int> = mutableMapOf()
override fun getKeyNames(): MutableList<String> {
return ArrayList(currentVersion.keys)
@tanopwan
tanopwan / example.html
Created August 3, 2020 05:33
Alpine.js with bulma with event with event params and fetch :D
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Alpine Example</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.0/css/bulma.min.css">
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.x.x/dist/alpine.js" defer></script>
</head>
<button class="button" x-data="{}" @click="$dispatch('show-modal', { id: 1 })">Show</button>