Skip to content

Instantly share code, notes, and snippets.

View caligo-mentis's full-sized avatar

Andrey Ivashchenko caligo-mentis

View GitHub Profile
@caligo-mentis
caligo-mentis / toJSONSpec.js
Created November 11, 2011 08:50
toJSON spec
describe('toJSON', function() {
var Address = SC.Resource.define({
schema: {
city: String,
}
});
var Person = SC.Resource.define({
schema: {
id: Number,
App.SelectableCollectionView = Ember.CollectionView.extend({
selected: null,
itemViewClass: Ember.View.extend({
attributeBindings: ['isSelected'],
isSelected: Ember.computed(function() {
return this.get('content') === this.getPath('parentView.selected');
}).property('parentView.selected').cacheable(),
@caligo-mentis
caligo-mentis / adapter.js
Created October 1, 2012 06:57
Fragment of ember.js data adapter which ask for data after commit
createRecord: function(store, type, model) {
var primaryKey = get(model, 'primaryKey');
var url = this.urlFor(type);
var id = this.nextUUID();
var data = model.toJSON();
data[primaryKey] = id;
return this.ajax(url + "/create", "POST", { data: JSON.stringify(data), contentType: 'application/json' }).pipe(function(json) {
var filter = {};
<?xml version="1.0" encoding="UTF-8"?>
<name>log</name>
<data>
<row>
<timestamp type="datetime">2014-07-01T09:30:10Z</timestamp>
<message type="string">First message</message>
</row>
<row>
<timestamp type="datetime">2014-07-01T09:35:15Z</timestamp>
<message type="string">Second message</message>
@caligo-mentis
caligo-mentis / parallel.js
Created March 3, 2016 09:03
Parallel Queries
var seq = require('nd-seq');
var utils = require('nd-utils');
var mysql = require('mysql');
var map = utils.map;
var identity = utils.identity;
var ensureFunction = utils.ensureFunction;
var config = {
socketPath: '/tmp/mysql.sock',
var lockingStatements = [
[
"INSERT `projects` (`projects`.`title`) VALUES ('Project 1')",
function(ids) {
return "INSERT `tasks` (`tasks`.`title`, `tasks`.`project_id`) VALUES ('Task 1.1', " + ids[0] + ")";
},
function(ids) {
return "INSERT `tasks` (`tasks`.`title`, `tasks`.`project_id`) VALUES ('Task 1.2', " + ids[0] + ")";
},
var SmartBus = require('smart-bus');
var bus = new SmartBus({
subnet: 1,
id: 50, // Device id for connector
gateway: '192.168.10.152', // HDL SmartBus gateway IP
port: 6000 // Listening port, default: 6000
});
bus.socket.on('listening', function() {
@caligo-mentis
caligo-mentis / mocha-uncaught-exception.js
Created June 9, 2016 07:30
Test uncaught exception with mocha tests runner
var should = require('should');
describe('uncaught exception', function() {
describe('with interception', function() {
var listeners;
beforeEach(function() {
listeners = process.listeners('uncaughtException');
process.removeAllListeners('uncaughtException');
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">