Skip to content

Instantly share code, notes, and snippets.

View listochkin's full-sized avatar

Андрей Листочкин (Andrei Listochkin) listochkin

View GitHub Profile
@listochkin
listochkin / socket.io-client.js
Created March 5, 2013 15:13
Dist version of Socket.IO-client
/*! Socket.IO.js build:0.9.11, development. Copyright(c) 2011 LearnBoost <dev@learnboost.com> MIT Licensed */
var io = ('undefined' === typeof module ? {} : module.exports);
(function() {
/**
* socket.io
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
@listochkin
listochkin / ember-data.js
Created March 28, 2013 19:49
Ember Data, API rev 12, build: 5fd6d65 (2013-03-28 01:13:50 +0100),
// Last commit: 5fd6d65 (2013-03-28 01:13:50 +0100)
(function() {
window.DS = Ember.Namespace.create({
// this one goes past 11
CURRENT_API_REVISION: 12
});
})();
@listochkin
listochkin / bootstrap-2.3.1.all.js
Created March 30, 2013 06:29
bootstrap-2.3.1.js in a single file
/* ===================================================
* bootstrap-transition.js v2.3.1
* http://twitter.github.com/bootstrap/javascript.html#transitions
* ===================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
@listochkin
listochkin / domains.irc.log
Last active December 16, 2015 03:09
Forrest L Norvell describes Domains in Node
02:15:46 (listochkin) how do I know if my current callback is running in a domain?
02:16:17 (Remy) listochkin: can you clarify ?
02:19:35 (listochkin) Remy: I mean, suppose I have a module A that does something potentially dangerous. I want to wrap a function in that module in a domain dA. Now suppose I require that module A from module B. And inside that module I've already created a domain dB. What I want is to use dB inside of A instead of creating an extra domain dA since my code is now protected by that external domain. Is it possible and is it a good idea?
02:25:24 (ChrisPartridge) listochkin: then don't put the domain in module A, just have it in module B
02:27:07 (listochkin) ChrisPartridge: what if A is my module and B is someone else's app?
02:33:48 (listochkin) Remy, ChrisPartridge: so, guys any ideas about my nested domains question?
02:33:51 (ChrisPartridge) listochkin: in that case I'm not too sure, I think domains should be used in the application context, not so much in every module - I could
@listochkin
listochkin / node-cluster-and-domains.md
Created April 17, 2013 11:12
Node Cluster and Domains. Links.

Cluster: helps running and coordinating several Node processes:

  1. [API][1].
  2. Module to get started easily: [cluster-master][2].

Domains: help keeping your Node process up and running by catching unhandled errors:

  1. [API][3].
  2. Read [the example code][4] to understand the basic workflow of domains.
  3. Module to get started easier: [domain-http-server][5].
@listochkin
listochkin / jquery-2.0.0.js
Created April 22, 2013 12:15
jQuery 2.0 custom build: no sizzle, effects, and aliases, XHR-only Ajax
/*!
* jQuery JavaScript Library v2.0.0 -sizzle,-event-alias,-ajax/script,-ajax/jsonp,-effects,-deprecated
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/
*
* Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors
* Released under the MIT license
* http://jquery.org/license
@listochkin
listochkin / domain-sample.js
Last active December 21, 2015 15:29
Simple domain example
var server = http.createServer(function(req, res) {
var requestDomain = domain.create();
var sentError = false;
requestDomain.on('error', function(error) {
console.error('Request error', error.stack);
try {
server.close();
shutdown();
if (!sentError) {
sentError = true;
@listochkin
listochkin / domain.js
Last active December 21, 2015 15:29 — forked from iliakan/domain.js
var domain = require('domain');
var mysql = require('mysql');
var pool = mysql.createPool({
host: '127.0.0.1',
port: 3306,
database: 'test',
user: 'localuser',
password: 'localpass',
});
@listochkin
listochkin / fixture-adapter-find-query-support.js
Created September 4, 2013 08:49
Support for App.Person.find({name: 'Tom'})
App.Store = DS.Store.extend({
adapter: DS.FixtureAdapter.extend({
queryFixtures: function(fixtures, query, type) {
return fixtures.filter(function (fixture) {
for (var key in query) {
if (fixture[key] != query[key]) // type coercion required
return false;
}
return true;
});
@listochkin
listochkin / instructions.js
Created September 10, 2013 08:28
Phone Number formatting with RegExps
// Let's say we have US phone numbers in forms:
// 1222333444 and 2223334444
//
// We need to format them in a form:
// 1-(222)-333-4444
// Step 1: prepend phone number with '1' if it's in a short form:
var phone = '2223334444';