Skip to content

Instantly share code, notes, and snippets.

# Redis configuration file example.
#
# Note that in order to read the configuration file, Redis must be
# started with the file path as first argument:
#
# ./redis-server /path/to/redis.conf
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
@akshendra
akshendra / socket-haproxy.conf
Last active July 19, 2022 09:30
Haproxy config for socket server
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
maxconn 16384
tune.ssl.default-dh-param 2048
user haproxy
group haproxy
@akshendra
akshendra / webpack-react.config.js
Last active January 7, 2017 08:16
webpack config for react projects
'use strict';
const p = require('path');
// const webpack = require('webpack');
module.exports = {
// we are going to read from here
entry: p.resolve(__dirname, 'src/app.js'),
// where we gonna spit it out
output: {
@akshendra
akshendra / .eslintrc
Last active January 18, 2019 20:38
Common eslint config
{
"extends": [
"plugin:import/errors",
"plugin:import/warnings"
],
"settings": {
"import/resolver": {
"node": {
"extensions": [".mjs", ".js", ".json"]
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> React + Webpack + Babel </title>
<link href="http://fonts.googleapis.com/css?family=Roboto:400,300,700" rel="stylesheet" type="text/css">
<link href="css/styles.css" rel="stylesheet" type="text/css">
</head>
'use strict';
/**
* =============================================================================================
* A state container
* @exports {Object} Continer
*
* // in the very beginning
* const con = require('container.js')
* con.add('logger', new Logger('log'));
@akshendra
akshendra / qerror.js
Created June 9, 2017 11:11
Extended error
/**
* @class QError
*/
class QError extends Error {
/**
* @param {string} message
* @param {string} [type=error]
* @param {Object} [cause=null] - extra data for debugging
*/
@akshendra
akshendra / ssh-alias-for-aws-ec2.py
Last active December 10, 2017 15:30
Generate ssh aliases for aws ec2 instances
#!/usr/bin/env python3
"""
Create ssh shortcut alias
"""
import boto3
ec2 = boto3.client('ec2')
@akshendra
akshendra / mongo-bulk.js
Created April 17, 2018 06:06
mongo bulk insert
function updateOrUpsertMany(mongo, col, docs) {
const bulk = mongo.colection(col).initializeUnorderedBulkOp();
docs.forEach(doc => {
bulk.find({ _id: doc._id }).upsert().updateOne({ $set: doc });
});
if (docs.length > 0) {
return bulk.execute()
.catch((ex) => {
if (ex.message.indexOf('E11000 duplicate key error collection') !== -1) {
return this.updateOrUpsertMany(mongo, col, docs);
@akshendra
akshendra / cw-ec2:setup.sh
Last active December 24, 2019 11:24
Setup ec2 for sending info to cloudwatch
#!/usr/bin/env bash
# Setup for gathering metrices, debian based
required_env='AWS_REGION, MONITOR_DISKS, MACHINE_NAME';
function checkEnv() {
echo "Checking $1"
local val=$(env | grep "$1")
echo $val