Skip to content

Instantly share code, notes, and snippets.

View lukicdarkoo's full-sized avatar

Darko Lukić lukicdarkoo

View GitHub Profile
@lukicdarkoo
lukicdarkoo / KeypadShield.c
Created December 17, 2015 13:36
Notes for Arduino LCD Keypad Shield
// Notes for Arduino LCD Keypad Shield
// Create custom character: https://omerk.github.io/lcdchargen/
// String reference: https://www.arduino.cc/en/Reference/StringObject
// LCD reference: https://www.arduino.cc/en/Reference/LiquidCrystal
// Stream reference: http://playground.arduino.cc/Main/StreamingOutput
#define _BYTE(a) _BYTE_CODE(a)
#define _HEX(a) _BASED(a, HEX)
#define _DEC(a) _BASED(a, DEC)
#define _OCT(a) _BASED(a, OCT)
@lukicdarkoo
lukicdarkoo / dft.py
Created December 18, 2015 22:32
Basic implementation of DFT algorithm in Python
'''
Basic implementation of DFT algorithm in Python
X_k = sum(x_n * exp(-j*2*PI*k*n/N))
Reference:
https://en.wikipedia.org/wiki/Discrete_Fourier_transform
'''
__author__ = 'Darko Lukic'
__email__ = 'lukicdarkoo@gmail.com'
@lukicdarkoo
lukicdarkoo / fft.py
Created December 19, 2015 12:24
Basic implementation of Cooley-Tukey FFT algorithm in Python
'''
Basic implementation of Cooley-Tukey FFT algorithm in Python
Reference:
https://en.wikipedia.org/wiki/Fast_Fourier_transform
'''
__author__ = 'Darko Lukic'
__email__ = 'lukicdarkoo@gmail.com'
@lukicdarkoo
lukicdarkoo / FFT.c
Last active August 14, 2023 12:49
Basic implementation of Cooley-Tukey FFT algorithm in C++
#include "FFT.h"
void fft(int *x_in,
std::complex<double> *x_out,
int N) {
// Make copy of array and apply window
for (int i = 0; i < N; i++) {
x_out[i] = std::complex<double>(x_in[i], 0);
x_out[i] *= 1; // Window
@lukicdarkoo
lukicdarkoo / fir.py
Last active July 29, 2016 12:00
Basic implementation of FIR filter with given coefficients
'''
Basic implementation of FIR filter with given coefficients
Y[n] = sum(f(i)*g(n-i))
'''
__author__ = 'Darko Lukic'
__email__ = 'lukicdarkoo@gmail.com'
@lukicdarkoo
lukicdarkoo / FFT.c
Created December 28, 2015 23:54
Parallel FFT with TBB
#include "FFT.h"
#if defined(MODE_PARALLEL_DEV) || defined(MODE_PARALLEL_TEST)
class FFTTask: public task {
public:
const int N;
std::complex<double> *x;
FFTTask(std::complex<double> *_x, int _N) :
x(_x), N(_N)
{}
@lukicdarkoo
lukicdarkoo / hj.m
Last active July 29, 2016 12:00
Hook - Jeeves method - Multidimensional Optimization
% Moved from http://pastebin.com/YD8FGFL8
function t = hj(f, x0, step, e)
d = eye(length(x0));
t = x0;
xb = x0;
while step > e
% Pretrazivanje u okolini tacke
for i = 1:length(d)
t_p = t + step * d(i, :);
@lukicdarkoo
lukicdarkoo / powell.m
Last active July 29, 2016 11:59
Powell method - Multidimensional Optimization
% Moved from: http://pastebin.com/YD8FGFL8
function out = powel(f, x0, e)
[directions, ~] = size(x0);
u = eye(directions);
t(:, 1) = x0;
xNew = x0;
while true
xOld = xNew
@lukicdarkoo
lukicdarkoo / Robot.cc
Created July 29, 2016 11:59
Node.js and C++ bindings with events (EventEmitter)
/*
Coded by Darko Lukic <lukicdarkoo@gmail.com>
Node.js and C++ bindings with events (EventEmitter)
*/
#include <nan.h>
#include <iostream>
using v8::Local;
using v8::FunctionTemplate;
@lukicdarkoo
lukicdarkoo / Bits.c
Last active December 18, 2016 13:18
Bits manipulation module for fast prototyping
#include "Bits.h"
void Bits_ByteDump(uint64_t value, uint8_t numberOfBytes) {
int8_t i;
for (i = numberOfBytes * 8 - 1; i >= 0; i--) {
printf("%ld", (value >> i) & 1);
if (i % 8 == 0) {
printf(" ");