# Setting for the new UTF-8 terminal support in Lion
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
# Setting for the new UTF-8 terminal support in Lion LC_CTYPE=en_US.UTF-8 LC_ALL=en_US.UTF-8
# Setting for the new UTF-8 terminal support in Lion
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
# Setting for the new UTF-8 terminal support in Lion LC_CTYPE=en_US.UTF-8 LC_ALL=en_US.UTF-8
-(UIView *)roundCornersOnView:(UIView *)view onTopLeft:(BOOL)tl topRight:(BOOL)tr bottomLeft:(BOOL)bl bottomRight:(BOOL)br radius:(float)radius {
UIRectCorner corner; //holds the corner
//Determine which corner(s) should be changed
if (tl) {
corner = UIRectCornerTopLeft;
}
if (tr) {
corner = UIRectCornerTopRight;
}
if (bl) {
corner = UIRectCornerBottomLeft;
}
if (br) {
corner = UIRectCornerBottomRight;
}
if (tl && tr) { //top
corner = UIRectCornerTopRight | UIRectCornerTopLeft;
}
if (bl && br) { //bottom
corner = UIRectCornerBottomLeft | UIRectCornerBottomRight;
}
if (tl && bl) { //left
corner = UIRectCornerTopLeft | UIRectCornerBottomLeft;
}
if (tr && br) { //right
corner = UIRectCornerTopRight | UIRectCornerBottomRight;
}
if (tl & tr & bl & br) {
corner = UIRectCornerAllCorners;
}
UIView *roundedView = view;
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:roundedView.bounds byRoundingCorners:corner cornerRadii:CGSizeMake(radius, radius)];
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = roundedView.bounds;
maskLayer.path = maskPath.CGPath;
roundedView.layer.mask = maskLayer;
return roundedView;
}
UIButton *openInMaps = [UIButton new];
[openInMaps setFrame:CGRectMake(15, 135, 114, 70)];
openInMaps = (UIButton *)[self roundCornersOnView:openInMaps onTopLeft:NO topRight:NO bottomLeft:YES bottomRight:NO radius:5.0];
# wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
# rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm
# wget http://nginx.org/packages/rhel/6/noarch/RPMS/nginx-release-rhel-6-0.el6.ngx.noarch.rpm
# rpm -ivh nginx-release-rhel-6-0.el6.ngx.noarch.rpm
# yum install nginx
# chkconfig nginx on
# service nginx start
# service nginx stop
# service nginx restart
# service nginx status
# service nginx reload
# vi /etc/nginx/nginx.conf
worker_processes 2;
gzip on;
# vi /etc/nginx/conf.d/default.conf
listen 202.54.1.1.1:80;
server_name www.cyberciti.biz;
# service nginx start
# netstat -tulpn | grep :80
# ps aux | grep nginx
# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
# service iptables restart
[base] name=CentOS-$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os baseurl=http://mirror1.ku.ac.th/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled = 1 #released updates [updates] name=CentOS-$releasever - Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates baseurl=http://mirror1.ku.ac.th/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled = 1 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras baseurl=http://mirror1.ku.ac.th/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled = 1
yum -v repolist
DEVICE="eth0" HWADDR=specifc mac address NM_CONTROLLED="no" ONBOOT="yes" BOOTPROTO="static" IPADDR=ip address here. NETMASK=netmask here.
nameserver 8.8.8.8 nameserver 8.8.4.4
connection.connect(); connection.query('SELECT 1 + 1 AS solution', function(err, rows, fields) { if (err) throw err; console.log('The solution is: ', rows[0].solution); }); connection.end();
$ npm install validator
validator-min.js
var check = require('validator').check,
sanitize = require('validator').sanitize
//Validate
check('test@email.com').len(6, 64).isEmail(); //Methods are chainable
check('abc').isInt(); //Throws 'Invalid integer'
check('abc', 'Please enter a number').isInt(); //Throws 'Please enter a number'
check('abcdefghijklmnopzrtsuvqxyz').is(/^[a-z]+$/);
//Sanitize / Filter
var int = sanitize('0123').toInt(); //123
var bool = sanitize('true').toBoolean(); //true
var str = sanitize(' \t\r hello \n').trim(); //'hello'
var str = sanitize('aaaaaaaaab').ltrim('a'); //'b'
var str = sanitize(large_input_str).xss();
var str = sanitize('<a>').entityDecode(); //'<a>'
request
prototype.http://localhost:8080/?zip=12345&foo=1&textarea=large_string
get('/', function (req, res) {
req.onValidationError(function (msg) {
//Redirect the user with error 'msg'
});
//Validate user input
req.check('zip', 'Please enter a valid ZIP code').len(4,5).isInt();
req.check('email', 'Please enter a valid email').len(6,64).isEmail();
req.checkHeader('referer').contains('localhost');
//Sanitize user input
req.sanitize('textarea').xss();
req.sanitize('foo').toBoolean();
//etc.
});
is() //Alias for regex()
not() //Alias for notRegex()
isEmail()
isUrl() //Accepts http, https, ftp
isIP()
isAlpha()
isAlphanumeric()
isNumeric()
isHexadecimal()
isHexColor() //Accepts valid hexcolors with or without # prefix
isInt() //isNumeric accepts zero padded numbers, e.g. '001', isInt doesn't
isLowercase()
isUppercase()
isDecimal()
isFloat() //Alias for isDecimal
notNull()
isNull()
notEmpty() //i.e. not just whitespace
equals(equals)
contains(str)
notContains(str)
regex(pattern, modifiers) //Usage: regex(/[a-z]/i) or regex('[a-z]','i')
notRegex(pattern, modifiers)
len(min, max) //max is optional
isUUID(version) //Version can be 3 or 4 or empty, see http://en.wikipedia.org/wiki/Universally_unique_identifier
isDate() //Uses Date.parse() - regex is probably a better choice
isAfter(date) //Argument is optional and defaults to today. Comparison is non-inclusive
isBefore(date) //Argument is optional and defaults to today. Comparison is non-inclusive
isIn(options) //Accepts an array or string
notIn(options)
max(val)
min(val)
isArray()
isCreditCard() //Will work against Visa, MasterCard, American Express, Discover, Diners Club, and JCB card numbering formats
trim(chars) //Trim optional `chars`, default is to trim whitespace (\r\n\t )
ltrim(chars)
rtrim(chars)
ifNull(replace)
toFloat()
toInt()
toBoolean() //True unless str = '0', 'false', or str.length == 0
toBooleanStrict() //False unless str = '1' or 'true'
entityDecode() //Decode HTML entities
entityEncode()
escape() //Escape &, <, >, and "
xss() //Remove common XSS attack vectors from user-supplied HTML
xss(true) //Remove common XSS attack vectors from images
this.str
to access the string and this.error(this.msg || default_msg)
when the string is invalidvar Validator = require('validator').Validator;
Validator.prototype.contains = function(str) {
if (!~this.str.indexOf(str)) {
this.error(this.msg || this.str + ' does not contain ' + str);
}
return this; //Allow method chaining
}
this.str
to access the string and this.modify(new_str)
to update itvar Filter = require('validator').Filter;
Filter.prototype.removeNumbers = function() {
this.modify(this.str.replace(/[0-9]+/g, ''));
return this.str;
}
try {
check('abc').notNull().isInt()
} catch (e) {
console.log(e.message); //Invalid integer
}
check()
try {
check('abc', 'Please enter a valid integer').notNull().isInt()
} catch (e) {
console.log(e.message); //Please enter a valid integer
}
error
method of the validator instancevar Validator = require('validator').Validator;
var v = new Validator();
v.error = function(msg) {
console.log('Fail');
}
v.check('abc').isInt(); //'Fail'
Validator.prototype.error = function (msg) {
this._errors.push(msg);
return this;
}
Validator.prototype.getErrors = function () {
return this._errors;
}
var validator = new Validator();
validator.check('abc').isEmail();
validator.check('hello').len(10,30);
var errors = validator.getErrors(); // ['Invalid email', 'String is too small']