在开发中,我们经常会遇到这样的需求,将数据库中的图片导出到本地,再传给别人。
一、一般我会这样做:
1.通过接口或者定时任务的形式
2.读取Oracle或者MySQL数据库
3.通过FileOutputStream将Base64解密后的byte[]存储到本地
4.遍历本地文件夹,将图片通过FTP上传到第三方服务器
给我一个需求,还你一个项目——别管它是什么。这就是全栈。
In development, we often run into a requirement like this: export images from the database to the local machine, then pass them on to someone else.
Through an interface or a scheduled task
Read from an Oracle or MySQL database
Use FileOutputStream to store the Base64-decoded byte[] locally
Walk the local folder and upload the images to a third-party server over FTP
Continuous integration, or CI for short. As software development grows ever more complex, how team members can better work together to ensure software quality has slowly become an unavoidable problem in the development process. Especially in recent years, as Agile has become increasingly popular in the software engineering field, being able to quickly adapt to constantly changing requirements while guaranteeing software quality has become particularly important. Continuous integration is a software development practice aimed precisely at this class of problems. It advocates that team members must integrate their work frequently, possibly many times a day. Each integration is verified through an automated build, including automatic compilation, release and testing, so that integration errors are found as quickly as possible and the team can develop cohesive software faster.
开发卡牌游戏或者匹配游戏等等,需要重新洗牌或重新更换位置,这就需要清洗数据。那么就以最常见的扑克牌为例,来一个数据随机化算法。
When developing a card game or a match game, you need to reshuffle or reposition things, which means shuffling the data. So let’s take the most common example — a deck of playing cards — and build a data randomization algorithm.
最近开发后总要测试接口性能,来定位接口问题,突然想到有xhprof扩展可以用。翻了翻,发现多数要不代码不更新,要不就是太繁琐,干脆自己开发以下。
参考phacility/xhprof、phpxxb/xhprof的项目,自己下载了一份代码。于是就先做了webman的插件xhprof-webman,磨蹭了一段时间就又弄了laravel版的插件xhprof-laravel。最新版已更新,大家有用到的去composer安装吧。
Lately I always have to test interface performance after development to pin down interface problems, and it suddenly occurred to me that the xhprof extension could be used. I looked around and found that most of them either are no longer updated or are just too cumbersome, so I simply developed my own.
Referring to the phacility/xhprof and phpxxb/xhprof projects, I downloaded a copy of the code myself. So first I made the webman plugin xhprof-webman, and after dawdling for a while I made the laravel version of the plugin xhprof-laravel. The latest versions have been updated, so if you find them useful, go install them with composer.
偶然发现datahub很不错,单机部署来了。
本地安装docker,进入到opt目录或home目录,执行以下命令(国内锁了):
git clone https://github.com/linkedin/datahub.git
cd /opt/datahub/docker
datahub docker quickstart -f ./quickstart/docker-compose-without-neo4j.quickstart.yml
source ./quickstart.sh
I stumbled on DataHub and it looked pretty good, so here’s a single-node deployment.
Install Docker locally, cd into the /opt or home directory, and run the following commands (blocked in China):
git clone https://github.com/linkedin/datahub.git
cd /opt/datahub/docker
datahub docker quickstart -f ./quickstart/docker-compose-without-neo4j.quickstart.yml
source ./quickstart.sh
红包算法
给定具体人数和金额,所有人都有,所有人的金额都是随机。那么,在分配中就要限定最大额度不能超过平局值,最小额度1分,算法如下:
Red envelope algorithm
Given a specific number of people and a total amount, everyone gets a share, and everyone’s amount is random. So the allocation has to be limited such that the maximum amount cannot exceed the average value and the minimum amount is 1 cent. The algorithm is as follows:
在同一平台中买卖交易,需要进行订单撮合。相近的金额从大到小递减组合。期初想用mq分别匹配整数的金额倍数处理,总觉的不太完美。最近刚好有空就找到了猴子选大王算法:
When buying and selling on the same platform, orders need to be matched. Similar amounts are combined in descending order. At first I wanted to use mq to separately match integer multiples of amounts, but I always felt it wasn’t quite perfect. Recently I happened to have some free time, so I found the “monkey chooses the king” algorithm:
对于当前数据库的监控方式有很多,分为数据库自带、商用、开源三大类,每一种都有各自的特色;而对于 mysql 数据库由于其有很高的社区活跃度,监控方式更是多种多样,不管哪种监控方式最核心的就是监控数据,获取得到全面的监控数据后就是灵活的展示部分。那我们今天就介绍一下完全采用 mysql 自有方式采集获取监控数据,在单体下达到最快速、方便、损耗最小。
There are many ways to monitor a database today, split into three broad categories: built into the database, commercial, and open source, each with its own characteristics; and for the mysql database, thanks to its highly active community, monitoring approaches are even more varied. Regardless of the monitoring approach, the core is the monitoring data, and after obtaining comprehensive monitoring data comes the flexible presentation part. So today let’s introduce collecting and obtaining monitoring data entirely using mysql’s own facilities, achieving the fastest, most convenient and least overhead approach for a single instance.
支付永远是一个公司的核心领域,因为这是一个有交易属性公司的命脉。那么,支付系统到底长什么样,又是怎么运行交互的呢?抛开带有支付牌照的金融公司的支付架构,下述链路和系统组成基本上符合绝大多数支付场景。其实整体可以看成是交易核心+支付核心 两个大系统。交易系统关联了业务场景和底层支付,而支付系统完成了调用支付工具到对账清算等一系列相关操作。下面我们就来一起看下各个系统的核心组成和交互。
Payment is always a core domain of a company, because it is the lifeline of any company with a transactional nature. So what does a payment system actually look like, and how does it run and interact? Setting aside the payment architecture of financial companies that hold payment licenses, the links and system composition described below basically fit the vast majority of payment scenarios. In fact, the whole thing can be seen as two big systems: a transaction core + a payment core. The transaction system connects business scenarios with the underlying payment, while the payment system completes a series of related operations from invoking payment instruments to reconciliation and settlement. Let’s take a look at the core composition and interaction of each system.
Nginx is a lightweight / high-performance reverse proxy web server, used for the HTTP, HTTPS, SMTP, POP3 and IMAP protocols. It implements very efficient reverse proxying and load balancing. It can handle 20,000-30,000 concurrent connections, and official monitoring shows it can support 50,000 concurrent connections. Many website users in China use nginx today, for example: Sina, NetEase, Tencent and others.
Cross-platform, simple configuration.
Non-blocking, high-concurrency connections: handles 20,000-30,000 concurrent connections, with official monitoring supporting 50,000 concurrent connections.
Memory consumption
没有找到匹配的文章 🙈