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
location ~ ^/kibana-int/dashboard/.*$ { | |
set $privs NA; # by default, no privs needed | |
proxy_read_timeout 90; | |
if ( $request_method ~ (PUT|DELETE) ) { | |
set $privs M; # M for modify | |
} | |
if ( $remote_user ~ (admin1|admin2|admin3|admin4) ) { | |
set $privs "${privs}Y"; # Y for admin | |
} |
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 | |
public static function getYoutubeVideoIdFromUrl($url) | |
{ | |
// Check for a valid youtube url | |
$rx = '~ # Using ~ to avoid LTS (http://en.wikipedia.org/wiki/Leaning_toothpick_syndrome) | |
^http(?:s)?:// # Mandatory protocol (optional ssl) | |
(?:www\.)? # Optional subdomain | |
(?:youtube\.com/watch(?:/)?\?v=|youtu\.be/) # mandatory domain & path for youtube or shortlink for youtu.be | |
([^?&]+) # video id as capture group 1 | |
~x'; |
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
// Source: http://stackoverflow.com/questions/2834353/php-how-do-i-convert-a-server-timestamp-to-the-users-timezone | |
$timestamp = time(); | |
echo 'Unix timestamp: ' . $timestamp; | |
$dt = DateTime::createFromFormat('U', $timestamp); | |
$dt->setTimeZone(new DateTimeZone($timezone)); | |
$adjusted_timestamp = $dt->format('U') + $dt->getOffset(); | |
echo ' Timestamp adjusted for: ' . $timezone . $adjusted_timestamp; |
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 tree(&$tree, $num_nodes) | |
{ | |
if($num_nodes == 0) | |
return null; | |
$left = (int)($num_nodes / 2); | |
$right = $num_nodes - $left -1; | |
$tree[]['value'] = (int)(mt_rand( 1, 50) / $num_nodes+1); | |
$last = count($tree)-1; |
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
echo "Community Namespace" | |
echo "------------------------------------------" | |
cd app/code/community | |
for i in $(ls -d */) | |
do | |
echo ${i%%/} && fgrep -Rho --include='*.php' '__(' ${i%%/} | wc -l | |
done | |
echo | |
echo "Local Namespace" | |
echo "------------------------------------------" |
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
/** | |
* This is a simple "sketch" that calls a web page when a button is pressed. It is a proof-of-concept | |
* for my boss and hastily written in about 2 hours. The remote URL is a PHP script that handles | |
* making the API calls to a remote SMS-messaging service. | |
* | |
* I'm sure it could make use of interrupts somehow, but I'm not sure how off the top of my head. | |
* | |
* It uses the onboard RGB LED as status display: | |
* - Red = Waiting to be pressed | |
* - Green = Making HTTP request |
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 | |
/** | |
* A class for validating and filtering user input | |
* | |
* This class acts as a wrapper for the filter functions in >= PHP 5.2 or PECL. | |
* If an optional array of required items is passed to the class constructor, | |
* the Pos_Validator object generates an array of missing items. | |
* | |
* The first argument for each validation method is the name of the input | |
* field or URL variable, which is always required. Many methods accept |
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 foobarbaz(){ | |
// Extract environment object to local scope (not mandatory, you can access the parent scope via $this. Ex. $this->foo ) | |
extract((array)$this); | |
var_dump($foo, $bar, $baz); | |
} | |
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 F { | |
public static function curry($f) { | |
return new F($f); | |
} | |
private function __construct($f, $args = []) { | |
$this->f = $f; | |
$this->args = $args; |
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 main() { | |
for ($c=0;$c<1000000;$c++) { | |
bubble(); | |
} | |
} | |
function bubble() { | |
$array = array(3,4,1,3,5,1,92,2,4124,424,52,12); |
OlderNewer