Friday, June 14, 2019

gpio Raspberry

gpio read 23

php script test.php (www-data zu gruppe gpio hinzufügen )

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Schalter</title>
</head>
GPIO 23 schalten:
<form method="get" action="pool.php">
<input type="submit" value="Licht ein" name="Lichtein">
<input type="submit" value="Licht aus" name="Lichtaus">
</form>
<?php
$modeon18 = exec("gpio mode 23 out");
if(isset($_GET["Lichtein"])){
$val = exec("gpio write 23 1");
echo "Licht an";
}
else if(isset($_GET["Lichtaus"])){
$val = exec("gpio write 23 0");
echo "Licht aus";
}
echo "<hr/>";
$val = exec("gpio read 23");
echo " gpio23 = $val ";
echo " <hr />"
?>
</body>
</html>

Friday, June 07, 2019

ownlcloud auf raspberry

Vorbedingungen

apt install -y apache2 mariadb-server libapache2-mod-php7.0 \
    php7.0-gd php7.0-json php7.0-mysql php7.0-curl \
    php7.0-intl php7.0-mcrypt php-imagick \
    php7.0-zip php7.0-xml php7.0-mbstring php-intl

anschließend rebooten

download und entpacken owncloud 

neueste version auf download page)
wget https://download.owncloud.org/community/owncloud-10.2.0.zip

das zip file dann nach /var/www/html verschieben und entpacken:
unzip -q owncloud-10.2.0.zip

owncloud data verzeichnis vorbereiten:
mkdir /var/www/html/owncloud/data
chown www-data:www-data /var/www/html/owncloud/data
chmod 750 /var/www/html/owncloud/data




hat nicht ganz funktioniert:

wget -nv https://download.owncloud.org/download/repositories/production/Debian_9.0/Release.key -O Release.key
apt-key add - < Release.key

echo 'deb http://download.owncloud.org/download/repositories/production/Debian_9.0/ /' > /etc/apt/sources.list.d/owncloud.list
apt-get update
apt-get install owncloud-files

ssms sql server management studio pfad

"C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\Ssms.exe"


Thursday, May 23, 2019

configure grub

sudo nano /etc/default/grub
sudo update-grub

Sunday, May 19, 2019

wordpress Export/Import (einrichten der seite)

