I hereby claim:
- I am gen1us2k on github.
- I am andrewminkin (https://keybase.io/andrewminkin) on keybase.
- I have a public key ASAM-UwP8DtGVASlZTslau5CciVo-n0SKMG7fluUJinMGgo
To claim this, I am signing this object:
package main | |
import ( | |
"crypto/tls" | |
"crypto/x509" | |
"encoding/base64" | |
"encoding/json" | |
"fmt" | |
"io/ioutil" | |
"log" |
I hereby claim:
To claim this, I am signing this object:
package main | |
import ( | |
"context" | |
"fmt" | |
"net/http" | |
"os" | |
client "github.com/ory/hydra-client-go" | |
) |
from django import forms | |
class ForecastForm(forms.Form): | |
city = forms.CharField() | |
def clean_city(self): | |
if 'city' not in self.cleaned_data: | |
raise forms.ValidationError("Invalid city", "invalid") | |
return self.cleaned_data['city'] |
def test_weather_forecast(client): | |
settings.API_KEY = 'key' | |
response = client.get(reverse('forecast'), data={"city": "Los Angeles"}) | |
data = json.loads(response.content) | |
assert {'lat': 34.05, 'lon': -118.24} == data.get('coord') | |
assert "Los Angeles" == data.get('name') |
import pytest | |
import json | |
from django.urls import reverse | |
@pytest.mark.django_db | |
def test_empty_list_of_users(client): | |
response = client.get(reverse('list-users')) | |
data = json.loads(response.content) |
import requests | |
from django.http import JsonResponse | |
from django.conf import settings | |
from django.contrib.auth.models import User | |
from .forms import ForecastForm | |
def list_users(request): | |
return JsonResponse({"users": [{ | |
"username": u.username, "first_name": u.first_name, |
# Install ARCH Linux with encrypted file-system and UEFI | |
# The official installation guide (https://wiki.archlinux.org/index.php/Installation_Guide) contains a more verbose description. | |
# Download the archiso image from https://www.archlinux.org/ | |
# Copy to a usb-drive | |
dd if=archlinux.img of=/dev/sdX bs=16M && sync # on linux | |
# Boot from the usb. If the usb fails to boot, make sure that secure boot is disabled in the BIOS configuration. | |
# Set swedish keymap |
package main | |
import ( | |
"log" | |
"net" | |
"os/exec" | |
"github.com/hsheth2/water" | |
) |
res, err := conn.Exec("INSERT INTO users (name) VALUES(\"Peter\")") | |
if err != nil { | |
panic(err) | |
} | |
id, err := res.LastInsertId() | |
if err != nil { | |
panic(err) | |
} | |
fmt.Printf("Created user with id:%d", id) | |
var user User |