Skip to content

Instantly share code, notes, and snippets.

View defaye's full-sized avatar

Jono Feist defaye

  • England
View GitHub Profile
@Necklaces
Necklaces / ufw_vpn_killswitch_tutorial.md
Last active February 28, 2024 22:13
GNU/Linux UFW VPN kill switch tutorial

GNU/Linux UFW VPN kill switch tutorial

This is a quick guide for setting up a kill switch using UFW (Uncomplicated FireWall). It is assumed you are using OpenVPN and optionally Network-Manager with network-manager-openvpn.

1. (Optional) IP Addresses

Before we can start we're going to need the IP address (or the IP addresses) of your VPN so that we can whitelist those later on, write them down. They are obviously going to be different for every VPN and VPNs with multiple servers, so I'll leave this up to you.

2. Install UFW

On some systems UFW is installed and enabled by default (Ubuntu, for example). Installation procedure is going to be different for every distribution of GNU/Linux, but it's usually something like

@javilobo8
javilobo8 / download-file.js
Last active April 9, 2024 12:01
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@simonhamp
simonhamp / AppServiceProvider.php
Last active March 26, 2024 15:56
A pageable Collection implementation for Laravel
<?php
namespace App\Providers;
use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
class AppServiceProvider extends ServiceProvider
{
public function boot()
@beeman
beeman / remove-all-from-docker.sh
Created November 15, 2016 03:04
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
@remarkablemark
remarkablemark / Dockerfile
Last active April 24, 2024 13:40
Install node and npm with nvm using Docker.
# set the base image to Debian
# https://hub.docker.com/_/debian/
FROM debian:latest
# replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# update the repository sources list
# and install dependencies
RUN apt-get update \
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@ghinda
ghinda / object-to-form-data.js
Last active March 30, 2024 18:51
JavaScript Object to FormData, with support for nested objects, arrays and File objects. Includes Angular.js usage.
// takes a {} object and returns a FormData object
var objectToFormData = function(obj, form, namespace) {
var fd = form || new FormData();
var formKey;
for(var property in obj) {
if(obj.hasOwnProperty(property)) {
if(namespace) {
@kohnmd
kohnmd / flatten.php
Last active September 20, 2021 12:48
Function to recursively flatten multidimensional PHP array.
<?php
// Requires PHP 5.3+
// Found here: http://stackoverflow.com/a/1320156
function flatten_array(array $array) {
$flattened_array = array();
array_walk_recursive($array, function($a) use (&$flattened_array) { $flattened_array[] = $a; });
return $flattened_array;
}
@nogweii
nogweii / plugin.rb
Last active August 29, 2015 13:57
steam login plugin for discourse
# name: discourse-steam
# about: VALVE's Steam login support for Discourse
# version: 0.0.1
# authors: Colin Shea
auth_provider :title => 'with Steam',
:authenticator => Auth::OpenIdAuthenticator.new('steam','http://steamcommunity.com/openid', trusted: true),
:message => 'Authenticating with Steam (make sure pop up blockers are not enabled)',
:frame_width => 1000, # the frame size used for the pop up window, overrides default
:frame_height => 800
@jasonrobertfox
jasonrobertfox / commit-msg
Last active August 15, 2021 10:05
This is a commit-msg hook for git that will validate your commit message to conform to the rules outlined in http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html It's a ruby adaptation of the hook outlined in http://addamhardy.com/blog/2013/06/05/good-commit-messages-and-enforcing-them-with-git-hooks/ (Thanks Addam Hardy!)
#!/bin/sh
exec < /dev/tty
./.git/hooks/validate_commit.rb $1