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 / 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 / live-earth-wallpaper.sh
Last active September 17, 2024 21:06
Live Earth Wallpaper
#!/usr/bin/env bash
PATH=/home/fracz/.nvm/versions/node/v12.13.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
cd "$(dirname "$0")"
# npm install -g capture-website-cli
capture-website 'https://zoom.earth/#view=38,23.4,4z' --output wallpaper.png --hide-elements='.cookies, .panel, .locate, .help, .attribution, button, .settings' --overwrite --script='setTimeout(function() { document.getElementById("menu-terminator").click(); document.getElementById("menu-radar").click(); document.getElementById("menu-storm-tracks").click(); document.getElementById("menu-labels").click(); }, 1000)' --delay=2 --width=1920 --height=1000 && \
gsettings set org.gnome.desktop.background picture-uri file://$(pwd)/wallpaper.png
@fracz
fracz / Readme.md
Last active July 27, 2021 10:21
SUPLA Events by @fracz

SUPLA Events (unofficial)

This is a SUPLA Cloud extension that enables basic events support. Installation includes changing some sources of SUPLA Cloud instance (yes, you need to have your own SUPLA Cloud, it cannot use it on a shared official platform at supla.org).

Event specification consist of a condition (what should happen in order for the event to be perceived as occured) and a webhooks, that is, URLs to call in such cases. The condition is a Twig expression with a simple state function provided. state(XX) returns a state of a channel with ID XX. The returned value depends on the channel function. You will find the example states for specific functions helpful. Take a look at example config.yml for different possibilities.

Event specification might also contain a time_conditions, that is cron expression (or array of them) specifying when the event should be active. If the time conditio

@fracz
fracz / supla-rf-listen.py
Last active June 12, 2018 15:39
SUPLA RF Button
#!/usr/bin/env python3
import argparse
import signal
import sys
import time
import logging
import requests
import json
@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.
@fracz
fracz / app.html
Last active March 22, 2018 10:24 — forked from ScottWhittaker/app.html
Aurelia Router open in new tab bug - aurelia/router#457
<template>
<require from="components/navigation.html"></require>
<h1>Aurelia Router Demo</h1>
<navigation router.bind="router" class="primary-navigation"></navigation>
<div class="page-host">
<router-view></router-view>
</div>
</template>
@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 / index.html
Last active August 11, 2017 07:14 — forked from darwin/index.html
Welcome to comix!
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css">
<script src="http://cmx.io/v/0.1/cmx.js" charset="utf-8"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg)">
<scene id="scene1">
<label t="translate(0,346)">
@fracz
fracz / aw.xml
Last active March 24, 2017 08:20
Coffeescript Angular templates for IntelliJ IDEA
<template name="aw" value="@org.springframework.beans.factory.annotation.Autowired&#10;private $CLASS_NAME$ $FIELD_NAME$;" description="Adds @Autowired field" toReformat="true" toShortenFQNames="true">
<variable name="CLASS_NAME" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="FIELD_NAME" expression="" defaultValue="decapitalize(CLASS_NAME)" alwaysStopAt="true" />
<context>
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
@fracz
fracz / README.md
Created March 9, 2017 07:09
FFMPEG time lapse from photos
ffmpeg -r 15 -start_number 1 -i frame%04d.JPG -s 1280x720 -vcodec libx264 timelapse.mp4