Skip to content

Instantly share code, notes, and snippets.

View jyap808's full-sized avatar

Julian Y jyap808

View GitHub Profile
@salanfe
salanfe / AdditionContract.sol
Last active July 9, 2022 22:07
Ethereum: python for sending raw JSON-RPC HTTP requests to deploy and interact with a smart contract
pragma solidity ^0.4.18;
contract AdditionContract {
uint public state = 0;
function add(uint value1, uint value2) public {
state = value1 + value2;
}
function getState() public constant returns (uint) {
@ryandotsmith
ryandotsmith / main.go
Created January 15, 2015 01:10
Sending an OP_RETURN Bitcoin Transaction with Go using Chain's Bitcoin API
package main
import (
"bytes"
"encoding/hex"
"encoding/json"
"io/ioutil"
"log"
"net/http"
/**
* Render CyberBrokers
* Using the on-chain Broker renderer
**/
// Change these variables as you see fit
const WEB3_PROVIDER_URL = "http://0.0.0.0:8545";
const TOKEN_ID = 0;
const SVG_SAVE_FILE_NAME = `${__dirname}/CyberBroker_${TOKEN_ID}.svg`;
@miguelmota
miguelmota / sha3.go
Last active September 24, 2022 02:26
Ethereum Sha3 (Keccak256) in Golang
package main
import (
"encoding/hex"
"fmt"
"github.com/ethereum/go-ethereum/crypto/sha3"
)
func main() {
hash := sha3.NewKeccak256()
@freeformz
freeformz / WhyILikeGo.md
Last active October 6, 2022 23:31
Why I Like Go

A slightly updated version of this doc is here on my website.

Why I Like Go

I visited with PagerDuty yesterday for a little Friday beer and pizza. While there I got started talking about Go. I was asked by Alex, their CEO, why I liked it. Several other people have asked me the same question recently, so I figured it was worth posting.

Goroutines

The first 1/2 of Go's concurrency story. Lightweight, concurrent function execution. You can spawn tons of these if needed and the Go runtime multiplexes them onto the configured number of CPUs/Threads as needed. They start with a super small stack that can grow (and shrink) via dynamic allocation (and freeing). They are as simple as go f(x), where f() is a function.

@alexvandesande
alexvandesande / Random generator
Last active December 23, 2022 09:10
A very simple random generator. A miner can influence the number by not publishing a block with an unwanted outcome, and forfeiting the 5 block reward.
contract random {
/* Generates a random number from 0 to 100 based on the last block hash */
function randomGen(uint seed) constant returns (uint randomNumber) {
return(uint(sha3(block.blockhash(block.number-1), seed ))%100);
}
/* generates a number from 0 to 2^n based on the last n blocks */
function multiBlockRandomGen(uint seed, uint size) constant returns (uint randomNumber) {
uint n = 0;
for (uint i = 0; i < size; i++){
@aalness
aalness / benchmark.cpp
Last active March 10, 2023 10:15
Benchmark SHA256 for libsecp256k1 / crypto++ / openssl
#include <string.h>
#include <sys/time.h>
#include <iostream>
#include <openssl/sha.h>
#include <openssl/rand.h>
#include "secp256k1/src/hash_impl.h"
#include "cryptopp/sha.h"
static const size_t NUM_RUNS = 300000UL;
@yllan
yllan / nginx.conf
Created February 5, 2013 07:55
設定 nginx 使用 server sent event
location xxxx {
proxy_pass http://localhost:9000;
proxy_buffering off;
proxy_cache off;
proxy_redirect off;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
@zer0TF
zer0TF / convert_to_safe.py
Created November 28, 2022 04:53
Convert all CKPT files to SAFETENSOR files in a directory
# Got a bunch of .ckpt files to convert?
# Here's a handy script to take care of all that for you!
# Original .ckpt files are not touched!
# Make sure you have enough disk space! You are going to DOUBLE the size of your models folder!
#
# First, run:
# pip install torch torchsde==0.2.5 safetensors==0.2.5
#
# Place this file in the **SAME DIRECTORY** as all of your .ckpt files, open a command prompt for that folder, and run:
# python convert_to_safe.py
@sh1n0b1
sh1n0b1 / ssltest.py
Created April 8, 2014 07:53
Python Heartbleed (CVE-2014-0160) Proof of Concept
#!/usr/bin/python
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford (jspenguin@jspenguin.org)
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select