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 array_nbr(row_idx, column_idx, rows, columns, level) | |
{ | |
level = level || 1; | |
var nbr = []; | |
for (var y = Math.max(0, row_idx - level); y <= Math.min(row_idx + level, rows); y++) | |
{ | |
for (var x = Math.max(0, column_idx - level); x <= Math.min(column_idx + level, columns); x++) | |
{ | |
nbr.push([x, y]); | |
} |
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 | |
/** | |
* Calculates monthly or total payable amount of the loan. | |
* | |
* @param integer $amount Loaned amount, default is 1000 | |
* @param integer $percent Percent in which amount should be calculated, default is 15 | |
* @param integer $months Loan duration in months, default is 12 months (1 year) | |
* @param boolean $total If positive value is passed function returns total payable amount instead of monthly | |
* @return float Returns 2 decimal float number |
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 | |
/** | |
* Detect current environment and define as a global constant. | |
* @param array $environments Associative-Array where the keys are environment | |
* names and it's values the URI's that should be matched. Environment URI's can | |
* be string or an array of strings. If no environment URI is matched sets | |
* current environment as a first key element of an environments array. | |
* @param string $constant_name Name of the constant enfironment should be | |
* assigned to. |
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() | |
{ | |
$('a[rel="confirm"]').on('click', function(event) | |
{ | |
var message = !$(this).data('confirm') | |
? 'Are you sure you want to do this?' | |
: $(this).data('confirm'); | |
if (!confirm(message)) | |
{ |
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 | |
function request_path() | |
{ | |
$request_uri = explode('/', trim($_SERVER['REQUEST_URI'], '/')); | |
$script_name = explode('/', trim($_SERVER['SCRIPT_NAME'], '/')); | |
$parts = array_diff_assoc($request_uri, $script_name); | |
if (empty($parts)) | |
{ | |
return '/'; |
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
var jsonp = function(url) | |
{ | |
var script = window.document.createElement('script'); | |
script.async = true; | |
script.src = url; | |
script.onerror = function() | |
{ | |
alert('Can not access JSONP file.') | |
}; | |
var done = false; |
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
#!/bin/bash | |
# Following the guide found at this page | |
# http://programmingarehard.com/2014/03/17/behat-and-selenium-in-vagrant.html | |
echo "\r\nUpdating system ...\r\n" | |
sudo apt-get update | |
# Create folder to place selenium in |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> |