Skip to content

Instantly share code, notes, and snippets.

View juandesant's full-sized avatar

Juande Santander-Vela juandesant

View GitHub Profile
#!/usr/bin/env python
import datetime as dt
def riddle_for_date(date, solutions=False):
"""
Determines the number for the Saturday Mac Riddle associated with
a given date, considering whether it is the date for the riddle
or the solutions.
@juandesant
juandesant / acronym_index.tex
Created February 26, 2024 18:04
Create glossary and index entries in LaTeX
\documentclass{article}
\usepackage{hyperref}
\usepackage{makeidx}
\usepackage{glossaries}
\makeindex
\makeglossaries
% Define your acronym
@juandesant
juandesant / export_access_tables.py
Created November 7, 2023 20:35
Export tables from an Access database
# This script assumes that [mdbtools][1] are installed, for instance with
# `brew install mdbtools`
# [1]: https://github.com/mdbtools/mdbtools
# It also assumes that [pandas][2] and [pandas_access][3] are installed,
# [2]: https://pandas.pydata.org/
# [3]: https://pypi.org/project/pandas_access/
# which you can do with
# `pip install pandas pandas_access`
# or
# `pip install pandas_access`
@juandesant
juandesant / Check email from Exchange.py
Created June 10, 2020 15:02
Check email from Exchange with Python
# /usr/bin/env python
# Based on https://chuoi.org/posts/checkexchangeemailandsendemailwithpython/
"""Description
A Python script to check email exchange mailbox, download require attachment and send email to user.
Use:
cd /path/to/file && python3 main.py
"""
import os
digraph pictionary_play {
node [fontname = "Handlee"];
edge [fontname = "Handlee"];
splines=false;
randir=LR;
draw [
label = "Draw a picture";
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
gh_url = 'https://api.github.com'
req = urllib2.Request(gh_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
@juandesant
juandesant / scidb-install.sh
Last active August 2, 2023 21:22 — forked from yzhang1991/scidb-install.txt
Install SciDB
scp yzhang@linux04.cs.uh.edu:~/packages/scidb-15.7.0.9267.tgz ./
tar -xzf scidb-15.7.0.9267.tgz
mv scidb-15.7.0.9267/ scidbtrunk
sudo apt-get update
sudo apt-get -y install subversion expect openssh-server openssh-client
# The following environment variables should go into ~/.bashrc
export SCIDB_VER="15.7"
export SCIDB_SOURCE_PATH="/home/scidb/scidbtrunk"
@juandesant
juandesant / GetInnoslateRequirementsWithLabel.xquery
Last active August 2, 2023 21:19
Get Innoslate Requirements with a given label from an Innoslate project XML export
let $reqLabel := for $c in /innoslate/schema/schemaClass
where $c/name="Requirement"
return $c/@id
let $L2label := for $l in /innoslate/labels/label
where $l/name="L2"
return $l/@id
for $e in /innoslate/database/entity
where $e/schemaClassId=$reqLabel and $e/labelId[contains(child::text(), $L2label)]
@juandesant
juandesant / atlassian_api_confluence.py
Last active July 28, 2023 14:48
Confluence API examples
from atlassian import Confluence # requires atlassian-python-api
cf_user = os.environ['CONFLUENCE_USER'] # requires environment variable
cf_pwd = os.environ['CONFLUENCE_PWD']
cf_url = os.environ['CONFLUENCE_URL']
cf_space = os.environ['CONFLUENCE_SPACE']
# Content preparation
my_title = "Testing Confluence API"
html_body = """<p>Paragraph 1</p>
<p>Paragraph 2</p>
@juandesant
juandesant / add_labels_to_page_children.py
Created July 28, 2023 13:51
Use their Atlassian Python API to set labels for the children of a given page. The script asks for the URL, and the list of tags. It then finds all children for that page, regardless of URL form, and sets the proper tags.
import sys
import os
from atlassian import Confluence
def obtain_confluence_pat(path='~/.ConfluencePAT'):
confluence_PAT_filename = os.path.expanduser(path)
confluence_PAT = None
if os.path.exists(confluence_PAT_filename):
with open(confluence_PAT_filename, "r") as pat_file:
confluence_PAT = pat_file.readline()