Skip to content

Instantly share code, notes, and snippets.

View dipakyadav's full-sized avatar
💭
Open for opportunities

Dipak Yadav dipakyadav

💭
Open for opportunities
View GitHub Profile

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@dipakyadav
dipakyadav / gist:29597b94f97bfc1bc9e60967e621568b
Created December 29, 2018 11:54
No executable found matching command "dotnet-aspnet-codegenerator" linux
// Replace {username} in the below command with your actual username
dotnet tool install -g dotnet-aspnet-codegenerator
/home/{username}/.dotnet/tools/dotnet-aspnet-codegenerator razorpage -m Movie -dc RazorPagesMovieContext -udl -outDir Pages/Movies --referenceScriptLibraries
"""input manatees: a list of "manatees", where one manatee is represented by a dictionary
a single manatee has properties like "name", "age", et cetera
n = the number of elements in "manatees"
m = the number of properties per "manatee" (i.e. the number of keys in a manatee dictionary)"""
def example1(manatees):
for manatee in manatees:
print manatee['name']
def example2(manatees):
>>> from pymongo import MongoClient
>>> client = MongoClient("mongodb+srv://kay:password@clustername.mongodb.net/test?retryWrites=true")
>>> db = client.test_database
>>> collection = db.test_collection
>>> import datetime
>>> post = {"author": "Mike", "text": "My first blog post!", "tags": ["mongodb", "python", "pymongo"], "date": datetime.datetime.utcnow()}
>>> posts = db.posts
>>> post_id = posts.insert_one(post).inserted_id
>>> post_id
ObjectId('5b2070f157a2f413b5d6c668')
@dipakyadav
dipakyadav / get-github-repo-stargazers.py
Last active May 5, 2018 01:26
Retrieve list of stargazers information for specific repo
# -*- coding: utf-8 -*-
# python3
"""
author : Dipak Yadav
"""
from github import Github
g = Github("{GitHub Personal Token}", per_page=100)
print("'name', 'url', 'bio', 'location', 'email', 'blog', 'avatar_url'")