Skip to content

Instantly share code, notes, and snippets.

here is my mustard to the types topic:
- it’s more effort to serve to types.
- the effort is only worth in some cases, so it would be nice to opt-in (e.g. business logic) or opt-out (boilerplate, gluecode) to types anytime.
- with types the developers get some of the errors in their face and not the customer
- dependent types are the future in my world (https://en.wikipedia.org/wiki/Dependent_type)
- if we (js-devs) would just have something like the stanley millner typesystem then we would have a compromise between effort and runtime safety: https://drboolean.gitbooks.io/mostly-adequate-guide/content/ch7.html
- static analysis through types would give me a more powerful Webstorm than ever
- some problems (e.g. promise is not returned, promise chain broken) can also be detected by eslint (https://github.com/xjamundx/eslint-plugin-promise)
- union types, the absence of `null`/`nil`/`undefined`, the Maybe Type are things that a developer in 2017 should know and value. (https://robots.thoughtbot.com/modeli
echo "Spawning 100 processes"
for i in {1..100} ; do ( rake jobs:work & ) ; done
@snackycracky
snackycracky / brand_markets.rb
Created March 3, 2014 09:14
transform string
brand_market_combinations.collect{|it|it.first}.uniq.each{|brand| puts "{'#{brand}'=> [#{brand_market_combinations.find_all{|it|it.first == brand}.collect{|it| "'#{it.second}'"}.join(', ')}]}," }
echo "ETag: \"1aawecvf23\"" | grep -o "[^ETag:\ \"]\(.*\)[^\"]"
ergibt: 1aawecvf23
inject
public Object inject(Object initialValue, Closure closure)
Iterates through the given Collection, passing in the initial value to the 2-arg closure along with the first item. The result is passed back (injected) into the closure along with the second item. The new result is injected back into the closure along with the third item and so on until the entire collection has been used. Also known as foldLeft in functional parlance. Examples:
assert 1*1*2*3*4 == [1,2,3,4].inject(1) { acc, val -> acc * val }
assert 0+1+2+3+4 == [1,2,3,4].inject(0) { acc, val -> acc + val }
assert 'The quick brown fox' ==
@Grab(group='org.codehaus.gpars', module='gpars', version='0.11')
import groovyx.gpars.actor.DynamicDispatchActor
import org.codehaus.groovy.runtime.NullObject
final class MyActor extends DynamicDispatchActor {
private int counter = 0
void onMessage(String message) {
counter += message.size()
println 'Received string'
@snackycracky
snackycracky / groovyx.gpars.GParsPool
Created June 24, 2011 09:17
Step 3 - Experiment with parallel collection processing
@Grab(group='org.codehaus.gpars', module='gpars', version='0.11')
import groovyx.gpars.GParsPool
def x,y
GParsPool.withPool {
def animals = ['dog', 'ant', 'cat', 'whale']
x = animals.anyParallel {it ==~ /ant/} ? 'Found an ant' : 'No ants found'
y = animals.everyParallel {it.contains('a')} ? 'All animals contain a' : 'Some animals can live without an a'
}
println x
println y