Skip to content

Instantly share code, notes, and snippets.

View dmpayton's full-sized avatar
🦄
Doin' all the things.

Derek Payton dmpayton

🦄
Doin' all the things.
View GitHub Profile
import board
import time
import neopixel
from random import choice, randint
leds = neopixel.NeoPixel(board.RX, 50, pixel_order=neopixel.RGB)
color = (128, 0, 255)
def permutations(iterable, r=None):
@dmpayton
dmpayton / neopixel_pan_nb.py
Created October 9, 2020 07:21
Pan and NB flag colors on a Neopixel strip on a QTPy
import board
import time
import neopixel
from random import randint, choice
leds = neopixel.NeoPixel(board.RX, 50, pixel_order=neopixel.RGB)
palette = [
# pan
0xff218c,
$ ./scripts/xephyr
./scripts/xephyr: 7: ./scripts/xephyr: [[: not found
_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
(EE)
Fatal server error:
(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE)
2018-05-11 10:40:22,376 libqtile log_utils.py:init_log():L120 Starting logging for Qtile
2018-05-11 10:40:22,377 libqtile confreader.py:from_file():L85 Could not import config file '/home/derek/.config/qtile/config.py'
Traceback (most recent call last):
@dmpayton
dmpayton / cmd.sketch
Created April 26, 2017 02:23
Fresno.py arduino sketch
String incomingByte = ""; // for incoming serial data
bool blinking = false;
int blinkSpeed = 100;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
@dmpayton
dmpayton / Vagrantfile
Created January 19, 2017 23:04
Django/Node Vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/xenial64"
# Forward a port from the guest to the host, which allows for outside
# computers to access the VM, whereas host only networking does not.
@dmpayton
dmpayton / keybase.md
Last active July 4, 2019 01:40
keybase.md

Keybase proof

I hereby claim:

  • I am dmpayton on github.
  • I am dmpayton (https://keybase.io/dmpayton) on keybase.
  • I have a public key ASDKF0XQ4DJ6RgbyT_axfdilCrfqU8R8X54fzRyxU7G6vgo

To claim this, I am signing this object:

@dmpayton
dmpayton / parse_datetime.py
Created September 19, 2016 05:30
dateutil + parsedatetime
import dateutil.parser
import parsedatetime
def parse_datetime(value):
try:
return dateutil.parser.parse(value)
except ValueError:
# Unknown string format
cal = parsedatetime.Calendar()
@dmpayton
dmpayton / README
Created July 27, 2016 03:11
FresnoPython web crawler demo
1. `mkvirtualenv philosophy -p /usr/bin/python3.5`
2. Install dependencies:
`pip install requests beautifulsoup4`
3a. run `python crawler.py`
3b. run `python crawler.py <article_slug>`
4. Profit^wPhilosophy
@dmpayton
dmpayton / gitweb.py
Last active January 28, 2016 09:30
Django+Git server proof of concept
import itertools
from django.conf import settings
from django.conf.urls import url
from django.http import HttpResponse
from django.utils.decorators import classonlymethod
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import View
from dulwich.repo import Repo
@dmpayton
dmpayton / pypi-versions.py
Created May 13, 2015 20:31
Check a requirements.txt for updated packages
#!/usr/bin/env python
''' Get a list of out-of-date packages from a pip requirements.txt file. '''
import itertools
import json
import requests
import sys