Skip to content

Instantly share code, notes, and snippets.

View onosendi's full-sized avatar

Daniel Lindegren onosendi

View GitHub Profile
@onosendi
onosendi / das-hotkey-generator.py
Last active October 28, 2022 09:11
DAS Trader hotkey generator
"""
das-hotkey-generator
~~~~~~~~~~~~~~~~~~~~
If you came across this and have no idea what it is, read the article I
wrote here: https://forums.bearbulltraders.com/topic/518-position-sizing
on position sizing, and how I manage my risk.
INTRO
=====
@onosendi
onosendi / arch-linux-btrfs-install.md
Last active March 5, 2024 23:22
Arch linux install: efi, btrfs, systemd boot.

Arch linux install

This is my current Arch linux installation. I created this for myself, so there's not much description.

What I want out of my install:

  • EFI boot partition
  • Btrfs filesystem to take advantage of snapshots
  • Systemd boot loader
import { Route, Routes } from 'react-router-dom';
export default function App() {
return (
<Routes>
<Route element={<Home />} path="/" />
<Route element={<SomePage />} path="/somepage" />
</Routes>
);
}
@onosendi
onosendi / ForwardRef.jsx
Last active December 28, 2021 19:44
React named function declarations
const ForwardRef = React.forwardRef(({}, ref) => {
return <div ref={ref}>Foo</div>;
});
export default ForwardRef;
export default function Foo() {
const {
data,
setData,
} = useSomeContextHook();
useEffect(async () => {
const response = await api('/some/url');
setData(response);
}, []);
function hasErrorsMutable(values) {
const errors = {};
if (values.foo === 'bar') {
errors.foo = 'Foo has bar, no bueno';
}
if (values.bar === 'baz') {
errors.bar = 'Bar has baz, no bueno';
}
return errors;
}
function isInRange(number, range) {
const [start, end] = range.split('-').map((r) => Number(r));
return number >= start && number <= end;
}
console.log(isInRange(5, '0-10'));
// true
console.log(isInRange(11, '0-10'));
// false
function sleep(miliseconds = 1000) {
return new Promise((resolve) => setTimeout(resolve, miliseconds));
}
// This will log 'foo' and 'bar' immediately.
async function foo1() {
console.log('foo');
sleep();
console.log('bar');
}
const myDict = [{ index: 1, area: 1 }, { index: 9, area: 9 }, { index: 2, area: 2 }];
const z = myDict.reduce((acc, item) => item.area > (acc?.area ?? Infinity) ? item: acc);
console.log(z);
const foo = [
{ key: 'one' },
{ key: 'two' },
];
const bar = {
one: 'one',
two: 'two',
};