Skip to content

Instantly share code, notes, and snippets.

Avatar

Nikita Butenko nkbt

View GitHub Profile
View app.lib.payment.js
it('should return error if at least one domain is unavailable', function (done) {
nock(test.mock.user)
.intercept('/info', 'SEARCH', {"count": 100, "query": "data.name:\"test.test\" AND type:\"domain\" AND name:\"reseller.pb\""})
.replyWithFile(200, __dirname + '/fixtures/info/found.json');
nock(test.mock.admin)
.get('/user/aaaa11112222333344445555', {})
.replyWithFile(200, __dirname + '/fixtures/user/_nkbt.json');
View async-auto.js
var _ = require('underscore');
var async = require('async');
async.auto({
first: function(next) {
setTimeout(next, 500);
},
second: function(next) {
setTimeout(next, 700);
},
@nkbt
nkbt / passport-config.js
Created Feb 28, 2014
Passport.js config
View passport-config.js
"apps": {
"twitter": {
"consumerKey": "1234",
"consumerSecret": "1234",
"callbackURL": "http://localhost/auth/twitter/callback"
},
"linkedin": {
"consumerKey": "1234",
"consumerSecret": "1234",
"callbackURL": "http://localhost/auth/linkedin/callback"
@nkbt
nkbt / passport.js
Created Feb 28, 2014
Passport.js usage example
View passport.js
ar TwitterStrategy = require('passport-twitter').Strategy;
var FacebookStrategy = require('passport-facebook').Strategy;
var LinkedinStrategy = require('passport-linkedin').Strategy;
var passport = require('passport');
var _ = require('underscore');
var configurable = require('configurable-module');
function configure(options) {
@nkbt
nkbt / circular-require.md
Last active Aug 29, 2015
Circular dependency in NodeJS
View circular-require.md

Может и баян старый, но я тут наступил сегодня: циклические зависимости в ноде резолвятся в пустой объект. Вот немного сильно упрощенного кода.

Есть модуль models/user:

var api = require('../lib/api');

function UserModel() {
}
@nkbt
nkbt / hammers
Created Oct 20, 2014
Nobody really buys hammers anymore.
View hammers
Let's pretend I've decided to build a spice rack.
I've done small woodworking projects before, and I think I have a pretty good idea of what I need: some wood and a few basic tools: a tape measure, a saw, a level, and a hammer.
If I were going to build a whole house, rather than just a spice rack, I'd still need a tape measure, a saw, a level, and a hammer (among other things).
So I go to the hardware store to buy the tools, and I ask the sales clerk where I can find a hammer.
"A hammer?" he asks. "Nobody really buys hammers anymore. They're kind of old fashioned."
@nkbt
nkbt / legacy_lib_spec.js
Created Jan 7, 2015
Simple way to load legacy dependency with Webpack for tests
View legacy_lib_spec.js
/*
Example of legacy lib
./legacy_lib.js
*/
App = App || {};
App.Tool = function () {
};
View jest.md

Before each

# 1. use <version>
nvm use <version>

# 2. check version
node -v

# 3. remove node_modules
View aws-api.md

Working with AWS makes me feel like coding in AST.

var params = {
  TableName: 'Table',
  AttributesToGet: [
    'BucketId',
    'BucketKey'
  ],
  KeyConditions: {
View parallelshell.md
✔ ~/nkbt/react-component-template [master|✔] 
13:25 $ `npm bin`/parallelshell '`npm bin`/eslint .' '`npm bin`/karma start ./karma.conf.js --single-run --reporters coverage'

fs.js:691
  return binding.lstat(pathModule._makeLong(path));
                 ^
Error: ENOENT, no such file or directory '/Users/nkbt/nkbt/react-component-template/reports/coverage/prettify.js'
    at Object.fs.lstatSync (fs.js:691:18)
    at Object.realpathSync (fs.js:1279:21)
You can’t perform that action at this time.