Skip to content

Instantly share code, notes, and snippets.

View jcbrinfo's full-sized avatar

Jean-Christophe Beaupré jcbrinfo

View GitHub Profile
@jcbrinfo
jcbrinfo / get_avail.sh
Last active April 20, 2016 03:00
Get the availibility of some courses at UQAM for a specific semester
#! /bin/sh
# List all courses available for the specified semester.
#
# The courses to consider are given trought the standard input (one code by
# line).
#
# Takes one argument: the semester code, that is the year, followed by 1, 2 or
# 3. For example, `20153` corresponds to the semester of fall 2015.
#
# Copyright (c) 2016, jcbrinfo <[email protected]>.
Initialize memory with "\0\0zero\0one\0two\0three\0"
(space for a counter; read index; array of strings)
0x char
65 == 'e'
68 == 'h'
6E == 'n'
6F == 'o'
72 == 'r'
74 == 't'
77 == 'w'
@jcbrinfo
jcbrinfo / List Gist Updates.md
Last active June 28, 2016 16:16
List Gist Updates

List Gist Updates

Example: ./whatsnew-gist '2 hours ago' < gist-urls.txt

Use with moderation: Rate limits for unauthenticated IP addresses are very low (60 requests per hour as of 2016-06-20).

@jcbrinfo
jcbrinfo / git-reauthor.sh
Created June 30, 2016 14:31
Re-author the head of the specified branches.
#! /bin/sh
# Re-author the head of the specified branches of `origin`.
working_branch="$(git symbolic-ref --short HEAD 2>/dev/null || git describe --tags --always 2>/dev/null)"
[ -n "$working_branch" ] || exit
git stash || exit
reset_status() {
git checkout "${working_branch}"
git stash pop
/* For use in Stylish. */
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("github.com") {
body, .markdown-body {
font-family: "Noto Sans", sans-serif;
}
}
@jcbrinfo
jcbrinfo / migrate-drive.md
Last active September 17, 2016 22:11
How to migrate drive content

How to migrate drive content

This procedure explain how to migrate the content of one internal drive to another (example: upgrading your hard disk for a SSD), without requiring more than one SATA port (so the procedure works on laptops).

Note: This procedure works well if using a MBR. On the other hand, GPTs are more complex so we can not just copy them as-is: we have to recreate the headers. This implies that with GPTs, some systems may become unbootable (until some setting are changed manually) because IDs have changed.

WARNING: Some steps might assume 512 octets sectors.

Requirements

  • A LiveCD/LiveDVD/LiveUSB of Linux with GParted, kpartx and all the necessary driver to manage the partitions present on the old drive.
  • An external drive with enough free space to hold a single file which size equals the capacity of the old internal drive. Note: A contiguous unallocated zone maybe used in place of a file, but it’s more complex and error-prone.
@jcbrinfo
jcbrinfo / infographie-ressources.md
Last active March 9, 2018 09:45
Ressources utiles pour l’infographie
@jcbrinfo
jcbrinfo / markdown-comment.md
Last active May 9, 2017 15:43
The universal Markdown comment syntax

The universal Markdown comment syntax

Before

[/]: / "Your comment here"

After

It exploit the “reference-style” link syntax (and workarounds various bugs) to make the egine fully ignore the comment line.

@jcbrinfo
jcbrinfo / what-changed
Created May 13, 2017 20:33
A thin wrapper over the Nit’s `./tests.sh` script that displays the changes since the last run.
#! /bin/bash
# A thin wrapper over the Nit’s `./tests.sh` script that displays the changes
# since the last run.
#
# Also, recompiles (except when `--no-make` is specified) the invoked engine
# before running the tests.
#
# Synopsis
# --------
@jcbrinfo
jcbrinfo / dirname.sh
Created June 2, 2017 14:31
`dirname` in POSIX SH
#! /bin/sh
# dirname <path>
#
# Strip the last path component.
#
# Apply the same transformation than `dirname(1)`, but end the resulting path
# with `/`, so it can be safely used inside a `"$(…)"`
#
# Edge cases