Skip to content

Instantly share code, notes, and snippets.

Avatar

Anil Singh Singhak

View GitHub Profile
View DateDiff.js
let startDate = new Date("2010-05-28");
let endDate = new Date("2020-03-01");
function isDateValid(dateToCheck) {
return isNaN(Date.parse(dateToCheck)) ? false : true;
}
function getMilliSecDiff(startDate, endDate) {
let startMilliSec = startDate.getTime();
let endMilliSec = endDate.getTime();
View qrcode-js.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Cross-Browser QRCode generator for Javascript</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
<script type="text/javascript" src="jquery.min.js"></script>
<!-- Download from https://github.com/davidshimjs/qrcodejs/zipball/master -->
<script type="text/javascript" src="qrcode.js"></script>
</head>
View circle-with-css.html
<html>
<head>
<style>
.full-circle {
width: 300px;
height: 300px;
border-radius: 150px 150px 150px 150px;
background-color: red;
}
View AbstractClassEx.py
# need to import ABCMeta, abstractmethod from abc (abstract base classes) module to implement abstract class feature
from abc import ABCMeta, abstractmethod
# we required (metaclass = ABCMeta) to use feature of abstraction
class Shape(metaclass = ABCMeta):
#To tell python this is abstractmethod we have to use A decorator indicating abstract methods.
@abstractmethod
def area(self):
pass
@Singhak
Singhak / GradleExec.gradle
Last active Sep 21, 2017
Example of gradle task exec
View GradleExec.gradle
// First way
task SvnDiif {
new ByteArrayOutputStream().withStream { os ->
exec {
executable = 'svn'
args = ['diff', '-r', "reviosionNo_from:revisionNo_to", "svn_repo", '--summarize']
standardOutput = os
}
def outputAsString = os.toString()
View fragment_b.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.admin.tabhostwithfragment.FragmentA">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Fragment B" />
View fragment_a.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.admin.tabhostwithfragment.FragmentA">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Fragment A" />
@Singhak
Singhak / fragment_tab_host.xml
Created Jun 21, 2016
This is use to host fragment
View fragment_tab_host.xml
<android.support.v4.app.FragmentTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
@Singhak
Singhak / activity_main.xml
Created Jun 21, 2016
This is used in MainActivity
View activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:id="@+id/relative_layout"
View FragmentB.java
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class FragmentB extends Fragment {
public FragmentB() {
// Required empty public constructor