How to set proxy through setting.json in JetBrains Toolbox? - intellij-idea

When I click change proxy setting button on this app, it will crash. And I realize that I can set proxy through settings.json. But in this file it shows like below.
{
"autostart": true,
"install_location": "D:/Jetbrains/ToolBox",
"privacy_policy": {
"eua_accepted_version": "1.1"
},
"proxy": null
"shell_scripts": {
"enabled": false
},
"statistics": {
"allow": true
},
"update": {
"filter": {
"quality_filter": {
"order_value": 10000
}
}
}
}
I got no idea about proxy:null, there is no sample to help me figure out how to set proxy through json. So what's the right properties about proxy in this file? Could anybody give a sample?

It takes a dictionary where the keys are the same variable names you'd define in your shell and the values are the values you'd assign them. For instance http_proxy, https_proxy, no_proxy. Here is an example of what I have in my settings.json:
"proxy": {
"http_proxy": "http://my.proxy.url:8888",
"https_proxy": "http://my.proxy.url:8888",
"no_proxy": "localhost,127.0.0.1,localaddress,.localdomain.com"
},
I also tried manually editing the .desktop file's Exec line by adding the proxy environmental variables and while that works the first launch, the .desktop file is overwritten each time the application is launched so it won't work on subsequent launches and won't work if you have the application launch on login. Setting the proxy in the settings.json is the only way to make it work without manual intervention every time it's launched.
This is not documented anywhere that I could find and I wasted way more time than I'd liek to admit before I tried this solution. I'm glad it was as simple as it is but how hard would that be to document? It may seem intuitive, but how often have we all been burned by something where the intuitive and logical answer was not the actual implementation.

Related

Get notified when execution context is changed or created

I am injecting bunch of javascript code to a website by means of selenium webdriver (over chromedriver).
While the method i use works most of the time, it fails when an iframe is loaded or page is reloaded by website's javascript code.
I can trace the problem from the chromedriver's log.
For example:
[6.203][DEBUG]: DEVTOOLS EVENT Runtime.executionContextDestroyed {
"executionContextId": 1
}
[6.203][DEBUG]: DEVTOOLS EVENT Runtime.executionContextsCleared {
}
[6.203][DEBUG]: DEVTOOLS EVENT Runtime.executionContextCreated {
"context": {
"auxData": {
"frameId": "274.1",
"isDefault": true
},
"id": 5,
"name": "",
"origin": "https://<some url>"
}
}
When i see executionContextDestroyed i know that, most probably my injected scripts are destroyed too. I have tried bunch of options like switch_to.default_content() or switch_to.parent_frame but they didn't help, as there is nothing to do in case of reload but re-inject the scripts.
My question is, is there a way to hook into executionContextCreated events, so i can inject my scripts/functions into the context again and again.

Calling phone with appcelerator

