Skip to content

Instantly share code, notes, and snippets.

View adityasharat's full-sized avatar
🎯
Focusing

Aditya Sharat adityasharat

🎯
Focusing
View GitHub Profile
@adityasharat
adityasharat / single-form.json
Created December 24, 2018 17:14
Generic Form Schema
{
"forms": [
{
"title": "",
"pages": [
{
"title": "",
"sections": [
{
"title":""
@adityasharat
adityasharat / indexOf.js
Created March 25, 2017 06:57
Index of sublist
function indexOf(list, sublist) {
var counter = 0,
index = -1,
sub = sublist;
do {
if (list.val === sub.val) {
if (index === -1) {
index = counter;
}
@adityasharat
adityasharat / looknsay.js
Created March 25, 2017 06:29
Look And Say
const regexp = /(.)\1*/g;
function looknsay(input) {
return input.replace(regexp, function(match, capture) {
return match.length.toString() + capture;
});
}
function runner(input, interations) {
for (var i = interations; i > 0; i--) {
input = looknsay(input);
@adityasharat
adityasharat / formula.js
Created March 17, 2017 14:07
Number to Words (Indian) (Google Sheets)
function INR(input) {
var a, b, c, d, e, output, outputA, outputB, outputC, outputD, outputE;
var ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
if (input === 0) { // Zero
output = "Zero";
@adityasharat
adityasharat / WebViewAttributeHandler.java
Created February 23, 2017 07:35
Proteus:WebView Custom Attribute Handler
public class ProteusHelper {
public static void register(LayoutBuilder builder) {
LayoutHandler webViewParser = builder.getHandler("WebView");
webViewParser.addHandler(new Attributes.Attribute("disableCache"), new StringAttributeProcessor<WebView>() {
@Override
public void handle(String attributeKey, String attributeValue, WebView view) {
boolean bool = ParseHelper.parseBoolean(attributeValue);
@adityasharat
adityasharat / ProteusDrawableGlideExample.java
Last active March 20, 2017 16:37
Proteus: Load Images using Glide
public class ProteusDrawableGlideExample {
private BitmapLoader loader = new BitmapLoader() {
@Override
public Future < Bitmap > getBitmap(String imageUrl, View view) {
return null;
}
@Override
@adityasharat
adityasharat / unzip.sh
Last active December 14, 2016 18:02
Unzip recursively
find . -name "*.zip" | while read filename; do unzip -o -d "`dirname "$filename"`" "$filename"; done;
@adityasharat
adityasharat / math.js
Created May 5, 2015 13:18
Create a Math Utility
var Math = {};
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/E
Math.E = 2.718;
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max
Math.max = function (x, y) {
if (x > y) {
return x;
} else {
@adityasharat
adityasharat / toWords.js
Created February 28, 2015 05:03
Convert a number to words.
(function () {
function toWords() {
var ones,
tens,
hundred,
output,
numString,
denominations,
groups,
number = this;
@adityasharat
adityasharat / index.html
Created January 28, 2015 17:51
AngularJS: loop over some models in the scope and bind them to elements
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Angular</title>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js"></script>
</head>
<body>