Skip to content

Instantly share code, notes, and snippets.

View aahnik's full-sized avatar
🏠
something's happening!

Aahnik Daw aahnik

🏠
something's happening!
View GitHub Profile
@pkuczynski
pkuczynski / parse_yaml.sh
Last active September 23, 2024 01:42
Read YAML file from Bash script
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
@rain1024
rain1024 / tut.md
Last active November 15, 2024 16:03
Install pdflatex ubuntu

PdfLatex is a tool that converts Latex sources into PDF. This is specifically very important for researchers, as they use it to publish their findings. It could be installed very easily using Linux terminal, though this seems an annoying task on Windows. Installation commands are given below.

  • Install the TexLive base
sudo apt-get install texlive-latex-base
  • Also install the recommended and extra fonts to avoid running into the error [1], when trying to use pdflatex on latex files with more fonts.
@bennylope
bennylope / ffmpeg-watermark.md
Created April 22, 2016 23:17 — forked from webkader/ffmpeg-watermark.md
FFmpeg add a watermark to video

How to Add a Watermark to Video

FFMPEG filters provide a powerful way to programmatically enhance or alter videos, and it’s fairly simple to add a watermark to a video using the overlay filter. The easiest way to install ffmpeg is to download a pre-built binary for your specific platform. Then you don’t have to worry about including and installing all the right dependencies and codecs you will be using.

Once you have ffmpeg installed, adding a watermark is as easy as passing your existing source through an overlay filter like so:

ffmpeg -i test.mp4 -i watermark.png -filter_complex "overlay=10:10" test1.mp4

Basically, we’re passing in the original video, and an overlay image as inputs, then passing it through the filter, and saving the output as test1.mp4.

@munim
munim / docker_start_stopped_container_in_interactive_mode.md
Last active October 20, 2023 06:51
Start a stopped docker container in bash/shell interactive mode

Start a stopped docker container in bash/shell interactive mode

For instance, you have just pulled a CentOS or Ubuntu image using docker pull centos:latest or docker pull ubuntu:latest.

Your immediate command would be

# docker run -it centos:latest
# docker ps -a
@noampc
noampc / server.js
Created December 29, 2017 18:27
Render entire EJS views directory with Express.js
import express from 'express';
import fs from 'fs';
const server = express();
server.set('view engine', 'ejs');
function filesToRender(dir){
function fileSubstring(file, dir){
return file.substring(0, file.length - 4).replace(dir,'')
@painor
painor / FastTelethon.py
Last active October 14, 2024 08:25
This will increase the download/upload speed when using telethon
# copied from https://github.com/tulir/mautrix-telegram/blob/master/mautrix_telegram/util/parallel_file_transfer.py
# Copyright (C) 2021 Tulir Asokan
import asyncio
import hashlib
import inspect
import logging
import math
import os
from collections import defaultdict
from typing import Optional, List, AsyncGenerator, Union, Awaitable, DefaultDict, Tuple, BinaryIO
@aahnik
aahnik / toGIF.md
Last active November 10, 2020 07:09
Ubuntu records 30s .webm screencasts in Videos Folder via Ctrl+Shift+Alt+R, automatically convert them to GIF in Pictures Folder, and delete video file

Make GIF ScreenCasts of 30s

Ubuntu records 30s .webm screencasts in Videos Folder via Ctrl+Shift+Alt+R, automatically convert them to GIF in Pictures Folder, and delete video file

Make sure to have ffmpeg installed

  • Save the toGIF.sh in your Videos folder, link
  • make it executable chmod +x ~/Videos/toGIF.sh
  • Go to Settings ---> Keyboard Shortcuts ---> New ShortCut
  • Set a new shortcut like this
@aahnik
aahnik / #tg_conv_bot.md
Last active August 6, 2023 18:31
A simple conversation bot that will ask user's name, and save it. Persistent, Polling, Shows Button, Has conversation flow, Conversation Handler, python-telegram-bot, ptb,

How to run

  1. Install dependancies.
pip3 install python-dotenv python-telegram-bot
  1. Then put the files of this gist inside a folder.
@aahnik
aahnik / get_chat_info.py
Last active January 8, 2021 15:47
Telegram Chat info. Telethon. Python.
import asyncio
from settings import API_ID, API_HASH
from telethon import TelegramClient
from utils import _
async def get_chat_id(ref=None):
async with TelegramClient('tg_session', API_ID, API_HASH) as client:
if not ref:
ref = input('Enter link/phone/username/id to get chat info: ')
@aahnik
aahnik / #channel joiner.md
Last active October 22, 2022 19:54
Telethon , telegram , join telegram channels from a list

Here is an example of .env file you need to use:

Screenshot from 2021-01-15 17-21-41

Make sure to have telethon and python-dotenv installed.