This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pass your own location | |
# syntax of name is in /usr/share/zoneinfo/ usually | |
zdump -v "America/New_York" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |