Skip to content

Instantly share code, notes, and snippets.

View luixal's full-sized avatar

Luis Alberto Pérez García luixal

View GitHub Profile
@luixal
luixal / Mushroom_countdown_input_hours_scheduling.md
Last active April 19, 2024 10:23
Mushroom Countdown with Input Hours and Scheduling

Mushroom Countdown with Input Hours and Scheduling

This card shows an hours input card while charger is off and a countdown when charger is running for the hours selected.

Also, it shows a popup for scheduling running hours at certain time by long tap in the card.

Screenshots

image

@luixal
luixal / Mushroom_Input_Countdown.md
Last active September 20, 2024 18:15
Home Assistant cards configuration

Mushroom Countdown with Input Hours

This card shows an hours input card while charger is off and a countdown when charger is running for the hours selected.

There's another version that adds a simple scheduling feature in top of this here.

Screeenshots

image

image

@luixal
luixal / brightness.sh
Last active January 31, 2022 23:03
Gnome Brightness Control Hack for fn keys
#!/bin/bash
# brightness: Change all monitors brightness in software.
# by hackerb9, 2019
# Examples: brightness 75; brightness -5; brightness +10
# Usage:
# brightess [n] [+n] [-n]
# n An integer from 0 to 100 specifies a brightness level.
# +n Increase brightness by n.
# -n Decrease brightness by n.
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh3/main/themes/schema.json",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "os",
"style": "diamond",
// Needed in AndroidManifest:
<!-- Permission for using NFC hardware -->
<uses-permission android:name="android.permission.NFC"/>
<!-- Forcing device to have NFC hardware -->
<uses-feature android:name="android.hardware.nfc" android:required="true"/>
<!-- Registering app for receiving NFC's TAG_DISCOVERED intent -->
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
@luixal
luixal / GetRealLastKnowLocation.java
Created May 6, 2013 02:55
Get last known location from all providers without using any criteria but time.
public Location getLastKnownLocation() {
// variable for keeping most up to date location:
Location lastLocation = null;
// getting location manager:
LocationManager locationManager = (LocationManager)this.getSystemService(LOCATION_SERVICE);
// getting list of providers:
List<String> providers = locationManager.getAllProviders();
// getting most up to date location from any enabled provider:
if (providers != null && !providers.isEmpty()) {
for (String provider:providers) {
@luixal
luixal / CheckDataConnection.java
Last active December 16, 2015 17:09
Checking for data connection
// Permission needed in Manifest:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
// Code:
public boolean isDataConnectionAvailable() {
ConnectivityManager connManager = (ConnectivityManager)this.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = connManager.getActiveNetworkInfo();
return (netInfo != null && netInfo.isConnected());
}
@luixal
luixal / RestClient.java
Created February 13, 2011 04:10
Calling WebServices through HttpClient: A RestClient class for calling webservice using both, get and post methods, and getting the response dropped into an String.
public class RestClient {
private ArrayList<NameValuePair> params;
private ArrayList<NameValuePair> headers;
private String url;
private int responseCode;
private String message;