Skip to content

Instantly share code, notes, and snippets.

View commadelimited's full-sized avatar

Andy Matthews commadelimited

View GitHub Profile
import sys
word = sys.argv[1] # 'dad'
emoji = sys.argv[2] # 'parrot_dad'
letters = dict(
a=[
[1, 1, 1, 1, 0],
[1, 0, 0, 1, 0],
[1, 0, 0, 1, 0],
emoji = 'square'
letter = 'a'
letters = dict(
a=[
[1, 1, 1, 1, 1, 0],
[1, 0, 0, 0, 1, 0],
[1, 0, 0, 0, 1, 0],
[1, 1, 1, 1, 1, 0],
@commadelimited
commadelimited / temp.py
Created January 20, 2016 19:47
', '.join() fails in script, works in iPython
final = [u'Blokus Trigon', u'Coloretto', u'Friday (2)', u'Luna', u'Mancala (2)', u'Medieval Academy', u'No Thanks! (3)', u'Patchwork', u'Pi\xf1ata', u'Port Royal', u'Rhino Hero', u'Roll For It!', u'Rolling America', u'Star Realms', u'Tsuro']
', '.join(final)
# results in
u'Blokus Trigon, Coloretto, Friday (2), Luna, Mancala (2), Medieval Academy, No Thanks! (3), Patchwork, Pi\xf1ata, Port Royal, Rhino Hero, Roll For It!, Rolling America, Star Realms, Tsuro'
@commadelimited
commadelimited / flask.py
Created November 23, 2014 06:21
Multiple Flask URL routes on a single method
@course.route('/courses/<slug>_<id>/print/')
@course.route('/courses/<slug>_<id>/')
def show_course(slug=None, id=None):
# how do I know whether /print was used, or just normal?
pass
@commadelimited
commadelimited / models.py
Last active November 21, 2020 08:33
Looping over an object somehow adds an extra two interactions
class StudentAssignments(BaseModel):
assignment = ForeignKeyField(Assignment)
student = ForeignKeyField(User)
grade = IntegerField(null=True)
@commadelimited
commadelimited / gist:ec44848faa2ac767e1b1
Created November 19, 2014 22:17
Group, and count, results in a numbered text file.
Given a text file with n numbers of rows, each containing a single integer, sorted in descending order, I want to group (by 10s) and count the results. So for the following content:
100
100
99
87
75
75
72
69

I'm having trouble storing a date into a Peewee DateField for SQLite. I keep getting "Invalid Date" What am I doing wrong? I've tried all three of the options below and all have the same result.

scores = [
('Andy', 85),
('Bob', 92),
('Cindy', 85),
('Dale', 89),
('Edmund', 81),
]
def place(scores):
@commadelimited
commadelimited / Gruntfile.js
Created September 8, 2014 17:00
Gruntfile for Node-webkit project
/*jshint camelcase: false*/
module.exports = function (grunt) {
'use strict';
// load all grunt tasks
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
// An existing code sample I have uses cURL (found below).
// But is there a reason why someone would use the second example instead of the first example?
// They both appear to do the exact same thing, but the first one is MUCH simpler.
// Thoughts?
<?php
$response = file_get_contents("http://feeds.arstechnica.com/arstechnica/index?format=xml");
print_r($response);
?>