Skip to content

Instantly share code, notes, and snippets.

View birkir's full-sized avatar
👋
Howdy

Birkir Gudjonsson birkir

👋
Howdy
View GitHub Profile
@birkir
birkir / hut.tub.timemachine.js
Created November 12, 2023 23:26
Spa Temperature Controller for Shelly
// Constants
const TARGET_TEMPERATURE = 40;
const PUMP_INTERVAL = 10 * 1000;
const START_STOP_THRESHOLD = 1.0;
const WEATHER_STATION_ID = "1395";
const HEATLOSS_RATE = 0.0158;
const HEATLOSS_RATE_COVER = 0.001206;
const INLET_FLOW_RATE = 2.2334;
const INLET_TEMPERATURE = 43;
const SPA_VOLUME = 1000;
@birkir
birkir / bmw-ibus.cpp
Created May 14, 2013 15:14
BMW I-Bus monitor and decoder
/**
* BMW IBus Daemon reads BMW IBus data through serial port. It detects
* BMW board monitor(at least BM53) unit and steering wheel button presses
* from IBus data, maps them to key events and injects them to system event
* queue via uinput.
*
* It also can be configured to inject key events only in certain state like
* TAPE or AUX which can be useful if you want to hijack for example TAPE
* mode for other use.
*
@birkir
birkir / Typeorm.ts
Created January 18, 2019 15:14
@accounts/typeorm - Typeorm database implementation for @accounts
import { ConnectionInformations, CreateUser, DatabaseInterface, Session } from '@accounts/types';
import { Repository, getRepository } from 'typeorm';
import { User } from '../entity/User';
import { UserEmail } from '../entity/UserEmail';
import { UserService } from '../entity/UserService';
import { UserSession } from '../entity/UserSession';
type ISession = Session & UserSession;
export class Typeorm implements DatabaseInterface {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@birkir
birkir / Bootstrap.php
Last active September 30, 2022 11:51
Twitter Bootstrap helper module for Kohana 3.3 (DRAFT)
<?php
/**
* Twitter Bootstrap Kohana helper
*
* example of use:
* <?=Bootstrap::grid($grid, Bootstrap::FLUID);?>
* <?=$grid->span($view, 4);?>
* <?=Bootstrap::icon('download', TRUE);?>
* <?=Bootstrap::button('Button'); ?>
@birkir
birkir / Cube.tsx
Created September 2, 2019 14:42
react native react-three-fiber
function Cube({ position }: { position?: number[] | THREE.Vector3 }) {
const mesh = useRef<THREE.Mesh>();
const touched = useTouch(mesh);
return (
<mesh ref={mesh} castShadow receiveShadow position={position}>
<boxGeometry attach="geometry" args={[1, 1, 1]} />
<meshStandardMaterial
attach="material"
color={touched ? 0xff0000 : 0xffffff}
/**
* Arduino based "2-step launch control"
* Works by interrupt power signal to ignition coil.
* Requires RPM and Clutch signal
*
* @author Birkir Gudjonsson (birkir.gudjonsson@gmail.com)
* @licence http://en.wikipedia.org/wiki/BSD_licenses
*/
// settings
@birkir
birkir / chuck-norris.js
Created November 14, 2014 10:54
Convert 7-bit ASCII to Chuck Norris style binary
/**
* Convert 7-bit ASCII to Chuck Norris style binary
*
* @param string Characters to encode
* @return string Binary' norris style.
*/
function asciiToChuckNorris(chars) {
// Variables
var bits = [],
@birkir
birkir / ORM_Revision.php
Created September 17, 2013 11:31
ORM Revision Control
<?php
class ORM_Revision extends Kohana_ORM {
// revision table prefix (default _revision_)
protected $_revision_table_prefix = '_revision_';
// are we going for draft or published
protected $_draft = FALSE;
@birkir
birkir / gps-plugin.js
Last active February 11, 2020 21:57
GPS Plugin for BMW ibus interface
/**
* This plugin will emit events with GPS coordinates
*
* const gps = new GPSPlugin();
* gps.on('gps', ({ lat, lng, alt }) => console.log(lat, lng, alt));
* MINI.addPlugin(gps);
*/
class GPSPlugin {
/**