Skip to content

Instantly share code, notes, and snippets.

Avatar

Enrico Campidoglio ecampidoglio

View GitHub Profile
View keybase.md

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 Apr 3, 2021
starship prompt with Nerd Fonts icons.
View starship.toml
# 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 Oct 30, 2019
Checkout Pull Request
View git-cpr-alias.md

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 Aug 22, 2019
A client-side Git hook that checks the length of the commit message.
View commit-msg.sh
#!/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 Oct 24, 2018
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
View htmltomd.sh
#!/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 Feb 21, 2013
A Bash script that prints the current state of the CPU on a Raspberry Pi. It displays variables like temperature, voltage and speed.
View cpustatus.sh
#!/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 Oct 17, 2012
Import-PSSnapin cmdlet to compensate for the shortcomings of the built-in snap-in cmdlets.
View Import-PSSnapin.ps1
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 Jan 18, 2012
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/
View Out-Diff.ps1
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 Oct 26, 2011
CS0853: An expression tree may not contain a named argument specification
View gist:1316023
[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 Oct 6, 2011
Visual Studio Code Snippet that adds a StyleCop compliant file header comment with company and copyright information.
View FileHeader.snippet.xml
<?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>