Skip to content

Instantly share code, notes, and snippets.

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

Kim Aarnseth morgondag

😎
(◉-◉)
View GitHub Profile
@morgondag
morgondag / gist:8401700
Created January 13, 2014 14:54
سمَـَّوُوُحخ ̷̴̐خ ̷̴̐خ ̷̴̐خ امارتيخ ̷̴̐خ
سمَـَّوُوُحخ ̷̴̐خ ̷̴̐خ ̷̴̐خ امارتيخ ̷̴̐خ
@morgondag
morgondag / gist:8540802
Created January 21, 2014 14:11
do we got old crappy flash?
var hasFlash = false;
try {
var fo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
if(fo) hasFlash = true;
}catch(e){
if(navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) hasFlash = true;
}
@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');
@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 / 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;
encode4HTML:function(str) {
return str
//.replace(/\r\n?/g,'\n')
// normalize newlines - I'm not sure how these
// are parsed in PC's. In Mac's they're \n's
//.replace(/(^((?!\n)\s)+|((?!\n)\s)+$)/gm,'')
// trim each line
//.replace(/(?!\n)\s+/g,' ')
// reduce multiple spaces to 2 (like in "a b")
//.replace(/^\n+|\n+$/g,'')
for (var i = 0; i < 6; i++) {
x = basepos.x + Math.sin( (Math.PI/12*i))*(600);
y = basepos.y + Math.cos( (Math.PI/12*i))*(600);
this.deployStar(x,y);
}
@morgondag
morgondag / gulpfile.js
Created September 1, 2015 14:11
render
var render = require('./app/render.js');
// Build our templates
gulp.task('templates', function() {
render.render(templateData.JS, templateData.CSS);
})
@morgondag
morgondag / gist:896c76f69888afc1236c
Created September 10, 2015 07:15
nw.js settings per platform
Windows:
"chromium-args": "--in-process-gpu --ignore-gpu-blacklist --enable-webgl --disable-transparency --disable-device-orientation"
Linux:
"chromium-args": "--ignore-gpu-blacklist --enable-webgl --disable-transparency --disable-device-orientation --disable-setuid-sandbox"
Mac OS X:
"chromium-args": "--ignore-gpu-blacklist --enable-webgl --disable-transparency --disable-device-orientation"
{
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/Theme - Spacegray/base16-eighties.dark.tmTheme",
"detect_indentation": true,
"draw_minimap_border": true,
"draw_white_space": "selection",
"ensure_newline_at_eof_on_save": true,
"fade_fold_buttons": false,
"folder_exclude_patterns":