Skip to content

Instantly share code, notes, and snippets.

@gruber
gruber / Liberal Regex Pattern for All URLs
Last active November 4, 2024 20:04
Liberal, Accurate Regex Pattern for Matching All URLs
The regex patterns in this gist are intended to match any URLs,
including "mailto:[email protected]", "x-whatever://foo", etc. For a
pattern that attempts only to match web URLs (http, https), see:
https://gist.github.com/gruber/8891611
# Single-line version of pattern:
(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))
DropboxClient.prototype.putFile = function(file, path, optargs, cb) {
if (typeof optargs == 'function') cb = optargs, optargs = {};
var boundary = 'sAxIqse3tPlHqUIUI9ofVlHvtdt3tpaG',
content_type = 'multipart/form-data; boundary=' + boundary,
self = this;
require('fs').readFile(file, function (err, data) {
if (err) return cb(err);
// Build request body.
path = escapePath(path);
/* mobile UA detection http://jsfiddle.net/Takazudo/rxPYk/ */
var ua = (function(){
var ua = {};
var navigator = window.navigator;
var platforms = [
{ property: 'platform', regex: /iPhone/i, identity: 'iPhone' },
{ property: 'platform', regex: /iPod/i, identity: 'iPod' },
{ property: 'userAgent', regex: /iPad/i, identity: 'iPad' },
{ property: 'userAgent', regex: /Blackberry/i, identity: 'Blackberry' },
@atty303
atty303 / .gitignore
Created May 31, 2011 07:42
Initial gitignore for iOS project.
# xcode noise
build/*
*.perspective
*.perspectivev3
*.pbxuser
*.xcworkspace
*.mode1
*.mode2v3
*.mode1v3
xcuserdata
@trodrigues
trodrigues / gist:1023167
Created June 13, 2011 16:51
Checkout only certain branches with git-svn
If you want to clone an svn repository with git-svn but don't want it to push all the existing branches, here's what you should do.
* Clone with git-svn using the -T parameter to define your trunk path inside the svnrepo, at the same time instructing it to clone only the trunk:
git svn clone -T trunk http://example.com/PROJECT
* If instead of cloning trunk you just want to clone a certain branch, do the same thing but change the path given to -T:
git svn clone -T branches/somefeature http://example.com/PROJECT
@heavenshell
heavenshell / app.py
Created September 30, 2011 16:01
Flask static file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@smebberson
smebberson / .gitignore
Created January 9, 2012 06:46
Express simple authentication example
node_modules
*.swp
@joshuapowell
joshuapowell / reset.less
Last active September 25, 2024 18:58
LESS: Global LESS CSS reset that gives elements default formatting.
/**
* Global Reset of all HTML Elements
*
* Resetting all of our HTML Elements ensures a smoother
* visual transition between browsers. If you don't believe me,
* try temporarily commenting out this block of code, then go
* and look at Mozilla versus Safari, both good browsers with
* a good implementation of CSS. The thing is, all browser CSS
* defaults are different and at the end of the day if visual
* consistency is what we're shooting for, then we need to
@joshj
joshj / server.js
Created February 28, 2012 16:58 — forked from jeffrafter/server.js
Twitter OAuth with node-oauth for node.js+express
/*
Node.js, express, oauth example using Twitters API
Install Node.js:
curl -0 http://nodejs.org/dist/v0.6.11/node-v0.6.11.tar.gz
tar -zxf node-v0.6.11.tar.gz
cd node-v0.6.11
./configure
make
make install
@tqc
tqc / jqmdialogfix.css
Created April 19, 2012 12:24
jQuery mobile dialog transparency fix
.ui-dialog-background {
opacity: 0.5;
display: block !important;
-webkit-transition: opacity 0.5s ease-in;
}
.ui-dialog-background.pop.in {
opacity: 1;
-webkit-transition: opacity 0.5s ease-in;
}