seiten importieren (Import, wordpress Importer installieren, starten, xml fiole
theme installieren (z.b. donovan)
Apeareance-Customize / HomepageSettings/StaticPage/Hauptseite=
Apeareance-Customize/Menu

WPF Binding ToolTip and ContextMenu with PlacementTarget

ToolTip und Contextmenü haben keinen übergeordneten visuellen Baum, da sie in eigenen Fenstern angezeigt werden

Friday, May 10, 2019

linux mysql basics

linux: apt install mysql-server
starten wenn nicht gestartet: /etc/init.d/mysql start

mysql -u user

show databases;

SELECT User FROM mysql.user; 


CREATE USER 'da'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'da'@'localhost' WITH GRANT OPTION;

FLUSH PRIVILEGES;

Monday, April 15, 2019

Razore Asp.net Core


  1. https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/razor-pages-start?view=aspnetcore-3.0&tabs=visual-studio
  2. neue Web App anlegen (asp.net core web app, Type Web Application)
  3. starten & testen
  4. statische Seiten in wwwroot hinufügen
  5. https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/model?view=aspnetcore-3.0&tabs=visual-studio
  6. Model Folder und Model Klasse Test.cs hinzufügen
  7. in Pages Folder Test hinzu
  8. rechte Maustaste auf Foldfer test, Hinzufügen, nues Gerüstelement
  9. Razor Pages EF (CRUD) hinzufügen
  10. Modelkalsse Test.cs auswählen und bei Context auf + drücken => neuer Context wird erzeugt
  11. RUN: Zu Root /Test hinzufügen um generierte Seiten anzuzeigen

Sunday, April 14, 2019

Citadel: Apache und webcit citadel Ports



server starten: sudo service citadel start
neu konfigurieren: sudo /usr/lib/citadel-server/setup



/etc/default/webcit
/etc/apache2/ports.conf
#service webcit restart && service apache2 restart

wennes nicht geht:
updaten, dann:
apt-get install build-essential curl g++ gettext shared-mime-info libssl-dev zlib1g-dev
und
curl http://easyinstall.citadel.org/install | bash

Friday, April 12, 2019

nützliche Raspi Raspberry Software

sudo apt install:

lynx #textbrowser
midori #old rasbian browser, fast light

xrdp #remote desktop server
rdesktop # remote desktop client

Thursday, March 28, 2019

wpf binding examples

Satic Resource und Converter:

Width="{Binding Source ={StaticResource ColorPickerColumnDefaultWidth}, Converter={StaticResource DoubleToGridLengthConverter},Mode=OneWay}" />

Dependency property in User Control:
Text="{Binding TitleText, ElementName=MyUserControl}"


<TextBlock Text="{Binding Name, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}} }"/>
<TextBlock Text="{Binding Name, ElementName=UcPaneHeader}"/>

<TextBlock Text="{Binding Name, ElementName=PaneTitle}"/>

Thursday, March 21, 2019

asp.net core and EF (asp.net types: empty, API)

Connection Strings

InMemory Datenbank:

services.AddDbContext<TodoContext>(opt => opt.UseInMemoryDatabase("TodoList"));

LocalDb

aus https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/new-db?tabs=visual-studio

var connection = @"Server=(localdb)\mssqllocaldb;Database=EFGetStarted.AspNetCore.NewDb;Trusted_Connection=True;ConnectRetryCount=0";
    services.AddDbContext<BloggingContext>
        (options => options.UseSqlServer(connection));

leere Web App

Programm.cs startet Webhost mit class Startup und Methode Configure, z.b.: 

            app.Run(async (context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });

einfaches Webservice (API)

webApi Template Projekt erstellen - liefert value1, value2 durch ValuesController, der einfach auf GET Request mit Konstantem String antwortet, dazu genügen die Attribute:
    [Route("api/[controller]")] // antwortet auf SubDir mit Controllername (schneided Controller Suffix weg)
    [ApiController]

in Startup.cs: app.UseMvc();


füge Model Klasse und DbContext hinzu:

Model(s):

    public class TodoItem
    {
        public long Id { get; set; }
        public string Name { get; set; }
        public bool IsComplete { get; set; }
    }

DbContext:

public class TodoContext : DbContext
    {
        public TodoContext(DbContextOptions<TodoContext> options)
            : base(options)
        {
        }
        public DbSet<TodoItem> TodoItems { get; set; }
    }

in Startup.cs DbContext hinzufügen:
public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext<TodoContext>(opt => opt.UseInMemoryDatabase("TodoList"));
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }


Controller hinzufügen (rechte Maustaste auf Controller Ordner )

1)MVC-Controller leer
2) MVC Controller mit Ansichten unter Verwendung von EF
3) MVC Controller mit Lese/SchreibAktionen
4) API-Controller leer:
    [Route("api/[controller]")]
    [ApiController]
    public class EmptyController : ControllerBase
    {
    }
5) API-Controller mit Lese/Schreibaktionen:
fügt get, post,put und delete Methoden hinzu, unter Annahme einer id vom Typ int,, gibt string "value" zurück
6) API-Controller mit Aktionen unter Verwendung von EF:
in Maske Context und Modell Klasse auswählen => generiert API mit put, get usw.


Statische Files

schließlich jquery static file dass die api nutzt:
in Startup.onfigure:
            app.UseDefaultFiles();
            app.UseStaticFiles();



Wednesday, March 20, 2019

clean obj bin

Get-ChildItem .\ -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }

asp.net core EF core migrations

1) add a model
    public class TestEntity
    {
        public int Id { get; set; }

        public string TestString { get; set; }

    }

2) add a context
    public class TestContext1 : DbContext
    {
        DbSet<TestEntity> TestEntities { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
                optionsBuilder.UseSqlServer(@"Server=localhost\sqlexpress;Database=test;Trusted_Connection=True;");
            }
         

        }
    }

