Skip to content

Instantly share code, notes, and snippets.

Avatar

Kahtaf Alam Kahtaf

View GitHub Profile
View gist:814c53231309ac1ea403d82969360b41
# Stop Home Assistant services
sudo systemctl stop hassio-supervisor.service && \
sudo systemctl stop hassio-apparmor.service && \
sudo systemctl disable hassio-supervisor.service && \
sudo systemctl disable hassio-apparmor.service && \
sudo rm -rf /etc/systemd/system/hassio-supervisor.service && \
sudo rm -rf /etc/systemd/system/hassio-apparmor.service
# Remove Home Assistant directories
sudo rm -rf /usr/sbin/hassio-supervisor && \
@Kahtaf
Kahtaf / bitwarden-env.yml
Created Jun 5, 2022
Github Actions - Download secret note from BitWarden - Great for storing .env files
View bitwarden-env.yml
jobs:
...
steps:
...
- name: Download .env from BitWarden
env:
# Client ID and Secret can be found in https://vault.bitwarden.com/#/settings/security/security-keys
BW_CLIENTID: ${{ secrets.BITWARDEN_CLIENTID }}
BW_CLIENTSECRET: ${{ secrets.BITWARDEN_CLIENTSECRET }}
# BitWarden master password required for unlocking vault
@Kahtaf
Kahtaf / index.js
Created Sep 15, 2020
Create a simple CORS proxy with Cloudflare Workers to bypass CORS restrictions in the browser. Perfect for local development.
View index.js
/**
* Create a simple CORS proxy with Cloudflare Workers
* to bypass cors restrictions in the browser.
* Example Usage: https://<worker_subdomain>.workers.dev/https://postman-echo.com/get?foo1=bar1&foo2=bar2
*/
addEventListener('fetch', event =>
event.respondWith(handleRequest(event.request))
)
@Kahtaf
Kahtaf / Settings.java
Created Aug 3, 2017
Android Preferences - Reusable widget layout for a preference and it's onClick listener
View Settings.java
// Parent activity of the preference screen
// onClick listener for reusable preference widget.
public void onPreferenceSecondaryButtonClicked(View view){
// Gets a reference to the preference that contains this widget
ListView preferenceList = (ListView) view.getParent().getParent().getParent();
int preferencePosition = preferenceList.getPositionForView(view);
Preference preference = (Preference) preferenceList.getAdapter().getItem(preferencePosition);
// Add onclick logic here, using reference to the preference object that contains this widget
@Kahtaf
Kahtaf / KeyboardEntry.cs
Last active Jan 26, 2017
Xamarin.Forms custom renderer for an Entry that forcibly shows/hides the keyboard on demand. Useful when Entry.Focus() and Entry.Unfocus() does not work as intended.
View KeyboardEntry.cs
using Xamarin.Forms;
namespace Project.Controls
{
public class KeyboardEntry : Entry
{
#region ShowKeyboardProperty
public static readonly BindableProperty ShowKeyboardProperty = BindableProperty.Create<KeyboardEntry, bool>(p => p.ShowKeyboard, default(bool));