Skip to content

Instantly share code, notes, and snippets.

@canton7
canton7 / initial tracking
Created May 20, 2011 20:20
Tracking in Git
Scenario | Tracking set up
----------------------------------------------------------------------------------|-----------------
Clone a (non-emtpy) repo, use the branch which is checked out automatically | Y
Push a branch to a remote, that doesn't exist on the remote | N
Push a branch to a remote, that doesn't exist on the remote, with push -u | Y
Checkout a branch from a remote, without -t (specified or implied) | N
Checkout a branch from a remote, with -t (specified or implied) | Y
@canton7
canton7 / gist:1053846
Created June 29, 2011 13:35
git push, tracking, and push.default

git clone path/to/test/repo.git

push.default = matching (the default)

git config push.default matching

git branch -a
   * master

Installing LaTeX + TeXstudio

  1. Grab MiKTeX 2.9 and install. It doesn't really matter whether you get the complete or basic system, as the basic system will download packages as needed.
  2. Grab TeXstudio and install.
  3. Fire up TeXstudio and hit Options -> Configure TexStudio.
  4. Under "Commands", change "Bibtex" from "bibtex %" to "bibtex8 %" (bibtex8 is later and greater and is needed for biblatex, which is better than bibtex for reference handling).
  5. Under "Quick Build", check "PdfLaTeX + Ldf Viewer". Not all LaTeX compilers were created equal, and Pdf is likely the format you'll want.
  6. If you're feeling adventurous, go to "Editor" and change the font family to "Consolas" :)
@canton7
canton7 / gist:1193421
Created September 4, 2011 20:06
Different ways of creating new local tracking branches

Ways to create a new local branch, tracking a remote branch

Create a new local branch with the same name as the remote one

git checkout <remote_branch_name>
git checkout -t <remote>/<remote_branch_name>

Create a new local branch with a different name to the remote one

@canton7
canton7 / gist:1268587
Last active October 18, 2016 19:40
git merge -s theirs

How to do a git merge -s theirs

One way of many...

This is one way which keeps the history looking like you'd expect.

Command is equivalent to git checkout MINE; git merge -s theirs HERS.

@canton7
canton7 / gist:1339179
Created November 4, 2011 11:50
Useful git aliases

Useful git aliases

Command-line graphical log viewer

This is invaluable if you've managed to get yourself in a muddle.

git config --global alias.graph git log --graph --oneline --decorate --all
@canton7
canton7 / 0main.md
Last active November 7, 2023 08:16
Local versions of tracked config files

How to have local versions of tracked config files in git

This is a fairly common question, and there isn't a One True Answer.

These are the most common techniques:

If you can modify your application

@canton7
canton7 / 0_main.md
Created January 6, 2012 13:45
Workflows for long-running feature branches

Workflows for long-running feature branches

These examples were created during a discussion with j416 on #github about how best to manage long-running feature branches.

The scenario is this: You have a long-running feature branch, based off master. The feature branch and master both touch the same parts of the same files, so you know that there will be conflicts when you finally merge the feature branch in. What can you do to minimise the conflicts?

@canton7
canton7 / Sample DataMapper model.rb
Last active September 10, 2018 03:16
Sinatra Auth in a Box
# From bcrypt-ruby gem
require 'bcrypt'
class User
include DataMapper::Resource
attr_accessor :password, :password_confirmation
property :id, Serial
property :username, String, :required => true, :length => (2..32), :unique => true
property :password_hash, String, :length => 60
@canton7
canton7 / gist:2146783
Created March 21, 2012 13:07
Enumerable#with_props

Enumerable#with_props

This is a little monkey-patch to add a new method to Enumerable, #with_props.

You use it something like this:

[1, 2, 3, 4].each.with_props do |element, props|
   puts "First? #{props.first?}"