Skip to content

Instantly share code, notes, and snippets.

View abhishektiwari's full-sized avatar
👋
hello

Abhishek Tiwari abhishektiwari

👋
hello
View GitHub Profile
@abhishektiwari
abhishektiwari / agent loop
Created April 3, 2025 23:37 — forked from jlia0/agent loop
Manus tools and prompts
You are Manus, an AI agent created by the Manus team.
You excel at the following tasks:
1. Information gathering, fact-checking, and documentation
2. Data processing, analysis, and visualization
3. Writing multi-chapter articles and in-depth research reports
4. Creating websites, applications, and tools
5. Using programming to solve various problems beyond development
6. Various tasks that can be accomplished using computers and the internet
@abhishektiwari
abhishektiwari / psi-poc.ipynb
Created March 22, 2025 19:11 — forked from mg98/psi-poc.ipynb
Proof-of-Concept: Private Set Intersection
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@abhishektiwari
abhishektiwari / psi-poc.ipynb
Created March 22, 2025 19:11 — forked from mg98/psi-poc.ipynb
Proof-of-Concept: Private Set Intersection
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"printWidth": 120,
"proseWrap": "always",
"semi": false,
"overrides": [
{
"files": ["*.html"],
"options": {
"parser": "go-template"
}
@abhishektiwari
abhishektiwari / convert_check_to_status.yml
Created November 30, 2024 21:43 — forked from onnenon/convert_check_to_status.yml
A GitHub Actions workflow that runs whenever a check run completes and creates a commit status with the target_url. This allows Cloudflare pages deploy previews to work with Decap CMS
name: Convert Cloudflare Check Run to Status
on:
check_run:
types: [completed]
jobs:
create_status_for_check:
name: Create Status for Check Run
runs-on: ubuntu-latest
permissions:

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

@abhishektiwari
abhishektiwari / MultipleFieldLookupORMixin.py
Created April 4, 2021 10:07 — forked from nik-hil/MultipleFieldLookupORMixin.py
Django REST framework support only one lookup field at a time. To support more than one field we have to use MultipleFieldLookupMixin. But it has a limitation. It require all fields to be present in URL. I have different requirement. I can call view using two differnet identifier.
class MultipleFieldLookupORMixin(object):
"""
Actual code http://www.django-rest-framework.org/api-guide/generic-views/#creating-custom-mixins
Apply this mixin to any view or viewset to get multiple field filtering
based on a `lookup_fields` attribute, instead of the default single field filtering.
"""
def get_object(self):
queryset = self.get_queryset() # Get the base queryset
queryset = self.filter_queryset(queryset) # Apply any filter backends
filter = {}
@abhishektiwari
abhishektiwari / .bashrc
Created March 26, 2021 22:42 — forked from vsouza/.bashrc
Golang setup in Mac OSX with HomeBrew. Set `GOPATH` and `GOROOT` variables in zshell, fish or bash.
# Set variables in .bashrc file
# don't forget to change your path correctly!
export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
@abhishektiwari
abhishektiwari / chrono-chooser.vue
Created July 22, 2020 10:54 — forked from codenamezjames/chrono-chooser.vue
quasar date range picker
<template>
<div>
<div class="row q-col-gutter-sm q-mb-md q-px-md q-pt-md">
<div class="col flex items-center q-gutter-sm">
<q-input
v-model="zFromUs"
label="From"
outlined
dense
mask="##-##-####"
@abhishektiwari
abhishektiwari / gist:df4ee929cd301a0d8d5f9ad5d19837e5
Created May 12, 2020 09:30 — forked from ratchit/gist:3942066
Flask MethodView decorators for individual request methods
from flask.views import MethodView
class MethodView(MethodView):
_decorators = {}
def dispatch_request(self, *args, **kwargs):
"""Derived MethodView dispatch to allow for decorators to be
applied to specific individual request methods - in addition