Skip to content

Instantly share code, notes, and snippets.

@megabayt
megabayt / gist:4df4492d4a138f5aa6d76951d51bbe40
Created October 22, 2017 12:25
remove doubles opencart
public function clear_doubles(){
$query = $this->db->query("SELECT * FROM `oc_product` WHERE xml_id IN ( SELECT xml_id FROM `oc_product` GROUP BY `xml_id` HAVING COUNT( `xml_id` ) > 1 ) ORDER BY `oc_product`.`xml_id` ASC");
$doubles = $query->num_rows != 0 ? $query->rows : [];
$original = array_shift($doubles);
foreach($doubles as $double){
var_dump($original['xml_id'], $double['xml_id']); echo "<br>";
@megabayt
megabayt / gist:ebb83e7be7e57e20770fb263a7c92bf4
Created October 23, 2017 15:15
Generate meta wordpress AIOSP
<?php
require './wp-config.php';
mb_internal_encoding("UTF-8");
try {
$dbh = new PDO('mysql:host='. DB_HOST .';dbname='. DB_NAME .';charset=utf8' , DB_USER, DB_PASSWORD);
$posts = $dbh->query("SELECT * from 8qbBV3a040_posts WHERE `post_type`='". page ."'");
foreach($posts as $post){
<div class="bigCont">
<img src="//lorempixel.com/500/500" />
</div>
<div class="smallCont">
<ul class="list-inline" style="list-style: none">
<li style="display: inline-block"><a href="//lorempixel.com/500/500"><img src="//lorempixel.com/100/100" alt=""></a></li>
<li style="display: inline-block"><a href="//lorempixel.com/500/500"><img src="//lorempixel.com/100/100" alt=""></a></li>
<li style="display: inline-block"><a href="//lorempixel.com/500/500"><img src="//lorempixel.com/100/100" alt=""></a></li>
<li style="display: inline-block"><a href="//lorempixel.com/500/500"><img src="//lorempixel.com/100/100" alt=""></a></li>
<li style="display: inline-block"><a href="//lorempixel.com/500/500"><img src="//lorempixel.com/100/100" alt=""></a></li>
@megabayt
megabayt / gist:3b1b60c39720e1ba1208a6787f1b975a
Created November 7, 2017 11:03
Add floor and skybox to threejs
// FLOOR
var floorTexture = new THREE.ImageUtils.loadTexture( 'images/checkerboard.jpg' );
floorTexture.wrapS = floorTexture.wrapT = THREE.RepeatWrapping;
floorTexture.repeat.set( 10, 10 );
var floorMaterial = new THREE.MeshBasicMaterial( { map: floorTexture, side: THREE.DoubleSide } );
var floorGeometry = new THREE.PlaneGeometry(30, 30, 0, 0);
var floor = new THREE.Mesh(floorGeometry, floorMaterial);
floor.position.y = -0.5;
floor.rotation.x = Math.PI / 2;
scene.add(floor);
//ROOM
var roomGeometry = new THREE.BoxGeometry( 20, 10, 20 );
var roomFrontMaterial = new THREE.MeshPhongMaterial( {
color: 0xffffff,
transparent: true,
opacity: 0.1
} );
var roomFront = new THREE.Mesh( roomGeometry, roomFrontMaterial );
roomFront.position.y = 5;
var roomBackMaterial = new THREE.MeshPhongMaterial( {
@megabayt
megabayt / gist:96906da76628e2d5ac279f663689f2ec
Last active November 24, 2017 09:53
custom items magnific
//magnific-popup
$(document).ready(function () {
$('div.big-image').click(function (e) {
e.preventDefault();
var items = [];
var active;
$('.thumbnails img').each(function(i, item) {
@megabayt
megabayt / accordion.js
Last active November 25, 2017 16:24
Accordion
$('.accordion-link').click(function(){
var $btn = $(this);
var $tab = $btn.next();
if($tab.is(':visible')){
$('.tabcontent').slideUp();
}else{
$('.tabcontent').slideUp();
$tab.slideDown(function(){
$('html,body').animate({
scrollTop: $btn.offset().top - ($(document).width()<768 ? 60 : $('.header-fixed').height())
include_once "library/sxgeo/SxGeo.php";
$sxGeoBase = "library/sxgeo/SxGeoCity.dat";
$sxGeo = new SxGeo($sxGeoBase, SXGEO_BATCH | SXGEO_MEMORY);
$city = $sxGeo->getCity($this->request->server['REMOTE_ADDR'])['city']['name_ru'];
if ($('#header .button-ugps span').hasClass('choose-city')) {
$.ajax({
url: '/index.php?route=ugps/city/get&json=Y',
type: 'GET',
dataType: 'json',
error: function() {
return console.error();
},
success: function(res) {
if (res.name !== void 0) {
@megabayt
megabayt / cloudSettings
Last active January 9, 2019 12:06
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-01-09T12:05:59.049Z","extensionVersion":"v3.2.4"}