Skip to content

Instantly share code, notes, and snippets.

View Dineshs91's full-sized avatar
🎯
Focusing

DINESH S Dineshs91

🎯
Focusing
  • Security Innovation
  • India
View GitHub Profile
dbClient := datastore.Client
database := dbClient.Database(datastore.DatabaseName)
collection := database.Collection("users")
user_count, _ := collection.FindOne(
context.Background(),
bson.D{},
)
fmt.Println("Number of users", user_count)
@Dineshs91
Dineshs91 / db.go
Last active April 21, 2019 10:45
database connection for go-mongo-driver medium article
package db
import (
"context"
"fmt"
"log"
"os"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
@Dineshs91
Dineshs91 / post_table.md
Last active December 3, 2018 09:25
Post table

Table: Post

Column Type Table Modifiers
id integer not null
title character varying not null
description character varying not null
meta character varying not null
0xe6fcE3877BA7C73e6Acad9F77bDCF2E14A53245c
@Dineshs91
Dineshs91 / add_cron.sh
Last active August 18, 2017 19:24
Add cron job to the provided machines
#! /bin/bash
# Usage:
# sh add_cron.sh [key_file] [user] ip
key_file=$1
username=$2
ip=$3
if [ $# -le 2 ]; then
@Dineshs91
Dineshs91 / File system
Created March 29, 2017 12:44
Simple file system
- Directories
- Files
- Inode
Each inode describes a data structure on the hard disk, storing the properties of a file.
Struct
- Owner, Group Owner of the file.
- File type
- Permissions
@Dineshs91
Dineshs91 / postgres_stats
Last active February 16, 2017 20:26
Postgres stats
## List all indexes
```
SELECT i.relname as indname,
i.relowner as indowner,
idx.indrelid::regclass,
am.amname as indam,
idx.indkey,
ARRAY(
SELECT pg_get_indexdef(idx.indexrelid, k + 1, true)
@Dineshs91
Dineshs91 / README
Last active October 16, 2016 20:39
Backup scripts
## Restoring with tar from a compressed archive.
### Test the command first with 't' argument
tar -ztvpf /archive/full-backup-02-March-2016.tar.gz
### Extract with 'x' argument
tar -zxvpf /archive/full-backup-02-March-2016.tar.gz
@Dineshs91
Dineshs91 / rupee_repr.py
Created September 15, 2015 13:37
Convert given no into rupee representation
# Money in INR(Indian Rupees)
def convert(no):
rev_no = no[::-1]
ans = ''
for index, char in enumerate(rev_no):
ans = char + ans
if index >= 2 and index % 2 == 0 and len(no) > index + 1:
ans = ',' + ans
@Dineshs91
Dineshs91 / FizzBuzz
Created June 19, 2015 18:01
FizzBuzz using match in rust
# Method 1
fn main() {
for x in 1..101 {
match x {
x if x % 15 == 0 => println!("{} FizzBuzz", x),
x if x % 5 == 0 => println!("{} Buzz", x),
x if x % 3 == 0 => println!("{} Fizz", x),
_ => println!("{}", x),
}