Skip to content

Instantly share code, notes, and snippets.

View mihaitodor's full-sized avatar
:shipit:
Shipit!

Mihai Todor mihaitodor

:shipit:
Shipit!
View GitHub Profile
@mihaitodor
mihaitodor / Makefile
Created September 18, 2016 21:02
GTest sample Makefile
# A sample Makefile for building Google Test and using it in user
# tests. Please tweak it to suit your environment and project. You
# may want to move it to your project's root directory.
#
# SYNOPSIS:
#
# make [all] - makes everything.
# make TARGET - makes the given target.
# make clean - removes all files generated by make.
@mihaitodor
mihaitodor / cloudflare_fetch_rayid_log.sh
Created February 12, 2019 21:49
Fetch Cloudflare log data for a given Ray ID
#!/bin/bash
# Fetch Cloudflare log data for a given Ray ID
# Please note that the Ray ID is the first part of `CF-RAY` (4a807f60ca5727a4-FRA -> 4a807f60ca5727a4)
CF_ZONE=${1}
RAY_ID=${2}
if ! host -N 0 "${CF_ZONE}" 2>&1 > /dev/null; then
echo "Invalid domain '${CF_ZONE}'"
@mihaitodor
mihaitodor / foo_names.md
Created July 9, 2016 22:05
Map slugs to course names

https://archive.org/download/archiveteam_coursera_20160627114043/coursera_20160627114043.megawarc.warc.gz

  • bigdata = Web Intelligence and Big Data
  • clinical skills = Teaching and Assessing Clinical Skills
  • comp finance = Introduction to Computational Finance and Financial Econometrics
  • data sci = Introduction to Data Science
  • dmathgen = 离散数学概论 Discrete Mathematics Generality
  • global introuslaw = The Global Student's Introduction to U.S. Law
  • global theatre = Theatre and Globalization
  • global theatre = Theatre and Globalization
  • inforiskman = Information Security and Risk Management in Context
@mihaitodor
mihaitodor / singularity_menu_extra_script.js
Created August 7, 2020 22:17
Hubspot/Singularity `extraScript` config hack for adding links in the menu to instances of a given service
<script>
fetch('/singularity/api/tasks/ids/request/{{ Environment }}_{{ Service }}')
.then(response => response.json()).then((taskIDs) => {
Object.values(taskIDs.healthy).forEach(function(task) {
fetch('/singularity/api/tasks/task/' + task.id)
.then(response => response.json()).then((taskInfo) => {
let host = taskInfo.taskId.host.replace(/_/g, '-');
let port = taskInfo.mesosTask.container.docker.portMappings[0].hostPort;
let a = document.createElement('a');
a.textContent = '{{ Service }} at ' + host + ':' + port;
@mihaitodor
mihaitodor / smart_ssh.sh
Last active February 14, 2019 19:45
ssh convenience wrapper script
#!/bin/sh
# Assume that the last argument is the address of the host
input_addr="${@: -1}"
do_ssh () {
ssh "$@"
ret_val=$?
if [[ ${ret_val} != 0 && ${ret_val} != 127 && ${ret_val} != 130 ]]; then
echo "Failed to connect to: ${input_addr}"