Skip to content

Instantly share code, notes, and snippets.

View jtuttas's full-sized avatar

jtuttas jtuttas

  • http://www.mmbbs.de
View GitHub Profile
do {
[int32]$zstart = read-host "Startzahl"
} while (($zstart % 2) -eq 0)
do {
[int32]$zende = read-host "Endezahl"
} while (($zende % 2) -eq 0)
[int32]$summe = 0
for ($i=$zstart+2;$i -le $zende -2;$i+=2) {
$hmax = read-host Maximale Länge für Hypothenuse eingeben!;
for ($j=1; $j -le $hmax; $j++){
for ($k=1; $k -lt $j; $k++){
$h= [math]::Sqrt(($j * $j)+($k * $k));
if ($h % 1.0 -eq 0.0 -and $h -le $hmax){
write-host $h + $j + $k;
}
}
}
@jtuttas
jtuttas / 0_reuse_code.js
Created May 7, 2014 14:42
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
param([String]$ips,[String]$subs)
$sub=$subs.Split(".") # Array Oktette der Subnezmaske
$ip=$ips.Split(".") # Array Oktelle der Netzip
# Netz IP bestimmen
$netz=0,0,0,0
for ($i=0; $i -lt 4;$i++) {
$netz[$i]=$ip[$i] -band $sub[$i]
}
$imSubnetz=$true
$aktuelleIP=0,0,0,0
@jtuttas
jtuttas / udpClient.ps1
Created January 22, 2014 13:50
UDP Client / Server
$port=2021
$endpoint = new-object System.Net.IPEndPoint ([IPAddress]"10.13.6.100",$port)
$udpclient=new-Object System.Net.Sockets.UdpClient
$b=[Text.Encoding]::ASCII.GetBytes('Is anyone there!')
$bytesSent=$udpclient.Send($b,$b.length,$endpoint)
$udpclient.Close()
@jtuttas
jtuttas / Netzip.ps1
Created September 27, 2013 15:42
Netz-IP's aus zweidimensionalen Array
$rechnerliste = (("NAS",192,168,178,1),("Desktop PC1",192,168,178,19),("Desktop PC2",192,168,178,22),("Drucker",192,168,118,22),("WebServer",192,168,118,9),("Fileserver",192,168,118,56))
$sub1= Read-Host ("1. Oktett Subnetzmaske")
$sub2=Read-Host ("2. Oktett Subnetzmaske")
$sub3=Read-Host ("3. Oktett Subnetzmaske")
$sub4=Read-Host ("4. Oktett Subnetzmaske")
$n1=$rechnerliste[0][1] -band $sub1
$n2=$rechnerliste[0][2] -band $sub2
$n3=$rechnerliste[0][3] -band $sub3
$n4=$rechnerliste[0][4] -band $sub4
Write-Host ("Netz Adresse von "+$rechnerliste[0][0]+" ist $n1.$n2.$n3.$n4")
@jtuttas
jtuttas / energie.ps1
Last active December 23, 2015 12:19
Energieverbrauch bestimmen
Param(
[String]$file
)
function check ([String]$ipadress) {
#param ($ipadress)
$ipadress -match "(\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b)"
}
if ($file -ne "") {
$dir = Get-Location
@jtuttas
jtuttas / ausnahme.ps1
Last active September 26, 2016 13:55
Ausnahmebehandlung mit Datenbank
#Datenbank Ausnahmebahandlung
$ok=$false
do {
try {
$connString = "Server=localhost;Uid=tuttas;Pwd=joerg123;database=wol";
# load MySQL driver and query database
[void][system.reflection.Assembly]::LoadFrom("MySQL.Data.dll");
$conn = New-Object MySql.Data.MySqlClient.MySqlConnection;
$conn.ConnectionString = $connString;
$conn.Open();
@jtuttas
jtuttas / connect.ps1
Created July 5, 2013 11:55
Verbindung von Powershell zu einer MySql Datenbank
$connString = "Server=localhost;Uid=tuttas;Pwd=joerg123;database=wol";
# load MySQL driver and query database
[void][system.reflection.Assembly]::LoadFrom("MySQL.Data.dll");
$conn = New-Object MySql.Data.MySqlClient.MySqlConnection;
$conn.ConnectionString = $connString;
$conn.Open();
@jtuttas
jtuttas / nebenkosten.ps1
Created May 13, 2013 13:10
Nebenkosten berechnen wie in IHK Prüfung 2012
[xml] $xml = gc "Nebenkosten.xml"
[float]$sum=0;
foreach($node in $xml.GetElementsByTagName("Haus"))
{
$max=$node.childnodes.count
$item=$node.FirstChild
for ($i=0;$i -lt $max;$i++) {
$sum+=[float]$item.InnerText
$item=$item.NextSibling
}