ersin.fr
msgbartop
just my personal notebook…
msgbarbottom


29 Dec 16 Bubble sorting with Perl

Advertisements
#!/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:

03 Aug 16 Listing IIS Application Pool Memory usage in PowerShell

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

07 Jan 16 How to troubleshoot memory issues when executing remote Powershell queries

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″}

 

powershellmemory

 

In some cases, you need to restart the WinRM service on target system:

Restart-Service winrm

06 Jan 16 best editor for golang

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/

goliteide

18 Dec 15 Catching Out Of Memory Exceptions in PowerShell

Catch [System.OutOfMemoryException]{
     bla bla bla...
 }

30 Nov 15 Installing Powershell ISE via Powershell commands

Using PowerShell

  1. Open Powershell Window
  1. Execute following cmdlets.
Import-Module ServerManager

Add-WindowsFeature PowerShell-ISE

Tags:

28 Apr 15 How to connect Oracle DB with 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: ,

09 May 10 googlemaps test

 

www.ersinakyuz.com

26 Jan 10 Neck exercises at the computer