Skip to content

Instantly share code, notes, and snippets.

@banagale
banagale / walmart_grocery_inventory.py
Created March 16, 2021 02:21 — forked from philipjewell/walmart_grocery_inventory.py
Finding which Walmart locations nearby have inventory of a product
#!/usr/bin/python3
from datetime import datetime
import click
import requests
from py_imessage import imessage
def build_store_dict(zipcode, n):
url = f'https://www.walmart.com/grocery/v4/api/serviceAvailability?postalCode={zipcode}'
const nodeRSA = require('node-rsa');
const fetch = require('node-fetch');
const publicKey = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCbM2br48JS2JJy8Ajy0gy33Gu5RNAFgysUp4Mj9FqzXWg7AwdGaXc0vIAGG3vmyrP906qJpiEV1aW9GhsEGNQ9Mjmngfnu1VAKZjskVToqG1ktiXZJKSlVUfGTYj+r1lKDgd2iKt4azIzoeElk1gnLovn8zEaiCT7prHlzWWb7JgW3qp1e12e5WvSC5xX9P5iKOs6WM3qTSAX3e8qGeA9wtlHdQuDjSjWA0WlYQIFKgpoCBNZeldNxel79QgR7QKG6Oo/H4aImhDW9vXH00mGVy9QX11ngovVYPhCQWzsAo+v+Y2lAJUtFdjr2t9/mJisKxpYvpMeqVo2ZSydwBmb5'
const consumerId = 'change this to your consumer id'
const privateKey = "MIIEpAIBAAKCAQEAmzNm6+PCUtiScvAI8tIMt9xruUTQBYMrFKeDI/Ras11oOwMH\
Rml3NLyABht75sqz/dOqiaYhFdWlvRobBBjUPTI5p4H57tVQCmY7JFU6KhtZLYl2\
SSkpVVHxk2I/q9ZSg4HdoireGsyM6HhJZNYJy6L5/MxGogk+6ax5c1lm+yYFt6qd\
XtdnuVr0gucV/T+YijrOljN6k0gF93vKhngPcLZR3ULg40o1gNFpWECBSoKaAgTW\
XpXTcXpe/UIEe0ChujqPx+GiJoQ1vb1x9NJhlcvUF9dZ4KL1WD4QkFs7AKPr/mNp\
@banagale
banagale / wordpress_auth_console.php
Last active March 18, 2021 18:01
Output WordPress user authentication status to console
<?php
function display_wordpress_user_auth()
{ ?>
<script>
<?php
$current_user = wp_get_current_user();
if (isset($current_user)) {
if ($current_user->ID === 0) {
echo 'console.log(\'User is anonymous\');';
} else {
@banagale
banagale / useCreateSessionToken.js
Last active May 12, 2021 14:44
Example custom hook for retrieving an OpenVidu session token, implemented using React Query
import Cookies from "js-cookie";
import { wvApiUrl } from "../../routes";
const fetchUrl = wvApiUrl.ovToken();
export async function useCreateSessionToken(bodyData) {
const response = await fetch(fetchUrl, {
method: 'POST',
body: JSON.stringify(bodyData),
headers: {
@banagale
banagale / frontend.api.views.py
Created May 12, 2021 14:54
A DRF Serializer and APIView defining an endpoint for behavioral analytics events posted from a frontend application
import logging
from rest_framework import serializers
from rest_framework.authentication import SessionAuthentication, TokenAuthentication
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from core.analytics.helpers import track_event
from frontend.api.event_constants import GATHERING_EVENT_ID_MAP
@banagale
banagale / useSendGatheringEvent.js
Created May 12, 2021 15:03
A React Query function that POSTs user behavioral events to /events/ from the frontend
import Cookies from "js-cookie";
import { wvApiUrl } from "../../routes";
const fetchUrl = wvApiUrl.events();
export async function useSendGatheringEvent(bodyData) {
const response = await fetch(fetchUrl, {
method: 'POST',
body: JSON.stringify(bodyData),
headers: {
@banagale
banagale / build.js
Last active May 21, 2024 16:06
An example javascript api-based `esbuild` build script with a watch and automatic post-build bash script execution.
// As discussed in https://github.com/evanw/esbuild/issues/1688
require('esbuild').build({
entryPoints: ['./briefings/frontend/src/briefings.ts'],
outfile: './briefings/frontend/build/briefings-fe.js',
bundle: true,
minify: true,
target: 'es2017',
color: true,
watch: {

Keybase proof

I hereby claim:

  • I am banagale on github.
  • I am ripta (https://keybase.io/ripta) on keybase.
  • I have a public key ASBQIWFoZCW-maRzA_BfwRaYmYBMq8R0wEFhhOIVmYp3wQo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am banagale on github.
  • I am banagale (https://keybase.io/banagale) on keybase.
  • I have a public key ASCiFfGzAc_BnpIu0cz0oaFPn_uOFsOOG4AWJiXAXQ7jigo

To claim this, I am signing this object:

@banagale
banagale / wagtail-database-tables-removal.sql
Created March 21, 2023 16:07
Footgun blast wagtail out of a django installation
--This script removes all tables that start with 'wagtail' and 'taggit' database.
--Use with great caution, slightly modified https://stackoverflow.com/a/4202280
--If you have an app to support wagtail, such as 'blog', uncomment that line at end.
--You will also need to manually remove all related entries from django_migrations (consider extending this to also remove those) to run migrations and get back to clean install
CREATE OR REPLACE FUNCTION footgun(IN _schema TEXT, IN _parttionbase TEXT)
RETURNS void
LANGUAGE plpgsql
AS
$$
DECLARE