To create a DPAPI-encrypted environment variable run the following PowerShell:
[Environment]::SetEnvironmentVariable((Read-Host "Enter name"), (Read-Host "Enter value" -AsSecureString | ConvertFrom-SecureString), 'User')
And follow the prompts:
// Call initFunc on elements in selector that are in DOM now and also on dynamically-added elements later on | |
function dynamicInit(selector, initFunc) { | |
//console.log('dynamicInit', selector) | |
window._dynamicInitData ??= []; | |
window._dynamicInitData.push({ selector, initFunc }); | |
if (!window._dynamicInitObserver) { | |
window._dynamicInitObserver = new MutationObserver(function (mutations) { | |
// avoid infinite loop when we add new elements below | |
window._dynamicInitObserver.disconnect() |
/// <summary> | |
/// Compares tuples of 2 items of the same type, using the specified comparer. | |
/// </summary> | |
class TupleComparer<T> : IEqualityComparer<(T, T)> | |
{ | |
IEqualityComparer<T> _comparer; | |
public TupleComparer(IEqualityComparer<T> comparer) => _comparer = comparer; | |
public bool Equals((T, T) x, (T, T) y) => _comparer.Equals(x.Item1, y.Item1) && _comparer.Equals(x.Item2, y.Item2); | |
public int GetHashCode((T, T) obj) => HashCode.Combine(_comparer.GetHashCode(obj.Item1), _comparer.GetHashCode(obj.Item2)); | |
} |
############################################################################### | |
# Get a refresh token using something like https://chrome.google.com/webstore/detail/tesla-access-token-genera/kokkedfblmfbngojkeaepekpidghjgag | |
$REFRESH_TOKEN = 'your.token.here' | |
# Set as appropriate: | |
$startDate = [DateTime]::Parse('2023-04-01') | |
$csvFile = 'C:\temp\my powerwall data.csv' | |
############################################################################### | |
# Auth | |
$token = Invoke-RestMethod -Uri "https://auth.tesla.com/oauth2/v3/token" -Method Post -Body @{ |
using System; | |
using System.IO; | |
class SmartStream : Stream | |
{ | |
int _maxMemorySize; | |
Stream _stream = new MemoryStream(); | |
public SmartStream(int maxMemorySize) | |
{ |
<?xml version="1.0" encoding="UTF-8"?> | |
<configuration> | |
<system.web> | |
<httpRuntime requestPathInvalidCharacters="<,>,%,&,\,?" /> <!-- some requests contains mac address thus ":" should be allowed --> | |
</system.web> | |
<system.webServer> | |
<httpErrors errorMode="Detailed" /> | |
<rewrite> | |
<rules> | |
<clear /> |
const url = require('url'); | |
const axios = require('axios'); | |
const qs = require('querystring') | |
const WebSocket = require('ws'); | |
// disable certificate verification | |
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; | |
const baseUrl = 'https://192.168.1.1'; | |
const username = 'ubnt'; |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>PayloadContent</key> | |
<array> | |
<dict> | |
<key>APNs</key> | |
<array> | |
<dict> |
# powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -Command "& { .\MailEventLogs.ps1 }" | |
$mailTo = "foo@example.com" | |
$mailFrom = "$env:COMPUTERNAME@example.com" | |
$smtpServer = "aspmx.l.google.com" | |
Set-StrictMode -Version Latest | |
$startDate = (Get-Date).AddDays(-1).AddMinutes(-5) |
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Linq; | |
using System.Reflection; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Threading.Tasks; |