Skip to content

Instantly share code, notes, and snippets.

View pushandplay's full-sized avatar
:octocat:
💻💰

Master of life pushandplay

:octocat:
💻💰
View GitHub Profile
<?php
$memory = round(memory_get_usage()/1024/1024, 4).' Mb';
print "<div>Memory: {$memory}</div>";
$totalTime= ($modx->getMicroTime() - $modx->startTime);
$queryTime= $modx->queryTime;
$queryTime= sprintf("%2.4f s", $queryTime);
$queries= isset ($modx->executedQueries) ? $modx->executedQueries : 0;
$totalTime= sprintf("%2.4f s", $totalTime);
<?php
/**
* @package modx
* @subpackage processors.element.tv.renders.mgr.input
*
* core/model/modx/processors/element/tv/renders/mgr/input/gmaps.class.php
*/
class modTemplateVarInputRenderGmaps extends modTemplateVarInputRender {
public function getTemplate() {
return 'element/tv/renders/input/gmaps.tpl';
@pushandplay
pushandplay / gist:5992196
Created July 13, 2013 21:00
FIX for Bootstrap and Google Maps Info window styes problem
# FIX for Bootstrap and Google Maps Info window styes problem
css = document.createElement 'style'
css.type = 'text/css'
styles = 'img[src*="gstatic.com/"], img[src*="googleapis.com/"] { max-width: none; }'
if css.styleSheet
css.styleSheet.cssText = styles
else
css.appendChild(document.createTextNode styles)
document.getElementsByTagName("head")[0].appendChild css
# Create project
phonegap create path/to/project my.project.id ProjectName
# Add specific platform
phonegap local build platformName
# Add plugin
phonegap local plugin add RemotePathToPlugin
# Remove plugin
@pushandplay
pushandplay / gist:6203883
Last active December 20, 2015 22:19
Add "Rate my app" functionality to PhoneGap application
rateApp = ->
# Use iTunes link maker http://itunes.apple.com/linkmaker/ to get the real direct link
rate_app_counter = parseInt window.localStorage.getItem("rate_app_counter") or 0
rate_app = parseInt window.localStorage.getItem("rate_app") or 1
rate_count_max = 3
app_id_ios = "123456789"
app_id_android = "com.company.YourAppID"
app_id_blackberry = "123456789"
rate = (buttonIndex) ->
@pushandplay
pushandplay / gist:6230880
Created August 14, 2013 13:08
Cordova project build procedure
MODULE_NOT_FOUND = 1
check_module = (module) ->
try
require.resolve module
catch e
process.stderr.write "ERROR: #{module} is not found. Please install it first.\n"
process.exit MODULE_NOT_FOUND
fs = require 'fs'
{print} = require 'sys'
{
"id":0,
"title":"",
"width":100,
"height":100,
"background-color":"FFF",
"background-image":"",
"background-repeat":"no-repeat | repeat | repeat-x | repeat-y",
"frames":
[
String::hash = ->
userNumber = @length
for i in @
char = @charCodeAt i
userNumber += char
(userNumber + Math.floor(userNumber * 1e15)).toString(32).toUpperCase()
ProcessDocument = app.trustedFunction(function () {
app.beginPriv();
var newDoc = app.newDoc();
var p = app.response("Start with page(default 0 - process all pages)?", "Query", "0");
var startFrom = parseInt(p) || 0;
var i = 0;
while (i < this.numPages) {
newDoc.insertPages({
nPage: newDoc.numPages - 1,
<?php
function parseFavicon($html) {
// Get the 'href' attribute value in a <link rel="icon" ... />
// Also works for IE style: <link rel="shortcut icon" href="http://www.example.com/myicon.ico" />
// And for iOS style: <link rel="apple-touch-icon" href="somepath/image.ico">
$matches = array();
// Search for <link rel="icon" type="image/png" href="http://example.com/icon.png" />
preg_match('/<link.*?rel=("|\').*icon("|\').*?href=("|\')(.*?)("|\')/i', $html, $matches);
if (count($matches) > 4) {