Sveučilište u Zagrebu  |  Filozofski fakultet  |  Služba za informatiku  |  Links

 

Kutak za korisnike

Teme

.NET, VB/C# .NET 6
  • Copy text to clipboard
    - install package TextCopy into the project, then use in code:
    ---- await TextCopy.ClipboardService.SetTextAsync("text-to-copy-to-clipboard"));
  • Add non-essential code pages
    System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
  • Read a connection string from a config file
    var builder = new ConfigurationBuilder().AddJsonFile("appsettings.json", optional: false);
    string connectionString = builder.Build().GetConnectionString("ConnectionStringName");
  • Add non-essential code pages
    var contextOptions = new DbContextOptionsBuilder<MyDbContextClassName>().UseSqlServer(connectionString).Options;
    using (var dbx = new MyDbContextClassName(contextOptions)) { ... } <
  • Passing lambdas to a method
RegularExpressions Print Formatting
  • Convert a decimal value with a culturally appropriate format
    Dim culture As CultureInfo = CultureInfo.CreateSpecificCulture("hr-HR")
    Dim destinationVariable as decimal
    If Decimal.TryParse(decimalStringText, Globalization.NumberStyles.Number, culture, destinationVariable) = False Then
      // error
    End If
  • Parse a DateTime string
    CultureInfo enUS = new CultureInfo("en-US");
    DateTimeStyles noStyle = DateTimeStyles.None;
    DateTime t1, t2;
    string f = "yyyyMMddHHmmss";

    if (!DateTime.TryParseExact(t1string, f, enUS, noStyle, out t1)) t1 = DateTime.MinValue;
    if (!DateTime.TryParseExact(t2string, f, enUS, noStyle, out t2)) t2 = DateTime.MinValue;

    // return date plus two times
    return string.Format("{0:yyyy-MM-dd} {0:HH:mm}-{1:HH:mm}", t1, t2)
Collections & Sorting VB.NET 2010 Constants, Literals and Collection initialization Enums Basic I/O Entity framework XML in VB.NET Processes, delegates, threads and timing Mail, Zip... Other
Referentni materijali:
  • ISO popis zemalja¸
  • Sadržaj autoexec.bat i config.sys datoteka, vezano za narodne znakove
  • Popis Excel 2000 funkcija:
    • po kategorijama (Excel), 
    • po abecedi (Excel),
    • po abecedi (Word, podobno za ispis na jedan list papira, ako možete printati "2 na 1" i dvostrano)
