Skip to content

Instantly share code, notes, and snippets.

@sameerkumar18
sameerkumar18 / casparser_php_example.php
Last active May 20, 2023 20:21
Example to call CASParser.in APIs sending Binary File
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://portfolio-parser.api.casparser.in/v2/cams_karvy/parse',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
{"Etc/GMT+12": "Dateline Standard Time", "Etc/GMT+11": "UTC-11", "Pacific/Pago_Pago": "UTC-11", "Pacific/Niue": "UTC-11", "Pacific/Midway": "UTC-11", "America/Adak": "Aleutian Standard Time", "Pacific/Honolulu": "Hawaiian Standard Time", "Pacific/Rarotonga": "Hawaiian Standard Time", "Pacific/Tahiti": "Hawaiian Standard Time", "Pacific/Johnston": "Hawaiian Standard Time", "Etc/GMT+10": "Hawaiian Standard Time", "Pacific/Marquesas": "Marquesas Standard Time", "America/Anchorage": "Alaskan Standard Time", "America/Juneau": "Alaskan Standard Time", "America/Metlakatla": "Alaskan Standard Time", "America/Nome": "Alaskan Standard Time", "America/Sitka": "Alaskan Standard Time", "America/Yakutat": "Alaskan Standard Time", "Etc/GMT+9": "UTC-09", "Pacific/Gambier": "UTC-09", "America/Tijuana": "Pacific Standard Time (Mexico)", "America/Santa_Isabel": "Pacific Standard Time (Mexico)", "Etc/GMT+8": "UTC-08", "Pacific/Pitcairn": "UTC-08", "America/Los_Angeles": "Pacific Standard Time", "America/Vancouver": "Pacific Stan
@sameerkumar18
sameerkumar18 / bpp_var_weight.py
Created January 8, 2022 16:19
Bin Packing with Variable Weight BPP - using PuLP
from pulp import pulp, constants as pulp_constants
items = [("a", 2), ("b", 0.5), ("c", 0.5), ("d", 0.5), ("e", 0.5), ("f", 0.5)]
itemCount = len(items)
maxBins = 3
binCapacity = [4, 2, 2, 2] * 4
binCost = binCapacity
y = pulp.LpVariable.dicts('BinUsed',
@sameerkumar18
sameerkumar18 / wix_blogs_scraper.py
Last active December 28, 2021 10:21
Export Wix Blogs to CSV - No API needed.
responses = []
WIX_SITE_URL = 'https://www.YOUR WIX SITE.com'
import xmltodict
import requests
import json
import csv
def get_blog_posts_urls():
@sameerkumar18
sameerkumar18 / yourapp_admin.py
Last active January 16, 2024 08:12
Django Admin: Celery Retry Task by ID
# Add this code in any Django app's admin.py
# Works for all Task Statuses; you can filter them in line 12.
import ast
import importlib
import json
from django.contrib import admin
from django.contrib import messages
from django.utils.safestring import mark_safe
@sameerkumar18
sameerkumar18 / epList.json
Created October 1, 2021 12:15
EasyPost JSON for all Shipping Carriers and their Predefined Packages, Service Levels
{"AmazonMws":{"predefinedPackages":[],"serviceLevels":["UPS Rates","USPS Rates","FedEx Rates","UPS Labels","USPS Labels","FedEx Labels","UPS Tracking","USPS Tracking","FedEx Tracking"]},"APC":{"predefinedPackages":[],"serviceLevels":["parcelConnectBookService","parcelConnectExpeditedDDP","parcelConnectExpeditedDDU","parcelConnectPriorityDDP","parcelConnectPriorityDDPDelcon","parcelConnectPriorityDDU","parcelConnectPriorityDDUDelcon","parcelConnectPriorityDDUPQW","parcelConnectStandardDDU","parcelConnectStandardDDUPQW","parcelConnectPacketDDU"]},"Asendia":{"predefinedPackages":[],"serviceLevels":["PMI","ePacket","IPA","ISAL"]},"AsendiaUsa":{"predefinedPackages":[],"serviceLevels":["ADS","AirFreightInbound","AirFreightOutbound","AsendiaDomesticBoundPrinterMatterExpedited","AsendiaDomesticBoundPrinterMatterGround","AsendiaDomesticFlatsExpedited","AsendiaDomesticFlatsGround","AsendiaDomesticParcelGroundOver1lb","AsendiaDomesticParcelGroundUnder1lb","AsendiaDomesticParcelMAXOver1lb","AsendiaDomesticParcelMAXUnder1
@sameerkumar18
sameerkumar18 / currency_code.json
Last active August 2, 2020 22:18
An array of all Currency Name, Symbol, Code, Decimal Code
[
{
"name": "Albania Lek",
"code": "ALL",
"decimal_code": "&#76;&#101;&#107;",
"sign": "Lek"
},
{
"name": "Afghanistan Afghani",
"code": "AFN",
@sameerkumar18
sameerkumar18 / cleanup_git.sh
Last active November 2, 2019 12:10
Remove all merged branches older than X months
#!/bin/sh
for k in $(git branch | sed /\*/d); do
if [ -n "$(git log -1 --before='4 months ago' -s $k)" ]; then
git branch -d $k
git push origin --delete $k
fi
done
@sameerkumar18
sameerkumar18 / views.py
Created May 12, 2019 15:37
Shopify 429, 5XX and malformed JSON patch
# For handling Shopify 429 - https://gist.github.com/wowkin2/079844c867a1a06ce15ea1e4ffdee87c
def patch_shopify():
connection_func = ShopifyConnection._open
decode_func = formats.JSONFormat.decode
def patch_decode(resource_string):
count_format_error = 0
while count_format_error <= 2:
try:
@sameerkumar18
sameerkumar18 / regex_validation.py
Created May 30, 2018 04:42
Self help - Regex Validation
'''
To match Date such as "20-21-2018"
(\d{2})[/.-](\d{2})[/.-](\d{4})$
To match Mobile number such as "9810284901"
^[0][1-9]\d{9}$|^[1-9]\d{9}$
To match a URL
^.*http.*$
'''
import requests