Skip to content

Instantly share code, notes, and snippets.

@helix84
helix84 / python-zip.md
Last active Apr 5, 2020 — forked from asimjalis/python-zip.md
How to deploy a Python application as a zip file
View python-zip.md

How to deploy a Python application as a zip file

by Asim Jalis, MetaProse.com

Create a file __main__.py containing:

print "Hello world from Python"

Zip up the Python files (in this case just this one file) into app.zip by typing:

@helix84
helix84 / .screenrc
Created Mar 31, 2020 — forked from joaopizani/.screenrc
A killer GNU Screen Config
View .screenrc
# the following two lines give a two-line status, with the current window highlighted
hardstatus alwayslastline
hardstatus string '%{= kG}[%{G}%H%? %1`%?%{g}][%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}][%{B}%m/%d %{W}%C%A%{g}]'
# huge scrollback buffer
defscrollback 5000
# no welcome message
startup_message off
@helix84
helix84 / diff-configs.sh
Created Feb 12, 2020 — forked from matthewd/diff-configs.sh
Diff /etc files against the versions supplied in Debian packages
View diff-configs.sh
#!/bin/bash
# This script will make a best-effort attempt at showing modifications
# to package-provided config files on a Debian system.
#
# It's subject to some pretty significant limitations: most notably,
# there's no way to identify all such config files. We approximate the
# answer by looking first at dpkg-managed conffiles, and then hoping
# that most of the time, if maintainer scripts are managing files
# themselves, they're using ucf. So, DO NOT TRUST THIS SCRIPT to find
@helix84
helix84 / Highlight non-matching anchor links (Bookmarklet)
Created Jan 2, 2020 — forked from jkphl/Highlight non-matching anchor links (Bookmarklet)
Use this JavaScript bookmarklet to find invalid anchor references within your HTML documents. The script searches the current document for links referring to named anchors on the same page that don't really exist and highlights them with a red background.
View Highlight non-matching anchor links (Bookmarklet)
@helix84
helix84 / dummy_assetstore.sh
Created Nov 14, 2019
DSpace: create a mock assetstore with empty files with names from the database
View dummy_assetstore.sh
#!/bin/sh
DBNAME=dspace5
psql $DBNAME -A -t -c "SELECT internal_id FROM bitstream" > /tmp/ids.txt
for id in `cat /tmp/ids.txt`; do
dir=`echo $id | cut -c1-2`/`echo $id | cut -c3-4`/`echo $id | cut -c5-6`
echo $dir/$id
mkdir -p assetstore/$dir
touch assetstore/$dir/$id
@helix84
helix84 / LdapAuth.java
Created Oct 8, 2019 — forked from jbarber/LdapAuth.java
LDAP example for searching and simple binding (authentication)
View LdapAuth.java
/*
* First create the keystore (to allow SSL protection) by importing the LDAP
* certificate (cert.pem) with:
* keytool -import -keystore keystore -storepass changeit -noprompt -file cert.pem
*
* You can get the certificate with OpenSSL:
* openssl s_client -connect ldap.server.com:636 </dev/null 2>/dev/null | sed -n '/^-----BEGIN/,/^-----END/ { p }' > cert.pem
*
* Then compile this class with:
* javac LdapAuth.java
@helix84
helix84 / README-setup-tunnel-as-systemd-service.md
Created Jan 7, 2019 — forked from drmalex07/README-setup-tunnel-as-systemd-service.md
Setup a secure (SSH) tunnel as a systemd service. #systemd #ssh #ssh-tunnel #ssh-forward
View README-setup-tunnel-as-systemd-service.md

README

Create a template service file at /etc/systemd/system/secure-tunnel@.service. The template parameter will correspond to the name of target host:

[Unit]
Description=Setup a secure tunnel to %I
After=network.target
@helix84
helix84 / timed_cache.py
Last active Apr 14, 2020 — forked from jmdacruz/timed_cache.py
Python lru_cache with timeout
View timed_cache.py
from datetime import datetime, timedelta
import functools
def timed_cache(**timedelta_kwargs):
def _wrapper(f):
maxsize = timedelta_kwargs.pop('maxsize', 128)
typed = timedelta_kwargs.pop('typed', False)
update_delta = timedelta(**timedelta_kwargs)
View ssh-key-permissions.sh
#!/bin/sh
chmod 700 ~/.ssh
chmod 600 ~/.ssh/* # for private keys
chmod 644 ~/.ssh/*.pub # for public keys
chmod 644 ~/.ssh/known_hosts
chmod 600 ~/.ssh/authorized_keys
chmod 600 ~/.ssh/config