Skip to content

Instantly share code, notes, and snippets.

@cwhsu1984
cwhsu1984 / selenium-mod-header
Created January 3, 2020 12:00
try to use selenium with mod-header
using System.IO;
using OpenQA.Selenium.Chrome;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var options = new ChromeOptions();
@cwhsu1984
cwhsu1984 / gist:e13d4648ddd7723eabd2a01b9dffcf15
Last active August 23, 2018 12:03
upgrade from php7.1 to php7.2 with mcrypt
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.2 php7.2-fpm php7.2-xml php-dev php-pear libmcrypt-dev
sudo pecl install mcrypt-snapshot
# add mcrypt.so to php cli and fpm
sudo bash -c "echo 'extension=mcrypt.so' >> /etc/php/7.2/cli/php.ini"
sudo bash -c "echo 'extension=mcrypt.so' >> /etc/php/7.2/fpm/php.ini"
# change nginx site-availables to use php7.2-fpm
@cwhsu1984
cwhsu1984 / gist:8da07027438ee78e16a2ced78449a6ad
Created December 30, 2017 13:39
config nginx for concurrent connections
# ec2 t2.micro can get over 20k connections by adding this line to nginx.conf
# test on ubuntu 16.04
# modify /etc/nginx/nginx.conf
worker_connections 10240;
# restart nginx
sudo systemctl reload nginx
# tool for testing
@cwhsu1984
cwhsu1984 / gist:1d2a4a36839fede24baa6e4739f3e0a3
Last active October 30, 2017 12:30
php7.1-fpm and xdebug
ubuntu 16.04
sudo apt-get install php-xdebug
/etc/php/7.1/fpm/php.ini
[xdebug]
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
@cwhsu1984
cwhsu1984 / parse_raw_http_request.php
Last active March 17, 2023 01:59
parse multi-dimensional form-data from PATCH request
<?php
// The code is inspired by the following discussions and post:
// http://stackoverflow.com/questions/5483851/manually-parse-raw-http-data-with-php/5488449#5488449
// http://www.chlab.ch/blog/archives/webdevelopment/manually-parse-raw-http-data-php
/**
* Parse raw HTTP request data
*
* Pass in $a_data as an array. This is done by reference to avoid copying
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1