Design pattern in Symfony2 - Nanos gigantium humeris insidentes from Giulio De Donato
Symfony2 Framework Complete flow:
Symfony2 Framework Complete flow:
echo | openssl s_client -connect ${MY_SERVER}:443 2>&1 | \ sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > mycert.pem
-----BEGIN CERTIFICATE----- MIIDITCCAoqgAwIBAgIQL9+89q6RUm0PmqPfQDQ+mjANBgkqhkiG9w0BAQUFADBM MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkg THRkLjEWMBQGA1UEAxMNVGhhd3RlIFNHQyBDQTAeFw0wOTEyMTgwMDAwMDBaFw0x MTEyMTgyMzU5NTlaMGgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh MRYwFAYDVQQHFA1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKFApHb29nbGUgSW5jMRcw FQYDVQQDFA53d3cuZ29vZ2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkC gYEA6PmGD5D6htffvXImttdEAoN4c9kCKO+IRTn7EOh8rqk41XXGOOsKFQebg+jN gtXj9xVoRaELGYW84u+E593y17iYwqG7tcFR39SDAqc9BkJb4SLD3muFXxzW2k6L 05vuuWciKh0R73mkszeK9P4Y/bz5RiNQl/Os/CRGK1w7t0UCAwEAAaOB5zCB5DAM BgNVHRMBAf8EAjAAMDYGA1UdHwQvMC0wK6ApoCeGJWh0dHA6Ly9jcmwudGhhd3Rl LmNvbS9UaGF3dGVTR0NDQS5jcmwwKAYDVR0lBCEwHwYIKwYBBQUHAwEGCCsGAQUF BwMCBglghkgBhvhCBAEwcgYIKwYBBQUHAQEEZjBkMCIGCCsGAQUFBzABhhZodHRw Oi8vb2NzcC50aGF3dGUuY29tMD4GCCsGAQUFBzAChjJodHRwOi8vd3d3LnRoYXd0 ZS5jb20vcmVwb3NpdG9yeS9UaGF3dGVfU0dDX0NBLmNydDANBgkqhkiG9w0BAQUF AAOBgQCfQ89bxFApsb/isJr/aiEdLRLDLE5a+RLizrmCUi3nHX4adpaQedEkUjh5 u2ONgJd8IyAPkU0Wueru9G2Jysa9zCRo1kNbzipYvzwY4OA8Ys+WAi0oR1A04Se6 z5nRUP8pJcA2NhUzUnC+MY+f6H/nEQyNv4SgQhqAibAxWEEHXw== -----END CERTIFICATE-----
export CLASSPATH=bcprov-jdk16-145.jar CERTSTORE=res/raw/mystore.bks if [ -a $CERTSTORE ]; then rm $CERTSTORE || exit 1 fi keytool \ -import \ -v \ -trustcacerts \ -alias 0 \ -file <(openssl x509 -in mycert.pem) \ -keystore $CERTSTORE \ -storetype BKS \ -provider org.bouncycastle.jce.provider.BouncyCastleProvider \ -providerpath /usr/share/java/bcprov.jar \ -storepass ez24get
import android.content.Context; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.scheme.PlainSocketFactory; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.SchemeRegistry; import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.conn.SingleClientConnManager; import java.io.InputStream; import java.security.KeyStore; public class MyHttpClient extends DefaultHttpClient { final Context context; public MyHttpClient(Context context) { this.context = context; } @Override protected ClientConnectionManager createClientConnectionManager() { SchemeRegistry registry = new SchemeRegistry(); registry.register( new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); registry.register(new Scheme("https", newSslSocketFactory(), 443)); return new SingleClientConnManager(getParams(), registry); } private SSLSocketFactory newSslSocketFactory() { try { KeyStore trusted = KeyStore.getInstance("BKS"); InputStream in = context.getResources().openRawResource(R.raw.mystore); try { trusted.load(in, "ez24get".toCharArray()); } finally { in.close(); } return new SSLSocketFactory(trusted); } catch (Exception e) { throw new AssertionError(e); } } }
Originally Posted in crazybob blog
#!/usr/bin/php
<?php
//this can be anything from reading input from files, to retrieving database content, soap calls, etc.
//for this example I'm going to create a simple php associative array.
$a = array(
'first_name' => 'Hello',
'last_name' => 'World'
);
//it's important to note that anything you send to STDOUT will be written to the output specified by the mapper.
//it's also important to note, do not forget to end all output to STDOUT with a PHP_EOL, this will save you a lot of pain.
echo serialize($a), PHP_EOL;
?>
#!/usr/bin/php
<?php
//Remember when I said anything put out through STDOUT in our mapper would go to the reducer.
//Well, now we read from the STDIN to get the result of our mapper.
//iterate all lines of output from our mapper
while (($line = fgets(STDIN)) !== false) {
//remove leading and trailing whitespace, just in case
$line = trim($line);
//now recreate the array we serialized in our mapper
$a = unserialize($line);
//Now, we do whatever we need to with the data. Write it out again so another process can pick it up,
//send it to the database, soap call, whatever. In this example, just change it a little and
//write it back out.
$a['middle_name'] = 'Jason';
//do not forget the PHP_EOL
echo serialize($a), PHP_EOL;
}//end while
?>
Description: | Enables HTTP persistent connections |
---|---|
Syntax: | KeepAlive On|Off |
Default: | KeepAlive On |
Context: | server config, virtual host |
Status: | Core |
Module: | core |
KeepAlive On
.Description: | Amount of time the server will wait for subsequent requests on a persistent connection |
---|---|
Syntax: | KeepAliveTimeout seconds |
Default: | KeepAliveTimeout 5 |
Context: | server config, virtual host |
Status: | Core |
Module: | core |
Timeout
directive applies.KeepAliveTimeout
to a high value may cause performance problems in heavily loaded servers. The higher the timeout, the more server processes will be kept occupied waiting on connections with idle clients.NameVirtualHost
will be used. The other values will be ignored.Description: | Number of requests allowed on a persistent connection |
---|---|
Syntax: | MaxKeepAliveRequests number |
Default: | MaxKeepAliveRequests 100 |
Context: | server config, virtual host |
Status: | Core |
Module: | core |
MaxKeepAliveRequests
directive limits the number of requests allowed per connection whenKeepAlive
is on. If it is set to 0
, unlimited requests will be allowed. We recommend that this setting be kept to a high value for maximum server performance.MaxKeepAliveRequests 500
# yum info couchdb
Name : couchdb
Arch : x86_64
Version : 1.0.3
Release : 2.el6
Size : 1.7 M
Repo : epel
Summary : A document database server, accessible via a RESTful JSON API
# yum install couchdb
# vi /etc/couchdb/local.ini
[httpd]
;port = 5984
;bind_address = 127.0.0.1
bind_address = 192.168.101.38
# service couchdb start
Starting couchdb: [ OK ]
# service couchdb status
couchdb (pid 29915) is running...
# yum info gcc libtool xulrunner-devel libicu-devel openssl-devel
cd /usr/src
wget http://www.erlang.org/download/otp_src_R15B01.tar.gz
tar xvfz otp_src_R15B01.tar.gz
cd otp_src_R15B01
./configure --prefix=/opt/couchdb/erlang --without-termcap --without-javac --enable-smp-support --disable-hipe
make
make install
cd /usr/src
wget http://curl.haxx.se/download/curl-7.26.0.tar.gz
tar xvfz curl-7.25.0.tar.gz
cd curl-7.25.0
./configure --prefix=/opt/couchdb/curl
make
make install
cd /usr/src
wget http://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz
tar xvfz js185-1.0.0.tar.gz
cd js-1.8.5/js/src
./configure
make
make install
# ls -ltr /usr/local/lib
-rwxr-xr-x. 1 root root 3671764 May 30 09:39 libmozjs185.so.1.0.0
-rwxr-xr-x. 1 root root 5523616 May 30 09:39 libmozjs185-1.0.a
lrwxrwxrwx. 1 root root 35 May 30 09:40 libmozjs185.so.1.0 -> /usr/local/lib/libmozjs185.so.1.0.0
lrwxrwxrwx. 1 root root 33 May 30 09:40 libmozjs185.so -> /usr/local/lib/libmozjs185.so.1.0
checking for JS_NewObject in -lmozjs185... no
configure: error: Could not find the js library.
Is the Mozilla SpiderMonkey library installed?
cd /usr/src
wget http://apache.mirrors.pair.com/couchdb/releases/1.2.0/apache-couchdb-1.2.0.tar.gz
tar xvfz apache-couchdb-1.2.0.tar.gz
cd apache-couchdb-1.2.0
export ERL=/opt/couchdb/erlang/bin/erl
export ERLC=/opt/couchdb/erlang/bin/erlc
export CURL_CONFIG=/opt/couchdb/curl/bin/curl-config
export LDFLAGS=-L/opt/couchdb/curl/lib
./configure --prefix=/opt/couchdb/couchdb --with-erlang=/opt/couchdb/erlang/lib/erlang/usr/include/ --enable-js-trunk
make
make install
./configure --prefix=/opt/couchdb/couchdb --with-erlang=/opt/couchdb/erlang/lib/erlang/usr/include/ --with-js-include=/usr/include/xulrunner-2/ --with-js-lib=/usr/lib64/xulrunner-devel-2/lib/
Note: If you’ve installed the latest version of spidermonkey js, and if you are not using –enable-js-trunk, you’ll get the following error message during “make” of couchdb:cc1: warnings being treated as errors
In file included from couch_js/main.c:20:
couch_js/sm170.c: In function req_status:
couch_js/sm170.c:105: error: implicit declaration of function INT_FITS_IN_JSVAL
couch_js/sm170.c: In function evalcx:
couch_js/sm170.c:138: error: implicit declaration of function JS_GetStringChars
couch_js/sm170.c:138: error: assignment makes pointer from integer without a cast
couch_js/sm170.c: In function seal:
couch_js/sm170.c:220: error: implicit declaration of function JS_SealObject
couch_js/sm170.c: At top level:
couch_js/sm170.c:236: error: initialization from incompatible pointer type
# adduser couchdb
# chown -R couchdb /opt/couchdb/couchdb/var/
# ln -s /opt/couchdb/couchdb/etc/rc.d/couchdb /etc/init.d/couchdb
# service couchdb start
Starting database server couchdb