Skip to content

Instantly share code, notes, and snippets.

View zahqresh's full-sized avatar
🏠
Working from home

Muhammad Hamza Qureshi zahqresh

🏠
Working from home
View GitHub Profile
@zahqresh
zahqresh / yt-dlp_partial_download.py
Created December 12, 2023 15:55 — forked from space-pope/yt-dlp_partial_download.py
Using yt-dlp to download a portion of a video in Python
"""
It took me far longer than necessary to figure out how to use yt-dlp to trim/download a subset of a longer video
outside the context of a command line (i.e., directly in Python), so I'm recording it here for posterity.
There's no shortage of command-line examples of using `--ppa "ffmpeg_i:[...]`, but the documentation doesn't
exactly make it clear how to translate this to the Python version of the options, so here goes. A couple
additional quirks come into play too; we'll get to those soon enough.
"""
import yt_dlp
@zahqresh
zahqresh / Discord.js-v14-Events.md
Created January 20, 2023 06:27 — forked from Iliannnn/Discord.js-v14-Events.md
Discord.js v14 Events - Cheatsheet

Discord.js v14 Events

An overview of all events in Discord.js v14 with examples.

📢 | Last updated: 27 July 2022

ℹ️ | client references to your client instance.

ℹ️ | The v13 overview can be found here.

@zahqresh
zahqresh / 1ready.js
Created September 16, 2021 01:58 — forked from icourt/1ready.js
How to create a DiscordJS Invite Tracker
// Welcome to my gist! This is how you can create an invite tracker using JavaScript and Discord.JS!
// First we are going to statt off in our ready event.
// Create a new Collection called guildInvites and add it to your client
// client is the new Client you created in your main file. If you're using an event handler, make sure to pass the client into this file.
const { Collection } = require("discord.js");
// Collection is an enhanced Map which we are going to save our invites to.
const guildInvites = new Collection();
client.invites = guildInvites;
@zahqresh
zahqresh / css-units-best-practices.md
Created August 31, 2021 07:04 — forked from basham/css-units-best-practices.md
CSS Units Best Practices

CSS units

Recommendations of unit types per media type:

Media Recommended Occasional use Infrequent use Not recommended
Screen em, rem, % px ch, ex, vw, vh, vmin, vmax cm, mm, in, pt, pc
Print em, rem, % cm, mm, in, pt, pc ch, ex px, vw, vh, vmin, vmax

Relative units

Relative units

//Update one annotation
app.put('/api/annotations/:req_id', (req, res) => {
const {
qoute,
ranges,
text,
id
} = req.body;
const {
req_id
{
"total": 43127,
"rows": [
{
"id": "d41d8cd98f00b204e9800998ecf8427e",
"text": "Updated annotation text",
...
},
...
]
app.get('/api/search/:name', (req, res) => {
const {
name
} = req.params;
db.find({ file_name: name }).then(doc => {
let annotations = [];
doc.forEach(n => {
annotations.push(n.rows);
});
res.json({
//Create annotations
app.post('/api/annotations/:name', (req, res) => {
//create a random id object for annotations
let id = uuidv4();
const {
qoute,
ranges,
text
} = req.body;
const {
//Our custom function to add uri into annotations
var pageUri = function () {
return {
beforeAnnotationCreated: function (ann) {
ann.uri = window.location.href;
}
};
};
//Init Annotatorjs
var app = new annotator.App()
@zahqresh
zahqresh / directions.md
Last active June 26, 2021 05:23 — forked from omushpapa/directions.md
Deploy Django App on Heroku

Requirements

Run pip install pipenv to install pipenv

Run pipenv shell to create an environment, if does not exist, and activate it.

Run pipenv install python_decouple whitenoise dj_database_url Pillow gunicorn May take a while.

This should create two files: Pipfile and Pipfile.lock. Keep them in the project root.