Skip to content

Instantly share code, notes, and snippets.

View catacs's full-sized avatar

Catalin Stanciu catacs

View GitHub Profile
@catacs
catacs / call_with_curl.md
Last active May 22, 2019 15:33
Asterisk ARI
@catacs
catacs / main.lua
Created August 16, 2018 14:08
Example Firebase Analytics setCurrentScreen
local firebaseAnalytics = require "plugin.firebaseAnalytics"
firebaseAnalytics.init()
local widget = require("widget")
local bg = display.newRect( display.contentCenterX, display.contentCenterY, display.actualContentWidth, display.actualContentHeight )
bg:setFillColor( 1,.5,0 )
local title = display.newText( {text = "Firebase Analytics", fontSize = 30} )
title.width, title.height = 300, 168
title.x, title.y = display.contentCenterX, 168*.5
@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 / 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();
@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 / singleton.js
Created February 15, 2016 15:40
Singleton pattern javascript
var Singleton = (function () {
var privateVariable = 'value';
function privateFunction() {
}
function publicFunction() {
}
return {
@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 = { ... };