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
amites / PROJECT.service
Created Apr 25, 2019
Nginx & Gunicorn Boilerplate Config
View PROJECT.service
[Unit]
Description=Gunicorn PROJECTNAME Daemon
After=network.target
[Service]
User=VALIDUSER
Group=www-data
WorkingDirectory=/PATH/TO/PROJECT/ROOT
ExecStart=/PATH/TO/GUNICORN/bin/gunicorn --workers 3 --bind unix:/PATH/TO/PROJECT/ROOT/PROJECTNAME.sock PROJECTDIR.wsgi:application
[Install]
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
amites / attr_wtf.py
Created Feb 24, 2017
Why do I get a different result from `getattr` and a direct attribute call?
View attr_wtf.py
# 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
amites / installfest.md
Last active Nov 16, 2016
Installfest 1
View installfest.md

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
amites / unit_test_exmple.py
Created Oct 30, 2016
Python unit testing example.
View unit_test_exmple.py
import unittest
class TestStringMethods(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')
def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())
@amites
amites / README-class-18.md
Created Sep 19, 2016
Extending Django project hello_world with the admin, views and extending models.
View README-class-18.md

This section will continue from our Davinci Django project.

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

Open hello_world/models.py and add 2 fields to StuffToRate

ex:

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

In Terminal run the following commands

    virtualenv  VIRTUALENV_NAME
    cd VIRTUALENV_NAME
    source bin/activate
    pip install django ipython
@amites
amites / camel_case.py
Created Sep 10, 2016
Camel Case Code Wars
View camel_case.py
# https://www.codewars.com/kata/convert-string-to-camel-case/train/python
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)
View code_wars_signup.py
# solution to entry problem 1
def multiply(a, b):
return a * b
# solution to entry problem 2
class Person:
def __init__(self, name):
self.name = name
@amites
amites / setup_TP-WN722NC.sh
Last active Sep 5, 2015
Bash script to setup a TL-WN722NC as an available wifi dongle onto a bbb.
View setup_TP-WN722NC.sh
#!/bin/bash
# install linux headers
wget https://raw.github.com/gkaindl/beaglebone-ubuntu-scripts/master/bb-get-rcn-kernel-source.sh
chmod +x bb-get-rcn-kernel-source.sh
sudo ./bb-get-rcn-kernel-source.sh
# download backports drivers
wget https://www.kernel.org/pub/linux/kernel/projects/backports/stable/v3.16/backports-3.16-1.tar.gz
tar xvfz backports-3.16-1.tar.gz
You can’t perform that action at this time.