Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am alexhaker on github.
  • I am alexhaker (https://keybase.io/alexhaker) on keybase.
  • I have a public key ASCOL4AAo0ySPeLL7m_b2my5Aj_Gek8DvcnrxgVZLc5RPAo

To claim this, I am signing this object:

@alexhaker
alexhaker / php-fpm-restart.sh
Created February 24, 2019 20:33 — forked from maxkostinevich/php-fpm-restart.sh
Cloudways PHP-FPM restart via API
# Restart PHP-FPM on CloudWays via API
# Replace YOUR_NAME%40DOMAIN.COM with your email (URL-encoded), YOUR_API_KEY with your Cloudways API key and SERVER_ID with id of your server
# If you want to use it with DeployBot just add the following commands to the "Run commands after new version becomes active" section.
# Do auth and receive access_token
cloudways_token=$(curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' -d 'email=YOUR_NAME%40DOMAIN.COM&api_key=YOUR_API_KEY' 'https://api.cloudways.com/api/v1/oauth/access_token' | python3 -c "import sys, json; print(json.load(sys.stdin)['access_token'])")
# Restart PHP-FPM
curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' --header "Authorization: Bearer ${cloudways_token}" -d 'server_id=SERVER_ID&service=php7.0-fpm&state=restart' 'https://api.cloudways.com/api/v1/service/state'
@alexhaker
alexhaker / google-suggestions.rb
Created January 31, 2019 06:20 — forked from jehrhardt/google-suggestions.rb
Get suggestions from Google's completion API like http://ubersuggest.org
# Copyright © 2014 Jan Ehrhardt
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@alexhaker
alexhaker / README.md
Created September 20, 2018 12:11 — forked from gdamjan/README.md
Setup for an easy to use, simple reverse http tunnels with nginx and ssh. It's that simple there's no authentication at all. The end result, a single ssh command invocation gives you a public url for your web app hosted on your laptop.

What

A lot of times you are developing a web application on your own laptop or home computer and would like to demo it to the public. Most of those times you are behind a router/firewall and you don't have a public IP address. Instead of configuring routers (often not possible), this solution gives you a public URL that's reverse tunnelled via ssh to your laptop.

Because of the relaxation of the sshd setup, it's best used on a dedicated virtual machine just for this (an Amazon micro instance for example).

Requirements

@alexhaker
alexhaker / Awesome selfhosted
Created January 30, 2018 08:56
Awesome selfhosted
https://github.com/Kickball/awesome-selfhosted#analytics
@alexhaker
alexhaker / git-tag-delete-local-and-remote.sh
Created December 29, 2017 15:56 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@alexhaker
alexhaker / flattenExceptionBacktrace.php
Created December 14, 2017 14:38 — forked from Thinkscape/flattenExceptionBacktrace.php
Make any PHP Exception serializable by flattening complex values in backtrace.
<?php
function flattenExceptionBacktrace(\Exception $exception) {
$traceProperty = (new \ReflectionClass('Exception'))->getProperty('trace');
$traceProperty->setAccessible(true);
$flatten = function(&$value, $key) {
if ($value instanceof \Closure) {
$closureReflection = new \ReflectionFunction($value);
$value = sprintf(
'(Closure at %s:%s)',
@alexhaker
alexhaker / remove-all-from-docker.sh
Created November 17, 2017 11:09 — forked from beeman/remove-all-from-docker.sh
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes