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
// Recursive function to flatten out a multi-dimensional array | |
function FlattenArray(arr) { | |
var newArr = []; | |
for (var i = 0; i < arr.length; i++) { | |
// Go through each elements of array, if element is array, call this function with it as parameter and then concatenate | |
// with the new array, else just add the element to the new array, then return the new array in the end | |
if (Array.isArray(arr[i])) { | |
newArr = newArr.concat(FlattenArray(arr[i])); | |
} | |
else { |
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
// Prints a Pascal Triangle of 'n' no. of lines | |
function PascalTriangle(n) { | |
var arr = []; | |
for (var i = 0; i < n; i++) { | |
// Create an array | |
arr[i] = []; | |
// Mark 1st and last element as 1 | |
arr[i][0] = 1; | |
arr[i][i] = 1; |
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
Dim speaks, speech | |
If (Minute(Time()) = 0) Then | |
speaks = "It is now " & (((Hour(Time()) + 11) Mod 12) + 1) & " O' clock" | |
Else | |
speaks = "The time is now " & (((Hour(Time()) + 11) Mod 12) + 1) & " " & Minute(Time()) | |
End If | |
Set speech = CreateObject("sapi.spvoice") | |
speech.Speak speaks |
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
// Get all sentences | |
var sentences = document.body.innerText.split("."); | |
// Remove all sentences with newline characters in them since they're likely tags or sidebar data | |
for (i=sentences.length - 1; i>-1; i--) | |
{ | |
if (sentences[i].trim().indexOf("\n") !== -1) | |
{ | |
sentences.splice(i,1); | |
} |
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
-- MarI/O by SethBling | |
-- Feel free to use this code, but please do not redistribute it. | |
-- Intended for use with the BizHawk emulator and Super Mario World or Super Mario Bros. ROM. | |
-- For SMW, make sure you have a save state named "DP1.state" at the beginning of a level, | |
-- and put a copy in both the Lua folder and the root directory of BizHawk. | |
if gameinfo.getromname() == "Super Mario World (USA)" then | |
Filename = "DP1.state" | |
ButtonNames = { | |
"A", |
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
# Watch a file changes in the current directory, | |
# Execute all tests when a file is changed or renamed | |
$watcher = New-Object System.IO.FileSystemWatcher | |
$watcher.Path = Get-Location | |
$watcher.IncludeSubdirectories = $true | |
$watcher.EnableRaisingEvents = $false | |
$watcher.NotifyFilter = [System.IO.NotifyFilters]::LastWrite -bor [System.IO.NotifyFilters]::FileName | |
while($true) |
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
# How to use: | |
# | |
# Dependencies - scort, imagemagick, i3lock | |
# | |
# Just place a lock.png in your home folder to overlay whatever you want | |
#!/bin/bash | |
scrot -e 'convert -blur 0x3 $f ~/lockbg.png' | |
convert -gravity center -composite ~/lockbg.png ~/lock.png ~/lockfinal.png | |
i3lock -i ~/lockfinal.png -p default -e |
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
if (Object.defineProperty && Object.getOwnPropertyDescriptor && Object.getOwnPropertyDescriptor(Element.prototype, "textContent") && !Object.getOwnPropertyDescriptor(Element.prototype, "textContent").get) { | |
(function() { | |
var innerText = Object.getOwnPropertyDescriptor(Element.prototype, "innerText"); | |
Object.defineProperty(Element.prototype, "textContent", | |
{ | |
get: function() { | |
return innerText.get.call(this); | |
}, | |
set: function(s) { | |
return innerText.set.call(this, s); |
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 AfterRunning { | |
param ( | |
[String] $Process | |
) | |
while ((Get-Process $Process -ErrorAction SilentlyContinue | Select-Object -ExpandProperty ProcessName) -ne $null) { | |
Start-Sleep -Seconds 2 | |
Write-Host "Process still running..." | |
} | |
} |
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
#Create array of file list from a directory. | |
$arr = (dir).FullName #Get all files | |
$arr = (dir *.log).FullName #Get files of .log extension | |
#Get headers of file to identify its format. | |
Get-Content -Path FilePath -Encoding Byte -TotalCount 4 | |
#Download File via http. | |
Invoke-WebRequest "http://filepath/file.jpg" -OutFile "C:\LocalPath\filename.jpg" |