Skip to content

Instantly share code, notes, and snippets.

View hitenpratap's full-sized avatar
🎯
Focusing

Hiten Pratap Singh hitenpratap

🎯
Focusing
View GitHub Profile
@hitenpratap
hitenpratap / pass_validator.java
Last active August 29, 2015 14:17
Validate password in java that must have atleat 1 uppercase char, 1 number and 1 special char in it and can be of 6 to 20 character in size.
package com.hprog99;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TestPasswordValidator {
private static Pattern passPattern =
Pattern.compile("((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%_*]).{6,20})");
@hitenpratap
hitenpratap / 502.html
Created May 1, 2015 20:21
502.html page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@hitenpratap
hitenpratap / ExtractStrTag.java
Last active December 1, 2015 10:14
Extract particulars tags from String using regex
package com.hprog99;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ExtractStrTag {
private static Pattern tagPattern =
Pattern.compile("<imageTag>(.+?)</imageTag>"); //here replace <imageTag> with your required tag
@hitenpratap
hitenpratap / tagInput.html
Created December 22, 2015 19:56
Tag input with autocomplete in AngularJS
<html ng-app="tagApp">
<head>
<style>
.friendTag {
display: inline-block;
margin-right: 5px;
font-size: 13px;
background-color: dodgerblue;
}
@hitenpratap
hitenpratap / tagInput.js
Last active December 22, 2015 20:09
Tag input with autocomplete in AngularJS
var tagApp = angular.module('tagApp',['ui.autocomplete']);
tagApp.controller('tagController',function($scope,EventService){
$scope.tags = [];
$scope.addTag = function () {
if ($scope.modelObj != "" && $scope.tags.indexOf($scope.modelObj) == -1) {
$scope.tags.push($scope.modelObj);
}
$scope.modelObj = "";
};
@hitenpratap
hitenpratap / sort_xsl_date.xsl
Last active January 27, 2016 19:43
Sort data in XSLT based on date
<xsl:sort select="normalize-space(substring(itpc:StartDate,1,4))" order="descending"/>
<xsl:sort select="normalize-space(substring(itpc:StartDate,6,2))" order="descending"/>
<xsl:sort select="normalize-space(substring(itpc:StartDate,9,2))" order="descending"/>
<!--Suppose date is in format: 2015-11-15T12:22:15-->
@hitenpratap
hitenpratap / package.json
Created June 24, 2016 12:59
Angular 2 Dependency And Configuration Files
{
"name": "angular2-quickstart",
"version": "1.0.0",
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
@hitenpratap
hitenpratap / variable_scope_angularjs.js
Created July 22, 2016 07:06
How to use variables with $scope in angularjs
//Lets assume value.questionUniqueId is coming from json response
var dataModel = $parse('data_' + value.questionUniqueId);
var dataModel1 = $parse(value.questionUniqueId + '_data');
var labelsModel = $parse('labels_' + value.questionUniqueId);
var seriesModel = $parse('series_' + value.questionUniqueId);
dataModel.assign($scope, ['1', '2', '3', '4', '5']);
dataModel1.assign($scope, ['1', '2', '3', '4', '5']);
labelsModel.assign($scope, [
[3, 0, 1, 4, 6]
]);
@hitenpratap
hitenpratap / removeMySQLMac.sh
Created October 19, 2016 14:28
Script to remove MySQL completely from Mac(If being installed using non-homebrew method)
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*
@hitenpratap
hitenpratap / backup_folders.sh
Last active May 28, 2018 12:16
Take Backup of folders (e.g.. Tomcat, MySQL and MongoDB etc.) to Azure Storage
#!/bin/bash
AZURE_STORAGE_CONNECTION_STRING=""
FOLDER_NAME="data_"$(date +'%d-%m-%Y-%H-%M-%S')
MYSQL_USER_NAME="root"
MYSQL_USER_PASSWORD=""
MYSQL_DB_NAME_ARRAY=()
MONGO_DB_NAME_ARRAY=()
FOLDER_BACKUP_ARRAY=()
AZURE_STORAGE_CONTAINER_NAME=""
AZURE_BLOB_NAME="full_backup_"$(date +'%d-%m-%Y')".zip"