Skip to content

Instantly share code, notes, and snippets.

View omtodkar's full-sized avatar
:atom:
Cosmos!

Omkar Todkar omtodkar

:atom:
Cosmos!
View GitHub Profile
@omtodkar
omtodkar / keygen.sh
Created March 27, 2023 16:12
JWT generate key-pair to sign in token
# Generate Private Key
keytool -genkey -alias <example name> -keyalg RSA -keysize 4096 -keypass <example password> -storepass <example password> -keystore ./private.jks
# Extract Public Key
keytool -export -alias <example name> -keystore ./private.jks -file ./public.pub -storepass <example password>
@omtodkar
omtodkar / pre-commit
Last active October 28, 2021 05:26
Pre Commit Hook | Flutter
#!/bin/sh
set -e
echo "Running pre commit analysis..."
# Collect staged files
changed_files="$(git --no-pager diff --name-status --no-color --cached | awk '$1 != "D" && $2 ~ /\.dart/ { print $2}')"
# If any, Dart file is changed
if [ "${#changed_files}" -eq 0 ]; then
echo "Nothing to analyze."
@omtodkar
omtodkar / schema.md
Created June 16, 2021 20:02
Social Media Integration

Table Schema

create type auth_providers as enum ('FACEBOOK', 'INSTAGRAM', 'GOOGLE', 'TWITTER');

create table user_auth_providers
(
    user_id             bigint references users (user_id) not null,
    provider            auth_providers                    not null,
 token text not null,
@omtodkar
omtodkar / ShortCodes.cs
Created March 30, 2020 07:32 — forked from craigtp/ShortCodes.cs
Short code generator.Converts a long integer to a "short code" (a seemingly random string of characters - as seen on many popular URL Shortener utilities.) and vice-versa.See: http://stackoverflow.com/a/529852/57477
using System;
namespace ShortCodes
{
public static class ShortCodes
{
// You may change the "shortcode_Keyspace" variable to contain as many or as few characters as you
// please. The more characters that are included in the "shortcode_Keyspace" constant, the shorter
// the codes you can produce for a given long.
private static string shortcodeKeyspace = "abcdefghijklmnopqrstuvwxyz0123456789";
#!/bin/bash
<< ////
The script creates 'licenses' under '$ANDROID_HOME' and creates a file which proves
that the SDK license was accepted by the user.
Please copy this to your own account/gist/server. Every time there's an updated license, update the file with the new
license hash.
Legally if you run this script (or your own version of it), it means YOU accepted the license - don't trust someone else.
The hashes below are supposed to be taken from $ANDROID_HOME/licenses/android-sdk-license on YOUR machine, after you
@omtodkar
omtodkar / ApiManager.java
Created March 27, 2018 18:21 — forked from marcelpinto/ApiManager.java
Cache RxJava observables on Android approach to reuse and avoid multiple calls.
private ObservableManager obsManager = new ObservableManager(EventBus.getDefault());
@Override
public Subscription getStores() {
// Get the observable if exists and is not too old
Observable<StoresList> observable = obsManager.get(ObservableManager.Types.STORES);
if (observable == null) {
// If is null create it and us cache to keep it in memeroy
observable = api.getStoresList()
.compose(applySchedulers(api.getStoresList()))
@omtodkar
omtodkar / Paytm.log
Last active March 29, 2017 13:53
Error during Paytm Payment Gateway integration
2017-03-29 19:21:33.241 DoneTemplate[8504:550787] *** Assertion failure in -[AFJSONRequestSerializer requestWithMethod:URLString:parameters:error:], /Users/done/Workspace/iOS Projects/done-ios/AFNetworking/AFURLRequestSerialization.m:353
2017-03-29 19:21:33.371 DoneTemplate[8504:550787] *** WebKit discarded an uncaught exception in the webView:didFinishLoadForFrame: delegate: <NSInternalInconsistencyException> Invalid parameter not satisfying: URLString
@omtodkar
omtodkar / MultipartObserver.java
Last active October 13, 2016 21:15
Multipart uploading helper
package co.omkar.utility;
import java.net.HttpRetryException;
/**
* <p>A callback listener for {@link MultipartUploader}
* which emits progress, result and status.</p>
* Created on 14/10/16.
*
* @author Omkar Todkar
</!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Answer 1</title>
</head>
<body>
<form style="border: solid 1px #000000; position:absolute;">
<table>
<tr>
@omtodkar
omtodkar / CategoryRecyclerAdapter.java
Created March 31, 2016 19:03
UI Freezing on transaction of fragment, but works smoothly on reverting same fragment from fragment back stack.
package com.example.omkar.adapters.product;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;