Idea: Conditional Chrome theme based on environment [closed] - google-chrome

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
As a web developer I'm constantly working on projects in different environments (local, staging, testing, production). I mostly work on Drupal projects. I can't tell you the number of times I've been led from local to production by just browsing the site. And then accidentally changing a setting on production that was really only supposed to be changed on my local environment.
So here's an idea: A Chrome theme that changes color depending on the sub domain of a site.
For example: on local.mysite.com* the browser chrome should be green, on staging.mysite.com* it should be blue, and on mysite.com* the color should be standard chrome grey.
This could avoid a lot of confusion for a lot of people working in different environments. Not only for developers, also for "content" people.
Sadly, I have no idea how to code a Chrome theme with that kind of behavior.

Themes are not dynamic, so the solution is not straightforward.
It's possible to create the feature using the management API. At least three extension are needed:
The main extension for switching themes.
Theme #1, theme #2 etc (an extra extension for every additional theme).
How to
Create a theme - See the Chrome themes documentation.
Bind a chrome.tabs.onUpdated event to listen for tab changes, and possibly save the state of known "theme-tabs" in a hash (by tabId). Don't forget to remove the tabId when the tab's URI is not "special" any more, using the delete operator.
Create another extension, with a background script.
Add a chrome.tabs.onActivated Warning: See below event, to listen for tab changes. This event is passed a windowId and tabId. Use the hash, created in step 2, to check whether the theme has to be changed or not.
If the URL matches a certain pattern, activate the new theme using the chrome.management.setEnabled method.
Alternative approach for step 3-4: Use Content scripts to call a method the background page. The match patterns can then be set in the manifest file, at the "content_scripts", "matches" section.
Warning: The onActivated event was not supported prior Chrome 18. Before Chrome 18, the event was called onActiveChanged.
The extension as described in steps 2-4 requires the following permissions:
management
tabs

My solution is to use PHP to detect what server I am connected to and then update Administrative screens of my application (WordPress, Drupal etc.) with a specific color. You could also display a color bar at the top of local and staging sites as well.
Here is what I do for WordPress admin screens:
// determine if this is development, staging or production environment
if (strpos(home_url(),'http://localhost') !== false)
{
define('MY_ENVIRONMENT', 'DEV');
}
else if (strpos(home_url(),'<enter staging URL here>') !== false)
{
define('MY_ENVIRONMENT', 'STAGE');
}
else
{
define('MY_ENVIRONMENT', 'PROD');
}
And then I used this to show specific colors in WordPress admin screen:
function change_admin_color($result) {
return (MY_ENVIRONMENT== 'PROD' ? 'sunrise' : (MY_ENVIRONMENT== 'STAGE' ? 'ocean' : 'fresh'));
}
add_filter('get_user_option_admin_color','change_admin_color');

Related

Chrome on startup to continue where I left off and one more page

