It turns out that setting up SSL on Nginx + Unicorn + Rails is actually pretty easy. But there's a few pitfalls you have to watch out for. The following guide is based partially on these instructions and assumes you already have an SSL certificate and already have it placed on your server.
Let's take a look at our initial Nginx configuration file. You can find yours in /etc/nginx/sites-available
, but if you're reading this you probably already knew that.
upstream unicorn_mysite { server unix:/tmp/unicorn.mysite.sock fail_timeout=0; } server { listen 80; server_name mysite.com; root /srv/mysite/current/public; access_log /srv/mysite/shared/log/nginx.access.log main; error_log /srv/mysite/shared/log/nginx.error.log info; location ^~ /assets/ { gzip_static on; expires max; add_header Cache-Control public; } try_files $uri/index.html $uri @unicorn; location @unicorn { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://unicorn_mysite; } error_page 500 502 503 504 /500.html; client_max_body_size 4G; keepalive_timeout 10; }
As you can see, this configuration makes some assumptions about our setup that are unlikely to be true for yours. However, for this exercise the details of the configuration are largely inconsequential.
In your editor of choice take the above config file and copy the server
section and paste it below. Now, make the second server
section look something like this:
server { listen 443; ssl on; ssl_certificate /etc/httpd/conf/ssl/mysite.com.crt; ssl_certificate_key /etc/httpd/conf/ssl/mysite.com.key; server_name mysite.com; root /srv/mysite/current/public; access_log /srv/mysite/shared/log/nginx.ssl.access.log main; error_log /srv/mysite/shared/log/nginx.ssl.error.log info; location ^~ /assets/ { gzip_static on; expires max; add_header Cache-Control public; } try_files $uri/index.html $uri @unicorn; location @unicorn { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://unicorn_mysite; } error_page 500 502 503 504 /500.html; client_max_body_size 4G; keepalive_timeout 10; }
The first difference you should notice is the listen port. HTTPS uses port 443 instead of port 80. The following three lines tell Nginx that we want SSL on and where our certificate and where our certificate keys are being stored. /etc/httpd/conf/ssl
is a pretty standard location, but you can keep them anywhere.
The next change we make is to the log file locations. The normal HTTP config will write to nginx.access.log
and nginx.error.log
. Here we're telling the HTTPS config to write to nginx.ssl.access.log
and nginx.ssl.error.log
instead. If you ever encounter any problems with your SSL setup it'll be pretty handy to have your logs separated out by protocol.
The last difference between the two configurations is the extra proxy_set_header
setting. Since we plan on using force_ssl
in our Rails application to selectively ensure SSL on different controllers this step is really important. force_ssl
relies on the HTTP_X_FORWARDED_PROTO
HTTP header to determine whether or not the request was an HTTPS request. If this setting isn't set to https then you will end up with an infinite redirect loop as force_ssl
will always think the forwarded request isn't HTTPS.
At this point you should restart Nginx: sudo /etc/init.d/nginx restart
. In your Rails app's controller add the call to force_ssl
at the top like this:
class ContactsController < ApplicationController force_ssl before_filter :whatever ...
Now, when you go to any action on that controller you should immediately be redirected to the SSL version.
If you get an error similar to "Error 102 (net:: ERR CONNECTION REFUSED)" then this likely means your server is blocking port 443. Odds are you won't have this issue, but I did, so it makes sense to me to include a possible fix. This makes the assumption you're using iptables to manage your ports. Open up /etc/sysconfig/iptables
and look for a line similar to this:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
Immediately below it add the following:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
As usual, if your settings look similar but not quite the same then base your changes off your settings. The important part here is the --dport
, we want to open up port 443. After you do this you'll need to restart iptables with sudo /etc/init.d/iptables restart
.
At this point your controllers with force_ssl
in them should be redirecting to the SSL version of your site. Like most ActionController callbacks you can also specify which actions force_ssl
will be run on using the only
and except
options.


Abstract
There are plenty of Lisp Markup Languages out there - every Lisp programmer seems to write at least one during his career - and CL-WHO (where WHO means "with-html-output" for want of a better acronym) is probably just as good or bad as the next one. They are all more or less similar in that they provide convenient means to convert S-expressions intermingled with code into (X)HTML, XML, or whatever but differ with respect to syntax, implementation, and API. So, if you haven't made a choice yet, check out the alternatives as well before you begin to use CL-WHO just because it was the first one you came across. (Was that repelling enough?) If you're looking for a slightly different approach you might also want to look at HTML-TEMPLATE.I wrote this one in 2002 although at least Tim Bradshaw's htout and AllegroServe's HTML generation facilities by John Foderaro of Franz Inc. were readily available. Actually, I don't remember why I had to write my own library - maybe just because it was fun and didn't take very long. The syntax was obviously inspired by htout although it is slightly different.
CL-WHO tries to create efficient code in that it makes constant strings as long as possible. In other words, the code generated by the CL-WHO macros will usually be a sequence of
WRITE-STRING
forms for constant parts of the output interspersed with arbitrary code inserted by the user of the macro. CL-WHO will make sure that there aren't two adjacentWRITE-STRING
forms with constant strings. CL-WHO's output is either XHTML (default), 'plain' (SGML) HTML or HTML5 (using HTML syntax) — depending on what you've setHTML-MODE
to.CL-WHO is intended to be portable and should work with all conforming Common Lisp implementations. Let us know if you encounter any problems.
It comes with a BSD-style license so you can basically do with it whatever you want.
CL-WHO is for example used by clutu and Heike Stephan.
Download shortcut: http://weitz.de/files/cl-who.tar.gz.
with-html-output
with-html-output-to-string
*attribute-quote-char*
*downcase-tokens-p*
*html-empty-tag-aware-p*
*html-empty-tags*
*html-no-indent-tags*
*prologue*
esc
fmt
htm
str
html-mode
escape-string
escape-char
*escape-char-p*
escape-string-minimal
escape-string-minimal-plus-quotes
escape-string-iso-8859-1
escape-string-all
escape-char-minimal
escape-char-minimal-plus-quotes
escape-char-iso-8859-1
escape-char-all
conc
convert-tag-to-string-list
convert-attributes
*HTTP-STREAM*
is the stream your web
application is supposed to write to. Here are some contrived code snippets
together with the Lisp code generated by CL-WHO and the resulting HTML output.
(with-html-output (*http-stream*) (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") ("http://marcusmiller.com/" . "Marcus Miller") ("http://www.milesdavis.com/" . "Miles Davis")) do (htm (:a :href link (:b (str title))) :br))) |
Frank Zappa Marcus Miller Miles Davis |
|||||||||||||||||||||||||
;; code generated by CL-WHO (simplified) (let ((*http-stream* *http-stream*)) (progn nil (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa") ("http://marcusmiller.com/" . "Marcus Miller") ("http://www.milesdavis.com/" . "Miles Davis")) do (progn (write-string "" *http-stream*) (princ title *http-stream*) (write-string "
" *http-stream*))))) |
||||||||||||||||||||||||||
(with-html-output (*http-stream*) (:table :border 0 :cellpadding 4 (loop for i below 25 by 5 do (htm (:tr :align "right" (loop for j from i below (+ i 5) do (htm (:td :bgcolor (if (oddp j) "pink" "green") (fmt "~@R" (1+ j)))))))))) |
|
|||||||||||||||||||||||||
;; code generated by CL-WHO (simplified) (let ((*http-stream* *http-stream*)) (progn nil (write-string "
" *http-stream*) (loop for i below 25 by 5 do (progn (write-string "
" *http-stream*) (loop for j from i below (+ i 5) do (progn (write-string "" *http-stream*) (format *http-stream* "~@r" (1+ j)) (write-string "	" *http-stream*))) (write-string "
" *http-stream*))) (write-string "
" *http-stream*))) |
||||||||||||||||||||||||||
(with-html-output (*http-stream*) (:h4 "Look at the character entities generated by this example") (loop for i from 0 for string in '("Fête" "Sørensen" "naïve" "Hühner" "Straße") do (htm (:p :style (conc "background-color:" (case (mod i 3) ((0) "red") ((1) "orange") ((2) "blue"))) (htm (esc string)))))) |
Look at the character entities generated by this exampleFête Sørensen naïve Hühner Straße |
|||||||||||||||||||||||||
;; code generated by CL-WHO (simplified) (let ((*http-stream* *http-stream*)) (progn nil (write-string "
Look at the character entities generated by this example
" *http-stream*) (loop for i from 0 for string in '("Fête" "Sørensen" "naïve" "Hühner" "Straße") do (progn (write-string "
" *http-stream*) (progn (write-string (escape-string string) *http-stream*)) (write-string "
" *http-stream*))))) |
The preferred method to fetch, compile and load CL-WHO is via Quicklisp. Install Quicklisp, then run
(ql:quickload :cl-who)
The current development version of CL-WHO can be found at https://github.com/edicl/cl-who. This is the one to send patches against. Use at your own risk.
Luís Oliveira maintains an unofficial darcs repository of CL-WHO at http://common-lisp.net/~loliveira/ediware/.
You can run a test suite which tests some (but not all) aspects of the library with
(asdf:oos 'asdf:test-op :cl-who)
WITH-HTML-OUTPUT
, which
transforms the body of code it encloses into something else obeying the
following rules (which we'll call transformation rules) for the body's forms:
"foo" => (write-string "foo" s) |
(:br) => (write-string "
" s) |
HTML-MODE
set to :SGML
an empty element is written this way:
(:br) => (write-string "
" s) |
NIL
.) The form denoting the attribute's value will be treated as follows. (Note that the behaviour with respect to attributes is incompatible with versions earlier than 0.3.0!)
(:td :bgcolor "red") => (write-string "" s) |
T
and HTML-MODE
is :XML
(default) the attribute's value will be the attribute's name (following XHTML convention to denote attributes which don't have a value in HTML).
(:td :nowrap t) => (write-string "" s) |
HTML-MODE
set to :SGML
:
(:td :nowrap t) => (write-string "" s) |
NIL
the attribute will be left out completely.
(:td :nowrap nil) => (write-string "" s) |
"~A"
at macro expansion time.
(:table :border 3) => (write-string "
" s) |
PRINC
unless the value is T
or NIL
which will be treated as above. (It is the application developer's job to provide the correct printer control variables.)
;; simplified example, see function CHECKBOX below ;; note that this form is not necessarily CONSTANTP in all Lisps (:table :border (+ 1 2)) => (write-string "
" s) |
(:table :border 0 :cellpadding 5 :cellspacing 5) => (write-string "
" s) |
(:p "Paragraph") => (write-string "
Paragraph
" s) (:p :class "foo" "Paragraph") => (write-string "
Paragraph
" s) (:p :class "foo" "One" " " "long" " " "sentence") => (write-string "
One long sentence
" s) (:p :class "foo" "Visit " (:a :href "http://www.cliki.net/" "CLiki")) => (write-string "
Visit CLiki
" s) |
((:p) "Paragraph") => (write-string "
Paragraph
" s) ((:p :class "foo") "Paragraph") => (write-string "
Paragraph
" s) ((:p :class "foo" :name "humpty-dumpty") "One" " " "long" " " "sentence") => (write-string "
One long sentence
" s) ((:p :class "foo") "Visit " ((:a :href "http://www.cliki.net/") "CLiki")) => (write-string "
Visit CLiki
" s) |
* (defun checkbox (stream name checked &optional value) (with-html-output (stream) (:input :type "checkbox" :name name :checked checked :value value))) CHECKBOX * (with-output-to-string (s) (checkbox s "foo" t)) "<input type='checkbox' name='foo' checked='checked' />" * (with-output-to-string (s) (checkbox s "foo" nil)) "<input type='checkbox' name='foo' />" * (with-output-to-string (s) (checkbox s "foo" nil "bar")) "<input type='checkbox' name='foo' value='bar' />" * (with-output-to-string (s) (checkbox s "foo" t "bar")) "<input type='checkbox' name='foo' checked='checked' value='bar' />"
:hr => (write-string "
" s) |
(str form)
will be substituted with
(let ((result form)) (when result (princ result s)))
.
(loop for i below 10 do (str i)) => (loop for i below 10 do (let ((#:result i)) (when #:result (princ #:result *standard-output*)))) |
(fmt form*)
will be substituted with (format s form*)
.
(loop for i below 10 do (fmt "~R" i)) => (loop for i below 10 do (format s "~R" i)) |
(esc form)
will be substituted with
(let ((result form)) (when result (write-string (escape-string result s))))
.
(htm form*)
then each of the forms
will be subject to the transformation rules we're just describing, i.e. this is the body is wrapped with another invocation of WITH-HTML-OUTPUT
.
(loop for i below 100 do (htm (:b "foo") :br)) => (loop for i below 100 do (progn (write-string "foo
" s))) |
:foobar
instead of :hr
.
[Macro]
with-html-output (var &optional stream &key prologue indent) declaration* form* => result*
This is the main macro of CL-WHO. It will transform its body by the transformation rules described in Syntax and Semantics such that the output generated is sent to the stream denoted byvar
andstream
.var
must be a symbol. Ifstream
isNIL
it is assumed thatvar
is already bound to a stream, ifstream
is notNIL
var
will be bound to the formstream
which will be evaluated at run time.prologue
should be a string (orNIL
for the empty string which is the default) which is guaranteed to be the first thing sent to the stream from within the body of this macro. Ifprologue
isT
the prologue string is the value of*PROLOGUE*
.CL-WHO will usually try not to insert any unnecessary whitespace in order to save bandwidth. However, if
indent
is true line breaks will be inserted and nested tags will be indented properly. The value ofindent
- if it is an integer - will be taken as the initial indentation. If it is not an integer it is assumed to mean0
. Value of*HTML-NO-INDENT-TAGS*
controls which tag-contents are excempt from indentation: by default contents ofPRE
andTEXTAREA
tags are not indented to avoid spurious layout changes. (Note: in certain situations additional whitespace may change the layout of tables.)The
results
are the values returned by theforms
.Note that the keyword arguments
prologue
andindent
, and the associated variables are used at macro expansion time.* (with-html-output (*standard-output* nil :prologue t) (:html (:body "Not much there")) (values)) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">Not much there * (with-html-output (*standard-output*) (:html (:body :bgcolor "white" "Not much there")) (values)) Not much there * (with-html-output (*standard-output* nil :prologue t :indent t) (:html (:body :bgcolor "white" "Not much there")) (values)) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">   Not much there
This is just a thin wrapper aroundWITH-HTML-OUTPUT
. Indeed, the wrapper is so thin that the best explanation probably is to show its definition:(defmacro with-html-output-to-string ((var &optional string-form &key (element-type ''character) prologue indent) &body body) "Transform the enclosed BODY consisting of HTML as s-expressions into Lisp code which creates the corresponding HTML as a string." `(with-output-to-string (,var ,string-form :elementy-type ,element-type) (with-html-output (,var nil :prologue ,prologue :indent ,indent) ,@body)))Note that theresults
of this macro are determined by the behaviour ofWITH-OUTPUT-TO-STRING
.
[Special variable]
*attribute-quote-char*
This character is used as the quote character when building attributes. Defaults to the single quote#\'
. Only other reasonable character is the double quote#\"
.
[Special variable]
*downcase-tokens-p*
If the value of this variable isNIL
, keyword symbols representing a tag or attribute name will not be automatically converted to lowercase. This is useful when one needs to output case sensitive XML. The default isT
.
[Special variable]
*html-empty-tag-aware-p*
Set this toNIL
to if you want to use CL-WHO as a strict XML generator. Otherwise, CL-WHO will only write empty tags listed in*HTML-EMPTY-TAGS*
as<tag/>
(XHTML mode) or<tag>
(SGML mode or HTML mode). For all other tags, it will always generate<tag></tag>
. The initial value of this variable isT
.
[Special variable]
*html-empty-tags*
The list of HTML tags that should be output as empty tags. See*HTML-EMPTY-TAG-AWARE-P*
. The initial value is the list(:area :atop :audioscope :base :basefont :br :choose :col :command :embed :frame :hr :img :input :isindex :keygen :left :limittext :link :meta :nextid :of :over :param :range :right :source :spacer :spot :tab :track :wbr)
[Special variable]
*html-no-indent-tags*
The list of HTML tags that should disable indentation inside them even when indentation is requested. The initial value is a list containing only:pre
and:texarea
.
[Special variable]
*prologue*
This is the prologue string which will be printed if theprologue
keyword argument toWITH-HTML-OUTPUT
isT
. Gets changed when you setHTML-MODE
. Its initial value is"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
[Symbol]
esc
[Symbol]
fmt
[Symbol]
htm
[Symbol]
str
These are just symbols with no bindings associated with them. The only reason they are exported is their special meaning during the transformations described in Syntax and Semantics.
[Accessor]
html-mode => mode
(setf (html-mode) mode)
The functionHTML-MODE
returns the current mode for generating HTML. The default is:XML
for XHTML. You can change this by setting it with(SETF (HTML-MODE) :SGML)
to pre-XML HTML mode or(SETF (HTML-MODE) :HTML5)
to HTML5 mode (using HTML syntax).Setting it to SGML HTML sets the
*prologue*
to the doctype string for HTML 4.01 transitional:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">Code generation in SGML HTML is slightly different from XHTML - there's no need to end empty elements with/>
and empty attributes are allowed.Setting it to HTML5 sets the
*prologue*
to the following doctype string:<!DOCTYPE html>
[Function]
escape-string string &key test => escaped-string
This function will accept a stringstring
and will replace every character for whichtest
returns true with its character entity. The numeric character entities use decimal instead of hexadecimal values whenHTML-MODE
is set to:SGML
because of compatibility reasons with old clients.test
must be a function of one argument which accepts a character and returns a generalized boolean. The default is the value of*ESCAPE-CHAR-P*
. Note theESC
shortcut described in Syntax and Semantics.* (escape-string "<Hühner> 'naïve'") "<Hühner> 'naïve'" * (with-html-output-to-string (s) (:b (esc "<Hühner> 'naïve'"))) "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"<Hühner> 'naïve'"
[Function]
escape-char character &key test => escaped-string
This function works identical toESCAPE-STRING
, except that it operates on characters instead of strings.
[Special variable]
*escape-char-p*
This is the default for thetest
keyword argument toESCAPE-STRING
andESCAPE-CHAR
. Its initial value is#'(lambda (char) (or (find char "<>&'\"") (> (char-code char) 127)))
[Function]
escape-string-minimal string => escaped-string
[Function]
escape-string-minimal-plus-quotes string => escaped-string
[Function]
escape-string-iso-8859-1 string => escaped-string
[Function]
escape-string-all string => escaped-string
[Function]
escape-char-minimal character => escaped-string
[Function]
escape-char-minimal-plus-quotes character => escaped-string
[Function]
escape-char-iso-8859-1 character => escaped-string
[Function]
escape-char-all character => escaped-string
These are convenience function based onESCAPE-STRING
andESCAPE-CHAR
. The string functions are defined in a way similar to this one:(defun escape-string-minimal (string) "Escape only #\<, #\>, and #\& in STRING." (escape-string string :test #'(lambda (char) (find char "<>&")))) (defun escape-string-minimal-plus-quotes (string) "Like ESCAPE-STRING-MINIMAL but also escapes quotes." (escape-string string :test #'(lambda (char) (find char "<>&'\"")))) (defun escape-string-iso-8859-1 (string) "Escapes all characters in STRING which aren't defined in ISO-8859-1." (escape-string string :test #'(lambda (char) (or (find char "<>&'\"") (> (char-code char) 255))))) (defun escape-string-all (string) "Escapes all characters in STRING which aren't in the 7-bit ASCII character set." (escape-string string :test #'(lambda (char) (or (find char "<>&'\"") (> (char-code char) 127)))))The character functions are defined in an analogous manner.
[Function]
conc &rest string-list => string
Utility function to concatenate all arguments (which should be strings) into one string. Meant to be used mainly with attribute values.* (conc "This" " " "is" " " "a" " " "sentence") "This is a sentence" * (with-html-output-to-string (s) (:div :style (conc "padding:" (format nil "~A" (+ 3 2))) "Foobar")) "
Foobar
"
[Generic Function]
convert-tag-to-string-list tag attr-list body body-fn => strings-or-forms
This function exposes some of CL-WHO's internals so users can customize its behaviour. It is called whenever a tag is processed and must return a corresponding list of strings or Lisp forms. The idea is that you can specialize this generic function in order to process certain tags yourself.
tag
is a keyword symbol naming the outer tag,attr-list
is an alist of its attributes (the car is the attribute's name as a keyword, the cdr is its value),body
is the tag's body, andbody-fn
is a function which should be applied to the body to further process it. Of course, if you define your own methods you can ignorebody-fn
if you want.Here are some simple examples:
* (defmethod convert-tag-to-string-list ((tag (eql :red)) attr-list body body-fn) (declare (ignore attr-list)) (nconc (cons "" (funcall body-fn body)) (list ""))) ; Compiling LAMBDA (PCL::.PV-CELL. PCL::.NEXT-METHOD-CALL. TAG ATTR-LIST BODY BODY-FN): ; Compiling Top-Level Form: #<STANDARD-METHOD CONVERT-TAG-TO-STRING-LIST ((EQL :RED) T T T) {582B268D}> * (with-html-output (*standard-output*) (:red (:b "Bold and red")) (values)) Bold and red * (show-html-expansion (s) (:red :style "spiffy" (if (foo) (htm "Attributes are ignored")))) (LET ((S S)) (PROGN NIL (WRITE-STRING "" S) (IF (FOO) (PROGN (WRITE-STRING "Attributes are ignored" S))) (WRITE-STRING "" S))) * (defmethod convert-tag-to-string-list ((tag (eql :table)) attr-list body body-fn) (cond ((cdr (assoc :simple attr-list)) (nconc (cons "
") (loop for row in body collect "
" nconc (loop for col in row collect "" when (constantp col) collect (format nil "~A" col) else collect col collect "	") collect "
") (list "
"))) (t ;; you could as well invoke CALL-NEXT-METHOD here, of course (nconc (cons "
") (funcall body-fn body) (list "
"))))) ; Compiling LAMBDA (PCL::.PV-CELL. PCL::.NEXT-METHOD-CALL. TAG ATTR-LIST BODY BODY-FN): ; Compiling Top-Level Form: #<STANDARD-METHOD CONVERT-TAG-TO-STRING-LIST ((EQL :TABLE) T T T) {58AFB7CD}> * (with-html-output (*standard-output*) (:table :border 0 (:tr (:td "1") (:td "2")) (:tr (:td "3") (:td "4"))))

1	2

3	4

 "

" * (show-html-expansion (s) (:table :simple t :border 0 (1 2) (3 (fmt "Result = ~A" (compute-result))))) (LET ((S S)) (PROGN NIL (WRITE-STRING "

1	2

3	" S) (FORMAT S "Result = ~A" (COMPUTE-RESULT)) (WRITE-STRING "

" S)))
[Function]
convert-attributes attr-list => strings-or-forms
This is a helper function which can be called fromCONVERT-TAG-TO-STRING-LIST
to process the list of attributes.
$Header: /usr/local/cvsrep/cl-who/doc/index.html,v 1.68 2009/03/09 21:54:11 edi Exp $


smartcrop.js is a content aware image cropping library. On this page you can test it with your own images. You can learn more about the library on it's github page.
Rule of thirds
Face Detection
Example Photo by Makhmutova Dina on Unsplash


[gecode-users] Who submitted Gecode to sourcearchive.com?
Guido Tack
tack at ps.uni-sb.de
Tue Apr 7 05:08:29 CEST 2009
Hi everyone,
it seems that sourcearchive.com just automatically downloads new
Debian packages, unpacks them, and runs doxygen on the result. That's
of course a pretty useless service, but we can't do much about it.
I'll ask the administrator to add a robots.txt to his website, so that
the docs are not indexed.
Cheers,
Guido
Christian Schulte wrote:
> Dear users,
>
> I just stumbled upon
> http://sourcearchive.com/
> which seriously diminishes the usefulness of Gecode (IMHO) by
> putting all
> outdated Gecode documentation on the Web such that it gets indexed
> by web
> search engines. Now, a search engine will vomit lots of outdated
> hits at you
> when you search for a Gecode concept. Brilliant! Well done!
>
> Please, I would like you to understand that we are extremely liberal
> in what
> we ask you to do and what not to do with Gecode. It is not a legal
> issue, it
> is just an issue whether you as a user are willing to show a little
> respect
> for our wishes (and these particular wishes are rational and not
> selfish).
>
> To remind you, we just ask one thing for our documentation:
>
>> We kindly ask that documentation is not installed anywhere in such
>> a way
> that it will be
>> indexed by search engines.
>
> We would be delighted if this wish would be granted. After all, all
> previous
> documentation is available from Gecode's website anyway.
>
> If you disagree with our policy, please let us know so that we can
> discuss.
> If you were unaware of our policy, please remove the documentation
> from the
> above mentioned website ASAP.
>
> Christian
>
> PS: I have to admit that I am quite shocked, as far as I can see we
> are
> extremely liberal in any respect how OUR software and documentation
> is used.
> But, still, that seems to be something that some people just do not
> care to
> respect. Very disappointing. And - of course - incidents like this
> will make
> people like us think twice in the future.
>
> --
> Christian Schulte, www.it.kth.se/~cschulte/
>
>
>
>
> _______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users
More information about the gecode-users
mailing list


Money balance
{{countbalance}}/{{count}} Members
Total Revenue This Month
Rs {{revenue}}
App usage This Month
{{countapp}}/{{count}}
Mahal Members
+{{count}}
Pending Payments Stats
New stats on {{todays}} at {{time}}
| Reg ID | Name | lastpaid | mobile |
|---|---|---|---|
| {{data.regno}} | {{data.name}} | {{data.lastpaid}} | {{data.mobile}} |


{%extends "registration/base.html"%} {% load bootstrap3 %} {% block content %}
Password or username is incorrect
you dont have an account? Sign Up


Preparation time
overnight
Cooking time
30 mins to 1 hour
Serves
Serves 6
Dietary
Summer favourite blackberry fool gets a chef makeover.
Equipment: You’ll need a cream whipper/espuma gun.
For the blackberry fool, melt the butter in a saucepan and add the sugar. Pour the blackberries on top and add the lemon juice. Cook on a low heat until it becomes a purée. Blend until smooth, then pass through a fine sieve into a bowl and cover with cling film. Set aside until needed.
For the custard, bring the cream and milk to the boil in a large saucepan. In a heatproof bowl, whisk together the egg yolks and caster sugar. Pour the cream and milk onto the eggs, whisking continuously. Place the pan back on the heat and gently cook until the custard coats the back of a spoon or reaches 82C/180F on a cooking thermometer. Pass through a fine sieve into a bowl, cover with cling film and chill in the fridge.
Mix 400g/14oz blackberry purée with the custard. Pass through a fine sieve and pour into an espuma gun. Charge with two chargers and give it a good shake. Leave to settle for 10-15 minutes.
For the mace biscuits, place all the dry ingredients in a large mixing bowl and add the butter, rubbing it together until the mixture resembles coarse crumbs. Add the egg and syrup and bring together to form a stiff paste. Wrap in cling film and chill in the fridge for at least one hour.
When you are ready to cook reheat the oven to 180C/350F/Gas mark 4. Line two baking sheets with baking parchment.
Roll the mixture into 16-20 walnut-sized balls and place them 5cm/2in apart on the baking sheets so they have room to spread out. Bake for 12-15 minutes, until just cooked. Remove from the oven, leave on the sheets to firm up for a couple of minutes, then place on a wire rack to cool completely.
To serve, mix some blackberries with some purée and place in the bottom of six serving glasses. Crumble on some mace biscuits. Add a ball of vanilla ice cream to each glass. Add more blackberries and purée, then some more crumbled biscuit.  Dust with mace and serve.


open class EnumTransformer<T : Enum<*>> : Transformer<T>
A base enum transformer implementation that should be extended for specific enums
See Also
Author
bright_spark
Since
2.1.0
<init> |
A base enum transformer implementation that should be extended for specific enums EnumTransformer(type: KClass<T>) |
parse |
Tries to parse the input to the type T Returns null if unsuccessful open fun parse(input: String, ctx: Context?): T? |
TimeUnitTransformer |
object TimeUnitTransformer : EnumTransformer<TimeUnit> |


Hellom I am Emmanuel a web developer from Tanzania
I love writing code and that is the main reason I decided to join
Moringa School
. I love playing football and basketball. And I just recently graduated year 11 last year.
I am hoping to do well at Moringa.


6.2. Feature extraction¶
The sklearn.feature_extraction module can be used to extract features in a format supported by machine learning algorithms from datasets consisting of formats such as text and image.
6.2.1. Text feature extraction¶
<IP_ADDRESS>. The Bag of Words representation¶
Text Analysis is a major application field for machine learning algorithms. However the raw data, a sequence of symbols cannot be fed directly to the algorithms themselves as most of them expect numerical feature vectors with a fixed size rather than the raw text documents with variable length.
In order to address this, scikit-learn provides utilities for the most common ways to extract numerical features from text content, namely:
- tokenizing strings and giving an integer id for each possible token, for instance by using whitespaces and punctuation as token separators.
- counting the occurrences of tokens in each document.
- normalizing and weighting with diminishing importance tokens that occur in the majority of samples / documents.
In this scheme, features and samples are defined as follows:
- each individual token occurrence frequency (normalized or not) is treated as a feature.
- the vector of all the token frequencies for a given document is considered a multivariate sample.
A corpus of documents can thus be represented by a matrix with one row per document and one column per token (e.g. word) occurring in the corpus.
We call vectorization the general process of turning a collection of text documents into numerical feature vectors. This specific stragegy (tokenization, counting and normalization) is called the Bag of Words or “Bag of n-grams” representation. Documents are described by word occurrences while completely ignoring the relative position information of the words in the document.
When combined with TF-IDF normalization, the bag of words encoding is also known as the Vector Space Model.
<IP_ADDRESS>. Sparsity¶
As most documents will typically use a very subset of a the words used in the corpus, the resulting matrix will have many feature values that are zeros (typically more than 99% of them).
For instance a collection of 10,000 short text documents (such as emails) will use a vocabulary with a size in the order of 100,000 unique words in total while each document will use 100 to 1000 unique words individually.
In order to be able to store such a matrix in memory but also to speed up algebraic operations matrix / vector, implementations will typically use a sparse representation such as the implementations available in the scipy.sparse package.
<IP_ADDRESS>. Common Vectorizer usage¶
CountVectorizer implements both tokenization and occurrence counting in a single class:
>>> from sklearn.feature_extraction.text import CountVectorizer
This model has many parameters, however the default values are quite reasonable (please see the reference documentation for the details):
>>> vectorizer = CountVectorizer()
>>> vectorizer
CountVectorizer(analyzer='word', binary=False, charset='utf-8',
charset_error='strict', dtype=<type 'long'>, input='content',
lowercase=True, max_df=1.0, max_features=None, max_n=1, min_n=1,
preprocessor=None, stop_words=None, strip_accents=None,
token_pattern=u'\\b\\w\\w+\\b', tokenizer=None, vocabulary=None)
Let’s use it to tokenize and count the word occurrences of a minimalistic corpus of text documents:
>>> corpus = [
... 'This is the first document.',
... 'This is the second second document.',
... 'And the third one.',
... 'Is this the first document?',
... ]
>>> X = vectorizer.fit_transform(corpus)
>>> X
<4x9 sparse matrix of type '<type 'numpy.int64'>'
with 19 stored elements in COOrdinate format>
The default configuration tokenizes the string by extracting words of at least 2 letters. The specific function that does this step can be requested explicitly:
>>> analyze = vectorizer.build_analyzer()
>>> analyze("This is a text document to analyze.")
[u'this', u'is', u'text', u'document', u'to', u'analyze']
Each term found by the analyzer during the fit is assigned a unique integer index corresponding to a column in the resulting matrix. This interpretation of the columns can be retrieved as follows:
>>> vectorizer.get_feature_names()
[u'and', u'document', u'first', u'is', u'one', u'second', u'the', u'third', u'this']
>>> X.toarray()
array([[0, 1, 1, 1, 0, 0, 1, 0, 1],
[0, 1, 0, 1, 0, 2, 1, 0, 1],
[1, 0, 0, 0, 1, 0, 1, 1, 0],
[0, 1, 1, 1, 0, 0, 1, 0, 1]])
The converse mapping from feature name to column index is stored in the vocabulary_ attribute of the vectorizer:
>>> vectorizer.vocabulary_.get('document')
1
Hence words that were not seen in the training corpus will be completely ignored in future calls to the transform method:
>>> vectorizer.transform(['Something completely new.']).toarray()
array([[0, 0, 0, 0, 0, 0, 0, 0, 0]])
Note that in the previous corpus, the first and the last documents have exactly the same words hence are encoded in equal vectors. In particular we lose the information that the last document is an interogative form. To preserve some of the local ordering information we can extract 2-grams of words in addition to the 1-grams (the word themselvs):
>>> bigram_vectorizer = CountVectorizer(min_n=1, max_n=2,
... token_pattern=ur'\b\w+\b')
>>> analyze = bigram_vectorizer.build_analyzer()
>>> analyze('Bi-grams are cool!')
[u'bi', u'grams', u'are', u'cool', u'bi grams', u'grams are', u'are cool']
The vocabulary extracted by this vectorizer is hence much bigger and can now resolve ambiguities encoded in local positioning patterns:
>>> X_2 = bigram_vectorizer.fit_transform(corpus).toarray()
>>> X_2
array([[0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0],
[0, 0, 1, 0, 0, 1, 1, 0, 0, 2, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0],
[1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1]])
In particular the interogative form “Is this” is only present in the last document:
>>> feature_index = bigram_vectorizer.vocabulary_.get(u'is this')
>>> X_2[:, feature_index]
array([0, 0, 0, 1])
<IP_ADDRESS>. TF-IDF normalization¶
In a large text corpus, some words will be very present (e.g. “the”, “a”, “is” in English) hence carrying very little meaningul information about the actual contents of the document. If we were to feed the direct count data directly to a classifier those very frequent terms would shadow the frequencies of rarer yet more interesting terms.
In order to re-weight the count features into floating point values suitable for usage by a classifier it is very common to use the tf–idf transform.
Tf means term-frequency while tf–idf means term-frequency times inverse document-frequency. This is a orginally a term weighting scheme developed for information retrieval (as a ranking function for search engines results), that has also found good use in document classification and clustering.
This normalization is implemented by the TfidfTransformer class:
>>> from sklearn.feature_extraction.text import TfidfTransformer
>>> transformer = TfidfTransformer()
>>> transformer
TfidfTransformer(norm='l2', smooth_idf=True, sublinear_tf=False, use_idf=True)
Again please see the reference documentation for the details on all the parameters.
Let’s take an example with the following counts. The first term is present 100% of the time hence not very interesting. The two other features only in less than 50% of the time hence probably more representative of the content of the documents:
>>> counts = [[3, 0, 1],
... [2, 0, 0],
... [3, 0, 0],
... [4, 0, 0],
... [3, 2, 0],
... [3, 0, 2]]
...
>>> tfidf = transformer.fit_transform(counts)
>>> tfidf
<6x3 sparse matrix of type '<type 'numpy.float64'>'
with 9 stored elements in Compressed Sparse Row format>
>>> tfidf.toarray()
array([[ 0.85..., 0. ..., 0.52...],
[ 1. ..., 0. ..., 0. ...],
[ 1. ..., 0. ..., 0. ...],
[ 1. ..., 0. ..., 0. ...],
[ 0.55..., 0.83..., 0. ...],
[ 0.63..., 0. ..., 0.77...]])
Each row is normalized to have unit euclidean norm. The weights of each feature computed by the fit method call are stored in a model attribute:
>>> transformer.idf_
array([ 1. ..., 2.25..., 1.84...])
As tf–idf is a very often used for text features, there is also another class called Vectorizer that combines all the option of CountVectorizer and TfidfTransformer in a single model:
>>> from sklearn.feature_extraction.text import Vectorizer
>>> vectorizer = Vectorizer()
>>> vectorizer.fit_transform(corpus)
...
<4x9 sparse matrix of type '<type 'numpy.float64'>'
with 19 stored elements in Compressed Sparse Row format>
While the tf–idf normalization is often very useful, there might be cases where the binary occurrence markers might offer better features. This can be achieved by using the binary parameter of CountVectorizer. In particular, some estimators such as Bernoulli Naive Bayes explicitly model discrete boolean random variables. Also very short text are likely to have noisy tf–idf values while the binary occurrence info is more stable.
As usual the only way how to best adjust the feature extraction parameters is to use a cross-validated grid search, for instance by pipelining the feature extractor with a classifier:
<IP_ADDRESS>. Applications and examples¶
The bag of words representation is quite simplistic but surprisingly useful in practice.
In particular in a supervised setting it can be successfully combined with fast and scalable linear models to train document classificers, for instance:
In an unsupervised setting it can be used to group similar documents together by applying clustering algorithms such as K-means:
Finally it is possible to discover the main topics of a corpus by relaxing the hard assignement constraint of clustering, for instance by using Non-negative matrix factorization (NMF or NNMF):
<IP_ADDRESS>. Limitations of the Bag of Words representation¶
While some local positioning information can be preserved by extracting n-grams instead of individual words, Bag of Words and Bag of n-grams destroy most of the inner structure of the document and hence most of the meaning carried by that internal structure.
In order to address the wider task of Natural Language Understanding, the local structure of sentences and paragraphs should thus be taken into account. Many such models will thus be casted as “Structured output” problems which are currently outside of the scope of scikit-learn.
<IP_ADDRESS>. Customizing the vectorizer classes¶
It is possible to customize the behavior by passing some callable as parameters of the vectorizer:
>>> def my_tokenizer(s):
... return s.split()
...
>>> vectorizer = CountVectorizer(tokenizer=my_tokenizer)
>>> vectorizer.build_analyzer()(u"Some... punctuation!")
[u'some...', u'punctuation!']
In particular we name:
- preprocessor a callable that takes a string as input and return another string (removing HTML tags or converting to lower case for instance)
- tokenizer a callable that takes a string as input and output a sequence of feature occurrences (a.k.a. the tokens).
- analyzer a callable that wraps calls to the preprocessor and tokenizer and further perform some filtering or n-grams extractions on the tokens.
To make the preprocessor, tokenizer and analyzers aware of the model parameters it is possible to derive from the class and override the build_preprocessor, build_tokenizer` and build_analyzer factory method instead.
Customizing the vectorizer can be very useful to handle Asian languages that do not use an explicit word separator such as the whitespace for instance.
6.2.2. Image feature extraction¶
<IP_ADDRESS>. Patch extraction¶
The extract_patches_2d function extracts patches from an image stored as a two-dimensional array, or three-dimensional with color information along the third axis. For rebuilding an image from all its patches, use reconstruct_from_patches_2d. For example let use generate a 4x4 pixel picture with 3 color channels (e.g. in RGB format):
>>> import numpy as np
>>> from sklearn.feature_extraction import image
>>> one_image = np.arange(4 * 4 * 3).reshape((4, 4, 3))
>>> one_image[:, :, 0] # R channel of a fake RGB picture
array([[ 0, 3, 6, 9],
[12, 15, 18, 21],
[24, 27, 30, 33],
[36, 39, 42, 45]])
>>> patches = image.extract_patches_2d(one_image, (2, 2), max_patches=2,
... random_state=0)
>>> patches.shape
(2, 2, 2, 3)
>>> patches[:, :, :, 0]
array([[[ 0, 3],
[12, 15]],
[[15, 18],
[27, 30]]])
>>> patches = image.extract_patches_2d(one_image, (2, 2))
>>> patches.shape
(9, 2, 2, 3)
>>> patches[4, :, :, 0]
array([[15, 18],
[27, 30]])
Let us now try to reconstruct the original image from the patches by averaging on overlapping areas:
>>> reconstructed = image.reconstruct_from_patches_2d(patches, (4, 4, 3))
>>> np.testing.assert_array_equal(one_image, reconstructed)
The PatchExtractor class works in the same way as extract_patches_2d, only it supports multiple images as input. It is implemented as an estimator, so it can be used in pipelines. See:
>>> five_images = np.arange(5 * 4 * 4 * 3).reshape(5, 4, 4, 3)
>>> patches = image.PatchExtractor((2, 2)).transform(five_images)
>>> patches.shape
(45, 2, 2, 3)


To get started with growthcleanr
, the
growthcleanr
package must be installed. To install the
latest growthcleanr
release from CRAN:
install.packages("growthcleanr")
To install the latest development version from GitHub using
devtools
:
devtools::install_github("carriedaymont/growthcleanr", ref="main")
Installing growthcleanr
will install several additional
packages in turn.
Further installation details and notes can be found under Installation.
Once the growthcleanr
package and its dependencies are
installed, the minimal input data vectors needed for cleaning data
are:
subjid
- a unique identifier for each subject; if you
have long (64-bit) integer subjid
values, add the
bit64
R package to your install list to ensure R will
process these correctlyparam
- a string designating the measurement being
‘HEIGHTCM
’, ‘LENGTHCM
’, or
‘WEIGHTKG
’agedays
- a numeric value for age in days at time of
measurement; will be rounded down (floor) to nearest integer if needed
(note that there are 30.4375 days in one month; see also the additional
notes
on calculating agemos
from whole numbers of monthssex
- a numeric value of 0
(male) or
1
(female)measurement
- numeric value of measurement in cm for
height or kg for weightNote: the dataset should be sorted by
subjid
, param
, and agedays
, as
demonstrated in the Example below.
Starting with a dataset such as the following:
| subjid | param | agedays | sex | measurement |
|---|---|---|---|---|
| 1 | HEIGHTCM | 2790 | 0 | 118.5 |
| 1 | HEIGHTCM | 3677 | 0 | 148.22 |
| 1 | WEIGHTKG | 2790 | 0 | 23.8 |
| 1 | WEIGHTKG | 3677 | 0 | 38.41 |
| 2 | HEIGHTCM | 2112 | 1 | 118.2 |
| 2 | HEIGHTCM | 2410 | 1 | 123.9 |
| 2 | HEIGHTCM | 2708 | 1 | 128.03 |
| 2 | HEIGHTCM | 3029 | 1 | 135.3 |
| 2 | WEIGHTKG | 2112 | 1 | 25.84 |
| 2 | WEIGHTKG | 2410 | 1 | 28.61 |
| 2 | WEIGHTKG | 2708 | 1 | 28.61 |
| 2 | WEIGHTKG | 3029 | 1 | 34.5 |
| … | … | … | … | … |
Note that in this example, we see data from two subjects, sorted as
described above, with two pairs of height/weight measurements for the
first patient and four pairs for the second. Most of these values pass
the “eyeball test”, but the third weight measurement for
subjid
2 looks like it might be a value that has been
carried forward from the previous value, given that their same ageday
height has changed by several centimeters but their third height value
is exactly the same as their second. This is an example of an
implausible value and exclusion type that growthcleanr
might identify.
The cleangrowth()
function provided by
growthcleanr
will return a vector that specifies, for each
measurement, whether to:
Include
” the measurement,Missing
”,Exclude
” the measurement (numerous variations of
Exclude
exist, as specified in Understanding growthcleanr output).For a data.frame object source_data
containing growth
data:
library(growthcleanr)
# prepare data as a data.table
data <- as.data.table(source_data)
# set the data.table key for better indexing
setkey(data, subjid, param, agedays)
# generate new exclusion flag field using function
cleaned_data <- data[, gcr_result := cleangrowth(subjid, param, agedays, sex, measurement)]
# extract data limited only to values flagged for inclusion:
only_included_data <- cleaned_data[gcr_result == "Include"]
If our example dataset above were named source_data
,
examining cleaned_data
would show:
| subjid | param | agedays | sex | measurement | gcr_result |
|---|---|---|---|---|---|
| 1 | HEIGHTCM | 2790 | 0 | 118.5 | Include |
| 1 | HEIGHTCM | 3677 | 0 | 148.22 | Include |
| 1 | WEIGHTKG | 2790 | 0 | 23.8 | Include |
| 1 | WEIGHTKG | 3677 | 0 | 38.41 | Include |
| 2 | HEIGHTCM | 2112 | 1 | 118.2 | Include |
| 2 | HEIGHTCM | 2410 | 1 | 123.9 | Include |
| 2 | HEIGHTCM | 2708 | 1 | 128.03 | Include |
| 2 | HEIGHTCM | 3029 | 1 | 135.3 | Include |
| 2 | WEIGHTKG | 2112 | 1 | 25.84 | Include |
| 2 | WEIGHTKG | 2410 | 1 | 28.61 | Include |
| 2 | WEIGHTKG | 2708 | 1 | 28.61 | Exclude-Carried-Forward |
| 2 | WEIGHTKG | 3029 | 1 | 34.5 | Include |
| … | … | … | … | … | … |
In this sample output, we see that growthcleanr
has
indeed flagged the third weight measurement for subjid 2
as
an apparent carried forward value. The measurement remains in the
dataset, and it is up to the researcher to determine which exclusions to
accept directly or investigate further.
This example uses the default configuration options for
cleangrowth()
. Longer examples demonstrating some common
options are in Usage, and full details about
all options are documented in Configuration.
To compute percentiles and Z-scores using the included CDC macro, continue with these next steps:
# Use the built-in utility function to convert the input observations to wide
# format for BMI calculation
cleaned_data_wide <- longwide(cleaned_data)
# Compute simple BMI
cleaned_data_bmi <- simple_bmi(cleaned_data_wide)
# Compute Z-scores and percentiles
cleaned_data_bmiz <- ext_bmiz(cleaned_data_bmi)
The longwide()
function defaults to converting only
records included by cleangrowth()
, with options to change
this default, and ext_bmiz()
will return the wide version
of the cleaned data with many metrics added. Both of these functions are
described in Computing BMI percentiles and
Z-scores.


For this box, I used Autodesk Fushion 360.
Tools used for formation of Box
1. Change parameter
'Change parameter' is used to fix a measurement of an item. It is located under 'Modify'. With this, when in need of adjustments, one has to just change the measurements in the settings of parameter and the object will adjust accordingly. This not only enables one to save time adjusting everything, but to also change sizing accordingly to projected item.
2. Combination of bodies
Under 'Modify', 'Combine'. Then select base of box.
Select sides of box then use operation 'cut'
3. To extrude body from the other side of the box
Select 'Extrude', then select surface from extrusion.
After selection, click Start:object
Under operation, select 'new body'


MySQL's security model is not as elaborate as other popular databases. It's missing quite a lot.
I wish to point out what I think are some very disturbing security holes, which may affect the database integrity.
This post is not about Roles, Kerberos, IPs and such. It's about simple MySQL features, which allow common, unprivileged users, to break data integrity by using unprotected session variables.
I will consider three such issues.
We will assume a database with two tables, and two users.
 TO 'root'@'localhost' WITH GRANT OPTION; GRANT SELECT, INSERT, UPDATE, DELETE ON `w2`.* TO 'w2user'@'%';
We have one 'root' user, and one very simple 'w2user', which can't be accused of having too many privileges. The schema, with some sample data, follows.
DROP DATABASE IF EXISTS w2; CREATE DATABASE w2; USE w2; DROP TABLE IF EXISTS city; DROP TABLE IF EXISTS country; CREATE TABLE country ( country_id int(11) not null auto_increment, name varchar(32) NOT NULL, PRIMARY KEY (country_id) )ENGINE=INNODB; CREATE TABLE city ( city_id int(11) NOT NULL auto_increment, name varchar(32) NOT NULL, country_id int(11) not null , PRIMARY KEY (city_id), INDEX country_id (country_id), FOREIGN KEY (country_id) REFERENCES country(country_id) ON DELETE CASCADE )ENGINE=INNODB; INSERT INTO country (country_id, name) values (1, 'gbr'); INSERT INTO country (country_id, name) values (2, 'usa'); INSERT INTO city (name, country_id) values ('london',1); INSERT INTO city (name, country_id) values ('liverpool',1); INSERT INTO city (name, country_id) values ('birmingham',1); INSERT INTO city (name, country_id) values ('ny',2); INSERT INTO city (name, country_id) values ('boston',2);
Both tables are InnoDB, to support transactions and foreign keys.
Obviously, 'root' is allowed to do anything. But what harm can our unprivileged 'w2user' do?
FOREIGN_KEY_CHECKS
The following INSERT should fail:
INSERT INTO city (name, country_id) values ('no_city',1234567);
But look at the following:
mysql> SELECT CURRENT_USER();
+----------------+
| CURRENT_USER() |
+----------------+
| w2user@% |
+----------------+
1 row in set (0.00 sec)
mysql> SET FOREIGN_KEY_CHECKS=0;
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO city (name, country_id) values ('no_city',1234567);
Query OK, 1 row affected (0.01 sec)
mysql> SET FOREIGN_KEY_CHECKS=1;
Query OK, 0 rows affected (0.00 sec)
What was that? w2user was allowed to temporarily disable foreign key checks, insert an otherwise invalid row, then re-enable checks, and no error was thrown? Wait, did the row really get inserted?
mysql> SELECT * FROM city;
+---------+------------+------------+
| city_id | name | country_id |
+---------+------------+------------+
| 1 | london | 1 |
| 2 | liverpool | 1 |
| 3 | birmingham | 1 |
| 4 | ny | 2 |
| 5 | boston | 2 |
| 6 | no_city | 1234567 |
+---------+------------+------------+
6 rows in set (0.01 sec)
Yes, it did.
Disabling FK checks is handy when importing large data from dump, or from CSV, when it is known to be valid. For example, when restoring a backup created with mysqldump, FK checks can be safely disabled since dumped data must have been valid. Disabling checks helps in reducing import time.
But I don't think normal users should be allowed to set the FOREIGN_KEY_CHECKS variable. This should be restricted to users with the SUPER privilege.
tx_isolation
When using InnoDB, we can choose one of four isolation levels:
- READ-UNCOMMITTED
- READ COMMITTED
- REPEATABLE-READ (default):
- SERIALIZABLE
In READ-UNCOMMITTED, a transaction can read other open transactions uncommitted data. It's usually not a good idea to use this isolation level when working with transactional engines, since it undermines the very foundation of using transactions.
But MySQL, and through it, InnoDB, allow a strange thing: the transaction isolation level can be modified on the run. I consider this to be peculiar and undesired. An isolation level imposes an application logic, which should not be changed. But MySQL also allows different isolation level on a per-connection basis.
Every session can work on a different isolation level. This may be a good idea, when a session wishes to be stricter than the rest of the code, by using the SERIALIZABLE isolation, for example.
But our w2user may decide to lower her session's isolation level below the global one. That is, MySQL may be configured to work at REPEATABLE-READ, but w2user is allowed to:
mysql> SELECT CURRENT_USER(); +----------------+ | CURRENT_USER() | +----------------+ | w2user@% | +----------------+ 1 row in set (0.00 sec) mysql> SET tx_isolation='READ-UNCOMMITTED'; Query OK, 0 rows affected (0.00 sec)
Our 'root' user does the following:
mysql> SELECT CURRENT_USER(); +----------------+ | CURRENT_USER() | +----------------+ | root@localhost | +----------------+ 1 row in set (0.00 sec) mysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO country (name) VALUES ('nowhere'); Query OK, 1 row affected (0.00 sec)
While the transaction is still open, w2user can:
mysql> SELECT CURRENT_USER();
+----------------+
| CURRENT_USER() |
+----------------+
| w2user@% |
+----------------+
1 row in set (0.00 sec)
mysql> SELECT * FROM country;
+------------+---------+
| country_id | name |
+------------+---------+
| 1 | gbr |
| 2 | usa |
| 3 | nowhere |
+------------+---------+
3 rows in set (0.00 sec)
w2user used the READ-UNCOMMITED, hence was allowed to see the (soon to be rolled back?) 'nowhere' country. But that country was inserted by a session using the REPEATABLE-READ level.
Each session confirms to its isolation level rules, and the complaint is not about that. The complaint is with the fact that there's a mess in our database.
Working with the REPEATABLE-READ isolation level should guarantee me some privacy in my transaction. My transaction may choose to delete all rows from a table, only to fill them back again, and none (a small white lie here, since locking is also involved) is the wiser. The privacy notion is so inherent, that it's shocking to learn that any other connection can knowingly choose to ignore my privacy and see any changes I make. This is why I consider this as a security breach, and not just some isolation nuance.
In my opinion, the isolation level should not be dynamic at all. It must not be changed while the database is running. Perhaps I'm missing some interesting scenario where it would be desired, but the majority of applications would not find this feature beneficial.
sql_mode
I've written about sql_mode before, and here's an example for a data integrity issue caused by weak security:
In our example, sql_mode is set to 'TRADITONAL', which maps to:
STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
Let's add a TIMESTAMP column to the country table:
ALTER TABLE country ADD COLUMN ts TIMESTAMP NOT NULL;
We now try to set a '0' value for the time stamps (as user root):
mysql> UPDATE country SET ts=NOW(); Query OK, 2 rows affected (0.42 sec) Rows matched: 2 Changed: 2 Warnings: 0 mysql> UPDATE country SET ts=0; ERROR 1292 (22007): Incorrect datetime value: '0' for column 'ts' at row 1
We got the error becuase of the NO_ZERO_DATE part of our sql_mode.
But, again, look at what w2user can do:
mysql> SELECT @@sql_mode; +-------------------------------------------------------------------------------------------------------------------------------+ | @@sql_mode | +-------------------------------------------------------------------------------------------------------------------------------+ | STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER | +-------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> SET sql_mode=''; Query OK, 0 rows affected (0.00 sec) mysql> UPDATE country SET ts=0; Query OK, 2 rows affected (0.01 sec) Rows matched: 2 Changed: 2 Warnings: 0 mysql> SELECT * FROM country; +------------+------+---------------------+ | country_id | name | ts | +------------+------+---------------------+ | 1 | gbr | 0000-00-00 00:00:00 | | 2 | usa | 0000-00-00 00:00:00 | +------------+------+---------------------+ 2 rows in set (0.00 sec)
So, are '0' values allowed for timestamps in our database or not? Turns out any simple user may decide differently.
See my earlier posts here and here. Roland Bouman also offers suggestions for fixing this issue.
Conclusion
The above three examples show how simple users can break data integrity due to very permissive MySQL logic. Even when the database is carfully tuned and secured, there's no way to prevent non privileged users from damaging its integrity.
comments powered by Disqus


{% extends "master.html" %} {% block body %}
The official example template of creating a blog with Bootstrap modified for Jhona22baz.


pain stimulation nerve vagus effects vagal tVNS VNS iVNS studies reported patients Pain perception modulation psychological intensity depression study Brain observed response spinal mood {border-style chronic migraine px;} #ffffff;} heat transcutaneous evidence headache Frangos Res. attention compared frequency significant Vagus electrical factors increased low min modulate pain. regions thresholds Hz, activity auricular pain, threshold unpleasantness Bushnell brain epilepsy functional induced Randich Table cortex decreased effect human mechanical shown significantly Kraus Transcutaneous activation affective afferent associated component cord nucleus treatment Borckardt George Kirchner Liu M.S. Neurosci. Villemure affect cervical ear fMRI humans increase measured modulates reduction using Ellrich Migraine Stimul. changes clinical healthy inhibitory investigating on, possible provide px; rats stimulation, tonic {font-family Healthy However, Komisaruk Ren Usichenko Zhang acute anterior control findings font-size high measures memory non-invasive participants preferentially processes ratings similar thermal treatment-resistant trial Behav. Effects Epilepsy Fang Komisaruk, M.C. Nahas Neurol. Yakunina afferents analgesic cognitive correlated decrease discussed double; experimental imaging implicated invasive modulation. parameters perception, pilot pressure produced receiving reflex review sensitivity sensory temporal trigeminal (VNS) Affect Chandler Dietrich Gebhart M.J. MRI Med. Ness R.D. Rong Sackeim Thus, Vagal Van access affects animal anxiety border-color border-width brainstem cluster conditions connectivity descending enhances experienced insula left long-term mechanism neurons nociceptive order overall painful parameters, patient perception. prefrontal present pw, refractory region relief remains solid; somatosensory stimulation. stimuli studies. summation symptoms {font-style {font-weight (i.e., (tVNS) A.J. B.R. BOLD Busch Cephalalgia Clark D.C. Fig. Foreman Functional G.F. Goadsby H.A. Headache Hz) Kinfe Laqua Napadow Nesbitt Neurology Nevertheless, Peuker R.A. Rush STN Sellaro Smith Stefan action amygdala approach beneficial bold branch cases, central complete controlled courier; daily dependent depressed depressive disorder doses em; external extinction fear future implantation. including insula, intensity, known longer major modulated mood, network nociception optimal participants, patients, perceived positive posterior previous previously produces projections pt;} pulse raphe recent reduced reduces reliably responses role state tVNS. thalamus, tolerance unclear used various


| |
SECTION-II
No. of Questions
: 50
|
| |
DIRECTIONS
for questions 46 to 48: Choose the correct alternatives |
| Question
46. |
A
wife leaves home and reaches her husbands office by car everyday at 5
p.m. to pick him up.One day, since the husband finished his work at 4
p.m. he started walking towards home. On the way he met his wife
and they reached home 10 minutes earlier than they normally to.
For how much did the husband walk before he met his wife?
A.
50 mins
B.
40mins
C.
55min
D.
35min
|
| Question
47. |
Two
men starting from the same place walk at the rate of 4 kms/hr and 6 kms/hr
respectively. How many kms will they be apart at the end of 3-5
hours if they walk in opposite directions initially for the 1st
half an hour and they reverse directions after every one hour
A.
10km
B.
5kms
C.
9kms
D.
6kms
|
| Question
48. |
A
train travelling at 40 km/hr while inside a tunnel meets another train
of half its length travelling at 60 km/hr and passes it completely in
4.5 seconds. Find the length of the tunnel if 1st
train passes completely through it in 4 minutes 37.5 seconds
A.
2000m
B.
3000m
C.
4000m
D.
5000m
|
| |
DIRECTIONS
for questions 49 to 51: Read the following and answer the questions that
follow
Mr. Will power died and left Rs.1.000,000 to three relatives and
their wives. The wives together received Rs.396,000. Jaya received
Rs.10,000 more than Chandrika and Maya received Rs.10,000 more than Jaya.
Rohan Kapoor was given just as much as his wife, Anil Mathur got one and
half times as much as his wife. Dilip Kaul received twice as much
as his wife. |
| Question
49. |
Who
is Rohan’s wife?
A.
Jaya
B.
Chandrika
C.
Maya
D.
Cannot say
|
| Question
50. |
Who
is Anil’s wife?
A.
Jaya
B.
Chandrika
C.
Maya
D.
Cannot say
|
| Question
51. |
Who
is Dilip’s wife?
A.
Jaya
B.
Chandrika
C.
Maya
D.
Cannot say
|
| |
DIRECTIONS
for questions 52 to 78: Choose the correct alternatives |
| Question
52. |
A
cycle dealer buys 30 bicycles of which 8 are 1st grade and
the rest 2nd grade, for Rs. 4725. Find at what
price h must shell the 1st grade bicycles, so that if he sells
the 2nd grade bicycles at ¾ ths of this price, he makes a profit
of 40% of his outlay?
A.
Rs.240
B.
Rs250
C.
Rs.260
D.
Rs.270
|
| Question
53. |
A
student bought books, notebooks & pencils from a shop. If ratio
of no. of books to no.of notebooks is the same as the ratio
of no. of pencils, find the no.of notebooks if books & pencils
are 20 & 5 respectively
A.
7
B.
8
C.
9
D.
10
|
| Question
54. |
A piece of work is done by A,B,C in 5 days as follows
A works for the whole time,
B only on the first 2 days and C only on last 3 days. This work
could have been done by B and C in 6 days without involving A.
If B and C working together can do as much work in 2 days as A can
do in 3 days, find how long it will take for each one to do this
work alone.
A.
10,20,10 days
B.
7,9,11 days
C.
8,12,9 days
D.
9,18,9 days
|
| Question
55. |
A
tank supplies water to a family for 60 days. Due to a leak
in the tank, 5 litres of water waste every day and then the supply
last for 10 day less. For how many days less will the supply last
if 50 litres of water leak everyday.
A.
15 days
B.
16 days
C.
18days
D.
20 days
|
| Question
56. |
In the figure
L1 is parallel to L2. If AB=CD, then
A.
ABE is in equilateral triangle
B.
AC=BD
C.
AD=BC
D.
AC=AD
|
| Question
57. |
Line BC divides
rADE into 2 sections, one of them an isosceles r (AB=AC).
Angle DBC is equal to 105°. What is the sum of he measure of angles
D and E?
A.
100
B.
125
C.
150
D.
175
|
| Question
58. |
65%
of children in a sports club play football, 10% play volleyball and 75
% play baseketball. What is the smallest % of children playing all
the three games?
A.
15
B.
16
C.
10
D.
20
|
| Question
59. |
The
radius OA of the circle in the figure is
A.
9
B.
7
C.
5
D.
3
|
| Question
60. |
A
pyramid is cut 1 cm from the top, parallel to its base. The base
area of the cut out piece is 20cm2 and the base area of the pyramid is
80 cm2. Find from what height from the base of the pyramid, was
the portion cut?
A.
7cms
B.
1cm
C.
3,7cms
D.
can't be determined
|
| Question
61. |
The
Cost Price of four qualities of tea are Rs.12, Rs.15, Rs.18 and Rs.21
per kg. If they are mixed in the production 4:3:2:1, find Selling
Price of mixture per kg in order to make a profit of 10%.
A.
Rs.16.5
B.
Rs.17
C.
Rs.17.5
D.
Rs. 18
|
| Question
62. |
A
farmer bought some donkeys for Rs.50 each, sheep at Rs.40
each, goats at Rs.25 each and pigs at Rs.10 each. The average price of
the animals per head worked to Rs.30. Which of the following can
be a value for the number of goats purchased
A.
1
B.
2
C.
3
D.
5
|
| Question
63. |
If
a/b = c/d and d/c=x/y. Which of the following is true?
A.
y/a = x/b
B.
xy = ab
C.
ac/bd = x/y
D.
x- c+d-y
|
| Question
64. |
A
vessel contains 180 litres of wine, 60 litres are taken out of the vessel
everyday and equal quantity of water put in what quantity of wine remains
at the end of 3 days?
A.
52 litres
B.
52.5 litres
C.
54 litres
D.
53.3 litres
|
| Question
65. |
If
r,s and t are consecutive odd integers with r<s<t, Which of the
following must be true?
A.
rs = t
B.
r + t = 2t – s
C.
r + s = t+ 2
D.
r + t = 2s
|
| Question
66. |
The
cost price of 4 chairs and 5 tables is 330. If the chairs are sold
at 25% loss and tables at 25% profit, the total S.P is Rs. 372.50.
The cost price of chair is
A.
Rs. 15
B.
Rs.20
C.
Rs.25
D.
Rs.30
|
| Question
67. |
ab
+ cd + ac +bd = 6, If a + d =3 then b + c =
A.
1
B.
2
C.
6
D.
3
|
| Question
68. |
A
cistern can be filled separately by 2 pipes A &B in 45 minutes &
36 minutes respectively. Tap C at the bottom can empty the cistern
in 30 minutes. If the tap C is opened 7 minutes after the 2 pipes
A and B are opened, find when will cistern be filled?
A.
48 minutes
B.
46 minutes
C.
44 minutes
D.
39 minutes
|
| Question
69. |
If
r-1, and r+1 are sides of a r, then r can’t be
A.
greater than 3
B.
less than or equal to 3
C.
less than 4
D.
less than or equal to 2
|
| Question
70. |
The
expressions y + X3 + yx and Y3
+ Y2 + x are equal if
A.
y=0
B.
x2 =1
C.
y + x3 = x+ y3
D.
x2 = 2
|
| Question
71. |
It
is possible to fill in the remaining squares in the figure so all rows
and all the columns have the same sum. That would be the entry in
the middle square?
A.
0
B.
5
C.
8
D.
12
|
| Question
72. |
If
m and n are integers and =
10 Which of the following cannot be the value of m + n
A.
29
B.
25
C.
52
D.
50
|
| Question
73. |
A
man has a job which requires him to work 8 straight days and then rest
on the ninth day If he started work on the Monday, the 12th
time he rests will be on what day of the week?
A.
Sunday
B.
Wednesday
C.
Tuesday
D.
Friday
|
| Question
74. |
If
x is extremely large, then 2x/(1+x) is
A.
close to 0
B.
extremely large
C.
close to 2
D.
greater than 2 but lesser than 3
|
| Question
75. |
If
we know that x>y then which of the following need not be true?
A.
-x < -y
B.
x + 2 > y + 1
C.
x / 3 > y / 3
D.
x2 > y2
|
| Question
76. |
If
x and y are positive integers, then what is the smallest value of x+y
such that 2x+5y is divisible by 16?
A.
7
B.
3
C.
10
D.
5
|
| Question
77. |
a
x b
The above figure shows the graph of a relation between x and y.
For each value of x between a and b there is (are)
A.
at least one value of y
B.
exactly one value of y
C.
at least ‘a’ value of y
D.
exactly ‘a’ values of y
|
| Question
78. |
Define
prq = p2 + q2 and psq= p2=q2,
then the value of (5r2) s25 is
A.
216
B.
126
C.
154
D.
121
|
| |
DIRECTIONS
for questions 79 and 80 :[ Refer to the data below]
(x) = Least integer greater than or equal to x
[x] = Greatest integer less or equal to x
çxç = absolute value of x
Le (a,b,c…….) = Least of a,b,c,……..
Lo (a, b,c…..) = Highest of a,b,c……. |
| Question
79. |
If
x is any positive real number then the value of [x] - [x] is
A.
0
B.
1
C.
-1
D.
-1 or 0
|
| Question
80. |
Which
of the following is true?
A.
[lxl] = l[x]l
B.
[lxl]< l[x]l
C.
[lxl]> l[x]l
D.
None of these
|
| |
DIRECTIONS
for questions 81 to 83: are based on the following instruction
Divide the unit square into 9 equal squares by means of 2 pairs of lines
parallel to the sides. Remove central square. Treat the remaining
squares in the same way. Then |
| Question
81. |
Area
left after 2 steps is equal to
A.
64/81
B.
46/54
C.
82/92 –17
D.
None of these
|
| Question
82. |
Length
of the small square after 3 steps is
A.
1/27
B.
1/9
C.
1/93
D.
None of these
|
| Question
83. |
If
n is very large, then sum of the areas of removed squares after ‘n’ steps
is
A.
0
B.
1
C.
approaches
D.
approaches to 1
|
| |
DIRECTIONS
for questions 84 to 86: Refer to the data below.
Greatest common divisor of a,b,c,f(n)
=Total number of natural numbers less than n and relatively prime to
n. Two natural numbers are said to be relatively prime if their
GCD is 1.
|
| Question
84. |
The
value of f(p) where p is any prime numer i
A.
1
B.
less than or equal to p
C.
greater than p
D.
p – 1
|
| Question
85. |
If
one of a,b,c,d is a prime number then the value of (a,b,c,d)
A.
always 1
B.
Greater than1
C.
a prime number or 1
D.
None of these
|
| Question
86. |
If
n is any integer, which of the following must be true?
A.
3 n + 1 is odd
B.
n(n+2) is even
C.
n (3n + 3) is divisible by 6
D.
n(n + 1) is divisible by 3
|
| |
DIRECTIONS
for questions 87 to 90: Each question below is followed by two statements.
Mark
A if statement I alone, but not statement II alone is sufficient to
answer the question
Mark B if statement II alone, but not statement I alone, is sufficient
to answer the question
Mark C if the question can be answered with the help of both statements
together, but not with the help of either statement alone.
Mark D if the question cant be
answered unless more information is provided.
|
| Question
87. |
What
is the average of 2 brothers Ram and Shyam’s age?
I. The average of the rest of the family
is 40
II. The overall averages of the family is 35
A.
B.
C.
D.
|
| Question
88. |
A
box containing only 50 paise coins and 25 paise coins has a total sum
of Rs.20. What is the no. of each of these coins?
I. The total no of coins is 50
II. If there were 10 more 50 paise coins, the sum will increase
by 25%
A.
B.
C.
D.
|
| Question
89. |
Is
x < y
I. 1/x = -1/y
II.1/xp > 1/yp ‘p’ is odd
A.
B.
C.
D.
|
| Question
90. |
If D1 and D2 are the diameters of the outer and
inner circles respectively, that is D1:D2?
I. The two circles are concentric
II. The area of the ring is 2/3 the area of the greater circle.
A.
B.
C.
D.
|
| |
DIRECTIONS
for questions 91 to 93: Read the following and answer the questions
that follow.
In the league below each team played each other team once, two points
were awarded for a win, one for a draw.
|
|
Matches
Played
|
Matches
Won
|
Matches
Drawn
|
Matches
Lost
|
Goals
For
|
Goals
Against
|
Points
|
|
Giants
Top
Gun
Fighters
Challengers
|
3
3
3
3
|
2
2
0
0
|
1
0
2
1
|
0
1
1
2
|
4
3
0
1
|
1
1
2
4
|
5
4
2
1
|
|
| Question
91. |
What
was the score in the match between Giants and Challengers?
A.
2 – 1
B.
3 – 1
C.
3 – 0
D.
2 – 0
|
| Question
92. |
What
was the score in the match between Top Gun and Fighters?
A.
2 – 1
B.
3 – 1
C.
2 – 0
D.
1- 0
|
| Question
93. |
What
was the score in the match between Giants and Top gun?
A.
2 – 1
B.
2 – 0
C.
0 – 1
D.
1 – 0
|
| Question
94. |
A
shopkeeper introduces two schemes for his customers during Diwali festival
on a T.V whose price is marked at Rs. 15,000. In the first scheme
he sells the T.V set at a discount of 20% and in the second scheme he
sells it at a down-payment of Rs.5000 and 3 installments of Rs.4000 each
at an interval of a year. If he invests his money at simple interest
of 10% then which offer features him more money and how much?
A.
Scheme I, Rs.600
B.
Scheme II, Rs.600
C.
Scheme II, Rs.800
D.
Scheme I, Rs.800
|
| Question
95. |
In
a competitive exam of 200 questions with five alternatives student marks
1 as an answer to all the questions. What is his probable net score
if each right answer scores +1 and each wrong answer is given
–1/4 marks?
A.
0
B.
40
C.
20
D.
30
|
| |
answers
scores next
|


{include file="../application/blog/view/default/public/header.html" /}
{include file="../application/blog/view/default/public/footer.html" /}


|
void background(colour_t) |
Sets the color of background. |
|
colour_t background() const |
Returns the color of background. |
|
nana::string caption() const |
Returns the caption. |
|
void caption(const nana::string&) |
Sets the caption. |
|
void close() const |
Closes the window. |
|
bool create(window wd, bool visible) |
Creates no-size a widget. |
|
bool create(window wd, const nana::rectangle& r = rectangle(), bool visible = true) |
Creates a specified size widget. |
|
void cursor(nana::gui::cursor); |
Sets a system predefined cursor. |
|
nana::gui::cursor cursor() const |
Retrieves the shape of cursor. |
|
bool empty() const |
Determines whether the manipulator is handling a window. |
|
bool enabled() const |
Determines whether the window is enabled for mouse and keyboard input. |
|
void enabled(bool) |
Sets the window whether enabled for mouse and keyboard input. |
|
bool focused() const |
Returns true if the widget has focused. |
|
void foreground(colour_t) |
Sets the color of foreground. |
|
colour_t foreground() const |
Returns the color of foreground. |
|
void hide() |
Sets the window invisible. |
template<typename Event, typename Function>
event_handle make_event(Function) |
Register an event callback functor. |
template<typename Event, typename Class, typename Concept>
event_handle make_event(Class& object, void (Concept::*)(const eventinfo&)) |
Register an event callback functor. The functor is a member function of Concept. |
|
void move(int x, int y) |
Moves the window to a new position. |
|
void show() |
Sets the window visible. |
|
nana::size size() const |
Returns the size of window. |
|
void size(unsigned width, unsigned height) |
Sets the size of window. |
|
void umake_event(event_handle) const |
Deletes an event callback by a handle. |


The Prince
by Niccolo Machiavelli
Chapter 23: How Flatterers Should Be Avoided
Additional Information
- Year Published: 1916
- Language: English
- Country of Origin: Italy
- Source: Machiavelli, N. (1916). The Prince New York: The Macmillan Company.
-
Readability:
- Flesch–Kincaid Level: 12.0
- Word Count: 696
- Genre: Informational
- Keywords: history, philosophy, politics, society
- ✎ Cite This
Downloads
I do not wish to leave out an important branch of this subject, for it is a danger from which princes are with difficulty preserved, unless they are very careful and discriminating. It is that of flatterers, of whom courts arc full, because men are so self-complacent in their own affairs, and in a way so deceived in them, that they are preserved with difficulty from this pest, and if they wish to defend themselves they run the danger of falling into contempt. Because there is no other way of guarding oneself from flatterers except letting men understand that to tell you the truth does not offend you; but when every one may tell you the truth, respect for you abates.
Therefore a wise prince ought to hold a third course by choosing the wise men in his state, and giving to them only the liberty of speaking the truth to him, and then only of those things of which he inquires, and of none others; but he ought to question them upon everything, and listen to their opinions, and afterwards form his own conclusions. With these councillors, separately and collectively, he ought to carry himself in such a way that each of them should know that, the more freely he shall speak, the more he shall be preferred; outside of these, he should listen to no one, pursue the thing resolved on, and be steadfast in his resolutions. He who does otherwise is either overthrown by flatterers, or is so often changed by varying opinions that he falls into contempt.
I wish on this subject to adduce a modern example. Fra Luca, the man of affairs to Maximilian, the present emperor, speaking of his majesty, said: He consulted with no one, yet never got his own way in anything. This arose because of his following a practice the opposite to the above; for the emperor is a secretive man — he does not communicate his designs to any one, nor does he receive opinions on them. But as in carrying them into effect they become revealed and known, they are at once obstructed by those men whom he has around him, and he, being pliant, is diverted from them. Hence it follows that those things he does one day he undoes the next, and no one ever understands what he wishes or intends to do, and no one can rely on his resolutions.
A prince, therefore, ought always to take counsel, but only when he wishes and not when others wish; he ought rather to discourage every one from offering advice unless he asks it; but, however, he ought to be a constant inquirer, and afterwards a patient listener concerning the things of which he inquired; also, on learning that any one, on any consideration, has not told him the truth, he should let his anger be felt.
And if there are some who think that a prince who conveys an impression of his wisdom is not so through his own ability, but through the good advisers that he has around him, beyond doubt they are deceived, because this is an axiom which never fails: that a prince who is not wise himself will never take good advice, unless by chance he has yielded his affairs entirely to one person who happens to be a very prudent man. In this case indeed he may be well governed, but it would not be for long, because such a governor would in a short time take away his state from him.
But if a prince who is not experienced should take counsel from more than one he will never get united counsels, nor will he know how to unite them. Each of the counsellors will think of his own interests, and the prince will not know how to control them or to see through them. And they are not to be found otherwise, because men will always prove untrue to you unless they are kept honest by constraint. Therefore it must be inferred that good counsels, whencesoever they come, are born of the wisdom of the prince, and not the wisdom of the prince from good counsels.


Enemy Of The State A review by Joe Chamberlain
Starring Will Smith; Gene Hackman; Jon Voight & Lisa Bonet
If nothing else, Enemy Of The State will do one thing. It leaves no doubt that Will Smith is officially a movie star. While Smith has been in other hits like Independence Day and Men In Black, their success could be attributed as much to their high-end special effects and not so much to Smith's presence. Well, no more. While Enemy Of The State has great action sequences and special effects, the main attraction here is Will Smith. He does a great job in this film, and when you throw Gene Hackman and Jon Voight into the mix, you can almost guarantee that you have a very entertaining movie. Smith plays an attorney who becomes mixed up in something that he wants no part of. A secret US Government agency thinks that Smith's character has acquired some very sensitive information that they don't want him to have. They are afraid that he may leak this information to the press and ruin them. So the agency, led by a very nasty Jon Voight, sets out do discredit him as a preemptive strike, in case he can use this information before they can get it back from him. Along the way Smith enlists the help of a former Government surveillance expert (Gene Hackman) in order to get his life back.
Enemy Of the State is a top notch movie in every sense of the word. The acting is terrific, the writing is intelligent, and visually it looks great. Smith does a great job carrying the film, and he very easily proves that he is capable of more than just comic relief in a movie. No surprises when it comes to the performances of Gene Hackman and Jon Voight. These two men leave little doubt why they are two of the most talented actors working today. In a little bit of irony, Hackman's paranoid surveillance expert could almost be the same character that he played back in the early seventies in The Conversation. The irony being that The Conversation in one of the worst films of all time and Enemy Of The State is one of the better movies of the year.
The other thing that is worth mentioning is the fact that unlike many other similar cloak and dagger type movies, Enemy Of The State doesn't suffer from the inevitable confusing plot twists that usually plague this type of movie. At no point will you find yourself scratching your head wondering what the heck is going on. This is not to say that Enemy Of The State is without it's intricate plot twists, quite the contrary. The writing is simply so slick that a brain-damaged chimpanzee could follow along. Another interesting part of this movie is the technology that the government uses to track and spy on Will Smith's character. You can't help getting just a little uneasy when you wonder just who much of this stuff is real, and how much of it is just strictly a work of fiction. My money is on very little fiction.
Enemy Of The State should appeal to action fans and fans of the suspense genre alike. Will Smith fans will not be disappointed either. While he isn't cracking jokes in this movie, his charisma makes up for it. Enemy Of The State is a very entertaining way to spend a couple of hours.
8/10
Visit The Movie Guy http://members.tripod.com/~MovieGuy/index.html
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


Health:
10
Defence:
7
Attack:
10
Health:
5
Defence:
10
Attack:
15
Health:
15
Defence:
7
Attack:
5
Health:
15
Defence:
0
Attack:
10
Attack!
Choose Your Fighter!
Choose Your Enemy!
VS.


--- layout: post title: Gnus configuration (2.75 of N) - Spam Splitting published: true date: 2011-12-07 categories: [] posterous_url: http://verdammelt.posterous.com/gnus-configuration-275-of-n-spam-splitting posterous_slug: gnus-configuration-275-of-n-spam-splitting ---
I think I have no solved the problem of Bogofilter not running after
group exit. I had my spam-process
group parameter written wrong.
(spam-process ((spam spam-use-bogofilter) (ham spam-use-bogofilter)))
Note that this is a sexpr
of two elements, the second one being a
list. I had it being a sexpr
of three elements.
Oh the joy of silent failure.
I have also found mention of the BBDB
problem on the mailing list – so
there is a possible fix there if I get a new copy of spam.el
from the
repository or something like that.


This is header 1
This is header 2
This is header 3
This is a paragraph. I am styled by a class called "intro"
I am enclosed within a
div
tag. And i can be styled on a document level.
this is an ordered list and it is centered
apple
orange
banana
this is an unordered list and it is centered
apple
orange
banana
I am a link that is styled by a class
I am enclosed within a
div
tag.
this is an ordered list and it is centered
apple
orange
banana
this is an unordered list and it is centered and i have a class defined
apple
orange
banana
I am a link that is styled by a class
change properties
Create dynamic content
Rearrange list
Rearrange unordered list
hide header 1
Change hyperlink colors
Hide header 2 (using tag name)


This is my first paragraph in my new webpage.
Yes, that's right - web pages can be a lot of fun. Link to Google Link to Google
"A designer knows he has achieved perfection not when there is nothing left to take away."
Some example text


Cashew
A lightweight caching library for Java
Cashew is a lightweight cache library for use in Java applications and servers. It allows intuitive access to data in an object-oriented cache with minimal overhead.
Cashew is still in beta
More features, support, and a guide will be available soon
Download and import
You can easily import Cashew in your project using Maven or Gradle:
Maven:
<dependency> <groupId>com.raylabz</groupId> <artifactId>cashew</artifactId> <version>0.3.3</version> </dependency>
Gradle:
implementation 'com.raylabz:cashew:0.3.3'
Documentation
License
Cashew is released under the Apache license.
Source code
You can find the source code at the project's repository here.
Bug reporting
Please report bugs here.


My home
$80
2 Guests
1 Bedroom
1 Bathroom
Owner: Daniel
This is a lovely 1 bedroom and 1 bathroom apartment that can accommodate 2
people. It locates at the center of Phoenix, capital of the state of Arizona in the southwestern
U.S. This city is known for its warm and sunny climate throughout the year, and is the center of a
large metropolitan area of several cities known as the Valley of the Sun. It is famous for its
exclusive spas, Jack Nicklaus-designed golf courses and lively nightclubs. Other highlights include
the Desert Botanical Garden, which features cacti and numerous native plants.


public class DiscoveryModule
extends java.lang.Object
| 限定符和类型 | 字段和说明 |
|---|---|
static Setting<java.util.Optional<java.lang.String>> |
DISCOVERY_HOSTS_PROVIDER_SETTING |
static Setting<java.lang.String> |
DISCOVERY_TYPE_SETTING |
| 构造器和说明 |
|---|
DiscoveryModule(Settings settings,
ThreadPool threadPool,
TransportService transportService,
NamedWriteableRegistry namedWriteableRegistry,
NetworkService networkService,
MasterService masterService,
ClusterApplier clusterApplier,
ClusterSettings clusterSettings,
java.util.List<DiscoveryPlugin> plugins,
AllocationService allocationService) |
| 限定符和类型 | 方法和说明 |
|---|---|
Discovery |
getDiscovery() |
public static final Setting<java.lang.String> DISCOVERY_TYPE_SETTING
public static final Setting<java.util.Optional<java.lang.String>> DISCOVERY_HOSTS_PROVIDER_SETTING
public DiscoveryModule(Settings settings, ThreadPool threadPool, TransportService transportService, NamedWriteableRegistry namedWriteableRegistry, NetworkService networkService, MasterService masterService, ClusterApplier clusterApplier, ClusterSettings clusterSettings, java.util.List<DiscoveryPlugin> plugins, AllocationService allocationService)
public Discovery getDiscovery()


Builder mac-rel Build 5963
Overview
Pending
Actions
Input
| Patch | 1447158 (ps #3) |
Infra
- Buildbucket ID:<PHONE_NUMBER>121312624
- Swarming Task: 42ba0286a65eff10
- Bot: N/A
- Recipe: chromium_trybot
Timing
| Create | Saturday, 30-Jan-16 23:56:06 UTC |
| Start | N/A |
| End | N/A |
| Pending | 1099 days 4 hrs |
| Execution | N/A |
Build Steps
Show:Debug Logs:
Tags
N/A
Input Properties
| Name | Value |
|---|---|
| $build/goma | { "jobs": 150 } |
| $kitchen | { "devshell": true, "git_auth": true } |
| $recipe_engine/buildbucket | { "build": { "builder": { "bucket": "try", "builder": "mac-rel", "project": "chromium" }, "createTime": "2016-01-30T23:56:06.525946Z", "createdBy"<EMAIL_ADDRESS>"id": "8922862144121312624", "infra": { "buildbucket": { "serviceConfigRevision": "01134cf47e8a2d5d7cea5ec1232ca64ed2f16a5c" }, "swarming": { "hostname": "chromium-swarm.appspot.com" } }, "input": { "gerritChanges": [ { "change": "1447158", "host": "chromium-review.googlesource.com", "patchset": "3", "project": "chromium/src" } ] }, "number": 5963, "tags": [ { "key": "builder", "value": "mac-rel" }, { "key": "buildset", "value": "patch/gerrit/chromium-review.googlesource.com/1447158/3" }, { "key": "cq_experimental", "value": "false" … |
| $recipe_engine/runtime | { "is_experimental": false } |
| attempt_start_ts |<PHONE_NUMBER>000000 |
| blamelist | [<EMAIL_ADDRESS>] |
| buildbucket | { "build": { "bucket": "luci.chromium.try", "created_by"<EMAIL_ADDRESS>"created_ts":<PHONE_NUMBER>525946, "id": "8922862144121312624", "project": "chromium", "tags": [ "build_address:luci.chromium.try/mac-rel/5963", "builder:mac-rel", "buildset:patch/gerrit/chromium-review.googlesource.com/1447158/3", "cq_experimental:false", "user_agent:cq" ] }, "hostname": "cr-buildbucket.appspot.com" } |
| builder_group | "tryserver.chromium.mac" |
| buildername | "mac-rel" |
| buildnumber | 5963 |
| category | "cq" |
| patch_gerrit_url | "https://chromium-review.googlesource.com" |
| patch_issue | 1447158 |
| patch_project | "chromium/src" |
| patch_ref | "refs/changes/58/1447158/3" |
| patch_repository_url | "https://chromium.googlesource.com/chromium/src" |
| patch_set | 3 |
| patch_storage | "gerrit" |
| reason | "CQ" |
| recipe | "chromium_trybot" |
| repository | "https://chromium.googlesource.com/chromium/src" |
| revision | "HEAD" |
Output Properties
N/A
Rendering...
Related Builds
No buildsets found
No Blamelist


Title
Mr
Mrs
Miss
First name
Last name
Email
Phone number
Password
Country
China
Brasil
Uruguai
Alemanha
I agree to the
terms and conditions
Sign up
Reset form


Easy(1000ms)
Medium(600ms)
Hard(400ms)
The TYPING CHRONICLES
High-Score:
Extravaganza
Score:0
It was fun! Wasn't it?
wanna retry?
RETRY


I was at a friends house, lot of people there. I picked up the salvia 2 days before and tried it with minimal effects. This time I asked my one buddy to accompany me in the car while I did it. I get into my car and pack the bowl and start hitting it. After I was done, I went completely numb, I felt as though my body and brain were completely dead. I sat in this expierence for a couple minutes when the song that was playing in the car said 'step inside'.
Well that must have fired something off in my brain because seconds later I was desperately trying to pack the bowl with more salvia, I thought that if I smoked more I would be able to 'step inside'. First hit off the bowl and I was gone. It was like the first bowl just kept me on some plateau and the next hit blew me into space. I definitely got to step inside, but that wasn't a good thing. I was transported to some crazy place... and all I can imagine was a lady that was showing me something. I can't even put words to it b/c it was just like raw emotion. At this point I got extremely terrified.  I frantically wanted out of the car and to lay on the grass, i thought that was my only escape. Once I got out of the car, I completely changed.
Into a MADMAN.
I started laughing hysterically, not a fun laugh, but a very very evil laugh. I was kneeling in between my car and the car door. I started to swear and say horrible things. A pizza delivering boy was coming up the drive way and I kept talking about killing him. And killing people at the party. It was disgusting to say the least. After a while I went back into the car. I couldn't even control my head, it kept going back and forth and hitting the side of the car. Then I had to go to the grass again. I hit the grass and started to swear and spit. After a while it wore off and I was back to normal. To even try to explain a salvia trip is nearly impossible. I don't think there are words to describe what you feel. Anyway, that is the last time I'm going to do salvia in a loong time.
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


Age: 25
Nationality: Mexican
Address: Rio Mezcala #1210
Phone number:<PHONE_NUMBER>
E-mail<EMAIL_ADDRESS>Last two leves of study : High school
Current level of study: University
Career: Computer engineering
University: Centro universitario de ciencias exactas e ingenierias
Logical thinking: 80%
Programing abstraction: 70%
1 year as C# developer in Web information technology solutions WITS
Enerducer - Domotic system
Internet of things
C# profesional developing
English: 75%
Photoshop: 50%
Like videogames
Like solving problems


Title of a longer featured blog post
Multiple lines of text that form the lede, informing new readers quickly and efficiently about what’s most interesting in this post’s contents.
 Totally up to you.


Front-End Web Developer
Who I am:
A multilingual Web Developer with a strong passion for language learning and technology. An Italian-English-Spanish-Japanese
translator and avid learner of HTML, CSS, and JavaScript. Experienced in creating digital content to ensure a better
experience for a wide range of users.


Automating the deployment of Rails application using Capistrano, Ruby, Rails, Automation.
Difficulty: 2
Time: 30 minutes
In this article, you will learn to automate the deployment of Ruby on Rails application using Capistrano. Capistrano is a remote server automation and deployment tool, which can be used to push your Rails application to remote repository. It's assumed that you have a GitHub account and also own sudo
priviledges to perform this task.
This article assumes that the host machine has Ruby on Rails using rbenv installed and running. For more details, see:
Capistrano relies on Git for deployments.
1. Yes: download, compile and install Nginx for me.(recommended) The easiest way to get started. A stock Nginx 1.4.4 with Passenger support, but with no other additional third party modules, will be installed for you to a directory of your choice.
Press Enter to continue.
#!/bin/sh . /etc/pam.d/nginx . /etc/sysconfig/network [ "$NETWORKING" = "no" ] && exit 0 nginx="/opt/nginx/sbin/nginx" prog=$(basename $nginx) NGINX_CONF_FILE="/opt/nginx/conf/nginx.conf" lockfile=/var/lock/subsys/nginx start() { [ -x $nginx ] || exit 5 [ -f $NGINX_CONF_FILE ] || exit 6 echo -n $"Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog:" killproc $prog -QUIT retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { configtest || return $? stop start } reload() { configtest || return $? echo -n $"Reloading $prog: " killproc $nginx -HUP RETVAL=$? echo } force_reload() { restart } configtest() { $nginx -t -c $NGINX_CONF_FILE } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" exit 2 esac
Open the configuration file of NGINX.
passenger_root
and passenger_ruby
directives.
passenger_app_env development;
# location / { # root html; # index index.html index.htm; # }
root /var/www/Your_application/public; passenger_enabled on;
/etc/sudoers
file.
Scroll down to the bottom of this file and find out the place where root is defined. Add the following line there:
UserName ALL=(ALL:ALL) ALL
Or
# mkdir -p config/deploy # create config/deploy.rb # create config/deploy/staging.rb # create config/deploy/production.rb # mkdir -p lib/capistrano/tasks # Capified
config/deploy.rb
file.
The file deploy.rb
contains arguments and settings relevant to the deployment server(s). Here, you will tell Capistrano that which server(s) you would like to connect to, complete the deployment and how.
# Define the name of the application set :application, 'Your_application' # Define where can Capistrano access the source repository # set :repo_url, 'https://github.com/[user name]/[application name].git' set :scm, :git set :repo_url, 'https://github.com/GitHub_UserName/Your_application/Your_application.git' # Define where to put your application code set :deploy_to, "/var/www/Your_application" // rail application path set :pty, true set :format, :pretty # Set the post-deployment instructions here. # Once the deployment is complete, Capistrano # will begin performing them as described. # To learn more about creating tasks, # check out: # http://capistranorb.com/ # namespace: deploy do # desc 'Restart application' # task :restart do # on roles(:app), in: :sequence, wait: 5 do # # Your restart mechanism here, for example: # execute :touch, release_path.join('tmp/restart.txt') # end # end # after :publishing, :restart # after :restart, :clear_cache do # on roles(:web), in: :groups, limit: 3, wait: 10 do # # Here we can do anything such as: # # within release_path do # # execute :rake, 'cache:clear' # # end # end # end # end
config/deploy/production.rb
file.
# Define roles, user and IP address of deployment server # role :name, %{[user]@[IP adde.]} role :app<EMAIL_ADDRESS>// YOUR PUBLIC IP role :web<EMAIL_ADDRESS>role :db<EMAIL_ADDRESS># Define server(s) server '<IP_ADDRESS>', user: 'UserName', roles: %w{web} # SSH Options # See the example commented out section in the file # for more options. set :ssh_options, { forward_agent: false, auth_methods: %w(password), password: 'System_User_Password’, user: 'UserName', }
To deploy to the production server, set the following permission:
Type the following to deploy:
In this article, you have learnt how to automate the deployment of your Rails application using Capistrano on Arch Linux.


Not to be confused with Capri!. This small island lies east of the northern tip of Corsica and NW of Elba. It is part of the Arcipelago Toscano National Park. Apart from the port area, this mountainous island is uninhabited.
In addition to berths in the port, there are 20 new visitors' buoys just outside this popular destination.
It is also possible to anchor here.
Shelter is good except from the east.
Last updated June 2011.