#!/usr/bin/perl use strict; use Data::Dumper; sub swap{ @_[ 0, 1 ] = @_[ 1, 0 ]; } sub bsort{ my (@a) = @_; for my $j (0 .. $#a){ for my $i (0 .. $#a - 1 - $j ){ swap $a[$i], $a[ $i + 1 ] if $a[$i] > $a[ $i + 1 ]; } } \@a; } #Testing my $a=1; my $b=3; my @c=(3,2,1,4); print "First:".Dumper(@c); print "\nLatest:".Dumper(bsort(@c));
Tags: perl
Open Powershell as an Administrator on the web server, then run:
$apmem= gwmi -ComputerName localhost -NS 'root\WebAdministration' -class 'WorkerProcess' | select PSComputerName, AppPoolName,ProcessId , @{n='RAM';e={ [math]::round((Get-Process -Id $_.ProcessId -ComputerName $_.PSComputerName).WorkingSet / 1Mb) }} | sort RAM -Descending | ft -AutoSize echo $apmem
You should see something like:
PS C:\Windows\system32> C:\scripts\appool.ps1 PSComputerName AppPoolName ProcessId RAM -------------- ----------- --------- --- MYSERVER01 ersinakyuz.com 2352 1150 MYSERVER01 kutuphaneleriseviyorum.org 6184 729 MYSERVER01 perlmonks.com 3444 646
If you get Get-WmiObject : Could not get objects from namespace root/WebAdministration. Invalid namespace then you need to enable the IIS Management Scripts and Tools feature using:
ipmo ServerManager Add-WindowsFeature Web-Scripting-Tools
If you are receiving “Processing data for a remote command failed with the following error message: The WSMan provider” message from the PS Queries (e.g. on the Nagios)
All you have to do is log on the target computer, and run powershell with Administrator Rights. Then you can increase Powershell memory with below commands
You can get current memory size with get-item:
Get-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB
And here is the command for change the value:
Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 250 -Force
or
winrm set winrm/config/winrs @{MaxMemoryPerShellMB=”512″}
In some cases, you need to restart the WinRM service on target system:
Restart-Service winrm
I was looking for a good (and free) GoLang IDE. Then I found fully opensource LITEIDE. It supports code completion and syntax highlighting. Also has a debugger which running in background.
You can download it from below link:
http://code.google.com/p/golangide/
Catch [System.OutOfMemoryException]{ bla bla bla... }
Using PowerShell
Import-Module ServerManager Add-WindowsFeature PowerShell-ISE
Tags: powershell
# Load the ODP assembly [Reflection.Assembly]::LoadFile("C:\oracle\11.2.0\client_2\odp.net\bin\4\Oracle.DataAccess.dll")|Out-Null
# #vars&cons $stations =@{ "424"="Istanbul"; "421"="İzmir" } $dbuser="user" $dbpasswd="password"
connect to Oracle
$constr = " User Id=$dbuser; Password=$dbpasswd; Data Source=CITIES " $conn= New-Object Oracle.DataAccess.Client.OracleConnection($constr) $conn.Open()
Create a datareader for a SQL statement
$sql="select stationid from CITIES.SWITCHPARAMETER where switchid = '2' " $command = New-Object Oracle.DataAccess.Client.OracleCommand( $sql,$conn) $reader=$command.ExecuteReader()
Write out the results
# while ($reader.read()) { $stationID=$reader.GetString(0) $stationname=$stations.Get_Item($stationID) Write-Host " Station ID: $stationID ($stationname)" }
Tags: oracle, powershell