Skip to content

Instantly share code, notes, and snippets.

View ShadowBelmolve's full-sized avatar

Renan Tomal Fernandes ShadowBelmolve

View GitHub Profile
@ShadowBelmolve
ShadowBelmolve / battery_alert.yaml
Created April 27, 2025 02:53
Basic battery level alert blueprint for Home Assistant
blueprint:
name: Low/High Battery Notification (v0.1)
description: |
A basic blueprint to alert when a battery needs to be charged or stopped from charging.
It can send the notification and remove it when outside of the alert zones.
Use the extra/pre-condition actions to add/change some variables and change when the actions are called. e.g.:
```yaml
variables:
@ShadowBelmolve
ShadowBelmolve / README.md
Created April 22, 2025 00:56 — forked from lukasnellen/README.md
Connect host and VM when using MACVTAP instead of TAP interfaces

Connect host and VM when using a MACVTAP interface

NB: The following is only of interest if you want to share the host network with your virtual machine. The most common way this gets implemented is by setting up a bridge which includes the physical interface. Using a [MACVTAP] inerface is suposed to be more efficient, since it avoids the additional bridge in the network setup.

In this gist, we extend the information provided in the documenation on linux virtual interfaces.

In the following, we assume you host interface is eth0. IP addresses used:

  • host: 198.51.100.50/24
  • virtual machine: 198.51.100.198/24
  • default gateway: 198.51.100.254
@ShadowBelmolve
ShadowBelmolve / Main.hx
Last active January 2, 2016 10:19 — forked from anonymous/Main.hx
haxe-traits break with this. Seems that if you import an "interface A"(IEntity) that has a variable of type "class B"(EntityData) that has a function with return type "class C"(Entity) and "class C" implements the "interface A", then variables from "interface A" simply aren't copied to "class C" or something like this. The same if you import "Cl…
package;
//works
//import world.Entity;
//works
//import world.IEntity;
//import world.Entity;
//not work
@ShadowBelmolve
ShadowBelmolve / example.rb
Created November 4, 2012 17:55
A prototype of my next gem.
#app/filters/user.rb
FilterIt.create('user') do
requires :name, :class => String # stop the filter if no name is found on 'data'
if current_user.admin? # search in each context for one that respond to the method 'current_user' without an error
# optional will not raise an error if isn't found, if any validation fail it will be simply ignored.
optional :authorizantion_level, :class => Integer,:in => 0..10
end
if current_user.manager?
optional :org_ids, :class => Array do
unless (is_creating_user rescue false)
@ShadowBelmolve
ShadowBelmolve / main.rb
Created October 12, 2012 02:30
Inspect source of files
SCRIPT_LINES__ = {}
require './test'
puts SCRIPT_LINES__.keys
# [".../test.rb"]
puts SCRIPT_LINES__.first[1].join
# def foo
# puts "bar"
@ShadowBelmolve
ShadowBelmolve / auto-hash.rb
Created October 11, 2012 16:47
Autovivification hash
deep = Hash.new { |hash, key| hash[key] = Hash.new(&hash.default_proc) }
# {}
deep[:foo][:bar][:lol?][:win!] = 10
# 10
deep
# {:foo=>{:bar=>{:lol?=>{:win!=>10}}}}
Today I've updated my gems and got this error with ActiveRecord::Base#to_json
>> User.all.to_json
=> "[\"#<User:0x6a9eb00>\",\"#<User:0x6a9ea60>\",\"#<User:0x6a9e9c0>\",\"#<User:0x6a9e920>\"]" #this isn't what I want
I think the problems is json_pure :/ but I can't remove it from project(some gems depend on it)
>> User.all.to_json
=> "[\"#<User:0x6a9eb00>\",\"#<User:0x6a9ea60>\",\"#<User:0x6a9e9c0>\",\"#<User:0x6a9e920>\"]"
Account 5 | Sem data
Act 2078164 | 2010-08-26 18:26:37 UTC
Address 169 | Sem data
Area 12 | 2009-06-02 11:52:57 UTC
Article 0 | Sem data
Avl 354 | 2008-08-27 20:10:47 UTC
AvlMacro 0 | Sem data
AvlProfile 0 | Sem data
BackupHost 0 | Sem data
Booth 29 | 2008-12-19 16:26:31 UTC
@import <Foundation/CPObject.j>
@import "PageView.j"
@import "PhotoInspector.j"
@implementation AppController : CPObject
{
}