Skip to content

Instantly share code, notes, and snippets.

View carbonrobot's full-sized avatar

Charlie Brown carbonrobot

View GitHub Profile
@fgilio
fgilio / axios-catch-error.js
Last active April 11, 2024 19:02
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@carbonrobot
carbonrobot / git.log
Last active January 30, 2018 15:27
GIT Tricks
// Prettier Log output
git config --global alias.logc "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(cyan) <%an>%Creset' --abbrev-commit"
// show all branches by owner
git for-each-ref --format='%(committerdate) %09 %(authorname) %09 %(refname)' | sort -k5n -k2M -k3n -k4n
anonymous
anonymous / ReferenceValuesService
Created January 15, 2015 09:19
public class ReferenceValuesService{
public ReferenceValuesService(Func<Context> contextFactory){
this.contextFactory = contextFactory;
this.referenceValues = new Lazy<IEnumerable<ReferenceValue>>(() => this.contextFactory().GetReferenceValues());
}
public IEnumerable<ReferenceValue> ReferenceValues(){
return this.referenceValues.Value;
}
public class SomeClass {
public void SomeMethod() {
this.Log().Info(() => "Here is a log message with params which can be in Razor Views as well: '{0}'".FormatWith(typeof(SomeClass).Name));
}
}