Git Product home page Git Product logo

essentials's Introduction

Essential tutorial bits for developers

This document is a collection of tutorial bits that I gather over time from topics ranging from simple bash commands and git gems to creating self-signed certifcates. It helps to have a common place to store these gems which can be easily searched.

Git

  • List branches that contain a given commit
# search within a local branch
$ git branch --contains <commit>
# search across local and remote branches
$ git branch -r --contains <commit>
  • List all commits in the current branch that are not in the remote branch
git cherry -v
  • For a given file, find what commits were added to master relative to the local branch
git log --oneline HEAD..master -- <file>
  • Change the author
git commit --amend --author="<Author Name> <[email protected]>"
  • Show git root directory
git rev-parse --show-toplevel

Bash

  • Check if stdin, stdout or stderr is attached to a terminal
# File descriptors for stdin, stdout and stderr are 0, 1 and 2 respectively.
# The bash builtin `-t` takes one of the above file descriptors and returns
# true if the descriptor is attached to a terminal and false otherwise. The
# following checks if stdout is attached to a terminal.
$ [ -t 1 ] && echo "Yes" || echo "No"
Yes
$ ([ -t 1 ] && echo "Yes" || echo "No") | cat
No
  • Check if a given function or alias exists
# Bash builtin `type` determines if a given identifier is a function or an
# alias. For example, let's define a function `bar` and an alias `baz`
$ function bar() {
> echo "i am a bar function"
> }
$ alias baz='bar'
# Now, let's use the `type` builtin to determine the type of `bar` and `baz`
$ type -t bar
function
$ type -t baz
alias

Certificate generation

  • Generate a keystore using the Java keytool
keytool -genkey -alias server -keyalg RSA -keysize 2048 -keystore cloud.jks
  • Generate a certificate request
keytool -certreq -alias server -file cloud.csr.txt -keystore cloud.jks
  • Import one or all entries from another keystore
keytool -importkeystore -srckeystore cloud.jks -destkeystore cloud.pkcs -srcstoretype JKS  -deststoretype PKCS12
  • Generate a PEM from a pkcs12 formatted file
openssl pkcs12 -in cloud.pkcs -out cloud.pem
  • Reveal the private key from the PEM file
openssl rsa -in cloud.pem -out cloud.key
  • Generate a certificate from the certificate request and private key
openssl x509 -req -days 365 -in cloud.csr.txt -signkey cloud.key -out cloud.crt
  • Convert CRT to PEM format
openssl x509 -in cloud.crt -out cloud.pem -outform PEM

essentials's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.