Skip to content

Instantly share code, notes, and snippets.

@anurupr
anurupr / pacman.sh
Created March 5, 2024 12:53
pacman sync command
pacman -Sy && pacman-key --init && pacman-key --populate archlinux && pacman -S --noconfirm archlinux-keyring && pacman -S --noconfirm openssh
@anurupr
anurupr / c_flac_mp3.sh
Created September 4, 2022 22:18
Convert flac to mp3 in a directory ( regardless of depth ) and puts it in a folder called mp3
#!/bin/bash
mkdir mp3 # comment out if it already exists where you are running this script
find . -type f -name "*.flac" -exec sh -c 'for f do ff=$(basename -- "$f" .flac); ffmpeg -i "$f" -ab 320k -map_metadata 0 -id3v2_version 3 "mp3/$ff.mp3"; done' sh {} +
@anurupr
anurupr / benchmark_cygwin_mirrors.bat
Created November 2, 2021 23:13 — forked from kou1okada/benchmark_cygwin_mirrors.bat
Benchmark cygwin mirrors.
@ECHO OFF
ECHO Benchmark cygwin mirrors.
powershell -Command ^
"^
$len = 0;^
$min = 1e9;^
$best = """nothing""";^
Import-Module BitsTransfer;^
Start-BitsTransfer https://cygwin.com/mirrors.lst;^
foreach($mirror in Get-Content mirrors.lst) {^
@anurupr
anurupr / parseColor.js
Created January 17, 2021 20:07 — forked from THEtheChad/parseColor.js
Super compact javascript color parsing function
/**!
* @preserve $.parseColor
* Copyright 2011 THEtheChad Elliott
* Released under the MIT and GPL licenses.
*/
// Parse hex/rgb{a} color syntax.
// @input string
// @returns array [r,g,b{,o}]
@anurupr
anurupr / hextobin.c
Created December 23, 2020 05:24 — forked from vi/hextobin.c
Hex string to byte buffer in C
// Based on https://stackoverflow.com/a/23898449/266720
void tallymarker_hextobin(const char * str, uint8_t * bytes, size_t blen)
{
uint8_t pos;
uint8_t idx0;
uint8_t idx1;
// mapping of ASCII characters to hex values
const uint8_t hashmap[] =
{
@anurupr
anurupr / ARMonQEMUforDebianUbuntu.md
Created December 23, 2020 05:17 — forked from luk6xff/ARMonQEMUforDebianUbuntu.md
Emulating ARM with QEMU on Debian/Ubuntu

You might want to read this to get an introduction to armel vs armhf.

If the below is too much, you can try Ubuntu-ARMv7-Qemu but note it contains non-free blobs.

Running ARM programs under linux (without starting QEMU VM!)

First, cross-compile user programs with GCC-ARM toolchain. Then install qemu-arm-static so that you can run ARM executables directly on linux

If there's no qemu-arm-static in the package list, install qemu-user-static instead

@anurupr
anurupr / usb-android-emulator-ubuntu.md
Created December 23, 2020 05:17 — forked from Alabate/usb-android-emulator-ubuntu.md
Use custom USB device with Android emulator by using custom built kernel on Ubuntu 18.04

Use custom USB device with Android emulator by using custom built kernel on Ubuntu 18.04

The android emulator doesn't support all usb devices because they are disabled in the kernel. So we need to build it with another configuration. My goal was to build the same version as it was before, but with just configuration modifications.

Find current android version

Start the emulator without modifications, go into

Configuration > System > About emulated device > Android version

@anurupr
anurupr / cellrecognition.py
Created December 20, 2020 08:16 — forked from huks0/cellrecognition.py
A table detection, cell recognition and text extraction algorithm to convert tables in images to excel files, using pytesseract and open cv.
import cv2
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import csv
try:
from PIL import Image
except ImportError:
import Image
@anurupr
anurupr / generate-ssh-key.sh
Created November 20, 2020 05:59 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa
@anurupr
anurupr / qpdf-split-pages.sh
Last active July 3, 2020 01:27
Script to split pdf using qpdf
#!/bin/bash
PDF_PATH="$1"
if [ -z "$PDF_PATH" ]; then
echo "ERROR: Missing pdf path. Call script with path to pdf file"
exit 1
fi
# get number of pages using npdf
NPAGES=$(qpdf --show-npages $PDF_PATH)
DIR=$(dirname "${PDF_PATH}")
# store split pages in a folder