Skip to content

Instantly share code, notes, and snippets.

View aviraldg's full-sized avatar

Aviral Dasgupta aviraldg

View GitHub Profile
@aviraldg
aviraldg / buttons.py
Created March 16, 2026 23:50
Label based configuration for button entity actions in Home Assistant.
import homeassistant.helpers.entity_registry as er
import homeassistant.helpers.label_registry as lr
@event_trigger("state_changed", "entity_id.startswith('event.')")
def matter_button_toggle_handler(entity_id=None, new_state=None, old_state=None, **kwargs):
# Safely extract the state value
new_s = new_state.state if hasattr(new_state, "state") else (new_state.get("state") if isinstance(new_state, dict) else None)
old_s = old_state.state if hasattr(old_state, "state") else (old_state.get("state") if isinstance(old_state, dict) else None)
# Ignore pure attribute updates
- repo: git://github.com/pre-commit/pre-commit-hooks
sha: v0.8.0
hooks:
- id: autopep8-wrapper
- id: check-added-large-files
- id: check-ast
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-docstring-first
- id: check-json

Keybase proof

I hereby claim:

  • I am aviraldg on github.
  • I am aviraldg (https://keybase.io/aviraldg) on keybase.
  • I have a public key whose fingerprint is 3875 FC93 96D5 216A 2768 0341 0E18 4AB0 523D 1E9B

To claim this, I am signing this object:

@aviraldg
aviraldg / scraper.py
Last active November 3, 2022 00:22 — forked from anpseftis/crawler.py
Web Scraper
#!/usr/bin/python
__author__ = 'Angelis Pseftis'
from bs4 import BeautifulSoup
import urllib
import urlparse
import argparse
from termcolor import colored
import subprocess
import whois
import fetch from 'isomorphic-fetch';
import receivePlaces from './receivePlaces'
import requestPlaces from './requestPlaces'
export default function() {
return dispatch => {
dispatch(requestPlaces());
fetch(`https://www.mozzobytes.com/api/places/`)
.then(response => response.json())
/* Combine all available reducers to a single root reducer.
*
* CAUTION: When using the generators, this file is modified in some places.
* This is done via AST traversal - Some of your formatting may be lost
* in the process - no functionality should be broken though.
* This modifications only run once when the generator is invoked - if
* you edit them, they are not updated again.
*/
import { combineReducers } from 'redux';
/* Populated by react-webpack-redux:reducer */
@aviraldg
aviraldg / post-commit
Created June 29, 2015 19:46
post-commit
#!/usr/bin/python
import subprocess, cv2, os
PATH = os.environ.get('GITPIC_PATH')
def main():
sha = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip()
repo_name = os.path.basename(subprocess.check_output(["git", "rev-parse", "--show-toplevel"])).strip()
try:
os.makedirs(os.path.join(PATH, repo_name))
#!/usr/bin/python
import subprocess, cv2, os
PATH = '/home/aviraldg/Pictures/gitpic/'
def main():
sha = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip()
repo_name = os.path.basename(subprocess.check_output(["git", "rev-parse", "--show-toplevel"])).strip()
try:
os.makedirs(os.path.join(PATH, repo_name))
@aviraldg
aviraldg / rescopy.py
Created March 3, 2015 08:02
Copy Android drawable resources.
#!/usr/bin/env python
import shutil, sys, os
def main():
srcname = sys.argv[1]
destname = os.path.abspath(sys.argv[2])
base = os.path.dirname(srcname)
srcname = os.path.basename(srcname)
def copy(arg, fname, fnames):
if os.path.basename(fname).startswith('drawable'):
import java.io.*;
import java.util.*;
/** Decomposes a number into sums */
public class Decompose {
public static final int MAX_NO = 20;
/**
* n - The number to sum up to.
* m - The number to start with (to sum up)