Skip to content

Instantly share code, notes, and snippets.

View morgondag's full-sized avatar
😎
(◉-◉)

Kim Aarnseth morgondag

😎
(◉-◉)
View GitHub Profile
@morgondag
morgondag / linky
Created September 26, 2014 11:37
Linkify
linkify: function(inputText) {
var replacedText, replacePattern1, replacePattern2, replacePattern3;
replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
replacedText = inputText.replace(replacePattern1, '<a href="$1" target="_blank">$1</a>');
replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
replacedText = replacedText.replace(replacePattern2, '$1<a href="http://$2" target="_blank">$2</a>');
replacePattern3 = /(([a-zA-Z0-9\-\_\.])+@[a-zA-Z\_]+?(\.[a-zA-Z]{2,6})+)/gim;
replacedText = replacedText.replace(replacePattern3, '<a href="mailto:$1">$1</a>');
replacedText = replacedText.replace(/\B@([\w-]+)/gm, '<a href="http://twitter.com/$1" target="_blank">@$1</a>');
return replacedText;
@morgondag
morgondag / node-proxy
Created June 23, 2014 09:27
basic proxy
var httpProxy = require('http-proxy');
var proxy = httpProxy.createProxyServer();
var http = require('http')
http.createServer(function(req, res) {
proxy.web(req, res, { target: 'http://127.0.0.1/'});
}).listen(8787);
@morgondag
morgondag / flightfile.js
Last active August 29, 2015 13:57
A awesome flight.js ui file
/*
1. save this file in ui/data folder with a name
for example if its reader discussion ajax reader_discussion_ajax.js
2. go to reader.js or builder.js
3. require this new file add
var newAwesomeFile = require('ui/reader_discussion_ajax');
4. in the initialize in reader.js attach this file to a DOM node.
if its global add it to document
example:
newAwesomeFile.attachTo('#yourParentSelector');