Skip to content

Instantly share code, notes, and snippets.

View pavlo-yuriychuk's full-sized avatar

Pavlo Yuriychuk pavlo-yuriychuk

View GitHub Profile
@pavlo-yuriychuk
pavlo-yuriychuk / Service.js
Created June 4, 2015 13:11
Angular service
'use strict';
angular.constant('Environment', {
ROOT_URL: 'https://api.harmonic.com/v1'
});
angular.factory('Services', ['Environment', 'lodash', '$resource', function (Environment, lodash, $resource) {
return $resource(Environment.ROOT_URL, {
get: {
@pavlo-yuriychuk
pavlo-yuriychuk / database-cleanup.js
Created January 30, 2015 12:38
Morning@Lohika, Lviv
'use strict';
var should = require('should'),
modules = require('../index.js'),
models = modules.models,
fixtures = modules.fixtures,
MyModel = models.myModel;
describe('Cleanup Database', function() {
before(function(done) {
@pavlo-yuriychuk
pavlo-yuriychuk / .bashrc
Created November 12, 2014 07:45
Environment setup
[ -s $HOME/.nvm/nvm.sh ] && . $HOME/.nvm/nvm.sh # This loads NVM
@pavlo-yuriychuk
pavlo-yuriychuk / step1.sh
Last active August 29, 2015 14:08
Angular.js courses - Lesson1
\curl -sSL https://get.rvm.io | bash -s stable
source ~/.bash_profile
rvm install ruby-2.1.3 --binary
rvm use 2.1.3
gem install compass
curl https://raw.githubusercontent.com/creationix/nvm/v0.18.0/install.sh | bash
source ~/.nvm/nvm.sh
npm install -g generator-angular
yo angular
npm install
@pavlo-yuriychuk
pavlo-yuriychuk / connections.js
Created July 24, 2014 15:28
Connections, Sessions, Users
var _ = require('lodash');
var connections = {};
var sessions = {};
var users = {};
function registerConnection(id, socket) {
connections[id] = {
id: id,
socket: socket,
var _ = require('lodash');
function Trie() {
this.root = {};
}
Trie.prototype.add = function (string, root) {
var hasTouched = false;
root = root || this.root;
if (string) {
@pavlo-yuriychuk
pavlo-yuriychuk / .bowerrc
Created April 15, 2014 13:58
Proper bower configuration
{
"directory" : "app/bower_components",
"json" : "bower.json",
"storage": {
"packages": ".bower-cache",
"registry": ".bower-registry"
},
"tmp": ".bower-tmp"
}
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
@pavlo-yuriychuk
pavlo-yuriychuk / app-skeleton.js
Created October 22, 2013 20:05
Sample angular app main file skeleton
"use sctrict";
angular.
module("App", ["module1", "module2", "module3"]).
config(["providerName1Provider", "providerName2Provider", function (providerName1Provider, providerName2Provider) {
// Configuration and initialization code here
// Routes
// Initialization of i18n anf i10n
}]).
run(["providerName1", "providerName2", function (providerName1, providerName2) {
@pavlo-yuriychuk
pavlo-yuriychuk / loader.js
Created July 30, 2013 05:44
Chaplin module loader implementation
define(["jquery"], function ($) {
"use strict";
function load(name, config) {
var deferred = $.Deferred();
require([name], function (Module) {
var instance = new Module();
instance.configure(config);
deferred.resolve(instance.export());