Skip to content

Instantly share code, notes, and snippets.

View superbarne's full-sized avatar

Barne Jürgensen superbarne

View GitHub Profile
#curl https://gist.githubusercontent.com/einfacheruser/77bd850d5c270bf7cad4/raw/ff398380c2c8a1dad17ce00a307223fb57fcba24/gistfile1.txt | sh
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
@superbarne
superbarne / ptags.js
Created June 9, 2013 13:44
parse tags for a module system
var str = '[youtube="UKnkc-4ZzEU"]';
var ptags = [
{
name:'youtube',
search: /\[youtube\="?(.*?)"?\]/g,
replace:'<iframe width="560" height="315" src="http://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>'
}
]
@superbarne
superbarne / yt-stream
Created June 6, 2013 14:01
Streams youtube videos directly to the browser like a proxy
var ytdl = require('ytdl')
function stream(req,res,id) {
var dl = ytdl('http://www.youtube.com/watch?v='+id, {
quality:43 //poor quality leave empty for good quality
})
dl.pipe(res);
}
var getSlug = require('speakingurl');
slug = getSlug('Apple & Pear!');
console.log(slug);
// Output: apple-and-pear
slug = getSlug('Foo ♥ Bar');
console.log(slug);
// Output: foo-love-bar