Skip to content

Instantly share code, notes, and snippets.

View olekhy's full-sized avatar
🤓
happy developer

Alexander Hutorezki olekhy

🤓
happy developer
View GitHub Profile
@jacobbubu
jacobbubu / 如何实现 pull-stream 的 Source.md
Last active March 7, 2023 14:31
如何实现 pull-stream 的 Source

Source(read) 概述

Sink 对 Source 有两种请求:

  1. read: 向 Source 请求数据,通过 read(null, currCb) 来请求。
  2. abort: 通知 Source 终止当前的 stream,通过 read(endOrError, currCb) 来请求。endOrError 的类型是 true | Error,表示是一次正常的终止还是异常的终止。

对于 read 请求,Sink 应该基于 上一次的 read 请求回调了,再发起新的 read 请求这样的规则。 对于 abort 请求,由于有时 Source 也不知道何时需要 abort(出现了异常或者外部其他条件触发的),因此可能在上一次 read 没有回调就发生。

  • 对于 Sink 的 read 请求,如果”重入“(上一次 read 没有结束,新的 read 来了),Source 完成实际资源的读取后,仅仅调用最后一个传入的 currCb 来传递数据。
@craigdmckenna
craigdmckenna / sqlalchemy_mysql_binary_uuid.py
Last active January 15, 2023 21:22
SQLAlchemy, MySQL 16 bit UUID, Custom Data Type
import UUID
from sqlalchemy.dialects.mysql import BINARY
from sqlalchemy.types import TypeDecorator
class BinaryUUID(TypeDecorator):
'''Optimize UUID keys. Store as 16 bit binary, retrieve as uuid.
inspired by:
http://mysqlserverteam.com/storing-uuid-values-in-mysql-tables/
@jwhulette
jwhulette / .htaccess
Last active July 25, 2021 23:03
[A base .htaccess with HTTPS redirect behind an AWS Load Balancer] #apache #aws
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Force HTTPS - Proto needed for AWS ELB
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTP_USER_AGENT} !^ELB-HealthChecker

Here's how to test whether a parameter is unset, or empty ("Null") or set with a value:

+--------------------+----------------------+-----------------+-----------------+
|                    |       parameter      |     parameter   |    parameter    |
|                    |   Set and Not Null   |   Set But Null  |      Unset      |
+--------------------+----------------------+-----------------+-----------------+
| ${parameter:-word} | substitute parameter | substitute word | substitute word |
| ${parameter-word}  | substitute parameter | substitute null | substitute word |
| ${parameter:=word} | substitute parameter | assign word     | assign word     |
| ${parameter=word}  | substitute parameter | substitute null | assign word     |
@ralphschindler
ralphschindler / code-complete-stub-generator.php
Last active March 14, 2020 20:52
IDE code-completion stub generation script that utilizes reflection. (Primary use would be for extension stubs.)
<?php
define('T', ' ');
define('N', PHP_EOL);
$functions = array();
$classes = array();
$constant_prefix = 'X_';
$php = '<?php' . N;
@fhferreira
fhferreira / ddd_cqrs_event-sourcing_in_php.md
Created February 13, 2019 05:00 — forked from jsor/ddd_cqrs_event-sourcing_in_php.md
DDD, CQRS and Event Sourcing in PHP

DDD, CQRS and Event Sourcing in PHP

  • Broadway - Infrastructure and testing helpers for creating CQRS and event sourced applications
  • EventCentric.Core - Event Sourcing and CQRS in PHP
  • LiteCQRS - Small convention based CQRS library for PHP
  • predaddy - Common DDD classes including an annotation driven message bus and tools for CQRS and Event Sourcing
  • ProophEventSourcing - Provides basic functionality for event-sourced aggregates
  • ProophEventStore - PHP 5.4+ EventStore Implementation
  • ProophServiceBus - PHP Enterprise Service Bus Implementation supporting CQRS and DDD
@raminfp
raminfp / docker-ce-ubuntu-17.10.md
Created December 13, 2017 14:15
Install Docker CE on Ubuntu 17.10 and Docker-compose

Installing Docker CE on Ubuntu 17.10 Artful Aardvark

As of 20/10/2017, a release file for Ubuntu 17.10 Artful Aardvark is not available on Download Docker.

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
@olekhy
olekhy / capture display on linux.txt
Created March 23, 2017 16:41
capture display on linux
https://trac.ffmpeg.org/wiki/Capture/Desktop
ffmpeg -framerate 25 -video_size 1024x768 -f x11grab -i :0.0+100,200 -f alsa -ac 2 -i pulse -vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le output.mkv
losless
ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -i :0.0 -c:v libx264 -qp 0 -preset ultrafast capture.mkv
@johnbellone
johnbellone / .env
Last active December 19, 2016 19:51
Using dotenv gem with Vagrant and proxies.
VAGRANT_HTTP_PROXY=$HTTP_PROXY
VAGRANT_HTTPS_PROXY=$HTTPS_PROXY
VAGRANT_NO_PROXY=$NO_PROXY

Awesome PHP Libraries

A list of amazingly awesome PHP libraries that you should consider using (and some other shiny extras).