Skip to content

Instantly share code, notes, and snippets.

View Yogendra0Sharma's full-sized avatar
🎯
Focusing

Yogendra Sharma Yogendra0Sharma

🎯
Focusing
View GitHub Profile
@Yogendra0Sharma
Yogendra0Sharma / MongoDB Commands.md
Created January 10, 2017 10:33
MongoDB Commands

Basic Mongo shell commands

mongo             //Start mongo shell
show dbs          //Display databases
use mydb          //Start using 'mydb' database
db                //Display current database
show collections  //Display collections
help              //help
# Get documents, where writters are Joel Coen and Ethan Coen.
db.movieDetails.find({ "writters" : ["Joel Coen", "Ethan Coen"] }).count()
# Get documents, where Jeff Bridges is playing leading role.
> db.movieDetails.find({ "actors.0": "Jeff Bridges" }).pretty()
@Yogendra0Sharma
Yogendra0Sharma / redis_cheatsheet.bash
Created January 10, 2017 10:36 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@Yogendra0Sharma
Yogendra0Sharma / docker-cleanup
Created January 12, 2017 06:56 — forked from balos1/docker-cleanup
Cleanup unused Docker images and containers
#!/bin/sh
# Cleanup docker files: untagged containers and images.
#
# Use `docker-cleanup -n` for a dry run to see what would be deleted.
untagged_containers() {
# Print containers using untagged images: $1 is used with awk's print: 0=line, 1=column 1.
# NOTE: "[0-9a-f]{12}" does not work with GNU Awk 3.1.7 (RHEL6).
# Ref: https://github.com/blueyed/dotfiles/commit/a14f0b4b#commitcomment-6736470
docker ps -a | tail -n +2 | awk '$2 ~ "^[0-9a-f]+$" {print $'$1'}'
@Yogendra0Sharma
Yogendra0Sharma / install.sh
Created January 12, 2017 07:08 — forked from balos1/install.sh
Install Latest Docker and Docker-compose on Ubuntu
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
# Install kernel extra's to enable docker aufs support
sudo apt-get -y install linux-image-extra-$(uname -r)
# Add Docker PPA and install latest version
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
@Yogendra0Sharma
Yogendra0Sharma / rawSQL.py
Created January 12, 2017 08:41 — forked from citmusa/rawSQL.py
delete heroku - postgress table
python manage.py shell:
>>> sql = '''drop table mytable cascade;
... drop table mytable2; '''
>>>
>>> from django.db import connections, transaction
>>> cursor = connections['default'].cursor()
>>> cursor.execute(sql)
@Yogendra0Sharma
Yogendra0Sharma / dumpdbs3.py
Created January 12, 2017 08:43 — forked from goliatone/dumpdbs3.py
Simple django management command to dump database using mysqldump, pg_dump, or sqlite3 .dump, and store in S3
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand
# from django.core.management.base import CommandError
from optparse import make_option
from django.conf import settings
import os
import sys
import yaml
from boto.s3.connection import S3Connection
@Yogendra0Sharma
Yogendra0Sharma / README.md
Created January 12, 2017 08:43 — forked from genomics-geek/README.md
Setting up a Dockerized web application with Django REST APIs, ReactJS with Redux pattern, and Webpack Hot Reloading! Mouthful.

Guide on how to create and set up a Dockerized web app using Django REST APIs and ReactJS

Hopefully this will answer "How do I setup or start a Django project using REST Framework and ReactJS?"

I created this because it was SUCH a pain in the ass setting up a project using all the latest technologies. After some research, I figured it out and have it working. The repo that implements this is located here. Feel free to use it as a boilerplate ;)

Main features:

  • Django REST APIs
  • ReactJS with Redux Pattern
  • Webpack module bundler manager
@Yogendra0Sharma
Yogendra0Sharma / gist:42870b90e3b7c446b4c04083b1c2960a
Created January 12, 2017 08:44 — forked from guillaumepiot/gist:3939452
ANGULARJS - Django CSRF Token header setup
var myApp = angular.module('myApp').config(function($httpProvider) {
$httpProvider.defaults.headers.post['X-CSRFToken'] = $('input[name=csrfmiddlewaretoken]').val();
});
// service.js
angular.service('Address', function($resource, $cookies, $xhr, $log) {
// Add Header to comply with Django's CSRF implementation
token = $cookies['csrftoken'];
$xhr.defaults.headers['delete']['X-CSRFToken'] = token;
return $resource('/api/user/address/:addressId', {addressId:'@id'}, {});
});