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;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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}
@birkir
birkir / PRIVACY_POLICY.md
Created July 29, 2019 10:46
Privacy Policy

Privacy Policy

Effective date: July 12, 2018

Transload ("us", "we", or "our") operates the website and the Transload mobile application (the "Service"). This page informs you of our policies regarding the collection, use, and disclosure of personal data when you use our Service and the choices you have associated with that data.

We use your data to provide and improve the Service. By using the Service, you agree to the collection and use of information in accordance with this policy. Unless otherwise defined in this Privacy Policy, terms used in this Privacy Policy have the same meanings as in our Terms and Conditions.

@birkir
birkir / data.csv
Created April 18, 2019 21:59
Torque OBD2 Parser in JS
000_Airbag H/wire Duty Airbag 0x220105 w 50 100 7E4
000_Auxillary Battery Voltage Aux Batt Volts 0x220101 ad*0.1 11 14.6 V 7E4
000_Available Charge Power Max REGEN 0x220101 ((f<8)+g)/100 0 98 kW 7E4
000_Available Discharge Power Max POWER 0x220101 ((h<8)+i)/100 0 98 kW 7E4
000_Battery Cell Voltage Deviation V Diff 0x220105 u/50 0 0.5 V 7E4
000_Battery Current Batt Current 0x220101 ((Signed(K)*256)+L)/10 -230 230 A 7E4
000_Battery DC Voltage Batt Volts 0x220101 ((m<8)+n)/10 268.8 403.2 V 7E4
000_Battery Fan Feedback Batt Fan SPD 0x220101 ac 0 120 Hz 7E4
000_Battery Fan Status Batt Fan MOD 0x220101 ab 0 9 7E4
000_Battery Heater 1 Temperature Heater Temp1 0x220105 Signed(X) 0 30 C 7E4
@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 {
@birkir
birkir / islandsbanki.js
Last active November 23, 2018 14:22
How things were done back in 2012
/**
* Islandsbanki 2.0
* @copyright Islandsbanki (c) 2013
* @author Birkir Gudjonsson (birkir.gudjonsson@gmail.com)
*/
var Islandsbanki = function() {
$(".allownumericwithdecimal")
.on("keypress keyup blur", function(event) {
//this.value = this.value.replace(/[^0-9\.]/g,'');
@birkir
birkir / PrismicIFace.ts
Created October 26, 2018 18:02
Mocking prismic types
interface Document {
id: string;
uid?: string;
type: string;
href: string;
tags: string[];
first_publication_date: string;
last_publication_date: string;
slugs: string[];
linked_documents: Array<{
export const Product = types.model('Product', {
id: types.identifier,
name: types.string,
price: types.number,
})
.actions(self => ({
update() {
},
});
# Fix playground on XCode 10
cd ./node_modules/react-native
sh ./scripts/ios-configure-glog.sh
cd ./third-party/glog-0.3.4
sh ../../scripts/ios-configure-glog.sh
# Hit play in XCode, then
cp ~/Library/Developer/Xcode/DerivedData/playground-*/Build/Products/Debug-iphonesimulator/libfishhook.a ./node_modules/react-native/Libraries/WebSocket/.