Skip to content

Instantly share code, notes, and snippets.

@titomus
titomus / ngrams.js
Created Sep 13, 2022
Ngram creation with probabilities
View ngrams.js
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()*/];
View rangeipbots.txt
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.
View 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));
View aigeneratecontent.js
async function writeAboutTest(prompt,keywords = 'vie,ce que',exemple= '1.', engine = "davinci-instruct-beta-v3") { //text-davinci-002
let text = "";
/*
1. intro
2. sous titre
content
sous titre
content
3. conclusion
@titomus
titomus / bonnespratiques.js
Created Mar 27, 2022
Bonnes pratiques JS
View bonnespratiques.js
/*
Class js avec private vars
*/
class Person {
name = '';
//private vars
#age = 0;
#ageInDogYears = 0;
@titomus
titomus / cache_wp.php
Created Feb 28, 2022
Cache WordPress sur index.php directement
View cache_wp.php
<?php
/**
* Class Compress
*/
class Compress {
// methode basique de compression utile pour html, css, js
public static function compress_inline($code) {
return preg_replace(
array(
View is-alive-backlink.php
View string-between.php
<?php
function getStringBetween($p_string, $p_from, $p_to, $p_multiple=false){
//checking for valid main string
if (strlen($p_string) > 0) {
//checking for multiple strings
if ($p_multiple) {
// getting list of results by end delimiter
$result_list = explode($p_to, $p_string);
//looping through result list array
foreach ( $result_list AS $rlkey => $rlrow) {
@titomus
titomus / gsuggest.php
Created Feb 13, 2022
Google Suggest scraper
View gsuggest.php
<?php
function ggSuggest($word, $lang = 'fr', $spin = false){
$word = urlencode(trim($word));
$words = array();
$apicall = ("https://www.google.com/complete/search?output=toolbar&q=$word");
$result = utf8_encode(file_get_contents($apicall));
$resp = simplexml_load_string($result);
if ($resp){
foreach ($resp as $t) {
@titomus
titomus / spin.js
Created Feb 13, 2022
Content Spinning JS
View spin.js
function spin(txt){
var matches = txt.match(/{([^{}]*)}/g);
if (!matches) return txt;
for (i in matches) {
spin = matches[i]+'';
ori_spin = spin;
spin = spin.replace("{", "").replace("}", "");
spin_strs = spin.split('|');
txt = txt.replace(ori_spin,spin_strs[Math.floor(Math.random() * spin_strs.length)]);