Skip to content

Instantly share code, notes, and snippets.

gb = new GnuBook();
gb.getPageWidth = function(index) {
return 800;
}
gb.getPageHeight = function(index) {
return 1200;
}
from __future__ import division # allows floating point division from integers
from FreeCAD import Base
import Part
import math
# Run this macro to create a generic project enclosure box
# You can change all the parameters by selecting the object in the tree view and tweaking values in the "Data" tab
# Possible additions/improvements
# counterbore bridging .4mm
@mangtronix
mangtronix / textProject
Last active August 29, 2015 14:04
Attempt to project text onto a cylinder and then extrude for embossing in FreeCAD
import Part, Draft
from FreeCAD import Base
v=Base.Vector
doc=App.ActiveDocument
font="/Users/mangtronix/src/blender/release/datafiles/bfont.ttf"
# ShapeString text
ss=Draft.makeShapeString(String=u"Hi",FontFile=font,Size=2.0,Tracking=0)
@mangtronix
mangtronix / TextOnCylinder
Last active August 13, 2020 10:11
FreeCAD macro to wrap text on a cylinder
# Macro to put text on a cylinder. Select a cylinder and one or more
# ShapeStrings to place on the cylinder. You can edit the vertical
# and angular offset of the text in the TextOnCylinder properties.
#
# Michael Ang <http://github.com/mangtronix>
# http://michaelang.com
#
# TODO:
# - Split up the string and actually wrap it around the cylinder
@mangtronix
mangtronix / orient_top.FCMacro
Last active April 12, 2016 22:09
FreeCAD macro to orient objects to top view
# Assuming a simple shapes like a triangle, orient to top view. Doesn't handle Z position.
#
# Usage:
# Select shapes and execute macro (e.g. Macro->Macros->Execute)
#
# mangtronix
# 2016-04-14
from FreeCAD import Base
@mangtronix
mangtronix / bisect.py
Created May 5, 2016 10:09
Bisect an angle between two lines, for skildall
from FreeCAD import Base
A = Base.Vector(10,3,0)
B = Base.Vector(1,10,0)
C = Base.Vector(0,0,0)
dirCB = B-C
dirCB.normalize()
dirCA = A-C
dirCA.normalize()
dirCc = dirCA + dirCB
dirCc.normalize()
@mangtronix
mangtronix / laser_test.gcode
Created November 30, 2016 20:24
Short test fire of laser - no warranty or fitness expressed or implied!
G91 ; Relative mode
G1 X0.25 Y0 F200 S.2 ; 0.25 in X direction at 20% power
M18 ; Disable steppers
@mangtronix
mangtronix / kobo-fullscreen.md
Last active April 12, 2018 02:42
Enabling fullscreen mode (disabling header and footer) on Kobo eReader (e.g. Aura One)

Fullscreen reading removes the header (book title) and footer (page progress) for a pure text reading experience. There's a hidden setting to toggle fullscreen on/off, but it exposes a bug that needs to be patched in the Kobo's onboard CSS.

  1. Edit the "Kobo eReader.config" on the device http://blog.the-ebook-reader.com/2014/10/20/how-to-enable-full-screen-mode-on-kobo-ereaders/
  2. Check your firmware version in Settings->Device information. These instructions are for 4.7.10413
  3. Download stock firmware https://www.mobileread.com/forums/showpost.php?p=3625746&postcount=5
  4. Review instructions for patching https://www.mobileread.com/forums/showthread.php?t=293052
  5. Enable the fix by editing libnickel.so.1.0.0.patch and setting patch_enable to yes for the fullScreenReading fix
diff --git a/libnickel.so.1.0.0.patch b/libnickel.so.1.0.0.patch
@mangtronix
mangtronix / Keybot.pde
Created January 15, 2019 18:10
Processing sketch - Demo code to show pressing keys from simulated serial input
// Demo code to show pressing keys from simulated serial input
//
// Click in the window to send some simulated serial data.
// Press the keys on the keyboard to see the output is the same.
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
Robot robot;
@mangtronix
mangtronix / StreamMP3_internalDAC.ino
Last active July 3, 2022 21:58
ESP streaming audio example for ESP32 adapted from ESP8266Audio example
#include <Arduino.h>
#ifdef ESP32
#include <WiFi.h>
#else
#include <ESP8266WiFi.h>
#endif
#include "AudioFileSourceICYStream.h"
#include "AudioFileSourceBuffer.h"
#include "AudioGeneratorMP3.h"