Skip to content

Instantly share code, notes, and snippets.

@amilcar-andrade
amilcar-andrade / gist:3400851
Last active October 8, 2015 22:58
Pyhton: Calculator Parser
import sys
class Number:
def __init__(self, lexeme):
self.lexeme = lexeme
class OpenParenthesis:
lexeme ="("
class CloseParenthesis:
@amilcar-andrade
amilcar-andrade / LinkifyTextView.java
Last active August 22, 2017 15:14
@TextView that only responds to touch events of links
public class LinkifyTextView extends TextView {
public LinkifyTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public LinkifyTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout android:id="@+id/main_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="128dp"
@amilcar-andrade
amilcar-andrade / SantaSecret.java
Last active October 15, 2016 19:09
SantaSecret basic implementation
import java.util.*;
public class SantaSecret {
public static void main(String[] args) {
String[][] list = generateList(new String[]{"amilcar", "andrade", "garcia"});
for (int i = 0; i < list.length; i++) {
System.out.println("From: " + list[i][0] + " To: " + list[i][1]);
}
}
@amilcar-andrade
amilcar-andrade / profile.xml
Created October 23, 2016 20:37
profile.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
@amilcar-andrade
amilcar-andrade / WordDistanceFinder.java
Created May 9, 2017 03:37
WordDistanceFinder solution
/* This class will be given a list of words (such as might be tokenized
* from a paragraph of text), and will provide a method that takes two
* words and returns the shortest distance (in words) between those two
* words in the provided text.
* Example:
* WordDistanceFinder finder = new WordDistanceFinder(Arrays.asList("the", "quick", "brown", "fox", "quick"));
* assert(finder.distance("fox", "the") == 3);
* assert(finder.distance("quick", "fox") == 1);
*
* "quick" appears twice in the input. There are two possible distance values for "quick" and "fox":
@amilcar-andrade
amilcar-andrade / Anagrams.java
Created May 25, 2017 17:22
Implementation of the isAnagram problem and groupAnagrams
import java.util.*;
class Main {
public static void main(String[] args) {
List<String> words = new ArrayList<>(Arrays.asList("a", "b", "a", "d"));
List<List<String>> g = groupAnamgrams(words);
System.out.println(g);
}
public static List<List<String>> groupAnamgrams(List<String> anagrams){
if (anagrams == null || anagrams.isEmpty()) {
@amilcar-andrade
amilcar-andrade / Palindrome.java
Created May 25, 2017 22:42
isPalindrome implementation
import java.io.*;
import java.util.*;
/*
* To execute Java, please define "static void main" on a class
* named Solution.
*
* If you need more classes, simply define them inline.
456654 => true
@amilcar-andrade
amilcar-andrade / VoiceActivity.java
Last active April 15, 2020 21:24
arghhhhh! stupid FragmentTranstions
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.transition.Fade;
import androidx.appcompat.app.AppCompatActivity;
/** VoiceActivity 2.0 */
public class VoiceActivity extends AppCompatActivity {
VoiceFragment mVoiceFragment = new VoiceFragment();
package io.plaidapp.ui.recyclerview;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import io.plaidapp.data.DataLoadingSubject;
/**