Skip to content

Instantly share code, notes, and snippets.

View alexphelps's full-sized avatar
🤔

Alex Phelps alexphelps

🤔
View GitHub Profile
@alexphelps
alexphelps / clean_translations.py
Last active February 6, 2024 02:05
clean translations
import os
import json
import pathlib
directory = "./"
locale_file = "./locales/en.default.json"
def search_html_files(directory, search_string):
result = False
for root, dirs, files in os.walk(directory):
@alexphelps
alexphelps / 29next-storefront-api.md
Created November 30, 2022 04:10
29 Next Storefront API Guide

Storefront GraphQL API

GraphQL Endpoint - https://<store domain>/api/graphql/

Use the GraphiQL browser client to write, validate, and test your GraphQL queries.

Customer

me

Returns current user account information.

@alexphelps
alexphelps / nginx.conf
Last active August 27, 2021 01:57
Nginx Block File Scanners
server {
# ...
location ~ \.(asp|aspx|axd|asx|asmx|ashx|cfm|jsp|jspx|do|action|pl|php|php3|php4|phtml|py|rb|rhtml|ini|stm|net|env|cgi|dll|fcgi|conf)$ {
return 410;
}
# ...
@alexphelps
alexphelps / natural_language_time_periods.py
Created January 26, 2020 07:07 — forked from psychemedia/natural_language_time_periods.py
Simple python functions to give dates and date ranges in "natural time"; this week, next month, etc.
import datetime
from dateutil.relativedelta import relativedelta
def today(date=None,iso=False):
if date is None: date=datetime.date.today()
if iso: return date.isoformat()
else: return date
def yesterday(date=None,iso=False):
if date is None: date=today()
@alexphelps
alexphelps / calls.json
Created February 7, 2019 10:27
Calls API Response
{
"count": 43,
"next": "https://app.calltracker.io/api/calls/?limit=100&offset=100",
"previous": null,
"results": [
{
"id": 48155,
"timestamp": "2018-07-25T19:41:12.786731Z",
"status": "answered",
"company_id": 1000,
@alexphelps
alexphelps / get_auth_token.js
Created November 30, 2017 18:45
Postman Get Oauth Bear Token Prescript with Username & Password
// grab our env variables for access
var domain = pm.environment.get("domain");
var username = pm.environment.get('username');
var password = pm.environment.get('password');
// Send request to get token and set as env variabled {{authorization}}
pm.sendRequest({
url: domain + '/api/token',
method: 'POST',
header: {
@alexphelps
alexphelps / django_db_query_info.py
Created September 14, 2017 15:28
Django DB Query Info Time & Count
from django.db import connection
sqltime = 0
for query in connection.queries:
sqltime += float(query["time"])
print('Page render: ' + str(sqltime) + 'sec for ' + str(len(connection.queries)) + 'queries')
@alexphelps
alexphelps / ltc-mining.sh
Created September 12, 2017 21:37 — forked from gfranchini/ltc-mining.sh
Litecoin CPU Mining setup on Ubuntu Server
#!/bin/bash
#
# Litecoin CPU Mining setup on Ubuntu Server
#
sudo apt-get update;
# install prerequisit software/libs
sudo apt-get -y install make automake build-essential libcurl4-openssl-dev htop
@alexphelps
alexphelps / event_save.py
Last active September 8, 2017 18:27
Event save
class ModelDiffMixin(object):
"""
Ref: https://stackoverflow.com/questions/1355150/django-when-saving-how-can-you-check-if-a-field-has-changed
"""
def __init__(self, *args, **kwargs):
super(ModelDiffMixin, self).__init__(*args, **kwargs)
self.__initial = self._dict
@property
def _dict(self):
@alexphelps
alexphelps / ecs-compose.yml
Last active September 1, 2017 13:12
ECS Compose
---
version: '2'
services:
nginx:
image: "#####.dkr.ecr.us-east-1.amazonaws.com/nginx:latest"
cpu_shares: 50
mem_limit: 104857600
logging:
driver: awslogs
options: