Skip to content

Instantly share code, notes, and snippets.

View avjinder's full-sized avatar
👨‍💻

Avi avjinder

👨‍💻
  • Canada
View GitHub Profile
class ProgressView: UIView {
private var progressPath: UIBezierPath!
private var progressShape: CAShapeLayer!
private var backgroundShape: CAShapeLayer!
/// Set by user to increment or decrement progress
/// On being set, this changes the `strokeEnd` property of the
/// `progressShape`, denoting where the stroke should end
/// Value between 0.0 - 1.0
var progress: Float = 0 {
fun partTwo(input: String): Int {
var frequency = 0
val diff = measureTimeMillis {
val lines = input.split("\n").map { it.toIntOrNull() ?: 0 }
val frequencies = mutableSetOf<Int>()
for (i in 0..Int.MAX_VALUE) {
frequency += lines[i % lines.count()]
if (!frequencies.add(frequency)) break
}
func PartTwo(input string) int {
f, err := os.Create("p2cpu.pprof")
if err != nil {
fmt.Println("pprof file error")
panic(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
lines := strings.FieldsFunc(input, func(r rune) bool {
return unicode.IsSpace(r) || r == '\n'
@avjinder
avjinder / 1_drawable_ic_hash_io16.xml
Created May 12, 2016 04:48 — forked from eneim/1_drawable_ic_hash_io16.xml
Animated Stroke. The google I/O website this year (https://google.com/io) has some funky animated lettering. I especially liked the animated stroke around the letters and wondered how you might implement that on Android. Turns out that AnimatedVectorDrawable makes this very easy! Here's how it looks: https://twitter.com/crafty/status/71077957997…
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016 Google Inc.
Licensed 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
http://www.apache.org/licenses/LICENSE-2.0
@avjinder
avjinder / gist:fed3bbe814fc7eb8913e
Last active September 8, 2015 21:11 — forked from ljubisa987/gist:e33cd5597da07172c55d
TextInputLayout temporary workaround for hint not showing on initial load for SDK > 20
import android.content.Context;
import android.graphics.Canvas;
import android.support.design.widget.TextInputLayout;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
public class CustomTextInputLayout extends TextInputLayout {
@avjinder
avjinder / ScrollingFABBehavior.java
Last active September 8, 2015 20:35 — forked from mzgreen/ScrollingFABBehavior.java
HideOnScrollExample - custom fab behavior
public class ScrollingFABBehavior extends CoordinatorLayout.Behavior<FloatingActionButton> {
private int toolbarHeight;
public ScrollingFABBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
this.toolbarHeight = Utils.getToolbarHeight(context);
}
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, FloatingActionButton fab, View dependency) {
package com.example.avjindersinghsekhon.toodle;
import android.content.Context;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.util.Log;