Skip to content

Instantly share code, notes, and snippets.

@SAVE-UP
SAVE-UP / gitcheat.sh
Created October 5, 2021 09:31
Github cheats
git init # initiates git in the current directory
git clone <address> # creates a git repo from given address (get the address from your git-server)
git clone <address> -b <branch_name> <path/to/directory> # clones a git repo from the address into the given directory and checkout's the given branch
git clone <address> -b <branch_name> --single-branch # Clones a single branch
git add file.txt # adds(stages) file.txt to the git
git add * # adds(stages) all new modifications, deletions, creations to the git
git reset file.txt # Removes file.txt from the stage
git reset --hard # Throws away all your uncommitted changes, hard reset files to HEAD
git rm file.txt # removes file.txt both from git and file system
@hkak03key
hkak03key / .gitignore
Last active April 30, 2021 17:14
google-drive-api-example
# credentials
service_account_credentials.json
# go
go.sum
@yardbirdsax
yardbirdsax / startCodeBuild.sh
Last active September 27, 2024 22:23
Start AWS Codebuild pipeline from command prompt and wait
#!/bin/bash
error_exit()
{
echo "$1" 1>&2
exit 1
}
CODEBUILD_PROJECT_NAME=$1
job "{{service_name}}" {
datacenters = [{{list_of_datacenters}}]
type = "service"
reschedule {
delay = "30s"
delay_function = "constant"
unlimited = true
}
@darkn3rd
darkn3rd / serverspechelpers.md
Last active September 9, 2021 16:13
ServerSpec Spec Helpers

ServerSpec Notes

These are snippets of auto-generated from ServerSpec. The serverspec-init only auto-generates base functionality with cmd, exec, ssh, and winrm backends with some optional vagrant support for dyanmic inventory on ssh backend.

There are additional backends available from SpecInfra, but these are not supported and only documented in O'Reilly book for Serverspec: The Definitive Guide by Gosuke Miyashita (ISBN978-4-87311-709-6), which is in Japanese only:

Spec Helper

@huyinghuan
huyinghuan / encrypt_file_pkcs5_pkcs7.go
Created May 31, 2017 07:44
golang encrypt with pkcs5 and pkcs7
package main
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"errors"
"io"
"io/ioutil"
@mosquito
mosquito / README.md
Last active March 28, 2025 02:03
Add doker-compose as a systemd unit

Docker compose as a systemd unit

Create file /etc/systemd/system/[email protected]. SystemD calling binaries using an absolute path. In my case is prefixed by /usr/local/bin, you should use paths specific for your environment.

[Unit]
Description=%i service with docker compose
PartOf=docker.service
After=docker.service
@mihow
mihow / load_dotenv.sh
Last active March 25, 2025 16:33
Load environment variables from dotenv / .env file in Bash
# The initial version
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
# My favorite from the comments. Thanks @richarddewit & others!
set -a && source .env && set +a
@linuxsimba
linuxsimba / netbox-ansible.py
Created December 10, 2016 06:12
Ansible Netbox Integration Example
#!/usr/bin/python
""" Ansible Inventory Generated From Netbox
Author: Stanley Karunditu <stanley@linuxsimba.com>
License: MIT
Requirements:
* use netbox device roles that result in hyphenated role names. E.g
root@master:~ # tail -n1 /etc/puppetlabs/code/environments/production/environment.conf
config_version = config_version.sh
root@master:~ # cat /etc/puppetlabs/code/environments/production/config_version.sh
#!/bin/sh
/bin/echo "Puppet run starting at `date`: ╰( ⁰ ਊ ⁰ )━☆゚.*・。"
root@master:~ # puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts