WIP (Qt)
1 manually trigger the QWebEnginePage::SavePage action========
QMenu *menu;
if (page()->contextMenuData().linkUrl().isValid()) {
menu = new QMenu(this);
menu->addAction(page()->action(QWebEnginePage::OpenLinkInThisWindow));
menu->addAction(page()->action(QWebEnginePage::OpenLinkInNewWindow));
menu->addAction(page()->action(QWebEnginePage::OpenLinkInNewTab));
menu->addAction(page()->action(QWebEnginePage::OpenLinkInNewBackgroundTab));
menu->addSeparator();
menu->addAction(page()->action(QWebEnginePage::DownloadLinkToDisk));
menu->addAction(page()->action(QWebEnginePage::CopyLinkToClipboard));
} else {
menu = page()->createStandardContextMenu();
}
if (page()->contextMenuData().selectedText().isEmpty())
menu->addAction(page()->action(QWebEnginePage::SavePage));
connect(menu, &QMenu::aboutToHide, menu, &QObject::deleteLater);
menu->popup(event->globalPos());
2. ========
void TabWidget::downloadRequested(QWebEngineDownloadItem *download)
{
if (download->savePageFormat() != QWebEngineDownloadItem::UnknownSaveFormat) {
SavePageDialog dlg(this, download->savePageFormat(), download->path());
if (dlg.exec() != SavePageDialog::Accepted)
return;
download->setSavePageFormat(dlg.pageFormat());
download->setPath(dlg.filePath());
}
BrowserApplication::downloadManager()->download(download);
download->accept();
}
=====
http://stackoverflow.com/questions/38812787/how-to-handle-downloads-in-qwebengine
======
http://doc.qt.io/qt-5/qwebengineprofile.html#downloadRequested
======
http://doc.qt.io/qt-5/qwebenginepage.html#save
Code as Fast as You Can Think
"I have only proved my code correct, not tested it" - Donald Knuth
Search This Blog
Sunday, February 19, 2017
Friday, February 3, 2017
Wagtail CMS (new site setup FreeBSD 11)
sudo pkg install bash
bash requires fdescfs(5) mounted on /dev/fd
If you have not done it yet, please do the following:
mount -t fdescfs fdesc /dev/fd
To make it permanent, you need the following lines in /etc/fstab:
fdesc /dev/fd fdescfs rw 0 0
===
sudo pkg install emacs-nox11
To run tcsd automatically, add the following line to /etc/rc.conf:
tcsd_enable="YES"
You might want to edit /usr/local/etc/tcsd.conf to reflect your setup.
If you want to use tcsd with software TPM emulator, use the following
configuration in /etc/rc.conf:
tcsd_enable="YES"
tcsd_mode="emulator"
tpmd_enable="YES"
To use TPM, add your_account to '_tss' group like following:
# pw groupmod _tss -m your_account
===
portsnap fetch extract
===
cd /usr/ports/lang/python3
make install clean BATCH=YES
===
cd /usr/ports/databases/postgresql96-server/
make install clean BATCH=YES
sudo /usr/local/etc/rc.d/postgresql initdb
The files belonging to this database system will be owned by user "postgres".
You can now start the database server using:
/usr/local/bin/pg_ctl -D /var/db/postgres/data96 -l logfile start
su postgres
$ createuser freebsd
$ createdb gchen
===
cd /usr/ports/databases/postgresql-libpqxx
make install clean BATCH=YES
===
==
/usr/ports/ports-mgmt/portupgrade-devel
==
bash requires fdescfs(5) mounted on /dev/fd
If you have not done it yet, please do the following:
mount -t fdescfs fdesc /dev/fd
To make it permanent, you need the following lines in /etc/fstab:
fdesc /dev/fd fdescfs rw 0 0
===
sudo pkg install emacs-nox11
To run tcsd automatically, add the following line to /etc/rc.conf:
tcsd_enable="YES"
You might want to edit /usr/local/etc/tcsd.conf to reflect your setup.
If you want to use tcsd with software TPM emulator, use the following
configuration in /etc/rc.conf:
tcsd_enable="YES"
tcsd_mode="emulator"
tpmd_enable="YES"
To use TPM, add your_account to '_tss' group like following:
# pw groupmod _tss -m your_account
===
portsnap fetch extract
===
cd /usr/ports/lang/python3
make install clean BATCH=YES
===
cd /usr/ports/databases/postgresql96-server/
make install clean BATCH=YES
sudo /usr/local/etc/rc.d/postgresql initdb
The files belonging to this database system will be owned by user "postgres".
You can now start the database server using:
/usr/local/bin/pg_ctl -D /var/db/postgres/data96 -l logfile start
su postgres
$ createuser freebsd
$ createdb gchen
sudo -u postgres psql postgres
(username postgres, databasename postgres)
alter user freebsd password 'mypassword'
===
cd /usr/ports/databases/postgresql-libpqxx
make install clean BATCH=YES
===
cd /usr/ports/www/nginx-devel/ && make install clean
===
cd /usr/ports/sysutils/py-supervisor/ && make install clean
===
cd /usr/ports/devel/py-virtualenv/ && make install clean
===
cd /usr/ports/devel/py-pip/ && make install clean
==
/usr/ports/ports-mgmt/portupgrade-devel
==
cd /usr/ports/devel/git
===
cd /usr/ports/graphics/jpeg
===
sudo tzsetup
===
bash
virtualenv -p /usr/local/bin/python3 py3wt
pip install -r mypip.txt (mypip.txt is the requirement file)
python manage.py migrate
python manage.py runserver
python manage.py collectstatic
===
/usr/local/etc/supervisord.conf
===
cd /usr/ports/security/py-fail2ban/ && make install clean
Please do not edit the fail2ban.conf and jail.conf files as they
will be overwritten upon each upgrade of the port.
Instead, create new files named fail2ban.local and jail.local
For more information, see the official manual:
http://www.fail2ban.org/wiki/index.php/MANUAL_0_8#Configuration
If you are upgrading from 0.8.x consider adopting the new
configuration style.
===
sudo ee /etc/ssh/sshd_config
ChallengeResponseAuthentication no
sudo service sshd restart
===
/usr/ports/lang/python36
/usr/ports/databases/py36-sqlite3
binary: /usr/local/bin/python3.6
===
cd /usr/ports/sysutils/tmux/ && make install clean
===
/usr/ports/devel/qt5-core
/usr/ports/devel/qmake5
/usr/local/lib/qt5/bin/qmake
/usr/local/lib/qt5/bin/qmake -project
QT += core
QT -= gui
add cpp file, e.g. "main.cpp"
/usr/local/lib/qt5/bin/qmake -makefile
make
===
/usr/ports/www/w3m-img
**********************************************************
* To display images in proper positions, *
* you should set font size of your terminal emulator to *
* "# of pixels per character" and "# of pixels per line" *
* in Option Setting Panel. *
* *
* For example, if you use 14 pixel fonts, the values *
* should be these. *
* *
* # of pixels per character = 7 *
* # of pixels per line = 14 *
**********************************************************
===
usr/ports/devel/boost-python-libs
Don't forget to add -pthread to your linker options when
linking your code.
You have built the Boost.Python library. You have to add the following
options when building your own code:
Compiler options:
-I/usr/local/include/python2.7 -I/usr/local/include
Linker options:
-L/usr/local/lib/python2.7 -L/usr/local/lib -lboost_python -lpython2.7
===
cd /usr/ports/net/rabbitmq
===
/usr/ports/devel/catch
===
/usr/ports/databases/postgresql96-contrib
===
/usr/ports/devel/boost-python-libs
Compiler options:
-I/usr/local/include/python2.7 -I/usr/local/include
Linker options:
-L/usr/local/lib/python2.7 -L/usr/local/lib -lboost_python -lpython2.7
===
/usr/ports/www/youtube_dl
If you want to use mp3 audio conversion please make sure multimedia/ffmpeg is
built with the "LAME" option enabled.
===
/usr/ports/security/py-certbot
Saturday, January 28, 2017
Wagtail CMS (new site setup UBUNTU 16.04)
cd
sudo apt install virtualenv
virtualenv -p /usr/bin/python3 py3wt
source py3wt/bin/activate
python manage.py createsuperuser
python manage.py runserver
==
connect to database
=====
change password:
alter user postgres password 'postgres';
=======
list database
\l
=====
deployment
sudo apt install supervisor
pip install gunicorn
python manage.py collectstatic
====
sudo apt install nodejs
sudo apt install virtualenv
virtualenv -p /usr/bin/python3 py3wt
source py3wt/bin/activate
pip install wagtail
wagtail start gchen
cd gchen
setup database
sudo apt-get install postgresql-client
sudo apt-get install postgresql postgresql-contrib sudo apt-get install pgadmin3
sudo apt install libpq-dev
sudo -u postgres psql postgres
sudo apt-get install python3-dev
\password postgres
sudo -u postgres createdb gchen (gchen is the database name)
pip install psycopg2
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
==
connect to database
sudo -u postgres psql postgres
(username postgres, databasename postgres)
=====
change password:
alter user postgres password 'postgres';
=======
list database
\l
=====
deployment
sudo apt install supervisor
pip install gunicorn
python manage.py collectstatic
====
sudo apt install nodejs
Sunday, June 28, 2015
Set up Ionic in Mac OS X Yosemite
1. Here is the official guide: http://cordova.apache.org/docs/en/3.3.0/guide_platforms_ios_index.md.html#iOS%20Platform%20Guide
2. Go to App Store, download Xcode and install it
3. Open Xcode
4. Xcode Menu → Preferences → Downloads → Components → iOS 8.2 Simulator (there are a few others, so pick iOS 8 that can run on iPhone 6)
5. Install Xcode Command Line Tools: Open a Terminal, type “xcode-select —install”
6. Install nodejs, https://nodejs.org/download/, downlod “Mac OS X Installer (.pkg)”, open the download file and follow the installer to install Nodejs
7. Install cordova tool chains, open a Terminal, and type “sudo npm install -g cordova”
8. In a terminal, create a sample app, type “cordova create hello com.example.hello HelloWorld”
9. In the termial, go to your hello app, “cd hello”
10. In the termial, specify your build target, type “cordova platform add ios” (target is ios here, others like android, firefox, kindle fire, blackberry etc..)
11. In the termial, ready to build the project, type “cordova build”
12. Use Xcode IDE and ready to develop, so double clicking “hello/platforms/ios/HelloWorld.xcodeproj” (or a file ending with .xcodeproj)
13. There is a “Play” symbol/button on the Xcode IDE, you can click it and Xcode will launch the iOS simulator running your ionic Hello app.
14. And the rest is iterating your code and build. That is, modifying your project in Xcode, building your project in a terminal with “cordova build”, then click the “Play” button to test
Thursday, October 17, 2013
BeagleBone Black
Compared with Rasparry Pi, Beaglebone Black looks more developer friendly and more powerful. Remember to order extra hardware (temperature sensor,sound buzzer, LEDs, simple LCD screen,power supply etc) with your Beaglebone Black together, so you can use your Beaglebone to control them.
You will pay around $120, nice price to pay for teaching yourself embedded programming. For example, write your own electronic thermometer. :)
Sunday, February 10, 2013
BCD Adder (Binary-coded decimal)
Binary Code Decimal (BCD) Adder.
This is a tool that helps you add two decimals as BCD.
Why is BCD adder useful?
Double and Float sometimes do not meet the requirement of precision. For example, you cannot hold more than 17 digits in double.
With this BCD adder, you can add numbers with 10^18 digits!
Source: https://github.com/crystalcoding/HappyHacking/tree/master/BCD/bcd_gui
Download (windows binary): http://dl.dropbox.com/u/58798915/release-BCD-v0.9.zip
Monday, January 14, 2013
FreeNAS GUI Update
FreeNAS (GUI) Web-based upgrade from 8.3.0 Release to 8.3.1 Beta2
1. Back up the configuration “System → Settings → General → Save Config”
2. Download the *.txz file. Upload it through the GUI, Remember to specify the checksum.
3. Take about 5~10 minutes flashing the USB key, the machine reboots once, and I manually reboot it again
Old services are up and running after the upgrade. (Say the old config are good)
reference
http://doc.freenas.org/index.php/Upgrading_FreeNAS%C2%AE
1. Back up the configuration “System → Settings → General → Save Config”
2. Download the *.txz file. Upload it through the GUI, Remember to specify the checksum.
3. Take about 5~10 minutes flashing the USB key, the machine reboots once, and I manually reboot it again
Old services are up and running after the upgrade. (Say the old config are good)
reference
http://doc.freenas.org/index.php/Upgrading_FreeNAS%C2%AE
Subscribe to:
Posts (Atom)