Skip to content

Instantly share code, notes, and snippets.

@kamermans
kamermans / install-mysql-pcre-udf.sh
Created January 22, 2012 20:28
Install MySQL PCRE (Perl-Compatible Regular Expression) UDF on Amazon Linux / CentOS / RedHat / Fedora
#!/bin/bash -e
# UDF Documentation: http://www.mysqludf.org/lib_mysqludf_preg/
yum -y install pcre-devel gcc make automake mysql-devel
wget http://www.mysqludf.org/lib_mysqludf_preg/lib_mysqludf_preg-1.0.1.tar.gz
tar -zxvf lib_mysqludf_preg-1.0.1.tar.gz
cd lib_mysqludf_preg-1.0.1
./configure
make install
echo "You'll need to enter your MySQL password a few times to install the UDFs and test them"
@tuanpmt
tuanpmt / php7_build_ubuntu15.04.sh
Created December 4, 2015 07:32 — forked from m1st0/php_build_ubuntu.sh
Compiling PHP 7 on Ubuntu 15.04 with LDAP Support
#! /bin/bash
## PHP 7 Initial Compile ##
## Some help from the various places like these. ##
# http://www.zimuel.it/install-php-7/
# http://www.hashbangcode.com/blog/compiling-and-installing-php7-ubuntu
## Setup Ubuntu 15.04 ##
# I like the speed of Apt-Fast. Will check for installs some other day.
sudo apt-get install apt-fast
@Divi
Divi / compile-php-thread-safe-and-pthreads.sh
Last active May 19, 2021 00:43
Compile PHP Thread Safe & pthreads extension
#!/usr/bin/env bash
# PARAMETERS
# ----------
# PHP
# ---
PHP_TIMEZONE="UTC"
PHP_DIRECTORY="/etc/php5ts"
@voscausa
voscausa / App engine cloudstorage update.md
Last active October 15, 2021 14:07
Use GCS (Google cloudstoarge) to replace the app engine blobstore. You can use the Blobstore service to access GCS.
@dccampbell
dccampbell / PrintToPDF.php
Created October 1, 2018 07:08
Minimal PHP example of printing HTML to PDF using Headless Chrome
<?php
$chromeExec = 'google-chrome';
$inputFile = __DIR__.'/input.html';
$outputFile = __DIR__.'/output.pdf';
$version = shell_exec($chromeExec . ' --version 2>&1');
if(!strpos($version, 'Google Chrome') === 0) {
throw new Exception('Google Chrome not found at: '.$chromeExec);
@lucasdavila
lucasdavila / object_join.js
Last active February 24, 2023 17:40
Joining javascript key-value objects as string.
Object.prototype.join = function(glue, separator) {
var object = this;
if (glue == undefined)
glue = '=';
if (separator == undefined)
separator = ',';
return Object.keys(object).map(function (key, value) { return [key, value].join(glue); }).join(separator);
@joshmfrankel
joshmfrankel / fixBrokenHTMLString.php
Last active September 8, 2023 12:22
PHP: Fix broken html tags in string and use html entities
/**
* Fix for broken html tags inside strings for php.
*
* By using passing the html through DOMDocument and converting the html
* entities we are left with beautiful well formatted code. Huzzah!
*
* "Nothing is ever easy" -Zedd, Wizards First Rule
*
* @var DOMDocument
*/
@phoenixg
phoenixg / header_http_status_codes.php
Created April 6, 2013 14:02
PHP header() for sending HTTP status codes
<?php
/*
参考自:
http://darklaunch.com/2010/09/01/http-status-codes-in-php-http-header-response-code-function
http://snipplr.com/view/68099/
*/
function HTTPStatus($num) {
$http = array(
@bsalim
bsalim / php speed up tips.html
Created January 3, 2013 09:09
63 Tips for speeding up PHP
<html>
<body>
<p>Here are Webber’s points:</p>
<ul>
<li>If a method can be static, declare it static. Speed improvement is by a factor of 4.</li>
<li>echo is faster than print.(<em>* compare with list from phplens by John Lim</em>)</li>
<li>Use echo’s multiple parameters instead of string concatenation.</li>
<li>Set the maxvalue for your for-loops before and not in the loop.</li>
<li>Unset your variables to free memory, especially large arrays.</li>
<li>Avoid magic like __get, __set, __autoload</li>
@niw
niw / libpng_test.c
Last active November 12, 2023 19:54
How to read and write PNG file using libpng. Covers trivial method calls like png_set_filler.
/*
* A simple libpng example program
* http://zarb.org/~gc/html/libpng.html
*
* Modified by Yoshimasa Niwa to make it much simpler
* and support all defined color_type.
*
* To build, use the next instruction on OS X.
* $ brew install libpng
* $ clang -lz -lpng16 libpng_test.c