Skip to content

Instantly share code, notes, and snippets.

View rylexr's full-sized avatar
💭
Working on Memorigi Web!

R rylexr

💭
Working on Memorigi Web!
View GitHub Profile
@lucasr
lucasr / SimpleListLayout.java
Last active May 2, 2020 06:21
List layout built with the new TwoWayView API
public class SimpleListLayout extends TwoWayLayoutManager {
public SimpleListLayout(Context context, Orientation orientation) {
super(context, orientation);
}
@Override
protected void measureChild(View child, Direction direction) {
measureChildWithMargins(child, 0, 0);
}
@gabrielemariotti
gabrielemariotti / Readme.md
Last active January 1, 2025 22:35
A SimpleSectionedRecyclerViewAdapter: use this class to realize a simple sectioned `RecyclerView.Adapter`.

You can use this class to realize a simple sectioned RecyclerView.Adapter without changing your code.

The RecyclerView should use a LinearLayoutManager. You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)

This is a porting of the class SimpleSectionedListAdapter provided by Google

Screen

Example:

@jaredrummler
jaredrummler / SearchViewStyle.java
Last active May 22, 2020 22:48
Customize the SearchView in an ActionBar for Android
/*
* Copyright (C) 2015 Jared Rummler <[email protected]>
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
@chomi3
chomi3 / ToolbarColorizeHelper
Last active February 11, 2022 23:41
Helper class to colorize all Android Toolbar Icons
/*
Copyright 2015 Michal Pawlowski
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
Unless required by applicable law or agreed to in writing, software
@SH4DY
SH4DY / rand5.js
Last active October 10, 2016 02:13
rand5() - Weekly interview question from interview cake
/*
You have a function rand7() that generates a random integer from 1 to 7.
Use it to write a function rand5() that generates a random integer from 1 to 5.
rand7() returns each integer with equal probability.
rand5() must also return each integer with equal probability.
*/
function rand5(){
var x = rand7();
while(x > 5){
@SH4DY
SH4DY / productExceptIndexDP.java
Last active October 10, 2016 02:13
/*You have an array of integers, and for each index you want to find the product of every integer except the integer at that index. Write a function get_products_of_all_ints_except_at_index() that takes an array of integers and returns an array of the products.*/ Greedy/DP approach
/*You have an array of integers, and for each index you want to find the product
of every integer except the integer at that index.
Write a function get_products_of_all_ints_except_at_index() that takes an array
of integers and returns an array of the products.*/
public static int[] get_products_of_all_ints_except_at_index_dp(int[] arr){
//build front
int[] front = new int[arr.length];
front[0] = 1;
for(int i = 1; i < arr.length; i++){
@SH4DY
SH4DY / parentheses.java
Created March 22, 2015 11:13
. A common problem for compilers and text editors is determining whether the parentheses in a string are balanced and properly nested. For example, the string ((())())() contains properly nested pairs of parentheses, which the strings )()( and ()) do not. Give an algorithm that returns true if a string contains properly nested and balanced paren…
//return -1: correct parentheses
//return n: Position of first offending bracket
public static int parantheses(char[] chrs){
Stack s = new Stack();
int i = 0;
for(;i<chrs.length;i++){ //Checks for erroneous chars omitted
char c = chrs[i];
@SH4DY
SH4DY / swap.java
Last active October 10, 2016 02:13
Swap two numbers in-place ==> without using a temp variable
//This method works only with integers
int a = 5;
int b = 7;
a = a-b; //diff. a = -2
b = a+b; // b = 5
a = b-a; // a = 7
//This method relies on bit manipulation and does not depend on the number format
int c = 3;
@ferdy182
ferdy182 / CircularRevealingFragment.java
Created March 27, 2015 17:18
Make circular reveal animations on a fragment
/**
* Our demo fragment
*/
public static class CircularRevealingFragment extends Fragment {
OnFragmentTouched listener;
public CircularRevealingFragment() {
}
@SH4DY
SH4DY / permutationPalindrome.java
Created April 2, 2015 19:25
Give an algorithm to decide whether a given string or ANY of its permutations is a Palindrome. There is an O(n) algorithm for this problem!
/**
* Decide whether a given string or ANY
* of its permutations is a Palindrome.
*
* The given solution works in O(n). Building the parity map
* takes n steps, iterating through the map takes
* not more than n steps (size of the alphabet).
* Space consumption: Map with the size of the alphabet. (constant)
* @param str
* @return