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
| @EnableWebSecurity | |
| public class SecurityConfig { | |
| @Value("${security.enabled:false}") | |
| private Boolean security_enabled; | |
| @Configuration | |
| @Order(1) | |
| public class BasicSecurityConfig extends WebSecurityConfigurerAdapter { | |
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
| { | |
| "languageModel": { | |
| "types": [ | |
| { | |
| "name": "power_states", | |
| "values": [ | |
| { | |
| "id": null, | |
| "name": { | |
| "value": "on", |
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
| @ask.intent("TVPowerIntent", convert={'power':str}) | |
| def sourcetv(power): | |
| power = power.lower() | |
| msg = "Sorry! batman did not recognise your command" | |
| if power == "on": | |
| subprocess.check_output('echo "on 0" | cec-client RPI -s -d 1', shell=True) | |
| msg = render_template('confirmed', confirmation="the t.v. is now on") | |
| elif power == "off": | |
| subprocess.check_output('echo "standby 0" | cec-client RPI -s -d 1', shell=True) | |
| msg = render_template('confirmed', confirmation="the t.v. is now off") |
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
| for bucket in res['transactions']['buckets']: | |
| key1 = bucket['key'] | |
| for innerbucket1 in bucket['BySourceAddress']: | |
| key2 = innerbucket1['key'] | |
| for innerbucket2 in innerbucket1['buckets']: | |
| key3 = innerbucket2['key'] | |
| for innerbucket3 in innerbucket2['buckets']: | |
| key4 = innerbucket3['key'] | |
| print "({},{}.{},{})".format(key1,key2,key3,key4) |
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
| from rx import Observable, Observer | |
| def getAggregation(transaction, aggName): | |
| return Observable.from_(transaction[aggName]["buckets"]) | |
| getAggregation(res["aggregations"],"transactions") \ | |
| .flat_map(lambda transaction : getAggregation(transaction, 'BySourceAddress').map(lambda b: (transaction["key"],b) ) ) \ | |
| .flat_map(lambda transaction : getAggregation(transaction[1], 'ByASN').map(lambda b: (transaction[0],transaction[1]["key"],b) ) ) \ | |
| .flat_map(lambda transaction : getAggregation(transaction[2], 'ByDestPort').map(lambda b: (transaction[0],transaction[1],transaction[2]["key"],b) ) ) \ | |
| .map(lambda t : (t[0], t[1],t[2], t[3]["key"])) \ |
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
| { | |
| "aggregations": { | |
| "transactions": { | |
| "buckets": [ | |
| { | |
| "key": 1512720000000, | |
| "BySourceAddress": { | |
| "buckets": [ | |
| { | |
| "key": "192.168.2.2", |
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
| var cy = cytoscape({ | |
| container: document.getElementById('graphNetwork'), // container to render in | |
| elements: cytoscape_elements, // list of graph elements | |
| style: [ // the stylesheet for the graph | |
| { |
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
| edges = [["192.168.1.1","1.1.1.1"],["192.168.2.1","2.2.2.2"], ...] //sample data - in reality you'd probably get this from an API | |
| let id_counter = 0; | |
| external_nodes.forEach(function(element){ | |
| const src = element[0]; | |
| const dst = element[1]; | |
| cytoscape_elements.push({ | |
| data: { |
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
| external_nodes = [["1.1.1.1", 0.23],["2.2.2.2", 0.85], ...] //sample data - in reality you'd probably get this from an API | |
| external_nodes.forEach(function(element){ | |
| const label = element[0]; | |
| const confidence = element[1]; | |
| cytoscape_elements.push({ | |
| data: { | |
| id: label, | |
| label: label, |
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
| import * as d3 from "d3"; | |
| let node_color_scale = d3.scaleLinear() | |
| .domain([0, 0.5, 1]) | |
| .range([d3.rgb("#96f788"), d3.rgb('#f9f370'), d3.rgb('#f27676')]); |