Skip to content

Instantly share code, notes, and snippets.

View VivienGiraud's full-sized avatar
🏒
Freelancing

Vivien Giraud VivienGiraud

🏒
Freelancing
View GitHub Profile
@lysender
lysender / htmx-allow-400-errors-swap-for-validation-errors.md
Created August 19, 2023 13:49
HTMX - Allow HTTP error 400 and 422 swap content to enable showing validation errors

Still a newbie to HTMX.

I was writing some form submit interaction and realized that HTMX won't swap/render if the HTTP status code is not 2xx.

For 404, 500 or 503 errors, I think it's fair enough.

For my use case, I'm returning error 400 or 422 for validation errors. I'm returning the form back with some error decorations for example.

According to the docs, I can change that behavior.

@fransr
fransr / customcsrf.py
Created February 16, 2021 08:30
Hackvertor Custom CSRF tag
import httplib
import urllib
http = httplib.HTTPSConnection('example.com', 443)
cookie = 'your=cookies';
http.request("GET", "/api/v1/csrf", "", {
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36',
'referer': 'https://example.com/',
@fnky
fnky / stripe-keys-and-ids.tsv
Last active July 17, 2024 22:12
Stripe keys and IDs
Prefix Description Notes
ac_ Platform Client ID Identifier for an auth code/client id.
acct_ Account ID Identifier for an Account object.
aliacc_ Alipay Account ID Identifier for an Alipay account.
ba_ Bank Account ID Identifier for a Bank Account object.
btok_ Bank Token ID Identifier for a Bank Token object.
card_ Card ID Identifier for a Card object.
cbtxn_ Customer Balance Transaction ID Identifier for a Customer Balance Transaction object.
ch_ Charge ID Identifier for a Charge object.
cn_ Credit Note ID Identifier for a Credit Note object.
@mfowl
mfowl / ws.harness.py
Created March 4, 2019 19:38
Web Socket Harness
#!/usr/bin/python
import socket,ssl
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
from websocket import create_connection, WebSocket
from urlparse import parse_qs
import argparse
import os
LOOP_BACK_PORT_NUMBER = 8000
@johnkahn
johnkahn / airportTimezones.json
Created January 24, 2019 20:54
Airport Timezones by Airport Code
{
"3BB": "America/Detroit",
"AAA": "Pacific/Tahiti",
"AAB": "Australia/Brisbane",
"AAC": "Africa/Cairo",
"AAD": "Africa/Nairobi",
"AAE": "Africa/Algiers",
"AAF": "America/New_York",
"AAG": "America/Sao_Paulo",
"AAH": "Europe/Berlin",
@helix84
helix84 / timed_cache.py
Last active December 12, 2022 06:49 — forked from jmdacruz/timed_cache.py
Python lru_cache with timeout
from datetime import datetime, timedelta
import functools
def timed_cache(**timedelta_kwargs):
def _wrapper(f):
maxsize = timedelta_kwargs.pop('maxsize', 128)
typed = timedelta_kwargs.pop('typed', False)
update_delta = timedelta(**timedelta_kwargs)
@yocontra
yocontra / gtfs-feeds.json
Last active July 28, 2021 20:59
huge collection of gtfs and gtfs-rt feeds - originally from transit.land
[{"id":"roam-transit/953","type":"gtfs","name":"Roam Transit GTFS","raw":"http://data.trilliumtransit.com/gtfs/roamtransit-banff-ab-ca/roamtransit-banff-ab-ca.zip","location":{"type":"Point","properties":{"name":"Banff, AB, Canada","shortName":"Banff"},"coordinates":[-115.570769,51.178363]}},{"id":"mission-bay-tma/952","type":"gtfs","name":"Mission Bay TMA GTFS","raw":"http://data.trilliumtransit.com/gtfs/missionbay-ca-us/missionbay-ca-us.zip","location":{"type":"Point","properties":{"name":"San Francisco, CA, USA","shortName":"San Francisco"},"coordinates":[-122.419415,37.774929]}},{"id":"avalon-transit/951","type":"gtfs","name":"Avalon Transit","raw":"http://data.trilliumtransit.com/gtfs/avalon-ca-us/avalon-ca-us.zip","location":{"type":"Point","properties":{"name":"Santa Catalina Island, California 90704, USA","shortName":"Santa Catalina Island"},"coordinates":[-118.41631,33.387886]}},{"id":"blue-grass-ultra-transit-service/950","type":"gtfs","name":"Blue Grass Ultra-Transit Service GTFS","raw":"http://dat
@zthxxx
zthxxx / Activate Office 2019 for macOS VoL.md
Last active July 22, 2024 08:35
crack activate Office on mac with license file
@mortenege
mortenege / django_channels_aws_eb_alb.md
Created March 4, 2018 06:48
Django Channels on AWS Elastic Beanstalk using an ALB

Django Channels on AWS Elastic Beanstalk using an ALB

This post will describe how to set up a Django Channels solution using AWS Elastic Beanstalk [EB]. This guide is written in response to there being very little information on the combination of Channels and AWS. Mainly many solutions end with problems regarding websockets, which is a fundamental part of Channels. See here and here. This guide will consist of multiple step-by-step parts including

  • How to set up a local Django Channels solution
  • How to set up an Application Load Balancer [ALB] to serve websockets
  • How to configure EB to deploy Cha
@Lwdthe1
Lwdthe1 / usaCities.js
Last active June 13, 2024 12:53
JSON of 5,950+ USA Cities and Their States - Presented by https://www.ManyStories.com
[
{'city': 'Abbeville', 'state': 'Louisiana'},
{'city': 'Aberdeen', 'state': 'Maryland'},
{'city': 'Aberdeen', 'state': 'Mississippi'},
{'city': 'Aberdeen', 'state': 'South Dakota'},
{'city': 'Aberdeen', 'state': 'Washington'},
{'city': 'Abilene', 'state': 'Texas'},
{'city': 'Abilene', 'state': 'Kansas'},