Skip to content

Instantly share code, notes, and snippets.

@titomus
titomus / functions.php
Created October 4, 2023 15:08
Display Woocommerce Reviews outside product page
function display_woocommerce_reviews($atts) {
// Extraire les attributs du shortcode
extract(shortcode_atts(array(
'product_id' => '0',
), $atts));
// Vérifier si l'ID produit est valide
if(!$product_id || $product_id === '0') {
return "Veuillez spécifier un ID produit valide.";
}
@titomus
titomus / index.js
Created September 11, 2023 08:16
Auto Indexing Urls via Google API's
const fs = require('fs');
var request = require('request');
var { google } = require('googleapis');
var key = require('./cle.json');
const jwtClient = new google.auth.JWT(
key.client_email,
null,
key.private_key,
['https://www.googleapis.com/auth/indexing'],
const https = require('https');
const http = require('http');
const fs = require('fs');
const htmlparser = require('htmlparser2');
const urlModule = require('url');
const MAX_CONCURRENT_REQUESTS = 5;
const MAX_RETRIES = 1;
const RETRY_DELAY = 5000; // Delay in milliseconds (5 seconds)
const EXPIRED_DOMAINS_FILE = 'expired_domains.txt';
@titomus
titomus / wp-sauce.js
Created February 6, 2023 14:29
Utiliser Moment et WPapi pour publier en masse
const fs = require("fs");
const moment = require("moment");
var WPAPI = require("wpapi");
const blogUrl = "https://site.fr/";
const login = "LOGIN";
const password = "PASS";
const cat = 3; // id de votre catégorie
@titomus
titomus / kw_suggest.js
Created January 31, 2023 17:09
Trouver le champ sémantique d'une liste de sujets avec GPT3
const { Configuration, OpenAIApi } = require("openai");
const fs = require("fs");
const { get } = require("https");
const configuration = new Configuration({
apiKey: "VOTRE-CLE-API",
});
const openai = new OpenAIApi(configuration);
async function gpt3_completion(prompt) {
try {
const completion = await openai.createCompletion({
@titomus
titomus / utils.js
Created January 17, 2023 08:55
Utils NodeJS GPT-3
const fs = require("fs");
module.exports = {
getFileContent: function (file) {
return fs.readFileSync(file, 'utf8');
},
logThis: function (file,datas) {
fs.appendFileSync(file, `${datas}\n===\n`);
},
@titomus
titomus / ja-auto-cat.php
Last active December 13, 2022 10:09
Auto Categorize WordPress posts with GPT-3 IA
<?php
/*
Plugin Name: JA auto Cat
Plugin URI: https://la-faucheuse.fr
Description: Auto set category for post based on GPT-3
Version: 1.0
Author: Jeremy ALLARD
Author URI: https://la-faucheuse.fr
License: GPL2
*/
@titomus
titomus / ngrams.js
Created September 13, 2022 06:05
Ngram creation with probabilities
function n_grams(tokens,n = 2,sep = ' ',epoch = 3) {
var ngrams = [];
for (let j=0; j < epoch; j++) {
//remove first token
if (j!=0){tokens.shift();}
for (var i = 0; i < tokens.length -n; i+=n) {
let ng1 = tokens.slice(i, i+n).join(sep);
let ng2 = tokens.slice(i+n, i+n+n).join(sep);
let ngram = [ng1.replace(/\s?(START|END)\s?/gm,'')/*.trim()*/, ng2.replace(/\s?(START|END)\s?/gm,'')/*.trim()*/];
@titomus
titomus / rangeipbots.txt
Last active July 8, 2022 11:11
Bots IP Range
Yahoo|66.196.,68.142.,202.165.,66.142.
BingBot|157.55.39,207.46.13,40.77.167,13.66.139,13.66.144,52.167.144,13.67.10,13.69.66,13.71.172,139.217.52,191.233.204,20.36.108,20.43.120,40.79.131,40.79.186,52.231.148,51.8.235,51.105.67
Yandex|87.250.224.,95.108.213.,5.255.,77.88.,213.180.
Ahrefs|54.36.,51.222.
Semrush|185.191.,85.208.
Majestic|65.21.,65.108.,199.58.,167.114.,162.210.,108.59.,149.202.,176.31.,173.249.,192.99.,195.201.,167.86.,135.181.,173.212.,95.91.
DataForSeoBot|138.201.,142.132.,144.76.
Babbar|154.54.249
Petalbot|114.119.
SerpsStat|136.243.,94.130.
@titomus
titomus / tokenize.js
Created May 23, 2022 08:55
Tokenize js
function tokenize(txt) {
// on sépare en phrases pour avoir quelques points de départ dans la génération
let tokens = [];
const sentences = txt.split(/\n/gim).filter((x) => x);
// on tokenize chaque phrase en splitant les mots
for (let i = 0; i < sentences.length; i++) {
// on insert un START
tokens.push("START");
let tks = sentences[i].match(/\S+/gim).filter((x) => x);
tks.map((token) => tokens.push(token));