Whenever I open chrome, I want:
All my previous pages are there
Another page, with a custom URL, is there. (With the possibility of me setting it to be chrome://newtab.)
Is this possible?
Is there a way that on open specific set of pages, I can add previous pages?
I have tried looking. The closest thing I could find was this. This is not exactly what I wanted.
I would like a simple and easy way of doing this. (I don't mind extensions but I couldn't find any.)
I want this to be done without any input from me every time. So no CtrlShiftT please.
Thank you in advance.
If you need to automate Chrome GUI, it's possible using pywinauto. My student wrote an example dragging file from explorer.exe to Google Disk opened in Chrome. There are some tricks used here.
test_explorer_google_drive.py
Chrome requires command line parameter --force-renderer-accessibility to enable MS UI Automation support in Chrome. So if you're starting Chrome it should work for you. If you're trying to connect to existing Chrome window this might be a problem.
Need to use backend='uia' explicitly for pywinauto.Application object. See the Getting Started Guide for more details, core concept and other useful things.
The relevant part of the mentioned script:
from pywinauto import Application
chrome_dir = r'"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"'
# start Chrome
chrome = Application(backend='uia')
chrome.start(chrome_dir + ' --force-renderer-accessibility --incognito --start-maximized <URL>')
# wait while page is loading (up to 10 sec.)
chrome['<Tab caption>'].child_window(title_re='Reload.*', control_type='Button').wait('visible', timeout=10)
the details of this may depend on your operating system but on windows I can access a "master_preferences" file in C: > Program Files > Google > Chrome > application.
the contents of the file looks like:
{
"homepage": "http://www.google.com/",
"homepage_is_newtabpage": false,
"distribution": {
"suppress_first_run_bubble": false,
"import_search_engine": false,
"import_history": false,
"do_not_launch_chrome": true,
"make_chrome_default": false,
"verbose_logging": false,
"ping_delay": -60
},
"sync_promo": {
"show_on_first_run_allowed": false
},
"session": {
"restore_on_startup": 4,
"startup_urls": ["http://www.google.com/"]
},
"first_run_tabs": ["http://www.google.com/", "http://welcome_page"]
}
You can see there are settings for restore_on_startup
and startup_urls under the "session" heading
try editing those settings so the look like this:
"restore_on_startup": 2,
"startup_urls": ["http://www.google.com/", "http://www.theurlyouwant.com"]
You may not be able to configure these settings on your work or school computer as it requires administrator privileges. And also if you're not familiar with JSON pay especial close attention to the syntax (commas, quotation marks etc) I've used in my examples.
I don't know if this will help, it's certainly not as technical a response as everyone else, but I use the OneTab Chrome extension to do some of the stuff you're talking about.
I have a handful of pages saved to it, and I click the Restore All button and they all load in. You can save groups of tabs, and lock those groups so they're not easily deleted on accident, and name groups of saved tabs as well. I think it's pretty helpful, but it might not be exactly what you need/are looking for. Hope it helps though!

Multiple Shiny apps using the ui to populate the second app

I currently have a app that manages projects. The user sees a list of projects and can select one. They can should (it would be nice) be able to click a run button and have another app open. The parameters stored in the project they selected are populated into the second application. The issue I am having is firing the second application. runApp generates the following.
ui code line:
actionButton("RunProj", "Run"),
Warning in run(timeoutMs) :
Unhandled error in observer: Key / already in use
observeEvent(input$RunProj)
I would like to trigger the second app and pass in the location of the project directory I have looked at parseQueryString and still trying to figure out a way to include that. Maybe via a redirect?
Any suggests would be much appreciated.
Regards,
Rich
I'm not 100% sure if I understand your intention correctly but here is a few things I think you may want to think about.
In one project, if you want to run a few kinds of analyses, you may want to try navbarPage
If there are many different types of analyses, you may want to try shinydashboard
If you know the link to each app and you really want to add those "run" buttons, you can add a button manually in ui.R. I think you can write some codes in server.r to generate the link based on your database.
tags$a(href="the link to your apps", class= "btn btn-default", "Run App")

Rename Taxonomy label in editor bolt-cms

I would like to rename the default tab value of Taxonomy in the backend page editor. I didn't find anything in the twig or yml files that would address this. Any ideas?
I checked with bolt developers and there is no way currently to do this. One potential option was to use the messages file but it was not recommended.
As you can imagine, since this isn't supported via the public configs, this will need a bit more advanced plugging together.
Here is a way to add an additional resource to the stack of translations.
https://gist.github.com/rossriley/c74fdee4fec3eaffb12f
This is a technique to add your own messages onto the translation stack without touching the underlying core files.
After creating this, you'll need to add your new service provider to the app, which you normally will bootstrap either in your index.php or a custom bootstrap file.

Suggestions for developing WebInterface (using Tomcat)?

I am working with TS-7500 (ARM 9) board running Debian Linux (Linux ts7500 2.6.24.4). It is connected to a couple of sensors and is running driver code to talk to these sensors.
Every time the C program starts, it reads a couple of config-parameters from a config-file and starts sensors with those values.
So the task at hand is : presenting a web interface to show/edit these config-parameters to user. The task of the web interface can be summarized in four steps :
Read config-parameters from the config-file and show the current configuration
Allow user to change the configuration
Capture and save the changes to same config-file
These config-parameters could be presented as drop-down menu items or radio-buttons. And I have a linux background script which restarts the C prg when config-file is modified.
I know TS-7500 runs Tomcat. Now please suggest a good way to handle this problem. I have heard about using Servlet and JSPs (am not very familiar with those actually). Which one of them is suitable to generate HTML pages dynamically ? (as I see everytime I need to generate a new HTML page by selecting the current configuration while displaying the page).
Sorry for being very elaborate !
EDIT : Beeps ! No reply ? Come on guyz, is the question not clear ? Or no one has ever faced a similar problem (design problem) ??
The solution would be to use a PHP in addition with Apache web server ! PHP script could be used to
Read the config file and capturing the parameters
Generate a HTML form (by pre-selecting the dropdown menus and radio buttons from the already read parameters)
And capturing the new edits and saving them to config file.
PHP script must be placed in /var/www/ directory of the embedded board. Then from any system, it could be accessed just by keying the IP address of the board and the script name using a simple web browser.

How can I over-ride the default code formatting policy in MonoDevelop?

MonoDevelop allows creation and installation of custom policies to control all aspects of code formatting. I have created a policy for our work site, which can be applied via Project > Apply Policy ...
We are using the Unity game engine, which regularly regenerates the MonoDevelop solution, requiring each developer to re-apply the policy -- irritating and error-prone.
How can I make my policy file be the default for new MonoDevelop solutions?
Also, where is the information about the applied policy saved?
In the .sln file I see "$0.CSharpFormattingPolicy = $2", but this is unchanged after applying my custom policy. I have compared all the project files before and after applying the policy, and the only changes are (1) a .userprefs file is generated, but doesn't mention policies, and (2) various .pidb files are different, but this can't be where policy information goes??
I'm using the version of MonoDevelop that is integrated with Unity 3.5.2, which is MonoDevelop version 2.8.2 (on Windows 7). (Yes, 2.8.2 is a little out of date, and it's possible that Unity Technologies has made changes that are causing my issues.)
This is a year after the other answers, but none of the above works for unity, and this was near the top of the google search.
Here are the steps I had to follow to get formatting to work:
MonoDevelop->Tools->Custom Policies->Add Policy->New Policy
Edit the policy inside of the 'Custom Policies' window, making sure your policy is selected.
Project->Apply Policy->Apply Stock or Custom Policy Set (select your policy)->Apply
Goto Tools->Options->KeyBinding
Then goto Edit -> FormatDocument
Then assign your shortcut key and click on apply and use it in your document.
The default policy is applied to new solutions or solutions without policies. It can be edited in the Preferences/Options dialog, where it's mixed in with the user preferences: Tools->Options on Windows, MonoDevelop->Preferences on Mac. You can identify the policies because they have a "Policy" dropdown at the top of the panel that allows you to load from a named policy.
I spent like 30 minutes fixing this and finally figure it out.
In Windows:
Go to Project -> Assembly C-Sharp Options
Then change the Code Formatting from there!
Going to Project -> Solution Options does absolutely nothing
After a year of dealing with this, we wrote a Unity editor script that would watch the project files for changes, and when they changed, check the policy entries in the project (pretty simple XML to parse.) If they had deviated from our desired policy, we'd modify them and write them back out with the correct policy changes.
Another idea (we wanted to enforce a policy) would be do do the same thing, but just remove the policy entries from the project whenever they got updated, and then you'd never have project policies overriding what you set up at the tool level.