Skip to content

Instantly share code, notes, and snippets.

@edy555
edy555 / gen-rainbow.py
Created September 16, 2014 15:35
Generate rainbow shape as voxel in json for VoxelEditor https://github.com/perfume-dev/VoxelEditor
#!/usr/bin/env python
import json
import colorsys
import math
def hsv(h, s, v):
r, g, b = colorsys.hsv_to_rgb(h, s, v)
return (int(r*255)*256 + int(g*255))*256 + int(b*255)
arr = []
@edy555
edy555 / cictest-mod.py
Last active October 12, 2017 17:13
simulating CIC filter and modified one in python
#!/usr/bin/env python
import numpy as np
from pylab import *
x = np.random.randn(65536)
m=16
d0 = [0] * m
d1 = [0] * m
d2 = [0] * m
@edy555
edy555 / hdr.py
Created February 13, 2014 14:53
append header onto binary file for writing dfu-util
#!/usr/bin/env python
import struct
import sys
fin = open(sys.argv[1], 'rb')
fout = open(sys.argv[2], 'wb')
bin = fin.read()
fin.close()
@edy555
edy555 / sna-test.py
Created November 25, 2013 15:58
trial to build sna with rtl2832u dongle and pll synthesizer
#!/usr/bin/env python
from adf4351usb import ADF4351
import numpy as np
import rtlsdr
import time
import matplotlib.pyplot as plt
import scipy.fftpack as sf
#start = 390e6
@edy555
edy555 / openlase-apple.patch
Created October 18, 2013 11:45
patch for building openlase (https://github.com/marcan/openlase) on MacOSX
diff --git a/Modules/CMakeASM_YASMInformation.cmake b/Modules/CMakeASM_YASMInformation.cmake
index 50b2848..3d7b330 100644
--- a/Modules/CMakeASM_YASMInformation.cmake
+++ b/Modules/CMakeASM_YASMInformation.cmake
@@ -1,7 +1,13 @@
set(ASM_DIALECT "_YASM")
set(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS asm)
-if(UNIX)
+if(APPLE)
@edy555
edy555 / adf4351usb.py
Created October 2, 2013 17:46
Control script to configure Analog Devices ADF4351 via USB HID
#!/usr/bin/env python
import hid
import math
verbose = False
class ADF4351:
DIV1 = 0
DIV2 = 1
DIV4 = 2
@edy555
edy555 / sensortag2xively.py
Last active December 21, 2015 16:38
Fetch temperature from sensortag by bluetooth low energy and feed it up into xively. Source code is derived from https://github.com/msaunby/ble-sensor-pi usage: python sensortag2xively.py {mac address}
#!/usr/bin/env python
# Fetch temperature from sensortag by bluetooth low energy and feed it up into xively.
# Source code is derived from https://github.com/msaunby/ble-sensor-pi
# usage: python sensortag2xively.py {mac address}
import xively
import datetime
import sys
import time
import pytz
@edy555
edy555 / collada-gencube.py
Created June 11, 2013 08:41
generate dae file with pycollada
#!/usr/bin/env python
from collada import *
import numpy
mesh = Collada()
effect = material.Effect("effect0", [], "phong", diffuse=(1,0,0), specular=(0,1,0))
mat = material.Material("material0", "mymaterial", effect)
mesh.effects.append(effect)
mesh.materials.append(mat)
@edy555
edy555 / SerialEvent_loop.ino
Last active December 17, 2015 08:49
Work around for USB CDC based Arduino. Arduino 'Serial Event' example does not work on USB CDC based arduino such as Leonard or DaVinci board.
/*
Serial Event example
When new serial data arrives, this sketch adds it to a String.
When a newline is received, the loop prints the string and
clears it.
A good test for this is to try it with a GPS receiver
that sends out NMEA 0183 sentences.
@edy555
edy555 / miku-scope.py
Last active January 8, 2019 12:48
This script draws hatsune miku in your oscilloscope via audio output. requirement: python, numpy, pyaudio YouTube: http://youtu.be/3iCEyhPH608
#!/usr/bin/env python
from numpy import sin,sign,pi,sqrt
import numpy as np
import pyaudio
import array
# generation function derived from WolframAlpha
# http://www.wolframalpha.com/input/?i=graph+Hatsune+miku+curve
# ignore "RuntimeWarning: invalid value encountered in sqrt"