Node Webkit - Finding standard directories - node-webkit

Is it possible to find standard directories like 'Program Files' or 'Windows' and their Linux and Mac equivalents in Node webkit?

Are you looking for that:
process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME']

Related

Can react-native-desktop access the filesystem?

There are react-native projects for:
Linux
macOS
Windows
If I have a file that already exists on the filesystem, can I read it from react-native-* ?
If not, how can otherwise get some data from a text file on the filesystem?
If to talk regarding react-native-desktop you can try to use react-native-fs fork with desktop platform support.
At the time of this answer writing it has implementation of only 2 methods:
RNFSManager::readFile and RNFSManager::moveFile
The only known sample of usage can be found there.
In package.json of project based on react-native-desktop it should be referenced as:
"desktopExternalModules": [
"node_modules/react-native-fs/desktop"
],
...
"react-native-fs": "git+https://github.com/status-im/react-native-fs.git",
...
Also react-native-desktop supports OS X as well.

Unable to load dynamic library php_sqlsrv_7_nts.dll is not a valid Win32 application

Thought I'd see if there were any sql server drivers for php 7. Another question on Stack Overflow pointed me to these drivers here
So I install php_sqlsrv_7_nts.dll into my ext folder and add the following line to my php.ini:
extension=php_sqlsrv_7_nts.dll
I get this warning on every php script I run:
Warning: PHP Startup: Unable to load dynamic library 'C:\php7\ext\php_sqlsrv_7_nts.dll' - %1 is not a valid Win32 application
I realise this is just a pre-release version and there are many things to iron out still, but I was hoping to at least do some basic things.
What am I doing wrong, or do I need to wait a bit more for a better release.
Some info that might be useful:
PHP Version => 7.0.5
System => Windows NT GB275L-I-T-5654 6.3 build 9600 (Windows 8.1 Professional Edition) i586
Build Date => Mar 30 2016 09:57:56
Compiler => MSVC14 (Visual C++ 2015)
Architecture => x86
Configure Command => cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--disable-zts" "--with-pdo-oci=c:\php-sdk\oracle\x86\instantclient_12_1\sdk,shared" "--with-oci8-12c=c:\php-sdk\oracle\x86\instantclient_12_1\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--without-analyzer" "--with-pgo"
Finally got this solved. Needed to install some more things before it would work, namely:
Microsoft Visual C++ 2015 Redistributable (x86) which you can get from here
The ODBC drivers which you can get from here
It works for me.
1.Download the extension windows 7.0
https://github.com/Microsoft/msphpsql/releases
2.And then according to the system requirement paste it in ext folder.
Note: Paste only the thread safe version (php_pdo_sqlsrv_7_ts.dll , php_sqlsrv_7_ts.dll)
3.And edit the php.ini file add this extension to your php.ini file and restart and check
The extension file from Github MSPHPSQL releases did not work for me and gave me the same predicament with the OP. I went to this Microsoft article which gave me the driver (extension) for MSSQL Server, go ahead and install it on a directory you can easily find, in my case I saved it in my c:\mssql-driver then inside get the extension (DLL) file that fits your OS and PHP version, in my case since I am using PHP 7.2.x and x64 Windows I picked the following file and put it in my PHP extension directory c:\xampp\php\ext:
php_pdo_sqlsrv_72_ts_x64.dll
php_sqlsrv_72_ts_x64.dll
and in my php.ini located in c:\xampp\php\php.ini defined it under the Dynamic Extensions section:
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
...
extension=curl
extension=php_pdo_sqlsrv_72_ts_x64.dll
extension=php_sqlsrv_72_ts_x64.dll
...
delete the "php_" on "php_sqlsrv_7_nts". just write "sqlsrv_7_nts"

Automated translation management with Cmake and Qt5

I used to use the following qt4 commands for creation of translation files:
SET(PROJECTNAME "TEST")
SET(${PROJECTNAME}_TRANSLATIONS
${PROJECTNAME}_de.ts
)
SET(${PROJECTNAME}_TRANSLATIONS_COMPILED
${PROJECTNAME}_de.qm
)
QT4_CREATE_TRANSLATION (${PROJECTNAME}_TRANSLATION_FILES
${${PROJECTNAME}_FORMS}
${${PROJECTNAME}_HEADERS}
${${PROJECTNAME}_SOURCES}
${${PROJECTNAME}_RESSOURCES}
${${PROJECTNAME}_TRANSLATIONS}
)
How to port this kind of translation cmake snippet to work with Qt5 ?
The answer can be found in the Qt5-Cmake docs, here:
http://qt-project.org/doc/qt-5.0/qtdoc/cmake-manual.html#qt5linguisttools-macros
so, to your Cmakelists add:
find_package(Qt5LinguistTools)
then use:
QT5_CREATE_TRANSLATION(...)
Note for Ubuntu users (Oct.2013): you will need to install qttools5-dev

How to use 'Consolas' as the coding font

