Skip to content

Instantly share code, notes, and snippets.

@vdaluz
vdaluz / fibonacci-midi.py
Created February 9, 2018 03:05
Music generated from the Fibonacci sequence and output to midi
import midi
# Music generated from the Fibonacci sequence and output to midi
# Inspired by https://dev.to/daniel40392/visualizing-fibonacci-for-the-music-lover-in-you-2609
# Using https://github.com/vishnubob/python-midi for midi output
# Please excuse any python or music theory mistakes, I'm not an expert at either
print('Welcome to the Fibonacci Composer.')
x = int(input('Enter Song Length: '))
k = input('Enter Song Key (C, G, D, A, E, B, F#, Db, Ab, Eb, Bb, F): ')
@dfee
dfee / graphene_subscription.py
Created November 25, 2017 03:17
Example of how subscriptions work with graphene
from collections import OrderedDict
import graphene
import rx
subject = rx.subjects.Subject()
class Author(graphene.ObjectType):
@nonamenix
nonamenix / hug_swagger.py
Last active April 5, 2019 19:37
Swagger specification for hug. Ugly draft.
import inspect
import collections
from collections import OrderedDict
import hug
import logging
from apispec import APISpec
from apispec.ext.marshmallow.swagger import field2parameter
from copy import copy
@lattner
lattner / TaskConcurrencyManifesto.md
Last active July 25, 2024 20:23
Swift Concurrency Manifesto
# Import Slack Client
from slackclient import SlackClient
## Import Time
import time
#Set Bot Name
BOT_NAME = ''
#We will give the token in a moment
@wonderbeyond
wonderbeyond / objectview.py
Created July 24, 2017 04:59
python dict to object view
class objectview(object):
"""Convert dict(or parameters of dict) to object view
See also:
- https://goodcode.io/articles/python-dict-object/
- https://stackoverflow.com/questions/1305532/convert-python-dict-to-object
>>> o = objectview({'a': 1, 'b': 2})
>>> o.a, o.b
(1, 2)
@CMCDragonkai
CMCDragonkai / struct_packing_unpacking_network_communication.md
Last active January 8, 2024 16:45
Struct Packing and Unpacking for Network Communication #c

Struct Packing and Unpacking for Network Communication

Structs in C have both host/compiler-specific padding and host endianness. When communicating over a network, the struct must be framed (prefix length or frame character), packed (this means getting rid of the padding) and ordered according to a common endianness. On the reverse, the bytestream must then be read, message framed, re-ordered, and unpacked into a struct.

It is important that the structs that are used as interfaces have fixed sizes, that is uint32_t and not int.

@rmosolgo
rmosolgo / Gemfile
Last active March 27, 2023 08:38
GraphQL Ruby Subscriptions
source 'https://rubygems.org'
gem "graphql", github: "rmosolgo/graphql-ruby", branch: "subscriptions"
gem "sinatra"
gem "thin"
@philips
philips / users.md
Last active April 5, 2023 14:17
Kubernetes Third-Party Resource Users
@MinaGabriel
MinaGabriel / gist:c97b7a22c40c94b283723c7226dc9b68
Created November 17, 2016 00:34
Python socket program Server/ Client with Android Client
****************** Server ********************
import socket
import sys
HOST = '192.168.142.160' #this is your localhost
PORT = 8888
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#socket.socket: must use to create a socket.
#socket.AF_INET: Address Format, Internet = IP Addresses.