Skip to content

Instantly share code, notes, and snippets.

@GiovanniK
GiovanniK / dante_setup.sh
Created February 1, 2019 14:19 — forked from gpchelkin/dante_setup.sh
How To Setup SOCKS5 Proxy Server for (not only) Telegram using Dante on Ubuntu 16.04 / 18.04
### NOT A SCRIPT, JUST A REFERENCE!
# install dante-server
sudo apt update
sudo apt install dante-server
# or download latest dante-server deb for Ubuntu, works for 16.04 and 18.04:
wget http://archive.ubuntu.com/ubuntu/pool/universe/d/dante/dante-server_1.4.2+dfsg-2build1_amd64.deb
# or older version:
wget http://ppa.launchpad.net/dajhorn/dante/ubuntu/pool/main/d/dante/dante-server_1.4.1-1_amd64.deb
@GiovanniK
GiovanniK / backup.sh
Last active January 3, 2023 15:50
Linux backup script (local + ftp + sftp)
#!/bin/bash
archiveLocation=/backups
archiveTempPath=/backups/tmp_backup
archiveName=$(date '+%d-%m-%Y_%H:%M');
archiveFullName=$archiveName.tar.gz
archivePath=$archiveLocation/$archiveFullName
deleteLocalArchive=false
backupPath=/var/www
backupToRemoteServer=false
@GiovanniK
GiovanniK / maps.php
Created March 15, 2016 07:51
Google maps - duratie en afstand berekenen
<?php
function distance($start, $destination)
{
// Send request to Google
$start = urlencode($start);
$destination = urlencode($destination);
$url = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=$start&destinations=$destination&mode=driving&language=nl-NL&sensor=false";
// Get response
@GiovanniK
GiovanniK / gist:426de8e1f307e7335ba8
Created January 12, 2016 08:30
24 uur, 15 min interval - PHP
<?php
for($i = 0; $i <= 23; $i++) {
// If hour is lower than 10, append a 0
if($i < 10) {
$append = 0;
} else {
$append = '';
}
@GiovanniK
GiovanniK / gist:a8e93807b56b98b97465
Created November 20, 2015 17:03
Laravel outside of public folder
# Disallow access to framework's files
RewriteRule ^(app/|bootstrap/|config/|database|resources|storage|tests|vendor|artisan|composer\.json|composer\.lock|gulpfile\.js|package\.json|phpspec\.yml|phpunit\.xml|readme\.md|server\.php|\.env) - [F,L,NC]
<?php
$dir = __DIR__ . '/..';
$keys = [
'mijnkey'
];
$lock = $dir . '/DEPLOY.LOCK';
if (!file_exists($lock)) {
if (isset($_GET['key']) && in_array($_GET['key'], $keys)) {
@GiovanniK
GiovanniK / gist:de0fdf9b08fcdd0b9f10
Created August 18, 2014 07:56
Sort array (descending or ascending)
public static function do_sort($a, $b) {
$date = $a->publishOn;
$date2 = $b->publishOn;
$aval = strtotime($date);
$bval = strtotime($date2);
if ($aval == $bval) {
return 0;
<?php
$data['var'] = urlencode($_POST['var']);
$ch = curl_init();
$url = 'API_URL';
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data, '', '&'));
# First, Install Vagrant and Virtualbox then:
# Create new project directory
mkdir -p ~/Sites/newproject # Create new project directory
mk ~/Sites/newproject # Go into your new project directory
# Setup Vagrant
vagrant init
# Edit vagrant file box and box url to install Ubuntu, just like https://gist.github.com/fideloper/dab171a2aa646e86b782#file-vagrantfile-share-var-www-rb-L6-L8
# Edit Vagrantfile to create a static IP address, just like https://gist.github.com/fideloper/dab171a2aa646e86b782#file-vagrantfile-share-var-www-rb-L10
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
$('input').keyup(function() {