Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
LATEST_RELEASE=$(curl -sSL -H "Accept: application/json" https://github.com/adnanh/webhook/releases/latest)
LATEST_VERSION=$(echo $LATEST_RELEASE | jq -r .tag_name)
ARTIFACT_URL="https://github.com/adnanh/webhook/releases/download/$LATEST_VERSION/webhook-linux-amd64.tar.gz"
mkdir -p "${DIR}/bin"
[ -f "${DIR}/hooks.yml" ] || touch "${DIR}/hooks.yml"
# Staging
# Use this command for testing purpose, because of Let's Encrypt API restrictions
docker run -it --rm \
-v certs:/etc/letsencrypt \
-v certs-data:/data/letsencrypt \
certbot/certbot \
certonly --webroot \
--register-unsafely-without-email --agree-tos \
--webroot-path=/data/letsencrypt \
--staging \
#!/bin/bash
# Updating and installing stuff
apt-get update
apt-get install -y git curl
# Install docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository \
@askobara
askobara / new_ovpn_user.sh
Created July 4, 2018 09:03
generates .ovpn config for the new user
#!/bin/bash
set -e
NAME=$1
if [ -z "$NAME" ]; then
echo "$0 NAME"
exit
fi
#!/usr/bin/env bash
set -e
function info {
echo " "
echo "--> $1"
echo " "
}
if [[ $EUID -ne 0 ]]; then
@askobara
askobara / gist:85f6261bdbb2ac392d49125642607df9
Created January 30, 2018 13:59
Yii2 loggin db profiling
'response' => [
'on afterSend' => function ($event) {
list($queryCount, $totalExecTime) = Yii::getLogger()->getDbProfiling();
list($mongoQueryCount, $mongoTotalExecutionTime) = mongodb_profiling();
$elapsedTime = Yii::getLogger()->getElapsedTime();
$request = Yii::$app->getRequest();
Yii::info(\yii\helpers\VarDumper::dumpAsString([
'url' => "{$request->getMethod()} {$request->getAbsoluteUrl()}",
location ^~ /api/ {
root /var/www/;
index index.php;
fastcgi_split_path_info ^/api(.+\.php)(.*)$;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
try_files $uri /index.php =404;
@askobara
askobara / http_status.sh
Created September 14, 2015 13:24
Make http requests to the given url in loop
#!/bin/bash
COLOR_NC='\e[0m' # No Color
COLOR_LIGHT_RED='\e[1;31m'
COLOR_LIGHT_GREEN='\e[1;32m'
COLOR_LIGHT_YELLOW='\e[1;33m'
COLOR_LIGHT_BLUE='\e[1;34m'
usage() {
echo "$0 [options] url"
@askobara
askobara / local_build_with_semver_and_rsync.sh
Last active August 29, 2015 14:25
Set of deploy scripts
#!/bin/bash
set -e
RSYNC_BIN=`command -v rsync`
GIT_BIN=`command -v git`
GULP_BIN=`command -v node_modules/gulp/bin/gulp.js`
SEMVER_BIN=`command -v node_modules/semver/bin/semver`
COLOR_NC='\e[0m' # No Color
COLOR_LIGHT_BLUE='\e[1;34m'
@askobara
askobara / copy.rb
Created April 8, 2015 07:29
Dump mysql db through ssh
#!/usr/bin/env ruby
require 'rubygems'
require 'net/ssh'
require 'net/scp'
HOST = '127.0.0.1'
@username = 'user'
@password = 'password'
MYSQL_DATABASE = 'db'