Skip to content

Instantly share code, notes, and snippets.

View oropesa's full-sized avatar
🙂
I'm chachon

Oropesa oropesa

🙂
I'm chachon
View GitHub Profile
@oropesa
oropesa / 1. Common Table Expressions (CTEs).sql
Created February 14, 2024 08:02
3 Essential SQL Tricks You Absolutely Need to Know
// ❌ Without CTEs
SELECT customer_id, COUNT(order_id) AS order_count
FROM (
SELECT customer_id, order_id
FROM orders
WHERE order_date >= '2023-01-01' AND order_date <= '2023-12-31'
) AS yearly_orders
GROUP BY customer_id
HAVING COUNT(order_id) > 5;
@oropesa
oropesa / psql create users with readonly access
Created May 17, 2023 11:00
Postgresql: create users w/ readonly (SELECT only)
> CREATE ROLE name_readonly WITH
NOLOGIN
NOSUPERUSER
NOCREATEDB
NOCREATEROLE
INHERIT
NOREPLICATION
CONNECTION LIMIT -1;
> GRANT CONNECT ON DATABASE db_name TO name_readonly;
#https://askubuntu.com/questions/325807/arrow-keys-home-end-tab-complete-keys-not-working-in-shell
$> sudo chsh -s /bin/bash <username>
@oropesa
oropesa / check files utf-8
Created January 29, 2021 10:26
From a directory, list files with encoding utf-8
> file * --mime-encoding | grep utf-8
@oropesa
oropesa / example.bash
Created January 15, 2021 12:34
Git Repository in Windows - All in Local
# https://stackoverflow.com/questions/7632454/how-do-you-use-git-bare-init-repository
# I use this workflow to work with Git in a Windows Server (with several user accounts) only in Local mode.
# 1. Initialise the bare repo
> git init --bare "C:/git-repositories/chacho.git"
Initialised empty Git repository in C:/git-repositories/chacho.git/
# 2a. Create a new working folder (no existing files) by cloning the empty repo
> git clone "C:/git-repositories/chacho.git" "C:/workplaces/chacho-project/master/"
Cloning into 'C:/workplaces/chacho-project/master/'...
$str = 'In My Cart : 11 12 items';
preg_match_all('!\d+!', $str, $number);
// array( array( '11', '12' ) )
$str = '000031chacho87tio2loco';
preg_match_all('!\d+!', $str, $number);
// array( array( '000031', '87', '2' ) )
@oropesa
oropesa / Wordpress Localhost Dev Prod .php
Created March 29, 2020 15:58
In wp-config.php add the next lines with mysql DEV or PRO data.
// In the parent folder where wordpress is located, add the file 'environment' with the words 'DEVELOPMENT', 'PRODUCTION',
// or the environment label that you want.
// In wp-config.php add:
if( ! defined( 'WP_ENVIRONMENT' ) ) {
$dir_environment = dirname( dirname( __FILE__ ) );
define( 'WP_ENVIRONMENT', empty( $dir_environment ) ?
'PRODUCTION' : file_get_contents( $dir_environment . 'environment' ) );
}
(In both Windows)
1. Go to C:\Users\{USER}\AppData\Roaming\AnyDesk
2. Copy & Paste 'thumbnails'
3. Open 'user.conf'
4. Replace the line 'ad.roster.items='
5. Done.
$> curl https://ipinfo.io/ip