Skip to content

Instantly share code, notes, and snippets.

View zot24's full-sized avatar
🦑
boom!

zot24

🦑
boom!
View GitHub Profile
@zot24
zot24 / git-extract-file.markdown
Created April 19, 2017 11:02 — forked from ssp/git-extract-file.markdown
Extract a single file from a git repository

How to extract a single file with its history from a git repository

These steps show two less common interactions with git to extract a single file which is inside a subfolder from a git repository. These steps essentially reduce the repository to just the desired files and should performed on a copy of the original repository (1.).

First the repository is reduced to just the subfolder containing the files in question using git filter-branch --subdirectory-filter (2.) which is a useful step by itself if just a subfolder needs to be extracted. This step moves the desired files to the top level of the repository.

Finally all remaining files are listed using git ls, the files to keep are removed from that using grep -v and the resulting list is passed to git rm which is invoked by git filter-branch --index-filter (3.). A bit convoluted but it does the trick.

1. copy the repository to extract the file from and go to the desired branch

Keybase proof

I hereby claim:

  • I am zot24 on github.
  • I am zot24 (https://keybase.io/zot24) on keybase.
  • I have a public key ASDOTr1lCCS5MRBEEP18foqzSRxNs05e1eesOn0ANqNOqgo

To claim this, I am signing this object:

@zot24
zot24 / main.tf
Created March 5, 2017 11:47
Attempt to create a development role in a second aws account to then attache it to the main aws account
# setup aws provider for dev account
provider "aws" {
alias = "dev"
region = "${var.aws_region}"
access_key = "${var.dev_access_key}"
secret_key = "${var.dev_secret_key}"
}
# in dev account create iam policy, which will grants admin rights
resource "aws_iam_policy" "external_admin_policy" {
@zot24
zot24 / body.ejs
Last active January 3, 2017 15:18
Inject JSON file as a body of a response with mountbank
{
"data":{
"type":"settings",
"page_length":100,
"email_smtp_port":25,
"email_encryption":"none",
"timezone":"UTC",
"password_policy":"min_6_letters"
}
}
@zot24
zot24 / clean_up_all_things_on_docker.sh
Created October 21, 2016 10:39
Clean docker containers, images., volumes and netwroks
#!/bin/bash
docker stop $(docker ps -a -q) && \
docker rm $(docker ps -a -q) && \
docker rmi -f $(docker images -q) && \
docker volume rm `docker volume ls -q` & \
docker network rm $(docker network ls | tail -n+2 | awk '{if($2 !~ /bridge|none|host/){ print $1 }}')
@zot24
zot24 / sed_cmd_remove_all_between_x.sh
Created October 20, 2016 14:52
sed command to remove all in between something including that `something` on a file
#!/bin/bash
sed -i.bak -rn ':a;N;$!ba;s/<match docker\.all(.*?)<\/match>//gp' /etc/fluent/fluent.conf
@zot24
zot24 / jenkins_haproxy_config.cfg
Created September 15, 2016 14:10 — forked from xelwarto/jenkins_haproxy_config.cfg
Jenkins CI haproxy configuration example
global
chroot /var/lib/haproxy
crt-base /etc/pki/tls/certs
daemon
group haproxy
log 127.0.0.1 local0
maxconn 2000
pidfile /var/run/haproxy.pid
stats socket /var/lib/haproxy/stats
tune.ssl.default-dh-param 2048
provider "azurerm" {}
#########
# group #
#########
module "resource_group" {
source = "github.com/zot24/tf_azure_resource_group"
name = "${var.app_name}_${var.resource_group_name}"
module.resource_group.azurerm_resource_group.mod: Creating...
location: "" => "westeurope"
name: "" => "testm1_resource_group_1"
module.resource_group.azurerm_resource_group.mod: Creation complete
module.public_ip.azurerm_public_ip.mod: Creating...
fqdn: "" => "<computed>"
ip_address: "" => "<computed>"
location: "" => "westeurope"
name: "" => "testm1_public_ip_1"
public_ip_address_allocation: "" => "static"
@zot24
zot24 / create_rancher_environment_api_key
Last active August 29, 2018 12:33
Script to create a Rancher Environment API Keys programmatically #test
#!/bin/bash
docker exec --privileged -i rancher-agent bash << EOF
ACCOUNT_ID=\`curl -sL "\${CATTLE_URL}/accounts?name=Default" | jq -r .data[].id\`
echo \`curl -u "${CATTLE_ACCESS_KEY}:${CATTLE_SECRET_KEY}" \
-X POST \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{"description":"Development API key", "name":"development"}' \
"\${CATTLE_URL}/projects/"\$ACCOUNT_ID"/apikeys"\`