Skip to content

Instantly share code, notes, and snippets.

View binarweb's full-sized avatar
🛌
Sleeping at the gym.

Binar Web binarweb

🛌
Sleeping at the gym.
View GitHub Profile
#!/bin/bash
# Removes old revisions of snaps
# CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu
snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done
@binarweb
binarweb / enableSelect-bookmarklet.html
Created March 24, 2023 12:38 — forked from duzun/enableSelect-bookmarklet.html
Enable Right Click and Text Selection Bookmarklet
<a class="btn btn-default btn-info bookmarklet" href="javascript:(function(d){var a=d.document,h=function(){},c=a.body||a.getElementsByTagName("body")[0],f=a.documentElement||a.getElementsByTagName("html")[0],k=[c,f,a],l=["webkit","khtml","moz","ms",""],g=["contextmenu","selectstart","select","mousedown","mouseup"],b=d.Selection,e=b&&b.prototype;e&&(e.removeAllRanges=h,b=a.selection)&&(b.clear=h);for(e=k.length;e--;)if(f=k[e]){for(b=g.length;b--;)f["on"+g[b]]=null;if(a=f.style)for(a.cursor="",a.webkitTouchCallout="initial",b=l.length;b--;)a[((c=l[b])?"-"+c+"-":c)+"user-select"]="initial"}(c=d.jQuery||d.Zepto)&&c(d).off(g)})(this);">
Enable Select
</a>
@binarweb
binarweb / main.py
Created December 5, 2022 18:40 — forked from FulcronZ/main.py
Python MQTT Logging Handler
"""
MIT License
Copyright (c) 2016 Pipat Methavanitpong
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
@binarweb
binarweb / rpc-consumer.php
Created December 20, 2019 19:38 — forked from frankmayer/rpc-consumer.php
Consumer and producer files for blog post : http://bit.ly/14SaWpp
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use PhpAmqpLib\Connection\AMQPConnection;
use PhpAmqpLib\Message\AMQPMessage;
define('AMQP_DEBUG_FM', true);
$host = '127.0.0.1';
//$host = '192.168.2.3';
@binarweb
binarweb / clean-up-boot-partition-ubuntu.md
Created October 30, 2018 13:30 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@binarweb
binarweb / Github commands.md
Last active February 17, 2025 10:25
Github commands

This tutorial is about setting up a Github account to commit (via SSH) to an existing/new repository and common commands to handle that repository.

1. Setting up git

  • globally (recommended for one github account / OS user)

git config --global user.email "[email protected]"
git config --global user.name "Your Name"

  • locally (recommended for multiple github accounts / OS user)
@binarweb
binarweb / apache-self-signed-ssl-certificate.md
Last active January 24, 2020 22:54
Setup a self-signed SSL certificate for Apache (server side only)

Create the certificate:

$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt

Create a strong Diffie-Hellman group:

$ openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048

Create an Apache Configuration Snippet with Strong Encryption Settings

@binarweb
binarweb / nginx-self-signed-ssl-certificate.md
Last active May 25, 2018 09:14 — forked from clemlatz/self-signed-ssl-certificate.md
Setup a self-signed SSL certificate for Nginx (server side only)

Create the certificate:

$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt

Create a strong Diffie-Hellman group:

$ sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048

Create a new configuration snippet file for Nginx:

@binarweb
binarweb / nginx_config_cloudfront_real_ips.js
Created April 17, 2018 08:47 — forked from radiofrequency/nginx_config_cloudfront_real_ips.js
list cloufront ip ranges for nginx real ip module
var request = require("request");
var fs = require("fs");
var output = "#cloudfront ip ranges\n";
request("https://ip-ranges.amazonaws.com/ip-ranges.json", function(err, res, body) {
if (err) {
console.error("error", err);
}
var j = JSON.parse(body);
j.prefixes.forEach(function(item) {
if (item.service ==='CLOUDFRONT') {