Skip to content

Instantly share code, notes, and snippets.

View KaiCode2's full-sized avatar
🔨
Buidling

Kai Aldag KaiCode2

🔨
Buidling
View GitHub Profile
@KaiCode2
KaiCode2 / copy_contract.ts
Created February 2, 2024 07:31
WIP: Deploys contracts to deterministic addresses based on their names
import { ethers, artifacts, deployments, run, getNamedAccounts, network } from 'hardhat'
import { setCode, takeSnapshot, getStorageAt, setStorageAt } from '@nomicfoundation/hardhat-network-helpers'
import { Contracts } from '@/utils'
import { Signer } from 'ethers'
import fs from 'fs'
/*
This script deploys the contracts to hardhat/anvil chain such that their addresses can be derived from the keccak256 hash of their name.
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.2 <0.9.0;
library PartiallyApplied {
struct PartiallyEncodedCall {
address callee;
bytes4 selector;
bytes partialPayload;
}
did:3:kjzl6cwe1jw1497yrut53npsjcs5fvnoxv10bfpschjnajdlb94e37vy7z0p24y
did:3:kjzl6cwe1jw146ederf8pgr1249dx4iyc3j2kw2z12894guez8mwn5whh3tpihb
@KaiCode2
KaiCode2 / SquarespaceConfirmAgeInjection.js
Last active February 22, 2022 04:01
A simple snippet of code to add Squarespace website to add an age confirmation pop-up. To add, go to Setting > Advanced > Code Injection and add the below into the header. Note: Change the imageUrl (line #24) and change the ageGateUrl (lines #43, #51) to redirected underage visitors
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
<script type="text/javascript">
//document.onload = checkAge(document.URL);
function setCookie(name, value, days) {
var d = new Date();
d.setTime(d.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "expires="+d.toGMTString();
document.cookie = name + "=" + value + "; " + expires + "; path=/";
}
@KaiCode2
KaiCode2 / AP-Research-Handbook.md
Last active June 19, 2019 20:51
A Reference Handbook for new student to the AP Research Program

AP Research Handbook

Introduction: AP Research is a self guided classes requiring discipline, time management and dedication. While the completion of the paper requires much work, it is a deeply rewarding class lead by curiousity and interest. The aim of this handbook is to have an accessible, informative aid for the research and writing you will partake in.

Best of luck, Kai

Structuring Your Research

The first phase of the course is to become knowledgable and informed in your area of inquiry. As you will be writing an academic paper, collecting sources and managing how your information is collected is vital to succesfully completing the paper.

//: Playground - noun: a place where people can play
import UIKit
func closestPermutation(forNumber number: Int) -> Int {
guard number.digits().sorted(by: <) != number.digits() else { return number }
var currentPurmutation = number
var lastN: Float = 2
while true {
@KaiCode2
KaiCode2 / Star.swift
Created August 29, 2017 18:14
Core Graphics experiment: draw a star
//: Playground - noun: a place where people can play
import UIKit
import PlaygroundSupport
internal final class StarView: UIView {
let numberOfEdges = 5
let fillColor: UIColor = .red
let strokeColor: UIColor = .black
let lineWidth: CGFloat = 2
@KaiCode2
KaiCode2 / HackMit2-Brute.py
Created August 1, 2017 06:15
The script I used to finish Hack Mit challenge 2. (Commented code is for part 1)
# Script for breaking HackMIT challenge 2
import requests
import threading
fail = '''
<html>
<head>
<title>Hack Store</title>
<link href="https://fonts.googleapis.com/css?family=Poppins:400,700" rel="stylesheet">
@KaiCode2
KaiCode2 / CoreImageFacialRecognition.swift
Created October 9, 2016 20:06
Facial Recognition using CIDetector.
import UIKit
import CoreImage
extension UIImage {
/** Returns an Array of all detected faces as *UIImages.* If none are found empty Array will be returned.
- Author: Kai Aldag
*/
func findFacesInImage() throws -> [UIImage] {