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 / queue.go
Created April 17, 2024 05:55
handle laravel queue jobs by golang
package main
import (
"encoding/json"
"fmt"
"github.com/elliotchance/phpserialize"
"strings"
)
type job struct {
@cevin
cevin / cnet-net.go
Created December 24, 2022 10:32
test golang with systemd socket load balance
// cnet/net.go
package cnet
import (
"fmt"
"log"
"net"
"os"
"strconv"
"strings"
@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
@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;
// 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 / 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)
@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"}}';
<?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 / 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; //测试点
@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;