This file contains 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
function executeOnPageSpace(code){ | |
// create a script tag | |
var script = document.createElement('script') | |
script.id = 'tmpScript' | |
// place the code inside the script. later replace it with execution result. | |
script.textContent = | |
'document.getElementById("tmpScript").textContent = JSON.stringify(' + code + ')' | |
// attach the script to page | |
document.documentElement.appendChild(script) |
This file contains 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
/* | |
Invalid data will cause the server to silently reject your POST request. | |
Analyze the POST request on form submission via Chrome Dev tools. | |
*/ | |
(async () => { | |
// create a form data object | |
let form = new FormData() |
This file contains 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/perl -l | |
# wvdiald.pl - Auto connect USB modems on Linux | |
# Author: naveenk <dndkumarasnghe@gmail.com> | |
# License: MIT | |
# Make sure you have wvdial and usb-modeswitch installed. Fill the connection parameters below. | |
# Run this as root. Add "perl /path/to/wvdiald.pl" to /etc/rc.local to make this a service | |
######################### CHANGE AS NEEDED ################################ | |
# connection parameters |
This file contains 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/perl | |
my $path = "/folder/to/monitor"; | |
my $mailCMD = "/usr/bin/msmtp"; | |
my $mailTo = 'you@gmail.com'; | |
chdir $path; | |
my @files = `du -hs * | cut -f2`; | |
my @actualSizes = `du -hs * | cut -f1`; | |
my @apparentSizes = `du -hs --apparent-size * | cut -f1`; |
This file contains 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
/* | |
reads a file upwards from the given 'startPosition' to the specified length and | |
returns an object with the lines and the final position read | |
if 'startPosition' is not specified it will be the very bottom of the file | |
*/ | |
async function readFileBottomUp(filename, length, startPosition) { | |
return new Promise((resolve, reject) => { | |
// file does not exist |
This file contains 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
const CACHE_VERSION = 'cache-v1' // increment this when you update the web site | |
const filesToCache = [ | |
"./index.html", | |
"./path/an/image.png", | |
// add more static assets to cache | |
] | |
self.addEventListener( | |
'install', |
This file contains 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
// go to the course page, press F12 and run this code in Java Script console. | |
// once done you get a list of video download links. Right click and save them or, | |
// download all at once with a tool of your choice (e.g. Chrome Simple Mass Downloader) | |
(async () => { | |
let SELECTOR_CHAPTER_EXPANDERS = '.classroom-toc-chapter__toggle' | |
let SELECTOR_LESSONS = '[data-control-name="toc_item"]' | |
let VIDEO_LOAD_WAIT = 3000 | |
// expand chapters on sidebar except the first |
This file contains 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
// CORS policies apply | |
async function download(url, filename){ | |
let res = await fetch(url) | |
let blob = await res.blob() | |
let a = document.createElement("a"); | |
a.href = URL.createObjectURL(blob) | |
a.download = filename; | |
a.click(); | |
} |
This file contains 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
getMACAddress() { | |
let vmMACPrefixes = [ | |
"00:50:56", | |
"00:0C:29", | |
"00:05:69", | |
"00:1C:14", | |
"0A:00:27", | |
"00:03:FF", | |
"00:1C:42", | |
"00:0F:4B", |
This file contains 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
<style> | |
.switch input{ | |
display: none; | |
} | |
.switch label{ | |
background-color: grey; | |
} | |
.switch input:checked + label{ | |
background-color: red; | |
} |
OlderNewer