This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="file" onchange="angular.element(this).scope().myController.uploadFile(this.files[0]); angular.element(this).scope().$digest();"> | |
var uploadFile = function(file) { | |
var formData = new FormData(); | |
formData.append('file', file); | |
$http({ | |
method: 'POST', | |
url: 'url-to-accept-file', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xmlToJson: function(xml) { | |
var parser, obj; | |
if (typeof xml == 'string') { | |
if (window.ActiveXObject){ | |
xml = new ActiveXObject('Microsoft.XMLDOM'); | |
xml.async = 'false'; | |
xml.loadXML(xml); | |
} else { | |
parser = new DOMParser(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var connect = require('connect'); | |
var portNum = 1337; | |
connect.createServer( | |
connect.static(__dirname) | |
).listen(portNum); | |
console.log('listening on '+portNum+'...'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var exec = require('child_process').exec; | |
var commands = ['npm install', 'bower install']; | |
var command = 0; | |
var run = function(cmd){ | |
console.log('running > ' + cmd); | |
var child = exec(cmd, function (error, stdout, stderr) { | |
if (stderr !== null) { | |
console.log(stderr); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var sys = require('sys'); | |
var oauth = require('oauth'); | |
var app = express.createServer(); | |
var _twitterConsumerKey = "YOURTWITTERCONSUMERKEY"; | |
var _twitterConsumerSecret = "YOURTWITTERCONSUMERSECRET"; | |
function consumer() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var css = 'insert lots of css here'; | |
var files = {}; | |
css = css.replace(/url\(["']?(\S*)\.(png|jpg|jpeg|gif)["']?\)/g, function(match, file, type) | |
{ | |
var fileName = file + '.' + type; | |
var size = fs.statSync(fileName).size; | |
if (size > 4096) { | |
console.log('Skipping ' + fileName + ' (' + (Math.round(size/1024*100)/100) + 'k)'); | |
return match; |