Skip to content

Instantly share code, notes, and snippets.

View lukicdarkoo's full-sized avatar

Darko Lukić lukicdarkoo

View GitHub Profile
@lukicdarkoo
lukicdarkoo / Config.c
Last active December 18, 2016 13:31
Simple configuration system
#include "Config.h"
int8_t Config_Init(const uint8_t* const filename) {
int i;
char line[CONFIG_MAX_LINE_LENGTH];
FILE* file;
keys = (uint8_t**)malloc(sizeof(uint8_t*));
values = (uint8_t**)malloc(sizeof(uint8_t*));
@lukicdarkoo
lukicdarkoo / main.c
Last active April 23, 2019 19:44
Epoch time
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
#include <assert.h>
uint8_t time2string(char* result, uint64_t time) {
// Calculate time
uint8_t mm_prim = ((time & 0x000000FF00) >> 8);
uint8_t ss_prim = (time & 0x00000000FF);
uint8_t hh_prim = ((time & 0x0000FF0000) >> 16);
@lukicdarkoo
lukicdarkoo / Dockerfile
Last active February 5, 2018 09:13
mep-master in a Docker container
# Use `sudo docker build .` to run it
FROM ros
RUN apt-get update
RUN apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash
RUN apt-get install -y nodejs
RUN apt-get install -y git
RUN git clone https://github.com/Memristor-Robotics/mep-master.git --depth 2
@lukicdarkoo
lukicdarkoo / music.sh
Last active November 15, 2017 14:23
Music Flasher
#!/bin/bash
#
# Use following command to run the script:
# $ curl https://gist.githubusercontent.com/lukicdarkoo/3ff2af3f739ee8ead98da950747a3db9/raw/a998c45fde127ee58808f55db3cd53b6ceded88d/music.sh | sh
#
# Created by Darko Lukic <lukicdarkoo@gmail.com>
DEVICE=/dev/sdb
@lukicdarkoo
lukicdarkoo / performance.js
Last active December 13, 2017 19:17
Node.js Performance Test
/*
* The script allows fast performance comparison of Node.js interpreter (different version on different architectures).
* `curl https://gist.githubusercontent.com/lukicdarkoo/810dcac696ddd6fcc956fb6a5fdd9693/raw | node`
*/
// Functions
function calc(val) {
return {
'cos': Math.cos(val),
'sin': Math.sin(val)
@lukicdarkoo
lukicdarkoo / kinetic-ubuntu.sh
Last active December 31, 2017 13:01
ROS installation script
#!/bin/bash
# Usage `curl https://gist.githubusercontent.com/lukicdarkoo/1a448da0903e0a21fc77979b9e24c3b9/raw/99ae53ef92c4c1ca85e0e992e7b62098f74036b1/kinetic-ubuntu.sh | sh`
# Make ROS packages available
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
sudo apt update
# Install ROS
sudo apt install -y ros-kinetic-desktop-full
@lukicdarkoo
lukicdarkoo / SmartVideoPlayer.js
Created March 2, 2018 19:22
Starts a YouTube video only when it is visible on screen
/*
* Starts a YouTube video only when it is visible on screen. If user stops the video
* it will not be played again.
*
* @example
* <iframe id="video-intro" width="100%" height="380px" src="https://www.youtube.com/embed/ZyOuAHrKX2c?rel=0&amp;controls=0&amp;showinfo=0&amp;enablejsapi=1" frameborder="0"></iframe>
* <script>
* new SmartVideoPlayer('video-intro');
* </script>
*/
@lukicdarkoo
lukicdarkoo / TimeTest.js
Created April 14, 2018 16:01
[Medium] Node.js in Robotics
let startTime = process.hrtime();
if (centerPoint.getDistance(Mep.Position.getPosition()) < this.config.hazardObstacleDistance) {
let target = this._targetQueue.getTargetBack();
if (target !== null) {
let line = new Line(Mep.Position.getPosition(), target.getPoint());
if (line.isIntersectWithPolygon(polygon) === true) {
// this.emit('pathObstacleDetected', true);
}
}
}
@lukicdarkoo
lukicdarkoo / install.sh
Last active June 14, 2020 15:50
CosmicPi configuration script
#!/bin/bash
# Usage: curl https://gist.githubusercontent.com/lukicdarkoo/e33e00c6780ad0215d3932b810a10e46/raw | sh
echo "In case of any issues please consult cosmicpi.org for help, or contact us via Facebook "
echo "--- Expand the file system ---"
sudo resize2fs /dev/mmcblk0p2
echo "--- Update OS ---"
sudo apt -y update
@lukicdarkoo
lukicdarkoo / configure.sh
Last active November 22, 2023 04:37
Raspberry Pi: AP + client mode
#!/bin/sh
# The script configures simultaneous AP and Managed Mode Wifi on Raspberry Pi Zero W (should also work on Raspberry Pi 3)
# Usage: curl https://gist.githubusercontent.com/lukicdarkoo/6b92d182d37d0a10400060d8344f86e4/raw | sh -s WifiSSID WifiPass APSSID APPass
# Licence: GPLv3
# Author: Darko Lukic <lukicdarkoo@gmail.com>
# Special thanks to: https://albeec13.github.io/2017/09/26/raspberry-pi-zero-w-simultaneous-ap-and-managed-mode-wifi/
MAC_ADDRESS="$(cat /sys/class/net/wlan0/address)"
CLIENT_SSID="${1}"
CLIENT_PASSPHRASE="${2}"