Skip to content

Instantly share code, notes, and snippets.

Jessamyn Smith jessamynsmith

Block or report user

Report or block jessamynsmith

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
View gist:67344a7c26cef59a273ec76ab64a2992
#!/usr/bin/env bash
# Bash scope experiments
func ()
{
echo "in func: param1: $1, param2: $2, var1: $var1, var2: $var2"
}
var1=$1
View Promise test
function myAsyncFunction(url) {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.onload = () => resolve(xhr.responseText);
xhr.onerror = () => reject(xhr.statusText);
xhr.send();
});
}
View See types of attributes on a Python class
>>> class MyClass:
... """ hello """
... attr1 = 'hello'
... attr2 = 23
...
... def method1(self):
... return self.attr1
...
... def __str__(self):
... return '{} {}'.format(attr1, attr2)
@jessamynsmith
jessamynsmith / gist:32afb8a05d7b59965e6dbf48852acabc
Created Sep 27, 2018
Installing mysqlclient with python3 on OSX
View gist:32afb8a05d7b59965e6dbf48852acabc
$ pip install mysqlclient
Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz
Building wheels for collected packages: mysqlclient
Running setup.py bdist_wheel for mysqlclient ... error
Complete output from command /Users/jessamyn/.virtualenvs/django-mysql-test/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/nj/cf50gt6s7x97fk9gqg7h6xr00000gn/T/pip-install-0d9salg8/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/nj/cf50gt6s7x97fk9gqg7h6xr00000gn/T/pip-wheel-bgng27ta --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
View How to Debug an Exception
1. Read the stack trace carefully. In particular, look for:
a) The name and text of the exception
b) Where the trace enters your code
2. Go to the lowest level in your code that the stack trace showed
3. Look carefully at the line of code throwing the error, and the preceeding lines, and see if you can see how they relate to the exception you got.
4. Try to imagine what values the variables might have had at this point, to generate the exception you saw.
5. If you have a debugger, set a breakpoint on this line and inspect all relevant variables. If you don’t have access to a debugger, print out the values of the variables.
6. If you can see a value that looks bad, follow that variable up through the program to see where it came from and why it’s incorrect.
7. If you can’t see any values that look bad, rethink you assumptions about what caused the error.
View gist:2a92920f011c382370e0
from codementor import models as codementor_models
from django.db.models import Sum
payments = codementor_models.Payment.objects.all().order_by('date')
payments.count()
payments[:5]
payment_values = payments.values_list('date').annotate(total_earnings=Sum('earnings'))
payment_values.count()
payment_values[:5]
@jessamynsmith
jessamynsmith / gist:9482c1ff01720af385da
Created Oct 23, 2015
Error when clicking sidemenu entry in project run in iOS simulator with XCode 7
View gist:9482c1ff01720af385da
[Error] Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.4.3/$rootScope/infdig?p0=10&p1=%5B%5D
file:///Users/jessamyn/Library/Developer/CoreSimulator/Devices/80FF3AB8-32B7-40D8-B6B5-E90F6A41A36C/data/Containers/Bundle/Application/D3A4B7C1-F54B-4B3A-9268-89EAB08D3562/HelloCordova.app/www/lib/ionic/js/ionic.bundle.js:8895:32
$digest@file:///Users/jessamyn/Library/Developer/CoreSimulator/Devices/80FF3AB8-32B7-40D8-B6B5-E90F6A41A36C/data/Containers/Bundle/Application/D3A4B7C1-F54B-4B3A-9268-89EAB08D3562/HelloCordova.app/www/lib/ionic/js/ionic.bundle.js:24548:35
$apply@file:///Users/jessamyn/Library/Developer/CoreSimulator/Devices/80FF3AB8-32B7-40D8-B6B5-E90F6A41A36C/data/Containers/Bundle/Application/D3A4B7C1-F54B-4B3A-9268-89EAB08D3562/HelloCordova.app/www/lib/ionic/js/ionic.bundle.js:24778:31
file:///Users/jessamyn/Library/Developer/CoreSimulator/Devices/80FF3AB8-32B7-40D8-B6B5-E90F6A41A36C/data/Containers/Bundle/Appl
View index.html
<div class="container">
<div class="big">
<div class="medium">
<div class="small">
</div>
</div>
</div>
</div>
@jessamynsmith
jessamynsmith / gist:5334087
Created Apr 8, 2013
South import failing, due to earlier mangling of modules by nose
View gist:5334087
Traceback (most recent call last):
File "/Applications/PyCharm.app/helpers/pycharm/django_test_manage.py", line 113, in <module>
utility.execute()
File "/Applications/PyCharm.app/helpers/pycharm/django_test_manage.py", line 89, in execute
PycharmTestCommand().run_from_argv(self.argv)
File "/Users/jessamyn/.virtualenvs/MapStore/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/jessamyn/.virtualenvs/MapStore/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/Applications/PyCharm.app/helpers/pycharm/django_test_manage.py", line 76, in handle
You can’t perform that action at this time.