Skip to content

Instantly share code, notes, and snippets.

View cevin's full-sized avatar
🐢
couch potato

cevin cevin

🐢
couch potato
View GitHub Profile
@cevin
cevin / README.md
Created November 14, 2013 02:20 — forked from nikcub/README.md
# Raw transaction API example work-through
# Send coins to a 2-of-3 multisig, then spend them.
#
# For this example, I'm using these three keypairs (public/private)
# 0491bba2510912a5bd37da1fb5b1673010e43d2c6d812c514e91bfa9f2eb129e1c183329db55bd868e209aac2fbc02cb33d98fe74bf23f0c235d6126b1d8334f86 / 5JaTXbAUmfPYZFRwrYaALK48fN6sFJp4rHqq2QSXs8ucfpE4yQU
# 04865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac09ef122b1a986818a7cb624532f062c1d1f8722084861c5c3291ccffef4ec6874 / 5Jb7fCeh1Wtm4yBBg3q3XbT6B525i17kVhy3vMC9AqfR6FH2qGk
# 048d2455d2403e08708fc1f556002f1b6cd83f992d085097f9974ab08a28838f07896fbab08f39495e15fa6fad6edbfb1e754e35fa1c7844c41f322a1863d46213 / 5JFjmGo5Fww9p8gvx48qBYDJNAzR9pmH5S389axMtDyPT8ddqmw
# First: combine the three keys into a multisig address:
./bitcoind createmultisig 2 '["0491bba2510912a5bd37da1fb5b1673010e43d2c6d812c514e91bfa9f2eb129e1c183329db55bd868e209aac2fbc02cb33d98fe74bf23f0c235d6126b1d8334f86","04865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac09ef122b1a9
@cevin
cevin / best_match.php
Created December 20, 2017 13:30
最优匹配
<?php
$rand = [20,15,10,6];
$r = 39;
function combination($a, $m) {
$r = array();
$n = count($a);
if ($m <= 0 || $m > $n) {
return $r;
@cevin
cevin / test.php
Last active April 22, 2019 03:03
is point in polygon
<?php
function is_point_in_polygon($point, $pts) {
$N = count($pts);
$boundOrVertex = true; //如果点位于多边形的顶点或边上,也算做点在多边形内,直接返回true
$intersectCount = 0;//cross points count of x
$precision = 2e-10; //浮点类型计算时候与0比较时候的容差
$p1 = 0;//neighbour bound vertices
$p2 = 0;
$p = $point; //测试点
<?php
// page: https://yuanxuxu.com/2018/11/26/php-snowflake/
class Snowflake
{
const EPOCH = 1543223810238; // 起始时间戳,毫秒
const SEQUENCE_BITS = 12; //序号部分12位
const SEQUENCE_MAX = -1 ^ (-1 << self::SEQUENCE_BITS); // 序号最大值
@cevin
cevin / apns.php
Created March 30, 2021 06:03
php curl APNs push
<?php
// passed in php 7.4
$service_url = 'https://api.push.apple.com/3/device/';
$token = '07cd****3217****6289****94999228d7b45339fbafdf08****8f83****499b';
$headers = array();
$header[] = 'apns-topic:com.xxxxx.xxapp'; // bundle-id
$payload = '{"aps":{"alert":"hello","sound":"msg_high.m4a"}}';
@cevin
cevin / server.py
Created November 5, 2021 10:36
python epoll
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import socket
import select
import Queue
#创建socket对象
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build ignore
// +build ignore
// Generate a self-signed X.509 certificate for a TLS server. Outputs to
// 'cert.pem' and 'key.pem' and will overwrite existing files.
@cevin
cevin / AppServiceProvider.php
Created February 27, 2022 12:39
laravel transaction event test
<?php
namespace App\Providers;
use Illuminate\Database\Events\ConnectionEvent;
use Illuminate\Database\Events\TransactionBeginning;
use Illuminate\Database\Events\TransactionCommitted;
use Illuminate\Database\Events\TransactionRolledBack;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
@cevin
cevin / build-php-static.sh
Created April 21, 2022 00:36 — forked from gtgt/build-php-static.sh
Script to build static php
#!/bin/bash
U=${SUDO_USER:=${USER}}
if [[ -x `which realpath` ]]; then
T=$(realpath ${BASH_SOURCE[0]:=${0}})
else
T=${BASH_SOURCE[0]:=${0}}
fi
D=$(dirname ${T})
#apt-get install libfcgi-dev libfcgi0ldbl libjpeg62-turbo-dbg libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev libxml2-dev libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng12-dev libfreetype6-dev libkrb5-dev libpq-dev libxml2-dev libtidy-dev libmemcached-dev imagemagick-dev msgpack-dev