Skip to content

Instantly share code, notes, and snippets.

@Verurteilt
Created April 21, 2013 08:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Verurteilt/5428866 to your computer and use it in GitHub Desktop.
Save Verurteilt/5428866 to your computer and use it in GitHub Desktop.
var http = require('http'),
fs = require('fs'),
url = require('url'),
qs = require('querystring'),
io = require('socket.io');
var server = http.createServer(function(req, res){
res.setHeader('Content-Type','application/json');
if (req.headers['user-agent'] == 'RTC-UA'){
var GET = qs.parse(url.parse(req.url).query);
console.log(GET);
var file_name = GET.file_name;
var code = GET.code;
var codigo = GET.codigo;
console.log(new Buffer(codigo,'base64').toString('ascii'))
socket.sockets.emit('file', {name:file_name.substr(file_name.lastIndexOf('/')+1, file_name.length), code:code, codigo:codigo});
res.end('{"exito":true}');
} else {
res.end('{"exito":false}');
}
}).listen(3000);
var socket = io.listen(server);
import sublime
import sublime_plugin
import urllib2
import base64
class ExampleCommand(sublime_plugin.TextCommand):
def run(self, edit):
the_sels = self.view.sel()
the_sels_begin = the_sels[0].begin()
the_sels_end = the_sels[0].end()
lista = []
for i in range(the_sels_begin, the_sels_end):
lista.append(self.view.substr(i))
lista_unida = "".join(lista)
nombre_del_archivo = self.view.file_name()
url = 'http://localhost:3000/?code=%s&file_name=%s&codigo=%s' % ('print', self.view.file_name(),base64.b64encode(lista_unida))
request = urllib2.Request(url, None, {'User-Agent': 'RTC-UA'})
print urllib2.urlopen(request), lista_unida
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment