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 / 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');
@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');
?>
function reportError(error, message) {
message = message || '';
console.error(
'ERROR: ' + message + ' [' + error.toString() + ']\n' +
'\nName:\t\t' + (error.name || '-') +
'\nMessage:\t' + (error.message || '-') +
'\nFile:\t\t\t' + (error.fileName || '-') +
'\nSource:\t\t' + ((error.toSource && error.toSource()) || '-') +
'\nLine #:\t\t' + (error.lineNumber || '-') +
'\nColumn #:\t' + (error.columnNumber || '-') +
@AdamMadrzejewski
AdamMadrzejewski / trace.js
Created September 15, 2014 07:18
Force Stack Traces with JavaScript
// The magic
console.log(new Error().stack);
/* SAMPLE:
Error
at Object.module.exports.request (/home/vagrant/src/kumascript/lib/kumascript/caching.js:366:17)
at attempt (/home/vagrant/src/kumascript/lib/kumascript/loaders.js:180:24)
at ks_utils.Class.get (/home/vagrant/src/kumascript/lib/kumascript/loaders.js:194:9)
at /home/vagrant/src/kumascript/lib/kumascript/macros.js:282:24
@AdamMadrzejewski
AdamMadrzejewski / cached-prototype.js
Created September 5, 2014 18:36
cached prototype using clousure
Function.prototype.cached = function() {
var self = this, //"this" refers to the original function
cache = {}; //our local, lexically scoped cache storage
return function(args) {
if(args in cache) return cache[args];
return cache[args] = self(args);
};
};
Math.sin = Math.sin.cached();
@AdamMadrzejewski
AdamMadrzejewski / bconverter.js
Created September 4, 2014 11:04
Numeric base converter
;(function() {
function baseConverter(number, base, desiredBase) {
var result;
function genericToDec (n, dB) {
return parseInt(n, dB);
}
function decToGeneric (n, dB) {
@AdamMadrzejewski
AdamMadrzejewski / uri.js
Last active September 2, 2015 14:25 — forked from jlong/uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"