Skip to content

Instantly share code, notes, and snippets.

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

@efrenfuentes
efrenfuentes / main.go
Created June 5, 2018 00:53 — forked from walm/main.go
Simple Golang DNS Server
package main
import (
"fmt"
"log"
"strconv"
"github.com/miekg/dns"
)
@efrenfuentes
efrenfuentes / md5-example.go
Created May 12, 2018 00:10 — forked from sergiotapia/md5-example.go
Golang - How to hash a string using MD5.
import (
"crypto/md5"
"encoding/hex"
)
func GetMD5Hash(text string) string {
hasher := md5.New()
hasher.Write([]byte(text))
return hex.EncodeToString(hasher.Sum(nil))
}
@efrenfuentes
efrenfuentes / install.sh
Created October 1, 2017 16:34 — forked from swelham/install.sh
Install Elixir on c9.io
sudo touch /etc/init.d/couchdb
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
sudo apt-get update
sudo apt-get -y install elixir erlang-dev
rm erlang-solutions_1.0_all.deb
sudo yum -y install gcc gcc-c++ glibc-devel make ncurses-devel openssl-devel autoconf java-1.8.0-openjdk-devel git
sudo yum -y install wxBase.x86_64
sudo yum -y install wget
wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
sudo rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
sudo yum -y install esl-erlang
sudo mkdir /opt/elixir
sudo git clone https://github.com/elixir-lang/elixir.git /opt/elixir
cd /opt/elixir
sudo make clean test
@efrenfuentes
efrenfuentes / periodically.ex
Created September 23, 2016 14:14
Ejecutar proceso periodicamente en Elixir
defmodule MyApp.Periodically do
use GenServer
def start_link do
GenServer.start_link(__MODULE__, %{})
end
def init(state) do
schedule_work() # Schedule work to be performed at some point
{:ok, state}
@efrenfuentes
efrenfuentes / slack_nagios.rb
Last active June 14, 2016 13:57
Send Nagios notifications to slack
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'json'
WEB_HOOK = 'https://hooks.slack.com/services/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'
def arguments_to_field
fields = {}
@efrenfuentes
efrenfuentes / roman.rb
Last active June 10, 2016 20:46
Romans
# Roman numbers values
ROMAN_VALUES = {
1000 => "M",
900 => "CM",
500 => "D",
400 => "CD",
100 => "C",
90 => "XC",
50 => "L",
@efrenfuentes
efrenfuentes / histogram.py
Last active June 1, 2016 18:40
Histogram 2
#!/usr/bin/env python
import operator
import re
def histogram_for(text):
text = re.sub('[!@#$-]', '', text)
words = text.lower().split()
frequency = {}
for word in words:
@efrenfuentes
efrenfuentes / histogram.rb
Last active June 1, 2016 18:06
Histogram
def histogram_for(text)
words = text.split(' ')
frequency = Hash.new(0)
words.each { |word| frequency[word.downcase] += 1 }
frequency.sort_by {|_key, value| value}.to_h
end
# Read file