- list local configs:
git config --list
- create a branch:
git branch testing
, testing is the branch name - point to a branch:
git checkout testing
git checkout master
- create and point to a branch:
git checkout -b testing
- list of current branches:
git branch
- merge:
git checkout master
;git merge testing
- delete a branch:
git branch -d testing
- to point a local copy to a different url: git remote set-url origin
- to revert all changes to be just like remote repository head:
git fetch origin
&&git reset --hard origin/master
I just had to set up Jenkins to use GitHub. My notes (to myself, mostly):
For setting up Jenkins to build GitHub projects. This assumes some ability to manage Jenkins, use the command line, set up a utility LDAP account, etc. Please share or improve this Gist as needed.
- get both the git and github plugin
- http://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin
Ctrl + a – go to the start of the command line
Ctrl + e – go to the end of the command line
Ctrl + k – delete from cursor to the end of the command line
Ctrl + u – delete from cursor to the start of the command line
Ctrl + w – delete from cursor to start of word (i.e. delete backwards one word)
Ctrl + y – paste word or text that was cut using one of the deletion shortcuts (such as the one above) after the cursor
Ctrl + xx – move between start of command line and current cursor position (and back again)
Alt + b – move backward one word (or go to start of word the cursor is currently on)
Alt + f – move forward one word (or go to end of word the cursor is currently on)
Alt + d – delete to end of word starting at cursor (whole word if cursor is at the beginning of word)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Test; | |
import static org.junit.Assert.*; | |
public class MyTest { | |
@Test | |
public void shouldReturnASDF() { | |
assertEquals("asdf", MySingleton.INSTANCE.asdf()); | |
} | |
@Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val z: Int => Int = _ + 1 | |
val y = z(3) | |
val x = z | |
val sum: (Int, Int) => Int = _ + _ | |
val sumCurried: Int => Int => Int = sum.curried | |
sum(1,2) | |
sumCurried(1)(2) | |
val w = sumCurried(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.util.Try | |
val a = Try(5 / 0) | |
a.isSuccess | |
a.isFailure | |
a.toOption | |
a.failed | |
a.orElse(Try(1)) | |
a.recoverWith { case _ ⇒ Try(1) } | |
a.getOrElse("boom") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Bird { | |
val name: String | |
} | |
trait Flying { | |
def flyMessage: String | |
def fly() = println(flyMessage) | |
} | |
trait Swimming { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rev[A](str: List[A]): List[A] = str match { | |
case Nil => Nil | |
case x :: Nil => x :: Nil | |
case x :: y :: Nil => y :: x :: Nil | |
case x :: xs => xs.last +: rev(xs.init) :+ x | |
} | |
val gus = "Gustavo".toList //gus: List[Char] = List(G, u, s, t, a, v, o) | |
rev(gus) //res0: List[Char] = List(o, v, a, t, s, u, G) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////// Implicit parameter | |
def giveMeAnInt(implicit i: Int) = i | |
giveMeAnInt(123) | |
implicit val someInt: Int = 42 | |
giveMeAnInt | |
giveMeAnInt(321) | |
def makeString(i: Int): String = s"makeString: ${i.toString}" | |
makeString(1) |
OlderNewer