Skip to content

Instantly share code, notes, and snippets.

View alxgmpr's full-sized avatar
:shipit:

Alex Gompper alxgmpr

:shipit:
  • TryNow Inc
  • Colorado Springs
View GitHub Profile

Using UCG Ultra + Cloudflare Dynamic DNS + Cloudflare SSL

Motivation

  • Want to expose the Unifi console via a public domain like unifi.mydomain.com.
  • Theoretically if unifi.ui.com goes down this proxy would continue to work.
  • Also just good practice hackin'

Background

Enforcing Singletons

Lateley at work, I've become invested in making sure that we only have one of things. In modern development, we are blessed with patterns that don't require instantiating expensive things, or not having to worry about creating them at all. But when working with service class instances which talk over the wire, it becomes imperative to enforce expensive operations only being done once, and moreover ensuring that multiple consumers of the same singleton don't duplicate requests.

Simple Window Instance

I've found that the easiest way to ensure instantiation only occurs once (in browser contexts) is to use the window.

@alxgmpr
alxgmpr / form_data.md
Last active September 19, 2021 14:47

Sometimes, it is useful to gather form data from a webpage en masse.

The quick-script way to do this is to iterate via document.forms and construct FormData objects for each form on the page.

// es6 spread converts fancy collection obj into plain array
const allForms = [...document.forms]

allForms.forEach((f) => {
  const fd = new FormData(form)
@alxgmpr
alxgmpr / tasks.json
Created August 22, 2019 16:54
Template for how to lay out auto-checkout tasks in JSON format
{
"tasks": [
{
"first_name": "",
"last_name": "",
"email": "",
"phone": "",
"address_1": "",
"address_2": "",
@alxgmpr
alxgmpr / shopify-stop-bots.md
Created June 13, 2019 18:14
A common sense guide to avoiding botted releases

A short guide on how to beat, fool, and trick Shopify bots and prevent them from checking out on your store.

  1. Do not publish products live on the store until drop time. Loading a product live on the site and then quickly un-publishing it has already given away your product to bots and scrapers, which log every product that publishes on your site.

  2. Do not add variants to your product until it is ready to go live. Similar to #1, loading variants of your product before release time gives them away to bots.

  3. Cycle your API keys and credentials for any private app that you use. API keys allow for access to published and unpublished products. If they leak or are revealed, everyone will have backend access to your products. Cycle these often and before releases (before you draft your release products).

  4. Enter password-mode on your storefront well before release time. This will allow any pre-generated checkout sessions to expire and level the playing field once your product releases and goes into a queue.

@alxgmpr
alxgmpr / proxy_finder.py
Created May 31, 2019 22:01
Find peoples sequential and arbitrarily secured proxies!
import requests
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
class ProxyFinder:
def __init__(self):
self.username = 'XXX'
self.password = 'XXX'
@alxgmpr
alxgmpr / cheatsheet.md
Created May 15, 2019 17:48
Tidbits of code, bash scripts, etc. that I commonly find myself Googling

Remove all *.pyc files in a directory

find . -name \*.pyc -delete

Turn off InsecureRequestWarning for unverified requests

import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
@alxgmpr
alxgmpr / dropbox-to-shopify.md
Created May 9, 2019 21:39
Finding the true Dropbox location of images, so that they can be uploaded directly to Shopify.

One of the projects I'm working on right now requires being able to upload product images to Shopify. These images are sourced via Dropbox links, which look something like this: https://www.dropbox.com/s/[some id]/[filename].jpg?dl=0.

Shopify has a feature which allows for API image uploads via URL or via a Base64 encoded attachment. However, when you try and link a Dropbox URL, you will likely encounter an error since Dropbox file extensions are "faux", and aren't the actual location of the image you want.

Searching for a solution to this yeilds little help. The common solution from Shopify indicates that you'd have to download the images via your URL (to do this you must pass ?dl=1), and either encode it to base64 or host it somewhere on your own, then attach the image to your API request.

@alxgmpr
alxgmpr / ebay.py
Created September 6, 2018 03:56
boost ebay views
import requests
LISTINGURL = ''
VIEWS = 200
def main():
for i in range(VIEWS):
r = requests.get(LISTINGURL)
if __name__ == '__main__':
@alxgmpr
alxgmpr / stockx_history.py
Last active September 10, 2021 00:15
Download StockX Sales History
import requests
import json
import threading
import csv
from datetime import datetime
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)