Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex DeLorenzo alexdelorenzo

View GitHub Profile
@alexdelorenzo
alexdelorenzo / install_ff.sh
Last active Jan 20, 2021
Install Firefox with Global Menu patches on Ubuntu derived Linux distributions
View install_ff.sh
#!/usr/bin/env bash
#
# This script requires Bash, curl, wget and pup. You can find the latter here:
# https://github.com/ericchiang/pup
#
# Copyright 2021 Alex DeLorenzo. License: AGPLv3
#
# Usage:
# $ ./install_ff.sh amd64
#
@alexdelorenzo
alexdelorenzo / get-cflags.sh
Last active Jan 20, 2021
Get native CFLAGS for your host device. This will list the flags that are enabled on your hardware that are not enabled on the parent arch.
View get-cflags.sh
#!/usr/bin/env bash
# License: AGPLv3
export arch="${1:-skylake}"
diff \
<(gcc -march=native -mtune=native -Q --help=target) \
<(gcc -march=$arch -Q --help=target) \
| grep "<" \
| grep "enabled" \
| col2 \
@alexdelorenzo
alexdelorenzo / to_opml.sh
Last active Jan 17, 2021
Generate an OPML file from Airsonic podcast subscriptions
View to_opml.sh
#!/usr/bin/env bash
# License: AGPLv3
export script=${1:-airsonic.script}
export title="Airsonic Podcasts"
export sqlRegex="'https?://[^ ,]+','[^']*"
export delim=','
echo -e "<opml version='2.0'>
\t<body>
@alexdelorenzo
alexdelorenzo / popcorntime-vpn.sh
Created Apr 20, 2018 — forked from Schnouki/popcorntime-vpn.sh
OpenVPN for a single application using network namespaces -- helper scripts
View popcorntime-vpn.sh
#!/usr/bin/env zsh
# Initialize VPN
sudo vpnns up
sudo vpnns start_vpn
# Popcorn time!
sudo ip netns exec frootvpn sudo -u $USER popcorntime
# Cleanup
View WhyPython.md

Why Python is Making a Comeback

Since the advent of nodeJS, you may have experienced something called Javascript-fatigue: the natural exhaustion one feels in response to the influx of new Javascript modules and developers putting Javascript everywhere - your phone, your car, your toaster - instead of just the web. For a while, it seemed that Javascript would eat the world.

However, over the past few years, an underdog has silently established itself as a cogent solution in both mainstream and niche spaces. Not only has it proved its mettle seemingly overnight, developers are adopting it fast.

Growth of Popular Programming Languages Over a Six Year Period - Courtesy of StackOverflow

Enter Python. A dynamic, strongly-typed programming language with a well-deserved reputation of having a beautifully concise, yet expressive, syntax. One might even say that Python code is executable pseudocod

View unfollow-pinterest.userscript.js
// ==UserScript==
// @name Pinterest Autounfollow
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Autofollow
// @author Alex DeLorenzo
// @match https://www.pinterest.com/organicallergyr/following
// @match https://www.pinterest.com/organicallergyr/following/*
// @require http://code.jquery.com/jquery-latest.js
// @grant none
View Ansible Let's Encrypt Nginx setup
Ansible playbook to setup HTTPS using Let's encrypt on nginx.
The Ansible playbook installs everything needed to serve static files from a nginx server over HTTPS.
The server pass A rating on [SSL Labs](https://www.ssllabs.com/).
To use:
1. Install [Ansible](https://www.ansible.com/)
2. Setup an Ubuntu 16.04 server accessible over ssh
3. Create `/etc/ansible/hosts` according to template below and change example.com to your domain
4. Copy the rest of the files to an empty directory (`playbook.yml` in the root of that folder and the rest in the `templates` subfolder)
@alexdelorenzo
alexdelorenzo / wordpress_dynamic_dropdown_menu.js
Created Feb 12, 2017
Theme agnostic dynamic drop down menu for Wordpress
View wordpress_dynamic_dropdown_menu.js
//
// Copyright Alex DeLorenzo 2017
//
// Dynamic Drop Down Menu for Wordpress
// Theme agnostic.
//
// Usage:
//
// 1) Embed this script in your page.
//
@alexdelorenzo
alexdelorenzo / wrapper.py
Last active Sep 28, 2016
HtmlWrapper -> Fast drop in replacement for BeautifulSoup
View wrapper.py
from functools import lru_cache
from lxml.html import HtmlElement, fromstring
from lxml.etree import XPath
BS4_TYPES = "bs4.element.Tag", "bs4.BeautifulSoup"
class HtmlWrapper(object):
View wrapper.py
from functools import lru_cache
from lxml.html import HtmlElement, Element, fromstring
from lxml.etree import XPath
from bs4 import BeautifulSoup, Tag
class BeauToLxml(object):
"""
An adapter for a small subset of the BeautifulSoup4 API