I would like to change the font for code edition in a Squeak 4.3 image on windows OS, to use if possible the consolas font.
I found nothing in the preferences browser to do that easily. That SO question looked perfect, but none of the answers work in my case.
For example on the line
font := LogicalFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.
It fails on the LogicalFont: I get the popup that allows to fix a missing class/variable.
Unknown variable: LogicalFont please correct, or cancel: [...]
Is that solution not suitable for Squeak 4.3, or am I missing some package?
EDIT: as often, I am finding some answer elements after the question has been posted on SO:
I found nothing in the preferences browser to do that easily.
Because the setting is not accessible via the Preference Browser, but via the World menu -> Appearance -> System fonts -> code font.
But I only see a handful of fonts available (beside ComicSans and BitstreamVera), but no Consolas. I do have the preference Offer native fonts enabled, though...
Second Edit: given the answer of Igor Stasenko, I found on SqueakSource a mention of FreeTypePlus that seems the most recent (not often easy for a beginner to find out how to install new software on Squeak, also it seems that Squeak has slowed down since 2006/2007 and some items mentioned in the Swiki are down now...)
So I added on Monticello
MCHttpRepository
location: 'http://www.squeaksource.com/FreeTypePlus'
user: ''
password: ''
And installed FreeType, FreeTypeSubPixelAntiAliasing and PinesoftEnhancementsForFreetype. Now I can see my ttf system fonts...
AFAIK, Squeak doesn't includes Freetype support by default.
You may try Pharo, where Freetype is included by default. http://www.pharo-project.org/home
Or you can try to install Freetype package in Squeak & download freetype plugin for VM.

Jython - javaos.getenv() gives "Failed to get environment, environ will be empty"

Whenever I run any jython program in Eclipse, I got the following error in the beginning of the output:
" Failed to
get environment, environ will be
empty: (0, 'Failed to execute command
([\'sh\', \'-c\', \'env\']):
java.io.IOException: Cannot run
program "sh": Crea teProcess error=2,
The system cannot find the file
specified')
First, my environment is:
Windows 2008
JDK 1.6.0u10
jython 2.2.1
I did some digging, and I realized that this message is produced in the function javaos.getenv().
Whenever I call the javaos.getenv() function, it throws the following error:
C:\jython2.2.1>java -jar jython.jar
import javaos
print javaos.getenv("user.name")
Failed to get environment, environ
will be empty: (0, 'Failed to execute
command ([\'sh\', \'-c\', \'env\']):
java.io.IOException: Cannot run
program "sh": Crea teProcess error=2,
The system cannot find the file
specified')
This is strange, because I'm currently using a Windows machine, not an Unix.
Try to uncomment and change the os setting in the 'registry' file
(it is in the same directory as your jython.jar / i hope)
# python.os determines operating-specific features, similar to and overriding the
# Java property "os.name".
# Some generic values are also supported: 'nt', 'ce' and 'posix'.
# Uncomment the following line for the most generic OS behavior available.
#python.os=None
python.os=nt
# try nt or dos
Interesting. Well, I seem to have found the relevant code here:
http://www.koders.com/python/fid4B7C33153C1427D2CE19CE361EA9519D1652F802.aspx?s=self
If you look towards the bottom, it seems when setting the environment command jython thinks your os is posix. You say you're using "Windows 2008". I'm not sure what that is. Do you mean Windows Server 2008? If so, it's quite new and if you look at the _getOsType function in the same module, it looks like it might be too new for that module. You may need to upgrade to the most recent version of jython or Eclipse. But it's quite possible they haven't yet released a version that supports this OS. If that's the case, you may need to just report the bug to them.
I'm running on Windows 7.
I'm running Jython as a script in the Websphere wsadmin tool.
I encountered this same error.
I cut-n-pasted these lines from javaos.py into my script:
os or sys.registry.getProperty( "python.os" ) or \ java.lang.System.getProperty( "os.name" )
and it returned "Windows Vista".
So I performed the same surgery as suggested above, ie., add Windows Vista to javaos.py and that solved my problem.
I ran into the same error, using Windows Vista, and Jython 2.5.1, under Eclipse/PyDev By editing javaos.py, to include "Windows Vista" in the OR statement in getOsType,;
I fixed the error. (I've filed a bug with the fix under the PyDev Tracker at SourceForge.)
Details:
I installed the full version of Jython, and that did not help.
I also tried editing the "registry" file in the Jython tree. That did not help either.
Then I looked at the files in:
C:\eclipse-platform-3.5-win32\eclipse\plugins\org.python.pydev.jython_1.4.8.2881\Lib
to find "javaos.py" and added a bit of code to read:
def _getOsType( os=None ):
os = os or sys.registry.getProperty( "python.os" ) or \
java.lang.System.getProperty( "os.name" )
_osTypeMap = (
( "nt", r"(nt)|(Windows NT)|(Windows NT 4.0)|(WindowsNT)|"
r"(Windows 2000)|(Windows XP)|(Windows CE)|(Windows Vista)" ),
( "dos", r"(dos)|(Windows 95)|(Windows 98)|(Windows ME)" ),
( "mac", r"(mac)|(MacOS.*)|(Darwin)" ),
( "None", r"(None)" ),
( "posix", r"(.*)" ), # default - posix seems to vary mast widely
)
for osType, pattern in _osTypeMap:
if re.match( pattern, os ):
break
return osType
I've used this hack from Dave Brands blog: http://dbrand666.wordpress.com/2010/04/08/fix1/
try:
import javaos
if javaos._osType == 'posix' and \
java.lang.System.getProperty('os.name').startswith('Windows'):
sys.registry.setProperty('python.os', 'nt')
reload(javaos)
except:
pass