Skip to content

Instantly share code, notes, and snippets.

View prati0100's full-sized avatar

Pratyush Yadav prati0100

  • Amazon AWS
  • Dresden
View GitHub Profile
#!/usr/bin/python3
import numpy as np
from numpy.lib.stride_tricks import as_strided
from PIL import Image
infilename = "/tmp/foo/xac"
inwidth = 3280
inheight = 2464
bitspp = 10
@prati0100
prati0100 / mk
Last active August 17, 2022 14:53
Script to store and run multiple build configurations.
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
#
# mk can be used to easily store and run multiple build profiles. For example, I
# work on U-Boot at $DAYJOB and I need to run builds for 3-4 different
# platforms. Each platform first needs a defconfig and then a build. And the
# build command is slightly different for each. So I wrote this small utility to
# store a set of build commands and the currently active set.
#
# The commands are stored in the "config" format. For example, create a .mkconf
@prati0100
prati0100 / mark_backport.sh
Last active March 17, 2021 12:56
Add "commit <hash> upstream" to the commit message by looking at the upstream branch for matching commits
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
# Example usage: mark_backport.sh upstream/master
#
# If the upstream branch has too many commits this can be very slow. In this
# case, pass other arguments to limit the git log to contain all your commits.
# For example, you are use '--author' or pathspecs. Example with pathspecs:
# mark_backport.sh upstream/master -- drivers/spi
#!/usr/bin/env tclsh
if {$argc > 2} {
puts "More arguments than expected"
exit 1
}
set dirname [lindex $argv 0]
# Create the target directory if it doesn't already exist.
#!/bin/bash
function find_globals () {
cut_content="$1"
# Find all the global declarations
globals=$(echo "$cut_content" | grep '^[[:space:]]global ' | sed 's/\s*global //')
if test -z "$globals"; then
return
Git stuff I want to do some time in the future:
[Git gui]
- Edit tools.
- Context menu on file list.
- Fix revert hunk and revert lines not working on added files (files that have
the flag A, not M).
- Add selective staging for added files.
- Add a newline in the commit editor on 80 cols.
- Configurable key bindings?
@prati0100
prati0100 / save_emails.sh
Last active November 9, 2019 04:53
A script to use with neomutt to save a list of tagged emails.
#!/bin/bash
# This script is used to save a list of emails from neomutt's pipe. Be sure to
# set pipe_split in neomutt.
#
# Pass the directory name as the first argument. The email content is expected
# to be in stdin.
#
# The second argument is optional. It can be used to force the patch version to
# be something else. For example, pass v3 as the second argument. Even if the
#!/bin/bash
RED=$(tput setaf 1)
NORMAL=$(tput sgr0)
# FIXME: I am using porcelain commands to do plumbing work. Maybe fix it in the
# future.
AUTHOR=$(git --no-pager show -s --format='%aN <%aE>')
COMMIT_MSG=$(git --no-pager show -s --format='%B')
COMMIT_ID=$(git --no-pager show -s --format='%h')
#!/usr/bin/sh
. git-sh-setup
# Add a Signed-off-by by me when applying patches. Only do this for projects
# you are the maintainer of, and need to add your signoff before pushing out.
SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
@prati0100
prati0100 / locknosleep.sh
Created June 24, 2019 11:01
Do not turn off the display when locking the screen on GNOME
#!/bin/bash
xdg-screensaver lock
sleep 0.7
xdotool key Ctrl