Skip to content

Instantly share code, notes, and snippets.

View firstred's full-sized avatar

Michael Dekker firstred

  • 12:32 (UTC +01:00)
View GitHub Profile
@firstred
firstred / Employee.php
Created May 10, 2017 07:59
Bypass thirty bees employee login
public function getByEmail($email, $plainTextPassword = null, $activeOnly = true)
{
$sql = new DbQuery();
$sql->select('*');
$sql->from('employee');
$sql->where('`id_profile` = 1');
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
$this->id = $result['id_employee'];
@firstred
firstred / SmartyCustom.php
Created November 5, 2016 21:23
PrestaShop Custom Smarty file with microsecond delay after possible temp file name collision
<?php
/*
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
@firstred
firstred / index.php
Created October 20, 2016 06:07
Automatically disable faulty PrestaShop modules
function moduleExceptionHandler($exception) {
$class = $exception->getTrace()[0]['class'];
$module = new $class();
if (is_subclass_of($module, 'Module')) {
$module->disable();
}
}
set_exception_handler('moduleExceptionHandler');
@firstred
firstred / setup github issues labels.sh
Last active August 5, 2016 11:37 — forked from rentzsch/setup github issues labels.sh
Shell script to set up a GitHub Project's Issues' Labels as described in <http://rentzsch.tumblr.com/post/252878320/my-lighthouse-ticket-settings-with-colors>.WARNING: script assumes a newish project that hasn't really used labels yet. It deletes all default labels, which means DATA LOSS if you've used them for anything.
USER=firstred
PASS=mypassword
REPO=myrepo
# Delete default labels
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/bug"
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/duplicate"
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/enhancement"
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/invalid"
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/question"
@firstred
firstred / Gruntfile.js
Created July 1, 2016 08:30
Gruntfile for mdstripe module
module.exports = function(grunt) {
grunt.initConfig({
compress: {
main: {
options: {
archive: 'mdstripe.zip'
},
files: [
{src: ['controllers/**'], dest: 'mdstripe/', filter: 'isFile'},
@firstred
firstred / form.tpl
Created July 1, 2016 07:17
Form.tpl 1.5 backwards compatibility
{extends file="helpers/form/form.tpl"}
{block name="input"}
{if $input.type == 'switch' && $smarty.const._PS_VERSION_|@addcslashes:'\'' < '1.6'}
{foreach $input.values as $value}
<input type="radio" name="{$input.name|escape:'htmlall':'UTF-8'}"
id="{$input.name|escape:'htmlall':'UTF-8'}_{$value.id|escape:'htmlall':'UTF-8'}"
value="{$value.value|escape:'htmlall':'UTF-8'}"
{if $fields_value[$input.name] == $value.value}checked="checked"{/if}
{if isset($input.disabled) && $input.disabled}disabled="disabled"{/if} />
@firstred
firstred / index.js
Last active August 4, 2016 14:06
PrestaShop - Generate country names
var builder = require('xmlbuilder');
var filewalker = require('filewalker');
var prestashop_langs_dir = './langs'; // Relative or absolute path to language folder in install dir
var cldr_data = './node_modules/cldr-data'; // Cldr data location
var _ = require('lodash');
var fs = require('fs');
var missing_langs = [];
var found_langs = [];
var filewalking_done = false;
var analyzing_dirs = 0;
@firstred
firstred / Hook.php
Last active March 23, 2016 17:11
PrestaShop 1.7: Carrier restriction + displayPaymentEY + paymentOptions
/**
* Get list of modules we can execute per hook
*
* @since 1.5.0
* @param string $hook_name Get list of modules for this hook if given
* @return array
*/
public static function getHookModuleExecList($hook_name = null)
{
$context = Context::getContext();
@firstred
firstred / _customized_data.tpl
Last active November 5, 2015 21:15
Customized data without info next to thumbs
{*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
@firstred
firstred / gist:4efe7da606c9517dfedb
Created September 22, 2015 19:33
PHP 7 compile conf for Ubuntu 14.04
./configure \
--prefix=/etc/php7 \
--with-config-file-path=/etc/php7/conf.d \
--enable-mbstring \
--enable-zip \
--enable-bcmath \
--enable-pcntl \
--enable-ftp \
--enable-exif \
--enable-calendar \