This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Realtime lines per second in a log file | |
tail -f /var/log/logfile | perl -e 'while (<>) {$l++;if (time > $e) {$e=time;print "$l\n";$l=0}}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encode | |
$Text = "Hidden secret!" | |
$Bytes = [System.Text.Encoding]::Unicode.GetBytes($Text) # or Unicode.GetBytes($Text), if Unicode is not needed | |
$EncodedText =[Convert]::ToBase64String($Bytes) | |
$EncodedText | |
# decode | |
$EncodedText = “SABpAGQAZABlAG4AIABzAGUAYwByAGUAdAAhAA==” | |
$DecodedText = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($EncodedText)) | |
$DecodedText |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install-WindowsFeature -name Telnet-Client | |
# or | |
dism /online /Enable-Feature /FeatureName:TelnetClient |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### WINDOWS ### | |
# option #1: generic version, from here: https://gallery.technet.microsoft.com/scriptcenter/Get-ExternalPublic-IP-c1b601bb | |
Invoke-RestMethod http://ipinfo.io/json | Select -exp ip | |
# option #2: Azure metadata service | |
(Invoke-RestMethod -H @{'Metadata'='true'} "http://169.254.169.254/metadata/instance?api-version=2017-08-01").network.interface.ipv4.ipAddress.publicIpAddress | |
### LINUX ### | |
dig +short myip.opendns.com @resolver1.opendns.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################## | |
## Original version @ https://gallery.technet.microsoft.com/scriptcenter/Powershell-Script-for-13a551b3 | |
## Updated: 5/26/2015, Version 2.0, By: Sangamesh (sangameshb@yahoo) on 5/26/2015 | |
############################################################################## | |
param ( | |
[string]$url = 'https://google.com', | |
[switch]$t = $true, | |
[switch]$help | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tcpping.exe google.com:80 | |
nameresolver.exe google.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FeedStorage | |
{ | |
public FeedStorage() | |
{ | |
GroupStoryChildIdList = ""; | |
} | |
[PrimaryKey] | |
public string Id { get; set; } | |
public DateTime FeedItemDateTime { get; set; } | |
public string ItemType { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- from: https://stackoverflow.com/questions/2729126/how-to-find-column-names-for-all-tables-in-all-databases-in-sql-server | |
SELECT | |
s.name as ColumnName | |
,sh.name+'.'+o.name AS ObjectName | |
,o.type_desc AS ObjectType | |
,CASE | |
WHEN t.name IN ('char','varchar') THEN t.name+'('+CASE WHEN s.max_length<0 then 'MAX' ELSE CONVERT(varchar(10),s.max_length) END+')' | |
WHEN t.name IN ('nvarchar','nchar') THEN t.name+'('+CASE WHEN s.max_length<0 then 'MAX' ELSE CONVERT(varchar(10),s.max_length/2) END+')' | |
WHEN t.name IN ('numeric') THEN t.name+'('+CONVERT(varchar(10),s.precision)+','+CONVERT(varchar(10),s.scale)+')' | |
ELSE t.name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static string GetSsoUrl(string baseUrl, string secret, string name, string email) { | |
var timems = (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds.ToString(); | |
return String.Format("{0}/login/sso?name={1}&email={2}×tamp={3}&hash={4}", | |
baseUrl, Server.UrlEncode(name), Server.UrlEncode(email), timems, GetHash(secret, name, email, timems)); | |
} | |
private static string GetHash(string secret, string name, string email, string timems) { | |
var input = name + secret + email + timems; | |
var keybytes = Encoding.Default.GetBytes(secret); | |
var inputBytes = Encoding.Default.GetBytes(input); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-NetTCPConnection -RemotePort 25 -ErrorAction SilentlyContinue | Format-Table |
NewerOlder