Skip to content

Instantly share code, notes, and snippets.

@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;
}
@hectorcorrea
hectorcorrea / passenger_report.rb
Last active September 4, 2018 13:41
Creates a tab delimited list from the passenger status log file.
# Parses a file with the output of `passenger-status` and outputs a
# tab delimited list with the date and number of requests in queue
# that `passenger-status` reported.
#
# The file `passenger_status.log` is created with via a cron job that
# runs every X minutes as follows:
#
# /path/to/.gem/gems/passenger-5.1.12/bin/passenger-status >> ./logs/passenger_status.log
#
#
@hectorcorrea
hectorcorrea / server.go
Last active October 10, 2017 17:00
An example on how to generate a local SSL certificate in Go and serve HTTPS traffic with it
// An example on how to generate a local SSL certificate in Go
// and serve HTTPS traffic with it.
//
// Code taken from the book Go Web Programming by Sau Sheong Chang
// https://github.com/sausheong/gwp
//
// Run with `--https` to serve traffic via HTTPS (it will create the certificate
// and private key files if they don't exist)
//
// Run with no parameters to serve traffic via HTTP (no certificates needed)
@hectorcorrea
hectorcorrea / forever-initd-hectorcorrea.sh
Last active January 18, 2017 17:39
A sample init.d script to start a CoffeeScript application through forever. This used to be part of the source code of my hectorcorrea.com repo but since I have deleted the CoffeeScript code this script was lost. This gist is to preserve it for posterity since it is referenced in a StackOverflow question.
#!/bin/bash
#
# initd-example Node init.d
#
# chkconfig: 345
# description: Script to start a coffee script application through forever
# processname: forever/coffeescript/node
# pidfile: /var/run/forever-initd-hectorcorrea.pid
# logfile: /var/run/forever-initd-hectorcorrea.log
#