Skip to content

Instantly share code, notes, and snippets.

View fracz's full-sized avatar

Wojciech Frącz fracz

  • Poland
View GitHub Profile
@fracz
fracz / backup.sh
Created March 3, 2018 12:11
Automatic dockerized SUPLA MySQL database backup to Google Drive
#!/usr/bin/env bash
# Sample crontab: 0 */2 * * * /home/unicorn/backup.sh > /home/unicorn/backup.log 2>&1
NOW=$(date +"%Y%m%d%H%M%S")
BACKUP_FILE=supla-$NOW.sql
GDRIVE_DIR=0B0OnuB36CtoeknVRX2xRbS1sT1E
SUPLA_PATH=/var/www/supla-docker
BACKUP_EXPIRATION_DAYS=7
@fracz
fracz / memoize-expirable-decorator.spec.ts
Created January 14, 2017 11:54
Typescript memoize decorator with expiration time
import {memoize, clearMemoizedValue} from "./memoize";
describe("memoize", () => {
class MyClass {
@memoize(5)
getNumber() {
return Math.random();
}
}
@fracz
fracz / gc-helpers.js
Last active November 29, 2022 09:29
GC helpers
'N 50° 02. [G(A x E) : (A-C) + 2(F x H) + (B - 6C) -1]'.replace(/\[/g, '(').replace(/\]/g, ')').replace(/x/g, '*').replace(/:/g, '/').replace(/(\d)([A-Z\(])/g, '$1*$2').replace(/([A-Z])([\(])/g, '$1*$2')
letterValue = (letter) => letter.toUpperCase().charCodeAt(0) - 64;
letterValues = (word) => word.split('').map(letterValue);
// [A,B,C] = letterValues('KOT');
@fracz
fracz / Readme.md
Last active May 2, 2023 07:25
Restore intentionally deleted commits in Git

Restore intentionally deleted commits in Git (remote)

Situation

  1. You own a Git repository server and the developers do not have access to it (i.e. they can only read & write to the repo, but not gc it).
  2. You had a developer that wrote a project for you.
  3. He got angry for whatever reason and deleted all branches from the remote repo. He also push -fed the master branch leaving only one silly commit there.
  4. He escaped from the country leaving you without any code at all (at least this is what he believe in).
  5. You have never cloned the repo to other machine. There were only two copies of it: the developer's one and the server's one.