3) start Nuget Package Manager Console: ALT T N O
select the project with your model and context as start project
Add-Migration M0001
update-database

WICHTIG: Projekt mit Context muß als Startup projekt und in Nuget Manager Console ausgewählt sein ! Bei Asp.Net muß der Context auch in der Startup Klasse sein ...

asp.net core using existing db

https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/existing-db

1) in Packet-Manager-Console: Scaffold-DbContext "Server=localhost\sqlexpress;Database=test;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
=> erzeugt Context und EF Models
2) in Startup.cs Context regisitrieren:
services.AddDbContext<testContext>();

3) rechts click auf Controllers, Add Controller, MVC Controller mit Ansichten (Views) unter Verwendung von EF

4) Starten, und in adresszeile den Modellnamen hinzufügen

Monday, March 18, 2019

einfaches css beispiel

<link rel="stylesheet" type="text/css" href="style.css" />
<h1>header1</h1>
normal
<p style="color:green; font-weight: bold; ">absatz</p>

direkt im code: style="Eigenschaft:wert"

in style.css (einbinden mit link rel="stylesheet" type="text/css" href="style.css" )

h1 { color:red}

wordpress grundlagen

https://www.miss-webdesign.at/wordpress-grundlagen/

theme:
jedes jahr bringt wordpress ein neues theme raus - 2015 twentyFifteen stellt das menü in der sidebar als Baum dar, 2017 twentySeventeen bringt die menüpunkte nebeneinander

child theme:
neuen ordner in wp_content/themes mit parentTheme-child name und 3 dateien: style.css, functions.php und screenshot.png:

siteurls usw. in db in wp_options tabelle

define('FS_METHOD','direct');
chown www-data:www-data wordpress -R


wordpress auf linux

Apache, php installieren und testen:

sudo apt install apache2 php libapache2-mod-php -y
sudo service apache2 restart
cd /var/www/html/
create index.php:
<?php echo "hello world"; ?>
<?php echo date('Y-m-d H:i:s'); ?>
<?php phpinfo(); ?>

mysql installieren

sudo apt install mysql-server php-mysql phpmyadmin -y
sudo wget http://wordpress.org/latest.tar.gz
sudo tar xzf latest.tar.gz
=> test localhost/wordpress Directory sollte etwas anzeigen
sudo chown -R www-data: .
sudo mysql_secure_installation

Datenbank anlegen

sudo mysql -uroot -p
create database wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO 'root'@'localhost' IDENTIFIED BY 'PASSWORD';
FLUSH PRIVILEGES;
Exit the MariaDB database management tool with Ctrl + D.

Wordpress installieren

initial Seite wordpress aufrufen und db daten eingeben

Thursday, March 14, 2019

wpf dependency Properties

Definition 