Microsoft Savjeti za rad s Windowsima, Office-om i sve ostalo.... character tables EXCEL Outlook MAUI SHELL EXTENSIONS LINQ
  • Query expression basics
  • group clause (C# Reference)
  • LINQ @ Wikipedia
  • LINQ Method Syntax (FluentAPI)
  • Standard LINQ Query Operators
    • Filtering - Where, OfType
    • Sorting - OrderBy, OrderByDescending, ThenBy, ThenByDescending, Reverse
    • Grouping - GroupBy, ToLookup
    • Join - GroupJoin, Join
    • Projection - Select, SelectMany
    • Aggregation - Aggregate, Average, Count, LongCount, Max, Min, Sum
    • Quantifiers - All, Any, Contains
    • Elements - ElementAt, ElementAtOrDefault, First, FirstOrDefault, Last, LastOrDefault, Single, SingleOrDefault
    • Set - Distinct, Except, Intersect, Union
    • Partitioning - Skip, SkipWhile, Take, TakeWhile
    • Concatenation - Concat
    • Equality - SequenceEqual
    • Generation - DefaultEmpty, Empty, Range, Repeat
    • Conversion - AsEnumerable, AsQueryable, Cast, ToArray, ToDictionary, ToList
  • Sum of squares
      Console.WriteLine(
        Enumerable.Range(1, 10)
        .Where(x => x % 2 == 0)
        .Select(x => x * x)
        .Aggregate(0, (sum, x) => sum + x)
        ); // Output: 220
  • Group to odd and even numbers
      foreach (var group in Enumerable.Range(1, 10).GroupBy(x => x % 2).OrderBy(x => x.Key))
      {
        Console.WriteLine(group.Key == 0 ? "EVEN" : "ODD");
        foreach (var item in group) { Console.WriteLine(" " + item); }
      }
SQL *[iu]x Exchange Git devtut.github.io
  • devtut.github.io/
    • git
    • Creating a personal access token
    • PowerShell
    • PSGitHub module
    • Getting Github collaborators
        Get-GithubRepository -AccessToken <YOUR_github_access_token> | Select-Object -First 3 | ForEach {
        # you might have access to other pepople's repositories but you lack permission to reach their collaborators list, so...
        if ($_.full_name.StartsWith("<YOUR_github_login>")) {
          $colaborators = $_ | Get-GitHubRepositoryCollaborator -AccessToken <YOUR_github_access_token>
          echo "$($_.Name)#$($colaborators.login)" }}
    • .NET Framework
    • C#
    • Visual Basic .NET
PowerShell
  • The basics of PowerShell scripting
  • PowerShell for Beginners (1-13)
  • VisualBasic.NET code in PowerShell script
  • Elevated powershell from WSL:
    powershell.exe -Command "Start-Process powershell -Verb RunAs"
  • Ensure that script is run by an elevated powershell process
    #include the following Requires comment line at the start of the script
    #Requires -RunAsAdministrator
  • Console input/output
    $Server = Read-Host -Prompt 'Input your server name'
    $User = Read-Host -Prompt 'Input the user name'
    $Password = Read-Host -Prompt 'Input the user password' -AsSecureString
    $Date = Get-Date
    Write-Host "You input server '$Server' and '$User' on '$Date'"
    Write-Output "You input server '$Server' and '$User' on '$Date'"
  • Execute a command in a string
    $cmd = "dir *.ps1"
    Invoke-Expression $cmd
  • Convert a string of commands into a scriptblock
    $cmd = @"
       a multiline set of commands
    "@
    $scriptBlock = [Scriptblock]::Create($cmd)
    Invoke-Command -ScriptBlock $scriptBlock
  • PowerShell scheduled job # from an Administrator PowerShell
    $trigger = New-JobTrigger -Once -At ((Get-Date).AddSeconds(5)) -RepeatIndefinitely -RepetitionInterval (New-TimeSpan -Minutes 1)
    Register-ScheduledJob -Name "EveryMinuter" -Trigger $trigger -ScriptBlock { whoami }
    # Get-Job, Receive-Job, Remove-Job, Unregister-ScheduledJob
  • Change local user password
    $Password = Read-Host -AsSecureString -Prompt "Enter new password"
    Get-LocalUser -Name <username> | Set-LocalUser -Password $Password
  • Outlook attachments via PowerShell
  • Accessing Outlook Inbox messages from Powershell
    Add-Type -Assembly "Microsoft.Office.Interop.Outlook"
    $Outlook = New-Object -ComObject Outlook.Application
    $namespace = $Outlook.GetNameSpace("MAPI")
    $inbox = $namespace.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox)
    $inbox.Items | foreach {
      "{0:yyyy-MM-dd HH:mm}#{1:n0}#{2}#{3}" -f $_.ReceivedTime, $($_.Size / 1024), $_.SenderEmailAddress, $_.Subject
      }
  • Inspect the MS SQL Server database
    sqlps -noexit -command cd sql/<machineName>/<instanceName>/databases
    dir <databaseName>/tables | foreach { $_.Script() }
    dir <databaseName>/storedProcedures | foreach { $_.Script() }
    dir <databaseName>/tables/dbo.<tableName>/columns |
      foreach {
        "Column: $($_.name) $($_.datatype.SqlDataType) $($_.datatype.MaximumLength) $($_.Nullable)"
        }
  • Get Target Path from Shortcuts
  • Securng Passwords
  • PowerShell Massive Mailing
  • Invoke-WebRequest cmdlet in PowerShell
  • Prebroj programske linije
  • Find PDF files with 'python' in the name (case insensitive)
    Get-ChildItem c:\,d:\ -Recurse -ErrorAction SilentlyContinue | where name -like "*python*pdf"
  • Massive filename deyusciification
    dir | foreach {
      $name = $_.name
      $newName = $name.Replace("ć", "c").Replace("č", "c").Replace("š", "s").Replace("ž", "z").Replace("đ", "dj")
      $newName = $newname.Replace("Ć", "C").Replace("Č", "C").Replace("Š", "S").Replace("Ž", "Z").Replace("Đ", "DJ")
      if ($name -ne $newName) {
        "mv $name $newName"
        #mv $name $newName
        }
      }
  • List parents of folders listed in a file by creation date
    cat <fielNamesListFileName> | foreach {
      $gitFile = [System.IO.DirectoryInfo]$_
      $gitfile.Parent
    } | sort lastwritetime | foreach {
      "{0:yyyy-MM-dd} {1}" -f $_.lastwritetime, $_.fullname
    }
Markdown Pandoc Cartificates Web Ostalo

 
 komentare molim ovdje