Skip to content

Instantly share code, notes, and snippets.

View ghacosta's full-sized avatar

Guille Acosta ghacosta

View GitHub Profile
@ghacosta
ghacosta / memory_limit_usage_percent.php
Last active January 18, 2016 15:03
Memory limit vs usage percent
<?php
$memory_limit = (int)trim(ini_get("memory_limit"),'M');
function echo_memory_usage() {
$mem_usage = memory_get_usage(true);
if ($mem_usage < 1024)
echo $mem_usage." bytes";
elseif ($mem_usage < 1048576) {
echo "memory usage: ".round($mem_usage/1024,2)." kilobytes"."<br>";
echo "percent usage:".round((($mem_usage/1024) * 100 / ($GLOBALS['memory_limit'] * 1024)),2)."%"."<br>";
}
@ghacosta
ghacosta / echo_in_loop.php
Last active January 14, 2016 18:29
enabling echo in real time flushing buffer.
<?php
// Turn off output buffering
ini_set('output_buffering', 'off');
// Turn off PHP output compression
ini_set('zlib.output_compression', false);
//Flush (send) the output buffer and turn off output buffering
while(@ob_end_flush());
// Implicitly flush the buffer(s)
@ghacosta
ghacosta / index.html
Last active January 25, 2016 17:45
initial bootstrap file with CDN and first container, row and col. #BootstrapFromScratch
<!DOCTYPE html>
<html>
<head>
<title></title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
@ghacosta
ghacosta / urlobject.js
Created October 25, 2015 05:58 — forked from aymanfarhat/urlobject.js
JS utility function that: - Breaks down url to an object with accessible properties: protocol, parameters object, host, hash, etc... - Converts url parameters to key/value pairs - Convert parameter numeric values to their base types instead of strings - Store multiple values of a parameter in an array - Unescape parameter values
function urlObject(options) {
"use strict";
/*global window, document*/
var url_search_arr,
option_key,
i,
urlObj,
get_param,
key,
cordova plugin add https://github.com/brodysoft/Cordova-SQLitePlugin.git
@ghacosta
ghacosta / StopWatch.php
Last active October 6, 2015 17:34 — forked from phybros/StopWatch.php
A simple "StopWatch" class to measure PHP execution time. The class can handle multiple separate timers at the same time.
<?php
class StopWatch {
/**
* @var $start float The start time of the StopWatch
*/
private static $startTimes = array();
/**
* Start the timer
*