Skip to content

Instantly share code, notes, and snippets.

View gustavofranke's full-sized avatar

Gustavo Franke gustavofranke

View GitHub Profile

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

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

@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 / 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 / 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 {
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)
// Write some code, that will flatten an array of arbitrarily
// nested arrays of integers into a flat array of integers.
// e.g. [[1,2,[3]],4] -> [1,2,3,4].
val a = List(List(1,2,List(3)),4)
val b = List(1,2,List(3))
///////////////////
//implicit class WrapFlatten(val ls: List[Any]) {
def flatten(ls: List[Any]): List[Any] = ls flatMap {
case i: List[_] => flatten(i)
case e => List(e)
@gustavofranke
gustavofranke / fpis.sc
Created May 7, 2017 22:09
exercises from the amazing fpiscala
import scala.annotation.tailrec
/**
* EXERCISE 2.1
* Write a recursive function to get the nth Fibonacci number (http://mng.bz/C29s).
* The first two Fibonacci numbers are 0 and 1 . The nth number is always the sum of the
* previous two—the sequence begins 0, 1, 1, 2, 3, 5 . Your definition should use a
* local tail-recursive function.
*/
def fib(n: Int): Int = {