Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@weivall
weivall / gist:3513624
Created August 29, 2012 14:44
Access-Control-Allow-Origin
<Directory "/home/the directory_where_your_serverside_pages_is">
Header set Access-Control-Allow-Origin "*"
AllowOverride all
Order allow,deny
Allow from all
</Directory>
@weivall
weivall / gist:3305329
Created August 9, 2012 15:51
isValidEmail
function isValidEmail(email){
return /^((([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+(\.([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+)*)@((((([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.))*([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.)[\w]{2,4}|(((([0-9]){1,3}\.){3}([0-9]){1,3}))|(\[((([0-9]){1,3}\.){3}([0-9]){1,3})\])))$/.test(email);
}
@weivall
weivall / gist:3305323
Created August 9, 2012 15:50
isValidURL
function isValidURL(url){
return /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&amp;?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/.test(url);
@weivall
weivall / gist:3225920
Created August 1, 2012 11:21
function is_url($url)
function is_url($url) {
return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
}
user www-data www-data;
worker_processes 2;
error_log logs/error.log debug;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
@weivall
weivall / gist:2780773
Created May 24, 2012 10:38
mod_expires
FileETag MTime Size
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="ru" class="m-locale_ru m-layout_2pane" xml:lang="ru">
@weivall
weivall / gist:2595515
Created May 4, 2012 15:26
<meta name="format-detection" content="address=no;email=no" />
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, width=device-width">
<meta name="format-detection" content="address=no;email=no" />
#!/bin/bash -e
# Define common variables
USERNAME=redmine
WWW_USERNAME=redmine
RUN_WITH_USERNAME="sudo -iu $USERNAME http_proxy=$http_proxy https_proxy=$https_proxy"
# Create user with $USERNAME
id $USERNAME || sudo useradd -rm $USERNAME