Skip to content

Instantly share code, notes, and snippets.

View OlofFredriksson's full-sized avatar
🤠

Olof Fredriksson OlofFredriksson

🤠
View GitHub Profile
@OlofFredriksson
OlofFredriksson / nginx.sh
Created April 21, 2015 13:28
Simple Nginx conf for Django
upstream localhost {
server localhost:8000;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
{
"default_line_ending": "unix",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"font_size": 10,
"ignored_packages": [
"Vintage"
],
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
/*
*
* Originally inspired by: http://designedbythomas.co.uk/blog/how-detect-width-web-browser-using-jquery
*
* Original source by https://gist.github.com/highrockmedia/3710930
*
* My contribution: I re-wrote some code it to fire as one function, so you're only editing values in one place.
*
*/
var reflowDocument = function () {
var viewportWidth = jQuery(window).width();
// do stuff here
};
jQuery(document).ready(function($) {
var reflowTimer = null;
$(window).on('resize', function () {
@OlofFredriksson
OlofFredriksson / spop-pi.sh
Last active December 25, 2024 07:48
Install Spop on Raspberry Pi
# Made by Olof Fredriksson
# http://olof.nu
# https://github.com/oloffredriksson
# Tested on Raspberry Pi with Raspbian OS. Will probably work on Ubuntu and other Debian based systems, just make sure you install correct libspotify for your process architecture.
# Big thanks to Thomas Jost for creating Spop and uploading the project to Github (https://github.com/Schnouki/spop)
#Thanks to Björn Andersson (https://github.com/bjornandersson) for testing, reviewing and contributing to this guide.
# Changelog
# 1.0 2013-08-28 : First public release
@OlofFredriksson
OlofFredriksson / multi-replace.js
Last active December 17, 2015 02:59
Javascript String Multireplace
/*
* Add a function to String prototype to do multiple regex
* Credit goes to @datanizze
* Licence: Public domain
*/
if(String.prototype.multiReplace === undefined) {
String.prototype.multiReplace = function(match, replace) {
var output = this;
for (var i in match) {
@OlofFredriksson
OlofFredriksson / ufw-vpn.sh
Last active October 13, 2015 21:48
(Ubuntu) VPN, Firewall block
#! /bin/bash
# Functions needed for this script
is_valid_ipv4() {
local -a octets=( ${1//\./ } )
local RETURNVALUE=0
# return an error if the IP doesn't have exactly 4 octets
[[ ${#octets[@]} -ne 4 ]] && return 1