Skip to content

Instantly share code, notes, and snippets.

View catacs's full-sized avatar

Catalin Stanciu catacs

View GitHub Profile
@catacs
catacs / system-backup
Last active February 7, 2016 23:38
Entire system backup
#!/bin/bash
cd /
tar cvpzf system-backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/system-backup.tgz --exclude=/mnt --exclude=/tmp --exclude=/sys /
@catacs
catacs / fail2ban-report
Created February 8, 2016 20:57
Fail2ban log statistics
#!/bin/bash
echo "Baned last log"
awk '($(NF-1) = /Ban/){print $NF}' /var/log/fail2ban.log | sort | uniq -c | sort -n
echo "------------ Baned in all files --------------"
zgrep -h "Ban " /var/log/fail2ban.log* | awk '{print $NF}' | sort | uniq -c
echo "------------ Baned by subnet --------------------"
zgrep -h "Ban " /var/log/fail2ban.log* | awk '{print $NF}' | awk -F\. '{print $1"."$2"."}' | sort | uniq -c | sort -n | tail
echo "------------ Baned by date -------------------------"
zgrep -h "Ban " /var/log/fail2ban.log* | awk '{print $5,$1}' | sort | uniq -c
@catacs
catacs / class.js
Created February 15, 2016 15:38
Class pattern javascipt
// Constructor
var Class = function (value1, value2) {
this.value1 = value1;
};
// properties and methods
Class.prototype = {
value1: 'default_value',
method: function (argument) {
this.value2 = argument + 100;
@catacs
catacs / factory.js
Created February 15, 2016 15:38
Factory pattern javascript
// Constructor
var Class = function(value1, value2) { }
// Factory
Class.factory(value1) {
return new Class(value1, 'aaa');
};
// properties and methods
Class.prototype = { ... };
@catacs
catacs / singleton.js
Created February 15, 2016 15:40
Singleton pattern javascript
var Singleton = (function () {
var privateVariable = 'value';
function privateFunction() {
}
function publicFunction() {
}
return {
@catacs
catacs / mongo-c-driver.md
Last active March 8, 2016 21:16
MongoDB driver for C

Centos 6.7

export PKG_CONFIG_PATH=/usr/lib64/pkgconfig:/usr/src/mongo-c-driver-1.3.3/src/:/usr/local/lib/pkgconfig/

@catacs
catacs / body-parameters-node.js
Last active April 22, 2017 19:34
How to get body parameters in node.js
const bodyParser = require('body-parser');
const express = require('express');
const app = express();
const multer = require('multer');
const upload = multer();
app.use(bodyParser.json());
var router = express.Router();