This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//parse json plugin | |
(function($) { | |
Sammy.JSON.LoadJSON = function(app) { | |
app.helpers({ | |
loadJSON: function(location, options, callback) { | |
options = $.extend(options, {json: true}); | |
return new Sammy.RenderContext(this).load(location, options, callback); | |
} | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $type must equal 'GET' or 'POST' | |
function curl_request_async($url, $params, $type='POST') | |
{ | |
foreach ($params as $key => &$val) { | |
if (is_array($val)) $val = implode(',', $val); | |
$post_params[] = $key.'='.urlencode($val); | |
} | |
$post_string = implode('&', $post_params); | |
$parts=parse_url($url); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isPrime( num ) { | |
if ( isPrime.cache[ num ] != null ) | |
return isPrime.cache[ num ]; | |
var prime = num != 1; // Everything but 1 can be prime | |
for ( var i = 2; i < num; i++ ) { | |
if ( num % i == 0 ) { | |
prime = false; | |
break; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ioSocket = io.connect("http://www.mydomain:443/chatserver"); | |
ioSocket.of('/chatserver').on('connect', function() | |
{ | |
// Everything works fine | |
console.info("Connected to Chat-server"); | |
}).on('connect_failed', function(reason) | |
{ | |
/* Connection failed. This can have many reasons. | |
One possible reason is the blocking of port 443 which I used above. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Declarations with var: Always | |
var | |
Constants: | |
Use NAMES_LIKE_THIS for constant values. | |
Never use the const keyword as it not supported in Internet Explorer. | |
If a value is intended to be constant and immutable, it should be given a name in CONSTANT_VALUE_CASE. ALL_CAPS additionally implies @const (that the value is not overwritable | |
ex: | |
TIMEOUT_IN_MILLISECONDS = 60; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Require.js allows us to configure shortcut alias | |
require.config({ | |
// The shim config allows us to configure dependencies for | |
// scripts that do not call define() to register a module | |
shim: { | |
'socketio': { | |
exports: 'io' | |
}, | |
'underscore': { | |
exports: '_' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Services\Validators; | |
abstract class Validator { | |
protected $attributes; | |
public $errors; //allow access to error messages | |
public function __construct($attributes = null){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Services\Validators; | |
class Step1 extends Validator{ | |
//rules for step1 validation | |
public static $rules = array( | |
'email' => 'required', | |
'firstname' => 'required', | |
'lastname' => 'required', | |
'system_key' => 'required|systemcheck', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class RegisterController extends BaseController { | |
protected $layout = 'layouts.master'; | |
//post | |
public function post_index(){ | |
$validation = new Services\Validators\Step1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @package boot | |
*/ | |
if(!defined('PHP_VERSION_ID')){ | |
$version = PHP_VERSION; | |
/** |