Skip to content

Instantly share code, notes, and snippets.

View emprendenauta's full-sized avatar
👨‍💻
Turning coffee into code ☕

Luis Angel emprendenauta

👨‍💻
Turning coffee into code ☕
View GitHub Profile
@emprendenauta
emprendenauta / makebook_obfuscate.php
Created August 29, 2025 02:10 — forked from levelsio/makebook_obfuscate.php
Obfuscate your ebook so that people who didn't pay can read it, partly
<?php
/*
I wrote this function to progressively obfuscate text in MAKEbook.io. When it KINDA worked, I just used it.
It can take a lot of improvement. I kinda just tweaked the values until it was good enough. It's not SO progressive though.
It takes all the output of your PHP scripts via ob_start(), reroutes that to the obfuscation function.
You should check if user paid for book or not, then either run ob_start or not!
@emprendenauta
emprendenauta / filamentv3-re-generate-slug.php
Last active February 27, 2025 19:16
Re-generate slug when user clicks away from the input with regex validation
<?php
/*
- Regex validation for slug
- Re-generate slug when user leave the currente input
*/
TextInput::make('slug')
->maxLength(250)
->regex('/^[a-z0-9]+(?:[_-][a-z0-9]+)*$/')
@emprendenauta
emprendenauta / filamentv3-create-validate-slug.php
Last active February 27, 2025 19:16
Generate slug on leave input field in filamentphp v3
<?php
/*
Create slug in other field called "slug" but only if the "slug" input is empty
*/
TextInput::make('title')
->maxLength(250)
->live(onBlur: true)
->afterStateUpdated(fn(Set $set, ?string $state, Get $get) => strlen($get('slug')) === 0 ? $set('slug', Str::slug($state)) : null),
@emprendenauta
emprendenauta / export_db.sql
Last active January 11, 2024 23:26
Export/Backup database from terminal using mysql
--- Use this for export db from terminal
--- Comando para exportar base de datos desde la terminal
mysqldump -u root -p data_base_name > exported_file_name.sql
---
@emprendenauta
emprendenauta / gist:4416d50a3530ae45a845a054035e0768
Created October 26, 2023 17:15 — forked from pinceladasdaweb/gist:6662290
Get Youtube Video Thumbnail with JavaScript.
var Youtube = (function () {
'use strict';
var video, results;
var getThumb = function (url, size) {
if (url === null) {
return '';
}
size = (size === null) ? 'big' : size;
@emprendenauta
emprendenauta / web.php
Created January 28, 2022 17:14
Redirect user if is authenticated
<?php
Route::get('/', function () {
// Si el usuario está autenticado/ ha iniciado sesión redireccionará a la página de admin
// if user is authenticated will redirecto to admin section
if (Auth::check()) {
return redirect()->to(route('admin'));
}
return view('public-home');
@emprendenauta
emprendenauta / get_os_and_browser.php
Created April 29, 2021 21:19 — forked from Balamir/get_os_and_browser.php
PHP: get user os and browser information
<?php
/**
* Kullanicinin kullandigi isletim sistemi bilgisini alir.
*
* @since 2.0
*/
function getOS() {
$user_agent = $_SERVER['HTTP_USER_AGENT'];
@emprendenauta
emprendenauta / custom-open-graph.php
Created April 14, 2021 18:02
Add custom open graph tags for woocommerce product
<?php
//Adding the Open Graph in the Language Attributes
function add_opengraph_doctype($output)
{
return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"';
}
add_filter('language_attributes', 'add_opengraph_doctype');
//Lets add Open Graph Meta Info
@emprendenauta
emprendenauta / less-fields-virtual.php
Created March 23, 2021 18:21 — forked from neilgee/less-fields-virtual.php
WooCommerce Remove Address Fields from checkout based on presence of virtual products in cart
<?php
add_filter( 'woocommerce_checkout_fields' , 'virtual_products_less_fields' );
/**
* WooCommerce Remove Address Fields from checkout based on presence of virtual products in cart
* @link https://www.skyverge.com/blog/checking-woocommerce-cart-contains-product-category/
* @link https://docs.woothemes.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/
* @link https://businessbloomer.com/woocommerce-hide-checkout-billing-fields-if-virtual-product-cart/
*/
<?
// Se agregaron backslashes en la clase "work-position"
echo "<li class=\"work-position\">
<h5>{$jobs[$idx]['title']}</h5>
<p>{$jobs[$idx]['description']}</p>
<strong>Achievements:</strong>
<ul>
<li>Lorem ipsum dolor sit amet, 80% consectetuer adipiscing elit.</li>
<li>Lorem ipsum dolor sit amet, 80% consectetuer adipiscing elit.</li>