Skip to content

Instantly share code, notes, and snippets.

Avatar

Gustavo Franke gustavofranke

View GitHub Profile
View git-basics.md
  • 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
View jenkins-notes.md

I just had to set up Jenkins to use GitHub. My notes (to myself, mostly):

Detailed Instructions

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.

Install Jenkins Plugins

@gustavofranke
gustavofranke / Linux basics.md
Last active Apr 18, 2016
Basic use cases of cmd line programs
View Linux basics.md

GREP

Filter by file extension: grep -r --include \*.java <the-expression> .

Recursive Find and Replace

find ./ -type f -readable -writable -exec sed -i 's/this/by that/g' {} ;

View cmd-line.md
  • 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)
@gustavofranke
gustavofranke / MyTest.java
Created Feb 5, 2016
Singleton with Enum in Java
View MyTest.java
import org.junit.Test;
import static org.junit.Assert.*;
public class MyTest {
@Test
public void shouldReturnASDF() {
assertEquals("asdf", MySingleton.INSTANCE.asdf());
}
@Test
@gustavofranke
gustavofranke / curry.scala
Created Feb 17, 2017
playing with curryfied functions
View curry.scala
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)
View scala-try-type.scala
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")
View traits-basic.scala
trait Bird {
val name: String
}
trait Flying {
def flyMessage: String
def fly() = println(flyMessage)
}
trait Swimming {
View reverse-string.scala
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)
@gustavofranke
gustavofranke / implic.sc
Last active Jan 27, 2018
implicit examples
View implic.sc
//////// 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)