Skip to content

Instantly share code, notes, and snippets.

View ardiesaeidi's full-sized avatar

Ardalan Saeidi ardiesaeidi

View GitHub Profile
@ardiesaeidi
ardiesaeidi / aws_ec2_wait.sh
Created April 28, 2020 21:58 — forked from sgnn7/aws_ec2_wait.sh
Wait for AWS EC2 snapshot or volume for longer than 20 mins
#!/bin/bash -e
EC2_REGION="us-west-1"
DEFAULT_PROGRESS_WAIT=5
# ========== SNAPSHOT WAIT ==============
snapshot_id="snap-testtesttest"
while [ "$snapshot_progress" != "100%" ]; do
sleep "$DEFAULT_PROGRESS_WAIT"
@ardiesaeidi
ardiesaeidi / logger.js
Created April 18, 2020 06:17 — forked from xeoncross/logger.js
Expressjs Server Monitoring with Winston + Morgan
const { createLogger, format, transports } = require("winston");
// https://github.com/winstonjs/winston#logging
// { error: 0, warn: 1, info: 2, verbose: 3, debug: 4, silly: 5 }
const level = process.env.LOG_LEVEL || "debug";
function formatParams(info) {
const { timestamp, level, message, ...args } = info;
const ts = timestamp.slice(0, 19).replace("T", " ");
@ardiesaeidi
ardiesaeidi / 2019-https-localhost.md
Created March 19, 2020 07:16 — forked from cecilemuller/2019-https-localhost.md
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@ardiesaeidi
ardiesaeidi / aws-ec2-redis-cli.md
Created April 18, 2019 07:59 — forked from paladini/aws-ec2-redis-cli.md
AWS redis-cli without redis server on AWS EC2

Setup redis-cli without the whole Redis Server on AWS EC2

This fast tutorial will teach you how to install redis-clion AWS EC2 without having to install the whole Redis Server. Firstly, SSH into your EC2 instance and run the following command:

$ sudo yum install gcc

This may return an "already installed" message, but that's OK. After that, just run:

$ wget http://download.redis.io/redis-stable.tar.gz && tar xvzf redis-stable.tar.gz && cd redis-stable && make && sudo cp src/redis-cli /usr/local/bin/ && sudo chmod 755 /usr/local/bin/redis-cli

@ardiesaeidi
ardiesaeidi / ETagMiddleware.cs
Created January 1, 2018 22:13 — forked from madskristensen/ETagMiddleware.cs
ASP.NET Core ETAg middleware
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Net.Http.Headers;
using System.IO;
using System.Security.Cryptography;
using System.Threading.Tasks;
public class ETagMiddleware
{
@ardiesaeidi
ardiesaeidi / .bash_profile
Created August 2, 2017 22:47 — forked from ahawthorne/.bash_profile
OSX ssh-agent forwarding -> .bash_profile
#####################
# ssh-agent stuff #
#####################
# get the ssh agent started
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
@ardiesaeidi
ardiesaeidi / nginx.conf
Created July 18, 2017 06:42 — forked from nateware/nginx.conf
Nginx sample config for EC2
#
# Sample nginx.conf optimized for EC2 c1.medium to xlarge instances.
# Also look at the haproxy.conf file for how the backend is balanced.
#
user "nginx" "nginx";
worker_processes 10;
error_log /var/log/nginx_error.log info;
@ardiesaeidi
ardiesaeidi / snippet.js
Created June 20, 2016 07:44 — forked from necolas/snippet.js
Optimised async loading of cross-domain scripts
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
@ardiesaeidi
ardiesaeidi / config.json
Created May 23, 2016 08:26 — forked from anonymous/config.json
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
@ardiesaeidi
ardiesaeidi / boot.js
Last active August 29, 2015 14:24 — forked from jdx/boot.js
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run