One Click Shadowsocks with no technical knowledge needed

Posted on 23. November 2017 Comments

Shadowsocks is a proxy that has been designed and used to circumvent censorship in China. So if it’s possible to get traffic across the Great Firewall of China it pretty much can be used anywhere, e.g. Egypt where VPNs are blocked since mid 2017.

Digital Ocean offers virtual servers for cheap with an easy to understand pricing model. Basically you pay either $5, $10, $20, $40, $80 or $160 per month, for more have a look at pricing at digitalocean.com. These server are general purpose servers, you can do everything with them, which also means, they don’t have anything installed and you need to do everything yourself.

oneclickshadowsocks.de is a service to install shadowsocks on DigitalOcean servers without having to actually login via SSH and entering lots of technical commands in the commandline. It uses the DigitalOcean API to create a Droplet (=server) with shadowsocks already set up and running. All you have to do is to enter the IP address you get via e-mail in your shadowsocks client and the password given to you on the website.

The code is open source and the website itself is hosted on GitHub Pages, which means, you can see the sourcecode of the page itself, running at that very moment. This way other people can verify they nothing shady is going on.

Commandline: Which programs are using network connection

Posted on 29. August 2017 Comments

lsof -P -i -n | cut -f 1 -d " " | uniq

lsof – list open files
-P list port numbers instead of service names
-i list all network files
-n IP addresses instead of host names

cut – cut output
-f specifies fields, separated in the input by the field delimiter character (-d)
-d delimiter

uniq – filters out repeated lines

Backup 2 harddrives with rsync

Posted on 24. August 2017 Comments

Linux

rsync -a -v -P --delete -h --stats /media/repat/hdd1/ /media/repat/hdd2

 

MacOS:
rsync -a -v -P --delete -h --stats /Volumes/hdd1/ /Volumes/hdd2

 

-a all (-r, -l, -t, -p, -g, -o, -D)
-v verbose
-P show progress and continue partial transfers
–delete delete extraneous files from destination dirs
–stats give some file-transfer stats

Note: the last / after hdd1 is important, so the contents of hdd1 are written directly into hdd2. If you forget, there will be a new folder called hdd1 in the folder hdd2

 

Delete empty rows in CSV file with sed

Posted on 23. August 2017 Comments

This is for when you have empty lines (so lot’s of ,,,,,,) in your file.

MacOS

sed -i '' -e '/^,*$/d' filename.csv
find ./ -type f -exec sed -i '' -e '/^,*$/d' {} \;

Linux

sed -i '/^,*$/d' filename.csv
find ./ -type f -exec sed -i '/^,*$/d' {} \;

 

^ marks the beginning of a line
,* marks a possible infinite amount of commas
$ marks the end of a line

Scuba Diving on Gran Canaria Overview

Posted on 4. Juli 2017 Comments

One of the best destinations for Scuba Diving in Europe are the Canary Islands. There are quite a number of dive centers on the island. This is a compiled list, which shows Name, Homepage, Diving Associations, whether or not they offer Technical Diving (+Rebreathers), how far you can get certified (Divemaster, Instructor etc) and what Specitalties they offer.
There are a couple more dive centers but I only listed those that the official list of the Gobierno de Canarias because those are definitely legal. There might be others who didn’t make it onto the list yet and operate with a temporary license (so they are legal) but it’s hard to tell.

Scuba Diving Centers Gran Canaria

Feel free to let me know if I made mistakes or you want to add a divecenter/course.

I can personally recommend diving with Leagues Ahead Diving in Maspalomas.

Quick and dirty redirect script for the fitting shipping provider

Posted on 2. März 2017 Comments

Another way to use the PHP library shipping-service-provider-check apart from fixing the shipping providers in the ERP Plentymarkets is a simple quick and dirty PHP script that redirects to the tracking page of a fitting shipping provider. You can find the whole sourcecode on GitHub.

Installation

If you don’t use some sort of MVC this is a quick way to do it. If you do, I suspect you’ll know how to alter this example to fit your system. Feel free to write me an e-mail or comment if you need help

  1. Log onto your server and create a folder
  2. Copy or git pull the files, including .htaccess
  3. Get Composer
  4. composer require repat/shipping-service-provider-check

Explanation of the code

The $trackingId variable is received via HTTP GET. This means the URL would be http://url.tld/trackingscriptfolder/script.php?tracking_id=123456 (or without the script.php in case of the .htaccess), where 123456 is the TrackingID. The rest is more or less just for debugging. The scripts returns a HTTP Code 422 and ends if there is no input given.

$trackingId = $_GET["tracking_id"];
if (empty($trackingId)) {
  $unprocessableEntity = 422;
  http_response_code($unprocessableEntity);
  echo "wrong input";
  return;
}

Next the URLs will be defined. The keys have to match the shipping providers so make sure the shipping providers are added at the library as well. The TrackingID will be added at the end of the URL, so make sure they have the right format.

$shippingProviderURLs = [
  "dhl" => 'https://nolp.dhl.de/nextt-online-public/set_identcodes.do?idc=',
...
];

Then follows the documented way of checking for the providers. It could technically be that at the same time a TrackingID is valid for more than one provider. To keep things simple, we’ll just use the first one (array_search instead of array_keys). In case there is none found, array_search returns false and the script continues. In case there is one found, the header() function is called to redirect the user to the correct provider page.

$checkedProvider = array_search(true, $result);
$urlOfCheckedProvider = $shippingProviderURLs[$checkedProvider];

if ($checkedProvider !== false) {
  header('location: ' . $urlOfCheckedProvider . $trackingId);
}

Now it’s up to you what you will do with the ones you can’t redirect. I decided to write a little skeleton.html file and include that with a simple message that the user could try the shipping providers where a check is not possible (no API, no website scraping, no regex). They are listed earlier:

$shippingProviderURLsNoCheck = [
  "DPD" => 'https://tracking.dpd.de/parcelstatus?query=',
...