Skip to content

Instantly share code, notes, and snippets.

View dhcgn's full-sized avatar

Daniel dhcgn

View GitHub Profile

Keybase proof

I hereby claim:

  • I am dhcgn on github.
  • I am dhcgn (https://keybase.io/dhcgn) on keybase.
  • I have a public key ASAnHmjKvQUr0KeI6M62iH50npaQA7HajANhF_hFcrf2jwo

To claim this, I am signing this object:

using System;
using System.Collections.Generic;
using System.Linq;
using Net.Pkcs11Interop.Common;
using Net.Pkcs11Interop.HighLevelAPI;
using Net.Pkcs11Interop.HighLevelAPI.MechanismParams;
using NUnit.Framework;
namespace HsmTry
{
private const string LibraryPath = @"C:\Windows\System32\opensc-pkcs11.dll";
public static byte[] Derive(string privateEc, string publicEc)
{
Func<string, Session, CKO, ObjectHandle> getObjectHandle = (label, session, keyType) =>
{
var objectAttributes = new List<ObjectAttribute>
{
new ObjectAttribute(CKA.CKA_CLASS, keyType),
new ObjectAttribute(CKA.CKA_LABEL, label),
@dhcgn
dhcgn / listDevices.ps1
Last active March 16, 2017 22:06
Call the method listDevices to get all devices from a ccu2 (homematic basis station)
$homematicUrl = 'http://192.168.10.21:2001'
$body = @'
<?xml version="1.0"?>
<methodCall>
<methodName>listDevices</methodName>
</methodCall>
'@
$response = Invoke-WebRequest -Uri $homematicUrl -Method Post -Body $body
@dhcgn
dhcgn / Init_start.ps1
Created March 16, 2017 22:52
Init the event callback fot the ccu2 (homematic basis station)
$homematicUrl = 'http://192.168.10.21:2001'
$destination = 'http://192.168.10.105:5050'
$interfaceId = '1'
$body = @'
<?xml version="1.0"?>
<methodCall>
<methodName>init</methodName>
<params>
# http://stackoverflow.com/a/35089747
# Solution 2: Delete installation cache
gci 'c:/programdata/package cache/' -Include *.msi,*.cab -Recurse | Remove-Item -Force
# Solution 3: Delete temporary file data stored on your computer
Resolve-Path "C:\Users\*\AppData\Local\Microsoft\VSCommon" | Remove-Item -Recurse -Force
Resolve-Path "C:\Users\*\AppData\Local\Microsoft\VisualStudio" | Remove-Item -Recurse -Force
@dhcgn
dhcgn / wipe_external_device_on_synlology.sh
Created March 29, 2017 19:34
If you want to wipe an external device atteched to a synlology nas
# First find the device
sudo fdisk -l
# Disk /dev/sdq: 372.6 GiB, 400088457216 bytes, 781422768 sectors
# Units: sectors of 1 * 512 = 512 bytes
# Sector size (logical/physical): 512 bytes / 512 bytes
# I/O size (minimum/optimal): 512 bytes / 512 bytes
# Disklabel type: dos
# Disk identifier: 0x00000000
@dhcgn
dhcgn / DownloadAndInstallChrome.ps1
Last active June 2, 2017 08:14 — forked from kurokikaze/gist:350fe1713591641b3b42
install chrome from powershell
$Path = $env:TEMP; `
$Installer = 'chrome_installer.exe'; `
Invoke-WebRequest 'http://dl.google.com/chrome/install/375.126/chrome_installer.exe' -OutFile $Path\$Installer; `
Start-Process -FilePath $Path\$Installer -Args "/silent /install" -Verb RunAs -Wait; `
Remove-Item $Path\$Installer
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FileCopyAndHash
gci *.png | Measure-Object Length -Sum | %{$_.Sum / 1kb}
# 8.402 kb
gci *.png | %{."C:\Program Files\ImageMagick-7.0.6-Q16\convert.exe" $_.FullName -strip $_.FullName }
gci *.png | Measure-Object Length -Sum | %{$_.Sum / 1kb}
# 9.665 kb
gci *.png | Measure-Object Length -Sum | %{$_.Sum / 1kb}