Skip to content

Instantly share code, notes, and snippets.

View usametov's full-sized avatar

Ulan Sametov usametov

  • Asta Nova Enterprise Solutions
View GitHub Profile
@usametov
usametov / bipartite-graph.md
Last active March 13, 2025 00:57
graph theory: men and women

https://grok.com/share/bGVnYWN5_046f4fe1-c33f-4c68-a4d6-51711bc40c07

To address the statement "men also have more sexual partners than women" using graph theory, we can model heterosexual relationships as a bipartite graph and analyze the implications. This approach helps us rigorously evaluate the statement, particularly in the context of averages, which is often implied in such claims.

Step 1: Define the Problem and Model

The statement compares the number of sexual partners between men and women, typically interpreted as comparing the average number of partners. We will focus on heterosexual relationships for simplicity, as this is the most straightforward interpretation of the statement (though we can later consider extensions to other cases). In graph theory terms, we can represent heterosexual relationships as a bipartite graph:

  • Let ( M ) be the set of all men, and ( W ) be the set of all women.
  • An edge ( (m, w) ) exists between a man ( m \in M ) and a woman ( w \in W ) if they have
@usametov
usametov / modern-java.md
Created March 12, 2025 23:32
new java features, last 10 years

Over the past 8 years (since 2017), the Java programming language has undergone significant improvements, with new features and enhancements introduced in each major release. Oracle shifted Java to a six-month release cycle starting with Java 9 in September 2017, enabling faster delivery of features. Below is a summary of key improvements in Java from Java 9 (2017) to Java 23 (expected in 2024), focusing on major language enhancements, performance improvements, and developer productivity.


Java 9 (September 2017)

  1. Module System (Project Jigsaw)
    • Introduced the Java Platform Module System (JPMS) to modularize the JDK and applications.
    • Key feature: module-info.java files to define module boundaries, exports, and dependencies.
    • Benefits: Improved encapsulation, security, and scalability for large applications.
@usametov
usametov / playwright-help.md
Created March 12, 2025 03:57
how to avoid being blocked

When scraping websites using Playwright in headless mode, you might get blocked due to anti-bot measures implemented by the target website. These measures often detect automated browsers and block them to prevent scraping. Below are several strategies to help you avoid being blocked, along with implementation tips using Playwright in Python or JavaScript.


Why You're Getting Blocked

Websites use various techniques to detect headless browsers, such as:

  1. User-Agent Detection: Your browser's user-agent might indicate a headless browser.
  2. Browser Fingerprinting: Websites analyze browser properties (e.g., screen resolution, WebGL, plugins) to detect automation.
  3. Behavior Analysis: Websites may track mouse movements, click patterns, or other human-like behavior.
  4. IP Blocking: Frequent requests from the same IP can trigger rate-limiting or blocking.

A/B testing is a powerful method to compare two versions of a user experience (UX) design to determine which performs better. Below is a quickstart guide for conducting A/B testing for UX, with a focus on using R for statistical analysis.

Quickstart Guide to A/B Testing for UX with R

1. Define Your Goal and Metrics

  • Goal: Identify the specific UX improvement you want to test (e.g., increase button click-through rate, reduce bounce rate, improve form completion).
  • Metrics:
    • Primary Metric: The key performance indicator (KPI) tied to your goal (e.g., conversion rate, time on page).
    • Secondary Metrics: Additional metrics to monitor for unintended consequences (e.g., user satisfaction, page load time).
  • Example: If testing a new button design, your primary metric might be the click-through rate (CTR).
@usametov
usametov / charts.md
Last active March 10, 2025 19:59
angular learning notes

Integrating charts into Angular applications is a common requirement for visualizing data, and while D3.js is a powerful low-level library, its complexity can make it challenging, as you experienced. Fortunately, there are several easier-to-use charting libraries that integrate well with Angular, offering pre-built components, TypeScript support, and simpler APIs. Below, I’ll explain how to integrate charts into Angular, compare D3 with more user-friendly alternatives, and provide practical examples inspired by "The Angular Mini-Book" and current Angular practices as of March 10, 2025.


1. Why D3 Was Challenging

D3.js is a low-level data visualization library that gives you full control over SVG elements, scales, and animations. However:

  • Steep Learning Curve: Requires understanding SVG, DOM manipulation, and D3’s API.
  • Manual Integration: No native Angular components; you must manage lifecycle hooks (e.g., ngOnInit, ngOnDestroy) and DOM updates manually.
  • Boilerplate: Crea
@usametov
usametov / thinking_tokens.py
Created January 26, 2025 04:03 — forked from zainhas/thinking_tokens.py
Extract ONLY thinking tokens from DeepSeek-R1
from together import Together
client = Together(api_key = TOGETHER_API_KEY)
question = "Which is larger 9.9 or 9.11?"
thought = client.chat.completions.create(
model="deepseek-ai/DeepSeek-R1",
messages=[{"role": "user", "content": question}],
stop = ['</think>']
)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// ©jdehorty
// @version=5
indicator('Machine Learning: Lorentzian Classification', 'Lorentzian Classification', true, precision=4, max_labels_count=500)
import jdehorty/MLExtensions/2 as ml
import jdehorty/KernelFunctions/2 as kernels
// ====================
@usametov
usametov / simba.clj
Created May 25, 2024 18:36 — forked from apeckham/simba.clj
connect to bigquery with clojure.java.jdbc
(ns simba
(:require [clojure.java.jdbc :as j])
(:import (com.simba.googlebigquery.jdbc42 Driver)))
(def conn {:classname "com.simba.googlebigquery.jdbc42.Driver"
:subprotocol "bigquery"
:subname "//https://www.googleapis.com/bigquery/v2:443;ProjectId=MY-PROJECT-ID;[email protected];OAuthPvtKeyPath=PATH-TO-P12-FILE"})
(defn run-query [query] (j/query conn [query]))
@usametov
usametov / rust-xp-01-s3.rs
Created May 10, 2024 02:12 — forked from jeremychone/rust-xp-01-s3.rs
Rust Quick Example to connect to S3 and Minio bucket server
#![allow(unused)] // silence unused warnings while exploring (to comment out)
use std::{error::Error, str};
use s3::bucket::Bucket;
use s3::creds::Credentials;
use s3::region::Region;
use s3::BucketConfiguration;
// Youtube Walkthrough - https://youtu.be/uQKBW8ZgYB8
@usametov
usametov / rsakeypairgen.clj
Created April 13, 2024 22:36 — forked from postspectacular/rsakeypairgen.clj
RSA keypair generator w/ Clojure (requires Bouncycastle & unlimited JCE). Based on bundled example (org.bouncycastle.openpgp.examples.RSAKeyPairGenerator)
;; usage:
;;
;; (-> (rsa-keypair 2048)
;; (generate-secret-key "[email protected]" "hello")
;; (export-keypair "alice.pub" "alice.sec" true))
(import
'[java.util Date]
'[java.security SecureRandom KeyPair KeyPairGenerator]
'[org.bouncycastle.jce.provider BouncyCastleProvider]