Skip to content

Instantly share code, notes, and snippets.

View samuelguebo's full-sized avatar

Samuel Guebo samuelguebo

View GitHub Profile
function sendPayStubReminder() {
const monthYear = new Date().toLocaleString('en-us',{month:'long', year:'numeric'})
const senderName = "YOUR-NAME"
const recipientName = "THEIR-NAME"
const recipientEmail = "hr-person-1@example.com"
const subject = `Need stamped payslip (${monthYear})`
const cc = "hr-person-2@example.com,hr-person-3@example.com"
let emailBody = `Hello ${recipientName},<br><br/>`
import mysql.connector
import json
import requests
import csv
import os
from datetime import datetime, date, time
"""
Wiki replicas credentials, update with your own
See how to obtain these here: https://wikitech.wikimedia.org/wiki/Help:Toolforge/#Database#Connecting_to_the_database_replicas_from_your_own_computer
/**
* "Active Users" are registered users who have made at least
* one edit in the last thirty days.
*/
let apiURI = 'https://meta.wikimedia.org/w/api.php?action=parse&page=List%20of%20Wikipedias&origin=*&format=json'
fetch(apiURI)
.then(res => res.json())
.then(data => {
data = data.parse.text['*']
@samuelguebo
samuelguebo / php-wordpress-posts-to-csv.php
Created October 26, 2018 21:37
WordPress posts to CSV using WPDB class
<?php
# Author: Samuel Guebo
# reference: https://codex.wordpress.org/Class_Reference/wpdb
# Description: A simple snippet to display WordPress posts as in CSV (comma separated format).
# The script uses WPDB class and can accessed directly if put in the Website's root (/script.php)
// Include WordPress core features
require_once("wp-blog-header.php");
// Leverage WPDB class, utility for perfoming DB actions
@samuelguebo
samuelguebo / php-array-5000-spanish-words.php
Created September 24, 2018 09:05
Array of 5000 Spanish Sentences Sorted from Easiest to Hardest
<?php
$rawUrl = "https://pastebin.com/raw/fjmQKxnQ";
$rawText = file_get_contents($rawUrl);
$lines = preg_split("/\r\n|\n|\r/", $rawText);
$lines_count = count($lines);
$output = array();
$i = 0;
for($j = 0; $j<$lines_count; $j++){
@samuelguebo
samuelguebo / php-get-facebook-likes-from-url.php
Last active September 15, 2018 12:24
Quickly find the Facebook Like count for any url using Graph api (v3)
<?php
function checkFacebookReactions($url){
// Generate a token https://elfsight.com/blog/2017/10/how-to-get-facebook-access-token/
$access_token = "YOUR-FACEBOOK-TOKEN";
$api_url = 'https://graph.facebook.com/v3.0/?id=' . urlencode( $url ) . '&fields=engagement&access_token=' . $access_token;
$fb_connect = curl_init(); // initializing
curl_setopt( $fb_connect, CURLOPT_URL, $api_url );
curl_setopt( $fb_connect, CURLOPT_RETURNTRANSFER, 1 ); // return the result, do not print
curl_setopt( $fb_connect, CURLOPT_TIMEOUT, 20 );
@samuelguebo
samuelguebo / fetch-and-display-json.js
Created March 31, 2018 22:01
How to Use the JavaScript Fetch API to Get JSON Data
// ES6 compatibility
require("isomorphic-fetch")
// Set default api url
var apiUrl = 'https://randomuser.me/api/?results=10'
fetch(apiUrl).then(response => {
return response.json();
}).then(data => {
/**
@samuelguebo
samuelguebo / header.php
Last active August 14, 2021 19:31
Create new Admin user programatically
<?php
// Add this line at the very begining of the header.php of your active theme.
// And just launch your website url in your browser. It will create a new admin with the credentials that you mentioned
create_super_admin("your_username","your_email@gmail.com","your_password"); // change the variables to match your needs
## Add thumbnail to post columns in Dashboard
```php
add_image_size( 'admin-list-thumb', 80, 80, false );
function wpcs_add_thumbnail_columns( $columns ) {
if ( !is_array( $columns ) )
$columns = array();
$new = array();
@samuelguebo
samuelguebo / gist:a55531ae667d1f5d2638
Last active August 29, 2015 14:17
Wordpress: Insérer des variables dans une table
<?php
/*
Au lieu d'utiliser les variables de $_POST j'ai remplacé par des variables statiques
A toi de t'assurer que ces données là sont bien envoyées et de les sécuriser: se referer au lien ci-dessous
http://code.tutsplus.com/articles/data-sanitization-and-validation-with-wordpress--wp-25536
*/
function insert_into_db_test() {
global $wpdb;
$id=addslashes("001");
$idreservation=addslashes("001");