Skip to content

Instantly share code, notes, and snippets.

View eeshangarg's full-sized avatar
🏠
Working from home

Eeshan Garg eeshangarg

🏠
Working from home
View GitHub Profile
@eeshangarg
eeshangarg / breadcrumb_lektor_bootstrap.py
Created March 24, 2017 23:58
Breadcrumb in Lektor using Bootstrap
<ol class="breadcrumb">
{% set crumbs = [] %}
{% set current = {'crumb': this} %}
{% for i in this._path.split("/") %}
{% if current.crumb is not none %}
{% if crumbs.insert(0, current.crumb) %}{% endif %}
{% if current.update({"crumb": current.crumb.parent}) %}{% endif %}
{% endif %}
{% endfor %}
{% for crumb in crumbs %}
self.open = new BinaryHeap(function_to_sort_on)
@eeshangarg
eeshangarg / test_not_too_many_queries.diff
Created May 5, 2018 19:56
The diff depicting the one extra SQL query after my changes/refactor (zerver.tests.test_messages.StreamMessagesTest.test_not_too_many_queries).t
--- data_without_changes.json 2018-05-05 16:35:40.522986224 -0230
+++ data_with_changes.json 2018-05-05 16:33:37.482789614 -0230
@@ -4,15 +4,19 @@
"time": "0.000"
},
{
+ "sql": "SELECT COUNT(*) AS \"__count\" FROM \"zerver_subscription\" INNER JOIN \"zerver_recipient\" ON (\"zerver_subscription\".\"recipient_id\" = \"zerver_recipient\".\"id\") INNER JOIN \"zerver_userprofile\" ON (\"zerver_subscription\".\"user_profile_id\" = \"zerver_userprofile\".\"id\") WHERE (\"zerver_recipient\".\"type\" = 2 AND \"zerver_subscription\".\"active\" = true AND \"zerver_recipient\".\"type_id\" = 1 AND \"zerver_userprofile\".\"is_active\" = true)",
+ "time": "0.000"
+ },
+ {
@eeshangarg
eeshangarg / test_multi_user_subscription.diff
Created May 5, 2018 19:58
The diff depicting the one extra SQL query after my changes/refactor (zerver.tests.test_subs.SubscriptionAPITest.test_multi_user_subscription)
--- test_without_changes.json 2018-05-05 17:11:07.234475225 -0230
+++ test_with_changes.json 2018-05-05 17:08:37.606523263 -0230
@@ -4,11 +4,11 @@
"time": "0.000"
},
{
- "sql": "SELECT \"zerver_userprofile\".\"id\", \"zerver_userprofile\".\"password\", \"zerver_userprofile\".\"last_login\", \"zerver_userprofile\".\"is_superuser\", \"zerver_userprofile\".\"email\", \"zerver_userprofile\".\"is_staff\", \"zerver_userprofile\".\"is_active\", \"zerver_userprofile\".\"is_realm_admin\", \"zerver_userprofile\".\"is_bot\", \"zerver_userprofile\".\"is_guest\", \"zerver_userprofile\".\"bot_type\", \"zerver_userprofile\".\"is_api_super_user\", \"zerver_userprofile\".\"date_joined\", \"zerver_userprofile\".\"is_mirror_dummy\", \"zerver_userprofile\".\"bot_owner_id\", \"zerver_userprofile\".\"long_term_idle\", \"zerver_userprofile\".\"full_name\", \"zerver_userprofile\".\"short_name\", \"zerver_userprofile\".\"pointer\", \"zerver_userprofile\".\"last_pointer_updater\", \"zerver_userprofile\".\"rea
#include "Physics.h"
#include "Components.h"
Vec2 Physics::GetOverlap(std::shared_ptr<Entity> a, std::shared_ptr<Entity> b)
{
auto x1 = a->getComponent<CTransform>()->pos.x;
auto y1 = a->getComponent<CTransform>()->pos.y;
auto x2 = b->getComponent<CTransform>()->pos.x;
auto y2 = b->getComponent<CTransform>()->pos.y;
Vec2 delta(abs(x1-x2), abs(y1-y2));
@eeshangarg
eeshangarg / calories.py
Created August 18, 2020 23:56
calories.py
AGE = 22
WEIGHT = 59.87 # kg
HEIGHT = 170 # cm
BMR = 10 * WEIGHT + 6.25 * HEIGHT - 5 * AGE + 5
print("BMR: ", BMR)
ACTIVITY_MULTIPLIER = 1.3 # Sedentary + Training
MAINTENANCE = BMR * ACTIVITY_MULTIPLIER
SURPLUS = 0.15 # 15%
@eeshangarg
eeshangarg / New gist
Created March 17, 2021 23:20
New gist
New gist by Eeshan
@eeshangarg
eeshangarg / gist.txt
Created March 18, 2021 14:10
New gist
This is a new gist
@eeshangarg
eeshangarg / New gist
Created March 18, 2021 14:35
New gist
Another new gist
@eeshangarg
eeshangarg / so many gists
Created March 19, 2021 02:34
Another new gist
ugh