Skip to content

Instantly share code, notes, and snippets.

View tallesairan's full-sized avatar
🏠
Working from home

Talles Airan tallesairan

🏠
Working from home
View GitHub Profile
@tallesairan
tallesairan / README.md
Created February 7, 2023 20:21
How to unpack .wpress archive files created by the All-in-one-Wp-Migration Wordpress plugin

How to unpack .wpress archive files created by the All-in-one-Wp-Migration Wordpress plugin

Recently I needed to download some files from a Wordpress installation where the client only gave me access to the admin dashboard. Fortunately the All-in-One WP Migration plugin was already installed, so I could take a quick backup of the whole site by downloading the installed plugins, theme and database. To my surprise downloading the backup from the All-in-One WP Migration plugin only gave me a single compressed migration.wpress file that any unpack tool refused to extract. A little web search brought me to a five year old tool called Wpress-Extractor but the provided binaries for MacOS refused to work because the package was already too old.

So I decided to rewrite this little helpful tool in Node.js to make it cross-platform compatible for Windows, MacOS and Linux.

Ok here it is: A simple 2-step tutorial how to extract a file with the .wpress extension on your computer:

  1. Step
<?php
function home_url($path){
$protocol = 'http://';
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
$protocol = 'https://';
}
$host = $_SERVER['HTTP_HOST'];
return $protocol.$host.$path;
}
// ativa ou desativar redirect
@tallesairan
tallesairan / README.md
Last active March 25, 2024 22:06
check if the post exists by slug and post type #wp

Tips

very useful when you can have an attachment with the same slug as a post record_exists_by_slug You can check the post if it exists as an attachment you can change, this way it is practically impossible to duplicate a post

@tallesairan
tallesairan / ytacfoembed.php
Last active March 11, 2024 21:55
Youtube Video gallery acf oEmbed field
<?php
function get_youtube_video_ID($youtube_video_url) {
/**
* Pattern matches
* http://youtu.be/ID
* http://www.youtube.com/embed/ID
* http://www.youtube.com/watch?v=ID
* http://www.youtube.com/?v=ID
* http://www.youtube.com/v/ID
* http://www.youtube.com/e/ID
@tallesairan
tallesairan / gpta.py
Created August 11, 2023 14:20 — forked from NaxAlpha/gpta.py
a custom gpt-like model that is tiny but can also scale context very long
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.backends.cuda as cuda
class NewGELU(nn.Module):
def forward(self, x):
@tallesairan
tallesairan / pythia_1b4_8k.py
Created August 11, 2023 14:19 — forked from NaxAlpha/pythia_1b4_8k.py
Fine-tune Pythia 1.4b model for 8k context window, this script requires at least 40 GB of memory, 15-20 hours of fine-tune is sufficient.
import copy
import torch
import torch.nn.functional as F
import torch.backends.cuda as cuda
from torch.utils.data import DataLoader, IterableDataset
import wandb
from tqdm import tqdm
import bitsandbytes as bnb
@tallesairan
tallesairan / 31 AI Prompts that are better than Rewrite.md
Created July 26, 2023 21:36
31 AI Prompts that are better than “Rewrite”

31 AI Prompts that are better than “Rewrite”

  • Paraphrase: This is useful when you want to avoid plagiarism
  • Reframe: Change the perspective or focus of the rewrite.
  • Summarize: When you want a quick overview of a lengthy topic.
  • Expand: For a more comprehensive understanding of a topic.
  • Explain: Make the meaning of something clearer in the rewrite.
  • Reinterpret: Provide a possible meaning or understanding.
  • Simplify: Reduce the complexity of the language.
  • Elaborate: Add more detail or explanation to a given point.
@tallesairan
tallesairan / debug.php
Created May 12, 2023 14:30
Get user by id and log-in
<?php
$username = "z";
$user = get_user_by('login', $username );
// Redirect URL //
if ( !is_wp_error( $user ) )
{
wp_clear_auth_cookie();
@tallesairan
tallesairan / pid.md
Last active April 7, 2023 12:05
get pid by port on unix

On Linux, you must be root or the other user to get process information for processes running as other users, so prepending sudo is most of what you need. In addition to that, on modern Linux systems, ss is tool to use to do this:

$ sudo ss -lptn 'sport = :80'

State Local Address:Port Peer Address:Port
LISTEN 127.0.0.1:80 : users:(("nginx",pid=125004,fd=12)) LISTEN ::1:80 :::* users:(("nginx",pid=125004,fd=11))

@tallesairan
tallesairan / hreflang.php
Last active March 31, 2023 20:04
HrefLang correct language_attributes for global support
<?php
add_filter('language_attributes', function($language_attributes) {
$la = explode('-',$language_attributes);
if(!$la){
return $language_attributes;
}
return $la[0].'"';
} ) ;