Skip to content

Instantly share code, notes, and snippets.

View azdle's full-sized avatar

Patrick Barrett azdle

View GitHub Profile
begin;
create table user_ratings (
id serial primary key,
user_id integer not null,
rating integer not null check (rating >= 0 and rating <= 5),
ratable_id integer not null
);
create function random_int(max integer) returns integer as $$
@dankrause
dankrause / ssdp.py
Last active April 25, 2024 13:14
Tiny python SSDP discovery library with no external dependencies
# Copyright 2014 Dan Krause
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
#include <stdio.h>
#include <iostream>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <arpa/inet.h>
#include <openssl/ssl.h>
#include <event2/event.h>
#include <event2/util.h>
from sqlalchemy import engine
from sqlalchemy import event
class DbStats():
def __init__(self):
self.clear()
def clear(self):
self.total_queries = 0
self.total_time = 0
@wkjagt
wkjagt / audio-book-reader.md
Last active April 12, 2024 14:18
How I built an audio book reader for my nearly blind grandfather

#How I built an audio book reader for my nearly blind grandfather

Tweet this - Follow me

Last year, when visiting my family back home in Holland, I also stopped by my grand-parents. My grand-father, now 93 years old, had always been a very active man. However, during the presceding couple of months, he'd gone almost completely blind and now spent his days sitting in a chair. Trying to think of something for him to do, I suggested he try out audio books. After finally convincing him -- he said audio books were for sad old people -- that listening to a well performed recording is actually a wonderful experience, I realized the problem of this idea.

####The problem with audio devices and the newly blind. After my first impulse to jump up and go buy him an

@tommie
tommie / gist:89011c5ac06553d5cdb8
Last active December 6, 2023 06:08
PL2303 USB Protocol

A description of the PL2303HX USB protocol.

Control Transfers

Read Register

Read a device register value.

  • bmRequestType: IN, VENDOR, DEVICE
  • bRequest: 1
  • wValue: 80h | registerNumber

Experimental Generation of Interpersonal Closeness

Instructions to Subjects Included With Task Slips Packet

This is a study of interpersonal closeness, and your task, which we think will be quite enjoyable, is simply to get close to your partner. We believe that the best way for you to get close to your partner is for you to share with them and for them to share with you. Of course, when we advise you about getting close to your partner, we are giving advice regarding your behavior in this demonstration only, we are not advising you about your behavior outside of this demonstration.

In order to help you get close we've arranged for the two of you to engage in a kind of sharing game. You're sharing time will be for about one hour, after which time we ask you to fill out a questionnaire concerning your experience of getting close to your partner.

You have been given three sets of slips. Each slip has a question or a task written on it. As soon as you both finish reading these instructions, you should

@lmarkus
lmarkus / README.MD
Last active May 21, 2024 02:50
Extracting / Exporting custom emoji from Slack

Extracting Emoji From Slack!

Slack doesn't provide an easy way to extract custom emoji from a team. (Especially teams with thousands of custom emoji) This Gist walks you through a relatively simple approach to get your emoji out.

If you're an admin of your own team, you can get the list of emoji directly using this API: https://api.slack.com/methods/emoji.list. Once you have it, skip to Step 3

HOWEVER! This gist is intended for people who don't have admin access, nor access tokens for using that list.

Follow along...

@GeorgeHahn
GeorgeHahn / ESP8266 WeatherStation.ino
Created July 7, 2016 03:19
Tweaked code from Jens Jensen to run in ESP8266 Arduino environment
/*****************************************
accurite 5n1 weather station decoder
for arduino and 433 MHz OOK RX module
Note: use superhet (with xtal) rx board
the regen rx boards are too noisy
Jens Jensen, (c)2015
*****************************************/
//here is descriptors
//needs interrupt endpoint 1 in, bulk endpoint 2 out, bulk endpoint 3 in
//info from pl2303hx datasheet
/* Device Descriptor */
const USB_DEVICE_DESCRIPTOR device_dsc=
{
0x12, // Size of this descriptor in bytes
USB_DESCRIPTOR_DEVICE, // DEVICE descriptor type
0x0200, // USB Spec Release Number in BCD format