I'm trying on device make calls but device do not nothing...
This is my code, i'm using Appcelerator 4.4.0.201511241829, IOS 9.2
var dialog = Ti.UI.createAlertDialog({
cancel: 0,
buttonNames: ['Cancel', 'Ok'],
message: "Are you sure?"
});
dialog.addEventListener('click', function(e){
if (e.index !== e.source.cancel){
// IF WE ARE BUILDING FOR DEVELOPMENT PURPOSES - TRY CALLING A FAKE NUMBER
if(ENV_DEV){
Titanium.Platform.openURL('tel:00000000');
}
// ELSE IF WE ARE BUILDING PRODUCTION - THEN USE THE LISTED NUMBER
else if(ENV_PRODUCTION){
Titanium.Platform.openURL('tel:00000000');
}
}
});
dialog.show();
any help?
Your code for call a number seems correct. I suppose that nothing happen because ENV_DEV and ENV_PRODUCTION variables are not True, and so the two if statements are not satisfy.
First of all I suggest you to add an else statement for be sure that one one condition is satisfy. You can modify your code like this:
// IF WE ARE BUILDING FOR DEVELOPMENT PURPOSES - TRY CALLING A FAKE NUMBER
if(ENV_DEV){
Titanium.Platform.openURL('tel:00000000');
}
// ELSE IF WE ARE BUILDING PRODUCTION - THEN USE THE LISTED NUMBER
else if(ENV_PRODUCTION){
Titanium.Platform.openURL('tel:00000000');
}else{
Titanium.Platform.openURL('tel:00000000');
}
Secondly you can add a console log like this Ti.API.info("yourMsg") in each statements to check in which if you are.
I hope this is helpful
Your 'dial a number' code indeed seems correct. I would like to suggest you to structure your code a bit different, I'll give you an example from a recent project of mine.
You can configure phone numbers for your different environments(prod, dev) in your config.json(assuming you are working on an Alloy project, and not a Classic Titanium project), an example:
{
"global": {
"phoneNumber": tel:0032499001122"
},
"env:development": {
"phoneNumber": tel:0111111"
},
"env:test": {},
"env:production": {}, ..
This reduces the code in your click-handler to:
if (e.index !== e.source.cancel){
Ti.Platform.openURL(Alloy.CFG.phoneNumber);
}
Because you pass the environment when you start the application, you do not longer need to check the environment in your code.
Don't forget to add your environment flag(-D development) if you run your app via the CLI, eg.
titanium build -p ios -T simulator -D development

Universal Links iOS 9 - Issue

I have implemented Universal links in iOS app. It works perfectly when I put the url in external app such as "Notes" and then tap it. It opens the app.
What I want to achieve is that when someone visits a specific url of my webpage, the ios app should be launched by itself. So in order to accomplish this, I have put:
applinks:www.mydomain.com
in my entitlements.
And the following in my "apple-app-site-association" file
{
"applinks":
{
"apps": [ ],
"details":
[
{
"appID": "team_id.com.teamname.app_name",
"paths": ["/path-CompA/path-CompB/"]
}
]
}
}
But When I navigate through my website, and I reach the path mentioned in json file, it only shows the bar at top of web page saying "Open in App_name" with "Open" button on right side.
I want to know if its the default behaviour of Universal links to not open the app if user is coming from the same domain? If its not the case then how does it open the app form "Notes".
Please note that my json file is not signed but I have put it on my website which is on https.
Thanks,
A couple of things. Can you try changing your apple-app-site-association file code as such?
{
"applinks": {
"apps": [],
"details": [
{
"appID": "team_id.com.teamname.app_name",
"paths": [
"*",
"/"
]
}
]
}
}
You can check your format with this validation tool: https://search.developer.apple.com/appsearch-validation-tool/
The answer is that basically, this behavior is expected as of iOS9.2, with Universal links. Universal links only work from a different domain.
With Branch (https://branch.io/), you can use one domain for links (bnc.lt), so that when you (as a developer using branch) host universal links on your site, they still operate as expected.
Also, for universal links from other domains (not to the same domain), you can 'unbreak' the safari redirect behavior by long-pressing on the link from an application and choosing 'Open in «App»'. I hope this helps!

Array store Sencha Touch 2

While building my first mobile app using sencha touch 2 some questions got in my way and I can't seem to find their answer.
Where should an app configuration be stored (theme, language, font size ). I was thinking
to count the data from a store and if bigger than 0 work on that data otherwise add data( this would happen only the first time application is opened or localstorage cleared..). There are other options for this kind of thing(things like an array which will be changed when user is interacting with the app) ?
I need to use in my application around 100 images. I don't know what options I have here to embed the images into app. Saw lots of examples loading image from external server but not sure if there is an option for packing them with the app.
If I had an array with a name(key) and the image url(value), where should this array be ? in a json file and use an ajax load each time a need a name in there ?
Thanks.
Let me suggest few options:
1- App configuration : If app configuration is like set of constant values which won't change by user interaction you can create a file (e.g. properties.js) and load it on application load.
Properties = {
SERVICE_URL : 'http://mycompany.com/api',
PAGE_SIZE : 20
}
and to load it you just have to edit app.json
"js": [
{
"path": "touch/sencha-touch.js",
"x-bootstrap": true
},
{
"path": "resources/data/properties.js"
}
]
If you want to control these values then you can keep it on your server and give its URL as "path" in app.json
2- There is always option of packaging images with your app, just like all the icon & startup images are packaged but its not suggested because it increases size of your deployable and people with slow internet connections and low end devices might skip installing it if size it too large.
3- No need to load the JSON file every time you need it, you can cache the data in global variable after first load and keep referring to the array whenever required. Now where to define global variable is another interesting discussion with people suggesting lot of things but I prefer to have a singleton class which can keep all the global functions & variables. See this thread to understand how : Where do I put my global helper functions if they are needed before Ext.application() is being executed?
For Text we can Try like this
var A_address=Ext.getCmp('address').getValue(); //get the value
localStorage.setItem("Adult1_select1",A_select1); // assign localstore
var web_arrayTotalPAssengers=[];
web_arrayTotalPAssengers.push(localStorage.getItem("web_TotalPassengers"));
console.log(web_arrayTotalPAssengers);
// push the values in array...
Ext.Ajax.request({
url:'http:/...........',
method:'POST',
disableCaching: false,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
jsonData: {
origin:Ext.decode(web_arrayTotalPAssengers), //decode and send
}
success:function(response)
{
console.log(response);
console.log("Success");
},
failure : function(response)
{
console.log("Failed");
}

How can i use the port.postmessage to send info from the background page to the content script in a Google Chrome extension

I've been able to send data from the background page to the content script. but this is done using sendrequest(). I will need to send data back and forth so I'm trying to figure out the correct syntax for using the port.postmessage from background page to content script. I have already read, several times, the google page on Messaging and I don't seem to get it. I even copied the code directly from the page and tested with no result. All I'm trying to do for now is send data from background page to content script using connect as opposed to sendrequest. The response from the content script I will deal with later as code with this response has been the main thorn. I just want to understand the process one step at a time without the extra knowledge of sending a response back.
I'm not sure if this contravenes the rules of this board but can someone PLEASE give me an example of some code to do this (background page and content script excerpt, the background page is the sender).
I've asked for assistance several times on this site only to be told to read the documentation or check out sites I've already visited.
If you just want any example of opening a port from the extension to a content script, here's the simplest I can think of. The background just opens a port and sends "Hello tab!" over the port, and the content script sends a message to the background any time you click on the webpage.
I think this is pretty simple, so I don't know why you are so stressed. Just make sure that the content tab is already listening when the background tries to connect (I do this by waiting until the "complete" event).
manifest.json:
{
"name": "TestExt",
"version": "0.1",
"background_page": "background.html",
"content_scripts": [{
"matches": ["http://localhost/*"], // same as background.html regexp
"js": ["injected.js"]
}],
"permissions": [
"tabs" // ability to inject js and listen to onUpdated
]
}
background.html:
<script>
var interestingTabs = {};
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
// same as manifest.json wildcard
if (changeInfo.url && /http:\/\/localhost(:\d+)?\/(.|$)/.test(changeInfo.url)) {
interestingTabs[tabId] = true;
}
if (changeInfo.status === 'complete' && interestingTabs[tabId]) {
delete interestingTabs[tabId];
console.log('Trying to connect to tab ' + tabId);
var port = chrome.tabs.connect(tabId);
port.onMessage.addListener(function(m) {
console.log('received message from tab ' + tabId + ':');
console.log(m);
});
port.postMessage('Hello tab!');
}
});
</script>
injection.js:
chrome.extension.onConnect.addListener(function(port) {
console.log('Connected to content script!');
port.onMessage.addListener(function(m) {
console.log('Received message:');
console.log(m);
});
document.documentElement.addEventListener('click', function(e) {
port.postMessage('User clicked on a ' + e.target.tagName);
}, true);
});
Detailed documentation and easy (the most basic) examples shown in the documentation page.
Plus, a quick search in stackoverflow will allow you to see many similar questions with detailed answers.