Skip to content

Instantly share code, notes, and snippets.

View gustavofranke's full-sized avatar

Gustavo Franke gustavofranke

View GitHub Profile
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 / traits-basic.scala
Created March 8, 2017 14:48
traits-basic.scala
trait Bird {
val name: String
}
trait Flying {
def flyMessage: String
def fly() = println(flyMessage)
}
trait Swimming {
@gustavofranke
gustavofranke / scala-try-type.scala
Created February 22, 2017 13:59
scala try type
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")
@gustavofranke
gustavofranke / curry.scala
Created February 17, 2017 17:23
playing with curryfied functions
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)
@gustavofranke
gustavofranke / MyTest.java
Created February 5, 2016 14:00
Singleton with Enum in Java
import org.junit.Test;
import static org.junit.Assert.*;
public class MyTest {
@Test
public void shouldReturnASDF() {
assertEquals("asdf", MySingleton.INSTANCE.asdf());
}
@Test
  • 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 / Linux basics.md
Last active April 18, 2016 14:42
Basic use cases of cmd line programs

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' {} ;

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 / git-basics.md
Last active January 25, 2021 17:15
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