Skip to content

Instantly share code, notes, and snippets.

@MagicMicky
MagicMicky / update_notification.yaml
Last active Dec 15, 2021 — forked from Klumper/update_notification.yaml
Home Assistant update notification blueprint
View update_notification.yaml
blueprint:
name: Home Assistant update notification
description: Send a notification when there's an update availiable for Home Assistant
domain: automation
input:
updater:
name: Update sensor
description: The sensor which indicates if there's an update
selector:
entity:
View gist:b0cb97c5799e6d8db52db9cda7c432be
/// twitch-videoad.js
const origFetch = window.fetch;
window.fetch = (url, init, ...args) => {
if (typeof url === "string") {
if (url.includes("/access_token")) {
url = url.replace("player_type=site", "player_type=site");
} else if (
url.includes("/gql") &&
init &&
typeof init.body === "string" &&
@MagicMicky
MagicMicky / audio_detector.sh
Created Sep 23, 2015
Audio detection turn on hdmi
View audio_detector.sh
#!/bin/bash
SWITCH_ON_CMD="echo 'on 0' > /tmp/cec.fifo"
CHANGE_HDMI="echo 'as' > /tmp/cec.fifo"
if [ -e "/tmp/cec.fifo" ]; then
echo proceeding: file exists
else
echo You need to start the server.
exit
fi
@MagicMicky
MagicMicky / Adapters.java
Created Oct 12, 2014
An example showing the Adapter Design pattern, adapted to some account authentication
View Adapters.java
/*
* We want to auth our user on an application.
* We have two way to auth our user.
* We can either authenticate the user using his mail and password via Google, thanks to the Google SDK
* Or we can use the Facebook SDK to auth our user.
*/
public GoogleAuthenticator() {
public String authenticateViaGoogle(String mail, String password) {
//Android code
@MagicMicky
MagicMicky / BundleTestActivity.java
Last active Aug 29, 2015
A gist that allows to check whether or not objects given through a Bundle are of the same instance. Used for an example on http://magicmicky.github.io/android_development/loose_coupling_using_otto/
View BundleTestActivity.java
package com.magicmicky.loosecoopling;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
@MagicMicky
MagicMicky / InflationPerformanceTestActivity.java
Last active Jun 16, 2021
Simple Android program to test performance gain when inflating temporary view programmatically or setting it to GONE and modify to VISIBLE when needed. Used for a blog article http://magicmicky.github.io/android_development/benchmark-using-traceview/
View InflationPerformanceTestActivity.java
package com.magicmicky.testperfviews;
import android.app.Activity;
import android.graphics.LinearGradient;
import android.os.Debug;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;