Skip to content

Instantly share code, notes, and snippets.

View brotherbigbao's full-sized avatar
💭
965ing.

Brother Big Bao brotherbigbao

💭
965ing.
View GitHub Profile
@MarshalW
MarshalW / privoxy-whitelist-forward-socks5.md
Last active March 27, 2024 07:37
privoxy设置转发socks5 proxy白名单

privoxy设置转发socks5 proxy白名单

以下步骤可在ubuntu/raspbian下执行

安装配置socks5 proxy

需要有一个可ssh访问境外节点账号。

需要创建本地账号的密钥(如果没有~/.ssh/id_rsa):

@sawant
sawant / homebrew old version.txt
Last active March 16, 2024 05:35
Install older version of Formula in Homebrew
[From: http://hanxue-it.blogspot.com/2018/08/macos-homebrew-installing-older-version-of-software.html - just created a copy to keep it for long term]
Homebrew always wants to install the latest version of the Formula (software). This is by design, because every time there is an update to a formula, it wants to be tested against all the other formulas that it depends on. Mixing new and old versions of software is a recipe for incompatibility disaster.
But sometimes there are situations where you need an older version of software. In my specific case, Yarn was compiled against an older version of icu4c, and I want that older version instead of recompiling Yarn.
$ yarn install
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.61.dylib
Referenced from: /usr/local/bin/node
@chadrien
chadrien / README.md
Last active September 1, 2023 12:43
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@Shelob9
Shelob9 / class-name-without-namespace.php
Last active February 14, 2022 16:09
Get name of class, without the namespace. get_called_class() used instead of __CLASS__ to ensure that if class is extended, that class' name is used.
<?php
$class = get_called_class();
$class = explode( '\\', $class );
end( $class );
$last = key( $class );
$class = $class[ $last ];
/**
@chzyer
chzyer / php-header-file-type.md
Created January 10, 2013 18:38
[转] PHP分析文件头信息判断文件类型

我的话:

前阵子用PHP的上传功能貌似是能自动从文件头信息判断文件类型的而不是简单得从后缀名,因为最近在处理一个百度文库功能,需要处理上传文档功能,发现就算其他文件只要改后缀名就能伪装成文档的格式
下面是我在网上找到的所谓能判断文件类型,但是经过试验,不是很精准,因为OFFICE新出文件类型实际上是一个ZIP的压缩包,而07前版本的文件类型是srorage方式储存,可见,要实现完全正确的文件类型判断是一件很困难的事情...

PHP分析文件头信息判断文件类型

在用PHP上传文件时一般要限制可上传的文件类型,以保证系统的安全。文件类型通常通过文件的后缀进行判断,但这样只要用户把文件的后缀名修改一下就可以绕过检查而实现上传,但如果我们在判断文件名后缀的同时通过分析文件头信息判断文件类型,那些不怀好意的鸟人们再想捣乱可能就没那么简单了: 要分析文件头信息肯定要先读取文件,在PHP中,可以先用fopen()打开文件,然后通过fread()读取文件内容,不用全部读取,因为要判断文件类型我们只需要得到文件的前2个字节就足够了。得到的内容是二进制的,为了能在程序代码中做判断,需要把二进制数据转换成十进制数字的字符串,这时最关键的 unpack() 函数就派上用场了,unpack()函数主要用于二进制操作,我了解的也不多,看起来比较深奥,有时间好好研究下。 OK,还是把示例代码放上来吧: