Skip to content

Instantly share code, notes, and snippets.

View machinekoder's full-sized avatar
💻
view-source

Alexander (Rössler) Poss machinekoder

💻
view-source
View GitHub Profile
@machinekoder
machinekoder / rc_servo_machinekit.py
Last active August 22, 2018 21:41
Controlling an RC servo with Machinekit (untested)
# Turn commanded position -5 to +5 into 1-2 mS pulse for RC (hobby) servo
# gain = 1 mS (range) / 50 mS (PWM period) / 10 (units)= 0.002
# offset = 1.5 mS (value) / 50 mS (PWM period) = 0.03
# Resulting PWM values should be between 0.02 and 0.04, representing a
# 1 mS to 2 mS wide pulse
def rc_servo(thread, name, range_ms, offset_ms, period_ms, min_step, max_step, in_signal, out_signal):
gain = range_ms / pwm_ms / (max_step - min_step)
offset = value_ms / pwm_ms
@machinekoder
machinekoder / Hotspot
Created June 7, 2018 18:27
place in /etc/NetworkManager/system-connections/ to create a AP hotspot under Linux
[connection]
id=Hotspot
uuid=bd4058b4-f99e-48f9-ac88-26513b9ac517
type=wifi
autoconnect=true
permissions=
[wifi]
hidden=false
mac-address=00:0F:60:06:EE:BE
@machinekoder
machinekoder / dxf_postpro.cfg
Created March 27, 2018 19:35
DXF Postprocessor for Dxf2GCode
[Number format]
post_decimals = 3
pre_decimal_zero_padding = 0
signed_values = 0
pre_decimals = 4
decimal_seperator = .
post_decimal_zero_padding = 1
[Program]
cutter_comp_left =
@machinekoder
machinekoder / gdrive_download.sh
Created August 16, 2017 06:29
Download huge files from Google Drive from https://stackoverflow.com/a/43478623
#!/usr/bin/env bash
fileid="$1"
destination="$2"
# try to download the file
curl -c /tmp/cookie -L -o /tmp/probe.bin "https://drive.google.com/uc?export=download&id=${fileid}"
probeSize=`du -b /tmp/probe.bin | cut -f1`
# did we get a virus message?
# this will be the first line we get when trying to retrive a large file
import requests
def download_file_from_google_drive(id, destination):
def get_confirm_token(response):
for key, value in response.cookies.items():
if key.startswith('download_warning'):
return value
return None
@machinekoder
machinekoder / PIN_7I76x1D_UART_34.vhd
Last active May 20, 2017 15:41
PktUART test component
library IEEE;
use IEEE.std_logic_1164.all; -- defines std_logic types
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Copyright (C) 2007, Peter C. Wallace, Mesa Electronics
-- http://www.mesanet.com
--
-- This program is is licensed under a disjunctive dual license giving you
-- the choice of one of the two following sets of free software/open source
@machinekoder
machinekoder / export.py
Created March 6, 2017 18:45
Pilot-API Pinconfig
#!/usr/bin/env python
def exportPin(id):
try:
with open('/sys/class/gpio/export', 'w') as f:
f.write('%i' % id)
except IOError as e:
print(str(e))
try:
#!/usr/bin/env python
#
# Copyright 2014 Marta Rodriguez.
#
# Licensed under the Apache License, Version 2.0 (the 'License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#!/bin/bash
echo Building Google Protobuf for Mac OS X / iOS.
echo Use 'tail -f build.log' to monitor progress.
(
VERSION=2.6.1
DARWIN_RELEASE=`uname -r`
CORES=`sysctl hw.ncpu | awk '{print $2}'`
#PREFIX=`pwd`/protobuf
@machinekoder
machinekoder / cos_test.c
Created May 10, 2015 14:26
Quick test for timing behavior of cos C function
/* Program to demonstrate time taken by function cos() */
#include <stdio.h>
#include <time.h>
#include <math.h>
// The main program calls fun() and measures time taken by fun()
int main()
{
// Calculate the time taken by fun()
clock_t start;