Skip to content

Instantly share code, notes, and snippets.

View krabello's full-sized avatar

Kevin Rabello krabello

  • Stetson University
  • DeLand, Florida
View GitHub Profile
@krabello
krabello / session.php
Created November 10, 2021 18:09
Session Start
<?php
if (session_status() == PHP_SESSION_NONE) {
// Prevents javascript XSS attacks aimed to steal the session ID
ini_set('session.cookie_httponly', '1');
// ** PREVENTING SESSION FIXATION **
// Session ID cannot be passed through URLs
ini_set('session.use_only_cookies', '1');
@krabello
krabello / docker-compose.yml
Created July 2, 2021 22:48
Wordpress docker-compose
version: "3.9"
services:
db:
platform: linux/x86_64
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
@krabello
krabello / price_conversion.py
Last active April 26, 2021 15:40
Generates SQL for Prestashop Special Pricing import
###
Usage: python3 ./price_conversion.py <DATA-FILE> > <EXPORT>.sql
###
import csv, math, re, sys
id_field_name = "ID"
regular_price_field_name = "Price tax excluded or Price tax included"
approved_customer_price_field_name = "Specific Price"
def generate_values(id_product, discount_price):
@krabello
krabello / gist:f21e48d5dff9d066446ad1d8e7fce07a
Last active November 28, 2020 21:54
Line Clamp Example
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.clamp {
-webkit-line-clamp: 2;
display: -webkit-box;
-webkit-box-orient: vertical;
overflow: hidden;
word-break: keep-all;
- hosts: webservers-test
gather_facts: no
remote_user: root
pre_tasks:
- name: Update apt cache.
apt: update_cache=true cache_valid_time=600
tasks:
- name: Install opendkim
@krabello
krabello / remove-all-ps-products.sql
Created October 10, 2018 18:00
Prestashop Delete * Product Data
# All these tables have an id_product primary key
TRUNCATE TABLE ps_product;
TRUNCATE TABLE ps_product_attachment;
TRUNCATE TABLE ps_product_country_tax;
TRUNCATE TABLE ps_product_group_reduction_cache;
TRUNCATE TABLE ps_product_lang;
TRUNCATE TABLE ps_product_sale;
TRUNCATE TABLE ps_product_tag;
TRUNCATE TABLE ps_category_product;
TRUNCATE TABLE ps_feature_product;
@krabello
krabello / RIBPS.sql
Created September 21, 2018 18:10
RIBPS, Recommended InnoDB Buffer Pool Size based on all InnoDB Data and Indexes with an additional 60%
SELECT CEILING(Total_InnoDB_Bytes*1.6/POWER(1024,3)) RIBPS FROM
(SELECT SUM(data_length+index_length) Total_InnoDB_Bytes
FROM information_schema.tables WHERE engine='InnoDB') A;
@krabello
krabello / Innodb_buffer_pool_reads.sh
Created September 21, 2018 18:09
The number of reads from disk into the buffer pool (per second)
mysqladmin -uroot -proot ext -ri1 | grep Innodb_buffer_pool_reads
@krabello
krabello / convert_myisam_to_innodb.sql
Created September 21, 2018 18:08
Returns list of queries that will convert all tables in a given schema from MyISAM to InnoDB
SET @DB_NAME = 'your_database';
SELECT CONCAT('ALTER TABLE `',
table_name, '` ENGINE=InnoDB;') AS sql_statements
FROM information_schema.tables AS tb
WHERE table_schema = @DB_NAME
AND ENGINE = 'MyISAM'
AND TABLE_TYPE = 'BASE TABLE'
ORDER BY table_name DESC;
@krabello
krabello / MyISAM_tables.sql
Created September 21, 2018 18:01
Returns list of all MyISAM tables sorted by size
SELECT
concat(table_schema, '.', table_name) tbl,
engine,
concat(round(table_rows/
1000000,2),'M') rows,
concat(round(data_length/
(1024*1024*1024),2),'G') DATA,
concat(round(index_length/
(1024*1024*1024),2),'G') idx,
concat(round((data_length+index_length)/