Skip to content

Instantly share code, notes, and snippets.

@mfe5003
mfe5003 / prod_test_avro_no-schema.py
Created September 16, 2017 16:36
example producer with no schema
from confluent_kafka import avro
from confluent_kafka.avro import AvroProducer
# load schema to the registry from one producer
value_schema = avro.load('test_schema.avsc')
# This producer creates the schema and registers it
p1 = AvroProducer({
'bootstrap.servers': 'localhost:9092',
'schema.registry.url': 'http://localhost:8081'
@mfe5003
mfe5003 / ad9910.py
Last active August 25, 2018 15:37
Changes to ad9910.py API for RAM mode
from numpy import int32, int64
from artiq.language.core import kernel, delay, portable
from artiq.language.units import us, ns, ms
from artiq.coredevice import spi2 as spi
from artiq.coredevice import urukul
urukul_sta_pll_lock = urukul.urukul_sta_pll_lock
@mfe5003
mfe5003 / urukul.py
Created August 25, 2018 15:42
additions to CPLD code for ad9910 profile support
# CFG configuration register bit masks
CFG_PROF_MASK = 7 << CFG_PROFILE
@kernel
def change_profile(self, profile):
"""Change the DDS profile for all channels in the configuration register.
:param profile: profile number between 0 and 7
@mfe5003
mfe5003 / dds_ram_test.py
Created August 25, 2018 15:47
dds RAM mode test experiment
from artiq.experiment import *
import numpy as np
class DDSTest(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("core_dma")
self.setattr_device("led0")
self.setattr_device("ttl4")
def answer(map, git_gud=True):
"""Find the shortest path in a binary 2D map where a wall can be removed.
The algorithm uses a modified Dijstra's algorithm to find the shortest path
from the start vertex (0,0) to the end vertex (w-1,h-1) in a 2D binary map.
A single wall can be removed from the map to make the shortest path, if
necessary. The first wall in any path can be ignored easily, but if a wall
is necessary to be removed for a valid solution to exist the simple
algorithm does not remember the minimum path that does not pass through a
wall to arrive at the mandatory wall vertex. Therefore we modify the
@mfe5003
mfe5003 / device_db.py
Created September 17, 2018 22:24
modified device database
# This is an example device database that needs to be adapted to your setup.
# The list of devices here is not exhaustive.
core_addr = "192.168.1.150"
device_db = {
"core": {
"type": "local",
"module": "artiq.coredevice.core",
"class": "Core",
@mfe5003
mfe5003 / led.py
Created September 20, 2018 18:11
minimal artiq kasli experiment
from artiq.experiment import *
class LED(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("led0")
self.setattr_device("led1")
@kernel
@mfe5003
mfe5003 / .vimrc
Created September 26, 2018 19:00
.vimrc for servers
syntax on
colorscheme mebert
set nu
map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
@mfe5003
mfe5003 / mebert.vim
Created September 26, 2018 19:01
vim color scheme for servers, based on pablo (no blue!)
" local syntax file - set colors on a per-machine basis:
" vim: tw=0 ts=4 sw=4
" Vim color file
" Maintainer: mebert
" Last Change: 2018 Sept 26
hi clear
set background=dark
if exists("syntax_on")
syntax reset
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\n\$ '