Skip to content

Instantly share code, notes, and snippets.

View Thinkscape's full-sized avatar

Arthur Bodera Thinkscape

View GitHub Profile
@Thinkscape
Thinkscape / application.config.php
Last active December 20, 2015 20:58
Example of production/devel runtime config branching with ZF2 skeleton app.
<?php
// Determine ENV
define('APPLICATION_ENV', getenv('APPLICATION_ENV') == 'development' || PHP_SAPI == 'cli' ? 'development' : 'production');
// Load the appropriate config file
return
APPLICATION_ENV == 'development' ?
require __DIR__.'/application.development.config.php' :
require __DIR__.'/application.production.config.php'
;
@Thinkscape
Thinkscape / bytesToString.php
Last active December 19, 2015 23:59
Converts int bytes to a highest, rounded, multiplication that is IEC compliant.
<?php
/**
* Converts int bytes to a highest, rounded, multiplication that is IEC compliant.
*
* @link https://en.wikipedia.org/wiki/Binary_prefix
*
* @param int $size Number of bytes to convert
* @param int $precision Rounding precision (defaults to 0)
* @return string Highest rounded multiplication with IEC suffix
*/
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_max_tw_buckets = 262144
net.core.somaxconn = 65536
net.nf_conntrack_max = 262144
net.ipv4.tcp_max_syn_backlog = 65536
net.ipv4.tcp_max_orphans = 262144
@Thinkscape
Thinkscape / mobile-screen-sizes.md
Last active December 17, 2015 19:39
Pixel sizes of mobile screens as reported by JavaScript, useful for making pixel-perfect HTML5 app designs.

iPhone

Model Runtime System Bar Call bar Width Height
iPhone Retina 4" Native/phonegap transparent hidden 320 568
iPhone Retina 4" Native/phonegap black/def hidden 320 548
iPhone Retina 4" Native/phonegap transparent visible 320 568 2
iPhone Retina 4" Native/phonegap black/def visible 320 528
iPhone Retina 4" Safari n/a hidden 320 444
<?php
error_reporting(E_ALL & ~ E_NOTICE);
ini_set('display_errors',1);
require_once 'autoload_register.php';
$content = 'foobar';
if(isset($_GET['genimg']) || PHP_SAPI == 'cli'){
$ date
Fri Apr 26 19:40:14 CEST 2013
$ traceroute www.mwop.net
traceroute to ec2-204-236-242-255.compute-1.amazonaws.com (204.236.242.255), 64 hops max, 52 byte packets
1 * router (10.0.15.1) 3.577 ms 0.910 ms
2 192.168.0.1 (192.168.0.1) 1.750 ms 1.533 ms 1.330 ms
3 10.179.224.1 (10.179.224.1) 8.392 ms 7.388 ms 8.223 ms
4 89-75-20-174.infra.chello.pl (89.75.20.174) 7.988 ms 9.643 ms 8.973 ms
5 84.116.253.181 (84.116.253.181) 116.268 ms 116.382 ms 116.560 ms
6 84.116.253.178 (84.116.253.178) 115.290 ms 115.971 ms 116.097 ms
@Thinkscape
Thinkscape / GeoIP.php
Created April 17, 2013 18:20
Reading maxmind localized region names
$region = iconv(
'ISO-8859-1',
'UTF-8//IGNORE',
@geoip_region_name_by_code(
$rec['country_code'],$rec['region']
)
);
@Thinkscape
Thinkscape / findMaxOverlappingIntervals.php
Last active December 15, 2015 23:38
Find max overlapping intervals algorithm implementation in PHP. See also: http://stackoverflow.com/a/4542928/181664
<?php
/**
* Find the maximum number of overlapping intervals.
*
* For example, given a series of the following int-based intervals [[1,2], [3,4], [2,10]]
* the following intervals overlap: [1,2] with [2,10], [3,4] with [2,10], hence the maximum
* number of overlapping intervals is 2.
*
* @link http://stackoverflow.com/a/4542928/181664
* @param array $series An array of pairs of positive integers, i.e. [[1,2], [3,4], [2,10] ...]
@Thinkscape
Thinkscape / module.config.php
Created March 15, 2013 11:26
Application/config/module.config
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
return array(
<?php
return array (
'view_manager' =>
array (
'template_path_stack' =>
array (
'zenddevelopertools' => '/Users/Thinkscape/Documents/Projects/jobdate/vendor/zendframework/zend-developer-tools/config/../view',
0 => '/Users/Thinkscape/Documents/Projects/jobdate/module/Application/config/../view',
),
'display_not_found_reason' => true,