Skip to content

Instantly share code, notes, and snippets.

View freeart's full-sized avatar

Nekrasov Pavel freeart

View GitHub Profile
const async = require('async'),
vm = require("vm"),
fs = require("fs"),
moment = require('moment'),
changeCase = require('change-case');
class Contract {
constructor(cb, scope) {
this.modules;
this.ready = false;
var cluster = require('cluster');
var ping = require('ping');
var async = require('async');
var randomstring = require("randomstring");
var jsonfile = require('jsonfile')
var worker;
if (cluster.isMaster) {
let file = './dict.json'
let nums;
SELECT * FROM (
SELECT ROW_NUMBER() OVER (ORDER BY data.[DeviceId]) as ID, data.[UserId], data.[DeviceId],
l2u.[PurchaseTime], lic.[Name] [LicenceName],
d.[Name] [DeviceName], d.[Code], d.[Number], d.[VersionHW], sb.[Version] [VersionSW], d.[DeviceStatus], d.[SigFoxActive], d.[Comment],
CASE WHEN s.id > sb.id THEN s.[BatteryPercent] ELSE sb.[BatteryPercent] END AS BatteryPercent,
CASE WHEN nog.[Latitude] IS NULL OR nog.[Latitude] = 0 THEN CASE WHEN l.[Latitude] IS NULL OR l.[Latitude] = 0 THEN CASE WHEN e.[Latitude] IS NULL OR e.[Latitude] = 0 THEN 0 ELSE e.[Latitude] END ELSE l.[Latitude] END ELSE nog.[Latitude] END AS Latitude,
CASE WHEN nog.[Longitude] IS NULL OR nog.[Longitude] = 0 THEN CASE WHEN l.[Longitude] IS NULL OR l.[Longitude] = 0 THEN CASE WHEN e.[Longitude] IS NULL OR e.[Longitude] = 0 THEN 0 ELSE e.[Longitude] END ELSE l.[Longitude] END ELSE nog.[Longitude] END AS Longitude,
CASE WHEN nog.[Precision] IS NULL OR nog.[Precision] = 0 THEN CASE WHEN l.[Precision] IS NULL OR
@freeart
freeart / poll.js
Created November 15, 2014 15:11
Pool
var async = require('async');
module.exports.Pool = function (factory) {
var private = {}
var public = {}
private.clients = {};
private.queue = [];
private.draining = false;
@freeart
freeart / sequence
Created November 15, 2014 15:09
Sequence
function sequence(iterator, arrayList) {
this.iterator = iterator;
this.sequence = arrayList || [];
}
sequence.prototype.next = function (cb) {
var self = this;
if (self.sequence.length == 0){
return setImmediate(cb, null, null);
}
@freeart
freeart / index.js
Created November 15, 2014 14:02
parser
var cluster = require('cluster');
var os = require('os');
var async = require('async');
var strftime = require('strftime');
var argv = require('yargs').argv;
var config = require(__dirname + '/config/' + argv.conf + '.json');
var logger = {
trace: function () {
//var args = Array.prototype.slice.call(arguments);
var expect = require('chai').expect;
var UUID = require('./uuid-v5');
describe('When generating a uuid v5', function() {
it('must generate the expected uuids from 3 examples on the web', function() {
var testUrl = UUID.v5(UUID.URL, 'www.example.org');
var testDns = UUID.v5(UUID.DNS, 'www.example.org');
var testDns2 = UUID.v5(UUID.DNS, 'php.net');
// see the examples here: http://jsfiddle.net/rexmac/F3pwA/
expect(testDns).to.equal('74738ff5-5367-5958-9aee-98fffdcd1876');
expect(testUrl).to.equal('abe19220-c90c-5288-b33a-58772250d428');
sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3
sudo su -l postgres
psql -d template1 -p 5433
CREATE EXTENSION IF NOT EXISTS hstore;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
\q
/usr/lib/postgresql/9.3/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.3/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.3/main/ -O "-c config_file=/etc/postgresql/9.3/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"
@freeart
freeart / collision.html
Created June 16, 2011 20:42
Detect colision of absolute position div
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="http://code.jquery.com/jquery-1.6.1.js" type="text/javascript"></script>
<style media="all" type="text/css">
.target
{
position: absolute;
@freeart
freeart / module.js
Created February 21, 2011 20:03
примеры кода
if (!window["App"]) throw new Error("Critical Error in Application");
(function m(App) {
//===========================================================================================================
function lib() {
var _windowContainer = null,
_guid = null,