Skip to content

Instantly share code, notes, and snippets.

/**
* @author mrdoob / http://mrdoob.com/
* @author supereggbert / http://www.paulbrunt.co.uk/
* @author julianwa / https://github.com/julianwa
*/
THREE.RenderableObject = function () {
this.id = 0;
/**
* @author Eberhard Graether / http://egraether.com/
* @author Mark Lundin / http://mark-lundin.com
* @author Simone Manini / http://daron1337.github.io
* @author Luca Antiga / http://lantiga.github.io
*/
THREE.TrackballControls = function ( object, domElement ) {
var _this = this;
@alectoist
alectoist / ajaxTrackingNumberUpdate.js
Created July 29, 2015 10:30
Ajax order update on Prestashop, js part
$(document).ready(function() {
var tableRows = $('table tbody tr');
for (var i = 0; i <= tableRows.length; i++) {
$(tableRows[i]).attr('id', 'tableRowId_' + i.toString());
$($(tableRows[i]).find('td')[ 1 ]).attr('id', 'table_item_id_' + i.toString());
$($(tableRows[i]).find('td')[ 3 ]).attr('id', i.toString())
.attr('class', 'table_item_tracking_number')
.attr('onclick', '');
};
@alectoist
alectoist / AdminOrdersController.php
Created July 29, 2015 10:32
Ajax order update on Prestashop, php part
//I know, it's horrible
if ($_POST['action']=='ajaxOrderUpdate'){
$orderId = $_POST['order_id'];
$changeTo = $_POST['change_to'];
Db::getInstance()->update('order_carrier', array(
'tracking_number' => $changeTo,
),
@alectoist
alectoist / gist:9d7119ca0544c39ad2eb
Created August 4, 2015 09:11
How do I async loaded CSS
//Stolen from http://stackoverflow.com/questions/24020254/async-true-for-css-link-tag
var resource = document.createElement('link');
resource.setAttribute("rel", "stylesheet");
resource.setAttribute("href","path/to/cssfile.css");
resource.setAttribute("type","text/css");
var head = document.getElementsByTagName('head')[0];
head.appendChild(resource);
@alectoist
alectoist / bestSyntaxEver.php
Created August 7, 2015 13:12
Best syntax ever
public function processGenerateDeliverySlipPDF()
{
if (Tools::isSubmit('id_order'))
$this->generateDeliverySlipPDFByIdOrder((int)Tools::getValue('id_order'));
elseif (Tools::isSubmit('id_order_invoice'))
$this->generateDeliverySlipPDFByIdOrderInvoice((int)Tools::getValue('id_order_invoice'));
elseif (Tools::isSubmit('id_delivery'))
{
$order = Order::getByDelivery((int)Tools::getValue('id_delivery'));
$this->generateDeliverySlipPDFByIdOrder((int)$order->id);
@alectoist
alectoist / uploads.php
Created September 7, 2015 11:01
Files upload, etc
<?php
// Old piece of code
if ($_FILES['uploaded_icon']['tmp_name'] && $_FILES['uploaded_icon']['size'] > 0 && $_FILES['uploaded_icon']['size'] < 10000000) {
//destroy the old file if exists
$has_icon = "SELECT icon FROM articles WHERE id_article=".$_POST['id_art'];
$db_response = $db->Execute($has_icon);
if ($db_response->fields[icon] !== NULL) {
@alectoist
alectoist / functions.php
Created September 11, 2015 10:51
Functions modifying attribute images in prestashop
<?php
private function checkAndAddAttributeImage($id_attribute, $attribute_image)
{
//update scenario
if ($id_attribute !== false) {
if ($attribute_image['error'] === 0)
{
if ($attribute_image['type'] == 'image/jpeg' || $attribute_image['type'] == 'image/png')
{
@alectoist
alectoist / nested_foreach.php
Created September 11, 2015 13:36
Assign attribute images in presta
<?php
foreach ($groups as &$group) {
foreach ($group['attributes'] as $index => &$value) {
$sql = new DbQuery();
$sql->select('image_available, image_name, image_extension, a.id_attribute');
$sql->from('attribute_lang', 'l');
$sql->leftJoin('attribute', 'a', 'l.id_attribute = a.id_attribute');
@alectoist
alectoist / tooltipster-loop.js
Created September 14, 2015 08:10
Apply tooltipster only if an element contains image
// Apply tooltipster only if an element contains image and if so, make the tooltip display this image.
$(document).ready(function() {
var attributesArray = $('.group-attribute-li').toArray();
$.each(attributesArray, function(index, attribute) {
var attributeImage = $(attribute).find('.tooltip-image');
if (attributeImage.length) {
$(attribute).tooltipster({
content: $('<img style="max-width: 100px; height: auto;" class="tooltip-image" src="'+ attributeImage.attr('src') +'" />')