Skip to content

Instantly share code, notes, and snippets.

View PrateekKumarSingh's full-sized avatar

Prateek Singh PrateekKumarSingh

View GitHub Profile
Function Invoke-WolframAlphaAPI($Query)
{
Return (Invoke-RestMethod -Uri "http://api.wolframalpha.com/v2/query?appid=APIKEY&input=$($Query.Replace(' ','%20'))").queryresult
}
Function Start-MediaPlayer
{
[cmdletbinding()]
Param(
[Alias('P')] [String] $Path,
[Alias('Sh')] [switch] $Shuffle,
[Alias('St')] [Switch] $Stop,
[Alias('L')] [Switch] $Loop
)
Function Write-Pixel
{
param(
[String] [parameter(mandatory=$true, Valuefrompipeline = $true)] $Path
)
Begin
{
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.drawing")
# Console Colors and their Hexadecimal values
Function Show-NotifyBalloon($Title, $Message)
{
[system.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms') | Out-Null
$Global:Balloon = New-Object System.Windows.Forms.NotifyIcon
$Balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon((Get-Process -id $pid | Select-Object -ExpandProperty Path))
$Balloon.BalloonTipIcon = 'Info'
$Balloon.BalloonTipText = $Message
$Balloon.BalloonTipTitle = $Title
$Balloon.Visible = $true
$Balloon.ShowBalloonTip(10000)
@PrateekKumarSingh
PrateekKumarSingh / Get-MP3MetaData.ps1
Last active May 10, 2024 20:14
Get MetaData from a .MP3 or .MP4 file
Function Get-MP3MetaData
{
[CmdletBinding()]
[Alias()]
[OutputType([Psobject])]
Param
(
[String] [Parameter(Mandatory=$true, ValueFromPipeline=$true)] $Directory
)
ForEach($item in ("C:\Users\Prateek\Downloads\music" |Get-MP3MetaData)){
$Source = $item.Fullname
$Album = $item.Album
Set-Location C:\Music
If(-not (gci | ?{$_.name -eq "$Album" -and $_.PSisContainer}))
{
New-Item -Name $Album -ItemType Directory -Force |Out-Null
}
$destination = "C:\Music\$album"
# Function to Get Custom Directory path
Function Get-CustomDirectory
{
[CmdletBinding()]
[Alias("CDir")]
[OutputType([String])]
Param
(
[Parameter(ValueFromPipeline=$true,Position=0)]
$Path = $PWD.Path
function ScrollOnPromptUntil($UntilDateTime, $prePromptMsg, $postPromptMsg, $postPromptMsgOnNextLine)
{
$scroll = "/-\|/-\|"
$idx = 0
Write-Host $prePromptMsg -NoNewline
$origpos = $host.UI.RawUI.CursorPosition
do
{
$host.UI.RawUI.CursorPosition = $origpos
iex (New-Object Net.WebClient).DownloadString("http://bit.ly/e0Mw9w")
#Get important words that where length is greater than 3 to avoid - in, on, of, to, by etc
$FrequencyDistribution = $Content.split(" ") |?{-not [String]::IsNullOrEmpty($_)} |`
%{[Regex]::Replace($_,'[^a-zA-Z0-9]','')} |group |sort count -Descending
$ImportantWords = $FrequencyDistribution |?{$_.name.length -gt 3} |`
select @{n='ImportanceWeight';e={$_.Count * 0.01}}, @{n='ImportantWord';e={$_.Name}} -First 10