Skip to content

Instantly share code, notes, and snippets.

View wchesley's full-sized avatar
🔜
20 GOTO 10

Walker Chesley wchesley

🔜
20 GOTO 10
View GitHub Profile
@wchesley
wchesley / validateIpv4Address.cs
Created May 19, 2023 18:29
Validate IPv4 Address C#
/// <summary>
/// Tests string to see if it is valid IPv4 address
/// </summary>
/// <param name="ip">String to test</param>
/// <returns>True if string is IP address, False otherwise</returns>
private bool ValidateIpv4Address(string ip)
{
IPAddress address;
return ip != null && ip.Count(c => c == '.') == 3 &&
IPAddress.TryParse(ip, out address);
@wchesley
wchesley / django-postgres-docker.md
Last active January 26, 2020 22:00
Docker set up files for django and postgres, using docker-compose v3.7

Django, Postgres & Docker

First we need to set up a docker python environment:

FROM python:3.7.6-slim

# Set environment varibles
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set work directory
@wchesley
wchesley / Gitea to mirror github.md
Created December 18, 2019 15:45
Gitea mirror to github

Gitea to mirror github

In the instance you want to migrate all of your GitHub repositories to gitea, instead of manually importing all repos to github and setting them up to mirror we can import them all at once. When I add a repository to Gitea and specify I want it to be mirrored, Gitea will take charge of periodically querying the source repository and pulling changes in it. I’ve mentioned Gitea previously, and I find it’s improving as it matures. I’ve been doing this with version 1.7.5.

After setting up Gitea and creating a user, I create an API token in Gitea with which I can create repositories programatically. The following program will obtain a list of all Github repositories I have, skip those I’ve forked from elsewhere, and then create the repository in Gitea.

#!/usr/bin/env python -B