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
#!/bin/bash | |
now=$(date +"%T") | |
echo "Starting backup at ${now}..." | tee -a /root/megabackup.log | |
SERVER="servername" | |
DAYS_TO_BACKUP=7 | |
WORKING_DIR="/root/backup_tmp_dir" | |
BACKUP_MYSQL="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
# "enumerate_bin("1xx000") generates a vector of all binary strings: c("100000","101000","110000","111000") | |
enumerate_bin <- function(input_str) { | |
strlen<-nchar(input_str) | |
for(i in 1:strlen) { | |
if(tolower(substr(input_str,i,i))=="x") { | |
str0 <- paste(substr(input_str,1,i-1),"0",substr(input_str,i+1,strlen),sep="") | |
str1 <- paste(substr(input_str,1,i-1),"1",substr(input_str,i+1,strlen),sep="") | |
return(c(enumerate_bin(str0), enumerate_bin(str1))) | |
} | |
} |
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
// ==UserScript== | |
// @name Fastmail - email body width | |
// @description Fix width of emails being wider than screen | |
// @author Will Jobs | |
// @id fastmail-emailwidth | |
// @include https://www.fastmail.com/mail/* | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js | |
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js | |
// @grant GM_addStyle | |
// ==/UserScript== |
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 sumdollars(input) { | |
if(input.map) { | |
return input.map(sumdollars); | |
} else { | |
if(input.length === 0) {return 0;} | |
if(typeof input === 'number') {return input;} | |
var strArr = input.split('$').slice(1); | |
var mysum = 0; | |
for(i=0; i < strArr.length; i++) { | |
mysum += parseFloat(strArr[i].split(/[^0-9\.]+/)[0]); |
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
(netsh wlan show profiles) | Select-String "\:(.+)$" | %{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name="$name" key=clear)} | Select-String "Key Content\W+\:(.+)$" | %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -AutoSize |
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 getMonthText(val, short) { | |
if(val !== parseInt(val,10)) { | |
return ""; | |
} | |
if(val < 1 || val > 12) { | |
return ""; | |
} | |
var x = ""; | |
switch(val) { | |
case 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
overall_sum = 0; | |
$('.thin.list-unstyled.lesson-list-condensed').each(function(idx, el) { | |
sum = 0; | |
$(el).find('.lesson-item').each( | |
function(idx2, inner_el) { | |
time = $(inner_el).find('.lesson-item-subtitle').text(); | |
time = time.split(':'); | |
if(time.length > 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
Public Function countDifferences(str1 As String, str2 As String) As Integer | |
Dim i As Integer | |
If Len(str1) <> Len(str2) Then | |
countDifferences = -1 | |
Exit Function | |
End If | |
countDifferences = 0 | |
For i = 1 To Len(str1) | |
If Mid(str1, i, 1) <> Mid(str2, i, 1) Then |
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 YNABAccounts(accessToken, budgetId) { | |
const accounts = _getBudgetAccounts(accessToken, budgetId); | |
if(accounts == null) { | |
return null; | |
} | |
const columns = ["Name", "Type", "Budget", "Closed", "Balance"]; | |
const rows = accounts.map(function (acc) { | |
return [ |
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
# allows importing of ModuleB from ModuleA within the same subdirectory, when the code is run from a parent directory | |
# see https://stackoverflow.com/a/49375740/1102199 | |
import os | |
import sys | |
sys.path.append(os.path.dirname(os.path.realpath(__file__))) |
OlderNewer