Skip to content

Instantly share code, notes, and snippets.

View wsvincent's full-sized avatar

Will Vincent wsvincent

View GitHub Profile
@wsvincent
wsvincent / tests.yaml
Created October 27, 2023 23:42
GitHub Actions CI
name: Continuous Integration
on:
- push
- pull_request
jobs:
test:
name: Run Python/Django Tests
runs-on: ubuntu-latest
@wsvincent
wsvincent / _base.html
Created July 9, 2020 18:49
LearnDjango.com OG stuff
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>{% block title %}LearnDjango{% endblock title %} | LearnDjango.com</title>
<meta name="author" content="Learn Django">
<meta name="description" content="{% block description %}Tutorials and courses on web development with Python and the Django Web Framework. {% endblock description %}">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1,
shrink-to-fit=no">
version: '3.7'
services:
web:
build: .
command: python /code/manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- 8000:8000
@wsvincent
wsvincent / admin.py
Created November 2, 2018 19:23
Django Custom User Model for any new project
# users/admin.py
from django.contrib import admin
from django.contrib.auth import get_user_model
from django.contrib.auth.admin import UserAdmin
from .forms import CustomUserCreationForm, CustomUserChangeForm
from .models import CustomUser
class CustomUserAdmin(UserAdmin):
add_form = CustomUserCreationForm
@wsvincent
wsvincent / course_detail.html
Last active July 26, 2018 18:54
Django slugs ex w/in a "courses" app
{% extends 'base.html' %}
{% block content %}
<div class="container">
<h2>{{ object.title }}</h2>
<p>Author: {{ object.author}}</p>
<p>Description: {{ object.description }}</p>
<p>Sections:</p>
<ul>
{% for section in course.sections.all %}
import csv
from school.models import Zipcode
def import_us_population():
for csvfile in (
'school_data/us_population_2014.csv',
):
with open(csvfile, 'rU') as csvinput:
@wsvincent
wsvincent / permutations.js
Created April 28, 2017 17:16
Permutations in JavaScript
// notes on this discussion from http://stackoverflow.com/questions/9960908/permutations-in-javascript
@wsvincent
wsvincent / hello.py
Created December 16, 2016 21:49
Python3
print("Hi Haya");
@wsvincent
wsvincent / gist:6ae3cb4b2f5293587fa1
Last active August 29, 2015 14:02
brew install elasticsearch 404 error
~ brew --config
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew.git
HEAD: e8e2df1f67090d2d9d6b4a8440891a920727cd2a
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: 8-core 64-bit ivybridge
OS X: 10.9.3-x86_64
Xcode: 5.1.1
CLT: 5.1.0.0.1.1396320587