Skip to content

Instantly share code, notes, and snippets.

View orion55's full-sized avatar

Orion55 orion55

  • 04:41 (UTC +05:00)
View GitHub Profile
@orion55
orion55 / git.sh
Last active August 30, 2021 11:33
assume-unchanged
git update-index --assume-unchanged web/src/index.tsx
git update-index --assume-unchanged web/public/env-config.js
@orion55
orion55 / update.ts
Created August 17, 2021 05:46
Partial update
const setPartialSettingsParameters = useCallback(
(settings) => {
setSettings((prevState: Partial<SettingsRequest>) => ({
...prevState,
...settings,
}));
},
[setSettings]
@orion55
orion55 / hashtable.ts
Created August 16, 2021 06:31
interface hashtable
interface hashtable {
[key: string]: string;
}
@mixin ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
@mixin scrollbar() {
$color: $silver;
$background-color: $white;
$margin: 0;
$margin2: 0;
scrollbar-width: thin;
scrollbar-color: $color $background-color;
@orion55
orion55 / usePersistFn.ts
Created July 7, 2021 14:38
Аналог useCallback
export function usePersistFn(fn: Function) {
const fnRef = useRef<Function>(fn);
fnRef.current = fn;
const persistFn = useRef<Function>();
if (!persistFn.current) {
persistFn.current = function (...args: any) {
return fnRef.current.apply(this, args);
};
}
return persistFn.current;
@orion55
orion55 / deconstructors.cs
Created July 1, 2021 04:13
Деконструктор
Person person = new Person { Name = "Tom", Age = 33 };
(string name, int age) = person;
Console.WriteLine(name); // Tom
Console.WriteLine(age); // 33
@orion55
orion55 / noselect.scss
Created June 29, 2021 10:01
No select element
&__menu-noselect {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
@orion55
orion55 / operator.cs
Created June 27, 2021 06:06
Оператор null-объединения
Оператор ?? - оператором null-объединения.
оператор ?. - условного null
Индексаторы позволяют индексировать объекты и обращаться к данным по индексу.
возвращаемый_тип this [Тип параметр1, ...]
@orion55
orion55 / interface.ts
Created June 24, 2021 04:43
Преобразование к интерфейсу
interface IPerson {
name: string;
}
class Person {
name: string;
constructor(userName: string) {
this.name = userName;
}