Skip to content

Instantly share code, notes, and snippets.

View davidbitton's full-sized avatar

David B. Bitton davidbitton

View GitHub Profile
@davidbitton
davidbitton / motor_mix.lua
Created September 29, 2021 20:33
Custom MotorsMatrix Arducopter Lua Script
-- duplicate the #defines from AP_Motors
local AP_MOTORS_MOT_1 = 0
local AP_MOTORS_MOT_2 = 1
local AP_MOTORS_MOT_3 = 2
local AP_MOTORS_MOT_4 = 3
local function add_motor(motor_num, angle_degrees, yaw_factor, testing_order)
gcs:send_text(6, string.format("Adding motor:%i to MotorsMatrix", motor_num + 1))
--
-- lsyncd conf file
--
settings {
delay = 1,
maxProcesses = 5,
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd-status.log",
}
@davidbitton
davidbitton / gist:3030772
Created July 2, 2012 03:11
Why is it always 1?!
static GLKVector4 HslToRgb(float h, float s, float l, float a);
static GLKVector4 HslToRgb(float h, float s, float l, float a) {
float r = 0.0f, g = 0.0f, b = 0.0f;
float temp1, temp2;
if(l == 0.0f)
{
r = g = b = 0.0f;
}
else
@davidbitton
davidbitton / token_replace.sh
Created May 22, 2012 13:36
Replace a token in a file from a Bash script using Perl
#!/bin/bash
perl - /var/www/html/wp-config.php <<'EOF'
use strict;
use warnings;
$^I = '.bak';
my $keys = `curl -sS https://api.wordpress.org/secret-key/1.1/salt/`;
while(<>) {
if (/\{KEYS_TOKEN\}/){
@davidbitton
davidbitton / ServiceStackFormatter.cs
Created March 2, 2012 20:11
Using ServiceStack.Test JsonSerializer in a Web API MediaTypeFormatter
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using ServiceStack.Text;
namespace HttpClientTest.Formatters {
public class ServiceStackFormatter : MediaTypeFormatter {
public ServiceStackFormatter() {
// Fill out the mediatype and encoding we support
@davidbitton
davidbitton / gist:1094320
Created July 20, 2011 04:12
sphere vertex and index generation
- (void)setupSphere {
std::vector<vertexStruct> verticesVector;
std::vector<int> indicesVector;
double latitudeBands = 30;
double longitudeBands = 30;
double radius = 2;
for (double latNumber = 0; latNumber <= latitudeBands; latNumber++) {
double theta = latNumber * M_PI / latitudeBands;
@davidbitton
davidbitton / TransmitView.xaml
Created April 25, 2011 19:56
ActualWidth Binding Fail
<UserControl x:Class="OsgExporter.Shell.Views.TransmitView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" Loaded="TransmitView_OnLoaded"
d:DesignHeight="312" d:DesignWidth="496">
<Grid x:Name="LayoutRoot">
<Grid Margin="8,0,0,0" Height="Auto" VerticalAlignment="Center">
<Grid.RowDefinitions>