Just got a comment on the post Google Chrome extension Boss Key and Button, and knew that the extension's Options page stopped working. After some investigation, it turned out that the new version of Google Chrome does not support the syntax:
<script src="bossknb.js" />
We have to change it into:
<script src="bossknb.js"></script>
It was not only Google's fault. Google did broadcast an Email in early November to reveal this bug in Google Chrome -- which Google promised to fix ASAP.
As people are asking for a fix for the extension, we are going to release an update for this issue ASAP -- should be much sooner than Chrome.
BTW, is Chrome mature enough to compete with Firefox?
Monday, January 31, 2011
Thursday, January 27, 2011
C++ programming: split a string
We have a string
red, green, brown, blue
and we want to split it by ", " into four words
red
green
brown
blue
Method 1 -- the traditional way with the C function strtok()
#include <vector>
#include <string>
#include <iostream>
#include <string.h>
#include <stdlib.h>
using namespace std;
vector<string> splitString(string input, string delimiter)
{
vector<string> output;
char *pch;
char *str = strdup(input.c_str());
pch = strtok (str, delimiter.c_str());
while (pch != NULL)
{
output.push_back(pch);
pch = strtok (NULL, delimiter.c_str());
}
free(str);
return output;
}
int main()
{
string str;
getline(cin, str);
vector<string> output = splitString(str, ", ");
for (size_t i = 0; i < output.size(); i++)
{
cout << output[i] << endl;
}
return 0;
}
Be aware that when using strtok(), the input string will be modified. So we use strdup() to create a temporary copy and free it later on.
Method 2 -- the C++ way
#include <vector>
#include <string>
#include <iostream>
using namespace std;
vector<string> splitString(string input, string delimiter)
{
vector<string> output;
size_t start = 0;
size_t end = 0;
while (start != string::npos && end != string::npos)
{
start = input.find_first_not_of(delimiter, end);
if (start != string::npos)
{
end = input.find_first_of(delimiter, start);
if (end != string::npos)
{
output.push_back(input.substr(start, end - start));
}
else
{
output.push_back(input.substr(start));
}
}
}
return output;
}
Method 3 -- using Boost.
#include <boost/algorithm/string.hpp>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
using namespace boost;
vector<string> splitString(string input, string delimiter)
{
vector<string> output;
split(output, input, is_any_of(delimiter), token_compress_on);
return output;
}
red, green, brown, blue
and we want to split it by ", " into four words
red
green
brown
blue
Method 1 -- the traditional way with the C function strtok()
#include <vector>
#include <string>
#include <iostream>
#include <string.h>
#include <stdlib.h>
using namespace std;
vector<string> splitString(string input, string delimiter)
{
vector<string> output;
char *pch;
char *str = strdup(input.c_str());
pch = strtok (str, delimiter.c_str());
while (pch != NULL)
{
output.push_back(pch);
pch = strtok (NULL, delimiter.c_str());
}
free(str);
return output;
}
int main()
{
string str;
getline(cin, str);
vector<string> output = splitString(str, ", ");
for (size_t i = 0; i < output.size(); i++)
{
cout << output[i] << endl;
}
return 0;
}
Be aware that when using strtok(), the input string will be modified. So we use strdup() to create a temporary copy and free it later on.
Method 2 -- the C++ way
#include <vector>
#include <string>
#include <iostream>
using namespace std;
vector<string> splitString(string input, string delimiter)
{
vector<string> output;
size_t start = 0;
size_t end = 0;
while (start != string::npos && end != string::npos)
{
start = input.find_first_not_of(delimiter, end);
if (start != string::npos)
{
end = input.find_first_of(delimiter, start);
if (end != string::npos)
{
output.push_back(input.substr(start, end - start));
}
else
{
output.push_back(input.substr(start));
}
}
}
return output;
}
Method 3 -- using Boost.
#include <boost/algorithm/string.hpp>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
using namespace boost;
vector<string> splitString(string input, string delimiter)
{
vector<string> output;
split(output, input, is_any_of(delimiter), token_compress_on);
return output;
}
Monday, January 24, 2011
How to change the font and color of the Google Dictionary and Google Translate extension
In the version 2.0 of the Google Dictionary and Google Translate Firefox extension, you can apply your own style to the dictionary pop-up. You can change the background color, the font family, the font color, or the font size, etc. To do that, you must have some knowledge of CSS (Cascading Style Sheets). If you do not want to bother, you can just choose from the samples we provide.
To input your own CSS code, go to the extension's Options dialog and click on the Style tab; check the Enable my style option; and input your CSS code underneath.
One or two style classes are applied to each element of the dictionary pop-up. The names of the classes are shown in the following picture.
To change the appearance of an element, just write your own CSS code for the class for that element. For example, if you want to turn the background color of the pop-up into white, add the following code into the CSS input box in the Options dialog:
To let your code override the default one, you must append !important to the end of the value for a property.
Here is another example. If you want to change the font size and color of the more link, you need to write code for two style classes -- gDicClassPopupMore and gDicClassPopupMoreDisabled. Because the more link can sometimes be disabled, we want it to have a different appearance (e.g. grayed out) when it is. Class gDicClassPopupMore is for the normal appearance -- e.g. blue and underlined, and class gDicClassPopupMoreDisabled is for when the link is disabled -- e.g. gray and not underlined.
To input your own CSS code, go to the extension's Options dialog and click on the Style tab; check the Enable my style option; and input your CSS code underneath.
One or two style classes are applied to each element of the dictionary pop-up. The names of the classes are shown in the following picture.
To change the appearance of an element, just write your own CSS code for the class for that element. For example, if you want to turn the background color of the pop-up into white, add the following code into the CSS input box in the Options dialog:
.gDicClassPopup {
background-color: white !important;
}
To let your code override the default one, you must append !important to the end of the value for a property.
Here is another example. If you want to change the font size and color of the more link, you need to write code for two style classes -- gDicClassPopupMore and gDicClassPopupMoreDisabled. Because the more link can sometimes be disabled, we want it to have a different appearance (e.g. grayed out) when it is. Class gDicClassPopupMore is for the normal appearance -- e.g. blue and underlined, and class gDicClassPopupMoreDisabled is for when the link is disabled -- e.g. gray and not underlined.
.gDicClassPopupMore
{
color: cyan !important;
font-size: 16px !important;
}
.gDicClassPopupMoreDisabled
{
/* color: gray !important; */ /* not necessary, as it is the default */
font-size: 16px !important;
}
Friday, January 14, 2011
Style templates for Google Dictionary and Google Translate firefox extension
In the upcoming version 2.0 of the Google Dictionary and Google Translate firefox extension, users can apply their own style to the dictionary pop-up. This is a highly wanted feature requested in many comments.
To do that, go to the extension's Options dialog and click on the "Style" tab; check the "Enable my style" option; and input your CSS code underneath. Yes, the user should know some CSS to better use this feature. However, if you can stand these common/popular styles we provide -- we would continue to provide more style templates based on your comments -- you can just copy and paste the code and make little modification to suit your needs.
A more detail explanation of how to write your own CSS code for the Google Dictionary and Google Translate firefox extension can be found in another post. This post just keeps all the templates for the common people who only want it work.
Now, talk less and act best. Here are the style templates we have --
Black font on white background
/* black on white */
.gDicClassPopup {
background-color: white !important;
border: 2px solid gray !important;
}
White font on black background
/* white on black */
.gDicClassPopup {
color: white !important;
background-color: black !important;
border: 2px solid gray !important;
}
.gDicClassPopupMore
{
color: cyan !important;
}
Big font
/* big font */
.gDicClassPopupOrig
{
font-size: 20px !important;
}
.gDicClassPopupTrans
{
font-size: 20px !important;
}
.gDicClassPopupDetail
{
font-size: 16px !important;
}
.gDicClassPopupMore
{
font-size: 16px !important;
}
.gDicClassPopupMoreDisabled
{
font-size: 16px !important;
}
Black font on white background with big font
/* black on white with big font */
.gDicClassPopup {
background-color: white !important;
border: 2px solid gray !important;
}
.gDicClassPopupOrig
{
font-size: 20px !important;
}
.gDicClassPopupTrans
{
font-size: 20px !important;
}
.gDicClassPopupDetail
{
font-size: 16px !important;
}
.gDicClassPopupMore
{
font-size: 16px !important;
}
.gDicClassPopupMoreDisabled
{
font-size: 16px !important;
}
White font on black background with big font
/* white on black with big font */
.gDicClassPopup {
color: white !important;
background-color: black !important;
border: 2px solid gray !important;
}
.gDicClassPopupOrig
{
font-size: 20px !important;
}
.gDicClassPopupTrans
{
font-size: 20px !important;
}
.gDicClassPopupDetail
{
font-size: 16px !important;
}
.gDicClassPopupMore
{
color: cyan !important;
font-size: 16px !important;
}
.gDicClassPopupMoreDisabled
{
font-size: 16px !important;
}
Round corner
(for version 2.5 and up)
/* round corner */
.gDicClassPopupBox {
border-style: none !important;
background-color: transparent !important;
}
.gDicClassPopup {
border-radius: 10px !important;
margin: 0px !important;
}
AERO GLASS (by Benedikt P.)
See Benedikt's comments for this fancy style. You may need to restart Firefox after applying this style.
.gDicClassPopupBox {
-moz-appearance: -moz-win-glass !important;
border-style: none !important;
background-color: transparent !important;
}
.gDicClassPopup {
border: none !important;
background-color: rgba(255, 255, 255, 0.25) !important;
border-radius: 3px !important;
margin: 5px !important;
}
Note: if you are using Windows, the popup usually has a shadow. This can not be changed within Firefox or the extension. To get rid of the shadow, you need to change the appearance of the desktop. Follow these steps (this example is for Window XP, other variants of Windows should be similar):
To select or highlight the text in the popup, you can use the "-moz-user-select" property. However, it has not much use till the current version (5.0) unless you are using Linux where you can paste the selected text with the middle button of the mouse.
.gDicClassPopupBox {
-moz-user-select: text !important;
}
To do that, go to the extension's Options dialog and click on the "Style" tab; check the "Enable my style" option; and input your CSS code underneath. Yes, the user should know some CSS to better use this feature. However, if you can stand these common/popular styles we provide -- we would continue to provide more style templates based on your comments -- you can just copy and paste the code and make little modification to suit your needs.
A more detail explanation of how to write your own CSS code for the Google Dictionary and Google Translate firefox extension can be found in another post. This post just keeps all the templates for the common people who only want it work.
Now, talk less and act best. Here are the style templates we have --
Black font on white background
/* black on white */
.gDicClassPopup {
background-color: white !important;
border: 2px solid gray !important;
}
White font on black background
/* white on black */
.gDicClassPopup {
color: white !important;
background-color: black !important;
border: 2px solid gray !important;
}
.gDicClassPopupMore
{
color: cyan !important;
}
Big font
/* big font */
.gDicClassPopupOrig
{
font-size: 20px !important;
}
.gDicClassPopupTrans
{
font-size: 20px !important;
}
.gDicClassPopupDetail
{
font-size: 16px !important;
}
.gDicClassPopupMore
{
font-size: 16px !important;
}
.gDicClassPopupMoreDisabled
{
font-size: 16px !important;
}
Black font on white background with big font
/* black on white with big font */
.gDicClassPopup {
background-color: white !important;
border: 2px solid gray !important;
}
.gDicClassPopupOrig
{
font-size: 20px !important;
}
.gDicClassPopupTrans
{
font-size: 20px !important;
}
.gDicClassPopupDetail
{
font-size: 16px !important;
}
.gDicClassPopupMore
{
font-size: 16px !important;
}
.gDicClassPopupMoreDisabled
{
font-size: 16px !important;
}
White font on black background with big font
/* white on black with big font */
.gDicClassPopup {
color: white !important;
background-color: black !important;
border: 2px solid gray !important;
}
.gDicClassPopupOrig
{
font-size: 20px !important;
}
.gDicClassPopupTrans
{
font-size: 20px !important;
}
.gDicClassPopupDetail
{
font-size: 16px !important;
}
.gDicClassPopupMore
{
color: cyan !important;
font-size: 16px !important;
}
.gDicClassPopupMoreDisabled
{
font-size: 16px !important;
}
Round corner
(for version 2.5 and up)
/* round corner */
.gDicClassPopupBox {
border-style: none !important;
background-color: transparent !important;
}
.gDicClassPopup {
border-radius: 10px !important;
margin: 0px !important;
}
AERO GLASS (by Benedikt P.)
See Benedikt's comments for this fancy style. You may need to restart Firefox after applying this style.
.gDicClassPopupBox {
-moz-appearance: -moz-win-glass !important;
border-style: none !important;
background-color: transparent !important;
}
.gDicClassPopup {
border: none !important;
background-color: rgba(255, 255, 255, 0.25) !important;
border-radius: 3px !important;
margin: 5px !important;
}
Note: if you are using Windows, the popup usually has a shadow. This can not be changed within Firefox or the extension. To get rid of the shadow, you need to change the appearance of the desktop. Follow these steps (this example is for Window XP, other variants of Windows should be similar):
- Right click on the desktop and select Properties on the context menu
- In the Display Properties dialog, select the Appearance tab
- Click the Effects button
- In the Effects dialog, deselect Show shadows under menus
- Click OK in the Effects dialog
- Click OK in the Display Properties dialog.
.gDicClassPopupBox {
-moz-user-select: text !important;
}
Wednesday, January 5, 2011
ASCII <--> EBCDIC Online Converter
(Beta version)
ASCII:
EBCDIC in uppercased hex (\x??): (e.g. \xC1\x82\x83\xF1 for Abc1)
ASCII:
EBCDIC in uppercased hex (\x??): (e.g. \xC1\x82\x83\xF1 for Abc1)
Subscribe to:
Posts (Atom)







