Skip to content

Instantly share code, notes, and snippets.

View ecampidoglio's full-sized avatar

Enrico Campidoglio ecampidoglio

View GitHub Profile

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@ecampidoglio
ecampidoglio / starship.toml
Last active January 7, 2023 04:25
starship prompt with Nerd Fonts icons.
# Replace the "❯" symbol in the prompt with "➜"
[character]
symbol = "➜"
# Configure the number of directories to truncate in the current path
[directory]
truncation_length = 3
truncate_to_repo = true
style = "blue"
@ecampidoglio
ecampidoglio / git-cpr-alias.md
Created October 30, 2019 12:19
Checkout Pull Request

Checkout Pull Request

A Git alias to quickly check out a Pull Request branch in a single move. ⚡

git config --global alias.cpr '!f() { git fetch --quiet ${GIT_DEFAULT_REMOTE-origin} pull/$1/head:pulls/$1 && git checkout pulls/$1; }; f'

Usage

@ecampidoglio
ecampidoglio / commit-msg.sh
Last active August 22, 2019 20:33
A client-side Git hook that checks the length of the commit message.
#!/bin/sh
#
# A hook script that checks the length of the commit message.
#
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
DEFAULT="\033[0m"
@ecampidoglio
ecampidoglio / htmltomd.sh
Last active October 24, 2018 12:48
A Bash script that downloads the HTML source from a list of URLs and converts it to Markdown. The source file must contain each URL to download from on a separate line. The actual conversion is done by the awesome API available at http://heckyesmarkdown.com
#!/bin/bash
# htmltomd
# Downloads the HTML source from a list of URLs and converts it to Markdown.
# The source file must contain each URL to download from on a separate line.
# The actual conversion is done by the awesome API available at
# http://heckyesmarkdown.com
urlsFile=$1
outputDir=${2:-.} # Defaults to local dir
@ecampidoglio
ecampidoglio / cpustatus.sh
Created February 21, 2013 23:42
A Bash script that prints the current state of the CPU on a Raspberry Pi. It displays variables like temperature, voltage and speed.
#!/bin/bash
# cpustatus
#
# Prints the current state of the CPU like temperature, voltage and speed.
# The temperature is reported in degrees Celsius (C) while
# the CPU speed is calculated in megahertz (MHz).
function convert_to_MHz {
let value=$1/1000
echo "$value"
@ecampidoglio
ecampidoglio / Import-PSSnapin.ps1
Created October 17, 2012 11:25
Import-PSSnapin cmdlet to compensate for the shortcomings of the built-in snap-in cmdlets.
function Import-PSSnapin {
<#
.Synopsis
Adds a Windows PowerShell snap-in with the specified name to the current session.
This cmdlet will not throw an exception if the specified snap-in is already present in the session.
.Description
Helper function to safely add a Windows PowerShell snap-in with the specified name to the current session.
.Parameter Name
The name of the snap-in to import.
#>
@ecampidoglio
ecampidoglio / Out-Diff.ps1
Created January 18, 2012 21:48
A PowerShell function to colorize a sequence of text lines that represent an Universal Diff. For more information, see http://megakemp.com/2012/01/19/better-diffs-with-powershell/
function Out-Diff {
<#
.Synopsis
Redirects a Universal DIFF encoded text from the pipeline to the host using colors to highlight the differences.
.Description
Helper function to highlight the differences in a Universal DIFF text using color coding.
.Parameter InputObject
The text to display as Universal DIFF.
#>
[CmdletBinding()]
@ecampidoglio
ecampidoglio / gist:1316023
Created October 26, 2011 10:54
CS0853: An expression tree may not contain a named argument specification
[Test]
public void CS_compiler_should_allow_named_arguments_in_lambdas()
{
// Given
var mock = new Mock<IProceduralPizzaStore>();
// When
mock.Verify(
m => m.OrderPizza(
name: "Quattro Formaggi",
@ecampidoglio
ecampidoglio / FileHeader.snippet.xml
Created October 6, 2011 09:16
Visual Studio Code Snippet that adds a StyleCop compliant file header comment with company and copyright information.
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>File Header</Title>
<Author>Enrico Campidoglio</Author>
<Shortcut>fh</Shortcut>
<Description>Adds a StyleCop compliant file header comment with company and copyright information.</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>