Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
#encrypt files with aes-256-cbc cipher using openssl
# taken from https://superuser.com/questions/370388/simple-built-in-way-to-encrypt-and-decrypt-a-file-on-a-mac-via-command-line/370412
# with minor modifications
#encrypt files
if [[ $1 == "-e" ]];
then
if [ -f "$2" ];
then
@juanino
juanino / ssl-check.py
Created February 17, 2021 22:17 — forked from gdamjan/ssl-check.py
Python script to check on SSL certificates
# -*- encoding: utf-8 -*-
# requires a recent enough python with idna support in socket
# pyopenssl, cryptography and idna
from OpenSSL import SSL
from cryptography import x509
from cryptography.x509.oid import NameOID
import idna
from socket import socket
@juanino
juanino / stock.py
Last active November 10, 2019 17:38
check yahoo stock for price change for the day, return true if postive
from yahoo_fin.stock_info import get_live_price
from yahoo_fin.stock_info import get_quote_table
def check_stock(stock):
price = get_live_price(stock)
prev_price = get_quote_table(stock)['Previous Close']
if price > prev_price:
return(True)
else:
@juanino
juanino / timecheck.sh
Last active November 7, 2019 02:21
when does my machine think a timezone change occurs
# pass your own location
# syntax of name is in /usr/share/zoneinfo/ usually
zdump -v "America/New_York"
@juanino
juanino / bigls.py
Last active November 7, 2019 02:21
do an ls in a huge dir and print out a shell script to remove. better than shell globbing
# when you have millions of files
# this is faster than ls if you don't need the other metadata
# like mod times or perms
from os import listdir
files = listdir(".")
# here we can output the giant list with some rm commands
# then you can pipe it to sh -x to perform the operations you wawnt
# or grep out the noise first
@juanino
juanino / mcp23017.py
Created November 7, 2019 02:20
test mcp23017 - 9 of the 16 pins
#!/usr/bin/python3
import pprint
import board
import busio
from digitalio import Direction
from time import sleep
from adafruit_mcp230xx.mcp23017 import MCP23017
i2c = busio.I2C(board.SCL, board.SDA)
@juanino
juanino / getinstalledapps
Created January 22, 2019 02:05
powershell list of installed apps
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize
@juanino
juanino / gist:d88f70bf8b37017fa51a8d3b7ac04908
Created September 10, 2017 15:09
post to dweet.io with a curl line
# post json to dweet.io
curl \
--header "Content-Type:application/json" \
--header "Accept: application/json" \
--request POST \
--data '{"temp_last":"2:3:aa","temp":"20"}' \
https://dweet.io/dweet/for/DWEETname
@juanino
juanino / gist:e8043be04cec2dadbbb5202bf9a6e29a
Created September 4, 2017 14:15
check ansible yml file for package existence in raspian (or any apt system for that matter)
# problem: you have a bunch of files in some ansible playbook but some don't exist
# solution: apt-cache show each of them and check return code $?
cat pi-base.yml | grep "\- " | grep -v name\: | grep -v hosts\: | sed 's/.*- //g' | awk {'print "echo -n " $1 " ; apt-cache show " $1 " 1>/dev/null ;echo \" \" $?" '} | sh | tee /tmp/output
@juanino
juanino / lstags.sh
Created December 13, 2016 03:06
get a listing of aws instances and name and project tags
/usr/bin/aws ec2 describe-instances --output table --query 'Reservations[].Instances[].[join(`,`,Tags[?Key==`Name`].Value),State.Name,PublicIpAddress,join(`,`,Tags[?Key==`project`].Value),join(`,`,Tags[?Key==`aws:ec2spot:fleet-request-id`].Value)]'