Skip to content

Instantly share code, notes, and snippets.

Alvin Mites amites

Block or report user

Report or block amites

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
amites / PROJECT.service
Created Apr 25, 2019
Nginx & Gunicorn Boilerplate Config
View PROJECT.service
Description=Gunicorn PROJECTNAME Daemon
ExecStart=/PATH/TO/GUNICORN/bin/gunicorn --workers 3 --bind unix:/PATH/TO/PROJECT/ROOT/PROJECTNAME.sock PROJECTDIR.wsgi:application
View gist:07eaa8f7b494454f9f002922862b9c73
fundweb_1 | fail: Microsoft.EntityFrameworkCore.Update[10000]
fundweb_1 | An exception occurred in the database while saving changes for context type 'FundWeb.Data.FundWebContext'.
fundweb_1 | System.InvalidOperationException: A second operation started on this context before a previous operation completed. Any instance members are not guaranteed to be thread safe.
fundweb_1 | at Microsoft.EntityFrameworkCore.Internal.ConcurrencyDetector.EnterCriticalSection()
fundweb_1 | at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.<SaveChangesAsync>d__61.MoveNext()
fundweb_1 | --- End of stack trace from previous location where exception was thrown ---
fundweb_1 | at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
fundweb_1 | at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
fundweb_1 | at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
fundweb_1 |
amites /
Created Feb 24, 2017
Why do I get a different result from `getattr` and a direct attribute call?
# function being called
# Use case is within a migration
# apps = `from django.apps import apps` -- within a migration
# model_name = str lowercase model name
def blob_to_file(apps, model_name, text_field_name, file_field_name):
Upload existing TextField json blobs to files.
amites /
Last active Nov 16, 2016
Installfest 1

Welcome to Introduction to Python Programming

If you are unable or uncomfortable with installing programs to your computer you can use the following web-site. It will be fully functional for this bootcamp but will not provide some useful shortcuts.

OSX / Linux

  • Python is already installed -- =)

  • Install easy_install

amites /
Created Oct 30, 2016
Python unit testing example.
import unittest
class TestStringMethods(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')
def test_isupper(self):
amites /
Created Sep 19, 2016
Extending Django project hello_world with the admin, views and extending models.

This section will continue from our Davinci Django project.

First we'll update our existing models to include additional fields.

Open hello_world/ and add 2 fields to StuffToRate


	color = models.CharField(max_length=100, default='Green')
	description = models.TextField()
amites /
Last active Sep 19, 2016
README to setup a new django project.

In Terminal run the following commands

    virtualenv  VIRTUALENV_NAME
    source bin/activate
    pip install django ipython
amites /
Created Sep 10, 2016
Camel Case Code Wars
def to_camel_case(text):
text_list = text.replace('-', '_').split('_')
answer_list = [text_list[0], ]
for word in text_list[1:]:
answer_list.append( word.title() )
return ''.join(answer_list)
# solution to entry problem 1
def multiply(a, b):
return a * b
# solution to entry problem 2
class Person:
def __init__(self, name): = name
amites /
Last active Sep 5, 2015
Bash script to setup a TL-WN722NC as an available wifi dongle onto a bbb.
# install linux headers
chmod +x
sudo ./
# download backports drivers
tar xvfz backports-3.16-1.tar.gz
You can’t perform that action at this time.