Skip to content

Instantly share code, notes, and snippets.

@benjiqq
benjiqq / get_solana_clock.py
Created October 3, 2024 04:53 — forked from SEJeff/get_solana_clock.py
Getting the Solana Proof of History clock time via the Clock sysvar
#!/usr/bin/env python3
# Uses construct and is a bit nicer code
import pytz
import pprint
import datetime
from construct import Int64ul, Int64sl, Struct
import requests
import base64
def main():
@benjiqq
benjiqq / sha256.cu
Created June 1, 2023 16:17 — forked from allanmac/sha256.cu
A CUDA SHA-256 subroutine using macro expansion
// -*- compile-command: "nvcc -m 32 -arch sm_35 -Xptxas=-v,-abi=no -cubin sha256.cu"; -*-
//
// Copyright 2013 Allan MacKinnon <[email protected]>
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
@benjiqq
benjiqq / FairlaunchPool.sol
Created May 17, 2023 15:08 — forked from platodev2/FairlaunchPool.sol
Magnet Fairlaunch contract
// SPDX-License-Identifier: MIT
pragma solidity 0.8.5;
import "OpenZeppelin/[email protected]/contracts/access/Ownable.sol";
//NRT is like a private stock
//can only be traded with the issuer who remains in control of the market
//until he opens the redemption window
contract NRT is Ownable {
@benjiqq
benjiqq / generic_json_parsing.go
Created January 10, 2023 14:56 — forked from alexhudici/generic_json_parsing.go
Example of generic Golang json parsing
package main
import (
"encoding/json"
"reflect"
"fmt"
)
type GenericObj struct {
Overwrite interface{} `json:"overwrite"`
/*
* STATICCALL Proxy
*
* It expects the input:
* 256 bit - address
* 256 bit - gas
* 256 bit - value
* n bit - calldata to be proxied
*
* And returns the output:
@benjiqq
benjiqq / alexa.js
Created June 29, 2020 15:44 — forked from chilts/alexa.js
Getting the Alexa top 1 million sites directly from the server, unzipping it, parsing the csv and getting each line as an array.
var request = require('request');
var unzip = require('unzip');
var csv2 = require('csv2');
request.get('http://s3.amazonaws.com/alexa-static/top-1m.csv.zip')
.pipe(unzip.Parse())
.on('entry', function (entry) {
entry.pipe(csv2()).on('data', console.log);
})
;
@benjiqq
benjiqq / gob.go
Created February 7, 2020 22:03 — forked from udhos/gob.go
golang gob interface example
package main
import (
"bytes"
"encoding/gob"
"fmt"
)
type MyFace interface {
A()
@benjiqq
benjiqq / zeromq-vs-redis.md
Created November 2, 2019 04:46 — forked from hmartiro/zeromq-vs-redis.md
Comparison of ZeroMQ and Redis for a robot control platform

ZeroMQ vs Redis

This document is research for the selection of a communication platform for robot-net.

Goal

The purpose of this component is to enable rapid, reliable, and elegant communication between the various nodes of the network, including controllers, sensors, and actuators (robot drivers). It will act as the core of robot-net to create a standardized infrastructure for robot control.

Requirements:

@benjiqq
benjiqq / ecdsa_demo.py
Created April 24, 2019 07:56 — forked from nlitsme/ecdsa_demo.py
python implementation of ecdsa calculations, demonstrating how to recover a private key from two signatures with identical 'r', and demonstrating how to find the public key from a signature and message, or from two signatures.
"""
By Willem Hengeveld <[email protected]>
ecdsa implementation in python
demonstrating several 'unconventional' calculations,
like finding a public key from a signature,
and finding a private key from 2 signatures with identical 'r'
"""
# (gcd,c,d)= GCD(a, b) ===> a*c+b*d!=gcd:
@benjiqq
benjiqq / supervisord.conf
Created March 7, 2019 10:57 — forked from jasonamyers/supervisord.conf
A sample supervisor config file
; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Note: shell expansion ("~" or "$HOME") is not supported. Environment
; variables can be expanded using this syntax: "%(ENV_HOME)s".
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)