Skip to content

Instantly share code, notes, and snippets.

View nesquena's full-sized avatar

Nathan Esquenazi nesquena

View GitHub Profile
@nesquena
nesquena / ItemClickSupport.java
Last active September 11, 2023 02:48
Click handling for RecyclerView
/*
Source: http://www.littlerobots.nl/blog/Handle-Android-RecyclerView-Clicks/
USAGE:
ItemClickSupport.addTo(mRecyclerView).setOnItemClickListener(new ItemClickSupport.OnItemClickListener() {
@Override
public void onItemClicked(RecyclerView recyclerView, int position, View v) {
// do it
}
});
@nesquena
nesquena / SnappyRecyclerView.java
Last active June 21, 2023 23:04
Snap-to-Center RecyclerView Extension
// From: http://stackoverflow.com/a/37816976
public class SnappyRecyclerView extends RecyclerView {
// Use it with a horizontal LinearLayoutManager
// Based on http://stackoverflow.com/a/29171652/4034572
public SnappyRecyclerView(Context context) {
super(context);
}
@nesquena
nesquena / basic.sql
Created September 7, 2011 01:56
PostgreSQL Common Utility Queries
/* How to calculate postgreSQL database size in disk ? */
SELECT pg_size_pretty(pg_database_size('thedbname'));
/* Calculate size of a table including or excluding the index */
SELECT pg_size_pretty(pg_total_relation_size('big_table'));
SELECT pg_size_pretty(pg_relation_size('big_table')); /* without index */
/* See indexes on a table with `\d tablename` */
@nesquena
nesquena / Contact.java
Last active January 15, 2023 13:03 — forked from rogerhu/Contact.java
Endless Scrolling with RecyclerVIew
package codepath.com.recyclerviewfun;
import java.util.ArrayList;
import java.util.List;
public class Contact {
private String mName;
private boolean mOnline;
public Contact(String name, boolean online) {
@nesquena
nesquena / PatternEditableBuilder.java
Last active October 21, 2022 10:20
PatternEditableBuilder - Easy way to create colored clickable spans within a TextView!
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.View;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.regex.Matcher;
@nesquena
nesquena / markdown_yard.md
Created November 29, 2011 21:51
Github Flavored Markdown in YARD
@nesquena
nesquena / CursorRecyclerAdapter.java
Created April 3, 2017 07:13
Cursor Adapters for RecyclerView
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 ARNAUD FRUGIER
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@nesquena
nesquena / Rakefile
Created June 5, 2010 09:51
Dead simple gem packaging gemspec and tasks
# coding:utf-8
require 'rubygems'
require 'rubygems/specification'
require 'rake'
def gemspec
@gemspec ||= begin
gem_name = File.basename(File.dirname(__FILE__))
file = File.expand_path("../#{gem_name}.gemspec", __FILE__)
@nesquena
nesquena / base.conf
Last active February 28, 2020 11:35
nginx configuration
include mime.types;
default_type application/octet-stream;
access_log logs/access.log;
sendfile on;
keepalive_timeout 65;
tcp_nodelay on;
tcp_nopush on;
@nesquena
nesquena / Uniform Setup.md
Created August 3, 2010 22:30
Uniform Server Setup

Enable universe repository:

# /etc/apt/sources.list

## main & restricted repositories
deb http://us.archive.ubuntu.com/ubuntu/ jaunty main restricted universe
deb-src http://us.archive.ubuntu.com/ubuntu/ jaunty main restricted universe

deb http://security.ubuntu.com/ubuntu jaunty-security main restricted universe

deb-src http://security.ubuntu.com/ubuntu jaunty-security main restricted universe