Skip to content

Instantly share code, notes, and snippets.

View Kahtaf's full-sized avatar

Kahtaf Alam Kahtaf

View GitHub Profile
@Kahtaf
Kahtaf / KeyboardEntry.cs
Last active January 26, 2017 18:11
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.
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));
@Kahtaf
Kahtaf / Settings.java
Created August 3, 2017 03:21
Android Preferences - Reusable widget layout for a preference and it's onClick listener
// 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 / bitwarden-env.yml
Created June 5, 2022 14:23
Github Actions - Download secret note from BitWarden - Great for storing .env files
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 / gist:814c53231309ac1ea403d82969360b41
Created July 29, 2022 03:00
Uninstall Home Assistant
# 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 / index.js
Created September 15, 2020 14:37
Create a simple CORS proxy with Cloudflare Workers to bypass CORS restrictions in the browser. Perfect for local development.
/**
* 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))
)