Skip to content

Instantly share code, notes, and snippets.

Compiled from "MatchVsVal.scala"
public class MatchVsVal {
public scala.Tuple2<java.lang.Object, java.lang.Object> source(int);
Code:
0: getstatic #17 // Field scala/Predef$.MODULE$:Lscala/Predef$;
3: invokevirtual #21 // Method scala/Predef$.$qmark$qmark$qmark:()Lscala/runtime/Nothing$;
6: athrow
public double matchVersion(int);
Code:
@squid314
squid314 / App.java
Last active October 7, 2019 01:09
A lambda does not close over local variables it does not reference.
import java.lang.ref.WeakReference;
import java.util.function.Supplier;
public class App {
public static void main(String[] args) {
System.out.println("Using lambda, does NOT hold on to unreferenced local variable:");
Object strong0 = new Object();
Supplier<WeakReference<Object>> s0 = lambda(strong0);
System.out.println(strong0);
System.out.println(s0.get());
@squid314
squid314 / gist:e274b0fd320957484507
Last active August 29, 2015 14:01 — forked from thomseddon/gist:4703810
Placeholder polyfill > Updated to allow the *remote possibility* that the user wants the value of the input to exactly match the placeholder value.
angular.module('test', [])
.directive('placeholder', function($timeout){
var i = document.createElement('input');
if ('placeholder' in i) {
return {}
}
return {
link: function(scope, elm, attrs){
if (attrs.type === 'password') {
return;
# git stuff (pulled from https://github.com/git/git/tree/master/contrib/completion)
if [ -f ~/.git-completion.bash ] ; then . ~/.git-completion.bash ; fi
if [ -f ~/.git-prompt.sh ] ; then . ~/.git-prompt.sh ; fi
# see .git-prompt.sh for explanation of the (and other) options
export GIT_PS1_SHOWDIRTYSTATE=true GIT_PS1_SHOWSTASHSTATE=true GIT_PS1_SHOWUPSTREAM=auto
# append history file after each command and execute the git PS1 embed generator
PROMPT_COMMAND='history -a ; MY_GIT_PS1="`__git_ps1`"'
# better prompt (window title gets directory and git info, nice colors, last cmd status indicator)
PS1='\[\e]0;\w$MY_GIT_PS1\007\e[0;1;34m\]\u \[\e[32m\]\w$MY_GIT_PS1 `[ $? -eq 0 ]&&echo ":)\[\e[0;31"||echo "\[\e[31m\]:(\[\e[21"`m\] \$\[\e[0m\] '