This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var | |
arrayPop = Array.prototype.pop, | |
arrayPush = Array.prototype.push, | |
arrayReverse = Array.prototype.reverse, | |
arrayShift = Array.prototype.shift, | |
arraySort = Array.prototype.sort, | |
arraySplice = Array.prototype.splice, | |
arrayUnshift = Array.prototype.unshift; | |
var Arr = function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var List = function(data, el, itemTamplate) { | |
if (! data instanceof Arr) { | |
throw new Error('data should be an instance of Arr'); | |
} | |
if (! el instanceof HTMLElement) { | |
throw new Error('el should be an instanceof of HTMLElement'); | |
} | |
if (typeof itemTamplate !== 'string') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var navItems = new Arr( | |
{ | |
name: 'Home', | |
path: '/' | |
}, | |
{ | |
name: 'About Us', | |
path: '/aboutus', | |
active: true | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Db; | |
class Db { | |
private $connection; | |
public function __construct(\PDO $connection) { | |
$connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
router.post('/upload', | |
[ multer({ | |
dest: path.join(__dirname, '..', config.imagesUplodsPath), | |
rename: function (fieldname, filename) { | |
return filename.replace(/\W+/g, '-').toLowerCase() + Date.now() | |
} | |
}) ], | |
function(req, res, next) { | |
res.json({ | |
success: true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// passport | |
passport.use(new LocalStrategy( | |
function(username, password, next) { | |
userService.findByUsername(username) | |
.then(function(user) { | |
if (! user) { | |
return userService.save({ | |
username: username, | |
password: password | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function observable(obj) { | |
var listeners = {}; | |
// | |
obj.on = function(name, handler) { | |
if (! (name in listeners)) { | |
listeners[name] = []; | |
} | |
listeners[name].push(handler); | |
return this; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var DataList = function(el, data, itemTpl, populateItemDataFn) { | |
if (! (el instanceof Node)) { | |
throw new Error('el should be an Node.'); | |
} | |
if (! (data instanceof Array)) { | |
throw new Error('data should be an Array.'); | |
} | |
if (typeof itemTpl !== 'string') { | |
throw new Error('itemTpl should be an String.'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map $status $loggable { | |
~^[2,3] 0; | |
default 1; | |
} | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server ipv6only=on; | |
server_name ~^(www\.)?(?<domain>.+?).loc$; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": ["es2015", "react"] | |
} |