Skip to content

Instantly share code, notes, and snippets.

View camilohe's full-sized avatar

Camilo E. Hidalgo Estevez camilohe

View GitHub Profile
@camilohe
camilohe / latency.txt
Created April 7, 2022 23:47 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@camilohe
camilohe / clean_code.md
Created December 27, 2019 22:06 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@camilohe
camilohe / Get-WindowsUpdateFileList.ps1
Created November 12, 2019 16:23 — forked from altrive/Get-WindowsUpdateFileList.ps1
PowerShell cmdlets to get WindowsUpdate patch file List.
#Requires –Version 3
#Get WindowsUpdate List for offline patch
function Get-WindowsUpdateFileList
{
param(
[Parameter(Mandatory=$True)]
[string] $Filter
)
$objSession = New-Object -ComObject "Microsoft.Update.Session"
@camilohe
camilohe / Install-SysInternalsTool.ps1
Created November 12, 2019 16:22 — forked from altrive/Install-SysInternalsTool.ps1
Install and setup script for SysInternals tools(BGInfo/AutoLogon).
#Install SysInternals BGInfo/AutoLogon tools
function Install-SysInternalsTool
{
#Target directory is %WinDir%C:\Windows\System32\SysInternals
$targetDir = Join-Path $env:WinDir "System32\SysInternals"
#Tools to be downloaded
$tools = @{
Bginfo = "http://live.sysinternals.com/Bginfo.exe"
Autologon = "http://live.sysinternals.com/Autologon.exe"
@camilohe
camilohe / Get-EventLogError.ps1
Created November 12, 2019 16:22 — forked from altrive/Get-EventLogError.ps1
PowerShell utility function to find EventLog errors.
function Get-EventLogError
{
[CmdletBinding()]
param(
[Parameter(Mandatory,ParameterSetName="FromLastBootupTime")]
[switch] $FromLastBootupTime,
[Parameter(Mandatory,ParameterSetName="FromLastQueryTime")]
[switch] $FromLastQueryTime,
[Parameter(Mandatory,ParameterSetName="Range")]
[DateTime] $From,
@camilohe
camilohe / SavedCredential.ps1
Created November 12, 2019 16:22 — forked from altrive/SavedCredential.ps1
Credential management utilities for PowerShell
#Requires -Version 3
#Credential file path
$script:CredentialsFile = Join-Path $env:TEMP "SavedCredentials\Credentials.xml"
function Set-SavedCredential()
{
[CmdletBinding()]
param(
[Parameter(Mandatory)]
@camilohe
camilohe / Test-NetConnection.Tests.ps1
Created November 12, 2019 16:22 — forked from altrive/Test-NetConnection.Tests.ps1
PowerShell v4 new cmdlet "Test-NetConnection"
#if ComputerName is not supplied. Connect to "internetbeacon.msedge.net" by default
Test-NetConnection
#Test ping(ICMP protocol)
Test-NetConnection "google.com"
#Ping with TraceRoute
Test-NetConnection "google.com" -TraceRoute
#Set Remote ComputerName
@camilohe
camilohe / Out-HtmlView.ps1
Created November 12, 2019 16:21 — forked from altrive/Out-HtmlView.ps1
Cmdlet to show object tree in HtmlView
#TODO:support for non serializable object(example:PSCustomObject)
function Out-HtmlView
{
[CmdletBinding()]
param(
[Parameter()]
[int]$Depth = 2,
[Parameter(Mandatory,ValueFromPipeLine)]
$InputObject
)
@camilohe
camilohe / Find-GitHubRepository.ps1
Created November 12, 2019 16:21 — forked from altrive/Find-GitHubRepository.ps1
List GitHub PowerShell repositories using GitHub Search API.
function Main
{
#Execute Query(Note:Github Search API return up to 1000 results for each search.)
$results = Find-GitHubRepository -Filter "language:powershell+created:>=2013-12-01&sort=stars" -Verbose
#Show Results
Write-Host ("Total Repositry Count : {0}" -f $results.total_count)
Write-Host ("Returned Repository Count: {0}" -f $results.items.Count)
$selectedItems = $results.items | select name, description, html_url, fork | Out-GridView -OutputMode Multiple
@camilohe
camilohe / PSModuleLoading.psm1
Created November 12, 2019 16:19 — forked from altrive/PSModuleLoading.psm1
Custom PSmodule sample to load command defined separated files using dot-sourcing.
#Write-Host "Load script files..." -ForegroundColor DarkGray
$scriptFiles = Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "*.Tests.ps1" -Recurse
foreach ($script in $scriptFiles)
{
#Write-Host "`tLoad script:" $script.Name -ForegroundColor DarkGray
try
{
#TODO: Suppress $Error entry recorded after module loading completed(can't suppress inside psm1 module?)
. $script.FullName