Skip to content

Instantly share code, notes, and snippets.

View josemariagarcia95's full-sized avatar

José María josemariagarcia95

View GitHub Profile
@josemariagarcia95
josemariagarcia95 / excel-to-html-table.js
Created September 29, 2021 11:34
Quick snippet to turn a list of students into a simple HTML table to post on Moodle or similars
const readXlsxFile = require('read-excel-file/node')
const fs = require('fs');
let file = `
<table border="0" cellpadding="0" cellspacing="0" width="400">
<colgroup>
<col width="200">
<col width="200">
<col width="80">
</colgroup>
# Function to update a picture date
def date_update():
# Open the side bar with the info, including the name file and the date the photo was made
chrome_driver.find_element_by_xpath("//button[@class='info']").click()
time.sleep(2)
# Grab the image name
image_name = chrome_driver.find_element_by_xpath("//div[@class='detail-item fileInfo']//span[@class='label']").text
print(image_name)
# Start the date parsing
image_date = ""
# Remove the upper bar, but it is not really necessary, it was just a test using execute_script
chrome_driver.execute_script(
"var a = arguments[0]; var b = arguments[1]; a.parentElement.removeChild(a); b.parentElement.removeChild(b)", header, header_inline)
# Spread "Year" drop-drown list to make the "Undated" category visible
for see_more_button in chrome_driver.find_elements_by_css_selector("button.show-more-button"):
chrome_driver.execute_script("arguments[0].click();", see_more_button)
# Click the "Undated" button (it has to be found like this since there is no id and the class name is not valid, '1000,' and it's not
# detected by others methods like find_element_by_class_name or find_element_by_css_selector)
more_photos_button = chrome_driver.find_element_by_xpath(
"//button[@class='1000']"
# Loop through the images in the grid
for image_mosaic in chrome_driver.find_elements_by_class_name("mosaic-item"):
time.sleep(1)
# Open an image
chrome_driver.find_element_by_xpath("//a[@class='node-link']").click()
# Update its date
date_update()
n_photos += 1
# Go back to the grid
chrome_driver.find_element_by_xpath("//a[@class='back']").click()
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
chrome_driver = webdriver.Chrome()
# Open the amazon photos login page
chrome_driver.get(
"https://www.amazon.es/photos?sf=1/ref=s9_acss_bw_h1_EEEESSS_bn_w?ref_=BN_ES_C_U_E_M_CD_CG_417_ADAPSI&pf_rd_m=A1AT7YVPFBWXBL&pf_rd_s=merchandised-search-1&pf_rd_r=CKMHBDSC7YCPSMXR24KE&pf_rd_t=101&pf_rd_p=d284dade-6826-459b-9042-bf7f3d7341d1&pf_rd_i=12364776031"
)
@josemariagarcia95
josemariagarcia95 / update-photo-part1.py
Last active April 5, 2020 23:25
Log in Amazon Photos and reach the "Undated pictures" section
#Log in using your credentials
name_field = chrome_driver.find_element_by_id("ap_email")
password_field = chrome_driver.find_element_by_id("ap_password")
name_field.clear()
name_field.send_keys("**********************")
password_field.clear()
password_field.send_keys("************************")
chrome_driver.find_element_by_id("signInSubmit").click()
header_inline = chrome_driver.find_element_by_id("primary-header-inline")
header = chrome_driver.find_element_by_id("primary-header")
@josemariagarcia95
josemariagarcia95 / word-replace-cross-reference-regex.md
Last active May 20, 2020 17:26
Snippet to fix a space after cross-reference in Word using find and replace.

Edit Word's cross-references using Find and Replace and regex

  1. Select the whole document (Ctrl + E, or triple click in the left side).
  2. Hit Alt + F9, to turn every reference into its respective code.

E.g., This cross reference, [1], after hitting Alt + F9 goes { REF _Ref88888888 \n or something }

  1. Open the Find and Replace dialog.
  2. Click in More and mark the Use wildcards checkbox so we can use *, ?, {}, & and so on.
  3. Write this in the Find box:
@josemariagarcia95
josemariagarcia95 / update-photos-date.py
Last active November 8, 2021 09:51
Selenium script with Python to update photos with no date in Amazon Photos
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
# Function to update a picture date
def date_update():
# Open the side bar with the info, including the name file and the date the photo was made
chrome_driver.find_element_by_xpath("//button[@class='info']").click()
time.sleep(2)
@josemariagarcia95
josemariagarcia95 / git-commands.txt
Last active July 17, 2019 11:41
Nice git commands
# Created a repository with a gitignore and a LICENSE file.
# Had already a gitignore in local repository in my PC
# After the git init and git add remote, use this command (check flag) to pull stuff from Github so I could fix
# merge problems afterwards
git pull --allow-unrelated-histories
@josemariagarcia95
josemariagarcia95 / curry.js
Last active November 23, 2018 11:46
Example of currifying functions in JavaScript
//The function we're gonna currify
let extractEmotion = function( media, callback ) {
console.log( 'This is extractEmotions' );
callback( media );
};
//The previous function receives a callback
let test = function( media ) {
console.log( 'I\'m the callback and I\'ve received ' + media );
};