Skip to content

Instantly share code, notes, and snippets.

View jamwaffles's full-sized avatar
💼
Hireable - Rust full time or part time

James Waples jamwaffles

💼
Hireable - Rust full time or part time
View GitHub Profile
@jamwaffles
jamwaffles / MergeGUI.md
Last active June 23, 2022 15:59
Graphical merge tool for resolving Git merge conflicts

Diff screenshot

Installation

  1. Download DiffMerge from here. It's not the prettiest merge tool but it works.

  2. Install it as usual

  3. Open up a console and run the following commands:

     git config --global merge.tool diffmerge
     git config --global mergetool.diffmerge.cmd 'diffmerge --merge --result="$MERGED" "$LOCAL" "$(if test -f "$BASE"; then echo "$BASE"; else echo "$LOCAL"; fi)" "$REMOTE"'
    
@jamwaffles
jamwaffles / monotonic.rs
Created September 13, 2021 08:20
32 bit monotonic from STM32Lxx 16 bit timer
use core::convert::TryFrom;
use embedded_time::rate::{Extensions, Hertz};
use rtic::{rtic_monotonic::Clock, Monotonic};
use stm32l0xx_hal::{
pac::{TIM2, TIM21, TIM22, TIM3},
rcc::Rcc,
};
pub trait TimExt {
fn configure(&mut self, rcc: &mut Rcc, frequency: Hertz);
@jamwaffles
jamwaffles / monotonic.rs
Created May 10, 2021 09:26
L0xx monotonic impl for TIM2
use rtic::{rtic_monotonic::Clock, Monotonic};
use stm32l0xx_hal::pac::TIM2;
pub struct Tim2Monotonic {
local_timer: TIM2,
overflows: u16,
next_compare_value: Option<u32>,
}
impl Tim2Monotonic {
@jamwaffles
jamwaffles / docker-compose.yml
Created December 6, 2020 22:03
Grafana + Postgres
version: "3"
services:
adminer:
image: adminer:4.7.7
ports:
- "8081:8080"
networks:
- bbench
postgres:
linux_steps: &linux_steps
docker:
- image: cimg/rust:1.47.0
steps:
- checkout
- restore_cache:
keys:
- v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "Cargo.lock" }}
- run: ./linux_build_script_1_here.sh
- run: ./linux_build_script_2_here.sh
#![no_std]
#![no_main]
use panic_semihosting as _;
use rtfm::app;
use stm32f1xx_hal::{
device, gpio,
gpio::{gpioc::PC13, Edge, ExtiPin, Output, PushPull, State},
prelude::*,
stm32,
//! Interface factory
//!
//! This is the easiest way to create a driver instance. You can set various parameters of the
//! driver and give it an interface to use. The builder will return a
//! [`mode::RawMode`](../mode/raw/struct.RawMode.html) object which you should coerce to a richer
//! display mode, like [mode::Graphics](../mode/graphics/struct.GraphicsMode.html) for drawing
//! primitives and text.
//!
//! # Examples
//!
@jamwaffles
jamwaffles / ImgurAPI.php
Created January 8, 2014 14:52
Imgur API class
<?php
namespace Model;
use RedBean_Facade as R;
class ImgurAPI extends \Pliers\Model {
protected $user;
protected $session;
public function __construct() {
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io').listen(server);
app.get('/', function(req, res) {
res.sendfile(__dirname + '/index.html');
});
app.use('/public', express.static(__dirname + '/public'));
/* Copyright (c) 2015 Gordon Williams, Pur3 Ltd. Modified by James Waples 2018 */
/*
Library for interfacing to the EspressIF ESP8266. Uses the 'NetworkJS'
library to provide a JS endpoint for HTTP.
For EspressIF ESP8266 firmware 0.25
*/
var at;
var socks = [];