Skip to content

Instantly share code, notes, and snippets.

@Kishanjvaghela
Kishanjvaghela / prog.c
Created February 11, 2016 07:24
Program to print number 1..n as right triangle.
#include <stdio.h>
int main(void) {
int i,j,rows;
printf("Enter the nth number of series: ");
scanf("%d",&rows);
printf("\n");
for(i=1;i<=rows;++i)
{
for(j=1;j<=i;++j)
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
/**
* Created by DSK02 on 1/27/2016.
*/
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = "EndlessRecycler";
private int previousTotal = 0; // The total number of items in the dataset after the last load
@Kishanjvaghela
Kishanjvaghela / Utils.java
Created February 26, 2016 11:03
Utility methods
/**
* get android id of device.
*
* @param context app context
* @return android id
*/
public static String getAndroidID(Context context) {
if (context != null) {
return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
} else {
/*
* onAttach(Context) is not called on pre API 23 versions of Android and onAttach(Activity) is deprecated
* Use onAttachToContext instead
*/
@TargetApi(23)
@Override
public void onAttach(Context context) {
super.onAttach(context);
onAttachToContext(context);
}
@Kishanjvaghela
Kishanjvaghela / Age.java
Created May 23, 2016 09:47
AgeCalculator
public class Age {
private int days;
private int months;
private int years;
public Age(int days, int months, int years) {
this.days = days;
this.months = months;
this.years = years;
public class BaseActivity extends Activity implements DetectsSoftKeyboardLayout.OnSoftKeyboardListener
{
DetectsSoftKeyboardLayout rootlayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
rootLayout.setOnSoftKeyboardListener(this);
}
@Kishanjvaghela
Kishanjvaghela / prog.java
Created September 23, 2016 13:11
Problem
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
@Kishanjvaghela
Kishanjvaghela / example
Last active September 23, 2016 14:39
You're given an array of positive numbers. Write an algorithm that arranges these numbers one after another in a way that the end result is a single number and is the largest number possible using those combinations.
Input: {252, 11, 9, 17545}
Output: 92521754511
@Kishanjvaghela
Kishanjvaghela / WrapContentViewPager.java
Created October 5, 2016 05:55
Wrap content height ViewPager
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.View;
/**
* Created by DSK02 on 7/4/2016.
*/
@Kishanjvaghela
Kishanjvaghela / 01-Arrow-Functions-add.js
Last active January 5, 2017 09:46
Let's Learn ES6 - Arrow Functions
// 1
let add = (a,b) => {
return a+b;
}
console.log(add(4,5));
// 2
let add = (a,b) => a+b;
console.log(add(4,5));