Skip to content

Instantly share code, notes, and snippets.

View AdamMadrzejewski's full-sized avatar
🎯
Focusing

Adam AdamMadrzejewski

🎯
Focusing
  • Journey Digital
  • Auckland, New Zealand
View GitHub Profile
@AdamMadrzejewski
AdamMadrzejewski / cookiePreventer.js
Created September 11, 2015 15:43
Prevent all cookies from being set
Object.defineProperty(document, 'cookie', {
get: function () { return ''; },
set: function () { console.warn('Cookie prevented from being set. Please accept cookie privacy police first and refresh the page.'); }
});
if (document.URL.substr(-6) == 'secret') {
document.body.style.setProperty("background-image", "none", "important")
document.body.style.setProperty("background-color", "#10FF00", "important")
}
@AdamMadrzejewski
AdamMadrzejewski / shortener.php
Created January 12, 2016 14:05
Short text by whole words + '...'. Super simple.
<?php
if (strlen($property->pro_name) > 75)
{
$propertyName = implode(" ", explode( "\n", wordwrap($property->pro_name, 75))).'...';
}
else
{
$propertyName = $property->pro_name;
}
?>
@AdamMadrzejewski
AdamMadrzejewski / change_php_dir_permissions.php
Created February 29, 2016 10:09
PHP change directory permissions recursively on shared hostings
<?php
file_fix_directory(dirname(__FILE__));
function file_fix_directory($dir, $nomask = array('.', '..')) {
if (is_dir($dir)) {
// Try to make each directory world writable.
if (@chmod($dir, 0755)) {
echo "<p>Cambio permessi directory a 0755: " . $dir . "</p>";
}
}
@AdamMadrzejewski
AdamMadrzejewski / joomla.php
Last active July 15, 2016 07:58
Simple Joomla 3 external script with JSON result from database
<?php
defined('_JEXEC') or die('Restricted access');
define('DS', DIRECTORY_SEPARATOR);
// Use these variables for direct file access
// define('_JEXEC', 1);
// define('JPATH_BASE', realpath(dirname(__FILE__)));
require_once (JPATH_BASE.DS.'includes'.DS.'defines.php');
require_once (JPATH_BASE.DS.'includes'.DS.'framework.php');
@AdamMadrzejewski
AdamMadrzejewski / joomla-password-hash.php
Last active September 26, 2016 06:18
Hashing password with Joomla 3
<?php
define('_JEXEC', 1);
define('JPATH_BASE', dirname(__FILE__));
require_once(JPATH_BASE . '/includes/defines.php');
require_once(JPATH_BASE . '/includes/framework.php');
echo "<strong>Password: </strong>" . JUserHelper::hashPassword('adam');
?>
@AdamMadrzejewski
AdamMadrzejewski / jAuthentication.php
Last active January 16, 2020 10:50
Joomla 3 External authentication script
<?php
/**
* Joomla! External authentication script
*
* @author vdespa
* Version 1.0
*
* Code adapted from /index.php
*
* @package Joomla.Site
@AdamMadrzejewski
AdamMadrzejewski / jRegistration.php
Created December 12, 2014 16:07
Joomla 3 external registration script
<?php
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );
define( 'DS', DIRECTORY_SEPARATOR );
/* Required Files */
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$app = JFactory::getApplication('site');