Skip to content

Instantly share code, notes, and snippets.

View alinpopa's full-sized avatar

Alin Popa alinpopa

View GitHub Profile
package org.test.uml
case class Object(name: String) {
def --(message: String) = (this, message)
def <--(message: String) = (this, message)
}
sealed trait Action
sealed case class Call(source: Object, verb: String, destination: Object) extends Action
sealed case class Async(source: Object, verb: String, destination: Object) extends Action
@alinpopa
alinpopa / validate2.erl
Created August 1, 2012 05:00
validate2.erl
validate_elements(ListOfLists) ->
lists:reverse(lists:foldl(fun(ValidationResult, Acc) ->
case ValidationResult of
ok -> Acc;
Else -> [Else | Acc]
end
end, [], lists:map(fun(Element) -> apply_validators(Element) end, ListOfLists))).
@alinpopa
alinpopa / validate1.erl
Created August 1, 2012 04:58
validate1.erl
lists:flatmap(fun(ListElement) -> apply_validators(ListElement) end, [[1,2,3], [4,5]])
@alinpopa
alinpopa / app.conf
Created April 20, 2012 20:47
app.conf
%% Riak KV config
{riak_kv, [
%% Storage_backend specifies the Erlang module defining the storage
%% mechanism that will be used on this node.
%{storage_backend, riak_kv_bitcask_backend},
{storage_backend, riak_kv_eleveldb_backend},
@alinpopa
alinpopa / Test.java
Created April 11, 2012 14:02
Test.java
String value = null;
if(weather.theSunIsUp()){
value = "Nice";
}
System.out.println("The weather is " + value);
@alinpopa
alinpopa / gist:1309937
Created October 24, 2011 19:41
Elasticsearch client hanging (too many open files)
2011-10-24 22:26:15
Full thread dump Java HotSpot(TM) 64-Bit Server VM (20.1-b02-383 mixed mode):
"elasticsearch[cached]-pool-1-thread-1" daemon prio=5 tid=7fe3a51e4800 nid=0x1175cc000 waiting for monitor entry [1175cb000]
java.lang.Thread.State: BLOCKED (on object monitor)
at org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler.sample(TransportClientNodesService.java:253)
- waiting to lock <7f40c0048> (a org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler)
at org.elasticsearch.client.transport.TransportClientNodesService$ScheduledNodeSampler.run(TransportClientNodesService.java:243)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
@alinpopa
alinpopa / gist:1281448
Created October 12, 2011 15:05 — forked from vshkurin/gist:1109136
elasticsearch analyzer example - Test Queries
# Index
---------------------------------------------------------------------
curl -XPUT http://localhost:9200/pictures/ -d '
{
"settings": {
"analysis": {
"analyzer": {
"index_analyzer": {
"tokenizer": "standard",
@alinpopa
alinpopa / elasticsearch.yml
Created October 12, 2011 15:05 — forked from pcdinh/elasticsearch.yml
elasticsearch.yml example
name: ${HOSTNAME}
# The cluster should be named with the name of the AD domain
cluster:
name: bldrprod-0.14.0
routing:
allocation:
# As small as possible, very large performance hits during recovery
concurrent_recoveries: 1
require 'thread'
class Context
class << self
def evaluate(&block)
self.new.instance_eval(&block)
end
end
def self.execute(&block)
self.new.instance_eval(&block)
@alinpopa
alinpopa / .gemrc
Created May 31, 2011 15:53
Ruby .gemrc
gem: --no-ri --no-rdoc