Skip to content

Instantly share code, notes, and snippets.

View omidraha's full-sized avatar
🦋
♥‿♥

Omid Raha omidraha

🦋
♥‿♥
View GitHub Profile
@omidraha
omidraha / gist:8052f523222263ac3c6d3794208a7dab
Last active July 13, 2022 06:10 — forked from benbacardi/gist:227f924ec1d9bedd242b
Django reverse with a querystring
from django.utils.http import urlencode
def reverse_querystring(view, urlconf=None, args=None, kwargs=None, current_app=None, query_kwargs=None):
'''Custom reverse to handle query strings.
Usage:
reverse_querystring('app.views.my_view', kwargs={'pk': 123}, query_kwargs={'search': 'Bob'})
'''
base_url = reverse(view, urlconf=urlconf, args=args, kwargs=kwargs, current_app=current_app)
if query_kwargs:
return '{}?{}'.format(base_url, urlencode(query_kwargs))
{
"clientId": "slack",
"surrogateAuthRequired": false,
"enabled": true,
"alwaysDisplayInConsole": false,
"clientAuthenticatorType": "client-secret",
"redirectUris": [
"https://slack.com/",
"https://slack.com/*"
],
@omidraha
omidraha / open-source-sso.md
Created December 15, 2021 14:34 — forked from yanivmn/open-source-sso.md
Comparison of open-source SSO implementations
Aerobase Keycloak WSO2 Identity Server Gluu CAS OpenAM Shibboleth IdP
OpenID Connect/OAuth support yes yes yes yes yes yes third-party
Multi-factor authentication yes yes yes yes yes yes yes
Admin UI yes yes yes yes yes yes no
OpenJDK support yes yes yes yes no
Identity brokering yes yes yes
Middleware NGINX, Wildfly Wildfly, JBOSS WSO2 Carbon Jetty, Apache HTTPD any Java app server any Java app server Jetty, Tomc
@omidraha
omidraha / inspections.txt
Created September 30, 2021 15:46 — forked from pylover/inspections.txt
PyCharm inspections
# Extracted using: $ unzip -p lib/pycharm.jar com/jetbrains/python/PyBundle.properties | grep -B1 INSP.NAME | grep '^#' | sed 's|Inspection||g' | sed -e 's|#\s\{,1\}|# noinspection |'
# noinspection PyPep8
# noinspection PyPep8Naming
# noinspection PyTypeChecker
# noinspection PyAbstractClass
# noinspection PyArgumentEqualDefault
# noinspection PyArgumentList
# noinspection PyAssignmentToLoopOrWithParameter
# noinspection PyAttributeOutsideInit
@omidraha
omidraha / snippet.java
Created November 2, 2019 20:14 — forked from xaf-cv/snippet.java
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;
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.d(getClass().getName(), "touch event: " + event.toString());
@omidraha
omidraha / umap_sparse.py
Created August 23, 2018 07:12 — forked from johnhw/umap_sparse.py
1 million prime UMAP layout
### 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
<?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 April 23, 2018 04:23
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.

Problems

@omidraha
omidraha / S3 bucket sync
Created December 7, 2017 15:46 — forked from andrewschoen/S3 bucket sync
Python script to sync an S3 bucket to the local file system
# -*- 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."