Skip to content

Instantly share code, notes, and snippets.

View heyitsaamir's full-sized avatar

Aamir heyitsaamir

  • Microsoft
  • Seattle, Washington
View GitHub Profile
@heyitsaamir
heyitsaamir / rag_agent.py
Last active August 1, 2024 19:50
Rag agent in a group chat (Autogen)
from datetime import datetime, timedelta
import re
from typing import List, Union, Tuple
from autogen.agentchat.contrib.vectordb.base import QueryResults, VectorDB, Document
from autogen.agentchat.contrib.retrieve_user_proxy_agent import RetrieveUserProxyAgent
from autogen.agentchat.contrib.retrieve_assistant_agent import RetrieveAssistantAgent
from autogen import AssistantAgent, ConversableAgent
from azure.core.credentials import AzureKeyCredential
from azure.search.documents import SearchClient
from azure.core.exceptions import ResourceNotFoundError
@heyitsaamir
heyitsaamir / README.md
Last active April 5, 2024 16:57
Convert .mov files to gifs for easier PR integration

Convert To gif

If you're on a mac, and you use cmd+shift+5 to record screens to put in your PR, here's a little snippet i wrote to convert that into a gif:

convertToGif () {
  if [ -z "$1" ]; then
    mov_filename=$(ls -t ~/Desktop/*.mov | head -n 1)
    if [ -z "$mov_filename" ]; then
      echo "No MOV files found on the desktop."
@heyitsaamir
heyitsaamir / gist:d9e36e23ee2402e6d41e92903827bf32
Last active October 15, 2024 21:03
Github Title Selector
/* globals jQuery, $, waitForKeyElements */
// ==UserScript==
// @name Github Title Selector
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author Aamir Jawaid
// @match https://github.com/*/pull/*
// @icon https://www.google.com/s2/favicons?domain=tampermonkey.net
@heyitsaamir
heyitsaamir / withCurrentSelection.ts
Created May 23, 2020 18:11
Simple HOC to maintain current selection of the editor (slatejs)
import React, { useContext, useRef } from 'react';
import { isEqual } from 'lodash';
import { Range } from 'slate';
import { ReactEditor, useSlate } from 'slate-react';
export const CurrentSelectionContext = React.createContext<{
current: Range | null;
}>({ current: null });
with prices as (
SELECT entity_id, id, created_at
FROM src.prices p
WHERE p.org_type = 'CARRIER'
AND p.source_type = 'MODEL'
AND p.reason_code != 'DEDICATION_PRICE_REGEN'
QUALIFY ROW_NUMBER() OVER (PARTITION BY p.entity_id ORDER BY p.created_at desc) = 1
)
, total_prices as (
select p.entity_id, sum(pli.cents) total, LISTAGG(pli.type, ', ') AS cost_type
with historical_shipment_matching as
(
SELECT -- Use a distinct to avoid duplicate entries coming from lane mapping table
DISTINCT s.id AS shipment_id
, s.created_at as matched_at
, m.contract_id
, coalesce(m.rate_override, cc.contract_rate) AS contracted_rate_dollars
, s.pickup_driver_end_time
@heyitsaamir
heyitsaamir / live_live_to_drop_drop_query.sql
Last active April 29, 2020 14:08
Live_Live to Drop_Drop Investigation - query
with qualified as (
select *, get_path(matching_criteria, 'jobSummary.shipmentDigests[0].classification') classification from src.dedication_event_logs del
where event_type = 'MATCHING'
and match_type = 'QUALIFIED'
and matching_contracts != '[]'
)
, drop_drops as (
select s.id, 'DROP_DROP' classification from bi.SHIPMENTS s
inner join src.shipment_stops ss_pick on ss_pick.id = s.pickup_stop_id
inner join src.shipment_stops ss_drop on ss_drop.id = s.last_dropoff_stop_id