Skip to content

Instantly share code, notes, and snippets.

View IlanVivanco's full-sized avatar
💡
Coding!

Ilán Vivanco IlanVivanco

💡
Coding!
View GitHub Profile
@IlanVivanco
IlanVivanco / replace_accents.sql
Last active October 16, 2019 18:03
Replace accents
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'Š','S');
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'š','s');
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'Ð','Dj');
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'Ž','Z');
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'ž','z');
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'À','A');
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'Á','A');
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'Â','A');
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'Ã','A');
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'Ä','A');
@IlanVivanco
IlanVivanco / download.sh
Last active April 14, 2020 13:30
Download images from URL from list
while read -r url name ; do
wget -O $name $url
done < images.txt
@IlanVivanco
IlanVivanco / settings.json
Last active August 18, 2020 17:57
Windows Terminal Settings
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
"initialCols": 120,
"initialRows": 30,
"copyOnSelect": true,
"profiles": {
"defaults": {
"acrylicOpacity": 0.85,
"cursorColor": "#CCC",
REM WSL symlink guide here https://dev.to/themartes_/how-to-make-wsl2-even-faster-with-fast-git-28p8
REM ---------------------
REM Now when we have our script we need to run it every time we boot into our machine. We also need to do that with the highest privileges because you need to be an admin to make a symlink from network drive to your base drive.
REM So go ahead and search for Task Scheduler. On the left sidebar you will see Task Scheduler Library. Click on it and on the right sidebar click on Create Task....
REM Now make sure you'll give a name to your task, then write a little description and Check "Run with highest privileges". Also make sure you'll change Configure for: To Windows10
REM Next click on Triggers tab and add new trigger. This will look fairly simple, Just make sure it's like this, and click OK.
REM Next click on Actions add New and Select the .bat script we created earlier with the following code:
REM ---------------------
@echo off
@IlanVivanco
IlanVivanco / download_files.txt
Last active March 16, 2021 12:43
Download multiple files using wget
https://example.com/file1.gz
https://example.com/file2.gz
https://example.com/file3.gz
@IlanVivanco
IlanVivanco / .htaccess
Last active March 16, 2021 12:49
Browser cache
# Enable Compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
@IlanVivanco
IlanVivanco / wordpress-menu-filter.php
Last active March 16, 2021 12:55
Add a shortcode to a specific menu item
<?php
/**
* Filters all menu item URLs for a #placeholder#.
*
* @param WP_Post[] $menu_items All of the nave menu items, sorted for display.
*
* @return WP_Post[] The menu items with any placeholders properly filled in.
*/
function iv_dynamic_menu_items( $menu_items ) {
@IlanVivanco
IlanVivanco / replace_relative_urls.sql
Last active March 16, 2021 12:56
Replace WP relative URLs images
UPDATE
wp_posts
SET
post_content = (
REPLACE(post_content, 'src="http://', 'src="//')
)
WHERE
INSTR(post_content, 'jpeg') > 0
OR INSTR(post_content, 'jpg') > 0
OR INSTR(post_content, 'gif') > 0
@IlanVivanco
IlanVivanco / count-number-of-pages.sql
Last active March 16, 2021 12:56
Find pages using a template
SELECT
COUNT(*) as total
FROM
wp_posts as p
JOIN wp_postmeta as m ON p.ID = m.post_id
WHERE
p.`post_type` = 'page'
AND p.`post_status` = 'publish'
AND m.`meta_key` = '_wp_page_template'
AND m.`meta_value` = 'page-your-template-name.php'
@IlanVivanco
IlanVivanco / wp_library_size.php
Last active March 16, 2021 13:00
Media library size Dashboard Widget
<?php
add_action( 'wp_dashboard_setup', 'iv_wp_dashboard_setup' );
function iv_wp_dashboard_setup() {
if( current_user_can( 'install_plugins' ) )
wp_add_dashboard_widget( 'iv_folder_sizes', __( 'Folder Sizes' ), 'iv_wp_add_dashboard_widget' );
}
function iv_wp_add_dashboard_widget() {
$upload_dir = wp_upload_dir();