Skip to content

Instantly share code, notes, and snippets.

Avatar
🦋

Omid Raha omidraha

🦋
View GitHub Profile
@omidraha
omidraha / snippet.java
Created Nov 2, 2019 — forked from xaf-cv/snippet.java
Click&Hold detection through View.OnTouchListener()
View snippet.java
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;
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.d(getClass().getName(), "touch event: " + event.toString());
@omidraha
omidraha / umap_sparse.py
Created Aug 23, 2018 — forked from johnhw/umap_sparse.py
1 million prime UMAP layout
View umap_sparse.py
### JHW 2018
import numpy as np
import umap
# This code from the excellent module at:
# https://stackoverflow.com/questions/4643647/fast-prime-factorization-module
import random
View ignite_config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="dataStorageConfiguration">
@omidraha
omidraha / blockchain-voting.md
Created Apr 23, 2018
Blockchain voting system
View blockchain-voting.md

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.

Problems

@omidraha
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
try:
from boto.s3.connection import S3Connection
from boto.s3.key import Key
except ImportError:
raise ImproperlyConfigured, "Could not load Boto's S3 bindings."
@omidraha
omidraha / GridAutoFitLayoutManager.java
Last active May 26, 2020
RecyclerView GridLayoutManager, auto-detect span count
View GridAutoFitLayoutManager.java
// https://stackoverflow.com/a/30256880/538284
// https://stackoverflow.com/a/42241730/538284
// https://stackoverflow.com/a/38082715/538284
import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
public class GridAutoFitLayoutManager extends GridLayoutManager {
View keybase.md

Keybase proof

I hereby claim:

  • I am omidraha on github.
  • I am omidraha (https://keybase.io/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
omidraha / README.md
Last active Feb 9, 2021 — forked from andineck/README.md
Authentication and Authorization Concepts for MicroServices
View README.md

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
<useragentswitcher>
<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 (http://www.avantbrowser.com)" 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/4.0.249.0 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=