Skip to content

Instantly share code, notes, and snippets.

View mjameswh's full-sized avatar

James Watkins-Harvey mjameswh

View GitHub Profile
@mjameswh
mjameswh / rename_es_index.sh
Last active August 18, 2023 20:59
Demonstration of how to rename an ElasticSearch index using the Index Clone API, introduced in ES 7.4. This is the cUrl based version. See here for details: https://stackoverflow.com/a/59397746/2887657 .
source_index=source_index
target_index=target_index
elastic_search_server=elasticsearch:9200
# Make sure the source index is actually open
curl -X POST "${elastic_search_server}/${source_index}/_open"
# Put the source index in read-only mode
curl -X PUT "${elastic_search_server}/${source_index}/_settings" \
////////////////////////////////////////////////////////////////////////////////
// This is an example of a proposed configuration language for restic,
// based on Hashpicorp's HCL.
//
// The main feature of the grammar in this example are:
//
// - More than one repository can be defined in a single configuration file.
// - Some aspects of the configuration (i.e. backends definitions) can be
// shared by different repositories.
// - Support for multiple backends for a single repository.
@mjameswh
mjameswh / certbot-auto-with-plugins.sh
Last active August 5, 2020 15:15
A wrapper around the certbot-auto wrapper that ensure that required plugins are reinstalled.
#!/bin/bash
# The list of plugins to be installed
CERTBOT_PLUGINS="certbot-dns-route53"
### DO NOT MODIFY ANYTHING BELOW THIS LINE ###
# Work even if somebody does "sh thisscript.sh".
@mjameswh
mjameswh / Ma première page.html
Created May 3, 2019 19:33
Un exemple de page HTML très simple
<html>
<head>
<title>Ma première page web</title>
</head>
<body>
<h1>Ma première page web</h1>
<p>
Allo!
</p>
<p>
@mjameswh
mjameswh / my_login.php.diff
Created April 15, 2019 19:40
Use an existing PHP application with login as an OAuth2 Authorization Server
<?php
// ...
// Verify that provided username and password are valid
if ( checkLogin($_POST['username'], $_POST['password']) ) {
+ // If a target URL has been set, then redirect the user to that URL.
+ if (isset($_SESSION['login_success_target'])) {
+ header('Location: ' . $_SESSION['login_success_target']);