Skip to content

Instantly share code, notes, and snippets.

View baryon's full-sized avatar
💭
Founder of ChainBow

LI Long baryon

💭
Founder of ChainBow
View GitHub Profile
@baryon
baryon / bigint.test.ts
Created January 31, 2024 06:16
Convert between bigint and buffer
import { expect, use } from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { buffer2bigint, bigint2buffer } from '../src/bigint'
use(chaiAsPromised)
describe('Test Utils', () => {
before(async () => {
})
@baryon
baryon / createScriptFromTx.js
Last active November 9, 2022 22:27
Create Bitcoin Script from any unlockTx or lockingTx
const bsv = require( 'bsv' )
const WhatsOnChain = require( 'whatsonchain' )
const _ = require( 'lodash' )
async function createScriptFromTx ( woc, prevTxid, outputIndex, scriptName, unlockParams = '', debugParams = '', txContext = {} ) {
//fetch transaction from prevTxid
const prevTxHex = await woc.getRawTxData( prevTxid )
const prevTx = new bsv.Transaction(prevTxHex)
magic减肥法完整版
看到不少人,在减肥,为了避免出问题,还是贴个完整版。
这可是全球首发,目前周围有好多人实践过我的方法,有效率100%,成功率50%,没成功的原因是因为没有坚持到底,又长回去了。
此 方法主要参照阿特金斯法和永田孝行法。阿特金斯是低糖减肥的鼻祖,一直被人批斗,永田孝行是阿特金斯的改良版。
阿特金斯叫人一辈子不吃主食终生保持50克以内的糖类才能保持体重,永田孝行叫人一辈子吃粗粮才能保持体重。
本人研究结果,没有必要,而且他们对原理的解释我认为不完全正确。
@baryon
baryon / cfs.sol
Created September 6, 2019 10:20
CFS股权合约
/**
*Submitted for verification at Etherscan.io on 2019-09-06
*/
pragma solidity 0.5.4;
library SafeMath {
uint256 constant internal MAX_UINT = 2 ** 256 - 1; // max uint256
@baryon
baryon / css_bdr.sol
Created September 6, 2019 10:18
CSS代币合约
/**
*Submitted for verification at Etherscan.io on 2019-09-06
*/
pragma solidity 0.5.4;
library SafeMath {
uint256 constant internal MAX_UINT = 2 ** 256 - 1; // max uint256
@baryon
baryon / CopyableLabel.swift
Created February 28, 2019 06:53
CopyableLabel
// Original Source:
// https://stackoverflow.com/questions/1246198/show-iphone-cut-copy-paste-menu-on-uilabel
class CopyableLabel: UILabel {
override init(frame: CGRect) {
super.init(frame: frame)
self.sharedInit()
}
@baryon
baryon / blockchain.js
Last active January 2, 2019 10:17
A blockchain demo
const tracer = require('tracer').colorConsole()
const console = tracer
const bitcoin = require('bsv')
const maxTried = 100000//Number.MAX_VALUE
class Block {
constructor(data, previousHash, difficulty) {
this.data = data.toString()
this.previousHash = previousHash
this.timestamp = Date.now().toString()
@baryon
baryon / nginx-dev-ssl.md
Last active March 11, 2022 08:45 — forked from LeZuse/nginx-dev-ssl.sh
配合nginx在本地开发https后端服务器

在开发后端服务时, APP中已经写好了服务器地址, 如何在本地开发机器调试呢? 首先,需要设置本地机器的hosts。 最方便的工具是gas masks https://github.com/2ndalpha/gasmask

添加类似如下代码

127.0.0.1		dev.example.com

生成本地证书 copy default OpenSSL config

{"sig":"53a00b60a3ce616e9608d6f9dbb05f50c20ffa5cbd95d35933e9fd514e683be5577af7a730ca1046220fd40e0f495036b32d64c25b2584399f9a739d96b76bc10","msghash":"5d0ce7f63dca01f074c1ae9c9e5626b9a245edcb5d6cd818694b182c1d919575"}
@baryon
baryon / ss2.yml
Last active August 22, 2022 18:48
翻墙回国听音乐+屏蔽广告
adapter:
#ss代理, 在国内购买一台云服务器,安装好ShadowSocks代理服务器,iPhone版安装Wingy APP (SMART LIMITED的深蓝紫色免费版)。使用的本文的自定义配置YAML
- id: proxyAdapter
type: ss
#修改ss_host为服务器地址
host: ss_host
#修改ss_port为端口号
port: ss_port
#修改ss_password为密码
password: ss_password