Skip to content

Instantly share code, notes, and snippets.

@eerkaijun
eerkaijun / Solution.s.sol
Last active January 19, 2024 16:33
Paradigm CTF
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "forge-ctf/CTFSolver.sol";
import "../src/Split.sol";
import "../src/Challenge.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract Solution is CTFSolver {
@eerkaijun
eerkaijun / nocturne-v1_attestation.log
Created October 27, 2023 07:21
Attestation for nocturne-v1 MPC Phase 2 Trusted Setup ceremony
Hey, I'm eerkaijun-47535524 and I have contributed to the nocturne-v1 MPC Phase2 Trusted Setup ceremony.
The following are my contribution signatures:
Circuit # 1 (canonaddrsigcheck)
Contributor # 27
Contribution Hash: a826bf54 5f7ecfaa 85581345 4e123d71
b3ddef0f e8d82308 20775e92 830dfbf8
9374fdae 55f559dc 580ba201 36dc7abe
54af3759 cb3d3ae3 4f07dcb5 0e3bd38a
const HDWalletProvider = require('@truffle/hdwallet-provider');
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();
module.exports = {
networks: {
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 7545, // Standard Ethereum port (default: none)
pragma solidity >=0.4.22 <0.7.0;
contract Bank {
mapping(address => uint256) balance;
address[] public customers;
event Deposit(address customer, string message);
event Withdrawal(address customer);
function deposit(string memory message) public payable {
<template>
<v-app>
<v-card>
Some random content
</v-card>
</v-app>
</template>
<script language="javascript" type="text/javascript" src="jslibs/web3.min.js"></script>
<script>
# agent taking a step at each time step
def agent_step(self, reward, state):
# reward (r.t) is the reward obtained from the previous step, state (s.t+1) is the state for the current step
act_values = self.model.predict(state)[0] # an array of action values of current time step
action = self.agent_take_action(act_values) # action chosen in current time step
# Perform an update to the neural network model based on previous step
target = reward + self.discount * act_values[action]
target_f = self.model.predict(self.prev_state) # action values of previous step
target_f[0][self.prev_action] = target # update
@eerkaijun
eerkaijun / load_model.py
Created August 14, 2020 14:05
Load BERT pretrained model
# Requirements: install HuggingFace Transformer library beforehand
# pip install transformers
from transformers import BertTokenizer, TFBertForSequenceClassification
from transformers import InputExample, InputFeatures
model = TFBertForSequenceClassification.from_pretrained("bert-base-uncased")
tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
@eerkaijun
eerkaijun / predictions.py
Created August 14, 2020 14:02
Make sentiment predictions on fine tuned BERT model
tf_batch = tokenizer(pred_sentences, max_length=128, padding=True, truncation=True, return_tensors='tf')
tf_outputs = model(tf_batch)
tf_predictions = tf.nn.softmax(tf_outputs[0], axis=-1)
labels = ['Negative','Positive']
label = tf.argmax(tf_predictions, axis=1)
label = label.numpy()
for i in range(len(pred_sentences)):
print(pred_sentences[i], ": ", labels[label[i]])
@eerkaijun
eerkaijun / fine_tune.py
Created August 14, 2020 14:00
Fine tune BERT model
optimizer = tf.keras.optimizers.Adam(learning_rate=3e-5, epsilon=1e-08, clipnorm=1.0)
loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)
metric = tf.keras.metrics.SparseCategoricalAccuracy('accuracy')
model.compile(optimizer=optimizer, loss=loss, metrics=[metric])
model.fit(train_data, epochs=7, validation_data=validation_data)
@eerkaijun
eerkaijun / convert_data.py
Created August 14, 2020 13:53
Convert raw dataset to tensors which are compatible with pretrained BERT model
def convert_data_to_examples(train, test, DATA_COLUMN, LABEL_COLUMN):
train_InputExamples = train.apply(lambda x: InputExample(guid=None, # Globally unique ID for bookkeeping, unused in this case
text_a = x[DATA_COLUMN],
text_b = None,
label = x[LABEL_COLUMN]), axis = 1)
validation_InputExamples = test.apply(lambda x: InputExample(guid=None, # Globally unique ID for bookkeeping, unused in this case
text_a = x[DATA_COLUMN],
text_b = None,
label = x[LABEL_COLUMN]), axis = 1)