Skip to content

Instantly share code, notes, and snippets.

View jjyr's full-sized avatar
🌊
Stay foolish

jjy jjyr

🌊
Stay foolish
View GitHub Profile
@jjyr
jjyr / minimal_rust_binary.rs
Created June 30, 2020 05:00
minimal_rust_binary.rs
#![feature(no_core)]
#![feature(lang_items)]
#![feature(optin_builtin_traits, link_args, start)]
#![no_std]
#![no_core]
// Compiler needs these to proceed
#[lang = "sized"]
pub trait Sized {}
@jjyr
jjyr / lottery.py
Created November 6, 2019 08:54 — forked from Mine77/lottery.py
Lottery Program for Nervos CKB Mining Competition (6/15 - 6/28)
from hashlib import sha256
# the seed here is only an example.
# The seed for the lottery (of Nervos CKB Minning Competition between 6/15 and 6/28) will be the block hash of the block of height N.
# Here is the sha256 hash of the sentence that contains the information of N:0x24f7501665d4f59b7f65c0853f8dd2a68fe528d345ffe63721f391eec711c190
# Update: The message is "N = 77". According to the competition result, the block hash of height 77 is 0x73ba270324ee87ed8990acbc316380c584dea21a1b8b87f4e8c363595e08225f
seed = "0x73ba270324ee87ed8990acbc316380c584dea21a1b8b87f4e8c363595e08225f"
# This is the number of the participants in total.
# The number here should be replaced with the actual number after the competition conclude.
./configure --host=riscv64-unknown-elf CC=riscv64-unknown-elf-gcc CXX=riscv64-unknown-elf-g++ CFLAGS='-Os -Wl,-static -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-s' CXXFLAGS='-Os -Wl,-static -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-s'

cmake

  1. change CMAKE_C_COMPILER to riscv-unknown-elf-gcc
  2. change CMAKE_SYSTEM_NAME to Generic
  3. cmake

fixed length encoding

  • u8 - 1 bytes little endian encode
  • u32 - 4 bytes little endian encode
  • u64 - 8 bytes little endian encode
  • u256 - 32 bytes little endian encode
  • H160 - 20 bytes raw binary
  • H256 - 32 bytes raw binary
@jjyr
jjyr / 全世界目前最大的威胁是什么.md
Created May 16, 2018 10:46
全世界目前最大的威胁是什么?

全世界目前最大的威胁是什么?

原文来自匿名答主的知乎回答
原文链接:
https://www.zhihu.com/question/265839602/answer/389245281?utm_source=com.ideashower.readitlater.pro&utm_medium=social&utm_oi=36863653969920

世界真正的大风暴还在后!!!(强烈推荐)

0479ffbf0ec273a56400588b50446246a533ff290a879ee2985fafd2e9c242ce1c4d96a780cca058b6fe08c3b9e9d4b0a3ab05bb17fd05faaeb3388b392758cc2e;ioquatix
@jjyr
jjyr / gist:71e17924c7906e8dfc9d6000ef421ab9
Created January 6, 2018 09:19
NIO4r ruby backend behaviour
#!/usr/bin/env ruby
# frozen_string_literal: true
$LOAD_PATH.push File.expand_path("../../lib", __FILE__)
require "nio"
require "socket"
# Echo server example written with nio4r
class EchoServer
def initialize(host, port)
@jjyr
jjyr / benchmark_result.md
Last active January 1, 2018 07:49
LightIO benchmark

Webrick

ab -n 5000 -c 50 127.0.0.1:8000/

Webrick
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
@jjyr
jjyr / Caddyfile
Created July 10, 2017 03:17
Caddyfile example
https://example.com {
gzip
log stdout
# force https
header / Strict-Transport-Security "max-age=31536000;"
# static files
root /app/public