Skip to content

Instantly share code, notes, and snippets.

@straightdave
straightdave / Set-ConnPrivate.ps1
Created July 4, 2017 16:18
[win7] [powershell] set all connections private
# Get network connections
$networkListManager = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]"{DCB00C01-570F-4A9B-8D69-199FDBA5723B}"))
$connections = $networkListManager.GetNetworkConnections()
# Set network location to Private for all networks
$connections | % {$_.GetNetwork().SetCategory(1)}
# this is a must for creating winrm listener of https
@straightdave
straightdave / Configure-WinRM.ps1
Last active August 25, 2017 07:03
setting all network connections private before creating winrm listener of https
#################################################################################################################################
# Name : Configure-WinRM.ps1 #
# #
# Description : Configures the WinRM on an Azure machine #
# #
# Arguments : HostName, specifies the FQDN of machine or domain #
#################################################################################################################################
param
(
call winrm set winrm/config/service/auth @{Basic="true"}
call winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname="%1";CertificateThumbprint="%2"}
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"omniPrefix": {
"type": "string",
"defaultValue": "legacytest"
},
"vmOS": {
"type": "string",
@straightdave
straightdave / NX-param.json
Last active July 27, 2017 07:49
test params
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmCount": {
"value": 5
},
"adminUsername": {
"value": ""
},
@straightdave
straightdave / parser_sampler.go
Last active June 15, 2022 03:21
parse golang source file
package main
import (
"bytes"
"fmt"
"go/ast"
"go/parser"
"go/printer"
"go/token"
"strings"
func rotateString(A string, B string) bool {
if len(A) != len(B) {
return false
}
l := len(A)
if l == 0 {
return true
}
@straightdave
straightdave / 788_rotated_digits
Last active March 18, 2018 16:26
pending, not submit yet
// NOT completed!
// should consider about non-full count:
// 10, is 2-digi int, but not using fully count(2)
func rotatedDigits(N int) int {
switch {
case N<=10000 && N>=1000: return count(4)
case N<1000 && N>=100: return count(3)
case N<100 && N>=10: return count(2)
case N<10 && N>=1: return count(1)
@straightdave
straightdave / sample_grpc_client.go
Created April 23, 2018 15:37
sample gRPC client with very limit dependent
package main
import (
"log"
"reflect"
"time"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
package jsonsampler
import (
"encoding/json"
"reflect"
"testing"
)
type Struct1 struct {
Name string