Skip to content

Instantly share code, notes, and snippets.

View bgadrian's full-sized avatar
✍️
available for OSS Go packages

B.G.Adrian bgadrian

✍️
available for OSS Go packages
View GitHub Profile
@bgadrian
bgadrian / appfog.deploy.bat
Created March 16, 2015 17:04
AppFog update app from windows
#put this in a ./.git/hooks/ file, like post-update
#exec update.appfog.bat
#update.appfog.bat content
::activate ruby
/E:ON /K e:\Ruby200-x64\bin\setrbvars.bat
::move to application location
cd server/
call af login --email [email protected] --password blank123
::timeout /t 60
@bgadrian
bgadrian / iscli.php
Created March 16, 2015 17:04
PHP CLI mode
//lock only from CLI mode, usually for cronjobs left in public !! Do not make this !
if (strpos(strtolower(PHP_SAPI),'cli') === false)
{
die(0);
}
@bgadrian
bgadrian / browsers.txt
Created March 16, 2015 17:05
Max count of paralel connections same client/server since 2008
Settings for Current Browsers
The table below shows the number of connections per server supported by current browsers for HTTP/1.1 as well as HTTP/1.0.
Browser HTTP/1.1 HTTP/1.0
IE 6,7 2 4
IE 8 6 6
Firefox 2 2 8
Firefox 3 6 6
Safari 3,4 4 4
Chrome 1,2 6 ?
<?php
//http://sourceforge.net/projects/precompiledbin/
//firefox addon https://addons.mozilla.org/en-US/firefox/addon/the-easiest-xdebug/?src=api
//tutorial http://devzone.zend.com/1120/introducing-xdebug/
if (APPLICATION_ENV == 'development')
xdebug_start_trace('E:\wamp\tmp\xdebug\callgrind.brentz.',XDEBUG_TRACE_HTML);
//XDEBUG_TRACE_HTML XDEBUG_TRACE_COMPUTERIZED XDEBUG_TRACE_APPEND
@bgadrian
bgadrian / space.neighbours.php
Created March 16, 2015 17:07
Checks / verify if 2 points are adjacent in a 2 dimension space
/** Calculates, from two set of coord, if two nodes are adjacents.
* @return bool|null True if they are adiacents, null if the coords are not valid or are the same.
*/
public static function areNodeAdjacents($coord_1_norm,$coord_2_norm)
{
if ($coord_1_norm['x'] === $coord_2_norm['x'] AND $coord_1_norm['y'] === $coord_2_norm['y'])//or is the same planet ..
return null;
//the formula
@bgadrian
bgadrian / notification.screen.js
Last active August 29, 2015 14:17
JS HTML Jquery alert on screen auto dissapear
/**
Add a temporal message to the interface that with auto deleting feature
*/
var uiAddMessage = function(text)
{
$('<div>'+text+'</div>')
.prependTo(this.dom_messages)//$('#parent')
.show(100)
.delay(3000 + (this.dom_messages.children().length * 700))//we must add time of lots of messages are on
.hide(200)
@bgadrian
bgadrian / objlength.js
Created March 16, 2015 17:12
JS Length of an associative array (object)
Object.keys(myArray).length
@bgadrian
bgadrian / tween.value.js
Created March 16, 2015 17:13
tweenJS modify a JS object
// Each time score is added, tween the value.
function addScore(score) {
// Save the new score
this.newScore = score;
// Create a tween that will update the "displayScore", which
// we use to display the changing number.
var tween = createjs.Tween.get(this).to({displayScore:score}, 800);
// For this example, set a local "scope" so the onChange
@bgadrian
bgadrian / memory.object.js
Created March 16, 2015 17:16
Script JS memory size object/array
/* cruel way to sum your global vars */
function roughSizeOfObject( object ) {
var objectList = [];
var stack = [ object ];
var bytes = 0;
while ( stack.length ) {
var value = stack.pop();
@bgadrian
bgadrian / bytes.size.human.js
Created March 16, 2015 17:17
JS php like bytes to human size kb mb gb
function bytesToSize(bytes) {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return 'n/a';
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
};