http://www.sslshopper.com/article-how-to-disable-weak-ciphers-and-ssl-2.0-in-apache.html
First, verify that you have weak ciphers or SSL 2.0 enabled. You can do this using a local OpenSSL command or by just entering your public domain name in at https://www.ssllabs.com/ssldb/index.html
Code StackCats Edoc
Monday, January 7, 2013
Friday, January 4, 2013
Sex & Zend: Zend framework form input fields validator
zend framework form add validator
http://framework.zend.com/manual/1.12/en/zend.form.elements.html
->addValidator('Regex', false, array('/^[a-z0-9]{6,}$/i'))
XXXXXXXXXXXXXXXXX
http://framework.zend.com/manual/1.12/en/zend.form.elements.html
->addValidator('Regex', false, array('/^[a-z0-9]{6,}$/i'))
If failing a particular validation should prevent later validators from firing, pass booleanTRUE as the second parameter:
- $element->addValidator('alnum', true);
If you are using a string name to add a validator, and the validator class accepts arguments to the constructor, you may pass these to the third parameter ofaddValidator() as an array:
Arguments passed in this way should be in the order in which they are defined in the constructor. The above example will instantiate the Zend_Validate_StringLenth class with its $min and $max parameters:
- $validator = new Zend_Validate_StringLength(6, 20);
XXXXXXXXXXXXXXXXX
Its addValidatorS (multiple validators):
$this->addElement('text', 'firstname', array(
'label' => 'Your first name:',
'required' => true,
'validators' => array(
array('regex', false, array(
'pattern' => '/[^<>]/i',
'messages' => 'Your first name cannot contain those characters : < >'))
)
));
Online Interpreter (and Pastebin) for most popular programming languages
online php interpreter
Google search for that search string reveals this handy webapp:
http://codepad.org/
Which I used, and resulted in this result, which I am able to share with the rest of the world:
http://codepad.org/XSQScOV1
Something like GitHub Gist or pastebin, only better.
So, what wrought this state of affairs?
1
Actually, I needed to write a regular expression condition in PHP, and I also wanted to check that all the special characters required to be escaped, ...are escaped.
To do that manually would be an error-prone affair, so:
php regex which need escape
http://stackoverflow.com/questions/1789382/php-escaping-regex-reserved-characters-anyone-know-whats-wrong-with-this
Answer: Why not simply use preg_quote?
http://php.net/manual/en/function.preg-quote.php
preg_quote() takes str and puts a backslash in front of every character that is part of the regular expression syntax. This is useful if you have a run-time string that you need to match in some text and the string may contain special regex characters.
The special regular expression characters are: . \ + * ? [ ^ ] $ ( ) { } = ! < > | : -
Last time I didn't know what did preg_match, preg...etc. meant... somehow sounds like a /contraction/ for 'pregnant'.
Okay, but it actually refers to 'Perl-style REGular expression'... thus, 'preg'.
2
Learnt from these:
how to write a regular expression for php
http://www.noupe.com/php/php-regular-expressions.html
http://www.catswhocode.com/blog/15-php-regular-expressions-for-web-developers
http://www.macronimous.com/resources/writing_regular_expression_with_php.asp
\s Matches any whitespace character including space, tab, form-feed, etc.
\S Matches any non-whitespace character.
As for the third link, it feels ironic that an info page on how to use PHP is written using M$ ASP.
(Btw, so is w3schools.)
3
Using PHP in codepad initially gave me a syntax error though:
http://stackoverflow.com/questions/9135784/syntax-error-unexpected-t-variable
Parse error: syntax error, unexpected T_VARIABLE in xxxx.php on line 2
There is no semicolon at the end of that instruction causing the error.
As in C or Perl, PHP requires instructions to be terminated with a semicolon at the end of each statement.
Never had to type a semicolon in recent days.
Anyway, the correct code:
<?php
$str = 'abc() !#$%^"\'&*()';
$result = preg_quote ( $str );
echo $result;
?>
The output:
abc\(\) \!#\$%\^"'&\*\(\)
Tuesday, January 1, 2013
Installing latest Geany (1.22) in debian 6
Installing latest Geany (1.22) in debian 6
you gotta make from sources package, just like installing python 2.7.3 on debian 6.
1. You need these dependencies first
apt-get install libgtk2.0-dev
apt-get install intltool
2. download source distrib
3. unpack
4. ./configure --prefix=/path/to/where-you-wanna-put-geany-program-files
You should get this
you gotta make from sources package, just like installing python 2.7.3 on debian 6.
1. You need these dependencies first
apt-get install libgtk2.0-dev
apt-get install intltool
2. download source distrib
3. unpack
4. ./configure --prefix=/path/to/where-you-wanna-put-geany-program-files
You should get this
config.status: creating doc/geany.1
config.status: creating geany.spec
config.status: creating geany.pc
config.status: creating doc/Doxyfile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing default-1 commands
config.status: executing po/stamp-it commands
-----------------------------------------------------
Install Geany in : /home/your-path-to-install-to/geany
Using GTK version : 2.20.1
Enable binary relocation : no
Build with plugin support : yes
Use (UNIX domain) socket support : yes
Use virtual terminal support : yes
Configuration is done OK.
5. make install
There you have it.
EDIT: To install Geany plugins for debian 6, you need to build them,
set this env variable first:
export PKG_CONFIG_PATH=/home/<your-username>/geany/lib/pkgconfig
then only run ./configure
If successful you should get these results
Then
sudo make install
EDIT: To install Geany plugins for debian 6, you need to build them,
set this env variable first:
export PKG_CONFIG_PATH=/home/<your-username>/geany/lib/pkgconfig
then only run ./configure
If successful you should get these results
Pretty Printer: yes
ShiftColumn: yes
Spellcheck: no
TreeBrowser: yes
Tableconvert: yes
Updatechecker: no
WebHelper: no
XMLSnippets: yes
Features:
GeanyVC GtkSpell support: no
TreeBrowser GIO support: yes
Then
sudo make install
Sunday, November 25, 2012
Linux Environment Variables by using export or not
Using export and not using export - environment variables
http://lowfatlinux.com/linux-environment-variables.html
code=$HOME/projects/src/spew
and then, regardless of what directory you are in, you can issue
cd $code
to pop over quickly to the directory containing the source code for that way-cool spew program you're developing. (The cd command means "change directory.")
A variable assignment like this will work just fine, but its scope (visibility) is limited to the current shell. If you launch a program or enter another shell, that child task will not know about your environment variables unless you export them first.
Unless you know for sure that an environment variable will have meaning only in the current shell, it's a good idea to always useexport when creating variables to ensure they will be global in scope--for example,
export PS1="\u \$ "
export code=$HOME/projects/src/spew
export code=$HOME/projects/src/spew
And be sure to add these commands to your .profile file so you won't have to retype them eac h time you log in.
http://en.wikibooks.org/wiki/Guide_to_Unix/Environment_Variables
http://en.wikipedia.org/wiki/Environment_variable
http://stackoverflow.com/questions/1158091/bash-defining-a-variable-with-or-without-export
export
makes the variable available to sub-processes.
That is,
export name=value
means that the variable name is available to any process you run from that shell process. If you want a process to make use of this variable, use
export
, and run the process from that shell.name=value
means the variable scope is restricted to the shell, and is not available to any other process. You would use this for (say) loop variables, temporary variables etc.
Specifically export makes the variable available to child processes via the environment. – Beano Jul 21 '09 at 13:35
Tuesday, November 20, 2012
How to use Flask micro-framework
1
Where does one draw the distinction between micro- and megaframeworks? Or, for that reference, just a "framework"?
2
The difference between a library and a framework is simply that you call the library whereas the framework calls you. The framework provides a frame into which you put your code as opposed to a library which you use as part of your code.
Generally I would consider any framework which requires (almost) no setup requirements to be a microframework. This is opposed to frameworks which require a basic configuration, directory layout or certain files to be present.
However there are a lot of other people with other definitions regarding this, the distinction is not at all very clear for example there are people that consider being written in a single file to be a distinguishing feature of microframeworks.
3
http://hitesh.in/2012/how-to-migrate-from-bottle-py-to-flask-micro-framework/
from flask import Flask, render_template as template, request, make_response, jsonify, abort from flask.ext.sqlalchemy import SQLAlchemy
from bottle import route, run, template, install, static_file, response import bottle
What is the g object in Flask?
Monday, November 19, 2012
How do I enable remote access to my Postgre database?
The actual file contents you used:
How do I enable remote access to my Postgre database?
http://kb.mediatemple.net/questions/1237/How+do+I+enable+remote+access+to+my+PostgreSQL+server%3F#dv
http://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html
Edit the file:
OR
Append the following configuration lines to give access to 10.10.29.0/24 network:
Save and close the file. Make sure you replace 10.10.29.0/24 with actual network IP address range of the clients system in your own network.
installing postgresql on debian 6
http://library.linode.com/databases/postgresql/debian-6-squeeze
postgres allow remote connection
http://www.ndchost.com/wiki/postgres/remote-access
http://blog.akendo.eu/enable-remote-access-postgresql/
sqlalchemy postgres connection string
http://docs.sqlalchemy.org/en/rel_0_7/core/engines.html
http://docs.sqlalchemy.org/en/rel_0_7/dialects/mysql.html
Without this setting, many MySQL server installations default to a latin1 encoding for client connections, which has the effect of all data being converted into latin1, even if you have utf8 or another character set configured on your tables and columns. With versions 4.1 and higher, you can change the connection character set either through server configuration or by including the charsetparameter. The charset parameter as received by MySQL-Python also has the side-effect of enablinguse_unicode=1:
Manually configuring use_unicode=0 will cause MySQL-python to return encoded strings:
http://www.postgresql.org/docs/8.1/static/sql-grant.html
How do I enable remote access to my Postgre database?
http://kb.mediatemple.net/questions/1237/How+do+I+enable+remote+access+to+my+PostgreSQL+server%3F#dv
External PostgreSQL connections
1. To be able to reach the server remotely you have to add the following line into the file:
/var/lib/pgsql/data/postgresql.conf
:listen_addresses = '*'
2. PostgreSQL, by default, refuses all connections it receives from any remote address. You have to relax these rules by adding this line to
/var/lib/pgsql/data/pg_hba.conf
:host all all 0.0.0.0/0 md5
This is an access control rule that lets anyone login from any address if a valid password is provided (the md5 keyword). You can use your network/mask instead of 0.0.0.0/0 to only allow access from certain IP addresses.
3. When you have applied these modifications to your configuration files, you will need to restart the PostgreSQL server.
/etc/init.d/postgresql start
http://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html
Edit the file:
$ vi /var/lib/pgsql/data/pg_hba.conf
OR
$ vi /etc/postgresql/8.2/main/pg_hba.conf
Append the following configuration lines to give access to 10.10.29.0/24 network:
host all all 10.10.29.0/24 trust
Save and close the file. Make sure you replace 10.10.29.0/24 with actual network IP address range of the clients system in your own network.
installing postgresql on debian 6
http://library.linode.com/databases/postgresql/debian-6-squeeze
postgres allow remote connection
http://www.ndchost.com/wiki/postgres/remote-access
http://blog.akendo.eu/enable-remote-access-postgresql/
sqlalchemy postgres connection string
http://docs.sqlalchemy.org/en/rel_0_7/core/engines.html
from sqlalchemy import create_engine
engine = create_engine('postgresql://scott:tiger@localhost:5432/mydatabase')
The above engine creates a Dialect object tailored towards PostgreSQL, as well as a Pool object which will establish a DBAPI connection at localhost:5432 when a connection request is first received. Note that the Engine and its underlying Pool do not establish the first actual DBAPI connection until theEngine.connect() method is called, or an operation which is dependent on this method such asEngine.execute() is invoked. In this way, Engine and Pool can be said to have a lazy initializationbehavior.
http://docs.sqlalchemy.org/en/rel_0_7/dialects/mysql.html
Unicode
MySQLdb will accommodate Python unicode objects if the use_unicode=1 parameter, or the charsetparameter, is passed as a connection argument.Without this setting, many MySQL server installations default to a latin1 encoding for client connections, which has the effect of all data being converted into latin1, even if you have utf8 or another character set configured on your tables and columns. With versions 4.1 and higher, you can change the connection character set either through server configuration or by including the charsetparameter. The charset parameter as received by MySQL-Python also has the side-effect of enablinguse_unicode=1:
# set client encoding to utf8; all strings come back as unicode
create_engine('mysql+mysqldb:///mydb?charset=utf8')
# set client encoding to utf8; all strings come back as utf8 str
create_engine('mysql+mysqldb:///mydb?charset=utf8&use_unicode=0')
Known Issues
MySQL-python version 1.2.2 has a serious memory leak related to unicode conversion, a feature which is disabled via use_unicode=0. It is strongly advised to use the latest version of MySQL-Python.http://www.postgresql.org/docs/8.1/static/sql-grant.html
The possible privileges are:
- SELECT
- INSERT
- UPDATE
- Allows UPDATE of any column of the specified table. (In practice, any nontrivial UPDATE command will require SELECT privilege as well, since it must reference table columns to determine which rows to update, and/or to compute new values for columns.) SELECT ... FOR UPDATE and SELECT ... FOR SHARE also require this privilege, in addition to the SELECT privilege. For sequences, this privilege allows the use of the
nextval
andsetval
functions. - DELETE
- Allows DELETE of a row from the specified table. (In practice, any nontrivial DELETE command will require SELECT privilege as well, since it must reference table columns to determine which rows to delete.)
- RULE
- Allows the creation of a rule on the table/view. (See the CREATE RULE statement.)
- REFERENCES
- To create a foreign key constraint, it is necessary to have this privilege on both the referencing and referenced tables.
Subscribe to:
Posts (Atom)