Skip to content

Instantly share code, notes, and snippets.

View 2yk's full-sized avatar
☯️

Yeshu Kochher 2yk

☯️
View GitHub Profile
@2yk
2yk / multiple-deploy-keys-multiple-private-repos-github-ssh-config.md How to configure multiple deploy keys for different private github repositories on the same computer without using ssh-agent

Let's say alice is a github.com user, with 2 or more private repositories repoN. For this example we'll work with just two repositories named repo1 and repo2

https://github.com/alice/repo1

https://github.com/alice/repo2

You need to be to pull from these repositories without entering a passwords probably on a server, or on multiple servers. You want to perform git pull origin master for example, and you want this to happen without asking for a password.

@2yk
2yk / app.js
Created July 20, 2019 18:21 — forked from stongo/app.js
Joi validation in a Mongoose model
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;
db.on('error', function() {
return console.error.bind(console, 'connection error: ');
});
@2yk
2yk / query.js
Created May 8, 2019 06:22
Mongo Group by Month Query Example
   const match = {
     $group: {
       _id: { month: { $month: '$createdAt' } },
       count: { $sum: 1 },
     },
   };
   const group = {
     $group: {
       _id: null,
       patient: { $push: { month: '$_id.month', count: '$count' } },
@2yk
2yk / gist:1377458e37c64b164977b6212b12eac8
Created April 26, 2019 07:19 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@2yk
2yk / iterm2.md
Created February 7, 2019 05:19 — forked from squarism/iterm2.md
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@2yk
2yk / index.js
Created January 24, 2019 04:52
Browser detection tools
const express = require('express');
const useragent = require('useragent');
const browserInfo = require('browser-info');
const geoip = require('geoip-lite');
const app = express();
const port = process.env.PORT || 3000;
app.get('/', (req, res) => {
const defaultAgent = req.headers['user-agent'];
@2yk
2yk / dummy.js
Created January 18, 2019 06:35
MongoDB Aggregate Example
const docs = await Entry.aggregate([
{ $match: { compId: { $eq } } },
{ $group: { _id: '$userId', data: { $push: { userId: '$userId' } }, count: { $sum: 1 } } },
{
$lookup: {
from: 'users', localField: 'data.userId', foreignField: '_id', as: 'userData',
},
},
{ $unwind: '$userData' },
{
@2yk
2yk / gist:f17b94f65b352ae277c2d2f7b9ff3530
Created January 15, 2019 11:33
Following function will convert search string to object
# Following function will convert search string to object
<script>
!function(){"use strict";Array.isArray||(Array.isArray=function(r){return"[object Array]"===Object.prototype.toString.call(r)});var r={get:function(){var r=window.location.search,t={};return""===r?t:(r=r.slice(1),r=r.split("&"),r.map(function(r){var i,o;r=r.split("="),i=r[0],o=r[1],t[i]?(Array.isArray(t[i])||(t[i]=[t[i]]),t[i].push(o)):t[i]=o}),t)}};if(window){if(window.qs)throw new Error("Error bootstrapping qs: window.qs already set.");window.qs=r}}();
const obj = window.qs.get(search);
</script>

Keybase proof

I hereby claim:

  • I am theyeshu on github.
  • I am yeshu (https://keybase.io/yeshu) on keybase.
  • I have a public key ASD6pKxZ5N5q9DlMHnE2-4kneIH1ZdP8pqJ0gb9dL8fMpAo

To claim this, I am signing this object:

@2yk
2yk / My Bash Prompt
Created October 17, 2018 09:17
My base prompt setup => local:<Dir name>(Git Branch)$
git_branch() {
git branch 2> /dev/null | sed -e 's/* \(.*\)/(\1)/'
}
PS1="\[\033[01;32m\]local\[\033[00m\]:\[\033[01;34m\]\W\[\033[33m\]\$(git_branch)\[\033[00m\]$ "