Skip to content

Instantly share code, notes, and snippets.

@Adirael
Adirael / AWS.sh
Last active October 27, 2022 17:14
Cheatsheet for devops (jq, bash, aws...)
# List all subnets and returns an iterable list of subnet and free ip addresses
aws ec2 describe-subnets | jq \
'.Subnets[] | {Subnet: (.Tags[] | select(.Key == "Name") | .Value), AvailableIpAddressCount: .AvailableIpAddressCount}' | \
jq -s -c 'sort_by(.Subnet) | .[]'
# Iterate subnets
for subnet in ${SUBNETS}; do # To generate subnets wrap the previous command in the variable: SUBNETS=$(COMMAND)
Name=$(echo $subnet | jq -r '.Subnet')
AvailableIpCount=$(echo $subnet | jq -r '.AvailableIpAddressCount')
@Adirael
Adirael / MQTT Temperature.ino
Last active January 24, 2021 18:14
Send temperature readings from an NTC 3950 thermistor to MQTT and retrieve them in Home Assistant
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <NTC_Thermistor.h>
#define wifi_ssid "Eros"
#define wifi_password "Protomolecule"
//Static IP address configuration
IPAddress staticIP(192, 168, 1, 36); // ESP static ip
IPAddress gateway(192, 168, 1, 1); // IP Address of your WiFi Router (Gateway)
@Adirael
Adirael / monit
Created April 28, 2016 11:59 — forked from clasense4/monit
Fresh Install monit from 0 Centos 6.5
#!/bin/bash
#
# Init file for Monit system monitor
# Written by Stewart Adam <[email protected]>
# based on script by Dag Wieers <[email protected]>.
#
# chkconfig: - 98 02
# description: Utility for monitoring services on a Unix system
#
# processname: monit

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

var vertical = 0;
var horizontal = 0;
var cuadrada = 0;
jQuery('div.play').each(
function(index, Element){
if(jQuery(Element).width() > jQuery(Element).height()){
horizontal = horizontal + 1;
} else if (jQuery(Element).width() < jQuery(Element).height()) {
vertical = vertical + 1;
#Retrive old website from Google Cache. Optimized with sleep time, and avoid 504 error (Google block Ip send many request).
#Programmer: Kien Nguyen - QTPros http://qtpros.info/kiennguyen
#change search_site and search_term to match your requirement
#Original: http://www.guyrutenberg.com/2008/10/02/retrieving-googles-cache-for-a-whole-website/
#!/usr/bin/python
import urllib, urllib2
import re
import socket
@Adirael
Adirael / fix-wordpress-permissions.sh
Created August 17, 2012 23:16
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory