Skip to content

Instantly share code, notes, and snippets.

@jnerin
jnerin / get-ip.sh
Last active September 25, 2020 10:39
Get external IP from commandline by querying some DNS servers
# Faster with dig
dig -4 +short myip.opendns.com @resolver1.opendns.com # -4 needed to force ipv4 connectivity as resolver1.opendns.com doesn't return any result for this over ipv6
dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com | tr -d '"' # IPv4
dig -6 TXT +short o-o.myaddr.l.google.com @ns1.google.com | tr -d '"' # IPv6
# Slower with curl
curl -4 https://diagnostic.opendns.com/myip
curl -6 https://diagnostic.opendns.com/myip
curl -4 https://icanhazip.com
curl -6 https://icanhazip.com
@jnerin
jnerin / xorg-log-extract-modelines.pl
Last active November 25, 2022 15:16
Quick & dirty tool to generate fb.modes file from xorg detected valid modes. Just a way to avoid boring myself to death by manually generating modelines to convert them later to fb.modes with modeline2fb.
#!/usr/bin/perl
#
# Quick & dirty tool to generate fb.modes file from xorg detected valid modes.
# Just a way to avoid boring myself to death by manually generating modelines
# to convert them later to fb.modes with modeline2fb
#
# First we generate a X logfile with detailed info and later convert it.
#
# Usage:
# X :1 -logverbose 6
@jnerin
jnerin / generate-ovpn.sh
Last active June 22, 2016 18:48
.ovpn file generator
#!/bin/bash
#
# Copyright (c) 2014 Jorge Nerín <jnerin@gmail.com>
# Last updated on: Jun/26/2014 by Jorge Nerín
#
############################################################################
#
# .ovpn file generator (OpenVPN configuration files)
#
# It expects to find files with this names:
@jnerin
jnerin / oom_score_values.sh
Last active August 29, 2015 13:57
oneliners to explore the oom_score* values
#!/bin/bash
# Linked from: https://plus.google.com/+JorgeNer%C3%ADn/posts/3zdnEnXFN7Z
# Some oneliners to explore the oom_score* values:
# Processes with oom_score_adj != 0:
grep . /proc/*/oom_score_adj | grep -v ":0" | grep -v self | perl -ne 'm@/([0-9]+)/oom_score_adj:(-?[0-9]+)@; ($pid,$score)=($1,$2); open FILE,"<","/proc/$pid/cmdline"; $cmd=<FILE>; $cmd=~s/\0.*//; close FILE; print "$score\t$pid\t$cmd\n"; '
# In my system the results sumarized are:
# adj name
@jnerin
jnerin / clown_car-image_generator.sh
Created February 12, 2014 16:40
This is a helper script to generate a svg used to load images adapted to the pixel density of the screen using the clown car technique by Estelle Weyl at Clown Car Technique (https://github.com/estelle/clowncar), but using min-device-pixel-ratio and min-resolution instead of min/max-width
#!/bin/bash
RESOLUTIONS="1 1.25 1.3 1.5 2 3"
BASEDPI=96
INFILE="image.jpg"
OUTFILE="image.svg"
WIDTH_AT_1DPPX=88
IMAGE_TEMPLATE="$(basename $INFILE .jpg)_small"
cat > $OUTFILE <<EOF
@jnerin
jnerin / autoscan.sh
Last active August 29, 2015 13:56
Simple script to scan consecutive pages and OCR them waiting for Intro between pages
#!/bin/bash
#
# Script to automatically scan consecutive pages and OCR them
#
# Dependencies:
# scanimage from SANE
# convert from imagemagick
# tesseract for OCR
#
# But they are easy to replace