Skip to content

Instantly share code, notes, and snippets.

@Bibo-Joshi
Bibo-Joshi / lirc-pi3.txt
Created January 30, 2018 10:49 — forked from prasanthj/lirc-pi3.txt
Getting lirc to work with Raspberry Pi 3 (Raspbian Stretch)
Notes to make IR shield (made by LinkSprite) work in Raspberry Pi 3 (bought from Amazon [1]).
The vendor has some documentation [2] but that is not complete and sufficient for Raspbian Stretch.
Following are the changes that I made to make it work.
$ sudo apt-get update
$ sudo apt-get install lirc
# Add the following lines to /etc/modules file
lirc_dev
lirc_rpi gpio_in_pin=18 gpio_out_pin=17
@Bibo-Joshi
Bibo-Joshi / create_ptb_test_bot.py
Last active November 6, 2022 20:55 — forked from jsmnbom/create_ptb_test_bot.py
Put in python-telegram-bot/tests with API_ID and API_HASH (from my.telegram.org) as envvars. Customize the bot to be created in main(). Doesn't create video sticker set yet. Tested with `python-telegram-bot==20.0a4` and `telethon==1.25.4`. ⚠️ The script needs to be updated to make the bot also an admin in the forum test group (chat id -100161915…
import asyncio
import itertools
import json
import os
import re
import urllib.parse
import itertools
from telethon import TelegramClient
from telethon.utils import get_input_peer
@Bibo-Joshi
Bibo-Joshi / convert_pp.py
Last active January 1, 2021 14:59
Prepare PTB pickle files for v13.0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This script prepares the file(s) saved by PicklePersistence for v13.0. How you do it:
1. Edit the PicklePersistence according to your settings below.
2. Run this script *before* upgrading to v13
3. Upgrade to v13 and run your bot to make sure everything is working
@Bibo-Joshi
Bibo-Joshi / cloudsend.sh
Created December 27, 2020 17:26 — forked from tavinus/cloudsend.sh
Send files to Nextcloud/Owncloud shared folder using curl
#!/usr/bin/env bash
############################################################
# MIGRATED TO REPOSITORY
# https://github.com/tavinus/cloudsend.sh
#
# This gist will NOT be updated anymore
############################################################
############################################################
@Bibo-Joshi
Bibo-Joshi / convert_pp_13.1
Last active January 1, 2021 15:15
Prepare PTB pickle files for v13.1
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This script prepares the file(s) saved by PicklePersistence for v13.1. How you do it:
1. Edit the PicklePersistence according to your settings below.
2. Run this script *before* upgrading from 12.x to v13.1
3. Upgrade to v13.1 and run your bot to make sure everything is working
import itertools
from collections import namedtuple
from typing import List
Arg = namedtuple('Arg', ['name', 'type_var', 'default'])
args = [
Arg('context', 'CCT', 'CallbackContext'),
# Order matters!
Arg('user_data', 'UD', 'Dict'),
@Bibo-Joshi
Bibo-Joshi / inline_results.py
Created May 18, 2021 19:04
A small study on the more exotic parameters of inline results for Telegram Bots.
"""
Tested with pyhon-telegram-bot>=13.5 (>=13.0 should also do the trick …)
A small study on the more exotic parameters of inline results for Telegram Bots.
Punchline: The effect heavily depends on the client and is not always straight forward.
E.g. when passing a `url` to the `input_message_content` of a `InlineQueryResultArticle`, but set
`hide_url=True`, the `url` just has no effect at all (on official Android and Windows clients)
"""
@Bibo-Joshi
Bibo-Joshi / is_coroutine_function.py
Created January 12, 2022 20:11
Wrapper around `asyncio.iscoroutinefunction` that handles `functools.partial` on Python<=3.7 and also async `__call__` methods
import asyncio
import sys
from functools import partial
if sys.version_info >= (3, 8):
_MANUAL_UNWRAP = False
else:
_MANUAL_UNWRAP = True
def is_coroutine_function(obj: object) -> bool:
@Bibo-Joshi
Bibo-Joshi / trackingdefaultdict.py
Last active February 13, 2022 19:48
A defaultdict that keeps track of the accessed keys.
"""This module contains subclasses of :class:`collections.abc.MutableMapping` that keeps track of the
keys that where accessed.
Warning:
Tested only manually.
"""
from typing import (
TypeVar,
DefaultDict,
Callable,