Skip to content

Instantly share code, notes, and snippets.

@benve
benve / Regex.scala
Created June 8, 2011 09:48
Esempi in Scala
//http://daily-scala.blogspot.com/2010/01/regular-expression-3-regex-matching.html
val date = "11/01/2010"
val Date = """(\d\d)/(\d\d)/(\d\d\d\d)""".r
val Date(day, month, year) = date
println(day)
println(month)
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 24, 2024 17:56
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@benve
benve / JVM.md
Last active July 21, 2020 03:29
Link ed esempi su come monitorare e migliorare le performance della JVM
@takawitter
takawitter / ScalaJSR223Test.java
Last active March 12, 2021 10:38
The sample code to run scala via JSR223 API. I turn usejavacp option true at line 10. Unless that you have to use http://github.com/rjolly/jarlister to list classes in scala-library.jar into MANIFEST.MF of jar that contains this ScalaTest class. I use Scala-2.11.6 to run this code.
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import scala.tools.nsc.interpreter.IMain;
import scala.tools.nsc.settings.MutableSettings.BooleanSetting;
public class ScalaTest {
public static void main(String[] args) throws Exception{
ScriptEngine engine = new ScriptEngineManager().getEngineByName("scala");
((BooleanSetting)(((IMain)engine).settings().usejavacp())).value_$eq(true);
@viktorklang
viktorklang / gbr.txt
Created June 30, 2015 08:43
shell alias for showing git branches sorted by last activity date
alias gbr='git for-each-ref --sort="-authordate:iso8601" --format=" %(color:green)%(authordate:iso8601)%09%(color:white)%(refname:short)" refs/heads'

10 Scala One Liners to Impress Your Friends

Here are 10 one-liners which show the power of scala programming, impress your friends and woo women; ok, maybe not. However, these one liners are a good set of examples using functional programming and scala syntax you may not be familiar with. I feel there is no better way to learn than to see real examples.

Updated: June 17, 2011 - I'm amazed at the popularity of this post, glad everyone enjoyed it and to see it duplicated across so many languages. I've included some of the suggestions to shorten up some of my scala examples. Some I intentionally left longer as a way for explaining / understanding what the functions were doing, not necessarily to produce the shortest possible code; so I'll include both.

1. Multiple Each Item in a List by 2

The map function takes each element in the list and applies it to the corresponding function. In this example, we take each element and multiply it by 2. This will return a list of equivalent size, compare to o

@eginez
eginez / goGraal.md
Last active March 3, 2022 20:58
Graal and PseudoGo

I was reviewing some documents on the graalvm and its truffle languages and it occured to me that one could write a go ast to LLVM IR emitter. Go has pretty good support for ast operations, thus it looked feasable at least. Obviously next thing I did was to check and see if someone had already done this. And yes.There is a project doing exactly that.

The support for the language is not all there yet and honestly I don't think this is the most sustainable approach but it was fun to play with it. I got some minimal go(tre) code running through graal's lli pretty fast

Ingredients