Skip to content

Instantly share code, notes, and snippets.

View neeksor's full-sized avatar
🐷
oink

nick neeksor

🐷
oink
View GitHub Profile
@evandempsey
evandempsey / shopify_app_bridge_token_django_rest_framework.py
Last active December 7, 2023 01:18
Setting up token authentication for Shopify App Bridge embedded apps in Django with Django Rest Framework
# Put the following in shopify_app.authentication.py. This assumes we have a
# custom User model in shopify_app.models with a unique myshopify_domain
# attribute. The Shopify app API key and shared secret are imported from
# settings.py.
import datetime
import jwt
from datetime import timezone
from rest_framework import authentication
from rest_framework import exceptions
@certator
certator / Dockerfile
Last active August 10, 2021 17:17
celery ETA+gevent bug
FROM python:3.7.8-alpine3.12
RUN apk add --no-cache python3-dev libffi-dev gcc musl-dev make git
#RUN pip install redis gevent fire
#RUN pip install celery==4.4.6
#RUN pip install git+https://github.com/celery/celery.git@455e0a0e86679eaaba9f0da533066627b1d79296#egg=celery
WORKDIR /app
COPY requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
@rengler33
rengler33 / scrape_with_logs.py
Last active March 22, 2024 05:01
How to Capture Network Traffic When Scraping with Selenium & Python
# see rkengler.com for related blog post
# https://www.rkengler.com/how-to-capture-network-traffic-when-scraping-with-selenium-and-python/
import json
import pprint
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
capabilities = DesiredCapabilities.CHROME
#!/bin/bash
#
# This script will launch and configure a step-ca SSH Certificate Authority
# with OIDC and AWS provisioners
#
# See https://smallstep.com/blog/diy-single-sign-on-for-ssh/ for full instructions
OIDC_CLIENT_ID="[OAuth client ID]" # from Google
OIDC_CLIENT_SECRET="[OAuth client secret]" # from Google
ALLOWED_DOMAIN="[the domain name of accounts your users will use to sign to Google]"
# https://hakibenita.com/fast-load-data-python-postgresql
from typing import Iterator, Dict, Any, Optional
from urllib.parse import urlencode
import datetime
#------------------------ Profile
import time
@hakib
hakib / admin.py
Last active January 22, 2024 15:18
How to Turn Django Admin Into a Lightweight Dashboard
# https://hakibenita.com/how-to-turn-django-admin-into-a-lightweight-dashboard
from django.contrib import admin
from django.db.models import Count, Sum, Min, Max, DateTimeField
from django.db.models.functions import Trunc
from . import models
def get_next_in_date_hierarchy(request, date_hierarchy):
from selenium import webdriver
from selenium.webdriver.common.proxy import Proxy
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.chrome.options import Options
import zipfile,os
def proxy_chrome(PROXY_HOST,PROXY_PORT,PROXY_USER,PROXY_PASS):
manifest_json = """
{
@bogsio
bogsio / ner.py
Last active February 29, 2020 00:18
NER Python
# https://nlpforhackers.io/named-entity-extraction/
import os
import string
import collections
import pickle
from collections import Iterable
from nltk.tag import ClassifierBasedTagger
from nltk.chunk import ChunkParserI, conlltags2tree, tree2conlltags
@jessepearson
jessepearson / adding_new_webhook_topics.php
Last active September 14, 2023 10:27
How to add a new custom Webhook topic in WooCommerce, with example of order filtering.
<?php // do not copy this line
/**
* add_new_topic_hooks will add a new webhook topic hook.
* @param array $topic_hooks Esxisting topic hooks.
*/
function add_new_topic_hooks( $topic_hooks ) {
// Array that has the topic as resource.event with arrays of actions that call that topic.
@zbyte64
zbyte64 / async_app.py
Created May 26, 2016 20:47
Asyncio Views With Django
import asyncio
from django import http
from django.core.urlresolvers import set_script_prefix
from django.utils.encoding import force_str
from django.core.handlers.wsgi import get_script_name
from django_wsgi.handler import DjangoApplication
import logging
import logging
import sys