I have "Super+Alt+left" to set the layout so that the left pane is wider (66%) of the screen:
I would also like the same key stroke to focus on the left tab so that I can start typing immediately without a click or Ctrl + 0.
Here's what I tried. I added a new plugin:
import sublime, sublime_plugin
class ExpandAndFocusLeftPane(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command("focus_group", "args": {"group": 0})
self.view.run_command("set_layout", "args": {
"cols": [0.0, 0.66, 1.0],
"rows": [0.0, 1.0],
"cells": [[0, 0, 1, 1], [1, 0, 2, 1]]
})
And I bound "Super+Alt+Left" to this new command.
{
"keys": ["super+alt+left"],
"command": "expand_and_focus_left_pane",
"args":
{
"cols": [0.0, 0.66, 1.0],
"rows": [0.0, 1.0],
"cells": [[0, 0, 1, 1], [1, 0, 2, 1]]
}
},
But it still does not do what i want it to do. Any ideas ?
First, you have to check if the "focus_group" and "set_layout" commands work as expected.
Open the console (View->Show Console) and try this:
view.run_command("focus_group", "args": {"group": 0})
You'll get a:
File "<string>", line 1
view.run_command("focus_group", "args": {"group": 0})
^
SyntaxError: invalid syntax
If you change it to
view.run_command("focus_group", {"group": 0})
it won't work. That's because "focus_group" and "set_layout" are window commands, so this will work:
window.run_command("focus_group", {"group": 0})
window.run_command("set_layout", { "cols": [0.0, 0.66, 1.0], "rows": [0.0, 1.0], "cells": [[0, 0, 1, 1], [1, 0, 2, 1]] })
So your plugin should extend sublime_plugin.WindowCommand and use self.window:
class ExpandAndFocusLeftPaneCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command("focus_group", {"group": 0})
self.window.run_command("set_layout", {
"cols": [0.0, 0.66, 1.0],
"rows": [0.0, 1.0],
"cells": [[0, 0, 1, 1], [1, 0, 2, 1]]
})
And ExpandAndFocusLeftPane should be ExpandAndFocusLeftPaneCommand.
Related
I am using a xAPI Playground for testing, link here:
https://playground.xapi.pro/
I want to edit/modify existing position with command: tradeTransaction
Documentation says to modify existing position I should use "type" as 3 and "cmd" should match existing position (0 for BUY and 1 for SELL)
{
"command": "tradeTransaction",
"arguments": {
"tradeTransInfo": {
"cmd": 1,
"customComment": "Some text",
"expiration": 0,
"order": order_number_as_int ,
"price": open_price_as_double,
"sl": my_double_value,
"tp": my_another_double_value,
"symbol": "f.e. OIL.WTI",
"type": 3,
"volume": 0.01
}
}
}
Error code
{
"status": false,
"errorCode": "SE199",
"errorDescr": "Internal error"
}
All possible data collected from API about existing position:
{'cmd': 1, 'order': 474325736, 'digits': 2, 'offset': 0, 'order2': 474325838, 'position': 474325736, 'symbol': 'OIL.WTI', 'comment': '', 'customComment': '', 'commission': 0.0, 'storage': 0.0, 'margin_rate': 0.0, 'close_price': 76.65, 'open_price': 76.57, 'nominalValue': 0.0, 'profit': -3.56, 'volume': 0.01, 'sl': 80.0, 'tp': 70.0, 'closed': False, 'timestamp': 1676665564666, 'spread': 0, 'taxes': 0.0, 'open_time': 1676663063081, 'open_timeString': 'Fri Feb 17 20:44:23 CET 2023', 'close_time': None, 'close_timeString': None, 'expiration': None, 'expirationString': None},
API documentation is here:
http://developers.xstore.pro/documentation/#tradeTransaction
Ofc I tried every possible value in "cmd" and "type" but it does not help.
Error code sometimes are diffrent, f. e:
{
"command": "tradeTransaction",
"arguments": {
"tradeTransInfo": {
"cmd": 3,
"customComment": "Some text",
"expiration": 0,
"order": 474325838,
"price": 0,
"sl": 0,
"tp": 0,
"symbol": "OIL.WTI",
"type": 3,
"volume": 0.01
}
}
}
Error code:
{
"status": false,
"errorCode": "BE4",
"errorDescr": "remaining nominal must be greater than zero"
}
Any ideas what I can do wrong?
I am in touch with XTB support, still waiting for response.
Thanks in advance for any help!
I have some position & time values describing movement of some vehicle. But in some time intervals vehicle wait in some position. I cant figure out how can i set waiting time.?
In the example data provided below : position values corresponding to 40 and 50 are same = (4, 4 ,0) That means vehicle wait 10 second in that position. But it doesn't work because of interpolation.
Ex :
"position":{
"interpolationAlgorithm":"LAGRANGE",
"interpolationDegree":1,
"epoch":"2012-08-04T16:00:00Z",
"cartesian": [
0.0, 0, 0, 0,
10.0, 1 ,1 ,0,
20.0, 2, 2, 0,
30.0, 3, 3, 0,
40.0, 4, 4, 0,
50.0, 4, 4, 0
]
}
After some research I found that we can use "interval" property. Such that :
"position" : [
{
"interval": "2018-08-07T23:50:00Z/2018-08-08T00:09:00Z",
"cartographicDegrees" : [
"2018-08-07T23:50:00Z", 39.8495,43.3802,0,
"2018-08-08T00:00:00Z", 39.8734,43.4129,0,
"2018-08-08T00:09:00Z", 39.8048,43.4324,0
],
"interpolationAlgorithm": "LAGRANGE",
"interpolationDegree": 5
},
{
"interval": "2018-08-08T00:09:00Z/2018-08-08T00:11:00Z",
"cartographicDegrees" : [39.8048,43.4324,0]
},
...
I'm looking for errors in a data file because it's making a game to get stucked and not start. I'm absolutely ignorant in programming, so don't kill me if this is senseless.
The error (JSONLint):
Error: Parse error on line 6782:
...cSpeciesCached": 0.0
-----------------------^
Expecting '}', ',', got 'EOF'
The last part of the file:
"facilities": [{
"cityID": "Qk3s7KAzLwUz7v0KQjUdCZyW0X2x9rZc",
"constructionType": 0,
"constructionTimer": {
"repeatMax": 7200,
"timeInterval": 4680,
"hasFired": true,
"repeats": false,
"shouldCatchUp": true,
"shouldStop": true,
"iterationThreshold": 2340,
"iterations": 19849
},
"upgradeTimer": {
"repeatMax": 7200,
"timeInterval": 3600,
"hasFired": true,
"repeats": false,
"shouldCatchUp": true,
"shouldStop": true,
"iterationThreshold": 1800,
"iterations": 3606
},
"facilityID": "HA17AvUZYVNrGIW64FrOOzx5eIXyX2vG",
"type": 33,
"level": 2,
"isDisabled": false,
"isOnMoon": true,
"heatCached": 0.0,
"airPressureCached": 0.0,
"oxygenContentCached": 0.0,
"seaLevelCached": 0.0,
"biomassCached": 0.0,
"aquaticSpeciesCached": 0.0
The whole file is 6782 lines long, I think this is too big for finding an error, is it?
I have the following Json data (extract) that I use to graph a dual Y axis chart with amchart:
[{"Day":"24-05 10H","Production":"0.82431267","USD":"482.02837415988"},{"Day":"24-05 11H","Production":"0.83045272","USD":"485.61885435808"},{"Day":"24-05 12H","Production":"0.83441691","USD":"487.93696995924"},{"Day":"24-05 01H","Production":"0.84323421","USD":"493.09300957644"},{"Day":"24-05 02H","Production":"0.85096095","USD":"497.61132896580006"},{"Day":"24-05 03H","Production":"0.85694953","USD":"501.11323496092"},{"Day":"24-05 04H","Production":"0.868104","USD":"507.635967456"},{"Day":"24-05 06H","Production":"0.8802085","USD":"519.796567173"},{"Day":"24-05 07H","Production":"0.8913847","USD":"532.3438566870001"},{"Day":"24-05 08H","Production":"0.89426695","USD":"530.7322322868499"},{"Day":"24-05 09H","Production":"0.89904346","USD":"531.08385173466"},{"Day":"24-05 10H","Production":"0.90740126","USD":"535.88759172324"},{"Day":"24-05 11H","Production":"0.91944257","USD":"554.8872687652799"},{"Day":"25-05 12H","Production":"0.92783829","USD":"554.54203862259"},{"Day":"25-05 02H","Production":"0.94182047","USD":"565.81654194143"},{"Day":"25-05 03H","Production":"0.94743531","USD":"574.52571941931"},{"Day":"25-05 04H","Production":"0.95331299","USD":"579.83927978564"},{"Day":"25-05 05H","Production":"0.9563386","USD":"580.4497132700001"},{"Day":"25-05 06H","Production":"0.96906754","USD":"594.5520078162"},{"Day":"25-05 07H","Production":"0.97823946","USD":"580.6878346533"},{"Day":"25-05 08H","Production":"0.97823946","USD":"580.6878346533"},{"Day":"25-05 09H","Production":"0.99806768","USD":"595.88932187024"},{"Day":"25-05 10H","Production":"0.00706363","USD":"4.21520001161"},{"Day":"25-05 11H","Production":"0.01715723","USD":"10.19647316008"},{"Day":"25-05 12H","Production":"0.02629501","USD":"15.77321951856"},{"Day":"25-05 01H","Production":"0.04011605","USD":"24.3299831645"}
And the following code used to graph:
<script>
var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"dataLoader": {
"url": "http://x.x.x.x/json.php", "format": "json"
},
"valueAxes": [{
"id": "v1",
"startDuration": 1,
"axisColor": "#FF6600",
"axisThickness": 5,
"gridAlpha": 0.1,
"axisAlpha": 1
}, {
"id": "v2",
"axisColor": "#FCD202",
"axisThickness": 5,
"gridAlpha": 0,
"axisAlpha": 1,
"position": "right",
"synchronizeWith": "v1",
"synchronizationMultiplier": 5
}],
"graphs": [{
"valueAxis": "v1",
"type": "column",
"fillColorsField": "#B0DE09",
"balloonText": "[[category]]: <b>[[value]]</b>",
"fillAlphas": 0.8,
"lineAlpha": 0.2,
"title": "Production Crypto",
"valueField": "Production"
}, {
"valueAxis": "v2",
"type": "smoothedLine",
"lineColor": "#364cf2",
"lineThickness": 3,
"bulletBorderThickness": 1,
"hideBulletsCount": 30,
"title": "Production USD",
"valueField": "USD",
"fillAlphas": 0
}],
"chartCursor": {
"categoryBalloonEnabled": false,
"cursorAlpha": 0,
"zoomable": false
},
"categoryField": "Day",
"categoryAxis": {
"gridPosition": "start",
"gridAlpha": 0,
"tickPosition": "start",
"tickLength": 20
}
});
</script>
This is the screenshot of the graph I get:
Where the blue line for the USD series clearly does not render properly.
I have been able to get a dual Y axis graph showing properly (http://jsfiddle.net/spjem6b8/) with random generated data, so I guess this is the json part that generates this issue.
What am I doing wrong here?
Thanks
Your synchronizationMultiplier isn't high enough to make the second Y axis large enough to encapsulate your USD values in your dataset. In your current setup, your second Y axis values range from 0-6, but your USD values range from 4-600. Increase your syncrhonizationMultiplier to 600 in this case and it will work.
"valueAxes": [{
"id": "v1",
"startDuration": 1,
"axisColor": "#FF6600",
"axisThickness": 5,
"gridAlpha": 0.1,
"axisAlpha": 1
}, {
"id": "v2",
"axisColor": "#FCD202",
"axisThickness": 5,
"gridAlpha": 0,
"axisAlpha": 1,
"position": "right",
"synchronizeWith": "v1",
"synchronizationMultiplier": 600
}],
There's also an unsupported beta property called synchronizeGrid that can sometimes do this for your automatically, but it's not guaranteed to work with all value axis setting combinations so your mileage may vary. This is set at the top of the chart config:
AmCharts.makeChart("chartdiv", {
// ...
synchronizeGrid: true, //no need for synchronizeWith/Multiplier in the value axis
// ...
});
Here's an updated fiddle with the updated multiplier: http://jsfiddle.net/spjem6b8/1/
I have the following file:
[
{
'id': 1,
'arr': [{'x': 1,
{'x': 2}]
},
{
'id': 2,
'arr': [{'x': 3},
{'x': 4}]
}
]
How can I transform it into the following form using jq?
[
{'id': 1, 'x': 1},
{'id': 1, 'x': 2},
{'id': 2, 'x': 3},
{'id': 2, 'x': 4},
]
Assuming it doesn't get any more complex than that, you could simply do this:
map(del(.arr) + .arr[])
This is under the assumption that you're replacing the arr property of each object with the contents of the items in arr. It's unclear what you're trying to do exactly.
The input shown in the question is not valid JSON. After making some minor changes to make it valid JSON, the following filter produces the output as shown below:
map( (.arr[]|.x) as $x | {id, "x": $x} )
Output:
[
{
"id": 1,
"x": 1
},
{
"id": 1,
"x": 2
},
{
"id": 2,
"x": 3
},
{
"id": 2,
"x": 4
}
]