Skip to content

Instantly share code, notes, and snippets.

@samuelguebo
samuelguebo / wmf-production-access-groups-stats.py
Last active August 20, 2025 23:02
Stats on Wikimedia's production groups from publicly availble data.yaml
#!/usr/bin/env python3
# -----------------------------------------------------------------------------
# MIT License
#
# Copyright (c) 2025 Samuel Guebo
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@samuelguebo
samuelguebo / wiki-user-group-count.py
Last active August 19, 2025 22:34
Wikimedia projects stats
#!/usr/bin/env python3
# -----------------------------------------------------------------------------
# MIT License
#
# Copyright (c) 2025 Samuel Guebo
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
#!/usr/bin/env python3
# -----------------------------------------------------------------------------
# MIT License
#
# Copyright (c) 2025 Samuel Guebo
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
/**
* "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-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","[email protected]","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");