Skip to content

Instantly share code, notes, and snippets.

git show <commit-sha> -- <file> | git apply -R
To remove a submodule you need to:
- Delete the relevant section from the .gitmodules file.
- Stage the .gitmodules changes git add .gitmodules
- Delete the relevant section from .git/config.
- Run git rm --cached path_to_submodule (no trailing slash).
- Run rm -rf .git/modules/path_to_submodule (no trailing slash).
- Commit git commit -m "Removed submodule "
- Delete the now untracked submodule files rm -rf path_to_submodule
1- Install
brew install bash
2- List bashes
$ which -a bash
/usr/local/bin/bash
/bin/bash
3- Check versions
$ /usr/local/bin/bash --version
GNU bash, version 5.0.0(1)-release (x86_64-apple-darwin18.2.0) ...
$ /bin/bash --version
@turgay
turgay / terraform-get-by-name
Created December 14, 2019 00:25
Terraform: Get a VPC by name
//file: provider.tf
provider "aws" {
region = "us-east-1"
}
//file: vpc.tf
variable "vpc_name" {}
data "aws_vpc" "selected" {
tags = {
Prune all branches locally not existing in remote in Git:
git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done
@turgay
turgay / sources.list
Created September 26, 2018 06:39 — forked from rohitrawat/sources.list
Ubuntu 16.04 Xenial default /etc/apt/sources.list
#deb cdrom:[Ubuntu 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.2)]/ xenial main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
Search by timestamp:
timestamp:["2014-12-01 00:00:00.000" TO "2014-12-31 00:00:00.000"]
@turgay
turgay / DuplicateFinder.clj
Last active July 15, 2020 03:11
Find duplicates in a sequence using Clojure
(defn extract-names [seq]
(for [lib seq :let [dot-index (.indexOf lib ".")]]
(subs lib 0 (- dot-index 2))))
;(println (extract-names ["x-security-1.0.7.jar" "aksis-1.0.jar" "antlr-2.7.6.jar"]))
(defn dups [seq]
(for [[id freq] (frequencies seq) ;; get the frequencies, destructure
:when (> freq 1)] ;; this is the filter condition
@turgay
turgay / barber.go
Created October 14, 2015 15:35 — forked from kachayev/barber.go
Solve "Sleeping Barber Problem" with Golang (more about problem - http://en.wikipedia.org/wiki/Sleeping_barber_problem)
package main
import (
"fmt"
"time"
"math/rand"
)
const (
CUTTING_TIME = 20