Skip to content

Instantly share code, notes, and snippets.

View jessamynsmith's full-sized avatar

Jessamyn Smith jessamynsmith

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title of the document</title>
</head>
<body>
<svg height="210" width="500">
<polygon points="100,10 40,198 190,78 10,78 160,198" style="fill:lime;stroke:purple;stroke-width:5;fill-rule:nonzero;"/>
</svg>
#!/usr/bin/env bash
# Bash scope experiments
func ()
{
echo "in func: param1: $1, param2: $2, var1: $var1, var2: $var2"
}
var1=$1
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();
});
}
>>> 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 September 27, 2018 23:59
Installing mysqlclient with python3 on OSX
$ 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
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.
*
*
~
~~~
****** ~~~~~ ******
~~~
~
*
*
@jessamynsmith
jessamynsmith / gist:2a92920f011c382370e0
Created October 28, 2015 13:42
Using Django aggregates
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 October 23, 2015 00:57
Error when clicking sidemenu entry in project run in iOS simulator with XCode 7
[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
<div class="container">
<div class="big">
<div class="medium">
<div class="small">
</div>
</div>
</div>
</div>