Skip to content

Instantly share code, notes, and snippets.


Omid Raha omidraha

View GitHub Profile
omidraha /
Created Nov 2, 2019 — forked from xaf-cv/
Click&Hold detection through View.OnTouchListener()
View.OnTouchListener detectClickAndHoldListener = new View.OnTouchListener() {
private Timer timer = new Timer();
private long LONG_PRESS_TIMEOUT = 1337; // TODO: your timeout here
private boolean wasLong = false;
public boolean onTouch(View v, MotionEvent event) {
Log.d(getClass().getName(), "touch event: " + event.toString());
omidraha /
Created Aug 23, 2018 — forked from johnhw/
1 million prime UMAP layout
### JHW 2018
import numpy as np
import umap
# This code from the excellent module at:
import random
View ignite_config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="dataStorageConfiguration">
omidraha /
Created Apr 23, 2018
Blockchain voting system

Blockchain Voting System

How current system works

  • Users are allowed to vote after their identity is confirmed by an authority.
  • Votes are collected and counted by an authority.
  • The person who has the most votes, have the power for ~4 years, then we vote again.


omidraha / S3 bucket sync
Created Dec 7, 2017 — forked from andrewschoen/S3 bucket sync
Python script to sync an S3 bucket to the local file system
View S3 bucket sync
# -*- coding: utf-8 -*-
import os
import StringIO
import hashlib
from boto.s3.connection import S3Connection
from boto.s3.key import Key
except ImportError:
raise ImproperlyConfigured, "Could not load Boto's S3 bindings."
omidraha /
Last active May 26, 2020
RecyclerView GridLayoutManager, auto-detect span count
import android.content.Context;
import android.util.TypedValue;
public class GridAutoFitLayoutManager extends GridLayoutManager {

Keybase proof

I hereby claim:

  • I am omidraha on github.
  • I am omidraha ( on keybase.
  • I have a public key whose fingerprint is CEE2 5EF9 A639 0EF7 BDB5 EFFA 4D05 83DB 0938 E415

To claim this, I am signing this object:

omidraha /
Last active Feb 9, 2021 — forked from andineck/
Authentication and Authorization Concepts for MicroServices

auth with microservices

Authorization and Authentication are hard. when you only have to implement them once (as you do within a monolith) instead of over and over again, it makes the developer happy :-), and maybe leads to less implementation failures.

When you have a bunch of microservices, this is something that has to be considered.

Implement it once or in every microservice, or something in between?

View useragentswitcher.xml
<folder description="Browsers - Windows">
<folder description="Legacy Browsers">
<useragent description="Arora 0.6.0 - (Vista)" useragent="Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/527 (KHTML, like Gecko, Safari/419.3) Arora/0.6 (Change: )" appcodename="" appname="" appversion="" platform="" vendor="" vendorsub=""/>
<useragent description="Avant Browser 1.2" useragent="Avant Browser/1.2.789rel1 (" appcodename="" appname="" appversion="" platform="" vendor="" vendorsub=""/>
<useragent description="Chrome 4.0 (Win 7)" useragent="Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/ Safari/532.5" appcodename="" appname="" appversion="" platform="" vendor="" vendorsub=""/>
<useragent description="Chrome 5.0 (Server 2003)" useragent="Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/532.9 (KHTML, like Gecko) Chrome/5.0.310.0 Safari/532.9" appcodename="" appname="" appversion=