Skip to content

Instantly share code, notes, and snippets.

@hectorcorrea
hectorcorrea / tictactoe_turtle_v6.py
Created June 30, 2026 12:55
Game of Tic Tac Toe using a dict to keep information about the board including the cell coordinates and state values
# Version 6:
# Same as V4 and V5 (full game) but converted to use a dict for
# all the information about the board including the information
# about the cells.
from turtle import Turtle
def vertical_line(x, y):
t = Turtle()
t.speed('fastest')
t.hideturtle()
@hectorcorrea
hectorcorrea / tictactoe_turtle_v5.py
Created June 30, 2026 12:53
Game of Tic Tac Toe but using a dict for the board information
# Version 5:
# Same as V4 (full game) but converted to use a dict for
# all the information about the board but the cells are still
# hard coded.
from turtle import Turtle
def vertical_line(x, y):
t = Turtle()
t.speed('fastest')
t.hideturtle()
@hectorcorrea
hectorcorrea / tictactoe_turtle_v4.py
Created June 30, 2026 12:52
Game of Tic Tac Toe
# Version 4:
# draws the board
# allows a user to click on the cells
# only allows a cell to be used once
# detects when a user wins
# draws the winning line
# detects ties
from turtle import Turtle
def vertical_line(x, y):
@hectorcorrea
hectorcorrea / execute-request.sh
Last active November 11, 2025 19:42
Calling Mediaflux from the terminal
# Execute the HTTP POST to Mediaflux
# The details of the request (service to call, parameters) are in payload-trivial.xml
# Make sure you also enter a valid session in the payload-trivial.xml
curl -X POST http://0.0.0.0:8888/__mflux_svc__ -H "Content-Type: text/xml" -d @payload-trivial.xml
@hectorcorrea
hectorcorrea / xml-to-mf.md
Created May 8, 2025 21:31
Using xtoshell to get the Mediaflux document representation of an XML string

Getting a Mediaflux document out of an XML string from Aterm:

> set xml "<result><tigerdataX:resourceDoc xmlns:tigerdataX=\"tigerdataX\" id=\"2\"></tigerdataX:resourceDoc></result>"
> set doc [xtoshell $xml]
> puts $doc :tigerdataX:resourceDoc -xmlns:tigerdataX "tigerdataX" -id "2"
:tigerdataX:resourceDoc -xmlns:tigerdataX "tigerdataX" -id "2":tigerdataX:resourceDoc-xmlns:tigerdataXtigerdataX-id2
# DESCRIPTION:
#
# Returns a list of files (assets) for a given path.
#
# This script uses iterators to handle cases where there are many files
# in the given path. Therefore the first time you call it you give it a
# `path` and the script will give you back an interator. Call the script
# again with the `iterator` to start iterating over the list of files.
#
# Call it as many times until the return includes `iterated complete="true"`
@hectorcorrea
hectorcorrea / demo.html
Last active March 21, 2024 14:56
JavaScript DOM events and call back functions
<html>
<head>
<!-- what does this code do? -->
<script src="leequery.js"></script>
</head>
<body>
<h1>Playing with JavaScript</h1>
<p>
This is a paragraph with a button:
# =======================================================================
# tagAdd - adds a tag (term) to the dictionary
#
# Usage:
#
# script.execute :in file:/Users/correah/src/mediaflux/tagAdd.tcl :arg -name tagName "tagXX" :arg -name tagDescription "this is the tag XX"
#
# =======================================================================
set log_name "homework-2023-03-24"
@hectorcorrea
hectorcorrea / results.html
Created November 30, 2020 15:47
Sample results.html for SolrDora using hard-coded fields. Allows to easily set the display order.
{{ define "content" }}
<style>
em {
background: #e9e91966;
}
</style>
<div class="row">
<div class="col-md-4">
<form action="/search" method="GET">
<input type="text" id="q" name="q" value="{{ .Q }}" placeholder="enter text" autofocus/>
@hectorcorrea
hectorcorrea / one.html
Created November 17, 2020 16:48
Sample one.html for SolrDora using hard-coded fields. Allows to easily set the display order.
{{ define "content" }}
<style>
/* https://stackoverflow.com/a/22955585/446681 */
.input-group{
width: 100%;
}
.input-group-addon{
width: 15%;
text-align: left;
}