Skip to content

Instantly share code, notes, and snippets.

@RomanTuras
RomanTuras / README.md
Created June 14, 2025 17:06 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@RomanTuras
RomanTuras / solution.txt
Created February 21, 2024 13:29
419 page expired, Laravel
CSRF and expired login forms
How to handle a page with a login form that will expire
If your homepage contains a login form, or a modal with login, then when the session ends (by default, after 2 hours) then the csrf token is no longer valid and the user sees a page expired warning after they have filled out their login details.
We can work around this with a simple addition to the <head> of the main layout template.
```
<meta http-equiv="refresh" content="{{ config('session.lifetime') * 60 }}">
```
This simple line will the page when it gets to the end of the session. The refreshed page will have a new session and a new csrf token. This way, your login form is always valid.
@RomanTuras
RomanTuras / restore_product_name.sql
Created July 27, 2023 10:33
MySQL Restoring product name from backup table
-- Restoring product name from backup table
-- where new name != backup name AND backup table name is `oc_product_description_n`
-- Starting for each language ID - 1,3
DROP PROCEDURE IF EXISTS restore_product_name;
DELIMITER $$
CREATE PROCEDURE restore_product_name()
BEGIN
DECLARE cursor_List_isdone BOOLEAN DEFAULT FALSE;
DECLARE cur_product_id INT;
DECLARE cur_name TEXT;
@RomanTuras
RomanTuras / replace_char_between_procedure.sql
Created July 27, 2023 08:27
MySQL Replace cyrillic 'x' by lat 'x' when 'x' between numbers
-- Replace cyrillic 'x' by lat 'x' when 'x' between numbers
DROP PROCEDURE IF EXISTS replace_char_product_name;
DELIMITER $$
CREATE PROCEDURE replace_char_product_name()
BEGIN
DECLARE cursor_List_isdone BOOLEAN DEFAULT FALSE;
DECLARE cur_product_id INT;
DECLARE cur_name TEXT;
DECLARE cur_finded TEXT;
DECLARE cur_replaced TEXT;
@RomanTuras
RomanTuras / sql_get_doubles.sql
Last active April 26, 2023 14:48
SQL get doubles example
-- searching doubles by id
-- represent in the result all duplicated rows
SELECT ptc.product_id, 1c_id, p.status, p.date_added, p.date_modified
FROM oc_product_to_1c ptc
LEFT JOIN oc_product p ON ptc.product_id=p.product_id
WHERE EXISTS
(
SELECT 1
FROM oc_product_to_1c ptcii
WHERE ptcii.product_id = ptc.product_id
@RomanTuras
RomanTuras / sql_trigger.sql
Created April 26, 2023 13:57
SQL trigger example
-- Trigger for `oc_product_to_category`
-- 1) IF INSERTED a new row with main_category = 1
-- 2) IF UPDATED with: new.main_category = 1
DELIMITER $$
DROP TRIGGER IF EXISTS update_product_trigger $$
CREATE TRIGGER update_product_trigger AFTER UPDATE ON oc_product_to_category FOR EACH ROW BEGIN
IF NOT EXISTS(SELECT * FROM oc_version_changes WHERE entity_id=new.product_id AND entity_type='product') AND new.main_category = 1 THEN
INSERT INTO oc_version_changes (entity_id,entity_type) VALUES (new.product_id, 'product'); END IF; END$$
DELIMITER ;
### Wordpress config
[https://www.youtube.com/watch?v=c6PWC9m6Ai8]
_wp-config.php_
```php
define( 'WP_DEBUG', true );
//Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );
//End disable display debug
@RomanTuras
RomanTuras / sql_cli_helper.sql
Last active April 26, 2023 14:41
SQL cli helper
-- Create mysql database and user, basic tips:
-- sudo mysql -u root -p
-- Show MySQL Users
SELECT user FROM mysql.user;
CREATE DATABASE [IF NOT EXISTS] database_name;
@RomanTuras
RomanTuras / gulpfile.js
Created January 13, 2019 13:44
gulp-4 sass
gulp.task('sass', function(){
return gulp.src('catalog/view/theme/apple/stylesheet/stylesheet.sass')
.pipe(sass({
includePaths: bourbon.includePaths
}))
.pipe(autoprefixer(['last 15 versions'], { cascade: true }))
.pipe(gulp.dest('catalog/view/theme/apple/stylesheet/'))
.pipe(browserSync.reload({stream: true}))
});