Skip to content

Instantly share code, notes, and snippets.

@bga
bga / ntc_convert.app.c
Last active April 16, 2021 11:11
ntc thermistor fixed point int no float calculation 16 bit avr stm8 pic16 pure c embedded mcu
/*
Copyright 2021 Bga <bga.email@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@bga
bga / gist:e7fb25ede9be6b89ccfa6e28f2e8ebfa
Created March 7, 2021 09:06
Ошибки и советы реболла bga rebolling tips errors
Рассказываю основные ошибки и проблемы при реболле
Пастой через трафарет.
А) Паста не сплавляется в шарики. Причина; высохшая старая паста. Решение: сменить пасту.
Б) шарики не липнут к чипу. Возможные причины: смещен чип, плохо облужены контактные пятаки. Решение: перелудить пятаки ПОС-61 и активным флюсом, аккуратнее выравнивать чип.
В) чип не вынимается из трафарета. Внимание: он плохо вынимается ВСЕГДА! Решение: отмочить ацетоном, чуть подогреть градусов до ста. Отделять края по очереди, сгибая трафарет.
Г) один-два шарика остались на трафарете. Решение: выковырять шарики иголкой, посадить на место феном под микроскопом. Пятак предварительно зачистить иголкой. Процедура сродни цирковому номеру.
Хинт: вынутый из трафарета чип необходимо еще раз оплавить феном. Шарики осядут надежнее и аккуратнее.
Д) трафарет при нагреве гнет дугой. Причина: трафарет слишком велик. Решение: пропилить термобарьеры или вырезать из большого трафарета нужный квадратик (лучше дремелем, а не ножницами).
@bga
bga / unit.js
Created March 6, 2018 20:17
js class with private fields
"use strict"
class Foo {
constructor() {
//# make object with private properties atop { this }
const privateObject = {
__proto__: this,
_a: 1
}
//# and bind every method to { privateObject }
@bga
bga / Object.getRealmOf.js
Created December 7, 2017 15:34
Object.getRealmOf.js
#!/usr/bin/env node
"use strict"
//const global = (typeof(global) != "undefined") ? global : this
//# or { null } if you dont want cache
let cache = new WeakMap()
const isPrimitive = (v) => {
return v !== Object(v)
@bga
bga / freezeBackgroudActivity.js
Created October 7, 2017 06:48
userscript that freezes backgroud activity when tab is inactive
// ==UserScript==
// @name freezeBackgroudActivity
// @include https://*/*
// @include http://*/*
// @description freeze backgroud activity when tab is inactive
// ==/UserScript==
//# because modern websites do alot of backgroud "useful" job (hope its not mining *coins) and keep cpu busy, fan periodically blows and thats annoyong especially at night
!(function(global) {
var log = function() {
@bga
bga / handleEventVsLambdaStyle.js
Created June 18, 2017 13:47
handleEventVsLambdaStyle.js
//# "Class" style
class MyWidgit {
var root = null;
handleEvent(ev) {
//# imagine 10 types and 20 subelements - it will be 500sloc bloody mess
switch(ev.type) {
case("click") {
alert("you clicked me!")
} break;
case("input") {
@bga
bga / gist:9c4af286f9bdeccdc3b890c7bacfb24c
Created March 19, 2017 15:02
handy expr inspection for printf style debug.js
//# for printf style debugging
var inspect = function(v) {
console.dir(v)
return v
}
Object.defineProperty(Object.prototype, "inspect", {
value: function() {
console.dir(this)
return this
},
@bga
bga / gist:030075cdad2c5d8a2909d77e53d14be7
Created March 4, 2017 12:05
canvas+Math api versioning
var demoSeasonDate = "2015/02"
(function() {
var whiteListApi = function(methodNames) {
var C = function(nativeObj) {
this._nativeObj = nativeObj
}
methodNames.forEach(function(methodName) {
C.prototype[methodName] = function() {
return this._nativeObj[methodName].apply(this._nativeObj, arguments)
}
var defCompare = function(a, b) {
var aStr = String(a),
bStr = String(b);
if (aStr > bStr) {
return 1;
}
else if (aStr < bStr) {
return -1;
}
String.prototype.template = function (scopeEval) {
// Andrea Giammarchi - WTFPL License
var
re = /\$\{([\S\s]*?)\}/g,
evaluate = [],
i = 0,
m
;
while (m = re.exec(this)) {
evaluate.push(