Skip to content

Instantly share code, notes, and snippets.

View mikaelz's full-sized avatar

Michal Zuber mikaelz

View GitHub Profile
@mikaelz
mikaelz / php-compile.sh
Last active December 17, 2015 21:38 — forked from JeffreyWay/gist:3185773
configure for php compile
// http://kubyshkin.ru/posts/installing-php-xdebug-extension-on-mac-os-x-10-7-lion.html
MACOSX_DEPLOYMENT_TARGET=10.7
CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"
export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET
./configure \
--prefix=/usr \
@mikaelz
mikaelz / cache.php
Created May 30, 2013 05:45
Content Caching in PHP
<?php
// http://talks.php.net/show/perf_tunning/20
// http://talks.php.net/show/perf_tunning/21
function cache_start()
{
global $cache_file_name, $age;
// a superbly creative way for creating cache files
$cache_file_name = __FILE__ . '_cache';
mike@mikembp:~$ ab -vv -n1000 http://wordpress.localhost/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking wordpress.localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
@mikaelz
mikaelz / gist:5676805
Created May 30, 2013 09:39
svn ci templates/custom/index.php -m "Added param 'v' to have versioning pattern for main.css and main.js"
mike@mikembp:~/Sites/cms$ svn diff templates/custom/index.php
Index: templates/custom/index.php
===================================================================
--- templates/custom/index.php (revision 317)
+++ templates/custom/index.php (working copy)
@@ -21,7 +21,7 @@
<?php if (page_description() != '') echo '<meta name="description" content="' . page_description() . '"/>' ?>
<link rel="shortcut icon" href="<?php echo WB_URL; ?>/favicon.ico">
<link type="text/plain" rel="author" href="<?php echo WB_URL; ?>/humans.txt" />
-<link rel="stylesheet" href="<?php echo TEMPLATE_DIR; ?>/css/main.css"/>
@mikaelz
mikaelz / siege.sh
Last active December 17, 2015 23:09
Siege - http load tester and benchmarking utility from http://www.joedog.org/
bash:~$ siege -q -b -t30s -c50 http://www.google.com
Lifting the server siege... done.
Transactions: 4544 hits
Availability: 100.00 %
Elapsed time: 29.06 secs
Data transferred: 24.83 MB
Response time: 0.31 secs
Transaction rate: 156.37 trans/sec
@mikaelz
mikaelz / vim-resources.txt
Created June 2, 2013 05:17
Best VIM resources
Reading
http://pragprog.com/book/dnvim/practical-vim
http://stevelosh.com/blog/2010/09/coming-home-to-vim/
http://learnvimscriptthehardway.stevelosh.com/
Watching
http://vimcasts.org/
http://derekwyatt.org/vim/vim-tutorial-videos/
@mikaelz
mikaelz / functions.php
Last active December 9, 2017 03:10
Removing some unneeded WordPress stuff
<?php
/**
* Unset unneeded head stuff
* Default filters from wp-includes/default-filters.php
**/
remove_action('init','wp_cron');
remove_action('wp_head','rsd_link');
remove_action('wp_head','wlwmanifest_link');
remove_action('wp_head','wp_generator');
remove_action('wp_head','start_post_rel_link');
@mikaelz
mikaelz / pdo.php
Created June 2, 2013 08:39
Some PHP PDO snippets for learning
<?php
define('DB_HOST', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_NAME', 'db');
define('TABLE_PREFIX', '');
$GLOBALS['PDO_OPTIONS'] = array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
@mikaelz
mikaelz / protect-mailto.php
Created June 5, 2013 12:40
Convert characters to ASCII, mailto spam protection
<?php
function convert_email($email) {
$new_mail = '';
$pieces = str_split(trim($email));
foreach ($pieces as $val) {
$new_mail .= '&#'.ord($val).';';
}
return $new_mail;
}
@mikaelz
mikaelz / mysql-tuning.sql
Last active December 18, 2015 03:09
mysql performance tuning, profiling
-- http://www.percona.com/sites/default/files/presentations/MySQL%20Query%20Patterns%2C%20Optimized.pdf
-- SHOW PROFILE --
-- Enable query profiler for the current session.
SET PROFILING = 1;
SELECT t.title FROM title t;
SHOW PROFILES;
-- SHOW SESSION STATUS --
FLUSH STATUS;