Skip to content

Instantly share code, notes, and snippets.

View foger's full-sized avatar

Serg Foger foger

View GitHub Profile
@foger
foger / curl.md
Created September 7, 2018 13:28 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@foger
foger / curl_token.md
Created September 10, 2018 09:21
CURL: token and request example

Get token:

curl -X POST -H "Content-Type: application/json" -d '{"username": "john", "password": "password"}' http://localhost:8080/api-token-auth/

Request:

curl -X GET -H "Authorization: Token <token>" http://localhost:8080/users/33456/ | json_pp
@foger
foger / dump
Created October 23, 2018 09:57
Dump
12:15:13.226201 18:a6:f7:71:70:b1 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 10.71.224.1 tell 10.71.225.223, length 46
12:16:07.152997 18:a6:f7:71:70:b1 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 10.71.225.223 tell 10.71.225.223, length 46
12:17:08.151867 18:a6:f7:71:70:b1 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 10.71.225.223 tell 10.71.225.223, length 46
12:18:09.150929 18:a6:f7:71:70:b1 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 10.71.225.223 tell 10.71.225.223, length 46
12:19:10.150006 18:a6:f7:71:70:b1 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 10.71.225.223 tell 10.71.225.223, length 46
12:20:11.149077 18:a6:f7:71:70:b1 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 10.71.225.223 tell 10.71.225.223, length 46
12:21:12.148137 18:a6:f7:71:70:b1 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 10.71.225.223 tell 1
@foger
foger / dump2
Created October 23, 2018 10:00
Dump2
12:26:39.633548 18:a6:f7:71:70:b1 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 10.71.224.1 tell 10.71.225.223, length 46
12:26:39.648976 18:a6:f7:71:70:b1 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 10.71.224.1 tell 10.71.225.223, length 46
12:26:43.730693 18:a6:f7:71:70:b1 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 10.71.224.1 tell 10.71.225.223, length 46
12:26:43.740123 18:a6:f7:71:70:b1 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 10.71.224.1 tell 10.71.225.223, length 46
12:26:43.740213 18:a6:f7:71:70:b1 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 10.71.224.1 tell 10.71.225.223, length 46
12:26:43.762777 18:a6:f7:71:70:b1 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 10.71.224.1 tell 10.71.225.223, length 46
12:26:44.761346 18:a6:f7:71:70:b1 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 60: Request who-has 10.71.224.1 tell 10.71.225.223
@foger
foger / sql_replace_in_django_orm.py
Created November 21, 2018 10:58 — forked from simonw/sql_replace_in_django_orm.py
How to use the SQL replace function in a Django ORM query
from django.db.models import F, Func, Value
from myapp.models import MyModel
# Annotation
MyModel.objects.filter(description__icontains='\r\n').annotate(
fixed_description=Func(
F('description'),
Value('\r\n'), Value('\n'),
function='replace',
)