Skip to content

Instantly share code, notes, and snippets.

@gregelin
Last active March 17, 2021 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregelin/5201bd57aa669cb2263464e2037f071b to your computer and use it in GitHub Desktop.
Save gregelin/5201bd57aa669cb2263464e2037f071b to your computer and use it in GitHub Desktop.
WSOA
<html>
<head>
<style>
body { padding-top:24px; font-size:24pt; text-align:center; border:8px solid green; }
</style>
<script>
var i = 1; // set your counter to 1
function myLoop() { // create a loop function
setTimeout(function() { // call a 3s setTimeout when the loop is called
window.location = "file.html";
console.log('page reloaded'); // your code here
i++; // increment the counter
if (i < 100) { // if the counter < 10, call the loop function
myLoop(); // .. again which will trigger another
} // .. setTimeout()
}, 3000)
}
myLoop(); // start the loop
</script>
</head>
<body>
The File
</body>
</html>
<html>
<head>
<style>
body { padding-top:24px; font-size:24pt; text-align:center; border:8px solid red; }
</style>
<script>
var i = 1; // set your counter to 1
function myLoop() { // create a loop function
setTimeout(function() { // call a 3s setTimeout when the loop is called
window.location = "file.html";
console.log('page reloaded'); // your code here
i++; // increment the counter
if (i < 100) { // if the counter < 10, call the loop function
myLoop(); // .. again which will trigger another
} // .. setTimeout()
}, 3000)
}
myLoop(); // start the loop
</script>
</head>
<body>
Reset
</body>
</html>
# Python script
import sys, json, time
oscal = json.load(sys.stdin)
content = oscal['system-security-plan']['system-implementation']['components']['8a37089d-1a4f-4aa3-9e39-aa064c71d521']['title']
# Conditionally set border_color
if 1 == 1:
border_color = 'green'
else:
border_color = 'red'
html = f"""<html>
<head>
<style>
body {{ padding-top:24px; font-size:24pt; text-align:center; border:8px solid {border_color}; }}
</style>
<script>
var i = 1; // set your counter to 1
function myLoop() {{ // create a loop function
setTimeout(function() {{ // call a 3s setTimeout when the loop is called
window.location = "file.html";
console.log('page reloaded'); // your code here
i++; // increment the counter
if (i < 100) {{ // if the counter < 10, call the loop function
myLoop(); // .. again which will trigger another
}} // .. setTimeout()
}}, 3000)
}}
myLoop(); // start the loop
</script>
</head>
<body>
{content}
</body>
</html>"""
# Save content to file
f = open('file.html', 'w')
f.write(html)
f.close()
# Define file path
$fp = "C:\Users\grege\wsoa"
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = $fp
$watcher.EnableRaisingEvents = $true
$action =
{
$path = $event.SourceEventArgs.FullPath
$changetype = $event.SourceEventArgs.ChangeType
Get-Content -Raw -Path '.\ssp_v1_oscal_json (1).json' | python wsoa.py | Wait-Process; start 'file.html'Write-Host "$path was $changetype at $(get-date)"
}
Register-ObjectEvent $watcher 'Created' -Action $action
# older action
$action =
{
$path = $event.SourceEventArgs.FullPath
$changetype = $event.SourceEventArgs.ChangeType
Write-Host "$path was $changetype at $(get-date)"
}
# oneliners
Get-Content -Raw -Path '.\ssp_v1_oscal_json (1).json' | python -c "import sys, json; oscal = json.load(sys.stdin); print(oscal['system-security-plan']['system-implementation']['components']['8a37089d-1a4f-4aa3-9e39-aa064c71d521']['title'])"
Get-Content -Raw -Path '.\ssp_v1_oscal_json (1).json' | python -c "import sys, json; oscal = json.load(sys.stdin); content = oscal['system-security-plan']['system-implementation']['components']['8a37089d-1a4f-4aa3-9e39-aa064c71d521']['title']; f = open('file.html', w); f.write(content); f.close()" | start 'file.html'
# oneliner using python script
# wsoa.py will change content of the file.
Get-Content -Raw -Path '.\ssp_v1_oscal_json (1).json' | python wsoa.py | Wait-Process; start 'file.html'
# change content of file
# Open file in browser
start 'file.html'
# Set WallPaper
Function Set-WallPaper($value)
{
Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value $value
rundll32.exe user32.dll, UpdatePerUserSystemParameters
}
Set-WallPaper -value "path to wallpaper"
Set-WallPaper -value "path to wallpaper"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment