Skip to content

Instantly share code, notes, and snippets.

View Offirmo's full-sized avatar
⚔️
Coding a RPG… (as a hobby)

Offirmo Offirmo

⚔️
Coding a RPG… (as a hobby)
View GitHub Profile
@Offirmo
Offirmo / testing-library.tsx
Last active May 13, 2024 04:37
[react testing library] #react
https://testing-library.com/docs/react-testing-library/migrate-from-enzyme
// getByRole, queryByRole, getAllByRole, queryAllByRole, findByRole, findAllByRole
// getByLabelText, queryByLabelText, getAllByLabelText, queryAllByLabelText, findByLabelText, findAllByLabelText
// getByPlaceholderText, queryByPlaceholderText, getAllByPlaceholderText, queryAllByPlaceholderText, findByPlaceholderText, findAllByPlaceholderText
// getByText, queryByText, getAllByText, queryAllByText, findByText, findAllByText
// getByDisplayValue, queryByDisplayValue, getAllByDisplayValue, queryAllByDisplayValue, findByDisplayValue, findAllByDisplayValue
// getByAltText, queryByAltText, getAllByAltText, queryAllByAltText, findByAltText, findAllByAltText
@Offirmo
Offirmo / basics.py
Last active February 28, 2024 02:31
[Python basics] #python
## https://developers.google.com/edu/python
# ternary
a if x else b
## strings
## https://developers.google.com/edu/python/strings
s = 'hi'
print(s[1]) ## i
print(len(s)) ## 2
@Offirmo
Offirmo / base.cpp
Last active February 15, 2024 16:52
[Basic C++]
// https://isocpp.org/images/uploads/2-Tour-Basics.pdf
std::cout << __func__ << __FILE__ << __LINE__ << std::endl;
// XXX scalar vs aggregate
const auto foo { 42 }; // valid but {} hints at aggregate (in theory)
const auto foo = 42;
const auto str { "foo" };
@Offirmo
Offirmo / libs.cpp
Last active February 6, 2024 09:44
[C++ libs usage]
// all libs
// https://en.cppreference.com/w/cpp/header
////////////
#include <iostream>
std::cout << "Hello, world!" << std::endl;
@Offirmo
Offirmo / hackerrank.py
Last active February 27, 2024 23:51
[Python snippets for hacker rank] python
## starters
x = [ 1, 2, 3, 4, 5 , 6, 7 ]
print(f'{x} => {xyz(x)}')'
x = [ 1, 2, 3, 4, 5 , 6, 7 ]
print(f'{x} => {xyz(x, len(x))}')
x, y = 'foo', 2
print(f'{x},{y} => {xxxxx(x, y)}')
@Offirmo
Offirmo / jest.js
Last active October 12, 2023 04:48
[Jest]
// Match objet partiel:
expect(xyz).toMatchObject({
action: 'generated',
attributes: {
duration: expect.any(Number),
},
});
@Offirmo
Offirmo / foo_spec.ts
Last active February 9, 2023 16:50
Unit Test in TypeScript
import { expect } from 'chai'
import {
LIB
} from '../index.js'
describe(`${LIB}`, function () {
describe('plugins', function () {
@Offirmo
Offirmo / condtypes.ts
Last active January 2, 2023 07:14
[typescript conditional types playground] #typescript
// type tester for generics
type ImmutablePrimitive = undefined | null | boolean | string | number | Function
interface EmptyStruct { }
// https://www.typescriptlang.org/docs/handbook/2/functions.html#other-types-to-know-about
//type T = any
//type T = unknown
//type T = void
@Offirmo
Offirmo / javascript_learning_resources.md
Last active September 5, 2024 07:00
[Resources for learning JavaScript] #JavaScript
@Offirmo
Offirmo / migrations.ts
Last active August 20, 2021 10:57
[Offirmo's migrations] #Offirmo #TypeScript
import { enforce_immutability, LastMigrationStep, MigrationStep, generic_migrate_to_latest } from '@offirmo-private/state-utils'
import { LIB, SCHEMA_VERSION } from './consts'
import { UState, TState } from './types'
import { OMRSoftExecutionContext } from './sec'
// some hints may be needed to migrate to demo state
// need to export them for composing tests
export const MIGRATION_HINTS_FOR_TESTS: any = enforce_immutability({
})