Skip to content

Instantly share code, notes, and snippets.

@YurySolovyov
YurySolovyov / disk.js
Created March 5, 2015 19:18
asar packager without pickle
var Filesystem = require('./filesystem');
var fs = require('fs');
var pickleHeader = new Buffer([0x04, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00]);
var writeFileListToStream = function(out, list, cb) {
if (list.length === 0) {
out.end();
if ('function' === typeof cb) {
cb(null);
}
'use strict';
var path = require('path');
var Promise = require('bluebird');
var asar = Promise.promisifyAll(require('asar'));
var globAsync = Promise.promisify(require('glob'));
var stylus = Promise.promisifyAll(require('stylus'));
var fs = Promise.promisifyAll(require('fs-extra'));
var readFiles = function(files) {
return Promise.map(files, function(file) {
@YurySolovyov
YurySolovyov / client.js
Last active August 29, 2015 14:18
Streaming XHR response
$(function() {
var url = 'http://127.0.0.1:8000/';
var req = new XMLHttpRequest();
var updateProgress = function(e) {
var chunks = req.responseText.split('\n');
var last_chunk = chunks[chunks.length - 1];
if (last_chunk) {
console.log(last_chunk);
}
@YurySolovyov
YurySolovyov / gist:38726cf806c52ed16183
Created April 22, 2015 07:51
complie node with llvm
export CC=llvm-gcc CXX=llvm-g++
@YurySolovyov
YurySolovyov / server.sh
Created October 14, 2015 08:00
simple http sever
python -m SimpleHTTPServer 8000
{
"rules": {
"indent": [
2,
4
],
"quotes": [
2,
"single"
],
var fs = require('fs');
var Pipe = require('./core').Pipe;
var getStatAndWriteToJSONFile = Pipe.create(function(file,next){
fs.stat(file, next);
}).then(function(err, stats, next){
var fs = require('fs');
var Pipe = require('./core').Pipe;
var folder = './files/';
var getStatsAndWriteThemToFile = Pipe.create(function(file,pipe){
pipe.set('filename',file);
fs.stat(folder + file, pipe.next);
@YurySolovyov
YurySolovyov / conf.ru
Created February 19, 2016 21:13
threads.ruby
require "rack"
require "json"
use Rack::ContentLength
use Rack::Logger, Logger.new(STDOUT)
use Rack::Static, :urls => ["/static"]
module CacheHolder
CACHE = Hash.new
LOCK = Mutex.new
extern crate winapi;
extern crate user32;
use self::winapi::windef::HWND;
use self::winapi::minwindef::UINT;
use self::winapi::minwindef::DWORD;
use self::winapi::minwindef::WPARAM;
use self::winapi::minwindef::LPARAM;
fn register_hotkey_api_call(key_options: u32, key_code: u32) -> bool {