Skip to content

Instantly share code, notes, and snippets.

View gengkev's full-sized avatar

Kevin Geng gengkev

  • Carnegie Mellon University
View GitHub Profile
@gabrielemariotti
gabrielemariotti / Readme.md
Last active March 2, 2024 23:10
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:

@debasishg
debasishg / gist:8172796
Last active March 15, 2024 15:05
A collection of links for streaming algorithms and data structures

General Background and Overview

  1. Probabilistic Data Structures for Web Analytics and Data Mining : A great overview of the space of probabilistic data structures and how they are used in approximation algorithm implementation.
  2. Models and Issues in Data Stream Systems
  3. Philippe Flajolet’s contribution to streaming algorithms : A presentation by Jérémie Lumbroso that visits some of the hostorical perspectives and how it all began with Flajolet
  4. Approximate Frequency Counts over Data Streams by Gurmeet Singh Manku & Rajeev Motwani : One of the early papers on the subject.
  5. [Methods for Finding Frequent Items in Data Streams](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.187.9800&rep=rep1&t
  1. Plain Strings (207): foo
  2. Anchors (208): k$
  3. Ranges (202): ^[a-f]*$
  4. Backrefs (201): (...).*\1
  5. Abba (169): ^(.(?!(ll|ss|mm|rr|tt|ff|cc|bb)))*$|^n|ef
  6. A man, a plan (177): ^(.)[^p].*\1$
  7. Prime (286): ^(?!(..+)\1+$)
  8. Four (199): (.)(.\1){3}
  9. Order (198): ^[^o].....?$
  10. Triples (507): (^39|^44)|(^([0369]|([147][0369]*[258])|(([258]|[147][0369]*[147])([0369]*|[258][0369]*[147])([147]|[258][0369]*[258])))*$)
@TooTallNate
TooTallNate / endianness.js
Created February 10, 2013 20:32
Get host machine endianness using JavaScript Typed Arrays (polyfill for `os.endianness()` in node.js)
function endianness () {
var b = new ArrayBuffer(4);
var a = new Uint32Array(b);
var c = new Uint8Array(b);
a[0] = 0xdeadbeef;
if (c[0] == 0xef) return 'LE';
if (c[0] == 0xde) return 'BE';
throw new Error('unknown endianness');
}
@timkuijsten
timkuijsten / Bye Bye Ubuntu (Desktop)
Last active December 10, 2015 04:18
No Ubuntu for Christmas
Yesterday, after evangelizing Ubuntu for years and running Ubuntu on my
parents desktop since 2009, I finally "relieved" them by giving them
Windows 7 as a gift.
For years I had the hope that every Ubuntu release would get better
than the previous edition. That the vision of Canonical aligned with my
vision of openness and where user rights are put central. I took the
fact that some proprietary things didn't work for granted and thought
we could fight it best by adding weight to the open source movement and
use open source software while demanding open codecs, standards etc.
@domenic
domenic / promises.md
Last active March 31, 2024 14:07
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@axemclion
axemclion / IndexedDB.setVersionShim.js
Created May 11, 2012 00:29
Shim that converts Chrome's SetVersion to the standard IndexedDB onupgradeneeded events
////////////////////////////////////////////////////////////////////////////////////////////////////
var openReqShim = function(dbName, version){
var me = this;
var IDBRequest = function(){
this.onsuccess = this.onerror = this.onblocked = this.onupgradeneeded = null;
};
function copyReq(req){
req = req || dbOpenReq;
@antimatter15
antimatter15 / regeression.js
Created March 30, 2012 03:28
Linear Regression
//an implementation of the AIClass linear regression algorithm
//http://www.youtube.com/watch?v=CE-R7a5xodI#t=4m18s
var x = [1,2,3,4], y = [2,3,4,5];
var M = x.length;
function sumxy(fn){
var sum = 0;
for(var i = 0; i < M; i++){
sum += fn(x[i], y[i]);
@mranney
mranney / emoji_sad.txt
Created January 30, 2012 23:05
Why we can't process Emoji anymore
From: Chris DeSalvo <chris.desalvo@voxer.com>
Subject: Why we can't process Emoji anymore
Date: Thu, 12 Jan 2012 18:49:20 -0800
Message-Id: <AE459007-DF2E-4E41-B7A4-FA5C2A83025F@voxer.com>
--Apple-Mail=_6DEAA046-886A-4A03-8508-6FD077D18F8B
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=utf-8
//SHA1 in Javascript 862 bytes
SHA1=function(l){function p(b,a){return b<<a|b>>>32-a}l+="€";for(var n=Math,c=[1518500249,1859775393,2400959708,3395469782,1732584193,4023233417,2562383102,271733878,3285377520,4294967295],s=n.ceil(l.length/4)+2,q=n.ceil(s/16),g=[],a=0,h=[],j,d,e,f,m,i,b,k;a<q;a++){g[a]=[];for(k=0;k<16;k++){function o(b,c){return l.charCodeAt(a*64+k*4+b)<<c}g[a][k]=o(0,24)|o(1,16)|o(2,8)|o(3,0)}}i=l.length*8-8;a=q-1;g[a][14]=i/(c[9]+1);g[a][14]=n.floor(g[a][14]);g[a][15]=i&c[9];for(a=0;a<q;a++){for(b=0;b<16;b++)h[b]=g[a][b];for(b=16;b<80;b++)h[b]=p(h[b-3]^h[b-8]^h[b-14]^h[b-16],1);j=c[4];d=c[5];e=c[6];f=c[7];m=c[8];for(b=0;b<80;b++){var r=n.floor(b/20),t=p(j,5)+(r<1?d&e^~d&f:r==2?d&e^d&f^e&f:d^e^f)+m+c[r]+h[b]&c[9];m=f;f=e;e=p(d,30);d=j;j=t}c[4]+=j;c[5]+=d;c[6]+=e;c[7]+=f;c[8]+=m}i="";for(z=4;z<9;z++)for(a=7;a>=0;a--)i+=((c[z]&c[9])>>>a*4&15).toString(16);return i};