This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(angular){ | |
"use strict"; | |
/** | |
* Patched $injector.invoke | |
* | |
* It allows in many situations to avoid promise related boilerplate like | |
* | |
* factory('$loggedUser',['$login','$loadedConfig',function($login,$loadedConfig){ | |
* return $login.then(function($login){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('EventTarget',[]) | |
.run(['$injector',function($injector){ | |
function removeFromList(list,item) { | |
var next = item.next || null | |
var prev = item.prev || null | |
if (prev) { | |
prev.next = next | |
} | |
else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Kotlin example | |
class Delegate() { | |
fun get(obj: String, desc: PropertyMetadataImpl) : String = obj.toString() + ".log" | |
} | |
val String.log by Delegate() | |
fun main(args : Array<String>) { | |
println("Hello, world!".log) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package angular.demo | |
import angular.* | |
object HelloWorldModule : Module("HelloWorld") { | |
val hello = constant("hello", "Hello") | |
val world: String by factory("world") {"World"} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Typed class GridGainTest { | |
public static void main(String[] args) { | |
def local = GridFactory.start("spring-cache.xml").localNode | |
local.remoteListenAsync(local) { nid, String msg -> | |
// we infer of course that this is GridListenActor | |
grid () | |
// we infer nid instanceof UUID | |
println nid.leastSignificantBits | |
println msg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Typed package example | |
import org.mbte.gretty.httpserver.GrettyServer | |
new GrettyServer() [ | |
// server local address | |
localAddress: new InetSocketAddress(8081), | |
// directory where to find static resources | |
static: "../static", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Typed package p | |
import java.util.concurrent.Executors | |
import java.util.concurrent.CountDownLatch | |
import groovypp.channels.ExecutingChannel | |
import java.util.concurrent.TimeUnit | |
def pool = Executors.newFixedThreadPool(8) | |
def t1 = System.currentTimeMillis() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ForkJoinPool fjPool = [] | |
def res = fjPool.map(2..<15){ arg -> | |
// We are in AsyncTaskWithArg<Integer,Integer> | |
// function which take Integer param and calculate Integer | |
// both types are type inferenced | |
// | |
// method map will fork copy of the task for each element of given Iterable ( 2..<15 Range in this case) | |
// and when all results ready will merge them in to List<Integer> | |
// The task itself (the one applied to each element) uses fork/join (which is stupid for Fibonacci) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract static class Listener<T> { | |
abstract void call(T oldValue, T newValue) | |
} | |
private FList<Listener<T>> listeners = FList.emptyList | |
final Listener<T> addListener(Listener<T> listener, Executor executor = null) { | |
if(executor) { | |
def myListener = listener | |
listener = { oldValue, newValue -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Java version | |
Parameter param = new Parameter(ClassHelper.OBJECT_TYPE, "$it"); | |
VariableExpression ve = new VariableExpression(param); | |
ve.setSourcePosition(originalProperty); | |
PropertyExpression prop = new PropertyExpression(ve, originalProperty); | |
prop.setSourcePosition(originalProperty); | |
ReturnStatement retStat = new ReturnStatement(prop); | |
retStat.setSourcePosition(originalProperty); |
NewerOlder