Skip to content

Instantly share code, notes, and snippets.

@vpilot
vpilot / JPAValidation
Last active August 29, 2015 13:56
Regex Tips
// email validation, supports only lower case emails
@Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\."
+"[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@"
+"(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?",
message="Invalid Email")
protected String email;
// not blank
@NotNull(message="Title can not be NULL.")
@Pattern(regexp="^(?!\\s*$).+", message="Title can not be empty.")
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
[url "git@github.com:"]
insteadOf = "gh:"
pushInsteadOf = "github:"
pushInsteadOf = "git://github.com/"
[url "git://github.com/"]
insteadOf = "github:"
[url "git@gist.github.com:"]
insteadOf = "gst:"
pushInsteadOf = "gist:"
pushInsteadOf = "git://gist.github.com/"
public class WebLinkValidator {
private final static String linkRegex = "((([A-Za-z]{3,9}:(?://)?)(?:[\\-;:&=\\+\\$,\\w]+@)?[A-Za-z0-9\\.\\-]+|(?:www\\.|[\\-;:&=\\+\\$,\\w]+@)[A-Za-z0-9\\.\\-]+)((?:/[\\+~%/\\.\\w\\-]*)?\\??(?:[\\-\\+=&;%@\\.\\w]*)#?(?:[\\.\\!/\\\\\\w]*))?)";
/**
* Examples of valid web links are:
* <ul>
* <li>"www.site.com"</li>
* <li>"http://www.site.com"</li>
* <li>"mailto:lucy@site.com"</li>
# Install mysql
brew install mysql
# pin the version so you don't override it accidentally with upgrate
brew pin mysql
# Copy launch agent into place
mkdir -p ~/Library/LaunchAgents && cp /usr/local/Cellar/mysql/<version>/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
# Edit launch agent and set both keepalive and runatload at startup to false
#Store screenshots in subfolder on desktop
mkdir ~/Desktop/Screenshots
defaults write com.apple.screencapture location ~/Desktop/Screenshots
#Show the ~/Library folder
chflags nohidden ~/Library
@vpilot
vpilot / PEAR and PECL installation
Last active August 29, 2015 14:12
Enable PEAR and PECL on Yosemite
// By default PEAR is not installed on Yosemite, but it comes with installation phar file
$ cd /usr/lib/php
$ sudo php install-pear-nozlib.phar
// If you don't have php.ini file use default one provided
$ sudo cp /etc/php.ini.default /etc/php.ini
// edit php.ini with your editor of choice and add two following lines
// make sure to douple check your extension path, it maybe different
include_path = ".:/usr/lib/php/pear"
# Apache configuration
AddType application/font-woff .woff
AddType application/font-woff2 .woff2
AddType application/font-sfnt .ttf .otf
AddType image/svg+xml .svg
AddType application/vnd.ms-fontobject .eot
@vpilot
vpilot / phpMyAdmin on Mac
Last active August 29, 2015 14:20
Installing phpMyAdmin on Mac
1. Download the latest phpMyAdmin distribution
phpMyAdmin-x.x.x-english.tar.gz
2. Create folder ~/Sites/database/ and move distribution into the folder
mv ~/Downloads/phpMyAdmin-x.x.x-english.tar.gz ~/Sites/database/
2. Untar and make files executable
@vpilot
vpilot / mcrypt installation
Last active August 29, 2015 14:20
Installing mcrypt on OS X 10.10
Pre-requisit is to have homebrew installed.
1. brew install mcrypt
2. brew install autoconf
3. brew tap homebrew/dupes
4. brew tap homebrew/versions
5. brew tap homebrew/homebrew-php
6. brew install php55
7. brew install php55-mcrypt --without-homebrew-php
8. At last edit /ect/php.ini and add extension path to mcrypt.so, something like: