Skip to content

Instantly share code, notes, and snippets.

View Olegas's full-sized avatar

Oleg Elifantiev Olegas

  • Russia, Yaroslavl
View GitHub Profile
@Olegas
Olegas / embedded-development.md
Last active January 8, 2021 08:15
Embedded Development using CLion on macOS

Embedded Development using CLion on macOS

  • brew install stlink
  • brew install open-ocd
  • brew tap osx-cross/arm
  • brew install arm-gcc-bin
  • brew install --cask clion
  • Install JDK (run sudo java and follow instructions)
  • Download STM32CubeMX (registration is required), unpack archive
  • Run unstaller sudo java -jar SetupSTM32CubeMX-6.1.1.exe (version will be different!)
class A extends Control {
protected _x: object = {
val: 1,
_version: 0
}
_doSomthing() {
this._x._version++;
}
@Olegas
Olegas / promise.js
Last active November 28, 2019 18:09
class DoStuff {
runAnimation() {
return new Promise((resolve, reject) => {
const run = true;
const step = () => {
if (run) {
run = this._doSomething();
describe('Some case', () => {
before(() => {
// Mock BL here
declareMock('Object.Method').staticResponse(new RecordSet(....));
declareMock('Object.Complicated').withResolver((args) => {
// if arg1 > 10 -> result1
// if arg1 <= 10 -> result2
});
});
@Olegas
Olegas / bulk_insert.md
Last active July 11, 2019 12:55
Bulk insert

JavaSript (Node)

   const data = [{ field1: 1, field2: 'abc'}, {field1: 10, field3: 20}];
   driver.none(query, {
      data: JSON.stringify(data)
   });

SQL

function apiWrapper(args) {
const method = getMethodSomehow(args); // Тут мы как-то получили someAppliedAPI
return method(args).catch((e) => {
// это общий обработчик
})
}
function someAppliedAPI(args) {
console.log(0);
for(var i = 0; i < 1000000000; i++) {
setTimeout(function() {
console.log(1);
}, 0);
}
console.log(2);
const o = {
foo: function() { return this.bar },
bar: 10
};
const f = o.foo;
console.log(f()); // ??
const cls = require('cls-hooked');
const ctx = cls.createNamespace('test-cls-context');
// result of this demo: 4 and 13
// despite ctx is "global", every async "context" has it's own strage and values are not mixed between timeouts
setTimeout(() => {
ctx.run(() => {
ctx.set('value', 1);
setTimeout(() => {
@Olegas
Olegas / symbol.js
Last active June 4, 2019 22:10
Symbol?
// router.js
app.get('/', (req, res) => {
// generate rewuest uuid
// assign it to something (?)
// kick in some app logic
});
// db.js
async function getAfromB() {
const result = await driver.oneOrNone('SELECT a FROM b');