Skip to content

Instantly share code, notes, and snippets.

View Dev-Dipesh's full-sized avatar

Dipesh Bhardwaj Dev-Dipesh

  • The Contentment Foundation
  • San Francisco, California
View GitHub Profile
@Dev-Dipesh
Dev-Dipesh / kue_issues_debugging.md
Last active October 24, 2016 07:00
Kue (priority job queue) error debugging and repairs - Thanks to @dfoody ( https://github.com/dfoody )

Issue: Automattic/kue#130

Here's the rough set of steps we typically follow to repair various kue issues we see regularly: (note that some of these apply only to our fork - that has the ability to do "locks" so jobs for - in our case - a single user are serialized (users are differentiated based on their email address).

Failed Jobs Not Showing When there are failed jobs (the sidebar says non-zero), but none show in the list, use the follow this procedure to repair them:

@Dev-Dipesh
Dev-Dipesh / go-redis-amz-ami.md
Last active June 24, 2020 20:33
Golang and Redis Setup on Amazon 64 bit AMI Linux

Update Server

sudo yum -y update
sudo yum -y install gcc make

Golang Installation

Download Go binary

@Dev-Dipesh
Dev-Dipesh / nginx-ssl.md
Last active March 21, 2023 19:14
Setting SSL/TLS in Nginx Using Godaddy as CA Provider

CA PROVIDER - GODADDY

Certificates

Ones you have generated, downloaded and extracted the certificate zip, you will find 2 files in it:

  • gd_bundle-g2-g1.crt Intermediate Certificate
  • RANDOM_NUM.crt Your SSL Certificate

Creating single chained certificate

/**
* GET /api/scraping
* Web scraping example using Cheerio library.
*/
exports.getScraping = function(req, res, next) {
cheerio = require('cheerio');
request = require('request');
request.get('https://news.ycombinator.com/', function(err, request, body) {
if (err) return next(err);
@Dev-Dipesh
Dev-Dipesh / ELK with Nginx.md
Last active January 24, 2024 14:34
Setting up Elasticsearch, Logstash and Kibana with Nginx.

ELK (Elasticsearch Logstash Kibana)

Though we're focused more on server setup procedure in this document, I will still give a very brief explanation in laymen terms for ELK. To those who are starting new in this stack, must have already heard of MVC (Model View Controller), so take it like this:

  • Model => Elasticsearch (for Storage, Indexing & Search)
  • View => Kibana (for DataViz & G-Man, yeah the one in half life 😏)
  • Controller => Logstash (For Logs & Filtering)

const server = restify.createServer();
const https_server = restify.createServer({
certificate: fs.readFileSync('certs/ca.crt'),
key: fs.readFileSync('certs/key.pem'),
name: 'Sellnews-Trends',
}, err => {
console.log(err, err.stack);
});
const setup_server = function(server) {
@Dev-Dipesh
Dev-Dipesh / skeleton-daemon.sh
Created June 20, 2016 06:21 — forked from shawnrice/skeleton-daemon.sh
A template to write a quick daemon as a bash script
#!/bin/sh
# This is a skeleton of a bash daemon. To use for yourself, just set the
# daemonName variable and then enter in the commands to run in the doCommands
# function. Modify the variables just below to fit your preference.
daemonName="DAEMON-NAME"
pidDir="."
pidFile="$pidDir/$daemonName.pid"
@Dev-Dipesh
Dev-Dipesh / cb-views-automate.js
Last active June 16, 2016 09:49
Create Couchbase Views on the fly. Automate the view creation process in Couchbase.
/**
* Create Couchbase Views on the fly
* v1.0.0 June 15, 2016
* Dipesh Bhardwaj
* Code Style - ES6 Javascript | ES Lint | AirBnB Arrow Functions
* This script contains example for sample beer bucket, which comes
* pre-loaded with Couchbase.
* Create a `startupCheck.js` script in your application, if not already exist
* and call this script through it to create all your Couchbase views
* during app initialization. This script first checks if the views are already
@Dev-Dipesh
Dev-Dipesh / node-on-ec2-port-80.md
Created May 24, 2016 12:34 — forked from kentbrew/node-on-ec2-port-80.md
How I Got Node.js Talking on EC2's Port 80

The Problem

Standard practices say no non-root process gets to talk to the Internet on a port less than 1024. How, then, could I get Node talking on port 80 on EC2? (I wanted it to go as fast as possible and use the smallest possible share of my teeny tiny little micro-instance's resources, so proxying through nginx or Apache seemed suboptimal.)

The temptingly easy but ultimately wrong solution:

Alter the port the script talks to from 8000 to 80:

}).listen(80);
@Dev-Dipesh
Dev-Dipesh / .adoc File Syntax
Created May 20, 2016 08:30
ASCII Doctor .adoc file syntax from - http://asciidoctor.org
= AsciiDoc Article Title
Firstname Lastname <author@asciidoctor.org>
1.0, July 29, 2014, Asciidoctor 1.5 article template
:toc:
:icons: font
:quick-uri: http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/
Content entered directly below the header but before the first section heading is called the preamble.
== First level heading