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 Parser( text ) { | |
EventEmitter.call(this); | |
var parent = this; | |
this.text = text; | |
// Счётчик выполненных функций | |
this.done = 0; | |
// Проверяем все ли функции выполнены для передачи результата | |
this.on('done', function(where) { | |
// Если счётчик < 0 то вызываем событие end и отдаём результат | |
if(!done) emit('end', this.text); |
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
// we need the fs module for moving the uploaded files | |
var fs = require('fs'), | |
EventEmitter = require('events').EventEmitter; | |
var uploadQueue = new EventEmitter(); | |
uploadQueue.on('upload', function(tmp_path, target_path) { | |
// move the file from the temporary location to the intended location | |
fs.rename(tmp_path, target_path, function(err) { | |
if (err) throw err; | |
// delete the temporary file, so that the explicitly set temporary upload dir does not get filled with unwanted files |
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 express = require('express'), | |
// стандартные либы | |
http = require('http'), | |
path = require('path'), | |
// подключаем mongodb | |
MongoClient = require('mongodb').MongoClient, | |
// ObjectID | |
ObjectID = require('mongodb').ObjectID; | |
// Подключаемся к БД |
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
/** | |
* Encrypt given plain text using the key with RC4 algorithm. | |
* All parameters and return value are in binary format. | |
* | |
* @param string key - secret key for encryption | |
* @param string pt - plain text to be encrypted | |
* @return string | |
*/ | |
exports = module.exports = function rc4(key, pt) { | |
s = new Array(); |
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
// RC4 PRIVATE KEY | |
var key = '123456789'; | |
var file = 'test123456'; | |
// Encrypt | |
var crypto = require('crypto'); | |
var cipher = crypto.createCipher('aes-256-cbc', key); | |
var encfile = cipher.update(file, 'utf8', 'hex'); | |
encfile += cipher.final('hex'); |
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
#!/usr/bin/node | |
function cb(data) { | |
console.log('[>] Выполнена задача', data); | |
} | |
function empty() { | |
console.log('[!] Очередь пуста (выполняется последнее задание)'); | |
} | |
function drain() { | |
console.log('[!] Все задания выполнены (последнее задание выполнено)'); |
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
{ | |
"success": true, | |
"code": 200, | |
"stats": [{ | |
"day": "2015-05-22", | |
"views": 1, | |
"visitors": 1, | |
"reach": 1, | |
"reach_subscribers": 0, | |
"subscribed": null, |
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 App\Exceptions; | |
use Exception; | |
use Illuminate\Auth\Access\AuthorizationException; | |
use Symfony\Component\HttpKernel\Exception\HttpException; | |
use Illuminate\Validation\ValidationException; | |
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | |
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; |
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
# Запрещаем листинг директории | |
Options -Indexes | |
# Здесь мы запрещаем доступ из веба к файлам с расширениями | |
<FilesMatch "\.(php|cgi|pl|php|php3|php4|php5|php6|php7|phps|phtml|shtml|py|phtml|pl|asp|aspx|cgi|dll|exe|ico|shtm|shtml|fcg|fcgi|fpl|asmx|pht|py|psp)$"> | |
Order allow,deny | |
Deny from all | |
</FilesMatch> | |
# Ниже мы говорим, что данные расширения отдавать как текст, чтобы не выполнять как исполняемые файлы |
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
#!/bin/bash | |
apt update && apt upgrade -y && apt install -y mc htop curl git | |
# swap | |
fallocate -l 4G /swapfile | |
chmod 600 /swapfile | |
mkswap /swapfile | |
swapon /swapfile | |
echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab |
OlderNewer