I hereby claim:
- I am mavaddat on github.
- I am mavaddat (https://keybase.io/mavaddat) on keybase.
- I have a public key whose fingerprint is A0F1 C894 5FA0 3F0A 40AB B121 9667 69C3 1FD6 37A1
To claim this, I am signing this object:
#!/bin/bash | |
LOG="/path_to_save_logs" | |
echo "Start backup web `date`" >> $LOG | |
cd /folder_to_save | |
FECHAF=`date +%Y.%m.%d` | |
mkdir $FECHAF | |
cd $FECHAF | |
FECHA=`date +%-m-%-d-%Y` |
'---------------------------------------------------- | |
' Code by Ricardo Drizin (contact info at http://www.drizin.com.br) @Drizin | |
'---------------------------------------------------- | |
Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) | |
Option Explicit | |
'--------------------------------------------------------------------- | |
' This method closes ActiveInspectors if any. | |
' All importing is based on the assumption that the EML | |
' is opened by shell and we can refer to it through the ActiveInspector |
# Get the ID and security principal of the current user account | |
$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent() | |
$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID) | |
# Get the security principal for the Administrator role | |
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator | |
# Check to see if we are currently running "as Administrator" | |
if ($myWindowsPrincipal.IsInRole($adminRole)) |
#Requires -RunAsAdministrator | |
Stop-Service -Name @("bits","wuauserv","appidsvc","cryptsvc") | |
del "$env:ALLUSERSPROFILE\Application Data\Microsoft\Network\Downloader\qmgr*.*" | |
if(Test-Path variable:global:errs) {Remove-Variable -Name @("errs") -ErrorAction SilentlyContinue } #$err = $null | |
$errs = [System.Collections.ArrayList](@{}) | |
function Start-Backup { | |
param([string[]]$paths = @("$env:SystemRoot\system32\catroot2","$env:SystemRoot\SoftwareDistribution")) | |
foreach($path in $paths){ | |
$bak = "$($path).bak" | |
if((Test-Path -PathType Any $bak) -and (Test-Path -PathType Any $path)){ |
# Requires PSParseHTML Module for ConvertFrom-HTML | |
# Load ConvertTo-Slug from Gist | |
iex (New-Object -TypeName System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/mavaddat/0bbed730a4c10a066d75894a7611d730/raw/4a37c2ec4f0d33ff2bbb1a224b0b901063dce871/slugify.ps1') | |
mkdir "$env:TEMP\Calibre\" | |
foreach($file in Get-ChildItem -Path $env:USERPROFILE\Downloads\Books\ | Where-Object -Property Length -GT 0){ | |
$libgen = Invoke-RestMethod -Method Get -Uri "https://libgen.is/book/index.php?md5=$($file.BaseName)" | ConvertFrom-HTML -Engine AngleSharp | |
$title = $libgen.QuerySelector("body > table > tbody > tr > td > b > a").InnerHtml | |
$authors = $libgen.QuerySelector("body > table > tbody > tr > td:nth-child(2) > b").InnerHtml -replace '\([^\)]+\)', '' -replace '\s*[;,]\s*',' & ' | |
$ext = $libgen.QuerySelector("body > table > tbody > tr:nth-child(11) > td:nth-child(4)").InnerHtml | |
$file | Copy-Item -Destination "$env:TEMP\Calibre\$(ConvertTo-Slug -Text $title -CapitalizeFirstLetter -Delimiter ' ') - |
Set-Location C:\CalibrePortable\Calibre\ | |
$calibreNS = @{ 'dc' = 'http://purl.org/dc/elements/1.1/' | |
'calibre' = 'http://calibre.kovidgoyal.net/2009/metadata' | |
} | |
$formatLessBookIds = [int[]](&.\calibredb.exe search 'formats:false and (identifiers:"=isbn:")' --library-path="..\Calibre Library\" | ForEach-Object { $_ -split ',' }) | |
$formatLessBooks = Import-Clixml -Path .\formatLessBooks.xml | |
if($null -eq $formatLessBooks -or $null -eq $formatLessBooks.Hash -or $formatLessBooks.Hash -ne $formatLessBookIds.GetHashCode()) | |
{ | |
$formatLessBooks = @{ Hash = ($formatLessBookIds.GetHashCode());Books = ($formatLessBookIds | ForEach-Object { [xml](&.\calibredb.exe show_metadata --as-opf $PSItem --library-path="..\Calibre Library\") } | Where-Object { [string]::IsNullOrWhiteSpace((&.\calibredb.exe search formats:true title:`"$(Select-Xml -Xml $PSItem -Namespace $calibreNS -XPath '//dc:title' | ForEach-Object { $_.Node.InnerXml })`" author:`"$((Select-Xml -Xml $PSItem -Namespace $calibreNS -XPath '//dc:creator' |
I hereby claim:
To claim this, I am signing this object:
$ebookLibraryPath = '.\OneDrive\Documents\Ebook Library\' | |
Function Get-Empties { | |
PARAM($targetPath) | |
Return Get-ChildItem -Path $targetPath -Recurse | Where { $_.PsIsContainer -eq $true } | Where { $_.GetDirectories().Count -eq 0 -and ($_.GetFiles().Count -eq 0) -or ($_.GetFiles().Count -eq 1 -and $_.GetFiles().Name -match "(?i)(.*?)\.opf$")} | |
} | |
$failed = @{} | |
$toEmpty = Get-Empties $ebookLibraryPath | |
Function Write-Log { | |
Param ( [parameter(Mandatory=$true, |
#Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; Invoke-Expression $($(Invoke-RestMethod -Method Get -Uri 'https://api.github.com/gists/30e1c0cb20f6a1800e3ed7f728a69763').files.'removeNumerationFromWifiNames.ps1'.content) | |
if (-not $(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { | |
$Host.UI.WriteErrorLine("You need to be running PowerShell as an administrator to run this script. Please open an admin PowerShell session and try again.") | |
exit | |
} | |
$scriptName = 'removeNumerationFromWifiNames.ps1' | |
try { | |
if (Get-Command -Name Get-EventLog -CommandType Function -ErrorAction Ignore) { | |
Get-EventLog -LogName Application -Source $scriptName -ErrorAction Ignore |
# Download latest dotnet/codeformatter release from github | |
$repo = "dotnet/codeformatter" | |
$file = "CodeFormatter.zip" | |
$releases = "https://api.github.com/repos/$repo/releases" | |
Write-Host Determining latest release | |
$tag = (Invoke-WebRequest $releases | ConvertFrom-Json)[0].tag_name |