Skip to content

Instantly share code, notes, and snippets.

View listochkin's full-sized avatar

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

View GitHub Profile
@listochkin
listochkin / README.md
Last active August 29, 2015 14:08
Set up iojs environment for Node API class

Instructions

If you

  • run Mac OS X or Linux
  • have iojs installed ($ node -v prints v2.0.1)
  • can bulid binary Node packages (npm install ws doesn't fail)

then you can skip all the steps below.

Установка Node и NPM

Для воркшопа nodeschool необходимо установить платформу node.js и пакетный менеджер npm.

для Windows, MacOS самый простой способ установки через официальный сайт в автоматическом режиме, нажав на кнопку Install.

для Linux/Unix систем самый надежный способ через командную строку, использую подходы:

@listochkin
listochkin / node-command-line-options.txt
Created April 17, 2014 11:00
Node V8 GC-related options
--log_gc (Log heap samples on garbage collection for the hp2ps tool.)
type: bool default: false
--expose_gc (expose gc extension)
type: bool default: false
--max_new_space_size (max size of the new generation (in kBytes))
type: int default: 0
--max_old_space_size (max size of the old generation (in Mbytes))
type: int default: 0
--max_executable_size (max size of executable memory (in Mbytes))
type: int default: 0
* {
font-family: 'Source Code Pro';
}
p {
font-size: 30px;
color: gray;
}
input {
@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';
@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 / 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 / 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 / javascript-static-analysis-tools.md
Created August 16, 2013 13:52
JavaScript Static Analysis Tools

JavaScript Static Analysis Tools

Most people are familiar with these three tools:

  1. [JSHint][1]
  2. [JSLint][2]
  3. [Google Closure Linter][3]

The first one is more popular among developers because it is style-agnostic. The other two enforce rules of [Crockford Style][4] and [Google Code Style][5] respectively.