Skip to content

Instantly share code, notes, and snippets.

View korniltsev's full-sized avatar
🏳️‍🌈
s/jz/jnz/

Tolya Korniltsev korniltsev

🏳️‍🌈
s/jz/jnz/
View GitHub Profile
// Copyright 2012 Pierre-Yves Ricau
//
// 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
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
@korniltsev
korniltsev / gist:80a35f76a65c49c5a2df
Last active August 29, 2015 14:02
cool lexer definition
/*
* The scanner definition for COOL.
*/
import java_cup.runtime.Symbol;
%%
%{
@korniltsev
korniltsev / cool.cup
Last active August 29, 2015 14:02
cool.cup 70
/*
* cool.cup
* Parser definition for the COOL language.
*
*/
import java_cup.runtime.*;
/* Stuff enclosed in {: :} is copied verbatim to the class containing
all parser actions. All the extra variables/functions you want to use

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

Screen

The RecyclerView has to use a GridLayoutManager.

This is a porting of the class SimpleSectionedListAdapter provided by Google

If you are looking for a sectioned list RecyclerView.Adapter you can take a look here

@korniltsev
korniltsev / introrx.md
Last active August 29, 2015 14:21 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class StringUtils {
private StringUtils() { /* No op */ }
public static String from(InputStream is) {
byte[] buffer = new byte[1024];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@korniltsev
korniltsev / GZIPUtils.java
Created October 23, 2012 13:49 — forked from johnkil/GZIPUtils.java
Utilities for working with GZIP archives.
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.LinkedList;
import java.util.List;
import java.util.zip.GZIPInputStream;
@korniltsev
korniltsev / gist:4024343
Created November 6, 2012 12:26
Use declared stylable from apklib
Added support for custom views with custom attributes in libraries. Layouts using custom attributes must use the namespace URI http://schemas.android.com/apk/res-auto instead of the URI that includes the app package name. This URI is replaced with the app specific one at build time.
@korniltsev
korniltsev / gist:4030294
Created November 7, 2012 09:03
Android ListViews not clickable
http://netpenthe.wordpress.com/2011/11/20/android-listviews-not-clickable/
Apparently ListViews lose their clickability if they contain focusable child elements in their layout.
I initially set all the child elements to not be focusable.
But now do this in the getView() method instead:
((ViewGroup) convertedView).setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
@korniltsev
korniltsev / MyActivity.java
Created November 14, 2012 12:48
AutoCompleteTextView sample
package com.example.popup_test;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;