Skip to content

Instantly share code, notes, and snippets.

@Jeffrey-Fazal
Jeffrey-Fazal / Add WordPress User
Created March 25, 2025 00:01
Easily add a WordPress user. Can be run via MangeWP codesnippets or add to functions.php (and remove after use)
<?php
// Configurable user details
$username = 'newuser';
$password = 'supersecurepassword';
$email = '[email protected]';
// Check if user or email already exists
if ( username_exists( $username ) ) {
echo "Username already exists.";
return;
@Jeffrey-Fazal
Jeffrey-Fazal / convert2text
Last active March 19, 2025 13:24
A bookmarklet that will allow you to copy a websites text (with the help of r.jina.ai). Simply copy the code and add it as a new bookmark with the name Convert2Text (or whatever else you choose)
javascript:(function(){let newUrl="https://r.jina.ai/"+location.hostname+location.pathname;fetch(newUrl).then(response=>{if(!response.ok){throw new Error("Server responded with status: "+response.status);}return response.text();}).then(html=>{let doc=new DOMParser().parseFromString(html,"text/html");let text=doc.body?doc.body.innerText:%22(No%20readable%20text%20found)%22;alert(%22Successfully%20loaded%20the%20text%20version.%22);if(confirm(%22Do%20you%20want%20to%20copy%20the%20text%20to%20clipboard?%22)){navigator.clipboard.writeText(text).then(()=%3E{alert(%22Text%20copied%20to%20clipboard!\n\n%22+text.substring(0,200)+%22...%22);if(confirm(%22Do%20you%20want%20to%20visit%20the%20text%20version%20of%20the%20page?%22)){window.location.href=newUrl;}}).catch(err=%3Ealert(%22Failed%20to%20copy%20text:%20%22+err));}else{window.location.href=newUrl;}}).catch(error=%3Ealert(%22Error:%20%22+error.message));})();
@Jeffrey-Fazal
Jeffrey-Fazal / gist:6941e5e8fee2831579d187d05d2c14f8
Created January 18, 2023 19:06 — forked from arjunvenkat/gist:1115bc41bf395a162084
Seeding a Rails database with a CSV file

How to seed a Rails database with a CSV file

1. Setup

First, Create a folder inside of lib called seeds

Put your CSV file example.csv into the lib/seeds folder. In the example below, the file is called real_estate_transactions.csv

Make sure you've created a resource with the appropriate columns to match your seed data. The names don't have to match up.