Skip to content

Instantly share code, notes, and snippets.

View astromahi's full-sized avatar

Mahendran Kathirvel astromahi

View GitHub Profile
@caraboides
caraboides / backup-mongodb-to-s3.sh
Last active August 2, 2023 06:11
Simple script to backup MongoDB to S3, without waste diskspace for temp files. And a way to restore from the latest snapshot.
#!/bin/sh
set -e
HOST=localhost
DB=test-entd-products
COL=asimproducts
S3PATH="s3://mongodb-backups-test1-entd/$DB/$COL/"
S3BACKUP=$S3PATH`date +"%Y%m%d_%H%M%S"`.dump.gz
S3LATEST=$S3PATH"latest".dump.gz
/usr/bin/aws s3 mb $S3PATH
@uorat
uorat / nginx-websocket-proxy.conf
Last active February 11, 2023 16:04
Nginx Reverse Proxy for WebSocket
upstream websocket {
server localhost:3000;
}
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/websocket.access.log main;
@Stoffo
Stoffo / remove_documents_mongodb.js
Created October 29, 2015 12:29
Remove Documents older than x days in MongoDB
var date = new Date();
var daysToDeletion = 120;
var deletionDate = new Date(date.setDate(date.getDate() - daysToDeletion));
printjson(deletionDate);
var db = db.getSiblingDB('db')
db.getMongo().setSlaveOk();
printjson(db.messages.find({insertDate : {$lt : deletionDate}}).count());
@icholy
icholy / goi.md
Last active August 31, 2017 03:17

Interfaces

Let's imagine a very simple table

CREATE TABLE people {
  id bigserial,
  name character varying
}
package main
import (
"fmt"
"log"
"net/http"
"html/template"
"github.com/gorilla/sessions"
@bryfry
bryfry / gzip.go
Last active August 28, 2023 09:23
Idiomatic golang net/http gzip transparent compression (works with Alice)
package main
import (
"compress/gzip"
"io"
"net/http"
"strings"
)
// Gzip Compression
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active April 20, 2024 16:52
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@chrisgillis
chrisgillis / ssl_smtp_example.go
Created April 16, 2014 14:48
Golang SSL SMTP Example
package main
import (
"fmt"
"log"
"net"
"net/mail"
"net/smtp"
"crypto/tls"
)
@mschoebel
mschoebel / main.go
Created March 6, 2014 20:02
Snippet: login/logout (Golang)
package main
import (
"fmt"
"github.com/gorilla/mux"
"github.com/gorilla/securecookie"
"net/http"
)
// cookie handling
@leesmith
leesmith / simple-git-workflow.md
Last active December 30, 2023 23:37
Simple Git Workflow For Continuous Delivery

Simple Git Workflow For Continuous Delivery

Workflow guidelines:

  • master branch is always production-ready, deployable, 100% green test suite
  • New development is done on feature branches, with frequent rebasing onto master
  • Clean commit history by preferring to rebase instead of merge (git pull is configured to automatically rebase)

rebase workflow

Workflow