Skip to content

Instantly share code, notes, and snippets.

View gmx's full-sized avatar

Graham Max gmx

  • Rangoon
View GitHub Profile
@gmx
gmx / format_number.js
Last active December 12, 2015 07:38
Format any number into comma separated string
function format_value( value )
{
var _value = value.toString();
var _decimal = '00';
if (_value.indexOf( '.' ) != -1 )
{
// the given value is float
var temp = _value.split( '.' );
_value = temp[ 0 ];
@gmx
gmx / format_number.php
Created February 8, 2013 09:27
Format any number into comma-separated numeric values
<?php
function format_value( $value )
{
$value = (string) $value;
if (strpos( $value, '.') !== FALSE)
{
list( $int_val, $decimal ) = explode( '.', $value );
}
@gmx
gmx / scope_vs_context.js
Created December 1, 2012 17:32
Callback, Scope and Context for Beginners
functions say( str, callback_fn )
{
// in the function "say",
// we call the callBack and parse the param "str", that is in the scope of "say"
callback_fn( str );
}