Skip to content

Instantly share code, notes, and snippets.

# tested on 2020-01-04 on latest rasbian (buster) and nano 4.7
sudo apt-get install pkg-config libncursesw5-dev groff
URL="https://www.nano-editor.org$(curl https://www.nano-editor.org/download.php 2>/dev/null | grep -o '<a .*href=.*>' | sed -e 's/<a /\n<a /g' | sed -e 's/<a .*href=['"'"'"]//' -e 's/["'"'"'].*$//' -e '/^$/ d' | egrep '\.tar\.gz$')"
wget "$URL"
tar zxvf nano-*.tar.gz
cd nano-*[0-9]
sudo mkdir -p /usr/local/share/doc
>>> " ".join("%02x"%b for b in bytearray(u'abc•£¶','utf-8'))
'61 62 63 e2 80 a2 c2 a3 c2 b6'
print((lambda s:repr(str(s)).replace(' ',u'·'))('joe fred\n')[1:-1])
@mscalora
mscalora / getch.py
Created June 20, 2016 11:40
Gets a single character from standard input. Does not echo to the screen
class _Getch:
"""Gets a single character from standard input. Does not echo to the screen."""
def __init__(self):
try:
self.impl = _GetchWindows()
except ImportError:
self.impl = _GetchUnix()
def __call__(self): return self.impl()
python -c "import subprocess ; print subprocess.check_output(['stty', 'size']).split()"
see: http://stackoverflow.com/questions/566746/how-to-get-console-window-width-in-python
$ sudo apt-get upgrade libncurses5 libncursesw5 git curl wget automake autopoint
Reading package lists... Done
Building dependency tree
Reading state information... Done
automake is already the newest version (1:1.15-4ubuntu1).
autopoint is already the newest version (0.19.7-2ubuntu3).
curl is already the newest version (7.47.0-1ubuntu2).
git is already the newest version (1:2.7.4-0ubuntu1).
libncurses5 is already the newest version (6.0+20160213-1ubuntu1).
libncursesw5 is already the newest version (6.0+20160213-1ubuntu1).
@mscalora
mscalora / Add_undo_stack_debug_logging-remove.patch
Created May 15, 2016 13:13
Remove extra nano undo debug logging
Index: src/winio.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/winio.c (revision )
+++ src/winio.c (date 1462931713000)
@@ -3076,12 +3076,6 @@
(long)openfile->filebot->lineno, linepct,
(unsigned long)cur_xpt, (unsigned long)cur_lenpt, colpct,
@mscalora
mscalora / Add_undo_stack_debug_logging.patch
Created May 15, 2016 13:13
Add extra nano undo debug logging
Index: src/winio.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/winio.c (date 1462931713000)
+++ src/winio.c (revision )
@@ -3076,6 +3076,12 @@
(long)openfile->filebot->lineno, linepct,
(unsigned long)cur_xpt, (unsigned long)cur_lenpt, colpct,
@mscalora
mscalora / letsencrypt-update-lighttpd
Last active January 18, 2024 00:28
script to auto update letsencrypt certs for debian lighttpd installation (based on script by Danny Tuppeny)
#!/usr/bin/env bash
#
# Update letsencrypt on a lighttp installation
#
# if you installed letsencrypt in a non-standard location you
# can set the LEDIR env var before you run this script
#
# setup letsencrypt install directory
STDLEDIR=/opt/letsencrypt
#!/usr/bin/env bash
# script for testing nano build configurations
grep 'GNU nano - an enhanced clone of the Pico text editor' README >/dev/null 2>&1
if [ $? -ne 0 ] ; then
printf "\n\e[31mError: Must be run from the nano dev folder! \e[39m\n"
exit 1
fi