maartenmostert
maartenmostert
On Visualworks
4 posts
This blog deals with various day to day issues encountered during the development and deployement of StakePoint Projects environment
Don't wanna be here? Send us removal request.
maartenmostert · 8 years ago
Text
Beautify AppeX Javascript in the Browser
Now if you are like me and tired to copy paste your javascript code into http://jsbeautifier.org/ then you can do the following.
For the moment I only did it on OSX 
First, update brew
brew update
Of from here you can install either python 2.7 or python 3.
The default encoding for Python 2.7 is ASCII which is something, I am no longer really used to, while the default encoding for Python3 is supposed to be utf8 ?
Either way, you can install python 2.7 with
brew install python
pip install jsbeautifier
or use 
brew install python3
pip3 install jsbeautifier
In any case, you end up with UNIX executable which is here:
/usr/local/bin/js-beautify
Of from here you can do things like
js-beautify  -h
or 
js-beautify   /Users/maartenmostert/Dropbox/VW8.2.1/image/toformat.js
Next thing to do is to integrate this trick into to the Browsers JavascriptParser class
JavascriptParser >>format: parseTree
| stream components aFilename command result | components := ObjectMemory imageFilename asAbsoluteFilename components. components removeLast. components add: 'toformat.js'. aFilename := (LogicalFilename fromComponents: components) asFilename. aFilename exists ifTrue: [aFilename delete]. stream := aFilename writeStream. stream := (aFilename  withEncoding: #ascii) appendStream. stream nextPutAll: parseTree sourceCode string. stream close. command := '/usr/local/bin/js-beautify  ' , aFilename asString. result:=ExternalProcess cshOne: command.
^result
Of you go ! Your browser will now format javascript so that you can almost read it !
What I haven’t solved here is the default asci encoding of Python
After typing Python you can do 
import sys reload(sys) sys.setdefaultencoding('utf-8')
But this is not persistent and in order to make it so, you have to alter the site.py file and rebuild and install which is above my knowledge
You can uninstall these things by working in reverse order
pip uninstall jsbeautifier
brew uninstall python
0 notes
maartenmostert · 8 years ago
Text
Postgres listening on multiple ports
If you need to have Postgres listening on multiple ports you can do so using the iptables
In our case, we want to have Postgres listing on both 80 and 443 on top of its standard 5432 port.
To do so you type the following in terminal
iptables -t nat -A PREROUTING -p tcp -s 0/0 -d 37.58.106.56 --match multiport --dport 80,443 -j DNAT --to 37.58.106.56:5432
In this case, our IP is 37.58.106.56
In order to make the IP tables persistent first install the tool
sudo apt-get install iptables-persistent
For Ubuntu 14.04 you will need to do:
sudo /etc/init.d/iptables-persistent save sudo /etc/init.d/iptables-persistent reload
On Ubuntu 16.04 the commands changed to:
 sudo netfilter-persistent save  sudo netfilter-persistent reload
Also see the following external resources
http://www.cyberciti.biz/faq/linux-port-redirection-with-iptables/ http://www.debiantutorials.com/port-forwarding-with-iptables/ http://askubuntu.com/questions/119393/how-to-save-rules-of-the-iptables
0 notes
maartenmostert · 8 years ago
Text
Virtual hosts
You can run a VisualWorks Sioux image behind Apache either as non-secure HTTP or as a secure HTTPS server.
If you run an HTTPS site however you likely still want to be able to serve insecure files and you will also want to redirect HTTP Sioux request towards HTTPS request.
In order to do so will have to provide the correct conf files and place these into the /etc/apache2/sites-available directory.
HTTP configuration
The following conf file contains 3 parts.
The first part relates to the HTTP server you configured in the Appex Web Server Tool
The second part is a WebSocket server that does not serve any files and runs on a different port.
The third part is a subdomain redirection towards zendesk.
<VirtualHost 37.58.106.57:80>
 ServerAdmin [email protected]
 # set serer name  ProxyPreserveHost On   ServerName stakepoint.com   ServerAlias www.stakepoint.com
#Enable CORS Header set Access-Control-Allow-Origin "*"
 # configure static file serving  DocumentRoot /srv/site/files  <Directory /srv/site/files>    AllowOverride All    Require all granted  </Directory>
 # rewrite incoming requests  RewriteEngine On # RewriteCond %{HTTPS} !=on # This checks to make sure the connection is not already HTTPS
 RewriteCond %{HTTPS} off
 RewriteRule ^/files/(.*)$ http://localhost:8889/files/$1 [proxy,last]  RewriteCond /srv/site/files/%{REQUEST_FILENAME} !-f  #RewriteRule ^/(.*)$ http://localhost:8889/$1 [proxy,last]  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
<VirtualHost 37.58.106.57:80>
 ServerAdmin [email protected]  
 # set serer name  ProxyPreserveHost On   ServerName licence.stakepoint.com
 # rewrite incoming requests  RewriteEngine On  RewriteRule ^/(.*)$ http://localhost:4920/$1 [proxy,last]
</VirtualHost>
<VirtualHost 37.58.106.57:80>
 ServerAdmin [email protected]    ServerName help.stakepoint.com
 RewriteEngine On  RewriteRule ^/(.*)$  https://stakepoint.zendesk.com/hc/$1
</VirtualHost>
Notice that the above conf file actually rewrites HHTP request towards HTTPS request for anything that is not file related. The original rewrite rule for the proxy has been commented out to be replaced with a redirection towards HTTPS.
HTTPS configuration
Our Web Server Tool allows us to configure our HTTPS server in the following way:
Tumblr media
Please notice that the Sioux HTTPS server is explicitly hosted on 127.0.0.1 to be recognised as localhost. Also, notice the port 8003 further referenced within the HTTPS conf file given below
<VirtualHost 37.58.106.57:443> ServerAdmin [email protected]
SSLProxyEngine on         ProxyPreserveHost On   ServerName stakepoint.com   ServerAlias www.stakepoint.com
#Enable CORS Header set Access-Control-Allow-Origin "*"
DocumentRoot /srv/site/filessecure  <Directory /srv/site/filessecure>    AllowOverride All     Require all granted  </Directory>
# rewrite incoming requests  RewriteEngine On  RewriteRule ^/files/(.*)$ https://localhost:8003/filessecure/$1 [proxy,last]  RewriteCond /srv/site/filessecure/%{REQUEST_FILENAME} !-f  RewriteRule ^/(.*)$ https://localhost:8003/$1 [proxy,last]
#   SSL Engine Switch: #   Enable/Disable SSL for this virtual host. SSLEngine on
SSLProxyVerify none SSLProxyCheckPeerCN off SSLProxyCheckPeerName off SSLProxyCheckPeerExpire off
#   A self-signed (snakeoil) certificate can be created by installing #   the ssl-cert package. See #   /usr/share/doc/apache2.2-common/README.Debian.gz for more info. #   If both key and certificate are stored in the same file, only the #   SSLCertificateFile directive is needed. SSLCertificateFile    /etc/ssl/certs/stakepoint_com.pem SSLCertificateKeyFile /etc/ssl/private/ssl_comodo_stakepoint.key
#   Server Certificate Chain: #   Point SSLCertificateChainFile at a file containing the #   concatenation of PEM encoded CA certificates which form the #   certificate chain for the server certificate. Alternatively #   the referenced file can be the same as SSLCertificateFile #   when the CA certificates are directly appended to the server #   certificate for convinience. SSLCertificateChainFile  /etc/ssl/certs/stakepoint_com.pem
#   Certificate Authority (CA): #   Set the CA certificate verification path where to find CA #   certificates for client authentication or alternatively one #   huge file containing all of them (file must be PEM encoded) #   Note: Inside SSLCACertificatePath you need hash symlinks #         to point to the certificate files. Use the provided #         Makefile to update the hash symlinks after changes. SSLCACertificatePath /etc/ssl/certs/ SSLCACertificateFile  /etc/ssl/certs/stakepoint_com.ca-bundle.pem
</VirtualHost>
In order to use the new sites, you must disable the default Apache enabled sites in accordance with their file names
sudo a2dissite 000-default.conf
Next, you need to enable yours:
sudo a2ensite example.com.conf
You can load the new configuration with
sudo service apache2 reload
or
sudo service apache2 restart
0 notes
maartenmostert · 8 years ago
Text
Deploying VisualWorks Smalltalk on Ubuntu 14.04
We are starting here with a fresh Ubuntu 14.04 - 64bit installation.
We assume here you have a running 64bit VisualWorks Sioux image.
The reason we choose Ubuntu 14.04 over Ubuntu 16.04 is related to the PostgreSQL version that comes with 16.04 which is Postgres 9.5. This version is bugged and doesn’t want to listen to external connections. Ubuntu 14.04 comes with Postgres 9.4. This version responds correctly to modification in the configuration files.
If it is not there yet the first thing to do is to install Apache. 
sudo apt-get update 
sudo apt-get install apache2
In our case, this will install us Apache 2.4 in the directory /etc/apache2/
Now in order to run the Sioux Image behind Apache we need to enable a number of additional mods.
a2enmod headers
a2enmod proxy 
a2enmod proxy_http 
a2enmod proxy_ajp 
a2enmod rewrite 
a2enmod headers 
a2enmod proxy_connect 
a2enmod proxy_html
a2enmod ssl
Upon enabling the different mods you can double check their availability:
cd /etc/apache2/mods-available
ls -F
You can double check you have the following files here:
 access_compat.load  actions.conf  actions.load  alias.conf  alias.load  allowmethods.load  asis.load  auth_basic.load  auth_digest.load  auth_form.load  authn_anon.load  authn_core.load  authn_dbd.load  authn_dbm.load  authn_file.load  authn_socache.load  authnz_fcgi.load  authnz_ldap.load  authz_core.load  authz_dbd.load  authz_dbm.load  authz_groupfile.load  authz_host.load  authz_owner.load  authz_user.load  autoindex.conf  autoindex.load  buffer.load  cache_disk.conf  cache_disk.load  cache.load  cache_socache.load  cgid.conf  cgid.load  cgi.load  charset_lite.load  data.load  dav_fs.conf  dav_fs.load  dav.load  dav_lock.load  dbd.load  deflate.conf  deflate.load  dialup.load  dir.conf  dir.load  dump_io.load  echo.load  env.load  expires.load  ext_filter.load  file_cache.load  filter.load  headers.load  heartbeat.load  heartmonitor.load  ident.load  include.load  info.conf  info.load  lbmethod_bybusyness.load  lbmethod_byrequests.load  lbmethod_bytraffic.load  lbmethod_heartbeat.load  ldap.conf  ldap.load  log_debug.load  log_forensic.load  lua.load  macro.load  mime.conf  mime.load  mime_magic.conf  mime_magic.load  mpm_event.conf  mpm_event.load  mpm_prefork.conf  mpm_prefork.load  mpm_worker.conf  mpm_worker.load  negotiation.conf  negotiation.load  proxy_ajp.load  proxy_balancer.conf  proxy_balancer.load  proxy.conf  proxy_connect.load  proxy_express.load  proxy_fcgi.load  proxy_fdpass.load  proxy_ftp.conf  proxy_ftp.load  proxy_html.conf  proxy_html.load  proxy_http.load  proxy.load  proxy_scgi.load  proxy_wstunnel.load  ratelimit.load  reflector.load  remoteip.load  reqtimeout.conf  reqtimeout.load  request.load  rewrite.load  sed.load  session_cookie.load  session_crypto.load  session_dbd.load  session.load  setenvif.conf  setenvif.load  slotmem_plain.load  slotmem_shm.load  socache_dbm.load  socache_memcache.load  socache_shmcb.load  speling.load  ssl.conf  ssl.load  status.conf  status.load  substitute.load  suexec.load  unique_id.load  userdir.conf  userdir.load  usertrack.load  vhost_alias.load  xml2enc.load
You can restart Apache with the following command
service apache2 restart
In order to configure your site, you will need to configure your Virtual hosts
0 notes