Skip to content

Instantly share code, notes, and snippets.

@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 / AiFitToArtboard.jsx
Created August 14, 2019 15:44
Adobe Illustrator script to resize objects proportionally to fit inside the artboard.
/*
Illustrator CS4+ script for resizing objects
proportionally so that they fit inside artboard
Based on: https://forums.adobe.com/message/4164590
Usage:
1. Create new document with desired artboard size
2. Paste object into document, select it and run this script
#target Illustrator
var requiredABsize = 1700; //px
var activeDoc = app.activeDocument;
var abActive = activeDoc.artboards[ activeDoc.artboards.getActiveArtboardIndex() ];
var abProps = getArtboardBounds(abActive);
var scale = findRequiredScale(abProps);
if (scale > 1)
@anurupr
anurupr / youtube-vimeo-url-parser.js
Created August 13, 2019 17:18 — forked from yangshun/youtube-vimeo-url-parser.js
YouTube Vimeo URL Parser
function parseVideo (url) {
// - Supported YouTube URL formats:
// - http://www.youtube.com/watch?v=My2FRPA3Gf8
// - http://youtu.be/My2FRPA3Gf8
// - https://youtube.googleapis.com/v/My2FRPA3Gf8
// - Supported Vimeo URL formats:
// - http://vimeo.com/25451551
// - http://player.vimeo.com/video/25451551
// - Also supports relative URLs:
// - //player.vimeo.com/video/25451551