Skip to content

Instantly share code, notes, and snippets.

View panchalkalpesh's full-sized avatar

Kalpesh Panchal panchalkalpesh

View GitHub Profile
@panchalkalpesh
panchalkalpesh / extractTLD.js
Created April 30, 2024 20:30
Extract Top Level Domain Name in JavaScript
const extractTLD = (href = window.location.href) => {
const url = new URL(href);
return url.hostname.split('.').slice(-2).join('.');
}
export default extractTLD;
@panchalkalpesh
panchalkalpesh / multiple.proxy.config.json
Created October 22, 2019 15:26 — forked from elmentecato/multiple.proxy.config.json
Proxy configuration with a few paths for angular
{
"/myapp/*": {
"target": "https://pedro.internal.lab:9443",
"secure": false,
"logLevel": "debug",
"changeOrigin": true
},
"/users/*": {
"target": "https://sonia.internal.lab:9443",
"secure": false,
@panchalkalpesh
panchalkalpesh / capitalize.directive.spec.ts
Created October 18, 2019 19:11 — forked from Josh-Hicks/capitalize.directive.spec.ts
Test file for capitalize directive
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { CapitalizeDirective } from './capitalize.directive';
import { Component, HostListener } from '@angular/core';
// Simple test component that will not in the actual app
@Component({
template: '<p dtCapitalize>Testing Directives is awesome!</p>'
})
class TestComponent {
// clickCount is not necessary but it's used here to verify that the component
@panchalkalpesh
panchalkalpesh / capitalize.directive.ts
Created October 18, 2019 19:11 — forked from Josh-Hicks/capitalize.directive.ts
An Angular directive that can toggle text casing
import { Directive, HostListener, ElementRef } from '@angular/core';
@Directive({
selector: '[dtCapitalize]'
})
export class CapitalizeDirective {
constructor(private el: ElementRef) { }
@HostListener('click')
onClick() {
@panchalkalpesh
panchalkalpesh / exportShortGitCommit.groovy
Created November 8, 2018 22:26 — forked from fabito/exportShortGitCommit.groovy
Exporting short git commit sha1 hash in Jenkins through System Groovy Script build step
import hudson.model.*
def env = build.getEnvironment()
def gitCommit = env['GIT_COMMIT']
def shortGitCommit = gitCommit[0..6]
def pa = new ParametersAction([
new StringParameterValue("SHORT_GIT_COMMIT", shortGitCommit)
])
@panchalkalpesh
panchalkalpesh / gist:f68c3c81c21d8094ba1eb6f78cb6fab9
Created March 7, 2017 22:08 — forked from gesteves/gist:1051628
Google Apps script to export Google Talk chat logs to a Google Docs spreadsheet
/*
Quick instructions:
1. Go to Google Docs and open a new spreadsheet.
2. Go to Tools > Script editor...
3. Delete everything, paste this code in the script editor, and save it.
4. Go back to the spreadsheet, Tools > Script manager...
5. Select getChats, and press the "run" button.
6. It'll ask for a bunch of authorizations. Grant them.
7. When it says "now you can run the script", repeat step 5.
# Product Name
> Short blurb about what your product does.
[![NPM Version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Downloads Stats][npm-downloads]][npm-url]
One to two paragraph statement about your product and what it does.
![](header.png)
## Installation
OS X & Linux:
```sh
@panchalkalpesh
panchalkalpesh / email-address-syntax-validation-let-the-browser-do-it.md
Created December 6, 2016 21:13 — forked from nepsilon/email-address-syntax-validation-let-the-browser-do-it.md
Email address syntax validation? Let the browser do it (without regexp) — First published in fullweb.io issue #77

Email address syntax validation? Let the browser do it (without regexp)

Here is a simple and robust way to check for the validity of an email address syntax directly in the browser. No need for crazy regular expressions.

e = document.createElement('input')
e.type = 'email'
// check some email addresses
e.value = 'hi@'
@panchalkalpesh
panchalkalpesh / understanding-http-status-codes.md
Created November 22, 2016 14:52 — forked from nepsilon/understanding-http-status-codes.md
Understanding HTTP’s status codes — First published in fullweb.io issue #75

Understanding HTTP’s status codes

Following our series on HTTP, here is a quick note on HTTP status code, sent with the HTTP response. They are organized in 5 categories:

1xx Informational, ex:

  • 100 Continue used when doing a multi-part file upload
  • 101 Switching Protocol used when switching from HTTP to WebSocket

2xx Success, ex:

@panchalkalpesh
panchalkalpesh / git-grep-code.md
Created November 22, 2016 06:01 — forked from nepsilon/git-grep-code.md
How to grep search committed code in git? — First published on fullweb.io issue #47

How to grep search committed code in git?

Search working tree for text matching regular expression regexp:

git grep regexp 

Search working tree for lines of text matching regexp A or B:

git grep -e A --or -e B