Skip to content

Instantly share code, notes, and snippets.

@e7d
e7d / README.md
Last active December 19, 2022 09:13
[Debian] Build a Squid anonymous proxy from source code

If you don't want to build Squid from scratch, you can simply Setup a Squid anonymous proxy

Build a Squid anonymous proxy from source code

Please note that this whole manual refers to the version 3.5.23 of Squid. You probably would have to adapt some commands to the version you will actually download.

Table of contents

@e7d
e7d / parseDSV.js
Created August 12, 2014 10:05
[JavaScript] Parse delimiter-separated values (CSV, TSV...)
// Comma-separated values to JSON
function parseCSV(data) {
return parseDSV(data, ",");
}
// Tabulation-separated values to JSON
function parseTSV(data) {
return parseDSV(data, "\t");
}
@e7d
e7d / bootstrap-autocomplete.html
Last active March 5, 2021 20:44
Bootstrap autocomplete field
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="sampleAutocomplete" class="col-sm-3 control-label">Sample Autocomplete</label>
<div class="col-sm-9">
<input type="text" class="autocomplete form-control" id="sampleAutocomplete" data-toggle="dropdown" />
<ul class="dropdown-menu" role="menu">
<li><a>Action</a></li>
<li><a>Another action</a></li>
<li><a>Something else here</a></li>
<li><a>Separated link</a></li>
#!/bin/sh
SRC=/usr/src
NGINX_VERSION=1.8.0 # http://nginx.org/en/download.html
NPS_VERSION=1.9.32.6 # https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
@e7d
e7d / remove-old-kernels.sh
Last active August 29, 2015 14:23
Remove all unused kernels on Debian-based systems
#!/bin/sh
sudo apt-get remove $(dpkg -l|egrep '^ii linux-(im|he)'|awk '{print $2}'|grep -v `uname -r`)
update-grub
@e7d
e7d / README.md
Last active October 7, 2015 09:10
Setup an APT environment for all repositories

Automated install

Disclaimer

Read the install script before using it.
You may want to understand what the script is doing before executing it.
I will not be responsible for any damage caused to your server.

Installation script

@e7d
e7d / cryptURI.js
Created July 9, 2015 09:20
Crypt URI with JavaScript
(function() {
String.prototype.asciiEncode = function() {
var i, result = [];
for (i = 0; i < this.length; i++) {
result.push("%", this.charCodeAt(i).toString(16));
}
return result.join('');
}
@e7d
e7d / run.sh
Last active August 5, 2016 16:22
#!/bin/sh
run() {
echo -en "# "
($@ 2>&1; echo $?>~/_$$) | log
V=$(($(cat ~/_L$$;rm -f ~/_L$$) / $(tput cols)))
if test 0 -eq $(cat ~/_$$;rm -f ~/_$$); then
echo -e "\r\033["$V"A\033[1;32m✓\033[0m\r\033["$V"B"
else
echo -e "\r\033["$V"A\033[1;31m✕\033[0m\r\033["$V"B"
@e7d
e7d / sample.sh
Last active December 10, 2023 10:45
Bash "try catch"
#!/bin/bash
export AnException=100
export AnotherException=101
# start with a try
try
( # open a subshell !!!
echo "do something"
[ someErrorCondition ] && throw $AnException
@e7d
e7d / README.md
Last active February 6, 2017 15:33
Chroot SFTP users

Introduction

What we want is to allow John to connect through sftp only (no bash, no terminal) and to be limited to a set of folders.

In this example, we'll consider an existing user john, whose home directory is /home/john. You'll have to adapt the different commands to your specific case.

User preparation

We need our user to customized a bit. First of all the, its home directory must be owned by root: chown -c root:root /home/john