Skip to content

Instantly share code, notes, and snippets.

View mikey0000's full-sized avatar

Michael Arthur mikey0000

View GitHub Profile
@mikey0000
mikey0000 / convertToJPG
Last active March 15, 2024 10:10
convert png to jpeg using javascript and write back to original file
function convertDataURIToBinary(dataURI) {
var BASE64_MARKER = ';base64,';
var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
var base64 = dataURI.substring(base64Index);
var raw = window.atob(base64);
var rawLength = raw.length;
var array = new Uint8Array(new ArrayBuffer(rawLength));
for (i = 0; i < rawLength; i++) {
array[i] = raw.charCodeAt(i);
@mikey0000
mikey0000 / designer.html
Created January 15, 2015 00:10
designer
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../paper-button/paper-button.html">
<polymer-element name="my-element">
<template>
<style>
:host {
@mikey0000
mikey0000 / id_rsa_encryption.md
Created June 8, 2016 01:46
Encrypt/Decrypt a File using your SSH Public/Private Key on Mac OS X

A Guide to Encrypting Files with Mac OS X

This guide will demonstrate the steps required to encrypt and decrypt files using OpenSSL on Mac OS X. The working assumption is that by demonstrating how to encrypt a file with your own public key, you'll also be able to encrypt a file you plan to send to somebody else using their private key, though you may wish to use this approach to keep archived data safe from prying eyes.

Too Long, Didn't Read

Assuming you've already done the setup described later in this document, that id_rsa.pub.pcks8 is the public key you want to use, that id_rsa is the private key the recipient will use, and secret.txt is the data you want to transmit…

Encrypting

$ openssl rand 192 -out key

$ openssl aes-256-cbc -in secret.txt -out secret.txt.enc -pass file:key

@mikey0000
mikey0000 / Mower Locked Alert
Created September 5, 2024 19:53
Automation sample for alerting a user when their Mammotion lawm mower is locked.
alias: Mower Locked Alert
trigger:
- platform: state
entity_id:
- sensor.luba_2_activity_mode
to: MODE_LOCK
action:
- action: notify.mobile_app_my_phone
data:
title: WARNING Mower Locked!