Skip to content

Instantly share code, notes, and snippets.

View albertzak's full-sized avatar

Albert Zak albertzak

View GitHub Profile
@albertzak
albertzak / switches_off_at_sunrise.yaml
Last active December 12, 2021 12:06 — forked from Knuspel/switches_on_at_sunset.yaml
Home Assistant Blueprint for Turning Switches Off At Sunrise
blueprint:
name: Switch Off At Sunrise
description: Turn off the following switches at sunset
domain: automation
input:
# Create a variable for identifying the light to act upon
target_switch:
name: Switches
description: This is the switch (or switches) that will be turned off at sunset
# Use a selector, to pick the light(s)
(defn on-konami-code []
(prn :konami-code-detected))
(defn setup-konami-code-listener! []
(let
[key
{37 :left
38 :up
39 :right
40 :down
@albertzak
albertzak / keybase.md
Created September 6, 2018 11:00
Keybase Verification

Keybase proof

I hereby claim:

  • I am albertzak on github.
  • I am albertzak (https://keybase.io/albertzak) on keybase.
  • I have a public key ASAnBNnvobaG3vg5KZ7mebwPLzcNhd2N4aDD8eVpNAP5nwo

To claim this, I am signing this object:

@albertzak
albertzak / is_container.sh
Created November 29, 2017 22:58
Running Inside Container?
#!/bin/bash
is_container () {
cgroup_output=$(cat /proc/self/cgroup 2>&1)
echo "$cgroup_output" | grep -E '/docker/|/lxc/' > /dev/null
return $?
}
if is_container; then
echo "I'm trapped inside a container."
@albertzak
albertzak / flights.pl
Last active November 9, 2017 21:38
Flight Search
:- initialization(main).
main :-
routes(vie, nrt, R),
write(R), halt.
% data
flight(vie, nrt, 1000).
flight(vie, fra, 40).
flight(vie, cdg, 50).
package gq.icctv.webviewdemo;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
@albertzak
albertzak / stackfile.yml
Created December 22, 2016 18:52
Docker + nginx + Let's Encrypt = 😍
letsencrypt:
environment:
- LETSENCRYPT_EMAIL=email@example.com
image: 'jrcs/letsencrypt-nginx-proxy-companion:v1.3'
volumes:
- '/root/certs:/etc/nginx/certs'
- '/var/run/docker.sock:/var/run/docker.sock:ro'
volumes_from:
- nginx
@albertzak
albertzak / morse.c
Last active June 28, 2016 16:59
blink morse code
#include "stdlib.h"
#include "stm32f4xx.h"
// This morse code implementation uses the standard as defined
// by the International Telecommunication Union (ITU) in 1865
// T is short for "Time Unit"
int T = (100 * 100000);
@albertzak
albertzak / bellmanford.c
Created June 13, 2016 12:42
Bellman Ford Algorithm
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_NODES 8
#define INFINITE 0xffff
// structure for a node
typedef struct _node {
int node;
@albertzak
albertzak / main.c
Created June 2, 2016 19:43
semaphore
/*****************************
* Fernlehre Semaphore Example
* File: main.c
* Author: Granzer Wolfgang
* Version: 1.0
* Date: 30.4.2012
**/
#include <stdio.h>
#include <stdlib.h>