Skip to content

Instantly share code, notes, and snippets.

View snpy's full-sized avatar
🐢
I may be slow to respond.

Marek Snopkowski snpy

🐢
I may be slow to respond.
  • Kram-Soft
  • Kraków
View GitHub Profile
@snpy
snpy / gaq-with-data.js
Last active October 8, 2015 21:08
Handling GAQ with data
jQuery(function($) {
$('[data-gaq]').each(function() {
var self = $(this), gaq = JSON.parse(self.data('gaq')),
bind = self.data('gaq-bind') || 'click';
self[bind](function() {
window._gaq.add(gaq);
});
}
});
@snpy
snpy / isset_vs_in_array.php
Last active October 5, 2015 22:28
isset() vs in_array() - super simple test - no breaks
<?php
define('MAX', 100000);
define('NUM', 100);
$in = array('key');
for ($i = 0; $i < NUM; ++$i) {
$in100[] = 'key' . $i;
}
$is = array('key' => true,);
@snpy
snpy / filemtime-clearstatscache.php
Last active October 4, 2015 23:37
Real time web resource salt vs predefined (i.e. constant)
<?php
$mt = microtime(1);
for ($i = 0; $i < 10000; ++$i) {
clearstatcache();
$file = 'file-prefix.' . date('Ymdh', filemtime('some-file.txt')) . '.txt';
}
echo microtime(1) - $mt, PHP_EOL, $file, PHP_EOL;
@snpy
snpy / Test1.php
Last active October 1, 2015 15:37
Plain old class with multiple getters vs class with single magic method replacing multiple getters.
<?php
class Test
{
public $title0 = 'string value';
public $title1 = 'string value';
public $title2 = 'string value';
public $title3 = 'string value';
public $title4 = 'string value';
public $title5 = 'string value';