Skip to content

Instantly share code, notes, and snippets.

View utmishra's full-sized avatar
👨‍💻

Utkarsh Mishra utmishra

👨‍💻
View GitHub Profile
@utmishra
utmishra / pylance_type_friendly_singleton.py
Created September 10, 2025 13:20
Pylance Type friendly singleton
# singleton_decorator.py
from __future__ import annotations
from typing import Any, Callable, TypeVar, Type, cast
T = TypeVar("T", bound=type)
def singleton(cls: T) -> T:
# Enforce single instance by intercepting __call__ on the metatype of this class
# without changing the symbol's type.
# Option A: wrap __new__ on the class
@utmishra
utmishra / provision.sh
Created August 15, 2025 20:13
TTS provisioning
#!/usr/bin/env bash
set -euo pipefail
log() { echo "[provision] $*"; }
# Ensure apt is usable
if command -v apt-get >/dev/null 2>&1; then
log "apt-get update"
sudo apt-get update -y || apt-get update -y || true
log "install ffmpeg + libsndfile1"
@utmishra
utmishra / magento-1.7-installation.txt
Created April 26, 2018 10:16
Ubuntu 16.04 - Install Magento 1.7
1. Download Magento 1.7
2. Enable https://stackoverflow.com/a/36407094/1167269
3. sudo apt install php7.0-xml php-xml php7.0-gd php7.0-mcrypt php7.0-mysql
4. Change Line 555 in app/code/core/Mage/Core/Model/Layout.php
5. Make sure that pdo_mysql extension is enabled in php.ini
6. https://stackoverflow.com/a/15443527/1167269
@utmishra
utmishra / es_java_top_hits.txt
Created May 18, 2017 18:43
Elasticsearch Java API Top Hits implementation
https://github.com/elastic/elasticsearch/blob/master/docs/java-api/aggregations/metrics/tophits-aggregation.asciidoc
@utmishra
utmishra / gist:9003a38a7e2ab44b6216e479fe5b9558
Last active March 14, 2017 22:39
Multiple Spring Data modules found, entering strict repository configuration mode
There is a whole section about in the documents:
http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.multiple-modules
Basically if you are using the generic interfaces (e.g. CrudRepository) then Spring won't know if you want that repository to be backed on the spring-mongodb or spring-redis data modules.
Sources:
http://stackoverflow.com/questions/39432764/info-warnings-about-multiple-modules-in-spring-boot-what-do-they-mean
{
"cluster_name": "es_app",
"nodes": {
"0wkHZVDnQPKFggbPogcxhw": {
"timestamp": 1474481441697,
"name": "es_app-elasticsearch-prd-sg2-01",
"transport_address": "inet[/16.0.1.78:9300]",
"host": "es_app-elasticsearch-prd-sg2-01.sd.int",
"ip": ["inet[/16.0.1.78:9300]", "NONE"],
"attributes": {
::: [app-elasticsearch-prd-sg2-01][0wkHZVDnQPKFggbPogcxhw][app-elasticsearch-prd-sg2-01.sd.int][inet[/16.0.1.78:9300]]{master=false}
Hot threads at 2016-09-21T17:57:43.345Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:
::: [app-elasticsearch-prd-sg2-08][DKZvxCenTDaOLLr6xcBSTw][app-elasticsearch-prd-sg2-08.sd.int][inet[/16.0.1.221:9300]]{data=false, master=true}
Hot threads at 2016-09-21T17:57:43.343Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:
::: [app-elasticsearch-prd-sg2-06][NUUji2PqQOGti1B9y0Qy6A][app-elasticsearch-prd-sg2-06.sd.int][inet[/16.0.1.119:9300]]{master=false}
Hot threads at 2016-09-21T17:57:43.345Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:
::: [app-elasticsearch-prd-sg2-03][GCBd_Gr2S06Xa_6nSn0omQ][app-elasticsearch-prd-sg2-03.sd.int][inet[/16.0.1.77:9300]]{master=false}
::: [app-elasticsearch-prd-sg2-01][0wkHZVDnQPKFggbPogcxhw][app-elasticsearch-prd-sg2-01.sd.int][inet[/16.0.1.78:9300]]{master=false}
Hot threads at 2016-09-21T11:10:59.058Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:
17.3% (86.7ms out of 500ms) cpu usage by thread 'elasticsearch[app-elasticsearch-prd-sg2-01][search][T#14]'
3/10 snapshots sharing following 26 elements
org.apache.lucene.util.packed.DeltaPackedLongValues.get(DeltaPackedLongValues.java:39)
org.apache.lucene.util.packed.PackedLongValues.get(PackedLongValues.java:110)
org.apache.lucene.util.LongValues.get(LongValues.java:45)
org.elasticsearch.index.fielddata.plain.PackedArrayIndexFieldData$10.get(PackedArrayIndexFieldData.java:492)
org.apache.lucene.index.SingletonSortedNumericDocValues.setDocument(SingletonSortedNumericDocValues.java:52)
[INFO] com.google.code.findbugs:jsr305:jar:2.0.1:compile
[INFO] org.atteo:evo-inflector:jar:1.2.1:compile
[INFO] org.apache.lucene:lucene-sandbox:jar:4.10.4:compile
[INFO] org.springframework:spring-expression:jar:4.2.6.RELEASE:compile
[INFO] log4j:log4j:jar:1.2.17:compile
[INFO] aopalliance:aopalliance:jar:1.0:compile
[INFO] org.slf4j:jul-to-slf4j:jar:1.7.21:compile
[INFO] org.ow2.asm:asm-commons:jar:4.1:compile
[INFO] org.hibernate:hibernate-validator:jar:5.2.4.Final:compile
[INFO] org.springframework:spring-aop:jar:4.2.6.RELEASE:compile
@utmishra
utmishra / pom.xml
Created May 31, 2016 14:31
POM file
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.project.microservice</groupId>
<artifactId>search</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<inceptionYear>2015</inceptionYear>