Skip to content

Instantly share code, notes, and snippets.

View nkbt's full-sized avatar
💚

Nikita Butenko nkbt

💚
View GitHub Profile
@nkbt
nkbt / passport.js
Created February 28, 2014 13:38
Passport.js usage example
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 / passport-routes.js
Created February 28, 2014 13:39
Passport.js Routes
"use strict";
var passport = require('./passport');
var config = {
redirectBack: redirectBack
}
function redirectBack(req, res) {
res.redirect(req.param('__back') && decodeURIComponent(req.param('__back')) || '/');
}
@nkbt
nkbt / passport-config.js
Created February 28, 2014 13:44
Passport.js config
"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 / .bashrc
Last active February 4, 2016 15:34
.bashrc with git helpers and deployment
# .bashrc
PS1="\[\033[1;30m\][\[\033[1;34m\]\u\[\033[1;30m\]@\[\033[0;35m\]\h\[\033[1;30m\]] \[\033[0;37m\]\W \[\033[1;30m\]\$\[\033[0m\] "
export PATH=~/npm/bin:$PATH
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
@nkbt
nkbt / circular-require.md
Last active August 29, 2015 14:03
Circular dependency in NodeJS

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

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

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

function UserModel() {
}
@nkbt
nkbt / hammers
Created October 20, 2014 02:30
Nobody really buys hammers anymore.
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 January 7, 2015 06:14
Simple way to load legacy dependency with Webpack for tests
/*
Example of legacy lib
./legacy_lib.js
*/
App = App || {};
App.Tool = function () {
};
@nkbt
nkbt / .eslintrc.js
Last active April 23, 2024 03:19
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {

Before each

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

# 2. check version
node -v

# 3. remove node_modules
@nkbt
nkbt / aws-api.md
Last active August 29, 2015 14:26

Working with AWS makes me feel like coding in AST.

var params = {
  TableName: 'Table',
  AttributesToGet: [
    'BucketId',
    'BucketKey'
  ],
 KeyConditions: {