Skip to content

Instantly share code, notes, and snippets.

@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:
@hectorcorrea
hectorcorrea / fuse-demo.html
Created January 12, 2024 01:37
Demo how to use fuse.js with plain JavaScript
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/fuse.js/dist/fuse.js"></script>
</head>
<body>
<input type="text" id="searchTerms" placeholder="text to search" />
<button id="searchButton">Search</button>
<div id="searchResults">
# =======================================================================
# 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 / pre-commit
Created August 11, 2022 15:03
A sample Git pre-commit hook to make sure file vault.yml file is encrypted before accepting a commit
#!/bin/sh
# reference: https://www.atlassian.com/git/tutorials/git-hooks
#
# To use this Git hook in a given repository:
# 1. copy the content to .git/hooks/
# 2. make it an executable: chmod u+x .git/hooks/pre-commit
#
# Once installed, everytime you issue `git commit` it will make sure the file vault.yml has the
# expected token to indicate that is encrypted. If the token is not found we assume the file is
# NOT encrypted and reject the commit.
@hectorcorrea
hectorcorrea / simplest_sort.rb
Created May 9, 2022 15:02
Ruby version of "the simplest (and most surprising) sorting algorithm ever"
# Reference: https://arxiv.org/abs/2110.01111
a = [1, 9, 100, 23, 4, 99, 500, 245, 77]
n = a.length-1
puts "-- ORIGINAL --"
puts a
for i in 0..n do
for j in 0..n do
if a[i] < a[j]
@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)