Skip to content

Instantly share code, notes, and snippets.

@dlamichhane
dlamichhane / HTTP Status Code
Created December 14, 2012 19:43
HTTP Status Code
The Status-Code element is a 3-digit integer result code of the attempt to understand and
satisfy the request. The first digit of the Status-Code defines the class of response. The
last two digits do not have any categorization role.There are 5 values for the first digit:
1xx: Informational - Request received, continuing process
2xx: Success - The action was successfully received,understood, and accepted
3xx: Redirection - Further action must be taken in order to complete the request
4xx: Client Error - The request contains bad syntax or cannot be fulfilled
5xx: Server Error - The server failed to fulfill an apparently valid request
@dlamichhane
dlamichhane / raw_tag.rb
Created August 17, 2011 05:40 — forked from phaer/raw_tag.rb
Raw tag for jekyll. Keeps liquid from parsing text betweeen {% raw %} and {% endraw %}
module Jekyll
class RawTag < Liquid::Block
def parse(tokens)
@nodelist ||= []
@nodelist.clear
while token = tokens.shift
if token =~ FullToken
if block_delimiter == $1
end_tag
when "url"
regex = /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix
test match scenario:
http://www.en.hotmail-f.com.np
https://www.apple.co.uk
http://www.apple.com
http://www.apple.com
http://w3.apple.tv
http://www.apple-apple.com
when "email"
regex = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
when "url"
regex = /^(http:\/\/|https:\/\/)?(www.)?[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3})([.]?[a-zA-Z]{2})?(\/\S*)?$/i
when "number"
regex = /^\d{1,3}(\,?\d{3})*$/
when "time"
regex = /^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?$/
when "date"
regex = /^(\d{1,2})[\/|-|\.|\s](\d{1,2})[\/|-|\.|\s](\d{2,4})$/