Skip to content

Instantly share code, notes, and snippets.

@npearce
npearce / install-docker.md
Last active April 19, 2024 12:35
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@kacole2
kacole2 / IstioOnPKS.md
Last active July 11, 2019 02:01
How to Install Istio with Helm on PKS and VMware Cloud PKS

How to Install Istio with Helm on PKS and VMware Cloud PKS

The following guide is based on using a newly created Kubernetes cluster that plans to use Istio for its service mesh layer. This guide is not intended for backwards compatibility of injecting Istio into a cluster that has pods currently running.

Pre-Requisites

These pre-requesites determine the resources and software versions required.

PKS

  • PKS 1.2=<
  • NSX-T 2.3=<
@h0bbel
h0bbel / sources.list
Last active March 23, 2024 16:17
/etc/apt/sources.list for Ubuntu 18.04.1 LTS Bionic Beaver
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
@1RedOne
1RedOne / DownloadEmAll.ps1
Created August 29, 2016 16:11
Download all files from a site in powerShell.ps1
<#
found this site which has all of the soundtrack to MH4 for free
BUT, you can't click downlaod and save each one, instead each link takes you to a new page with it's own DL link embedded within the site
Solution?
Wou write a short powershell script to find all the links we want, then load each page, find any downloadable MP3 links within that page and save them all
#>
$u = 'http://downloads.khinsider.com/game-soundtracks/album/monster-hunter-4'
@levantoan
levantoan / Fix_vc.php
Last active November 29, 2020 12:11
Fix $template.get is not a function in VC when updated WordPress to 4.5
<?php
/*
Find html2element in
Version < 4.8: /wp-content/plugins/js_composer/assets/js/backend/composer-view.js
Version > 4.9: wp-content/plugins/js_composer/assets/js/dist/backend-actions.min.js
*/
html2element: function(html) {
var attributes = {},
$template;
if (_.isString(html)) {
@lokhman
lokhman / ubuntu-hardening.md
Last active April 23, 2024 09:05
List of things for hardening Ubuntu

WARNING

May contain out of date information. Check the comments below!

The list of actions listed below was taken mostly from Book Of Zeus with minor modifications and did the job well for Ubuntu version, which was available at that moment (May 2016). This gist was created for internal use and was never meant to be discovered by the web, although Google managed to find and index this page, which was a great surprise for me. Please check the original source for the updated information (links are provided in most of the sections), and read the comments below: they provide more details about the usage experience.

System Updates

http://bookofzeus.com/harden-ubuntu/initial-setup/system-updates/

Keeping the system updated is vital before starting anything on your system. This will prevent people to use known vulnerabilities to enter in your system.

@nitinbhojwani
nitinbhojwani / django_send_mail
Created May 4, 2016 18:33
Django - Send a Mail with Attachment File like CSV
# Import EmailMessage class - https://docs.djangoproject.com/en/1.9/topics/email/#django.core.mail.EmailMessage
from django.core.mail import EmailMessage
email = EmailMessage('... Subject ...', '... Body ...', 'from-email',
['to-email-1', 'to-email-2'], ['bcc-email-1', 'bcc-email-2'])
# now let's create a csv file dynamically
import csv, StringIO
attachment_csv_file = StringIO.StringIO()
writer = csv.writer(attachment_csv_file)
@SmileyChris
SmileyChris / mail.py
Last active March 5, 2016 08:49
Handle template-base email messages in Django
from email.Utils import formataddr
import os
from django.conf import settings
from django.core import mail
from django import template
from django.template.loader import select_template, get_template
def template_email(template_name, extra_context=None, *args, **kwargs):
@ncherro
ncherro / format_date_range.py
Created April 10, 2013 20:13
django template tag - format date range
from django import template
register = template.Library()
@register.simple_tag
def format_date_range(date_from, date_to, separator=" - ",
format_str="%B %d, %Y", year_f=", %Y", month_f="%B", date_f=" %d"):
""" Takes a start date, end date, separator and formatting strings and
returns a pretty date range string
"""
@mindlace
mindlace / middleware.py
Created October 19, 2012 13:43
Add user created/modified to every model
"""Add user created_by and modified_by foreign key refs to any model automatically.
Almost entirely taken from https://github.com/Atomidata/django-audit-log/blob/master/audit_log/middleware.py"""
from django.db.models import signals
from django.utils.functional import curry
class WhodidMiddleware(object):
def process_request(self, request):
if not request.method in ('GET', 'HEAD', 'OPTIONS', 'TRACE'):
if hasattr(request, 'user') and request.user.is_authenticated():
user = request.user