Skip to content

Instantly share code, notes, and snippets.

View ospatil's full-sized avatar

Omkar Patil ospatil

View GitHub Profile
@ospatil
ospatil / angular#2898.js
Last active December 18, 2015 04:49
AngularJS 1.1.5 - LocationHashbangUrl duplicates query params
//Two new test-cases in locationSpec 'HashbangUrl' suite
it('should should not duplicate query params - LocationHashbangUrl', function() {
var baseUrl = 'http://www.server.org:1234/?base=param';
url = new LocationHashbangUrl(baseUrl, '#');
url.$$parse(baseUrl);
expect(url.absUrl()).toBe(baseUrl);
});
it('should not duplicate query params - LocationHtml5Url', function() {
var baseUrl = 'http://www.server.org:1234/?base=param';
@ospatil
ospatil / Gruntfile.js
Last active March 9, 2020 14:26
Yeoman + Angular + Express = Full-stack
'use strict';
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// configurable paths
var yeomanConfig = {
app: 'app',
dist: 'dist'
@ospatil
ospatil / git.txt
Last active May 2, 2022 15:45
Important git command for branch and tag management
1. get list of remote tags
git ls-remote --tags origin
2. get list of local tags
git tag
3. remove local tag
git tag -d <tag name>
4. delete remote tag
@ospatil
ospatil / p7.exs
Last active July 23, 2016 23:18
Intuition into recursion as alternative to loops in FP
defmodule P7 do
# public function that calls a private one with accumulator
def flatten(list), do: Enum.reverse(do_flatten(list, []))
# base case - empty list
defp do_flatten([], result), do: result
# next two clauses for list with many elements
defp do_flatten([head | tail], result) when is_list(head), do: do_flatten(tail, do_flatten(head, result))
defp do_flatten([head | tail], result), do: do_flatten(tail, [head | result])
end
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/7.7.3/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'version',
1 verbose cli 'minor' ]
2 info using npm@4.1.2
3 info using node@v7.7.3
4 info git [ 'status', '--porcelain' ]
5 info lifecycle @ruf/shell@4.1.0~preversion: @ruf/shell@4.1.0
6 silly lifecycle @ruf/shell@4.1.0~preversion: no script for preversion, continuing
@ospatil
ospatil / docker.sh
Created January 7, 2019 23:54
Common docker commands needed for day to day working
# CREATION
## run an image in interactive mode (-it flag), map a folder between host and container (-v flag) and remove the container after stopping and run BASH in the container
docker run --rm -it -v ~/<HOST_DIR>:/<CONTAINER_DIR> <IMAGE_NAME> bash
## create an image from a container (useful when you make changes to a container and create a new image out of it)
docker commit <CONTAINER_NAME> <NEW_IMAGE_NAME>
## create an image from scratch. Create a a Dockerfile in a directory and run the following command in that directory
docker build -t <NEW_IMAGE_NAME> .
@ospatil
ospatil / VS Code shortcuts
Last active April 6, 2020 02:05
Keyboard navigation shortcuts for VS Code
# VS Code keyboard shortcuts
## Jumping between editors, views and terminal
* Jump to file explorer - `Cmd + shift + E`
* Switch between open editor tabs - `Ctrl` + `tab` or `Ctrl` + `1` or `2` so on
* Jump to terminal - `Ctrl + ``
* Quick View Selection - `Ctrl + Q`
* Jump to global search view - `Cmd + shift + F`
* Jump to Debug view - `shift + Cmd + D`
@ospatil
ospatil / Vagrantfile for Fedora 31 and Python 3.8
Last active June 6, 2023 06:46
Vagrant configuration for Fedora 31 and Python 3.8
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@ospatil
ospatil / docker-k8s-minikube.md
Last active October 18, 2020 15:55
Handy reference working locally with docker, kubernetes and minikube

Docker misc

  • Running a docker image with port mapping - docker run --init -p 4444:4444 --rm <IMAGE_NAME>

    --init makes it respond to signals like ctrl+c

    -d will make it run in detached mode, so for stopping you'll have to do docker ps and use the container id.

Working with minikube and local images

@ospatil
ospatil / poc.ts
Created March 31, 2021 14:33
TypeScript type LeanDocument for mongoose and nestjs
class Doc {
attrA: string;
attrB: string;
id: string;
_id: any;
_v: number;
func1 = () => {}
func2 = () => {}
}