Skip to content

Instantly share code, notes, and snippets.

View davengeo's full-sized avatar
🏠
Working from home

David Navarro davengeo

🏠
Working from home
View GitHub Profile
@davengeo
davengeo / remove-rels.ajs
Created September 19, 2019 09:22
#jArchi remove visible relationships of a selected element in a diagram
console.log("remove visible relationships");
$(selection).rels().each(function(r) {
v = r.view;
i = r.id;
$(v).find("relationship").each(function(f) {
if (i==f.id) {
console.log("deleting:"+f.id);
f.delete();
}
@davengeo
davengeo / copy-paste-simple.ajs
Created September 19, 2019 09:20
#jArchi very simple copy paste between models for lazy people
console.log("copy paste");
from = $(selection).first();
a = {};
a.name = from.name;
a.documentation = from.documentation;
a.type = from.type
b = from.prop();
@davengeo
davengeo / heatmap.ajs
Last active August 2, 2020 19:14
#jarchi heatmap for custom boolean property
var getDiagramComponents = function(v, e) {
return $(v).find("concept").filter(function(o) {
return o.concept.id == e.id;
});
}
gap = $("element").filter(function(obj) {
return obj.prop("GAP") == "true" ? true : false;
});
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class DemoApplicationTests {
private static final String NAMESPACE = "distributedlog://127.0.0.1:2181/messaging/distributedlog/testing";
@Autowired
JtaTransactionManager jtaTransactionManager;
private DistributedLogManager managerOne, managerTwo;
//trivial means trivial
@Test
public void transactionInDlog() throws SystemException, IOException {
final Namespace namespace = Factories.namespace(NAMESPACE).get();
final DistributedLogManager managerOne = namespace.openLog("stream-1");
final DistributedLogManager managerTwo = namespace.openLog("stream-2");
managerOne.delete();
managerTwo.delete();
final LogWriter logWriterOne = managerOne.openLogWriter();
@davengeo
davengeo / sort1.go
Last active February 25, 2017 16:26
Small sorting kata with Deniss Borisov
package main
import (
"fmt"
"strconv"
"reflect"
)
/* TODO:
1. Fill the array from lines in a file
@davengeo
davengeo / bulk-gets-fix.js
Created February 15, 2017 14:29
fix for protocol mismatch between sync-gw and pouchdb
const express = require('express'),
request = require('request'),
_ = require('lodash'),
config = { syncGwAdmin: 'http://localhost:4985', db: 'my-db' };
let router = express.Router();
let rebuildDocs = function(body) {
const parts = body.split(/\r\n|\r|\n/g);
return _.reduce(
@davengeo
davengeo / serviced-client.js
Last active September 15, 2016 19:34
getIpvalue in javascript
function getPublicAddress() {
let interfaces = os.networkInterfaces();
return _.chain(interfaces)
.filter(function(o) {
return o[0].family == 'IPv4' && !_.startsWith(o[0].address, '192.168');
})
.flatten()
.value();
}
@davengeo
davengeo / ChainOfMessageProcessors.java
Created April 25, 2016 16:37
My first default method in java 8
public interface ChainOfMessageProcessors extends MessagePostProcessor {
void setNext(ChainOfMessageProcessors next);
ChainOfMessageProcessors next();
default Message toNext(Message message) throws JMSException {
if (next()!=null) {
return next().postProcessMessage(message);
}
@davengeo
davengeo / TrivialIT.java
Created February 11, 2016 12:17
useful IT test to list the beans
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = {
Application.class,
TrivialIT.PostConfiguration.class
})
@WebAppConfiguration
@IntegrationTest("server.port=0")
@ActiveProfiles({"default", "test"})
@ConfigurationProperties("application.yml")
public class TrivialIT {