Skip to content

Instantly share code, notes, and snippets.

View dajve's full-sized avatar

Dajve Green dajve

View GitHub Profile
@dajve
dajve / IP Blacklist
Created December 9, 2016 15:16
IP Addresses identified as attempting malicious behaviour against either Magento or Wordpress installations
deny 183.90.173.109;
deny 195.88.6.173;
deny 80.87.205.100;
deny 80.87.205.101;
deny 80.87.205.102;
deny 80.87.205.103;
deny 80.87.205.104;
deny 80.87.205.105;
deny 80.87.205.106;
deny 80.87.205.107;

For an array passed with values

$tags = ['tag1','tag2','foo','bar']

the resulting $query will be

SELECT * FROM (
		SELECT 
 p.id
@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))));
#!/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 ""
<?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;
<?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
$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
$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;
@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
/**
* File: app/controllers/Pabel.php
* Class Pabel
*/
class Pabel
{
/**
* @return void
*/