in z.b. UserControl
public partial class MyUserControl : UserControl
{
        public static readonly DependencyProperty HeaderProperty =
            DependencyProperty.Register("Header", typeof(string), typeof(MyUserControl ), new FrameworkPropertyMetadata("DefaultHeaderText"));

//zusätzlich um einfacheen Setzten / Lesen der Dep.property:
        public string Header
        {
            get => (string)GetValue(HeaderProperty);
            set => SetValue(HeaderProperty, value);
        }
...

Binding 

im Usercontrol:
<UserControl x:Name="myUserControl"

<TextBlock Text="{Binding Header, ElementName=myUserControl}"/>

wichtig mit ElementName=myUserControl wird richtiger Context hergestellt

asp.net core simple web

create a dir
dotnet new web
creates Startup.cs and other files
dotnet run
browse localhost:5000


static files:
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-2.2
in Startup.cs

  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {

            app.UseStaticFiles(); }

then create test.htm in wwwroot with any text in it
browse localhost:5000/test.htm

or:
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {

            app.UseStaticFiles();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Run(async (context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });
        }

Wednesday, March 13, 2019

asp.net core on raspi (rasbian)

Installieren .netcore am rasperry:

This section is sourced from Dave the Engineer’s post on the Microsoft blog website.
The following commands need to be run on the Raspberry Pi whilst connected over an SSH session or via a terminal in the PIXEL desktop environment.
  • Run sudo apt-get install curl libunwind8 gettext. This will use the apt-get package manager to install three prerequiste packages.
  • Run curl -sSL -o dotnet.tar.gz https://dotnetcli.blob.core.windows.net/dotnet/Runtime/release/2.0.0/dotnet-runtime-latest-linux-arm.tar.gz to download the latest .NET Core Runtime for ARM32. This is refereed to as armhf on the Daily Builds page.
  • Run sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnet to create a destination folder and extract the downloaded package into it.
  • Run sudo ln -s /opt/dotnet/dotnet /usr/local/bin` to set up a symbolic link…a shortcut to you Windows folks 😉 to the dotnet executable.
  • Test the installation by typing dotnet -h or dotnet --help

Erstellen einer hello world console app mit windows .net core sdk:

dotnet new console --output sample1 dotnet run --project sample1

Monday, February 25, 2019

WPF SPY Tool SNOOP

1) Fadenkreuz auf das Fenster der WPF Anwendung drag & droppen => Fenster mit GUI-Baum der WPF App öffnet sich
2) mit CRT-SHIFT Mause over wird das Control, über dem sich die Maus befindet im Snoop GUI Baum ausgewählt
3) Datacontext zeigt View Model an

Wednesday, February 20, 2019

powershell Ja Nein (Yes No)

1) mit GridView

        $Answer = "J","N" | Out-GridView -PassThru -Title "Obige Schichten wirklich löschen ?"


2) mit Read-Host

        do
        {
            $Answer = Read-Host "Obige Schichten wirklich löschen ? (J/N)"
        }
        While ($Answer -ne "J" -and $Answer -ne "N")

Powershell Ergebnis sql Abfrage anzeigen Out-Gridview

display sql return:


Write-Verbose $sql;

# if windows user has not enough rights use other eg.: -Username sa -Password xxx
$ret=invoke-sqlcmd  -Query $sql -serverinstance $ServerInstance -Database $Database 

#display in cmd window
write-host ($ret | Format-Table | Out-String)

#display in new window with columns
$Ret | Out-GridView


Tuesday, February 19, 2019

powershell Debug Verbose



  • Run $DebugPreference = 'Continue' to start seeing output from Write-Debug calls.
  • When you're done, restore preference variable $DebugPreference to its default value, using $DebugPreference = 'SilentlyContinue'
  •   $VerbosePreference = "continue"

Wednesday, February 13, 2019

hardlink link erstellen mit miklink (windows )


/J für Verzeichnis:

mklink /J Git C:\Users\myUser\AppData\Local\Programs\Git\

Monday, February 04, 2019

constraint system views sql server


select * from sys.indexes
select * from sys.check_constraints
select * from sys.key_constraints
select * from sys.default_constraints
select * from sys.sysconstraints
select * from sys.foreign_keys

Friday, January 25, 2019

Hinzufügen einer neuen Windows Installation mit bcdboot d:\windows und bcdedit / Adding another Windows Installation with bcdboot D:\Windows and bcdedit

1) make a new partition or add a new hD
2) open admin cmd
3a) bcdedit shows the current bootmenu
3b) change name with bcdedit /set {current} description "my Existing Old Windows"
4) add new partition with bcdboot D:\Windows
5) change name with bcdedit /set {id} description "myNewWindows"

bcdedit /delete {id} deletes an entry in bootmenu / löscht einen eintrag im bootmenu

mit msconfig lassen sich die boot partitionen auch anzeigen


mit shutdown.exe /r /o /t 00
kann das boot menü auffgerufen werden beim neustart

Wednesday, January 23, 2019

linux mount readonly -o ro

sudo mount -o ro /dev/sda5 /media/DatenRo

Friday, January 04, 2019

Ubuntu Mate auf Raspberry


remote Desktop raspberry pi

Server:
 sudo apt-get install xrdp
Client:
 sudo apt-get install Remmina

open ssh

open-ssh installieren (aus ubunto Software Boutique)

wenn ssh nicht startet:
sudo service ssh restart

im /etc/rc.local
service ssh restart
einfügen