Skip to content

Instantly share code, notes, and snippets.

View dajve's full-sized avatar

Dajve Green dajve

View GitHub Profile
@dajve
dajve / kibana-mobile-monitoring.json
Last active November 29, 2018 08:47
Kibana Mobile Monitoring
{
"title": "Mobile Dashboard",
"services": {
"query": {
"list": {
"0": {
"id": 0,
"color": "#82B5D8",
"alias": "lb*",
"pin": true,
@dajve
dajve / djv-applog.php
Last active September 8, 2018 14:45
Magento shell script to parse system logs to CSV
<?php
require_once 'abstract.php';
class Djv_Shell_AppLog extends Mage_Shell_Abstract
{
const DEFAULT_SOURCE_FILE = 'system.log';
const LOG_LINE_REGEX = "/^(?P<date>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}([+-]\d{2}:\d{2})?)\b\s*\b(?P<errcode>[A-Z]+)\b\s\((?P<errno>\d)\):\s*(?P<message>.*?)(\s+in\s(?P<file>[^\s]+)\s+on\sline\s(?<line>\d+))?$/";
/**
<?php
/**
* File: app/controllers/Pabel.php
* Class Pabel
*/
class Pabel
{
/**
* @return void
*/
@dajve
dajve / object-to-array.php
Created May 27, 2018 10:28
PHP Object To Array
<?php
class Foo
{
/**#@+
* @var string
*/
public $hello = "Hello";
protected $world = "World";
private $exclam = "!";
<?php
$in = 100; $out = 200;
$s = microtime(true);
for ($i=0; $i<1000000; $i++) {
echo $in.'<br>'.$out;
}
$e = microtime(true);
echo PHP_EOL.PHP_EOL.sprintf("CONCAT (1,000,000) : %s", number_format($e-$s, 6)).PHP_EOL;
<?php
$in = 100; $out = 200;
$s = microtime(true);
for ($i=0; $i<1000000; $i++) {
echo $in,'<br>',$out;
}
$e = microtime(true);
echo PHP_EOL.PHP_EOL.sprintf("COMMA (1,000,000) : %s", number_format($e-$s, 6)).PHP_EOL;
<?php $popupIncrement = 1; ?>
<?php while ($objectResult) : ?>
<tr>
<td>
<div class="popup" onclick="myFunction(<?php echo $popupIncrement; ?>); return false;">
<img src="" />
</div>
<span class="popuptext" id="myPopup<?php echo $popupIncrement; ?>">Trigger<span>
</td>
</tr>
<?php
function pretRefuseAccord($age, $salaire)
{
switch (true) {
case $age >= 30 && $salaire < 20000 :
case $age > 40 && $salaire < 35000 :
case $age > 50 && $salaire < 50000 :
$return = true;
break;
#!/bin/bash
echo "Searching for class overrides"
echo ""
# echo "= Mage_Admin_Helper_Data"
# grep "extends Mage_Admin_Helper_Data" ./app/code/{community,local} -Rl
# echo ""
echo "= Mage_Admin_Model_Block"
grep "extends Mage_Admin_Model_Block" ./app/code/{community,local} -Rl | xargs grep "function validate("
echo ""
@dajve
dajve / 20180211.php
Last active February 11, 2018 17:08
<?php
// https://www.facebook.com/groups/2204685680/permalink/10156550592900681/
// These are your inputs
$str1 = "We all go to college";
$str2 = "We all go to temple";
// Create array of lowercase versions of the words
// Lowercase to allow our diff to not get caught up in case sensitivity
$ar1 = array_filter(array_map('trim', explode(' ', strtolower($str1))));