Skip to content

Instantly share code, notes, and snippets.

View rajivnarayana's full-sized avatar

Rajiv Narayana Singaseni rajivnarayana

View GitHub Profile
@rajivnarayana
rajivnarayana / GeoLocationPlugin-cordova.3x.js
Created March 18, 2015 13:35
The java script for Cordova geolocation plugin 'org.apache.cordova.geolocation' to be used when you had to serve cordova.3x.js from remote server.
cordova.define("org.apache.cordova.geolocation.Coordinates", function(require, exports, module) { /*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
@rajivnarayana
rajivnarayana / ColorTransformingPagerExample.java
Created November 20, 2014 20:32
An android activity that sets up a view page that changes background color as you scroll. As seen in https://play.google.com/store/apps/details?id=ch.bitspin.timely
public class MainActivity extends ActionBarActivity {
private ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final int[] mColors = new int[3];
mColors[0] = Color.BLUE;
@rajivnarayana
rajivnarayana / gist:64f52a2f731707a56684
Last active August 29, 2015 14:08
Simple compiler
/**
* A simple arithmetic language that consists of the following keywords
*
* reset
* reset x, creates a variable x if it doesnot exist and assigns 0 as its value
* increment
* increment x, increments a previously declared variable x, generates compiler warning if it doesnot have x already.
* loop
* loop x, loops the following statements until endloop x times, generates a compiler warning if x is not defined already.
* endloop
public class MyActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1) {
@Override
public int getCount() {
@rajivnarayana
rajivnarayana / DrawableAlignedButton.java
Created March 22, 2013 21:26
Custom drawn Android button which aligns left drawable and its text to center.
package com.webileapps.myrtprofile;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.Button;
/**
*
@rajivnarayana
rajivnarayana / MyTextView.m
Created March 6, 2013 15:23
Custom UITextView with a placeholder label.
//
// MyTextView.m
// TextViewDemo
//
// Created by Jayaprada on 10/11/12.
// Copyright (c) 2012 mountain lion. All rights reserved.
//
#import "MyTextView.h"
@rajivnarayana
rajivnarayana / MainActivity.java
Last active December 14, 2015 14:08
Demonstrates MyGridView a custom GridView that can be placed inside a Scrollview. Used in ResolutionTweet android app.
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GridView gridView = (GridView) findViewById(R.id.grid);
gridView.setAdapter(new MyArrayAdapter());
}
@rajivnarayana
rajivnarayana / DateIconWidget.java
Last active December 14, 2015 10:49
An android widget to display date as calendar.
package com.webileapps.dateiconwidget;
import java.text.SimpleDateFormat;
import java.util.Date;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Typeface;
@rajivnarayana
rajivnarayana / MyTableViewController.h
Created January 23, 2013 14:02
Custom TableViewController which has a UIView as a parent.
#import <UIKit/UIKit.h>
@interface MyTableViewController : UITableViewController {
}
@end
@rajivnarayana
rajivnarayana / TouchOverlayDemo.java
Created December 10, 2012 13:17
Custom Activity to mimic "Show Overlay Touches" for devices < 4.0.
import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.RelativeLayout;
public class TouchOverlayDemo extends Activity {
@Override