Skip to content

Instantly share code, notes, and snippets.

View fstefanov's full-sized avatar

Filip Stefanov fstefanov

View GitHub Profile
@SKempin
SKempin / Git Subtree basics.md
Last active June 22, 2024 00:59
Git Subtree basics

Git Subtree Basics

If you hate git submodule, then you may want to give git subtree a try.

Background

When you want to use a subtree, you add the subtree to an existing repository where the subtree is a reference to another repository url and branch/tag. This add command adds all the code and files into the main repository locally; it's not just a reference to a remote repo.

When you stage and commit files for the main repo, it will add all of the remote files in the same operation. The subtree checkout will pull all the files in one pass, so there is no need to try and connect to another repo to get the portion of subtree files, because they were already included in the main repo.

Adding a subtree

Let's say you already have a git repository with at least one commit. You can add another repository into this respository like this:

@Bergvca
Bergvca / unnittestexample.py
Last active December 22, 2022 20:54
Some unnittest + Mock examples in Python. Includes examples on how to mock a entire class (ZipFile), mock an Iterator object and how to use side_effect properly
import unittest
import os
from zipfile import ZipFile
from mock import MagicMock, patch, Mock, mock_open
# The functions that are tested:
def function_to_test_zipfile(example_arg):
with ZipFile(example_arg, 'r') as zip_in:
for input_file in zip_in.infolist():
@JJediny
JJediny / Jenkinsfile
Created February 22, 2017 20:17 — forked from abayer/Jenkinsfile
An example Declarative Pipeline Jenkinsfile for Feb 15 2017 demo
// A Declarative Pipeline is defined within a 'pipeline' block.
pipeline {
// agent defines where the pipeline will run.
agent {
// This also could have been 'agent any' - that has the same meaning.
label ""
// Other possible built-in agent types are 'agent none', for not running the
// top-level on any agent (which results in you needing to specify agents on
// each stage and do explicit checkouts of scm in those stages), 'docker',
@magnetikonline
magnetikonline / README.md
Last active June 22, 2024 06:03
List all Git repository objects by size.

List all Git repository objects by size

Summary

Bash script which will:

  • Iterate all commits made within a Git repository.
@mightyguava
mightyguava / migrate.md
Last active December 3, 2017 06:52
Migrate Gerrit 2.12 to Postgres
  1. Create an RDS instance
  2. SSH to gerrit and cd to /opt/gerrit/site
  3. Stop gerrit and open the gerrit prompt
  bin/gerrit.sh stop
  java -jar bin/gerrit.war 'gsql' -d .
  1. Copy in the below
@gwillem
gwillem / ansible-bootstrap-ubuntu-16.04.yml
Created June 16, 2016 21:59
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
# Add this snippet to the top of your playbook.
# It will install python2 if missing (but checks first so no expensive repeated apt updates)
# gwillem@gmail.com
- hosts: all
gather_facts: False
tasks:
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
@Faheetah
Faheetah / Jenkinsfile.groovy
Last active June 17, 2024 15:05
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
@olih
olih / jq-cheetsheet.md
Last active June 22, 2024 18:30
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@subfuzion
subfuzion / curl.md
Last active June 22, 2024 13:47
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@nottrobin
nottrobin / wsgi.py
Last active September 3, 2018 02:59
Simple WSGI application server
from wsgiref.simple_server import make_server
def application(env, start_response):
"""
A basic WSGI application
"""
http_status = '200 OK'
response_headers = [('Content-Type', 'text/html')]